-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
129 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...tFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/patches/MapCursorLag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package me.moomoo.anarchyexploitfixes.modules.patches; | ||
|
||
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes; | ||
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule; | ||
import me.moomoo.anarchyexploitfixes.utils.EntityUtil; | ||
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.ItemFrame; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.HandlerList; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerInteractEntityEvent; | ||
import org.bukkit.event.world.ChunkLoadEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.MapMeta; | ||
import org.bukkit.map.MapView; | ||
|
||
public class MapCursorLag implements AnarchyExploitFixesModule, Listener { | ||
|
||
public MapCursorLag() { | ||
shouldEnable(); | ||
AnarchyExploitFixes.getConfiguration().addComment("patches.map-cursor-lag-patch.enable", | ||
"Patches 2b2t stacked map cursor lag that causes both client and server crashes."); | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return "map-cursor-lag"; | ||
} | ||
|
||
@Override | ||
public String category() { | ||
return "patches"; | ||
} | ||
|
||
@Override | ||
public void enable() { | ||
AnarchyExploitFixes plugin = AnarchyExploitFixes.getInstance(); | ||
plugin.getServer().getPluginManager().registerEvents(this, plugin); | ||
} | ||
|
||
@Override | ||
public boolean shouldEnable() { | ||
return AnarchyExploitFixes.getConfiguration().getBoolean("patches.map-cursor-lag-patch.enable", false); | ||
} | ||
|
||
@Override | ||
public void disable() { | ||
HandlerList.unregisterAll(this); | ||
} | ||
|
||
private void disableTracker(ItemFrame itemFrame) { | ||
ItemStack item = itemFrame.getItem(); | ||
if ( | ||
MaterialUtil.isMap(item.getType()) | ||
&& item.getItemMeta() instanceof MapMeta mapMeta | ||
&& mapMeta.hasMapView() | ||
) { | ||
MapView mapView = mapMeta.getMapView(); | ||
assert mapView != null; | ||
mapView.setTrackingPosition(false); | ||
} | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) | ||
private void onChunkLoad(ChunkLoadEvent event) { | ||
if (event.isNewChunk()) return; | ||
|
||
for (Entity entity : event.getChunk().getEntities()) { | ||
if (EntityUtil.ITEM_FRAMES.contains(entity.getType())) { | ||
this.disableTracker((ItemFrame) entity); | ||
} | ||
} | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) | ||
private void onInteract(PlayerInteractEntityEvent event) { | ||
Entity rightClicked = event.getRightClicked(); | ||
if (EntityUtil.ITEM_FRAMES.contains(rightClicked.getType())) { | ||
this.disableTracker((ItemFrame) rightClicked); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters