TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/ServerInterface.java

74 lines
1.9 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.util.FLog;
import java.util.Arrays;
import java.util.List;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.PropertyManager;
import net.pravian.aero.component.service.AbstractService;
public class ServerInterface extends AbstractService<TotalFreedomMod>
{
public static final String COMPILE_NMS_VERSION = "v1_8_R3";
public ServerInterface(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
public void setOnlineMode(boolean mode)
{
final PropertyManager manager = MinecraftServer.getServer().getPropertyManager();
manager.setProperty("online-mode", mode);
manager.savePropertiesFile();
}
public int purgeWhitelist()
{
String[] whitelisted = MinecraftServer.getServer().getPlayerList().getWhitelisted();
int size = whitelisted.length;
for (EntityPlayer player : MinecraftServer.getServer().getPlayerList().players)
{
2015-04-26 18:43:37 +00:00
MinecraftServer.getServer().getPlayerList().getWhitelist().remove(player.getProfile());
}
2014-04-17 16:29:08 +00:00
try
{
MinecraftServer.getServer().getPlayerList().getWhitelist().save();
}
catch (Exception ex)
{
FLog.warning("Could not purge the whitelist!");
FLog.warning(ex);
2014-04-17 16:29:08 +00:00
}
return size;
}
public boolean isWhitelisted()
{
2015-04-26 18:43:37 +00:00
return MinecraftServer.getServer().getPlayerList().getHasWhitelist();
}
public List<?> getWhitelisted()
{
return Arrays.asList(MinecraftServer.getServer().getPlayerList().getWhitelisted());
}
public String getVersion()
{
return MinecraftServer.getServer().getVersion();
}
}