Initial Event Game push

This commit is contained in:
Cheese 2015-03-06 19:11:26 +11:00
parent 5c738a2e3c
commit e62d9774a9
11 changed files with 627 additions and 9 deletions

View File

@ -14,7 +14,7 @@ public class RefreshCommand extends CommandBase<NpcManager>
{
public RefreshCommand(NpcManager plugin)
{
super(plugin, Rank.DEVELOPER, "refresh");
super(plugin, Rank.SNR_MODERATOR, "refresh");
}
@Override

View File

@ -158,6 +158,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private AchievementManager _achievementManager;
private StatsManager _statsManager;
private PartyManager _partyManager;
private PreferencesManager _preferencesManager;
private TaskManager _taskManager;
private ArcadeRepository _arcadeRepository;
@ -192,6 +193,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_blood = blood;
_preferencesManager = preferences;
_explosionManager = new Explosion(plugin, _blockRestore);
_explosionManager.SetDebris(false);
@ -461,6 +463,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
return _gameWorldManager;
}
public PreferencesManager getPreferences()
{
return _preferencesManager;
}
public StatsManager GetStatsManager()
{
@ -1030,10 +1037,13 @@ public class ArcadeManager extends MiniPlugin implements IRelation
}
else if (event.GetState() == GameState.Prepare || event.GetState() == GameState.Loading || event.GetState() == GameState.Dead)
{
if (getCosmeticManager().isShowingInterface())
if (event.GetGame().GadgetsDisabled)
{
getCosmeticManager().setActive(false);
getCosmeticManager().disableItemsForGame();
if (getCosmeticManager().isShowingInterface())
{
getCosmeticManager().setActive(false);
getCosmeticManager().disableItemsForGame();
}
}
}
}

View File

@ -21,6 +21,7 @@ import nautilus.game.arcade.game.games.dragonriders.DragonRiders;
import nautilus.game.arcade.game.games.dragons.Dragons;
import nautilus.game.arcade.game.games.dragons.DragonsTeams;
import nautilus.game.arcade.game.games.draw.Draw;
import nautilus.game.arcade.game.games.event.EventGame;
import nautilus.game.arcade.game.games.evolution.Evolution;
import nautilus.game.arcade.game.games.gravity.Gravity;
import nautilus.game.arcade.game.games.halloween.Halloween;
@ -78,6 +79,7 @@ public class GameFactory
else if (gameType == GameType.DragonEscapeTeams) return new DragonEscapeTeams(_manager);
else if (gameType == GameType.DragonRiders) return new DragonRiders(_manager);
else if (gameType == GameType.Draw) return new Draw(_manager);
else if (gameType == GameType.Event) return new EventGame(_manager);
else if (gameType == GameType.Evolution) return new Evolution(_manager);
else if (gameType == GameType.Gravity) return new Gravity(_manager);
else if (gameType == GameType.Halloween) return new Halloween(_manager);

View File

@ -53,7 +53,9 @@ public enum GameType
UHC("Ultra Hardcore", Material.GOLDEN_APPLE, (byte)0, GameCategory.SURVIVAL, 46),
WitherAssault("Wither Assault", Material.SKULL_ITEM, (byte)1, GameCategory.ARCADE, 47),
Wizards("Wizards", Material.BLAZE_ROD, (byte)0, GameCategory.SURVIVAL, 48),
ZombieSurvival("Zombie Survival", Material.SKULL_ITEM, (byte)2, GameCategory.SURVIVAL, 49);
ZombieSurvival("Zombie Survival", Material.SKULL_ITEM, (byte)2, GameCategory.SURVIVAL, 49),
Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999);
String _name;
String _lobbyName;
@ -106,6 +108,6 @@ public enum GameType
public static enum GameCategory
{
SURVIVAL, CLASSICS, CHAMPIONS, ARCADE;
SURVIVAL, CLASSICS, CHAMPIONS, ARCADE, EVENT;
}
}

View File

@ -224,6 +224,10 @@ public abstract class Game implements Listener
public boolean StrictAntiHack = false;
public boolean DisableKillCommand = true;
public boolean GadgetsDisabled = true;
public boolean TeleportsDisqualify = true;
//Addons
public boolean CompassEnabled = false;

View File

