Arrow Retrieval will no longer work with piercing enchant

This commit is contained in:
nossr50 2019-06-18 13:06:26 -07:00
parent 31e9abd8eb
commit c83d38b5c2
8 changed files with 45 additions and 18 deletions

View File

@ -1,3 +1,7 @@
Version 2.1.83
Updated hu_HU locale (thanks andris155)
(FIX) Arrow Retrieval will no longer work with piercing enchant on crossbows
Version 2.1.82 Version 2.1.82
Added new WG flag 'mcmmo-hardcore' if set to negative players will not be penalized by hardcore mode (if hardcore mode is enabled) it defaults to true Added new WG flag 'mcmmo-hardcore' if set to negative players will not be penalized by hardcore mode (if hardcore mode is enabled) it defaults to true
Added proper error handling when loading parties file Added proper error handling when loading parties file

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId> <groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId> <artifactId>mcMMO</artifactId>
<version>2.1.82</version> <version>2.1.83-SNAPSHOT</version>
<name>mcMMO</name> <name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url> <url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm> <scm>

View File

@ -25,7 +25,6 @@ import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable; import org.bukkit.entity.Tameable;

View File

@ -22,7 +22,9 @@ import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.Material; import org.bukkit.Material;
@ -109,7 +111,8 @@ public class EntityListener implements Listener {
ItemStack bow = event.getBow(); ItemStack bow = event.getBow();
if (bow != null && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) { if (bow != null
&& bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue); projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
} }
@ -123,9 +126,10 @@ public class EntityListener implements Listener {
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
if(event.getEntity() instanceof Player) if(event.getEntity().getShooter() instanceof Player)
{ {
Player player = (Player) event.getEntity();
Player player = (Player) event.getEntity().getShooter();
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if(WorldGuardUtils.isWorldGuardLoaded())
@ -133,16 +137,28 @@ public class EntityListener implements Listener {
if(!WorldGuardManager.getInstance().hasMainFlag(player)) if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
Projectile projectile = event.getEntity();
//Hacky stuff for 1.13/1.14 compat
String itemKey = player.getInventory().getItemInMainHand().getType().getKey().toString();
if(!itemKey.equalsIgnoreCase("minecraft:bow") && !itemKey.equalsIgnoreCase("minecraft:crossbow"))
return;
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, 1.0));
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation()));
for(Enchantment enchantment : player.getInventory().getItemInMainHand().getEnchantments().keySet()) {
if(enchantment.getName().equalsIgnoreCase("piercing"))
return;
}
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) {
projectile.setMetadata(mcMMO.trackedArrow, mcMMO.metadataValue);
}
} }
Projectile projectile = event.getEntity();
if (!(projectile instanceof Arrow) || projectile.hasMetadata(mcMMO.bowForceKey)) {
return;
}
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, 1.0));
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation()));
} }
/** /**

View File

@ -279,7 +279,7 @@ public class PlayerListener implements Listener {
//TODO Update to new API once available! Waiting for case CAUGHT_TREASURE: //TODO Update to new API once available! Waiting for case CAUGHT_TREASURE:
Item fishingCatch = (Item) event.getCaught(); Item fishingCatch = (Item) event.getCaught();
if (Config.getInstance().getFishingOverrideTreasures() && if (Config.getInstance(). getFishingOverrideTreasures() &&
fishingCatch.getItemStack().getType() != Material.SALMON && fishingCatch.getItemStack().getType() != Material.SALMON &&
fishingCatch.getItemStack().getType() != Material.COD && fishingCatch.getItemStack().getType() != Material.COD &&
fishingCatch.getItemStack().getType() != Material.TROPICAL_FISH && fishingCatch.getItemStack().getType() != Material.TROPICAL_FISH &&
@ -450,6 +450,11 @@ public class PlayerListener implements Listener {
Item drop = event.getItem(); Item drop = event.getItem();
ItemStack dropStack = drop.getItemStack(); ItemStack dropStack = drop.getItemStack();
//Remove tracking
if(drop.hasMetadata(mcMMO.trackedArrow)) {
drop.removeMetadata(mcMMO.trackedArrow, mcMMO.p);
}
if (drop.hasMetadata(mcMMO.disarmedItemKey)) { if (drop.hasMetadata(mcMMO.disarmedItemKey)) {
if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).asString())) { if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).asString())) {
event.setCancelled(true); event.setCancelled(true);

View File

@ -118,6 +118,7 @@ public class mcMMO extends JavaPlugin {
public final static String customVisibleKey = "mcMMO: Name Visibility"; public final static String customVisibleKey = "mcMMO: Name Visibility";
public final static String droppedItemKey = "mcMMO: Tracked Item"; public final static String droppedItemKey = "mcMMO: Tracked Item";
public final static String infiniteArrowKey = "mcMMO: Infinite Arrow"; public final static String infiniteArrowKey = "mcMMO: Infinite Arrow";
public final static String trackedArrow = "mcMMO: Tracked Arrow";
public final static String bowForceKey = "mcMMO: Bow Force"; public final static String bowForceKey = "mcMMO: Bow Force";
public final static String arrowDistanceKey = "mcMMO: Arrow Distance"; public final static String arrowDistanceKey = "mcMMO: Arrow Distance";
public final static String BONUS_DROPS_METAKEY = "mcMMO: Double Drops"; public final static String BONUS_DROPS_METAKEY = "mcMMO: Double Drops";

View File

@ -16,6 +16,7 @@ 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.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@ -67,9 +68,10 @@ public class ArcheryManager extends SkillManager {
* *
* @param target The {@link LivingEntity} damaged by the arrow * @param target The {@link LivingEntity} damaged by the arrow
*/ */
public void retrieveArrows(LivingEntity target) { public void retrieveArrows(LivingEntity target, Projectile projectile) {
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, getPlayer())) { if(projectile.hasMetadata(mcMMO.trackedArrow)) {
Archery.incrementTrackerValue(target); Archery.incrementTrackerValue(target);
projectile.removeMetadata(mcMMO.trackedArrow, mcMMO.p); //Only 1 entity per projectile
} }
} }

View File

@ -223,7 +223,7 @@ public final class CombatUtils {
} }
if (!arrow.hasMetadata(mcMMO.infiniteArrowKey) && archeryManager.canRetrieveArrows()) { if (!arrow.hasMetadata(mcMMO.infiniteArrowKey) && archeryManager.canRetrieveArrows()) {
archeryManager.retrieveArrows(target); archeryManager.retrieveArrows(target, arrow);
} }
if(canUseLimitBreak(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) if(canUseLimitBreak(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK))