mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-03-10 13:49:03 +01:00
Revamp the announcements system.
This commit transforms the announcements system in the following way: - announcements.yml makes it easier to add missing nodes and remove obsolete ones. This way, users don't have to delete their previous announcements-file to get the new keys. - Color codes are supported in the fact that when an announcement message is "set()", the string value has all of its &-symbols translated. - No need for a defaults-file, because the enum is very easy to compile into a YAML file.
This commit is contained in:
parent
22723d883a
commit
ef9fd267c1
@ -1,7 +1,7 @@
|
|||||||
name: MobArena
|
name: MobArena
|
||||||
author: garbagemule
|
author: garbagemule
|
||||||
main: com.garbagemule.MobArena.MobArena
|
main: com.garbagemule.MobArena.MobArena
|
||||||
version: 0.95.5.18
|
version: 0.95.5.19
|
||||||
softdepend: [Multiverse-Core,Towny,Heroes,MagicSpells,Vault]
|
softdepend: [Multiverse-Core,Towny,Heroes,MagicSpells,Vault]
|
||||||
commands:
|
commands:
|
||||||
ma:
|
ma:
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
ARENA_START=Let the slaughter begin!
|
|
||||||
ARENA_END=Arena finished.
|
|
||||||
ARENA_DOES_NOT_EXIST=That arena does not exist. Type /ma arenas for a list.
|
|
||||||
JOIN_PLAYER_JOINED=
|
|
||||||
JOIN_NOT_ENABLED=MobArena is not enabled.
|
|
||||||
JOIN_IN_OTHER_ARENA=You are already in an arena! Leave that one first.
|
|
||||||
JOIN_ARENA_NOT_ENABLED=This arena is not enabled.
|
|
||||||
JOIN_ARENA_NOT_SETUP=This arena has not been set up yet.
|
|
||||||
JOIN_ARENA_PERMISSION=You don't have permission to join this arena.
|
|
||||||
JOIN_FEE_REQUIRED=Insufficient funds. Price: %
|
|
||||||
JOIN_FEE_PAID=Price to join was: %
|
|
||||||
JOIN_ARENA_IS_RUNNING=This arena is already in progress.
|
|
||||||
JOIN_ALREADY_PLAYING=You are already playing!
|
|
||||||
JOIN_ARG_NEEDED=You must specify an arena. Type /ma arenas for a list.
|
|
||||||
JOIN_TOO_FAR=You are too far away from the arena to join/spectate.
|
|
||||||
JOIN_EMPTY_INV=You must empty your inventory to join the arena.
|
|
||||||
JOIN_PLAYER_LIMIT_REACHED=The player limit of this arena has been reached.
|
|
||||||
JOIN_STORE_INV_FAIL=Failed to store inventory. Try again.
|
|
||||||
LEAVE_PLAYER_LEFT=You left the arena. Thanks for playing!
|
|
||||||
LEAVE_NOT_PLAYING=You are not in the arena.
|
|
||||||
PLAYER_DIED=% died!
|
|
||||||
SPEC_PLAYER_SPECTATE=Enjoy the show!
|
|
||||||
SPEC_NOT_RUNNING=This arena isn't running.
|
|
||||||
SPEC_ARG_NEEDED=You must specify an arena. Type /ma arenas for a list.
|
|
||||||
SPEC_EMPTY_INV=Empty your inventory first!
|
|
||||||
SPEC_ALREADY_PLAYING=Can't spectate when in the arena!
|
|
||||||
NOT_READY_PLAYERS=Not ready: %
|
|
||||||
FORCE_START_STARTED=Forced arena start.
|
|
||||||
FORCE_START_RUNNING=Arena has already started.
|
|
||||||
FORCE_START_NOT_READY=Can't force start, no players are ready.
|
|
||||||
FORCE_END_ENDED=Forced arena end.
|
|
||||||
FORCE_END_EMPTY=No one is in the arena.
|
|
||||||
FORCE_END_IDLE=You weren't quick enough!
|
|
||||||
REWARDS_GIVE=Here are all of your rewards!
|
|
||||||
LOBBY_CLASS_PICKED=You have chosen % as your class!
|
|
||||||
LOBBY_CLASS_RANDOM=You will get a random class on arena start.
|
|
||||||
LOBBY_CLASS_PERMISSION=You don't have permission to use this class!
|
|
||||||
LOBBY_PLAYER_READY=You have been flagged as ready!
|
|
||||||
LOBBY_DROP_ITEM=No sharing before the arena starts!
|
|
||||||
LOBBY_PICK_CLASS=You must first pick a class!
|
|
||||||
LOBBY_RIGHT_CLICK=Punch the sign. Don't right-click.
|
|
||||||
WARP_TO_ARENA=Can't warp to the arena during battle!
|
|
||||||
WARP_FROM_ARENA=Warping not allowed in the arena!
|
|
||||||
WAVE_DEFAULT=Get ready for wave #%!
|
|
||||||
WAVE_SPECIAL=Get ready for wave #%! [SPECIAL]
|
|
||||||
WAVE_REWARD=You just earned a reward: %
|
|
||||||
MISC_LIST_ARENAS=Available arenas: %
|
|
||||||
MISC_LIST_PLAYERS=Live players: %
|
|
||||||
MISC_COMMAND_NOT_ALLOWED=You can't use that command in the arena!
|
|
||||||
MISC_NO_ACCESS=You don't have access to this command.
|
|
||||||
MISC_NONE=<none>
|
|
@ -248,14 +248,6 @@ public class ArenaImpl implements Arena
|
|||||||
return settings.getInt("max-join-distance");
|
return settings.getInt("max-join-distance");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Material getClassLogo(String classname) {
|
|
||||||
ArenaClass arenaClass = classes.get(classname);
|
|
||||||
if (arenaClass == null) return Material.STONE;
|
|
||||||
|
|
||||||
return arenaClass.getLogo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getEntryFee() {
|
public List<ItemStack> getEntryFee() {
|
||||||
return entryFee;
|
return entryFee;
|
||||||
@ -471,7 +463,7 @@ public class ArenaImpl implements Arena
|
|||||||
leaderboard.initialize();
|
leaderboard.initialize();
|
||||||
leaderboard.startTracking();
|
leaderboard.startTracking();
|
||||||
|
|
||||||
Messenger.tellAll(this, Msg.ARENA_START);
|
Messenger.announce(this, Msg.ARENA_START);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -508,10 +500,10 @@ public class ArenaImpl implements Arena
|
|||||||
// Announce and clean arena floor, etc.
|
// Announce and clean arena floor, etc.
|
||||||
if (settings.getBoolean("global-end-announce", false)) {
|
if (settings.getBoolean("global-end-announce", false)) {
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
Messenger.tellPlayer(p, Msg.ARENA_END_GLOBAL, configName());
|
Messenger.tell(p, Msg.ARENA_END_GLOBAL, configName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Messenger.tellAll(this, Msg.ARENA_END, true);
|
Messenger.announce(this, Msg.ARENA_END);
|
||||||
}
|
}
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
@ -543,7 +535,7 @@ public class ArenaImpl implements Arena
|
|||||||
// Force leave.
|
// Force leave.
|
||||||
for (Player p : tmp) {
|
for (Player p : tmp) {
|
||||||
playerLeave(p);
|
playerLeave(p);
|
||||||
Messenger.tellPlayer(p, Msg.LEAVE_NOT_READY);
|
Messenger.tell(p, Msg.LEAVE_NOT_READY);
|
||||||
}
|
}
|
||||||
|
|
||||||
startArena();
|
startArena();
|
||||||
@ -572,7 +564,7 @@ public class ArenaImpl implements Arena
|
|||||||
if (settings.getBoolean("global-first-join-announce", false)) {
|
if (settings.getBoolean("global-first-join-announce", false)) {
|
||||||
if (lobbyPlayers.isEmpty()) {
|
if (lobbyPlayers.isEmpty()) {
|
||||||
for (Player q : Bukkit.getOnlinePlayers()) {
|
for (Player q : Bukkit.getOnlinePlayers()) {
|
||||||
Messenger.tellPlayer(q, Msg.ARENA_JOIN_GLOBAL, configName());
|
Messenger.tell(q, Msg.ARENA_JOIN_GLOBAL, configName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -596,11 +588,11 @@ public class ArenaImpl implements Arena
|
|||||||
autoStartTimer.start();
|
autoStartTimer.start();
|
||||||
|
|
||||||
// Notify player of joining
|
// Notify player of joining
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_PLAYER_JOINED);
|
Messenger.tell(p, Msg.JOIN_PLAYER_JOINED);
|
||||||
|
|
||||||
// Notify player of time left
|
// Notify player of time left
|
||||||
if (autoStartTimer.isRunning()) {
|
if (autoStartTimer.isRunning()) {
|
||||||
Messenger.tellPlayer(p, Msg.ARENA_AUTO_START, "" + autoStartTimer.getRemaining());
|
Messenger.tell(p, Msg.ARENA_AUTO_START, "" + autoStartTimer.getRemaining());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -614,7 +606,7 @@ public class ArenaImpl implements Arena
|
|||||||
int minPlayers = getMinPlayers();
|
int minPlayers = getMinPlayers();
|
||||||
if (minPlayers > 0 && lobbyPlayers.size() < minPlayers)
|
if (minPlayers > 0 && lobbyPlayers.size() < minPlayers)
|
||||||
{
|
{
|
||||||
Messenger.tellPlayer(p, Msg.LOBBY_NOT_ENOUGH_PLAYERS, "" + minPlayers);
|
Messenger.tell(p, Msg.LOBBY_NOT_ENOUGH_PLAYERS, "" + minPlayers);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,8 +684,8 @@ public class ArenaImpl implements Arena
|
|||||||
|
|
||||||
if (settings.getBoolean("spectate-on-death", true)) {
|
if (settings.getBoolean("spectate-on-death", true)) {
|
||||||
movePlayerToSpec(p);
|
movePlayerToSpec(p);
|
||||||
Messenger.tellPlayer(p, Msg.SPEC_FROM_ARENA);
|
Messenger.tell(p, Msg.SPEC_FROM_ARENA);
|
||||||
Messenger.tellPlayer(p, Msg.MISC_MA_LEAVE_REMINDER);
|
Messenger.tell(p, Msg.MISC_MA_LEAVE_REMINDER);
|
||||||
} else {
|
} else {
|
||||||
restoreInvAndExp(p);
|
restoreInvAndExp(p);
|
||||||
movePlayerToEntry(p);
|
movePlayerToEntry(p);
|
||||||
@ -719,7 +711,7 @@ public class ArenaImpl implements Arena
|
|||||||
MAUtils.sitPets(p);
|
MAUtils.sitPets(p);
|
||||||
movePlayerToSpec(p);
|
movePlayerToSpec(p);
|
||||||
|
|
||||||
Messenger.tellPlayer(p, Msg.SPEC_PLAYER_SPECTATE);
|
Messenger.tell(p, Msg.SPEC_PLAYER_SPECTATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawnPets() {
|
private void spawnPets() {
|
||||||
@ -1101,7 +1093,7 @@ public class ArenaImpl implements Arena
|
|||||||
}
|
}
|
||||||
|
|
||||||
assignClass(p, className);
|
assignClass(p, className);
|
||||||
Messenger.tellPlayer(p, Msg.LOBBY_CLASS_PICKED, TextUtils.camelCase(className), getClassLogo(className));
|
Messenger.tell(p, Msg.LOBBY_CLASS_PICKED, TextUtils.camelCase(className));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1335,7 +1327,7 @@ public class ArenaImpl implements Arena
|
|||||||
inv.removeItem(stack);
|
inv.removeItem(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_FEE_PAID.toString(MAUtils.listToString(entryFee, plugin)));
|
Messenger.tell(p, Msg.JOIN_FEE_PAID.format(MAUtils.listToString(entryFee, plugin)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1361,25 +1353,25 @@ public class ArenaImpl implements Arena
|
|||||||
@Override
|
@Override
|
||||||
public boolean canJoin(Player p) {
|
public boolean canJoin(Player p) {
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_ARENA_NOT_ENABLED);
|
Messenger.tell(p, Msg.JOIN_ARENA_NOT_ENABLED);
|
||||||
else if (!region.isSetup() || waveManager.getRecurrentWaves().isEmpty())
|
else if (!region.isSetup() || waveManager.getRecurrentWaves().isEmpty())
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_ARENA_NOT_SETUP);
|
Messenger.tell(p, Msg.JOIN_ARENA_NOT_SETUP);
|
||||||
else if (edit)
|
else if (edit)
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_ARENA_EDIT_MODE);
|
Messenger.tell(p, Msg.JOIN_ARENA_EDIT_MODE);
|
||||||
else if (arenaPlayers.contains(p) || lobbyPlayers.contains(p))
|
else if (arenaPlayers.contains(p) || lobbyPlayers.contains(p))
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_ALREADY_PLAYING);
|
Messenger.tell(p, Msg.JOIN_ALREADY_PLAYING);
|
||||||
else if (running)
|
else if (running)
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_ARENA_IS_RUNNING);
|
Messenger.tell(p, Msg.JOIN_ARENA_IS_RUNNING);
|
||||||
else if (!plugin.has(p, "mobarena.arenas." + configName()))
|
else if (!plugin.has(p, "mobarena.arenas." + configName()))
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_ARENA_PERMISSION);
|
Messenger.tell(p, Msg.JOIN_ARENA_PERMISSION);
|
||||||
else if (getMaxPlayers() > 0 && lobbyPlayers.size() >= getMaxPlayers())
|
else if (getMaxPlayers() > 0 && lobbyPlayers.size() >= getMaxPlayers())
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_PLAYER_LIMIT_REACHED);
|
Messenger.tell(p, Msg.JOIN_PLAYER_LIMIT_REACHED);
|
||||||
else if (getJoinDistance() > 0 && !region.contains(p.getLocation(), getJoinDistance()))
|
else if (getJoinDistance() > 0 && !region.contains(p.getLocation(), getJoinDistance()))
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_TOO_FAR);
|
Messenger.tell(p, Msg.JOIN_TOO_FAR);
|
||||||
else if (settings.getBoolean("require-empty-inv-join", true) && !InventoryManager.hasEmptyInventory(p))
|
else if (settings.getBoolean("require-empty-inv-join", true) && !InventoryManager.hasEmptyInventory(p))
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_EMPTY_INV);
|
Messenger.tell(p, Msg.JOIN_EMPTY_INV);
|
||||||
else if (!canAfford(p))
|
else if (!canAfford(p))
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_FEE_REQUIRED, MAUtils.listToString(entryFee, plugin));
|
Messenger.tell(p, Msg.JOIN_FEE_REQUIRED, MAUtils.listToString(entryFee, plugin));
|
||||||
else return true;
|
else return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -1388,17 +1380,17 @@ public class ArenaImpl implements Arena
|
|||||||
@Override
|
@Override
|
||||||
public boolean canSpec(Player p) {
|
public boolean canSpec(Player p) {
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_ARENA_NOT_ENABLED);
|
Messenger.tell(p, Msg.JOIN_ARENA_NOT_ENABLED);
|
||||||
else if (!region.isSetup())
|
else if (!region.isSetup())
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_ARENA_NOT_SETUP);
|
Messenger.tell(p, Msg.JOIN_ARENA_NOT_SETUP);
|
||||||
else if (edit)
|
else if (edit)
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_ARENA_EDIT_MODE);
|
Messenger.tell(p, Msg.JOIN_ARENA_EDIT_MODE);
|
||||||
else if (arenaPlayers.contains(p) || lobbyPlayers.contains(p))
|
else if (arenaPlayers.contains(p) || lobbyPlayers.contains(p))
|
||||||
Messenger.tellPlayer(p, Msg.SPEC_ALREADY_PLAYING);
|
Messenger.tell(p, Msg.SPEC_ALREADY_PLAYING);
|
||||||
else if (settings.getBoolean("require-empty-inv-spec", true) && !InventoryManager.hasEmptyInventory(p))
|
else if (settings.getBoolean("require-empty-inv-spec", true) && !InventoryManager.hasEmptyInventory(p))
|
||||||
Messenger.tellPlayer(p, Msg.SPEC_EMPTY_INV);
|
Messenger.tell(p, Msg.SPEC_EMPTY_INV);
|
||||||
else if (getJoinDistance() > 0 && !region.contains(p.getLocation(), getJoinDistance()))
|
else if (getJoinDistance() > 0 && !region.contains(p.getLocation(), getJoinDistance()))
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_TOO_FAR);
|
Messenger.tell(p, Msg.JOIN_TOO_FAR);
|
||||||
else return true;
|
else return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.garbagemule.MobArena;
|
package com.garbagemule.MobArena;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -68,9 +67,6 @@ import org.bukkit.metadata.Metadatable;
|
|||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import com.garbagemule.MobArena.MAUtils;
|
|
||||||
import com.garbagemule.MobArena.MobArena;
|
|
||||||
import com.garbagemule.MobArena.Msg;
|
|
||||||
import com.garbagemule.MobArena.framework.Arena;
|
import com.garbagemule.MobArena.framework.Arena;
|
||||||
import com.garbagemule.MobArena.leaderboards.Leaderboard;
|
import com.garbagemule.MobArena.leaderboards.Leaderboard;
|
||||||
import com.garbagemule.MobArena.listeners.MAGlobalListener.TeleportResponse;
|
import com.garbagemule.MobArena.listeners.MAGlobalListener.TeleportResponse;
|
||||||
@ -310,7 +306,7 @@ public class ArenaListener
|
|||||||
arena.setLeaderboard(new Leaderboard(plugin, arena, event.getBlock().getLocation()));
|
arena.setLeaderboard(new Leaderboard(plugin, arena, event.getBlock().getLocation()));
|
||||||
arena.getRegion().set(RegionPoint.LEADERBOARD, event.getBlock().getLocation());
|
arena.getRegion().set(RegionPoint.LEADERBOARD, event.getBlock().getLocation());
|
||||||
|
|
||||||
Messenger.tellPlayer(event.getPlayer(), "Leaderboard made. Now set up the stat signs!");
|
Messenger.tell(event.getPlayer(), "Leaderboard made. Now set up the stat signs!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||||
@ -418,7 +414,7 @@ public class ArenaListener
|
|||||||
onMountDeath(event);
|
onMountDeath(event);
|
||||||
}
|
}
|
||||||
else if (monsters.removeGolem(event.getEntity())) {
|
else if (monsters.removeGolem(event.getEntity())) {
|
||||||
Messenger.tellAll(arena, Msg.GOLEM_DIED);
|
Messenger.announce(arena, Msg.GOLEM_DIED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,7 +484,7 @@ public class ArenaListener
|
|||||||
msg += MAUtils.toCamelCase(reward.getType().toString()) + ":" + reward.getAmount();
|
msg += MAUtils.toCamelCase(reward.getType().toString()) + ":" + reward.getAmount();
|
||||||
}
|
}
|
||||||
for (Player q : arena.getPlayersInArena()) {
|
for (Player q : arena.getPlayersInArena()) {
|
||||||
Messenger.tellPlayer(q, msg);
|
Messenger.tell(q, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -792,25 +788,25 @@ public class ArenaListener
|
|||||||
// If the player is active in the arena, only cancel if sharing is not allowed
|
// If the player is active in the arena, only cancel if sharing is not allowed
|
||||||
if (arena.inArena(p)) {
|
if (arena.inArena(p)) {
|
||||||
if (!canShare) {
|
if (!canShare) {
|
||||||
Messenger.tellPlayer(p, Msg.LOBBY_DROP_ITEM);
|
Messenger.tell(p, Msg.LOBBY_DROP_ITEM);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the player is in the lobby, just cancel
|
// If the player is in the lobby, just cancel
|
||||||
else if (arena.inLobby(p)) {
|
else if (arena.inLobby(p)) {
|
||||||
Messenger.tellPlayer(p, Msg.LOBBY_DROP_ITEM);
|
Messenger.tell(p, Msg.LOBBY_DROP_ITEM);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same if it's a spectator, but...
|
// Same if it's a spectator, but...
|
||||||
else if (arena.inSpec(p)) {
|
else if (arena.inSpec(p)) {
|
||||||
Messenger.tellPlayer(p, Msg.LOBBY_DROP_ITEM);
|
Messenger.tell(p, Msg.LOBBY_DROP_ITEM);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
// If the spectator isn't in the region, force them to leave
|
// If the spectator isn't in the region, force them to leave
|
||||||
if (!region.contains(p.getLocation())) {
|
if (!region.contains(p.getLocation())) {
|
||||||
Messenger.tellPlayer(p, Msg.MISC_MA_LEAVE_REMINDER);
|
Messenger.tell(p, Msg.MISC_MA_LEAVE_REMINDER);
|
||||||
arena.playerLeave(p);
|
arena.playerLeave(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -821,7 +817,7 @@ public class ArenaListener
|
|||||||
* they are trying to drop items when not allowed
|
* they are trying to drop items when not allowed
|
||||||
*/
|
*/
|
||||||
else if (region.contains(p.getLocation())) {
|
else if (region.contains(p.getLocation())) {
|
||||||
Messenger.tellPlayer(p, Msg.LOBBY_DROP_ITEM);
|
Messenger.tell(p, Msg.LOBBY_DROP_ITEM);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -882,11 +878,11 @@ public class ArenaListener
|
|||||||
|
|
||||||
private void handleReadyBlock(Player p) {
|
private void handleReadyBlock(Player p) {
|
||||||
if (arena.getArenaPlayer(p).getArenaClass() != null) {
|
if (arena.getArenaPlayer(p).getArenaClass() != null) {
|
||||||
Messenger.tellPlayer(p, Msg.LOBBY_PLAYER_READY);
|
Messenger.tell(p, Msg.LOBBY_PLAYER_READY);
|
||||||
arena.playerReady(p);
|
arena.playerReady(p);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Messenger.tellPlayer(p, Msg.LOBBY_PICK_CLASS);
|
Messenger.tell(p, Msg.LOBBY_PICK_CLASS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -899,7 +895,7 @@ public class ArenaListener
|
|||||||
|
|
||||||
// Check for permission.
|
// Check for permission.
|
||||||
if (!plugin.has(p, "mobarena.classes." + className) && !className.equals("random")) {
|
if (!plugin.has(p, "mobarena.classes." + className) && !className.equals("random")) {
|
||||||
Messenger.tellPlayer(p, Msg.LOBBY_CLASS_PERMISSION);
|
Messenger.tell(p, Msg.LOBBY_CLASS_PERMISSION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -913,7 +909,7 @@ public class ArenaListener
|
|||||||
|
|
||||||
// If the new class is full, inform the player.
|
// If the new class is full, inform the player.
|
||||||
if (!classLimits.canPlayerJoinClass(newAC)) {
|
if (!classLimits.canPlayerJoinClass(newAC)) {
|
||||||
Messenger.tellPlayer(p, Msg.LOBBY_CLASS_FULL);
|
Messenger.tell(p, Msg.LOBBY_CLASS_FULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -928,7 +924,7 @@ public class ArenaListener
|
|||||||
/*private boolean cansPlayerJoinClass(ArenaClass ac, Player p) {
|
/*private boolean cansPlayerJoinClass(ArenaClass ac, Player p) {
|
||||||
// If they can not join the class, deny them
|
// If they can not join the class, deny them
|
||||||
if (!classLimits.canPlayerJoinClass(ac)) {
|
if (!classLimits.canPlayerJoinClass(ac)) {
|
||||||
Messenger.tellPlayer(p, Msg.LOBBY_CLASS_FULL);
|
Messenger.tell(p, Msg.LOBBY_CLASS_FULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -985,17 +981,17 @@ public class ArenaListener
|
|||||||
}
|
}
|
||||||
arena.assignClassGiveInv(p, className, contents);
|
arena.assignClassGiveInv(p, className, contents);
|
||||||
p.getInventory().setContents(contents);
|
p.getInventory().setContents(contents);
|
||||||
Messenger.tellPlayer(p, Msg.LOBBY_CLASS_PICKED, TextUtils.camelCase(className), arena.getClassLogo(className));
|
Messenger.tell(p, Msg.LOBBY_CLASS_PICKED, TextUtils.camelCase(className));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Otherwise just fall through and use the items from the config-file
|
// Otherwise just fall through and use the items from the config-file
|
||||||
}
|
}
|
||||||
arena.assignClass(p, className);
|
arena.assignClass(p, className);
|
||||||
Messenger.tellPlayer(p, Msg.LOBBY_CLASS_PICKED, TextUtils.camelCase(className), arena.getClassLogo(className));
|
Messenger.tell(p, Msg.LOBBY_CLASS_PICKED, TextUtils.camelCase(className));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
arena.addRandomPlayer(p);
|
arena.addRandomPlayer(p);
|
||||||
Messenger.tellPlayer(p, Msg.LOBBY_CLASS_RANDOM);
|
Messenger.tell(p, Msg.LOBBY_CLASS_RANDOM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1065,7 +1061,7 @@ public class ArenaListener
|
|||||||
return TeleportResponse.ALLOW;
|
return TeleportResponse.ALLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tellPlayer(p, Msg.WARP_FROM_ARENA);
|
Messenger.tell(p, Msg.WARP_FROM_ARENA);
|
||||||
return TeleportResponse.REJECT;
|
return TeleportResponse.REJECT;
|
||||||
}
|
}
|
||||||
else if (region.contains(to)) {
|
else if (region.contains(to)) {
|
||||||
@ -1078,7 +1074,7 @@ public class ArenaListener
|
|||||||
return TeleportResponse.ALLOW;
|
return TeleportResponse.ALLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tellPlayer(p, Msg.WARP_TO_ARENA);
|
Messenger.tell(p, Msg.WARP_TO_ARENA);
|
||||||
return TeleportResponse.REJECT;
|
return TeleportResponse.REJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1111,7 +1107,7 @@ public class ArenaListener
|
|||||||
|
|
||||||
// Cancel the event regardless.
|
// Cancel the event regardless.
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
Messenger.tellPlayer(p, Msg.MISC_COMMAND_NOT_ALLOWED);
|
Messenger.tell(p, Msg.MISC_COMMAND_NOT_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerPreLogin(PlayerLoginEvent event) {
|
public void onPlayerPreLogin(PlayerLoginEvent event) {
|
||||||
|
@ -1,117 +0,0 @@
|
|||||||
package com.garbagemule.MobArena;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
|
|
||||||
import com.garbagemule.MobArena.MobArena;
|
|
||||||
import com.garbagemule.MobArena.Msg;
|
|
||||||
|
|
||||||
public class MAMessages
|
|
||||||
{
|
|
||||||
public static void init(MobArena plugin) {
|
|
||||||
// Grab the file
|
|
||||||
File msgFile = new File(plugin.getDataFolder(), "announcements.properties");
|
|
||||||
|
|
||||||
// If it couldn't be loaded for some reason
|
|
||||||
if (!load(plugin, msgFile))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Otherwise, start parsing!
|
|
||||||
parseFile(plugin, msgFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean load(MobArena plugin, File file) {
|
|
||||||
// If the file exists, continue on!
|
|
||||||
if (file.exists()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, create it, and populate it with the defaults.
|
|
||||||
try {
|
|
||||||
file.createNewFile();
|
|
||||||
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
|
|
||||||
|
|
||||||
for (Msg m : Msg.values()) {
|
|
||||||
if (m.hasSpoutMsg()) {
|
|
||||||
bw.write(m.name() + "=" + m + "|" + m.toSpoutString());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
bw.write(m.name() + "=" + m);
|
|
||||||
}
|
|
||||||
bw.newLine();
|
|
||||||
}
|
|
||||||
bw.close();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
Messenger.warning("Couldn't initialize announcements-file. Using defaults.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void parseFile(MobArena plugin, File file) {
|
|
||||||
try {
|
|
||||||
FileInputStream fis = new FileInputStream(file);
|
|
||||||
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
|
|
||||||
BufferedReader br = new BufferedReader(isr);
|
|
||||||
|
|
||||||
// Check for BOM character.
|
|
||||||
br.mark(1);
|
|
||||||
int bom = br.read();
|
|
||||||
if (bom != 65279)
|
|
||||||
br.reset();
|
|
||||||
|
|
||||||
String s;
|
|
||||||
while ((s = br.readLine()) != null)
|
|
||||||
process(plugin, s);
|
|
||||||
|
|
||||||
br.close();
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Messenger.warning("Problem with announcements-file. Using defaults.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper-method for parsing the strings from the
|
|
||||||
* announcements-file.
|
|
||||||
*/
|
|
||||||
private static void process(MobArena plugin, String s) {
|
|
||||||
// If the line ends with = or |, just add a space
|
|
||||||
if (s.endsWith("=") || s.endsWith("|")) {
|
|
||||||
s += " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Split the string by the equals-sign.
|
|
||||||
String[] split = s.split("=");
|
|
||||||
if (split.length != 2) {
|
|
||||||
Messenger.warning("Couldn't parse \"" + s + "\". Check announcements-file.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Split the value by the pipe-sign.
|
|
||||||
String[] vals = split[1].split("\\|");
|
|
||||||
|
|
||||||
// For simplicity...
|
|
||||||
String key = split[0];
|
|
||||||
String val = vals.length == 2 ? vals[0] : split[1];
|
|
||||||
String spoutVal = vals.length == 2 ? vals[1] : null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
Msg msg = Msg.valueOf(key);
|
|
||||||
msg.set(val);
|
|
||||||
msg.setSpout(spoutVal);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
Messenger.warning(key + " is not a valid key. Check announcements-file.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,14 +9,9 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Creature;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.garbagemule.MobArena.ArenaPlayer;
|
|
||||||
import com.garbagemule.MobArena.MAUtils;
|
|
||||||
import com.garbagemule.MobArena.MobArena;
|
|
||||||
import com.garbagemule.MobArena.Msg;
|
|
||||||
import com.garbagemule.MobArena.events.NewWaveEvent;
|
import com.garbagemule.MobArena.events.NewWaveEvent;
|
||||||
import com.garbagemule.MobArena.framework.Arena;
|
import com.garbagemule.MobArena.framework.Arena;
|
||||||
import com.garbagemule.MobArena.region.ArenaRegion;
|
import com.garbagemule.MobArena.region.ArenaRegion;
|
||||||
@ -274,7 +269,7 @@ public class MASpawnThread implements Runnable
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tellPlayer(p, "Leaving so soon?");
|
Messenger.tell(p, "Leaving so soon?");
|
||||||
p.getInventory().clear();
|
p.getInventory().clear();
|
||||||
arena.playerLeave(p);
|
arena.playerLeave(p);
|
||||||
}
|
}
|
||||||
@ -322,19 +317,19 @@ public class MASpawnThread implements Runnable
|
|||||||
rewardManager.addReward(p, reward);
|
rewardManager.addReward(p, reward);
|
||||||
|
|
||||||
if (reward == null) {
|
if (reward == null) {
|
||||||
Messenger.tellPlayer(p, "ERROR! Problem with rewards. Notify server host!");
|
Messenger.tell(p, "ERROR! Problem with rewards. Notify server host!");
|
||||||
Messenger.warning("Could not add null reward. Please check the config-file!");
|
Messenger.warning("Could not add null reward. Please check the config-file!");
|
||||||
}
|
}
|
||||||
else if (reward.getTypeId() == MobArena.ECONOMY_MONEY_ID) {
|
else if (reward.getTypeId() == MobArena.ECONOMY_MONEY_ID) {
|
||||||
if (plugin.giveMoney(p, reward)) { // Money already awarded here, not needed at end of match as well
|
if (plugin.giveMoney(p, reward)) { // Money already awarded here, not needed at end of match as well
|
||||||
Messenger.tellPlayer(p, Msg.WAVE_REWARD, plugin.economyFormat(reward));
|
Messenger.tell(p, Msg.WAVE_REWARD, plugin.economyFormat(reward));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Messenger.warning("Tried to add money, but no economy plugin detected!");
|
Messenger.warning("Tried to add money, but no economy plugin detected!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Messenger.tellPlayer(p, Msg.WAVE_REWARD, MAUtils.toCamelCase(reward.getType().toString()) + ":" + reward.getAmount(), reward.getType());
|
Messenger.tell(p, Msg.WAVE_REWARD, MAUtils.toCamelCase(reward.getType().toString()) + ":" + reward.getAmount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,16 +26,12 @@ import org.bukkit.entity.Wolf;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import com.garbagemule.MobArena.MAUtils;
|
|
||||||
import com.garbagemule.MobArena.MobArena;
|
|
||||||
import com.garbagemule.MobArena.Msg;
|
|
||||||
import com.garbagemule.MobArena.framework.Arena;
|
import com.garbagemule.MobArena.framework.Arena;
|
||||||
import com.garbagemule.MobArena.framework.ArenaMaster;
|
import com.garbagemule.MobArena.framework.ArenaMaster;
|
||||||
import com.garbagemule.MobArena.region.ArenaRegion;
|
import com.garbagemule.MobArena.region.ArenaRegion;
|
||||||
import com.garbagemule.MobArena.util.EntityPosition;
|
import com.garbagemule.MobArena.util.EntityPosition;
|
||||||
import com.garbagemule.MobArena.util.ItemParser;
|
import com.garbagemule.MobArena.util.ItemParser;
|
||||||
import com.garbagemule.MobArena.util.TextUtils;
|
import com.garbagemule.MobArena.util.TextUtils;
|
||||||
import com.garbagemule.MobArena.util.config.ConfigUtils;
|
|
||||||
|
|
||||||
public class MAUtils
|
public class MAUtils
|
||||||
{
|
{
|
||||||
@ -59,7 +55,7 @@ public class MAUtils
|
|||||||
//String arenaPath = "arenas." + arena + ".rewards.waves.";
|
//String arenaPath = "arenas." + arena + ".rewards.waves.";
|
||||||
Map<Integer,List<ItemStack>> result = new HashMap<Integer,List<ItemStack>>();
|
Map<Integer,List<ItemStack>> result = new HashMap<Integer,List<ItemStack>>();
|
||||||
|
|
||||||
String typePath = "rewards." + type;
|
String typePath = "rewards.waves." + type;
|
||||||
if (!config.contains(typePath)) return result;
|
if (!config.contains(typePath)) return result;
|
||||||
|
|
||||||
//Set<String> waves = config.getKeys(arenaPath + type);
|
//Set<String> waves = config.getKeys(arenaPath + type);
|
||||||
@ -147,7 +143,7 @@ public class MAUtils
|
|||||||
if (!arena.getWorld().equals(p.getWorld())) {
|
if (!arena.getWorld().equals(p.getWorld())) {
|
||||||
Messenger.info("Player '" + p.getName() + "' is not in the right world. Kicking...");
|
Messenger.info("Player '" + p.getName() + "' is not in the right world. Kicking...");
|
||||||
p.kickPlayer("[MobArena] Cheater! (Warped out of the arena world.)");
|
p.kickPlayer("[MobArena] Cheater! (Warped out of the arena world.)");
|
||||||
Messenger.tellPlayer(p, "You warped out of the arena world.");
|
Messenger.tell(p, "You warped out of the arena world.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import java.util.List;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -19,51 +18,41 @@ public class Messenger
|
|||||||
|
|
||||||
private Messenger() {}
|
private Messenger() {}
|
||||||
|
|
||||||
public static boolean tellPlayer(CommandSender p, String msg) {
|
public static boolean tell(CommandSender p, String msg) {
|
||||||
// If the input sender is null or the string is empty, return.
|
// If the input sender is null or the string is empty, return.
|
||||||
if (p == null || msg.equals(" "))
|
if (p == null || msg.equals(" ")) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Otherwise, send the message with the [MobArena] tag.
|
// Otherwise, send the message with the [MobArena] tag.
|
||||||
p.sendMessage(ChatColor.GREEN + "[MobArena] " + ChatColor.WHITE + msg);
|
p.sendMessage(ChatColor.GREEN + "[MobArena] " + ChatColor.RESET + msg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean tellPlayer(CommandSender p, Msg msg, String s, boolean spout, Material logo) {
|
public static boolean tell(CommandSender p, Msg msg, String s) {
|
||||||
return tellPlayer(p, msg.toString(s));
|
return tell(p, msg.format(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean tellPlayer(CommandSender p, Msg msg, String s, Material logo) {
|
public static boolean tell(CommandSender p, Msg msg) {
|
||||||
return tellPlayer(p, msg.toString(s));
|
return tell(p, msg.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean tellPlayer(CommandSender p, Msg msg, String s) {
|
public static void announce(Arena arena, String msg) {
|
||||||
return tellPlayer(p, msg.toString(s));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean tellPlayer(CommandSender p, Msg msg) {
|
|
||||||
return tellPlayer(p, msg.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void tellAll(Arena arena, Msg msg, String s, boolean notifyPlayers) {
|
|
||||||
List<Player> players = new ArrayList<Player>();
|
List<Player> players = new ArrayList<Player>();
|
||||||
players.addAll(arena.getPlayersInArena());
|
players.addAll(arena.getPlayersInArena());
|
||||||
players.addAll(arena.getPlayersInLobby());
|
players.addAll(arena.getPlayersInLobby());
|
||||||
players.addAll(arena.getSpectators());
|
players.addAll(arena.getSpectators());
|
||||||
for (Player p : players)
|
for (Player p : players) {
|
||||||
tellPlayer(p, msg, s);
|
tell(p, msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void tellAll(Arena arena, Msg msg, String s) {
|
public static void announce(Arena arena, Msg msg, String s) {
|
||||||
tellAll(arena, msg, s, false);
|
announce(arena, msg.format(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void tellAll(Arena arena, Msg msg, boolean notifyPlayers) {
|
public static void announce(Arena arena, Msg msg) {
|
||||||
tellAll(arena, msg, null, notifyPlayers);
|
announce(arena, msg.toString());
|
||||||
}
|
|
||||||
|
|
||||||
public static void tellAll(Arena arena, Msg msg) {
|
|
||||||
tellAll(arena, msg, null, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void info(String msg) {
|
public static void info(String msg) {
|
||||||
|
@ -11,6 +11,7 @@ import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
|||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -59,6 +60,9 @@ public class MobArena extends JavaPlugin
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Initialize config-file
|
// Initialize config-file
|
||||||
loadConfigFile();
|
loadConfigFile();
|
||||||
|
|
||||||
|
// Initialize announcements-file
|
||||||
|
loadAnnouncementsFile();
|
||||||
|
|
||||||
// Load boss abilities
|
// Load boss abilities
|
||||||
loadAbilities();
|
loadAbilities();
|
||||||
@ -76,9 +80,6 @@ public class MobArena extends JavaPlugin
|
|||||||
// Register any inventories to restore.
|
// Register any inventories to restore.
|
||||||
registerInventories();
|
registerInventories();
|
||||||
|
|
||||||
// Make sure all the announcements are configured.
|
|
||||||
MAMessages.init(this);
|
|
||||||
|
|
||||||
// Register event listeners
|
// Register event listeners
|
||||||
registerListeners();
|
registerListeners();
|
||||||
|
|
||||||
@ -113,6 +114,31 @@ public class MobArena extends JavaPlugin
|
|||||||
getConfig().options().header(getHeader());
|
getConfig().options().header(getHeader());
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadAnnouncementsFile() {
|
||||||
|
// Create if missing
|
||||||
|
File file = new File(getDataFolder(), "announcements.yml");
|
||||||
|
try {
|
||||||
|
if (file.createNewFile()) {
|
||||||
|
Messenger.info("announcements.yml created.");
|
||||||
|
YamlConfiguration yaml = Msg.toYaml();
|
||||||
|
yaml.save(file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, load the announcements from the file
|
||||||
|
try {
|
||||||
|
YamlConfiguration yaml = new YamlConfiguration();
|
||||||
|
yaml.load(file);
|
||||||
|
ConfigUtils.addMissingRemoveObsolete(file, Msg.toYaml(), yaml);
|
||||||
|
Msg.load(yaml);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void registerListeners() {
|
private void registerListeners() {
|
||||||
// Bind the /ma, /mobarena commands to MACommands.
|
// Bind the /ma, /mobarena commands to MACommands.
|
||||||
|
@ -1,45 +1,46 @@
|
|||||||
package com.garbagemule.MobArena;
|
package com.garbagemule.MobArena;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
public enum Msg
|
public enum Msg {
|
||||||
{
|
ARENA_START("Let the slaughter begin!"),
|
||||||
ARENA_START("Let the slaughter begin!", "Arena started!", Material.REDSTONE_TORCH_ON),
|
ARENA_END("Arena finished."),
|
||||||
ARENA_END("Arena finished.", "Arena finished.", Material.REDSTONE_TORCH_OFF),
|
ARENA_DOES_NOT_EXIST("That arena does not exist. Type &e/ma arenas&r for a list."),
|
||||||
ARENA_END_GLOBAL("Arena '%' finished! Type /ma j % to join a new game!"),
|
ARENA_END_GLOBAL("Arena &e%&r finished! Type &e/ma j %&r to join a new game!"),
|
||||||
ARENA_JOIN_GLOBAL("Arena '%' is about to start! Type /ma j % to join!"),
|
ARENA_JOIN_GLOBAL("Arena &e%&r is about to start! Type &e/ma j %&r to join!"),
|
||||||
ARENA_DOES_NOT_EXIST("That arena does not exist. Type /ma arenas for a list.", "Can't find arena."),
|
|
||||||
ARENA_LBOARD_NOT_FOUND("That arena does not have a leaderboard set up."),
|
ARENA_LBOARD_NOT_FOUND("That arena does not have a leaderboard set up."),
|
||||||
ARENA_AUTO_START("Arena will auto-start in % seconds."),
|
ARENA_AUTO_START("Arena will auto-start in &c%&r seconds."),
|
||||||
JOIN_NOT_ENABLED("MobArena is not enabled.", "MobArena disabled.", Material.REDSTONE_TORCH_OFF),
|
JOIN_NOT_ENABLED("MobArena is not enabled."),
|
||||||
JOIN_IN_OTHER_ARENA("You are already in an arena! Leave that one first.", "In another arena."),
|
JOIN_IN_OTHER_ARENA("You are already in an arena! Leave that one first."),
|
||||||
JOIN_ARENA_NOT_ENABLED("This arena is not enabled.", "Arena disabled.", Material.REDSTONE_TORCH_OFF),
|
JOIN_ARENA_NOT_ENABLED("This arena is not enabled."),
|
||||||
JOIN_ARENA_NOT_SETUP("This arena has not been set up yet.", "Arena not set up.", Material.REDSTONE_TORCH_OFF),
|
JOIN_ARENA_NOT_SETUP("This arena has not been set up yet."),
|
||||||
JOIN_ARENA_EDIT_MODE("This arena is in edit mode.", "Arena in edit mode.", Material.IRON_SPADE),
|
JOIN_ARENA_EDIT_MODE("This arena is in edit mode."),
|
||||||
JOIN_ARENA_PERMISSION("You don't have permission to join this arena.", "No permission!", Material.FENCE),
|
JOIN_ARENA_PERMISSION("You don't have permission to join this arena."),
|
||||||
JOIN_FEE_REQUIRED("Insufficient funds. Price: %", "Price: %", Material.DIAMOND),
|
JOIN_FEE_REQUIRED("Insufficient funds. Price: &c%&r"),
|
||||||
JOIN_FEE_PAID("Price to join was: %", "Paid: %", Material.DIAMOND),
|
JOIN_FEE_PAID("Price to join was: &c%&r"),
|
||||||
JOIN_ARENA_IS_RUNNING("This arena is in already progress.", "Already running!", Material.GOLD_RECORD),
|
JOIN_ARENA_IS_RUNNING("This arena is in already progress."),
|
||||||
JOIN_ALREADY_PLAYING("You are already playing!", "Already playing!", Material.GOLD_RECORD),
|
JOIN_ALREADY_PLAYING("You are already playing!"),
|
||||||
JOIN_ARG_NEEDED("You must specify an arena."),
|
JOIN_ARG_NEEDED("You must specify an arena."),
|
||||||
JOIN_NO_PERMISSION("You don't have permission to join any arenas."),
|
JOIN_NO_PERMISSION("You don't have permission to join any arenas."),
|
||||||
JOIN_TOO_FAR("You are too far away from the arena to join/spectate.", "Too far from arena.", Material.COMPASS),
|
JOIN_TOO_FAR("You are too far away from the arena to join/spectate."),
|
||||||
JOIN_EMPTY_INV("You must empty your inventory to join the arena.", "Empty your inventory.", Material.CHEST),
|
JOIN_EMPTY_INV("You must empty your inventory to join the arena."),
|
||||||
JOIN_PLAYER_LIMIT_REACHED("The player limit of this arena has been reached.", "No spots left.", Material.MILK_BUCKET),
|
JOIN_PLAYER_LIMIT_REACHED("The player limit of this arena has been reached."),
|
||||||
JOIN_STORE_INV_FAIL("Failed to store inventory. Try again."),
|
JOIN_STORE_INV_FAIL("Failed to store inventory. Try again."),
|
||||||
JOIN_EXISTING_INV_RESTORED("Your old inventory items have been restored."),
|
JOIN_EXISTING_INV_RESTORED("Your old inventory items have been restored."),
|
||||||
JOIN_PLAYER_JOINED("You joined the arena. Have fun!", "Joined arena.", Material.IRON_SWORD),
|
JOIN_PLAYER_JOINED("You joined the arena. Have fun!"),
|
||||||
LEAVE_NOT_PLAYING("You are not in the arena.", "Not in arena."),
|
LEAVE_NOT_PLAYING("You are not in the arena."),
|
||||||
LEAVE_NOT_READY("You did not ready up in time! Next time, ready up by clicking an iron block."),
|
LEAVE_NOT_READY("You did not ready up in time! Next time, ready up by clicking an iron block."),
|
||||||
LEAVE_PLAYER_LEFT("You left the arena. Thanks for playing!", "Left arena.", Material.WOOD_DOOR),
|
LEAVE_PLAYER_LEFT("You left the arena. Thanks for playing!"),
|
||||||
PLAYER_DIED("% died!", "% died!", Material.BONE),
|
PLAYER_DIED("&c%&r died!"),
|
||||||
GOLEM_DIED("A friendly Golem has died!", "A Golem has died!", Material.PUMPKIN),
|
GOLEM_DIED("A friendly Golem has died!"),
|
||||||
SPEC_PLAYER_SPECTATE("Enjoy the show!", "Enjoy the show!"),
|
SPEC_PLAYER_SPECTATE("Enjoy the show!"),
|
||||||
SPEC_FROM_ARENA("Enjoy the rest of the show!", "Enjoy the show!"),
|
SPEC_FROM_ARENA("Enjoy the rest of the show!"),
|
||||||
SPEC_NOT_RUNNING("This arena isn't running.", "Arena not running.", Material.REDSTONE_TORCH_OFF),
|
SPEC_NOT_RUNNING("This arena isn't running."),
|
||||||
SPEC_EMPTY_INV("Empty your inventory first!", "Empty your inventory.", Material.CHEST),
|
SPEC_EMPTY_INV("Empty your inventory first!"),
|
||||||
SPEC_ALREADY_PLAYING("Can't spectate when in the arena!", "Already playing!"),
|
SPEC_ALREADY_PLAYING("Can't spectate when in the arena!"),
|
||||||
NOT_READY_PLAYERS("Not ready: %"),
|
NOT_READY_PLAYERS("Not ready: &c%&r"),
|
||||||
FORCE_START_RUNNING("Arena has already started."),
|
FORCE_START_RUNNING("Arena has already started."),
|
||||||
FORCE_START_NOT_READY("Can't force start, no players are ready."),
|
FORCE_START_NOT_READY("Can't force start, no players are ready."),
|
||||||
FORCE_START_STARTED("Forced arena start."),
|
FORCE_START_STARTED("Forced arena start."),
|
||||||
@ -47,136 +48,70 @@ public enum Msg
|
|||||||
FORCE_END_ENDED("Forced arena end."),
|
FORCE_END_ENDED("Forced arena end."),
|
||||||
FORCE_END_IDLE("You weren't quick enough!"),
|
FORCE_END_IDLE("You weren't quick enough!"),
|
||||||
REWARDS_GIVE("Here are all of your rewards!"),
|
REWARDS_GIVE("Here are all of your rewards!"),
|
||||||
LOBBY_DROP_ITEM("No sharing allowed at this time!", "Can't drop items here."),
|
LOBBY_DROP_ITEM("No sharing allowed at this time!"),
|
||||||
LOBBY_PLAYER_READY("You have been flagged as ready!", "Flagged as ready!"),
|
LOBBY_PLAYER_READY("You have been flagged as ready!"),
|
||||||
LOBBY_PICK_CLASS("You must first pick a class!", "Pick a class first!"),
|
LOBBY_PICK_CLASS("You must first pick a class!"),
|
||||||
LOBBY_CLASS_FULL("This class can no longer be selected, class limit reached!", "Class limit reached!"),
|
LOBBY_CLASS_FULL("This class can no longer be selected, class limit reached!"),
|
||||||
LOBBY_NOT_ENOUGH_PLAYERS("Not enough players to start. Need at least % players.", "Need more players."),
|
LOBBY_NOT_ENOUGH_PLAYERS("Not enough players to start. Need at least &c%&r players."),
|
||||||
LOBBY_RIGHT_CLICK("Punch the sign. Don't right-click.", "Punch the sign."),
|
LOBBY_RIGHT_CLICK("Punch the sign. Don't right-click."),
|
||||||
LOBBY_CLASS_PICKED("You have chosen % as your class!", "%"),
|
LOBBY_CLASS_PICKED("You have chosen &e%&r as your class!"),
|
||||||
LOBBY_CLASS_RANDOM("You will get a random class on arena start."),
|
LOBBY_CLASS_RANDOM("You will get a random class on arena start."),
|
||||||
LOBBY_CLASS_PERMISSION("You don't have permission to use this class!", "No permission!", Material.FENCE),
|
LOBBY_CLASS_PERMISSION("You don't have permission to use this class!"),
|
||||||
WARP_TO_ARENA("Warping to the arena not allowed!"),
|
WARP_TO_ARENA("Warping to the arena not allowed!"),
|
||||||
WARP_FROM_ARENA("Warping from the arena not allowed!"),
|
WARP_FROM_ARENA("Warping from the arena not allowed!"),
|
||||||
WAVE_DEFAULT("Wave #%!", "Wave #%!", Material.YELLOW_FLOWER),
|
WAVE_DEFAULT("Wave &b#%&r!"),
|
||||||
WAVE_SPECIAL("Wave #%! [SPECIAL]", "Wave #%! [SPECIAL]", Material.RED_ROSE),
|
WAVE_SPECIAL("Wave &b#%&r! [SPECIAL]"),
|
||||||
WAVE_SWARM("Wave #%! [SWARM]", "Wave #%! [SWARM]", Material.LONG_GRASS),
|
WAVE_SWARM("Wave &b#%&r! [SWARM]"),
|
||||||
WAVE_SUPPLY("Wave #%! [SUPPLY]", "Wave #%! [SUPPLY]", Material.BREAD),
|
WAVE_SUPPLY("Wave &b#%&r! [SUPPLY]"),
|
||||||
WAVE_UPGRADE("Wave #%! [UPGRADE]", "Wave #%! [UPGRADE]", Material.DIAMOND),
|
WAVE_UPGRADE("Wave &b#%&r! [UPGRADE]"),
|
||||||
WAVE_BOSS("Wave #%! [BOSS]", "Wave #%! [BOSS]", Material.FIRE),
|
WAVE_BOSS("Wave &b#%&r! [BOSS]"),
|
||||||
WAVE_BOSS_ABILITY("Boss used ability: %!", "Boss: %", Material.FIRE),
|
WAVE_BOSS_ABILITY("Boss used ability: &c%&r!"),
|
||||||
WAVE_BOSS_LOW_HEALTH("Boss is almost dead!", "Boss almost dead!", Material.FIRE),
|
WAVE_BOSS_LOW_HEALTH("Boss is almost dead!"),
|
||||||
WAVE_REWARD("You just earned a reward: %", "Reward: %"),
|
WAVE_REWARD("You just earned a reward: &e%&r"),
|
||||||
MISC_LIST_PLAYERS("Live players: %"),
|
MISC_LIST_PLAYERS("Live players: &a%&r"),
|
||||||
MISC_LIST_ARENAS("Available arenas: %"),
|
MISC_LIST_ARENAS("Available arenas: %"),
|
||||||
MISC_COMMAND_NOT_ALLOWED("You can't use that command in the arena!"),
|
MISC_COMMAND_NOT_ALLOWED("You can't use that command in the arena!"),
|
||||||
MISC_NO_ACCESS("You don't have access to this command."),
|
MISC_NO_ACCESS("You don't have access to this command."),
|
||||||
MISC_NOT_FROM_CONSOLE("You can't use this command from the console."),
|
MISC_NOT_FROM_CONSOLE("You can't use this command from the console."),
|
||||||
MISC_HELP("For a list of commands, type /ma help"),
|
MISC_HELP("For a list of commands, type &e/ma help&r"),
|
||||||
MISC_MULTIPLE_MATCHES("Did you mean one of these commands?"),
|
MISC_MULTIPLE_MATCHES("Did you mean one of these commands?"),
|
||||||
MISC_NO_MATCHES("Command not found. Type /ma help"),
|
MISC_NO_MATCHES("Command not found. Type &e/ma help&r"),
|
||||||
MISC_MA_LEAVE_REMINDER("Remember to use /ma leave when you are done."),
|
MISC_MA_LEAVE_REMINDER("Remember to use &e/ma leave&r when you are done."),
|
||||||
MISC_NONE("<none>");
|
MISC_NONE("&6<none>&r");
|
||||||
|
|
||||||
private String msg, spoutMsg;
|
private String value;
|
||||||
private Material logo;
|
|
||||||
|
private Msg(String value) {
|
||||||
/**
|
set(value);
|
||||||
* Default constructor.
|
}
|
||||||
* @param msg a string for the chat window
|
|
||||||
* @param spoutMsg a string for Spout
|
void set(String value) {
|
||||||
* @param logo a logo for Spout
|
this.value = ChatColor.translateAlternateColorCodes('&', value);
|
||||||
*/
|
|
||||||
private Msg(String msg, String spoutMsg, Material logo) {
|
|
||||||
this.msg = msg;
|
|
||||||
this.spoutMsg = spoutMsg;
|
|
||||||
this.logo = logo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom Spout constructor.
|
|
||||||
* @param msg a string for the chat window
|
|
||||||
* @param spoutMsg a string for Spout
|
|
||||||
*/
|
|
||||||
private Msg(String msg, String spoutMsg) {
|
|
||||||
this(msg, spoutMsg, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom normal constructor.
|
|
||||||
* @param msg a string for the chat window
|
|
||||||
*/
|
|
||||||
private Msg(String msg) {
|
|
||||||
this(msg, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change this enum's chat window string.
|
|
||||||
* @param msg a string for the chat window
|
|
||||||
*/
|
|
||||||
public void set(String msg) {
|
|
||||||
this.msg = msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change this enum's Spout string.
|
|
||||||
* @param spoutMsg a string for Spout
|
|
||||||
*/
|
|
||||||
public void setSpout(String spoutMsg) {
|
|
||||||
this.spoutMsg = spoutMsg;
|
|
||||||
|
|
||||||
if (spoutMsg == null)
|
|
||||||
logo = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if this enum has a Spout string associated with it.
|
|
||||||
* @return true, if a Spout string is available, false otherwise.
|
|
||||||
*/
|
|
||||||
public boolean hasSpoutMsg() {
|
|
||||||
return spoutMsg != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the logo of this enum.
|
|
||||||
* The default logo is Material.SLIME_BALL if none is specified.
|
|
||||||
* @return the logo for this enum
|
|
||||||
*/
|
|
||||||
public Material getLogo() {
|
|
||||||
return logo == null ? Material.SLIME_BALL : logo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return msg;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public String format(String s) {
|
||||||
* Same as above, just returning the string for Spout instead.
|
return value.replaceAll("%", s);
|
||||||
* @return the string for Spout
|
|
||||||
*/
|
|
||||||
public String toSpoutString() {
|
|
||||||
return spoutMsg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static void load(ConfigurationSection config) {
|
||||||
* Extended toString method that allows a variable.
|
for (Msg msg : values()) {
|
||||||
* @param s the variable value
|
// ARENA_END_GLOBAL => arena-end-global
|
||||||
* @return the string for the chat window, with all %'s replaced by the input
|
String key = msg.name().toLowerCase().replaceAll("_","-");
|
||||||
*/
|
msg.set(config.getString(key, ""));
|
||||||
public String toString(String s) {
|
}
|
||||||
return (s != null) ? msg.replace("%", s) : msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static YamlConfiguration toYaml() {
|
||||||
* Same as above, but for the Spout string.
|
YamlConfiguration yaml = new YamlConfiguration();
|
||||||
* @param s the variable value
|
for (Msg msg : values()) {
|
||||||
* @return the string for Spout, with all %'s replaced by the input
|
// ARENA_END_GLOBAL => arena-end-global
|
||||||
*/
|
String key = msg.name().replaceAll("_","-").toLowerCase();
|
||||||
public String toSpoutString(String s) {
|
yaml.set(key, msg.value);
|
||||||
if (spoutMsg == null)
|
}
|
||||||
return toString(s);
|
return yaml;
|
||||||
|
|
||||||
return (s != null) ? spoutMsg.replace("%", s) : spoutMsg;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
package com.garbagemule.MobArena.autostart;
|
package com.garbagemule.MobArena.autostart;
|
||||||
|
|
||||||
|
import com.garbagemule.MobArena.Msg;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.garbagemule.MobArena.Messenger;
|
import com.garbagemule.MobArena.Messenger;
|
||||||
import com.garbagemule.MobArena.Msg;
|
|
||||||
import com.garbagemule.MobArena.framework.Arena;
|
import com.garbagemule.MobArena.framework.Arena;
|
||||||
|
|
||||||
public class AutoStartTimer {
|
public class AutoStartTimer {
|
||||||
@ -106,7 +106,7 @@ public class AutoStartTimer {
|
|||||||
}
|
}
|
||||||
// Otherwise, warn at x seconds left
|
// Otherwise, warn at x seconds left
|
||||||
else if (remaining == intervals[countdownIndex]) {
|
else if (remaining == intervals[countdownIndex]) {
|
||||||
Messenger.tellAll(arena, Msg.ARENA_AUTO_START, "" + remaining);
|
Messenger.announce(arena, Msg.ARENA_AUTO_START, ""+remaining);
|
||||||
countdownIndex--;
|
countdownIndex--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
|
|
||||||
// If there's no base argument, show a helpful message.
|
// If there's no base argument, show a helpful message.
|
||||||
if (base.equals("")) {
|
if (base.equals("")) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_HELP);
|
Messenger.tell(sender, Msg.MISC_HELP);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
|
|
||||||
// If there's more than one match, display them.
|
// If there's more than one match, display them.
|
||||||
if (matches.size() > 1) {
|
if (matches.size() > 1) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_MULTIPLE_MATCHES);
|
Messenger.tell(sender, Msg.MISC_MULTIPLE_MATCHES);
|
||||||
for (Command cmd : matches) {
|
for (Command cmd : matches) {
|
||||||
showUsage(cmd, sender);
|
showUsage(cmd, sender);
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
|
|
||||||
// If there are no matches at all, notify.
|
// If there are no matches at all, notify.
|
||||||
if (matches.size() == 0) {
|
if (matches.size() == 0) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NO_MATCHES);
|
Messenger.tell(sender, Msg.MISC_NO_MATCHES);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
|
|
||||||
// First check if the sender has permission.
|
// First check if the sender has permission.
|
||||||
if (!plugin.has(sender, info.permission())) {
|
if (!plugin.has(sender, info.permission())) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
Messenger.tell(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
CommandInfo info = cmd.getClass().getAnnotation(CommandInfo.class);
|
CommandInfo info = cmd.getClass().getAnnotation(CommandInfo.class);
|
||||||
if (!plugin.has(sender, info.permission())) return;
|
if (!plugin.has(sender, info.permission())) return;
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, info.usage() + " " + ChatColor.YELLOW + info.desc());
|
Messenger.tell(sender, info.usage() + " " + ChatColor.YELLOW + info.desc());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -136,7 +136,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
* @param sender a player or the console
|
* @param sender a player or the console
|
||||||
*/
|
*/
|
||||||
private void showHelp(CommandSender sender) {
|
private void showHelp(CommandSender sender) {
|
||||||
Messenger.tellPlayer(sender, "Available MobArena commands:");
|
Messenger.tell(sender, "Available MobArena commands:");
|
||||||
|
|
||||||
for (Command cmd : commands.values()) {
|
for (Command cmd : commands.values()) {
|
||||||
showUsage(cmd, sender);
|
showUsage(cmd, sender);
|
||||||
|
@ -20,21 +20,21 @@ public class Commands
|
|||||||
public static Arena getArenaToJoinOrSpec(ArenaMaster am, Player p, String arg1) {
|
public static Arena getArenaToJoinOrSpec(ArenaMaster am, Player p, String arg1) {
|
||||||
// Check if MobArena is enabled first.
|
// Check if MobArena is enabled first.
|
||||||
if (!am.isEnabled()) {
|
if (!am.isEnabled()) {
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_NOT_ENABLED);
|
Messenger.tell(p, Msg.JOIN_NOT_ENABLED);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then check if we have permission at all.
|
// Then check if we have permission at all.
|
||||||
List<Arena> arenas = am.getPermittedArenas(p);
|
List<Arena> arenas = am.getPermittedArenas(p);
|
||||||
if (arenas.isEmpty()) {
|
if (arenas.isEmpty()) {
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_NO_PERMISSION);
|
Messenger.tell(p, Msg.JOIN_NO_PERMISSION);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then check if we have any enabled arenas.
|
// Then check if we have any enabled arenas.
|
||||||
arenas = am.getEnabledArenas(arenas);
|
arenas = am.getEnabledArenas(arenas);
|
||||||
if (arenas.isEmpty()) {
|
if (arenas.isEmpty()) {
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_NOT_ENABLED);
|
Messenger.tell(p, Msg.JOIN_NOT_ENABLED);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,19 +45,19 @@ public class Commands
|
|||||||
if (arg1 != null) {
|
if (arg1 != null) {
|
||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(p, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(p, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arenas.contains(arena)) {
|
if (!arenas.contains(arena)) {
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_ARENA_NOT_ENABLED);
|
Messenger.tell(p, Msg.JOIN_ARENA_NOT_ENABLED);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (arenas.size() > 1) {
|
if (arenas.size() > 1) {
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_ARG_NEEDED);
|
Messenger.tell(p, Msg.JOIN_ARG_NEEDED);
|
||||||
Messenger.tellPlayer(p, Msg.MISC_LIST_ARENAS.toString(TextUtils.listToString(arenas)));
|
Messenger.tell(p, Msg.MISC_LIST_ARENAS.format(TextUtils.listToString(arenas)));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
arena = arenas.get(0);
|
arena = arenas.get(0);
|
||||||
|
@ -32,7 +32,7 @@ public class DisableCommand implements Command
|
|||||||
if (!arg1.equals("")) {
|
if (!arg1.equals("")) {
|
||||||
Arena arena = am.getArenaWithName(arg1);
|
Arena arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class DisableCommand implements Command
|
|||||||
|
|
||||||
am.setEnabled(false);
|
am.setEnabled(false);
|
||||||
am.saveConfig();
|
am.saveConfig();
|
||||||
Messenger.tellPlayer(sender, "MobArena " + ChatColor.RED + "disabled");
|
Messenger.tell(sender, "MobArena " + ChatColor.RED + "disabled");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -50,6 +50,6 @@ public class DisableCommand implements Command
|
|||||||
private void disable(Arena arena, CommandSender sender) {
|
private void disable(Arena arena, CommandSender sender) {
|
||||||
arena.setEnabled(false);
|
arena.setEnabled(false);
|
||||||
arena.getPlugin().saveConfig();
|
arena.getPlugin().saveConfig();
|
||||||
Messenger.tellPlayer(sender, "Arena '" + arena.configName() + "' " + ChatColor.RED + "disabled");
|
Messenger.tell(sender, "Arena '" + arena.configName() + "' " + ChatColor.RED + "disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class EnableCommand implements Command
|
|||||||
if (!arg1.equals("")) {
|
if (!arg1.equals("")) {
|
||||||
Arena arena = am.getArenaWithName(arg1);
|
Arena arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class EnableCommand implements Command
|
|||||||
|
|
||||||
am.setEnabled(true);
|
am.setEnabled(true);
|
||||||
am.saveConfig();
|
am.saveConfig();
|
||||||
Messenger.tellPlayer(sender, "MobArena " + ChatColor.GREEN + "enabled");
|
Messenger.tell(sender, "MobArena " + ChatColor.GREEN + "enabled");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -50,6 +50,6 @@ public class EnableCommand implements Command
|
|||||||
private void enable(Arena arena, CommandSender sender) {
|
private void enable(Arena arena, CommandSender sender) {
|
||||||
arena.setEnabled(true);
|
arena.setEnabled(true);
|
||||||
arena.getPlugin().saveConfig();
|
arena.getPlugin().saveConfig();
|
||||||
Messenger.tellPlayer(sender, "Arena '" + arena.configName() + "' " + ChatColor.GREEN + "enabled");
|
Messenger.tell(sender, "Arena '" + arena.configName() + "' " + ChatColor.GREEN + "enabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public class ForceCommand implements Command
|
|||||||
arena.forceEnd();
|
arena.forceEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, Msg.FORCE_END_ENDED);
|
Messenger.tell(sender, Msg.FORCE_END_ENDED);
|
||||||
am.resetArenaMap();
|
am.resetArenaMap();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -37,18 +37,18 @@ public class ForceCommand implements Command
|
|||||||
// Otherwise, grab the arena in question.
|
// Otherwise, grab the arena in question.
|
||||||
Arena arena = am.getArenaWithName(arg2);
|
Arena arena = am.getArenaWithName(arg2);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.getAllPlayers().isEmpty()) {
|
if (arena.getAllPlayers().isEmpty()) {
|
||||||
Messenger.tellPlayer(sender, Msg.FORCE_END_EMPTY);
|
Messenger.tell(sender, Msg.FORCE_END_EMPTY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// And end it!
|
// And end it!
|
||||||
arena.forceEnd();
|
arena.forceEnd();
|
||||||
Messenger.tellPlayer(sender, Msg.FORCE_END_ENDED);
|
Messenger.tell(sender, Msg.FORCE_END_ENDED);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -56,35 +56,35 @@ public class ForceCommand implements Command
|
|||||||
if (arg1.equals("start")) {
|
if (arg1.equals("start")) {
|
||||||
// Require argument.
|
// Require argument.
|
||||||
if (arg2.equals("")) {
|
if (arg2.equals("")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma force start <arena>");
|
Messenger.tell(sender, "Usage: /ma force start <arena>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the arena.
|
// Grab the arena.
|
||||||
Arena arena = am.getArenaWithName(arg2);
|
Arena arena = am.getArenaWithName(arg2);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.isRunning()) {
|
if (arena.isRunning()) {
|
||||||
Messenger.tellPlayer(sender, Msg.FORCE_START_RUNNING);
|
Messenger.tell(sender, Msg.FORCE_START_RUNNING);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.getReadyPlayersInLobby().isEmpty()) {
|
if (arena.getReadyPlayersInLobby().isEmpty()) {
|
||||||
Messenger.tellPlayer(sender, Msg.FORCE_START_NOT_READY);
|
Messenger.tell(sender, Msg.FORCE_START_NOT_READY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// And start it!
|
// And start it!
|
||||||
arena.forceStart();
|
arena.forceStart();
|
||||||
Messenger.tellPlayer(sender, Msg.FORCE_START_STARTED);
|
Messenger.tell(sender, Msg.FORCE_START_STARTED);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma force start|end (<arena name>)");
|
Messenger.tell(sender, "Usage: /ma force start|end (<arena name>)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,13 @@ public class KickCommand implements Command
|
|||||||
|
|
||||||
// Require an argument
|
// Require an argument
|
||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma kick <player>");
|
Messenger.tell(sender, "Usage: /ma kick <player>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Arena arena = am.getArenaWithPlayer(arg1);
|
Arena arena = am.getArenaWithPlayer(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, "That player is not in an arena.");
|
Messenger.tell(sender, "That player is not in an arena.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,8 +40,8 @@ public class KickCommand implements Command
|
|||||||
// Force leave.
|
// Force leave.
|
||||||
arena.playerLeave(bp);
|
arena.playerLeave(bp);
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, "Player '" + arg1 + "' was kicked from arena '" + arena.configName() + "'.");
|
Messenger.tell(sender, "Player '" + arg1 + "' was kicked from arena '" + arena.configName() + "'.");
|
||||||
Messenger.tellPlayer(bp, "You were kicked by " + sender.getName() + ".");
|
Messenger.tell(bp, "You were kicked by " + sender.getName() + ".");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,19 +23,19 @@ public class RestoreCommand implements Command
|
|||||||
|
|
||||||
// Require an argument
|
// Require an argument
|
||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma restore <player>");
|
Messenger.tell(sender, "Usage: /ma restore <player>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (am.getArenaWithPlayer(arg1) != null) {
|
if (am.getArenaWithPlayer(arg1) != null) {
|
||||||
Messenger.tellPlayer(sender, "Player is currently in an arena.");
|
Messenger.tell(sender, "Player is currently in an arena.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (InventoryManager.restoreFromFile(am.getPlugin(), am.getPlugin().getServer().getPlayer(arg1))) {
|
if (InventoryManager.restoreFromFile(am.getPlugin(), am.getPlugin().getServer().getPlayer(arg1))) {
|
||||||
Messenger.tellPlayer(sender, "Restored " + arg1 + "'s inventory!");
|
Messenger.tell(sender, "Restored " + arg1 + "'s inventory!");
|
||||||
} else {
|
} else {
|
||||||
Messenger.tellPlayer(sender, "Failed to restore " + arg1 + "'s inventory.");
|
Messenger.tell(sender, "Failed to restore " + arg1 + "'s inventory.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -20,7 +20,7 @@ public class AddArenaCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,20 +32,20 @@ public class AddArenaCommand implements Command
|
|||||||
|
|
||||||
// Require an argument
|
// Require an argument
|
||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma addarena <arena>");
|
Messenger.tell(sender, "Usage: /ma addarena <arena>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Arena arena = am.getArenaWithName(arg1);
|
Arena arena = am.getArenaWithName(arg1);
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
Messenger.tellPlayer(sender, "An arena with that name already exists.");
|
Messenger.tell(sender, "An arena with that name already exists.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
arena = am.createArenaNode(arg1, p.getWorld());
|
arena = am.createArenaNode(arg1, p.getWorld());
|
||||||
am.setSelectedArena(arena);
|
am.setSelectedArena(arena);
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, "New arena with name '" + arg1 + "' created!");
|
Messenger.tell(sender, "New arena with name '" + arg1 + "' created!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,25 +23,25 @@ public class AddClassPermCommand implements Command
|
|||||||
String arg2 = (args.length > 1 ? args[1] : "");
|
String arg2 = (args.length > 1 ? args[1] : "");
|
||||||
|
|
||||||
if (arg1.equals("") || arg2.equals("")) {
|
if (arg1.equals("") || arg2.equals("")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma addclassperm <classname> <permission>");
|
Messenger.tell(sender, "Usage: /ma addclassperm <classname> <permission>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the arena class
|
// Grab the arena class
|
||||||
ArenaClass arenaClass = am.getClasses().get(arg1);
|
ArenaClass arenaClass = am.getClasses().get(arg1);
|
||||||
if (arenaClass == null) {
|
if (arenaClass == null) {
|
||||||
Messenger.tellPlayer(sender, "The class '" + TextUtils.camelCase(arg1) + "' does not exist.");
|
Messenger.tell(sender, "The class '" + TextUtils.camelCase(arg1) + "' does not exist.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to add the permission.
|
// Try to add the permission.
|
||||||
if (am.addClassPermission(arg1, arg2)) {
|
if (am.addClassPermission(arg1, arg2)) {
|
||||||
Messenger.tellPlayer(sender, "Added permission '" + arg2 + "' to class '" + TextUtils.camelCase(arg1) + "'.");
|
Messenger.tell(sender, "Added permission '" + arg2 + "' to class '" + TextUtils.camelCase(arg1) + "'.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it wasn't added, notify.
|
// If it wasn't added, notify.
|
||||||
Messenger.tellPlayer(sender, "Permission '" + arg2 + "' was NOT added to class '" + TextUtils.camelCase(arg1) + "'.");
|
Messenger.tell(sender, "Permission '" + arg2 + "' was NOT added to class '" + TextUtils.camelCase(arg1) + "'.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public class AddContainerCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,17 +31,17 @@ public class AddContainerCommand implements Command
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|
||||||
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
|
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma addcontainer <point name>");
|
Messenger.tell(sender, "Usage: /ma addcontainer <point name>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(p.getTargetBlock(null, 50).getState() instanceof InventoryHolder)) {
|
if (!(p.getTargetBlock(null, 50).getState() instanceof InventoryHolder)) {
|
||||||
Messenger.tellPlayer(sender, "You must look at container.");
|
Messenger.tell(sender, "You must look at container.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
am.getSelectedArena().getRegion().addChest(arg1, p.getTargetBlock(null, 50).getLocation());
|
am.getSelectedArena().getRegion().addChest(arg1, p.getTargetBlock(null, 50).getLocation());
|
||||||
Messenger.tellPlayer(sender, "Container '" + arg1 + "' added for arena \"" + am.getSelectedArena().configName() + "\"");
|
Messenger.tell(sender, "Container '" + arg1 + "' added for arena \"" + am.getSelectedArena().configName() + "\"");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class AddSpawnpointCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ public class AddSpawnpointCommand implements Command
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|
||||||
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
|
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma addspawn <point name>");
|
Messenger.tell(sender, "Usage: /ma addspawn <point name>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,9 +48,9 @@ public class AddSpawnpointCommand implements Command
|
|||||||
// Make sure we're inside the region
|
// Make sure we're inside the region
|
||||||
if (!am.getSelectedArena().getRegion().contains(p.getLocation())) {
|
if (!am.getSelectedArena().getRegion().contains(p.getLocation())) {
|
||||||
if (arena.getRegion().isDefined()) {
|
if (arena.getRegion().isDefined()) {
|
||||||
Messenger.tellPlayer(sender, "You must be inside the arena region!");
|
Messenger.tell(sender, "You must be inside the arena region!");
|
||||||
} else {
|
} else {
|
||||||
Messenger.tellPlayer(sender, "You must first set the region points p1 and p2");
|
Messenger.tell(sender, "You must first set the region points p1 and p2");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the world reference in the arena
|
// Restore the world reference in the arena
|
||||||
@ -61,13 +61,13 @@ public class AddSpawnpointCommand implements Command
|
|||||||
|
|
||||||
// Notify the player if world changed
|
// Notify the player if world changed
|
||||||
if (changeWorld) {
|
if (changeWorld) {
|
||||||
Messenger.tellPlayer(sender, "Changed world of arena '" + arena.configName() +
|
Messenger.tell(sender, "Changed world of arena '" + arena.configName() +
|
||||||
"' from '" + aw.getName() +
|
"' from '" + aw.getName() +
|
||||||
"' to '" + pw.getName() + "'");
|
"' to '" + pw.getName() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then notify about point set
|
// Then notify about point set
|
||||||
Messenger.tellPlayer(sender, "Spawnpoint '" + arg1 + "' added for arena '" + am.getSelectedArena().configName() + "'");
|
Messenger.tell(sender, "Spawnpoint '" + arg1 + "' added for arena '" + am.getSelectedArena().configName() + "'");
|
||||||
arena.getRegion().checkData(am.getPlugin(), sender, false, false, false, true);
|
arena.getRegion().checkData(am.getPlugin(), sender, false, false, false, true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -19,7 +19,7 @@ public class ArenaCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
Messenger.tellPlayer(sender, "Currently selected arena: " + ChatColor.GREEN + am.getSelectedArena().configName());
|
Messenger.tell(sender, "Currently selected arena: " + ChatColor.GREEN + am.getSelectedArena().configName());
|
||||||
|
|
||||||
StringBuffer buffy = new StringBuffer();
|
StringBuffer buffy = new StringBuffer();
|
||||||
if (am.getArenas().size() > 1) {
|
if (am.getArenas().size() > 1) {
|
||||||
@ -31,7 +31,7 @@ public class ArenaCommand implements Command
|
|||||||
}
|
}
|
||||||
else buffy.append(Msg.MISC_NONE);
|
else buffy.append(Msg.MISC_NONE);
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, "Other arenas: " + buffy.toString());
|
Messenger.tell(sender, "Other arenas: " + buffy.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,28 +23,28 @@ public class AutoDegenerateCommand implements Command
|
|||||||
|
|
||||||
// Require an argument
|
// Require an argument
|
||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma autodegenerate <arena>");
|
Messenger.tell(sender, "Usage: /ma autodegenerate <arena>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (am.getArenas().size() < 2) {
|
if (am.getArenas().size() < 2) {
|
||||||
Messenger.tellPlayer(sender, "At least one arena must exist!");
|
Messenger.tell(sender, "At least one arena must exist!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if arena exists.
|
// Check if arena exists.
|
||||||
Arena arena = am.getArenaWithName(arg1);
|
Arena arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MAUtils.undoItHippieMonster(arg1, am.getPlugin(), true)) {
|
if (!MAUtils.undoItHippieMonster(arg1, am.getPlugin(), true)) {
|
||||||
Messenger.tellPlayer(sender, "Could not degenerate arena.");
|
Messenger.tell(sender, "Could not degenerate arena.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, "Arena with name '" + arg1 + "' degenerated.");
|
Messenger.tell(sender, "Arena with name '" + arg1 + "' degenerated.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public class AutoGenerateCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,23 +32,23 @@ public class AutoGenerateCommand implements Command
|
|||||||
|
|
||||||
// Require an argument
|
// Require an argument
|
||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma autogenerate <arena>");
|
Messenger.tell(sender, "Usage: /ma autogenerate <arena>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if arena already exists.
|
// Check if arena already exists.
|
||||||
Arena arena = am.getArenaWithName(arg1);
|
Arena arena = am.getArenaWithName(arg1);
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
Messenger.tellPlayer(sender, "An arena with that name already exists.");
|
Messenger.tell(sender, "An arena with that name already exists.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MAUtils.doooooItHippieMonster(p.getLocation(), 13, arg1, am.getPlugin())) {
|
if (!MAUtils.doooooItHippieMonster(p.getLocation(), 13, arg1, am.getPlugin())) {
|
||||||
Messenger.tellPlayer(sender, "Could not auto-generate arena.");
|
Messenger.tell(sender, "Could not auto-generate arena.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, "Arena with name '" + arg1 + "' generated.");
|
Messenger.tell(sender, "Arena with name '" + arg1 + "' generated.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ public class CheckDataCommand implements Command
|
|||||||
|
|
||||||
Arena arena = arg1.equals("") ? am.getSelectedArena() : am.getArenaWithName(arg1);
|
Arena arena = arg1.equals("") ? am.getSelectedArena() : am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public class CheckSpawnsCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ public class CheckSpawnsCommand implements Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (arena.getRegion().getSpawnpoints().isEmpty()) {
|
if (arena.getRegion().getSpawnpoints().isEmpty()) {
|
||||||
Messenger.tellPlayer(sender, "There are no spawnpoints in the selected arena.");
|
Messenger.tell(sender, "There are no spawnpoints in the selected arena.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ public class CheckSpawnsCommand implements Command
|
|||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
|
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,18 +22,18 @@ public class ClassChestCommand implements Command {
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma classchest <class>");
|
Messenger.tell(sender, "Usage: /ma classchest <class>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArenaClass ac = am.getClasses().get(args[0].toLowerCase());
|
ArenaClass ac = am.getClasses().get(args[0].toLowerCase());
|
||||||
if (ac == null) {
|
if (ac == null) {
|
||||||
Messenger.tellPlayer(sender, "Class not found.");
|
Messenger.tell(sender, "Class not found.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,13 +47,13 @@ public class ClassChestCommand implements Command {
|
|||||||
case TRAPPED_CHEST:
|
case TRAPPED_CHEST:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Messenger.tellPlayer(sender, "You must look at a chest.");
|
Messenger.tell(sender, "You must look at a chest.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
am.getPlugin().getConfig().set("classes." + ac.getConfigName() + ".classchest", b.getLocation());
|
am.getPlugin().getConfig().set("classes." + ac.getConfigName() + ".classchest", b.getLocation());
|
||||||
am.saveConfig();
|
am.saveConfig();
|
||||||
Messenger.tellPlayer(sender, "Class chest updated for class " + ac.getConfigName());
|
Messenger.tell(sender, "Class chest updated for class " + ac.getConfigName());
|
||||||
am.loadClasses();
|
am.loadClasses();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -22,18 +22,18 @@ public class ConfigCommand implements Command
|
|||||||
|
|
||||||
if (arg1.equals("reload")) {
|
if (arg1.equals("reload")) {
|
||||||
am.reloadConfig();
|
am.reloadConfig();
|
||||||
Messenger.tellPlayer(sender, "Config reloaded.");
|
Messenger.tell(sender, "Config reloaded.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg1.equals("save")) {
|
if (arg1.equals("save")) {
|
||||||
am.saveConfig();
|
am.saveConfig();
|
||||||
Messenger.tellPlayer(sender, "Config saved.");
|
Messenger.tell(sender, "Config saved.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Requires an argument.
|
// Requires an argument.
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma config reload|save");
|
Messenger.tell(sender, "Usage: /ma config reload|save");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class ContainersCommand implements Command
|
|||||||
buffy.append(Msg.MISC_NONE);
|
buffy.append(Msg.MISC_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, "Containers for arena '" + am.getSelectedArena().configName() + "': " + buffy.toString());
|
Messenger.tell(sender, "Containers for arena '" + am.getSelectedArena().configName() + "': " + buffy.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,9 @@ public class EditArenaCommand implements Command
|
|||||||
else {
|
else {
|
||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, "There is no arena with that name.");
|
Messenger.tell(sender, "There is no arena with that name.");
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma editarena (true|false)");
|
Messenger.tell(sender, "Usage: /ma editarena (true|false)");
|
||||||
Messenger.tellPlayer(sender, " or /ma editarena <arena> (true|false)");
|
Messenger.tell(sender, " or /ma editarena <arena> (true|false)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
arena.setEditMode(!arena.inEditMode());
|
arena.setEditMode(!arena.inEditMode());
|
||||||
@ -54,22 +54,22 @@ public class EditArenaCommand implements Command
|
|||||||
// Two arguments
|
// Two arguments
|
||||||
else {
|
else {
|
||||||
if (!(arg2.matches("true|on") || arg2.matches("false|off"))) {
|
if (!(arg2.matches("true|on") || arg2.matches("false|off"))) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma editarena (true|false)");
|
Messenger.tell(sender, "Usage: /ma editarena (true|false)");
|
||||||
Messenger.tellPlayer(sender, " or /ma editarena <arena> (true|false)");
|
Messenger.tell(sender, " or /ma editarena <arena> (true|false)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, "There is no arena with that name.");
|
Messenger.tell(sender, "There is no arena with that name.");
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma editarena (true|false)");
|
Messenger.tell(sender, "Usage: /ma editarena (true|false)");
|
||||||
Messenger.tellPlayer(sender, " or /ma editarena <arena> (true|false)");
|
Messenger.tell(sender, " or /ma editarena <arena> (true|false)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
arena.setEditMode(arg2.equals("true"));
|
arena.setEditMode(arg2.equals("true"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, "Edit mode for arena '" + arena.configName() + "': " + ((arena.inEditMode()) ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
|
Messenger.tell(sender, "Edit mode for arena '" + arena.configName() + "': " + ((arena.inEditMode()) ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
|
||||||
if (arena.inEditMode()) Messenger.tellPlayer(sender, "Remember to turn it back off after editing!");
|
if (arena.inEditMode()) Messenger.tell(sender, "Remember to turn it back off after editing!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,12 @@ public class ExpandLobbyRegionCommand implements Command
|
|||||||
String arg2 = (args.length > 1 ? args[1] : "");
|
String arg2 = (args.length > 1 ? args[1] : "");
|
||||||
|
|
||||||
if (args.length != 2 || !arg1.matches("(-)?[0-9]+")) {
|
if (args.length != 2 || !arg1.matches("(-)?[0-9]+")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma expandlobbyregion <amount> up|down|out");
|
Messenger.tell(sender, "Usage: /ma expandlobbyregion <amount> up|down|out");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!am.getSelectedArena().getRegion().isLobbyDefined()) {
|
if (!am.getSelectedArena().getRegion().isLobbyDefined()) {
|
||||||
Messenger.tellPlayer(sender, "You must first define l1 and l2");
|
Messenger.tell(sender, "You must first define l1 and l2");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,14 +41,14 @@ public class ExpandLobbyRegionCommand implements Command
|
|||||||
am.getSelectedArena().getRegion().expandLobbyOut(Integer.parseInt(arg1));
|
am.getSelectedArena().getRegion().expandLobbyOut(Integer.parseInt(arg1));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma expandlobbyregion <amount> up|down|out");
|
Messenger.tell(sender, "Usage: /ma expandlobbyregion <amount> up|down|out");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case of a "negative" region, fix it!
|
// In case of a "negative" region, fix it!
|
||||||
am.getSelectedArena().getRegion().fixLobbyRegion();
|
am.getSelectedArena().getRegion().fixLobbyRegion();
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, "Lobby region for '" + am.getSelectedArena().configName() + "' expanded " + arg2 + " by " + arg1 + " blocks.");
|
Messenger.tell(sender, "Lobby region for '" + am.getSelectedArena().configName() + "' expanded " + arg2 + " by " + arg1 + " blocks.");
|
||||||
am.getSelectedArena().getRegion().save();
|
am.getSelectedArena().getRegion().save();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -22,12 +22,12 @@ public class ExpandRegionCommand implements Command
|
|||||||
String arg2 = (args.length > 1 ? args[1] : "");
|
String arg2 = (args.length > 1 ? args[1] : "");
|
||||||
|
|
||||||
if (args.length != 2 || !arg1.matches("(-)?[0-9]+")) {
|
if (args.length != 2 || !arg1.matches("(-)?[0-9]+")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma expandregion <amount> up|down|out");
|
Messenger.tell(sender, "Usage: /ma expandregion <amount> up|down|out");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!am.getSelectedArena().getRegion().isDefined()) {
|
if (!am.getSelectedArena().getRegion().isDefined()) {
|
||||||
Messenger.tellPlayer(sender, "You must first define p1 and p2");
|
Messenger.tell(sender, "You must first define p1 and p2");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,14 +41,14 @@ public class ExpandRegionCommand implements Command
|
|||||||
am.getSelectedArena().getRegion().expandOut(Integer.parseInt(arg1));
|
am.getSelectedArena().getRegion().expandOut(Integer.parseInt(arg1));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma expandregion <amount> up|down|out");
|
Messenger.tell(sender, "Usage: /ma expandregion <amount> up|down|out");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case of a "negative" region, fix it!
|
// In case of a "negative" region, fix it!
|
||||||
am.getSelectedArena().getRegion().fixRegion();
|
am.getSelectedArena().getRegion().fixRegion();
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, "Region for '" + am.getSelectedArena().configName() + "' expanded " + arg2 + " by " + arg1 + " blocks.");
|
Messenger.tell(sender, "Region for '" + am.getSelectedArena().configName() + "' expanded " + arg2 + " by " + arg1 + " blocks.");
|
||||||
am.getSelectedArena().getRegion().save();
|
am.getSelectedArena().getRegion().save();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -26,7 +26,7 @@ public class ListClassPermsCommand implements Command
|
|||||||
|
|
||||||
// Require an argument.
|
// Require an argument.
|
||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma listclassperms <classname>");
|
Messenger.tell(sender, "Usage: /ma listclassperms <classname>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,14 +34,14 @@ public class ListClassPermsCommand implements Command
|
|||||||
String className = TextUtils.camelCase(arg1);
|
String className = TextUtils.camelCase(arg1);
|
||||||
|
|
||||||
if (arenaClass == null) {
|
if (arenaClass == null) {
|
||||||
Messenger.tellPlayer(sender, "The class '" + className + "' does not exist.");
|
Messenger.tell(sender, "The class '" + className + "' does not exist.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, "Permissions for '" + className + "':");
|
Messenger.tell(sender, "Permissions for '" + className + "':");
|
||||||
Map<String,Boolean> perms = arenaClass.getPermissions();
|
Map<String,Boolean> perms = arenaClass.getPermissions();
|
||||||
if (perms.isEmpty()) {
|
if (perms.isEmpty()) {
|
||||||
Messenger.tellPlayer(sender, "<none>");
|
Messenger.tell(sender, "<none>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ public class ListClassPermsCommand implements Command
|
|||||||
if (!entry.getValue()) {
|
if (!entry.getValue()) {
|
||||||
perm = "^" + perm;
|
perm = "^" + perm;
|
||||||
}
|
}
|
||||||
Messenger.tellPlayer(sender, "- " + perm);
|
Messenger.tell(sender, "- " + perm);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -19,15 +19,15 @@ public class ListClassesCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
Messenger.tellPlayer(sender, "Current classes:");
|
Messenger.tell(sender, "Current classes:");
|
||||||
Set<String> classes = am.getClasses().keySet();
|
Set<String> classes = am.getClasses().keySet();
|
||||||
if (classes == null || classes.isEmpty()) {
|
if (classes == null || classes.isEmpty()) {
|
||||||
Messenger.tellPlayer(sender, "<none>");
|
Messenger.tell(sender, "<none>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String c : classes) {
|
for (String c : classes) {
|
||||||
Messenger.tellPlayer(sender, "- " + c);
|
Messenger.tell(sender, "- " + c);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,9 @@ public class ProtectCommand implements Command
|
|||||||
else {
|
else {
|
||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, "There is no arena with that name.");
|
Messenger.tell(sender, "There is no arena with that name.");
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma protect (true|false)");
|
Messenger.tell(sender, "Usage: /ma protect (true|false)");
|
||||||
Messenger.tellPlayer(sender, " or /ma protect <arena> (true|false)");
|
Messenger.tell(sender, " or /ma protect <arena> (true|false)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
arena.setProtected(!arena.isProtected());
|
arena.setProtected(!arena.isProtected());
|
||||||
@ -54,22 +54,22 @@ public class ProtectCommand implements Command
|
|||||||
// Two arguments
|
// Two arguments
|
||||||
else {
|
else {
|
||||||
if (!(arg2.matches("true|on") || arg2.matches("false|off"))) {
|
if (!(arg2.matches("true|on") || arg2.matches("false|off"))) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma protect (true|false)");
|
Messenger.tell(sender, "Usage: /ma protect (true|false)");
|
||||||
Messenger.tellPlayer(sender, " or /ma protect <arena name> (true|false)");
|
Messenger.tell(sender, " or /ma protect <arena name> (true|false)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, "There is no arena with that name.");
|
Messenger.tell(sender, "There is no arena with that name.");
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma protect (true|false)");
|
Messenger.tell(sender, "Usage: /ma protect (true|false)");
|
||||||
Messenger.tellPlayer(sender, " or /ma protect <arena name> (true|false)");
|
Messenger.tell(sender, " or /ma protect <arena name> (true|false)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
arena.setProtected(arg2.equals("true"));
|
arena.setProtected(arg2.equals("true"));
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.getPlugin().saveConfig();
|
arena.getPlugin().saveConfig();
|
||||||
Messenger.tellPlayer(sender, "Protection for arena '" + arena.configName() + "': " + ((arena.isProtected()) ? ChatColor.GREEN + "on" : ChatColor.RED + "off"));
|
Messenger.tell(sender, "Protection for arena '" + arena.configName() + "': " + ((arena.isProtected()) ? ChatColor.GREEN + "on" : ChatColor.RED + "off"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,18 +23,18 @@ public class RemoveArenaCommand implements Command
|
|||||||
|
|
||||||
// Require an argument
|
// Require an argument
|
||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma removearena <arena>");
|
Messenger.tell(sender, "Usage: /ma removearena <arena>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (am.getArenas().size() == 1) {
|
if (am.getArenas().size() == 1) {
|
||||||
Messenger.tellPlayer(sender, "At least one arena must exist.");
|
Messenger.tell(sender, "At least one arena must exist.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Arena arena = am.getArenaWithName(arg1);
|
Arena arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, "There is no arena with that name.");
|
Messenger.tell(sender, "There is no arena with that name.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ public class RemoveArenaCommand implements Command
|
|||||||
am.setSelectedArena(am.getArenas().get(0));
|
am.setSelectedArena(am.getArenas().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, "Arena '" + arena.configName() + "' deleted.");
|
Messenger.tell(sender, "Arena '" + arena.configName() + "' deleted.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ public class RemoveClassCommand implements Command
|
|||||||
|
|
||||||
// Require an argument.
|
// Require an argument.
|
||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma removeclass <classname>");
|
Messenger.tell(sender, "Usage: /ma removeclass <classname>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,12 +31,12 @@ public class RemoveClassCommand implements Command
|
|||||||
ArenaClass arenaClass = am.getClasses().get(arg1);
|
ArenaClass arenaClass = am.getClasses().get(arg1);
|
||||||
String className = TextUtils.camelCase(arg1);
|
String className = TextUtils.camelCase(arg1);
|
||||||
if (arenaClass == null) {
|
if (arenaClass == null) {
|
||||||
Messenger.tellPlayer(sender, "The class '" + className + "' does not exist.");
|
Messenger.tell(sender, "The class '" + className + "' does not exist.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
am.removeClassNode(className);
|
am.removeClassNode(className);
|
||||||
Messenger.tellPlayer(sender, "Removed class '" + className + "'.");
|
Messenger.tell(sender, "Removed class '" + className + "'.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,25 +23,25 @@ public class RemoveClassPermCommand implements Command
|
|||||||
String arg2 = (args.length > 1 ? args[1] : "");
|
String arg2 = (args.length > 1 ? args[1] : "");
|
||||||
|
|
||||||
if (arg1.equals("") || arg2.equals("")) {
|
if (arg1.equals("") || arg2.equals("")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma removeclassperm <classname> <permission>");
|
Messenger.tell(sender, "Usage: /ma removeclassperm <classname> <permission>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the arena class
|
// Grab the arena class
|
||||||
ArenaClass arenaClass = am.getClasses().get(arg1);
|
ArenaClass arenaClass = am.getClasses().get(arg1);
|
||||||
if (arenaClass == null) {
|
if (arenaClass == null) {
|
||||||
Messenger.tellPlayer(sender, "The class '" + TextUtils.camelCase(arg1) + "' does not exist.");
|
Messenger.tell(sender, "The class '" + TextUtils.camelCase(arg1) + "' does not exist.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the permission.
|
// Remove the permission.
|
||||||
if (am.removeClassPermission(arg1, arg2)) {
|
if (am.removeClassPermission(arg1, arg2)) {
|
||||||
Messenger.tellPlayer(sender, "Removed permission '" + arg2 + "' from class '" + TextUtils.camelCase(arg1) + "'.");
|
Messenger.tell(sender, "Removed permission '" + arg2 + "' from class '" + TextUtils.camelCase(arg1) + "'.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it wasn't removed, notify.
|
// If it wasn't removed, notify.
|
||||||
Messenger.tellPlayer(sender, "Permission '" + arg2 + "' was NOT removed from class '" + TextUtils.camelCase(arg1) + "'.");
|
Messenger.tell(sender, "Permission '" + arg2 + "' was NOT removed from class '" + TextUtils.camelCase(arg1) + "'.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,14 @@ public class RemoveContainerCommand implements Command
|
|||||||
|
|
||||||
// Require an argument
|
// Require an argument
|
||||||
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
|
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma removecontainer <point name>");
|
Messenger.tell(sender, "Usage: /ma removecontainer <point name>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (am.getSelectedArena().getRegion().removeChest(arg1))
|
if (am.getSelectedArena().getRegion().removeChest(arg1))
|
||||||
Messenger.tellPlayer(sender, "Container " + arg1 + " removed for arena '" + am.getSelectedArena().configName() + "'");
|
Messenger.tell(sender, "Container " + arg1 + " removed for arena '" + am.getSelectedArena().configName() + "'");
|
||||||
else
|
else
|
||||||
Messenger.tellPlayer(sender, "Could not find the container " + arg1 + "for the arena '" + am.getSelectedArena().configName() + "'");
|
Messenger.tell(sender, "Could not find the container " + arg1 + "for the arena '" + am.getSelectedArena().configName() + "'");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,26 +26,26 @@ public class RemoveLeaderboardCommand implements Command{
|
|||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
if (am.getSelectedArena().getRegion().getLeaderboard() != null) {
|
if (am.getSelectedArena().getRegion().getLeaderboard() != null) {
|
||||||
am.getSelectedArena().getRegion().set("leaderboard", null);
|
am.getSelectedArena().getRegion().set("leaderboard", null);
|
||||||
Messenger.tellPlayer(sender, "Leaderboard for " + am.getSelectedArena().arenaName() + " successfully removed!");
|
Messenger.tell(sender, "Leaderboard for " + am.getSelectedArena().arenaName() + " successfully removed!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Messenger.tellPlayer(sender, Msg.ARENA_LBOARD_NOT_FOUND);
|
Messenger.tell(sender, Msg.ARENA_LBOARD_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (am.getArenaWithName(arg1) != null) {
|
if (am.getArenaWithName(arg1) != null) {
|
||||||
if (am.getSelectedArena().getRegion().getLeaderboard() != null) {
|
if (am.getSelectedArena().getRegion().getLeaderboard() != null) {
|
||||||
am.getArenaWithName(arg1).getRegion().set("leaderboard", null);
|
am.getArenaWithName(arg1).getRegion().set("leaderboard", null);
|
||||||
Messenger.tellPlayer(sender, "Leaderboard for " + am.getArenaWithName(arg1).arenaName() + " successfully removed!");
|
Messenger.tell(sender, "Leaderboard for " + am.getArenaWithName(arg1).arenaName() + " successfully removed!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Messenger.tellPlayer(sender, Msg.ARENA_LBOARD_NOT_FOUND);
|
Messenger.tell(sender, Msg.ARENA_LBOARD_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma removeleaderboard <arenaname>");
|
Messenger.tell(sender, "Usage: /ma removeleaderboard <arenaname>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,14 @@ public class RemoveSpawnpointCommand implements Command
|
|||||||
|
|
||||||
// Require an argument
|
// Require an argument
|
||||||
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
|
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma removespawn <point name>");
|
Messenger.tell(sender, "Usage: /ma removespawn <point name>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (am.getSelectedArena().getRegion().removeSpawn(arg1))
|
if (am.getSelectedArena().getRegion().removeSpawn(arg1))
|
||||||
Messenger.tellPlayer(sender, "Spawnpoint " + arg1 + " removed for arena '" + am.getSelectedArena().configName() + "'");
|
Messenger.tell(sender, "Spawnpoint " + arg1 + " removed for arena '" + am.getSelectedArena().configName() + "'");
|
||||||
else
|
else
|
||||||
Messenger.tellPlayer(sender, "Could not find the spawnpoint " + arg1 + "for the arena '" + am.getSelectedArena().configName() + "'");
|
Messenger.tell(sender, "Could not find the spawnpoint " + arg1 + "for the arena '" + am.getSelectedArena().configName() + "'");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,17 +23,17 @@ public class SetArenaCommand implements Command
|
|||||||
|
|
||||||
// Require an argument
|
// Require an argument
|
||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma setarena <arena>");
|
Messenger.tell(sender, "Usage: /ma setarena <arena>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Arena arena = am.getArenaWithName(arg1);
|
Arena arena = am.getArenaWithName(arg1);
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
am.setSelectedArena(arena);
|
am.setSelectedArena(arena);
|
||||||
Messenger.tellPlayer(sender, "Currently selected arena: " + arena.configName());
|
Messenger.tell(sender, "Currently selected arena: " + arena.configName());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Messenger.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -20,7 +20,7 @@ public class SetClassCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ public class SetClassCommand implements Command
|
|||||||
|
|
||||||
// Require an argument.
|
// Require an argument.
|
||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
Messenger.tellPlayer(p, "Usage: /ma setclass (safe) <classname>");
|
Messenger.tell(p, "Usage: /ma setclass (safe) <classname>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ public class SetClassCommand implements Command
|
|||||||
boolean safe = arg1.equals("safe");
|
boolean safe = arg1.equals("safe");
|
||||||
|
|
||||||
if (safe && arg2.equals("")) {
|
if (safe && arg2.equals("")) {
|
||||||
Messenger.tellPlayer(p, "Usage: /ma setclass (safe) <classname>");
|
Messenger.tell(p, "Usage: /ma setclass (safe) <classname>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,13 +53,13 @@ public class SetClassCommand implements Command
|
|||||||
|
|
||||||
// If the class is null, it was not created.
|
// If the class is null, it was not created.
|
||||||
if (arenaClass == null) {
|
if (arenaClass == null) {
|
||||||
Messenger.tellPlayer(p, "That class already exists!");
|
Messenger.tell(p, "That class already exists!");
|
||||||
Messenger.tellPlayer(p, "To overwrite, omit the 'safe' parameter.");
|
Messenger.tell(p, "To overwrite, omit the 'safe' parameter.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, yay!
|
// Otherwise, yay!
|
||||||
Messenger.tellPlayer(p, "Class '" + className + "' set with your current inventory.");
|
Messenger.tell(p, "Class '" + className + "' set with your current inventory.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class SetLobbyRegionCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ public class SetLobbyRegionCommand implements Command
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|
||||||
if (!(arg1.equals("l1") || arg1.equals("l2"))) {
|
if (!(arg1.equals("l1") || arg1.equals("l2"))) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma setlobbyregion l1|l2");
|
Messenger.tell(sender, "Usage: /ma setlobbyregion l1|l2");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,12 +42,12 @@ public class SetLobbyRegionCommand implements Command
|
|||||||
|
|
||||||
if (!aw.getName().equals(pw.getName())) {
|
if (!aw.getName().equals(pw.getName())) {
|
||||||
String msg = String.format("Changing world of arena '%s' from '%s' to '%s'", arena.configName(), aw.getName(), pw.getName());
|
String msg = String.format("Changing world of arena '%s' from '%s' to '%s'", arena.configName(), aw.getName(), pw.getName());
|
||||||
Messenger.tellPlayer(sender, msg);
|
Messenger.tell(sender, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.setWorld(p.getWorld());
|
arena.setWorld(p.getWorld());
|
||||||
arena.getRegion().set(arg1, p.getLocation());
|
arena.getRegion().set(arg1, p.getLocation());
|
||||||
Messenger.tellPlayer(sender, "Lobby region point " + arg1 + " for arena '" + am.getSelectedArena().configName() + "' set.");
|
Messenger.tell(sender, "Lobby region point " + arg1 + " for arena '" + am.getSelectedArena().configName() + "' set.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class SetRegionCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ public class SetRegionCommand implements Command
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|
||||||
if (!(arg1.equals("p1") || arg1.equals("p2"))) {
|
if (!(arg1.equals("p1") || arg1.equals("p2"))) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma setregion p1|p2");
|
Messenger.tell(sender, "Usage: /ma setregion p1|p2");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,12 +42,12 @@ public class SetRegionCommand implements Command
|
|||||||
|
|
||||||
if (!aw.getName().equals(pw.getName())) {
|
if (!aw.getName().equals(pw.getName())) {
|
||||||
String msg = String.format("Changing world of arena '%s' from '%s' to '%s'", arena.configName(), aw.getName(), pw.getName());
|
String msg = String.format("Changing world of arena '%s' from '%s' to '%s'", arena.configName(), aw.getName(), pw.getName());
|
||||||
Messenger.tellPlayer(sender, msg);
|
Messenger.tell(sender, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.setWorld(p.getWorld());
|
arena.setWorld(p.getWorld());
|
||||||
arena.getRegion().set(arg1, p.getLocation());
|
arena.getRegion().set(arg1, p.getLocation());
|
||||||
Messenger.tellPlayer(sender, "Region point " + arg1 + " for arena '" + am.getSelectedArena().configName() + "' set.");
|
Messenger.tell(sender, "Region point " + arg1 + " for arena '" + am.getSelectedArena().configName() + "' set.");
|
||||||
arena.getRegion().checkData(am.getPlugin(), sender, true, true, false, false);
|
arena.getRegion().checkData(am.getPlugin(), sender, true, true, false, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public class SetWarpCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ public class SetWarpCommand implements Command
|
|||||||
if (arg1.equals("spec")) arg1 = "spectator";
|
if (arg1.equals("spec")) arg1 = "spectator";
|
||||||
|
|
||||||
if (!WARPS.contains(arg1)) {
|
if (!WARPS.contains(arg1)) {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma setwarp arena|lobby|spectator|exit");
|
Messenger.tell(sender, "Usage: /ma setwarp arena|lobby|spectator|exit");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,9 +56,9 @@ public class SetWarpCommand implements Command
|
|||||||
// Make sure the arena warp is inside the region
|
// Make sure the arena warp is inside the region
|
||||||
if (arg1.equals("arena") && !arena.getRegion().contains(p.getLocation())) {
|
if (arg1.equals("arena") && !arena.getRegion().contains(p.getLocation())) {
|
||||||
if (arena.getRegion().isDefined()) {
|
if (arena.getRegion().isDefined()) {
|
||||||
Messenger.tellPlayer(sender, "You must be inside the arena region!");
|
Messenger.tell(sender, "You must be inside the arena region!");
|
||||||
} else {
|
} else {
|
||||||
Messenger.tellPlayer(sender, "You must first set the region points p1 and p2");
|
Messenger.tell(sender, "You must first set the region points p1 and p2");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the world reference in the arena
|
// Restore the world reference in the arena
|
||||||
@ -70,11 +70,11 @@ public class SetWarpCommand implements Command
|
|||||||
// Notify the player if world changed
|
// Notify the player if world changed
|
||||||
if (changeWorld) {
|
if (changeWorld) {
|
||||||
String msg = String.format("Changed world of arena '%s' from '%s' to '%s'", arena.configName(), aw.getName(), pw.getName());
|
String msg = String.format("Changed world of arena '%s' from '%s' to '%s'", arena.configName(), aw.getName(), pw.getName());
|
||||||
Messenger.tellPlayer(sender, msg);
|
Messenger.tell(sender, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then notify about point set
|
// Then notify about point set
|
||||||
Messenger.tellPlayer(sender, "Warp point '" + arg1 + "' was set for arena '" + am.getSelectedArena().configName() + "'");
|
Messenger.tell(sender, "Warp point '" + arg1 + "' was set for arena '" + am.getSelectedArena().configName() + "'");
|
||||||
arena.getRegion().checkData(am.getPlugin(), sender, true, false, true, false);
|
arena.getRegion().checkData(am.getPlugin(), sender, true, false, true, false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -20,7 +20,7 @@ public class ShowRegionCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class ShowRegionCommand implements Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!arena.getRegion().isDefined()) {
|
if (!arena.getRegion().isDefined()) {
|
||||||
Messenger.tellPlayer(sender, "The region is not defined for the selected arena.");
|
Messenger.tell(sender, "The region is not defined for the selected arena.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,14 +47,14 @@ public class ShowRegionCommand implements Command
|
|||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
|
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show an error message if we aren't in the right world
|
// Show an error message if we aren't in the right world
|
||||||
if (!arena.getWorld().getName().equals(arena.getWorld().getName())) {
|
if (!arena.getWorld().getName().equals(arena.getWorld().getName())) {
|
||||||
Messenger.tellPlayer(sender, "Arena '" + arena.configName() +
|
Messenger.tell(sender, "Arena '" + arena.configName() +
|
||||||
"' is in world '" + arena.getWorld().getName() +
|
"' is in world '" + arena.getWorld().getName() +
|
||||||
"' and you are in world '" + p.getWorld().getName() + "'");
|
"' and you are in world '" + p.getWorld().getName() + "'");
|
||||||
return false;
|
return false;
|
||||||
|
@ -22,7 +22,7 @@ public class ShowSpawnsCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ public class ShowSpawnsCommand implements Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (arena.getRegion().getSpawnpoints().isEmpty()) {
|
if (arena.getRegion().getSpawnpoints().isEmpty()) {
|
||||||
Messenger.tellPlayer(sender, "There are no spawnpoints in the selected arena.");
|
Messenger.tell(sender, "There are no spawnpoints in the selected arena.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ public class ShowSpawnsCommand implements Command
|
|||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
|
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class SpawnpointsCommand implements Command
|
|||||||
buffy.append(Msg.MISC_NONE);
|
buffy.append(Msg.MISC_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, "Spawnpoints for arena '" + am.getSelectedArena().configName() + "': " + buffy.toString());
|
Messenger.tell(sender, "Spawnpoints for arena '" + am.getSelectedArena().configName() + "': " + buffy.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class ArenaListCommand implements Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
String list = MAUtils.listToString(arenas, am.getPlugin());
|
String list = MAUtils.listToString(arenas, am.getPlugin());
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_LIST_ARENAS.toString(list));
|
Messenger.tell(sender, Msg.MISC_LIST_ARENAS.format(list));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public class JoinCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public class JoinCommand implements Command
|
|||||||
|
|
||||||
// Deny joining from other arenas
|
// Deny joining from other arenas
|
||||||
if (fromArena != null && (fromArena.inArena(p) || fromArena.inLobby(p))) {
|
if (fromArena != null && (fromArena.inArena(p) || fromArena.inLobby(p))) {
|
||||||
Messenger.tellPlayer(p, Msg.JOIN_ALREADY_PLAYING);
|
Messenger.tell(p, Msg.JOIN_ALREADY_PLAYING);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class LeaveCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,13 +31,13 @@ public class LeaveCommand implements Command
|
|||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
arena = am.getArenaWithSpectator(p);
|
arena = am.getArenaWithSpectator(p);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(p, Msg.LEAVE_NOT_PLAYING);
|
Messenger.tell(p, Msg.LEAVE_NOT_PLAYING);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.playerLeave(p)) {
|
if (arena.playerLeave(p)) {
|
||||||
Messenger.tellPlayer(p, Msg.LEAVE_PLAYER_LEFT);
|
Messenger.tell(p, Msg.LEAVE_PLAYER_LEFT);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class NotReadyCommand implements Command
|
|||||||
if (!arg1.equals("")) {
|
if (!arg1.equals("")) {
|
||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,17 +37,17 @@ public class NotReadyCommand implements Command
|
|||||||
arena = am.getArenaWithPlayer(p);
|
arena = am.getArenaWithPlayer(p);
|
||||||
|
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, Msg.LEAVE_NOT_PLAYING);
|
Messenger.tell(sender, Msg.LEAVE_NOT_PLAYING);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Messenger.tellPlayer(sender, "Usage: /ma notready <arena name>");
|
Messenger.tell(sender, "Usage: /ma notready <arena name>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String list = MAUtils.listToString(arena.getNonreadyPlayers(), am.getPlugin());
|
String list = MAUtils.listToString(arena.getNonreadyPlayers(), am.getPlugin());
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_LIST_PLAYERS.toString(list));
|
Messenger.tell(sender, Msg.MISC_LIST_PLAYERS.format(list));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class PlayerListCommand implements Command
|
|||||||
Arena arena = am.getArenaWithName(arg1);
|
Arena arena = am.getArenaWithName(arg1);
|
||||||
|
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ public class PlayerListCommand implements Command
|
|||||||
list = buffy.toString();
|
list = buffy.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_LIST_PLAYERS.toString(list));
|
Messenger.tell(sender, Msg.MISC_LIST_PLAYERS.format(list));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public class SpecCommand implements Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tellPlayer(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public class SpecCommand implements Command
|
|||||||
|
|
||||||
// Deny spectating from other arenas
|
// Deny spectating from other arenas
|
||||||
if (fromArena != null && (fromArena.inArena(p) || fromArena.inLobby(p))) {
|
if (fromArena != null && (fromArena.inArena(p) || fromArena.inLobby(p))) {
|
||||||
Messenger.tellPlayer(p, Msg.SPEC_ALREADY_PLAYING);
|
Messenger.tell(p, Msg.SPEC_ALREADY_PLAYING);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +54,6 @@ public interface Arena
|
|||||||
|
|
||||||
public void setEditMode(boolean value);
|
public void setEditMode(boolean value);
|
||||||
|
|
||||||
public Material getClassLogo(String classname);
|
|
||||||
|
|
||||||
public List<ItemStack> getEntryFee();
|
public List<ItemStack> getEntryFee();
|
||||||
|
|
||||||
public Set<Map.Entry<Integer,List<ItemStack>>> getEveryWaveEntrySet();
|
public Set<Map.Entry<Integer,List<ItemStack>>> getEveryWaveEntrySet();
|
||||||
|
@ -93,7 +93,7 @@ public class MAGlobalListener implements Listener
|
|||||||
}
|
}
|
||||||
else if ((stat = Stats.getByShortName(text)) != null) {
|
else if ((stat = Stats.getByShortName(text)) != null) {
|
||||||
setSignLines(event, ChatColor.GREEN + "", "", ChatColor.AQUA + stat.getFullName(), "---------------");
|
setSignLines(event, ChatColor.GREEN + "", "", ChatColor.AQUA + stat.getFullName(), "---------------");
|
||||||
Messenger.tellPlayer(event.getPlayer(), "Stat sign created.");
|
Messenger.tell(event.getPlayer(), "Stat sign created.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ public class ArenaRegion
|
|||||||
if (p1 == null) list.add("p1");
|
if (p1 == null) list.add("p1");
|
||||||
if (p2 == null) list.add("p2");
|
if (p2 == null) list.add("p2");
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
Messenger.tellPlayer(s, "Missing region points: " + MAUtils.listToString(list, plugin));
|
Messenger.tell(s, "Missing region points: " + MAUtils.listToString(list, plugin));
|
||||||
list.clear();
|
list.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ public class ArenaRegion
|
|||||||
if (lobbyWarp == null) list.add("lobby");
|
if (lobbyWarp == null) list.add("lobby");
|
||||||
if (specWarp == null) list.add("spectator");
|
if (specWarp == null) list.add("spectator");
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
Messenger.tellPlayer(s, "Missing warps: " + MAUtils.listToString(list, plugin));
|
Messenger.tell(s, "Missing warps: " + MAUtils.listToString(list, plugin));
|
||||||
list.clear();
|
list.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,13 +146,13 @@ public class ArenaRegion
|
|||||||
// Spawnpoints
|
// Spawnpoints
|
||||||
if (spawns) {
|
if (spawns) {
|
||||||
if (spawnpoints.isEmpty()) {
|
if (spawnpoints.isEmpty()) {
|
||||||
Messenger.tellPlayer(s, "Missing spawnpoints");
|
Messenger.tell(s, "Missing spawnpoints");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ready?
|
// Ready?
|
||||||
if (ready && setup) {
|
if (ready && setup) {
|
||||||
Messenger.tellPlayer(s, "Arena is ready to be used!");
|
Messenger.tell(s, "Arena is ready to be used!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,12 +599,12 @@ public class ArenaRegion
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (map.isEmpty()) {
|
if (map.isEmpty()) {
|
||||||
Messenger.tellPlayer(p, "No spawnpoints cover your location!");
|
Messenger.tell(p, "No spawnpoints cover your location!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify the player
|
// Notify the player
|
||||||
Messenger.tellPlayer(p, "The following points cover your location:");
|
Messenger.tell(p, "The following points cover your location:");
|
||||||
for (Map.Entry<String,Location> entry : map.entrySet()) {
|
for (Map.Entry<String,Location> entry : map.entrySet()) {
|
||||||
Location l = entry.getValue();
|
Location l = entry.getValue();
|
||||||
String coords = l.getBlockX() + "," + l.getBlockY() + "," + l.getBlockZ();
|
String coords = l.getBlockX() + "," + l.getBlockY() + "," + l.getBlockZ();
|
||||||
|
@ -58,8 +58,8 @@ public class VersionChecker
|
|||||||
Messenger.info("MobArena v" + latestVersion + " is now available!");
|
Messenger.info("MobArena v" + latestVersion + " is now available!");
|
||||||
Messenger.info("Your version: v" + currentVersion);
|
Messenger.info("Your version: v" + currentVersion);
|
||||||
} else if (player.isOnline()) {
|
} else if (player.isOnline()) {
|
||||||
Messenger.tellPlayer(player, "MobArena v" + latestVersion + " is now available!");
|
Messenger.tell(player, "MobArena v" + latestVersion + " is now available!");
|
||||||
Messenger.tellPlayer(player, "Your version: v" + currentVersion);
|
Messenger.tell(player, "Your version: v" + currentVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, (player == null ? 0 : 60));
|
}, (player == null ? 0 : 60));
|
||||||
|
@ -4,9 +4,12 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -20,32 +23,44 @@ public class ConfigUtils
|
|||||||
process(plugin, resource, section, false, true);
|
process(plugin, resource, section, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addMissingRemoveObsolete(File file, YamlConfiguration defaults, FileConfiguration config) {
|
||||||
|
try {
|
||||||
|
process(defaults, config, false, true);
|
||||||
|
config.save(file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void process(Plugin plugin, String resource, ConfigurationSection section, boolean addOnlyIfEmpty, boolean removeObsolete) {
|
private static void process(Plugin plugin, String resource, ConfigurationSection section, boolean addOnlyIfEmpty, boolean removeObsolete) {
|
||||||
try {
|
try {
|
||||||
YamlConfiguration defaults = new YamlConfiguration();
|
YamlConfiguration defaults = new YamlConfiguration();
|
||||||
defaults.load(plugin.getResource("res/" + resource));
|
defaults.load(plugin.getResource("res/" + resource));
|
||||||
|
|
||||||
Set<String> present = section.getKeys(true);
|
process(defaults, section, addOnlyIfEmpty, removeObsolete);
|
||||||
Set<String> required = defaults.getKeys(true);
|
|
||||||
|
|
||||||
if (!addOnlyIfEmpty || present.isEmpty()) {
|
|
||||||
for (String req : required) {
|
|
||||||
if (!present.remove(req)) {
|
|
||||||
section.set(req, defaults.get(req));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (removeObsolete) {
|
|
||||||
for (String obs : present) {
|
|
||||||
section.set(obs, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void process(YamlConfiguration defaults, ConfigurationSection section, boolean addOnlyIfEmpty, boolean removeObsolete) {
|
||||||
|
Set<String> present = section.getKeys(true);
|
||||||
|
Set<String> required = defaults.getKeys(true);
|
||||||
|
if (!addOnlyIfEmpty || present.isEmpty()) {
|
||||||
|
for (String req : required) {
|
||||||
|
if (!present.remove(req)) {
|
||||||
|
section.set(req, defaults.get(req));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (removeObsolete) {
|
||||||
|
for (String obs : present) {
|
||||||
|
section.set(obs, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static ConfigurationSection makeSection(ConfigurationSection config, String section) {
|
public static ConfigurationSection makeSection(ConfigurationSection config, String section) {
|
||||||
if (!config.contains(section)) {
|
if (!config.contains(section)) {
|
||||||
return config.createSection(section);
|
return config.createSection(section);
|
||||||
|
@ -10,42 +10,42 @@ public enum WaveType
|
|||||||
DEFAULT {
|
DEFAULT {
|
||||||
@Override
|
@Override
|
||||||
public void announce(Arena arena, int wave) {
|
public void announce(Arena arena, int wave) {
|
||||||
Messenger.tellAll(arena, Msg.WAVE_DEFAULT, ""+wave);
|
Messenger.announce(arena, Msg.WAVE_DEFAULT, "" + wave);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
SPECIAL {
|
SPECIAL {
|
||||||
@Override
|
@Override
|
||||||
public void announce(Arena arena, int wave) {
|
public void announce(Arena arena, int wave) {
|
||||||
Messenger.tellAll(arena, Msg.WAVE_SPECIAL, ""+wave);
|
Messenger.announce(arena, Msg.WAVE_SPECIAL, "" + wave);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
SWARM {
|
SWARM {
|
||||||
@Override
|
@Override
|
||||||
public void announce(Arena arena, int wave) {
|
public void announce(Arena arena, int wave) {
|
||||||
Messenger.tellAll(arena, Msg.WAVE_SWARM, ""+wave);
|
Messenger.announce(arena, Msg.WAVE_SWARM, "" + wave);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
SUPPLY {
|
SUPPLY {
|
||||||
@Override
|
@Override
|
||||||
public void announce(Arena arena, int wave) {
|
public void announce(Arena arena, int wave) {
|
||||||
Messenger.tellAll(arena, Msg.WAVE_SUPPLY, ""+wave);
|
Messenger.announce(arena, Msg.WAVE_SUPPLY, "" + wave);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
BOSS {
|
BOSS {
|
||||||
@Override
|
@Override
|
||||||
public void announce(Arena arena, int wave) {
|
public void announce(Arena arena, int wave) {
|
||||||
Messenger.tellAll(arena, Msg.WAVE_BOSS, ""+wave);
|
Messenger.announce(arena, Msg.WAVE_BOSS, "" + wave);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
UPGRADE {
|
UPGRADE {
|
||||||
@Override
|
@Override
|
||||||
public void announce(Arena arena, int wave) {
|
public void announce(Arena arena, int wave) {
|
||||||
Messenger.tellAll(arena, Msg.WAVE_UPGRADE, ""+wave);
|
Messenger.announce(arena, Msg.WAVE_UPGRADE, "" + wave);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ public class BossWave extends AbstractWave
|
|||||||
public void announceAbility(Ability ability, MABoss boss, Arena arena) {
|
public void announceAbility(Ability ability, MABoss boss, Arena arena) {
|
||||||
if(getAbilityAnnounce()) {
|
if(getAbilityAnnounce()) {
|
||||||
AbilityInfo info = ability.getClass().getAnnotation(AbilityInfo.class);
|
AbilityInfo info = ability.getClass().getAnnotation(AbilityInfo.class);
|
||||||
Messenger.tellAll(arena, Msg.WAVE_BOSS_ABILITY, info.name());
|
Messenger.announce(arena, Msg.WAVE_BOSS_ABILITY, info.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user