fixing @p on signs, adding potioneffects and gadgets to areas.
This commit is contained in:
parent
b6ffee73f5
commit
fcec6253cd
@ -25,7 +25,10 @@ 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.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.recharge.Recharge;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
@ -68,6 +71,8 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class EventGame extends Game
|
||||
{
|
||||
@ -130,6 +135,7 @@ public class EventGame extends Game
|
||||
this.InventoryClick = true;
|
||||
this.InventoryOpenBlock = true;
|
||||
this.InventoryOpenChest = true;
|
||||
|
||||
|
||||
//Dont timeout
|
||||
this.GameTimeout = -1;
|
||||
@ -647,23 +653,27 @@ public class EventGame extends Game
|
||||
for(String varArgs : args)
|
||||
{
|
||||
ArrayList<Player> players = new ArrayList<>();
|
||||
if(Bukkit.getPlayer(playerName) != null)
|
||||
players.add(Bukkit.getPlayer(playerName));
|
||||
if(Bukkit.getPlayer(varArgs) != null)
|
||||
players.add(Bukkit.getPlayer(varArgs));
|
||||
|
||||
if(playerName.contentEquals("@p"))
|
||||
if(varArgs.contentEquals("@p"))
|
||||
{
|
||||
for(Player player : GetPlayers(true))
|
||||
{
|
||||
boolean found = 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 = true)
|
||||
if(found)
|
||||
{
|
||||
players.add(player);
|
||||
break;
|
||||
@ -736,7 +746,7 @@ public class EventGame extends Game
|
||||
|
||||
if(command.contentEquals("[SETBLOCK]"))
|
||||
{
|
||||
Material mat = Material.getMaterial(args[1]);
|
||||
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]);
|
||||
@ -747,7 +757,7 @@ public class EventGame extends Game
|
||||
if(command.contentEquals("[TESTFOR]"))
|
||||
{
|
||||
boolean redstone = false;
|
||||
Material mat = Material.getMaterial(args[1]);
|
||||
Material mat = Material.getMaterial(Integer.parseInt(args[1]));
|
||||
if(args[2].contains("r="))
|
||||
{
|
||||
int radius = 0;
|
||||
@ -853,7 +863,7 @@ public class EventGame extends Game
|
||||
{
|
||||
for(Player player : varMap.get(1))
|
||||
{
|
||||
player.getInventory().addItem(new ItemStack(Material.getMaterial(args[2]), Integer.parseInt(args[3])));
|
||||
player.getInventory().addItem(new ItemStack(Material.getMaterial(Integer.parseInt(args[2])), Integer.parseInt(args[3])));
|
||||
}
|
||||
|
||||
} catch (Exception e)
|
||||
@ -902,6 +912,68 @@ public class EventGame extends Game
|
||||
}
|
||||
}
|
||||
|
||||
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, 30, area.PotionEffects.get(type)), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void areaDamage(CustomDamageEvent event)
|
||||
{
|
||||
@ -917,20 +989,16 @@ public class EventGame extends Game
|
||||
{
|
||||
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(event.GetDamageeEntity().getLocation().getX() < area.CornerA.getX() || event.GetDamageeEntity().getLocation().getX() > area.CornerB.getX())
|
||||
continue;
|
||||
|
||||
if(event.GetDamageeEntity().getLocation().getY() < area.CornerA.getY() || event.GetDamageeEntity().getLocation().getY() > area.CornerB.getY())
|
||||
continue;
|
||||
|
||||
if(event.GetDamageeEntity().getLocation().getZ() < area.CornerA.getZ() || event.GetDamageeEntity().getLocation().getZ() > area.CornerB.getZ())
|
||||
if(!isInArea(area, event.GetDamageeEntity()))
|
||||
continue;
|
||||
|
||||
if(!area.DamageAll)
|
||||
@ -1004,6 +1072,67 @@ public class EventGame extends Game
|
||||
_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 (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
|
||||
{
|
||||
@ -1073,10 +1202,15 @@ public class EventGame extends Game
|
||||
|
||||
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>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.events.PlayerDeathOutEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -57,6 +58,7 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
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.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@ -1600,7 +1602,7 @@ public class EventModule extends MiniPlugin
|
||||
public void commandBC(Player caller, String[] args)
|
||||
{
|
||||
String message = args[1];
|
||||
for(int e = 2; e <= 3; e++)
|
||||
for(int e = 2; e < args.length; e++)
|
||||
message += " " + args[e];
|
||||
|
||||
String colored = ChatColor.translateAlternateColorCodes('&', message);
|
||||
@ -1919,12 +1921,6 @@ public class EventModule extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void playerDamage(CustomDamageEvent event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<Player> getDamagePlayers()
|
||||
{
|
||||
return _damage;
|
||||
|
Loading…
Reference in New Issue
Block a user