@ -0,0 +1,559 @@
package nautilus.game.arcade.game.games.event;
import java.util.HashMap;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Sound;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseBat;
import mineplex.core.disguise.disguises.DisguiseChicken;
import mineplex.core.disguise.disguises.DisguiseEnderman;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.event.kits.*;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.GameHostManager;
public class EventGame extends SoloGame
{
private GameHostManager _mps;
private String[] _sideText = new String[] {
" "," "," "," "," "," "," "," "," "," "," "," "
," "," "," "};
private boolean _doubleJump = true;
private boolean _gadgetsEnabled = true;
private NautHashMap<String, Integer> _radius = new NautHashMap<String, Integer>();
public EventGame(ArcadeManager manager)
{
super(manager, GameType.Event,
new Kit[]
{
new KitPlayer(manager),
},
new String[]
{
""
});
this.JoinInProgress = true;
this.DeathMessages = false;
this.DeathOut = false;
this.CanAddStats = false;
this.CanGiveLoot = false;
this.GadgetsDisabled = false;
this.TeleportsDisqualify = false;
this.PrepareFreeze = false;
_mps = manager.GetGameHostManager();
}
@EventHandler
public void playerJoinTeam(PlayerJoinEvent event)
{
//Put onto team and spawn
}
//Help
private void commandHelp(Player player)
{
UtilPlayer.message(player, F.main("Event", "Displaying Commands;"));
UtilPlayer.message(player, F.value("/e tp <Player>", "Teleport to Target"));
UtilPlayer.message(player, F.value("/e tp here <Player>", "Teleport Target to Self"));
UtilPlayer.message(player, F.value("/e tp here all", "Teleport Everyone to Self"));
UtilPlayer.message(player, F.value("/e gadget", "Toggle Gadgets"));
UtilPlayer.message(player, F.value("/e silence [Time]", "Silence Chat"));
UtilPlayer.message(player, F.value("/e gamemode [Player]", "Toggle Creative Mode"));
UtilPlayer.message(player, F.value("/e radius [Radius]", "Set Forcefield Radius"));
UtilPlayer.message(player, F.value(C.cRed + "/e give <Item> <Amount> [Player/\'All\']", "Give Item"));
UtilPlayer.message(player, F.value(C.cRed + "/e setting", "View Settings Help"));
UtilPlayer.message(player, F.value("/e doublejump", "Toggles Double Jump"));
UtilPlayer.message(player, F.value("/e scoreboard <Line #> [Text]", "Sets Scoreboard Text"));
}
//Command Handler
@EventHandler(priority = EventPriority.LOWEST)
public void commandHandler(PlayerCommandPreprocessEvent event)
{
if (!event.getMessage().toLowerCase().startsWith("/e "))
return;
event.setCancelled(true);
if (!_mps.isAdmin(event.getPlayer(), false))
return;
//Trim off /e and split to args
String[] args = event.getMessage().substring(3, event.getMessage().length()).split(" ");
if (args.length == 0)
{
commandHelp(event.getPlayer());
}
else if (args[0].equalsIgnoreCase("tp"))
{
commandTeleport(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("gadget"))
{
commandGadget(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("silence"))
{
commandSilence(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("gamemode"))
{
commandGamemode(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("radius"))
{
commandForcefieldRadius(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("doublejump"))
{
commandDoubleJump(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("scoreboard"))
{
commandScoreboard(event.getPlayer(), args);
}
}
//Teleport Command (To, Here, All)
@EventHandler
public void commandTeleport(Player player, String[] args)
{
if (args.length >= 3 && args[1].equalsIgnoreCase("here"))
{
if (args[2].equalsIgnoreCase("all"))
{
for (Player other : UtilServer.getPlayers())
{
UtilPlayer.message(other, F.main("Event TP", player.getName() + " teleported everyone to self."));
other.teleport(player);
}
return;
}
Player target = UtilPlayer.searchOnline(player, args[2], true);
if (target != null)
{
target.teleport(player);
UtilPlayer.message(target, F.main("Event TP", player.getName() + " teleported you to self."));
UtilPlayer.message(player, F.main("Event TP", "Teleported " + target.getName() + " to you."));
}
return;
}
if (args.length >= 2)
{
Player target = UtilPlayer.searchOnline(player, args[1], true);
if (target != null)
{
player.teleport(target);
UtilPlayer.message(player, F.main("Event TP", "Teleported to " + target.getName() + "."));
}
return;
}
commandHelp(player);
}
//Gadget Commands (Global & Individual)
@EventHandler
public void commandGadget(Player player, String[] args)
{
_gadgetsEnabled = !_gadgetsEnabled;
if (!_gadgetsEnabled)
{
Manager.getCosmeticManager().getMountManager().DisableAll();
Manager.getCosmeticManager().getGadgetManager().DisableAll();
}
for (Player other : UtilServer.getPlayers())
other.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(_gadgetsEnabled ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled"));
}
//Silence
@EventHandler
public void commandSilence(Player player, String[] args)
{
try
{
//Toggle
if (args.length == 1)
{
//Disable
if (Manager.GetChat().Silenced() != 0)
{
Manager.GetChat().Silence(0, true);
}
//Enable
else
{
Manager.GetChat().Silence(-1, true);
}
}
//Timer
else
{
long time = (long) (Double.valueOf(args[1]) * 3600000);
Manager.GetChat().Silence(time, true);
}
}
catch (Exception e)
{
UtilPlayer.message(player, F.main("Chat", "Invalid Time Parameter."));
}
}
//Gamemode (Self and Others)
@EventHandler
public void commandGamemode(Player player, String[] args)
{
Player target = player;
if (args.length >= 2)
{
Player newTarget = UtilPlayer.searchOnline(player, args[1], true);
if (newTarget != null)
target = newTarget;
else
return;
}
if (target.getGameMode() == GameMode.CREATIVE)
target.setGameMode(GameMode.SURVIVAL);
else
target.setGameMode(GameMode.CREATIVE);
UtilPlayer.message(player, F.main("Event GM", target.getName() + " Creative: " + F.tf(target.getGameMode() == GameMode.CREATIVE)));
}
//Forcefield
@EventHandler
public void commandForcefieldRadius(Player player, String[] args)
{
//Toggle
if (args.length >= 2)
{
try
{
int range = Integer.parseInt(args[1]);
_radius.put(player.getName(), range);
UtilPlayer.message(player, F.main("Forcefield", "Radius set to " + F.elem(range + "") + "."));
}
catch (Exception e)
{
UtilPlayer.message(player, F.main("Forcefield", "Invalid Input."));
}
}
else
{
commandHelp(player);
}
}
//Give
@EventHandler
public void commandGive(Player player, String[] args)
{
}
//Game Settings - PvP, Blocks, etc
@EventHandler
public void commandSetting(Player player, String[] args)
{
}
//Double Jump
@EventHandler
public void commandDoubleJump(Player player, String[] args)
{
_doubleJump = !_doubleJump;
UtilPlayer.message(player, F.main("Settings", "Double Jump: " + F.tf(_doubleJump)));
if (!_doubleJump)
for (Player other : UtilServer.getPlayers())
other.setAllowFlight(false);
}
//Scoreboard
@EventHandler
public void commandScoreboard(Player player, String[] args)
{
if (args.length >= 2)
{
//Line
int line = 0;
try
{
line = Integer.parseInt(args[1]);
}
catch (Exception e)
{
UtilPlayer.message(player, F.main("Scoreboard", "Invalid Line Number."));
return;
}
if (line < 1 || line > 14)
{
UtilPlayer.message(player, F.main("Scoreboard", "Invalid Line Number."));
return;
}
//Text
String lineText = "";
//Reset String
if (args.length <= 2)
for (int i=0 ; i<line ; i++)
lineText += " ";
//New String
for (int i=2 ; i<args.length ; i++)
{
lineText += args[i];
if (i < args.length -1)
lineText += " ";
}
_sideText[line] = lineText;
UtilPlayer.message(player, F.main("Scoreboard", "Set Line " + F.elem(line+"") + " to " + F.elem(lineText) + "."));
return;
}
//Clear
if (args.length >= 2 && args[1].equalsIgnoreCase("clear"))
{
for (int i=0 ; i<_sideText.length ; i++)
{
String lineText = "";
for (int j=0 ; j<i ; j++)
lineText += " ";
_sideText[i] = lineText;
}
return;
}
for (int i=0 ; i<_sideText.length ; i++)
{
UtilPlayer.message(player, F.value("Line " + i, _sideText[i]));
}
}
@EventHandler
public void doubleJumpTrigger(PlayerToggleFlightEvent event)
{
if (!_doubleJump)
return;
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE)
return;
//Chicken Cancel
DisguiseBase disguise = Manager.GetDisguise().getDisguise(player);
if (disguise != null &&
((disguise instanceof DisguiseChicken && !((DisguiseChicken)disguise).isBaby()) || disguise instanceof DisguiseBat || disguise instanceof DisguiseEnderman || disguise instanceof DisguiseWither))
return;
event.setCancelled(true);
player.setFlying(false);
//Disable Flight
player.setAllowFlight(false);
//Velocity
UtilAction.velocity(player, 1.4, 0.2, 1, true);
//Sound
player.playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0);
}
@EventHandler
public void doubleJumpRefresh(UpdateEvent event)
{
if (!_doubleJump)
return;
if (event.getType() != UpdateType.TICK)
return;
for (Player player : UtilServer.getPlayers())
{
if (player.getGameMode() == GameMode.CREATIVE)
continue;
if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
{
player.setAllowFlight(true);
player.setFlying(false);
}
}
}
@EventHandler
public void gadgetActivate(GadgetActivateEvent event)
{
if (!_gadgetsEnabled)
event.setCancelled(true);
}
@EventHandler
public void mountActivate(MountActivateEvent event)
{
if (!_gadgetsEnabled)
event.setCancelled(true);
}
@EventHandler
public void forcefieldUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
return;
for (Player player : UtilServer.getPlayers())
{
if (Manager.getPreferences().Get(player).HubForcefield)
{
for (Player other : UtilServer.getPlayers())
{
if (player.equals(other))
continue;
int range = 5;
if (_radius.containsKey(player.getName()))
range = _radius.get(player.getName());
if (UtilMath.offset(other, player) > range)
continue;
if (Manager.GetClients().Get(other).GetRank().Has(Rank.ADMIN))
continue;
if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false))
{
Entity bottom = other;
while (bottom.getVehicle() != null)
bottom = bottom.getVehicle();
UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(player, bottom), 1.6, true, 0.8, 0, 10, true);
other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f);
}
}
}
}
}
@EventHandler
public void updateVisibility(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player player : UtilServer.getPlayers())
{
for (Player other : UtilServer.getPlayers())
{
if (player.equals(other))
continue;
if (Manager.getPreferences().Get(player).Invisibility || !Manager.getPreferences().Get(other).ShowPlayers)
{
((CraftPlayer)other).hidePlayer(player, true, false);
}
else
{
other.showPlayer(player);
}
}
}
}
@Override
public void EndCheck()
{
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
if (!InProgress())
return;
if (event.getType() != UpdateType.FAST)
return;
if (GetTeamList().isEmpty())
return;
Scoreboard.Reset();
Scoreboard.WriteBlank();
for (int i=_sideText.length-1 ; i>=0 ; i--)
{
Scoreboard.Write(_sideText[i]);
}
Scoreboard.Draw();
}
}

