Reworked Entire Antigrief System

This commit is contained in:
Auxilor 2020-08-28 17:13:12 +01:00
parent 14ee3c1caf
commit 129e3df582
80 changed files with 603 additions and 568 deletions

View File

@ -0,0 +1,7 @@
<component name="ProjectDictionaryState">
<dictionary name="Will">
<words>
<w>antigrief</w>
</words>
</dictionary>
</component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.willfp.ecoenchants:API:4.1.0-pre10">
<library name="Maven: com.willfp.ecoenchants:API:4.1.0-pre11">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/willfp/ecoenchants/API/4.1.0-pre10/API-4.1.0-pre10.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/willfp/ecoenchants/API/4.1.0-pre11/API-4.1.0-pre11.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/willfp/ecoenchants/API/4.1.0-pre10/API-4.1.0-pre10-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/willfp/ecoenchants/API/4.1.0-pre11/API-4.1.0-pre11-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/willfp/ecoenchants/API/4.1.0-pre10/API-4.1.0-pre10-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/willfp/ecoenchants/API/4.1.0-pre11/API-4.1.0-pre11-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.willfp.ecoenchants</groupId>
<version>4.1.0-pre10</version>
<version>4.1.0-pre11</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -36,7 +36,7 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.13-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
<orderEntry type="library" name="Maven: com.willfp.ecoenchants:API:4.1.0-pre10" level="project" />
<orderEntry type="library" name="Maven: com.willfp.ecoenchants:API:4.1.0-pre11" level="project" />
<orderEntry type="module" module-name="v1_15_R1" />
<orderEntry type="module" module-name="v1_16_R1" />
<orderEntry type="module" module-name="v1_16_R2" />

View File

@ -7,7 +7,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.willfp.ecoenchants</groupId>
<version>4.1.0-pre10</version>
<version>4.1.0-pre11</version>
</parent>

View File

