From 655d7471dcf2073cfb87df7c3e533b2ed46f9b15 Mon Sep 17 00:00:00 2001 From: StevenLawson Date: Tue, 25 Jul 2017 21:07:22 -0400 Subject: [PATCH] Removed dependency to Craftbukkit and Spigot server code. This breaks whitelist and onlinemode toggle. --- pom.xml | 45 ++++---- .../totalfreedommod/LoginProcess.java | 18 ++-- .../totalfreedommod/ServerInterface.java | 101 ++++++++---------- .../totalfreedommod/ServerPing.java | 3 +- .../command/Command_onlinemode.java | 42 ++++---- .../command/Command_whitelist.java | 6 +- 6 files changed, 106 insertions(+), 109 deletions(-) diff --git a/pom.xml b/pom.xml index b07aaaca..2b392006 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ UTF-8 ${project.version} Electrum - + ${maven.build.timestamp} ${buildAuthor} ${buildHead} @@ -54,10 +54,10 @@ spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - + sk89q-snapshots http://maven.sk89q.com/artifactory/repo @@ -65,6 +65,17 @@ + + org.apache.commons + commons-lang3 + 3.6 + + + + commons-io + commons-io + 2.5 + org.projectlombok @@ -74,8 +85,9 @@ org.spigotmc - spigot - 1.12-R0.1-SNAPSHOT + spigot-api + 1.12-pre5-SNAPSHOT + compile @@ -90,6 +102,12 @@ 4.5-pre1 + + net.ess3 + Essentials + 2.13.1 + + com.github.TotalFreedom.TF-WorldEdit worldedit-bukkit @@ -102,23 +120,6 @@ 6.1.0-TF - - org.bukkit - craftbukkit - 1.12-R0.1-SNAPSHOT - - - - net.ess3 - Essentials - 2.13.1 - - - diff --git a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java index 9efa98e3..67469bdf 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java @@ -168,15 +168,15 @@ public class LoginProcess extends FreedomService return; } - // Whitelist - if (plugin.si.isWhitelisted()) - { - if (!plugin.si.getWhitelisted().contains(username.toLowerCase())) - { - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server."); - return; - } - } +// // Whitelist +// if (plugin.si.isWhitelisted()) +// { +// if (!plugin.si.getWhitelisted().contains(username.toLowerCase())) +// { +// event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server."); +// return; +// } +// } } @EventHandler(priority = EventPriority.MONITOR) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/ServerInterface.java b/src/main/java/me/totalfreedom/totalfreedommod/ServerInterface.java index d050790c..90df9edf 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/ServerInterface.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/ServerInterface.java @@ -1,14 +1,7 @@ package me.totalfreedom.totalfreedommod; -import java.util.Arrays; -import java.util.List; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; -import net.minecraft.server.v1_12_R1.EntityPlayer; -import net.minecraft.server.v1_12_R1.MinecraftServer; -import net.minecraft.server.v1_12_R1.PropertyManager; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_12_R1.CraftServer; public class ServerInterface extends FreedomService { @@ -41,52 +34,52 @@ public class ServerInterface extends FreedomService } } - public void setOnlineMode(boolean mode) - { - final PropertyManager manager = getServer().getPropertyManager(); - manager.setProperty("online-mode", mode); - manager.savePropertiesFile(); - } - - public int purgeWhitelist() - { - String[] whitelisted = getServer().getPlayerList().getWhitelisted(); - int size = whitelisted.length; - for (EntityPlayer player : getServer().getPlayerList().players) - { - getServer().getPlayerList().getWhitelist().remove(player.getProfile()); - } - - try - { - getServer().getPlayerList().getWhitelist().save(); - } - catch (Exception ex) - { - FLog.warning("Could not purge the whitelist!"); - FLog.warning(ex); - } - return size; - } - - public boolean isWhitelisted() - { - return getServer().getPlayerList().getHasWhitelist(); - } - - public List getWhitelisted() - { - return Arrays.asList(getServer().getPlayerList().getWhitelisted()); - } - - public String getVersion() - { - return getServer().getVersion(); - } - - private MinecraftServer getServer() - { - return ((CraftServer) Bukkit.getServer()).getServer(); - } +// public void setOnlineMode(boolean mode) +// { +// final PropertyManager manager = getServer().getPropertyManager(); +// manager.setProperty("online-mode", mode); +// manager.savePropertiesFile(); +// } +// +// public int purgeWhitelist() +// { +// String[] whitelisted = getServer().getPlayerList().getWhitelisted(); +// int size = whitelisted.length; +// for (EntityPlayer player : getServer().getPlayerList().players) +// { +// getServer().getPlayerList().getWhitelist().remove(player.getProfile()); +// } +// +// try +// { +// getServer().getPlayerList().getWhitelist().save(); +// } +// catch (Exception ex) +// { +// FLog.warning("Could not purge the whitelist!"); +// FLog.warning(ex); +// } +// return size; +// } +// +// public boolean isWhitelisted() +// { +// return getServer().getPlayerList().getHasWhitelist(); +// } +// +// public List getWhitelisted() +// { +// return Arrays.asList(getServer().getPlayerList().getWhitelisted()); +// } +// +// public String getVersion() +// { +// return getServer().getVersion(); +// } +// +// private MinecraftServer getServer() +// { +// return ((CraftServer) Bukkit.getServer()).getServer(); +// } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java b/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java index 1c500838..8bd6748f 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java @@ -55,7 +55,8 @@ public class ServerPing extends FreedomService return; } - String baseMotd = ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", plugin.si.getVersion()); +// String baseMotd = ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", plugin.si.getVersion()); + String baseMotd = ConfigEntry.SERVER_MOTD.getString(); baseMotd = baseMotd.replace("\\n", "\n"); baseMotd = FUtil.colorize(baseMotd); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_onlinemode.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_onlinemode.java index df6884e1..199f8e8f 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_onlinemode.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_onlinemode.java @@ -1,7 +1,6 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -44,26 +43,27 @@ public class Command_onlinemode extends FreedomCommand return false; } - try - { - plugin.si.setOnlineMode(onlineMode); - - if (onlineMode) - { - for (Player player : server.getOnlinePlayers()) - { - player.kickPlayer("Server is activating \"online-mode=true\". Please reconnect."); - } - } - - FUtil.adminAction(sender.getName(), "Turning player validation " + (onlineMode ? "on" : "off") + ".", true); - - server.reload(); - } - catch (Exception ex) - { - FLog.severe(ex); - } +// try +// { +// plugin.si.setOnlineMode(onlineMode); +// +// if (onlineMode) +// { +// for (Player player : server.getOnlinePlayers()) +// { +// player.kickPlayer("Server is activating \"online-mode=true\". Please reconnect."); +// } +// } +// +// FUtil.adminAction(sender.getName(), "Turning player validation " + (onlineMode ? "on" : "off") + ".", true); +// +// server.reload(); +// } +// catch (Exception ex) +// { +// FLog.severe(ex); +// } + FUtil.adminAction(sender.getName(), "Online-Mode toggling is temporarily disabled.", true); } return true; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java index e8cc7dc2..fe8cc084 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java @@ -158,8 +158,10 @@ public class Command_whitelist extends FreedomCommand //purge if (args[0].equalsIgnoreCase("purge")) { - FUtil.adminAction(sender.getName(), "Removing all players from the whitelist.", false); - msg("Removed " + plugin.si.purgeWhitelist() + " players from the whitelist."); +// FUtil.adminAction(sender.getName(), "Removing all players from the whitelist.", false); +// msg("Removed " + plugin.si.purgeWhitelist() + " players from the whitelist."); + + FUtil.adminAction(sender.getName(), "Whitelist purging is temporarily disabled.", true); return true; }