mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Further separate crossbows from bows
This commit is contained in:
parent
7543d8be12
commit
5ed415e453
@ -6,6 +6,7 @@ import com.gmail.nossr50.config.WorldBlacklist;
|
|||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.datatypes.meta.ProjectileOriginMeta;
|
import com.gmail.nossr50.datatypes.meta.ProjectileOriginMeta;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
|
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||||
@ -148,15 +149,32 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation()));
|
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation()));
|
||||||
|
|
||||||
|
boolean isCrossbow = false;
|
||||||
|
|
||||||
//Track origin of projectile
|
//Track origin of projectile
|
||||||
if(ItemUtils.hasItemInMainHand(player, "bow")) {
|
if(ItemUtils.hasItemInMainHand(player, "bow")) {
|
||||||
markProjectileOriginAsBow(projectile);
|
markProjectileOriginAsBow(projectile);
|
||||||
} else if(ItemUtils.hasItemInMainHand(player, "crossbow")) {
|
} else if(ItemUtils.hasItemInMainHand(player, "crossbow")) {
|
||||||
markProjectileOriginAsCrossbow(projectile);
|
markProjectileOriginAsCrossbow(projectile);
|
||||||
|
isCrossbow = true;
|
||||||
} else if(ItemUtils.hasItemInOffHand(player, "bow")) {
|
} else if(ItemUtils.hasItemInOffHand(player, "bow")) {
|
||||||
markProjectileOriginAsBow(projectile);
|
markProjectileOriginAsBow(projectile);
|
||||||
} else if(ItemUtils.hasItemInOffHand(player, "crossbow")) {
|
} else if(ItemUtils.hasItemInOffHand(player, "crossbow")) {
|
||||||
markProjectileOriginAsCrossbow(projectile);
|
markProjectileOriginAsCrossbow(projectile);
|
||||||
|
isCrossbow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Crossbow only
|
||||||
|
if(isCrossbow) {
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
|
//Process launch event
|
||||||
|
if(Permissions.skillEnabled(player, PrimarySkillType.CROSSBOWS)) {
|
||||||
|
if(mcMMOPlayer != null) {
|
||||||
|
mcMMOPlayer.getCrossbowManager().processProjectileLaunchEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Enchantment enchantment : player.getInventory().getItemInMainHand().getEnchantments().keySet()) {
|
for(Enchantment enchantment : player.getInventory().getItemInMainHand().getEnchantments().keySet()) {
|
||||||
@ -164,8 +182,11 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) {
|
//Bow only
|
||||||
projectile.setMetadata(mcMMO.trackedArrow, mcMMO.metadataValue);
|
if(!isCrossbow) {
|
||||||
|
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) {
|
||||||
|
projectile.setMetadata(mcMMO.trackedArrow, mcMMO.metadataValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import com.gmail.nossr50.skills.archery.Archery;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
|
|
||||||
public class CrossbowManager extends SkillManager {
|
public class CrossbowManager extends SkillManager {
|
||||||
public CrossbowManager(McMMOPlayer mcMMOPlayer) {
|
public CrossbowManager(McMMOPlayer mcMMOPlayer) {
|
||||||
@ -36,4 +37,13 @@ public class CrossbowManager extends SkillManager {
|
|||||||
return 1 + Math.min(firedLocation.distance(targetLocation), 50) * Archery.DISTANCE_XP_MULTIPLIER;
|
return 1 + Math.min(firedLocation.distance(targetLocation), 50) * Archery.DISTANCE_XP_MULTIPLIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for sub-skills that activate on projectile launch
|
||||||
|
* @param projectileLaunchEvent target event
|
||||||
|
*/
|
||||||
|
public void processProjectileLaunchEvent(ProjectileLaunchEvent projectileLaunchEvent) {
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage("Pew pew!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user