2013-08-27 17:14:08 +02:00
|
|
|
package nautilus.game.arcade;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import nautilus.game.arcade.addons.*;
|
|
|
|
import nautilus.game.arcade.command.*;
|
|
|
|
import nautilus.game.arcade.game.Game;
|
|
|
|
import nautilus.game.arcade.game.Game.GameState;
|
|
|
|
import nautilus.game.arcade.game.GameServerConfig;
|
|
|
|
import nautilus.game.arcade.game.GameTeam;
|
|
|
|
import nautilus.game.arcade.managers.*;
|
|
|
|
import nautilus.game.arcade.shop.ArcadeShop;
|
|
|
|
import nautilus.game.arcade.world.FireworkHandler;
|
|
|
|
|
2013-09-07 02:43:45 +02:00
|
|
|
import org.bukkit.Bukkit;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.GameMode;
|
|
|
|
import org.bukkit.Material;
|
2013-11-14 06:28:29 +01:00
|
|
|
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
2013-09-20 10:50:56 +02:00
|
|
|
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
|
2013-12-03 06:26:47 +01:00
|
|
|
import org.bukkit.entity.Chicken;
|
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
import org.bukkit.entity.IronGolem;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.entity.Player;
|
2013-12-03 06:26:47 +01:00
|
|
|
import org.bukkit.entity.Skeleton;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.event.EventHandler;
|
2013-11-22 08:40:38 +01:00
|
|
|
import org.bukkit.event.block.BlockBurnEvent;
|
|
|
|
import org.bukkit.event.block.BlockFadeEvent;
|
|
|
|
import org.bukkit.event.block.BlockSpreadEvent;
|
|
|
|
import org.bukkit.event.block.LeavesDecayEvent;
|
|
|
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
2013-12-03 06:26:47 +01:00
|
|
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.event.player.PlayerJoinEvent;
|
2013-09-07 02:43:45 +02:00
|
|
|
import org.bukkit.event.player.PlayerLoginEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.event.player.PlayerQuitEvent;
|
|
|
|
import org.bukkit.event.server.ServerListPingEvent;
|
|
|
|
|
2013-10-31 07:35:24 +01:00
|
|
|
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
|
|
|
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
|
|
|
|
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
|
|
|
import mineplex.minecraft.game.classcombat.shop.ClassCombatCustomBuildShop;
|
|
|
|
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.minecraft.game.core.IRelation;
|
|
|
|
import mineplex.minecraft.game.core.condition.ConditionManager;
|
|
|
|
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
|
|
|
import mineplex.minecraft.game.core.damage.DamageManager;
|
|
|
|
import mineplex.minecraft.game.core.fire.Fire;
|
|
|
|
import mineplex.core.MiniPlugin;
|
|
|
|
import mineplex.core.itemstack.ItemStackFactory;
|
2013-08-31 05:15:16 +02:00
|
|
|
import me.chiss.Core.Modules.Blood;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.account.CoreClientManager;
|
2013-09-13 04:24:33 +02:00
|
|
|
import mineplex.core.antistack.AntiStack;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.blockrestore.BlockRestore;
|
2013-09-04 20:35:59 +02:00
|
|
|
import mineplex.core.chat.Chat;
|
2013-09-07 02:43:45 +02:00
|
|
|
import mineplex.core.common.Rank;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.common.util.*;
|
|
|
|
import mineplex.core.creature.Creature;
|
|
|
|
import mineplex.core.disguise.DisguiseManager;
|
|
|
|
import mineplex.core.donation.DonationManager;
|
|
|
|
import mineplex.core.packethandler.PacketHandler;
|
|
|
|
import mineplex.core.explosion.Explosion;
|
|
|
|
import mineplex.core.portal.Portal;
|
|
|
|
import mineplex.core.projectile.ProjectileManager;
|
2013-12-14 06:00:56 +01:00
|
|
|
import mineplex.core.stats.StatsManager;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
2013-09-04 20:35:59 +02:00
|
|
|
public class ArcadeManager extends MiniPlugin implements IRelation
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
|
|
|
//Modules
|
2013-09-13 04:24:33 +02:00
|
|
|
private AntiStack _antistack;
|
2013-08-27 17:14:08 +02:00
|
|
|
private BlockRestore _blockRestore;
|
2013-08-31 05:15:16 +02:00
|
|
|
private Blood _blood;
|
2013-08-27 17:14:08 +02:00
|
|
|
private Chat _chat;
|
|
|
|
private CoreClientManager _clientManager;
|
|
|
|
private DisguiseManager _disguiseManager;
|
|
|
|
private DonationManager _donationManager;
|
|
|
|
private ConditionManager _conditionManager;
|
|
|
|
private Creature _creature;
|
|
|
|
private DamageManager _damageManager;
|
|
|
|
private Explosion _explosionManager;
|
|
|
|
private Fire _fire;
|
|
|
|
private FireworkHandler _firework;
|
|
|
|
private ProjectileManager _projectileManager;
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-09-02 01:51:53 +02:00
|
|
|
private Portal _portal;
|
2013-08-27 17:14:08 +02:00
|
|
|
private ArcadeShop _arcadeShop;
|
|
|
|
|
|
|
|
//Managers
|
|
|
|
private GameFactory _gameFactory;
|
|
|
|
private GameCreationManager _gameCreationManager;
|
|
|
|
private GameGemManager _gameGemManager;
|
|
|
|
private GameManager _gameManager;
|
|
|
|
private GameLobbyManager _gameLobbyManager;
|
|
|
|
private GameWorldManager _gameWorldManager;
|
2013-12-14 06:00:56 +01:00
|
|
|
|
|
|
|
private StatsManager _statsManager;
|
2013-10-31 07:35:24 +01:00
|
|
|
private ClassManager _classManager;
|
|
|
|
private SkillFactory _skillFactory;
|
|
|
|
private ClassShopManager _classShopManager;
|
|
|
|
private ClassCombatCustomBuildShop _classCustomBuildShop;
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Server Games
|
|
|
|
private GameServerConfig _serverConfig;
|
|
|
|
|
|
|
|
//Games
|
|
|
|
private Game _game;
|
|
|
|
|
2013-11-07 00:18:36 +01:00
|
|
|
public ArcadeManager(Arcade plugin, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DamageManager damageManager, DisguiseManager disguiseManager, Creature creature, Blood blood, AntiStack antistack, Portal portal, PacketHandler packetHandler, String webAddress)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
|
|
|
super("Game Manager", plugin);
|
|
|
|
|
|
|
|
_serverConfig = serverConfig;
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Modules
|
2013-09-13 04:24:33 +02:00
|
|
|
_antistack = antistack;
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
_blockRestore = new BlockRestore(plugin);
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-31 05:15:16 +02:00
|
|
|
_blood = blood;
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
_explosionManager = new Explosion(plugin, _blockRestore);
|
|
|
|
_explosionManager.SetDebris(false);
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
_conditionManager = conditionManager;
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
_clientManager = clientManager;
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-09-04 20:35:59 +02:00
|
|
|
_chat = new Chat(plugin, _clientManager);
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
_creature = creature;
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
_damageManager = damageManager;
|
2013-09-09 10:06:44 +02:00
|
|
|
_damageManager.UseSimpleWeaponDamage = true;
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-31 05:15:16 +02:00
|
|
|
_disguiseManager = disguiseManager;
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
_donationManager = donationManager;
|
|
|
|
|
|
|
|
_firework = new FireworkHandler();
|
|
|
|
_fire = new Fire(plugin, conditionManager, damageManager);
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-11-02 00:09:07 +01:00
|
|
|
_projectileManager = new ProjectileManager(plugin);
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-11-02 00:09:07 +01:00
|
|
|
/*
|
2013-10-31 07:35:24 +01:00
|
|
|
_skillFactory = new SkillFactory(plugin, damageManager, this, new CombatManager(plugin), conditionManager, _projectileManager, _blockRestore, _fire, new Movement(plugin), plugin.GetTeleport(), new Energy(plugin), webAddress);
|
|
|
|
_classManager = new ClassManager(plugin, clientManager, donationManager, _skillFactory, webAddress);
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-10-31 07:35:24 +01:00
|
|
|
_classShopManager = new ClassShopManager(_plugin, _classManager, _skillFactory, new ItemPackFactory(_plugin));
|
|
|
|
_classCustomBuildShop = new ClassCombatCustomBuildShop(_classShopManager, clientManager, donationManager, webAddress);
|
2013-11-22 08:40:38 +01:00
|
|
|
*/
|
|
|
|
|
2013-12-14 06:00:56 +01:00
|
|
|
_statsManager = new StatsManager(plugin);
|
|
|
|
|
2013-11-07 00:18:36 +01:00
|
|
|
_portal = portal;
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Shop
|
|
|
|
_arcadeShop = new ArcadeShop(this, clientManager, donationManager);
|
|
|
|
|
|
|
|
//Game Factory
|
|
|
|
_gameFactory = new GameFactory(this);
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Managers
|
2013-09-04 20:35:59 +02:00
|
|
|
new GameChatManager(this);
|
2013-08-27 17:14:08 +02:00
|
|
|
_gameCreationManager = new GameCreationManager(this);
|
|
|
|
_gameGemManager = new GameGemManager(this);
|
|
|
|
_gameManager = new GameManager(this);
|
|
|
|
_gameLobbyManager = new GameLobbyManager(this, packetHandler);
|
|
|
|
new GameFlagManager(this);
|
|
|
|
new GamePlayerManager(this);
|
|
|
|
_gameWorldManager = new GameWorldManager(this);
|
|
|
|
new MiscManager(this);
|
2013-09-02 10:45:12 +02:00
|
|
|
new IdleManager(this);
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Game Addons
|
|
|
|
new CompassAddon(plugin, this);
|
|
|
|
new SoupAddon(plugin, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void AddCommands()
|
|
|
|
{
|
|
|
|
AddCommand(new GameCommand(this));
|
|
|
|
AddCommand(new ParseCommand(this));
|
|
|
|
AddCommand(new WriteCommand(this));
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public GameServerConfig GetServerConfig()
|
|
|
|
{
|
|
|
|
return _serverConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ArrayList<GameType> GetGameList()
|
|
|
|
{
|
|
|
|
return GetServerConfig().GameList;
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-09-13 04:24:33 +02:00
|
|
|
public AntiStack GetAntiStack()
|
|
|
|
{
|
|
|
|
return _antistack;
|
|
|
|
}
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-08-31 05:15:16 +02:00
|
|
|
public Blood GetBlood()
|
|
|
|
{
|
|
|
|
return _blood;
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
public Chat GetChat()
|
|
|
|
{
|
|
|
|
return _chat;
|
|
|
|
}
|
|
|
|
|
|
|
|
public BlockRestore GetBlockRestore()
|
|
|
|
{
|
|
|
|
return _blockRestore;
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public CoreClientManager GetClients()
|
|
|
|
{
|
|
|
|
return _clientManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ConditionManager GetCondition()
|
|
|
|
{
|
|
|
|
return _conditionManager;
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public Creature GetCreature()
|
|
|
|
{
|
|
|
|
return _creature;
|
|
|
|
}
|
|
|
|
|
|
|
|
public DisguiseManager GetDisguise()
|
|
|
|
{
|
|
|
|
return _disguiseManager;
|
2013-09-13 04:24:33 +02:00
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public DamageManager GetDamage()
|
|
|
|
{
|
|
|
|
return _damageManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public DonationManager GetDonation()
|
|
|
|
{
|
|
|
|
return _donationManager;
|
|
|
|
}
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-09-06 07:58:58 +02:00
|
|
|
public Explosion GetExplosion()
|
|
|
|
{
|
|
|
|
return _explosionManager;
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
public Fire GetFire()
|
|
|
|
{
|
|
|
|
return _fire;
|
|
|
|
}
|
|
|
|
|
|
|
|
public FireworkHandler GetFirework()
|
|
|
|
{
|
|
|
|
return _firework;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ProjectileManager GetProjectile()
|
|
|
|
{
|
|
|
|
return _projectileManager;
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-09-02 10:45:12 +02:00
|
|
|
public Portal GetPortal()
|
|
|
|
{
|
|
|
|
return _portal;
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public GameLobbyManager GetLobby()
|
|
|
|
{
|
|
|
|
return _gameLobbyManager;
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public ArcadeShop GetShop()
|
|
|
|
{
|
|
|
|
return _arcadeShop;
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public GameCreationManager GetGameCreationManager()
|
|
|
|
{
|
|
|
|
return _gameCreationManager;
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public GameFactory GetGameFactory()
|
|
|
|
{
|
|
|
|
return _gameFactory;
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public GameManager GetGameManager()
|
|
|
|
{
|
|
|
|
return _gameManager;
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public GameGemManager GetGameGemManager()
|
|
|
|
{
|
|
|
|
return _gameGemManager;
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public GameWorldManager GetGameWorldManager()
|
|
|
|
{
|
|
|
|
return _gameWorldManager;
|
|
|
|
}
|
|
|
|
|
2013-12-14 06:00:56 +01:00
|
|
|
public StatsManager GetStatsManager()
|
|
|
|
{
|
|
|
|
return _statsManager;
|
|
|
|
}
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public ChatColor GetColor(Player player)
|
|
|
|
{
|
|
|
|
if (_game == null)
|
|
|
|
return ChatColor.GRAY;
|
|
|
|
|
|
|
|
GameTeam team = _game.GetTeam(player);
|
|
|
|
if (team == null)
|
|
|
|
return ChatColor.GRAY;
|
|
|
|
|
|
|
|
return team.GetColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean CanHurt(String a, String b)
|
|
|
|
{
|
|
|
|
return CanHurt(UtilPlayer.searchExact(a), UtilPlayer.searchExact(b));
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean CanHurt(Player pA, Player pB)
|
|
|
|
{
|
|
|
|
if (pA == null || pB == null)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!_game.Damage)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!_game.DamagePvP)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
//Self Damage
|
|
|
|
if (pA.equals(pB))
|
|
|
|
return _game.DamageSelf;
|
|
|
|
|
|
|
|
GameTeam tA = _game.GetTeam(pA);
|
|
|
|
if (tA == null)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
GameTeam tB = _game.GetTeam(pB);
|
|
|
|
if (tB == null)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (tA.equals(tB) && !_game.DamageTeamSelf)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!tA.equals(tB) && !_game.DamageTeamOther)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean IsSafe(Player player)
|
|
|
|
{
|
|
|
|
if (_game == null)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (_game.IsPlaying(player))
|
|
|
|
return false;
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void MessageMOTD(ServerListPingEvent event)
|
|
|
|
{
|
2013-09-09 10:28:35 +02:00
|
|
|
String extrainformation = "|" + _serverConfig.ServerType + "|" + (_game == null ? "Unknown" : _game.GetName()) + "|" + ((_game == null || _game.WorldData == null) ? "Unknown" : _game.WorldData.MapName);
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
if (_game == null || _game.GetState() == GameState.Recruit)
|
|
|
|
{
|
2013-09-11 04:22:55 +02:00
|
|
|
if (_game != null && _game.GetType() == GameType.UHC)
|
|
|
|
{
|
2013-12-04 02:45:17 +01:00
|
|
|
event.setMotd(ChatColor.RED + "UHC - Season 4");
|
2013-09-11 04:22:55 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
if (_game != null && _game.GetCountdown() != -1)
|
|
|
|
{
|
2013-09-09 10:28:35 +02:00
|
|
|
event.setMotd(ChatColor.GREEN + "Starting in " + _game.GetCountdown() + " Seconds" + extrainformation);
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-09 10:28:35 +02:00
|
|
|
event.setMotd(ChatColor.GREEN + "Recruiting" + extrainformation);
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-09 10:28:35 +02:00
|
|
|
event.setMotd(ChatColor.YELLOW + "In Progress" + extrainformation);
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
|
|
|
public void MessageJoin(PlayerJoinEvent event)
|
|
|
|
{
|
2013-09-09 10:06:44 +02:00
|
|
|
if (_game == null || _game.AnnounceJoinQuit)
|
|
|
|
event.setJoinMessage(F.sys("Join", event.getPlayer().getName()));
|
|
|
|
else
|
|
|
|
event.setJoinMessage(null);
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void MessageQuit(PlayerQuitEvent event)
|
|
|
|
{
|
2013-09-09 10:06:44 +02:00
|
|
|
if (_game == null || _game.AnnounceJoinQuit)
|
|
|
|
event.setQuitMessage(F.sys("Quit", GetColor(event.getPlayer()) + event.getPlayer().getName()));
|
|
|
|
else
|
|
|
|
event.setQuitMessage(null);
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Game GetGame()
|
|
|
|
{
|
|
|
|
return _game;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetGame(Game game)
|
|
|
|
{
|
|
|
|
_game = game;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int GetPlayerMin()
|
|
|
|
{
|
|
|
|
return GetServerConfig().MinPlayers;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int GetPlayerFull()
|
|
|
|
{
|
|
|
|
return GetServerConfig().MaxPlayers;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void HubClock(Player player)
|
|
|
|
{
|
2013-08-31 05:15:16 +02:00
|
|
|
player.getInventory().setItem(8, ItemStackFactory.Instance.CreateStack(Material.WATCH, (byte)0, 1, (short)0, C.cGreen + "Return to Hub",
|
2013-08-27 17:14:08 +02:00
|
|
|
new String[] {"", ChatColor.RESET + "Click while holding this", ChatColor.RESET + "to return to the Hub."}));
|
|
|
|
}
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-09-07 02:43:45 +02:00
|
|
|
@EventHandler
|
|
|
|
public void Login(PlayerLoginEvent event)
|
2013-10-12 07:03:17 +02:00
|
|
|
{
|
2013-11-22 08:40:38 +01:00
|
|
|
// Reserved Slot Check
|
2013-09-07 02:43:45 +02:00
|
|
|
if (Bukkit.getOnlinePlayers().length >= Bukkit.getServer().getMaxPlayers())
|
|
|
|
{
|
2013-10-12 11:53:22 +02:00
|
|
|
if (_clientManager.Get(event.getPlayer().getName()).GetRank().Has(event.getPlayer(), Rank.ULTRA, false) || _donationManager.Get(event.getPlayer().getName()).OwnsUnknownPackage(_serverConfig.ServerType + " ULTRA"))
|
2013-09-07 02:43:45 +02:00
|
|
|
{
|
|
|
|
event.allow();
|
|
|
|
event.setResult(PlayerLoginEvent.Result.ALLOWED);
|
|
|
|
return;
|
|
|
|
}
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-09-07 02:43:45 +02:00
|
|
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server Full > Donate for Ultra");
|
|
|
|
}
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public boolean IsAlive(Player player)
|
|
|
|
{
|
2013-09-09 10:06:44 +02:00
|
|
|
if (_game == null)
|
2013-08-27 17:14:08 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return _game.IsAlive(player);
|
|
|
|
}
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
public void Clear(Player player)
|
|
|
|
{
|
|
|
|
player.setGameMode(GameMode.SURVIVAL);
|
|
|
|
player.setAllowFlight(false);
|
|
|
|
UtilInv.Clear(player);
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-11-14 06:28:29 +01:00
|
|
|
((CraftEntity)player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0));
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
player.setFoodLevel(20);
|
2013-09-13 04:24:33 +02:00
|
|
|
player.setSaturation(3f);
|
|
|
|
player.setExhaustion(0f);
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-09-09 10:06:44 +02:00
|
|
|
player.setHealth(20);
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
player.setFireTicks(0);
|
|
|
|
player.setFallDistance(0);
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
player.setLevel(0);
|
|
|
|
player.setExp(0f);
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
((CraftPlayer)player).getHandle().spectating = false;
|
|
|
|
((CraftPlayer)player).getHandle().m = true;
|
|
|
|
|
2013-11-02 05:42:37 +01:00
|
|
|
GetCondition().EndCondition(player, ConditionType.CLOAK, null);
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
HubClock(player);
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-09-02 01:38:32 +02:00
|
|
|
GetDisguise().undisguise(player);
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public ArrayList<String> LoadFiles(String gameName)
|
|
|
|
{
|
2013-11-06 01:10:14 +01:00
|
|
|
File folder = new File(".." + File.separatorChar + ".." + File.separatorChar + "update" + File.separatorChar + "maps" + File.separatorChar + gameName);
|
2013-08-27 17:14:08 +02:00
|
|
|
if (!folder.exists()) folder.mkdirs();
|
|
|
|
|
|
|
|
ArrayList<String> maps = new ArrayList<String>();
|
|
|
|
|
|
|
|
System.out.println("Searching Maps in: " + folder);
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
for (File file : folder.listFiles())
|
|
|
|
{
|
|
|
|
if (!file.isFile())
|
|
|
|
continue;
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
String name = file.getName();
|
|
|
|
|
|
|
|
if (name.length() < 5)
|
|
|
|
continue;
|
2013-09-04 23:44:53 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
name = name.substring(name.length()-4, name.length());
|
|
|
|
|
|
|
|
if (file.getName().equals(".zip"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
maps.add(file.getName().substring(0, file.getName().length()-4));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (String map : maps)
|
|
|
|
System.out.println("Found Map: " + map);
|
|
|
|
|
|
|
|
return maps;
|
|
|
|
}
|
2013-10-31 07:35:24 +01:00
|
|
|
|
|
|
|
public ClassManager getClassManager()
|
|
|
|
{
|
|
|
|
return _classManager;
|
|
|
|
}
|
2013-11-22 08:40:38 +01:00
|
|
|
|
2013-10-31 07:35:24 +01:00
|
|
|
public ClassCombatCustomBuildShop getClassShop()
|
|
|
|
{
|
|
|
|
return _classCustomBuildShop;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void openClassShop(Player player, IPvpClass pvpClass)
|
|
|
|
{
|
|
|
|
_classCustomBuildShop.attemptShopOpen(player);
|
|
|
|
}
|
2013-11-22 08:40:38 +01:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void BlockBurn(BlockBurnEvent event)
|
|
|
|
{
|
|
|
|
if (_game == null)
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void BlockSpread(BlockSpreadEvent event)
|
|
|
|
{
|
|
|
|
if (_game == null)
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void BlockFade(BlockFadeEvent event)
|
|
|
|
{
|
|
|
|
if (_game == null)
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void BlockDecay(LeavesDecayEvent event)
|
|
|
|
{
|
|
|
|
if (_game == null)
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
2013-12-03 06:26:47 +01:00
|
|
|
//@EventHandler
|
2013-11-22 08:40:38 +01:00
|
|
|
public void MobSpawn(CreatureSpawnEvent event)
|
|
|
|
{
|
|
|
|
if (_game == null)
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
2013-12-03 06:26:47 +01:00
|
|
|
|
|
|
|
@EventHandler//XXX
|
|
|
|
public void TEST(PlayerCommandPreprocessEvent event)
|
|
|
|
{
|
|
|
|
if (event.getMessage().equals("/test1"))
|
|
|
|
{
|
|
|
|
Chicken chicken = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
|
|
|
|
chicken.setBaby();
|
|
|
|
Entity a = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 42, (byte)0);
|
|
|
|
Entity b = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 41, (byte)0);
|
|
|
|
|
|
|
|
chicken.setPassenger(a);
|
|
|
|
a.setPassenger(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event.getMessage().equals("/test2"))
|
|
|
|
{
|
|
|
|
Chicken chicken = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
|
|
|
|
chicken.setBaby();
|
|
|
|
Entity a = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 42, (byte)0);
|
|
|
|
Entity b = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 41, (byte)0);
|
|
|
|
|
|
|
|
Chicken chickenb = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
|
|
|
|
chickenb.setBaby();
|
|
|
|
chickenb.setCustomName("Dinnerbone");
|
|
|
|
|
|
|
|
chicken.setPassenger(chickenb);
|
|
|
|
chickenb.setPassenger(a);
|
|
|
|
a.setPassenger(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event.getMessage().equals("/test3"))
|
|
|
|
{
|
|
|
|
Chicken chicken = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
|
|
|
|
chicken.setBaby();
|
|
|
|
Chicken chickenb = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
|
|
|
|
chickenb.setBaby();
|
|
|
|
Chicken chickenc = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
|
|
|
|
chickenc.setBaby();
|
|
|
|
Entity a = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 42, (byte)0);
|
|
|
|
Entity b = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 41, (byte)0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chicken.setPassenger(chickenb);
|
|
|
|
chickenb.setPassenger(chickenc);
|
|
|
|
chickenc.setPassenger(a);
|
|
|
|
a.setPassenger(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event.getMessage().equals("/test4"))
|
|
|
|
{
|
|
|
|
Chicken chicken = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
|
|
|
|
chicken.setBaby();
|
|
|
|
Chicken chickenb = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
|
|
|
|
chickenb.setBaby();
|
|
|
|
Chicken chickenc = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
|
|
|
|
chickenc.setBaby();
|
|
|
|
Chicken chickend = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
|
|
|
|
chickend.setBaby();
|
|
|
|
Entity a = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 42, (byte)0);
|
|
|
|
Entity b = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 44, (byte)0);
|
|
|
|
Entity iron = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Skeleton.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chicken.setPassenger(chickenb);
|
|
|
|
chickenb.setPassenger(chickenc);
|
|
|
|
chickenc.setPassenger(chickend);
|
|
|
|
chickend.setPassenger(a);
|
|
|
|
a.setPassenger(iron);
|
|
|
|
iron.setPassenger(b);
|
|
|
|
}
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|