saving Project for pulling.

This commit is contained in:
Sarah 2015-08-31 11:32:18 +02:00
parent d79794c6d3
commit 58ae09ebd4
2 changed files with 159 additions and 32 deletions

View File

@ -1,9 +1,12 @@
package nautilus.game.arcade.game.games.event; package nautilus.game.arcade.game.games.event;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
@ -11,7 +14,9 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseBat; import mineplex.core.disguise.disguises.DisguiseBat;
import mineplex.core.disguise.disguises.DisguiseChicken; import mineplex.core.disguise.disguises.DisguiseChicken;
@ -26,21 +31,28 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.visibility.VisibilityManager; import mineplex.core.visibility.VisibilityManager;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.event.kits.KitPlayer; import nautilus.game.arcade.game.games.event.kits.KitPlayer;
import nautilus.game.arcade.game.games.skywars.TeamSkywars.TeamColors;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.GameHostManager; import nautilus.game.arcade.managers.GameHostManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
@ -66,6 +78,8 @@ public class EventGame extends Game
private boolean _allowAllGadgets = false; private boolean _allowAllGadgets = false;
private HashSet<SalesPackageBase> _gadgetWhitelist = new HashSet<SalesPackageBase>(); private HashSet<SalesPackageBase> _gadgetWhitelist = new HashSet<SalesPackageBase>();
private HashMap<Sign, Long> _functionSigns;
public EventGame(ArcadeManager manager) public EventGame(ArcadeManager manager)
{ {
super(manager, GameType.Event, super(manager, GameType.Event,
@ -110,10 +124,46 @@ public class EventGame extends Game
this.GameTimeout = -1; this.GameTimeout = -1;
_mps = manager.GetGameHostManager(); _mps = manager.GetGameHostManager();
_functionSigns = new HashMap<>();
this.CreatureAllow = true; this.CreatureAllow = true;
} }
@EventHandler
public void registerSigns(GameStateChangeEvent event)
{
if(event.GetState() != GameState.Live)
return;
for(Location loc : WorldData.GetDataLocs("RED"))
{
for(int i = -5; i < 5; i++)
{
Location temp = loc.clone().add(0, i, 0);
if(temp.getBlock().getType() == Material.SIGN_POST || temp.getBlock().getType() == Material.WALL_SIGN)
{
if(!_functionSigns.containsKey((Sign) temp.getBlock().getState()))
{
_functionSigns.put((Sign) temp.getBlock().getState(), System.currentTimeMillis());
}
}
}
}
}
@EventHandler
public void signPlace(SignChangeEvent event)
{
if(!IsLive())
return;
if(!Manager.GetGameHostManager().isAdmin(event.getPlayer(), true))
return;
if(event.getLine(0).startsWith("[") && event.getLine(0).endsWith("]"))
_functionSigns.put((Sign) event.getBlock().getState(), System.currentTimeMillis());
}
//Before GamePlayerManager puts onto Spec! //Before GamePlayerManager puts onto Spec!
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void specToTeam(PlayerJoinEvent event) public void specToTeam(PlayerJoinEvent event)
@ -464,4 +514,81 @@ public class EventGame extends Game
return losers; return losers;
} }
@EventHandler
public void signCheck(BlockRedstoneEvent event)
{
if(event.getBlock().getType() != Material.SIGN_POST && event.getBlock().getType() != Material.WALL_SIGN)
return;
useSign(((Sign) event.getBlock().getState()).getLines());
}
@EventHandler
public void signClock(UpdateEvent event)
{
if(event.getType() != UpdateType.SEC)
return;
for(Sign sign : _functionSigns.keySet())
{
if(sign.getBlock().getRelative(BlockFace.DOWN).getType() != Material.IRON_BLOCK)
continue;
Sign cooldown = null;
for(BlockFace face : BlockFace.values())
{
if(face == BlockFace.UP)
continue;
if(sign.getBlock().getRelative(BlockFace.DOWN).getRelative(face).getType() == Material.WALL_SIGN)
{
cooldown = (Sign) sign.getBlock().getRelative(BlockFace.DOWN).getRelative(face).getState();
break;
}
}
if(cooldown == null)
continue;
if(!UtilTime.elapsed(_functionSigns.get(sign), Long.parseLong(cooldown.getLine(0)) * 1000))
continue;
_functionSigns.put(sign, System.currentTimeMillis());
useSign(sign.getLines());
}
}
public void useSign(String[] args)
{
String command = args[0];
String playerName = args[1];
command.replace("[", "").replaceAll("]", "");
if(command.contentEquals("BC"))
{
String message = args[1];
for(int i = 2; i <= 3; i++)
message += " " + args[i];
String colored = ChatColor.translateAlternateColorCodes('&', message);
this.Announce(F.main("Event", colored), true);
}
Player player = Bukkit.getPlayer(playerName);
if(player == null)
return;
String[] vars = new String[args.length - 1];
vars[0] = args[0];
vars[1] = args[2];
vars[2] = args[3];
if(command.contentEquals("MOB"))
{
Manager.GetEventModule().commandMob(player, vars);
}
}
} }

