2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod;
|
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
|
|
|
|
import me.totalfreedom.totalfreedommod.banning.PermbanList;
|
|
|
|
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
|
|
|
import me.totalfreedom.totalfreedommod.fun.MP44;
|
|
|
|
import me.totalfreedom.totalfreedommod.fun.ItemFun;
|
|
|
|
import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
|
|
|
|
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
|
|
|
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
2015-10-19 17:43:46 +00:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.util.Properties;
|
|
|
|
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
|
|
|
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
|
|
|
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
|
|
|
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
|
|
|
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.caging.Cager;
|
|
|
|
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.commands.CommandLoader;
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
|
|
|
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
|
|
|
import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
|
|
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
2015-10-19 17:43:46 +00:00
|
|
|
import net.pravian.aero.component.service.ServiceManager;
|
|
|
|
import net.pravian.aero.plugin.AeroPlugin;
|
|
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
import org.mcstats.Metrics;
|
|
|
|
|
|
|
|
public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
public static final long SERVICE_CHECKER_RATE = 120L;
|
|
|
|
public static final int MAX_USERNAME_LENGTH = 20;
|
|
|
|
//
|
|
|
|
public static final String CONFIG_FILENAME = "config.yml";
|
|
|
|
public static final String SUPERADMIN_FILENAME = "superadmin.yml";
|
|
|
|
public static final String PERMBAN_FILENAME = "permban.yml";
|
|
|
|
public static final String UUID_FILENAME = "uuids.db";
|
|
|
|
public static final String PROTECTED_AREA_FILENAME = "protectedareas.dat";
|
|
|
|
public static final String SAVED_FLAGS_FILENAME = "savedflags.dat";
|
|
|
|
//
|
|
|
|
public static final BuildProperties build = new BuildProperties();
|
|
|
|
//
|
2015-11-15 23:32:04 +00:00
|
|
|
@SuppressWarnings("FieldNameHidesFieldInSuperclass")
|
2015-10-19 17:43:46 +00:00
|
|
|
public static TotalFreedomMod plugin;
|
|
|
|
public static String pluginName;
|
|
|
|
public static String pluginVersion;
|
|
|
|
//
|
|
|
|
public static boolean lockdownEnabled = false;
|
|
|
|
//
|
|
|
|
// Services
|
|
|
|
public ServiceManager<TotalFreedomMod> services;
|
|
|
|
public ServerInterface si;
|
2015-11-15 23:32:04 +00:00
|
|
|
public WorldManager wm;
|
2015-10-19 17:43:46 +00:00
|
|
|
public AdminList al;
|
2015-11-15 23:32:04 +00:00
|
|
|
public EventBlocker eb;
|
|
|
|
public BlockBlocker bb;
|
|
|
|
public MobBlocker mb;
|
|
|
|
public InteractBlocker ib;
|
|
|
|
public LoginProcess lp;
|
|
|
|
public AntiNuke nu;
|
|
|
|
public AntiSpam as;
|
|
|
|
public Muter mu;
|
2015-10-19 17:43:46 +00:00
|
|
|
public RankManager rm;
|
|
|
|
public BanManager bm;
|
|
|
|
public PlayerList pl;
|
|
|
|
public CommandLoader cl;
|
|
|
|
public CommandBlocker cb;
|
|
|
|
public Announcer an;
|
|
|
|
public PermbanList pb;
|
|
|
|
public ProtectArea pa;
|
|
|
|
public ServiceChecker sc;
|
|
|
|
public GameRuleHandler gr;
|
|
|
|
public RollbackManager rb;
|
|
|
|
public Jumppads jp;
|
2015-11-15 23:32:04 +00:00
|
|
|
public Cager ca;
|
|
|
|
public Freezer fm;
|
|
|
|
public Fuckoff fo;
|
|
|
|
public EntityWiper ew;
|
2015-10-19 17:43:46 +00:00
|
|
|
public FrontDoor fd;
|
2015-11-15 23:32:04 +00:00
|
|
|
public ServerPing sp;
|
|
|
|
public ItemFun it;
|
|
|
|
public Landminer lm;
|
|
|
|
public MP44 mp;
|
2015-10-19 17:43:46 +00:00
|
|
|
public HTTPDaemon hd;
|
|
|
|
//
|
|
|
|
// Bridges
|
|
|
|
public ServiceManager<TotalFreedomMod> bridges;
|
|
|
|
public BukkitTelnetBridge btb;
|
|
|
|
public EssentialsBridge esb;
|
|
|
|
public WorldEditBridge web;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void load()
|
|
|
|
{
|
|
|
|
TotalFreedomMod.plugin = this;
|
|
|
|
TotalFreedomMod.pluginName = plugin.getDescription().getName();
|
|
|
|
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
|
|
|
|
|
|
|
|
FLog.setPluginLogger(plugin.getLogger());
|
|
|
|
FLog.setServerLogger(server.getLogger());
|
|
|
|
|
|
|
|
build.load();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void enable()
|
|
|
|
{
|
|
|
|
TotalFreedomMod.plugin = this;
|
|
|
|
|
|
|
|
FLog.info("Created by Madgeek1450 and Prozza");
|
|
|
|
FLog.info("Version " + build.formattedVersion());
|
2015-11-22 18:26:47 +00:00
|
|
|
FLog.info("Compiled " + build.date + " by " + build.author);
|
2015-10-19 17:43:46 +00:00
|
|
|
|
|
|
|
final FUtil.MethodTimer timer = new FUtil.MethodTimer();
|
|
|
|
timer.start();
|
|
|
|
|
|
|
|
if (!ServerInterface.COMPILE_NMS_VERSION.equals(FUtil.getNmsVersion()))
|
|
|
|
{
|
|
|
|
FLog.warning(pluginName + " is compiled for " + ServerInterface.COMPILE_NMS_VERSION + " but the server is running "
|
|
|
|
+ "version " + FUtil.getNmsVersion() + "!");
|
|
|
|
FLog.warning("This might result in unexpected behaviour!");
|
|
|
|
}
|
|
|
|
|
|
|
|
FUtil.deleteCoreDumps();
|
|
|
|
FUtil.deleteFolder(new File("./_deleteme"));
|
|
|
|
|
|
|
|
// Create backups
|
|
|
|
FUtil.createBackups(CONFIG_FILENAME, true);
|
|
|
|
FUtil.createBackups(SUPERADMIN_FILENAME);
|
|
|
|
FUtil.createBackups(PERMBAN_FILENAME);
|
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
// Start services and bridgess
|
|
|
|
services = new ServiceManager<TotalFreedomMod>(plugin);
|
|
|
|
si = services.registerService(ServerInterface.class);
|
|
|
|
wm = services.registerService(WorldManager.class);
|
|
|
|
al = services.registerService(AdminList.class);
|
|
|
|
eb = services.registerService(EventBlocker.class);
|
|
|
|
bb = services.registerService(BlockBlocker.class);
|
|
|
|
mb = services.registerService(MobBlocker.class);
|
|
|
|
ib = services.registerService(InteractBlocker.class);
|
|
|
|
lp = services.registerService(LoginProcess.class);
|
|
|
|
nu = services.registerService(AntiNuke.class);
|
|
|
|
as = services.registerService(AntiSpam.class);
|
|
|
|
mu = services.registerService(Muter.class);
|
|
|
|
rm = services.registerService(RankManager.class);
|
|
|
|
bm = services.registerService(BanManager.class);
|
|
|
|
pl = services.registerService(PlayerList.class);
|
|
|
|
cl = services.registerService(CommandLoader.class);
|
|
|
|
cb = services.registerService(CommandBlocker.class);
|
|
|
|
an = services.registerService(Announcer.class);
|
|
|
|
pb = services.registerService(PermbanList.class);
|
|
|
|
pa = services.registerService(ProtectArea.class);
|
|
|
|
sc = services.registerService(ServiceChecker.class);
|
|
|
|
gr = services.registerService(GameRuleHandler.class);
|
|
|
|
rb = services.registerService(RollbackManager.class);
|
|
|
|
jp = services.registerService(Jumppads.class);
|
|
|
|
ca = services.registerService(Cager.class);
|
|
|
|
fm = services.registerService(Freezer.class);
|
|
|
|
fo = services.registerService(Fuckoff.class);
|
|
|
|
ew = services.registerService(EntityWiper.class);
|
|
|
|
fd = services.registerService(FrontDoor.class);
|
|
|
|
sp = services.registerService(ServerPing.class);
|
|
|
|
it = services.registerService(ItemFun.class);
|
|
|
|
lm = services.registerService(Landminer.class);
|
|
|
|
mp = services.registerService(MP44.class);
|
|
|
|
hd = services.registerService(HTTPDaemon.class);
|
2015-10-19 17:43:46 +00:00
|
|
|
services.start();
|
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
// Register bridges
|
|
|
|
bridges = new ServiceManager<TotalFreedomMod>(plugin);
|
|
|
|
btb = bridges.registerService(BukkitTelnetBridge.class);
|
|
|
|
esb = bridges.registerService(EssentialsBridge.class);
|
|
|
|
web = bridges.registerService(WorldEditBridge.class);
|
|
|
|
bridges.start();
|
2015-10-19 17:43:46 +00:00
|
|
|
|
|
|
|
timer.update();
|
|
|
|
|
|
|
|
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
|
|
|
|
|
|
|
|
// Metrics @ http://mcstats.org/plugin/TotalFreedomMod
|
|
|
|
try
|
|
|
|
{
|
|
|
|
final Metrics metrics = new Metrics(plugin);
|
|
|
|
metrics.start();
|
|
|
|
}
|
|
|
|
catch (IOException ex)
|
|
|
|
{
|
|
|
|
FLog.warning("Failed to submit metrics data: " + ex.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add spawnpoints later - https://github.com/TotalFreedom/TotalFreedomMod/issues/438
|
|
|
|
new BukkitRunnable()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
plugin.pa.autoAddSpawnpoints();
|
|
|
|
}
|
|
|
|
}.runTaskLater(plugin, 60L);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void disable()
|
|
|
|
{
|
|
|
|
// Stop services and bridges
|
|
|
|
bridges.stop();
|
2016-02-29 20:48:17 +00:00
|
|
|
services.stop();
|
2015-10-19 17:43:46 +00:00
|
|
|
|
|
|
|
server.getScheduler().cancelTasks(plugin);
|
|
|
|
|
|
|
|
FLog.info("Plugin disabled");
|
|
|
|
TotalFreedomMod.plugin = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class BuildProperties
|
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
|
|
|
public String author;
|
|
|
|
public String version;
|
2015-10-19 17:43:46 +00:00
|
|
|
public String number;
|
|
|
|
public String date;
|
2015-11-22 18:26:47 +00:00
|
|
|
public String head;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
|
|
|
public void load()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
final InputStream in = plugin.getResource("build.properties");
|
|
|
|
|
|
|
|
final Properties props = new Properties();
|
|
|
|
props.load(in);
|
|
|
|
in.close();
|
|
|
|
|
2015-11-22 18:26:47 +00:00
|
|
|
author = props.getProperty("program.build.author", "unknown");
|
|
|
|
version = props.getProperty("program.build.version", "unknown");
|
|
|
|
number = props.getProperty("program.build.number", "1");
|
|
|
|
date = props.getProperty("program.build.date", "unknown");
|
|
|
|
head = props.getProperty("program.build.head", "unknown");
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
FLog.severe("Could not load build properties! Did you compile with Netbeans/ANT?");
|
|
|
|
FLog.severe(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String formattedVersion()
|
|
|
|
{
|
|
|
|
return pluginVersion + "." + number + " (" + head + ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|