mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-26 12:36:00 +01:00
Removed excess files
This commit is contained in:
parent
110db86ab9
commit
203a4a15f7
@ -1,54 +0,0 @@
|
||||
package com.garbagemule.MobArena;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
|
||||
/**
|
||||
* This listener acts as a type of death-listener.
|
||||
* When a player is sufficiently low on health, and the next
|
||||
* damaging blow will kill them, they are teleported to the
|
||||
* spectator area, they have their hearts replenished, and all
|
||||
* their items are stripped from them.
|
||||
* By the end of the arena session, the rewards are given.
|
||||
*/
|
||||
// TO-DO: Perhaps implement TeamFluff's respawn-packet-code.
|
||||
public class MADeathListener extends EntityListener
|
||||
{
|
||||
public MADeathListener(MobArena instance)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all player/monster drops on death. Also handles
|
||||
* player death events.
|
||||
*/
|
||||
public void onEntityDeath(EntityDeathEvent event)
|
||||
{
|
||||
// If player, call player death and such.
|
||||
if (event.getEntity() instanceof Player)
|
||||
{
|
||||
Player p = (Player) event.getEntity();
|
||||
|
||||
if (!ArenaManager.playerSet.contains(p))
|
||||
return;
|
||||
|
||||
event.getDrops().clear();
|
||||
ArenaManager.playerDeath(p);
|
||||
p.getInventory().clear();
|
||||
}
|
||||
// If monster, remove from monster set
|
||||
else if (event.getEntity() instanceof LivingEntity)
|
||||
{
|
||||
LivingEntity e = (LivingEntity) event.getEntity();
|
||||
|
||||
if (!ArenaManager.monsterSet.contains(e))
|
||||
return;
|
||||
|
||||
event.getDrops().clear();
|
||||
ArenaManager.monsterSet.remove(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package com.garbagemule.MobArena;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
/**
|
||||
* Handles the disabled commands.
|
||||
*/
|
||||
public class MADisabledCommands extends PlayerListener
|
||||
{
|
||||
private MobArena plugin;
|
||||
|
||||
public MADisabledCommands(MobArena instance)
|
||||
{
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
|
||||
if (!ArenaManager.playerSet.contains(p))
|
||||
return;
|
||||
|
||||
String[] args = event.getMessage().split(" ");
|
||||
|
||||
if (!plugin.DISABLED_COMMANDS.contains(event.getMessage().substring(1).trim()) &&
|
||||
!plugin.DISABLED_COMMANDS.contains(args[0]))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
ArenaManager.tellPlayer(p, "You can't use that command in the arena!");
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package com.garbagemule.MobArena;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
/**
|
||||
* This listener acts when a player is kicked or disconnected
|
||||
* from the server. If 15 seconds pass, and the player hasn't
|
||||
* reconnected, the player is forced to leave the arena.
|
||||
*/
|
||||
public class MADisconnectListener extends PlayerListener
|
||||
{
|
||||
public MADisconnectListener(MobArena instance)
|
||||
{
|
||||
}
|
||||
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
|
||||
if (ArenaManager.playerSet.contains(p))
|
||||
{
|
||||
MAUtils.clearInventory(p);
|
||||
ArenaManager.playerLeave(p);
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerKick(PlayerKickEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
|
||||
if (ArenaManager.playerSet.contains(p))
|
||||
{
|
||||
MAUtils.clearInventory(p);
|
||||
ArenaManager.playerLeave(p);
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (!ArenaManager.checkUpdates)
|
||||
return;
|
||||
|
||||
final Player p = event.getPlayer();
|
||||
|
||||
if (!event.getPlayer().isOp())
|
||||
return;
|
||||
|
||||
ArenaManager.server.getScheduler().scheduleSyncDelayedTask(ArenaManager.plugin,
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
MAUtils.checkForUpdates(p, false);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
}
|
@ -1,122 +0,0 @@
|
||||
package com.garbagemule.MobArena;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
|
||||
/**
|
||||
* This listener prevents players from sharing class-specific
|
||||
* items (read: cheating) before the arena session starts.
|
||||
*/
|
||||
// TO-DO: Merge with MASignListener and MAReadyListener into MALobbyListener
|
||||
public class MALobbyListener extends PlayerListener
|
||||
{
|
||||
public MALobbyListener(MobArena instance)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Players can only drop items when the arena session has started.
|
||||
*/
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
|
||||
if (!ArenaManager.playerSet.contains(p))
|
||||
return;
|
||||
|
||||
if (ArenaManager.isRunning)
|
||||
return;
|
||||
|
||||
ArenaManager.tellPlayer(p, "No sharing before the arena starts!");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds liquid blocks to the blockset when players empty their buckets.
|
||||
*/
|
||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event)
|
||||
{
|
||||
if (!ArenaManager.playerSet.contains(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (!ArenaManager.isRunning)
|
||||
{
|
||||
event.getBlockClicked().getFace(event.getBlockFace()).setTypeId(0);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Block liquid = event.getBlockClicked().getFace(event.getBlockFace());
|
||||
ArenaManager.blockSet.add(liquid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player hits an iron block or a sign, or if the player
|
||||
* is trying to use an item.
|
||||
*/
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
// Only do these checks if the arena isn't running.
|
||||
if (ArenaManager.isRunning)
|
||||
return;
|
||||
|
||||
Player p = event.getPlayer();
|
||||
|
||||
if (!ArenaManager.playerSet.contains(p))
|
||||
return;
|
||||
|
||||
Action a = event.getAction();
|
||||
|
||||
// Check if player is trying to use an item.
|
||||
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 (ArenaManager.classMap.containsKey(p))
|
||||
{
|
||||
ArenaManager.tellPlayer(p, "You have been flagged as ready!");
|
||||
ArenaManager.playerReady(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ArenaManager.tellPlayer(p, "You must first pick a class!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Sign
|
||||
if (event.hasBlock() && event.getClickedBlock().getState() instanceof Sign)
|
||||
{
|
||||
if (a == Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
ArenaManager.tellPlayer(p, "Punch the sign. Don't 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 (!ArenaManager.classes.contains(className))
|
||||
return;
|
||||
|
||||
// Set the player's class.
|
||||
ArenaManager.assignClass(p, className);
|
||||
ArenaManager.tellPlayer(p, "You have chosen " + className + " as your class!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
package com.garbagemule.MobArena;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||
|
||||
/**
|
||||
* Prevents Creeper explosions from damaging the blocks of the
|
||||
* arena, zombies and skeletons from burning in the sun, and
|
||||
* monsters (mostly spiders) from losing their targets.
|
||||
*/
|
||||
public class MAMonsterListener extends EntityListener
|
||||
{
|
||||
private MobArena plugin;
|
||||
|
||||
public MAMonsterListener(MobArena instance)
|
||||
{
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents monsters from spawning inside the arena unless
|
||||
* it's running.
|
||||
*/
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||
{
|
||||
// If monster spawning is disabled, only spawn inside the region.
|
||||
if (!ArenaManager.spawnMonsters)
|
||||
{
|
||||
if (ArenaManager.isRunning && MAUtils.inRegion(event.getLocation()))
|
||||
return;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// Otherwise, ignore spawns inside the region...
|
||||
if (!MAUtils.inRegion(event.getLocation()))
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof LivingEntity))
|
||||
return;
|
||||
|
||||
// .. And cancel those inside the region if the arena isn't running.
|
||||
if (!ArenaManager.isRunning)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles all explosion events, also from TNT.
|
||||
*/
|
||||
public void onEntityExplode(EntityExplodeEvent event)
|
||||
{
|
||||
// Check if any of the block "victims" are in the region.
|
||||
if (!MAUtils.inRegion(event.getLocation()))
|
||||
{
|
||||
boolean inRegion = false;
|
||||
for (Block b : event.blockList())
|
||||
{
|
||||
if (!MAUtils.inRegion(b.getLocation()))
|
||||
continue;
|
||||
inRegion = true;
|
||||
break;
|
||||
}
|
||||
if (!inRegion)
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't drop any blocks from the explosion.
|
||||
event.setYield(0);
|
||||
|
||||
// Store the blocks and their values in the map.
|
||||
final HashMap<Block,Integer> blockMap = new HashMap<Block,Integer>();
|
||||
|
||||
for (Block b : event.blockList())
|
||||
{
|
||||
// Doors are wonky, so don't store them. Just smile and wave, and remove from set.
|
||||
if (b.getType() == Material.WOODEN_DOOR || b.getType() == Material.IRON_DOOR_BLOCK || b.getType() == Material.CAKE_BLOCK)
|
||||
{
|
||||
ArenaManager.blockSet.remove(b);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If a block is in the blockSet, make sure it drops "naturally" so Oddjob doesn't cry.
|
||||
if (ArenaManager.blockSet.remove(b))
|
||||
{
|
||||
ArenaManager.world.dropItemNaturally(b.getLocation(), new ItemStack(b.getTypeId(), 1));
|
||||
continue;
|
||||
}
|
||||
|
||||
// If a block has extra data, store it as a fourth digit (thousand).
|
||||
int type = b.getTypeId() + (b.getData() * 1000);
|
||||
blockMap.put(b, type);
|
||||
}
|
||||
|
||||
// Wait a couple of ticks, then rebuild the blocks.
|
||||
ArenaManager.server.getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
for (Block b : blockMap.keySet())
|
||||
{
|
||||
int type = blockMap.get(b);
|
||||
|
||||
// Modulo 1000 to get the actual type id.
|
||||
b.getLocation().getBlock().setTypeId(type % 1000);
|
||||
|
||||
/* If the type ID is greater than 1000, it means the block
|
||||
* has extra data (stairs, levers, etc.). We subtract the
|
||||
* block type data by dividing by 1000. Integer division
|
||||
* always rounds by truncation. */
|
||||
if (type > 1000)
|
||||
b.getLocation().getBlock().setData((byte) (type / 1000));
|
||||
}
|
||||
}
|
||||
}, ArenaManager.repairDelay);
|
||||
}
|
||||
|
||||
// Zombie/skeleton combustion from the sun.
|
||||
public void onEntityCombust(EntityCombustEvent event)
|
||||
{
|
||||
if (ArenaManager.monsterSet.contains(event.getEntity()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// Monsters losing their targets.
|
||||
public void onEntityTarget(EntityTargetEvent event)
|
||||
{
|
||||
if (!ArenaManager.isRunning)
|
||||
return;
|
||||
|
||||
if (!ArenaManager.monsterSet.contains(event.getEntity()))
|
||||
return;
|
||||
|
||||
if (event.getReason() == TargetReason.FORGOT_TARGET)
|
||||
event.setTarget(MASpawnThread.getClosestPlayer(event.getEntity()));
|
||||
|
||||
if (event.getReason() == TargetReason.TARGET_DIED)
|
||||
event.setTarget(MASpawnThread.getClosestPlayer(event.getEntity()));
|
||||
|
||||
if (event.getReason() == TargetReason.CLOSEST_PLAYER)
|
||||
event.setTarget(MASpawnThread.getClosestPlayer(event.getEntity()));
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package com.garbagemule.MobArena;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
/**
|
||||
* This listener prevents players from warping out of the arena, if
|
||||
* they are in the arena session.
|
||||
* Also prevents players from warping into the arena during a session.
|
||||
*/
|
||||
// TO-DO: Fix the bug that causes the message when people get stuck in walls.
|
||||
public class MATeleportListener extends PlayerListener
|
||||
{
|
||||
public MATeleportListener(MobArena instance)
|
||||
{
|
||||
}
|
||||
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
Location to = event.getTo();
|
||||
|
||||
// If the player teleports from outside of the arena..
|
||||
if (!ArenaManager.playerSet.contains(p))
|
||||
{
|
||||
if (!MAUtils.inRegion(to))
|
||||
return;
|
||||
|
||||
if (!ArenaManager.isRunning)
|
||||
return;
|
||||
|
||||
if (ArenaManager.spectatorLoc.equals(to))
|
||||
return;
|
||||
|
||||
// ..into the region during a battle; cancel
|
||||
ArenaManager.tellPlayer(p, "Can't warp to the arena during battle!");
|
||||
ArenaManager.tellPlayer(p, "Type /ma spec to watch.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, only warp if to is in the locationMap, or a valid warp
|
||||
if (ArenaManager.locationMap.get(p).equals(to) ||
|
||||
ArenaManager.arenaLoc.equals(to) ||
|
||||
ArenaManager.lobbyLoc.equals(to) ||
|
||||
ArenaManager.spectatorLoc.equals(to))
|
||||
return;
|
||||
|
||||
// If warp isn't valid, notify the player
|
||||
ArenaManager.tellPlayer(p, "Warping not allowed in the arena!");
|
||||
ArenaManager.tellPlayer(p, "Type /ma leave to leave");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user