Strip trailing whitespace; add missing newlines.
This promiscuous commit goes around touching almost every file in the repository with the intention of removing trailing whitespace and adding newlines to files missing them. Trailing whitespace has been a pain for along time, especially in terms of contributing to the project without accidentally littering commits with whitespace stripping, so this commit is long overdue. As for the newlines, well, the script I found on StackOverflow to strip trailing whitespace also happened to add missing newlines, which is something I wanted to tackle anyway, but in a different commit. It's all good though.
This commit is contained in:
parent
043d970593
commit
514c03dad0
|
@ -33,7 +33,7 @@ public class ArenaClass
|
|||
public ArenaClass(String name, Thing price, boolean unbreakableWeapons, boolean unbreakableArmor) {
|
||||
this.configName = name;
|
||||
this.lowercaseName = name.toLowerCase().replace(" ", "");
|
||||
|
||||
|
||||
this.items = new ArrayList<>();
|
||||
this.armor = new ArrayList<>(4);
|
||||
this.effects = new ArrayList<>();
|
||||
|
@ -45,7 +45,7 @@ public class ArenaClass
|
|||
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the name of the arena class as it appears in the config-file.
|
||||
* @return the class name as it appears in the config-file
|
||||
|
@ -53,7 +53,7 @@ public class ArenaClass
|
|||
public String getConfigName() {
|
||||
return configName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the lowercase class name.
|
||||
* @return the lowercase class name
|
||||
|
@ -61,7 +61,7 @@ public class ArenaClass
|
|||
public String getLowercaseName() {
|
||||
return lowercaseName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the helmet slot for the class.
|
||||
* @param helmet a Thing
|
||||
|
@ -69,7 +69,7 @@ public class ArenaClass
|
|||
public void setHelmet(Thing helmet) {
|
||||
this.helmet = helmet;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the chestplate slot for the class.
|
||||
* @param chestplate a Thing
|
||||
|
@ -77,7 +77,7 @@ public class ArenaClass
|
|||
public void setChestplate(Thing chestplate) {
|
||||
this.chestplate = chestplate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the leggings slot for the class.
|
||||
* @param leggings a Thing
|
||||
|
@ -85,7 +85,7 @@ public class ArenaClass
|
|||
public void setLeggings(Thing leggings) {
|
||||
this.leggings = leggings;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the boots slot for the class.
|
||||
* @param boots a Thing
|
||||
|
@ -93,7 +93,7 @@ public class ArenaClass
|
|||
public void setBoots(Thing boots) {
|
||||
this.boots = boots;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the off-hand slot for the class.
|
||||
* @param offhand a Thing
|
||||
|
@ -111,7 +111,7 @@ public class ArenaClass
|
|||
items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace the current items list with a new list of all the items in the given list.
|
||||
* This method uses the addItem() method for each item to ensure consistency.
|
||||
|
@ -121,7 +121,7 @@ public class ArenaClass
|
|||
this.items = new ArrayList<>(items.size());
|
||||
items.forEach(this::addItem);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace the current armor list with the given list.
|
||||
* @param armor a list of Things
|
||||
|
@ -133,7 +133,7 @@ public class ArenaClass
|
|||
public void setEffects(List<Thing> effects) {
|
||||
this.effects = effects;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPermission(Player p) {
|
||||
String perm = "mobarena.classes." + configName;
|
||||
return !p.isPermissionSet(perm) || p.hasPermission(perm);
|
||||
|
@ -144,7 +144,7 @@ public class ArenaClass
|
|||
* The normal items will be added to the inventory normally, while the
|
||||
* armor items will be verified as armor items and placed in their
|
||||
* appropriate slots. If any specific armor slots are specified, they
|
||||
* will overwrite any items in the armor list.
|
||||
* will overwrite any items in the armor list.
|
||||
* @param p a player
|
||||
*/
|
||||
public void grantItems(Player p) {
|
||||
|
@ -152,7 +152,7 @@ public class ArenaClass
|
|||
|
||||
// Fork over the items.
|
||||
items.forEach(item -> item.giveTo(p));
|
||||
|
||||
|
||||
// Check for legacy armor-node items
|
||||
armor.forEach(thing -> thing.giveTo(p));
|
||||
|
||||
|
@ -167,7 +167,7 @@ public class ArenaClass
|
|||
public void grantPotionEffects(Player p) {
|
||||
effects.forEach(thing -> thing.giveTo(p));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a permission value to the class.
|
||||
*/
|
||||
|
@ -212,17 +212,17 @@ public class ArenaClass
|
|||
public Thing getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null) return false;
|
||||
if (this == o) return true;
|
||||
if (!this.getClass().equals(o.getClass())) return false;
|
||||
|
||||
|
||||
ArenaClass other = (ArenaClass) o;
|
||||
return other.lowercaseName.equals(this.lowercaseName);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return lowercaseName.hashCode();
|
||||
|
|
|
@ -75,57 +75,57 @@ public class ArenaImpl implements Arena
|
|||
private String name;
|
||||
private World world;
|
||||
private Messenger messenger;
|
||||
|
||||
|
||||
// Settings section of the config-file for this arena.
|
||||
private ConfigurationSection settings;
|
||||
|
||||
|
||||
// Run-time settings and critical config settings
|
||||
private boolean enabled, protect, running, edit;
|
||||
|
||||
|
||||
// World stuff
|
||||
private boolean allowMonsters, allowAnimals;
|
||||
//private Difficulty spawnMonsters;
|
||||
|
||||
|
||||
// Warps, points and locations
|
||||
private ArenaRegion region;
|
||||
private Leaderboard leaderboard;
|
||||
|
||||
|
||||
// Player stuff
|
||||
private InventoryManager inventoryManager;
|
||||
private RewardManager rewardManager;
|
||||
private ClassLimitManager limitManager;
|
||||
private Map<Player,ArenaPlayer> arenaPlayerMap;
|
||||
|
||||
|
||||
private Set<Player> arenaPlayers, lobbyPlayers, readyPlayers, specPlayers, deadPlayers;
|
||||
private Set<Player> movingPlayers;
|
||||
private Set<Player> leavingPlayers;
|
||||
private Set<Player> randoms;
|
||||
|
||||
|
||||
// Classes stuff
|
||||
private ArenaClass defaultClass;
|
||||
private Map<String,ArenaClass> classes;
|
||||
|
||||
|
||||
// Blocks and pets
|
||||
private PriorityBlockingQueue<Repairable> repairQueue;
|
||||
private Set<Block> blocks;
|
||||
private LinkedList<Repairable> repairables, containables;
|
||||
|
||||
|
||||
// Monster stuff
|
||||
private MonsterManager monsterManager;
|
||||
|
||||
|
||||
// Wave stuff
|
||||
private WaveManager waveManager;
|
||||
private MASpawnThread spawnThread;
|
||||
private SheepBouncer sheepBouncer;
|
||||
private Map<Integer,List<Thing>> everyWaveMap, afterWaveMap;
|
||||
|
||||
|
||||
// Misc
|
||||
private ArenaListener eventListener;
|
||||
private List<Thing> entryFee;
|
||||
private AutoStartTimer autoStartTimer;
|
||||
private StartDelayTimer startDelayTimer;
|
||||
private boolean isolatedChat;
|
||||
|
||||
|
||||
// Warp offsets
|
||||
private double arenaWarpOffset;
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class ArenaImpl implements Arena
|
|||
|
||||
// Last player standing
|
||||
private Player lastStanding;
|
||||
|
||||
|
||||
// Actions
|
||||
private Map<Player, Step> histories;
|
||||
private StepFactory playerJoinArena;
|
||||
|
@ -148,13 +148,13 @@ public class ArenaImpl implements Arena
|
|||
public ArenaImpl(MobArena plugin, ConfigurationSection section, String name, World world) {
|
||||
if (world == null)
|
||||
throw new NullPointerException("[MobArena] ERROR! World for arena '" + name + "' does not exist!");
|
||||
|
||||
|
||||
this.name = name;
|
||||
this.world = world;
|
||||
this.plugin = plugin;
|
||||
this.settings = makeSection(section, "settings");
|
||||
this.region = new ArenaRegion(section, this);
|
||||
|
||||
|
||||
this.enabled = settings.getBoolean("enabled", false);
|
||||
this.protect = settings.getBoolean("protect", true);
|
||||
this.running = false;
|
||||
|
@ -185,21 +185,21 @@ public class ArenaImpl implements Arena
|
|||
if (defaultClassName != null) {
|
||||
this.defaultClass = classes.get(defaultClassName);
|
||||
}
|
||||
|
||||
|
||||
// Blocks and pets
|
||||
this.repairQueue = new PriorityBlockingQueue<>(100, new RepairableComparator());
|
||||
this.blocks = new HashSet<>();
|
||||
this.repairables = new LinkedList<>();
|
||||
this.containables = new LinkedList<>();
|
||||
|
||||
|
||||
// Monster stuff
|
||||
this.monsterManager = new MonsterManager();
|
||||
|
||||
|
||||
// Wave stuff
|
||||
this.waveManager = new WaveManager(this, section.getConfigurationSection("waves"));
|
||||
this.everyWaveMap = MAUtils.getArenaRewardMap(plugin, section, name, "every");
|
||||
this.afterWaveMap = MAUtils.getArenaRewardMap(plugin, section, name, "after");
|
||||
|
||||
|
||||
// Misc
|
||||
this.eventListener = new ArenaListener(this, plugin);
|
||||
this.allowMonsters = world.getAllowMonsters();
|
||||
|
@ -222,7 +222,7 @@ public class ArenaImpl implements Arena
|
|||
this.startDelayTimer = new StartDelayTimer(this, autoStartTimer);
|
||||
|
||||
this.isolatedChat = settings.getBoolean("isolated-chat", false);
|
||||
|
||||
|
||||
this.arenaWarpOffset = settings.getDouble("arena-warp-offset", 0.0);
|
||||
|
||||
// Scoreboards
|
||||
|
@ -239,15 +239,15 @@ public class ArenaImpl implements Arena
|
|||
|
||||
this.spawnsPets = plugin.getArenaMaster().getSpawnsPets();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NEW METHODS IN REFACTORING
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
@Override
|
||||
public ConfigurationSection getSettings() {
|
||||
return settings;
|
||||
|
@ -312,7 +312,7 @@ public class ArenaImpl implements Arena
|
|||
public int getMaxPlayers() {
|
||||
return settings.getInt("max-players");
|
||||
}
|
||||
|
||||
|
||||
private int getJoinDistance() {
|
||||
return settings.getInt("max-join-distance");
|
||||
}
|
||||
|
@ -421,25 +421,25 @@ public class ArenaImpl implements Arena
|
|||
public MonsterManager getMonsterManager() {
|
||||
return monsterManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ClassLimitManager getClassLimitManager() {
|
||||
return limitManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ScoreboardManager getScoreboard() {
|
||||
return scoreboard;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Messenger getMessenger() {
|
||||
|
@ -492,26 +492,26 @@ public class ArenaImpl implements Arena
|
|||
|
||||
// Store all chest contents.
|
||||
storeContainerContents();
|
||||
|
||||
|
||||
// Populate arenaPlayers and clear the lobby.
|
||||
arenaPlayers.addAll(lobbyPlayers);
|
||||
lobbyPlayers.clear();
|
||||
readyPlayers.clear();
|
||||
|
||||
|
||||
// Assign random classes.
|
||||
for (Player p : randoms) {
|
||||
assignRandomClass(p);
|
||||
}
|
||||
randoms.clear();
|
||||
|
||||
|
||||
// Then check if there are still players left.
|
||||
if (arenaPlayers.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Initialize scoreboards
|
||||
scoreboard.initialize();
|
||||
|
||||
|
||||
// Teleport players, give full health, initialize map
|
||||
for (Player p : arenaPlayers) {
|
||||
// Remove player from spec list to avoid invincibility issues
|
||||
|
@ -520,7 +520,7 @@ public class ArenaImpl implements Arena
|
|||
System.out.println("[MobArena] Player " + p.getName() + " joined the arena from the spec area!");
|
||||
System.out.println("[MobArena] Invincibility glitch attempt stopped!");
|
||||
}
|
||||
|
||||
|
||||
movingPlayers.add(p);
|
||||
if (arenaWarpOffset > 0.01) {
|
||||
Location warp = region.getArenaWarp();
|
||||
|
@ -541,35 +541,35 @@ public class ArenaImpl implements Arena
|
|||
if (price != null) {
|
||||
price.takeFrom(p);
|
||||
}
|
||||
|
||||
|
||||
scoreboard.addPlayer(p);
|
||||
}
|
||||
|
||||
|
||||
// Start spawning monsters (must happen before 'running = true;')
|
||||
startSpawner();
|
||||
startBouncingSheep();
|
||||
|
||||
|
||||
// Set the boolean.
|
||||
running = true;
|
||||
|
||||
|
||||
// Spawn pets (must happen after 'running = true;')
|
||||
spawnsPets.spawn(this);
|
||||
|
||||
|
||||
// Spawn mounts
|
||||
spawnMounts();
|
||||
|
||||
|
||||
// Clear the classes in use map, as they're no longer needed
|
||||
limitManager.clearClassesInUse();
|
||||
|
||||
|
||||
// Reset rewards
|
||||
rewardManager.reset();
|
||||
|
||||
|
||||
// Initialize leaderboards and start displaying info.
|
||||
leaderboard.initialize();
|
||||
leaderboard.startTracking();
|
||||
|
||||
|
||||
announce(Msg.ARENA_START);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -589,16 +589,16 @@ public class ArenaImpl implements Arena
|
|||
|
||||
// Reset last standing
|
||||
lastStanding = null;
|
||||
|
||||
|
||||
// Set the running boolean and disable arena if not disabled.
|
||||
boolean en = enabled;
|
||||
enabled = false;
|
||||
running = false;
|
||||
|
||||
|
||||
// Stop tracking leaderboards
|
||||
leaderboard.stopTracking();
|
||||
leaderboard.update();
|
||||
|
||||
|
||||
// Stop spawning.
|
||||
stopSpawner();
|
||||
stopBouncingSheep();
|
||||
|
@ -612,18 +612,18 @@ public class ArenaImpl implements Arena
|
|||
announce(Msg.ARENA_END);
|
||||
}
|
||||
cleanup();
|
||||
|
||||
|
||||
// Restore region.
|
||||
if (settings.getBoolean("soft-restore", false)) {
|
||||
restoreRegion();
|
||||
}
|
||||
|
||||
|
||||
// Restore chests
|
||||
restoreContainerContents();
|
||||
|
||||
|
||||
// Restore enabled status.
|
||||
enabled = en;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -632,12 +632,12 @@ public class ArenaImpl implements Arena
|
|||
{
|
||||
if (running)
|
||||
return;
|
||||
|
||||
|
||||
// Set operations.
|
||||
Set<Player> tmp = new HashSet<>();
|
||||
tmp.addAll(lobbyPlayers);
|
||||
tmp.removeAll(readyPlayers);
|
||||
|
||||
|
||||
// Force leave.
|
||||
for (Player p : tmp) {
|
||||
playerLeave(p);
|
||||
|
@ -655,7 +655,7 @@ public class ArenaImpl implements Arena
|
|||
if (players.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
players.forEach(this::playerLeave);
|
||||
cleanup();
|
||||
}
|
||||
|
@ -713,17 +713,17 @@ public class ArenaImpl implements Arena
|
|||
|
||||
lobbyPlayers.add(p);
|
||||
plugin.getArenaMaster().addPlayer(p, this);
|
||||
|
||||
|
||||
arenaPlayerMap.put(p, new ArenaPlayer(p, this, plugin));
|
||||
|
||||
// Start the start-delay-timer if applicable
|
||||
if (!autoStartTimer.isRunning()) {
|
||||
startDelayTimer.start();
|
||||
}
|
||||
|
||||
|
||||
// Notify player of joining
|
||||
messenger.tell(p, Msg.JOIN_PLAYER_JOINED);
|
||||
|
||||
|
||||
// Notify player of time left
|
||||
if (startDelayTimer.isRunning()) {
|
||||
messenger.tell(p, Msg.ARENA_START_DELAY, "" + startDelayTimer.getRemaining() / 20l);
|
||||
|
@ -738,7 +738,7 @@ public class ArenaImpl implements Arena
|
|||
messenger.tell(p, Msg.LOBBY_CLASS_PICKED, defaultClass.getConfigName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
movingPlayers.remove(p);
|
||||
return true;
|
||||
}
|
||||
|
@ -753,14 +753,14 @@ public class ArenaImpl implements Arena
|
|||
}
|
||||
|
||||
readyPlayers.add(p);
|
||||
|
||||
|
||||
int minPlayers = getMinPlayers();
|
||||
if (minPlayers > 0 && lobbyPlayers.size() < minPlayers)
|
||||
{
|
||||
messenger.tell(p, Msg.LOBBY_NOT_ENOUGH_PLAYERS, "" + minPlayers);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
startArena();
|
||||
}
|
||||
|
||||
|
@ -785,10 +785,10 @@ public class ArenaImpl implements Arena
|
|||
unmount(p);
|
||||
clearInv(p);
|
||||
}
|
||||
|
||||
|
||||
removePermissionAttachments(p);
|
||||
removePotionEffects(p);
|
||||
|
||||
|
||||
boolean refund = inLobby(p);
|
||||
|
||||
if (inLobby(p)) {
|
||||
|
@ -802,13 +802,13 @@ public class ArenaImpl implements Arena
|
|||
startDelayTimer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
discardPlayer(p);
|
||||
|
||||
if (refund) {
|
||||
refund(p);
|
||||
}
|
||||
|
||||
|
||||
endArena();
|
||||
|
||||
leavingPlayers.remove(p);
|
||||
|
@ -841,7 +841,7 @@ public class ArenaImpl implements Arena
|
|||
unmount(p);
|
||||
clearInv(p);
|
||||
}
|
||||
|
||||
|
||||
deadPlayers.add(p);
|
||||
endArena();
|
||||
}
|
||||
|
@ -874,7 +874,7 @@ public class ArenaImpl implements Arena
|
|||
public void revivePlayer(Player p) {
|
||||
removePermissionAttachments(p);
|
||||
removePotionEffects(p);
|
||||
|
||||
|
||||
specPlayers.add(p);
|
||||
|
||||
if (settings.getBoolean("spectate-on-death", true)) {
|
||||
|
@ -897,7 +897,7 @@ public class ArenaImpl implements Arena
|
|||
}
|
||||
movingPlayers.add(p);
|
||||
|
||||
|
||||
|
||||
rollback(p);
|
||||
|
||||
Step step = playerSpecArena.create(p);
|
||||
|
@ -911,7 +911,7 @@ public class ArenaImpl implements Arena
|
|||
|
||||
specPlayers.add(p);
|
||||
plugin.getArenaMaster().addPlayer(p, this);
|
||||
|
||||
|
||||
messenger.tell(p, Msg.SPEC_PLAYER_SPECTATE);
|
||||
movingPlayers.remove(p);
|
||||
}
|
||||
|
@ -1000,7 +1000,7 @@ public class ArenaImpl implements Arena
|
|||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void startSpawner() {
|
||||
if (spawnThread != null) {
|
||||
spawnThread.stop();
|
||||
|
@ -1012,7 +1012,7 @@ public class ArenaImpl implements Arena
|
|||
spawnThread = new MASpawnThread(plugin, this);
|
||||
spawnThread.start();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Schedule a Runnable to be executed after the given delay in
|
||||
* server ticks. The method is used by the MASpawnThread to
|
||||
|
@ -1023,7 +1023,7 @@ public class ArenaImpl implements Arena
|
|||
public void scheduleTask(Runnable r, int delay) {
|
||||
Bukkit.getScheduler().runTaskLater(plugin, r, delay);
|
||||
}
|
||||
|
||||
|
||||
private void stopSpawner() {
|
||||
if (spawnThread == null) {
|
||||
plugin.getLogger().warning("Can't stop non-existent spawner in arena " + configName() + ". This should never happen.");
|
||||
|
@ -1035,7 +1035,7 @@ public class ArenaImpl implements Arena
|
|||
|
||||
world.setSpawnFlags(allowMonsters, allowAnimals);
|
||||
}
|
||||
|
||||
|
||||
private void startBouncingSheep() {
|
||||
if (sheepBouncer != null) {
|
||||
sheepBouncer.stop();
|
||||
|
@ -1082,7 +1082,7 @@ public class ArenaImpl implements Arena
|
|||
plugin.getArenaMaster().removePlayer(p);
|
||||
clearPlayer(p);
|
||||
}
|
||||
|
||||
|
||||
private void clearPlayer(Player p)
|
||||
{
|
||||
// Remove from boss health bar
|
||||
|
@ -1092,20 +1092,20 @@ public class ArenaImpl implements Arena
|
|||
boss.getHealthBar().removePlayer(p);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Remove pets.
|
||||
monsterManager.removePets(p);
|
||||
|
||||
|
||||
// readyPlayers before lobbyPlayers because of startArena sanity-checks
|
||||
readyPlayers.remove(p);
|
||||
specPlayers.remove(p);
|
||||
arenaPlayers.remove(p);
|
||||
lobbyPlayers.remove(p);
|
||||
arenaPlayerMap.remove(p);
|
||||
|
||||
|
||||
scoreboard.removePlayer(p);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void repairBlocks()
|
||||
{
|
||||
|
@ -1118,9 +1118,9 @@ public class ArenaImpl implements Arena
|
|||
{
|
||||
repairQueue.add(r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Items & Cleanup
|
||||
|
@ -1131,11 +1131,11 @@ public class ArenaImpl implements Arena
|
|||
public void assignClass(Player p, String className) {
|
||||
ArenaPlayer arenaPlayer = arenaPlayerMap.get(p);
|
||||
ArenaClass arenaClass = classes.get(className);
|
||||
|
||||
|
||||
if (arenaPlayer == null || arenaClass == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
InventoryManager.clearInventory(p);
|
||||
removePotionEffects(p);
|
||||
arenaPlayer.setArenaClass(arenaClass);
|
||||
|
@ -1158,21 +1158,21 @@ public class ArenaImpl implements Arena
|
|||
|
||||
autoReady(p);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void assignClassGiveInv(Player p, String className, ItemStack[] source) {
|
||||
ArenaPlayer arenaPlayer = arenaPlayerMap.get(p);
|
||||
ArenaClass arenaClass = classes.get(className);
|
||||
|
||||
|
||||
if (arenaPlayer == null || arenaClass == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
InventoryManager.clearInventory(p);
|
||||
removePermissionAttachments(p);
|
||||
removePotionEffects(p);
|
||||
arenaPlayer.setArenaClass(arenaClass);
|
||||
|
||||
|
||||
PlayerInventory inv = p.getInventory();
|
||||
|
||||
// Clone the source array to make sure we don't modify its contents
|
||||
|
@ -1189,7 +1189,7 @@ public class ArenaImpl implements Arena
|
|||
ItemStack leggings = null;
|
||||
ItemStack boots = null;
|
||||
ItemStack offhand = null;
|
||||
|
||||
|
||||
// Check the very last slot to see if it'll work as a helmet
|
||||
int last = contents.length-1;
|
||||
if (contents[last] != null) {
|
||||
|
@ -1221,7 +1221,7 @@ public class ArenaImpl implements Arena
|
|||
}
|
||||
contents[i] = null;
|
||||
}
|
||||
|
||||
|
||||
// Equip the fifth last slot as the off-hand
|
||||
offhand = contents[contents.length - 5];
|
||||
if (offhand != null) {
|
||||
|
@ -1276,7 +1276,7 @@ public class ArenaImpl implements Arena
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addRandomPlayer(Player p) {
|
||||
randoms.add(p);
|
||||
|
@ -1294,7 +1294,7 @@ public class ArenaImpl implements Arena
|
|||
playerLeave(p);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int index = MobArena.random.nextInt(classes.size());
|
||||
String className = classes.get(index).getConfigName();
|
||||
|
||||
|
@ -1322,7 +1322,7 @@ public class ArenaImpl implements Arena
|
|||
.map(PermissionAttachmentInfo::getAttachment)
|
||||
.forEach(PermissionAttachment::remove);
|
||||
}
|
||||
|
||||
|
||||
private void removePotionEffects(Player p) {
|
||||
p.getActivePotionEffects().stream()
|
||||
.map(PotionEffect::getType)
|
||||
|
@ -1335,21 +1335,21 @@ public class ArenaImpl implements Arena
|
|||
removeEntities();
|
||||
clearPlayers();
|
||||
}
|
||||
|
||||
|
||||
private void removeMonsters() {
|
||||
monsterManager.clear();
|
||||
}
|
||||
|
||||
|
||||
private void removeBlocks() {
|
||||
for (Block b : blocks) {
|
||||
b.setType(Material.AIR);
|
||||
}
|
||||
blocks.clear();
|
||||
}
|
||||
|
||||
|
||||
private void removeEntities() {
|
||||
List<Chunk> chunks = region.getChunks();
|
||||
|
||||
|
||||
for (Chunk c : chunks) {
|
||||
for (Entity e : c.getEntities()) {
|
||||
if (e == null) {
|
||||
|
@ -1368,16 +1368,16 @@ public class ArenaImpl implements Arena
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void clearPlayers() {
|
||||
arenaPlayers.clear();
|
||||
arenaPlayerMap.clear();
|
||||
lobbyPlayers.clear();
|
||||
readyPlayers.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Initialization & Checks
|
||||
|
@ -1388,13 +1388,13 @@ public class ArenaImpl implements Arena
|
|||
public void restoreRegion()
|
||||
{
|
||||
Collections.sort(repairables, new RepairableComparator());
|
||||
|
||||
|
||||
for (Repairable r : repairables)
|
||||
r.repair();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Getters & Misc
|
||||
|
@ -1458,7 +1458,7 @@ public class ArenaImpl implements Arena
|
|||
result.addAll(arenaPlayers);
|
||||
result.addAll(lobbyPlayers);
|
||||
result.addAll(specPlayers);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1477,10 +1477,10 @@ public class ArenaImpl implements Arena
|
|||
public List<ArenaPlayerStatistics> getArenaPlayerStatistics(Comparator<ArenaPlayerStatistics> comparator)
|
||||
{
|
||||
List<ArenaPlayerStatistics> list = new ArrayList<ArenaPlayerStatistics>();
|
||||
|
||||
|
||||
for (ArenaPlayer ap : arenaPlayerMap.values())
|
||||
list.add(ap.getStats());
|
||||
|
||||
|
||||
Collections.sort(list, comparator);
|
||||
return list;
|
||||
}*/
|
||||
|
@ -1519,7 +1519,7 @@ public class ArenaImpl implements Arena
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean refund(Player p) {
|
||||
entryFee.forEach(fee -> fee.giveTo(p));
|
||||
|
@ -1549,7 +1549,7 @@ public class ArenaImpl implements Arena
|
|||
else if (!canAfford(p))
|
||||
messenger.tell(p, Msg.JOIN_FEE_REQUIRED, MAUtils.listToString(entryFee, plugin));
|
||||
else return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1568,7 +1568,7 @@ public class ArenaImpl implements Arena
|
|||
else if (getJoinDistance() > 0 && !region.contains(p.getLocation(), getJoinDistance()))
|
||||
messenger.tell(p, Msg.JOIN_TOO_FAR);
|
||||
else return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1581,7 +1581,7 @@ public class ArenaImpl implements Arena
|
|||
public Player getLastPlayerStanding() {
|
||||
return lastStanding;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The "perfect equals method" cf. "Object-Oriented Design and Patterns"
|
||||
* by Cay S. Horstmann.
|
||||
|
@ -1591,11 +1591,11 @@ public class ArenaImpl implements Arena
|
|||
if (this == other) return true;
|
||||
if (other == null) return false;
|
||||
if (getClass() != other.getClass()) return false;
|
||||
|
||||
|
||||
// Arenas must have different names.
|
||||
if (other instanceof ArenaImpl && ((ArenaImpl)other).name.equals(name))
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ public class ArenaListener
|
|||
this.canShare = s.getBoolean("share-items-in-arena", true);
|
||||
this.autoIgniteTNT = s.getBoolean("auto-ignite-tnt", false);
|
||||
this.useClassChests = s.getBoolean("use-class-chests", false);
|
||||
|
||||
|
||||
this.classLimits = arena.getClassLimitManager();
|
||||
|
||||
this.banned = new HashSet<>();
|
||||
|
@ -157,13 +157,13 @@ public class ArenaListener
|
|||
EntityType.GUARDIAN
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void pvpActivate() {
|
||||
if (arena.isRunning() && !arena.getPlayersInArena().isEmpty()) {
|
||||
pvpEnabled = pvpOn;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void pvpDeactivate() {
|
||||
if (pvpOn) pvpEnabled = false;
|
||||
}
|
||||
|
@ -179,17 +179,17 @@ public class ArenaListener
|
|||
|
||||
// If the arena isn't protected, care
|
||||
if (!protect) return;
|
||||
|
||||
|
||||
if (!arena.getRegion().contains(event.getBlock().getLocation()))
|
||||
return;
|
||||
|
||||
|
||||
if (!arena.inArena(event.getPlayer())) {
|
||||
if (arena.inEditMode())
|
||||
return;
|
||||
else
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
if (onBlockDestroy(event))
|
||||
return;
|
||||
|
||||
|
@ -223,18 +223,18 @@ public class ArenaListener
|
|||
private boolean onBlockDestroy(BlockEvent event) {
|
||||
if (arena.inEditMode())
|
||||
return true;
|
||||
|
||||
|
||||
if (!arena.isRunning())
|
||||
return false;
|
||||
|
||||
Block b = event.getBlock();
|
||||
if (arena.removeBlock(b) || b.getType() == Material.TNT)
|
||||
return true;
|
||||
|
||||
|
||||
if (softRestore) {
|
||||
BlockState state = b.getState();
|
||||
Repairable r = null;
|
||||
|
||||
|
||||
if (state instanceof InventoryHolder)
|
||||
r = new RepairableContainer(state);
|
||||
else if (state instanceof Sign)
|
||||
|
@ -245,7 +245,7 @@ public class ArenaListener
|
|||
r = new RepairableBlock(state);
|
||||
|
||||
arena.addRepairable(r);
|
||||
|
||||
|
||||
if (!softRestoreDrops)
|
||||
b.setType(Material.AIR);
|
||||
return true;
|
||||
|
@ -302,11 +302,11 @@ public class ArenaListener
|
|||
arena.addBlock(b.getRelative(0, 1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setPlanter(Metadatable tnt, Player planter) {
|
||||
tnt.setMetadata("mobarena-planter", new FixedMetadataValue(plugin, planter));
|
||||
}
|
||||
|
||||
|
||||
private Player getPlanter(Metadatable tnt) {
|
||||
List<MetadataValue> values = tnt.getMetadata("mobarena-planter");
|
||||
for (MetadataValue value : values) {
|
||||
|
@ -511,9 +511,9 @@ public class ArenaListener
|
|||
}
|
||||
|
||||
/******************************************************
|
||||
*
|
||||
*
|
||||
* DEATH LISTENERS
|
||||
*
|
||||
*
|
||||
******************************************************/
|
||||
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
|
@ -571,11 +571,11 @@ public class ArenaListener
|
|||
arena.playerRespawn(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void onMountDeath(EntityDeathEvent event) {
|
||||
// Shouldn't ever happen
|
||||
}
|
||||
|
||||
|
||||
private void onMonsterDeath(EntityDeathEvent event) {
|
||||
EntityDamageEvent e1 = event.getEntity().getLastDamageCause();
|
||||
EntityDamageByEntityEvent e2 = (e1 instanceof EntityDamageByEntityEvent) ? (EntityDamageByEntityEvent) e1 : null;
|
||||
|
@ -652,9 +652,9 @@ public class ArenaListener
|
|||
}
|
||||
|
||||
/******************************************************
|
||||
*
|
||||
*
|
||||
* DAMAGE LISTENERS
|
||||
*
|
||||
*
|
||||
******************************************************/
|
||||
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
|
@ -771,7 +771,7 @@ public class ArenaListener
|
|||
double progress = boss.getHealth() / boss.getMaxHealth();
|
||||
boss.getHealthBar().setProgress(progress);
|
||||
}
|
||||
|
||||
|
||||
private void onMonsterDamage(EntityDamageEvent event, Entity monster, Entity damager) {
|
||||
if (damager instanceof Player) {
|
||||
Player p = (Player) damager;
|
||||
|
@ -796,7 +796,7 @@ public class ArenaListener
|
|||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void onGolemDamage(EntityDamageEvent event, Entity golem, Entity damager) {
|
||||
if (damager instanceof Player) {
|
||||
Player p = (Player) damager;
|
||||
|
@ -804,7 +804,7 @@ public class ArenaListener
|
|||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!pvpEnabled) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -898,7 +898,7 @@ public class ArenaListener
|
|||
private boolean isArenaPet(Entity entity) {
|
||||
return arena.hasPet(entity);
|
||||
}
|
||||
|
||||
|
||||
public void onEntityTeleport(EntityTeleportEvent event) {
|
||||
if (monsters.hasPet(event.getEntity()) && region.contains(event.getTo())) {
|
||||
return;
|
||||
|
@ -907,7 +907,7 @@ public class ArenaListener
|
|||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onPotionSplash(PotionSplashEvent event) {
|
||||
ThrownPotion potion = event.getPotion();
|
||||
if (!region.contains(potion.getLocation())) {
|
||||
|
@ -1014,18 +1014,18 @@ public class ArenaListener
|
|||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If the player is in the lobby, just cancel
|
||||
else if (arena.inLobby(p)) {
|
||||
arena.getMessenger().tell(p, Msg.LOBBY_DROP_ITEM);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
// Same if it's a spectator, but...
|
||||
else if (arena.inSpec(p)) {
|
||||
arena.getMessenger().tell(p, Msg.LOBBY_DROP_ITEM);
|
||||
event.setCancelled(true);
|
||||
|
||||
|
||||
// If the spectator isn't in the region, force them to leave
|
||||
if (!region.contains(p.getLocation())) {
|
||||
arena.getMessenger().tell(p, Msg.MISC_MA_LEAVE_REMINDER);
|
||||
|
@ -1122,14 +1122,14 @@ public class ArenaListener
|
|||
arena.getMessenger().tell(p, Msg.LOBBY_CLASS_PERMISSION);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ArenaClass oldAC = arena.getArenaPlayer(p).getArenaClass();
|
||||
|
||||
|
||||
// Same class, do nothing.
|
||||
if (newAC.equals(oldAC)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// If the new class is full, inform the player.
|
||||
if (!classLimits.canPlayerJoinClass(newAC)) {
|
||||
arena.getMessenger().tell(p, Msg.LOBBY_CLASS_FULL);
|
||||
|
@ -1144,7 +1144,7 @@ public class ArenaListener
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Otherwise, leave the old class, and pick the new!
|
||||
classLimits.playerLeftClass(oldAC, p);
|
||||
classLimits.playerPickedClass(newAC, p);
|
||||
|
@ -1152,14 +1152,14 @@ public class ArenaListener
|
|||
// Delay the inventory stuff to ensure that right-clicking works.
|
||||
delayAssignClass(p, className, price, sign);
|
||||
}
|
||||
|
||||
|
||||
/*private boolean cansPlayerJoinClass(ArenaClass ac, Player p) {
|
||||
// If they can not join the class, deny them
|
||||
if (!classLimits.canPlayerJoinClass(ac)) {
|
||||
Messenger.tell(p, Msg.LOBBY_CLASS_FULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Increment the "in use" in the Class Limit Manager
|
||||
classLimits.playerPickedClass(ac);
|
||||
return true;
|
||||
|
@ -1222,7 +1222,7 @@ public class ArenaListener
|
|||
}
|
||||
}, ticks);
|
||||
}
|
||||
|
||||
|
||||
public TeleportResponse onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
if (!arena.isEnabled() || !region.isSetup() || arena.inEditMode() || allowTeleport) {
|
||||
return TeleportResponse.IDGAF;
|
||||
|
@ -1310,10 +1310,10 @@ public class ArenaListener
|
|||
public void onPlayerPreLogin(PlayerLoginEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
if (p == null || !p.isOnline()) return;
|
||||
|
||||
|
||||
Arena arena = plugin.getArenaMaster().getArenaWithPlayer(p);
|
||||
if (arena == null) return;
|
||||
|
||||
|
||||
arena.playerLeave(p);
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ public class ArenaMasterImpl implements ArenaMaster
|
|||
public List<Arena> getEnabledArenas(List<Arena> arenas) {
|
||||
List<Arena> result = new ArrayList<>(arenas.size());
|
||||
for (Arena arena : arenas)
|
||||
if (arena.isEnabled())
|
||||
if (arena.isEnabled())
|
||||
result.add(arena);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class ClassLimitManager
|
|||
private HashMap<ArenaClass, HashSet<String>> classesInUse;
|
||||
private ConfigurationSection limits;
|
||||
private Map<String,ArenaClass> classes;
|
||||
|
||||
|
||||
public ClassLimitManager(Arena arena, Map<String,ArenaClass> classes, ConfigurationSection limits) {
|
||||
this.limits = limits;
|
||||
this.classes = classes;
|
||||
|
@ -26,7 +26,7 @@ public class ClassLimitManager
|
|||
loadLimitMap(arena.getPlugin());
|
||||
initInUseMap();
|
||||
}
|
||||
|
||||
|
||||
private void loadLimitMap(Plugin plugin) {
|
||||
// If the config-section is empty, create and populate it.
|
||||
if (limits.getKeys(false).isEmpty()) {
|
||||
|
@ -35,20 +35,20 @@ public class ClassLimitManager
|
|||
}
|
||||
plugin.saveConfig();
|
||||
}
|
||||
|
||||
|
||||
// Populate the limits map using the values in the config-file.
|
||||
for (ArenaClass ac : classes.values()) {
|
||||
classLimits.put(ac, new MutableInt(limits.getInt(ac.getConfigName(), -1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initInUseMap() {
|
||||
// Initialize the in-use map with zeros.
|
||||
for (ArenaClass ac : classes.values()) {
|
||||
classesInUse.put(ac, new HashSet<>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is the class a player is changing to
|
||||
* @param ac the new ArenaClass
|
||||
|
@ -56,7 +56,7 @@ public class ClassLimitManager
|
|||
public void playerPickedClass(ArenaClass ac, Player p) {
|
||||
classesInUse.get(ac).add(p.getName());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is the class a player left
|
||||
* @param ac the current/old ArenaClass
|
||||
|
@ -66,7 +66,7 @@ public class ClassLimitManager
|
|||
classesInUse.get(ac).remove(p.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks to see if a player can pick a specific class
|
||||
* @param ac the ArenaClass to check
|
||||
|
@ -78,13 +78,13 @@ public class ClassLimitManager
|
|||
classLimits.put(ac, new MutableInt(-1));
|
||||
classesInUse.put(ac, new HashSet<>());
|
||||
}
|
||||
|
||||
|
||||
if (classLimits.get(ac).value() <= -1)
|
||||
return true;
|
||||
|
||||
|
||||
return classesInUse.get(ac).size() < classLimits.get(ac).value();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns a set of Player Names who have picked an ArenaClass
|
||||
* @param ac the ArenaClass in question
|
||||
|
@ -93,7 +93,7 @@ public class ClassLimitManager
|
|||
public HashSet<String> getPlayersWithClass(ArenaClass ac) {
|
||||
return classesInUse.get(ac);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the classes in use map and reinitialize it for the next match
|
||||
*/
|
||||
|
@ -101,4 +101,4 @@ public class ClassLimitManager
|
|||
classesInUse.clear();
|
||||
initInUseMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,9 +184,9 @@ public class MASpawnThread implements Runnable
|
|||
Wave w = waveManager.next();
|
||||
|
||||
w.announce(arena, wave);
|
||||
|
||||
|
||||
arena.getScoreboard().updateWave(wave);
|
||||
|
||||
|
||||
// Set the players' level to the wave number
|
||||
if (wavesAsLevel) {
|
||||
for (Player p : arena.getPlayersInArena()) {
|
||||
|
@ -311,7 +311,7 @@ public class MASpawnThread implements Runnable
|
|||
if (waveClear && !monsterManager.getMonsters().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check for pre boss clear
|
||||
if (preBossClear && waveManager.getNext().getType() == WaveType.BOSS && !monsterManager.getMonsters().isEmpty()) {
|
||||
return false;
|
||||
|
@ -345,7 +345,7 @@ public class MASpawnThread implements Runnable
|
|||
if (region.contains(p.getLocation())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
arena.getMessenger().tell(p, "Leaving so soon?");
|
||||
p.getInventory().clear();
|
||||
arena.playerLeave(p);
|
||||
|
@ -402,4 +402,4 @@ public class MASpawnThread implements Runnable
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,18 +28,18 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
public class MAUtils
|
||||
{
|
||||
{
|
||||
/* ///////////////////////////////////////////////////////////////////// //
|
||||
|
||||
|
||||
INITIALIZATION METHODS
|
||||
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////// */
|
||||
|
||||
|
||||
/**
|
||||
* Generates a map of wave numbers and rewards based on the
|
||||
* type of wave ("after" or "every") and the config-file. If
|
||||
* no keys exist in the config-file, an empty map is returned.
|
||||
*/
|
||||
*/
|
||||
public static Map<Integer,List<Thing>> getArenaRewardMap(MobArena plugin, ConfigurationSection config, String arena, String type)
|
||||
{
|
||||
//String arenaPath = "arenas." + arena + ".rewards.waves.";
|
||||
|
@ -47,16 +47,16 @@ public class MAUtils
|
|||
|
||||
String typePath = "rewards.waves." + type;
|
||||
if (!config.contains(typePath)) return result;
|
||||
|
||||
|
||||
//Set<String> waves = config.getKeys(arenaPath + type);
|
||||
Set<String> waves = config.getConfigurationSection(typePath).getKeys(false);
|
||||
if (waves == null) return result;
|
||||
|
||||
|
||||
for (String n : waves)
|
||||
{
|
||||
if (!n.matches("[0-9]+"))
|
||||
continue;
|
||||
|
||||
|
||||
int wave = Integer.parseInt(n);
|
||||
String path = typePath + "." + wave;
|
||||
String rewards = config.getString(path);
|
||||
|
@ -75,20 +75,20 @@ public class MAUtils
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ///////////////////////////////////////////////////////////////////// //
|
||||
|
||||
|
||||
MISC METHODS
|
||||
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////// */
|
||||
|
||||
|
||||
|
||||
|
||||
public static Player getClosestPlayer(MobArena plugin, Entity e, Arena arena) {
|
||||
// Set up the comparison variable and the result.
|
||||
double current = Double.POSITIVE_INFINITY;
|
||||
Player result = null;
|
||||
|
||||
|
||||
/* Iterate through the ArrayList, and update current and result every
|
||||
* time a squared distance smaller than current is found. */
|
||||
List<Player> players = new ArrayList<>(arena.getPlayersInArena());
|
||||
|
@ -99,7 +99,7 @@ public class MAUtils
|
|||
arena.getMessenger().tell(p, "You warped out of the arena world.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
double dist = distanceSquared(plugin, p, e.getLocation());
|
||||
if (dist < current && dist < 256D) {
|
||||
current = dist;
|
||||
|
@ -108,7 +108,7 @@ public class MAUtils
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static double distanceSquared(MobArena plugin, Player p, Location l) {
|
||||
try {
|
||||
return p.getLocation().distanceSquared(l);
|
||||
|
@ -121,7 +121,7 @@ public class MAUtils
|
|||
return Double.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a config-name to a proper spaced and capsed arena name.
|
||||
* The input String is split around all underscores, and every part
|
||||
|
@ -133,7 +133,7 @@ public class MAUtils
|
|||
if (parts.length == 1) {
|
||||
return toCamelCase(parts[0]);
|
||||
}
|
||||
|
||||
|
||||
String separator = " ";
|
||||
StringBuffer buffy = new StringBuffer(name.length());
|
||||
for (String part : parts) {
|
||||
|
@ -141,30 +141,30 @@ public class MAUtils
|
|||
buffy.append(separator);
|
||||
}
|
||||
buffy.replace(buffy.length()-1, buffy.length(), "");
|
||||
|
||||
|
||||
return buffy.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the input String with a capital first letter, and all the
|
||||
* other letters become lower case.
|
||||
* other letters become lower case.
|
||||
*/
|
||||
public static String toCamelCase(String name) {
|
||||
return name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Turn a list into a space-separated string-representation of the list.
|
||||
*/
|
||||
*/
|
||||
public static <E> String listToString(Collection<E> list, boolean none, MobArena plugin)
|
||||
{
|
||||
if (list == null || list.isEmpty()) {
|
||||
return (none ? Msg.MISC_NONE.toString() : "");
|
||||
}
|
||||
|
||||
|
||||
StringBuffer buffy = new StringBuffer();
|
||||
int trimLength = 0;
|
||||
|
||||
|
||||
E type = list.iterator().next();
|
||||
if (type instanceof Player) {
|
||||
for (E e : list) {
|
||||
|
@ -192,7 +192,7 @@ public class MAUtils
|
|||
return buffy.toString().substring(0, buffy.length() - trimLength);
|
||||
}
|
||||
public static <E> String listToString(Collection<E> list, JavaPlugin plugin) { return listToString(list, true, (MobArena) plugin); }
|
||||
|
||||
|
||||
/**
|
||||
* Returns a String-list version of a comma-separated list.
|
||||
*/
|
||||
|
@ -200,15 +200,15 @@ public class MAUtils
|
|||
{
|
||||
List<String> result = new LinkedList<>();
|
||||
if (list == null) return result;
|
||||
|
||||
|
||||
String[] parts = list.trim().split(",");
|
||||
|
||||
|
||||
for (String part : parts)
|
||||
result.add(part.trim());
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stand back, I'm going to try science!
|
||||
*/
|
||||
|
@ -216,11 +216,11 @@ public class MAUtils
|
|||
{
|
||||
// Grab the Configuration and ArenaMaster
|
||||
ArenaMaster am = plugin.getArenaMaster();
|
||||
|
||||
|
||||
// Create the arena node in the config-file.
|
||||
World world = loc.getWorld();
|
||||
Arena arena = am.createArenaNode(name, world);
|
||||
|
||||
|
||||
// Get the hippie bounds.
|
||||
int x1 = (int)loc.getX() - radius;
|
||||
int x2 = (int)loc.getX() + radius;
|
||||
|
@ -228,14 +228,14 @@ public class MAUtils
|
|||
int y2 = (int)loc.getY() - 1;
|
||||
int z1 = (int)loc.getZ() - radius;
|
||||
int z2 = (int)loc.getZ() + radius;
|
||||
|
||||
|
||||
int lx1 = x1;
|
||||
int lx2 = x1 + am.getClasses().size() + 3;
|
||||
int ly1 = y1-6;
|
||||
int ly2 = y1-2;
|
||||
int lz1 = z1;
|
||||
int lz2 = z1 + 6;
|
||||
|
||||
|
||||
// Build some monster walls.
|
||||
for (int i = x1; i <= x2; i++)
|
||||
{
|
||||
|
@ -253,7 +253,7 @@ public class MAUtils
|
|||
world.getBlockAt(x2,j,k).setType(Material.SANDSTONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add some hippie light.
|
||||
for (int i = x1; i <= x2; i++)
|
||||
{
|
||||
|
@ -265,7 +265,7 @@ public class MAUtils
|
|||
world.getBlockAt(x1,y1+2,k).setType(Material.GLOWSTONE);
|
||||
world.getBlockAt(x2,y1+2,k).setType(Material.GLOWSTONE);
|
||||
}
|
||||
|
||||
|
||||
// Build a monster floor, and some Obsidian foundation.
|
||||
for (int i = x1; i <= x2; i++)
|
||||
{
|
||||
|
@ -275,20 +275,20 @@ public class MAUtils
|
|||
world.getBlockAt(i,y1-1,k).setType(Material.OBSIDIAN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Make a hippie roof.
|
||||
for (int i = x1; i <= x2; i++)
|
||||
{
|
||||
for (int k = z1; k <= z2; k++)
|
||||
world.getBlockAt(i,y2,k).setType(Material.GLASS);
|
||||
}
|
||||
|
||||
|
||||
// Monster bulldoze
|
||||
for (int i = x1+1; i < x2; i++)
|
||||
for (int j = y1+1; j < y2; j++)
|
||||
for (int k = z1+1; k < z2; k++)
|
||||
world.getBlockAt(i,j,k).setType(Material.AIR);
|
||||
|
||||
|
||||
// Build a hippie lobby
|
||||
for (int i = lx1; i <= lx2; i++) // Walls
|
||||
{
|
||||
|
@ -322,7 +322,7 @@ public class MAUtils
|
|||
for (int j = ly1+1; j <= ly2; j++)
|
||||
for (int k = lz1+1; k < lz2; k++)
|
||||
world.getBlockAt(i,j,k).setType(Material.AIR);
|
||||
|
||||
|
||||
// Place the hippie signs
|
||||
//Iterator<String> iterator = am.getClasses().iterator();
|
||||
Iterator<String> iterator = am.getClasses().keySet().iterator();
|
||||
|
@ -336,23 +336,23 @@ public class MAUtils
|
|||
sign.update();
|
||||
}
|
||||
world.getBlockAt(lx2-2,ly1+1,lz1+2).setType(Material.IRON_BLOCK);
|
||||
|
||||
// Set up the monster points.
|
||||
|
||||
// Set up the monster points.
|
||||
ArenaRegion region = arena.getRegion();
|
||||
region.set("p1", new Location(world, x1, ly1, z1));
|
||||
region.set("p2", new Location(world, x2, y2+1, z2));
|
||||
|
||||
|
||||
region.set("arena", new Location(world, loc.getX(), y1+1, loc.getZ()));
|
||||
region.set("lobby", new Location(world, x1+2, ly1+1, z1+2));
|
||||
region.set("spectator", new Location(world, loc.getX(), y2+1, loc.getZ()));
|
||||
|
||||
|
||||
region.addSpawn("s1", new Location(world, x1+3, y1+2, z1+3));
|
||||
region.addSpawn("s2", new Location(world, x1+3, y1+2, z2-3));
|
||||
region.addSpawn("s3", new Location(world, x2-3, y1+2, z1+3));
|
||||
region.addSpawn("s4", new Location(world, x2-3, y1+2, z2-3));
|
||||
region.save();
|
||||
|
||||
|
||||
am.reloadConfig();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ public class MobArena extends JavaPlugin
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setupArenaMaster() {
|
||||
arenaMaster = new ArenaMasterImpl(this);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
|||
public class MobArenaHandler
|
||||
{
|
||||
private MobArena plugin;
|
||||
|
||||
|
||||
/**
|
||||
* Primary constructor.
|
||||
* The field 'plugin' is initalized, if the server is running MobArena.
|
||||
|
@ -18,15 +18,15 @@ public class MobArenaHandler
|
|||
public MobArenaHandler() {
|
||||
plugin = (MobArena) Bukkit.getServer().getPluginManager().getPlugin("MobArena");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
REGION/LOCATION METHODS
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
/**
|
||||
* Check if a Location is inside of any arena region.
|
||||
* @param loc A location.
|
||||
|
@ -41,7 +41,7 @@ public class MobArenaHandler
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a Location is inside of a specific arena region (by arena object).
|
||||
* @param arena An Arena object
|
||||
|
@ -51,7 +51,7 @@ public class MobArenaHandler
|
|||
public boolean inRegion(Arena arena, Location loc) {
|
||||
return (arena != null && arena.getRegion().contains(loc));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a Location is inside of a specific arena region (by arena name).
|
||||
* @param arenaName The name of an arena
|
||||
|
@ -65,7 +65,7 @@ public class MobArenaHandler
|
|||
|
||||
return arena.getRegion().contains(loc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a Location is inside of the region of an arena that is currently running.
|
||||
* @param loc A location.
|
||||
|
@ -74,7 +74,7 @@ public class MobArenaHandler
|
|||
public boolean inRunningRegion(Location loc) {
|
||||
return inRegion(loc, false, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a Location is inside of the region of an arena that is currently enabled.
|
||||
* @param loc A location.
|
||||
|
@ -83,7 +83,7 @@ public class MobArenaHandler
|
|||
public boolean inEnabledRegion(Location loc) {
|
||||
return inRegion(loc, true, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Private helper method for inRunningRegion and inEnabledRegion
|
||||
* @param loc A location
|
||||
|
@ -106,15 +106,15 @@ public class MobArenaHandler
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
PLAYER/MONSTER/PET METHODS
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
/**
|
||||
* Check if a player is in a MobArena arena (by Player).
|
||||
* @param player The player
|
||||
|
@ -123,7 +123,7 @@ public class MobArenaHandler
|
|||
public boolean isPlayerInArena(Player player) {
|
||||
return (plugin.getArenaMaster().getArenaWithPlayer(player) != null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a player is in a MobArena arena (by name).
|
||||
* @param playerName The name of the player
|
||||
|
@ -132,7 +132,7 @@ public class MobArenaHandler
|
|||
public boolean isPlayerInArena(String playerName) {
|
||||
return (plugin.getArenaMaster().getArenaWithPlayer(playerName) != null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the MobArena class of a given player.
|
||||
* @param player The player
|
||||
|
@ -144,7 +144,7 @@ public class MobArenaHandler
|
|||
|
||||
return getPlayerClass(arena, player);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the MobArena class of a given player in a given arena.
|
||||
* This method is faster than the above method, granted the Arena object is known.
|
||||
|
@ -155,13 +155,13 @@ public class MobArenaHandler
|
|||
public String getPlayerClass(Arena arena, Player player) {
|
||||
ArenaPlayer ap = arena.getArenaPlayer(player);
|
||||
if (ap == null) return null;
|
||||
|
||||
|
||||
ArenaClass ac = ap.getArenaClass();
|
||||
if (ac == null) return null;
|
||||
|
||||
|
||||
return ac.getLowercaseName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a monster is in a MobArena arena.
|
||||
* @param entity The monster entity
|
||||
|
@ -170,7 +170,7 @@ public class MobArenaHandler
|
|||
public boolean isMonsterInArena(LivingEntity entity) {
|
||||
return plugin.getArenaMaster().getArenaWithMonster(entity) != null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a pet is in a MobArena arena.
|
||||
* @param wolf The pet wolf
|
||||
|
@ -179,15 +179,15 @@ public class MobArenaHandler
|
|||
public boolean isPetInArena(LivingEntity wolf) {
|
||||
return plugin.getArenaMaster().getArenaWithPet(wolf) != null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
ARENA GETTERS
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
/**
|
||||
* Get an Arena object at the given location.
|
||||
* @param loc A location
|
||||
|
@ -196,7 +196,7 @@ public class MobArenaHandler
|
|||
public Arena getArenaAtLocation(Location loc) {
|
||||
return plugin.getArenaMaster().getArenaAtLocation(loc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Arena object that the given player is currently in.
|
||||
* @param p A player
|
||||
|
@ -205,7 +205,7 @@ public class MobArenaHandler
|
|||
public Arena getArenaWithPlayer(Player p) {
|
||||
return plugin.getArenaMaster().getArenaWithPlayer(p);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Arena object that the given pet is currently in.
|
||||
* @param wolf A pet wolf
|
||||
|
@ -214,7 +214,7 @@ public class MobArenaHandler
|
|||
public Arena getArenaWithPet(Entity wolf) {
|
||||
return plugin.getArenaMaster().getArenaWithPet(wolf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Arena object that the given monster is currently in.
|
||||
* @param monster A monster
|
||||
|
|
|
@ -24,7 +24,7 @@ public class MonsterManager
|
|||
private Set<LivingEntity> mounts;
|
||||
private Map<Entity, Player> petToPlayer;
|
||||
private Map<Player, Set<Entity>> playerToPets;
|
||||
|
||||
|
||||
public MonsterManager() {
|
||||
this.monsters = new HashSet<>();
|
||||
this.sheep = new HashSet<>();
|
||||
|
@ -35,7 +35,7 @@ public class MonsterManager
|
|||
this.petToPlayer = new HashMap<>();
|
||||
this.playerToPets = new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
public void reset() {
|
||||
monsters.clear();
|
||||
sheep.clear();
|
||||
|
@ -46,7 +46,7 @@ public class MonsterManager
|
|||
petToPlayer.clear();
|
||||
playerToPets.clear();
|
||||
}
|
||||
|
||||
|
||||
public void clear() {
|
||||
bosses.values().stream()
|
||||
.map(MABoss::getHealthBar)
|
||||
|
@ -60,10 +60,10 @@ public class MonsterManager
|
|||
removeAll(suppliers.keySet());
|
||||
removeAll(mounts);
|
||||
removeAll(petToPlayer.keySet());
|
||||
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
private void removeAll(Collection<? extends Entity> collection) {
|
||||
for (Entity e : collection) {
|
||||
if (e != null) {
|
||||
|
@ -71,7 +71,7 @@ public class MonsterManager
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void remove(Entity e) {
|
||||
if (monsters.remove(e)) {
|
||||
sheep.remove(e);
|
||||
|
@ -83,50 +83,50 @@ public class MonsterManager
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Set<LivingEntity> getMonsters() {
|
||||
return monsters;
|
||||
}
|
||||
|
||||
|
||||
public void addMonster(LivingEntity e) {
|
||||
monsters.add(e);
|
||||
}
|
||||
|
||||
|
||||
public boolean removeMonster(Entity e) {
|
||||
return monsters.remove(e);
|
||||
}
|
||||
|
||||
|
||||
public Set<LivingEntity> getExplodingSheep() {
|
||||
return sheep;
|
||||
}
|
||||
|
||||
|
||||
public void addExplodingSheep(LivingEntity e) {
|
||||
sheep.add(e);
|
||||
}
|
||||
|
||||
|
||||
public boolean removeExplodingSheep(LivingEntity e) {
|
||||
return sheep.remove(e);
|
||||
}
|
||||
|
||||
|
||||
public Set<LivingEntity> getGolems() {
|
||||
return golems;
|
||||
}
|
||||
|
||||
|
||||
public void addGolem(LivingEntity e) {
|
||||
golems.add(e);
|
||||
}
|
||||
|
||||
|
||||
public boolean removeGolem(LivingEntity e) {
|
||||
return golems.remove(e);
|
||||
}
|
||||
|
||||
|
||||
public void addPet(Player player, Entity pet) {
|
||||
petToPlayer.put(pet, player);
|
||||
playerToPets
|
||||
.computeIfAbsent(player, (key) -> new HashSet<>())
|
||||
.add(pet);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPet(Entity e) {
|
||||
return petToPlayer.containsKey(e);
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ public class MonsterManager
|
|||
}
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
||||
public void removePets(Player p) {
|
||||
Set<Entity> pets = playerToPets.remove(p);
|
||||
if (pets != null) {
|
||||
|
@ -162,7 +162,7 @@ public class MonsterManager
|
|||
pets.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addMount(LivingEntity e) {
|
||||
mounts.add(e);
|
||||
}
|
||||
|
@ -180,29 +180,29 @@ public class MonsterManager
|
|||
e.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addSupplier(LivingEntity e, List<ItemStack> drops) {
|
||||
suppliers.put(e, drops);
|
||||
}
|
||||
|
||||
|
||||
public List<ItemStack> getLoot(Entity e) {
|
||||
return suppliers.get(e);
|
||||
}
|
||||
|
||||
|
||||
public MABoss addBoss(LivingEntity e, double maxHealth) {
|
||||
MABoss b = new MABoss(e, maxHealth);
|
||||
bosses.put(e, b);
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
public MABoss removeBoss(LivingEntity e) {
|
||||
return bosses.remove(e);
|
||||
}
|
||||
|
||||
|
||||
public MABoss getBoss(LivingEntity e) {
|
||||
return bosses.get(e);
|
||||
}
|
||||
|
||||
|
||||
public Set<LivingEntity> getBossMonsters() {
|
||||
return bosses.keySet();
|
||||
}
|
||||
|
|
|
@ -124,4 +124,4 @@ public enum Msg {
|
|||
}
|
||||
return yaml;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,17 +15,17 @@ public class RewardManager
|
|||
{
|
||||
private Map<Player,List<Thing>> players;
|
||||
private Set<Player> rewarded;
|
||||
|
||||
|
||||
public RewardManager(Arena arena) {
|
||||
this.players = new HashMap<>();
|
||||
this.rewarded = new HashSet<>();
|
||||
}
|
||||
|
||||
|
||||
public void reset() {
|
||||
players.clear();
|
||||
rewarded.clear();
|
||||
}
|
||||
|
||||
|
||||
public void addReward(Player p, Thing thing) {
|
||||
if (!players.containsKey(p)) {
|
||||
players.put(p, new ArrayList<>());
|
||||
|
@ -35,10 +35,10 @@ public class RewardManager
|
|||
|
||||
public void grantRewards(Player p) {
|
||||
if (rewarded.contains(p)) return;
|
||||
|
||||
|
||||
List<Thing> rewards = players.get(p);
|
||||
if (rewards == null) return;
|
||||
|
||||
|
||||
for (Thing reward : rewards) {
|
||||
if (reward == null) {
|
||||
continue;
|
||||
|
@ -47,4 +47,4 @@ public class RewardManager
|
|||
}
|
||||
rewarded.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class ScoreboardManager {
|
|||
private Objective kills;
|
||||
|
||||
private Map<Player, Scoreboard> scoreboards;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new scoreboard for the given arena.
|
||||
* @param arena an arena
|
||||
|
@ -30,7 +30,7 @@ public class ScoreboardManager {
|
|||
scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
|
||||
scoreboards = new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a player to the scoreboard by setting the player's scoreboard
|
||||
* and giving him an initial to-be-reset non-zero score.
|
||||
|
@ -44,7 +44,7 @@ public class ScoreboardManager {
|
|||
player.setScoreboard(scoreboard);
|
||||
kills.getScore(player.getName()).setScore(8);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove a player from the scoreboard by setting the player's scoreboard
|
||||
* to the main server scoreboard.
|
||||
|
@ -108,7 +108,7 @@ public class ScoreboardManager {
|
|||
fake.setScore(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the scoreboard to display the given wave number.
|
||||
* @param wave a wave number
|
||||
|
@ -116,7 +116,7 @@ public class ScoreboardManager {
|
|||
void updateWave(int wave) {
|
||||
kills.setDisplayName(DISPLAY_NAME + wave);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the scoreboard by resetting the kills objective and
|
||||
* setting all player scores to 0.
|
||||
|
@ -129,7 +129,7 @@ public class ScoreboardManager {
|
|||
resetKills();
|
||||
arena.scheduleTask(this::resetPlayerScores, 1);
|
||||
}
|
||||
|
||||
|
||||
private void resetKills() {
|
||||
if (kills != null) {
|
||||
kills.unregister();
|
||||
|
|
|
@ -53,7 +53,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter
|
|||
private Messenger fallbackMessenger;
|
||||
|
||||
private Map<String,Command> commands;
|
||||
|
||||
|
||||
public CommandHandler(MobArena plugin) {
|
||||
this.plugin = plugin;
|
||||
this.fallbackMessenger = new Messenger("&a[MobArena] ");
|
||||
|
@ -98,7 +98,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter
|
|||
|
||||
// Get all commands that match the base.
|
||||
List<Command> matches = getMatchingCommands(base);
|
||||
|
||||
|
||||
// If there's more than one match, display them.
|
||||
if (matches.size() > 1) {
|
||||
am.getGlobalMessenger().tell(sender, Msg.MISC_MULTIPLE_MATCHES);
|
||||
|
@ -107,29 +107,29 @@ public class CommandHandler implements CommandExecutor, TabCompleter
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// If there are no matches at all, notify.
|
||||
if (matches.size() == 0) {
|
||||
am.getGlobalMessenger().tell(sender, Msg.MISC_NO_MATCHES);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Grab the only match.
|
||||
Command command = matches.get(0);
|
||||
CommandInfo info = command.getClass().getAnnotation(CommandInfo.class);
|
||||
|
||||
|
||||
// First check if the sender has permission.
|
||||
if (!sender.hasPermission(info.permission())) {
|
||||
am.getGlobalMessenger().tell(sender, Msg.MISC_NO_ACCESS);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Check if the last argument is a ?, in which case, display usage and description
|
||||
if (last.equals("?") || last.equals("help")) {
|
||||
showUsage(command, sender, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Otherwise, execute the command!
|
||||
String[] params = trimFirstArg(args);
|
||||
if (!command.execute(am, sender, params)) {
|
||||
|
@ -162,7 +162,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all commands that match a given string.
|
||||
* @param arg the given string
|
||||
|
@ -170,17 +170,17 @@ public class CommandHandler implements CommandExecutor, TabCompleter
|
|||
*/
|
||||
private List<Command> getMatchingCommands(String arg) {
|
||||
List<Command> result = new ArrayList<>();
|
||||
|
||||
|
||||
// Grab the commands that match the argument.
|
||||
for (Entry<String,Command> entry : commands.entrySet()) {
|
||||
if (arg.matches(entry.getKey())) {
|
||||
result.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the usage and description messages of a command to a player.
|
||||
* The usage will only be shown, if the player has permission for the command.
|
||||
|
@ -193,7 +193,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter
|
|||
|
||||
sender.sendMessage((prefix ? "Usage: " : "") + info.usage() + " " + ChatColor.YELLOW + info.desc());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the first argument of a string. This is because the very first
|
||||
* element of the arguments array will be the command itself.
|
||||
|
@ -203,7 +203,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter
|
|||
private String[] trimFirstArg(String[] args) {
|
||||
return Arrays.copyOfRange(args, 1, args.length);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List all the available MobArena commands for the CommandSender.
|
||||
* @param sender a player or the console
|
||||
|
@ -240,7 +240,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter
|
|||
if (setup.length() > 0) am.getGlobalMessenger().tell(sender, "Setup commands: " + setup.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, org.bukkit.command.Command bcmd, String alias, String[] args) {
|
||||
// Only players can tab complete
|
||||
|
@ -302,7 +302,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter
|
|||
*/
|
||||
private void registerCommands() {
|
||||
commands = new LinkedHashMap<>();
|
||||
|
||||
|
||||
// mobarena.use
|
||||
register(JoinCommand.class);
|
||||
register(LeaveCommand.class);
|
||||
|
@ -319,7 +319,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter
|
|||
register(ForceCommand.class);
|
||||
register(KickCommand.class);
|
||||
register(RestoreCommand.class);
|
||||
|
||||
|
||||
// mobarena.setup
|
||||
register(SetupCommand.class);
|
||||
register(SettingCommand.class);
|
||||
|
@ -339,7 +339,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter
|
|||
register(RemoveLeaderboardCommand.class);
|
||||
register(AutoGenerateCommand.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a command.
|
||||
* The Command's CommandInfo annotation is queried to find its pattern
|
||||
|
@ -349,7 +349,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter
|
|||
public void register(Class<? extends Command> c) {
|
||||
CommandInfo info = c.getAnnotation(CommandInfo.class);
|
||||
if (info == null) return;
|
||||
|
||||
|
||||
try {
|
||||
commands.put(info.pattern(), c.newInstance());
|
||||
}
|
||||
|
|
|
@ -10,24 +10,24 @@ public @interface CommandInfo
|
|||
* The actual name of the command. Not really used anywhere.
|
||||
*/
|
||||
String name();
|
||||
|
||||
|
||||
/**
|
||||
* A regex pattern that allows minor oddities and alternatives to the command name.
|
||||
*/
|
||||
String pattern();
|
||||
|
||||
|
||||
/**
|
||||
* The usage message, i.e. how the command should be used.
|
||||
*/
|
||||
String usage();
|
||||
|
||||
|
||||
/**
|
||||
* A description of what the command does.
|
||||
*/
|
||||
String desc();
|
||||
|
||||
|
||||
/**
|
||||
* The permission required to execute this command.
|
||||
*/
|
||||
String permission();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class Commands
|
|||
public static boolean isPlayer(CommandSender sender) {
|
||||
return (sender instanceof Player);
|
||||
}
|
||||
|
||||
|
||||
public static Arena getArenaToJoinOrSpec(ArenaMaster am, Player p, String arg1) {
|
||||
// Check if MobArena is enabled first.
|
||||
if (!am.isEnabled()) {
|
||||
|
@ -48,17 +48,17 @@ public class Commands
|
|||
am.getGlobalMessenger().tell(p, Msg.JOIN_NO_PERMISSION);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// Then check if we have any enabled arenas.
|
||||
arenas = am.getEnabledArenas(arenas);
|
||||
if (arenas.isEmpty()) {
|
||||
am.getGlobalMessenger().tell(p, Msg.JOIN_NOT_ENABLED);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// The arena to join.
|
||||
Arena arena = null;
|
||||
|
||||
|
||||
// Branch on whether there's an argument or not.
|
||||
if (arg1 != null) {
|
||||
arena = am.getArenaWithName(arg1);
|
||||
|
@ -66,7 +66,7 @@ public class Commands
|
|||
am.getGlobalMessenger().tell(p, Msg.ARENA_DOES_NOT_EXIST);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (!arenas.contains(arena)) {
|
||||
am.getGlobalMessenger().tell(p, Msg.JOIN_ARENA_NOT_ENABLED);
|
||||
return null;
|
||||
|
@ -80,18 +80,18 @@ public class Commands
|
|||
}
|
||||
arena = arenas.get(0);
|
||||
}
|
||||
|
||||
|
||||
// If player is in a boat/minecart, eject!
|
||||
if (p.isInsideVehicle()) {
|
||||
p.leaveVehicle();
|
||||
}
|
||||
|
||||
|
||||
// If player is in a bed, unbed!
|
||||
if (p.isSleeping()) {
|
||||
p.kickPlayer("Banned for life... Nah, just don't join from a bed ;)");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return arena;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,14 +26,14 @@ public class DisableCommand implements Command
|
|||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||
// Grab the argument, if any.
|
||||
String arg1 = (args.length > 0 ? args[0] : "");
|
||||
|
||||
|
||||
if (arg1.equals("all")) {
|
||||
for (Arena arena : am.getArenas()) {
|
||||
disable(arena, sender);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!arg1.equals("")) {
|
||||
Arena arena = am.getArenaWithName(arg1);
|
||||
if (arena == null) {
|
||||
|
@ -43,13 +43,13 @@ public class DisableCommand implements Command
|
|||
disable(arena, sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
am.setEnabled(false);
|
||||
am.saveConfig();
|
||||
am.getGlobalMessenger().tell(sender, "MobArena " + ChatColor.RED + "disabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void disable(Arena arena, CommandSender sender) {
|
||||
arena.setEnabled(false);
|
||||
arena.getPlugin().saveConfig();
|
||||
|
|
|
@ -26,14 +26,14 @@ public class EnableCommand implements Command
|
|||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||
// Grab the argument, if any.
|
||||
String arg1 = (args.length > 0 ? args[0] : "");
|
||||
|
||||
|
||||
if (arg1.equals("all")) {
|
||||
for (Arena arena : am.getArenas()) {
|
||||
enable(arena, sender);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!arg1.equals("")) {
|
||||
Arena arena = am.getArenaWithName(arg1);
|
||||
if (arena == null) {
|
||||
|
@ -43,13 +43,13 @@ public class EnableCommand implements Command
|
|||
enable(arena, sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
am.setEnabled(true);
|
||||
am.saveConfig();
|
||||
am.getGlobalMessenger().tell(sender, "MobArena " + ChatColor.GREEN + "enabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void enable(Arena arena, CommandSender sender) {
|
||||
arena.setEnabled(true);
|
||||
arena.getPlugin().saveConfig();
|
||||
|
|
|
@ -30,7 +30,7 @@ public class ForceCommand implements Command
|
|||
// Grab the argument, if any.
|
||||
String arg1 = (args.length > 0 ? args[0] : "");
|
||||
String arg2 = (args.length > 1 ? args[1] : "");
|
||||
|
||||
|
||||
if (arg1.equals("end")) {
|
||||
// With no arguments, end all.
|
||||
if (arg2.equals("")) {
|
||||
|
@ -41,46 +41,46 @@ public class ForceCommand implements Command
|
|||
am.resetArenaMap();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Otherwise, grab the arena in question.
|
||||
Arena arena = am.getArenaWithName(arg2);
|
||||
if (arena == null) {
|
||||
am.getGlobalMessenger().tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (arena.getAllPlayers().isEmpty()) {
|
||||
am.getGlobalMessenger().tell(sender, Msg.FORCE_END_EMPTY);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// And end it!
|
||||
arena.forceEnd();
|
||||
am.getGlobalMessenger().tell(sender, Msg.FORCE_END_ENDED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (arg1.equals("start")) {
|
||||
// Require argument.
|
||||
if (arg2.equals("")) return false;
|
||||
|
||||
|
||||
// Grab the arena.
|
||||
Arena arena = am.getArenaWithName(arg2);
|
||||
if (arena == null) {
|
||||
am.getGlobalMessenger().tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (arena.isRunning()) {
|
||||
am.getGlobalMessenger().tell(sender, Msg.FORCE_START_RUNNING);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (arena.getReadyPlayersInLobby().isEmpty()) {
|
||||
am.getGlobalMessenger().tell(sender, Msg.FORCE_START_NOT_READY);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// And start it!
|
||||
arena.forceStart();
|
||||
am.getGlobalMessenger().tell(sender, Msg.FORCE_START_STARTED);
|
||||
|
|
|
@ -24,16 +24,16 @@ public class KickCommand implements Command
|
|||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||
// Require a player name
|
||||
if (args.length != 1) return false;
|
||||
|
||||
|
||||
Arena arena = am.getArenaWithPlayer(args[0]);
|
||||
if (arena == null) {
|
||||
am.getGlobalMessenger().tell(sender, "That player is not in an arena.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Grab the Player object.
|
||||
Player bp = am.getPlugin().getServer().getPlayer(args[0]);
|
||||
|
||||
|
||||
// Force leave.
|
||||
arena.playerLeave(bp);
|
||||
am.getGlobalMessenger().tell(sender, "Player '" + args[0] + "' was kicked from arena '" + arena.configName() + "'.");
|
||||
|
|
|
@ -25,7 +25,7 @@ public class RestoreCommand implements Command
|
|||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||
// Require a player name
|
||||
if (args.length != 1) return false;
|
||||
|
||||
|
||||
Player player = am.getPlugin().getServer().getPlayer(args[0]);
|
||||
if (player == null) {
|
||||
am.getGlobalMessenger().tell(sender, "Player not found.");
|
||||
|
@ -35,7 +35,7 @@ public class RestoreCommand implements Command
|
|||
am.getGlobalMessenger().tell(sender, "Player is currently in an arena.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (InventoryManager.restoreFromFile(am.getPlugin(), player)) {
|
||||
am.getGlobalMessenger().tell(sender, "Restored " + args[0] + "'s inventory!");
|
||||
} else {
|
||||
|
|
|
@ -27,10 +27,10 @@ public class AddArenaCommand implements Command
|
|||
|
||||
// Require an arena name
|
||||
if (args.length != 1) return false;
|
||||
|
||||
|
||||
// Unwrap the sender.
|
||||
Player p = Commands.unwrap(sender);
|
||||
|
||||
|
||||
Arena arena = am.getArenaWithName(args[0]);
|
||||
if (arena != null) {
|
||||
am.getGlobalMessenger().tell(sender, "An arena with that name already exists.");
|
||||
|
|
|
@ -28,22 +28,22 @@ public class AutoGenerateCommand implements Command
|
|||
|
||||
// Require an arena name
|
||||
if (args.length != 1) return false;
|
||||
|
||||
|
||||
// Unwrap the sender.
|
||||
Player p = Commands.unwrap(sender);
|
||||
|
||||
|
||||
// Check if arena already exists.
|
||||
Arena arena = am.getArenaWithName(args[0]);
|
||||
if (arena != null) {
|
||||
am.getGlobalMessenger().tell(sender, "An arena with that name already exists.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!MAUtils.doooooItHippieMonster(p.getLocation(), 13, args[0], am.getPlugin())) {
|
||||
am.getGlobalMessenger().tell(sender, "Could not auto-generate arena.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
am.getGlobalMessenger().tell(sender, "Arena with name '" + args[0] + "' generated.");
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ListClassesCommand implements Command
|
|||
am.getGlobalMessenger().tell(sender, "<none>");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
for (String c : classes) {
|
||||
am.getGlobalMessenger().tell(sender, "- " + c);
|
||||
}
|
||||
|
|
|
@ -24,12 +24,12 @@ public class RemoveArenaCommand implements Command
|
|||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||
// Require an arena name
|
||||
if (args.length != 1) return false;
|
||||
|
||||
|
||||
if (am.getArenas().size() == 1) {
|
||||
am.getGlobalMessenger().tell(sender, "At least one arena must exist.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Arena arena = am.getArenaWithName(args[0]);
|
||||
if (arena == null) {
|
||||
am.getGlobalMessenger().tell(sender, "There is no arena with that name.");
|
||||
|
|
|
@ -41,4 +41,4 @@ public class RemoveLeaderboardCommand implements Command
|
|||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,14 +24,14 @@ public class ArenaListCommand implements Command
|
|||
@Override
|
||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||
List<Arena> arenas;
|
||||
|
||||
|
||||
if (Commands.isPlayer(sender)) {
|
||||
Player p = Commands.unwrap(sender);
|
||||
arenas = am.getPermittedArenas(p);
|
||||
arenas = am.getPermittedArenas(p);
|
||||
} else {
|
||||
arenas = am.getArenas();
|
||||
}
|
||||
|
||||
|
||||
String list = MAUtils.listToString(arenas, am.getPlugin());
|
||||
am.getGlobalMessenger().tell(sender, Msg.MISC_LIST_ARENAS.format(list));
|
||||
return true;
|
||||
|
|
|
@ -29,7 +29,7 @@ public class JoinCommand implements Command
|
|||
am.getGlobalMessenger().tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Unwrap the sender, grab the argument, if any.
|
||||
Player p = Commands.unwrap(sender);
|
||||
String arg1 = (args.length > 0 ? args[0] : null);
|
||||
|
@ -39,7 +39,7 @@ public class JoinCommand implements Command
|
|||
if (toArena == null || !canJoin(p, toArena)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Join the arena!
|
||||
int seconds = toArena.getSettings().getInt("join-interrupt-timer", 0);
|
||||
if (seconds > 0) {
|
||||
|
|
|
@ -24,11 +24,11 @@ public class LeaveCommand implements Command
|
|||
am.getGlobalMessenger().tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Unwrap the sender.
|
||||
Player p = Commands.unwrap(sender);
|
||||
|
||||
Arena arena = am.getArenaWithPlayer(p);
|
||||
Arena arena = am.getArenaWithPlayer(p);
|
||||
if (arena == null) {
|
||||
arena = am.getArenaWithSpectator(p);
|
||||
if (arena == null) {
|
||||
|
@ -36,7 +36,7 @@ public class LeaveCommand implements Command
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (arena.playerLeave(p)) {
|
||||
arena.getMessenger().tell(p, Msg.LEAVE_PLAYER_LEFT);
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ public class NotReadyCommand implements Command
|
|||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||
// Grab the argument, if any
|
||||
String arg1 = (args.length > 0 ? args[0] : "");
|
||||
|
||||
|
||||
// The arena to query.
|
||||
Arena arena = null;
|
||||
|
||||
|
||||
if (!arg1.equals("")) {
|
||||
arena = am.getArenaWithName(arg1);
|
||||
if (arena == null) {
|
||||
|
@ -36,7 +36,7 @@ public class NotReadyCommand implements Command
|
|||
} else if (Commands.isPlayer(sender)) {
|
||||
Player p = Commands.unwrap(sender);
|
||||
arena = am.getArenaWithPlayer(p);
|
||||
|
||||
|
||||
if (arena == null) {
|
||||
am.getGlobalMessenger().tell(sender, Msg.LEAVE_NOT_PLAYING);
|
||||
return true;
|
||||
|
@ -44,7 +44,7 @@ public class NotReadyCommand implements Command
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
String list = MAUtils.listToString(arena.getNonreadyPlayers(), am.getPlugin());
|
||||
arena.getMessenger().tell(sender, Msg.MISC_LIST_PLAYERS.format(list));
|
||||
return true;
|
||||
|
|
|
@ -36,7 +36,7 @@ public class PickClassCommand implements Command
|
|||
|
||||
// Require a class name
|
||||
if (args.length != 1) return false;
|
||||
|
||||
|
||||
// Unwrap the sender
|
||||
Player p = Commands.unwrap(sender);
|
||||
|
||||
|
|
|
@ -25,29 +25,29 @@ public class PlayerListCommand implements Command
|
|||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||
// Grab the argument, if any.
|
||||
String arg1 = (args.length > 0 ? args[0] : "");
|
||||
|
||||
|
||||
String list = null;
|
||||
if (!arg1.equals("")) {
|
||||
Arena arena = am.getArenaWithName(arg1);
|
||||
|
||||
|
||||
if (arena == null) {
|
||||
am.getGlobalMessenger().tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
list = MAUtils.listToString(arena.getPlayersInArena(), am.getPlugin());
|
||||
} else {
|
||||
StringBuilder buffy = new StringBuilder();
|
||||
List<Player> players = new LinkedList<>();
|
||||
|
||||
|
||||
for (Arena arena : am.getArenas()) {
|
||||
players.addAll(arena.getPlayersInArena());
|
||||
}
|
||||
|
||||
|
||||
buffy.append(MAUtils.listToString(players, am.getPlugin()));
|
||||
list = buffy.toString();
|
||||
}
|
||||
|
||||
|
||||
am.getGlobalMessenger().tell(sender, Msg.MISC_LIST_PLAYERS.format(list));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@ public class SpecCommand implements Command
|
|||
am.getGlobalMessenger().tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Unwrap the sender, grab the argument, if any.
|
||||
Player p = Commands.unwrap(sender);
|
||||
String arg1 = (args.length > 0 ? args[0] : null);
|
||||
|
||||
|
||||
// Run some rough sanity checks, and grab the arena to spec.
|
||||
Arena toArena = Commands.getArenaToJoinOrSpec(am, p, arg1);
|
||||
if (toArena == null || !canSpec(p, toArena)) {
|
||||
|
|
|
@ -10,12 +10,12 @@ public class ArenaEndEvent extends Event implements Cancellable
|
|||
private static final HandlerList handlers = new HandlerList();
|
||||
private Arena arena;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
public ArenaEndEvent(Arena arena) {
|
||||
this.arena = arena;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
|
||||
public Arena getArena() {
|
||||
return arena;
|
||||
}
|
||||
|
@ -29,12 +29,12 @@ public class ArenaEndEvent extends Event implements Cancellable
|
|||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,17 +11,17 @@ public class ArenaPlayerDeathEvent extends Event
|
|||
private Player player;
|
||||
private Arena arena;
|
||||
private boolean last;
|
||||
|
||||
|
||||
public ArenaPlayerDeathEvent(Player player, Arena arena, boolean last) {
|
||||
this.player = player;
|
||||
this.arena = arena;
|
||||
this.last = last;
|
||||
}
|
||||
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
public Arena getArena() {
|
||||
return arena;
|
||||
}
|
||||
|
@ -29,12 +29,12 @@ public class ArenaPlayerDeathEvent extends Event
|
|||
public boolean wasLastPlayerStanding() {
|
||||
return last;
|
||||
}
|
||||
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,17 +12,17 @@ public class ArenaPlayerJoinEvent extends Event implements Cancellable
|
|||
private Player player;
|
||||
private Arena arena;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
public ArenaPlayerJoinEvent(Player player, Arena arena) {
|
||||
this.player = player;
|
||||
this.arena = arena;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
public Arena getArena() {
|
||||
return arena;
|
||||
}
|
||||
|
@ -36,12 +36,12 @@ public class ArenaPlayerJoinEvent extends Event implements Cancellable
|
|||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,17 +12,17 @@ public class ArenaPlayerLeaveEvent extends Event implements Cancellable
|
|||
private Player player;
|
||||
private Arena arena;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
public ArenaPlayerLeaveEvent(Player player, Arena arena) {
|
||||
this.player = player;
|
||||
this.arena = arena;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
public Arena getArena() {
|
||||
return arena;
|
||||
}
|
||||
|
@ -36,12 +36,12 @@ public class ArenaPlayerLeaveEvent extends Event implements Cancellable
|
|||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ public class ArenaPlayerReadyEvent extends Event implements Cancellable
|
|||
this.arena = arena;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
public Arena getArena() {
|
||||
return arena;
|
||||
}
|
||||
|
@ -36,12 +36,12 @@ public class ArenaPlayerReadyEvent extends Event implements Cancellable
|
|||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,12 @@ public class ArenaStartEvent extends Event implements Cancellable
|
|||
private static final HandlerList handlers = new HandlerList();
|
||||
private Arena arena;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
public ArenaStartEvent(Arena arena) {
|
||||
this.arena = arena;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
|
||||
public Arena getArena() {
|
||||
return arena;
|
||||
}
|
||||
|
@ -29,12 +29,12 @@ public class ArenaStartEvent extends Event implements Cancellable
|
|||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ public class NewWaveEvent extends Event implements Cancellable
|
|||
private static final HandlerList handlers = new HandlerList();
|
||||
private Arena arena;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
private Wave wave;
|
||||
private int waveNo;
|
||||
|
||||
|
||||
public NewWaveEvent(Arena arena, Wave wave, int waveNo) {
|
||||
this.arena = arena;
|
||||
this.wave = wave;
|
||||
|
@ -24,11 +24,11 @@ public class NewWaveEvent extends Event implements Cancellable
|
|||
public Wave getWave() {
|
||||
return wave;
|
||||
}
|
||||
|
||||
|
||||
public int getWaveNumber() {
|
||||
return waveNo;
|
||||
}
|
||||
|
||||
|
||||
public Arena getArena() {
|
||||
return arena;
|
||||
}
|
||||
|
@ -42,11 +42,11 @@ public class NewWaveEvent extends Event implements Cancellable
|
|||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
|
|
@ -40,78 +40,78 @@ public interface Arena
|
|||
/////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
ConfigurationSection getSettings();
|
||||
|
||||
|
||||
World getWorld();
|
||||
|
||||
|
||||
void setWorld(World world);
|
||||
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
|
||||
void setEnabled(boolean value);
|
||||
|
||||
|
||||
boolean isProtected();
|
||||
|
||||
|
||||
void setProtected(boolean value);
|
||||
|
||||
|
||||
boolean isRunning();
|
||||
|
||||
|
||||
boolean inEditMode();
|
||||
|
||||
|
||||
void setEditMode(boolean value);
|
||||
|
||||
int getMinPlayers();
|
||||
|
||||
int getMaxPlayers();
|
||||
|
||||
|
||||
List<Thing> getEntryFee();
|
||||
|
||||
|
||||
Set<Map.Entry<Integer,List<Thing>>> getEveryWaveEntrySet();
|
||||
|
||||
List<Thing> getAfterWaveReward(int wave);
|
||||
|
||||
|
||||
Set<Player> getPlayersInArena();
|
||||
|
||||
|
||||
Set<Player> getPlayersInLobby();
|
||||
|
||||
|
||||
Set<Player> getReadyPlayersInLobby();
|
||||
|
||||
|
||||
Set<Player> getSpectators();
|
||||
|
||||
MASpawnThread getSpawnThread();
|
||||
|
||||
|
||||
WaveManager getWaveManager();
|
||||
|
||||
|
||||
ArenaListener getEventListener();
|
||||
|
||||
|
||||
void setLeaderboard(Leaderboard leaderboard);
|
||||
|
||||
|
||||
ArenaPlayer getArenaPlayer(Player p);
|
||||
|
||||
|
||||
Set<Block> getBlocks();
|
||||
|
||||
void addBlock(Block b);
|
||||
|
||||
|
||||
boolean removeBlock(Block b);
|
||||
|
||||
|
||||
boolean hasPet(Entity e);
|
||||
|
||||
|
||||
void addRepairable(Repairable r);
|
||||
|
||||
|
||||
ArenaRegion getRegion();
|
||||
|
||||
|
||||
InventoryManager getInventoryManager();
|
||||
|
||||
|
||||
RewardManager getRewardManager();
|
||||
|
||||
|
||||
MonsterManager getMonsterManager();
|
||||
|
||||
ClassLimitManager getClassLimitManager();
|
||||
|
||||
void revivePlayer(Player p);
|
||||
|
||||
|
||||
ScoreboardManager getScoreboard();
|
||||
|
||||
|
||||
|
||||
|
||||
Messenger getMessenger();
|
||||
|
||||
Messenger getGlobalMessenger();
|
||||
|
@ -121,127 +121,127 @@ public interface Arena
|
|||
void announce(Msg msg, String s);
|
||||
|
||||
void announce(Msg msg);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void scheduleTask(Runnable r, int delay);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
boolean startArena();
|
||||
|
||||
|
||||
boolean endArena();
|
||||
|
||||
|
||||
void forceStart();
|
||||
|
||||
|
||||
void forceEnd();
|
||||
|
||||
boolean hasPermission(Player p);
|
||||
|
||||
|
||||
boolean playerJoin(Player p, Location loc);
|
||||
|
||||
|
||||
void playerReady(Player p);
|
||||
|
||||
|
||||
boolean playerLeave(Player p);
|
||||
|
||||
boolean isMoving(Player p);
|
||||
|
||||
boolean isLeaving(Player p);
|
||||
|
||||
|
||||
void playerDeath(Player p);
|
||||
|
||||
void playerRespawn(Player p);
|
||||
|
||||
|
||||
Location getRespawnLocation(Player p);
|
||||
|
||||
|
||||
void playerSpec(Player p, Location loc);
|
||||
|
||||
|
||||
void storeContainerContents();
|
||||
|
||||
|
||||
void restoreContainerContents();
|
||||
|
||||
|
||||
void discardPlayer(Player p);
|
||||
|
||||
|
||||
void repairBlocks();
|
||||
|
||||
|
||||
void queueRepairable(Repairable r);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Items & Cleanup
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
void assignClass(Player p, String className);
|
||||
|
||||
void assignClassGiveInv(Player p, String className, ItemStack[] contents);
|
||||
|
||||
void addRandomPlayer(Player p);
|
||||
|
||||
|
||||
void assignRandomClass(Player p);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Initialization & Checks
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
void restoreRegion();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Getters & Misc
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
boolean inArena(Player p);
|
||||
|
||||
|
||||
boolean inLobby(Player p);
|
||||
|
||||
|
||||
boolean inSpec(Player p);
|
||||
|
||||
|
||||
boolean isDead(Player p);
|
||||
|
||||
|
||||
String configName();
|
||||
|
||||
|
||||
String arenaName();
|
||||
|
||||
|
||||
MobArena getPlugin();
|
||||
|
||||
|
||||
Map<String,ArenaClass> getClasses();
|
||||
|
||||
|
||||
int getPlayerCount();
|
||||
|
||||
|
||||
List<Player> getAllPlayers();
|
||||
|
||||
|
||||
Collection<ArenaPlayer> getArenaPlayerSet();
|
||||
|
||||
|
||||
List<Player> getNonreadyPlayers();
|
||||
|
||||
|
||||
boolean canAfford(Player p);
|
||||
|
||||
|
||||
boolean takeFee(Player p);
|
||||
|
||||
boolean refund(Player p);
|
||||
|
||||
|
||||
boolean canJoin(Player p);
|
||||
|
||||
|
||||
boolean canSpec(Player p);
|
||||
|
||||
boolean hasIsolatedChat();
|
||||
|
|
|
@ -21,121 +21,121 @@ public interface ArenaMaster
|
|||
// NEW METHODS IN REFACTORING
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
|
||||
MobArena getPlugin();
|
||||
|
||||
Messenger getGlobalMessenger();
|
||||
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
|
||||
void setEnabled(boolean value);
|
||||
|
||||
|
||||
boolean notifyOnUpdates();
|
||||
|
||||
|
||||
List<Arena> getArenas();
|
||||
|
||||
|
||||
Map<String,ArenaClass> getClasses();
|
||||
|
||||
|
||||
void addPlayer(Player p, Arena arena);
|
||||
|
||||
|
||||
Arena removePlayer(Player p);
|
||||
|
||||
|
||||
void resetArenaMap();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Getters
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
List<Arena> getEnabledArenas();
|
||||
|
||||
|
||||
List<Arena> getEnabledArenas(List<Arena> arenas);
|
||||
|
||||
|
||||
List<Arena> getPermittedArenas(Player p);
|
||||
|
||||
|
||||
List<Arena> getEnabledAndPermittedArenas(Player p);
|
||||
|
||||
|
||||
Arena getArenaAtLocation(Location loc);
|
||||
|
||||
|
||||
List<Arena> getArenasInWorld(World world);
|
||||
|
||||
|
||||
List<Player> getAllPlayers();
|
||||
|
||||
|
||||
List<Player> getAllPlayersInArena(String arenaName);
|
||||
|
||||
|
||||
List<Player> getAllLivingPlayers();
|
||||
|
||||
|
||||
List<Player> getLivingPlayersInArena(String arenaName);
|
||||
|
||||
|
||||
Arena getArenaWithPlayer(Player p);
|
||||
|
||||
|
||||
Arena getArenaWithPlayer(String playerName);
|
||||
|
||||
|
||||
Arena getArenaWithSpectator(Player p);
|
||||
|
||||
|
||||
Arena getArenaWithMonster(Entity e);
|
||||
|
||||
|
||||
Arena getArenaWithPet(Entity e);
|
||||
|
||||
|
||||
Arena getArenaWithName(String configName);
|
||||
|
||||
|
||||
Arena getArenaWithName(Collection<Arena> arenas, String configName);
|
||||
|
||||
|
||||
boolean isAllowed(String command);
|
||||
|
||||
JoinInterruptTimer getJoinInterruptTimer();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Initialization
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
void initialize();
|
||||
|
||||
/**
|
||||
* Load the global settings.
|
||||
*/
|
||||
void loadSettings();
|
||||
|
||||
|
||||
/**
|
||||
* Load all class-related stuff.
|
||||
*/
|
||||
void loadClasses();
|
||||
|
||||
|
||||
/**
|
||||
* Load all arena-related stuff.
|
||||
*/
|
||||
void loadArenas();
|
||||
|
||||
|
||||
void loadArenasInWorld(String worldName);
|
||||
|
||||
|
||||
void unloadArenasInWorld(String worldName);
|
||||
|
||||
boolean reloadArena(String name);
|
||||
|
||||
|
||||
Arena createArenaNode(String configName, World world);
|
||||
|
||||
|
||||
void removeArenaNode(Arena arena);
|
||||
|
||||
|
||||
SpawnsPets getSpawnsPets();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Update and serialization methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
void reloadConfig();
|
||||
|
||||
|
||||
void saveConfig();
|
||||
}
|
||||
|
|
|
@ -10,32 +10,32 @@ public abstract class AbstractLeaderboardColumn implements LeaderboardColumn
|
|||
protected String statname;
|
||||
private Sign header;
|
||||
private List<Sign> signs;
|
||||
|
||||
|
||||
public AbstractLeaderboardColumn(String statname, Sign header, List<Sign> signs) {
|
||||
this.statname = statname;
|
||||
this.header = header;
|
||||
this.signs = signs;
|
||||
}
|
||||
|
||||
|
||||
public void update(List<ArenaPlayerStatistics> stats) {
|
||||
// Make sure the stats will fit on the signs.
|
||||
int range = Math.min(stats.size(), signs.size()*4);
|
||||
|
||||
|
||||
for (int i = 0; i < range; i++) {
|
||||
// Grab the right sign.
|
||||
Sign s = signs.get(i/4);
|
||||
|
||||
|
||||
// Call the template method.
|
||||
String value = getLine(stats.get(i));
|
||||
|
||||
|
||||
// And set the line
|
||||
s.setLine(i % 4, value);
|
||||
s.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract String getLine(ArenaPlayerStatistics stats);
|
||||
|
||||
|
||||
public void clear() {
|
||||
for (Sign s : signs) {
|
||||
s.setLine(0, "");
|
||||
|
@ -45,11 +45,11 @@ public abstract class AbstractLeaderboardColumn implements LeaderboardColumn
|
|||
s.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Sign getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
|
||||
public List<Sign> getSigns() {
|
||||
return signs;
|
||||
}
|
||||
|
|
|
@ -21,17 +21,17 @@ public class Leaderboard
|
|||
{
|
||||
private MobArena plugin;
|
||||
private Arena arena;
|
||||
|
||||
|
||||
private Location topLeft;
|
||||
private Sign topLeftSign;
|
||||
private BlockFace direction;
|
||||
private int rows, cols, trackingId;
|
||||
|
||||
|
||||
private List<LeaderboardColumn> boards;
|
||||
private List<ArenaPlayerStatistics> stats;
|
||||
|
||||
|
||||
private boolean isValid;
|
||||
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
* Creates a new leaderboard with no signs or locations or anything.
|
||||
|
@ -45,7 +45,7 @@ public class Leaderboard
|
|||
this.boards = new ArrayList<>();
|
||||
this.stats = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Location constructor.
|
||||
* Used to create a leaderboard on-the-fly from the location from the SignChangeEvent.
|
||||
|
@ -56,19 +56,19 @@ public class Leaderboard
|
|||
public Leaderboard(MobArena plugin, Arena arena, Location topLeft)
|
||||
{
|
||||
this(plugin, arena);
|
||||
|
||||
|
||||
if (topLeft == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!(topLeft.getBlock().getState() instanceof Sign)) {
|
||||
plugin.getLogger().warning("The leaderboard-node for arena '" + arena.configName() + "' does not point to a sign!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.topLeft = topLeft;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Grab all adjacent signs and register the individual columns.
|
||||
*/
|
||||
|
@ -77,26 +77,26 @@ public class Leaderboard
|
|||
if (!isGridWellFormed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
initializeBoards();
|
||||
initializeStats();
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
public void clear()
|
||||
{
|
||||
for (LeaderboardColumn column : boards)
|
||||
column.clear();
|
||||
}
|
||||
|
||||
|
||||
public void update()
|
||||
{
|
||||
Collections.sort(stats, ArenaPlayerStatistics.waveComparator());
|
||||
|
||||
|
||||
for (LeaderboardColumn column : boards)
|
||||
column.update(stats);
|
||||
}
|
||||
|
||||
|
||||
public void startTracking()
|
||||
{
|
||||
trackingId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin,
|
||||
|
@ -108,12 +108,12 @@ public class Leaderboard
|
|||
}
|
||||
}, 100, 100);
|
||||
}
|
||||
|
||||
|
||||
public void stopTracking()
|
||||
{
|
||||
plugin.getServer().getScheduler().cancelTask(trackingId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the leaderboards grid is well-formed.
|
||||
* @return true, if the grid is well-formed, false otherwise.
|
||||
|
@ -123,19 +123,19 @@ public class Leaderboard
|
|||
if (topLeft == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
BlockState state = topLeft.getBlock().getState();
|
||||
|
||||
|
||||
if (!(state instanceof Sign))
|
||||
{
|
||||
plugin.getLogger().severe("Leaderboards for '" + arena.configName() + "' could not be established!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Grab the top left sign and set up a copy for parsing.
|
||||
this.topLeftSign = (Sign) state;
|
||||
Sign current = this.topLeftSign;
|
||||
|
||||
|
||||
// Calculate matrix dimensions.
|
||||
BlockFace direction = getRightDirection(current);
|
||||
if (direction == null) {
|
||||
|
@ -144,12 +144,12 @@ public class Leaderboard
|
|||
this.direction = direction;
|
||||
this.rows = getSignCount(current, BlockFace.DOWN);
|
||||
this.cols = getSignCount(current, direction);
|
||||
|
||||
|
||||
// Require at least 2x2 to be valid
|
||||
if (rows <= 1 || cols <= 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Get the left-most sign in the current row.
|
||||
Sign first = getAdjacentSign(current, BlockFace.DOWN);
|
||||
|
||||
|
@ -163,13 +163,13 @@ public class Leaderboard
|
|||
current = getAdjacentSign(current, direction);
|
||||
if (current == null) return false;
|
||||
}
|
||||
|
||||
|
||||
// Hop down to the next row.
|
||||
first = getAdjacentSign(first, BlockFace.DOWN);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build the leaderboards.
|
||||
* Requires: The grid MUST be valid!
|
||||
|
@ -179,16 +179,16 @@ public class Leaderboard
|
|||
boards.clear();
|
||||
Sign header = this.topLeftSign;
|
||||
Sign current;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
// Strip the sign of any colors.
|
||||
String name = ChatColor.stripColor(header.getLine(2));
|
||||
|
||||
|
||||
// Grab the stat to track.
|
||||
Stats stat = Stats.getByFullName(name);
|
||||
if (stat == null) continue;
|
||||
|
||||
|
||||
// Create the list of signs
|
||||
List<Sign> signs = new ArrayList<>();
|
||||
current = header;
|
||||
|
@ -197,10 +197,10 @@ public class Leaderboard
|
|||
current = getAdjacentSign(current, BlockFace.DOWN);
|
||||
signs.add(current);
|
||||
}
|
||||
|
||||
|
||||
// Create the column.
|
||||
LeaderboardColumn column = null;
|
||||
|
||||
|
||||
// Switch on the type of stat
|
||||
switch (stat) {
|
||||
case PLAYER_NAME:
|
||||
|
@ -213,19 +213,19 @@ public class Leaderboard
|
|||
column = new IntLeaderboardColumn(stat.getShortName(), header, signs);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
this.boards.add(column);
|
||||
}
|
||||
while ((header = getAdjacentSign(header, direction)) != null);
|
||||
}
|
||||
|
||||
|
||||
private void initializeStats()
|
||||
{
|
||||
stats.clear();
|
||||
for (ArenaPlayer ap : arena.getArenaPlayerSet())
|
||||
stats.add(ap.getStats());
|
||||
}
|
||||
|
||||
|
||||
private int getSignCount(Sign s, BlockFace direction)
|
||||
{
|
||||
int i = 1;
|
||||
|
@ -247,7 +247,7 @@ public class Leaderboard
|
|||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
private Sign getAdjacentSign(Sign s, BlockFace direction)
|
||||
{
|
||||
BlockState state = s.getBlock().getRelative(direction).getState();
|
||||
|
@ -255,7 +255,7 @@ public class Leaderboard
|
|||
return (Sign) state;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private BlockFace getRightDirection(Sign s)
|
||||
{
|
||||
BlockData data = s.getBlockData();
|
||||
|
@ -270,7 +270,7 @@ public class Leaderboard
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return isValid;
|
||||
|
|
|
@ -12,7 +12,7 @@ public interface LeaderboardColumn
|
|||
* of the player stat associated with this column.
|
||||
*/
|
||||
void update(List<ArenaPlayerStatistics> stats);
|
||||
|
||||
|
||||
/**
|
||||
* Get the String representation of the stat in question.
|
||||
* The line is calculated by simply calling the appropriate
|
||||
|
@ -21,19 +21,19 @@ public interface LeaderboardColumn
|
|||
* @return the String representation of the stat in question
|
||||
*/
|
||||
String getLine(ArenaPlayerStatistics stats);
|
||||
|
||||
|
||||
/**
|
||||
* Clear the text on all the signs in the column.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
|
||||
/**
|
||||
* Get the top sign of the column.
|
||||
* The top sign displays the stat name.
|
||||
* @return the top sign of the column
|
||||
*/
|
||||
Sign getHeader();
|
||||
|
||||
|
||||
/**
|
||||
* Get all signs in the column (minus the header).
|
||||
* @return all signs in the column (minus the header)
|
||||
|
|
|
@ -10,29 +10,29 @@ public enum Stats
|
|||
SWINGS("Swings", "swings"),
|
||||
HITS("Hits", "hits"),
|
||||
LAST_WAVE("Last Wave", "lastWave");
|
||||
|
||||
|
||||
private String name, shortName;
|
||||
|
||||
|
||||
Stats(String name, String shortName) {
|
||||
this.name = name;
|
||||
this.shortName = shortName;
|
||||
}
|
||||
|
||||
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
|
||||
public String getFullName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public static Stats getByFullName(String name) {
|
||||
for (Stats s : Stats.values())
|
||||
if (s.name.equals(name))
|
||||
return s;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static Stats getByShortName(String name) {
|
||||
for (Stats s : Stats.values()) {
|
||||
if (s.shortName.equalsIgnoreCase(name)) {
|
||||
|
|
|
@ -65,18 +65,18 @@ public class MAGlobalListener implements Listener
|
|||
{
|
||||
private MobArena plugin;
|
||||
private ArenaMaster am;
|
||||
|
||||
|
||||
public MAGlobalListener(MobArena plugin, ArenaMaster am) {
|
||||
this.plugin = plugin;
|
||||
this.am = am;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// BLOCK EVENTS //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void blockBreak(BlockBreakEvent event) {
|
||||
for (Arena arena : am.getArenas())
|
||||
|
@ -125,15 +125,15 @@ public class MAGlobalListener implements Listener
|
|||
if (!event.getPlayer().hasPermission("mobarena.setup.leaderboards")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!event.getLine(0).startsWith("[MA]")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String text = event.getLine(0).substring((4));
|
||||
Arena arena;
|
||||
Stats stat;
|
||||
|
||||
|
||||
if ((arena = am.getArenaWithName(text)) != null) {
|
||||
arena.getEventListener().onSignChange(event);
|
||||
setSignLines(event, ChatColor.GREEN + "MobArena", ChatColor.YELLOW + arena.arenaName(), ChatColor.AQUA + "Players", "---------------");
|
||||
|
@ -143,23 +143,23 @@ public class MAGlobalListener implements Listener
|
|||
am.getGlobalMessenger().tell(event.getPlayer(), "Stat sign created.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setSignLines(SignChangeEvent event, String s1, String s2, String s3, String s4) {
|
||||
event.setLine(0, s1);
|
||||
event.setLine(1, s2);
|
||||
event.setLine(2, s3);
|
||||
event.setLine(3, s4);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// ENTITY EVENTS //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void creatureSpawn(CreatureSpawnEvent event) {
|
||||
for (Arena arena : am.getArenas())
|
||||
|
@ -217,7 +217,7 @@ public class MAGlobalListener implements Listener
|
|||
for (Arena arena : am.getArenas())
|
||||
arena.getEventListener().onEntityRegainHealth(event);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void entityFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
for (Arena arena : am.getArenas())
|
||||
|
@ -229,30 +229,30 @@ public class MAGlobalListener implements Listener
|
|||
for (Arena arena : am.getArenas())
|
||||
arena.getEventListener().onEntityTarget(event);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void entityTeleport(EntityTeleportEvent event) {
|
||||
for (Arena arena : am.getArenas()) {
|
||||
arena.getEventListener().onEntityTeleport(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void potionSplash(PotionSplashEvent event) {
|
||||
for (Arena arena : am.getArenas()) {
|
||||
arena.getEventListener().onPotionSplash(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// PLAYER EVENTS //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void playerAnimation(PlayerAnimationEvent event) {
|
||||
if (!am.isEnabled()) return;
|
||||
|
@ -340,7 +340,7 @@ public class MAGlobalListener implements Listener
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum TeleportResponse {
|
||||
ALLOW, REJECT, IDGAF
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ public class MAGlobalListener implements Listener
|
|||
boolean allow = true;
|
||||
for (Arena arena : am.getArenas()) {
|
||||
TeleportResponse r = arena.getEventListener().onPlayerTeleport(event);
|
||||
|
||||
|
||||
// If just one arena allows, uncancel and stop.
|
||||
switch (r) {
|
||||
case ALLOW:
|
||||
|
@ -375,7 +375,7 @@ public class MAGlobalListener implements Listener
|
|||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void playerPreLogin(PlayerLoginEvent event) {
|
||||
for (Arena arena : am.getArenas()) {
|
||||
|
@ -396,21 +396,21 @@ public class MAGlobalListener implements Listener
|
|||
arena.getEventListener().onVehicleExit(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// WORLD EVENTS //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void worldLoadEvent(WorldLoadEvent event) {
|
||||
am.loadArenasInWorld(event.getWorld().getName());
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void worldUnloadEvent(WorldUnloadEvent event) {
|
||||
am.unloadArenasInWorld(event.getWorld().getName());
|
||||
|
|
|
@ -32,17 +32,17 @@ public class ArenaRegion
|
|||
{
|
||||
private Arena arena;
|
||||
private World world;
|
||||
|
||||
|
||||
private Location lastP1, lastP2, lastL1, lastL2;
|
||||
private Location p1, p2, l1, l2, arenaWarp, lobbyWarp, specWarp, exitWarp, leaderboard;
|
||||
private Map<String,Location> spawnpoints, containers;
|
||||
|
||||
|
||||
private boolean setup, lobbySetup;
|
||||
|
||||
|
||||
private ConfigurationSection coords;
|
||||
private ConfigurationSection spawns;
|
||||
private ConfigurationSection chests;
|
||||
|
||||
|
||||
public ArenaRegion(ConfigurationSection section, Arena arena) {
|
||||
this.arena = arena;
|
||||
refreshWorld();
|
||||
|
@ -50,34 +50,34 @@ public class ArenaRegion
|
|||
this.coords = makeSection(section, "coords");
|
||||
this.spawns = makeSection(coords, "spawnpoints");
|
||||
this.chests = makeSection(coords, "containers");
|
||||
|
||||
|
||||
reloadAll();
|
||||
}
|
||||
|
||||
|
||||
public void refreshWorld() {
|
||||
this.world = arena.getWorld();
|
||||
}
|
||||
|
||||
|
||||
public void reloadAll() {
|
||||
reloadRegion();
|
||||
reloadWarps();
|
||||
reloadLeaderboards();
|
||||
reloadSpawnpoints();
|
||||
reloadChests();
|
||||
|
||||
|
||||
verifyData();
|
||||
}
|
||||
|
||||
|
||||
public void reloadRegion() {
|
||||
p1 = parseLocation(coords, "p1", world);
|
||||
p2 = parseLocation(coords, "p2", world);
|
||||
//fixRegion();
|
||||
|
||||
|
||||
l1 = parseLocation(coords, "l1", world);
|
||||
l2 = parseLocation(coords, "l2", world);
|
||||
//fixLobbyRegion();
|
||||
}
|
||||
|
||||
|
||||
public void reloadWarps() {
|
||||
arenaWarp = parseLocation(coords, "arena", world);
|
||||
lobbyWarp = parseLocation(coords, "lobby", world);
|
||||
|
@ -89,7 +89,7 @@ public class ArenaRegion
|
|||
throw new ConfigError("Failed to parse exit warp for arena " + arena.configName() + " because: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void reloadLeaderboards() {
|
||||
// try-catch for backwards compatibility
|
||||
try {
|
||||
|
@ -101,7 +101,7 @@ public class ArenaRegion
|
|||
leaderboard.setWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void reloadSpawnpoints() {
|
||||
spawnpoints = new HashMap<>();
|
||||
Set<String> keys = spawns.getKeys(false);
|
||||
|
@ -111,7 +111,7 @@ public class ArenaRegion
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void reloadChests() {
|
||||
containers = new HashMap<>();
|
||||
Set<String> keys = chests.getKeys(false);
|
||||
|
@ -121,7 +121,7 @@ public class ArenaRegion
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void verifyData() {
|
||||
setup = (p1 != null &&
|
||||
p2 != null &&
|
||||
|
@ -129,15 +129,15 @@ public class ArenaRegion
|
|||
lobbyWarp != null &&
|
||||
specWarp != null &&
|
||||
!spawnpoints.isEmpty());
|
||||
|
||||
|
||||
lobbySetup = (l1 != null &&
|
||||
l2 != null);
|
||||
}
|
||||
|
||||
|
||||
public void checkData(MobArena plugin, CommandSender s, boolean ready, boolean region, boolean warps, boolean spawns) {
|
||||
// Verify data first
|
||||
verifyData();
|
||||
|
||||
|
||||
// Prepare the list
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
|
@ -150,7 +150,7 @@ public class ArenaRegion
|
|||
list.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Warps
|
||||
if (warps) {
|
||||
if (arenaWarp == null) list.add("arena");
|
||||
|
@ -161,82 +161,82 @@ public class ArenaRegion
|
|||
list.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Spawnpoints
|
||||
if (spawns) {
|
||||
if (spawnpoints.isEmpty()) {
|
||||
arena.getGlobalMessenger().tell(s, "Missing spawnpoints");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Ready?
|
||||
if (ready && setup) {
|
||||
arena.getGlobalMessenger().tell(s, "Arena is ready to be used!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isDefined() {
|
||||
return (p1 != null && p2 != null);
|
||||
}
|
||||
|
||||
|
||||
public boolean isLobbyDefined() {
|
||||
return (l1 != null && l2 != null);
|
||||
}
|
||||
|
||||
|
||||
public boolean isSetup() {
|
||||
return setup;
|
||||
}
|
||||
|
||||
|
||||
public boolean isLobbySetup() {
|
||||
return lobbySetup;
|
||||
}
|
||||
|
||||
|
||||
public boolean isWarp(Location l) {
|
||||
return (l.equals(arenaWarp) ||
|
||||
l.equals(lobbyWarp) ||
|
||||
l.equals(specWarp) ||
|
||||
l.equals(exitWarp));
|
||||
}
|
||||
|
||||
|
||||
public boolean contains(Location l) {
|
||||
if (!l.getWorld().getName().equals(world.getName()) || !isDefined()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int x = l.getBlockX();
|
||||
int y = l.getBlockY();
|
||||
int z = l.getBlockZ();
|
||||
|
||||
|
||||
// Check the lobby first.
|
||||
if (lobbySetup) {
|
||||
if ((x >= l1.getBlockX() && x <= l2.getBlockX()) &&
|
||||
(z >= l1.getBlockZ() && z <= l2.getBlockZ()) &&
|
||||
if ((x >= l1.getBlockX() && x <= l2.getBlockX()) &&
|
||||
(z >= l1.getBlockZ() && z <= l2.getBlockZ()) &&
|
||||
(y >= l1.getBlockY() && y <= l2.getBlockY()))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Returns false if the location is outside of the region.
|
||||
return ((x >= p1.getBlockX() && x <= p2.getBlockX()) &&
|
||||
(z >= p1.getBlockZ() && z <= p2.getBlockZ()) &&
|
||||
return ((x >= p1.getBlockX() && x <= p2.getBlockX()) &&
|
||||
(z >= p1.getBlockZ() && z <= p2.getBlockZ()) &&
|
||||
(y >= p1.getBlockY() && y <= p2.getBlockY()));
|
||||
}
|
||||
|
||||
|
||||
public boolean contains(Location l, int radius) {
|
||||
if (!l.getWorld().getName().equals(world.getName()) || !isDefined()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int x = l.getBlockX();
|
||||
int y = l.getBlockY();
|
||||
int z = l.getBlockZ();
|
||||
|
||||
|
||||
if (lobbySetup) {
|
||||
if ((x + radius >= l1.getBlockX() && x - radius <= l2.getBlockX()) &&
|
||||
(z + radius >= l1.getBlockZ() && z - radius <= l2.getBlockZ()) &&
|
||||
if ((x + radius >= l1.getBlockX() && x - radius <= l2.getBlockX()) &&
|
||||
(z + radius >= l1.getBlockZ() && z - radius <= l2.getBlockZ()) &&
|
||||
(y + radius >= l1.getBlockY() && y - radius <= l2.getBlockY()))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return ((x + radius >= p1.getBlockX() && x - radius <= p2.getBlockX()) &&
|
||||
(z + radius >= p1.getBlockZ() && z - radius <= p2.getBlockZ()) &&
|
||||
(y + radius >= p1.getBlockY() && y - radius <= p2.getBlockY()));
|
||||
|
@ -263,33 +263,33 @@ public class ArenaRegion
|
|||
int z = p2.getBlockZ();
|
||||
setSaveReload(coords, "p2", p2.getWorld(), x ,y ,z);
|
||||
}
|
||||
|
||||
|
||||
public void expandDown(int amount) {
|
||||
int x = p1.getBlockX();
|
||||
int y = Math.max(0, p1.getBlockY() - amount);
|
||||
int z = p1.getBlockZ();
|
||||
setSaveReload(coords, "p1", p1.getWorld(), x ,y ,z);
|
||||
}
|
||||
|
||||
|
||||
public void expandP1(int dx, int dz) {
|
||||
int x = p1.getBlockX() - dx;
|
||||
int y = p1.getBlockY();
|
||||
int z = p1.getBlockZ() - dz;
|
||||
setSaveReload(coords, "p1", p1.getWorld(), x ,y ,z);
|
||||
}
|
||||
|
||||
|
||||
public void expandP2(int dx, int dz) {
|
||||
int x = p2.getBlockX() + dx;
|
||||
int y = p2.getBlockY();
|
||||
int z = p2.getBlockZ() + dz;
|
||||
setSaveReload(coords, "p2", p2.getWorld(), x ,y ,z);
|
||||
}
|
||||
|
||||
|
||||
public void expandOut(int amount) {
|
||||
expandP1(amount, amount);
|
||||
expandP2(amount, amount);
|
||||
}
|
||||
|
||||
|
||||
// Lobby expand
|
||||
public void expandLobbyUp(int amount) {
|
||||
int x = l2.getBlockX();
|
||||
|
@ -297,28 +297,28 @@ public class ArenaRegion
|
|||
int z = l2.getBlockZ();
|
||||
setSaveReload(coords, "l2", l2.getWorld(), x ,y ,z);
|
||||
}
|
||||
|
||||
|
||||
public void expandLobbyDown(int amount) {
|
||||
int x = l1.getBlockX();
|
||||
int y = Math.max(0, l1.getBlockY() - amount);
|
||||
int z = l1.getBlockZ();
|
||||
setSaveReload(coords, "l1", l1.getWorld(), x ,y ,z);
|
||||
}
|
||||
|
||||
|
||||
public void expandL1(int dx, int dz) {
|
||||
int x = l1.getBlockX() - dx;
|
||||
int y = l1.getBlockY();
|
||||
int z = l1.getBlockZ() - dz;
|
||||
setSaveReload(coords, "l1", l1.getWorld(), x ,y ,z);
|
||||
}
|
||||
|
||||
|
||||
public void expandL2(int dx, int dz) {
|
||||
int x = l2.getBlockX() + dx;
|
||||
int y = l2.getBlockY();
|
||||
int z = l2.getBlockZ() + dz;
|
||||
setSaveReload(coords, "l2", l2.getWorld(), x ,y ,z);
|
||||
}
|
||||
|
||||
|
||||
public void expandLobbyOut(int amount) {
|
||||
expandL1(amount, amount);
|
||||
expandL2(amount, amount);
|
||||
|
@ -330,19 +330,19 @@ public class ArenaRegion
|
|||
save();
|
||||
reloadRegion();
|
||||
}
|
||||
|
||||
|
||||
public void fixRegion() {
|
||||
fix("p1", "p2");
|
||||
}
|
||||
|
||||
|
||||
public void fixLobbyRegion() {
|
||||
fix("l1", "l2");
|
||||
}
|
||||
|
||||
|
||||
private void fix(String location1, String location2) {
|
||||
Location loc1 = parseLocation(coords, location1, world);
|
||||
Location loc2 = parseLocation(coords, location2, world);
|
||||
|
||||
|
||||
if (loc1 == null || loc2 == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -355,21 +355,21 @@ public class ArenaRegion
|
|||
loc2.setX(tmp);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
|
||||
if (loc1.getZ() > loc2.getZ()) {
|
||||
double tmp = loc1.getZ();
|
||||
loc1.setZ(loc2.getZ());
|
||||
loc2.setZ(tmp);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
|
||||
if (loc1.getY() > loc2.getY()) {
|
||||
double tmp = loc1.getY();
|
||||
loc1.setY(loc2.getY());
|
||||
loc2.setY(tmp);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
|
||||
if (!arena.getWorld().getName().equals(world.getName())) {
|
||||
arena.setWorld(world);
|
||||
modified = true;
|
||||
|
@ -378,39 +378,39 @@ public class ArenaRegion
|
|||
if (!modified) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
setLocation(coords, location1, loc1);
|
||||
setLocation(coords, location2, loc2);
|
||||
save();
|
||||
}
|
||||
|
||||
|
||||
public List<Chunk> getChunks() {
|
||||
List<Chunk> result = new ArrayList<>();
|
||||
|
||||
|
||||
if (p1 == null || p2 == null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Chunk c1 = world.getChunkAt(p1);
|
||||
Chunk c2 = world.getChunkAt(p2);
|
||||
|
||||
|
||||
for (int i = c1.getX(); i <= c2.getX(); i++) {
|
||||
for (int j = c1.getZ(); j <= c2.getZ(); j++) {
|
||||
result.add(world.getChunkAt(i,j));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public Location getArenaWarp() {
|
||||
return arenaWarp;
|
||||
}
|
||||
|
||||
|
||||
public Location getLobbyWarp() {
|
||||
return lobbyWarp;
|
||||
}
|
||||
|
||||
|
||||
public Location getSpecWarp() {
|
||||
return specWarp;
|
||||
}
|
||||
|
@ -418,27 +418,27 @@ public class ArenaRegion
|
|||
public Location getExitWarp() {
|
||||
return exitWarp;
|
||||
}
|
||||
|
||||
|
||||
public Location getSpawnpoint(String name) {
|
||||
return spawnpoints.get(name);
|
||||
}
|
||||
|
||||
|
||||
public Collection<Location> getSpawnpoints() {
|
||||
return spawnpoints.values();
|
||||
}
|
||||
|
||||
|
||||
public List<Location> getSpawnpointList() {
|
||||
return new ArrayList<>(spawnpoints.values());
|
||||
}
|
||||
|
||||
|
||||
public Collection<Location> getContainers() {
|
||||
return containers.values();
|
||||
}
|
||||
|
||||
|
||||
public Location getLeaderboard() {
|
||||
return leaderboard;
|
||||
}
|
||||
|
||||
|
||||
public void set(RegionPoint point, Location loc) {
|
||||
// Act based on the point
|
||||
switch (point) {
|
||||
|
@ -452,10 +452,10 @@ public class ArenaRegion
|
|||
case SPECTATOR: setWarp(point, loc); return;
|
||||
case LEADERBOARD: setLeaderboard(loc); return;
|
||||
}
|
||||
|
||||
|
||||
throw new IllegalArgumentException("Invalid region point!");
|
||||
}
|
||||
|
||||
|
||||
private void setPoint(RegionPoint point, Location l) {
|
||||
// Lower and upper locations
|
||||
RegionPoint r1, r2;
|
||||
|
@ -468,7 +468,7 @@ public class ArenaRegion
|
|||
* location for the given point. These location references are only
|
||||
* ever overwritten when using the set commands, and remain fully
|
||||
* decoupled from the 'fixed' points.
|
||||
*
|
||||
*
|
||||
* Effectively, the config-file and region store 'fixed' locations
|
||||
* that allow fast membership tests, but the region also stores the
|
||||
* 'unfixed' locations for a more intuitive setup process.
|
||||
|
@ -502,7 +502,7 @@ public class ArenaRegion
|
|||
lower = upper = null;
|
||||
r1 = r2 = null;
|
||||
}
|
||||
|
||||
|
||||
// Min-max if both locations are non-null
|
||||
if (lower != null && upper != null) {
|
||||
double tmp;
|
||||
|
@ -522,98 +522,98 @@ public class ArenaRegion
|
|||
upper.setZ(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set the coords and save
|
||||
if (lower != null) setLocation(coords, r1.name().toLowerCase(), lower);
|
||||
if (upper != null) setLocation(coords, r2.name().toLowerCase(), upper);
|
||||
save();
|
||||
|
||||
|
||||
// Reload regions and verify data
|
||||
reloadRegion();
|
||||
verifyData();
|
||||
}
|
||||
|
||||
|
||||
public void set(String point, Location loc) {
|
||||
// Get the region point enum
|
||||
RegionPoint rp = Enums.getEnumFromString(RegionPoint.class, point);
|
||||
if (rp == null) throw new IllegalArgumentException("Invalid region point '" + point + "'");
|
||||
|
||||
|
||||
// Then delegate
|
||||
set(rp, loc);
|
||||
}
|
||||
|
||||
|
||||
public void setWarp(RegionPoint point, Location l) {
|
||||
// Set the point and save
|
||||
setLocation(coords, point.toString(), l);
|
||||
save();
|
||||
|
||||
|
||||
// Then reload warps
|
||||
reloadWarps();
|
||||
}
|
||||
|
||||
|
||||
public void setLeaderboard(Location l) {
|
||||
// Set the point and save
|
||||
setLocation(coords, "leaderboard", l);
|
||||
save();
|
||||
|
||||
|
||||
// Then reload the leaderboards
|
||||
reloadLeaderboards();
|
||||
}
|
||||
|
||||
|
||||
public void addSpawn(String name, Location loc) {
|
||||
// Add the spawn and save
|
||||
setLocation(spawns, name, loc);
|
||||
save();
|
||||
|
||||
|
||||
// Reload spawnpoints and verify data
|
||||
reloadSpawnpoints();
|
||||
verifyData();
|
||||
}
|
||||
|
||||
|
||||
public boolean removeSpawn(String name) {
|
||||
// Check if the spawnpoint exists
|
||||
if (spawns.getString(name) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Null the spawnpoint and save
|
||||
setLocation(spawns, name, null);
|
||||
save();
|
||||
|
||||
|
||||
// Reload spawnpoints and verify data
|
||||
reloadSpawnpoints();
|
||||
verifyData();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void addChest(String name, Location loc) {
|
||||
// Add the chest location and save
|
||||
setLocation(chests, name, loc);
|
||||
save();
|
||||
|
||||
|
||||
// Reload the chests
|
||||
reloadChests();
|
||||
}
|
||||
|
||||
|
||||
public boolean removeChest(String name) {
|
||||
// Check if the chest exists
|
||||
if (chests.getString(name) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Null the chest and save
|
||||
setLocation(chests, name, null);
|
||||
save();
|
||||
|
||||
|
||||
// Reload the chests
|
||||
reloadChests();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void save() {
|
||||
arena.getPlugin().saveConfig();
|
||||
}
|
||||
|
||||
|
||||
public void showRegion(Player p) {
|
||||
if (!isDefined()) {
|
||||
return;
|
||||
|
|
|
@ -10,10 +10,10 @@ public interface Repairable
|
|||
void repair();
|
||||
|
||||
BlockState getState();
|
||||
|
||||
|
||||
Material getType();
|
||||
BlockData getData();
|
||||
|
||||
|
||||
World getWorld();
|
||||
int getX();
|
||||
int getY();
|
||||
|
|
|
@ -9,21 +9,21 @@ import org.bukkit.material.Attachable;
|
|||
public class RepairableAttachable extends RepairableBlock
|
||||
{
|
||||
private int x, y, z;
|
||||
|
||||
|
||||
public RepairableAttachable(BlockState state)
|
||||
{
|
||||
super(state);
|
||||
|
||||
|
||||
BlockState attached;
|
||||
if (state.getData() instanceof Attachable)
|
||||
attached = state.getBlock().getRelative(((Attachable) state.getData()).getAttachedFace()).getState();
|
||||
else
|
||||
attached = state.getBlock().getRelative(BlockFace.DOWN).getState();
|
||||
|
||||
|
||||
x = attached.getX();
|
||||
y = attached.getY();
|
||||
z = attached.getZ();
|
||||
|
||||
|
||||
state.getBlock().setType(Material.STONE);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class RepairableAttachable extends RepairableBlock
|
|||
Block b = getWorld().getBlockAt(x,y,z);
|
||||
if (b.getType() == Material.AIR)
|
||||
b.setType(Material.STONE);
|
||||
|
||||
|
||||
super.repair();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,18 +6,18 @@ import org.bukkit.material.Bed;
|
|||
public class RepairableBed extends RepairableBlock
|
||||
{
|
||||
private BlockState other;
|
||||
|
||||
|
||||
public RepairableBed(BlockState state)
|
||||
{
|
||||
super(state);
|
||||
super(state);
|
||||
other = state.getBlock().getRelative(((Bed) state.getData()).getFacing()).getState();
|
||||
}
|
||||
|
||||
|
||||
public void repair()
|
||||
{
|
||||
if (getWorld().getBlockAt(getX(), getY(), getZ()).getState().getData() instanceof Bed)
|
||||
return;
|
||||
|
||||
|
||||
super.repair();
|
||||
other.getBlock().setBlockData(other.getBlockData());
|
||||
}
|
||||
|
|
|
@ -12,21 +12,21 @@ public class RepairableBlock implements Repairable
|
|||
private BlockData data;
|
||||
private int x, y, z;
|
||||
private Material type;
|
||||
|
||||
|
||||
public RepairableBlock(BlockState state)
|
||||
{
|
||||
this.state = state;
|
||||
|
||||
|
||||
world = state.getWorld();
|
||||
|
||||
|
||||
x = state.getX();
|
||||
y = state.getY();
|
||||
z = state.getZ();
|
||||
|
||||
|
||||
data = state.getBlockData();
|
||||
type = state.getType();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Repairs the block by setting the type and data
|
||||
*/
|
||||
|
@ -39,32 +39,32 @@ public class RepairableBlock implements Repairable
|
|||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
public World getWorld()
|
||||
{
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
public Material getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
public BlockData getData()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
public int getY()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return z;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.bukkit.block.data.type.RedstoneWire;
|
|||
import java.util.Comparator;
|
||||
|
||||
public class RepairableComparator implements Comparator<Repairable>
|
||||
{
|
||||
{
|
||||
public int compare(Repairable r1, Repairable r2)
|
||||
{
|
||||
if (restoreLast(r1))
|
||||
|
@ -21,15 +21,15 @@ public class RepairableComparator implements Comparator<Repairable>
|
|||
}
|
||||
else if (restoreLast(r2))
|
||||
return -1;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
private boolean restoreLast(Repairable r)
|
||||
{
|
||||
Material t = r.getType();
|
||||
BlockData data = r.getData();
|
||||
|
||||
|
||||
return (data instanceof Attachable || data instanceof RedstoneWire || data instanceof Door || data instanceof Bed || t == Material.LAVA || t == Material.WATER || t == Material.FIRE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
|
|||
public class RepairableContainer extends RepairableBlock
|
||||
{
|
||||
private ItemStack[] contents;
|
||||
|
||||
|
||||
public RepairableContainer(BlockState state, boolean clear) {
|
||||
super(state);
|
||||
|
||||
|
@ -21,21 +21,21 @@ public class RepairableContainer extends RepairableBlock
|
|||
for (int i = 0; i < contents.length; i++) {
|
||||
contents[i] = (stacks[i] != null) ? stacks[i].clone() : null;
|
||||
}
|
||||
|
||||
|
||||
// Clear the inventory if prompted
|
||||
if (clear) inv.clear();
|
||||
}
|
||||
|
||||
|
||||
public RepairableContainer(BlockState state) {
|
||||
this(state, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Repairs the container block by adding all the contents back in.
|
||||
*/
|
||||
public void repair() {
|
||||
super.repair();
|
||||
|
||||
|
||||
// Grab the inventory
|
||||
InventoryHolder cb = (InventoryHolder) getWorld().getBlockAt(getX(),getY(),getZ()).getState();
|
||||
Inventory chestInv = cb.getInventory();
|
||||
|
|
|
@ -10,18 +10,18 @@ public class RepairableDoor extends RepairableAttachable//RepairableBlock
|
|||
{
|
||||
private BlockState other;
|
||||
private int x, y, z;
|
||||
|
||||
|
||||
public RepairableDoor(BlockState state)
|
||||
{
|
||||
super(state);
|
||||
super(state);
|
||||
other = state.getBlock().getRelative(BlockFace.UP).getState();
|
||||
|
||||
|
||||
BlockState attached = state.getBlock().getRelative(BlockFace.DOWN).getState();
|
||||
x = attached.getX();
|
||||
y = attached.getY();
|
||||
z = attached.getZ();
|
||||
}
|
||||
|
||||
|
||||
public void repair()
|
||||
{
|
||||
if (getWorld().getBlockAt(getX(), getY(), getZ()).getState().getData() instanceof Door)
|
||||
|
@ -30,7 +30,7 @@ public class RepairableDoor extends RepairableAttachable//RepairableBlock
|
|||
Block b = getWorld().getBlockAt(x,y,z);
|
||||
if (b.getType() == Material.AIR)
|
||||
b.setType(Material.STONE);
|
||||
|
||||
|
||||
super.repair();
|
||||
other.getBlock().setBlockData(other.getBlockData());
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ import org.bukkit.block.Sign;
|
|||
public class RepairableSign extends RepairableAttachable
|
||||
{
|
||||
private String[] lines = new String[4];
|
||||
|
||||
|
||||
public RepairableSign(BlockState state)
|
||||
{
|
||||
super(state);
|
||||
|
||||
|
||||
Sign s = (Sign) state;
|
||||
lines = s.getLines();
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class RepairableSign extends RepairableAttachable
|
|||
public void repair()
|
||||
{
|
||||
super.repair();
|
||||
|
||||
|
||||
Sign s = (Sign) getWorld().getBlockAt(getX(),getY(),getZ()).getState();
|
||||
s.setLine(0, lines[0]);
|
||||
s.setLine(1, lines[1]);
|
||||
|
|
|
@ -14,14 +14,14 @@ public enum Time
|
|||
DUSK(13300),
|
||||
NIGHT(14000),
|
||||
MIDNIGHT(18000);
|
||||
|
||||
|
||||
private int time;
|
||||
|
||||
|
||||
Time(int time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class EntityPosition implements Serializable{
|
|||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
|
||||
public EntityPosition(Location location) {
|
||||
this.x = location.getX();
|
||||
this.y = location.getY();
|
||||
|
@ -35,7 +35,7 @@ public class EntityPosition implements Serializable{
|
|||
this.yaw = location.getYaw();
|
||||
this.pitch = location.getPitch();
|
||||
}
|
||||
|
||||
|
||||
public Location getLocation(World world) {
|
||||
return new Location(world, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
@ -87,4 +87,4 @@ public class EntityPosition implements Serializable{
|
|||
public void setZ(double z) {
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class Enums
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the enum value of a string, null if it doesn't exist.
|
||||
*/
|
||||
|
|
|
@ -20,20 +20,20 @@ public class ItemParser
|
|||
if (s == null) {
|
||||
return new ArrayList<>(1);
|
||||
}
|
||||
|
||||
|
||||
String[] items = s.split(",");
|
||||
List<ItemStack> result = new ArrayList<>(items.length);
|
||||
|
||||
|
||||
for (String item : items) {
|
||||
ItemStack stack = parseItem(item.trim());
|
||||
if (stack != null) {
|
||||
result.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack parseItem(String item) {
|
||||
return parseItem(item, true);
|
||||
}
|
||||
|
@ -41,13 +41,13 @@ public class ItemParser
|
|||
public static ItemStack parseItem(String item, boolean logFailure) {
|
||||
if (item == null || item.equals(""))
|
||||
return null;
|
||||
|
||||
|
||||
// Check if the item has enchantments.
|
||||
String[] space = item.split(" ");
|
||||
String[] parts = (space.length == 2 ? space[0].split(":") : item.split(":"));
|
||||
|
||||
|
||||
ItemStack result = null;
|
||||
|
||||
|
||||
switch (parts.length) {
|
||||
case 1:
|
||||
result = singleItem(parts[0]);
|
||||
|
@ -72,19 +72,19 @@ public class ItemParser
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static ItemStack singleItem(String item) {
|
||||
return getType(item)
|
||||
.map(ItemStack::new)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
|
||||
private static ItemStack withAmount(String item, String amount) {
|
||||
return getType(item)
|
||||
.map(type -> new ItemStack(type, getAmount(amount)))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
|
||||
private static ItemStack withDataAndAmount(String item, String data, String amount) {
|
||||
ItemStack stack = withAmount(item, amount);
|
||||
if (stack == null) {
|
||||
|
@ -98,7 +98,7 @@ public class ItemParser
|
|||
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
private static ItemStack withPotionMeta(ItemStack stack, String data) {
|
||||
PotionType type;
|
||||
boolean extended = false;
|
||||
|
@ -127,23 +127,23 @@ public class ItemParser
|
|||
private static Optional<Material> getType(String item) {
|
||||
return Optional.ofNullable(Material.getMaterial(item.toUpperCase()));
|
||||
}
|
||||
|
||||
|
||||
private static int getAmount(String amount) {
|
||||
if (amount.matches("(-)?[1-9][0-9]*")) {
|
||||
return Integer.parseInt(amount);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
private static void addEnchantments(ItemStack stack, String list) {
|
||||
String[] parts = list.split(";");
|
||||
|
||||
|
||||
for (String ench : parts) {
|
||||
addEnchantment(stack, ench.trim());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void addEnchantment(ItemStack stack, String ench) {
|
||||
String[] parts = ench.split(":");
|
||||
if (parts.length != 2) {
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.garbagemule.MobArena.util;
|
|||
public class MutableInt
|
||||
{
|
||||
private int value;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new MutableInt with the given value.
|
||||
* @param value the initial value of the MutableInt
|
||||
|
@ -11,14 +11,14 @@ public class MutableInt
|
|||
public MutableInt(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new MutableInt with value 0.
|
||||
*/
|
||||
public MutableInt() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add the given amount to the internal int value.
|
||||
* @param amount the amount to add
|
||||
|
@ -26,7 +26,7 @@ public class MutableInt
|
|||
public void add(double amount) {
|
||||
this.value += amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Subtract the given amount from the internal int value.
|
||||
* @param amount the amount to subtract
|
||||
|
@ -34,7 +34,7 @@ public class MutableInt
|
|||
public void sub(int amount) {
|
||||
this.value -= amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increment the value and return it.
|
||||
* This is essentially the same as calling add(1), followed by value().
|
||||
|
@ -43,7 +43,7 @@ public class MutableInt
|
|||
public int inc() {
|
||||
return ++this.value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decrement the value and return it.
|
||||
* This is essentially the same as calling sub(1), followed by value().
|
||||
|
@ -52,7 +52,7 @@ public class MutableInt
|
|||
public int dec() {
|
||||
return --this.value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The value of the MutableInt.
|
||||
* @return the current value
|
||||
|
@ -60,7 +60,7 @@ public class MutableInt
|
|||
public int value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "" + value;
|
||||
|
|
|
@ -12,11 +12,11 @@ public class PotionEffectParser
|
|||
private static final int TICKS_PER_SECOND = 20;
|
||||
private static final int DEFAULT_POTION_AMPLIFIER = 0;
|
||||
private static final int DEFAULT_POTION_DURATION = Integer.MAX_VALUE;
|
||||
|
||||
|
||||
public static List<PotionEffect> parsePotionEffects(String s) {
|
||||
if (s == null || s.isEmpty())
|
||||
return null;
|
||||
|
||||
|
||||
List<PotionEffect> potions = new ArrayList<>();
|
||||
for (String potion : s.split(",")) {
|
||||
PotionEffect eff = parsePotionEffect(potion.trim());
|
||||
|
@ -24,21 +24,21 @@ public class PotionEffectParser
|
|||
potions.add(eff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return potions;
|
||||
}
|
||||
|
||||
|
||||
public static PotionEffect parsePotionEffect(String p) {
|
||||
return parsePotionEffect(p, true);
|
||||
}
|
||||
|
||||
|
||||
public static PotionEffect parsePotionEffect(String p, boolean logFailure) {
|
||||
if (p == null || p.isEmpty())
|
||||
return null;
|
||||
|
||||
|
||||
String[] parts = p.split(":");
|
||||
PotionEffect result = null;
|
||||
|
||||
|
||||
switch (parts.length) {
|
||||
case 1:
|
||||
result = parseSingle(parts[0]);
|
||||
|
@ -50,67 +50,67 @@ public class PotionEffectParser
|
|||
result = withAmplifierAndDuration(parts[0], parts[1], parts[2]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (result == null) {
|
||||
if (logFailure) {
|
||||
Bukkit.getLogger().warning("[MobArena] Failed to parse potion effect: " + p);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static PotionEffect parseSingle(String type) {
|
||||
PotionEffectType effect = PotionEffectType.getByName(type);
|
||||
|
||||
|
||||
if (effect == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new PotionEffect(effect, DEFAULT_POTION_DURATION, DEFAULT_POTION_AMPLIFIER);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static PotionEffect withAmplifier(String type, String amplifier) {
|
||||
PotionEffectType effect = PotionEffectType.getByName(type);
|
||||
int amp = getAmplification(amplifier);
|
||||
|
||||
|
||||
if (effect == null || amp == -1) {
|
||||
return null;
|
||||
} else {
|
||||
return new PotionEffect(effect, DEFAULT_POTION_DURATION, amp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static PotionEffect withAmplifierAndDuration(String type, String amplifier, String duration) {
|
||||
PotionEffectType effect = PotionEffectType.getByName(type);
|
||||
int amp = getAmplification(amplifier);
|
||||
int dur = getDuration(duration);
|
||||
|
||||
|
||||
if (effect == null || dur == -1 || amp == -1) {
|
||||
return null;
|
||||
} else {
|
||||
return new PotionEffect(effect, dur * TICKS_PER_SECOND, amp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static int getDuration(String duration) {
|
||||
int dur = -1;
|
||||
|
||||
|
||||
if (duration.matches("[0-9]+")) {
|
||||
dur = Integer.parseInt(duration);
|
||||
}
|
||||
|
||||
|
||||
return dur;
|
||||
}
|
||||
|
||||
|
||||
private static int getAmplification(String amplifier) {
|
||||
int amp = -1;
|
||||
|
||||
|
||||
if (amplifier.matches("[0-9]+")) {
|
||||
amp = Integer.parseInt(amplifier);
|
||||
}
|
||||
|
||||
|
||||
return amp;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class TextUtils
|
|||
public static String padLeft(String s, int length) { return padLeft(s, length, ' '); }
|
||||
public static String padLeft(int s, int length) { return padLeft(Integer.toString(s), length, ' '); }
|
||||
public static String padLeft(double s, int length) { return padLeft(Double.toString(s), length, ' '); }
|
||||
|
||||
|
||||
/**
|
||||
* Truncate the input string to be at most the input length
|
||||
* @param s The string to truncate
|
||||
|
@ -58,32 +58,32 @@ public class TextUtils
|
|||
return s.substring(0, length);
|
||||
}
|
||||
public static String truncate(String s) { return truncate(s, 15); }
|
||||
|
||||
|
||||
public static String camelCase(String s) {
|
||||
if (s == null || s.length() < 2)
|
||||
return null;
|
||||
|
||||
|
||||
String firstLetter = s.substring(0,1).toUpperCase();
|
||||
return firstLetter + s.substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
public static String playerListToString(Collection<? extends Player> list) {
|
||||
if (list.isEmpty()) {
|
||||
return Msg.MISC_NONE.toString();
|
||||
}
|
||||
|
||||
|
||||
StringBuffer buffy = new StringBuffer();
|
||||
for (Player p : list) {
|
||||
buffy.append(", " + p.getName());
|
||||
}
|
||||
return buffy.substring(2);
|
||||
}
|
||||
|
||||
|
||||
public static String listToString(Collection<? extends Object> list) {
|
||||
if (list.isEmpty()) {
|
||||
return Msg.MISC_NONE.toString();
|
||||
}
|
||||
|
||||
|
||||
StringBuffer buffy = new StringBuffer();
|
||||
for (Object o : list) {
|
||||
buffy.append(", " + o.toString());
|
||||
|
|
|
@ -17,22 +17,22 @@ public class TimeUtils
|
|||
long mins = total % 3600 / 60;
|
||||
long hours = total / 3600 % 24;
|
||||
long days = total / 3600 / 24;
|
||||
String time = (days > 0 ? days + ":" : "") +
|
||||
String time = (days > 0 ? days + ":" : "") +
|
||||
(hours < 10 ? "0" + hours : hours) + ":" +
|
||||
(mins < 10 ? "0" + mins : mins) + ":" +
|
||||
(secs < 10 ? "0" + secs : secs);
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Makes a new java.util.Date with the input long and toString()s it.
|
||||
* Makes a new java.util.Date with the input long and toString()s it.
|
||||
* @param ms time in milliseconds
|
||||
* @return java.util.Date toString() of the input long
|
||||
*/
|
||||
public static String toDateTime(long ms) {
|
||||
return new Date(ms).toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds two string-representations of time and returns the resulting time.
|
||||
* @param t1 a time-string
|
||||
|
@ -42,7 +42,7 @@ public class TimeUtils
|
|||
public static String addTimes(String t1, String t2) {
|
||||
String[] parts1 = t1.split(":");
|
||||
String[] parts2 = t2.split(":");
|
||||
|
||||
|
||||
long secs1 = extractSeconds(parts1);
|
||||
long secs2 = extractSeconds(parts2);
|
||||
|
||||
|
@ -54,12 +54,12 @@ public class TimeUtils
|
|||
|
||||
long days1 = extractDays(parts1);
|
||||
long days2 = extractDays(parts2);
|
||||
|
||||
|
||||
long time = (secs1 + secs2 + mins1 + mins2 + hours1 + hours2 + days1 + days2) * 1000;
|
||||
|
||||
|
||||
return toTime(time);
|
||||
}
|
||||
|
||||
|
||||
private static long extractSeconds(String[] parts) {
|
||||
int length = parts.length;
|
||||
if (length < 1) {
|
||||
|
@ -67,7 +67,7 @@ public class TimeUtils
|
|||
}
|
||||
return Long.parseLong(parts[length - 1]);
|
||||
}
|
||||
|
||||
|
||||
private static long extractMinutes(String[] parts) {
|
||||
int length = parts.length;
|
||||
if (length < 2) {
|
||||
|
@ -75,7 +75,7 @@ public class TimeUtils
|
|||
}
|
||||
return Long.parseLong(parts[length - 2]) * 60;
|
||||
}
|
||||
|
||||
|
||||
private static long extractHours(String[] parts) {
|
||||
int length = parts.length;
|
||||
if (length < 3) {
|
||||
|
@ -83,7 +83,7 @@ public class TimeUtils
|
|||
}
|
||||
return Long.parseLong(parts[length - 3]) * 3600;
|
||||
}
|
||||
|
||||
|
||||
private static long extractDays(String[] parts) {
|
||||
int length = parts.length;
|
||||
if (length < 4) {
|
||||
|
|
|
@ -17,15 +17,15 @@ import java.util.logging.Level;
|
|||
public class InventoryManager
|
||||
{
|
||||
private Map<Player, ItemStack[]> inventories;
|
||||
|
||||
|
||||
public InventoryManager() {
|
||||
this.inventories = new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
public void put(Player p, ItemStack[] contents) {
|
||||
inventories.put(p, contents);
|
||||
}
|
||||
|
||||
|
||||
public void equip(Player p) {
|
||||
ItemStack[] contents = inventories.get(p);
|
||||
if (contents == null) {
|
||||
|
@ -37,7 +37,7 @@ public class InventoryManager
|
|||
public void remove(Player p) {
|
||||
inventories.remove(p);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear a player's inventory completely.
|
||||
* @param p a player
|
||||
|
@ -59,11 +59,11 @@ public class InventoryManager
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean hasEmptyInventory(Player p) {
|
||||
ItemStack[] inventory = p.getInventory().getContents();
|
||||
ItemStack[] armor = p.getInventory().getArmorContents();
|
||||
|
||||
|
||||
// Check for null or id 0, or AIR
|
||||
for (ItemStack stack : inventory) {
|
||||
if (stack != null && stack.getType() != Material.AIR)
|
||||
|
@ -74,10 +74,10 @@ public class InventoryManager
|
|||
if (stack != null && stack.getType() != Material.AIR)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static boolean restoreFromFile(MobArena plugin, Player p) {
|
||||
try {
|
||||
File inventories = new File(plugin.getDataFolder(), "inventories");
|
||||
|
@ -89,10 +89,10 @@ public class InventoryManager
|
|||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
config.load(file);
|
||||
|
||||
|
||||
ItemStack[] contents = config.getList("contents").toArray(new ItemStack[0]);
|
||||
p.getInventory().setContents(contents);
|
||||
|
||||
|
||||
file.delete();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -13,17 +13,17 @@ import java.util.Map;
|
|||
public abstract class AbstractWave implements Wave
|
||||
{
|
||||
private String name;
|
||||
|
||||
|
||||
private WaveBranch branch; // recurrent, single
|
||||
private WaveType type; // default, special, swarm, boss
|
||||
|
||||
|
||||
private double healthMultiplier, amountMultiplier;
|
||||
|
||||
|
||||
private int firstWave, frequency, priority;
|
||||
|
||||
|
||||
private List<Location> spawnpoints;
|
||||
private List<PotionEffect> effects;
|
||||
|
||||
|
||||
public AbstractWave() {
|
||||
this.effects = new ArrayList<>();
|
||||
}
|
||||
|
@ -39,12 +39,12 @@ public abstract class AbstractWave implements Wave
|
|||
protected List<Location> getSpawnpoints() {
|
||||
return spawnpoints;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSpawnpoints(List<Location> spawnpoints) {
|
||||
this.spawnpoints = spawnpoints;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<PotionEffect> getEffects() {
|
||||
return effects;
|
||||
|
@ -64,7 +64,7 @@ public abstract class AbstractWave implements Wave
|
|||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
|
@ -84,7 +84,7 @@ public abstract class AbstractWave implements Wave
|
|||
public WaveType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setType(WaveType type) {
|
||||
this.type = type;
|
||||
|
@ -124,7 +124,7 @@ public abstract class AbstractWave implements Wave
|
|||
public double getHealthMultiplier() {
|
||||
return healthMultiplier;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setHealthMultiplier(double healthMultiplier) {
|
||||
this.healthMultiplier = healthMultiplier;
|
||||
|
@ -134,7 +134,7 @@ public abstract class AbstractWave implements Wave
|
|||
public double getAmountMultiplier() {
|
||||
return amountMultiplier;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAmountMultiplier(double amountMultiplier) {
|
||||
this.amountMultiplier = amountMultiplier;
|
||||
|
|
|
@ -13,26 +13,26 @@ public class BossAbilityThread implements Runnable
|
|||
private List<Ability> abilities;
|
||||
private Arena arena;
|
||||
private int counter;
|
||||
|
||||
|
||||
public BossAbilityThread(BossWave wave, List<Ability> abilities, Arena arena) {
|
||||
this.wave = wave;
|
||||
this.abilities = abilities;
|
||||
this.arena = arena;
|
||||
this.counter = 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// If we have no abilities, we can't execute any, so just quit.
|
||||
if (abilities.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// If the arena isn't running or has no players, quit.
|
||||
if (!arena.isRunning() || arena.getPlayersInArena().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// If all bosses are dead, quit.
|
||||
Set<MABoss> bosses = wave.getMABosses();
|
||||
if (bosses.isEmpty()) {
|
||||
|
@ -41,16 +41,16 @@ public class BossAbilityThread implements Runnable
|
|||
for (MABoss boss : bosses) {
|
||||
if (boss.isDead()) return;
|
||||
}
|
||||
|
||||
|
||||
// Get the next ability in the list.
|
||||
Ability ability = abilities.get(counter++ % abilities.size());
|
||||
|
||||
|
||||
// And make each boss in this boss wave use it!
|
||||
for (MABoss boss : bosses) {
|
||||
wave.announceAbility(ability, boss, arena);
|
||||
ability.execute(arena, boss);
|
||||
}
|
||||
|
||||
|
||||
// Schedule for another run!
|
||||
arena.scheduleTask(this, wave.getAbilityInterval());
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class MABoss
|
|||
private Thing reward;
|
||||
private List<ItemStack> drops;
|
||||
private HealthBar healthbar;
|
||||
|
||||
|
||||
/**
|
||||
* Create an MABoss from the given entity with the given max health.
|
||||
* @param entity an entity
|
||||
|
@ -34,7 +34,7 @@ public class MABoss
|
|||
this.entity = entity;
|
||||
this.dead = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the LivingEntity associated with this MABoss
|
||||
* @return a LivingEntity
|
||||
|
@ -42,7 +42,7 @@ public class MABoss
|
|||
public LivingEntity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current health of this MABoss
|
||||
* @return the current health of the boss
|
||||
|
@ -50,7 +50,7 @@ public class MABoss
|
|||
public double getHealth() {
|
||||
return entity.getHealth();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the maximum health of this MABoss
|
||||
* @return the maximum health of the boss
|
||||
|
@ -58,7 +58,7 @@ public class MABoss
|
|||
public double getMaxHealth() {
|
||||
return entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the boss is dead.
|
||||
* A boss is dead if it has been damaged such that its health is below 0.
|
||||
|
@ -67,7 +67,7 @@ public class MABoss
|
|||
public boolean isDead() {
|
||||
return dead;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the death status of a boss.
|
||||
* This is used by the ArenaListener to force kill bosses that die due to
|
||||
|
@ -78,7 +78,7 @@ public class MABoss
|
|||
this.dead = dead;
|
||||
healthbar.removeAll();
|
||||
}
|
||||
|
||||
|
||||
public void setReward(Thing reward) {
|
||||
this.reward = reward;
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ public class MACreature
|
|||
public MACreature(String name, EntityType type) {
|
||||
this(name, name + "s", type);
|
||||
}
|
||||
|
||||
|
||||
private MACreature(EntityType type) {
|
||||
this(
|
||||
type.name().toLowerCase().replaceAll("[-_\\.]", ""),
|
||||
|
@ -122,11 +122,11 @@ public class MACreature
|
|||
public EntityType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
public static MACreature fromString(String string) {
|
||||
return map.get(string.toLowerCase().replaceAll("[-_\\.]", ""));
|
||||
}
|
||||
|
||||
|
||||
public LivingEntity spawn(Arena arena, World world, Location loc) {
|
||||
LivingEntity e = (LivingEntity) world.spawnEntity(loc, type);
|
||||
e.getEquipment().clear();
|
||||
|
@ -191,12 +191,12 @@ public class MACreature
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (e instanceof Creature) {
|
||||
Creature c = (Creature) e;
|
||||
c.setTarget(WaveUtils.getClosestPlayer(arena, e));
|
||||
}
|
||||
|
||||
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ public class SheepBouncer implements Runnable
|
|||
private Arena arena;
|
||||
|
||||
private BukkitTask task;
|
||||
|
||||
|
||||
public SheepBouncer(Arena arena) {
|
||||
this.arena = arena;
|
||||
}
|
||||
|
||||
|
||||
public void start() {
|
||||
if (task != null) {
|
||||
arena.getPlugin().getLogger().warning("Starting sheep bouncer in arena " + arena.configName() + " with existing bouncer still running. This should never happen.");
|
||||
|
@ -48,44 +48,44 @@ public class SheepBouncer implements Runnable
|
|||
if (!arena.isRunning() || arena.getPlayersInArena().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Put all the sheep in a new collection for iteration purposes.
|
||||
Set<LivingEntity> sheep = new HashSet<>(arena.getMonsterManager().getExplodingSheep());
|
||||
|
||||
|
||||
// If there are no sheep, reschedule and return.
|
||||
if (sheep.isEmpty()) {
|
||||
arena.scheduleTask(this, BOUNCE_INTERVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (LivingEntity e : sheep) {
|
||||
// If an entity is null just ignore it.
|
||||
if (e == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// If the sheep is dead, remove it.
|
||||
if (e.isDead()) {
|
||||
arena.getMonsterManager().removeMonster(e);
|
||||
arena.getMonsterManager().removeExplodingSheep(e);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Create an explosion if there's a player amongst the nearby entities.
|
||||
for (Entity entity : e.getNearbyEntities(2D, 2D, 2D)) {
|
||||
if (entity instanceof Player) {
|
||||
e.getWorld().createExplosion(e.getLocation(), 2f);
|
||||
e.remove();
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Otherwise, if it's not already bouncing, BOUNCE!
|
||||
if (Math.abs(e.getVelocity().getY()) < 1)
|
||||
e.setVelocity(e.getVelocity().setY(0.5));
|
||||
}
|
||||
|
||||
|
||||
// Reschedule for more bouncy madness!
|
||||
task = Bukkit.getScheduler().runTaskLater(arena.getPlugin(), this, BOUNCE_INTERVAL);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public interface Wave
|
|||
* @return a collection of MACreatures and how many of each to spawn
|
||||
*/
|
||||
Map<MACreature,Integer> getMonstersToSpawn(int wave, int playerCount, Arena arena);
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of spawnpoints upon which the monsters of this
|
||||
* wave may be spawned. Note that it is expected that the
|
||||
|
@ -32,7 +32,7 @@ public interface Wave
|
|||
* @return a list of valid spawnpoints
|
||||
*/
|
||||
List<Location> getSpawnpoints(Arena arena);
|
||||
|
||||
|
||||
/**
|
||||
* Set the list of spawnpoints on which the monsters of this
|
||||
* wave may be spawned. If the value is null, all spawnpoints
|
||||
|
@ -40,7 +40,7 @@ public interface Wave
|
|||
* @param spawnpoints a list of spawnpoints
|
||||
*/
|
||||
void setSpawnpoints(List<Location> spawnpoints);
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of potion effects that the monsters of this wave
|
||||
* will be given when they spawn.
|
||||
|
@ -63,7 +63,7 @@ public interface Wave
|
|||
* @param wave a wave number
|
||||
*/
|
||||
void announce(Arena arena, int wave);
|
||||
|
||||
|
||||
/**
|
||||
* Get the wave's name.
|
||||
* @return The name
|
||||
|
@ -87,7 +87,7 @@ public interface Wave
|
|||
* @param branch recurrent or single
|
||||
*/
|
||||
void setBranch(WaveBranch branch);
|
||||
|
||||
|
||||
/**
|
||||
* Get the type of wave.
|
||||
* @return a WaveType
|
||||
|
@ -99,7 +99,7 @@ public interface Wave
|
|||
* @param type a WaveType
|
||||
*/
|
||||
void setType(WaveType type);
|
||||
|
||||
|
||||
/**
|
||||
* Get the first wave this Wave instance may spawn on.
|
||||
* @return a wave number
|
||||
|
@ -111,55 +111,55 @@ public interface Wave
|
|||
* @param firstWave a wave number
|
||||
*/
|
||||
void setFirstWave(int firstWave);
|
||||
|
||||
|
||||
/**
|
||||
* Get the wave's frequency, i.e. wave number "modulo"
|
||||
* @return a frequency
|
||||
*/
|
||||
int getFrequency();
|
||||
|
||||
|
||||
/**
|
||||
* Set the wave's frequency
|
||||
* @param frequency a frequency
|
||||
*/
|
||||
void setFrequency(int frequency);
|
||||
|
||||
|
||||
/**
|
||||
* Get the wave's priority value.
|
||||
* @return a priority
|
||||
*/
|
||||
int getPriority();
|
||||
|
||||
|
||||
/**
|
||||
* Set the wave's priority.
|
||||
* @param priority a priority
|
||||
*/
|
||||
void setPriority(int priority);
|
||||
|
||||
|
||||
/**
|
||||
* Get the wave's health multiplier.
|
||||
* @return The health multiplier
|
||||
*/
|
||||
double getHealthMultiplier();
|
||||
|
||||
|
||||
/**
|
||||
* Get the wave's health multiplier.
|
||||
* @param healthMultiplier a double in the range ]0;1]
|
||||
*/
|
||||
void setHealthMultiplier(double healthMultiplier);
|
||||
|
||||
|
||||
/**
|
||||
* Get the wave's amount multiplier.
|
||||
* @return The amount multiplier
|
||||
*/
|
||||
double getAmountMultiplier();
|
||||
|
||||
|
||||
/**
|
||||
* Set the wave's amount multiplier.
|
||||
* @param amountMultiplier a positive double
|
||||
*/
|
||||
void setAmountMultiplier(double amountMultiplier);
|
||||
|
||||
|
||||
/**
|
||||
* Check if this wave matches the wave number.
|
||||
* The SingleWave class does a simple check if its wave == the parameter.
|
||||
|
@ -179,4 +179,4 @@ public interface Wave
|
|||
* @return a copy of the wave
|
||||
*/
|
||||
Wave copy();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,38 +14,38 @@ public class WaveManager
|
|||
|
||||
private Wave defaultWave, currentWave;
|
||||
private TreeSet<Wave> recurrentWaves, singleWaves, singleWavesInstance;
|
||||
|
||||
|
||||
private int wave, finalWave;
|
||||
|
||||
|
||||
public WaveManager(Arena arena, ConfigurationSection section) {
|
||||
this.arena = arena;
|
||||
this.section = section;
|
||||
this.wave = 0;
|
||||
this.finalWave = 0;
|
||||
|
||||
|
||||
reloadWaves();
|
||||
}
|
||||
|
||||
|
||||
public TreeSet<Wave> getRecurrentWaves() {
|
||||
return recurrentWaves;
|
||||
}
|
||||
|
||||
|
||||
public void reset() {
|
||||
reloadWaves();
|
||||
wave = 0;
|
||||
singleWavesInstance = new TreeSet<>(singleWaves);
|
||||
}
|
||||
|
||||
|
||||
public void reloadWaves() {
|
||||
ConfigurationSection rConfig = section.getConfigurationSection("recurrent");
|
||||
ConfigurationSection sConfig = section.getConfigurationSection("single");
|
||||
|
||||
|
||||
recurrentWaves = WaveParser.parseWaves(arena, rConfig, WaveBranch.RECURRENT);
|
||||
singleWaves = WaveParser.parseWaves(arena, sConfig, WaveBranch.SINGLE);
|
||||
|
||||
// getParent() => go back to the arena-node to access settings
|
||||
finalWave = section.getParent().getInt("settings.final-wave", 0);
|
||||
|
||||
|
||||
if (recurrentWaves.isEmpty()) {
|
||||
if (singleWaves.isEmpty()) {
|
||||
arena.getPlugin().getLogger().warning("Found no waves for arena " + arena.configName() + ", using default wave.");
|
||||
|
@ -60,15 +60,15 @@ public class WaveManager
|
|||
defaultWave = recurrentWaves.first();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increment the wave number and get the next Wave to be spawned.
|
||||
* Note that this method is a mutator.
|
||||
* Note that this method is a mutator.
|
||||
* @return the next Wave
|
||||
*/
|
||||
public Wave next() {
|
||||
wave++;
|
||||
|
||||
|
||||
if (!singleWavesInstance.isEmpty() && singleWavesInstance.first().matches(wave)) {
|
||||
currentWave = singleWavesInstance.pollFirst().copy();
|
||||
}
|
||||
|
@ -76,10 +76,10 @@ public class WaveManager
|
|||
SortedSet<Wave> matches = getMatchingRecurrentWaves(wave);
|
||||
currentWave = (matches.isEmpty() ? defaultWave : matches.last()).copy();
|
||||
}
|
||||
|
||||
|
||||
return currentWave;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the next Wave to be spawned. This is an accessor and does not
|
||||
* advance the "counter". Note that the Wave objects, however, are
|
||||
|
@ -88,15 +88,15 @@ public class WaveManager
|
|||
*/
|
||||
public Wave getNext() {
|
||||
int next = wave + 1;
|
||||
|
||||
|
||||
if (!singleWavesInstance.isEmpty() && singleWavesInstance.first().matches(next)) {
|
||||
return singleWavesInstance.first();
|
||||
}
|
||||
|
||||
|
||||
SortedSet<Wave> matches = getMatchingRecurrentWaves(wave);
|
||||
return (matches.isEmpty() ? defaultWave : matches.last());
|
||||
return (matches.isEmpty() ? defaultWave : matches.last());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current wave that's being used.
|
||||
* Note that the current wave might not have spawned yet.
|
||||
|
@ -105,7 +105,7 @@ public class WaveManager
|
|||
public Wave getCurrent() {
|
||||
return currentWave;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current wave number.
|
||||
* @return the current wave number
|
||||
|
@ -113,7 +113,7 @@ public class WaveManager
|
|||
public int getWaveNumber() {
|
||||
return wave;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the final wave number.
|
||||
* @return the final wave number
|
||||
|
@ -121,7 +121,7 @@ public class WaveManager
|
|||
public int getFinalWave() {
|
||||
return finalWave;
|
||||
}
|
||||
|
||||
|
||||
private SortedSet<Wave> getMatchingRecurrentWaves(int wave) {
|
||||
TreeSet<Wave> result = new TreeSet<>(WaveUtils.getRecurrentComparator());
|
||||
for (Wave w : recurrentWaves) {
|
||||
|
|
|
@ -44,40 +44,40 @@ public class WaveParser
|
|||
public static TreeSet<Wave> parseWaves(Arena arena, ConfigurationSection config, WaveBranch branch) {
|
||||
// Create a TreeSet with the Comparator for the specific branch.
|
||||
TreeSet<Wave> result = new TreeSet<>(WaveUtils.getComparator(branch));
|
||||
|
||||
|
||||
// If the config is null, return the empty set.
|
||||
if (config == null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// If no waves were found, return the empty set.
|
||||
Set<String> waves = config.getKeys(false);
|
||||
if (waves == null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Otherwise, parse each wave in the branch.
|
||||
for (String wave : waves) {
|
||||
ConfigurationSection waveSection = config.getConfigurationSection(wave);
|
||||
Wave w = parseWave(arena, wave, waveSection, branch);
|
||||
result.add(w);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static Wave parseWave(Arena arena, String name, ConfigurationSection config, WaveBranch branch) {
|
||||
// Grab the WaveType and verify that it isn't null.
|
||||
String t = config.getString("type", null);
|
||||
WaveType type = WaveType.fromString(t);
|
||||
|
||||
|
||||
if (type == null) {
|
||||
throw new ConfigError("Invalid wave type for wave " + name + " of arena " + arena.configName() + ": " + t);
|
||||
}
|
||||
|
||||
|
||||
// Prepare the result
|
||||
Wave result = null;
|
||||
|
||||
|
||||
// Switch on the type of wave.
|
||||
switch (type) {
|
||||
case DEFAULT:
|
||||
|
@ -99,26 +99,26 @@ public class WaveParser
|
|||
result = parseBossWave(arena, name, config);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Grab the branch-specific nodes.
|
||||
int priority = config.getInt("priority", -1);
|
||||
int frequency = config.getInt("frequency", -1);
|
||||
int firstWave = config.getInt("wave", frequency);
|
||||
|
||||
|
||||
// Get multipliers
|
||||
double healthMultiplier = config.getDouble("health-multiplier", -1D);
|
||||
if (healthMultiplier == -1D) {
|
||||
healthMultiplier = config.getInt("health-multiplier", 1);
|
||||
}
|
||||
|
||||
|
||||
double amountMultiplier = config.getDouble("amount-multiplier", -1D);
|
||||
if (amountMultiplier == -1D) {
|
||||
amountMultiplier = config.getInt("amount-multiplier", 1);
|
||||
}
|
||||
|
||||
|
||||
// Grab the specific spawnpoints if any
|
||||
List<Location> spawnpoints = getSpawnpoints(arena, name, config);
|
||||
|
||||
|
||||
// Potion effects
|
||||
List<PotionEffect> effects = getPotionEffects(arena, name, config);
|
||||
|
||||
|
@ -133,31 +133,31 @@ public class WaveParser
|
|||
} else if (branch == WaveBranch.SINGLE && firstWave <= 0) {
|
||||
throw new ConfigError("Missing or invalid 'wave' node for single wave " + name + " of arena " + arena.configName());
|
||||
}
|
||||
|
||||
|
||||
// Set the important required values.
|
||||
result.setName(name);
|
||||
result.setBranch(branch);
|
||||
result.setFirstWave(firstWave);
|
||||
result.setPriority(priority);
|
||||
result.setFrequency(frequency);
|
||||
|
||||
|
||||
// And the multipliers.
|
||||
result.setHealthMultiplier(healthMultiplier);
|
||||
result.setAmountMultiplier(amountMultiplier);
|
||||
|
||||
|
||||
// Aaand the spawnpoints
|
||||
result.setSpawnpoints(spawnpoints);
|
||||
|
||||
// Potions
|
||||
result.setEffects(effects);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static Wave parseDefaultWave(Arena arena, String name, ConfigurationSection config) {
|
||||
// Grab the monster map.
|
||||
SortedMap<Integer,MACreature> monsters = getMonsterMap(arena, name, config);
|
||||
|
||||
|
||||
// Create the wave.
|
||||
DefaultWave result = new DefaultWave(monsters);
|
||||
|
||||
|
@ -167,7 +167,7 @@ public class WaveParser
|
|||
result.setFixed(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Grab the WaveGrowth
|
||||
String grw = config.getString("growth", null);
|
||||
if (grw != null && !grw.isEmpty()) {
|
||||
|
@ -180,21 +180,21 @@ public class WaveParser
|
|||
} else {
|
||||
result.setGrowth(WaveGrowth.MEDIUM);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static Wave parseSpecialWave(Arena arena, String name, ConfigurationSection config) {
|
||||
SortedMap<Integer,MACreature> monsters = getMonsterMap(arena, name, config);
|
||||
|
||||
|
||||
return new SpecialWave(monsters);
|
||||
}
|
||||
|
||||
|
||||
private static Wave parseSwarmWave(Arena arena, String name, ConfigurationSection config) {
|
||||
MACreature monster = getSingleMonster(arena, name, config);
|
||||
|
||||
|
||||
SwarmWave result = new SwarmWave(monster);
|
||||
|
||||
|
||||
// Grab SwarmAmount
|
||||
String amnt = config.getString("amount", null);
|
||||
if (amnt != null && !amnt.isEmpty()) {
|
||||
|
@ -207,15 +207,15 @@ public class WaveParser
|
|||
} else {
|
||||
result.setAmount(SwarmAmount.LOW);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static Wave parseSupplyWave(Arena arena, String name, ConfigurationSection config) {
|
||||
SortedMap<Integer,MACreature> monsters = getMonsterMap(arena, name, config);
|
||||
|
||||
|
||||
SupplyWave result = new SupplyWave(monsters);
|
||||
|
||||
|
||||
// Grab the loot.
|
||||
List<String> loot = config.getStringList("drops");
|
||||
if (loot == null || loot.isEmpty()) {
|
||||
|
@ -236,28 +236,28 @@ public class WaveParser
|
|||
})
|
||||
.collect(Collectors.toList());
|
||||
result.setDropList(stacks);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static Wave parseUpgradeWave(Arena arena, String name, ConfigurationSection config) {
|
||||
ThingManager thingman = arena.getPlugin().getThingManager();
|
||||
Map<String,List<Thing>> upgrades = getUpgradeMap(config, name, arena, thingman);
|
||||
|
||||
return new UpgradeWave(upgrades);
|
||||
}
|
||||
|
||||
|
||||
private static Wave parseBossWave(Arena arena, String name, ConfigurationSection config) {
|
||||
MACreature monster = getSingleMonster(arena, name, config);
|
||||
|
||||
|
||||
BossWave result = new BossWave(monster);
|
||||
|
||||
|
||||
// Check if there's a specific boss name
|
||||
String bossName = config.getString("name", null);
|
||||
if (bossName != null && !bossName.isEmpty()) {
|
||||
result.setBossName(ChatColor.translateAlternateColorCodes('&', bossName));
|
||||
}
|
||||
|
||||
|
||||
// Grab the boss health
|
||||
String healthString = config.getString("health", null);
|
||||
if (healthString != null && !healthString.isEmpty()) {
|
||||
|
@ -274,7 +274,7 @@ public class WaveParser
|
|||
} else {
|
||||
result.setHealth(BossHealth.MEDIUM);
|
||||
}
|
||||
|
||||
|
||||
// And the abilities.
|
||||
List<String> abilities = config.getStringList("abilities");
|
||||
if (abilities == null || abilities.isEmpty()) {
|
||||
|
@ -298,11 +298,11 @@ public class WaveParser
|
|||
return ability;
|
||||
})
|
||||
.forEach(result::addBossAbility);
|
||||
|
||||
|
||||
// As well as the ability interval and ability announce.
|
||||
result.setAbilityInterval(config.getInt("ability-interval", 3) * 20);
|
||||
result.setAbilityAnnounce(config.getBoolean("ability-announce", true));
|
||||
|
||||
|
||||
// Rewards!
|
||||
String rew = config.getString("reward", null);
|
||||
if (rew != null && !rew.isEmpty()) {
|
||||
|
@ -335,10 +335,10 @@ public class WaveParser
|
|||
})
|
||||
.collect(Collectors.toList());
|
||||
result.setDrops(stacks);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scan the ConfigSection for a "monster" (singular) node, which
|
||||
* must be exactly a single monster.
|
||||
|
@ -350,14 +350,14 @@ public class WaveParser
|
|||
if (monster == null || monster.isEmpty()) {
|
||||
throw new ConfigError("Missing 'monster' node for wave " + name + " of arena " + arena.configName());
|
||||
}
|
||||
|
||||
|
||||
MACreature result = MACreature.fromString(monster);
|
||||
if (result == null) {
|
||||
throw new ConfigError("Failed to parse monster for wave " + name + " of arena " + arena.configName() + ": " + monster);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scan the ConfigSection for a "monsters" (plural) node, which
|
||||
* must contain a list of at least one "monster: number" node.
|
||||
|
@ -374,31 +374,31 @@ public class WaveParser
|
|||
if (monsters == null || monsters.isEmpty()) {
|
||||
throw new ConfigError("Empty 'monsters' node for wave " + name + " of arena " + arena.configName());
|
||||
}
|
||||
|
||||
|
||||
// Prepare the map.
|
||||
SortedMap<Integer,MACreature> monsterMap = new TreeMap<>();
|
||||
int sum = 0;
|
||||
String path = "monsters.";
|
||||
|
||||
|
||||
// Check all the monsters.
|
||||
for (String monster : monsters) {
|
||||
MACreature creature = MACreature.fromString(monster);
|
||||
if (creature == null) {
|
||||
throw new ConfigError("Failed to parse monster for wave " + name + " of arena " + arena.configName() + ": " + monster);
|
||||
}
|
||||
|
||||
|
||||
int prob = config.getInt(path + monster, -1);
|
||||
if (prob < 0) {
|
||||
throw new ConfigError("Failed to parse probability for monster " + monster + " in wave " + name + " of arena " + arena.configName());
|
||||
}
|
||||
|
||||
|
||||
sum += prob;
|
||||
monsterMap.put(sum, creature);
|
||||
}
|
||||
|
||||
|
||||
return monsterMap;
|
||||
}
|
||||
|
||||
|
||||
private static List<Location> getSpawnpoints(Arena arena, String name, ConfigurationSection config) {
|
||||
List<String> spawnpoints = config.getStringList("spawnpoints");
|
||||
if (spawnpoints == null || spawnpoints.isEmpty()) {
|
||||
|
@ -408,7 +408,7 @@ public class WaveParser
|
|||
}
|
||||
spawnpoints = Arrays.asList(value.split(";"));
|
||||
}
|
||||
|
||||
|
||||
ArenaRegion region = arena.getRegion();
|
||||
return spawnpoints.stream()
|
||||
.map(String::trim)
|
||||
|
@ -451,7 +451,7 @@ public class WaveParser
|
|||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
private static Map<String,List<Thing>> getUpgradeMap(ConfigurationSection config, String name, Arena arena, ThingManager thingman) {
|
||||
ConfigurationSection section = config.getConfigurationSection("upgrades");
|
||||
if (section == null) {
|
||||
|
@ -462,10 +462,10 @@ public class WaveParser
|
|||
if (classes == null || classes.isEmpty()) {
|
||||
throw new ConfigError("Empty 'upgrades' node for wave " + name + " of arena " + arena.configName());
|
||||
}
|
||||
|
||||
|
||||
Map<String,List<Thing>> upgrades = new HashMap<>();
|
||||
String path = "upgrades.";
|
||||
|
||||
|
||||
for (String className : classes) {
|
||||
// Legacy support
|
||||
Object val = config.get(path + className, null);
|
||||
|
@ -479,7 +479,7 @@ public class WaveParser
|
|||
upgrades.put(className.toLowerCase(), list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
|
@ -570,14 +570,14 @@ public class WaveParser
|
|||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static Wave createDefaultWave() {
|
||||
SortedMap<Integer,MACreature> monsters = new TreeMap<>();
|
||||
monsters.put(10, MACreature.ZOMBIE);
|
||||
monsters.put(20, MACreature.SKELETON);
|
||||
monsters.put(30, MACreature.SPIDER);
|
||||
monsters.put(40, MACreature.SLIMESMALL);
|
||||
|
||||
|
||||
DefaultWave result = new DefaultWave(monsters);
|
||||
result.setName("MA_DEFAULT_WAVE");
|
||||
result.setBranch(WaveBranch.RECURRENT);
|
||||
|
@ -587,7 +587,7 @@ public class WaveParser
|
|||
result.setGrowth(WaveGrowth.OLD);
|
||||
result.setHealthMultiplier(1D);
|
||||
result.setAmountMultiplier(1D);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@ public class WaveUtils
|
|||
public static List<Location> getValidSpawnpoints(Arena arena, List<Location> spawnpoints, Collection<Player> players) {
|
||||
MobArena plugin = arena.getPlugin();
|
||||
List<Location> result = new ArrayList<>();
|
||||
|
||||
|
||||
// Ensure that we do have some spawnpoints.
|
||||
if (spawnpoints == null || spawnpoints.isEmpty()) {
|
||||
spawnpoints = arena.getRegion().getSpawnpointList();
|
||||
}
|
||||
|
||||
|
||||
// Loop through each one and check if any players are in range.
|
||||
for (Location l : spawnpoints) {
|
||||
for (Player p : players) {
|
||||
|
@ -37,7 +37,7 @@ public class WaveUtils
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If no spawnpoints in range, just return all of them.
|
||||
if (result.isEmpty()) {
|
||||
String locs = "";
|
||||
|
@ -50,14 +50,14 @@ public class WaveUtils
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static Player getClosestPlayer(Arena arena, Entity e)
|
||||
{
|
||||
// Set up the comparison variable and the result.
|
||||
double dist = 0;
|
||||
double current = Double.POSITIVE_INFINITY;
|
||||
Player result = null;
|
||||
|
||||
|
||||
/* Iterate through the ArrayList, and update current and result every
|
||||
* time a squared distance smaller than current is found. */
|
||||
for (Player p : arena.getPlayersInArena())
|
||||
|
@ -68,7 +68,7 @@ public class WaveUtils
|
|||
p.kickPlayer("[MobArena] Cheater! (Warped out of the arena world.)");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
dist = p.getLocation().distanceSquared(e.getLocation());
|
||||
if (dist < current && dist < MobArena.MIN_PLAYER_DISTANCE_SQUARED)
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ public class WaveUtils
|
|||
// Comparators
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
/**
|
||||
* Get a comparator based on the WaveBranch parameter.
|
||||
*/
|
||||
|
@ -97,7 +97,7 @@ public class WaveUtils
|
|||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a Comparator that compares Wave objects by wave number.
|
||||
* If the wave numbers are equal, the waves are equal. This is to
|
||||
|
@ -118,12 +118,12 @@ public class WaveUtils
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a Comparator that compares Wave objects by priority.
|
||||
* If the priorities are equal, the names are compared. This is to
|
||||
* ALLOW "duplicates" in the RECURRENT WAVES collection.
|
||||
* @return Comparator whose compare()-method compares wave priorities.
|
||||
* @return Comparator whose compare()-method compares wave priorities.
|
||||
*/
|
||||
public static Comparator<Wave> getRecurrentComparator()
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ public @interface AbilityInfo
|
|||
* This value is printed when a boss executes the ability in the arena.
|
||||
*/
|
||||
String name();
|
||||
|
||||
|
||||
/**
|
||||
* The config aliases for the ability.
|
||||
* This is used by MobArena to parse ability names from the config-file.
|
||||
|
|
|
@ -43,7 +43,7 @@ public class AbilityManager
|
|||
private static final String ma = "plugins" + File.separator + "MobArena.jar";
|
||||
private static final String cb = System.getProperty("java.class.path");
|
||||
private static final String classpath = ma + System.getProperty("path.separator") + cb;
|
||||
|
||||
|
||||
private static Map<String,Class<? extends Ability>> abilities;
|
||||
|
||||
/**
|
||||
|
@ -90,7 +90,7 @@ public class AbilityManager
|
|||
register(ThrowTarget.class);
|
||||
register(WarpToPlayer.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load the custom abilities from the specified directory.
|
||||
* @param dataDir main plugin data folder
|
||||
|
@ -105,7 +105,7 @@ public class AbilityManager
|
|||
|
||||
// Grab the source directory.
|
||||
File javaDir = new File(classDir, "src");
|
||||
|
||||
|
||||
/* If the source directory exists, we need to verify that the system
|
||||
* has a java compiler before attempting anything. If not, we need to
|
||||
* skip the compiling step and just go straight to loading in the
|
||||
|
@ -117,7 +117,7 @@ public class AbilityManager
|
|||
Bukkit.getLogger().warning("[MobArena] Found plugins/MobArena/abilities/src/ folder, but no Java compiler. The source files will not be compiled!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Load all the custom abilities.
|
||||
loadClasses(classDir);
|
||||
}
|
||||
|
@ -142,38 +142,38 @@ public class AbilityManager
|
|||
// Announce custom abilities
|
||||
if (announce) Bukkit.getLogger().info("[MobArena] Loaded custom ability '" + info.name() + "'");
|
||||
}
|
||||
|
||||
|
||||
private static void compileAbilities(File javaDir, File classDir) {
|
||||
if (!javaDir.exists()) return;
|
||||
|
||||
|
||||
// Make ready a new list of files to compile.
|
||||
List<File> toCompile = getSourceFilesToCompile(javaDir, classDir);
|
||||
|
||||
|
||||
// No files to compile?
|
||||
if (toCompile.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Notify the console.
|
||||
Bukkit.getLogger().info("[MobArena] Compiling abilities: " + fileListToString(toCompile));
|
||||
|
||||
|
||||
// Get the compiler
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
|
||||
|
||||
|
||||
// Generate some JavaFileObjects
|
||||
try {
|
||||
Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(toCompile);
|
||||
|
||||
|
||||
// Include the MobArena.jar on the classpath, and set the destination folder.
|
||||
List<String> options = Arrays.asList("-classpath", classpath, "-d", classDir.getPath());
|
||||
|
||||
|
||||
// Set up the compilation task.
|
||||
JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, null, options, null, compilationUnits);
|
||||
|
||||
|
||||
// Call the task.
|
||||
task.call();
|
||||
|
||||
|
||||
// And close the file manager.
|
||||
fileManager.close();
|
||||
}
|
||||
|
@ -182,17 +182,17 @@ public class AbilityManager
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static List<File> getSourceFilesToCompile(File javaDir, File classDir) {
|
||||
List<File> result = new ArrayList<>();
|
||||
|
||||
|
||||
if (javaDir == null || !javaDir.exists()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Grab the array of compiled files.
|
||||
File[] classFiles = classDir.listFiles();
|
||||
|
||||
|
||||
// Go through each source file.
|
||||
for (File javaFile : javaDir.listFiles()) {
|
||||
// Skip if it's not a .java file.
|
||||
|
@ -200,24 +200,24 @@ public class AbilityManager
|
|||
Bukkit.getLogger().info("[MobArena] Found invalid ability file: " + javaFile.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Find the associated .class file.
|
||||
File classFile = findClassFile(javaFile, classFiles);
|
||||
|
||||
|
||||
// If the .class file is newer, we don't need to compile.
|
||||
if (isClassFileNewer(javaFile, classFile)) {
|
||||
continue;
|
||||
}
|
||||
result.add(javaFile);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static File findClassFile(File javaFile, File[] classFiles) {
|
||||
String javaFileName = javaFile.getName();
|
||||
String classFileName = javaFileName.substring(0, javaFileName.lastIndexOf(".")) + ".class";
|
||||
|
||||
|
||||
for (File classFile : classFiles) {
|
||||
if (classFile.getName().equals(classFileName)) {
|
||||
return classFile;
|
||||
|
@ -225,13 +225,13 @@ public class AbilityManager
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static boolean isClassFileNewer(File javaFile, File classFile) {
|
||||
if (classFile == null) return false;
|
||||
|
||||
|
||||
return (classFile.lastModified() > javaFile.lastModified());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* (Compiles and) loads all custom abilities in the given directory.
|
||||
* @param classDir a directory
|
||||
|
@ -240,21 +240,21 @@ public class AbilityManager
|
|||
// Grab the class loader
|
||||
ClassLoader loader = getLoader(classDir);
|
||||
if (loader == null) return;
|
||||
|
||||
|
||||
for (File file : classDir.listFiles()) {
|
||||
String filename = file.getName();
|
||||
|
||||
|
||||
// Only load .class files.
|
||||
int dot = filename.lastIndexOf(".class");
|
||||
if (dot < 0) continue;
|
||||
|
||||
// Trim off the .class extension
|
||||
String name = filename.substring(0, file.getName().lastIndexOf("."));
|
||||
|
||||
|
||||
try {
|
||||
// Load the class
|
||||
Class<?> cls = loader.loadClass(name);
|
||||
|
||||
|
||||
// Verify that it's an Ability, then register it
|
||||
if (Ability.class.isAssignableFrom(cls)) {
|
||||
register(cls.asSubclass(Ability.class), true);
|
||||
|
@ -262,7 +262,7 @@ public class AbilityManager
|
|||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a ClassLoader for the given directory.
|
||||
* @param dir a directory
|
||||
|
@ -274,30 +274,30 @@ public class AbilityManager
|
|||
return loader;
|
||||
}
|
||||
catch (Exception e) {}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static String fileListToString(List<File> list) {
|
||||
return fileListToString(list, null);
|
||||
}
|
||||
|
||||
|
||||
private static String fileListToString(List<File> list, String exclude) {
|
||||
if (list.isEmpty()) return "";
|
||||
|
||||
|
||||
StringBuffer buffy = new StringBuffer();
|
||||
|
||||
|
||||
for (File file : list) {
|
||||
String name = file.getName();
|
||||
int dot = name.lastIndexOf(".");
|
||||
|
||||
|
||||
if (exclude != null && name.contains(exclude)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
buffy.append(", " + name.substring(0, dot));
|
||||
}
|
||||
|
||||
|
||||
// Trim off the first ", ".
|
||||
return buffy.substring(2);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.Random;
|
|||
public class AbilityUtils
|
||||
{
|
||||
public static Random random = new Random();
|
||||
|
||||
|
||||
/**
|
||||
* Get the target player of the LivingEntity if possible.
|
||||
* @param the arena
|
||||
|
@ -25,18 +25,18 @@ public class AbilityUtils
|
|||
public static LivingEntity getTarget(Arena arena, LivingEntity entity, boolean random) {
|
||||
if (entity instanceof Creature) {
|
||||
LivingEntity target = ((Creature) entity).getTarget();
|
||||
|
||||
|
||||
if (target instanceof Player && arena.inArena((Player) target)) {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (random) {
|
||||
return getRandomPlayer(arena);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a random arena player.
|
||||
* @param arena the arena
|
||||
|
@ -45,10 +45,10 @@ public class AbilityUtils
|
|||
public static Player getRandomPlayer(Arena arena) {
|
||||
List<Player> list = new ArrayList<>(arena.getPlayersInArena());
|
||||
if (list.isEmpty()) return null;
|
||||
|
||||
|
||||
return list.get(random.nextInt(list.size()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of nearby players
|
||||
* @param arena the arena
|
||||
|
@ -65,12 +65,12 @@ public class AbilityUtils
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of distant players
|
||||
* @param arena the arena
|
||||
* @param boss the boss
|
||||
* @param x the 'radius' in which to exclude players
|
||||
* @param x the 'radius' in which to exclude players
|
||||
* @return a list of distant players
|
||||
*/
|
||||
public static List<Player> getDistantPlayers(Arena arena, Entity boss, int x) {
|
||||
|
|
|
@ -18,43 +18,43 @@ import java.util.List;
|
|||
public class ChainLightning implements Ability
|
||||
{
|
||||
/**
|
||||
* How many blocks the chain lightning can spread over.
|
||||
* How many blocks the chain lightning can spread over.
|
||||
* Must be greater than 0.
|
||||
*/
|
||||
private static final int RADIUS = 4;
|
||||
|
||||
|
||||
/**
|
||||
* How many server ticks between each lightning strike.
|
||||
* Must be greater than 0.
|
||||
*/
|
||||
private static final int TICKS = 10;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
final LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), true);
|
||||
if (target == null || !(target instanceof Player))
|
||||
return;
|
||||
|
||||
|
||||
strikeLightning(arena, (Player) target, new ArrayList<>());
|
||||
}
|
||||
|
||||
|
||||
private void strikeLightning(final Arena arena, final Player p, final List<Player> done) {
|
||||
arena.scheduleTask(new Runnable() {
|
||||
public void run() {
|
||||
if (!arena.isRunning() || !arena.inArena(p))
|
||||
return;
|
||||
|
||||
|
||||
// Smite the target
|
||||
arena.getWorld().strikeLightning(p.getLocation());
|
||||
done.add(p);
|
||||
|
||||
|
||||
// Grab all nearby players
|
||||
List<Player> nearby = AbilityUtils.getNearbyPlayers(arena, p, RADIUS);
|
||||
|
||||
|
||||
// Remove all that are "done", and return if empty
|
||||
nearby.removeAll(done);
|
||||
if (nearby.isEmpty()) return;
|
||||
|
||||
|
||||
// Otherwise, smite the next target!
|
||||
strikeLightning(arena, nearby.get(0), done);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class DisorientDistant implements Ability
|
|||
* How far away players must be to be affected by the ability.
|
||||
*/
|
||||
private static final int RADIUS = 8;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
for (Player p : AbilityUtils.getDistantPlayers(arena, boss.getEntity(), RADIUS)) {
|
||||
|
|
|
@ -19,12 +19,12 @@ public class DisorientNearby implements Ability
|
|||
* How close players must be to be affected by the ability.
|
||||
*/
|
||||
private static final int RADIUS = 5;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), false);
|
||||
if (target == null) return;
|
||||
|
||||
|
||||
for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) {
|
||||
Location loc = p.getLocation();
|
||||
loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270));
|
||||
|
|
|
@ -18,12 +18,12 @@ public class DisorientTarget implements Ability
|
|||
* If the boss has no target, should a random player be selected?
|
||||
*/
|
||||
private static final boolean RANDOM = false;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), RANDOM);
|
||||
if (target == null) return;
|
||||
|
||||
|
||||
Location loc = target.getLocation();
|
||||
loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270));
|
||||
target.teleport(loc);
|
||||
|
|
|
@ -18,11 +18,11 @@ public class FetchDistant implements Ability
|
|||
* How far away players must be to be affected by the ability.
|
||||
*/
|
||||
private static final int RADIUS = 8;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
Location bLoc = boss.getEntity().getLocation();
|
||||
|
||||
|
||||
for (Player p : AbilityUtils.getDistantPlayers(arena, boss.getEntity(), RADIUS)) {
|
||||
p.teleport(bLoc);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ public class FetchNearby implements Ability
|
|||
* How close players must be to be affected by the ability.
|
||||
*/
|
||||
private static final int RADIUS = 5;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
Location bLoc = boss.getEntity().getLocation();
|
||||
|
||||
|
||||
for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) {
|
||||
p.teleport(bLoc);
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@ public class FetchTarget implements Ability
|
|||
* If the boss has no target, should a random player be selected?
|
||||
*/
|
||||
private static final boolean RANDOM = true;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), RANDOM);
|
||||
if (target == null) return;
|
||||
|
||||
|
||||
target.teleport(boss.getEntity());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@ public class FireAura implements Ability
|
|||
* How close players must be to be affected by the ability.
|
||||
*/
|
||||
private static final int RADIUS = 5;
|
||||
|
||||
|
||||
/**
|
||||
* How many ticks the players should be on fire for.
|
||||
*/
|
||||
private static final int TICKS = 20;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS))
|
||||
|
|
|
@ -19,7 +19,7 @@ public class Flood implements Ability
|
|||
public void execute(Arena arena, MABoss boss) {
|
||||
Player p = AbilityUtils.getRandomPlayer(arena);
|
||||
Block block = p.getLocation().getBlock();
|
||||
|
||||
|
||||
if (block.getType() == Material.AIR) {
|
||||
block.setType(Material.WATER);
|
||||
arena.addBlock(block);
|
||||
|
|
|
@ -18,7 +18,7 @@ public class LightningAura implements Ability
|
|||
* How close players must be to be affected by the ability.
|
||||
*/
|
||||
private static final int RADIUS = 5;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
World world = arena.getWorld();
|
||||
|
|
|
@ -18,29 +18,29 @@ public class LivingBomb implements Ability
|
|||
* How many ticks before the bomb goes off.
|
||||
*/
|
||||
private static final int FUSE = 60;
|
||||
|
||||
|
||||
/**
|
||||
* How close players must be to be affected by the bomb.
|
||||
*/
|
||||
private static final int RADIUS = 3;
|
||||
|
||||
|
||||
/**
|
||||
* How many ticks players affected by the bomb should burn.
|
||||
*/
|
||||
private static final int AFTERBURN = 40;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(final Arena arena, MABoss boss) {
|
||||
// Grab the target, or a random player.
|
||||
LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), true);
|
||||
|
||||
|
||||
// We only want players.
|
||||
if (target == null || !(target instanceof Player))
|
||||
return;
|
||||
|
||||
final Player p = (Player) target;
|
||||
p.setFireTicks(FUSE + 5);
|
||||
|
||||
|
||||
// Create an explosion after 4 seconds
|
||||
arena.scheduleTask(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -48,10 +48,10 @@ public class LivingBomb implements Ability
|
|||
if (!arena.isRunning() || !arena.inArena(p) || p.getFireTicks() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Explode!
|
||||
arena.getWorld().createExplosion(p.getLocation(), 1F);
|
||||
|
||||
|
||||
// And set every nearby player on fire!
|
||||
for (Player nearby : AbilityUtils.getNearbyPlayers(arena, p, RADIUS)) {
|
||||
nearby.setFireTicks(AFTERBURN);
|
||||
|
|
|
@ -23,12 +23,12 @@ public class ObsidianBomb implements Ability
|
|||
* How many ticks before the bomb goes off.
|
||||
*/
|
||||
private static final int FUSE = 80;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(final Arena arena, MABoss boss) {
|
||||
// Grab the target, or a random player.
|
||||
LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), true);
|
||||
|
||||
|
||||
final World world = arena.getWorld();
|
||||
final Location loc;
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class ObsidianBomb implements Ability
|
|||
public void run() {
|
||||
if (!arena.isRunning())
|
||||
return;
|
||||
|
||||
|
||||
world.getBlockAt(loc).setType(Material.AIR);
|
||||
world.createExplosion(loc, 3F);
|
||||
}
|
||||
|
|
|
@ -19,19 +19,19 @@ public class PullDistant implements Ability
|
|||
* How far away players must be to be affected by the ability.
|
||||
*/
|
||||
private static final int RADIUS = 8;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
Location bLoc = boss.getEntity().getLocation();
|
||||
|
||||
|
||||
for (Player p : AbilityUtils.getDistantPlayers(arena, boss.getEntity(), RADIUS)) {
|
||||
Location loc = p.getLocation();
|
||||
Vector v = new Vector(bLoc.getX() - loc.getX(), 0, bLoc.getZ() - loc.getZ());
|
||||
|
||||
|
||||
double a = Math.abs(bLoc.getX() - loc.getX());
|
||||
double b = Math.abs(bLoc.getZ() - loc.getZ());
|
||||
double c = Math.sqrt((a*a + b*b));
|
||||
|
||||
|
||||
p.setVelocity(v.normalize().multiply(c*0.3).setY(0.8));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,19 +19,19 @@ public class PullNearby implements Ability
|
|||
* How close players must be to be affected by the ability.
|
||||
*/
|
||||
private static final int RADIUS = 5;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
Location bLoc = boss.getEntity().getLocation();
|
||||
|
||||
|
||||
for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) {
|
||||
Location loc = p.getLocation();
|
||||
Vector v = new Vector(bLoc.getX() - loc.getX(), 0, bLoc.getZ() - loc.getZ());
|
||||
|
||||
|
||||
double a = Math.abs(bLoc.getX() - loc.getX());
|
||||
double b = Math.abs(bLoc.getZ() - loc.getZ());
|
||||
double c = Math.sqrt((a*a + b*b));
|
||||
|
||||
|
||||
p.setVelocity(v.normalize().multiply(c*0.3).setY(0.8));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,20 +19,20 @@ public class PullTarget implements Ability
|
|||
* If the boss has no target, should a random player be selected?
|
||||
*/
|
||||
private static final boolean RANDOM = false;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), RANDOM);
|
||||
if (target == null) return;
|
||||
|
||||
|
||||
Location loc = target.getLocation();
|
||||
Location bLoc = boss.getEntity().getLocation();
|
||||
Vector v = new Vector(bLoc.getX() - loc.getX(), 0, bLoc.getZ() - loc.getZ());
|
||||
|
||||
|
||||
double a = Math.abs(bLoc.getX() - loc.getX());
|
||||
double b = Math.abs(bLoc.getZ() - loc.getZ());
|
||||
double c = Math.sqrt((a*a + b*b));
|
||||
|
||||
|
||||
target.setVelocity(v.normalize().multiply(c*0.3).setY(0.8));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@ public class RootTarget implements Ability
|
|||
* How long the the potions last (in ticks).
|
||||
*/
|
||||
private static final int DURATION = 30;
|
||||
|
||||
|
||||
/**
|
||||
* The amplifier for the potions.
|
||||
*/
|
||||
private static final int AMPLIFIER = 100;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
final LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), true);
|
||||
|
|
|
@ -23,16 +23,16 @@ public class ShufflePositions implements Ability
|
|||
// Grab the players and add the boss
|
||||
List<LivingEntity> entities = new ArrayList<>(arena.getPlayersInArena());
|
||||
entities.add(boss.getEntity());
|
||||
|
||||
|
||||
// Grab the locations
|
||||
List<Location> locations = new LinkedList<>();
|
||||
for (LivingEntity e : entities) {
|
||||
locations.add(e.getLocation());
|
||||
}
|
||||
|
||||
|
||||
// Shuffle the entities list.
|
||||
Collections.shuffle(entities);
|
||||
|
||||
|
||||
/* The entities are shuffled, but the locations are not, so if
|
||||
* we remove the first element of each list, chances are they
|
||||
* will not match, i.e. shuffle achieved! */
|
||||
|
|
|
@ -19,11 +19,11 @@ public class ThrowDistant implements Ability
|
|||
* How far away players must be to be affected by the ability.
|
||||
*/
|
||||
private static final int RADIUS = 8;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
Location bLoc = boss.getEntity().getLocation();
|
||||
|
||||
|
||||
for (Player p : AbilityUtils.getDistantPlayers(arena, boss.getEntity(), RADIUS)) {
|
||||
Location loc = p.getLocation();
|
||||
Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ());
|
||||
|
|
|
@ -19,11 +19,11 @@ public class ThrowNearby implements Ability
|
|||
* How close players must be to be affected by the ability.
|
||||
*/
|
||||
private static final int RADIUS = 5;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
Location bLoc = boss.getEntity().getLocation();
|
||||
|
||||
|
||||
for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) {
|
||||
Location loc = p.getLocation();
|
||||
Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ());
|
||||
|
|
|
@ -19,7 +19,7 @@ public class ThrowTarget implements Ability
|
|||
* If the boss has no target, should a random player be selected?
|
||||
*/
|
||||
private static final boolean RANDOM = false;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Arena arena, MABoss boss) {
|
||||
LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), RANDOM);
|
||||
|
@ -28,7 +28,7 @@ public class ThrowTarget implements Ability
|
|||
Location bLoc = boss.getEntity().getLocation();
|
||||
Location loc = target.getLocation();
|
||||
Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ());
|
||||
|
||||
|
||||
target.setVelocity(v.normalize().setY(0.8));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,16 +4,16 @@ public enum BossHealth
|
|||
{
|
||||
VERYLOW(4), LOW(8), MEDIUM(15), HIGH(25), VERYHIGH(40), PSYCHO(60);
|
||||
private int multiplier;
|
||||
|
||||
|
||||
BossHealth(int multiplier) {
|
||||
this.multiplier = multiplier;
|
||||
}
|
||||
|
||||
|
||||
public int getMax(int playerCount) {
|
||||
return (playerCount + 1) * 20 * multiplier;
|
||||
}
|
||||
|
||||
|
||||
public int getMultiplier() {
|
||||
return multiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,12 @@ public enum SwarmAmount
|
|||
{
|
||||
LOW(10), MEDIUM(20), HIGH(30), PSYCHO(60);
|
||||
private int multiplier;
|
||||
|
||||
|
||||
SwarmAmount(int multiplier) {
|
||||
this.multiplier = multiplier;
|
||||
}
|
||||
|
||||
|
||||
public int getAmount(int playerCount) {
|
||||
return Math.max(1, playerCount / 2) * multiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public enum WaveBranch
|
|||
return (w.getFirstWave() == wave);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
RECURRENT {
|
||||
@Override
|
||||
public boolean matches(int wave, Wave w) {
|
||||
|
@ -20,6 +20,6 @@ public enum WaveBranch
|
|||
return ((wave - w.getFirstWave()) % w.getFrequency() == 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public abstract boolean matches(int wave, Wave w);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue