Improving /e commands (/e kick, /e area, etc)
This commit is contained in:
parent
4240026024
commit
b56813deef
@ -13,6 +13,7 @@ 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.UtilEvent;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
@ -62,6 +63,7 @@ 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.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
@ -851,13 +853,7 @@ public class EventGame extends Game
|
||||
{
|
||||
for(Player player : varMap.get(1))
|
||||
{
|
||||
String[] newArgs = new String[commandArgs.length-1];
|
||||
|
||||
for (int e=0 ; e<newArgs.length ; e++)
|
||||
newArgs[e] = commandArgs[e+1];
|
||||
|
||||
newArgs[0] = player.getName();
|
||||
Give.Instance.parseInput(Manager.GetGameHostManager().getHost(), newArgs);
|
||||
player.getInventory().addItem(new ItemStack(Material.getMaterial(args[2]), Integer.parseInt(args[3])));
|
||||
}
|
||||
|
||||
} catch (Exception e)
|
||||
@ -917,6 +913,17 @@ public class EventGame extends Game
|
||||
if(area.Usable == false)
|
||||
continue;
|
||||
|
||||
if(Manager.GetEventModule().getDamagePlayers().contains(event.GetDamagerPlayer(true)))
|
||||
{
|
||||
if(!Manager.GetGame().DamagePvP)
|
||||
{
|
||||
Manager.GetGame().DamagePvP = true;
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
Manager.GetGame().DamagePvP = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.GetDamageeEntity().getLocation().getX() < area.CornerA.getX() || event.GetDamageeEntity().getLocation().getX() > area.CornerB.getX())
|
||||
continue;
|
||||
|
||||
@ -929,12 +936,14 @@ public class EventGame extends Game
|
||||
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))
|
||||
@ -942,6 +951,7 @@ public class EventGame extends Game
|
||||
if(!area.DamagePvE)
|
||||
{
|
||||
event.SetCancelled("Event Area");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if((event.GetDamageeEntity() instanceof Player) && (event.GetDamagerEntity(true) instanceof Player))
|
||||
@ -949,8 +959,17 @@ public class EventGame extends Game
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1024,6 +1043,21 @@ public class EventGame extends Game
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
public class EventArea
|
||||
{
|
||||
|
||||
|
@ -12,16 +12,22 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilSystem;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
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.GadgetType;
|
||||
import mineplex.core.give.Give;
|
||||
import mineplex.core.mount.Mount;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -50,6 +56,7 @@ import org.bukkit.event.EventPriority;
|
||||
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.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@ -65,7 +72,10 @@ public class EventModule extends MiniPlugin
|
||||
|
||||
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)
|
||||
@ -74,6 +84,7 @@ public class EventModule extends MiniPlugin
|
||||
Manager = manager;
|
||||
_mobGriefing = true;
|
||||
_stacker = new ArrayList<>();
|
||||
_damage = new ArrayList<>();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -369,6 +380,29 @@ public class EventModule extends MiniPlugin
|
||||
{
|
||||
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)) {
|
||||
@ -389,8 +423,9 @@ public class EventModule extends MiniPlugin
|
||||
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.");
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Event", "You kicked " + C.cYellow + Bukkit.getPlayer(args[1]).getName()));
|
||||
//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"))
|
||||
{
|
||||
@ -1562,6 +1597,16 @@ public class EventModule extends MiniPlugin
|
||||
UtilPlayer.message(caller, F.main("Creature", "Killed " + target + ". " + count + " Removed."));
|
||||
}
|
||||
|
||||
public void commandBC(Player caller, String[] args)
|
||||
{
|
||||
String message = args[1];
|
||||
for(int e = 2; e <= 3; e++)
|
||||
message += " " + args[e];
|
||||
|
||||
String colored = ChatColor.translateAlternateColorCodes('&', message);
|
||||
Manager.GetGame().Announce(F.main("Event", colored), true);
|
||||
}
|
||||
|
||||
public void commandKit(Player caller, String[] args)
|
||||
{
|
||||
|
||||
@ -1773,25 +1818,25 @@ public class EventModule extends MiniPlugin
|
||||
{
|
||||
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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void StackPlayer(PlayerInteractEntityEvent event)
|
||||
public void StackEntity(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (!Manager.GetGame().IsLive())
|
||||
return;
|
||||
|
||||
if (!(event.getRightClicked() instanceof Player))
|
||||
return;
|
||||
|
||||
if (event.getRightClicked().getVehicle() != null)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Player other = (Player)event.getRightClicked();
|
||||
Entity other = event.getRightClicked();
|
||||
|
||||
if(!_allowStacker && !_stacker.contains(player))
|
||||
return;
|
||||
@ -1802,6 +1847,17 @@ public class EventModule extends MiniPlugin
|
||||
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);
|
||||
|
||||
@ -1812,8 +1868,66 @@ public class EventModule extends MiniPlugin
|
||||
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(other).GetColor() + other.getName()) + "."));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void playerDamage(CustomDamageEvent event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<Player> getDamagePlayers()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user