2
0
nossr50 3 жил өмнө
parent
commit
444e1532f2

+ 10 - 0
Changelog.txt

@@ -1,3 +1,13 @@
+Version 2.1.214
+    Temporarily removed FakePlayerAnimationEvent (see notes)
+
+    NOTES:
+    Spigot updated PlayerAnimationEvent with an API break between versions 1.18 and 1.19, as a temporary fix for mcMMO to be able to support both of these
+    Minecraft versions I have temporarily removed FakePlayerAnimationEvent. I am working on a fix to dynamically use the correct API depending on the version of MC
+    as many people will likely be stuck on 1.18 for a while.
+    FakePlayerAnimationEvent existed to circumvent false positives on anti-cheat plugins such as NoCheat, however
+    I am unsure if it is still needed and removing it may have no ill effects.. however I cannot be certain.
+    Anti-cheat plugin authors should be informed to update if you run into false positives with mcMMO after this update so they can make the appropriate changes.
 Version 2.1.213
 Version 2.1.213
     Updated various mechanics to recognize and understand the new blocks
     Updated various mechanics to recognize and understand the new blocks
     Added 'Packed_Mud' to mining xp
     Added 'Packed_Mud' to mining xp

+ 1 - 1
pom.xml

@@ -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.213</version>
+    <version>2.1.214</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>

+ 14 - 14
src/main/java/com/gmail/nossr50/events/fake/FakePlayerAnimationEvent.java

@@ -1,14 +1,14 @@
-package com.gmail.nossr50.events.fake;
-
-import org.bukkit.entity.Player;
-import org.bukkit.event.player.PlayerAnimationEvent;
-import org.bukkit.event.player.PlayerAnimationType;
-
-/**
- * Called when handling extra drops to avoid issues with NoCheat.
- */
-public class FakePlayerAnimationEvent extends PlayerAnimationEvent implements FakeEvent {
-    public FakePlayerAnimationEvent(Player player, PlayerAnimationType playerAnimationType) {
-        super(player, playerAnimationType);
-    }
-}
+//package com.gmail.nossr50.events.fake;
+//
+//import org.bukkit.entity.Player;
+//import org.bukkit.event.player.PlayerAnimationEvent;
+//import org.bukkit.event.player.PlayerAnimationType;
+//
+///**
+// * Called when handling extra drops to avoid issues with NoCheat.
+// */
+//public class FakePlayerAnimationEvent extends PlayerAnimationEvent implements FakeEvent {
+//    public FakePlayerAnimationEvent(Player player, PlayerAnimationType playerAnimationType) {
+//        super(player, playerAnimationType);
+//    }
+//}

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

@@ -8,7 +8,6 @@ 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.taming.CallOfTheWildType;
 import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
 import com.gmail.nossr50.events.McMMOReplaceVanillaTreasureEvent;
 import com.gmail.nossr50.events.McMMOReplaceVanillaTreasureEvent;
-import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
 import com.gmail.nossr50.locale.LocaleLoader;
 import com.gmail.nossr50.locale.LocaleLoader;
 import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.party.ShareHandler;
 import com.gmail.nossr50.party.ShareHandler;
