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

Binary file not shown.

View File

@ -76,8 +76,8 @@ public class Arena
protected Map<Integer,List<ItemStack>> everyWaveMap, afterWaveMap;
protected Map<Player,String> classMap;
protected Map<String,List<ItemStack>> classItems, classArmor;
protected Map<String,List<String>> classPerms;
protected Map<Player,List<PermissionAttachment>> attachments;
protected Map<String,Map<String,Boolean>> classPerms;
protected Map<Player,PermissionAttachment> attachments;
protected List<ItemStack> entryFee;
// Player sets
@ -144,7 +144,7 @@ public class Arena
randoms = new HashSet<Player>();
repairables = new LinkedList<Repairable>();
containables = new LinkedList<Repairable>();
attachments = new HashMap<Player,List<PermissionAttachment>>();
attachments = new HashMap<Player,PermissionAttachment>();
running = false;
edit = false;
@ -603,7 +603,7 @@ public class Arena
public void movePlayerToEntry(Player p)
{
Location entry = locations.get(p);
if (entry == null) return;
if (entry == null || p.isDead()) return;
updateChunk(entry);
p.teleport(entry);
@ -731,26 +731,22 @@ public class Arena
}
public void assignClassPermissions(Player p)
{
Configuration config = plugin.getConfig();
String clazz = classMap.get(p);
String path = "classes." + clazz + ".permissions.";
List<String> permissions = classPerms.get(classMap.get(p));
if (permissions == null || permissions.isEmpty()) return;
{
Map<String,Boolean> perms = classPerms.get(classMap.get(p));
if (perms == null || perms.isEmpty()) return;
attachments.put(p, new LinkedList<PermissionAttachment>());
for (String perm : permissions)
attachments.get(p).add(p.addAttachment(plugin, perm, config.getBoolean(path + perm, true)));
PermissionAttachment pa = p.addAttachment(plugin);
attachments.put(p,pa);
for (Map.Entry<String,Boolean> entry : perms.entrySet())
pa.setPermission(entry.getKey(), entry.getValue());
}
public void removeClassPermissions(Player p)
{
if (attachments.get(p) == null) return;
for (PermissionAttachment pa : attachments.get(p))
if (pa != null)
pa.remove();
for (PermissionAttachment pa : attachments.values())
if (pa != null) pa.remove();
}
private void cleanup()

View File

@ -30,7 +30,7 @@ public class ArenaMaster //implements Master
// Classes
protected List<String> classes;
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<Player,Arena> arenaMap;

View File

@ -197,14 +197,30 @@ public class MAUtils
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");
if (classes == null) return result;
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;
}

View File

@ -28,6 +28,9 @@ public enum MACreature
HUMAN(CreatureType.MONSTER), HUMANS(CreatureType.MONSTER),
GIANT(CreatureType.GIANT), GIANTS(CreatureType.GIANT),
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
CHICKEN(CreatureType.CHICKEN), CHICKENS(CreatureType.CHICKEN),