Fixed whitelist issue with tournament mode.

This commit is contained in:
Jonathan Williams 2014-07-26 10:40:49 -07:00
parent a455042c07
commit 4e1a05e9bd

View File

@ -19,6 +19,7 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
@ -76,7 +77,7 @@ import mineplex.core.timing.TimingManager;
public class ArcadeManager extends MiniPlugin implements IRelation
{
//Modules
// Modules
private AntiStack _antistack;
private BlockRestore _blockRestore;
private Blood _blood;
@ -95,7 +96,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private Portal _portal;
private ArcadeShop _arcadeShop;
//Managers
// Managers
private GameFactory _gameFactory;
private GameCreationManager _gameCreationManager;
private GameGemManager _gameGemManager;
@ -115,16 +116,19 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private MiscManager _miscManager;
//Observers
// Observers
private HashSet<Player> _specList = new HashSet<Player>();
//Server Games
// Server Games
private GameServerConfig _serverConfig;
//Games
// Games
private Game _game;
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, AntiStack antistack, Portal portal, PacketHandler packetHandler, PreferencesManager preferences, String webAddress)
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig,
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, AntiStack antistack,
Portal portal, PacketHandler packetHandler, PreferencesManager preferences, String webAddress)
{
super("Game Manager", plugin);
@ -135,7 +139,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
Bukkit.getServer().setWhitelist(true);
}
//Modules
// Modules
_antistack = antistack;
_blockRestore = new BlockRestore(plugin);
@ -145,7 +149,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_explosionManager = new Explosion(plugin, _blockRestore);
_explosionManager.SetDebris(false);
if (serverConfig.GameList.contains(GameType.ChampionsDominate) || serverConfig.GameList.contains(GameType.ChampionsTDM) || serverConfig.GameList.contains(GameType.ChampionsMOBA))
if (serverConfig.GameList.contains(GameType.ChampionsDominate)
|| serverConfig.GameList.contains(GameType.ChampionsTDM)
|| serverConfig.GameList.contains(GameType.ChampionsMOBA))
{
_conditionManager = new SkillConditionManager(plugin);
}
@ -172,12 +178,18 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_projectileManager = new ProjectileManager(plugin);
if (serverConfig.GameList.contains(GameType.ChampionsDominate) || serverConfig.GameList.contains(GameType.ChampionsTDM) || serverConfig.GameList.contains(GameType.ChampionsMOBA))
if (serverConfig.GameList.contains(GameType.ChampionsDominate)
|| serverConfig.GameList.contains(GameType.ChampionsTDM)
|| serverConfig.GameList.contains(GameType.ChampionsMOBA))
{
Energy energy = new Energy(plugin);
ItemFactory itemFactory = new ItemFactory(_plugin, _blockRestore, _conditionManager, damageManager, energy, _fire, _projectileManager, webAddress);
_skillFactory = new SkillFactory(plugin, damageManager, this, _damageManager.GetCombatManager(), _conditionManager, _projectileManager, _blockRestore, _fire, new Movement(plugin), teleport, energy, webAddress);
_classManager = new ClassManager(plugin, clientManager, donationManager, _skillFactory, itemFactory, webAddress);
ItemFactory itemFactory = new ItemFactory(_plugin, _blockRestore, _conditionManager, damageManager, energy,
_fire, _projectileManager, webAddress);
_skillFactory = new SkillFactory(plugin, damageManager, this, _damageManager.GetCombatManager(),
_conditionManager, _projectileManager, _blockRestore, _fire, new Movement(plugin), teleport,
energy, webAddress);
_classManager = new ClassManager(plugin, clientManager, donationManager, _skillFactory, itemFactory,
webAddress);
_classShopManager = new ClassShopManager(_plugin, _classManager, _skillFactory, itemFactory);
_classShop = new ClassCombatShop(_classShopManager, clientManager, donationManager, webAddress);
@ -185,17 +197,17 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_eloManager = new EloManager(_plugin);
}
//_statsManager = new StatsManager(plugin);
// _statsManager = new StatsManager(plugin);
_portal = portal;
//Shop
// Shop
_arcadeShop = new ArcadeShop(this, clientManager, donationManager);
//Game Factory
// Game Factory
_gameFactory = new GameFactory(this);
//Managers
// Managers
new GameChatManager(this);
_gameCreationManager = new GameCreationManager(this);
_gameGemManager = new GameGemManager(this);
@ -208,7 +220,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_miscManager = new MiscManager(this);
new IdleManager(this);
//Game Addons
// Game Addons
new CompassAddon(plugin, this);
new SoupAddon(plugin, this);
new TeamArmorAddon(plugin, this);
@ -385,7 +397,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
if (!_game.DamagePvP)
return false;
//Self Damage
// Self Damage
if (pA.equals(pB))
return _game.DamageSelf;
@ -421,7 +433,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
@EventHandler
public void MessageMOTD(ServerListPingEvent event)
{
String extrainformation = "|" + _serverConfig.ServerType + "|" + (_game == null ? "Unknown" : _game.GetName()) + "|" + ((_game == null || _game.WorldData == null) ? "Unknown" : _game.WorldData.MapName);
String extrainformation = "|" + _serverConfig.ServerType + "|" + (_game == null ? "Unknown" : _game.GetName())
+ "|" + ((_game == null || _game.WorldData == null) ? "Unknown" : _game.WorldData.MapName);
if (_game == null || _game.GetState() == GameState.Recruit)
{
@ -484,8 +497,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
if (_game != null && !_game.GiveClock)
return;
player.getInventory().setItem(8, ItemStackFactory.Instance.CreateStack(Material.WATCH, (byte)0, 1, (short)0, C.cGreen + "Return to Hub",
new String[] {"", ChatColor.RESET + "Click while holding this", ChatColor.RESET + "to return to the Hub."}));
player.getInventory().setItem(
8,
ItemStackFactory.Instance.CreateStack(Material.WATCH, (byte) 0, 1, (short) 0, C.cGreen
+ "Return to Hub", new String[] { "", ChatColor.RESET + "Click while holding this",
ChatColor.RESET + "to return to the Hub." }));
}
@EventHandler
@ -505,6 +521,16 @@ public class ArcadeManager extends MiniPlugin implements IRelation
}
else
{
for (OfflinePlayer player : Bukkit.getWhitelistedPlayers())
{
if (player.getName().equalsIgnoreCase(event.getPlayer().getName()))
{
event.allow();
event.setResult(PlayerLoginEvent.Result.ALLOWED);
return;
}
}
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server Whitelisted!");
}
@ -516,14 +542,18 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
if (_serverStatusManager.getCurrentServerName().contains("BETA"))
{
if (_clientManager.Get(event.getPlayer().getName()).GetRank().Has(event.getPlayer(), Rank.HELPER, false))
if (_clientManager.Get(event.getPlayer().getName()).GetRank()
.Has(event.getPlayer(), Rank.HELPER, false))
{
event.allow();
event.setResult(PlayerLoginEvent.Result.ALLOWED);
return;
}
}
else if (_clientManager.Get(event.getPlayer().getName()).GetRank().Has(event.getPlayer(), Rank.ULTRA, false) || _donationManager.Get(event.getPlayer().getName()).OwnsUnknownPackage(_serverConfig.ServerType + " ULTRA"))
else if (_clientManager.Get(event.getPlayer().getName()).GetRank()
.Has(event.getPlayer(), Rank.ULTRA, false)
|| _donationManager.Get(event.getPlayer().getName()).OwnsUnknownPackage(
_serverConfig.ServerType + " ULTRA"))
{
event.allow();
event.setResult(PlayerLoginEvent.Result.ALLOWED);
@ -549,7 +579,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
player.setAllowFlight(false);
UtilInv.Clear(player);
((CraftEntity)player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0));
((CraftEntity) player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0));
player.setSprinting(false);
@ -566,11 +596,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
player.setLevel(0);
player.setExp(0f);
((CraftPlayer)player).getHandle().spectating = false;
((CraftPlayer)player).getHandle().k = true;
((CraftPlayer) player).getHandle().spectating = false;
((CraftPlayer) player).getHandle().k = true;
// Arrows go bye bye.
((CraftPlayer)player).getHandle().p(0);
((CraftPlayer) player).getHandle().p(0);
GetCondition().EndCondition(player, ConditionType.CLOAK, null);
@ -582,8 +612,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation
public ArrayList<String> LoadFiles(String gameName)
{
TimingManager.start("ArcadeManager LoadFiles");
File folder = new File(".." + File.separatorChar + ".." + File.separatorChar + "update" + File.separatorChar + "maps" + File.separatorChar + gameName);
if (!folder.exists()) folder.mkdirs();
File folder = new File(".." + File.separatorChar + ".." + File.separatorChar + "update" + File.separatorChar
+ "maps" + File.separatorChar + gameName);
if (!folder.exists())
folder.mkdirs();
ArrayList<String> maps = new ArrayList<String>();
@ -599,12 +631,12 @@ public class ArcadeManager extends MiniPlugin implements IRelation
if (name.length() < 5)
continue;
name = name.substring(name.length()-4, name.length());
name = name.substring(name.length() - 4, name.length());
if (file.getName().equals(".zip"))
continue;
maps.add(file.getName().substring(0, file.getName().length()-4));
maps.add(file.getName().substring(0, file.getName().length() - 4));
}
for (String map : maps)
@ -707,15 +739,15 @@ public class ArcadeManager extends MiniPlugin implements IRelation
UtilPlayer.message(event.getPlayer(), F.main("Game", "You are no longer a Spectator!"));
}
//Clean
// Clean
if (_game != null)
{
//Remove Data
// Remove Data
_game.RemoveTeamPreference(event.getPlayer());
_game.GetPlayerKits().remove(event.getPlayer());
_game.GetPlayerGems().remove(event.getPlayer());
//Leave Team
// Leave Team
GameTeam team = _game.GetTeam(event.getPlayer());
if (team != null)
@ -754,6 +786,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
@EventHandler
public void TeleportLog(PlayerTeleportEvent event)
{
System.out.println("Teleporting: " + event.getPlayer().getName() + " to " + event.getTo().getWorld().getWorldFolder().getName());
System.out.println("Teleporting: " + event.getPlayer().getName() + " to "
+ event.getTo().getWorld().getWorldFolder().getName());
}
}