Now 1.7 compatible again

This commit is contained in:
DroppingAnvil 2019-10-09 16:53:32 -05:00
parent 2b0bfae44c
commit f730023b42
3 changed files with 30 additions and 28 deletions

View File

@ -147,18 +147,10 @@ public class FactionsPlugin extends MPlugin {
public void onEnable() { public void onEnable() {
log("==== Setup ===="); 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]); int version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]);
switch (version) { switch (version) {
case 7: 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; mc17 = true;
break; break;
case 8: case 8:
@ -177,6 +169,18 @@ public class FactionsPlugin extends MPlugin {
mc114 = true; mc114 = true;
break; break;
} }
//Dependency checks
if (Bukkit.getPluginManager().isPluginEnabled("Vault") && Bukkit.getPluginManager().isPluginEnabled("Essentials")) {
RegisteredServiceProvider<Economy> 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(); migrateFPlayerLeaders();
log("==== End Setup ===="); log("==== End Setup ====");
@ -292,16 +296,6 @@ public class FactionsPlugin extends MPlugin {
if (!CommodoreProvider.isSupported()) this.getCommand(refCommand).setTabCompleter(this); if (!CommodoreProvider.isSupported()) this.getCommand(refCommand).setTabCompleter(this);
if (Bukkit.getPluginManager().isPluginEnabled("Vault") && FactionsPlugin.this.getServer().getServicesManager().getRegistration(Essentials.class) != null) {
RegisteredServiceProvider<Economy> 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")) { if (getDescription().getFullName().contains("BETA")) {
divider(); divider();
System.out.println("You are using a BETA version of the plugin!"); System.out.println("You are using a BETA version of the plugin!");

View File

@ -9,6 +9,8 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.CornerTask; import com.massivecraft.factions.util.CornerTask;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
@ -29,6 +31,10 @@ public class CmdCorner extends FCommand {
@Override @Override
public void perform(CommandContext context) { 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()); FLocation to = new FLocation(context.player.getLocation());
if (FactionsPlugin.getInstance().getFactionsPlayerListener().getCorners().contains(to)) { if (FactionsPlugin.getInstance().getFactionsPlayerListener().getCorners().contains(to)) {
Faction cornerAt = Board.getInstance().getFactionAt(to); Faction cornerAt = Board.getInstance().getFactionAt(to);

View File

@ -54,18 +54,20 @@ public class FactionsPlayerListener implements Listener {
private Map<String, InteractAttemptSpam> interactSpammers = new HashMap<>(); private Map<String, InteractAttemptSpam> interactSpammers = new HashMap<>();
public FactionsPlayerListener() { public FactionsPlayerListener() {
this.corners = new HashSet<>();
for (Player player : FactionsPlugin.getInstance().getServer().getOnlinePlayers()) { for (Player player : FactionsPlugin.getInstance().getServer().getOnlinePlayers()) {
initPlayer(player); initPlayer(player);
} }
for (World world : FactionsPlugin.getInstance().getServer().getWorlds()) { if (!FactionsPlugin.getInstance().mc17) {
WorldBorder border = world.getWorldBorder(); this.corners = new HashSet<>();
if (border != null) { for (World world : FactionsPlugin.getInstance().getServer().getWorlds()) {
int cornerCoord = (int) ((border.getSize() - 1.0) / 2.0); WorldBorder border = world.getWorldBorder();
this.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(cornerCoord), FLocation.blockToChunk(cornerCoord))); if (border != null) {
this.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(cornerCoord), FLocation.blockToChunk(-cornerCoord))); 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)));
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)));
}
} }
} }
} }