@ -30,31 +30,6 @@ public class Main extends JavaPlugin {
*/
public static String newVersion;
/**
* Has worldguard?
*/
public static boolean hasWG;
/**
* Has GriefPrevention?
*/
public static boolean hasGP;
/**
* Has FactionsUUID?
*/
public static boolean hasFactionsUUID;
/**
* Has Towny?
*/
public static boolean hasTowny;
/**
* Has Lands?
*/
public static boolean hasLands;
/**
* Has AdvancedEnchantments?
*/

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.ItemDurability;
import org.bukkit.entity.Player;
@ -40,7 +40,7 @@ public class Abrasion extends EcoEnchant {
Player player = (Player) event.getDamager();
Player victim = (Player) event.getEntity();
if(!AntiGrief.canInjurePlayer(player, victim)) return;
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -1,13 +1,13 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.Main;
import com.willfp.ecoenchants.anticheat.AnticheatManager;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.BlockBreak;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -39,7 +39,7 @@ public class BlastMining extends EcoEnchant {
if (event.isCancelled())
return;
if (!AntiGrief.canBreakBlock(player, block)) return;
if(!AntigriefManager.canBreakBlock(player, block)) return;
if(player.isSneaking() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-sneak")) return;
@ -60,7 +60,7 @@ public class BlastMining extends EcoEnchant {
if(block1.getType().getHardness() > block.getType().getHardness() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "hardness-check")) continue;
if (!AntiGrief.canBreakBlock(player, block1)) continue;
if(!AntigriefManager.canBreakBlock(player, block1)) continue;
BlockBreak.breakBlock(player, block1);
if(!hasExploded) {

View File

@ -4,9 +4,10 @@ import com.willfp.ecoenchants.Main;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefGriefPrevention;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.LivingEntity;
@ -39,9 +40,7 @@ public class Bleed extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -4,9 +4,9 @@ import com.willfp.ecoenchants.Main;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
@ -39,9 +39,7 @@ public class Cleave extends EcoEnchant {
if(victim.hasMetadata("cleaved"))
return;
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,8 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefGriefPrevention;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -35,9 +36,7 @@ public class Deflection extends EcoEnchant {
if(!player.isBlocking()) return;
if(victim instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
int level;
if (!HasEnchant.playerOffhand(player, this) && !HasEnchant.playerHeld(player, this)) return;

View File

@ -1,13 +1,13 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.Main;
import com.willfp.ecoenchants.anticheat.AnticheatManager;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.BlockBreak;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.SimplifyVector;
import org.bukkit.block.Block;
@ -42,7 +42,7 @@ public class Drill extends EcoEnchant {
if (event.isCancelled())
return;
if (!AntiGrief.canBreakBlock(player, block)) return;
if(!AntigriefManager.canBreakBlock(player, block)) return;
if(player.isSneaking() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-sneak")) return;
@ -61,7 +61,7 @@ public class Drill extends EcoEnchant {
if(block1.getType().getHardness() > block.getType().getHardness() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "hardness-check")) continue;
if (!AntiGrief.canBreakBlock(player, block1)) continue;
if(!AntigriefManager.canBreakBlock(player, block1)) continue;
BlockBreak.breakBlock(player, block1);
block1.removeMetadata("from-drill", Main.getInstance());

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.LivingEntity;
@ -36,9 +36,7 @@ public class Dullness extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Lightning;
import com.willfp.ecoenchants.util.Rand;
@ -37,9 +37,7 @@ public class Electroshock extends EcoEnchant {
if(!player.isBlocking()) return;
if(victim instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
int level;
if (!HasEnchant.playerOffhand(player, this) && !HasEnchant.playerHeld(player, this)) return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.nms.TridentStack;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.LivingEntity;
@ -43,9 +43,7 @@ public class Extract extends EcoEnchant {
Trident trident = (Trident) event.getDamager();
ItemStack item = TridentStack.getTridentStack(trident);
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, (LivingEntity) event.getEntity())) return;
if (!HasEnchant.item(item, this)) return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.LivingEntity;
@ -36,9 +36,7 @@ public class Famine extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.LivingEntity;
@ -38,9 +38,7 @@ public class Flinch extends EcoEnchant {
if(!player.isBlocking()) return;
if(victim instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
int level;
if (!HasEnchant.playerOffhand(player, this) && !HasEnchant.playerHeld(player, this)) return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.LocationUtils;
import com.willfp.ecoenchants.util.Rand;
@ -35,9 +35,7 @@ public class Fury extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -37,7 +37,7 @@ public class Grapple extends EcoEnchant {
if(victim.hasMetadata("NPC")) return;
if(!AntiGrief.canInjureMob(player, victim)) return;
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.ItemDurability;
import org.bukkit.Material;
@ -38,7 +38,7 @@ public class GreenThumb extends EcoEnchant {
if (!HasEnchant.playerHeld(player, this)) return;
if(!AntiGrief.canBreakBlock(player, event.getClickedBlock())) return;
if(!AntigriefManager.canBreakBlock(player, event.getClickedBlock())) return;
if(this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "damage"))
ItemDurability.damageItem(player, player.getInventory().getItemInMainHand(), 1, player.getInventory().getHeldItemSlot());

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.ItemDurability;
import org.bukkit.entity.Player;
@ -33,7 +33,7 @@ public class Grit extends EcoEnchant {
Player player = (Player) event.getEntity();
Player attacker = (Player) event.getDamager();
if(!AntiGrief.canInjurePlayer(attacker, player)) return;
if(!AntigriefManager.canInjure(attacker, player)) return;
int totalGritPoints = HasEnchant.getArmorPoints(player, this, false);

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
@ -40,7 +40,7 @@ public class Hook extends EcoEnchant {
if(victim.hasMetadata("NPC")) return;
if(!AntiGrief.canInjureMob(player, victim)) return;
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Arrow;
@ -39,9 +39,7 @@ public class IceShot extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, (Player) event.getEntity())) return;
if(event.isCancelled()) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.Material;
@ -49,7 +49,7 @@ public class Ignite extends EcoEnchant {
float power = (float) (0.5 + (level * 0.5));
if (!AntiGrief.canBreakBlock(player, block))
if (!AntigriefManager.canBreakBlock(player, block))
return;
if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Player;
@ -35,7 +35,7 @@ public class IllusionAspect extends EcoEnchant {
Player victim = (Player) event.getEntity();
if(!AntiGrief.canInjurePlayer(player, victim)) return;
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.queue.DropQueue;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
@ -51,7 +51,7 @@ public class InfernalTouch extends EcoEnchant {
if (event.isCancelled())
return;
if (!AntiGrief.canBreakBlock(player, block)) return;
if (!AntigriefManager.canBreakBlock(player, block)) return;
Collection<ItemStack> drops = new ArrayList<>();

View File

@ -1,6 +1,6 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.anticheat.AnticheatManager;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.LivingEntity;
@ -35,9 +35,7 @@ public class Leeching extends EcoEnchant {
Player player = (Player) event.getDamager();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, (LivingEntity) event.getEntity())) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Arrow;
@ -39,9 +39,7 @@ public class Levitate extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if(event.isCancelled()) return;

View File

@ -1,13 +1,13 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.Main;
import com.willfp.ecoenchants.anticheat.AnticheatManager;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.BlockBreak;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.RecursiveBlock;
import org.bukkit.Bukkit;
@ -45,7 +45,7 @@ public class Lumberjack extends EcoEnchant {
if (event.isCancelled())
return;
if (!AntiGrief.canBreakBlock(player, block)) return;
if(!AntigriefManager.canBreakBlock(player, block)) return;
if(player.isSneaking() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-sneak")) return;
@ -65,7 +65,7 @@ public class Lumberjack extends EcoEnchant {
for(Block treeBlock : treeBlocks) {
treeBlock.setMetadata("from-lumberjack", new FixedMetadataValue(Main.getInstance(), true));
if(!AntiGrief.canBreakBlock(player, treeBlock)) continue;
if(!AntigriefManager.canBreakBlock(player, treeBlock)) continue;
BlockBreak.breakBlock(player, treeBlock);

View File

@ -1,12 +1,12 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.Main;
import com.willfp.ecoenchants.anticheat.AnticheatManager;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.Circle;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Bukkit;
@ -50,7 +50,7 @@ public class MagmaWalker extends EcoEnchant {
Block block = player.getWorld().getBlockAt(loc);
if (!AntiGrief.canPlaceBlock(player, player.getWorld().getBlockAt(loc))) continue;
if (!AntigriefManager.canPlaceBlock(player, player.getWorld().getBlockAt(loc))) continue;
if(!block.getType().equals(Material.LAVA)) continue;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.EqualIfOver;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.block.Block;
@ -32,7 +32,7 @@ public class Oxygenate extends EcoEnchant {
if (event.isCancelled())
return;
if (!AntiGrief.canBreakBlock(player, block)) return;
if (!AntigriefManager.canBreakBlock(player, block)) return;
if(player.getRemainingAir() == player.getMaximumAir()) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Arrow;
@ -39,9 +39,7 @@ public class Parasitic extends EcoEnchant {
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, (LivingEntity) event.getEntity())) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -36,7 +36,7 @@ public class Reel extends EcoEnchant {
if(victim.hasMetadata("NPC")) return;
if(!AntiGrief.canInjureMob(player, victim)) return;
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.Main;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -32,7 +32,7 @@ public class Replenish extends EcoEnchant {
if(!HasEnchant.playerHeld(player, this)) return;
if(!AntiGrief.canBreakBlock(player, block)) return;
if(!AntigriefManager.canBreakBlock(player, block)) return;
if(event.isCancelled()) return;
if(!(block.getBlockData() instanceof Ageable)) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -35,7 +35,7 @@ public class Spiked extends EcoEnchant {
if(victim.hasMetadata("NPC")) return;
if(!AntiGrief.canInjureMob(player, victim)) return;
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.queue.DropQueue;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.EqualIfOver;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
@ -42,7 +42,7 @@ public class StoneSwitcher extends EcoEnchant {
if (event.isCancelled())
return;
if (!AntiGrief.canBreakBlock(player, block)) return;
if (!AntigriefManager.canBreakBlock(player, block)) return;
int level = HasEnchant.getPlayerLevel(player, this);
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.LivingEntity;
@ -36,9 +36,7 @@ public class StrayAspect extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -4,10 +4,10 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.events.entitydeathbyentity.EntityDeathByEntityEvent;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.nms.TridentStack;
import com.willfp.ecoenchants.queue.DropQueue;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.GameMode;
import org.bukkit.Material;
@ -45,7 +45,7 @@ public class Telekinesis extends EcoEnchant {
Block block = event.getBlock();
if (!AntiGrief.canBreakBlock(player, block)) return;
if (!AntigriefManager.canBreakBlock(player, block)) return;
List<ItemStack> drops = new ArrayList<>();
event.getItems().forEach((item -> {
@ -75,7 +75,7 @@ public class Telekinesis extends EcoEnchant {
if (event.isCancelled())
return;
if (!AntiGrief.canBreakBlock(player, block)) return;
if (!AntigriefManager.canBreakBlock(player, block)) return;
if(block.getType().equals(Material.SPAWNER)) event.setExpToDrop(0);

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Lightning;
import com.willfp.ecoenchants.util.Rand;
@ -36,7 +36,7 @@ public class Thor extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
if(!AntigriefManager.canInjure(player, (Player) event.getEntity())) return;
}
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -4,8 +4,8 @@ import com.willfp.ecoenchants.Main;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
@ -39,7 +39,7 @@ public class Tornado extends EcoEnchant {
if(victim.hasMetadata("NPC")) return;
if(!AntiGrief.canInjureMob(player, victim)) return;
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.LivingEntity;
@ -37,9 +37,7 @@ public class Toxic extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.LivingEntity;
@ -37,9 +37,7 @@ public class VampireAspect extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -1,13 +1,13 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.Main;
import com.willfp.ecoenchants.anticheat.AnticheatManager;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.BlockBreak;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.RecursiveBlock;
import org.bukkit.Bukkit;
@ -45,7 +45,7 @@ public class Vein extends EcoEnchant {
if (event.isCancelled())
return;
if (!AntiGrief.canBreakBlock(player, block)) return;
if(!AntigriefManager.canBreakBlock(player, block)) return;
if(player.isSneaking() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-sneak")) return;
@ -65,7 +65,7 @@ public class Vein extends EcoEnchant {
for(Block veinBlock : blockSet) {
veinBlock.setMetadata("from-vein", new FixedMetadataValue(Main.getInstance(), true));
if(!AntiGrief.canBreakBlock(player, veinBlock)) continue;
if(!AntigriefManager.canBreakBlock(player, veinBlock)) continue;
BlockBreak.breakBlock(player, veinBlock);

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Arrow;
@ -38,9 +38,7 @@ public class Venom extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if(event.isCancelled()) return;

View File

@ -4,8 +4,8 @@ import com.willfp.ecoenchants.Main;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
@ -46,9 +46,7 @@ public class Weakening extends EcoEnchant {
event.setDamage(event.getDamage() * multiplier);
}
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Lightning;
import com.willfp.ecoenchants.util.Rand;
@ -37,9 +37,7 @@ public class Zeus extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -37,7 +37,7 @@ public class Annihilate extends EcoEnchant {
if(victim.hasMetadata("NPC")) return;
if(!AntiGrief.canInjureMob(player, victim)) return;
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Lightning;
import com.willfp.ecoenchants.util.Rand;
@ -35,9 +35,7 @@ public class Bolt extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -4,9 +4,9 @@ import com.willfp.ecoenchants.Main;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
@ -39,9 +39,7 @@ public class Carve extends EcoEnchant {
if(victim.hasMetadata("carved"))
return;
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Player;
@ -38,7 +38,7 @@ public class Confusion extends EcoEnchant {
Player victim = (Player) event.getEntity();
if(!AntiGrief.canInjurePlayer(player, victim)) return;
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -24,7 +24,7 @@ public class Energizing extends EcoEnchant {
public void onEnergizingBreak(BlockBreakEvent event) {
if(event.isCancelled()) return;
Player player = event.getPlayer();
if(!AntiGrief.canBreakBlock(player, event.getBlock())) return;
if(!AntigriefManager.canBreakBlock(player, event.getBlock())) return;
if(!HasEnchant.playerHeld(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -35,7 +35,7 @@ public class Harpoon extends EcoEnchant {
if(victim.hasMetadata("NPC")) return;
if(!AntiGrief.canInjureMob(player, victim)) return;
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType;
@ -43,9 +43,9 @@ public class Instability extends EcoEnchant {
float power = (float) (0.5 + (level * 0.5));
if (!AntiGrief.canCreateExplosion(player, event.getEntity().getLocation())) return;
if (!AntigriefManager.canCreateExplosion(player, event.getEntity().getLocation())) return;
if (breakblocks) {
if (!AntiGrief.canBreakBlock(player, event.getEntity().getLocation().getWorld().getBlockAt(event.getEntity().getLocation())))
if (!AntigriefManager.canBreakBlock(player, event.getEntity().getLocation().getWorld().getBlockAt(event.getEntity().getLocation())))
return;
}

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.LivingEntity;
@ -36,7 +36,7 @@ public class LifeSteal extends EcoEnchant {
Player player = (Player) event.getDamager();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
if(!AntigriefManager.canInjure(player, (Player) event.getEntity())) return;
}
if (!HasEnchant.playerHeld(player, this)) return;

View File

@ -2,8 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -30,8 +30,6 @@ public class Soulbound extends EcoEnchant {
public void onSoulboundDeath(PlayerDeathEvent event) {
if(event.getKeepInventory()) return;
if(AntiGrief.hasKeepInv(event.getEntity())) return;
Player player = event.getEntity();
List<ItemStack> soulboundItems = new ArrayList<>(); // Stored as list to preserve duplicates

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.AntiGrief;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.Location;
@ -35,9 +35,7 @@ public class Volatile extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if(event.getEntity() instanceof Player) {
if(!AntiGrief.canInjurePlayer(player, (Player) event.getEntity())) return;
}
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;
@ -54,9 +52,9 @@ public class Volatile extends EcoEnchant {
float power = (float) (0.5 + (level * 0.5));
if (!AntiGrief.canCreateExplosion(player, event.getEntity().getLocation())) return;
if (!AntigriefManager.canCreateExplosion(player, event.getEntity().getLocation())) return;
if (breakblocks) {
if (!AntiGrief.canBreakBlock(player, event.getEntity().getLocation().getWorld().getBlockAt(event.getEntity().getLocation())))
if (!AntigriefManager.canBreakBlock(player, event.getEntity().getLocation().getWorld().getBlockAt(event.getEntity().getLocation())))
return;
}

View File

@ -0,0 +1,9 @@
package com.willfp.ecoenchants.integrations;
public interface Integration {
/**
* Get the name of integration
* @return The name
*/
String getPluginName();
}

View File

@ -1,11 +1,10 @@
package com.willfp.ecoenchants.anticheat;
package com.willfp.ecoenchants.integrations.anticheat;
import com.willfp.ecoenchants.Main;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

View File

@ -1,14 +1,9 @@
package com.willfp.ecoenchants.anticheat;
package com.willfp.ecoenchants.integrations.anticheat;
import com.willfp.ecoenchants.integrations.Integration;
import org.bukkit.entity.Player;
public interface AnticheatWrapper {
/**
* Get the name of anticheat
* @return The name
*/
String getPluginName();
public interface AnticheatWrapper extends Integration {
/**
* Exempt a player from checks
* @param player The player to exempt

View File

@ -1,6 +1,6 @@
package com.willfp.ecoenchants.anticheat.anticheats;
package com.willfp.ecoenchants.integrations.anticheat.plugins;
import com.willfp.ecoenchants.anticheat.AnticheatWrapper;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatWrapper;
import me.konsolas.aac.api.PlayerViolationEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;

View File

@ -1,6 +1,6 @@
package com.willfp.ecoenchants.anticheat.anticheats;
package com.willfp.ecoenchants.integrations.anticheat.plugins;
import com.willfp.ecoenchants.anticheat.AnticheatWrapper;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatWrapper;
import me.rerere.matrix.api.events.PlayerViolationEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;

View File

@ -1,6 +1,6 @@
package com.willfp.ecoenchants.anticheat.anticheats;
package com.willfp.ecoenchants.integrations.anticheat.plugins;
import com.willfp.ecoenchants.anticheat.AnticheatWrapper;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatWrapper;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
import org.bukkit.entity.Player;

View File

@ -1,6 +1,6 @@
package com.willfp.ecoenchants.anticheat.anticheats;
package com.willfp.ecoenchants.integrations.anticheat.plugins;
import com.willfp.ecoenchants.anticheat.AnticheatWrapper;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatWrapper;
import me.vagdedes.spartan.api.PlayerViolationEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;

View File

@ -0,0 +1,58 @@
package com.willfp.ecoenchants.integrations.antigrief;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
public class AntigriefManager {
private static final Set<AntigriefWrapper> antigriefs = new HashSet<>();
public static void registerAntigrief(AntigriefWrapper antigrief) {
antigriefs.add(antigrief);
}
/**
* Can player break block
* @param player The player
* @param block The block
* @return If player can break block
*/
public static boolean canBreakBlock(Player player, Block block) {
return antigriefs.stream().allMatch(antigriefWrapper -> antigriefWrapper.canBreakBlock(player, block));
}
/**
* Can player create explosion at location
* @param player The player
* @param location The location
* @return If player can create explosion
*/
public static boolean canCreateExplosion(Player player, Location location) {
return antigriefs.stream().allMatch(antigriefWrapper -> antigriefWrapper.canCreateExplosion(player, location));
}
/**
* Can player place block
* @param player The player
* @param block The block
* @return If player can place block
*/
public static boolean canPlaceBlock(Player player, Block block) {
return antigriefs.stream().allMatch(antigriefWrapper -> antigriefWrapper.canPlaceBlock(player, block));
}
/**
* Can player injure living entity
* @param player The player
* @param victim The victim
* @return If player can injure
*/
public static boolean canInjure(Player player, LivingEntity victim) {
return antigriefs.stream().allMatch(antigriefWrapper -> antigriefWrapper.canInjure(player, victim));
}
}

View File

@ -0,0 +1,35 @@
package com.willfp.ecoenchants.integrations.antigrief;
import com.willfp.ecoenchants.integrations.Integration;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public interface AntigriefWrapper extends Integration {
boolean canBreakBlock(Player player, Block block);
/**
* Can player create explosion at location
* @param player The player
* @param location The location
* @return If player can create explosion
*/
boolean canCreateExplosion(Player player, Location location);
/**
* Can player place block
* @param player The player
* @param block The block
* @return If player can place block
*/
boolean canPlaceBlock(Player player, Block block);
/**
* Can player injure living entity
* @param player The player
* @param victim The victim
* @return If player can injure
*/
boolean canInjure(Player player, LivingEntity victim);
}

View File

@ -0,0 +1,67 @@
package com.willfp.ecoenchants.integrations.antigrief.plugins;
import com.massivecraft.factions.*;
import com.massivecraft.factions.perms.PermissibleAction;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefWrapper;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public class AntigriefFactionsUUID implements AntigriefWrapper {
@Override
public boolean canBreakBlock(Player player, Block block) {
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
FLocation flocation = new FLocation(block.getLocation());
Faction faction = Board.getInstance().getFactionAt(flocation);
if (!faction.hasAccess(fplayer, PermissibleAction.DESTROY)) {
return fplayer.isAdminBypassing();
}
return true;
}
@Override
public boolean canCreateExplosion(Player player, Location location) {
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
FLocation flocation = new FLocation(location);
Faction faction = Board.getInstance().getFactionAt(flocation);
return !faction.noExplosionsInTerritory();
}
@Override
public boolean canPlaceBlock(Player player, Block block) {
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
FLocation flocation = new FLocation(block.getLocation());
Faction faction = Board.getInstance().getFactionAt(flocation);
if (!faction.hasAccess(fplayer, PermissibleAction.BUILD)) {
return fplayer.isAdminBypassing();
}
return true;
}
@Override
public boolean canInjure(Player player, LivingEntity victim) {
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
FLocation flocation = new FLocation(victim.getLocation());
Faction faction = Board.getInstance().getFactionAt(flocation);
if(victim instanceof Player) {
if (faction.isPeaceful()) {
return fplayer.isAdminBypassing();
}
} else {
if (faction.hasAccess(fplayer, PermissibleAction.DESTROY)) {
return fplayer.isAdminBypassing();
}
}
return true;
}
@Override
public String getPluginName() {
return "FactionsUUID";
}
}

View File

@ -0,0 +1,57 @@
package com.willfp.ecoenchants.integrations.antigrief.plugins;
import com.comphenix.protocol.PacketType;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefWrapper;
import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public class AntigriefGriefPrevention implements AntigriefWrapper {
@Override
public boolean canBreakBlock(Player player, Block block) {
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(block.getLocation(), false, null);
if (claim != null) {
return claim.allowBreak(player, block.getType()) == null;
}
return true;
}
@Override
public boolean canCreateExplosion(Player player, Location location) {
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, false, null);
if (claim != null) {
return claim.areExplosivesAllowed;
}
return true;
}
@Override
public boolean canPlaceBlock(Player player, Block block) {
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(block.getLocation(), false, null);
if (claim != null) {
return claim.allowBuild(player, block.getType()) == null;
}
return true;
}
@Override
public boolean canInjure(Player player, LivingEntity victim) {
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(victim.getLocation(), false, null);
if(victim instanceof Player) {
return claim == null;
} else {
if (claim != null) {
return claim.ownerID.equals(player.getUniqueId());
}
return true;
}
}
@Override
public String getPluginName() {
return "GriefPrevention";
}
}

View File

@ -0,0 +1,64 @@
package com.willfp.ecoenchants.integrations.antigrief.plugins;
import com.willfp.ecoenchants.Main;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefWrapper;
import me.angeschossen.lands.api.integration.LandsIntegration;
import me.angeschossen.lands.api.land.Area;
import me.angeschossen.lands.api.role.enums.RoleSetting;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public class AntigriefLands implements AntigriefWrapper {
@Override
public boolean canBreakBlock(Player player, Block block) {
LandsIntegration landsIntegration = new LandsIntegration(Main.getInstance());
Area area = landsIntegration.getAreaByLoc(block.getLocation());
if (area != null) {
return area.canSetting(player, RoleSetting.BLOCK_BREAK, false);
}
return true;
}
@Override
public boolean canCreateExplosion(Player player, Location location) {
LandsIntegration landsIntegration = new LandsIntegration(Main.getInstance());
Area area = landsIntegration.getAreaByLoc(location);
if (area != null) {
return area.canSetting(player, RoleSetting.BLOCK_IGNITE, false);
}
return true;
}
@Override
public boolean canPlaceBlock(Player player, Block block) {
LandsIntegration landsIntegration = new LandsIntegration(Main.getInstance());
Area area = landsIntegration.getAreaByLoc(block.getLocation());
if (area != null) {
return area.canSetting(player, RoleSetting.BLOCK_PLACE, false);
}
return true;
}
@Override
public boolean canInjure(Player player, LivingEntity victim) {
LandsIntegration landsIntegration = new LandsIntegration(Main.getInstance());
Area area = landsIntegration.getAreaByLoc(victim.getLocation());
if(victim instanceof Player) {
if (area != null) {
return area.canSetting(player, RoleSetting.ATTACK_PLAYER, false);
}
} else {
if (area != null) {
return area.canSetting(player, RoleSetting.ATTACK_ANIMAL, false);
}
}
return true;
}
@Override
public String getPluginName() {
return "Lands";
}
}

View File

@ -0,0 +1,50 @@
package com.willfp.ecoenchants.integrations.antigrief.plugins;
import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.towny.object.TownyPermission;
import com.palmergames.bukkit.towny.object.WorldCoord;
import com.palmergames.bukkit.towny.utils.PlayerCacheUtil;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefWrapper;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public class AntigriefTowny implements AntigriefWrapper {
@Override
public boolean canBreakBlock(Player player, Block block) {
return PlayerCacheUtil.getCachePermission(player, block.getLocation(), block.getType(), TownyPermission.ActionType.DESTROY);
}
@Override
public boolean canCreateExplosion(Player player, Location location) {
return PlayerCacheUtil.getCachePermission(player, location, Material.TNT, TownyPermission.ActionType.ITEM_USE);
}
@Override
public boolean canPlaceBlock(Player player, Block block) {
return PlayerCacheUtil.getCachePermission(player, block.getLocation(), block.getType(), TownyPermission.ActionType.BUILD);
}
@Override
public boolean canInjure(Player player, LivingEntity victim) {
if(victim instanceof Player) {
try {
Town town = WorldCoord.parseWorldCoord(victim.getLocation()).getTownBlock().getTown();
return town.isPVP();
} catch (Exception ignored) {}
} else {
try {
Town town = WorldCoord.parseWorldCoord(victim.getLocation()).getTownBlock().getTown();
return town.hasMobs();
} catch (Exception ignored) {}
}
return true;
}
@Override
public String getPluginName() {
return "Towny";
}
}

View File

@ -0,0 +1,76 @@
package com.willfp.ecoenchants.integrations.antigrief.plugins;
import com.comphenix.protocol.PacketType;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefWrapper;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public class AntigriefWorldGuard implements AntigriefWrapper {
@Override
public boolean canBreakBlock(Player player, Block block) {
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
if (!query.testState(BukkitAdapter.adapt(block.getLocation()), localPlayer, Flags.BUILD)) {
return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(block.getWorld()));
}
return true;
}
@Override
public boolean canCreateExplosion(Player player, Location location) {
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
if (!query.testState(BukkitAdapter.adapt(location), localPlayer, Flags.OTHER_EXPLOSION)) {
return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(location.getWorld()));
}
return true;
}
@Override
public boolean canPlaceBlock(Player player, Block block) {
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
if (!query.testState(BukkitAdapter.adapt(block.getLocation()), localPlayer, Flags.BLOCK_PLACE)) {
return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(block.getWorld()));
}
return true;
}
@Override
public boolean canInjure(Player player, LivingEntity victim) {
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
if(victim instanceof Player) {
if (!query.testState(BukkitAdapter.adapt(victim.getLocation()), localPlayer, Flags.PVP)) {
return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(player.getWorld()));
}
} else {
if (!query.testState(BukkitAdapter.adapt(victim.getLocation()), localPlayer, Flags.DAMAGE_ANIMALS)) {
return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(player.getWorld()));
}
}
return true;
}
@Override
public String getPluginName() {
return "WorldGuard";
}
}

View File

@ -2,8 +2,9 @@ package com.willfp.ecoenchants.loader;
import com.comphenix.protocol.ProtocolLibrary;
import com.willfp.ecoenchants.Main;
import com.willfp.ecoenchants.anticheat.anticheats.AnticheatAAC;
import com.willfp.ecoenchants.anticheat.anticheats.AnticheatMatrix;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.integrations.anticheat.plugins.AnticheatAAC;
import com.willfp.ecoenchants.integrations.anticheat.plugins.AnticheatMatrix;
import com.willfp.ecoenchants.anvil.AnvilListeners;
import com.willfp.ecoenchants.bstats.Metrics;
import com.willfp.ecoenchants.commands.*;
@ -17,6 +18,8 @@ import com.willfp.ecoenchants.events.entitydeathbyentity.EntityDeathByEntityList
import com.willfp.ecoenchants.events.naturalexpgainevent.NaturalExpGainListeners;
import com.willfp.ecoenchants.extensions.ExtensionManager;
import com.willfp.ecoenchants.grindstone.GrindstoneListeners;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.integrations.antigrief.plugins.*;
import com.willfp.ecoenchants.listeners.EnchantingListeners;
import com.willfp.ecoenchants.listeners.PlayerJoinListener;
import com.willfp.ecoenchants.listeners.VillagerListeners;
@ -103,25 +106,40 @@ public class Loader {
Bukkit.getLogger().info("Loading Integrations...");
Main.hasWG = Bukkit.getPluginManager().isPluginEnabled("WorldGuard");
if(Main.hasWG) Bukkit.getLogger().info("WorldGuard: §aENABLED");
else Bukkit.getLogger().info("WorldGuard: §9DISABLED");
if(Bukkit.getPluginManager().isPluginEnabled("WorldGuard")) {
AntigriefManager.registerAntigrief(new AntigriefWorldGuard());
Bukkit.getLogger().info("WorldGuard: §aENABLED");
} else {
Bukkit.getLogger().info("WorldGuard: §9DISABLED");
}
Main.hasGP = Bukkit.getPluginManager().isPluginEnabled("GriefPrevention");
if(Main.hasGP) Bukkit.getLogger().info("GriefPrevention: §aENABLED");
else Bukkit.getLogger().info("GriefPrevention: §9DISABLED");
if(Bukkit.getPluginManager().isPluginEnabled("GriefPrevention")) {
AntigriefManager.registerAntigrief(new AntigriefGriefPrevention());
Bukkit.getLogger().info("GriefPrevention: §aENABLED");
} else {
Bukkit.getLogger().info("GriefPrevention: §9DISABLED");
}
Main.hasFactionsUUID = Bukkit.getPluginManager().isPluginEnabled("FactionsUUID");
if(Main.hasFactionsUUID) Bukkit.getLogger().info("FactionsUUID: §aENABLED");
else Bukkit.getLogger().info("FactionsUUID: §9DISABLED");
if(Bukkit.getPluginManager().isPluginEnabled("FactionsUUID")) {
AntigriefManager.registerAntigrief(new AntigriefFactionsUUID());
Bukkit.getLogger().info("FactionsUUID: §aENABLED");
} else {
Bukkit.getLogger().info("FactionsUUID: §9DISABLED");
}
Main.hasTowny = Bukkit.getPluginManager().isPluginEnabled("Towny");
if(Main.hasTowny) Bukkit.getLogger().info("Towny: §aENABLED");
else Bukkit.getLogger().info("Towny: §9DISABLED");
if(Bukkit.getPluginManager().isPluginEnabled("Towny")) {
AntigriefManager.registerAntigrief(new AntigriefTowny());
Bukkit.getLogger().info("Towny: §aENABLED");
} else {
Bukkit.getLogger().info("Towny: §9DISABLED");
}
Main.hasLands = Bukkit.getPluginManager().isPluginEnabled("Lands");
if(Main.hasLands) Bukkit.getLogger().info("Lands: §aENABLED");
else Bukkit.getLogger().info("Lands: §9DISABLED");
if(Bukkit.getPluginManager().isPluginEnabled("Lands")) {
AntigriefManager.registerAntigrief(new AntigriefLands());
Bukkit.getLogger().info("Lands: §aENABLED");
} else {
Bukkit.getLogger().info("Lands: §9DISABLED");
}
Main.hasAE = Bukkit.getPluginManager().isPluginEnabled("AdvancedEnchantments");
if(Main.hasAE) Bukkit.getLogger().info("AdvancedEnchantments: §aENABLED");
@ -131,28 +149,28 @@ public class Loader {
Bukkit.getLogger().info("Loading Anticheat Integrations...");
if(Bukkit.getPluginManager().isPluginEnabled("AAC")) {
com.willfp.ecoenchants.anticheat.AnticheatManager.registerAnticheat(new AnticheatAAC());
AnticheatManager.registerAnticheat(new AnticheatAAC());
Bukkit.getLogger().info("AAC: §aENABLED");
} else {
Bukkit.getLogger().info("AAC: §9DISABLED");
}
if(Bukkit.getPluginManager().isPluginEnabled("Matrix")) {
com.willfp.ecoenchants.anticheat.AnticheatManager.registerAnticheat(new AnticheatMatrix());
AnticheatManager.registerAnticheat(new AnticheatMatrix());
Bukkit.getLogger().info("Matrix: §aENABLED");
} else {
Bukkit.getLogger().info("Matrix: §9DISABLED");
}
if(Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus")) {
com.willfp.ecoenchants.anticheat.AnticheatManager.registerAnticheat(new AnticheatAAC());
AnticheatManager.registerAnticheat(new AnticheatAAC());
Bukkit.getLogger().info("NCP: §aENABLED");
} else {
Bukkit.getLogger().info("NCP: §9DISABLED");
}
if(Bukkit.getPluginManager().isPluginEnabled("Spartan")) {
com.willfp.ecoenchants.anticheat.AnticheatManager.registerAnticheat(new AnticheatAAC());
AnticheatManager.registerAnticheat(new AnticheatAAC());
Bukkit.getLogger().info("Spartan: §aENABLED");
} else {
Bukkit.getLogger().info("Spartan: §9DISABLED");

View File

@ -1,331 +0,0 @@
package com.willfp.ecoenchants.util;
import com.massivecraft.factions.*;
import com.massivecraft.factions.perms.PermissibleAction;
import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.towny.object.TownyPermission;
import com.palmergames.bukkit.towny.object.WorldCoord;
import com.palmergames.bukkit.towny.utils.PlayerCacheUtil;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import com.willfp.ecoenchants.Main;
import me.angeschossen.lands.api.integration.LandsIntegration;
import me.angeschossen.lands.api.land.Area;
import me.angeschossen.lands.api.role.enums.RoleSetting;
import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
/**
* Class containing methods for compatibility with land management plugins
*/
public class AntiGrief {
/**
* Can player break block
* @param player The player
* @param block The block
* @return If player can break block
*/
public static boolean canBreakBlock(Player player, Block block) {
if (Main.hasWG) {
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
if (!query.testState(BukkitAdapter.adapt(block.getLocation()), localPlayer, Flags.BUILD)) {
if (!WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(block.getWorld()))) {
return false;
}
}
}
if (Main.hasGP) {
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(block.getLocation(), false, null);
if (claim != null) {
if (claim.allowBreak(player, block.getType()) != null) {
return false;
}
}
}
if (Main.hasFactionsUUID) {
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
FLocation flocation = new FLocation(block.getLocation());
Faction faction = Board.getInstance().getFactionAt(flocation);
if (!faction.hasAccess(fplayer, PermissibleAction.DESTROY)) {
if (!fplayer.isAdminBypassing()) {
return false;
}
}
}
if (Main.hasTowny) {
if (!PlayerCacheUtil.getCachePermission(player, block.getLocation(), block.getType(), TownyPermission.ActionType.DESTROY)) {
return false;
}
}
if (Main.hasLands) {
LandsIntegration landsIntegration = new LandsIntegration(Main.getInstance());
Area area = landsIntegration.getAreaByLoc(block.getLocation());
if (area != null) {
return area.canSetting(player, RoleSetting.BLOCK_BREAK, false);
}
}
return true;
}
/**
* Can player create explosion at location
* @param player The player
* @param location The location
* @return If player can create explosion
*/
public static boolean canCreateExplosion(Player player, Location location) {
if (Main.hasWG) {
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
if (!query.testState(BukkitAdapter.adapt(location), localPlayer, Flags.OTHER_EXPLOSION)) {
if (!WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(location.getWorld()))) {
return false;
}
}
}
if (Main.hasGP) {
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, false, null);
if (claim != null) {
if (!claim.areExplosivesAllowed) {
return false;
}
}
}
if (Main.hasFactionsUUID) {
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
FLocation flocation = new FLocation(location);
Faction faction = Board.getInstance().getFactionAt(flocation);
if (faction.noExplosionsInTerritory()) {
return false;
}
}
if (Main.hasTowny) {
if (!PlayerCacheUtil.getCachePermission(player, location, Material.TNT, TownyPermission.ActionType.ITEM_USE)) {
return false;
}
}
if (Main.hasLands) {
LandsIntegration landsIntegration = new LandsIntegration(Main.getInstance());
Area area = landsIntegration.getAreaByLoc(location);
if (area != null) {
return area.canSetting(player, RoleSetting.BLOCK_IGNITE, false);
}
}
return true;
}
/**
* Can player place block
* @param player The player
* @param block The block
* @return If player can place block
*/
public static boolean canPlaceBlock(Player player, Block block) {
if (Main.hasWG) {
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
if (!query.testState(BukkitAdapter.adapt(block.getLocation()), localPlayer, Flags.BLOCK_PLACE)) {
if (!WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(block.getWorld()))) {
return false;
}
}
}
if (Main.hasGP) {
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(block.getLocation(), false, null);
if (claim != null) {
if (claim.allowBuild(player, block.getType()) != null) {
return false;
}
}
}
if (Main.hasFactionsUUID) {
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
FLocation flocation = new FLocation(block.getLocation());
Faction faction = Board.getInstance().getFactionAt(flocation);
if (!faction.hasAccess(fplayer, PermissibleAction.BUILD)) {
if (!fplayer.isAdminBypassing()) {
return false;
}
}
}
if (Main.hasTowny) {
if (!PlayerCacheUtil.getCachePermission(player, block.getLocation(), block.getType(), TownyPermission.ActionType.BUILD)) {
return false;
}
}
if (Main.hasLands) {
LandsIntegration landsIntegration = new LandsIntegration(Main.getInstance());
Area area = landsIntegration.getAreaByLoc(block.getLocation());
if (area != null) {
return area.canSetting(player, RoleSetting.BLOCK_PLACE, false);
}
}
return true;
}
/**
* Can player injure other player
* @param player The player
* @param victim The victim
* @return If player can injure player
*/
public static boolean canInjurePlayer(Player player, Player victim) {
if (Main.hasWG) {
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
if (!query.testState(BukkitAdapter.adapt(victim.getLocation()), localPlayer, Flags.PVP)) {
if (!WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(player.getWorld()))) {
return false;
}
}
}
if (Main.hasGP) {
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(victim.getLocation(), false, null);
if (claim != null) {
return false;
}
}
if (Main.hasFactionsUUID) {
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
FLocation flocation = new FLocation(victim.getLocation());
Faction faction = Board.getInstance().getFactionAt(flocation);
if (faction.isPeaceful()) {
if (!fplayer.isAdminBypassing()) {
return false;
}
}
}
if (Main.hasTowny) {
try {
Town town = WorldCoord.parseWorldCoord(victim.getLocation()).getTownBlock().getTown();
if (!town.isPVP()) {
return false;
}
} catch (Exception ignored) {}
}
if (Main.hasLands) {
LandsIntegration landsIntegration = new LandsIntegration(Main.getInstance());
Area area = landsIntegration.getAreaByLoc(victim.getLocation());
if (area != null) {
return area.canSetting(player, RoleSetting.ATTACK_PLAYER, false);
}
}
return true;
}
/**
* Can player injure mob
* @param player The player
* @param victim The victim
* @return If player can injure player
*/
public static boolean canInjureMob(Player player, LivingEntity victim) {
if (Main.hasWG) {
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
if (!query.testState(BukkitAdapter.adapt(victim.getLocation()), localPlayer, Flags.DAMAGE_ANIMALS)) {
if (!WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(player.getWorld()))) {
return false;
}
}
}
if (Main.hasGP) {
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(victim.getLocation(), false, null);
if (claim != null) {
if(!claim.ownerID.equals(player.getUniqueId())) {
return false;
}
}
}
if (Main.hasFactionsUUID) {
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
FLocation flocation = new FLocation(victim.getLocation());
Faction faction = Board.getInstance().getFactionAt(flocation);
if (faction.hasAccess(fplayer, PermissibleAction.DESTROY)) {
if (!fplayer.isAdminBypassing()) {
return false;
}
}
}
if (Main.hasTowny) {
try {
Town town = WorldCoord.parseWorldCoord(victim.getLocation()).getTownBlock().getTown();
if (!town.hasMobs()) {
return false;
}
} catch (Exception ignored) {}
}
if (Main.hasLands) {
LandsIntegration landsIntegration = new LandsIntegration(Main.getInstance());
Area area = landsIntegration.getAreaByLoc(victim.getLocation());
if (area != null) {
return area.canSetting(player, RoleSetting.ATTACK_ANIMAL, false);
}
}
return true;
}
/**
* Does player have keep inventory
* @param player The player
* @return If player has keep inventory
*/
public static boolean hasKeepInv(Player player) {
return false;
}
}

View File

@ -6,7 +6,7 @@
<groupId>com.willfp.ecoenchants</groupId>
<artifactId>parent</artifactId>
<version>4.1.0-pre10</version>
<version>4.1.0-pre11</version>
<packaging>pom</packaging>
<name>EcoEnchants Parent</name>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.willfp.ecoenchants</groupId>
<version>4.1.0-pre10</version>
<version>4.1.0-pre11</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -21,7 +21,7 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="API" />
<orderEntry type="library" name="Maven: com.willfp.ecoenchants:API:4.1.0-pre10" level="project" />
<orderEntry type="library" name="Maven: com.willfp.ecoenchants:API:4.1.0-pre11" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.15-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.willfp.ecoenchants</groupId>
<version>4.1.0-pre10</version>
<version>4.1.0-pre11</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -21,7 +21,7 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="API" />
<orderEntry type="library" name="Maven: com.willfp.ecoenchants:API:4.1.0-pre10" level="project" />
<orderEntry type="library" name="Maven: com.willfp.ecoenchants:API:4.1.0-pre11" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.willfp.ecoenchants</groupId>
<version>4.1.0-pre10</version>
<version>4.1.0-pre11</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -12,7 +12,7 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="API" />
<orderEntry type="library" name="Maven: com.willfp.ecoenchants:API:4.1.0-pre10" level="project" />
<orderEntry type="library" name="Maven: com.willfp.ecoenchants:API:4.1.0-pre11" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />