Add a couple of new tiny features.

- With pvp-enabled: true, PvP is activated at the first wave,
  giving players a period of time to spread out.
- The per-class config option, unbreakable-weapons: true-false, can
  be used to set whether weapons for a class should have infinite
  durability or not.
This commit is contained in:
garbagemule
2012-12-22 13:36:49 +01:00
parent df605b13fb
commit 5ed81f0a2a
5 changed files with 34 additions and 9 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
name: MobArena name: MobArena
author: garbagemule author: garbagemule
main: com.garbagemule.MobArena.MobArena main: com.garbagemule.MobArena.MobArena
version: 0.94.4.82 version: 0.94.4.90
softdepend: [Spout,MultiVerse,MultiWorld,XcraftGate,Towny,Heroes,MagicSpells,Vault] softdepend: [Spout,MultiVerse,MultiWorld,XcraftGate,Towny,Heroes,MagicSpells,Vault]
commands: commands:
ma: ma:
+5 -2
View File
@@ -20,12 +20,13 @@ public class ArenaClass
private List<ItemStack> items, armor; private List<ItemStack> items, armor;
private Map<String,Boolean> perms; private Map<String,Boolean> perms;
private int pets; private int pets;
private boolean unbreakableWeapons;
/** /**
* Create a new, empty arena class with the given name. * Create a new, empty arena class with the given name.
* @param name the class name as it appears in the config-file * @param name the class name as it appears in the config-file
*/ */
public ArenaClass(String name) { public ArenaClass(String name, boolean unbreakableWeapons) {
this.configName = name; this.configName = name;
this.lowercaseName = name.toLowerCase(); this.lowercaseName = name.toLowerCase();
@@ -33,6 +34,8 @@ public class ArenaClass
this.armor = new ArrayList<ItemStack>(4); this.armor = new ArrayList<ItemStack>(4);
this.perms = new HashMap<String,Boolean>(); this.perms = new HashMap<String,Boolean>();
this.pets = 0; this.pets = 0;
this.unbreakableWeapons = unbreakableWeapons;
} }
/** /**
@@ -104,7 +107,7 @@ public class ArenaClass
public void addItem(ItemStack stack) { public void addItem(ItemStack stack) {
if (stack == null) return; if (stack == null) return;
if (isWeapon(stack)) { if (unbreakableWeapons && isWeapon(stack)) {
stack.setDurability(Short.MIN_VALUE); stack.setDurability(Short.MIN_VALUE);
} }
else if (stack.getType() == Material.BONE) { else if (stack.getType() == Material.BONE) {
+11 -3
View File
@@ -760,6 +760,13 @@ public class ArenaImpl implements Arena
// Schedule it for the initial first wave delay. // Schedule it for the initial first wave delay.
scheduleTask(spawnThread, settings.getInt("first-wave-delay", 5) * 20); scheduleTask(spawnThread, settings.getInt("first-wave-delay", 5) * 20);
// Schedule to enable PvP if pvp-enabled: true
scheduleTask(new Runnable() {
public void run() {
eventListener.pvpActivate();
}
}, settings.getInt("first-wave-delay", 5) * 20);
} }
/** /**
@@ -778,6 +785,7 @@ public class ArenaImpl implements Arena
private void stopSpawner() { private void stopSpawner() {
world.setSpawnFlags(allowMonsters, allowAnimals); world.setSpawnFlags(allowMonsters, allowAnimals);
eventListener.pvpDeactivate();
//world.setDifficulty(spawnMonsters); //world.setDifficulty(spawnMonsters);
} }
@@ -856,7 +864,7 @@ public class ArenaImpl implements Arena
@Override @Override
public void movePlayerToLobby(Player p) public void movePlayerToLobby(Player p)
{ {
updateChunk(region.getLobbyWarp()); //updateChunk(region.getLobbyWarp());
specPlayers.remove(p); // If joining from spec area specPlayers.remove(p); // If joining from spec area
lobbyPlayers.add(p); lobbyPlayers.add(p);
p.teleport(region.getLobbyWarp()); p.teleport(region.getLobbyWarp());
@@ -867,7 +875,7 @@ public class ArenaImpl implements Arena
@Override @Override
public void movePlayerToSpec(Player p) public void movePlayerToSpec(Player p)
{ {
updateChunk(region.getSpecWarp()); //updateChunk(region.getSpecWarp());
specPlayers.add(p); specPlayers.add(p);
p.teleport(region.getSpecWarp()); p.teleport(region.getSpecWarp());
timeStrategy.setPlayerTime(p); timeStrategy.setPlayerTime(p);
@@ -880,7 +888,7 @@ public class ArenaImpl implements Arena
Location entry = playerData.get(p).entry(); Location entry = playerData.get(p).entry();
if (entry == null || p.isDead()) return; if (entry == null || p.isDead()) return;
updateChunk(entry); //updateChunk(entry);
p.teleport(entry); p.teleport(entry);
timeStrategy.resetPlayerTime(p); timeStrategy.resetPlayerTime(p);
//movePlayerToLocation(p, entry); //movePlayerToLocation(p, entry);
@@ -95,7 +95,8 @@ public class ArenaListener
protect; protect;
private boolean monsterExp, private boolean monsterExp,
monsterInfight, monsterInfight,
pvpEnabled, pvpOn, // pvp-enabled in config
pvpEnabled = false, // activated on first wave
foodRegen, foodRegen,
lockFoodLevel; lockFoodLevel;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@@ -124,7 +125,7 @@ public class ArenaListener
this.protect = s.getBoolean("protect", true); this.protect = s.getBoolean("protect", true);
this.monsterExp = s.getBoolean("monster-exp", false); this.monsterExp = s.getBoolean("monster-exp", false);
this.monsterInfight = s.getBoolean("monster-infight", false); this.monsterInfight = s.getBoolean("monster-infight", false);
this.pvpEnabled = s.getBoolean("pvp-enabled", false); this.pvpOn = s.getBoolean("pvp-enabled", false);
this.foodRegen = s.getBoolean("food-regen", false); this.foodRegen = s.getBoolean("food-regen", false);
this.lockFoodLevel = s.getBoolean("lock-food-level", true); this.lockFoodLevel = s.getBoolean("lock-food-level", true);
this.allowTeleport = s.getBoolean("allow-teleporting", false); this.allowTeleport = s.getBoolean("allow-teleporting", false);
@@ -137,6 +138,16 @@ public class ArenaListener
this.banned = new HashSet<Player>(); this.banned = new HashSet<Player>();
} }
void pvpActivate() {
if (arena.isRunning() && !arena.getPlayersInArena().isEmpty()) {
pvpEnabled = pvpOn;
}
}
void pvpDeactivate() {
if (pvpOn) pvpEnabled = false;
}
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
// Check if the block is a sign, it might be a leaderboard // Check if the block is a sign, it might be a leaderboard
@@ -309,9 +309,12 @@ public class ArenaMasterImpl implements ArenaMaster
Messenger.severe("Failed to load class '" + classname + "'."); Messenger.severe("Failed to load class '" + classname + "'.");
return null; return null;
} }
// Check if weapons for this class should be unbreakable
boolean unbreakableWeapons = section.getBoolean("unbreakable-weapons", true);
// Create an ArenaClass with the config-file name. // Create an ArenaClass with the config-file name.
ArenaClass arenaClass = new ArenaClass(classname); ArenaClass arenaClass = new ArenaClass(classname, unbreakableWeapons);
// Parse the items-node // Parse the items-node
String items = section.getString("items", ""); String items = section.getString("items", "");