2014-11-12 14:13:16 +01:00
|
|
|
package mineplex.game.clans;
|
|
|
|
|
2015-06-01 21:51:22 +02:00
|
|
|
import org.bukkit.Location;
|
2015-06-22 22:20:20 +02:00
|
|
|
import org.bukkit.Material;
|
2015-06-23 23:37:49 +02:00
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
2015-02-05 01:34:29 +01:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2015-05-05 21:34:32 +02:00
|
|
|
import net.minecraft.server.v1_7_R4.MinecraftServer;
|
2014-11-12 14:13:16 +01:00
|
|
|
import mineplex.core.account.CoreClientManager;
|
|
|
|
import mineplex.core.antihack.AntiHack;
|
|
|
|
import mineplex.core.blockrestore.BlockRestore;
|
2015-05-02 01:02:06 +02:00
|
|
|
import mineplex.core.chat.Chat;
|
2014-11-12 14:13:16 +01:00
|
|
|
import mineplex.core.command.CommandCenter;
|
|
|
|
import mineplex.core.donation.DonationManager;
|
2014-12-08 09:55:20 +01:00
|
|
|
import mineplex.core.explosion.Explosion;
|
2014-11-12 14:13:16 +01:00
|
|
|
import mineplex.core.friend.FriendManager;
|
2015-02-11 03:15:44 +01:00
|
|
|
import mineplex.core.ignore.IgnoreManager;
|
2014-11-12 14:13:16 +01:00
|
|
|
import mineplex.core.inventory.InventoryManager;
|
|
|
|
import mineplex.core.itemstack.ItemStackFactory;
|
|
|
|
import mineplex.core.memory.MemoryFix;
|
|
|
|
import mineplex.core.message.MessageManager;
|
|
|
|
import mineplex.core.monitor.LagMeter;
|
2015-05-25 20:22:06 +02:00
|
|
|
import mineplex.core.packethandler.PacketHandler;
|
2014-11-12 14:13:16 +01:00
|
|
|
import mineplex.core.portal.Portal;
|
|
|
|
import mineplex.core.preferences.PreferencesManager;
|
|
|
|
import mineplex.core.punish.Punish;
|
|
|
|
import mineplex.core.recharge.Recharge;
|
|
|
|
import mineplex.core.serverConfig.ServerConfiguration;
|
|
|
|
import mineplex.core.spawn.Spawn;
|
|
|
|
import mineplex.core.status.ServerStatusManager;
|
|
|
|
import mineplex.core.teleport.Teleport;
|
|
|
|
import mineplex.core.updater.FileUpdater;
|
|
|
|
import mineplex.core.updater.Updater;
|
2014-11-28 07:34:20 +01:00
|
|
|
import mineplex.game.clans.clans.ClansManager;
|
2015-04-30 20:15:20 +02:00
|
|
|
import mineplex.game.clans.clans.worldevent.WorldEventManager;
|
2015-05-05 21:34:32 +02:00
|
|
|
import mineplex.game.clans.items.GearManager;
|
2014-12-29 12:44:00 +01:00
|
|
|
import mineplex.game.clans.shop.building.BuildingShop;
|
|
|
|
import mineplex.game.clans.shop.pvp.PvpShop;
|
2014-11-12 14:13:16 +01:00
|
|
|
|
|
|
|
public class Clans extends JavaPlugin
|
|
|
|
{
|
|
|
|
private String WEB_CONFIG = "webServer";
|
|
|
|
|
|
|
|
//Modules
|
|
|
|
private CoreClientManager _clientManager;
|
2015-06-23 03:34:13 +02:00
|
|
|
private DonationManager _donationManager;
|
|
|
|
private ClansManager _clansManager;
|
2014-11-12 14:13:16 +01:00
|
|
|
|
2015-06-04 02:08:34 +02:00
|
|
|
|
2014-11-12 14:13:16 +01:00
|
|
|
@Override
|
|
|
|
public void onEnable()
|
|
|
|
{
|
|
|
|
//Configs
|
|
|
|
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
|
|
|
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
|
|
|
saveConfig();
|
|
|
|
|
|
|
|
String webServerAddress = getConfig().getString(WEB_CONFIG);
|
|
|
|
|
2015-01-23 08:18:38 +01:00
|
|
|
//Logger.initialize(this);
|
2014-11-12 14:13:16 +01:00
|
|
|
|
|
|
|
//Static Modules
|
|
|
|
CommandCenter.Initialize(this);
|
|
|
|
_clientManager = new CoreClientManager(this, webServerAddress);
|
|
|
|
CommandCenter.Instance.setClientManager(_clientManager);
|
|
|
|
|
|
|
|
ItemStackFactory.Initialize(this, false);
|
|
|
|
Recharge.Initialize(this);
|
|
|
|
|
2014-12-29 12:44:00 +01:00
|
|
|
_donationManager = new DonationManager(this, _clientManager, webServerAddress);
|
2014-11-12 14:13:16 +01:00
|
|
|
|
2015-03-02 21:33:04 +01:00
|
|
|
new ServerConfiguration(this, _clientManager);
|
2014-11-12 14:13:16 +01:00
|
|
|
|
|
|
|
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
|
|
|
|
|
2014-12-14 08:30:39 +01:00
|
|
|
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
|
2015-06-01 21:51:22 +02:00
|
|
|
|
|
|
|
// TODO: Add spawn locations to a configuration file of some sort?
|
|
|
|
Spawn spawn = new Spawn(this, serverStatusManager.getCurrentServerName());
|
|
|
|
|
2014-11-29 12:16:37 +01:00
|
|
|
Teleport teleport = new Teleport(this);
|
2015-01-11 09:42:31 +01:00
|
|
|
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
|
2015-01-23 08:18:38 +01:00
|
|
|
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
|
2014-11-12 14:13:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
Punish punish = new Punish(this, webServerAddress, _clientManager);
|
|
|
|
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
|
|
|
|
AntiHack.Instance.setKick(false);
|
2015-02-11 03:15:44 +01:00
|
|
|
|
2014-11-12 14:13:16 +01:00
|
|
|
BlockRestore blockRestore = new BlockRestore(this);
|
2015-02-11 03:15:44 +01:00
|
|
|
|
|
|
|
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
|
2015-05-02 01:02:06 +02:00
|
|
|
Chat chat = new Chat(this, _clientManager, preferenceManager, serverStatusManager.getCurrentServerName());
|
|
|
|
new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat);
|
2015-02-11 03:15:44 +01:00
|
|
|
|
2014-11-12 14:13:16 +01:00
|
|
|
new MemoryFix(this);
|
2014-12-08 09:55:20 +01:00
|
|
|
new Explosion(this, blockRestore);
|
2015-01-30 04:17:46 +01:00
|
|
|
new FriendManager(this, _clientManager, preferenceManager, portal);
|
2014-12-03 22:06:50 +01:00
|
|
|
new InventoryManager(this, _clientManager);
|
2014-11-12 14:13:16 +01:00
|
|
|
|
2015-06-23 03:34:13 +02:00
|
|
|
_clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), _clientManager, _donationManager, blockRestore, teleport, webServerAddress);
|
2014-12-04 14:05:27 +01:00
|
|
|
new Recipes(this);
|
|
|
|
new Farming(this);
|
2015-06-23 03:34:13 +02:00
|
|
|
new BuildingShop(_clansManager, _clientManager, _donationManager);
|
|
|
|
new PvpShop(_clansManager, _clientManager, _donationManager);
|
2015-06-15 00:30:02 +02:00
|
|
|
|
|
|
|
// Disable spigot item merging
|
|
|
|
for (World world : getServer().getWorlds())
|
|
|
|
{
|
|
|
|
// Disable item merging
|
|
|
|
((CraftWorld) world).getHandle().spigotConfig.itemMerge = 0;
|
|
|
|
}
|
2014-11-28 07:34:20 +01:00
|
|
|
|
2015-05-25 20:22:06 +02:00
|
|
|
// Enable custom-gear related managers
|
|
|
|
PacketHandler packetHandler = new PacketHandler(this);
|
|
|
|
GearManager customGear = new GearManager(this, packetHandler);
|
2015-05-05 21:34:32 +02:00
|
|
|
|
2014-11-12 14:13:16 +01:00
|
|
|
//Updates
|
|
|
|
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
|
|
|
|
|
|
|
MinecraftServer.getServer().getPropertyManager().setProperty("debug", true);
|
|
|
|
}
|
2015-06-23 03:34:13 +02:00
|
|
|
|
2015-06-22 22:20:20 +02:00
|
|
|
public static String prettifyName(Material material)
|
|
|
|
{
|
|
|
|
String name = "";
|
|
|
|
String[] words = material.toString().split("_");
|
|
|
|
|
|
|
|
for (String word : words)
|
|
|
|
{
|
|
|
|
word = word.toLowerCase();
|
|
|
|
name += word.substring(0, 1).toUpperCase() + word.substring(1) + " ";
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
2015-06-23 23:36:21 +02:00
|
|
|
|
2015-06-23 03:34:13 +02:00
|
|
|
@Override
|
|
|
|
public void onDisable()
|
|
|
|
{
|
|
|
|
// Need to notify WorldEventManager of server shutdown, this seemed like the only decent way to do it
|
|
|
|
_clansManager.onDisable();
|
|
|
|
}
|
2014-11-12 14:13:16 +01:00
|
|
|
}
|