mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-01-11 10:59:09 +01:00
v0.93.2 - Bugfixes and preparations for Battlegrounds
This commit is contained in:
parent
a118a5056f
commit
f3131585de
BIN
MobArena.jar
BIN
MobArena.jar
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
name: MobArena
|
||||
main: com.garbagemule.MobArena.MobArena
|
||||
version: 0.92
|
||||
softdepend: [MultiVerse]
|
||||
version: 0.93.2
|
||||
softdepend: [MultiVerse,XcraftGate]
|
||||
commands:
|
||||
ma:
|
||||
description: Base command for MobArena
|
||||
|
@ -3,7 +3,7 @@ package com.garbagemule.MobArena;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class AbstractArena
|
||||
{
|
||||
{
|
||||
/**
|
||||
* Start the arena session.
|
||||
* This method should warp all players to their respective warp points, start all
|
||||
@ -11,23 +11,51 @@ public abstract class AbstractArena
|
||||
*/
|
||||
public abstract void startArena();
|
||||
|
||||
/**
|
||||
* Force the arena to start.
|
||||
* If some players are ready, this method will force all non-ready players to leave,
|
||||
* and the arena will start with only the currently ready players.
|
||||
* @return true, if the arena was successfully started, false otherwise
|
||||
*/
|
||||
public abstract boolean forceStart();
|
||||
|
||||
/**
|
||||
* Stop the arena session.
|
||||
* Distribute rewards, clean up arena floor and reset everything to how it was before
|
||||
* the arena session was started.
|
||||
* the arena session was started, false otherwise
|
||||
*/
|
||||
public abstract void endArena();
|
||||
|
||||
/**
|
||||
* Force the arena to end.
|
||||
* Returns all players to their entry locations, distributes rewards, cleans the arena
|
||||
* floor, as well as all lists, sets and maps. Calling this method will return the
|
||||
* arena to the state it would be in right after MobArena has loaded.
|
||||
* @return true, if the session was successfully ended.
|
||||
*/
|
||||
public abstract boolean forceEnd();
|
||||
|
||||
/**
|
||||
* Player joins the arena/lobby.
|
||||
* @param p A player
|
||||
* @precondition Calling canJoin(p) for the given player must return true.
|
||||
*/
|
||||
public abstract void playerJoin(Player p);
|
||||
|
||||
/**
|
||||
* Player leaves the arena/lobby.
|
||||
* Player leaves the arena or lobby.
|
||||
* @param p A player
|
||||
* @precondition Calling canLeave(p) for the given player must return true.
|
||||
*/
|
||||
public abstract void playerLeave(Player p);
|
||||
|
||||
/**
|
||||
* Player joins the spectator area.
|
||||
* @param p A player
|
||||
* @precondition Calling canSpec(p) for the given player must return true.
|
||||
*/
|
||||
public abstract void playerSpec(Player p);
|
||||
|
||||
/**
|
||||
* Player dies in the arena.
|
||||
*/
|
||||
@ -37,4 +65,43 @@ public abstract class AbstractArena
|
||||
* Player signals that they are ready.
|
||||
*/
|
||||
public abstract void playerReady(Player p);
|
||||
|
||||
/**
|
||||
* Check if a player can join the arena.
|
||||
* @param p A player
|
||||
* @return true, if the player is eligible to join the arena.
|
||||
*/
|
||||
public abstract boolean canJoin(Player p);
|
||||
|
||||
/**
|
||||
* Check if a player can leave the arena.
|
||||
* @param p A player
|
||||
* @return true, if the player is eligible to leave the arena.
|
||||
*/
|
||||
public abstract boolean canLeave(Player p);
|
||||
|
||||
/**
|
||||
* Check if a player can spectate the arena.
|
||||
* @param p A player
|
||||
* @return true, if the player is eligible for spectating.
|
||||
*/
|
||||
public abstract boolean canSpec(Player p);
|
||||
|
||||
/**
|
||||
* Check if the arena is enabled.
|
||||
* @return true, if the arena is enabled.
|
||||
*/
|
||||
public abstract boolean isEnabled();
|
||||
|
||||
/**
|
||||
* Check if the arena is running.
|
||||
* @return true, if the arena is running.
|
||||
*/
|
||||
public abstract boolean isRunning();
|
||||
|
||||
/**
|
||||
* Check if the arena is set up and ready for use.
|
||||
* @return true, if the arena is ready for use.
|
||||
*/
|
||||
public abstract boolean isSetup();
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
57
src/com/garbagemule/MobArena/ArenaListener.java
Normal file
57
src/com/garbagemule/MobArena/ArenaListener.java
Normal file
@ -0,0 +1,57 @@
|
||||
package com.garbagemule.MobArena;
|
||||
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
public interface ArenaListener
|
||||
{
|
||||
public void onBlockBreak(BlockBreakEvent event);
|
||||
public void onBlockPlace(BlockPlaceEvent event);
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event);
|
||||
public void onEntityExplode(EntityExplodeEvent event);
|
||||
public void onEntityCombust(EntityCombustEvent event);
|
||||
public void onEntityTarget(EntityTargetEvent event);
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event);
|
||||
public void onEntityDeath(EntityDeathEvent event);
|
||||
public void onEntityDamage(EntityDamageEvent event);
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event);
|
||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event);
|
||||
public void onPlayerInteract(PlayerInteractEvent event);
|
||||
public void onPlayerQuit(PlayerQuitEvent event);
|
||||
public void onPlayerKick(PlayerKickEvent event);
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event);
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event);
|
||||
|
||||
/*
|
||||
public abstract void onBlockBreak(BlockBreakEvent event);
|
||||
public abstract void onBlockPlace(BlockPlaceEvent event);
|
||||
public abstract void onCreatureSpawn(CreatureSpawnEvent event);
|
||||
public abstract void onEntityExplode(EntityExplodeEvent event);
|
||||
public abstract void onEntityCombust(EntityCombustEvent event);
|
||||
public abstract void onEntityTarget(EntityTargetEvent event);
|
||||
public abstract void onEntityRegainHealth(EntityRegainHealthEvent event);
|
||||
public abstract void onEntityDeath(EntityDeathEvent event);
|
||||
public abstract void onEntityDamage(EntityDamageEvent event);
|
||||
public abstract void onPlayerDropItem(PlayerDropItemEvent event);
|
||||
public abstract void onPlayerBucketEmpty(PlayerBucketEmptyEvent event);
|
||||
public abstract void onPlayerInteract(PlayerInteractEvent event);
|
||||
public abstract void onPlayerQuit(PlayerQuitEvent event);
|
||||
public abstract void onPlayerKick(PlayerKickEvent event);
|
||||
public abstract void onPlayerTeleport(PlayerTeleportEvent event);
|
||||
public abstract void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event);
|
||||
*/
|
||||
}
|
@ -16,12 +16,12 @@ public class MABlockListener extends BlockListener
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onBlockBreak(event);
|
||||
arena.eventListener.onBlockBreak(event);
|
||||
}
|
||||
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onBlockPlace(event);
|
||||
arena.eventListener.onBlockPlace(event);
|
||||
}
|
||||
}
|
@ -57,6 +57,8 @@ public class MACommands implements CommandExecutor
|
||||
COMMANDS.add("addspawn"); // Add a spawnpoint
|
||||
COMMANDS.add("delspawn"); // Delete a spawnpoint
|
||||
COMMANDS.add("reset"); // Reset arena coordinates
|
||||
COMMANDS.add("addclass"); // Add a new class
|
||||
COMMANDS.add("delclass"); // Delete a class
|
||||
COMMANDS.add("auto-generate"); // Auto-generate arena
|
||||
COMMANDS.add("auto-degenerate"); // Restore cuboid
|
||||
}
|
||||
@ -144,7 +146,6 @@ public class MACommands implements CommandExecutor
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARG_NEEDED));
|
||||
else if (arena == null)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
||||
//else if (am.arenaMap.containsKey(p) && am.arenaMap.get(p).livePlayers.contains(p))
|
||||
else if (am.arenaMap.containsKey(p) && (am.arenaMap.get(p).arenaPlayers.contains(p) || am.arenaMap.get(p).lobbyPlayers.contains(p)))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_IN_OTHER_ARENA));
|
||||
else if (!arena.enabled)
|
||||
@ -153,22 +154,20 @@ public class MACommands implements CommandExecutor
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_NOT_SETUP));
|
||||
else if (arena.running && arena.waitPlayers.add(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_IS_RUNNING));
|
||||
//else if (arena.livePlayers.contains(p))
|
||||
else if (arena.arenaPlayers.contains(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ALREADY_PLAYING));
|
||||
else if (!plugin.has(p, "mobarena.arenas." + arena.configName()))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_PERMISSION));
|
||||
else if (!arena.canAfford(p) || !arena.takeFee(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_FEE_REQUIRED, MAUtils.listToString(arena.entryFee, plugin)));
|
||||
//else if (arena.playerLimit > 0 && arena.livePlayers.size() >= arena.playerLimit)
|
||||
else if (arena.playerLimit > 0 && arena.lobbyPlayers.size() >= arena.playerLimit)
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_PLAYER_LIMIT_REACHED));
|
||||
else if (arena.joinDistance > 0 && !arena.inRegionRadius(p.getLocation(), arena.joinDistance))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_TOO_FAR));
|
||||
else if (!arena.canAfford(p) || !arena.takeFee(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_FEE_REQUIRED, MAUtils.listToString(arena.entryFee, plugin)));
|
||||
else if (arena.emptyInvJoin && !MAUtils.hasEmptyInventory(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_EMPTY_INV));
|
||||
else if (!arena.emptyInvJoin && !MAUtils.storeInventory(p))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_STORE_INV_FAIL));
|
||||
else if (arena.joinDistance > 0 && !arena.inRegionRadius(p.getLocation(), arena.joinDistance))
|
||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_TOO_FAR));
|
||||
else error = false;
|
||||
|
||||
// If there was an error, don't join.
|
||||
|
@ -24,42 +24,42 @@ public class MAEntityListener extends EntityListener
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
||||
{
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onEntityRegainHealth(event);
|
||||
arena.eventListener.onEntityRegainHealth(event);
|
||||
}
|
||||
|
||||
public void onEntityDeath(EntityDeathEvent event)
|
||||
{
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onEntityDeath(event);
|
||||
arena.eventListener.onEntityDeath(event);
|
||||
}
|
||||
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
{
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onEntityDamage(event);
|
||||
arena.eventListener.onEntityDamage(event);
|
||||
}
|
||||
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||
{
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onCreatureSpawn(event);
|
||||
arena.eventListener.onCreatureSpawn(event);
|
||||
}
|
||||
|
||||
public void onEntityExplode(EntityExplodeEvent event)
|
||||
{
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onEntityExplode(event);
|
||||
arena.eventListener.onEntityExplode(event);
|
||||
}
|
||||
|
||||
public void onEntityCombust(EntityCombustEvent event)
|
||||
{
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onEntityCombust(event);
|
||||
arena.eventListener.onEntityCombust(event);
|
||||
}
|
||||
|
||||
public void onEntityTarget(EntityTargetEvent event)
|
||||
{
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onEntityTarget(event);
|
||||
arena.eventListener.onEntityTarget(event);
|
||||
}
|
||||
}
|
525
src/com/garbagemule/MobArena/MAListener.java
Normal file
525
src/com/garbagemule/MobArena/MAListener.java
Normal file
@ -0,0 +1,525 @@
|
||||
package com.garbagemule.MobArena;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.garbagemule.MobArena.MAMessages.Msg;
|
||||
|
||||
public class MAListener implements ArenaListener
|
||||
{
|
||||
private MobArena plugin;
|
||||
private Arena arena;
|
||||
|
||||
public MAListener(Arena arena, MobArena plugin)
|
||||
{
|
||||
this.arena = arena;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (!arena.inRegion(event.getBlock().getLocation()) || arena.edit || (!arena.protect && arena.running))
|
||||
return;
|
||||
|
||||
Block b = event.getBlock();
|
||||
if (arena.blocks.remove(b) || b.getType() == Material.TNT)
|
||||
return;
|
||||
|
||||
if (arena.softRestore && arena.running)
|
||||
{
|
||||
int[] buffer = new int[5];
|
||||
buffer[0] = b.getX();
|
||||
buffer[1] = b.getY();
|
||||
buffer[2] = b.getZ();
|
||||
buffer[3] = b.getTypeId();
|
||||
buffer[4] = (int) b.getData();
|
||||
arena.repairList.add(buffer);
|
||||
if (!arena.softRestoreDrops) event.getBlock().setTypeId(0);
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (!arena.inRegion(event.getBlock().getLocation()) || arena.edit)
|
||||
return;
|
||||
|
||||
Block b = event.getBlock();
|
||||
//if (running && livePlayers.contains(event.getPlayer()))
|
||||
if (arena.running && arena.arenaPlayers.contains(event.getPlayer()))
|
||||
{
|
||||
arena.blocks.add(b);
|
||||
Material mat = b.getType();
|
||||
|
||||
if (mat == Material.WOODEN_DOOR || mat == Material.IRON_DOOR_BLOCK)
|
||||
arena.blocks.add(b.getRelative(0,1,0));
|
||||
return;
|
||||
}
|
||||
|
||||
// If the arena isn't running, or if the player isn't in the arena, cancel.
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||
{
|
||||
if (!arena.inRegion(event.getLocation()))
|
||||
return;
|
||||
|
||||
// If running == true, setCancelled(false), and vice versa.
|
||||
event.setCancelled(!arena.running);
|
||||
}
|
||||
|
||||
public void onEntityExplode(EntityExplodeEvent event)
|
||||
{
|
||||
if (!arena.monsters.contains(event.getEntity()) && !arena.inRegionRadius(event.getLocation(), 10))
|
||||
return;
|
||||
|
||||
event.setYield(0);
|
||||
arena.monsters.remove(event.getEntity());
|
||||
|
||||
// If the arena isn't running
|
||||
if (!arena.running || arena.repairDelay == 0)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// If there is a sign in the blocklist, cancel
|
||||
for (Block b : event.blockList())
|
||||
{
|
||||
if (!(b.getType() == Material.SIGN_POST || b.getType() == Material.WALL_SIGN))
|
||||
continue;
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Uncancel, just in case.
|
||||
event.setCancelled(false);
|
||||
|
||||
int[] buffer;
|
||||
final HashMap<Block,Integer> blockMap = new HashMap<Block,Integer>();
|
||||
for (Block b : event.blockList())
|
||||
{
|
||||
Material mat = b.getType();
|
||||
|
||||
if (mat == Material.LAVA) b.setType(Material.STATIONARY_LAVA);
|
||||
else if (mat == Material.WATER) b.setType(Material.STATIONARY_WATER);
|
||||
|
||||
if (mat == Material.WOODEN_DOOR || mat == Material.IRON_DOOR_BLOCK || mat == Material.FIRE || mat == Material.CAKE_BLOCK || mat == Material.WATER || mat == Material.LAVA)
|
||||
{
|
||||
arena.blocks.remove(b);
|
||||
}
|
||||
else if (arena.blocks.remove(b))
|
||||
{
|
||||
arena.world.dropItemNaturally(b.getLocation(), new ItemStack(b.getTypeId(), 1));
|
||||
}
|
||||
else if (arena.softRestore)
|
||||
{
|
||||
buffer = new int[5];
|
||||
buffer[0] = b.getX();
|
||||
buffer[1] = b.getY();
|
||||
buffer[2] = b.getZ();
|
||||
buffer[3] = b.getTypeId();
|
||||
buffer[4] = (int) b.getData();
|
||||
arena.repairList.add(buffer);
|
||||
blockMap.put(b, b.getTypeId() + (b.getData() * 1000));
|
||||
}
|
||||
else
|
||||
{
|
||||
blockMap.put(b, b.getTypeId() + (b.getData() * 1000));
|
||||
}
|
||||
}
|
||||
|
||||
if (!arena.protect || arena.softRestore)
|
||||
return;
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
for (Map.Entry<Block,Integer> entry : blockMap.entrySet())
|
||||
{
|
||||
Block b = entry.getKey();
|
||||
int type = entry.getValue();
|
||||
|
||||
b.getLocation().getBlock().setTypeId(type % 1000);
|
||||
|
||||
if (type > 1000)
|
||||
b.getLocation().getBlock().setData((byte) (type / 1000));
|
||||
}
|
||||
}
|
||||
}, arena.repairDelay);
|
||||
}
|
||||
|
||||
public void onEntityCombust(EntityCombustEvent event)
|
||||
{
|
||||
if (arena.monsters.contains(event.getEntity()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public void onEntityTarget(EntityTargetEvent event)
|
||||
{
|
||||
if (!arena.running || event.isCancelled())
|
||||
return;
|
||||
|
||||
if (arena.pets.contains(event.getEntity()))
|
||||
{
|
||||
if (event.getReason() != TargetReason.TARGET_ATTACKED_OWNER && event.getReason() != TargetReason.OWNER_ATTACKED_TARGET)
|
||||
return;
|
||||
|
||||
if (!(event.getTarget() instanceof Player))
|
||||
return;
|
||||
|
||||
// If the target is a player, cancel.
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (arena.monsters.contains(event.getEntity()))
|
||||
{
|
||||
if (event.getReason() == TargetReason.FORGOT_TARGET)
|
||||
{
|
||||
event.setTarget(MAUtils.getClosestPlayer(event.getEntity(), arena));
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getReason() == TargetReason.TARGET_DIED)
|
||||
{
|
||||
event.setTarget(MAUtils.getClosestPlayer(event.getEntity(), arena));
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getReason() == TargetReason.CLOSEST_PLAYER)
|
||||
//if (!livePlayers.contains(event.getTarget()))
|
||||
if (!arena.arenaPlayers.contains(event.getTarget()))
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
||||
{
|
||||
if (!arena.running) return;
|
||||
|
||||
//if (!(event.getEntity() instanceof Player) || !livePlayers.contains((Player)event.getEntity()))
|
||||
if (!(event.getEntity() instanceof Player) || !arena.arenaPlayers.contains((Player)event.getEntity()))
|
||||
return;
|
||||
|
||||
if (event.getRegainReason() == RegainReason.REGEN)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public void onEntityDeath(EntityDeathEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player)
|
||||
{
|
||||
Player p = (Player) event.getEntity();
|
||||
|
||||
//if (!livePlayers.contains(p))
|
||||
if (!arena.arenaPlayers.contains(p))
|
||||
return;
|
||||
|
||||
event.getDrops().clear();
|
||||
arena.waveMap.put(p, arena.spawnThread.wave - 1);
|
||||
arena.playerDeath(p);
|
||||
return;
|
||||
}
|
||||
|
||||
if (arena.monsters.remove(event.getEntity()))
|
||||
{
|
||||
EntityDamageEvent e1 = event.getEntity().getLastDamageCause();
|
||||
EntityDamageByEntityEvent e2 = (e1 instanceof EntityDamageByEntityEvent) ? (EntityDamageByEntityEvent) e1 : null;
|
||||
Entity damager = (e2 != null) ? e2.getDamager() : null;
|
||||
|
||||
if (e2 != null && damager instanceof Player)
|
||||
arena.playerKill((Player) damager);
|
||||
|
||||
event.getDrops().clear();
|
||||
arena.resetIdleTimer();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
{
|
||||
if (!arena.running) return;
|
||||
|
||||
EntityDamageByEntityEvent e = (event instanceof EntityDamageByEntityEvent) ? (EntityDamageByEntityEvent) event : null;
|
||||
Entity damager = (e != null) ? e.getDamager() : null;
|
||||
Entity damagee = event.getEntity();
|
||||
|
||||
// Damagee - Pet Wolf - cancel all damage.
|
||||
if (damagee instanceof Wolf && arena.pets.contains(damagee))
|
||||
{
|
||||
if (event.getCause() == DamageCause.FIRE_TICK)
|
||||
{
|
||||
damagee.setFireTicks(32768); // For mcMMO
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (e != null && damager instanceof Player)
|
||||
event.setCancelled(true);
|
||||
|
||||
event.setDamage(0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Damager - Pet Wolf - lower damage
|
||||
if (e != null && damager instanceof Wolf && arena.pets.contains(damager))
|
||||
{
|
||||
event.setDamage(1);
|
||||
return;
|
||||
}
|
||||
|
||||
// Damagee & Damager - Player - cancel if pvp disabled
|
||||
if (damagee instanceof Player && damager instanceof Player)
|
||||
{
|
||||
//if (livePlayers.contains(damagee) && !pvp)
|
||||
if (arena.arenaPlayers.contains(damagee) && !arena.pvp)
|
||||
event.setCancelled(true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Damagee & Damager - Monsters - cancel if no monsterInfight
|
||||
if (e != null && arena.monsters.contains(damagee) && arena.monsters.contains(damager))
|
||||
{
|
||||
if (!arena.monsterInfight)
|
||||
event.setCancelled(true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Creeper detonations
|
||||
if (arena.inRegion(damagee.getLocation()))
|
||||
{
|
||||
//if (!detDamage || !(damagee instanceof Player) || !livePlayers.contains((Player) damagee))
|
||||
if (!arena.detDamage || !(damagee instanceof Player) || !arena.arenaPlayers.contains((Player) damagee))
|
||||
return;
|
||||
|
||||
if (event.getCause() == DamageCause.BLOCK_EXPLOSION)
|
||||
event.setCancelled(true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||
{
|
||||
if (arena.running && arena.shareInArena) return;
|
||||
|
||||
Player p = event.getPlayer();
|
||||
//if (!livePlayers.contains(p))
|
||||
if (!arena.arenaPlayers.contains(p) && !arena.lobbyPlayers.contains(p))
|
||||
return;
|
||||
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_DROP_ITEM));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event)
|
||||
{
|
||||
//if (!readyPlayers.contains(event.getPlayer()) && !livePlayers.contains(event.getPlayer()))
|
||||
if (!arena.readyPlayers.contains(event.getPlayer()) && !arena.arenaPlayers.contains(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (!arena.running)
|
||||
{
|
||||
event.getBlockClicked().getRelative(event.getBlockFace()).setTypeId(0);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Block liquid = event.getBlockClicked().getRelative(event.getBlockFace());
|
||||
arena.blocks.add(liquid);
|
||||
}
|
||||
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (!arena.arenaPlayers.contains(event.getPlayer()) && !arena.lobbyPlayers.contains(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (arena.running)
|
||||
{
|
||||
if (event.hasBlock() && event.getClickedBlock().getType() == Material.SAPLING)
|
||||
arena.addTrunkAndLeaves(event.getClickedBlock());
|
||||
return;
|
||||
}
|
||||
|
||||
Action a = event.getAction();
|
||||
Player p = event.getPlayer();
|
||||
if (a == Action.RIGHT_CLICK_AIR || a == Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// Iron block
|
||||
if (event.hasBlock() && event.getClickedBlock().getTypeId() == 42)
|
||||
{
|
||||
if (arena.classMap.containsKey(p))
|
||||
{
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_PLAYER_READY));
|
||||
arena.playerReady(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_PICK_CLASS));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Sign
|
||||
if (event.hasBlock() && event.getClickedBlock().getState() instanceof Sign)
|
||||
{
|
||||
if (a == Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_RIGHT_CLICK));
|
||||
return;
|
||||
}
|
||||
|
||||
// Cast the block to a sign to get the text on it.
|
||||
Sign sign = (Sign) event.getClickedBlock().getState();
|
||||
|
||||
// Check if the first line of the sign is a class name.
|
||||
String className = sign.getLine(0);
|
||||
if (!arena.classes.contains(className) && !className.equalsIgnoreCase("random"))
|
||||
return;
|
||||
|
||||
if (!plugin.hasDefTrue(p, "mobarena.classes." + className) && !className.equalsIgnoreCase("random"))
|
||||
{
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_CLASS_PERMISSION));
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the player's class.
|
||||
arena.assignClass(p, className);
|
||||
if (!className.equalsIgnoreCase("random"))
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_CLASS_PICKED, className));
|
||||
else
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_CLASS_RANDOM));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
if (!arena.enabled || (!arena.arenaPlayers.contains(p) && !arena.lobbyPlayers.contains(p)))
|
||||
return;
|
||||
|
||||
plugin.getAM().arenaMap.remove(p);
|
||||
arena.playerLeave(p);
|
||||
}
|
||||
|
||||
public void onPlayerKick(PlayerKickEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
if (!arena.enabled || (!arena.arenaPlayers.contains(p) && !arena.lobbyPlayers.contains(p)))
|
||||
return;
|
||||
|
||||
plugin.getAM().arenaMap.remove(p);
|
||||
arena.playerLeave(p);
|
||||
}
|
||||
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
if (arena.edit || !arena.enabled || !arena.setup || arena.allowWarp)
|
||||
return;
|
||||
|
||||
if (!arena.inRegion(event.getTo()) && !arena.inRegion(event.getFrom()))
|
||||
return;
|
||||
|
||||
Player p = event.getPlayer();
|
||||
Location old = arena.locations.get(p);
|
||||
Location to = event.getTo();
|
||||
Location from = event.getFrom();
|
||||
|
||||
if (arena.arenaPlayers.contains(p) || arena.lobbyPlayers.contains(p) || arena.specPlayers.contains(p))
|
||||
{
|
||||
if (arena.inRegion(from))
|
||||
{
|
||||
if (to.equals(arena.arenaLoc) || to.equals(arena.lobbyLoc) || to.equals(arena.spectatorLoc) || to.equals(old))
|
||||
return;
|
||||
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.WARP_FROM_ARENA));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (arena.inRegion(to))
|
||||
{
|
||||
if (to.equals(arena.arenaLoc) || to.equals(arena.lobbyLoc) || to.equals(arena.spectatorLoc) || to.equals(old))
|
||||
return;
|
||||
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.WARP_TO_ARENA));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (arena.running && arena.inRegion(to))
|
||||
{
|
||||
//MAUtils.tellPlayer(p, MAMessages.get(Msg.WARP_TO_ARENA));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
|
||||
//if (!livePlayers.contains(p))
|
||||
if (!arena.arenaPlayers.contains(p) && !arena.lobbyPlayers.contains(p))
|
||||
return;
|
||||
|
||||
String[] args = event.getMessage().split(" ");
|
||||
|
||||
if ((args.length > 1 && MACommands.COMMANDS.contains(args[1].trim())) ||
|
||||
MACommands.ALLOWED_COMMANDS.contains(event.getMessage().substring(1).trim()) ||
|
||||
MACommands.ALLOWED_COMMANDS.contains(args[0]))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.MISC_COMMAND_NOT_ALLOWED));
|
||||
}
|
||||
}
|
@ -24,50 +24,50 @@ public class MAPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (!am.enabled) return;
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onPlayerInteract(event);
|
||||
{
|
||||
if (!am.enabled) return;
|
||||
for (Arena arena : am.arenas)
|
||||
arena.eventListener.onPlayerInteract(event);
|
||||
}
|
||||
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||
{
|
||||
if (!am.enabled) return;
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onPlayerDropItem(event);
|
||||
arena.eventListener.onPlayerDropItem(event);
|
||||
}
|
||||
|
||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event)
|
||||
{
|
||||
if (!am.enabled) return;
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onPlayerBucketEmpty(event);
|
||||
arena.eventListener.onPlayerBucketEmpty(event);
|
||||
}
|
||||
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
if (!am.enabled) return;
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onPlayerTeleport(event);
|
||||
arena.eventListener.onPlayerTeleport(event);
|
||||
}
|
||||
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (!am.enabled) return;
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onPlayerCommandPreprocess(event);
|
||||
arena.eventListener.onPlayerCommandPreprocess(event);
|
||||
}
|
||||
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onPlayerQuit(event);
|
||||
arena.eventListener.onPlayerQuit(event);
|
||||
}
|
||||
|
||||
public void onPlayerKick(PlayerKickEvent event)
|
||||
{
|
||||
for (Arena arena : am.arenas)
|
||||
arena.onPlayerKick(event);
|
||||
arena.eventListener.onPlayerKick(event);
|
||||
}
|
||||
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
|
@ -75,6 +75,9 @@ public class MASpawnThread implements Runnable
|
||||
|
||||
public void run()
|
||||
{
|
||||
if (arena.arenaPlayers.isEmpty())
|
||||
return;
|
||||
|
||||
List<Entity> tmp = new LinkedList<Entity>(arena.monsters);
|
||||
for (Entity e : tmp)
|
||||
if (e.isDead())
|
||||
|
Loading…
Reference in New Issue
Block a user