View File

@ -54,7 +54,7 @@ import org.bukkit.potion.PotionEffectType;
public class EventModule extends MiniPlugin public class EventModule extends MiniPlugin
{ {
public ArcadeManager Manager; private ArcadeManager Manager;
private NautHashMap<PotionEffectType, Long> _potionEffectsDuration = new NautHashMap<>(); private NautHashMap<PotionEffectType, Long> _potionEffectsDuration = new NautHashMap<>();
private NautHashMap<PotionEffectType, Integer> _potionEffectsMult = new NautHashMap<>(); private NautHashMap<PotionEffectType, Integer> _potionEffectsMult = new NautHashMap<>();
@ -110,7 +110,7 @@ public class EventModule extends MiniPlugin
event.setCancelled(true); event.setCancelled(true);
} }
private void commandHelp(Player player) public void commandHelp(Player player)
{ {
UtilPlayer.message(player, F.main("Event", "Displaying Commands;")); UtilPlayer.message(player, F.main("Event", "Displaying Commands;"));
@ -151,7 +151,7 @@ public class EventModule extends MiniPlugin
UtilPlayer.message(player, F.value("/e effect <player> clear", "")); UtilPlayer.message(player, F.value("/e effect <player> clear", ""));
} }
private void commandHelpSettings(Player player) public void commandHelpSettings(Player player)
{ {
UtilPlayer.message(player, F.main("Event", "Displaying Settings Commands;")); UtilPlayer.message(player, F.main("Event", "Displaying Settings Commands;"));
UtilPlayer.message(player, F.value("/e damage all", "Toggles All Damage")); UtilPlayer.message(player, F.value("/e damage all", "Toggles All Damage"));
@ -181,7 +181,7 @@ public class EventModule extends MiniPlugin
//Command Handler //Command Handler
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
private void commandHandler(PlayerCommandPreprocessEvent event) public void commandHandler(PlayerCommandPreprocessEvent event)
{ {
if (!Manager.GetGame().InProgress()) if (!Manager.GetGame().InProgress())
return; return;
@ -366,7 +366,7 @@ public class EventModule extends MiniPlugin
} }
} }
private void listSettings(Player player) public void listSettings(Player player)
{ {
UtilPlayer.message(player, F.value("Damage All", F.tf(Manager.GetGame().Damage))); UtilPlayer.message(player, F.value("Damage All", F.tf(Manager.GetGame().Damage)));
UtilPlayer.message(player, F.value("Damage PvP", F.tf(Manager.GetGame().DamagePvP))); UtilPlayer.message(player, F.value("Damage PvP", F.tf(Manager.GetGame().DamagePvP)));
@ -389,28 +389,28 @@ public class EventModule extends MiniPlugin
UtilPlayer.message(player, F.value("Mob griefing", F.tf(_mobGriefing))); UtilPlayer.message(player, F.value("Mob griefing", F.tf(_mobGriefing)));
} }
private void commandBlockBreakInCreative(Player player, String[] args) public void commandBlockBreakInCreative(Player player, String[] args)
{ {
Manager.GetGame().BlockBreakCreative = !Manager.GetGame().BlockBreakCreative; Manager.GetGame().BlockBreakCreative = !Manager.GetGame().BlockBreakCreative;
UtilPlayer.message(player, F.main("Settings", "BlockBreakCreative: " + F.tf(Manager.GetGame().BlockBreakCreative))); UtilPlayer.message(player, F.main("Settings", "BlockBreakCreative: " + F.tf(Manager.GetGame().BlockBreakCreative)));
} }
private void commandBlockPlaceInCreative(Player player, String[] args) public void commandBlockPlaceInCreative(Player player, String[] args)
{ {
Manager.GetGame().BlockPlaceCreative = !Manager.GetGame().BlockPlaceCreative; Manager.GetGame().BlockPlaceCreative = !Manager.GetGame().BlockPlaceCreative;
UtilPlayer.message(player, F.main("Settings", "BlockPlaceCreative: " + F.tf(Manager.GetGame().BlockPlaceCreative))); UtilPlayer.message(player, F.main("Settings", "BlockPlaceCreative: " + F.tf(Manager.GetGame().BlockPlaceCreative)));
} }
private void commandMobGriefing(Player player, String[] args) public void commandMobGriefing(Player player, String[] args)
{ {
_mobGriefing = !_mobGriefing; _mobGriefing = !_mobGriefing;
UtilPlayer.message(player, F.main("Settings", "Mob Griefing: " + F.tf(_mobGriefing))); UtilPlayer.message(player, F.main("Settings", "Mob Griefing: " + F.tf(_mobGriefing)));
} }
private void commandBlockPlace(Player player, String[] args, boolean whitelist, String command) public void commandBlockPlace(Player player, String[] args, boolean whitelist, String command)
{ {
try try
{ {
@ -471,7 +471,7 @@ public class EventModule extends MiniPlugin
commandHelpSettings(player); commandHelpSettings(player);
} }
private void commandBlockBreak(Player player, String[] args, boolean whitelist, String command) public void commandBlockBreak(Player player, String[] args, boolean whitelist, String command)
{ {
try try
{ {
@ -532,7 +532,7 @@ public class EventModule extends MiniPlugin
commandHelpSettings(player); commandHelpSettings(player);
} }
private void commandHealth(Player player, String[] args) public void commandHealth(Player player, String[] args)
{ {
try try
{ {
@ -563,7 +563,7 @@ public class EventModule extends MiniPlugin
commandHelpSettings(player); commandHelpSettings(player);
} }
private void commandHunger(Player player, String[] args) public void commandHunger(Player player, String[] args)
{ {
try try
{ {
@ -594,7 +594,7 @@ public class EventModule extends MiniPlugin
commandHelpSettings(player); commandHelpSettings(player);
} }
private void commandTime(Player player, String[] args) public void commandTime(Player player, String[] args)
{ {
try try
{ {
@ -626,7 +626,7 @@ public class EventModule extends MiniPlugin
} }
//Teleport Command (To, Here, All) //Teleport Command (To, Here, All)
private void commandTeleport(Player player, String[] args) public void commandTeleport(Player player, String[] args)
{ {
if (args.length >= 3 && args[1].equalsIgnoreCase("here")) if (args.length >= 3 && args[1].equalsIgnoreCase("here"))
{ {
@ -668,7 +668,7 @@ public class EventModule extends MiniPlugin
} }
//Gadget Commands (Global & Individual) //Gadget Commands (Global & Individual)
private void commandGadget(Player player, String[] args) public void commandGadget(Player player, String[] args)
{ {
if(!(Manager.GetGame() instanceof EventGame)) { if(!(Manager.GetGame() instanceof EventGame)) {
UtilPlayer.message(player, F.main("Inventory", "You can only enable/disable gadgets in the Event game!")); UtilPlayer.message(player, F.main("Inventory", "You can only enable/disable gadgets in the Event game!"));
@ -780,7 +780,7 @@ public class EventModule extends MiniPlugin
} }
//Silence //Silence
private void commandSilence(Player player, String[] args) public void commandSilence(Player player, String[] args)
{ {
try try
{ {
@ -813,7 +813,7 @@ public class EventModule extends MiniPlugin
} }
//Gamemode (Self and Others) //Gamemode (Self and Others)
private void commandAdmin(Player player, String[] args) public void commandAdmin(Player player, String[] args)
{ {
Player target = player; Player target = player;
@ -835,7 +835,7 @@ public class EventModule extends MiniPlugin
} }
//Gamemode (Self and Others) //Gamemode (Self and Others)
private void commandGamemode(Player player, String[] args) public void commandGamemode(Player player, String[] args)
{ {
Player target = player; Player target = player;
@ -857,7 +857,7 @@ public class EventModule extends MiniPlugin
} }
//Forcefield //Forcefield
private void commandForcefieldRadius(Player player, String[] args) public void commandForcefieldRadius(Player player, String[] args)
{ {
if(!(Manager.GetGame() instanceof EventGame)) { if(!(Manager.GetGame() instanceof EventGame)) {
@ -889,7 +889,7 @@ public class EventModule extends MiniPlugin
} }
//Give //Give
private void commandGive(Player player, String[] args) public void commandGive(Player player, String[] args)
{ {
String[] newArgs = new String[args.length-1]; String[] newArgs = new String[args.length-1];
@ -900,7 +900,7 @@ public class EventModule extends MiniPlugin
} }
//Spec //Spec
private void commandSpectators(Player player, String[] args) public void commandSpectators(Player player, String[] args)
{ {
Manager.GetGame().JoinInProgress = !Manager.GetGame().JoinInProgress; Manager.GetGame().JoinInProgress = !Manager.GetGame().JoinInProgress;
@ -908,7 +908,7 @@ public class EventModule extends MiniPlugin
} }
//Deathout //Deathout
private void commandDeathout(Player player, String[] args) public void commandDeathout(Player player, String[] args)
{ {
Manager.GetGame().DeathOut = !Manager.GetGame().DeathOut; Manager.GetGame().DeathOut = !Manager.GetGame().DeathOut;
@ -916,7 +916,7 @@ public class EventModule extends MiniPlugin
} }
//QuitOut //QuitOut
private void commandQuitOut(Player player, String[] args) public void commandQuitOut(Player player, String[] args)
{ {
Manager.GetGame().QuitOut = !Manager.GetGame().QuitOut; Manager.GetGame().QuitOut = !Manager.GetGame().QuitOut;
@ -924,7 +924,7 @@ public class EventModule extends MiniPlugin
} }
//Double Jump //Double Jump
private void commandDoubleJump(Player player, String[] args) public void commandDoubleJump(Player player, String[] args)
{ {
if(!(Manager.GetGame() instanceof EventGame)) { if(!(Manager.GetGame() instanceof EventGame)) {
@ -942,7 +942,7 @@ public class EventModule extends MiniPlugin
} }
//Scoreboard //Scoreboard
private void commandScoreboard(Player player, String[] args) public void commandScoreboard(Player player, String[] args)
{ {
if(!(Manager.GetGame() instanceof EventGame)) { if(!(Manager.GetGame() instanceof EventGame)) {
@ -1016,7 +1016,7 @@ public class EventModule extends MiniPlugin
} }
//Whitelist //Whitelist
private void commandWhitelist(Player player, String[] args) public void commandWhitelist(Player player, String[] args)
{ {
//On and Off //On and Off
if (args.length >= 2) if (args.length >= 2)
@ -1056,7 +1056,7 @@ public class EventModule extends MiniPlugin
} }
//Mob //Mob
private void commandMob(Player caller, String[] args) public void commandMob(Player caller, String[] args)
{ {
if (args.length == 1) if (args.length == 1)
{ {
@ -1444,7 +1444,7 @@ public class EventModule extends MiniPlugin
} }
} }
private void commandMobKill(Player caller, String[] args) public void commandMobKill(Player caller, String[] args)
{ {
if (args.length < 3) if (args.length < 3)
{ {
@ -1490,7 +1490,7 @@ public class EventModule extends MiniPlugin
UtilPlayer.message(caller, F.main("Creature", "Killed " + target + ". " + count + " Removed.")); UtilPlayer.message(caller, F.main("Creature", "Killed " + target + ". " + count + " Removed."));
} }
private void commandKit(Player caller, String[] args) public void commandKit(Player caller, String[] args)
{ {
if(!(Manager.GetGame() instanceof EventGame)) { if(!(Manager.GetGame() instanceof EventGame)) {
@ -1533,7 +1533,7 @@ public class EventModule extends MiniPlugin
commandHelp(caller); commandHelp(caller);
} }
private void commandEffect(Player caller, String[] args) public void commandEffect(Player caller, String[] args)
{ {
//Clear //Clear
if (args.length >= 3 && args[2].equalsIgnoreCase("clear")) if (args.length >= 3 && args[2].equalsIgnoreCase("clear"))