mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-27 04:55:25 +01:00
0.94.4.66 - bug fixes, works for 1.2.5-R1.3
This commit is contained in:
parent
9ada0cd100
commit
708ed2821d
@ -101,6 +101,12 @@ public class ArenaClass
|
||||
else if (stack.getType() == Material.BONE) {
|
||||
pets += stack.getAmount();
|
||||
}
|
||||
else if (stack.getAmount() > 64) {
|
||||
while (stack.getAmount() > 64) {
|
||||
items.add(new ItemStack(stack.getType(), 64));
|
||||
stack.setAmount(stack.getAmount() - 64);
|
||||
}
|
||||
}
|
||||
|
||||
items.add(stack);
|
||||
}
|
||||
@ -229,7 +235,7 @@ public class ArenaClass
|
||||
/**
|
||||
* Used by isWeapon() to determine if an ItemStack is a weapon type.
|
||||
*/
|
||||
private static int[] weaponTypes = new int[]{256,257,258,267,268,269,270,271,272,273,274,275,276,277,278,279,283,284,285,286,290,291,292,293,294};
|
||||
private static int[] weaponTypes = new int[]{256,257,258,261,267,268,269,270,271,272,273,274,275,276,277,278,279,283,284,285,286,290,291,292,293,294};
|
||||
|
||||
/**
|
||||
* Returns true, if the ItemStack appears to be a weapon, in which case
|
||||
|
@ -100,6 +100,7 @@ public class ArenaImpl implements Arena
|
||||
private Map<Integer,List<ItemStack>> everyWaveMap, afterWaveMap;
|
||||
|
||||
// Logging
|
||||
private boolean logging;
|
||||
private ArenaLog log;
|
||||
private LogSessionBuilder sessionBuilder;
|
||||
private LogTotalsBuilder totalsBuilder;
|
||||
@ -124,6 +125,7 @@ public class ArenaImpl implements Arena
|
||||
|
||||
this.enabled = settings.getBoolean("enabled", false);
|
||||
this.protect = settings.getBoolean("protect", true);
|
||||
this.logging = settings.getBoolean("logging", true);
|
||||
this.running = false;
|
||||
this.edit = false;
|
||||
|
||||
@ -170,11 +172,13 @@ public class ArenaImpl implements Arena
|
||||
Time time = Enums.getEnumFromString(Time.class, timeString);
|
||||
this.timeStrategy = (time != null ? new TimeStrategyLocked(time) : new TimeStrategyNull());
|
||||
|
||||
this.dir = new File(plugin.getDataFolder() + File.separator + "arenas" + File.separator + name);
|
||||
this.sessionBuilder = new YMLSessionBuilder(new File(dir, "log_session.yml"));
|
||||
this.totalsBuilder = new YMLTotalsBuilder(new File(dir, "log_totals.yml"));
|
||||
|
||||
this.log = new ArenaLog(this, sessionBuilder, totalsBuilder);
|
||||
if(isLogging()) {
|
||||
this.dir = new File(plugin.getDataFolder() + File.separator + "arenas" + File.separator + name);
|
||||
this.sessionBuilder = new YMLSessionBuilder(new File(dir, "log_session.yml"));
|
||||
this.totalsBuilder = new YMLTotalsBuilder(new File(dir, "log_totals.yml"));
|
||||
|
||||
this.log = new ArenaLog(this, sessionBuilder, totalsBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -219,6 +223,18 @@ public class ArenaImpl implements Arena
|
||||
@Override
|
||||
public void setProtected(boolean value) {
|
||||
protect = value;
|
||||
settings.set("protect", protect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogging() {
|
||||
return logging;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogging(boolean value) {
|
||||
logging = value;
|
||||
settings.set("logging", logging);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -436,7 +452,8 @@ public class ArenaImpl implements Arena
|
||||
|
||||
// Start logging
|
||||
rewardManager.reset();
|
||||
log.start();
|
||||
if(isLogging())
|
||||
log.start();
|
||||
|
||||
// Initialize leaderboards and start displaying info.
|
||||
leaderboard.initialize();
|
||||
@ -471,7 +488,8 @@ public class ArenaImpl implements Arena
|
||||
leaderboard.update();
|
||||
|
||||
// Finish logging
|
||||
log.end();
|
||||
if(isLogging())
|
||||
log.end();
|
||||
|
||||
// Stop spawning.
|
||||
stopSpawner();
|
||||
|
@ -24,6 +24,7 @@ import com.garbagemule.MobArena.ArenaClass.ArmorType;
|
||||
import com.garbagemule.MobArena.framework.Arena;
|
||||
import com.garbagemule.MobArena.framework.ArenaMaster;
|
||||
import com.garbagemule.MobArena.util.ItemParser;
|
||||
import com.garbagemule.MobArena.util.TextUtils;
|
||||
import com.garbagemule.MobArena.util.config.Config;
|
||||
import com.garbagemule.MobArena.util.config.ConfigSection;
|
||||
import com.garbagemule.MobArena.util.config.ConfigUtils;
|
||||
@ -424,6 +425,7 @@ public class ArenaMasterImpl implements ArenaMaster
|
||||
}
|
||||
|
||||
private boolean addRemoveClassPermission(String classname, String perm, boolean add) {
|
||||
classname = TextUtils.camelCase(classname);
|
||||
String path = "classes." + classname;
|
||||
if (config.getConfigSection(path) == null)
|
||||
return false;
|
||||
@ -433,6 +435,18 @@ public class ArenaMasterImpl implements ArenaMaster
|
||||
|
||||
// Get any previous nodes
|
||||
List<String> nodes = section.getStringList("permissions", null);
|
||||
|
||||
if (nodes.contains(perm) && add)
|
||||
return false;
|
||||
else if (nodes.contains(perm) && !add)
|
||||
nodes.remove(perm);
|
||||
else if (!nodes.contains(perm) && add)
|
||||
nodes.add(perm);
|
||||
else if (!nodes.contains(perm) && !add)
|
||||
return false;
|
||||
|
||||
/* erroneous logic - if it contains the perm when trying to remove, it won't remove it.
|
||||
* it would return false early.
|
||||
if (nodes.contains(perm))
|
||||
return false;
|
||||
|
||||
@ -444,6 +458,7 @@ public class ArenaMasterImpl implements ArenaMaster
|
||||
else {
|
||||
nodes.remove(perm);
|
||||
}
|
||||
*/
|
||||
|
||||
// Replace the set.
|
||||
section.set("permissions", nodes);
|
||||
|
@ -185,6 +185,7 @@ public class CommandHandler implements CommandExecutor
|
||||
register(RemoveClassCommand.class);
|
||||
register(RemoveClassPermCommand.class);
|
||||
register(RemoveContainerCommand.class);
|
||||
register(RemoveLeaderboardCommand.class);
|
||||
register(RemoveSpawnpointCommand.class);
|
||||
register(SetArenaCommand.class);
|
||||
register(SetClassCommand.class);
|
||||
|
@ -10,7 +10,7 @@ import com.garbagemule.MobArena.framework.ArenaMaster;
|
||||
|
||||
@CommandInfo(
|
||||
name = "listclasses",
|
||||
pattern = "(list)?class(.)*",
|
||||
pattern = "(list)?classes(.)*",
|
||||
usage = "/ma listclasses",
|
||||
desc = "list all current classes",
|
||||
permission = "mobarena.setup.classes"
|
||||
|
@ -0,0 +1,47 @@
|
||||
package com.garbagemule.MobArena.commands.setup;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.garbagemule.MobArena.Messenger;
|
||||
import com.garbagemule.MobArena.commands.Command;
|
||||
import com.garbagemule.MobArena.commands.CommandInfo;
|
||||
import com.garbagemule.MobArena.framework.ArenaMaster;
|
||||
|
||||
@CommandInfo(
|
||||
name = "removeleaderboard",
|
||||
pattern = "(del(.)*|r(e)?m(ove)?)leaderboard",
|
||||
usage = "/ma removeleaderboard <arenaname>",
|
||||
desc = "remove the selected arena's leaderboard",
|
||||
permission = "mobarena.setup.leaderboards"
|
||||
)
|
||||
public class RemoveLeaderboardCommand implements Command{
|
||||
|
||||
@Override
|
||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||
// Grab the argument, if any.
|
||||
String arg1 = (args.length > 0 ? args[0] : "");
|
||||
|
||||
// If no argument, use the currently selected arena
|
||||
if (arg1.equals("")) {
|
||||
if(am.getSelectedArena().getRegion().getLeaderboard() != null) {
|
||||
am.getSelectedArena().getRegion().set("leaderboard", null);
|
||||
Messenger.tellPlayer(sender, "Leaderboard for " + am.getSelectedArena().arenaName() + " successfully removed!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(am.getArenaWithName(arg1) != null) {
|
||||
am.getArenaWithName(arg1).getRegion().set("leaderboard", null);
|
||||
Messenger.tellPlayer(sender, "Leaderboard for " + am.getSelectedArena().arenaName() + " successfully removed!");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
Messenger.tellPlayer(sender, "Usage: /ma removeleaderboard <arenaname>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -48,6 +48,10 @@ public interface Arena
|
||||
|
||||
public void setProtected(boolean value);
|
||||
|
||||
public boolean isLogging();
|
||||
|
||||
public void setLogging(boolean value);
|
||||
|
||||
public boolean isRunning();
|
||||
|
||||
public boolean inEditMode();
|
||||
|
@ -16,9 +16,9 @@ import com.garbagemule.MobArena.util.config.Config;
|
||||
|
||||
public class YMLSessionBuilder implements LogSessionBuilder
|
||||
{
|
||||
private final String GENERAL = "general-info.";
|
||||
private final String PLAYERS = "players.";
|
||||
private final String CLASSES = "class-distribution.";
|
||||
private final String GENERAL = "general-info";
|
||||
private final String PLAYERS = "players";
|
||||
private final String CLASSES = "class-distribution";
|
||||
|
||||
private Config config;
|
||||
private long start, end;
|
||||
@ -31,42 +31,42 @@ public class YMLSessionBuilder implements LogSessionBuilder
|
||||
@Override
|
||||
public void buildStartTime() {
|
||||
start = new Date().getTime();
|
||||
config.set(GENERAL + "start-time", TimeUtils.toDateTime(start));
|
||||
config.set(GENERAL + ".start-time", TimeUtils.toDateTime(start));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildEndTime() {
|
||||
end = new Date().getTime();
|
||||
config.set(GENERAL + "end-time", TimeUtils.toDateTime(end));
|
||||
config.set(GENERAL + ".end-time", TimeUtils.toDateTime(end));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildDuration() {
|
||||
String duration = TimeUtils.toTime(end - start);
|
||||
config.set(GENERAL + "duration", duration);
|
||||
config.set(GENERAL + ".duration", duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildLastWave(int lastWave) {
|
||||
config.set(GENERAL + "last-wave", lastWave);
|
||||
config.set(GENERAL + ".last-wave", lastWave);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildNumberOfPlayers(int amount) {
|
||||
config.set(GENERAL + "number-of-players", amount);
|
||||
config.set(GENERAL + ".number-of-players", amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildClassDistribution(Map<String,MutableInt> classDistribution) {
|
||||
for (Entry<String,MutableInt> entry : classDistribution.entrySet()) {
|
||||
int amount = entry.getValue().value();
|
||||
config.set(CLASSES + entry.getKey(), amount);
|
||||
config.set(CLASSES + "." + entry.getKey(), amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildPlayerEntry(ArenaLogPlayerEntry entry, List<ItemStack> rewards) {
|
||||
String path = PLAYERS + entry.playername + ".";
|
||||
String path = PLAYERS + "." + entry.playername + ".";
|
||||
|
||||
// Name and class
|
||||
config.set(path + "name", entry.playername);
|
||||
@ -106,8 +106,11 @@ public class YMLSessionBuilder implements LogSessionBuilder
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
config.set(GENERAL, null);
|
||||
config.set(CLASSES, null);
|
||||
config.set(PLAYERS, null);
|
||||
if(config.get(GENERAL) != null)
|
||||
config.set(GENERAL, null);
|
||||
if(config.get(CLASSES) != null)
|
||||
config.set(CLASSES, null);
|
||||
if(config.get(PLAYERS) != null)
|
||||
config.set(PLAYERS, null);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -193,7 +194,7 @@ public class ArenaRegion
|
||||
|
||||
// Region expand
|
||||
public void expandUp(int amount) {
|
||||
p2.setY(Math.min(127D, p2.getY() + amount));
|
||||
p2.setY(Math.min(arena.getWorld().getMaxHeight(), p2.getY() + amount));
|
||||
set(RegionPoint.P2, p2);
|
||||
}
|
||||
|
||||
@ -221,7 +222,7 @@ public class ArenaRegion
|
||||
|
||||
// Lobby expand
|
||||
public void expandLobbyUp(int amount) {
|
||||
l2.setY(Math.min(127D, l2.getY() + amount));
|
||||
l2.setY(Math.min(arena.getWorld().getMaxHeight(), l2.getY() + amount));
|
||||
set(RegionPoint.L2, l2);
|
||||
}
|
||||
|
||||
|
@ -57,12 +57,12 @@ public class ItemParser
|
||||
int lvl = entry.getValue();
|
||||
|
||||
// <eid>:<level>;
|
||||
enchantments += "; " + id + ":" + lvl;
|
||||
enchantments += ";" + id + ":" + lvl;
|
||||
}
|
||||
|
||||
// Trim off the leading ';' if it is there
|
||||
if (!enchantments.equals("")) {
|
||||
enchantments = enchantments.substring(2);
|
||||
enchantments = enchantments.substring(1);
|
||||
}
|
||||
|
||||
// <item>
|
||||
|
@ -250,9 +250,9 @@ public class WaveParser
|
||||
}
|
||||
}
|
||||
|
||||
// As well as the ability interval.
|
||||
int interval = config.getInt("ability-interval", 3) * 20;
|
||||
result.setAbilityInterval(interval);
|
||||
// As well as the ability interval and ability announce.
|
||||
result.setAbilityInterval(config.getInt("ability-interval", 3) * 20);
|
||||
result.setAbilityAnnounce(config.getBoolean("ability-announce", true));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class BossWave extends AbstractWave
|
||||
private BossHealth health;
|
||||
|
||||
private List<Ability> abilities;
|
||||
private boolean activated;
|
||||
private boolean activated, abilityAnnounce;
|
||||
|
||||
private int abilityInterval;
|
||||
|
||||
@ -34,6 +34,7 @@ public class BossWave extends AbstractWave
|
||||
this.bosses = new HashSet<MABoss>();
|
||||
this.abilities = new ArrayList<Ability>();
|
||||
this.activated = false;
|
||||
this.abilityAnnounce = false;
|
||||
this.setType(WaveType.BOSS);
|
||||
}
|
||||
|
||||
@ -78,6 +79,14 @@ public class BossWave extends AbstractWave
|
||||
this.abilityInterval = abilityInterval;
|
||||
}
|
||||
|
||||
public boolean getAbilityAnnounce() {
|
||||
return abilityAnnounce;
|
||||
}
|
||||
|
||||
public void setAbilityAnnounce(boolean abilityAnnounce) {
|
||||
this.abilityAnnounce = abilityAnnounce;
|
||||
}
|
||||
|
||||
public void activateAbilities(Arena arena) {
|
||||
if (activated) {
|
||||
return;
|
||||
@ -89,7 +98,9 @@ public class BossWave extends AbstractWave
|
||||
}
|
||||
|
||||
public void announceAbility(Ability ability, MABoss boss, Arena arena) {
|
||||
AbilityInfo info = ability.getClass().getAnnotation(AbilityInfo.class);
|
||||
Messenger.tellAll(arena, Msg.WAVE_BOSS_ABILITY, info.name());
|
||||
if(getAbilityAnnounce()) {
|
||||
AbilityInfo info = ability.getClass().getAnnotation(AbilityInfo.class);
|
||||
Messenger.tellAll(arena, Msg.WAVE_BOSS_ABILITY, info.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user