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
author: garbagemule
main: com.garbagemule.MobArena.MobArena
version: 0.94.4.82
version: 0.94.4.90
softdepend: [Spout,MultiVerse,MultiWorld,XcraftGate,Towny,Heroes,MagicSpells,Vault]
commands:
ma:
+5 -2
View File
@@ -20,12 +20,13 @@ public class ArenaClass
private List<ItemStack> items, armor;
private Map<String,Boolean> perms;
private int pets;
private boolean unbreakableWeapons;
/**
* Create a new, empty arena class with the given name.
* @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.lowercaseName = name.toLowerCase();
@@ -33,6 +34,8 @@ public class ArenaClass
this.armor = new ArrayList<ItemStack>(4);
this.perms = new HashMap<String,Boolean>();
this.pets = 0;
this.unbreakableWeapons = unbreakableWeapons;
}
/**
@@ -104,7 +107,7 @@ public class ArenaClass
public void addItem(ItemStack stack) {
if (stack == null) return;
if (isWeapon(stack)) {
if (unbreakableWeapons && isWeapon(stack)) {
stack.setDurability(Short.MIN_VALUE);
}
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.
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() {
world.setSpawnFlags(allowMonsters, allowAnimals);
eventListener.pvpDeactivate();
//world.setDifficulty(spawnMonsters);
}
@@ -856,7 +864,7 @@ public class ArenaImpl implements Arena
@Override
public void movePlayerToLobby(Player p)
{
updateChunk(region.getLobbyWarp());
//updateChunk(region.getLobbyWarp());
specPlayers.remove(p); // If joining from spec area
lobbyPlayers.add(p);
p.teleport(region.getLobbyWarp());
@@ -867,7 +875,7 @@ public class ArenaImpl implements Arena
@Override
public void movePlayerToSpec(Player p)
{
updateChunk(region.getSpecWarp());
//updateChunk(region.getSpecWarp());
specPlayers.add(p);
p.teleport(region.getSpecWarp());
timeStrategy.setPlayerTime(p);
@@ -880,7 +888,7 @@ public class ArenaImpl implements Arena
Location entry = playerData.get(p).entry();
if (entry == null || p.isDead()) return;
updateChunk(entry);
//updateChunk(entry);
p.teleport(entry);
timeStrategy.resetPlayerTime(p);
//movePlayerToLocation(p, entry);
@@ -95,7 +95,8 @@ public class ArenaListener
protect;
private boolean monsterExp,
monsterInfight,
pvpEnabled,
pvpOn, // pvp-enabled in config
pvpEnabled = false, // activated on first wave
foodRegen,
lockFoodLevel;
@SuppressWarnings("unused")
@@ -124,7 +125,7 @@ public class ArenaListener
this.protect = s.getBoolean("protect", true);
this.monsterExp = s.getBoolean("monster-exp", 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.lockFoodLevel = s.getBoolean("lock-food-level", true);
this.allowTeleport = s.getBoolean("allow-teleporting", false);
@@ -137,6 +138,16 @@ public class ArenaListener
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) {
// 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 + "'.");
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.
ArenaClass arenaClass = new ArenaClass(classname);
ArenaClass arenaClass = new ArenaClass(classname, unbreakableWeapons);
// Parse the items-node
String items = section.getString("items", "");