Removed dependency to Craftbukkit and Spigot server code.

This breaks whitelist and onlinemode toggle.
This commit is contained in:
StevenLawson 2017-07-25 21:07:22 -04:00
parent e16714ea6c
commit 655d7471dc
6 changed files with 106 additions and 109 deletions

45
pom.xml
View File

@ -11,7 +11,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tfm.build.version>${project.version}</tfm.build.version> <tfm.build.version>${project.version}</tfm.build.version>
<tfm.build.codename>Electrum</tfm.build.codename> <tfm.build.codename>Electrum</tfm.build.codename>
<!-- <tfm.build.number>${maven.buildnumber}</tfm.build.number> --> <!-- <tfm.build.number>${maven.buildnumber}</tfm.build.number> -->
<tfm.build.date>${maven.build.timestamp}</tfm.build.date> <tfm.build.date>${maven.build.timestamp}</tfm.build.date>
<tfm.build.author>${buildAuthor}</tfm.build.author> <tfm.build.author>${buildAuthor}</tfm.build.author>
<tfm.build.head>${buildHead}</tfm.build.head> <tfm.build.head>${buildHead}</tfm.build.head>
@ -54,10 +54,10 @@
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository> </repository>
<repository> <!-- <repository>
<id>elmakers-repo</id> <id>elmakers-repo</id>
<url>http://maven.elmakers.com/repository/</url> <url>http://maven.elmakers.com/repository/</url>
</repository> </repository>-->
<repository> <repository>
<id>sk89q-snapshots</id> <id>sk89q-snapshots</id>
<url>http://maven.sk89q.com/artifactory/repo</url> <url>http://maven.sk89q.com/artifactory/repo</url>
@ -65,6 +65,17 @@
</repositories> </repositories>
<dependencies> <dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
@ -74,8 +85,9 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot-api</artifactId>
<version>1.12-R0.1-SNAPSHOT</version> <version>1.12-pre5-SNAPSHOT</version>
<scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -90,6 +102,12 @@
<version>4.5-pre1</version> <version>4.5-pre1</version>
</dependency> </dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>Essentials</artifactId>
<version>2.13.1</version>
</dependency>
<dependency> <dependency>
<groupId>com.github.TotalFreedom.TF-WorldEdit</groupId> <groupId>com.github.TotalFreedom.TF-WorldEdit</groupId>
<artifactId>worldedit-bukkit</artifactId> <artifactId>worldedit-bukkit</artifactId>
@ -102,23 +120,6 @@
<version>6.1.0-TF</version> <version>6.1.0-TF</version>
</dependency> </dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>Essentials</artifactId>
<version>2.13.1</version>
</dependency>
<!-- <dependency>
<groupId>com.github.TotalFreedom</groupId>
<artifactId>TF-LibsDisguises</artifactId>
<version>-SNAPSHOT</version>
</dependency> -->
</dependencies> </dependencies>
<build> <build>

View File

@ -168,15 +168,15 @@ public class LoginProcess extends FreedomService
return; return;
} }
// Whitelist // // Whitelist
if (plugin.si.isWhitelisted()) // if (plugin.si.isWhitelisted())
{ // {
if (!plugin.si.getWhitelisted().contains(username.toLowerCase())) // if (!plugin.si.getWhitelisted().contains(username.toLowerCase()))
{ // {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server."); // event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
return; // return;
} // }
} // }
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)

View File

