2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod;
|
|
|
|
|
|
|
|
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
2018-02-22 12:55:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.amp.AMP;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.banning.PermbanList;
|
2018-02-09 08:21:44 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.blocking.*;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
2018-02-09 08:21:44 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.bridge.*;
|
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;
|
2017-12-29 18:12:47 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.discord.Discord;
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
2018-02-09 08:21:44 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.fun.*;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
|
|
|
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
2018-03-03 04:29:08 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
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;
|
2017-10-14 11:21:07 +00:00
|
|
|
import org.spigotmc.SpigotConfig;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2018-02-09 08:21:44 +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
|
|
|
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;
|
2017-12-29 18:12:47 +00:00
|
|
|
public Discord dc;
|
2018-03-03 04:29:08 +00:00
|
|
|
public PunishmentList pul;
|
2016-03-07 20:32:05 +00:00
|
|
|
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;
|
2017-10-14 11:21:07 +00:00
|
|
|
public EditBlocker ebl;
|
2017-12-28 05:50:39 +00:00
|
|
|
public PVPBlocker pbl;
|
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;
|
2017-12-31 03:58:20 +00:00
|
|
|
public Monitors mo;
|
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;
|
2017-12-28 05:50:39 +00:00
|
|
|
public SignBlocker snp;
|
2015-10-19 17:43:46 +00:00
|
|
|
//
|
|
|
|
// Bridges
|
|
|
|
public ServiceManager<TotalFreedomMod> bridges;
|
|
|
|
public BukkitTelnetBridge btb;
|
|
|
|
public EssentialsBridge esb;
|
2016-07-21 21:53:25 +00:00
|
|
|
public LibsDisguisesBridge ldb;
|
2017-10-14 11:21:07 +00:00
|
|
|
public CoreProtectBridge cpb;
|
2015-10-19 17:43:46 +00:00
|
|
|
public WorldEditBridge web;
|
2018-02-09 08:21:44 +00:00
|
|
|
public WorldGuardBridge wgb;
|
2018-02-22 12:55:04 +00:00
|
|
|
public AMP amp;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
|
|
|
@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");
|
2017-10-14 11:21:07 +00:00
|
|
|
FLog.info("Version " + build.version);
|
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);
|
2017-12-29 18:12:47 +00:00
|
|
|
dc = services.registerService(Discord.class);
|
2018-03-03 04:29:08 +00:00
|
|
|
pul = services.registerService(PunishmentList.class);
|
2016-03-07 20:32:05 +00:00
|
|
|
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
|
|
|
|
2017-12-28 05:50:39 +00:00
|
|
|
snp = services.registerService(SignBlocker.class);
|
2017-10-21 17:31:17 +00:00
|
|
|
|
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);
|
2017-10-14 11:21:07 +00:00
|
|
|
ebl = services.registerService(EditBlocker.class);
|
2017-12-28 05:50:39 +00:00
|
|
|
pbl = services.registerService(PVPBlocker.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);
|
2017-12-31 03:58:20 +00:00
|
|
|
mo = services.registerService(Monitors.class);
|
2017-12-28 05:50:39 +00:00
|
|
|
|
|
|
|
|
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);
|
2017-10-14 11:21:07 +00:00
|
|
|
cpb = bridges.registerService(CoreProtectBridge.class);
|
2015-11-15 23:32:04 +00:00
|
|
|
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);
|
2018-02-09 08:21:44 +00:00
|
|
|
wgb = bridges.registerService(WorldGuardBridge.class);
|
2018-02-22 12:55:04 +00:00
|
|
|
amp = bridges.registerService(AMP.class);
|
2015-11-15 23:32:04 +00:00
|
|
|
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);
|
2017-10-14 11:21:07 +00:00
|
|
|
//little workaround to stop spigot from autorestarting - causing AMP to detach from process.
|
|
|
|
SpigotConfig.config.set("settings.restart-on-crash", false);
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@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)
|
|
|
|
{
|
2017-09-09 14:16:00 +00:00
|
|
|
FLog.severe("Could not load build properties! Did you compile with Netbeans/Maven?");
|
2015-10-19 17:43:46 +00:00
|
|
|
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
|
|
|
}
|