mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-12-26 20:27:38 +01:00
Added support for KingdomsX
This commit is contained in:
parent
f99c6dbf62
commit
edfb1b40c7
@ -189,6 +189,12 @@
|
||||
<version>1.6.9.5-U0.5.13</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kingdoms</groupId>
|
||||
<artifactId>kingdoms</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.TownyAdvanced</groupId>
|
||||
<artifactId>Towny</artifactId>
|
||||
|
@ -11,12 +11,16 @@ import java.util.Set;
|
||||
public class AnticheatManager {
|
||||
private static final Set<AnticheatWrapper> anticheats = new HashSet<>();
|
||||
|
||||
public static void registerAnticheat(AnticheatWrapper anticheat) {
|
||||
if(anticheat instanceof Listener) {
|
||||
Bukkit.getPluginManager().registerEvents((Listener) anticheat, EcoEnchantsPlugin.getInstance());
|
||||
}
|
||||
public static boolean registerIfPresent(AnticheatWrapper anticheat) {
|
||||
if(Bukkit.getPluginManager().isPluginEnabled(anticheat.getPluginName())) {
|
||||
if(anticheat instanceof Listener) {
|
||||
Bukkit.getPluginManager().registerEvents((Listener) anticheat, EcoEnchantsPlugin.getInstance());
|
||||
}
|
||||
|
||||
anticheats.add(anticheat);
|
||||
anticheats.add(anticheat);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void exemptPlayer(Player player) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.willfp.ecoenchants.integrations.antigrief;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -11,8 +12,12 @@ import java.util.Set;
|
||||
public class AntigriefManager {
|
||||
private static final Set<AntigriefWrapper> antigriefs = new HashSet<>();
|
||||
|
||||
public static void registerAntigrief(AntigriefWrapper antigrief) {
|
||||
antigriefs.add(antigrief);
|
||||
public static boolean registerIfPresent(AntigriefWrapper antigrief) {
|
||||
if(Bukkit.getPluginManager().isPluginEnabled(antigrief.getPluginName())) {
|
||||
antigriefs.add(antigrief);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,63 @@
|
||||
package com.willfp.ecoenchants.integrations.antigrief.plugins;
|
||||
|
||||
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;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.kingdoms.constants.kingdom.Kingdom;
|
||||
import org.kingdoms.constants.land.Land;
|
||||
import org.kingdoms.constants.player.KingdomPlayer;
|
||||
import org.kingdoms.managers.PvPManager;
|
||||
import org.kingdoms.managers.land.LandManager;
|
||||
|
||||
public final class AntigriefKingdomsX implements AntigriefWrapper {
|
||||
private final LandManager landManager = new LandManager();
|
||||
|
||||
@Override
|
||||
public boolean canBreakBlock(Player player, Block block) {
|
||||
BlockBreakEvent event = new BlockBreakEvent(block, player);
|
||||
landManager.onBreak(event);
|
||||
return !event.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCreateExplosion(Player player, Location location) {
|
||||
Land land = Land.getLand(location);
|
||||
if (land == null) return true;
|
||||
if(!land.isClaimed()) return true;
|
||||
|
||||
Kingdom kingdom = land.getKingdom();
|
||||
return kingdom.getKingdomMembers().contains(KingdomPlayer.getKingdomPlayer(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlock(Player player, Block block) {
|
||||
Block placedOn = block.getRelative(0, -1, 0);
|
||||
BlockPlaceEvent event = new BlockPlaceEvent(block, block.getState(), placedOn, player.getInventory().getItemInMainHand(), player, true, EquipmentSlot.HAND);
|
||||
landManager.onPlace(event);
|
||||
return !event.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInjure(Player player, LivingEntity victim) {
|
||||
if(victim instanceof Player) {
|
||||
return PvPManager.canFight(player, (Player) victim);
|
||||
} else {
|
||||
Land land = Land.getLand(victim.getLocation());
|
||||
if (land == null) return true;
|
||||
if(!land.isClaimed()) return true;
|
||||
|
||||
Kingdom kingdom = land.getKingdom();
|
||||
return kingdom.getKingdomMembers().contains(KingdomPlayer.getKingdomPlayer(player));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "KingdomsX";
|
||||
}
|
||||
}
|
@ -1,13 +1,19 @@
|
||||
package com.willfp.ecoenchants.integrations.essentials;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class EssentialsManager {
|
||||
private static final Set<EssentialsWrapper> registered = new HashSet<>();
|
||||
|
||||
public static void registerEssentials(EssentialsWrapper essentials) {
|
||||
registered.add(essentials);
|
||||
public static boolean registerIfPresent(EssentialsWrapper essentials) {
|
||||
if(Bukkit.getPluginManager().isPluginEnabled(essentials.getPluginName())) {
|
||||
registered.add(essentials);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void registerEnchantments() {
|
||||
|
@ -320,72 +320,67 @@ public class Loader {
|
||||
Logger.info("");
|
||||
Logger.info("Loading Integrations...");
|
||||
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("WorldGuard")) {
|
||||
AntigriefManager.registerAntigrief(new AntigriefWorldGuard());
|
||||
if(AntigriefManager.registerIfPresent(new AntigriefWorldGuard())) {
|
||||
Logger.info("WorldGuard: §aENABLED");
|
||||
} else {
|
||||
Logger.info("WorldGuard: §9DISABLED");
|
||||
}
|
||||
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("GriefPrevention")) {
|
||||
AntigriefManager.registerAntigrief(new AntigriefGriefPrevention());
|
||||
Logger.info("GriefPrevention: §aENABLED");
|
||||
} else {
|
||||
Logger.info("GriefPrevention: §9DISABLED");
|
||||
}
|
||||
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("FactionsUUID")) {
|
||||
AntigriefManager.registerAntigrief(new AntigriefFactionsUUID());
|
||||
if(AntigriefManager.registerIfPresent(new AntigriefFactionsUUID())) {
|
||||
Logger.info("FactionsUUID: §aENABLED");
|
||||
} else {
|
||||
Logger.info("FactionsUUID: §9DISABLED");
|
||||
}
|
||||
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("Towny")) {
|
||||
AntigriefManager.registerAntigrief(new AntigriefTowny());
|
||||
Logger.info("Towny: §aENABLED");
|
||||
if(AntigriefManager.registerIfPresent(new AntigriefGriefPrevention())) {
|
||||
Logger.info("GriefPrevention: §aENABLED");
|
||||
} else {
|
||||
Logger.info("Towny: §9DISABLED");
|
||||
Logger.info("GriefPrevention: §9DISABLED");
|
||||
}
|
||||
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("Lands")) {
|
||||
AntigriefManager.registerAntigrief(new AntigriefLands());
|
||||
if(AntigriefManager.registerIfPresent(new AntigriefKingdomsX())) {
|
||||
Logger.info("KingdomsX: §aENABLED");
|
||||
} else {
|
||||
Logger.info("KingdomsX: §9DISABLED");
|
||||
}
|
||||
|
||||
if(AntigriefManager.registerIfPresent(new AntigriefLands())) {
|
||||
Logger.info("Lands: §aENABLED");
|
||||
} else {
|
||||
Logger.info("Lands: §9DISABLED");
|
||||
}
|
||||
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("Essentials")) {
|
||||
EssentialsManager.registerEssentials(new IntegrationEssentials());
|
||||
if(AntigriefManager.registerIfPresent(new AntigriefTowny())) {
|
||||
Logger.info("Towny: §aENABLED");
|
||||
} else {
|
||||
Logger.info("Towny: §9DISABLED");
|
||||
}
|
||||
|
||||
if(EssentialsManager.registerIfPresent(new IntegrationEssentials())) {
|
||||
Logger.info("Essentials: §aENABLED");
|
||||
EssentialsManager.registerEnchantments();
|
||||
} else {
|
||||
Logger.info("Essentials: §9DISABLED");
|
||||
}
|
||||
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("AAC")) {
|
||||
AnticheatManager.registerAnticheat(new AnticheatAAC());
|
||||
if(AnticheatManager.registerIfPresent(new AnticheatAAC())) {
|
||||
Logger.info("AAC: §aENABLED");
|
||||
} else {
|
||||
Logger.info("AAC: §9DISABLED");
|
||||
}
|
||||
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("Matrix")) {
|
||||
AnticheatManager.registerAnticheat(new AnticheatMatrix());
|
||||
if(AnticheatManager.registerIfPresent(new AnticheatMatrix())) {
|
||||
Logger.info("Matrix: §aENABLED");
|
||||
} else {
|
||||
Logger.info("Matrix: §9DISABLED");
|
||||
}
|
||||
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus")) {
|
||||
AnticheatManager.registerAnticheat(new AnticheatNCP());
|
||||
if(AnticheatManager.registerIfPresent(new AnticheatNCP())) {
|
||||
Logger.info("NCP: §aENABLED");
|
||||
} else {
|
||||
Logger.info("NCP: §9DISABLED");
|
||||
}
|
||||
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("Spartan")) {
|
||||
AnticheatManager.registerAnticheat(new AnticheatSpartan());
|
||||
if(AnticheatManager.registerIfPresent(new AnticheatSpartan())) {
|
||||
Logger.info("Spartan: §aENABLED");
|
||||
} else {
|
||||
Logger.info("Spartan: §9DISABLED");
|
||||
|
@ -13,6 +13,7 @@ softdepend:
|
||||
- Towny
|
||||
- FactionsUUID
|
||||
- Lands
|
||||
- KingdomsX
|
||||
- NoCheatPlus
|
||||
- AAC
|
||||
- Matrix
|
||||
|
BIN
lib/Kingdoms-1.9.2.jar
Normal file
BIN
lib/Kingdoms-1.9.2.jar
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user