2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod;
|
2012-12-09 03:42:29 +00:00
|
|
|
|
2017-12-23 04:07:36 +00:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2020-11-03 05:33:04 +00:00
|
|
|
import net.minecraft.server.v1_16_R3.EntityPlayer;
|
|
|
|
import net.minecraft.server.v1_16_R3.MinecraftServer;
|
2017-12-23 04:07:36 +00:00
|
|
|
import org.bukkit.Bukkit;
|
2020-11-03 05:33:04 +00:00
|
|
|
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
|
2012-12-09 03:42:29 +00:00
|
|
|
|
2016-03-01 16:47:01 +00:00
|
|
|
public class ServerInterface extends FreedomService
|
2012-12-09 03:42:29 +00:00
|
|
|
{
|
2020-11-03 05:33:04 +00:00
|
|
|
public static final String COMPILE_NMS_VERSION = "v1_16_R3";
|
2012-12-09 03:42:29 +00:00
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
public static void warnVersion()
|
|
|
|
{
|
2017-12-28 05:50:39 +00:00
|
|
|
final String nms = FUtil.getNMSVersion();
|
2016-03-06 15:56:15 +00:00
|
|
|
|
|
|
|
if (!COMPILE_NMS_VERSION.equals(nms))
|
|
|
|
{
|
|
|
|
FLog.warning(TotalFreedomMod.pluginName + " is compiled for " + COMPILE_NMS_VERSION + " but the server is running version " + nms + "!");
|
|
|
|
FLog.warning("This might result in unexpected behaviour!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-25 19:46:43 +00:00
|
|
|
@Override
|
|
|
|
public void onStart()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStop()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-12-23 04:07:36 +00:00
|
|
|
public void setOnlineMode(boolean mode)
|
|
|
|
{
|
2019-07-17 19:35:36 +00:00
|
|
|
getServer().setOnlineMode(mode);
|
2017-12-23 04:07:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
2018-07-31 07:01:29 +00:00
|
|
|
return ((CraftServer)Bukkit.getServer()).getServer();
|
2017-12-23 04:07:36 +00:00
|
|
|
}
|
2012-12-09 03:42:29 +00:00
|
|
|
|
|
|
|
}
|