Merge branch 'EventGameUpdates'

This commit is contained in:
Cheese 2015-09-22 14:59:17 +10:00
commit 4519f2dda1
2 changed files with 1125 additions and 46 deletions

View File

@ -1,53 +1,83 @@
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.Iterator;
import java.util.List; import java.util.List;
import mineplex.core.common.util.Callback;
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;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
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;
import mineplex.core.disguise.disguises.DisguiseEnderman; import mineplex.core.disguise.disguises.DisguiseEnderman;
import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.gadget.event.GadgetActivateEvent; import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.give.Give;
import mineplex.core.mount.Mount;
import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.SalesPackageBase;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.visibility.VisibilityManager; import mineplex.core.visibility.VisibilityManager;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
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.sheep.kits.KitBrute;
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.Action;
import org.bukkit.event.block.BlockBreakEvent;
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.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.sun.xml.internal.ws.resources.UtilMessages;
public class EventGame extends Game public class EventGame extends Game
{ {
@ -66,6 +96,11 @@ 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;
private ArrayList<Sign> _powerdedSigns;
private HashMap<Integer, EventArea> _customAreas;
public EventGame(ArcadeManager manager) public EventGame(ArcadeManager manager)
{ {
super(manager, GameType.Event, super(manager, GameType.Event,
@ -106,12 +141,81 @@ public class EventGame extends Game
this.InventoryOpenBlock = true; this.InventoryOpenBlock = true;
this.InventoryOpenChest = true; this.InventoryOpenChest = true;
//Dont timeout //Dont timeout
this.GameTimeout = -1; this.GameTimeout = -1;
_mps = manager.GetGameHostManager(); _mps = manager.GetGameHostManager();
_functionSigns = new HashMap<>();
_powerdedSigns = new ArrayList<>();
this.CreatureAllow = true; this.CreatureAllow = true;
_customAreas = new HashMap<>();
}
@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 registerAreas(GameStateChangeEvent event)
{
if(event.GetState() != GameState.Live)
return;
for(String name : WorldData.GetAllCustomLocs().keySet())
{
try
{
EventArea area = new EventArea(Integer.parseInt(name.split(" ")[0]));
Location tempA = WorldData.GetAllCustomLocs().get(name).get(0);
Location tempB = WorldData.GetAllCustomLocs().get(name).get(1);
area.CornerA = new Location(tempA.getWorld(), Math.min(tempA.getX(), tempB.getX()), Math.min(tempA.getY(), tempB.getY()), Math.min(tempA.getZ(), tempB.getZ()));
area.CornerB = new Location(tempA.getWorld(), Math.max(tempA.getX(), tempB.getX()), Math.max(tempA.getY(), tempB.getY()), Math.max(tempA.getZ(), tempB.getZ()));
area.DamageAll = name.contains("ALL");
area.DamagePvP = name.contains("PVP");
area.DamagePvE = name.contains("PVE");
area.DamageEvP = name.contains("EVP");
area.Usable = true;
_customAreas.put(Integer.parseInt(name.split(" ")[0]), area);
}
catch (Exception e)
{
System.out.println("Error while parsing area locs");
}
}
}
@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!
@ -464,4 +568,733 @@ 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.TICK)
return;
for(Sign sign : _functionSigns.keySet())
{
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)
{
if(!sign.getBlock().isBlockPowered())
{
_powerdedSigns.remove(sign);
continue;
}
if(_powerdedSigns.contains(sign))
continue;
useSign(sign, ((Sign) sign.getBlock().getState()).getLines());
if(sign.getBlock().isBlockPowered())
{
if(!_powerdedSigns.contains(sign))
{
_powerdedSigns.add(sign);
}
}
continue;
}
if(!sign.getBlock().isBlockPowered() && !UtilTime.elapsed(_functionSigns.get(sign), Long.parseLong(cooldown.getLine(0)) * 1000))
continue;
if(!sign.getBlock().isBlockPowered())
{
_powerdedSigns.remove(sign);
}
if(_powerdedSigns.contains(sign))
continue;
_functionSigns.put(sign, System.currentTimeMillis());
useSign(sign, ((Sign) sign.getBlock().getState()).getLines());
if(sign.getBlock().isBlockPowered())
{
if(!_powerdedSigns.contains(sign))
{
_powerdedSigns.add(sign);
}
}
}
}
public void useSign(final Sign sign, String[] args)
{
String command = args[0];
String playerName = args[1];
HashMap<Integer, ArrayList<Player>> varMap = new HashMap<>();
int i = 0;
for(String varArgs : args)
{
ArrayList<Player> players = new ArrayList<>();
if(Bukkit.getPlayer(varArgs) != null)
players.add(Bukkit.getPlayer(varArgs));
if(varArgs.contentEquals("@p"))
{
for(Player player : GetPlayers(true))
{
boolean found;
found = true;
for(Player otherPlayer : GetPlayers(true))
{
if(player == otherPlayer)
continue;
if(UtilMath.offset(sign.getLocation(), player.getLocation()) >= UtilMath.offset(sign.getLocation(), otherPlayer.getLocation()))
{
found = false;
break;
}
}
if(found)
{
players.add(player);
break;
}
}
}
if(playerName.contains("@a"))
{
int radius = 0;
if(playerName.contains("r="))
{
try
{
radius = Integer.parseInt(playerName.split("=")[1]);
}
catch (Exception e) {}
}
for(Player player : GetPlayers(true))
{
if(UtilMath.offset(sign.getLocation(), player.getLocation()) <= radius || radius <= 0)
players.add(player);
}
}
varMap.put(i, players);
i++;
}
if(command.contentEquals("[BC]"))
{
String message = args[1];
for(int e = 2; e <= 3; e++)
message += " " + args[e];
String colored = ChatColor.translateAlternateColorCodes('&', message);
this.Announce(F.main("Event", colored), true);
}
if(command.contentEquals("[TELEPORT]"))
{
for(Player player : varMap.get(1))
{
if(Bukkit.getPlayer(args[2]) != null)
{
player.teleport(Bukkit.getPlayer(args[2]));
}
else
{
String[] coords = args[2].split(" ");
int x = Integer.parseInt(coords[0]);
int y = Integer.parseInt(coords[1]);
int z = Integer.parseInt(coords[2]);
player.teleport(new Location(sign.getWorld(), x, y, z));
}
}
}
if(command.contentEquals("[MESSAGE]"))
{
String message = args[2];
message += " " + args[3];
String colored = ChatColor.translateAlternateColorCodes('&', message);
for(Player player : varMap.get(1))
{
UtilPlayer.message(player, F.main("Event", colored));
}
}
if(command.contentEquals("[SETBLOCK]"))
{
Material mat = Material.getMaterial(Integer.parseInt(args[1]));
String[] coords = args[2].split(" ");
int x = Integer.parseInt(coords[0]);
int y = Integer.parseInt(coords[1]);
int z = Integer.parseInt(coords[2]);
sign.getWorld().getBlockAt(new Location(sign.getWorld(), x, y, z)).setType(mat);
}
if(command.contentEquals("[TESTFOR]"))
{
boolean redstone = false;
Material mat = Material.getMaterial(Integer.parseInt(args[1]));
if(args[2].contains("r="))
{
int radius = 0;
try
{
radius = Integer.parseInt(args[2].split("=")[1]);
if(radius >= 30)
radius = 30;
for(int x = -radius + sign.getLocation().getBlockX(); x < radius + sign.getLocation().getBlockX(); x++)
{
for(int y = -radius + sign.getLocation().getBlockY(); y < radius + sign.getLocation().getBlockY(); y++)
{
for(int z = -radius + sign.getLocation().getBlockZ(); z < radius + sign.getLocation().getBlockZ(); z++)
{
if(sign.getWorld().getBlockAt(new Location(sign.getWorld(), x, y, z)).getType() == mat)
{
redstone = true;
}
}
}
}
}
catch (Exception e) {}
}
else
{
String[] coords = args[2].split(" ");
int x = Integer.parseInt(coords[0]);
int y = Integer.parseInt(coords[1]);
int z = Integer.parseInt(coords[2]);
if(sign.getWorld().getBlockAt(new Location(sign.getWorld(), x, y, z)).getType() == mat)
{
redstone = true;
}
}
if(redstone)
{
for(final BlockFace face : BlockFace.values())
{
if(face != BlockFace.UP
&& face != BlockFace.NORTH_WEST
&& face != BlockFace.NORTH_EAST
&& face != BlockFace.SOUTH_EAST
&& face != BlockFace.SOUTH_WEST)
{
continue;
}
if(sign.getBlock().getRelative(face).getType() != Material.AIR)
continue;
if(sign.getBlock().getRelative(face).isBlockPowered())
continue;
sign.getBlock().getRelative(face).setType(Material.REDSTONE_BLOCK);
Manager.runSyncLater(new Runnable()
{
@Override
public void run()
{
sign.getBlock().getRelative(face).setType(Material.AIR);
}
}, 3L);
}
}
}
if(varMap.get(1).isEmpty())
return;
String[] vars = new String[args.length - 1];
vars[0] = args[0];
vars[1] = args[2];
vars[2] = args[3];
String tempArgs = "";
for(String str : vars)
{
for(String string : str.split(" "))
{
tempArgs += string + " ";
}
}
String[] commandArgs = tempArgs.split(" ");
if(command.contentEquals("[MOB]"))
{
for(Player player : varMap.get(1))
Manager.GetEventModule().commandMob(player, commandArgs);
}
if(command.contentEquals("[SCORE]"))
{
for(Player player : varMap.get(1))
Manager.GetEventModule().commandScoreboard(player, vars);
}
if(command.contentEquals("[GIVE]"))
{
try
{
for(Player player : varMap.get(1))
{
player.getInventory().addItem(new ItemStack(Material.getMaterial(Integer.parseInt(args[2])), Integer.parseInt(args[3])));
}
} catch (Exception e)
{
}
}
if(command.contentEquals("[DOUBLEJUMP]"))
{
for(Player player : varMap.get(1))
Manager.GetEventModule().commandDoubleJump(player, vars);
}
if(command.contentEquals("[EFFECT]"))
{
//Manager.GetEventModule().commandEffect(Manager.GetGameHostManager().getHost(), commandArgs, varMap.get(1));
for(Player player : varMap.get(1))
{
player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(args[2]), Integer.parseInt(args[3].split(" ")[0]), Integer.parseInt(args[3].split(" ")[1])));
}
}
if(command.contentEquals("[KIT]"))
{
for(Player player : varMap.get(1))
Manager.GetEventModule().commandKit(player, commandArgs);
}
}
@EventHandler
public void signBreak(BlockBreakEvent event)
{
if(event.getBlock().getType() == Material.SIGN_POST || event.getBlock().getType() == Material.WALL_SIGN || event.getBlock().getType() == Material.SIGN)
{
Iterator<Sign> signIter = _functionSigns.keySet().iterator();
while(signIter.hasNext())
{
Sign sign = signIter.next();
if(sign.getLocation().getBlockX() == event.getBlock().getLocation().getBlockX()
&& sign.getLocation().getBlockY() == event.getBlock().getLocation().getBlockY()
&& sign.getLocation().getBlockZ() == event.getBlock().getLocation().getBlockZ())
{
signIter.remove();
}
}
}
}
public boolean isInArea(EventArea area, Entity entity)
{
if(entity.getLocation().getX() < area.CornerA.getX() || entity.getLocation().getX() > area.CornerB.getX())
return false;
if(entity.getLocation().getY() < area.CornerA.getY() || entity.getLocation().getY() > area.CornerB.getY())
return false;
if(entity.getLocation().getZ() < area.CornerA.getZ() || entity.getLocation().getZ() > area.CornerB.getZ())
return false;
return true;
}
@EventHandler
public void activateGadget(GadgetActivateEvent event)
{
for(EventArea area : _customAreas.values())
{
if(area.CornerA == null || area.CornerB == null)
continue;
if(area.Usable == false)
continue;
if(!isInArea(area, event.getPlayer()))
continue;
if(!area.GadgetsEnabled.contains(event.getGadget()))
{
event.setCancelled(true);
}
}
}
@EventHandler
public void areaPotionEffect(UpdateEvent event)
{
if(event.getType() != UpdateType.SEC)
return;
for(EventArea area : _customAreas.values())
{
for(Player player : GetPlayers(true))
{
if(area.CornerA == null || area.CornerB == null)
continue;
if(area.Usable == false)
continue;
if(!isInArea(area, player))
continue;
for(PotionEffectType type : area.PotionEffects.keySet())
{
player.addPotionEffect(new PotionEffect(type, 60, area.PotionEffects.get(type)), true);
}
}
}
}
@EventHandler(ignoreCancelled=true)
public void areaDamage(CustomDamageEvent event)
{
for(EventArea area : _customAreas.values())
{
if(area.CornerA == null || area.CornerB == null)
continue;
if(area.Usable == false)
continue;
if(Manager.GetEventModule().getDamagePlayers().contains(event.GetDamagerPlayer(true)))
{
if(!Manager.GetGame().DamagePvP)
{
Manager.GetGame().Damage = true;
Manager.GetGame().DamagePvP = true;
Bukkit.getPluginManager().callEvent(event);
Manager.GetGame().DamagePvP = false;
Manager.GetGame().Damage = false;
}
return;
}
if(!isInArea(area, event.GetDamageeEntity()))
continue;
if(!area.DamageAll)
{
event.SetCancelled("Event Area");
continue;
}
if(event.GetCause() == DamageCause.ENTITY_ATTACK && event.GetDamagerPlayer(true) == null)
{
if(!area.DamageEvP)
{
event.SetCancelled("Event Area");
continue;
}
}
if(!(event.GetDamageeEntity() instanceof Player))
{
if(!area.DamagePvE)
{
event.SetCancelled("Event Area");
continue;
}
}
if((event.GetDamageeEntity() instanceof Player) && (event.GetDamagerEntity(true) instanceof Player))
{
if(!area.DamagePvP)
{
event.SetCancelled("Event Area");
continue;
}
}
if(!Manager.GetGame().DamagePvP)
{
Manager.GetGame().Damage = true;
Manager.GetGame().DamagePvP = true;
Bukkit.getPluginManager().callEvent(event);
Manager.GetGame().DamagePvP = false;
Manager.GetGame().Damage = false;
}
}
}
public void listAreaSettings(Player player)
{
for(EventArea area : _customAreas.values())
{
UtilPlayer.message(player, F.main("Event", "============================"));
UtilPlayer.message(player, F.main("Event", "Settings for area " + area.ID));
UtilPlayer.message(player, F.oo("Damage All", area.DamageAll) + ", "
+ F.oo("Damage PvP", area.DamagePvP) + ", "
+ F.oo("Damage PvE", area.DamagePvE)
+ ", " + F.oo("Damage EvP", area.DamageEvP));
UtilPlayer.message(player, F.main("Event", "Potion Effects for area " + area.ID));
for(PotionEffectType type : area.PotionEffects.keySet())
UtilPlayer.message(player, F.oo(type.getName(), true) + " level: " + area.PotionEffects.get(type));
UtilPlayer.message(player, F.main("Event", "Gadgets for area " + area.ID));
for(SalesPackageBase gadget : area.GadgetsEnabled)
UtilPlayer.message(player, F.oo(gadget.GetName(), true));
}
}
public void editArea(Player player, String[] args)
{
if(args[1].equalsIgnoreCase("Info"))
{
listAreaSettings(player);
return;
}
try
{
if(_customAreas.containsKey(Integer.parseInt(args[1])))
{
if(args[2].equalsIgnoreCase("Del"))
{
_customAreas.remove(Integer.parseInt(args[1]));
UtilPlayer.message(player, F.main("Event", "Region deleted"));
}
if(args[2].equalsIgnoreCase("ALL"))
{
_customAreas.get(Integer.parseInt(args[1])).DamageAll = !_customAreas.get(Integer.parseInt(args[1])).DamageAll;
UtilPlayer.message(player, F.main("Event", "Damage all for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamageAll)));
}
if(args[2].equalsIgnoreCase("PVP"))
{
_customAreas.get(Integer.parseInt(args[1])).DamagePvP = !_customAreas.get(Integer.parseInt(args[1])).DamagePvP;
UtilPlayer.message(player, F.main("Event", "Damage PvP for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamagePvP)));
}
if(args[2].equalsIgnoreCase("PVE"))
{
_customAreas.get(Integer.parseInt(args[1])).DamagePvE = !_customAreas.get(Integer.parseInt(args[1])).DamagePvE;
UtilPlayer.message(player, F.main("Event", "Damage PvE for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamagePvE)));
}
if(args[2].equalsIgnoreCase("EVP"))
{
_customAreas.get(Integer.parseInt(args[1])).DamageEvP = !_customAreas.get(Integer.parseInt(args[1])).DamageEvP;
UtilPlayer.message(player, F.main("Event", "Damage EvP for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamageEvP)));
}
if(args[2].equalsIgnoreCase("Effect"))
{
PotionEffectType type = PotionEffectType.getByName(args[3]);
if(_customAreas.get(Integer.parseInt(args[1])).PotionEffects.containsKey(type))
{
_customAreas.get(Integer.parseInt(args[1])).PotionEffects.remove(type);
UtilPlayer.message(player, F.main("Event", "Removed potion effect from area"));
return;
}
if (type == null)
{
UtilPlayer.message(player, F.main("Effect", "Invalid Effect Type: " + args[2]));
UtilPlayer.message(player, F.value("Valid Types", "http://minecraft.gamepedia.com/Status_effect"));
return;
}
int strenght = 0;
try
{
strenght = Integer.parseInt(args[4]);
}
catch (Exception e) {}
_customAreas.get(Integer.parseInt(args[1])).PotionEffects.put(type, strenght);
UtilPlayer.message(player, F.main("Event", "Potion Effect added for Region " + args[1]));
}
if(args[2].equalsIgnoreCase("Gadget"))
{
//Gadgets
for (GadgetType type : GadgetType.values())
{
for (Gadget gadget : Manager.getCosmeticManager().getGadgetManager().getGadgets(type))
{
if (gadget.GetName().replaceAll(" ", "").equalsIgnoreCase(args[3]))
{
if (_customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.remove(gadget))
{
Manager.GetGame().Announce(F.main("Inventory", F.value(gadget.GetName() + " Gadget for area " + args[1], F.ed(false))));
}
else
{
Manager.GetGame().Announce(F.main("Inventory", F.value(gadget.GetName() + " Gadget for area " + args[1], F.ed(true))));
_customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.add(gadget);
}
return;
}
}
}
//Mounts
for (Mount mount : Manager.getCosmeticManager().getMountManager().getMounts())
{
if (mount.GetName().replaceAll(" ", "").equalsIgnoreCase(args[3]))
{
if (_customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.remove(mount))
{
Manager.GetGame().Announce(F.main("Inventory", F.value(mount.GetName() + " Gadget for area " + args[1], F.ed(false))));
}
else
{
Manager.GetGame().Announce(F.main("Inventory", F.value(mount.GetName() + " Gadget for area " + args[1], F.ed(true))));
_customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.add(mount);
}
return;
}
}
}
}
else
{
UtilPlayer.message(player, F.main("Event", "No Area Found"));
}
if(args[2].equalsIgnoreCase("Add"))
{
if(!_customAreas.containsKey(Integer.parseInt(args[1])))
_customAreas.put(Integer.parseInt(args[1]), new EventArea(Integer.parseInt(args[1])));
EventArea area = _customAreas.get(Integer.parseInt(args[1]));
if(args[3].equalsIgnoreCase("A"))
{
area.CornerA = player.getLocation();
UtilPlayer.message(player, F.main("Event", "Corner A set!"));
}
if(args[3].equalsIgnoreCase("B"))
{
area.CornerB = player.getLocation();
UtilPlayer.message(player, F.main("Event", "Corner B set!"));
}
if(area.CornerA != null && area.CornerB != null)
{
Location tempA = area.CornerA.clone();
Location tempB = area.CornerB.clone();
area.CornerA = new Location(tempA.getWorld(), Math.min(tempA.getX(), tempB.getX()), Math.min(tempA.getY(), tempB.getY()), Math.min(tempA.getZ(), tempB.getZ()));
area.CornerB = new Location(tempA.getWorld(), Math.max(tempA.getX(), tempB.getX()), Math.max(tempA.getY(), tempB.getY()), Math.max(tempA.getZ(), tempB.getZ()));
area.Usable = true;
UtilPlayer.message(player, F.main("Event", "Region is Usable"));
}
}
}
catch (Exception e)
{
UtilPlayer.message(player, F.main("Event", "Error while executing command"));
}
}
@EventHandler
public void preventChestDrop(PlayerDropItemEvent event)
{
if(event.getItemDrop() == null)
return;
if(event.getItemDrop().getItemStack().getType() != Material.CHEST)
return;
if(!event.getItemDrop().getItemStack().hasItemMeta())
return;
event.setCancelled(true);
}
@EventHandler
public void gemSign(final PlayerInteractEvent event)
{
if(event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if(event.getClickedBlock().getType() != Material.SIGN && event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST)
return;
Sign sign = (Sign) event.getClickedBlock().getState();
if(!sign.getLine(0).contentEquals("(GEM)"))
return;
final Material mat = Material.getMaterial(Integer.parseInt(sign.getLine(1)));
Integer price = Integer.parseInt(sign.getLine(2));
if(price > 500)
price = 500;
if(price <= 0)
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "You got an item for free."));
event.getPlayer().getInventory().addItem(new ItemStack(mat));
return;
}
if(Manager.GetDonation().Get(event.getPlayer()).GetGems() < price)
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "You dont have enough Gems."));
return;
}
final int gems = price;
Manager.GetDonation().RewardGems(new Callback<Boolean>()
{
public void run(Boolean completed)
{
if (completed)
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "You bought an item for " + gems + " Gems."));
event.getPlayer().getInventory().addItem(new ItemStack(mat));
}
}
}, "Gem Sign", event.getPlayer().getName(), event.getPlayer().getUniqueId(), -price);
}
public class EventArea
{
public int ID;
public Location CornerA;
public Location CornerB;
public boolean DamageAll;
public boolean DamagePvP;
public boolean DamagePvE;
public boolean DamageEvP;
public boolean Usable;
public HashMap<PotionEffectType, Integer> PotionEffects;
public HashSet<SalesPackageBase> GadgetsEnabled;
public EventArea(Integer id)
{
ID = id;
Usable = false;
PotionEffects = new HashMap<>();
GadgetsEnabled = new HashSet<SalesPackageBase>();
}
}
} }