@@ -841,7 +840,7 @@ public class PlayerListener implements Listener {
 
 
                 HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
                 HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
 
 
-                FakePlayerAnimationEvent fakeSwing = new FakePlayerAnimationEvent(event.getPlayer(), PlayerAnimationType.ARM_SWING); //PlayerAnimationEvent compat
+                // FakePlayerAnimationEvent fakeSwing = new FakePlayerAnimationEvent(event.getPlayer(), PlayerAnimationType.ARM_SWING); //PlayerAnimationEvent compat
                 if(!event.isCancelled() || event.useInteractedBlock() != Event.Result.DENY) {
                 if(!event.isCancelled() || event.useInteractedBlock() != Event.Result.DENY) {
                     //TODO: Is this code to set false from bone meal even needed? I'll have to double check later.
                     //TODO: Is this code to set false from bone meal even needed? I'll have to double check later.
                     if (heldItem.getType() == Material.BONE_MEAL) {
                     if (heldItem.getType() == Material.BONE_MEAL) {
@@ -860,7 +859,7 @@ public class PlayerListener implements Listener {
                     if (herbalismManager.canGreenThumbBlock(blockState)) {
                     if (herbalismManager.canGreenThumbBlock(blockState)) {
                         //call event for Green Thumb Block
                         //call event for Green Thumb Block
                         if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_GREEN_THUMB, block).isCancelled()) {
                         if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_GREEN_THUMB, block).isCancelled()) {
-                            Bukkit.getPluginManager().callEvent(fakeSwing);
+                            // Bukkit.getPluginManager().callEvent(fakeSwing);
                             player.getInventory().getItemInMainHand().setAmount(heldItem.getAmount() - 1);
                             player.getInventory().getItemInMainHand().setAmount(heldItem.getAmount() - 1);
                             player.updateInventory();
                             player.updateInventory();
                             if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
                             if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
@@ -871,7 +870,7 @@ public class PlayerListener implements Listener {
                     /* SHROOM THUMB CHECK */
                     /* SHROOM THUMB CHECK */
                     else if (herbalismManager.canUseShroomThumb(blockState)) {
                     else if (herbalismManager.canUseShroomThumb(blockState)) {
                         if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_SHROOM_THUMB, block).isCancelled()) {
                         if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_SHROOM_THUMB, block).isCancelled()) {
-                            Bukkit.getPluginManager().callEvent(fakeSwing);
+                            // Bukkit.getPluginManager().callEvent(fakeSwing);
                             event.setCancelled(true);
                             event.setCancelled(true);
                             if (herbalismManager.processShroomThumb(blockState)
                             if (herbalismManager.processShroomThumb(blockState)
                                     && EventUtils.simulateBlockBreak(block, player, false)) {
                                     && EventUtils.simulateBlockBreak(block, player, false)) {

+ 10 - 9
src/main/java/com/gmail/nossr50/util/EventUtils.java

@@ -44,6 +44,7 @@ import org.bukkit.entity.LivingEntity;
 import org.bukkit.entity.Player;
 import org.bukkit.entity.Player;
 import org.bukkit.event.Event;
 import org.bukkit.event.Event;
 import org.bukkit.event.entity.EntityDamageEvent;
 import org.bukkit.event.entity.EntityDamageEvent;
+import org.bukkit.event.player.PlayerAnimationEvent;
 import org.bukkit.event.player.PlayerAnimationType;
 import org.bukkit.event.player.PlayerAnimationType;
 import org.bukkit.event.player.PlayerFishEvent;
 import org.bukkit.event.player.PlayerFishEvent;
 import org.bukkit.inventory.ItemStack;
 import org.bukkit.inventory.ItemStack;
@@ -225,12 +226,12 @@ public final class EventUtils {
         return event;
         return event;
     }
     }
 
 
-    public static FakePlayerAnimationEvent callFakeArmSwingEvent(Player player) {
-        FakePlayerAnimationEvent event = new FakePlayerAnimationEvent(player, PlayerAnimationType.ARM_SWING);
-        mcMMO.p.getServer().getPluginManager().callEvent(event);
-
-        return event;
-    }
+//    public static Event callFakeArmSwingEvent(@NotNull Player player) {
+//        PlayerAnimationEvent event = new FakePlayerAnimationEvent(player, PlayerAnimationType.ARM_SWING);
+//        mcMMO.p.getServer().getPluginManager().callEvent(event);
+//
+//        return event;
+//    }
 
 
     public static boolean tryLevelChangeEvent(Player player, PrimarySkillType skill, int levelsChanged, float xpRemoved, boolean isLevelUp, XPGainReason xpGainReason) {
     public static boolean tryLevelChangeEvent(Player player, PrimarySkillType skill, int levelsChanged, float xpRemoved, boolean isLevelUp, XPGainReason xpGainReason) {
         McMMOPlayerLevelChangeEvent event = isLevelUp ? new McMMOPlayerLevelUpEvent(player, skill, levelsChanged, xpGainReason) : new McMMOPlayerLevelDownEvent(player, skill, levelsChanged, xpGainReason);
         McMMOPlayerLevelChangeEvent event = isLevelUp ? new McMMOPlayerLevelUpEvent(player, skill, levelsChanged, xpGainReason) : new McMMOPlayerLevelDownEvent(player, skill, levelsChanged, xpGainReason);
@@ -315,9 +316,9 @@ public final class EventUtils {
         PluginManager pluginManager = mcMMO.p.getServer().getPluginManager();
         PluginManager pluginManager = mcMMO.p.getServer().getPluginManager();
 
 
         // Support for NoCheat
         // Support for NoCheat
-        if (shouldArmSwing) {
-            callFakeArmSwingEvent(player);
-        }
+        //if (shouldArmSwing) {
+        //    callFakeArmSwingEvent(player);
+        //}
 
 
         FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getInventory().getItemInMainHand(), true);
         FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getInventory().getItemInMainHand(), true);
         pluginManager.callEvent(damageEvent);
         pluginManager.callEvent(damageEvent);

+ 1 - 1
src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java

@@ -626,7 +626,7 @@ public class ScoreboardWrapper {
         }
         }
     }
     }
 
 
-    public void acceptLeaderboardData(List<PlayerStat> leaderboardData) {
+    public void acceptLeaderboardData(@NotNull List<PlayerStat> leaderboardData) {
         for (PlayerStat stat : leaderboardData) {
         for (PlayerStat stat : leaderboardData) {
             String name = stat.name;
             String name = stat.name;
 
 

+ 1 - 1
src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java

@@ -681,7 +681,7 @@ public final class CombatUtils {
                 continue;
                 continue;
             }
             }
 
 
-            EventUtils.callFakeArmSwingEvent(attacker);
+            //EventUtils.callFakeArmSwingEvent(attacker);
 
 
             switch (type) {
             switch (type) {
                 case SWORDS:
                 case SWORDS: