2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod;
|
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
2016-03-06 15:56:15 +00:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.util.Properties;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
|
|
|
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.banning.PermbanList;
|
|
|
|
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
|
|
|
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
|
|
|
import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
|
|
|
|
import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
|
2016-05-12 19:40:39 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.blocking.PotionBlocker;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
|
|
|
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
2016-07-21 21:53:25 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.caging.Cager;
|
2016-03-02 19:28:01 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.command.CommandLoader;
|
2016-05-12 19:40:39 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.fun.ItemFun;
|
|
|
|
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.fun.MP44;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
|
|
|
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
2015-10-19 17:43:46 +00:00
|
|
|
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;
|
2016-05-12 19:40:39 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
2015-11-15 23:32:04 +00:00
|
|
|
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;
|
2016-05-12 19:40:39 +00:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.plugin.Plugin;
|
2015-10-19 17:43:46 +00:00
|
|
|
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 String CONFIG_FILENAME = "config.yml";
|
|
|
|
//
|
|
|
|
public static final BuildProperties build = new BuildProperties();
|
|
|
|
//
|
|
|
|
public static String pluginName;
|
|
|
|
public static String pluginVersion;
|
|
|
|
//
|
2016-05-12 19:40:39 +00:00
|
|
|
public MainConfig config;
|
|
|
|
//
|
2015-10-19 17:43:46 +00:00
|
|
|
// Services
|
|
|
|
public ServiceManager<TotalFreedomMod> services;
|
|
|
|
public ServerInterface si;
|
2016-05-12 19:40:39 +00:00
|
|
|
public SavedFlags sf;
|
2015-11-15 23:32:04 +00:00
|
|
|
public WorldManager wm;
|
2016-05-12 19:40:39 +00:00
|
|
|
public LogViewer lv;
|
2015-10-19 17:43:46 +00:00
|
|
|
public AdminList al;
|
2016-05-12 19:40:39 +00:00
|
|
|
public RankManager rm;
|
|
|
|
public CommandLoader cl;
|
|
|
|
public CommandBlocker cb;
|
2015-11-15 23:32:04 +00:00
|
|
|
public EventBlocker eb;
|
|
|
|
public BlockBlocker bb;
|
|
|
|
public MobBlocker mb;
|
|
|
|
public InteractBlocker ib;
|
2016-05-12 19:40:39 +00:00
|
|
|
public PotionBlocker pb;
|
2015-11-15 23:32:04 +00:00
|
|
|
public LoginProcess lp;
|
|
|
|
public AntiNuke nu;
|
|
|
|
public AntiSpam as;
|
2015-10-19 17:43:46 +00:00
|
|
|
public PlayerList pl;
|
|
|
|
public Announcer an;
|
2016-03-07 20:32:05 +00:00
|
|
|
public ChatManager cm;
|
|
|
|
public BanManager bm;
|
2016-05-12 19:40:39 +00:00
|
|
|
public PermbanList pm;
|
2015-10-19 17:43:46 +00:00
|
|
|
public ProtectArea pa;
|
|
|
|
public GameRuleHandler gr;
|
|
|
|
public RollbackManager rb;
|
2016-03-07 20:32:05 +00:00
|
|
|
public CommandSpy cs;
|
2015-11-15 23:32:04 +00:00
|
|
|
public Cager ca;
|
|
|
|
public Freezer fm;
|
2016-03-07 20:32:05 +00:00
|
|
|
public Orbiter or;
|
|
|
|
public Muter mu;
|
2015-11-15 23:32:04 +00:00
|
|
|
public Fuckoff fo;
|
2016-03-07 20:32:05 +00:00
|
|
|
public AutoKick ak;
|
2016-05-12 19:40:39 +00:00
|
|
|
public AutoEject ae;
|
2016-03-07 20:32:05 +00:00
|
|
|
public MovementValidator mv;
|
2015-11-15 23:32:04 +00:00
|
|
|
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;
|
2016-03-07 20:32:05 +00:00
|
|
|
public Jumppads jp;
|
2016-05-12 19:40:39 +00:00
|
|
|
public Trailer tr;
|
2015-10-19 17:43:46 +00:00
|
|
|
public HTTPDaemon hd;
|
|
|
|
//
|
|
|
|
// Bridges
|
|
|
|
public ServiceManager<TotalFreedomMod> bridges;
|
|
|
|
public BukkitTelnetBridge btb;
|
|
|
|
public EssentialsBridge esb;
|
2016-07-21 21:53:25 +00:00
|
|
|
public LibsDisguisesBridge ldb;
|
2015-10-19 17:43:46 +00:00
|
|
|
public WorldEditBridge web;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void load()
|
|
|
|
{
|
|
|
|
TotalFreedomMod.pluginName = plugin.getDescription().getName();
|
|
|
|
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
|
|
|
|
|
|
|
|
FLog.setPluginLogger(plugin.getLogger());
|
|
|
|
FLog.setServerLogger(server.getLogger());
|
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
build.load(plugin);
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void enable()
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
final MethodTimer timer = new MethodTimer();
|
2015-10-19 17:43:46 +00:00
|
|
|
timer.start();
|
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
// Warn if we're running on a wrong version
|
|
|
|
ServerInterface.warnVersion();
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
// Delete unused files
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.deleteCoreDumps();
|
|
|
|
FUtil.deleteFolder(new File("./_deleteme"));
|
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
// Convert old config files
|
|
|
|
new ConfigConverter(plugin).convert();
|
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
BackupManager backups = new BackupManager(this);
|
|
|
|
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
|
|
|
backups.createBackups(AdminList.CONFIG_FILENAME);
|
|
|
|
backups.createBackups(PermbanList.CONFIG_FILENAME);
|
|
|
|
|
|
|
|
config = new MainConfig(this);
|
|
|
|
config.load();
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2016-03-07 20:32:05 +00:00
|
|
|
// Start services
|
2016-03-02 19:28:01 +00:00
|
|
|
services = new ServiceManager<>(plugin);
|
2015-11-15 23:32:04 +00:00
|
|
|
si = services.registerService(ServerInterface.class);
|
2016-05-12 19:40:39 +00:00
|
|
|
sf = services.registerService(SavedFlags.class);
|
2015-11-15 23:32:04 +00:00
|
|
|
wm = services.registerService(WorldManager.class);
|
2016-05-12 19:40:39 +00:00
|
|
|
lv = services.registerService(LogViewer.class);
|
2015-11-15 23:32:04 +00:00
|
|
|
al = services.registerService(AdminList.class);
|
2016-05-12 19:40:39 +00:00
|
|
|
rm = services.registerService(RankManager.class);
|
|
|
|
cl = services.registerService(CommandLoader.class);
|
|
|
|
cb = services.registerService(CommandBlocker.class);
|
2015-11-15 23:32:04 +00:00
|
|
|
eb = services.registerService(EventBlocker.class);
|
|
|
|
bb = services.registerService(BlockBlocker.class);
|
|
|
|
mb = services.registerService(MobBlocker.class);
|
|
|
|
ib = services.registerService(InteractBlocker.class);
|
2016-05-12 19:40:39 +00:00
|
|
|
pb = services.registerService(PotionBlocker.class);
|
2015-11-15 23:32:04 +00:00
|
|
|
lp = services.registerService(LoginProcess.class);
|
|
|
|
nu = services.registerService(AntiNuke.class);
|
|
|
|
as = services.registerService(AntiSpam.class);
|
2016-03-07 20:32:05 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
pl = services.registerService(PlayerList.class);
|
|
|
|
an = services.registerService(Announcer.class);
|
2016-03-07 20:32:05 +00:00
|
|
|
cm = services.registerService(ChatManager.class);
|
|
|
|
bm = services.registerService(BanManager.class);
|
2016-05-12 19:40:39 +00:00
|
|
|
pm = services.registerService(PermbanList.class);
|
2015-11-15 23:32:04 +00:00
|
|
|
pa = services.registerService(ProtectArea.class);
|
|
|
|
gr = services.registerService(GameRuleHandler.class);
|
2016-03-07 20:32:05 +00:00
|
|
|
|
|
|
|
// Single admin utils
|
2015-11-15 23:32:04 +00:00
|
|
|
rb = services.registerService(RollbackManager.class);
|
2016-03-07 20:32:05 +00:00
|
|
|
cs = services.registerService(CommandSpy.class);
|
2015-11-15 23:32:04 +00:00
|
|
|
ca = services.registerService(Cager.class);
|
|
|
|
fm = services.registerService(Freezer.class);
|
2016-03-07 20:32:05 +00:00
|
|
|
or = services.registerService(Orbiter.class);
|
|
|
|
mu = services.registerService(Muter.class);
|
2015-11-15 23:32:04 +00:00
|
|
|
fo = services.registerService(Fuckoff.class);
|
2016-03-07 20:32:05 +00:00
|
|
|
ak = services.registerService(AutoKick.class);
|
2016-05-12 19:40:39 +00:00
|
|
|
ae = services.registerService(AutoEject.class);
|
2016-03-07 20:32:05 +00:00
|
|
|
|
|
|
|
mv = services.registerService(MovementValidator.class);
|
2015-11-15 23:32:04 +00:00
|
|
|
ew = services.registerService(EntityWiper.class);
|
|
|
|
fd = services.registerService(FrontDoor.class);
|
|
|
|
sp = services.registerService(ServerPing.class);
|
2016-03-07 20:32:05 +00:00
|
|
|
|
|
|
|
// Fun
|
2015-11-15 23:32:04 +00:00
|
|
|
it = services.registerService(ItemFun.class);
|
|
|
|
lm = services.registerService(Landminer.class);
|
|
|
|
mp = services.registerService(MP44.class);
|
2016-03-07 20:32:05 +00:00
|
|
|
jp = services.registerService(Jumppads.class);
|
2016-05-12 19:40:39 +00:00
|
|
|
tr = services.registerService(Trailer.class);
|
2016-03-07 20:32:05 +00:00
|
|
|
|
|
|
|
// HTTPD
|
2015-11-15 23:32:04 +00:00
|
|
|
hd = services.registerService(HTTPDaemon.class);
|
2015-10-19 17:43:46 +00:00
|
|
|
services.start();
|
|
|
|
|
2016-03-07 20:32:05 +00:00
|
|
|
// Start bridges
|
2016-03-02 19:28:01 +00:00
|
|
|
bridges = new ServiceManager<>(plugin);
|
2015-11-15 23:32:04 +00:00
|
|
|
btb = bridges.registerService(BukkitTelnetBridge.class);
|
|
|
|
esb = bridges.registerService(EssentialsBridge.class);
|
2016-07-21 21:53:25 +00:00
|
|
|
ldb = bridges.registerService(LibsDisguisesBridge.class);
|
2015-11-15 23:32:04 +00:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class BuildProperties
|
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
|
|
|
public String author;
|
2016-05-12 19:40:39 +00:00
|
|
|
public String codename;
|
2015-11-22 18:26:47 +00:00
|
|
|
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
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
public void load(TotalFreedomMod plugin)
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2016-05-12 19:40:39 +00:00
|
|
|
final Properties props;
|
|
|
|
try (InputStream in = plugin.getResource("build.properties"))
|
|
|
|
{
|
|
|
|
props = new Properties();
|
|
|
|
props.load(in);
|
|
|
|
}
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2015-11-22 18:26:47 +00:00
|
|
|
author = props.getProperty("program.build.author", "unknown");
|
2016-05-12 19:40:39 +00:00
|
|
|
codename = props.getProperty("program.build.codename", "unknown");
|
2015-11-22 18:26:47 +00:00
|
|
|
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 + ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
public static TotalFreedomMod plugin()
|
|
|
|
{
|
|
|
|
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
|
|
|
|
{
|
|
|
|
if (plugin.getName().equalsIgnoreCase(pluginName))
|
|
|
|
{
|
|
|
|
return (TotalFreedomMod) plugin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|