View File

@ -0,0 +1,37 @@
package nautilus.game.arcade.game.games.event.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
public class KitPlayer extends Kit
{
public KitPlayer(ArcadeManager manager)
{
super(manager, "Party Animal", KitAvailability.Free, 0,
new String[]
{
""
},
new Perk[]
{
},
EntityType.PIG,
new ItemStack(Material.PORK));
}
@Override
public void GiveItems(Player player)
{
}
}

View File

@ -874,6 +874,9 @@ public class GameFlagManager implements Listener
if (!game.IsLive())
return;
if (!game.TeleportsDisqualify)
return;
//Remove Kit
game.RemoveTeamPreference(event.getPlayer());

View File

@ -118,7 +118,8 @@ public class GameHostManager implements Listener
giveAdminItem(player);
}
if (player.equals(_host))
if (player.equals(_host) ||
(isAdmin(player, false) && Manager.GetGame() != null && Manager.GetGame().GetType() == GameType.Event))
_lastOnline = System.currentTimeMillis();
}
}

View File

@ -1248,7 +1248,7 @@ public class GameLobbyManager implements Listener, IPacketHandler
if (Manager.GetGame() == null)
return;
if (Manager.GetGame().GetState() != GameState.Recruit)
if (Manager.GetGame().GetState() != GameState.Recruit && Manager.GetGame().GadgetsDisabled)
return;
for (Player player : UtilServer.getPlayers())

View File

@ -229,7 +229,7 @@ public class GameManager implements Listener
}
//Disabling Cosmetics
if (game.GetCountdown() <= 5 && game.GetCountdown() >= 0)
if (game.GetCountdown() <= 5 && game.GetCountdown() >= 0 && game.GadgetsDisabled)
{
if (Manager.getCosmeticManager().isShowingInterface())
{