Merge pull request #24 from DroppingAnvil/1.6.x

Now 1.7 compatible again
This commit is contained in:
Driftay 2019-10-10 01:06:36 -04:00 committed by GitHub
commit f6fc529898
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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,10 +54,11 @@ 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);
} }
if (!FactionsPlugin.getInstance().mc17) {
this.corners = new HashSet<>();
for (World world : FactionsPlugin.getInstance().getServer().getWorlds()) { for (World world : FactionsPlugin.getInstance().getServer().getWorlds()) {
WorldBorder border = world.getWorldBorder(); WorldBorder border = world.getWorldBorder();
if (border != null) { if (border != null) {
@ -69,6 +70,7 @@ public class FactionsPlayerListener implements Listener {
} }
} }
} }
}
public static Boolean isSystemFaction(Faction faction) { public static Boolean isSystemFaction(Faction faction) {
return faction.isSafeZone() || return faction.isSafeZone() ||