-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
2 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/combat/MultiTask.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,65 @@ | ||
package me.xginko.aef.modules.combat; | ||
|
||
import com.cryptomorin.xseries.XEntityType; | ||
import io.papermc.paper.event.player.PrePlayerAttackEntityEvent; | ||
import me.xginko.aef.modules.AEFModule; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.HandlerList; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.block.BlockPlaceEvent; | ||
import org.bukkit.event.entity.EntityDamageByEntityEvent; | ||
import org.bukkit.event.player.PlayerInteractEvent; | ||
|
||
public class MultiTask extends AEFModule implements Listener { | ||
|
||
public MultiTask() { | ||
super("combat.multi-task-patch"); | ||
} | ||
|
||
@Override | ||
public void enable() { | ||
plugin.getServer().getPluginManager().registerEvents(this, plugin); | ||
} | ||
|
||
@Override | ||
public boolean shouldEnable() { | ||
return config.getBoolean(configPath + ".enable", false); | ||
} | ||
|
||
@Override | ||
public void disable() { | ||
HandlerList.unregisterAll(this); | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
private void onPrePlayerAttackEntity(PrePlayerAttackEntityEvent event) { | ||
if (event.getPlayer().hasActiveItem()) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
private void onEntityDamageByEntity(EntityDamageByEntityEvent event) { | ||
if (event.getDamager().getType() == XEntityType.PLAYER.get()) { | ||
if (((LivingEntity) event.getDamager()).hasActiveItem()) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
private void onPlayerInteract(PlayerInteractEvent event) { | ||
if (event.getPlayer().hasActiveItem()) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
private void onBlockPlace(BlockPlaceEvent event) { | ||
if (event.getPlayer().hasActiveItem()) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/combat/MultiTask.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,57 @@ | ||
package me.xginko.aef.modules.combat; | ||
|
||
import com.cryptomorin.xseries.XEntityType; | ||
import me.xginko.aef.modules.AEFModule; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.HandlerList; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.block.BlockPlaceEvent; | ||
import org.bukkit.event.entity.EntityDamageByEntityEvent; | ||
import org.bukkit.event.player.PlayerInteractEvent; | ||
|
||
public class MultiTask extends AEFModule implements Listener { | ||
|
||
public MultiTask() { | ||
super("combat.multi-task-patch"); | ||
} | ||
|
||
@Override | ||
public void enable() { | ||
plugin.getServer().getPluginManager().registerEvents(this, plugin); | ||
} | ||
|
||
@Override | ||
public boolean shouldEnable() { | ||
return config.getBoolean(configPath + ".enable", false); | ||
} | ||
|
||
@Override | ||
public void disable() { | ||
HandlerList.unregisterAll(this); | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
private void onEntityDamageByEntity(EntityDamageByEntityEvent event) { | ||
if (event.getDamager().getType() == XEntityType.PLAYER.get()) { | ||
if (((LivingEntity) event.getDamager()).getActiveItem() != null) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
private void onPlayerInteract(PlayerInteractEvent event) { | ||
if (event.getPlayer().getActiveItem() != null) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
private void onBlockPlace(BlockPlaceEvent event) { | ||
if (event.getPlayer().getActiveItem() != null) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
} |