From f730023b428bbc2e87987a7f4e333afc8acb02c1 Mon Sep 17 00:00:00 2001 From: DroppingAnvil Date: Wed, 9 Oct 2019 16:53:32 -0500 Subject: [PATCH] Now 1.7 compatible again --- .../massivecraft/factions/FactionsPlugin.java | 32 ++++++++----------- .../factions/cmd/claim/CmdCorner.java | 6 ++++ .../listeners/FactionsPlayerListener.java | 20 ++++++------ 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/FactionsPlugin.java b/src/main/java/com/massivecraft/factions/FactionsPlugin.java index 6e2d3761..c377316d 100755 --- a/src/main/java/com/massivecraft/factions/FactionsPlugin.java +++ b/src/main/java/com/massivecraft/factions/FactionsPlugin.java @@ -147,18 +147,10 @@ public class FactionsPlugin extends MPlugin { public void onEnable() { log("==== Setup ===="); - - // Vault dependency check. - if (getServer().getPluginManager().getPlugin("Vault") == null) { - log("Vault is not present, the plugin will not run properly."); - getServer().getPluginManager().disablePlugin(instance); - return; - } - int version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]); switch (version) { case 7: - FactionsPlugin.instance.log("Minecraft Version 1.7 found, disabling banners, itemflags inside GUIs, and Titles."); + FactionsPlugin.instance.log("Minecraft Version 1.7 found, disabling banners, itemflags inside GUIs, corners, and Titles."); mc17 = true; break; case 8: @@ -177,6 +169,18 @@ public class FactionsPlugin extends MPlugin { mc114 = true; break; } + //Dependency checks + if (Bukkit.getPluginManager().isPluginEnabled("Vault") && Bukkit.getPluginManager().isPluginEnabled("Essentials")) { + RegisteredServiceProvider rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class); + FactionsPlugin.econ = rsp.getProvider(); + } else { + divider(); + System.out.println("You are missing dependencies!"); + System.out.println("Please verify EssentialsX and Vault are installed!"); + Bukkit.getPluginManager().disablePlugin(instance); + divider(); + return; + } migrateFPlayerLeaders(); log("==== End Setup ===="); @@ -292,16 +296,6 @@ public class FactionsPlugin extends MPlugin { if (!CommodoreProvider.isSupported()) this.getCommand(refCommand).setTabCompleter(this); - if (Bukkit.getPluginManager().isPluginEnabled("Vault") && FactionsPlugin.this.getServer().getServicesManager().getRegistration(Essentials.class) != null) { - RegisteredServiceProvider rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class); - FactionsPlugin.econ = rsp.getProvider(); - } else { - divider(); - System.out.println("You are missing dependencies!"); - System.out.println("Please verify EssentialsX and Vault are installed!"); - Bukkit.getPluginManager().disablePlugin(this); - } - if (getDescription().getFullName().contains("BETA")) { divider(); System.out.println("You are using a BETA version of the plugin!"); diff --git a/src/main/java/com/massivecraft/factions/cmd/claim/CmdCorner.java b/src/main/java/com/massivecraft/factions/cmd/claim/CmdCorner.java index e1641790..bb51020b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/claim/CmdCorner.java +++ b/src/main/java/com/massivecraft/factions/cmd/claim/CmdCorner.java @@ -9,6 +9,8 @@ import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.util.CornerTask; import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.util.TL; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.Comparator; @@ -29,6 +31,10 @@ public class CmdCorner extends FCommand { @Override public void perform(CommandContext context) { + if (FactionsPlugin.getInstance().mc17) { + context.player.sendMessage(ChatColor.RED + "This command is disabled!"); + return; + } FLocation to = new FLocation(context.player.getLocation()); if (FactionsPlugin.getInstance().getFactionsPlayerListener().getCorners().contains(to)) { Faction cornerAt = Board.getInstance().getFactionAt(to); diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index ad5e479a..43c02e1c 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -54,18 +54,20 @@ public class FactionsPlayerListener implements Listener { private Map interactSpammers = new HashMap<>(); public FactionsPlayerListener() { - this.corners = new HashSet<>(); for (Player player : FactionsPlugin.getInstance().getServer().getOnlinePlayers()) { initPlayer(player); } - for (World world : FactionsPlugin.getInstance().getServer().getWorlds()) { - WorldBorder border = world.getWorldBorder(); - if (border != null) { - int cornerCoord = (int) ((border.getSize() - 1.0) / 2.0); - this.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(cornerCoord), FLocation.blockToChunk(cornerCoord))); - this.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(cornerCoord), FLocation.blockToChunk(-cornerCoord))); - this.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(-cornerCoord), FLocation.blockToChunk(cornerCoord))); - this.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(-cornerCoord), FLocation.blockToChunk(-cornerCoord))); + if (!FactionsPlugin.getInstance().mc17) { + this.corners = new HashSet<>(); + for (World world : FactionsPlugin.getInstance().getServer().getWorlds()) { + WorldBorder border = world.getWorldBorder(); + if (border != null) { + int cornerCoord = (int) ((border.getSize() - 1.0) / 2.0); + this.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(cornerCoord), FLocation.blockToChunk(cornerCoord))); + this.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(cornerCoord), FLocation.blockToChunk(-cornerCoord))); + this.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(-cornerCoord), FLocation.blockToChunk(cornerCoord))); + this.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(-cornerCoord), FLocation.blockToChunk(-cornerCoord))); + } } } }