Added player-limit, fixed a few bugs
This commit is contained in:
Binary file not shown.
@@ -89,8 +89,8 @@ public class Arena
|
|||||||
protected int spawnMonsters;
|
protected int spawnMonsters;
|
||||||
protected boolean allowMonsters, allowAnimals;
|
protected boolean allowMonsters, allowAnimals;
|
||||||
|
|
||||||
// Global settings
|
// Other settings
|
||||||
protected int repairDelay;
|
protected int repairDelay, playerLimit;
|
||||||
protected List<String> classes = new LinkedList<String>();
|
protected List<String> classes = new LinkedList<String>();
|
||||||
protected Map<Player,Location> locations = new HashMap<Player,Location>();
|
protected Map<Player,Location> locations = new HashMap<Player,Location>();
|
||||||
|
|
||||||
@@ -314,25 +314,9 @@ public class Arena
|
|||||||
listener.onPlayerLeave(p);
|
listener.onPlayerLeave(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playerQuit(Player p)
|
|
||||||
{
|
|
||||||
p.teleport(locations.get(p));
|
|
||||||
readyPlayers.remove(p);
|
|
||||||
livePlayers.remove(p);
|
|
||||||
deadPlayers.remove(p);
|
|
||||||
specPlayers.remove(p);
|
|
||||||
removePets(p);
|
|
||||||
|
|
||||||
if (!emptyInvJoin) MAUtils.restoreInventory(p);
|
|
||||||
|
|
||||||
if (running && livePlayers.isEmpty())
|
|
||||||
endArena();
|
|
||||||
else if (!readyPlayers.isEmpty() && readyPlayers.equals(livePlayers))
|
|
||||||
startArena();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playerDeath(final Player p)
|
public void playerDeath(final Player p)
|
||||||
{
|
{
|
||||||
|
p.teleport(arenaLoc); // This will force players to drop any items held
|
||||||
p.teleport(spectatorLoc);
|
p.teleport(spectatorLoc);
|
||||||
p.setFireTicks(0);
|
p.setFireTicks(0);
|
||||||
p.setHealth(20);
|
p.setHealth(20);
|
||||||
@@ -482,6 +466,7 @@ public class Arena
|
|||||||
pvp = config.getBoolean(arenaPath + "pvp-enabled", false);
|
pvp = config.getBoolean(arenaPath + "pvp-enabled", false);
|
||||||
monsterInfight = config.getBoolean(arenaPath + "monster-infight", false);
|
monsterInfight = config.getBoolean(arenaPath + "monster-infight", false);
|
||||||
allowWarp = config.getBoolean(arenaPath + "allow-teleporting", false);
|
allowWarp = config.getBoolean(arenaPath + "allow-teleporting", false);
|
||||||
|
playerLimit = config.getInt(arenaPath + "player-limit", 0);
|
||||||
repairDelay = config.getInt(arenaPath + "repair-delay", 5);
|
repairDelay = config.getInt(arenaPath + "repair-delay", 5);
|
||||||
waveDelay = config.getInt(arenaPath + "first-wave-delay", 5) * 20;
|
waveDelay = config.getInt(arenaPath + "first-wave-delay", 5) * 20;
|
||||||
waveInterval = config.getInt(arenaPath + "wave-interval", 20) * 20;
|
waveInterval = config.getInt(arenaPath + "wave-interval", 20) * 20;
|
||||||
@@ -1049,21 +1034,23 @@ public class Arena
|
|||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
public void onPlayerQuit(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
if (!enabled || !getAllPlayers().contains(p))
|
if (!enabled || !livePlayers.contains(p))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MAUtils.clearInventory(p);
|
//MAUtils.clearInventory(p);
|
||||||
playerQuit(p);
|
plugin.getAM().arenaMap.remove(p);
|
||||||
|
playerLeave(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerKick(PlayerKickEvent event)
|
public void onPlayerKick(PlayerKickEvent event)
|
||||||
{
|
{
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
if (!enabled || !getAllPlayers().contains(p))
|
if (!enabled || !livePlayers.contains(p))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MAUtils.clearInventory(p);
|
//MAUtils.clearInventory(p);
|
||||||
playerQuit(p);
|
plugin.getAM().arenaMap.remove(p);
|
||||||
|
playerLeave(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Teleport Listener
|
// Teleport Listener
|
||||||
@@ -1210,8 +1197,9 @@ public class Arena
|
|||||||
for (Player p : livePlayers)
|
for (Player p : livePlayers)
|
||||||
{
|
{
|
||||||
MAUtils.clearInventory(p);
|
MAUtils.clearInventory(p);
|
||||||
playerDeath(p);
|
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.FORCE_END_IDLE));
|
MAUtils.tellPlayer(p, MAMessages.get(Msg.FORCE_END_IDLE));
|
||||||
|
p.damage(32768);
|
||||||
|
//playerDeath(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, maxIdleTime);
|
}, maxIdleTime);
|
||||||
|
|||||||
@@ -261,6 +261,7 @@ public class ArenaMaster
|
|||||||
config.setProperty("arenas." + configName + ".settings.pvp-enabled", false);
|
config.setProperty("arenas." + configName + ".settings.pvp-enabled", false);
|
||||||
config.setProperty("arenas." + configName + ".settings.monster-infight", false);
|
config.setProperty("arenas." + configName + ".settings.monster-infight", false);
|
||||||
config.setProperty("arenas." + configName + ".settings.allow-teleporting", false);
|
config.setProperty("arenas." + configName + ".settings.allow-teleporting", false);
|
||||||
|
config.setProperty("arenas." + configName + ".settings.player-limit", 0);
|
||||||
config.save();
|
config.save();
|
||||||
config.load();
|
config.load();
|
||||||
config.setProperty("arenas." + configName + ".settings.repair-delay", 5);
|
config.setProperty("arenas." + configName + ".settings.repair-delay", 5);
|
||||||
|
|||||||
@@ -137,6 +137,8 @@ public class MACommands implements CommandExecutor
|
|||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_IS_RUNNING));
|
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_IS_RUNNING));
|
||||||
else if (arena.livePlayers.contains(p))
|
else if (arena.livePlayers.contains(p))
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ALREADY_PLAYING));
|
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ALREADY_PLAYING));
|
||||||
|
else if (arena.playerLimit > 0 && arena.livePlayers.size() >= arena.playerLimit)
|
||||||
|
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_PLAYER_LIMIT_REACHED));
|
||||||
else if (arena.emptyInvJoin && !MAUtils.hasEmptyInventory(p))
|
else if (arena.emptyInvJoin && !MAUtils.hasEmptyInventory(p))
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_EMPTY_INV));
|
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_EMPTY_INV));
|
||||||
else if (!arena.emptyInvJoin && !MAUtils.storeInventory(p))
|
else if (!arena.emptyInvJoin && !MAUtils.storeInventory(p))
|
||||||
@@ -147,6 +149,8 @@ public class MACommands implements CommandExecutor
|
|||||||
if (error)
|
if (error)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
System.out.println("playerLimit: " + arena.playerLimit + ", livePlayers: " + arena.livePlayers.size());
|
||||||
|
|
||||||
am.arenaMap.put(p,arena);
|
am.arenaMap.put(p,arena);
|
||||||
arena.playerJoin(p, p.getLocation());
|
arena.playerJoin(p, p.getLocation());
|
||||||
|
|
||||||
@@ -179,6 +183,8 @@ public class MACommands implements CommandExecutor
|
|||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_IS_RUNNING));
|
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_IS_RUNNING));
|
||||||
else if (arena.livePlayers.contains(p))
|
else if (arena.livePlayers.contains(p))
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ALREADY_PLAYING));
|
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ALREADY_PLAYING));
|
||||||
|
else if (arena.playerLimit > 0 && arena.livePlayers.size() >= arena.playerLimit)
|
||||||
|
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_PLAYER_LIMIT_REACHED));
|
||||||
else if (arena.emptyInvJoin && !MAUtils.hasEmptyInventory(p))
|
else if (arena.emptyInvJoin && !MAUtils.hasEmptyInventory(p))
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_EMPTY_INV));
|
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_EMPTY_INV));
|
||||||
else if (!arena.emptyInvJoin && !MAUtils.storeInventory(p))
|
else if (!arena.emptyInvJoin && !MAUtils.storeInventory(p))
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public class MAMessages
|
|||||||
JOIN_ARENA_IS_RUNNING,
|
JOIN_ARENA_IS_RUNNING,
|
||||||
JOIN_ALREADY_PLAYING,
|
JOIN_ALREADY_PLAYING,
|
||||||
JOIN_ARG_NEEDED,
|
JOIN_ARG_NEEDED,
|
||||||
|
JOIN_PLAYER_LIMIT_REACHED,
|
||||||
JOIN_EMPTY_INV,
|
JOIN_EMPTY_INV,
|
||||||
JOIN_STORE_INV_FAIL,
|
JOIN_STORE_INV_FAIL,
|
||||||
LEAVE_PLAYER_LEFT,
|
LEAVE_PLAYER_LEFT,
|
||||||
@@ -76,6 +77,7 @@ public class MAMessages
|
|||||||
defaults.put(Msg.JOIN_ALREADY_PLAYING, "You are already playing!");
|
defaults.put(Msg.JOIN_ALREADY_PLAYING, "You are already playing!");
|
||||||
defaults.put(Msg.JOIN_ARG_NEEDED, "You must specify an arena. Type /ma arenas for a list.");
|
defaults.put(Msg.JOIN_ARG_NEEDED, "You must specify an arena. Type /ma arenas for a list.");
|
||||||
defaults.put(Msg.JOIN_EMPTY_INV, "You must empty your inventory to join the arena.");
|
defaults.put(Msg.JOIN_EMPTY_INV, "You must empty your inventory to join the arena.");
|
||||||
|
defaults.put(Msg.JOIN_PLAYER_LIMIT_REACHED, "The player limit of this arena has been reached.");
|
||||||
defaults.put(Msg.JOIN_STORE_INV_FAIL, "Failed to store inventory. Try again.");
|
defaults.put(Msg.JOIN_STORE_INV_FAIL, "Failed to store inventory. Try again.");
|
||||||
defaults.put(Msg.JOIN_PLAYER_JOINED, "You joined the arena. Have fun!");
|
defaults.put(Msg.JOIN_PLAYER_JOINED, "You joined the arena. Have fun!");
|
||||||
defaults.put(Msg.LEAVE_NOT_PLAYING, "You are not in the arena.");
|
defaults.put(Msg.LEAVE_NOT_PLAYING, "You are not in the arena.");
|
||||||
@@ -108,7 +110,7 @@ public class MAMessages
|
|||||||
defaults.put(Msg.MISC_LIST_PLAYERS, "Live players: %");
|
defaults.put(Msg.MISC_LIST_PLAYERS, "Live players: %");
|
||||||
defaults.put(Msg.MISC_LIST_ARENAS, "Available arenas: %");
|
defaults.put(Msg.MISC_LIST_ARENAS, "Available arenas: %");
|
||||||
defaults.put(Msg.MISC_COMMAND_NOT_ALLOWED, "You can't use that command in the arena!");
|
defaults.put(Msg.MISC_COMMAND_NOT_ALLOWED, "You can't use that command in the arena!");
|
||||||
defaults.put(Msg.MISC_NO_ACCESS, "You don't have access to this comand.");
|
defaults.put(Msg.MISC_NO_ACCESS, "You don't have access to this command.");
|
||||||
defaults.put(Msg.MISC_NONE, "<none>");
|
defaults.put(Msg.MISC_NONE, "<none>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -330,6 +330,12 @@ public class MAUtils
|
|||||||
ItemStack[] armor = p.getInventory().getArmorContents();
|
ItemStack[] armor = p.getInventory().getArmorContents();
|
||||||
ItemStack[] items = p.getInventory().getContents();
|
ItemStack[] items = p.getInventory().getContents();
|
||||||
|
|
||||||
|
/*p.getLocation().getBlock().getRelative(BlockFace.UP).setType(Material.CHEST);
|
||||||
|
Chest chest = (Chest) p.getLocation().getBlock().getRelative(BlockFace.UP).getState();
|
||||||
|
for (ItemStack stack : p.getInventory().getContents())
|
||||||
|
if (stack != null)
|
||||||
|
chest.getInventory().addItem(stack);*/
|
||||||
|
|
||||||
String invPath = "plugins" + sep + "MobArena" + sep + "inventories";
|
String invPath = "plugins" + sep + "MobArena" + sep + "inventories";
|
||||||
new File(invPath).mkdir();
|
new File(invPath).mkdir();
|
||||||
File backupFile = new File(invPath + sep + p.getName() + ".inv");
|
File backupFile = new File(invPath + sep + p.getName() + ".inv");
|
||||||
|
|||||||
Reference in New Issue
Block a user