Browse Source

Track items dropped by a player, prevent them from being party shared

TfT_02 12 years ago
parent
commit
3ffcaae122

+ 1 - 0
Changelog.txt

@@ -29,6 +29,7 @@ Version 1.4.06-dev
  ! ExperienceAPI methods will now throw InvalidSkillException if the skill name passed in is invalid.
  ! ExperienceAPI methods will now throw InvalidSkillException if the skill name passed in is invalid.
  ! Changed default value for recently-hurt cooldown between teleports, this is also fully configurable now
  ! Changed default value for recently-hurt cooldown between teleports, this is also fully configurable now
  ! Changed the amount of info messages in the console when enabling/disabling, enable Verbose_Logging to enable them again
  ! Changed the amount of info messages in the console when enabling/disabling, enable Verbose_Logging to enable them again
+ ! Items dropped by players are now being tracked and are not being shared with party members
 
 
 Version 1.4.05
 Version 1.4.05
  + Added option to allow refreshing of chunks after block-breaking abilities. (Disabled by default)
  + Added option to allow refreshing of chunks after block-breaking abilities. (Disabled by default)

+ 4 - 1
src/main/java/com/gmail/nossr50/listeners/PlayerListener.java

@@ -164,6 +164,7 @@ public class PlayerListener implements Listener {
     @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
     @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
     public void onPlayerDropItemEvent(PlayerDropItemEvent event) {
     public void onPlayerDropItemEvent(PlayerDropItemEvent event) {
         Player player = event.getPlayer();
         Player player = event.getPlayer();
+        Item drop = event.getItemDrop();
         McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
         McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
 
 
         if (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) {
         if (mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) {
@@ -171,6 +172,8 @@ public class PlayerListener implements Listener {
             return;
             return;
         }
         }
 
 
+        drop.setMetadata(mcMMO.droppedItemKey, mcMMO.metadataValue);
+
         SkillUtils.removeAbilityBuff(event.getItemDrop().getItemStack());
         SkillUtils.removeAbilityBuff(event.getItemDrop().getItemStack());
     }
     }
 
 
@@ -234,7 +237,7 @@ public class PlayerListener implements Listener {
 
 
         McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
         McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
 
 
-        if (mcMMOPlayer.inParty() && ItemUtils.isShareable(dropStack)) {
+        if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isShareable(dropStack)) {
             event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
             event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
 
 
             if (event.isCancelled()) {
             if (event.isCancelled()) {

+ 1 - 0
src/main/java/com/gmail/nossr50/mcMMO.java

@@ -93,6 +93,7 @@ public class mcMMO extends JavaPlugin {
     public final static String tntMetadataKey      = "mcMMO: Tracked TNT";
     public final static String tntMetadataKey      = "mcMMO: Tracked TNT";
     public final static String customNameKey       = "mcMMO: Custom Name";
     public final static String customNameKey       = "mcMMO: Custom Name";
     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 static FixedMetadataValue metadataValue;
     public static FixedMetadataValue metadataValue;