Fixed/changed per-class permissions, added Endermen, Cave Spiders and Silverfish, and other stuff.

This commit is contained in:
Garbage Mule
2011-09-18 23:33:07 +02:00
parent f1433cfc88
commit dcff0915a5
5 changed files with 36 additions and 21 deletions
BIN
View File
Binary file not shown.
+13 -17
View File
@@ -76,8 +76,8 @@ public class Arena
protected Map<Integer,List<ItemStack>> everyWaveMap, afterWaveMap; protected Map<Integer,List<ItemStack>> everyWaveMap, afterWaveMap;
protected Map<Player,String> classMap; protected Map<Player,String> classMap;
protected Map<String,List<ItemStack>> classItems, classArmor; protected Map<String,List<ItemStack>> classItems, classArmor;
protected Map<String,List<String>> classPerms; protected Map<String,Map<String,Boolean>> classPerms;
protected Map<Player,List<PermissionAttachment>> attachments; protected Map<Player,PermissionAttachment> attachments;
protected List<ItemStack> entryFee; protected List<ItemStack> entryFee;
// Player sets // Player sets
@@ -144,7 +144,7 @@ public class Arena
randoms = new HashSet<Player>(); randoms = new HashSet<Player>();
repairables = new LinkedList<Repairable>(); repairables = new LinkedList<Repairable>();
containables = new LinkedList<Repairable>(); containables = new LinkedList<Repairable>();
attachments = new HashMap<Player,List<PermissionAttachment>>(); attachments = new HashMap<Player,PermissionAttachment>();
running = false; running = false;
edit = false; edit = false;
@@ -603,7 +603,7 @@ public class Arena
public void movePlayerToEntry(Player p) public void movePlayerToEntry(Player p)
{ {
Location entry = locations.get(p); Location entry = locations.get(p);
if (entry == null) return; if (entry == null || p.isDead()) return;
updateChunk(entry); updateChunk(entry);
p.teleport(entry); p.teleport(entry);
@@ -731,26 +731,22 @@ public class Arena
} }
public void assignClassPermissions(Player p) public void assignClassPermissions(Player p)
{ {
Configuration config = plugin.getConfig(); Map<String,Boolean> perms = classPerms.get(classMap.get(p));
String clazz = classMap.get(p); if (perms == null || perms.isEmpty()) return;
String path = "classes." + clazz + ".permissions.";
List<String> permissions = classPerms.get(classMap.get(p));
if (permissions == null || permissions.isEmpty()) return;
attachments.put(p, new LinkedList<PermissionAttachment>()); PermissionAttachment pa = p.addAttachment(plugin);
for (String perm : permissions) attachments.put(p,pa);
attachments.get(p).add(p.addAttachment(plugin, perm, config.getBoolean(path + perm, true))); for (Map.Entry<String,Boolean> entry : perms.entrySet())
pa.setPermission(entry.getKey(), entry.getValue());
} }
public void removeClassPermissions(Player p) public void removeClassPermissions(Player p)
{ {
if (attachments.get(p) == null) return; if (attachments.get(p) == null) return;
for (PermissionAttachment pa : attachments.get(p)) for (PermissionAttachment pa : attachments.values())
if (pa != null) if (pa != null) pa.remove();
pa.remove();
} }
private void cleanup() private void cleanup()
@@ -30,7 +30,7 @@ public class ArenaMaster //implements Master
// Classes // Classes
protected List<String> classes; protected List<String> classes;
protected Map<String,List<ItemStack>> classItems, classArmor; protected Map<String,List<ItemStack>> classItems, classArmor;
protected Map<String,List<String>> classPerms; protected Map<String,Map<String,Boolean>> classPerms;
//protected Map<Integer,Map<Player,List<ItemStack>>> classBonuses; //protected Map<Integer,Map<Player,List<ItemStack>>> classBonuses;
protected Map<Player,Arena> arenaMap; protected Map<Player,Arena> arenaMap;
+19 -3
View File
@@ -197,14 +197,30 @@ public class MAUtils
return result; return result;
} }
public static Map<String,List<String>> getClassPerms(Configuration config) public static Map<String,Map<String,Boolean>> getClassPerms(Configuration config)
{ {
Map<String,List<String>> result = new HashMap<String,List<String>>(); Map<String, Map<String,Boolean>> result = new HashMap<String, Map<String,Boolean>>();
List<String> classes = config.getKeys("classes"); List<String> classes = config.getKeys("classes");
if (classes == null) return result; if (classes == null) return result;
for (String c : classes) for (String c : classes)
result.put(c, config.getKeys("classes." + c + ".permissions")); {
// Get all the permissions for the class and return if empty.
List<String> keys = config.getStringList("classes." + c + ".permissions", new LinkedList<String>());
if (keys.isEmpty()) continue;
// If the string starts with a hyphen (-), use false.
Map<String,Boolean> perms = new HashMap<String,Boolean>();
for (String p : keys)
{
boolean b = !p.startsWith("-");
String s = b ? p : p.substring(1);
perms.put(s,b);
}
result.put(c,perms);
}
return result; return result;
} }
@@ -28,6 +28,9 @@ public enum MACreature
HUMAN(CreatureType.MONSTER), HUMANS(CreatureType.MONSTER), HUMAN(CreatureType.MONSTER), HUMANS(CreatureType.MONSTER),
GIANT(CreatureType.GIANT), GIANTS(CreatureType.GIANT), GIANT(CreatureType.GIANT), GIANTS(CreatureType.GIANT),
GHAST(CreatureType.GHAST), GHASTS(CreatureType.GHAST), GHAST(CreatureType.GHAST), GHASTS(CreatureType.GHAST),
ENDERMAN(CreatureType.ENDERMAN), ENDERMEN(CreatureType.ENDERMAN),
CAVESPIDER(CreatureType.CAVE_SPIDER), CAVESPIDERS(CreatureType.CAVE_SPIDER),
SILVERFISH(CreatureType.SILVERFISH),
// Passive creatures // Passive creatures
CHICKEN(CreatureType.CHICKEN), CHICKENS(CreatureType.CHICKEN), CHICKEN(CreatureType.CHICKEN), CHICKENS(CreatureType.CHICKEN),