Mineplex2018-withcommit/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java

171 lines
6.3 KiB
Java
Raw Normal View History

package mineplex.game.clans;
import org.bukkit.Material;
2015-06-23 23:37:49 +02:00
import org.bukkit.World;
2015-11-13 01:18:42 +01:00
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.plugin.java.JavaPlugin;
2015-11-26 01:08:13 +01:00
import mineplex.core.CustomTagFix;
2015-10-02 04:57:39 +02:00
import mineplex.core.FoodDupeFix;
import mineplex.core.account.CoreClientManager;
2015-07-14 08:57:53 +02:00
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandCenter;
import mineplex.core.donation.DonationManager;
2014-12-08 09:55:20 +01:00
import mineplex.core.explosion.Explosion;
import mineplex.core.friend.FriendManager;
2015-07-14 08:57:53 +02:00
import mineplex.core.give.Give;
2015-10-02 04:57:39 +02:00
import mineplex.core.hologram.HologramManager;
2015-02-11 03:15:44 +01:00
import mineplex.core.ignore.IgnoreManager;
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;
import mineplex.core.packethandler.PacketHandler;
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;
2015-07-14 08:57:53 +02:00
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.core.visibility.VisibilityManager;
2014-11-28 07:34:20 +01:00
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.shop.building.BuildingShop;
2015-08-25 05:03:26 +02:00
import mineplex.game.clans.shop.farming.FarmingShop;
import mineplex.game.clans.shop.mining.MiningShop;
import mineplex.game.clans.shop.pvp.PvpShop;
2015-08-25 05:03:26 +02:00
import mineplex.game.clans.spawn.travel.TravelShop;
import mineplex.game.clans.world.WorldManager;
2015-11-13 01:18:42 +01:00
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class Clans extends JavaPlugin
2015-11-23 21:57:13 +01:00
{
2015-11-27 11:53:57 +01:00
public static final String VERSION = "0.14";
private String WEB_CONFIG = "webServer";
2015-11-25 22:45:04 +01:00
// Modules
private CoreClientManager _clientManager;
private DonationManager _donationManager;
private ClansManager _clansManager;
@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-11-25 22:45:04 +01:00
// Logger.initialize(this);
2015-11-25 22:45:04 +01:00
// Static Modules
CommandCenter.Initialize(this);
_clientManager = new CoreClientManager(this, webServerAddress);
CommandCenter.Instance.setClientManager(_clientManager);
2015-11-25 22:45:04 +01:00
ItemStackFactory.Initialize(this, false);
Recharge.Initialize(this);
VisibilityManager.Initialize(this);
// new ProfileCacheManager(this);
2015-11-25 22:45:04 +01:00
_donationManager = new DonationManager(this, _clientManager, webServerAddress);
new ServerConfiguration(this, _clientManager);
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
2015-11-25 22:45:04 +01:00
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
// TODO: Add spawn locations to a configuration file of some sort?
new Spawn(this, serverStatusManager.getCurrentServerName());
2015-07-14 08:57:53 +02:00
Give.Initialize(this);
2015-11-25 22:45:04 +01:00
2015-11-27 11:53:57 +01:00
Teleport teleport = new Teleport(this, _clientManager);
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
2015-01-23 08:18:38 +01:00
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
2015-11-25 22:45:04 +01:00
Punish punish = new Punish(this, webServerAddress, _clientManager);
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
AntiHack.Instance.setKick(false);
2015-11-25 22:45:04 +01:00
BlockRestore blockRestore = new BlockRestore(this);
2015-11-25 22:45:04 +01:00
2015-02-11 03:15:44 +01:00
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
2015-11-25 22:45:04 +01:00
2015-07-14 08:57:53 +02:00
StatsManager statsManager = new StatsManager(this, _clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager);
Chat chat = new Chat(this, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat);
2015-11-25 22:45:04 +01:00
new MemoryFix(this);
2015-10-02 04:57:39 +02:00
new FoodDupeFix(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);
new InventoryManager(this, _clientManager);
2015-06-30 05:32:40 +02:00
// Enable custom-gear related managers
PacketHandler packetHandler = new PacketHandler(this);
2015-11-26 01:08:13 +01:00
new CustomTagFix(this, packetHandler);
GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager);
2015-11-25 22:45:04 +01:00
2015-11-27 09:22:17 +01:00
HologramManager hologram = new HologramManager(this, packetHandler);
2015-11-25 01:47:35 +01:00
_clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), packetHandler, _clientManager, _donationManager, preferenceManager, blockRestore, teleport, chat, customGear, hologram, webServerAddress);
new Recipes(this);
new Farming(this);
new BuildingShop(_clansManager, _clientManager, _donationManager);
new PvpShop(_clansManager, _clientManager, _donationManager);
2015-08-25 05:03:26 +02:00
new FarmingShop(_clansManager, _clientManager, _donationManager);
new TravelShop(_clansManager, _clientManager, _donationManager);
new MiningShop(_clansManager, _clientManager, _donationManager);
new WorldManager(this);
// 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-11-25 22:45:04 +01:00
//Updates
new Updater(this);
MinecraftServer.getServer().getPropertyManager().setProperty("debug", true);
getServer().setWhitelist(false); // TODO: remove
}
2015-11-25 22:45:04 +01: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-11-25 22:45:04 +01:00
@Override
public void onDisable()
{
// Need to notify WorldEventManager of server shutdown, this seemed like
// the only decent way to do it
_clansManager.onDisable();
}
}