Skip to content

Commit

Permalink
use permtool in elytra sections as well
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Mar 7, 2024
1 parent bf588f2 commit eb8bacf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import me.moomoo.anarchyexploitfixes.config.LanguageCache;
import me.moomoo.anarchyexploitfixes.enums.AEFPermission;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
import me.moomoo.anarchyexploitfixes.utils.CachingPermTool;
import me.moomoo.anarchyexploitfixes.utils.LocationUtil;
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil;
import org.bukkit.Location;
Expand Down Expand Up @@ -71,7 +72,7 @@ public boolean shouldEnable() {
private void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (!ElytraHelper.getInstance().isGliding(player)) return;
if (spawn_shouldCheckPermission && player.hasPermission(AEFPermission.BYPASS_ELYTRA.get())) return;
if (spawn_shouldCheckPermission && CachingPermTool.hasPermission(AEFPermission.BYPASS_ELYTRA, player)) return;
Location playerLoc = player.getLocation();
if (ceilingSettingsEnabled && LocationUtil.isNetherCeiling(playerLoc)) return;
if (LocationUtil.getDistance2DTo00(playerLoc) > spawn_Radius) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import me.moomoo.anarchyexploitfixes.config.LanguageCache;
import me.moomoo.anarchyexploitfixes.enums.AEFPermission;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
import me.moomoo.anarchyexploitfixes.utils.CachingPermTool;
import me.moomoo.anarchyexploitfixes.utils.LocationUtil;
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil;
import org.bukkit.Location;
Expand Down Expand Up @@ -82,7 +83,7 @@ public boolean shouldEnable() {
private void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (!ElytraHelper.getInstance().isGliding(player)) return;
if (global_shouldCheckPermission && player.hasPermission(AEFPermission.BYPASS_ELYTRA.get())) return;
if (global_shouldCheckPermission && CachingPermTool.hasPermission(AEFPermission.BYPASS_ELYTRA, player)) return;
Location playerLoc = player.getLocation();
if (ceiling_SettingsEnabled && LocationUtil.isNetherCeiling(playerLoc)) return;
if (spawn_SettingsEnabled && LocationUtil.getDistance2DTo00(playerLoc) <= spawn_Radius) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import me.moomoo.anarchyexploitfixes.config.LanguageCache;
import me.moomoo.anarchyexploitfixes.enums.AEFPermission;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
import me.moomoo.anarchyexploitfixes.utils.CachingPermTool;
import me.moomoo.anarchyexploitfixes.utils.LocationUtil;
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil;
import org.bukkit.Location;
Expand Down Expand Up @@ -76,7 +77,7 @@ public boolean shouldEnable() {
private void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (!ElytraHelper.getInstance().isGliding(player)) return;
if (ceiling_shouldCheckPermission && player.hasPermission(AEFPermission.BYPASS_ELYTRA.get())) return;
if (ceiling_shouldCheckPermission && CachingPermTool.hasPermission(AEFPermission.BYPASS_ELYTRA, player)) return;
Location playerLoc = player.getLocation();
if (!LocationUtil.isNetherCeiling(playerLoc)) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.github.benmanes.caffeine.cache.Caffeine;
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.config.Config;
import me.moomoo.anarchyexploitfixes.enums.AEFPermission;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil;
import org.bukkit.entity.EntityType;
Expand All @@ -23,21 +22,20 @@ public class ElytraPacketFly implements AnarchyExploitFixesModule, Listener {

private final Cache<UUID, Integer> elytraOpenCounts;
private final int maxElytraOpensPerTime;
private final boolean shouldCheckPermission, notify, kickPlayer;
private final boolean notify, kickPlayer;

public ElytraPacketFly() {
shouldEnable();
Config config = AnarchyExploitFixes.getConfiguration();
config.addComment("elytra.packet-elytra-fly.patch-packet-elytra-fly",
"Patches the future/rusherhack/kamiblue 2b2t elytra fly exploit");
this.shouldCheckPermission = config.getBoolean("elytra.packet-elytra-fly.use-bypass-permission", false);
this.maxElytraOpensPerTime = config.getInt("elytra.packet-elytra-fly.max-glide-toggles-per-time", 25,
"The exploit causes the player to constantly toggle gliding.\n" +
"If too many glide toggles occur within a timeframe, they are most likely using PacketFly\n" +
"Still triggers false positives when players are jump sprinting with elytras, so play around with the values.");
this.elytraOpenCounts = Caffeine.newBuilder().expireAfterWrite(Duration.ofSeconds(
Math.max(config.getInt("elytra.packet-elytra-fly.time-in-seconds", 8,
"Will only allow players to go about 85km/h."), 1)
Math.max(1, config.getInt("elytra.packet-elytra-fly.time-in-seconds", 8,
"Will only allow players to go about 85km/h."))
)).build();
this.notify = config.getBoolean("elytra.packet-elytra-fly.notify-player-to-disable-packetfly", true,
"Configure message in lang folder.");
Expand Down Expand Up @@ -69,7 +67,6 @@ public boolean shouldEnable() {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onElytraOpen(EntityToggleGlideEvent event) {
if (event.getEntityType() != EntityType.PLAYER) return;
if (shouldCheckPermission && event.getEntity().hasPermission(AEFPermission.BYPASS_ELYTRA.get())) return;

Integer elytraOpens = elytraOpenCounts.getIfPresent(event.getEntity().getUniqueId());
if (elytraOpens == null) elytraOpens = 0;
Expand Down

0 comments on commit eb8bacf

Please sign in to comment.