2013-08-27 17:14:08 +02:00
|
|
|
package nautilus.game.arcade;
|
2014-04-11 07:33:31 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
import java.io.File;
|
2015-06-20 10:43:38 +02:00
|
|
|
|
2014-09-19 04:03:46 +02:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2015-05-13 23:55:22 +02:00
|
|
|
import net.minecraft.server.v1_7_R4.BiomeBase;
|
2014-10-03 10:50:23 +02:00
|
|
|
import net.minecraft.server.v1_7_R4.MinecraftServer;
|
2014-09-05 13:36:01 +02:00
|
|
|
import mineplex.core.CustomTagFix;
|
2015-02-07 05:39:22 +01:00
|
|
|
import mineplex.core.TablistFix;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.account.CoreClientManager;
|
2015-06-20 10:43:38 +02:00
|
|
|
import mineplex.core.achievement.AchievementManager;
|
2013-10-16 03:23:23 +02:00
|
|
|
import mineplex.core.antihack.AntiHack;
|
2014-08-09 05:10:02 +02:00
|
|
|
import mineplex.core.blockrestore.BlockRestore;
|
2014-03-09 09:50:13 +01:00
|
|
|
import mineplex.core.blood.Blood;
|
2015-05-01 06:56:08 +02:00
|
|
|
import mineplex.core.chat.Chat;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.command.CommandCenter;
|
2014-09-19 04:03:46 +02:00
|
|
|
import mineplex.core.common.util.FileUtil;
|
|
|
|
import mineplex.core.common.util.UtilServer;
|
2014-08-09 10:57:56 +02:00
|
|
|
import mineplex.core.cosmetic.CosmeticManager;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.creature.Creature;
|
2013-08-31 05:15:16 +02:00
|
|
|
import mineplex.core.disguise.DisguiseManager;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.donation.DonationManager;
|
2014-10-03 10:50:23 +02:00
|
|
|
import mineplex.core.friend.FriendManager;
|
2014-08-09 05:10:02 +02:00
|
|
|
import mineplex.core.gadget.GadgetManager;
|
2015-03-16 03:39:33 +01:00
|
|
|
import mineplex.core.give.Give;
|
2014-11-25 22:28:37 +01:00
|
|
|
import mineplex.core.hologram.HologramManager;
|
2015-02-09 14:31:33 +01:00
|
|
|
import mineplex.core.ignore.IgnoreManager;
|
2014-08-09 05:10:02 +02:00
|
|
|
import mineplex.core.inventory.InventoryManager;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.itemstack.ItemStackFactory;
|
2015-02-20 00:53:46 +01:00
|
|
|
import mineplex.core.leaderboard.LeaderboardManager;
|
2014-03-09 09:50:13 +01:00
|
|
|
import mineplex.core.memory.MemoryFix;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.message.MessageManager;
|
2013-09-04 08:31:29 +02:00
|
|
|
import mineplex.core.monitor.LagMeter;
|
2014-08-09 05:10:02 +02:00
|
|
|
import mineplex.core.mount.MountManager;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.npc.NpcManager;
|
|
|
|
import mineplex.core.packethandler.PacketHandler;
|
2014-08-09 05:10:02 +02:00
|
|
|
import mineplex.core.pet.PetManager;
|
2013-09-02 13:19:56 +02:00
|
|
|
import mineplex.core.portal.Portal;
|
2014-06-10 04:51:47 +02:00
|
|
|
import mineplex.core.preferences.PreferencesManager;
|
2014-08-22 20:30:41 +02:00
|
|
|
import mineplex.core.projectile.ProjectileManager;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.punish.Punish;
|
|
|
|
import mineplex.core.recharge.Recharge;
|
2014-11-06 09:25:49 +01:00
|
|
|
import mineplex.core.serverConfig.ServerConfiguration;
|
2015-06-20 10:43:38 +02:00
|
|
|
import mineplex.core.stats.StatsManager;
|
2013-09-18 00:50:23 +02:00
|
|
|
import mineplex.core.status.ServerStatusManager;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.teleport.Teleport;
|
2013-09-02 13:19:56 +02:00
|
|
|
import mineplex.core.updater.FileUpdater;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.updater.Updater;
|
2015-08-02 11:24:34 +02:00
|
|
|
import mineplex.core.velocity.VelocityFix;
|
2015-03-13 01:34:45 +01:00
|
|
|
import mineplex.core.visibility.VisibilityManager;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.minecraft.game.core.combat.CombatManager;
|
|
|
|
import mineplex.minecraft.game.core.damage.DamageManager;
|
|
|
|
import nautilus.game.arcade.game.GameServerConfig;
|
2014-04-11 07:33:31 +02:00
|
|
|
|
2014-07-01 19:23:22 +02:00
|
|
|
public class Arcade extends JavaPlugin
|
2014-05-02 06:35:41 +02:00
|
|
|
{
|
2014-04-28 06:59:18 +02:00
|
|
|
private String WEB_CONFIG = "webServer";
|
2014-04-11 07:33:31 +02:00
|
|
|
|
2014-04-03 06:48:58 +02:00
|
|
|
//Modules
|
2014-04-12 10:28:33 +02:00
|
|
|
private CoreClientManager _clientManager;
|
2014-04-04 04:26:00 +02:00
|
|
|
private DonationManager _donationManager;
|
2013-08-27 17:14:08 +02:00
|
|
|
private DamageManager _damageManager;
|
2014-04-11 07:33:31 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
private ArcadeManager _gameManager;
|
2015-06-22 05:38:25 +02:00
|
|
|
|
2014-11-06 09:25:49 +01:00
|
|
|
private ServerConfiguration _serverConfiguration;
|
2014-04-11 07:33:31 +02:00
|
|
|
|
2014-04-02 12:22:21 +02:00
|
|
|
@Override
|
|
|
|
public void onEnable()
|
2014-08-19 23:54:28 +02:00
|
|
|
{
|
2014-08-16 06:17:15 +02:00
|
|
|
//Delete Old Games Folders
|
2014-04-30 19:57:19 +02:00
|
|
|
DeleteFolders();
|
2014-11-22 03:20:34 +01:00
|
|
|
|
2014-08-16 06:17:15 +02:00
|
|
|
//Configs
|
2014-02-21 22:32:14 +01:00
|
|
|
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
2013-08-27 17:14:08 +02:00
|
|
|
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
2014-07-01 19:23:22 +02:00
|
|
|
saveConfig();
|
|
|
|
|
|
|
|
String webServerAddress = getConfig().getString(WEB_CONFIG);
|
2014-04-11 07:33:31 +02:00
|
|
|
|
2015-01-23 08:18:38 +01:00
|
|
|
//Logger.initialize(this);
|
2014-08-16 06:17:15 +02:00
|
|
|
|
2014-07-01 19:23:22 +02:00
|
|
|
//Static Modules
|
|
|
|
CommandCenter.Initialize(this);
|
2014-07-02 06:42:00 +02:00
|
|
|
_clientManager = new CoreClientManager(this, webServerAddress);
|
|
|
|
CommandCenter.Instance.setClientManager(_clientManager);
|
2014-04-11 07:33:31 +02:00
|
|
|
|
2015-08-02 11:24:34 +02:00
|
|
|
|
2014-04-04 04:26:00 +02:00
|
|
|
ItemStackFactory.Initialize(this, false);
|
2014-05-03 05:06:15 +02:00
|
|
|
Recharge.Initialize(this);
|
2015-03-13 01:34:45 +01:00
|
|
|
VisibilityManager.Initialize(this);
|
2015-03-16 03:39:33 +01:00
|
|
|
Give.Initialize(this);
|
2015-08-02 11:24:34 +02:00
|
|
|
|
|
|
|
//Velocity Fix
|
|
|
|
new VelocityFix(this);
|
2014-04-11 07:33:31 +02:00
|
|
|
|
2014-12-29 12:44:00 +01:00
|
|
|
_donationManager = new DonationManager(this, _clientManager, webServerAddress);
|
2014-04-11 07:33:31 +02:00
|
|
|
|
2015-03-02 21:33:04 +01:00
|
|
|
_serverConfiguration = new ServerConfiguration(this, _clientManager);
|
2014-11-06 09:25:49 +01:00
|
|
|
|
2014-06-08 18:27:14 +02:00
|
|
|
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
|
2014-04-11 07:33:31 +02:00
|
|
|
|
2014-03-09 09:50:13 +01:00
|
|
|
Creature creature = new Creature(this);
|
2014-12-14 08:30:39 +01:00
|
|
|
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
|
2015-02-20 00:53:46 +01:00
|
|
|
LeaderboardManager leaderboardManager = new LeaderboardManager(this, _clientManager);
|
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-09-12 22:03:33 +02:00
|
|
|
PacketHandler packetHandler = new PacketHandler(this);
|
|
|
|
|
|
|
|
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
|
2014-04-11 07:33:31 +02:00
|
|
|
|
2015-05-12 02:55:26 +02:00
|
|
|
_damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager, null);
|
2014-04-11 07:33:31 +02:00
|
|
|
|
2014-07-01 19:23:22 +02:00
|
|
|
Punish punish = new Punish(this, webServerAddress, _clientManager);
|
2014-09-29 18:14:20 +02:00
|
|
|
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
|
2014-10-12 05:19:35 +02:00
|
|
|
AntiHack.Instance.setKick(false);
|
2014-05-03 05:06:15 +02:00
|
|
|
|
2015-02-09 14:31:33 +01:00
|
|
|
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
|
2015-06-20 10:43:38 +02:00
|
|
|
StatsManager statsManager = new StatsManager(this, _clientManager);
|
|
|
|
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager);
|
2015-02-11 16:08:06 +01:00
|
|
|
FriendManager friendManager = new FriendManager(this, _clientManager, preferenceManager, portal);
|
2015-06-20 10:43:38 +02:00
|
|
|
Chat chat = new Chat(this, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
|
2015-05-01 06:56:08 +02:00
|
|
|
new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat);
|
2015-02-09 14:31:33 +01:00
|
|
|
|
2014-08-09 05:10:02 +02:00
|
|
|
BlockRestore blockRestore = new BlockRestore(this);
|
|
|
|
|
2014-08-22 20:30:41 +02:00
|
|
|
ProjectileManager projectileManager = new ProjectileManager(this);
|
2014-11-25 22:28:37 +01:00
|
|
|
HologramManager hologramManager = new HologramManager(this);
|
2014-08-22 20:30:41 +02:00
|
|
|
|
2014-08-09 11:55:05 +02:00
|
|
|
//Inventory
|
2014-11-25 22:25:13 +01:00
|
|
|
InventoryManager inventoryManager = new InventoryManager(this, _clientManager);
|
2014-12-14 08:30:39 +01:00
|
|
|
PetManager petManager = new PetManager(this, _clientManager, _donationManager, disguiseManager, creature, blockRestore, webServerAddress);
|
2014-08-22 20:30:41 +02:00
|
|
|
MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager);
|
2015-08-07 21:45:38 +02:00
|
|
|
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager);
|
2014-12-01 11:27:39 +01:00
|
|
|
CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null);
|
2014-08-10 02:50:31 +02:00
|
|
|
cosmeticManager.setInterfaceSlot(7);
|
2015-02-17 03:17:14 +01:00
|
|
|
|
2014-08-09 11:55:05 +02:00
|
|
|
//Arcade Manager
|
2015-06-20 10:43:38 +02:00
|
|
|
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress);
|
2014-09-01 09:56:32 +02:00
|
|
|
|
2013-10-14 06:51:38 +02:00
|
|
|
new MemoryFix(this);
|
2014-10-19 04:15:53 +02:00
|
|
|
new CustomTagFix(this, packetHandler);
|
2015-02-07 05:39:22 +01:00
|
|
|
new TablistFix(this);
|
2014-10-03 10:50:23 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Updates
|
|
|
|
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
2014-08-23 08:49:48 +02:00
|
|
|
|
|
|
|
MinecraftServer.getServer().getPropertyManager().setProperty("debug", true);
|
2015-05-13 23:55:22 +02:00
|
|
|
|
|
|
|
// Remove nasty biomes from natural terrain generation, used for UHC
|
|
|
|
BiomeBase.getBiomes()[BiomeBase.OCEAN.id] = BiomeBase.PLAINS;
|
|
|
|
BiomeBase.getBiomes()[BiomeBase.DEEP_OCEAN.id] = BiomeBase.PLAINS;
|
|
|
|
BiomeBase.getBiomes()[BiomeBase.SWAMPLAND.id] = BiomeBase.PLAINS;
|
|
|
|
BiomeBase.getBiomes()[BiomeBase.RIVER.id] = BiomeBase.PLAINS;
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-30 23:45:11 +01:00
|
|
|
public void onDisable()
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
player.kickPlayer("Server Shutdown");
|
|
|
|
|
|
|
|
if (_gameManager.GetGame() != null)
|
|
|
|
if (_gameManager.GetGame().WorldData != null)
|
|
|
|
_gameManager.GetGame().WorldData.Uninitialize();
|
|
|
|
}
|
|
|
|
|
2014-05-03 05:06:15 +02:00
|
|
|
public GameServerConfig ReadServerConfig()
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
|
|
|
GameServerConfig config = new GameServerConfig();
|
|
|
|
|
2014-11-07 11:14:34 +01:00
|
|
|
try
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2014-12-23 06:49:52 +01:00
|
|
|
config.HostName = _serverConfiguration.getServerGroup().getHost();
|
2014-11-07 11:14:34 +01:00
|
|
|
config.ServerType = _serverConfiguration.getServerGroup().getServerType();
|
|
|
|
config.MinPlayers = _serverConfiguration.getServerGroup().getMinPlayers();
|
|
|
|
config.MaxPlayers = _serverConfiguration.getServerGroup().getMaxPlayers();
|
|
|
|
config.Tournament = _serverConfiguration.getServerGroup().getTournament();
|
|
|
|
config.TournamentPoints = _serverConfiguration.getServerGroup().getTournamentPoints();
|
|
|
|
config.TeamRejoin = _serverConfiguration.getServerGroup().getTeamRejoin();
|
|
|
|
config.TeamAutoJoin = _serverConfiguration.getServerGroup().getTeamAutoJoin();
|
|
|
|
config.TeamForceBalance = _serverConfiguration.getServerGroup().getTeamForceBalance();
|
|
|
|
config.GameAutoStart = _serverConfiguration.getServerGroup().getGameAutoStart();
|
|
|
|
config.GameTimeout = _serverConfiguration.getServerGroup().getGameTimeout();
|
|
|
|
config.RewardGems = _serverConfiguration.getServerGroup().getRewardGems();
|
|
|
|
config.RewardItems = _serverConfiguration.getServerGroup().getRewardItems();
|
|
|
|
config.RewardStats = _serverConfiguration.getServerGroup().getRewardStats();
|
|
|
|
config.RewardAchievements = _serverConfiguration.getServerGroup().getRewardAchievements();
|
|
|
|
config.HotbarInventory = _serverConfiguration.getServerGroup().getHotbarInventory();
|
|
|
|
config.HotbarHubClock = _serverConfiguration.getServerGroup().getHotbarHubClock();
|
|
|
|
config.PlayerKickIdle = _serverConfiguration.getServerGroup().getPlayerKickIdle();
|
|
|
|
|
|
|
|
for (String gameName : _serverConfiguration.getServerGroup().getGames().split(","))
|
2014-11-06 09:25:49 +01:00
|
|
|
{
|
2014-11-07 11:14:34 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
GameType type = GameType.valueOf(gameName);
|
|
|
|
config.GameList.add(type);
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2014-11-06 09:25:49 +01:00
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
2014-11-07 11:14:34 +01:00
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
System.out.println("Error reading ServerConfiguration values : " + ex.getMessage());
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
if (!config.IsValid())
|
|
|
|
config = GetDefaultConfig();
|
2014-04-11 07:33:31 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
|
|
|
public GameServerConfig GetDefaultConfig()
|
|
|
|
{
|
|
|
|
GameServerConfig config = new GameServerConfig();
|
|
|
|
|
|
|
|
config.ServerType = "Minigames";
|
|
|
|
config.MinPlayers = 8;
|
|
|
|
config.MaxPlayers = 16;
|
2014-05-02 06:35:41 +02:00
|
|
|
config.Tournament = false;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void DeleteFolders()
|
|
|
|
{
|
|
|
|
File curDir = new File(".");
|
|
|
|
|
|
|
|
File[] filesList = curDir.listFiles();
|
|
|
|
for(File file : filesList)
|
|
|
|
{
|
|
|
|
if (!file.isDirectory())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (file.getName().length() < 4)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!file.getName().substring(0, 4).equalsIgnoreCase("Game"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
FileUtil.DeleteFolder(file);
|
|
|
|
|
|
|
|
System.out.println("Deleted Old Game: " + file.getName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|