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>
<tfm.build.version>${project.version}</tfm.build.version>
<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.author>${buildAuthor}</tfm.build.author>
<tfm.build.head>${buildHead}</tfm.build.head>
@ -54,10 +54,10 @@
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<!-- <repository>
<id>elmakers-repo</id>
<url>http://maven.elmakers.com/repository/</url>
</repository>
</repository>-->
<repository>
<id>sk89q-snapshots</id>
<url>http://maven.sk89q.com/artifactory/repo</url>
@ -65,6 +65,17 @@
</repositories>
<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>
<groupId>org.projectlombok</groupId>
@ -74,8 +85,9 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<artifactId>spigot-api</artifactId>
<version>1.12-pre5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
@ -90,6 +102,12 @@
<version>4.5-pre1</version>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>Essentials</artifactId>
<version>2.13.1</version>
</dependency>
<dependency>
<groupId>com.github.TotalFreedom.TF-WorldEdit</groupId>
<artifactId>worldedit-bukkit</artifactId>
@ -102,23 +120,6 @@
<version>6.1.0-TF</version>
</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>
<build>

View File

@ -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)

View File

@ -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();
// }
}

View File

@ -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);

View File

@ -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;

View File

@ -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;
}