@ -1,14 +1,7 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import java.util.Arrays;
import java.util.List;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; 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 public class ServerInterface extends FreedomService
{ {
@ -41,52 +34,52 @@ public class ServerInterface extends FreedomService
} }
} }
public void setOnlineMode(boolean mode) // public void setOnlineMode(boolean mode)
{ // {
final PropertyManager manager = getServer().getPropertyManager(); // final PropertyManager manager = getServer().getPropertyManager();
manager.setProperty("online-mode", mode); // manager.setProperty("online-mode", mode);
manager.savePropertiesFile(); // manager.savePropertiesFile();
} // }
//
public int purgeWhitelist() // public int purgeWhitelist()
{ // {
String[] whitelisted = getServer().getPlayerList().getWhitelisted(); // String[] whitelisted = getServer().getPlayerList().getWhitelisted();
int size = whitelisted.length; // int size = whitelisted.length;
for (EntityPlayer player : getServer().getPlayerList().players) // for (EntityPlayer player : getServer().getPlayerList().players)
{ // {
getServer().getPlayerList().getWhitelist().remove(player.getProfile()); // getServer().getPlayerList().getWhitelist().remove(player.getProfile());
} // }
//
try // try
{ // {
getServer().getPlayerList().getWhitelist().save(); // getServer().getPlayerList().getWhitelist().save();
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
FLog.warning("Could not purge the whitelist!"); // FLog.warning("Could not purge the whitelist!");
FLog.warning(ex); // FLog.warning(ex);
} // }
return size; // return size;
} // }
//
public boolean isWhitelisted() // public boolean isWhitelisted()
{ // {
return getServer().getPlayerList().getHasWhitelist(); // return getServer().getPlayerList().getHasWhitelist();
} // }
//
public List<?> getWhitelisted() // public List<?> getWhitelisted()
{ // {
return Arrays.asList(getServer().getPlayerList().getWhitelisted()); // return Arrays.asList(getServer().getPlayerList().getWhitelisted());
} // }
//
public String getVersion() // public String getVersion()
{ // {
return getServer().getVersion(); // return getServer().getVersion();
} // }
//
private MinecraftServer getServer() // private MinecraftServer getServer()
{ // {
return ((CraftServer) Bukkit.getServer()).getServer(); // return ((CraftServer) Bukkit.getServer()).getServer();
} // }
} }

View File

@ -55,7 +55,8 @@ public class ServerPing extends FreedomService
return; 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 = baseMotd.replace("\\n", "\n");
baseMotd = FUtil.colorize(baseMotd); baseMotd = FUtil.colorize(baseMotd);

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -44,26 +43,27 @@ public class Command_onlinemode extends FreedomCommand
return false; return false;
} }
try // try
{ // {
plugin.si.setOnlineMode(onlineMode); // plugin.si.setOnlineMode(onlineMode);
//
if (onlineMode) // if (onlineMode)
{ // {
for (Player player : server.getOnlinePlayers()) // for (Player player : server.getOnlinePlayers())
{ // {
player.kickPlayer("Server is activating \"online-mode=true\". Please reconnect."); // player.kickPlayer("Server is activating \"online-mode=true\". Please reconnect.");
} // }
} // }
//
FUtil.adminAction(sender.getName(), "Turning player validation " + (onlineMode ? "on" : "off") + ".", true); // FUtil.adminAction(sender.getName(), "Turning player validation " + (onlineMode ? "on" : "off") + ".", true);
//
server.reload(); // server.reload();
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
FLog.severe(ex); // FLog.severe(ex);
} // }
FUtil.adminAction(sender.getName(), "Online-Mode toggling is temporarily disabled.", true);
} }
return true; return true;

View File

@ -158,8 +158,10 @@ public class Command_whitelist extends FreedomCommand
//purge //purge
if (args[0].equalsIgnoreCase("purge")) if (args[0].equalsIgnoreCase("purge"))
{ {
FUtil.adminAction(sender.getName(), "Removing all players from the whitelist.", false); // FUtil.adminAction(sender.getName(), "Removing all players from the whitelist.", false);
msg("Removed " + plugin.si.purgeWhitelist() + " players from the whitelist."); // msg("Removed " + plugin.si.purgeWhitelist() + " players from the whitelist.");
FUtil.adminAction(sender.getName(), "Whitelist purging is temporarily disabled.", true);
return true; return true;
} }