View File

@ -12,23 +12,33 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilSystem;
import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.creature.event.CreatureKillEntitiesEvent; import mineplex.core.creature.event.CreatureKillEntitiesEvent;
import mineplex.core.event.StackerEvent;
import mineplex.core.gadget.gadgets.MorphBlock;
import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.GadgetType;
import mineplex.core.give.Give; import mineplex.core.give.Give;
import mineplex.core.mount.Mount; import mineplex.core.mount.Mount;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.events.PlayerDeathOutEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
import org.bukkit.entity.Ageable; import org.bukkit.entity.Ageable;
@ -36,16 +46,19 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.Slime; import org.bukkit.entity.Slime;
import org.bukkit.entity.Villager; import org.bukkit.entity.Villager;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.entity.Wolf; import org.bukkit.entity.Wolf;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -54,17 +67,26 @@ 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<>();
private boolean _mobGriefing = true; private boolean _mobGriefing;
private HashSet<Entity> _tempStackShift = new HashSet<Entity>();
private ArrayList<Player> _stacker;
private ArrayList<Player> _damage;
private boolean _allowStacker;
public EventModule(ArcadeManager manager, JavaPlugin plugin) public EventModule(ArcadeManager manager, JavaPlugin plugin)
{ {
super("EventModule", plugin); super("EventModule", plugin);
Manager = manager; Manager = manager;
_mobGriefing = true;
_stacker = new ArrayList<>();
_damage = new ArrayList<>();
} }
@EventHandler @EventHandler
@ -110,7 +132,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;"));
@ -137,6 +159,12 @@ public class EventModule extends MiniPlugin
UtilPlayer.message(player, F.value("/e give <player> <item> <amount> [e:#,e:#...]", "Give Item")); UtilPlayer.message(player, F.value("/e give <player> <item> <amount> [e:#,e:#...]", "Give Item"));
UtilPlayer.message(player, F.value("/e doublejump", "Toggles Double Jump")); UtilPlayer.message(player, F.value("/e doublejump", "Toggles Double Jump"));
UtilPlayer.message(player, F.value("/e bc", "Broadcast a message with colorcodes"));
UtilPlayer.message(player, F.value("/e tempgadget", "Activates gadget for all player"));
UtilPlayer.message(player, F.value("/e playerdamage", "Toggles damage fpr player"));
UtilPlayer.message(player, F.value("/e stacker [Player]", "toggles stacker global or for Players"));
UtilPlayer.message(player, F.value("/e kick", "Remove a player from the event"));
UtilPlayer.message(player, F.value("/e area PVP|ALL|PVE|EVP|Gadget|Effect / add", "Create and edit areas"));
UtilPlayer.message(player, F.value("/e scoreboard <Line #> [Text]", "Sets Scoreboard Text")); UtilPlayer.message(player, F.value("/e scoreboard <Line #> [Text]", "Sets Scoreboard Text"));
@ -151,7 +179,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 +209,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;
@ -257,7 +285,7 @@ public class EventModule extends MiniPlugin
} }
else if (args[0].equalsIgnoreCase("effect")) else if (args[0].equalsIgnoreCase("effect"))
{ {
commandEffect(event.getPlayer(), args); commandEffect(event.getPlayer(), args, null);
} }
else if (args[0].equalsIgnoreCase("kit")) else if (args[0].equalsIgnoreCase("kit"))
{ {
@ -356,17 +384,77 @@ public class EventModule extends MiniPlugin
{ {
commandBlockPlaceInCreative(event.getPlayer(), args); commandBlockPlaceInCreative(event.getPlayer(), args);
} }
else if(args[0].equalsIgnoreCase("blockbreakcreative")) else if(args[0].equalsIgnoreCase("stacker"))
{ {
commandBlockBreakInCreative(event.getPlayer(), args); commandStacker(event.getPlayer(), args);
}
else if(args[0].equalsIgnoreCase("playerdamage"))
{
if(args[1] == null)
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "Insufficient arguments!"));
return;
}
if(Bukkit.getPlayer(args[1]) == null)
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "This Player is not online!"));
return;
}
if(_damage.contains(Bukkit.getPlayer(args[1])))
_damage.remove(Bukkit.getPlayer(args[1]));
else
_damage.add(Bukkit.getPlayer(args[1]));
}
else if(args[0].equalsIgnoreCase("bc"))
{
commandBC(event.getPlayer(), args);
}
else if(args[0].equalsIgnoreCase("area"))
{
if(!(Manager.GetGame() instanceof EventGame)) {
UtilPlayer.message(event.getPlayer(), F.main("Settings", "You can only edit areas in the Event game!"));
return;
}
((EventGame) Manager.GetGame()).editArea(event.getPlayer(), args);
} }
else if(args[0].equalsIgnoreCase("mobgriefing")) else if(args[0].equalsIgnoreCase("mobgriefing"))
{ {
commandMobGriefing(event.getPlayer(), args); commandMobGriefing(event.getPlayer(), args);
} }
else if(args[0].equalsIgnoreCase("kick"))
{
if(Bukkit.getPlayer(args[1]) == null)
{
UtilPlayer.message(event.getPlayer(), "No matches for: " + C.cYellow + args[1]);
return;
}
//Bukkit.getPlayer(args[1]).kickPlayer("You where kicked from the event, probably you didn't stick to the Event Rules.");
Manager.GetGameHostManager().getBlacklist().add(Bukkit.getPlayer(args[1]).getName());
UtilPlayer.message(event.getPlayer(), F.main("Event", "You removed " + C.cYellow + Bukkit.getPlayer(args[1]).getName()));
}
else if(args[0].equalsIgnoreCase("tempgadget"))
{
String gadget = args[1];
for(int e = 2; e < args.length; e++)
gadget+= " " + args[e];
try
{
for(Player target : UtilServer.getPlayers())
Manager.GetDonation().Get(target).AddUnknownSalesPackagesOwned(gadget);
}
catch (Exception e)
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "Gadget is not vallid"));
}
UtilPlayer.message(event.getPlayer(), F.main("Event", "You gave the gadget " + F.item(gadget) + " to all Players!"));
}
} }
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 +477,55 @@ 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 commandStacker(Player player, String[] args)
{
if(args.length == 1)
{
_allowStacker = !_allowStacker;
UtilPlayer.message(player, F.main("Settings", "Stacker all: " + F.tf(_allowStacker)));
}
else
{
for(Player target : UtilPlayer.matchOnline(player, args[1], true))
{
if(_stacker.contains(target))
{
_stacker.remove(target);
UtilPlayer.message(target, F.main("Settings", "Stacker: " + F.tf(false)));
UtilPlayer.message(player, F.main("Settings", "Stacker " + target.getName() + ": " + F.tf(false)));
}
else
{
_stacker.add(target);
UtilPlayer.message(target, F.main("Settings", "Stacker: " + F.tf(true)));
UtilPlayer.message(player, F.main("Settings", "Stacker " + target.getName() + ": " + F.tf(true)));
}
}
}
}
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 +586,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 +647,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 +678,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 +709,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 +741,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 +783,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 +895,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 +928,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 +950,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 +972,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 +1004,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 +1015,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 +1023,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 +1031,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 +1039,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 +1057,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)) {
@ -987,7 +1102,7 @@ public class EventModule extends MiniPlugin
lineText += " "; lineText += " ";
} }
((EventGame) Manager.GetGame()).getSideText()[line] = lineText; ((EventGame) Manager.GetGame()).getSideText()[line] = ChatColor.translateAlternateColorCodes('&', lineText);
UtilPlayer.message(player, F.main("Scoreboard", "Set Line " + F.elem(line+"") + " to " + F.elem(lineText) + ".")); UtilPlayer.message(player, F.main("Scoreboard", "Set Line " + F.elem(line+"") + " to " + F.elem(lineText) + "."));
@ -1016,7 +1131,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 +1171,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 +1559,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 +1605,17 @@ 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 commandBC(Player caller, String[] args)
{
String message = args[1];
for(int e = 2; e < args.length; e++)
message += " " + args[e];
String colored = ChatColor.translateAlternateColorCodes('&', message);
Manager.GetGame().Announce(F.main("Event", colored), true);
}
public void commandKit(Player caller, String[] args)
{ {
if(!(Manager.GetGame() instanceof EventGame)) { if(!(Manager.GetGame() instanceof EventGame)) {
@ -1533,7 +1658,7 @@ public class EventModule extends MiniPlugin
commandHelp(caller); commandHelp(caller);
} }
private void commandEffect(Player caller, String[] args) public void commandEffect(Player caller, String[] args, ArrayList<Player> players)
{ {
//Clear //Clear
if (args.length >= 3 && args[2].equalsIgnoreCase("clear")) if (args.length >= 3 && args[2].equalsIgnoreCase("clear"))
@ -1551,9 +1676,19 @@ public class EventModule extends MiniPlugin
} }
else else
{ {
targets = UtilPlayer.matchOnline(caller, args[1], true); if(players == null)
if (targets.isEmpty()) {
return; targets = UtilPlayer.matchOnline(caller, args[1], true);
if (targets.isEmpty())
return;
}
else
{
targets = new LinkedList<>();
for(Player player : players)
targets.add(player);
}
} }
for (Player player : targets) for (Player player : targets)
@ -1648,9 +1783,19 @@ public class EventModule extends MiniPlugin
} }
else else
{ {
targets = UtilPlayer.matchOnline(caller, args[1], true); if(players == null)
if (targets.isEmpty()) {
return; targets = UtilPlayer.matchOnline(caller, args[1], true);
if (targets.isEmpty())
return;
}
else
{
targets = new LinkedList<>();
for(Player player : players)
targets.add(player);
}
} }
//Apply //Apply
@ -1681,9 +1826,110 @@ public class EventModule extends MiniPlugin
{ {
for(PotionEffectType effect : _potionEffectsDuration.keySet()) for(PotionEffectType effect : _potionEffectsDuration.keySet())
{ {
if(_potionEffectsDuration.get(effect) < 0)
continue;
player.addPotionEffect(new PotionEffect(effect, (int) (((_potionEffectsDuration.get(effect) - System.currentTimeMillis()) / 1000) * 20), _potionEffectsMult.get(effect))); player.addPotionEffect(new PotionEffect(effect, (int) (((_potionEffectsDuration.get(effect) - System.currentTimeMillis()) / 1000) * 20), _potionEffectsMult.get(effect)));
} }
} }
} }
@EventHandler
public void StackEntity(PlayerInteractEntityEvent event)
{
if (!Manager.GetGame().IsLive())
return;
if (event.getRightClicked().getVehicle() != null)
return;
Player player = event.getPlayer();
Entity other = event.getRightClicked();
if(!_allowStacker && !_stacker.contains(player))
return;
if (Manager.isSpectator(event.getPlayer()))
return;
if (!Manager.GetGame().IsAlive(event.getPlayer()))
return;
if (Manager.getCosmeticManager().getGadgetManager().getActive(player, GadgetType.Morph) instanceof MorphBlock)
{
UtilPlayer.message(player, F.main("Stacker", "You cannot stack while using the Block Morph."));
return;
}
StackerEvent stackerEvent = new StackerEvent(player);
Bukkit.getServer().getPluginManager().callEvent(stackerEvent);
if (stackerEvent.isCancelled())
return;
//Effect
event.getRightClicked().getWorld().playEffect(event.getRightClicked().getLocation(), Effect.STEP_SOUND, 35);
//Stack
player.setPassenger(other);
//Audio
player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 1f);
//Inform
if ((event.getRightClicked() instanceof Player))
{
UtilPlayer.message(other, F.main("Event", F.elem(Manager.GetGame().GetTeam(player).GetColor() + player.getName()) + " picked you up."));
UtilPlayer.message(player, F.main("Event", "You picked up " + F.elem(Manager.GetGame().GetTeam(((Player) other)).GetColor() + ((Player) other).getName()) + "."));
}
}
@EventHandler
public void ThrowEntity(PlayerInteractEvent event)
{
if (!UtilEvent.isAction(event, ActionType.L))
return;
Player thrower = event.getPlayer();
if (thrower.getVehicle() != null)
return;
Entity throwee = thrower.getPassenger();
if (throwee == null)
return;
StackerEvent stackerEvent = new StackerEvent(thrower);
Bukkit.getServer().getPluginManager().callEvent(stackerEvent);
if (stackerEvent.isCancelled())
return;
thrower.eject();
Entity throweeStack = throwee.getPassenger();
if (throweeStack != null)
{
throwee.eject();
throweeStack.leaveVehicle();
final Entity fThrower = thrower;
final Entity fThroweeStack = throweeStack;
_tempStackShift.add(throweeStack);
getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
{
public void run()
{
fThrower.setPassenger(fThroweeStack);
_tempStackShift.remove(fThroweeStack);
}
}, 2);
}
}
public ArrayList<Player> getDamagePlayers()
{
return _damage;
}
} }