mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-01-27 02:31:28 +01:00
v0.92 - Added Permissions support
This commit is contained in:
parent
b5eb307513
commit
eae0439e25
BIN
MobArena.jar
BIN
MobArena.jar
Binary file not shown.
@ -288,9 +288,8 @@ public class Arena
|
||||
if (deadPlayers.remove(p)) clear = false;
|
||||
if (specPlayers.remove(p)) clear = false;
|
||||
|
||||
if (clear)
|
||||
MAUtils.clearInventory(p);
|
||||
MAUtils.restoreInventory(p);
|
||||
if (clear) MAUtils.clearInventory(p);
|
||||
if (!emptyInv) MAUtils.restoreInventory(p);
|
||||
|
||||
if (running && livePlayers.isEmpty())
|
||||
endArena();
|
||||
@ -942,6 +941,12 @@ public class Arena
|
||||
String className = sign.getLine(0);
|
||||
if (!classes.contains(className))
|
||||
return;
|
||||
|
||||
if (!MobArena.hasDefTrue(p, "mobarena.classes." + className))
|
||||
{
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_CLASS_PERMISSION));
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the player's class.
|
||||
assignClass(p, className);
|
||||
@ -1070,6 +1075,14 @@ public class Arena
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Player> getNonreadyPlayers()
|
||||
{
|
||||
List<Player> result = new LinkedList<Player>();
|
||||
result.addAll(livePlayers);
|
||||
result.removeAll(readyPlayers);
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Player> getDeadPlayers()
|
||||
{
|
||||
List<Player> result = new LinkedList<Player>();
|
||||
|
@ -92,8 +92,8 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
// Grab the command base and any arguments.
|
||||
String base = args[0].toLowerCase();
|
||||
String arg1 = (args.length >= 2) ? args[1].toLowerCase() : null;
|
||||
String arg2 = (args.length >= 3) ? args[2].toLowerCase() : null;
|
||||
String arg1 = (args.length > 1) ? args[1].toLowerCase() : "";
|
||||
String arg2 = (args.length > 2) ? args[2].toLowerCase() : "";
|
||||
//String arg3 = (args.length >= 4) ? args[3].toLowerCase() : null;
|
||||
|
||||
|
||||
@ -109,15 +109,15 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("join") || base.equals("j"))
|
||||
{
|
||||
if (!player)
|
||||
if (!player || !MobArena.has(p, "mobarena.use.join"))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Players only.");
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean error;
|
||||
|
||||
if (arg1 != null)
|
||||
if (!arg1.isEmpty())
|
||||
{
|
||||
Arena arena = am.getArenaWithName(arg1);
|
||||
|
||||
@ -152,8 +152,7 @@ public class MACommands implements CommandExecutor
|
||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_PLAYER_JOINED));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg1 == null)
|
||||
else
|
||||
{
|
||||
if (am.arenas.size() < 1)
|
||||
{
|
||||
@ -202,9 +201,9 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("leave") || base.equals("l"))
|
||||
{
|
||||
if (!player)
|
||||
if (!player || !MobArena.has(p, "mobarena.use.leave"))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Players only.");
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -225,16 +224,16 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("spectate") || base.equals("spec"))
|
||||
{
|
||||
if (!player)
|
||||
if (!player || !MobArena.has(p, "mobarena.use.spectate"))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Players only.");
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean error;
|
||||
Arena arena = null;
|
||||
|
||||
if (arg1 != null)
|
||||
if (!arg1.isEmpty())
|
||||
{
|
||||
arena = am.getArenaWithName(arg1);
|
||||
|
||||
@ -285,7 +284,7 @@ public class MACommands implements CommandExecutor
|
||||
* Prints a list of all arenas.
|
||||
*/
|
||||
if (base.equals("arenas"))
|
||||
{
|
||||
{
|
||||
String list = MAUtils.listToString(am.arenas);
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_LIST_ARENAS, list));
|
||||
return true;
|
||||
@ -296,7 +295,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("players") || base.equals("list"))
|
||||
{
|
||||
if (arg1 != null)
|
||||
if (!arg1.isEmpty())
|
||||
{
|
||||
Arena arena = am.getArenaWithName(arg1);
|
||||
if (arena == null)
|
||||
@ -312,20 +311,55 @@ public class MACommands implements CommandExecutor
|
||||
{
|
||||
StringBuffer buffy = new StringBuffer();
|
||||
for (Arena arena : am.arenas)
|
||||
buffy.append(MAUtils.listToString(arena.getLivingPlayers()));
|
||||
buffy.append(MAUtils.listToString(arena.getLivingPlayers(), false));
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_LIST_PLAYERS, buffy.toString()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prints a list of all non-ready players in current arena, or non-ready players in a specific arena.
|
||||
*/
|
||||
if (base.equals("notready"))
|
||||
{
|
||||
Arena arena;
|
||||
if (!arg1.isEmpty())
|
||||
{
|
||||
arena = am.getArenaWithName(arg1);
|
||||
if (arena == null)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (player)
|
||||
{
|
||||
arena = am.getArenaWithPlayer(p);
|
||||
if (arena == null)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.LEAVE_NOT_PLAYING));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma notready <arena name>");
|
||||
return true;
|
||||
}
|
||||
|
||||
String list = MAUtils.listToString(arena.getNonreadyPlayers());
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_LIST_PLAYERS, list));
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore a player's inventory.
|
||||
*/
|
||||
if (base.equals("restore"))
|
||||
{
|
||||
if (arg1 == null && player)
|
||||
if (arg1.isEmpty() && player)
|
||||
{
|
||||
if (am.getArenaWithPlayer((Player) sender) != null)
|
||||
if (am.getArenaWithPlayer(p) != null)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "You must first leave the current arena.");
|
||||
return true;
|
||||
@ -335,7 +369,7 @@ public class MACommands implements CommandExecutor
|
||||
MAUtils.tellPlayer(sender, "Restored your inventory!");
|
||||
return true;
|
||||
}
|
||||
if (arg1 != null && (op || console))
|
||||
if (!arg1.isEmpty() && (op || console))
|
||||
{
|
||||
if (am.getArenaWithPlayer(arg1) != null)
|
||||
{
|
||||
@ -362,13 +396,14 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if ((base.equals("enable") || base.equals("disable")))
|
||||
{
|
||||
if (!(op || console))
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.admin.enable")) && !op)
|
||||
//if (player && !MobArena.has(p, "mobarena.admin.enable"))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg1 != null)
|
||||
if (!arg1.isEmpty())
|
||||
{
|
||||
Arena arena = am.getArenaWithName(arg1);
|
||||
if (arena != null)
|
||||
@ -396,12 +431,12 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("protect"))
|
||||
{
|
||||
if (!(op || console))
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.admin.protect")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9_]*$") || arg2 == null || !(arg2.equals("true") || arg2.equals("false")))
|
||||
if (arg1.isEmpty() || !arg1.matches("^[a-zA-Z][a-zA-Z0-9_]*$") || !(arg2.equals("true") || arg2.equals("false")))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma protect <arena name> [true|false]");
|
||||
return true;
|
||||
@ -424,22 +459,17 @@ public class MACommands implements CommandExecutor
|
||||
/*
|
||||
* Force start/end arenas.
|
||||
*/
|
||||
if (base.equals("force"))
|
||||
{
|
||||
if (!(op || console))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9_]*$"))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma force [start|end] (<arena name>)");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (base.equals("force") && arg1.equals("end"))
|
||||
{
|
||||
if (arg1.equals("end"))
|
||||
{
|
||||
if (arg2 == null)
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.admin.force.end")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg2.isEmpty())
|
||||
{
|
||||
for (Arena arena : am.arenas)
|
||||
arena.forceEnd();
|
||||
@ -447,11 +477,6 @@ public class MACommands implements CommandExecutor
|
||||
am.arenaMap.clear();
|
||||
return true;
|
||||
}
|
||||
if (!arg2.matches("^[a-zA-Z][a-zA-Z0-9_]*$"))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma force end (<arena name>)");
|
||||
return true;
|
||||
}
|
||||
|
||||
Arena arena = am.getArenaWithName(arg2);
|
||||
if (arena == null)
|
||||
@ -460,7 +485,6 @@ public class MACommands implements CommandExecutor
|
||||
return true;
|
||||
}
|
||||
|
||||
// The arena exists.
|
||||
if (arena.livePlayers.isEmpty())
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.FORCE_END_EMPTY));
|
||||
@ -471,10 +495,15 @@ public class MACommands implements CommandExecutor
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.FORCE_END_ENDED));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg1.equals("start"))
|
||||
else if (arg1.equals("start"))
|
||||
{
|
||||
if (arg2 == null || !arg2.matches("^[a-zA-Z][a-zA-Z0-9_]*$"))
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.admin.force.start")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg2.isEmpty())
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma force start <arena name>");
|
||||
return true;
|
||||
@ -487,7 +516,6 @@ public class MACommands implements CommandExecutor
|
||||
return true;
|
||||
}
|
||||
|
||||
// The arena exists.
|
||||
if (arena.running)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.FORCE_START_RUNNING));
|
||||
@ -503,14 +531,19 @@ public class MACommands implements CommandExecutor
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.FORCE_START_STARTED));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma force [start|end] (<arena name>)");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Reload the config-file.
|
||||
*/
|
||||
if (base.equals("config") && arg1 != null)
|
||||
if (base.equals("config"))
|
||||
{
|
||||
if (!(op || console))
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.admin.config.reload")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -532,7 +565,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("arena"))
|
||||
{
|
||||
if (!(op || console))
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.arena")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -558,12 +591,12 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("setarena"))
|
||||
{
|
||||
if (!(op || console))
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.setarena")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9_]*$"))
|
||||
if (arg1.isEmpty())
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma setarena <arena name>");
|
||||
return true;
|
||||
@ -571,9 +604,14 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
Arena arena = am.getArenaWithName(arg1);
|
||||
if (arena != null)
|
||||
{
|
||||
am.selectedArena = arena;
|
||||
MAUtils.tellPlayer(sender, "Currently selected arena: " + arena.configName());
|
||||
}
|
||||
else
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -582,12 +620,12 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("addarena"))
|
||||
{
|
||||
if (!op)
|
||||
if (!(player && MobArena.has(p, "mobarena.setup.addarena")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9_]*$"))
|
||||
if (arg1.isEmpty())
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma addarena <arena name>");
|
||||
return true;
|
||||
@ -610,17 +648,17 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
if (base.equals("delarena"))
|
||||
{
|
||||
if (!(op || console))
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.delarena")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9_]*$"))
|
||||
if (arg1.isEmpty())
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma delarena <arena name>");
|
||||
return true;
|
||||
}
|
||||
if (am.arenas.size() == 1)
|
||||
if (am.arenas.size() < 2)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "At least one arena must exist.");
|
||||
return true;
|
||||
@ -643,12 +681,12 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
if (base.equals("editarena"))
|
||||
{
|
||||
if (!(op || console))
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.editarena")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9_]*$") || arg2 == null || (!arg2.equals("true") && !arg2.equals("false")))
|
||||
if (arg1.isEmpty() || !(arg2.equals("true") || arg2.equals("false")))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma editarena <arena name> [true|false]");
|
||||
return true;
|
||||
@ -672,13 +710,13 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("setregion"))
|
||||
{
|
||||
if (!op)
|
||||
if (!(player && MobArena.has(p, "mobarena.setup.setregion")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg1 == null || !(arg1.equals("p1") || arg1.equals("p2")))
|
||||
if (!(arg1.equals("p1") || arg1.equals("p2")))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma setregion [p1|p2]");
|
||||
return true;
|
||||
@ -694,7 +732,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("expandregion"))
|
||||
{
|
||||
if (!(op || console))
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.expandregion")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -737,12 +775,12 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("setwarp"))
|
||||
{
|
||||
if (!op)
|
||||
if (!(player && MobArena.has(p, "mobarena.setup.setwarp")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
if (arg1 == null || !(arg1.equals("arena") || arg1.equals("lobby") || arg1.equals("spectator")))
|
||||
if (!(arg1.equals("arena") || arg1.equals("lobby") || arg1.equals("spectator")))
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma setwarp [arena|lobby|spectator]");
|
||||
return true;
|
||||
@ -758,7 +796,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("spawnpoints"))
|
||||
{
|
||||
if (!(op || console))
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.spawnpoints")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -789,7 +827,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("addspawn"))
|
||||
{
|
||||
if (!op)
|
||||
if (!(player && MobArena.has(p, "mobarena.setup.addspawn")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -810,7 +848,7 @@ public class MACommands implements CommandExecutor
|
||||
*/
|
||||
if (base.equals("delspawn"))
|
||||
{
|
||||
if (!(op || console))
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.delspawn")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -830,7 +868,7 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
if (base.equals("auto-generate"))
|
||||
{
|
||||
if (!op)
|
||||
if (!(player && MobArena.has(p, "mobarena.setup.autogenerate")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
@ -855,16 +893,21 @@ public class MACommands implements CommandExecutor
|
||||
|
||||
if (base.equals("auto-degenerate"))
|
||||
{
|
||||
if (!(op || console))
|
||||
if (!console && !(player && MobArena.has(p, "mobarena.setup.autodegenerate")) && !op)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
||||
return true;
|
||||
}
|
||||
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$"))
|
||||
if (arg1.isEmpty())
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "Usage: /ma auto-degenerate <arena name>");
|
||||
return true;
|
||||
}
|
||||
if (am.arenas.size() < 2)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, "At least one arena must exist!");
|
||||
return true;
|
||||
}
|
||||
if (am.getArenaWithName(arg1) == null)
|
||||
{
|
||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
||||
|
@ -36,7 +36,6 @@ public class MAMessages
|
||||
SPEC_EMPTY_INV,
|
||||
SPEC_ALREADY_PLAYING,
|
||||
NOT_READY_PLAYERS,
|
||||
NOT_READY_RUNNING,
|
||||
FORCE_START_STARTED,
|
||||
FORCE_START_RUNNING,
|
||||
FORCE_START_NOT_READY,
|
||||
@ -45,6 +44,7 @@ public class MAMessages
|
||||
FORCE_END_IDLE,
|
||||
REWARDS_GIVE,
|
||||
LOBBY_CLASS_PICKED,
|
||||
LOBBY_CLASS_PERMISSION,
|
||||
LOBBY_PLAYER_READY,
|
||||
LOBBY_DROP_ITEM,
|
||||
LOBBY_PICK_CLASS,
|
||||
@ -86,7 +86,6 @@ public class MAMessages
|
||||
defaults.put(Msg.SPEC_ARG_NEEDED, "You must specify an arena. Type /ma arenas for a list.");
|
||||
defaults.put(Msg.SPEC_EMPTY_INV, "Empty your inventory first!");
|
||||
defaults.put(Msg.SPEC_ALREADY_PLAYING, "Can't spectate when in the arena!");
|
||||
defaults.put(Msg.NOT_READY_RUNNING, "The lobby is empty!");
|
||||
defaults.put(Msg.NOT_READY_PLAYERS, "Not ready: %");
|
||||
defaults.put(Msg.FORCE_START_RUNNING, "Arena has already started.");
|
||||
defaults.put(Msg.FORCE_START_NOT_READY, "Can't force start, no players are ready.");
|
||||
@ -100,6 +99,7 @@ public class MAMessages
|
||||
defaults.put(Msg.LOBBY_PICK_CLASS, "You must first pick a class!");
|
||||
defaults.put(Msg.LOBBY_RIGHT_CLICK, "Punch the sign. Don't right-click.");
|
||||
defaults.put(Msg.LOBBY_CLASS_PICKED, "You have chosen % as your class!");
|
||||
defaults.put(Msg.LOBBY_CLASS_PERMISSION, "You don't have permission to use this class!");
|
||||
defaults.put(Msg.WARP_TO_ARENA, "Can't warp to the arena during battle!");
|
||||
defaults.put(Msg.WARP_FROM_ARENA, "Warping not allowed in the arena!");
|
||||
defaults.put(Msg.WAVE_DEFAULT, "Get ready for wave #%!");
|
||||
|
@ -289,9 +289,16 @@ public class MASpawnThread implements Runnable
|
||||
List<Location> result = new ArrayList<Location>();
|
||||
|
||||
for (Location s : arena.spawnpoints.values())
|
||||
{
|
||||
for (Player p : arena.livePlayers)
|
||||
if (s.distanceSquared(p.getLocation()) < MIN_DISTANCE)
|
||||
result.add(s);
|
||||
{
|
||||
if (s.distanceSquared(p.getLocation()) > MIN_DISTANCE)
|
||||
continue;
|
||||
|
||||
result.add(s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If no players are in range, just use all the spawnpoints.
|
||||
if (result.isEmpty())
|
||||
|
@ -33,6 +33,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
import com.garbagemule.MobArena.MAMessages.Msg;
|
||||
|
||||
public class MAUtils
|
||||
{
|
||||
public static final String sep = File.separator;
|
||||
@ -827,10 +829,18 @@ public class MAUtils
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a list into a space-separated list.
|
||||
* Turn a list into a space-separated string-representation of the list.
|
||||
*/
|
||||
public static <E> String listToString(List<E> list)
|
||||
{
|
||||
return listToString(list, true);
|
||||
}
|
||||
|
||||
public static <E> String listToString(List<E> list, boolean none)
|
||||
{
|
||||
if (none && list.isEmpty())
|
||||
return MAMessages.get(Msg.MISC_NONE);
|
||||
|
||||
StringBuffer buffy = new StringBuffer();
|
||||
for (E e : list)
|
||||
{
|
||||
|
@ -2,26 +2,33 @@ package com.garbagemule.MobArena;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
|
||||
/**
|
||||
* MobArena
|
||||
* @author garbagemule
|
||||
*/
|
||||
public class MobArena extends JavaPlugin
|
||||
{
|
||||
/* Other useful variables. */
|
||||
{
|
||||
private Configuration config;
|
||||
private ArenaMaster am;
|
||||
|
||||
// Permissions stuff
|
||||
protected static PermissionHandler permissionHandler;
|
||||
|
||||
public MobArena()
|
||||
{
|
||||
}
|
||||
@ -30,11 +37,15 @@ public class MobArena extends JavaPlugin
|
||||
{
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
|
||||
// Config, messages and ArenaMaster initialization
|
||||
loadConfig();
|
||||
MAMessages.init(this);
|
||||
am = new ArenaMaster(this);
|
||||
am.initialize();
|
||||
|
||||
// Permissions
|
||||
setupPermissions();
|
||||
|
||||
// Bind the /ma, /marena, and /mobarena commands to MACommands.
|
||||
MACommands commandExecutor = new MACommands(this, am);
|
||||
getCommand("ma").setExecutor(commandExecutor);
|
||||
@ -131,6 +142,29 @@ public class MobArena extends JavaPlugin
|
||||
config.save();
|
||||
}
|
||||
|
||||
// Permissions stuff
|
||||
public static boolean has(Player p, String s)
|
||||
{
|
||||
//return (permissionHandler != null && permissionHandler.has(p, s));
|
||||
return (permissionHandler == null || permissionHandler.has(p, s));
|
||||
}
|
||||
|
||||
public static boolean hasDefTrue(Player p, String s)
|
||||
{
|
||||
return (permissionHandler == null || permissionHandler.has(p, s));
|
||||
}
|
||||
|
||||
private void setupPermissions()
|
||||
{
|
||||
if (permissionHandler != null)
|
||||
return;
|
||||
|
||||
Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions");
|
||||
if (permissionsPlugin == null) return;
|
||||
|
||||
permissionHandler = ((Permissions) permissionsPlugin).getHandler();
|
||||
}
|
||||
|
||||
public Configuration getConfig() { return config; }
|
||||
public ArenaMaster getAM() { return am; } // More convenient.
|
||||
public ArenaMaster getArenaMaster() { return am; }
|
||||
|
Loading…
Reference in New Issue
Block a user