Massive code clean up/refactor + Compile with 1.7.9 API + Fix scoreboard (I hope). This still update not good enough, since the main task loop still updates signs/scoreboards every second. This needs to be fixed so do not use this build.
This commit is contained in:
parent
b8f2335f9b
commit
83875fa8d3
4
pom.xml
4
pom.xml
@ -38,14 +38,14 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.6.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.7.9-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- CraftBukkit Dependency for experimental features
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.6.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.7.9-R0.1-SNAPSHOT</version>
|
||||
</dependency>-->
|
||||
|
||||
<!-- LibsDiguises is required for hiding -->
|
||||
|
@ -45,18 +45,11 @@ public class Arena implements ConfigurationSerializable {
|
||||
public List<Player> seekers;
|
||||
public Scoreboard scoreboard;
|
||||
|
||||
public Arena (String arenaName, LocationSerializable pos1,
|
||||
LocationSerializable pos2, int maxPlayers, int minPlayers,
|
||||
int amountSeekersOnStart, int timeInLobbyUntilStart,
|
||||
int waitingTimeSeeker, int gameTime, int timeUntilHidersSword,
|
||||
ArrayList<ItemStack> disguiseBlocks,
|
||||
LocationSerializable lobbyWarp, LocationSerializable hidersWarp,
|
||||
LocationSerializable seekersWarp, LocationSerializable spawnWarp,
|
||||
List<String> seekersWinCommands, List<String> hidersWinCommands,
|
||||
List<String> allowedCommands, int seekersTokenWin,
|
||||
int hidersTokenWin, int killTokens, List<Player> playersInArena,
|
||||
ArenaState gameState, int timer, List<Player> seekers,
|
||||
Scoreboard scoreboard) {
|
||||
public Arena(String arenaName, LocationSerializable pos1, LocationSerializable pos2, int maxPlayers, int minPlayers, int amountSeekersOnStart,
|
||||
int timeInLobbyUntilStart, int waitingTimeSeeker, int gameTime, int timeUntilHidersSword, ArrayList<ItemStack> disguiseBlocks,
|
||||
LocationSerializable lobbyWarp, LocationSerializable hidersWarp, LocationSerializable seekersWarp, LocationSerializable spawnWarp,
|
||||
List<String> seekersWinCommands, List<String> hidersWinCommands, List<String> allowedCommands, int seekersTokenWin, int hidersTokenWin, int killTokens,
|
||||
List<Player> playersInArena, ArenaState gameState, int timer, List<Player> seekers, Scoreboard scoreboard) {
|
||||
this.arenaName = arenaName;
|
||||
this.pos1 = pos1;
|
||||
this.pos2 = pos2;
|
||||
@ -100,7 +93,11 @@ public class Arena implements ConfigurationSerializable {
|
||||
}
|
||||
|
||||
public enum ArenaState {
|
||||
WAITING, STARTING, INGAME, RESTARTING, DISABLED;
|
||||
WAITING,
|
||||
STARTING,
|
||||
INGAME,
|
||||
RESTARTING,
|
||||
DISABLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -132,33 +129,15 @@ public class Arena implements ConfigurationSerializable {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Arena deserialize(Map<String, Object> map) {
|
||||
LocationSerializable loc = new LocationSerializable(
|
||||
Bukkit.getWorld("world"), 0, 0, 0, 0, 0);
|
||||
return new Arena((String) M.g(map, "arenaName", "UNKNOWN_NAME"),
|
||||
(LocationSerializable) M.g(map, "pos1", loc),
|
||||
(LocationSerializable) M.g(map, "pos2", loc), (Integer) M.g(
|
||||
map, "maxPlayers", 12), (Integer) M.g(map,
|
||||
"minPlayers", 3), (Integer) M.g(map,
|
||||
"amountSeekersOnStart", 1), (Integer) M.g(map,
|
||||
"timeInLobbyUntilStart", 90), (Integer) M.g(map,
|
||||
"waitingTimeSeeker", 20), (Integer) M.g(map,
|
||||
"gameTime", 200), (Integer) M.g(map,
|
||||
"timeUntilHidersSword", 30),
|
||||
(ArrayList<ItemStack>) M.g(map, "disguiseBlocks",
|
||||
new ArrayList<ItemStack>()),
|
||||
(LocationSerializable) M.g(map, "lobbyWarp", loc),
|
||||
(LocationSerializable) M.g(map, "hidersWarp", loc),
|
||||
(LocationSerializable) M.g(map, "seekersWarp", loc),
|
||||
(LocationSerializable) M.g(map, "spawnWarp", loc),
|
||||
(ArrayList<String>) M.g(map, "seekersWinCommands",
|
||||
new ArrayList<String>()), (ArrayList<String>) M.g(map,
|
||||
"hidersWinCommands", new ArrayList<String>()),
|
||||
(ArrayList<String>) M.g(map, "allowedCommands",
|
||||
new ArrayList<String>()), (Integer) M.g(map,
|
||||
"seekersTokenWin", 10), (Integer) M.g(map,
|
||||
"hidersTokenWin", 50), (Integer) M.g(map, "killTokens",
|
||||
8), new ArrayList<Player>(), ArenaState.WAITING, 0,
|
||||
new ArrayList<Player>(), Bukkit.getScoreboardManager()
|
||||
.getNewScoreboard());
|
||||
LocationSerializable loc = new LocationSerializable(Bukkit.getWorld("world"), 0, 0, 0, 0, 0);
|
||||
return new Arena((String) M.g(map, "arenaName", "UNKNOWN_NAME"), (LocationSerializable) M.g(map, "pos1", loc), (LocationSerializable) M.g(map, "pos2", loc),
|
||||
(Integer) M.g(map, "maxPlayers", 12), (Integer) M.g(map, "minPlayers", 3), (Integer) M.g(map, "amountSeekersOnStart", 1), (Integer) M.g(map,
|
||||
"timeInLobbyUntilStart", 90), (Integer) M.g(map, "waitingTimeSeeker", 20), (Integer) M.g(map, "gameTime", 200), (Integer) M.g(map,
|
||||
"timeUntilHidersSword", 30), (ArrayList<ItemStack>) M.g(map, "disguiseBlocks", new ArrayList<ItemStack>()), (LocationSerializable) M.g(map,
|
||||
"lobbyWarp", loc), (LocationSerializable) M.g(map, "hidersWarp", loc), (LocationSerializable) M.g(map, "seekersWarp", loc),
|
||||
(LocationSerializable) M.g(map, "spawnWarp", loc), (ArrayList<String>) M.g(map, "seekersWinCommands", new ArrayList<String>()), (ArrayList<String>) M.g(
|
||||
map, "hidersWinCommands", new ArrayList<String>()), (ArrayList<String>) M.g(map, "allowedCommands", new ArrayList<String>()), (Integer) M.g(map,
|
||||
"seekersTokenWin", 10), (Integer) M.g(map, "hidersTokenWin", 50), (Integer) M.g(map, "killTokens", 8), new ArrayList<Player>(),
|
||||
ArenaState.WAITING, 0, new ArrayList<Player>(), Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}
|
@ -40,11 +40,9 @@ public class ArenaHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendFMessage(Arena arena, ConfigC location,
|
||||
String... vars) {
|
||||
public static void sendFMessage(Arena arena, ConfigC location, String... vars) {
|
||||
for (Player player : arena.playersInArena) {
|
||||
String pMessage = location.config.getFile().get(location.location)
|
||||
.toString().replaceAll("%player%", player.getName());
|
||||
String pMessage = location.config.getFile().get(location.location).toString().replaceAll("%player%", player.getName());
|
||||
player.sendMessage(MessageM.replaceAll(pMessage, vars));
|
||||
}
|
||||
}
|
||||
@ -66,8 +64,7 @@ public class ArenaHandler {
|
||||
if (arena.arenaName.equalsIgnoreCase(arenaname)) {
|
||||
found = true;
|
||||
if (arena.disguiseBlocks.isEmpty()) {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_joinNoBlocksSet);
|
||||
MessageM.sendFMessage(player, ConfigC.error_joinNoBlocksSet);
|
||||
} else {
|
||||
boolean inventoryempty = true;
|
||||
for (ItemStack invitem : player.getInventory()) {
|
||||
@ -78,62 +75,38 @@ public class ArenaHandler {
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack invitem : player.getInventory()
|
||||
.getArmorContents()) {
|
||||
for (ItemStack invitem : player.getInventory().getArmorContents()) {
|
||||
if (invitem.getType() != Material.AIR) {
|
||||
inventoryempty = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Boolean) W.config
|
||||
.get(ConfigC.requireInventoryClearOnJoin)
|
||||
&& !inventoryempty) {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_joinInventoryNotEmpty);
|
||||
if ((Boolean) W.config.get(ConfigC.requireInventoryClearOnJoin) && !inventoryempty) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_joinInventoryNotEmpty);
|
||||
return;
|
||||
}
|
||||
|
||||
LocationSerializable zero = new LocationSerializable(
|
||||
Bukkit.getWorld(player.getWorld().getName()
|
||||
.toString()), 0, 0, 0, 0, 0);
|
||||
if (arena.lobbyWarp != null && arena.hidersWarp != null
|
||||
&& arena.seekersWarp != null
|
||||
&& arena.spawnWarp != null) {
|
||||
if (!arena.lobbyWarp.equals(zero)
|
||||
&& !arena.hidersWarp.equals(zero)
|
||||
&& !arena.seekersWarp.equals(zero)
|
||||
&& !arena.spawnWarp.equals(zero)) {
|
||||
if (arena.gameState == ArenaState.WAITING
|
||||
|| arena.gameState == ArenaState.STARTING) {
|
||||
LocationSerializable zero = new LocationSerializable(Bukkit.getWorld(player.getWorld().getName().toString()), 0, 0, 0, 0, 0);
|
||||
if (arena.lobbyWarp != null && arena.hidersWarp != null && arena.seekersWarp != null && arena.spawnWarp != null) {
|
||||
if (!arena.lobbyWarp.equals(zero) && !arena.hidersWarp.equals(zero) && !arena.seekersWarp.equals(zero) && !arena.spawnWarp.equals(zero)) {
|
||||
if (arena.gameState == ArenaState.WAITING || arena.gameState == ArenaState.STARTING) {
|
||||
if (arena.playersInArena.size() >= arena.maxPlayers) {
|
||||
if (!PermissionsM.hasPerm(player,
|
||||
Permissions.joinfull, false)) {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_joinFull);
|
||||
if (!PermissionsM.hasPerm(player, Permissions.joinfull, false)) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_joinFull);
|
||||
return;
|
||||
}
|
||||
}
|
||||
arena.playersInArena.add(player);
|
||||
|
||||
PlayerArenaData pad = new PlayerArenaData(
|
||||
player.getLocation(),
|
||||
player.getGameMode(), player
|
||||
.getInventory()
|
||||
.getContents(), player
|
||||
.getInventory()
|
||||
.getArmorContents(),
|
||||
player.getExp(), player.getLevel(),
|
||||
player.getHealth(),
|
||||
player.getFoodLevel(),
|
||||
player.getActivePotionEffects(),
|
||||
player.getAllowFlight());
|
||||
PlayerArenaData pad = new PlayerArenaData(player.getLocation(), player.getGameMode(), player.getInventory().getContents(), player
|
||||
.getInventory().getArmorContents(), player.getExp(), player.getLevel(), player.getHealth(), player.getFoodLevel(),
|
||||
player.getActivePotionEffects(), player.getAllowFlight());
|
||||
|
||||
W.pData.put(player, pad);
|
||||
|
||||
player.teleport(arena.lobbyWarp);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
for (PotionEffect pe : player
|
||||
.getActivePotionEffects()) {
|
||||
for (PotionEffect pe : player.getActivePotionEffects()) {
|
||||
player.removePotionEffect(pe.getType());
|
||||
}
|
||||
player.setFoodLevel(20);
|
||||
@ -141,129 +114,88 @@ public class ArenaHandler {
|
||||
player.setLevel(arena.timer);
|
||||
player.setExp(0);
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setHelmet(
|
||||
new ItemStack(Material.AIR));
|
||||
player.getInventory().setChestplate(
|
||||
new ItemStack(Material.AIR));
|
||||
player.getInventory().setLeggings(
|
||||
new ItemStack(Material.AIR));
|
||||
player.getInventory().setBoots(
|
||||
new ItemStack(Material.AIR));
|
||||
player.getInventory().setHelmet(new ItemStack(Material.AIR));
|
||||
player.getInventory().setChestplate(new ItemStack(Material.AIR));
|
||||
player.getInventory().setLeggings(new ItemStack(Material.AIR));
|
||||
player.getInventory().setBoots(new ItemStack(Material.AIR));
|
||||
player.setFlying(false);
|
||||
player.setAllowFlight(false);
|
||||
player.setWalkSpeed(0.25F);
|
||||
|
||||
// Fix for client not showing players after they join
|
||||
// Fix for client not showing players after
|
||||
// they join
|
||||
for (Player otherplayer : arena.playersInArena) {
|
||||
if (otherplayer.canSee(player)) otherplayer.showPlayer(player); // Make new player visible to others
|
||||
if (player.canSee(otherplayer)) player.showPlayer(otherplayer); // Make other players visible to new player
|
||||
if (otherplayer.canSee(player))
|
||||
otherplayer.showPlayer(player); // Make
|
||||
// new
|
||||
// player
|
||||
// visible
|
||||
// to
|
||||
// others
|
||||
if (player.canSee(otherplayer))
|
||||
player.showPlayer(otherplayer); // Make
|
||||
// other
|
||||
// players
|
||||
// visible
|
||||
// to
|
||||
// new
|
||||
// player
|
||||
}
|
||||
|
||||
if ((Boolean) W.config
|
||||
.get(ConfigC.shop_blockChooserv1Enabled) == true) {
|
||||
if (W.shop.getFile().get(
|
||||
player.getName()
|
||||
+ ".blockchooser") != null
|
||||
|| PermissionsM
|
||||
.hasPerm(
|
||||
player,
|
||||
Permissions.shopblockchooser,
|
||||
false)) {
|
||||
ItemStack shopBlockChooser = new ItemStack(
|
||||
Material.getMaterial((String) W.config
|
||||
.get(ConfigC.shop_blockChooserv1IDname)),
|
||||
1);
|
||||
ItemMeta shopBlockChooser_IM = shopBlockChooser
|
||||
.getItemMeta();
|
||||
shopBlockChooser_IM
|
||||
.setDisplayName(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.shop_blockChooserv1Name)));
|
||||
List<String> lores = W.config
|
||||
.getFile()
|
||||
.getStringList(
|
||||
ConfigC.shop_blockChooserv1Description.location);
|
||||
if ((Boolean) W.config.get(ConfigC.shop_blockChooserv1Enabled) == true) {
|
||||
if (W.shop.getFile().get(player.getName() + ".blockchooser") != null
|
||||
|| PermissionsM.hasPerm(player, Permissions.shopblockchooser, false)) {
|
||||
ItemStack shopBlockChooser = new ItemStack(Material.getMaterial((String) W.config.get(ConfigC.shop_blockChooserv1IDname)), 1);
|
||||
ItemMeta shopBlockChooser_IM = shopBlockChooser.getItemMeta();
|
||||
shopBlockChooser_IM.setDisplayName(MessageM.replaceAll((String) W.config.get(ConfigC.shop_blockChooserv1Name)));
|
||||
List<String> lores = W.config.getFile().getStringList(ConfigC.shop_blockChooserv1Description.location);
|
||||
List<String> lores2 = new ArrayList<String>();
|
||||
for (String lore : lores) {
|
||||
lores2.add(MessageM
|
||||
.replaceAll(lore));
|
||||
lores2.add(MessageM.replaceAll(lore));
|
||||
}
|
||||
shopBlockChooser_IM.setLore(lores2);
|
||||
shopBlockChooser
|
||||
.setItemMeta(shopBlockChooser_IM);
|
||||
shopBlockChooser.setItemMeta(shopBlockChooser_IM);
|
||||
|
||||
player.getInventory().addItem(
|
||||
shopBlockChooser);
|
||||
player.getInventory().addItem(shopBlockChooser);
|
||||
}
|
||||
}
|
||||
|
||||
if ((Boolean) W.config
|
||||
.get(ConfigC.shop_BlockHuntPassv2Enabled) == true) {
|
||||
if (W.shop.getFile().getInt(
|
||||
player.getName()
|
||||
+ ".blockhuntpass") != 0) {
|
||||
ItemStack shopBlockHuntPass = new ItemStack(
|
||||
Material.getMaterial((String) W.config
|
||||
.get(ConfigC.shop_BlockHuntPassv2IDName)),
|
||||
if ((Boolean) W.config.get(ConfigC.shop_BlockHuntPassv2Enabled) == true) {
|
||||
if (W.shop.getFile().getInt(player.getName() + ".blockhuntpass") != 0) {
|
||||
ItemStack shopBlockHuntPass = new ItemStack(Material.getMaterial((String) W.config.get(ConfigC.shop_BlockHuntPassv2IDName)),
|
||||
1);
|
||||
ItemMeta shopBlockHuntPass_IM = shopBlockHuntPass
|
||||
.getItemMeta();
|
||||
shopBlockHuntPass_IM
|
||||
.setDisplayName(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.shop_BlockHuntPassv2Name)));
|
||||
List<String> lores = W.config
|
||||
.getFile()
|
||||
.getStringList(
|
||||
ConfigC.shop_BlockHuntPassv2Description.location);
|
||||
ItemMeta shopBlockHuntPass_IM = shopBlockHuntPass.getItemMeta();
|
||||
shopBlockHuntPass_IM.setDisplayName(MessageM.replaceAll((String) W.config.get(ConfigC.shop_BlockHuntPassv2Name)));
|
||||
List<String> lores = W.config.getFile().getStringList(ConfigC.shop_BlockHuntPassv2Description.location);
|
||||
List<String> lores2 = new ArrayList<String>();
|
||||
for (String lore : lores) {
|
||||
lores2.add(MessageM
|
||||
.replaceAll(lore));
|
||||
lores2.add(MessageM.replaceAll(lore));
|
||||
}
|
||||
|
||||
shopBlockHuntPass_IM
|
||||
.setLore(lores2);
|
||||
shopBlockHuntPass
|
||||
.setItemMeta(shopBlockHuntPass_IM);
|
||||
shopBlockHuntPass
|
||||
.setAmount(W.shop
|
||||
.getFile()
|
||||
.getInt(player
|
||||
.getName()
|
||||
+ ".blockhuntpass"));
|
||||
shopBlockHuntPass_IM.setLore(lores2);
|
||||
shopBlockHuntPass.setItemMeta(shopBlockHuntPass_IM);
|
||||
shopBlockHuntPass.setAmount(W.shop.getFile().getInt(player.getName() + ".blockhuntpass"));
|
||||
|
||||
player.getInventory().addItem(
|
||||
shopBlockHuntPass);
|
||||
player.getInventory().addItem(shopBlockHuntPass);
|
||||
}
|
||||
}
|
||||
player.updateInventory();
|
||||
|
||||
DisguiseAPI.undisguiseToAll(player);
|
||||
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_joinJoinedArena,
|
||||
"playername-" + player.getName(),
|
||||
"1-" + arena.playersInArena.size(),
|
||||
"2-" + arena.maxPlayers);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_joinJoinedArena, "playername-" + player.getName(),
|
||||
"1-" + arena.playersInArena.size(), "2-" + arena.maxPlayers);
|
||||
if (arena.playersInArena.size() < arena.minPlayers) {
|
||||
ArenaHandler
|
||||
.sendFMessage(
|
||||
arena,
|
||||
ConfigC.warning_lobbyNeedAtleast,
|
||||
"1-" + arena.minPlayers);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.warning_lobbyNeedAtleast, "1-" + arena.minPlayers);
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_joinArenaIngame);
|
||||
MessageM.sendFMessage(player, ConfigC.error_joinArenaIngame);
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_joinWarpsNotSet);
|
||||
MessageM.sendFMessage(player, ConfigC.error_joinWarpsNotSet);
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_joinWarpsNotSet);
|
||||
MessageM.sendFMessage(player, ConfigC.error_joinWarpsNotSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -274,16 +206,14 @@ public class ArenaHandler {
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_noArena, "name-"
|
||||
+ arenaname);
|
||||
MessageM.sendFMessage(player, ConfigC.error_noArena, "name-" + arenaname);
|
||||
}
|
||||
|
||||
SignsHandler.updateSigns();
|
||||
}
|
||||
|
||||
public static void playerLeaveArena(Player player, boolean message,
|
||||
boolean cleanup) {
|
||||
|
||||
public static void playerLeaveArena(Player player, boolean message, boolean cleanup) {
|
||||
|
||||
Arena arena = null;
|
||||
for (Arena arena2 : W.arenaList) {
|
||||
if (arena2.playersInArena != null) {
|
||||
@ -302,18 +232,14 @@ public class ArenaHandler {
|
||||
arena.seekers.remove(player);
|
||||
}
|
||||
|
||||
if (arena.playersInArena.size() < arena.minPlayers
|
||||
&& arena.gameState.equals(ArenaState.STARTING)) {
|
||||
if (arena.playersInArena.size() < arena.minPlayers && arena.gameState.equals(ArenaState.STARTING)) {
|
||||
arena.gameState = ArenaState.WAITING;
|
||||
arena.timer = 0;
|
||||
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.warning_lobbyNeedAtleast, "1-"
|
||||
+ arena.minPlayers);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.warning_lobbyNeedAtleast, "1-" + arena.minPlayers);
|
||||
}
|
||||
|
||||
if (arena.playersInArena.size() <= 1
|
||||
&& arena.gameState == ArenaState.INGAME) {
|
||||
if (arena.playersInArena.size() <= 1 && arena.gameState == ArenaState.INGAME) {
|
||||
if (arena.seekers.size() >= arena.playersInArena.size()) {
|
||||
ArenaHandler.seekersWin(arena);
|
||||
} else {
|
||||
@ -325,16 +251,10 @@ public class ArenaHandler {
|
||||
ArenaHandler.seekersWin(arena);
|
||||
}
|
||||
|
||||
if (arena.seekers.size() <= 0
|
||||
&& arena.gameState == ArenaState.INGAME) {
|
||||
Player seeker = arena.playersInArena.get(W.random
|
||||
.nextInt(arena.playersInArena.size()));
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.warning_ingameNEWSeekerChoosen, "seeker-"
|
||||
+ seeker.getName());
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameSeekerChoosen, "seeker-"
|
||||
+ seeker.getName());
|
||||
if (arena.seekers.size() <= 0 && arena.gameState == ArenaState.INGAME) {
|
||||
Player seeker = arena.playersInArena.get(W.random.nextInt(arena.playersInArena.size()));
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.warning_ingameNEWSeekerChoosen, "seeker-" + seeker.getName());
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameSeekerChoosen, "seeker-" + seeker.getName());
|
||||
DisguiseAPI.undisguiseToAll(seeker);
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
pl.showPlayer(seeker);
|
||||
@ -347,14 +267,18 @@ public class ArenaHandler {
|
||||
|
||||
// Fix for client not showing players after they join
|
||||
for (Player otherplayer : arena.playersInArena) {
|
||||
if (otherplayer.canSee(player)) otherplayer.showPlayer(player); // Make new player visible to others
|
||||
if (player.canSee(otherplayer)) player.showPlayer(otherplayer); // Make other players visible to new player
|
||||
if (otherplayer.canSee(player))
|
||||
otherplayer.showPlayer(player); // Make new player
|
||||
// visible to others
|
||||
if (player.canSee(otherplayer))
|
||||
player.showPlayer(otherplayer); // Make other
|
||||
// players visible
|
||||
// to new player
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlayerArenaData pad = new PlayerArenaData(null, null, null, null,
|
||||
null, null, null, null, null, false);
|
||||
PlayerArenaData pad = new PlayerArenaData(null, null, null, null, null, null, null, null, null, false);
|
||||
|
||||
if (W.pData.get(player) != null) {
|
||||
pad = W.pData.get(player);
|
||||
@ -385,11 +309,9 @@ public class ArenaHandler {
|
||||
if (W.hiddenLocWater.get(player) != null) {
|
||||
Block pBlock = W.hiddenLoc.get(player).getBlock();
|
||||
if (W.hiddenLocWater.get(player)) {
|
||||
pl.sendBlockChange(pBlock.getLocation(),
|
||||
Material.STATIONARY_WATER, (byte) 0);
|
||||
pl.sendBlockChange(pBlock.getLocation(), Material.STATIONARY_WATER, (byte) 0);
|
||||
} else {
|
||||
pl.sendBlockChange(pBlock.getLocation(),
|
||||
Material.AIR, (byte) 0);
|
||||
pl.sendBlockChange(pBlock.getLocation(), Material.AIR, (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -401,10 +323,8 @@ public class ArenaHandler {
|
||||
|
||||
MessageM.sendFMessage(player, ConfigC.normal_leaveYouLeft);
|
||||
if (message) {
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_leaveLeftArena,
|
||||
"playername-" + player.getName(), "1-"
|
||||
+ arena.playersInArena.size(), "2-"
|
||||
+ arena.maxPlayers);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_leaveLeftArena, "playername-" + player.getName(), "1-" + arena.playersInArena.size(), "2-"
|
||||
+ arena.maxPlayers);
|
||||
}
|
||||
} else {
|
||||
if (message) {
|
||||
@ -422,22 +342,18 @@ public class ArenaHandler {
|
||||
for (Player player : arena.playersInArena) {
|
||||
if (arena.seekersWinCommands != null) {
|
||||
for (String command : arena.seekersWinCommands) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
|
||||
command.replaceAll("%player%", player.getName()));
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replaceAll("%player%", player.getName()));
|
||||
}
|
||||
|
||||
if (W.shop.getFile().get(player.getName() + ".tokens") == null) {
|
||||
W.shop.getFile().set(player.getName() + ".tokens", 0);
|
||||
W.shop.save();
|
||||
}
|
||||
int playerTokens = W.shop.getFile().getInt(
|
||||
player.getName() + ".tokens");
|
||||
W.shop.getFile().set(player.getName() + ".tokens",
|
||||
playerTokens + arena.seekersTokenWin);
|
||||
int playerTokens = W.shop.getFile().getInt(player.getName() + ".tokens");
|
||||
W.shop.getFile().set(player.getName() + ".tokens", playerTokens + arena.seekersTokenWin);
|
||||
W.shop.save();
|
||||
|
||||
MessageM.sendFMessage(player, ConfigC.normal_addedToken,
|
||||
"amount-" + arena.seekersTokenWin);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_addedToken, "amount-" + arena.seekersTokenWin);
|
||||
}
|
||||
}
|
||||
|
||||
@ -460,23 +376,18 @@ public class ArenaHandler {
|
||||
if (!arena.seekers.contains(player)) {
|
||||
if (arena.hidersWinCommands != null) {
|
||||
for (String command : arena.hidersWinCommands) {
|
||||
Bukkit.dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
command.replaceAll("%player%", player.getName()));
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replaceAll("%player%", player.getName()));
|
||||
}
|
||||
|
||||
if (W.shop.getFile().get(player.getName() + ".tokens") == null) {
|
||||
W.shop.getFile().set(player.getName() + ".tokens", 0);
|
||||
W.shop.save();
|
||||
}
|
||||
int playerTokens = W.shop.getFile().getInt(
|
||||
player.getName() + ".tokens");
|
||||
W.shop.getFile().set(player.getName() + ".tokens",
|
||||
playerTokens + arena.hidersTokenWin);
|
||||
int playerTokens = W.shop.getFile().getInt(player.getName() + ".tokens");
|
||||
W.shop.getFile().set(player.getName() + ".tokens", playerTokens + arena.hidersTokenWin);
|
||||
W.shop.save();
|
||||
|
||||
MessageM.sendFMessage(player, ConfigC.normal_addedToken,
|
||||
"amount-" + arena.hidersTokenWin);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_addedToken, "amount-" + arena.hidersTokenWin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package nl.Steffion.BlockHunt;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -31,7 +30,6 @@ import nl.Steffion.BlockHunt.Listeners.OnEntityDamageEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnFoodLevelChangeEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnInventoryClickEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnInventoryCloseEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnPlayerCommandPreprocessEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnPlayerDropItemEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnPlayerInteractEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnPlayerMoveEvent;
|
||||
@ -42,8 +40,6 @@ import nl.Steffion.BlockHunt.Managers.ConfigM;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
||||
import nl.Steffion.BlockHunt.Managers.PermissionsM;
|
||||
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
||||
import nl.Steffion.BlockHunt.mcstats.Metrics;
|
||||
import nl.Steffion.BlockHunt.mcstats.Metrics.Graph;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -53,9 +49,6 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -119,38 +112,25 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
public void onEnable() {
|
||||
getServer().getPluginManager().registerEvents(this, this);
|
||||
|
||||
getServer().getPluginManager().registerEvents(new OnBlockBreakEvent(),
|
||||
this);
|
||||
getServer().getPluginManager().registerEvents(new OnBlockPlaceEvent(),
|
||||
this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnEntityDamageByEntityEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnEntityDamageEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnFoodLevelChangeEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnInventoryClickEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnInventoryCloseEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnBlockBreakEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnBlockPlaceEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnEntityDamageByEntityEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnEntityDamageEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnFoodLevelChangeEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnInventoryClickEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnInventoryCloseEvent(), this);
|
||||
|
||||
// Removed - This is handled by WorldGuard now.
|
||||
// getServer().getPluginManager().registerEvents(
|
||||
// new OnPlayerCommandPreprocessEvent(), this);
|
||||
// Removed - This is handled by WorldGuard now.
|
||||
// getServer().getPluginManager().registerEvents(
|
||||
// new OnPlayerCommandPreprocessEvent(), this);
|
||||
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnPlayerDropItemEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnPlayerInteractEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerMoveEvent(),
|
||||
this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerQuitEvent(),
|
||||
this);
|
||||
getServer().getPluginManager().registerEvents(new OnSignChangeEvent(),
|
||||
this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerDropItemEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerInteractEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerMoveEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerQuitEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnSignChangeEvent(), this);
|
||||
|
||||
ConfigurationSerialization.registerClass(LocationSerializable.class,
|
||||
"BlockHuntLocation");
|
||||
ConfigurationSerialization.registerClass(LocationSerializable.class, "BlockHuntLocation");
|
||||
ConfigurationSerialization.registerClass(Arena.class, "BlockHuntArena");
|
||||
|
||||
pdfFile = getDescription();
|
||||
@ -158,72 +138,37 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
|
||||
ConfigM.newFiles();
|
||||
|
||||
CMD = new CommandM("BlockHunt", "BlockHunt", null, null,
|
||||
Permissions.info, ConfigC.help_info,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_info),
|
||||
BlockHuntCMD, new CMDinfo(), null);
|
||||
CMDinfo = new CommandM("BlockHunt INFO", "BlockHunt", "info", "i",
|
||||
Permissions.info, ConfigC.help_info,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_info),
|
||||
CMD = new CommandM("BlockHunt", "BlockHunt", null, null, Permissions.info, ConfigC.help_info, (Boolean) W.config.get(ConfigC.commandEnabled_info), BlockHuntCMD,
|
||||
new CMDinfo(), null);
|
||||
CMDinfo = new CommandM("BlockHunt INFO", "BlockHunt", "info", "i", Permissions.info, ConfigC.help_info, (Boolean) W.config.get(ConfigC.commandEnabled_info),
|
||||
BlockHuntCMD, new CMDinfo(), "/BlockHunt [info|i]");
|
||||
CMDhelp = new CommandM("BlockHunt HELP", "BlockHunt", "help", "h",
|
||||
Permissions.help, ConfigC.help_help,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_help),
|
||||
BlockHuntCMD, new CMDhelp(),
|
||||
"/BlockHunt <help|h> [page number]");
|
||||
CMDreload = new CommandM("BlockHunt RELOAD", "BlockHunt", "reload",
|
||||
"r", Permissions.reload, ConfigC.help_reload,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_reload),
|
||||
BlockHuntCMD, new CMDreload(), "/BlockHunt <reload|r>");
|
||||
CMDjoin = new CommandM("BlockHunt JOIN", "BlockHunt", "join", "j",
|
||||
Permissions.join, ConfigC.help_join,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_join),
|
||||
CMDhelp = new CommandM("BlockHunt HELP", "BlockHunt", "help", "h", Permissions.help, ConfigC.help_help, (Boolean) W.config.get(ConfigC.commandEnabled_help),
|
||||
BlockHuntCMD, new CMDhelp(), "/BlockHunt <help|h> [page number]");
|
||||
CMDreload = new CommandM("BlockHunt RELOAD", "BlockHunt", "reload", "r", Permissions.reload, ConfigC.help_reload,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_reload), BlockHuntCMD, new CMDreload(), "/BlockHunt <reload|r>");
|
||||
CMDjoin = new CommandM("BlockHunt JOIN", "BlockHunt", "join", "j", Permissions.join, ConfigC.help_join, (Boolean) W.config.get(ConfigC.commandEnabled_join),
|
||||
BlockHuntCMD, new CMDjoin(), "/BlockHunt <join|j> <arenaname>");
|
||||
CMDleave = new CommandM("BlockHunt LEAVE", "BlockHunt", "leave", "l",
|
||||
Permissions.leave, ConfigC.help_leave,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_leave),
|
||||
BlockHuntCMD, new CMDleave(), "/BlockHunt <leave|l>");
|
||||
CMDlist = new CommandM("BlockHunt LIST", "BlockHunt", "list", "li",
|
||||
Permissions.list, ConfigC.help_list,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_list),
|
||||
CMDleave = new CommandM("BlockHunt LEAVE", "BlockHunt", "leave", "l", Permissions.leave, ConfigC.help_leave,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_leave), BlockHuntCMD, new CMDleave(), "/BlockHunt <leave|l>");
|
||||
CMDlist = new CommandM("BlockHunt LIST", "BlockHunt", "list", "li", Permissions.list, ConfigC.help_list, (Boolean) W.config.get(ConfigC.commandEnabled_list),
|
||||
BlockHuntCMD, new CMDlist(), "/BlockHunt <list|li>");
|
||||
CMDshop = new CommandM("BlockHunt SHOP", "BlockHunt", "shop", "sh",
|
||||
Permissions.shop, ConfigC.help_shop,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_shop),
|
||||
CMDshop = new CommandM("BlockHunt SHOP", "BlockHunt", "shop", "sh", Permissions.shop, ConfigC.help_shop, (Boolean) W.config.get(ConfigC.commandEnabled_shop),
|
||||
BlockHuntCMD, new CMDshop(), "/BlockHunt <shop|sh>");
|
||||
CMDstart = new CommandM("BlockHunt START", "BlockHunt", "start", "go",
|
||||
Permissions.start, ConfigC.help_start,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_start),
|
||||
BlockHuntCMD, new CMDstart(),
|
||||
"/BlockHunt <start|go> <arenaname>");
|
||||
CMDwand = new CommandM("BlockHunt WAND", "BlockHunt", "wand", "w",
|
||||
Permissions.create, ConfigC.help_wand,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_wand),
|
||||
CMDstart = new CommandM("BlockHunt START", "BlockHunt", "start", "go", Permissions.start, ConfigC.help_start,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_start), BlockHuntCMD, new CMDstart(), "/BlockHunt <start|go> <arenaname>");
|
||||
CMDwand = new CommandM("BlockHunt WAND", "BlockHunt", "wand", "w", Permissions.create, ConfigC.help_wand, (Boolean) W.config.get(ConfigC.commandEnabled_wand),
|
||||
BlockHuntCMD, new CMDwand(), "/BlockHunt <wand|w>");
|
||||
CMDcreate = new CommandM("BlockHunt CREATE", "BlockHunt", "create",
|
||||
"c", Permissions.create, ConfigC.help_create,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_create),
|
||||
BlockHuntCMD, new CMDcreate(),
|
||||
"/BlockHunt <create|c> <arenaname>");
|
||||
CMDset = new CommandM("BlockHunt SET", "BlockHunt", "set", "s",
|
||||
Permissions.set, ConfigC.help_set,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_set),
|
||||
CMDcreate = new CommandM("BlockHunt CREATE", "BlockHunt", "create", "c", Permissions.create, ConfigC.help_create,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_create), BlockHuntCMD, new CMDcreate(), "/BlockHunt <create|c> <arenaname>");
|
||||
CMDset = new CommandM("BlockHunt SET", "BlockHunt", "set", "s", Permissions.set, ConfigC.help_set, (Boolean) W.config.get(ConfigC.commandEnabled_set),
|
||||
BlockHuntCMD, new CMDset(), "/BlockHunt <set|s> <arenaname>");
|
||||
CMDsetwarp = new CommandM("BlockHunt SETWARP", "BlockHunt", "setwarp",
|
||||
"sw", Permissions.setwarp, ConfigC.help_setwarp,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_setwarp),
|
||||
BlockHuntCMD, new CMDsetwarp(),
|
||||
CMDsetwarp = new CommandM("BlockHunt SETWARP", "BlockHunt", "setwarp", "sw", Permissions.setwarp, ConfigC.help_setwarp,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_setwarp), BlockHuntCMD, new CMDsetwarp(),
|
||||
"/BlockHunt <setwarp|sw> <lobby|hiders|seekers|spawn> <arenaname>");
|
||||
CMDremove = new CommandM("BlockHunt REMOVE", "BlockHunt", "remove",
|
||||
"delete", Permissions.remove, ConfigC.help_remove,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_remove),
|
||||
BlockHuntCMD, new CMDremove(),
|
||||
"/BlockHunt <remove|delete> <arenaname>");
|
||||
CMDtokens = new CommandM("BlockHunt TOKENS", "BlockHunt", "tokens",
|
||||
"t", Permissions.tokens, ConfigC.help_tokens,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_tokens),
|
||||
BlockHuntCMD, new CMDtokens(),
|
||||
"/BlockHunt <tokens|t> <set|add|take> <playername> <amount>");
|
||||
CMDremove = new CommandM("BlockHunt REMOVE", "BlockHunt", "remove", "delete", Permissions.remove, ConfigC.help_remove,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_remove), BlockHuntCMD, new CMDremove(), "/BlockHunt <remove|delete> <arenaname>");
|
||||
CMDtokens = new CommandM("BlockHunt TOKENS", "BlockHunt", "tokens", "t", Permissions.tokens, ConfigC.help_tokens,
|
||||
(Boolean) W.config.get(ConfigC.commandEnabled_tokens), BlockHuntCMD, new CMDtokens(), "/BlockHunt <tokens|t> <set|add|take> <playername> <amount>");
|
||||
|
||||
if (!getServer().getPluginManager().isPluginEnabled("LibsDisguises")) {
|
||||
MessageM.broadcastFMessage(ConfigC.error_libsDisguisesNotInstalled);
|
||||
@ -235,84 +180,13 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
|
||||
ArenaHandler.loadArenas();
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Metrics metrics = new Metrics(plugin);
|
||||
if (metrics.isOptOut()) { return; }
|
||||
Graph playersPlayingBlockHunt = metrics
|
||||
.createGraph("Players playing BlockHunt");
|
||||
|
||||
playersPlayingBlockHunt.addPlotter(new Metrics.Plotter(
|
||||
"Playing") {
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
int playersPlaying = 0;
|
||||
for (Arena arena : W.arenaList) {
|
||||
playersPlaying = playersPlaying
|
||||
+ arena.playersInArena.size();
|
||||
}
|
||||
return playersPlaying;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
playersPlayingBlockHunt.addPlotter(new Metrics.Plotter(
|
||||
"Not playing") {
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
int playersPlaying = 0;
|
||||
for (Arena arena : W.arenaList) {
|
||||
playersPlaying = playersPlaying
|
||||
+ arena.playersInArena.size();
|
||||
}
|
||||
return Bukkit.getOnlinePlayers().length
|
||||
- playersPlaying;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
metrics.start();
|
||||
FileConfiguration metrics_fc = new YamlConfiguration();
|
||||
metrics_fc.load(metrics.getConfigFile());
|
||||
/*if (!metrics_fc.getBoolean("opt-out", false)) {
|
||||
MessageM.sendMessage(null,
|
||||
"%TAG%NSending %AMCStats%N to the server...");
|
||||
} else {
|
||||
MessageM.sendMessage(null,
|
||||
"%TAG%EUnable to send %AMCStats %Eto the server. %AMCStats%E is disabled?");
|
||||
}*/
|
||||
} catch (IOException e) {
|
||||
MessageM.sendMessage(null,
|
||||
"%TAG%EUnable to send %AMCStats %Eto the server. Something went wrong ;(!");
|
||||
} catch (InvalidConfigurationException e) {
|
||||
MessageM.sendMessage(null,
|
||||
"%TAG%EUnable to send %AMCStats %Eto the server. Something went wrong ;(!");
|
||||
}
|
||||
}
|
||||
}, 0, 6000);
|
||||
|
||||
if ((Boolean) W.config.get(ConfigC.autoUpdateCheck)) {
|
||||
if ((Boolean) W.config.get(ConfigC.autoDownloadUpdate)) {
|
||||
new Updater(this, pdfFile.getName(), this.getFile(),
|
||||
Updater.UpdateType.DEFAULT, true);
|
||||
} else {
|
||||
new Updater(this, pdfFile.getName(), this.getFile(),
|
||||
Updater.UpdateType.NO_DOWNLOAD, true);
|
||||
}
|
||||
}
|
||||
|
||||
MessageM.sendFMessage(null, ConfigC.log_enabledPlugin, "name-"
|
||||
+ BlockHunt.pdfFile.getName(),
|
||||
"version-" + BlockHunt.pdfFile.getVersion(), "autors-"
|
||||
+ BlockHunt.pdfFile.getAuthors().get(0));
|
||||
MessageM.sendFMessage(null, ConfigC.log_enabledPlugin, "name-" + BlockHunt.pdfFile.getName(), "version-" + BlockHunt.pdfFile.getVersion(), "autors-"
|
||||
+ BlockHunt.pdfFile.getAuthors().get(0));
|
||||
|
||||
// Welcome to the massive game loop!!
|
||||
getServer().getScheduler().runTaskTimer(this, new Runnable() {
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Arena arena : W.arenaList) {
|
||||
@ -320,74 +194,41 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
if (arena.playersInArena.size() >= arena.minPlayers) {
|
||||
arena.gameState = ArenaState.STARTING;
|
||||
arena.timer = arena.timeInLobbyUntilStart;
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_lobbyArenaIsStarting, "1-"
|
||||
+ arena.timeInLobbyUntilStart);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-" + arena.timeInLobbyUntilStart);
|
||||
}
|
||||
} else if (arena.gameState == ArenaState.STARTING) {
|
||||
arena.timer = arena.timer - 1;
|
||||
if (arena.timer > 0) {
|
||||
if (arena.timer == 60) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_lobbyArenaIsStarting,
|
||||
"1-60");
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-60");
|
||||
} else if (arena.timer == 30) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_lobbyArenaIsStarting,
|
||||
"1-30");
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-30");
|
||||
} else if (arena.timer == 10) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_lobbyArenaIsStarting,
|
||||
"1-10");
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-10");
|
||||
} else if (arena.timer == 5) {
|
||||
arena.lobbyWarp.getWorld()
|
||||
.playSound(arena.lobbyWarp,
|
||||
Sound.ORB_PICKUP, 1, 0);
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_lobbyArenaIsStarting,
|
||||
"1-5");
|
||||
arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ORB_PICKUP, 1, 0);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-5");
|
||||
} else if (arena.timer == 4) {
|
||||
arena.lobbyWarp.getWorld()
|
||||
.playSound(arena.lobbyWarp,
|
||||
Sound.ORB_PICKUP, 1, 0);
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_lobbyArenaIsStarting,
|
||||
"1-4");
|
||||
arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ORB_PICKUP, 1, 0);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-4");
|
||||
} else if (arena.timer == 3) {
|
||||
arena.lobbyWarp.getWorld()
|
||||
.playSound(arena.lobbyWarp,
|
||||
Sound.ORB_PICKUP, 1, 1);
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_lobbyArenaIsStarting,
|
||||
"1-3");
|
||||
arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ORB_PICKUP, 1, 1);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-3");
|
||||
} else if (arena.timer == 2) {
|
||||
arena.lobbyWarp.getWorld()
|
||||
.playSound(arena.lobbyWarp,
|
||||
Sound.ORB_PICKUP, 1, 1);
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_lobbyArenaIsStarting,
|
||||
"1-2");
|
||||
arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ORB_PICKUP, 1, 1);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-2");
|
||||
} else if (arena.timer == 1) {
|
||||
arena.lobbyWarp.getWorld()
|
||||
.playSound(arena.lobbyWarp,
|
||||
Sound.ORB_PICKUP, 1, 2);
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_lobbyArenaIsStarting,
|
||||
"1-1");
|
||||
arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ORB_PICKUP, 1, 2);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-1");
|
||||
}
|
||||
} else {
|
||||
arena.gameState = ArenaState.INGAME;
|
||||
arena.timer = arena.gameTime;
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_lobbyArenaStarted, "secs-"
|
||||
+ arena.waitingTimeSeeker);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaStarted, "secs-" + arena.waitingTimeSeeker);
|
||||
|
||||
for (int i = arena.amountSeekersOnStart; i > 0; i = i - 1) {
|
||||
boolean loop = true;
|
||||
Player seeker = arena.playersInArena
|
||||
.get(W.random
|
||||
.nextInt(arena.playersInArena
|
||||
.size()));
|
||||
Player seeker = arena.playersInArena.get(W.random.nextInt(arena.playersInArena.size()));
|
||||
|
||||
for (Player playerCheck : arena.playersInArena) {
|
||||
if (W.choosenSeeker.get(playerCheck) != null) {
|
||||
@ -405,18 +246,12 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
|
||||
if (loop) {
|
||||
if (!arena.seekers.contains(seeker)) {
|
||||
ArenaHandler
|
||||
.sendFMessage(
|
||||
arena,
|
||||
ConfigC.normal_ingameSeekerChoosen,
|
||||
"seeker-"
|
||||
+ seeker.getName());
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameSeekerChoosen, "seeker-" + seeker.getName());
|
||||
arena.seekers.add(seeker);
|
||||
seeker.teleport(arena.seekersWarp);
|
||||
seeker.getInventory().clear();
|
||||
seeker.updateInventory();
|
||||
W.seekertime.put(seeker,
|
||||
arena.waitingTimeSeeker);
|
||||
W.seekertime.put(seeker, arena.waitingTimeSeeker);
|
||||
} else {
|
||||
i = i + 1;
|
||||
}
|
||||
@ -427,62 +262,30 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
if (!arena.seekers.contains(arenaPlayer)) {
|
||||
arenaPlayer.getInventory().clear();
|
||||
arenaPlayer.updateInventory();
|
||||
ItemStack block = arena.disguiseBlocks.get(W.random
|
||||
.nextInt(arena.disguiseBlocks
|
||||
.size()));
|
||||
ItemStack block = arena.disguiseBlocks.get(W.random.nextInt(arena.disguiseBlocks.size()));
|
||||
|
||||
if (W.choosenBlock.get(arenaPlayer) != null) {
|
||||
block = W.choosenBlock.get(arenaPlayer);
|
||||
W.choosenBlock.remove(arenaPlayer);
|
||||
}
|
||||
|
||||
MiscDisguise disguise = new MiscDisguise(
|
||||
DisguiseType.FALLING_BLOCK, block
|
||||
.getTypeId(), block
|
||||
.getDurability());
|
||||
DisguiseAPI.disguiseToAll(arenaPlayer,
|
||||
disguise);
|
||||
MiscDisguise disguise = new MiscDisguise(DisguiseType.FALLING_BLOCK, block.getTypeId(), block.getDurability());
|
||||
DisguiseAPI.disguiseToAll(arenaPlayer, disguise);
|
||||
|
||||
arenaPlayer.teleport(arena.hidersWarp);
|
||||
|
||||
ItemStack blockCount = new ItemStack(block
|
||||
.getType(), 5);
|
||||
blockCount.setDurability(block
|
||||
.getDurability());
|
||||
arenaPlayer.getInventory().setItem(8,
|
||||
blockCount);
|
||||
arenaPlayer.getInventory().setHelmet(
|
||||
new ItemStack(block));
|
||||
ItemStack blockCount = new ItemStack(block.getType(), 5);
|
||||
blockCount.setDurability(block.getDurability());
|
||||
arenaPlayer.getInventory().setItem(8, blockCount);
|
||||
arenaPlayer.getInventory().setHelmet(new ItemStack(block));
|
||||
W.pBlock.put(arenaPlayer, block);
|
||||
|
||||
if (block.getDurability() != 0) {
|
||||
MessageM.sendFMessage(
|
||||
arenaPlayer,
|
||||
ConfigC.normal_ingameBlock,
|
||||
"block-"
|
||||
+ block.getType()
|
||||
.name()
|
||||
.replaceAll(
|
||||
"_", "")
|
||||
.replaceAll(
|
||||
"BLOCK",
|
||||
"")
|
||||
.toLowerCase()
|
||||
+ ":"
|
||||
+ block.getDurability());
|
||||
MessageM.sendFMessage(arenaPlayer, ConfigC.normal_ingameBlock,
|
||||
"block-" + block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase() + ":" + block.getDurability());
|
||||
} else {
|
||||
MessageM.sendFMessage(
|
||||
arenaPlayer,
|
||||
ConfigC.normal_ingameBlock,
|
||||
"block-"
|
||||
+ block.getType()
|
||||
.name()
|
||||
.replaceAll(
|
||||
"_", "")
|
||||
.replaceAll(
|
||||
"BLOCK",
|
||||
"")
|
||||
.toLowerCase());
|
||||
MessageM.sendFMessage(arenaPlayer, ConfigC.normal_ingameBlock,
|
||||
"block-" + block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -490,31 +293,21 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
}
|
||||
|
||||
for (Player player : arena.seekers) {
|
||||
if (player.getInventory().getItem(0) == null
|
||||
|| player.getInventory().getItem(0).getType() != Material.DIAMOND_SWORD) {
|
||||
player.getInventory().setItem(0,
|
||||
new ItemStack(Material.DIAMOND_SWORD, 1));
|
||||
player.getInventory().setHelmet(
|
||||
new ItemStack(Material.IRON_HELMET, 1));
|
||||
player.getInventory().setChestplate(
|
||||
new ItemStack(Material.IRON_CHESTPLATE, 1));
|
||||
player.getInventory().setLeggings(
|
||||
new ItemStack(Material.IRON_LEGGINGS, 1));
|
||||
player.getInventory().setBoots(
|
||||
new ItemStack(Material.IRON_BOOTS, 1));
|
||||
player.playSound(player.getLocation(),
|
||||
Sound.ANVIL_USE, 1, 1);
|
||||
if (player.getInventory().getItem(0) == null || player.getInventory().getItem(0).getType() != Material.DIAMOND_SWORD) {
|
||||
player.getInventory().setItem(0, new ItemStack(Material.DIAMOND_SWORD, 1));
|
||||
player.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET, 1));
|
||||
player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1));
|
||||
player.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS, 1));
|
||||
player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS, 1));
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_USE, 1, 1);
|
||||
}
|
||||
|
||||
if (W.seekertime.get(player) != null) {
|
||||
W.seekertime.put(player,
|
||||
W.seekertime.get(player) - 1);
|
||||
W.seekertime.put(player, W.seekertime.get(player) - 1);
|
||||
if (W.seekertime.get(player) <= 0) {
|
||||
player.teleport(arena.hidersWarp);
|
||||
W.seekertime.remove(player);
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameSeekerSpawned,
|
||||
"playername-" + player.getName());
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameSeekerSpawned, "playername-" + player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -522,63 +315,39 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
if (arena.gameState == ArenaState.INGAME) {
|
||||
arena.timer = arena.timer - 1;
|
||||
if (arena.timer > 0) {
|
||||
if (arena.timer == arena.gameTime
|
||||
- arena.timeUntilHidersSword) {
|
||||
ItemStack sword = new ItemStack(
|
||||
Material.WOOD_SWORD, 1);
|
||||
sword.addUnsafeEnchantment(
|
||||
Enchantment.KNOCKBACK, 1);
|
||||
if (arena.timer == arena.gameTime - arena.timeUntilHidersSword) {
|
||||
ItemStack sword = new ItemStack(Material.WOOD_SWORD, 1);
|
||||
sword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1);
|
||||
for (Player arenaPlayer : arena.playersInArena) {
|
||||
if (!arena.seekers.contains(arenaPlayer)) {
|
||||
arenaPlayer.getInventory().addItem(
|
||||
sword);
|
||||
MessageM.sendFMessage(arenaPlayer,
|
||||
ConfigC.normal_ingameGivenSword);
|
||||
arenaPlayer.getInventory().addItem(sword);
|
||||
MessageM.sendFMessage(arenaPlayer, ConfigC.normal_ingameGivenSword);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (arena.timer == 190) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, "1-190");
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-190");
|
||||
} else if (arena.timer == 60) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, "1-60");
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-60");
|
||||
} else if (arena.timer == 30) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, "1-30");
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-30");
|
||||
} else if (arena.timer == 10) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, "1-10");
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-10");
|
||||
} else if (arena.timer == 5) {
|
||||
arena.lobbyWarp.getWorld()
|
||||
.playSound(arena.lobbyWarp,
|
||||
Sound.ORB_PICKUP, 1, 0);
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, "1-5");
|
||||
arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ORB_PICKUP, 1, 0);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-5");
|
||||
} else if (arena.timer == 4) {
|
||||
arena.lobbyWarp.getWorld()
|
||||
.playSound(arena.lobbyWarp,
|
||||
Sound.ORB_PICKUP, 1, 0);
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, "1-4");
|
||||
arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ORB_PICKUP, 1, 0);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-4");
|
||||
} else if (arena.timer == 3) {
|
||||
arena.lobbyWarp.getWorld()
|
||||
.playSound(arena.lobbyWarp,
|
||||
Sound.ORB_PICKUP, 1, 1);
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, "1-3");
|
||||
arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ORB_PICKUP, 1, 1);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-3");
|
||||
} else if (arena.timer == 2) {
|
||||
arena.lobbyWarp.getWorld()
|
||||
.playSound(arena.lobbyWarp,
|
||||
Sound.ORB_PICKUP, 1, 1);
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, "1-2");
|
||||
arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ORB_PICKUP, 1, 1);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-2");
|
||||
} else if (arena.timer == 1) {
|
||||
arena.lobbyWarp.getWorld()
|
||||
.playSound(arena.lobbyWarp,
|
||||
Sound.ORB_PICKUP, 1, 2);
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, "1-1");
|
||||
arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ORB_PICKUP, 1, 2);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-1");
|
||||
}
|
||||
} else {
|
||||
ArenaHandler.hidersWin(arena);
|
||||
@ -589,8 +358,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
if (!arena.seekers.contains(player)) {
|
||||
Location pLoc = player.getLocation();
|
||||
Location moveLoc = W.moveLoc.get(player);
|
||||
ItemStack block = player.getInventory()
|
||||
.getItem(8);
|
||||
ItemStack block = player.getInventory().getItem(8);
|
||||
|
||||
if (block == null) {
|
||||
if (W.pBlock.get(player) != null) {
|
||||
@ -601,126 +369,69 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
}
|
||||
|
||||
if (moveLoc != null) {
|
||||
if (moveLoc.getX() == pLoc.getX()
|
||||
&& moveLoc.getY() == pLoc.getY()
|
||||
&& moveLoc.getZ() == pLoc.getZ()) {
|
||||
if (moveLoc.getX() == pLoc.getX() && moveLoc.getY() == pLoc.getY() && moveLoc.getZ() == pLoc.getZ()) {
|
||||
if (block.getAmount() > 1) {
|
||||
block.setAmount(block.getAmount() - 1);
|
||||
} else {
|
||||
Block pBlock = player.getLocation()
|
||||
.getBlock();
|
||||
if (pBlock.getType().equals(
|
||||
Material.AIR)
|
||||
|| pBlock.getType().equals(
|
||||
Material.WATER)
|
||||
|| pBlock
|
||||
.getType()
|
||||
.equals(Material.STATIONARY_WATER)) {
|
||||
if (pBlock.getType().equals(
|
||||
Material.WATER)
|
||||
|| pBlock
|
||||
.getType()
|
||||
.equals(Material.STATIONARY_WATER)) {
|
||||
W.hiddenLocWater.put(
|
||||
player, true);
|
||||
Block pBlock = player.getLocation().getBlock();
|
||||
if (pBlock.getType().equals(Material.AIR) || pBlock.getType().equals(Material.WATER)
|
||||
|| pBlock.getType().equals(Material.STATIONARY_WATER)) {
|
||||
if (pBlock.getType().equals(Material.WATER) || pBlock.getType().equals(Material.STATIONARY_WATER)) {
|
||||
W.hiddenLocWater.put(player, true);
|
||||
} else {
|
||||
W.hiddenLocWater.put(
|
||||
player, false);
|
||||
W.hiddenLocWater.put(player, false);
|
||||
}
|
||||
if (DisguiseAPI
|
||||
.isDisguised(player)) {
|
||||
DisguiseAPI
|
||||
.undisguiseToAll(player);
|
||||
for (Player pl : Bukkit
|
||||
.getOnlinePlayers()) {
|
||||
if (DisguiseAPI.isDisguised(player)) {
|
||||
DisguiseAPI.undisguiseToAll(player);
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
if (!pl.equals(player)) {
|
||||
pl.hidePlayer(player);
|
||||
pl.sendBlockChange(
|
||||
pBlock.getLocation(),
|
||||
block.getType(),
|
||||
(byte) block
|
||||
.getDurability());
|
||||
pl.sendBlockChange(pBlock.getLocation(), block.getType(), (byte) block.getDurability());
|
||||
}
|
||||
}
|
||||
|
||||
block.addUnsafeEnchantment(
|
||||
Enchantment.DURABILITY,
|
||||
10);
|
||||
player.playSound(pLoc,
|
||||
Sound.ORB_PICKUP,
|
||||
1, 1);
|
||||
W.hiddenLoc.put(player,
|
||||
moveLoc);
|
||||
block.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
|
||||
player.playSound(pLoc, Sound.ORB_PICKUP, 1, 1);
|
||||
W.hiddenLoc.put(player, moveLoc);
|
||||
if (block.getDurability() != 0) {
|
||||
MessageM.sendFMessage(
|
||||
player,
|
||||
ConfigC.normal_ingameNowSolid,
|
||||
"block-"
|
||||
+ block.getType()
|
||||
.name()
|
||||
.replaceAll(
|
||||
"_",
|
||||
"")
|
||||
.replaceAll(
|
||||
"BLOCK",
|
||||
"")
|
||||
.toLowerCase()
|
||||
+ ":"
|
||||
"block-" + block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase() + ":"
|
||||
+ block.getDurability());
|
||||
} else {
|
||||
MessageM.sendFMessage(
|
||||
player,
|
||||
ConfigC.normal_ingameNowSolid,
|
||||
"block-"
|
||||
+ block.getType()
|
||||
.name()
|
||||
.replaceAll(
|
||||
"_",
|
||||
"")
|
||||
.replaceAll(
|
||||
"BLOCK",
|
||||
"")
|
||||
.toLowerCase());
|
||||
MessageM.sendFMessage(player, ConfigC.normal_ingameNowSolid, "block-"
|
||||
+ block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase());
|
||||
}
|
||||
}
|
||||
for (Player pl : Bukkit
|
||||
.getOnlinePlayers()) {
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
if (!pl.equals(player)) {
|
||||
pl.hidePlayer(player);
|
||||
pl.sendBlockChange(
|
||||
pBlock.getLocation(),
|
||||
block.getType(),
|
||||
(byte) block
|
||||
.getDurability());
|
||||
pl.sendBlockChange(pBlock.getLocation(), block.getType(), (byte) block.getDurability());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(
|
||||
player,
|
||||
ConfigC.warning_ingameNoSolidPlace);
|
||||
MessageM.sendFMessage(player, ConfigC.warning_ingameNoSolidPlace);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
block.setAmount(5);
|
||||
if (!DisguiseAPI.isDisguised(player)) {
|
||||
SolidBlockHandler
|
||||
.makePlayerUnsolid(player);
|
||||
SolidBlockHandler.makePlayerUnsolid(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ScoreboardHandler.updateScoreboard(arena); // TODO Only do this when needed (player added/removed)
|
||||
}
|
||||
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setLevel(arena.timer);
|
||||
pl.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
|
||||
ScoreboardHandler.updateScoreboard(arena);
|
||||
}
|
||||
|
||||
SignsHandler.updateSigns();
|
||||
SignsHandler.updateSigns(); //TODO Only do this when needed (gamestate change or player count change)
|
||||
}
|
||||
}, 0, 20);
|
||||
}
|
||||
@ -730,10 +441,8 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
ArenaHandler.stopArena(arena);
|
||||
}
|
||||
|
||||
MessageM.sendFMessage(null, ConfigC.log_disabledPlugin, "name-"
|
||||
+ BlockHunt.pdfFile.getName(),
|
||||
"version-" + BlockHunt.pdfFile.getVersion(), "autors-"
|
||||
+ BlockHunt.pdfFile.getAuthors().get(0));
|
||||
MessageM.sendFMessage(null, ConfigC.log_disabledPlugin, "name-" + BlockHunt.pdfFile.getName(), "version-" + BlockHunt.pdfFile.getVersion(), "autors-"
|
||||
+ BlockHunt.pdfFile.getAuthors().get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -758,8 +467,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
@ -787,9 +495,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
if (args.length >= argsSplit.length) {
|
||||
for (int i2 = argsSplit.length - 1; i2 >= 0; i2 = i2 - 1) {
|
||||
int loc = argsSplit.length - i2 - 1;
|
||||
if (!argsSplit[loc].equalsIgnoreCase(args[loc])
|
||||
&& !argsSplitAlias[loc]
|
||||
.equalsIgnoreCase(args[loc])) {
|
||||
if (!argsSplit[loc].equalsIgnoreCase(args[loc]) && !argsSplitAlias[loc].equalsIgnoreCase(args[loc])) {
|
||||
equals = false;
|
||||
}
|
||||
}
|
||||
@ -803,8 +509,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
if (command.enabled) {
|
||||
command.CMD.exectue(player, cmd, label, args);
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_commandNotEnabled);
|
||||
MessageM.sendFMessage(player, ConfigC.error_commandNotEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
@ -818,8 +523,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd,
|
||||
String label, String[] args) {
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
for (CommandM command : W.commands) {
|
||||
if (cmd.getName().equalsIgnoreCase(command.label)) {
|
||||
|
@ -18,26 +18,16 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class CMDcreate extends DefaultCMD {
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
if (player != null) {
|
||||
if (args.length <= 1) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
|
||||
"syntax-" + BlockHunt.CMDcreate.usage);
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments, "syntax-" + BlockHunt.CMDcreate.usage);
|
||||
} else {
|
||||
if (W.pos1.get(player) != null && W.pos2.get(player) != null) {
|
||||
if (W.pos1.get(player).getWorld()
|
||||
.equals(W.pos2.get(player).getWorld())) {
|
||||
Arena arena = new Arena(args[1], W.pos1.get(player),
|
||||
W.pos2.get(player), 12, 3, 1, 50, 20, 300, 30,
|
||||
new ArrayList<ItemStack>(), null, null, null,
|
||||
null, new ArrayList<String>(),
|
||||
new ArrayList<String>(),
|
||||
new ArrayList<String>(), 10, 50, 8,
|
||||
new ArrayList<Player>(), ArenaState.WAITING, 0,
|
||||
new ArrayList<Player>(), Bukkit
|
||||
.getScoreboardManager()
|
||||
.getNewScoreboard());
|
||||
if (W.pos1.get(player).getWorld().equals(W.pos2.get(player).getWorld())) {
|
||||
Arena arena = new Arena(args[1], W.pos1.get(player), W.pos2.get(player), 12, 3, 1, 50, 20, 300, 30, new ArrayList<ItemStack>(), null, null, null,
|
||||
null, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), 10, 50, 8, new ArrayList<Player>(), ArenaState.WAITING,
|
||||
0, new ArrayList<Player>(), Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
W.arenas.getFile().set(args[1], arena);
|
||||
W.arenas.save();
|
||||
W.signs.load();
|
||||
@ -45,16 +35,12 @@ public class CMDcreate extends DefaultCMD {
|
||||
W.arenaList.add(arena);
|
||||
ScoreboardHandler.createScoreboard(arena);
|
||||
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.normal_createCreatedArena, "name-"
|
||||
+ args[1]);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_createCreatedArena, "name-" + args[1]);
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_createNotSameWorld);
|
||||
MessageM.sendFMessage(player, ConfigC.error_createNotSameWorld);
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_createSelectionFirst);
|
||||
MessageM.sendFMessage(player, ConfigC.error_createSelectionFirst);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -24,8 +24,7 @@ public class CMDhelp extends DefaultCMD {
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
int amountCommands = 0;
|
||||
for (CommandM command : W.commands) {
|
||||
if (command.usage != null) {
|
||||
@ -40,38 +39,22 @@ public class CMDhelp extends DefaultCMD {
|
||||
|
||||
if (args.length == 1) {
|
||||
int page = 1;
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-"
|
||||
+ BlockHunt.pdfFile.getName() + " %Nhelp page %A"
|
||||
+ page + "%N/%A" + maxPages);
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-" + BlockHunt.pdfFile.getName() + " %Nhelp page %A" + page + "%N/%A" + maxPages);
|
||||
int i = 1;
|
||||
for (CommandM command : W.commands) {
|
||||
if (i <= 4) {
|
||||
if (command.usage != null) {
|
||||
if (PermissionsM.hasPerm(player, command.permission,
|
||||
false)) {
|
||||
MessageM.sendMessage(
|
||||
player,
|
||||
"%A"
|
||||
+ command.usage
|
||||
+ "%N - "
|
||||
+ W.messages.getFile().get(
|
||||
command.help.location));
|
||||
if (PermissionsM.hasPerm(player, command.permission, false)) {
|
||||
MessageM.sendMessage(player, "%A" + command.usage + "%N - " + W.messages.getFile().get(command.help.location));
|
||||
} else {
|
||||
MessageM.sendMessage(
|
||||
player,
|
||||
"%W"
|
||||
+ command.usage
|
||||
+ "%N - "
|
||||
+ W.messages.getFile().get(
|
||||
command.help.location));
|
||||
MessageM.sendMessage(player, "%W" + command.usage + "%N - " + W.messages.getFile().get(command.help.location));
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh,
|
||||
"header-&oHelp Page");
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-&oHelp Page");
|
||||
} else {
|
||||
int page = 1;
|
||||
try {
|
||||
@ -84,41 +67,24 @@ public class CMDhelp extends DefaultCMD {
|
||||
maxPages = page;
|
||||
}
|
||||
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-"
|
||||
+ BlockHunt.pdfFile.getName() + " %Nhelp page %A"
|
||||
+ page + "%N/%A" + maxPages);
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-" + BlockHunt.pdfFile.getName() + " %Nhelp page %A" + page + "%N/%A" + maxPages);
|
||||
|
||||
int i = 1;
|
||||
for (CommandM command : W.commands) {
|
||||
if (i <= (page * 4) + 4) {
|
||||
if (command.usage != null) {
|
||||
if (i >= ((page - 1) * 4) + 1
|
||||
&& i <= ((page - 1) * 4) + 4) {
|
||||
if (PermissionsM.hasPerm(player,
|
||||
command.permission, false)) {
|
||||
MessageM.sendMessage(
|
||||
player,
|
||||
"%A"
|
||||
+ command.usage
|
||||
+ "%N - "
|
||||
+ W.messages.getFile().get(
|
||||
command.help.location));
|
||||
if (i >= ((page - 1) * 4) + 1 && i <= ((page - 1) * 4) + 4) {
|
||||
if (PermissionsM.hasPerm(player, command.permission, false)) {
|
||||
MessageM.sendMessage(player, "%A" + command.usage + "%N - " + W.messages.getFile().get(command.help.location));
|
||||
} else {
|
||||
MessageM.sendMessage(
|
||||
player,
|
||||
"%W"
|
||||
+ command.usage
|
||||
+ "%N - "
|
||||
+ W.messages.getFile().get(
|
||||
command.help.location));
|
||||
MessageM.sendMessage(player, "%W" + command.usage + "%N - " + W.messages.getFile().get(command.help.location));
|
||||
}
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh,
|
||||
"header-&oHelp Page");
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-&oHelp Page");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -21,23 +21,15 @@ public class CMDinfo extends DefaultCMD {
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-"
|
||||
+ BlockHunt.pdfFile.getName());
|
||||
MessageM.sendMessage(player, "%A%name%%N made by %A%autors%%N.",
|
||||
"name-" + BlockHunt.pdfFile.getName(), "autors-"
|
||||
+ BlockHunt.pdfFile.getAuthors().get(0));
|
||||
MessageM.sendMessage(player, "%NVersion: %A%version%%N.", "version-"
|
||||
+ BlockHunt.pdfFile.getVersion());
|
||||
MessageM.sendMessage(player, "%NType %A%helpusage% %Nfor help.",
|
||||
"helpusage-" + BlockHunt.CMDhelp.usage);
|
||||
MessageM.sendMessage(player,
|
||||
"%NDev-Page: %Ahttp://dev.bukkit.org/bukkit-plugins/blockhunt/");
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-" + BlockHunt.pdfFile.getName());
|
||||
MessageM.sendMessage(player, "%A%name%%N made by %A%autors%%N.", "name-" + BlockHunt.pdfFile.getName(), "autors-" + BlockHunt.pdfFile.getAuthors().get(0));
|
||||
MessageM.sendMessage(player, "%NVersion: %A%version%%N.", "version-" + BlockHunt.pdfFile.getVersion());
|
||||
MessageM.sendMessage(player, "%NType %A%helpusage% %Nfor help.", "helpusage-" + BlockHunt.CMDhelp.usage);
|
||||
MessageM.sendMessage(player, "%NDev-Page: %Ahttp://dev.bukkit.org/bukkit-plugins/blockhunt/");
|
||||
MessageM.sendMessage(player, "%NDonations are welcome!");
|
||||
MessageM.sendMessage(player, "%NMade by help from some friends &c<3%N!");
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh,
|
||||
"header-&oInfo Page");
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-&oInfo Page");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -11,12 +11,10 @@ import org.bukkit.entity.Player;
|
||||
public class CMDjoin extends DefaultCMD {
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
if (player != null) {
|
||||
if (args.length <= 1) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
|
||||
"syntax-" + BlockHunt.CMDjoin.usage);
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments, "syntax-" + BlockHunt.CMDjoin.usage);
|
||||
} else {
|
||||
ArenaHandler.playerJoinArena(player, args[1]);
|
||||
}
|
||||
|
@ -10,8 +10,7 @@ import org.bukkit.entity.Player;
|
||||
public class CMDleave extends DefaultCMD {
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
if (player != null) {
|
||||
ArenaHandler.playerLeaveArena(player, true, true);
|
||||
} else {
|
||||
|
@ -12,10 +12,8 @@ import org.bukkit.entity.Player;
|
||||
public class CMDlist extends DefaultCMD {
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-"
|
||||
+ BlockHunt.pdfFile.getName());
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-" + BlockHunt.pdfFile.getName());
|
||||
if (W.arenaList.size() >= 1) {
|
||||
MessageM.sendMessage(player, "&7Available arena(s):");
|
||||
for (Arena arena : W.arenaList) {
|
||||
@ -25,8 +23,7 @@ public class CMDlist extends DefaultCMD {
|
||||
MessageM.sendMessage(player, "&7&oNo arenas available...");
|
||||
MessageM.sendMessage(player, "&7&oCreate an arena first please.");
|
||||
}
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh,
|
||||
"header-&oArenas list");
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, "header-&oArenas list");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,7 @@ public class CMDnotfound {
|
||||
* @author Steffion
|
||||
*/
|
||||
|
||||
public static boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
public static boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_commandNotFound);
|
||||
return true;
|
||||
}
|
||||
|
@ -24,8 +24,7 @@ public class CMDreload extends DefaultCMD {
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
ConfigM.newFiles();
|
||||
|
||||
W.config.load();
|
||||
|
@ -17,30 +17,21 @@ import org.bukkit.entity.Player;
|
||||
public class CMDremove extends DefaultCMD {
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
if (player != null) {
|
||||
if (args.length <= 1) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
|
||||
"syntax-" + BlockHunt.CMDremove.usage);
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments, "syntax-" + BlockHunt.CMDremove.usage);
|
||||
} else {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (args[1].equalsIgnoreCase(arena.arenaName)) {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.normal_removeRemovedArena, "name-"
|
||||
+ args[1]);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_removeRemovedArena, "name-" + args[1]);
|
||||
W.arenas.getFile().set(args[1], null);
|
||||
for (String sign : W.signs.getFile().getKeys(false)) {
|
||||
if (W.signs.getFile().get(sign + ".arenaName")
|
||||
.toString().equalsIgnoreCase(args[1])) {
|
||||
LocationSerializable signLoc = new LocationSerializable(
|
||||
(Location) W.signs.getFile().get(
|
||||
sign + ".location"));
|
||||
if (W.signs.getFile().get(sign + ".arenaName").toString().equalsIgnoreCase(args[1])) {
|
||||
LocationSerializable signLoc = new LocationSerializable((Location) W.signs.getFile().get(sign + ".location"));
|
||||
signLoc.getBlock().setType(Material.AIR);
|
||||
signLoc.getWorld().playEffect(signLoc,
|
||||
Effect.MOBSPAWNER_FLAMES, 0);
|
||||
signLoc.getWorld().playSound(signLoc,
|
||||
Sound.ENDERDRAGON_WINGS, 1, 1);
|
||||
signLoc.getWorld().playEffect(signLoc, Effect.MOBSPAWNER_FLAMES, 0);
|
||||
signLoc.getWorld().playSound(signLoc, Sound.ENDERDRAGON_WINGS, 1, 1);
|
||||
W.signs.getFile().set(sign, null);
|
||||
}
|
||||
}
|
||||
@ -53,8 +44,7 @@ public class CMDremove extends DefaultCMD {
|
||||
}
|
||||
}
|
||||
|
||||
MessageM.sendFMessage(player, ConfigC.error_noArena, "name-"
|
||||
+ args[1]);
|
||||
MessageM.sendFMessage(player, ConfigC.error_noArena, "name-" + args[1]);
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player, ConfigC.error_onlyIngame);
|
||||
|
@ -11,12 +11,10 @@ import org.bukkit.entity.Player;
|
||||
public class CMDset extends DefaultCMD {
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
if (player != null) {
|
||||
if (args.length <= 1) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
|
||||
"syntax-" + BlockHunt.CMDset.usage);
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments, "syntax-" + BlockHunt.CMDset.usage);
|
||||
} else {
|
||||
String arenaname = args[1];
|
||||
InventoryHandler.openPanel(player, arenaname);
|
||||
|
@ -14,12 +14,10 @@ import org.bukkit.entity.Player;
|
||||
public class CMDsetwarp extends DefaultCMD {
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
if (player != null) {
|
||||
if (args.length <= 2) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
|
||||
"syntax-" + BlockHunt.CMDsetwarp.usage);
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments, "syntax-" + BlockHunt.CMDsetwarp.usage);
|
||||
} else {
|
||||
String arenaname = args[2];
|
||||
String warpname = args[1];
|
||||
@ -31,40 +29,28 @@ public class CMDsetwarp extends DefaultCMD {
|
||||
}
|
||||
}
|
||||
if (arena != null) {
|
||||
LocationSerializable loc = new LocationSerializable(
|
||||
player.getLocation());
|
||||
LocationSerializable loc = new LocationSerializable(player.getLocation());
|
||||
if (warpname.equalsIgnoreCase("lobby")) {
|
||||
arena.lobbyWarp = loc;
|
||||
save(arena);
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.normal_setwarpWarpSet, "warp-"
|
||||
+ warpname);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_setwarpWarpSet, "warp-" + warpname);
|
||||
} else if (warpname.equalsIgnoreCase("hiders")) {
|
||||
arena.hidersWarp = loc;
|
||||
save(arena);
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.normal_setwarpWarpSet, "warp-"
|
||||
+ warpname);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_setwarpWarpSet, "warp-" + warpname);
|
||||
} else if (warpname.equalsIgnoreCase("seekers")) {
|
||||
arena.seekersWarp = loc;
|
||||
save(arena);
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.normal_setwarpWarpSet, "warp-"
|
||||
+ warpname);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_setwarpWarpSet, "warp-" + warpname);
|
||||
} else if (warpname.equalsIgnoreCase("spawn")) {
|
||||
arena.spawnWarp = loc;
|
||||
save(arena);
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.normal_setwarpWarpSet, "warp-"
|
||||
+ warpname);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_setwarpWarpSet, "warp-" + warpname);
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_setwarpWarpNotFound, "warp-"
|
||||
+ warpname);
|
||||
MessageM.sendFMessage(player, ConfigC.error_setwarpWarpNotFound, "warp-" + warpname);
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player, ConfigC.error_noArena,
|
||||
"name-" + arenaname);
|
||||
MessageM.sendFMessage(player, ConfigC.error_noArena, "name-" + arenaname);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -8,8 +8,7 @@ import org.bukkit.entity.Player;
|
||||
public class CMDshop extends DefaultCMD {
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
InventoryHandler.openShop(player);
|
||||
return true;
|
||||
}
|
||||
|
@ -13,12 +13,10 @@ import org.bukkit.entity.Player;
|
||||
public class CMDstart extends DefaultCMD {
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
if (player != null) {
|
||||
if (args.length <= 1) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
|
||||
"syntax-" + BlockHunt.CMDstart.usage);
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments, "syntax-" + BlockHunt.CMDstart.usage);
|
||||
} else {
|
||||
Arena arena = null;
|
||||
for (Arena arena2 : W.arenaList) {
|
||||
@ -32,12 +30,9 @@ public class CMDstart extends DefaultCMD {
|
||||
if (arena.playersInArena.size() >= 2) {
|
||||
arena.timer = 11;
|
||||
arena.gameState = ArenaState.STARTING;
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.normal_startForced, "arenaname-"
|
||||
+ arena.arenaName);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_startForced, "arenaname-" + arena.arenaName);
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.warning_lobbyNeedAtleast, "1-2");
|
||||
MessageM.sendFMessage(player, ConfigC.warning_lobbyNeedAtleast, "1-2");
|
||||
}
|
||||
} else if (arena.gameState.equals(ArenaState.STARTING)) {
|
||||
if (arena.playersInArena.size() < arena.maxPlayers) {
|
||||
@ -48,13 +43,10 @@ public class CMDstart extends DefaultCMD {
|
||||
arena.timer = 1;
|
||||
}
|
||||
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.normal_startForced, "arenaname-"
|
||||
+ arena.arenaName);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_startForced, "arenaname-" + arena.arenaName);
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player, ConfigC.error_noArena,
|
||||
"name-" + args[1]);
|
||||
MessageM.sendFMessage(player, ConfigC.error_noArena, "name-" + args[1]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -23,11 +23,9 @@ public class CMDtokens extends DefaultCMD {
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
if (args.length <= 3) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
|
||||
"syntax-" + BlockHunt.CMDtokens.usage);
|
||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments, "syntax-" + BlockHunt.CMDtokens.usage);
|
||||
} else {
|
||||
String option = args[1];
|
||||
String playerName = args[2];
|
||||
@ -35,16 +33,13 @@ public class CMDtokens extends DefaultCMD {
|
||||
try {
|
||||
amount = Integer.valueOf(args[3]);
|
||||
} catch (NumberFormatException e) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_notANumber, "1-"
|
||||
+ args[3]);
|
||||
MessageM.sendFMessage(player, ConfigC.error_notANumber, "1-" + args[3]);
|
||||
return true;
|
||||
}
|
||||
|
||||
Player tokenPlayer = Bukkit.getPlayer(playerName);
|
||||
if (tokenPlayer == null) {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_tokensPlayerNotOnline, "playername-"
|
||||
+ playerName);
|
||||
MessageM.sendFMessage(player, ConfigC.error_tokensPlayerNotOnline, "playername-" + playerName);
|
||||
return true;
|
||||
}
|
||||
String name = "\u00A78Console";
|
||||
@ -55,48 +50,28 @@ public class CMDtokens extends DefaultCMD {
|
||||
if (option.equalsIgnoreCase("set")) {
|
||||
W.shop.getFile().set(tokenPlayer.getName() + ".tokens", amount);
|
||||
W.shop.save();
|
||||
MessageM.sendFMessage(player, ConfigC.normal_tokensChanged,
|
||||
"option-Set", "playername-" + tokenPlayer.getName(),
|
||||
"option2-to", "amount-" + amount);
|
||||
MessageM.sendFMessage(tokenPlayer,
|
||||
ConfigC.normal_tokensChangedPerson, "option-set",
|
||||
"playername-" + name, "option2-to",
|
||||
"amount-" + amount);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_tokensChanged, "option-Set", "playername-" + tokenPlayer.getName(), "option2-to", "amount-" + amount);
|
||||
MessageM.sendFMessage(tokenPlayer, ConfigC.normal_tokensChangedPerson, "option-set", "playername-" + name, "option2-to", "amount-" + amount);
|
||||
} else if (option.equalsIgnoreCase("add")) {
|
||||
int tokens = 0;
|
||||
if (W.shop.getFile().getInt(tokenPlayer.getName() + ".tokens") != 0) {
|
||||
tokens = W.shop.getFile().getInt(
|
||||
tokenPlayer.getName() + ".tokens");
|
||||
tokens = W.shop.getFile().getInt(tokenPlayer.getName() + ".tokens");
|
||||
}
|
||||
W.shop.getFile().set(tokenPlayer.getName() + ".tokens",
|
||||
tokens + amount);
|
||||
W.shop.getFile().set(tokenPlayer.getName() + ".tokens", tokens + amount);
|
||||
W.shop.save();
|
||||
MessageM.sendFMessage(player, ConfigC.normal_tokensChanged,
|
||||
"option-Added", "playername-" + tokenPlayer.getName(),
|
||||
"option2-to", "amount-" + amount);
|
||||
MessageM.sendFMessage(tokenPlayer,
|
||||
ConfigC.normal_tokensChangedPerson, "option-added",
|
||||
"playername-" + name, "option2-to",
|
||||
"amount-" + amount);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_tokensChanged, "option-Added", "playername-" + tokenPlayer.getName(), "option2-to", "amount-" + amount);
|
||||
MessageM.sendFMessage(tokenPlayer, ConfigC.normal_tokensChangedPerson, "option-added", "playername-" + name, "option2-to", "amount-" + amount);
|
||||
} else if (option.equalsIgnoreCase("take")) {
|
||||
int tokens = 0;
|
||||
if (W.shop.getFile().getInt(tokenPlayer.getName() + ".tokens") != 0) {
|
||||
tokens = W.shop.getFile().getInt(
|
||||
tokenPlayer.getName() + ".tokens");
|
||||
tokens = W.shop.getFile().getInt(tokenPlayer.getName() + ".tokens");
|
||||
}
|
||||
W.shop.getFile().set(tokenPlayer.getName() + ".tokens",
|
||||
tokens - amount);
|
||||
W.shop.getFile().set(tokenPlayer.getName() + ".tokens", tokens - amount);
|
||||
W.shop.save();
|
||||
MessageM.sendFMessage(player, ConfigC.normal_tokensChanged,
|
||||
"option-Took", "playername-" + tokenPlayer.getName(),
|
||||
"option2-from", "amount-" + amount);
|
||||
MessageM.sendFMessage(tokenPlayer,
|
||||
ConfigC.normal_tokensChangedPerson, "option-took",
|
||||
"playername-" + name, "option2-from",
|
||||
"amount-" + amount);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_tokensChanged, "option-Took", "playername-" + tokenPlayer.getName(), "option2-from", "amount-" + amount);
|
||||
MessageM.sendFMessage(tokenPlayer, ConfigC.normal_tokensChangedPerson, "option-took", "playername-" + name, "option2-from", "amount-" + amount);
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_tokensUnknownsetting, "option-" + option);
|
||||
MessageM.sendFMessage(player, ConfigC.error_tokensUnknownsetting, "option-" + option);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -17,18 +17,13 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
public class CMDwand extends DefaultCMD {
|
||||
|
||||
@Override
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
if (player != null) {
|
||||
ItemStack wand = new ItemStack(
|
||||
Material.getMaterial((String) W.config
|
||||
.get(ConfigC.wandIDname)));
|
||||
ItemStack wand = new ItemStack(Material.getMaterial((String) W.config.get(ConfigC.wandIDname)));
|
||||
ItemMeta im = wand.getItemMeta();
|
||||
im.setDisplayName(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.wandName)));
|
||||
im.setDisplayName(MessageM.replaceAll((String) W.config.get(ConfigC.wandName)));
|
||||
W.config.load();
|
||||
List<String> lores = W.config.getFile().getStringList(
|
||||
ConfigC.wandDescription.location);
|
||||
List<String> lores = W.config.getFile().getStringList(ConfigC.wandDescription.location);
|
||||
List<String> lores2 = new ArrayList<String>();
|
||||
for (String lore : lores) {
|
||||
lores2.add(MessageM.replaceAll(lore));
|
||||
@ -38,9 +33,7 @@ public class CMDwand extends DefaultCMD {
|
||||
wand.setItemMeta(im);
|
||||
player.getInventory().addItem(wand);
|
||||
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 5, 0);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_wandGaveWand, "type-"
|
||||
+ wand.getType().toString().replaceAll("_", " ")
|
||||
.toLowerCase());
|
||||
MessageM.sendFMessage(player, ConfigC.normal_wandGaveWand, "type-" + wand.getType().toString().replaceAll("_", " ").toLowerCase());
|
||||
} else {
|
||||
MessageM.sendFMessage(player, ConfigC.error_onlyIngame);
|
||||
}
|
||||
|
@ -18,8 +18,7 @@ public class DefaultCMD {
|
||||
* @author Steffion
|
||||
*/
|
||||
|
||||
public boolean exectue(Player player, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean exectue(Player player, Command cmd, String label, String[] args) {
|
||||
MessageM.sendMessage(player, "%TAG%NExample of a Command!");
|
||||
// TODO Place the command stuff here.
|
||||
return true;
|
||||
|
@ -15,234 +15,95 @@ public enum ConfigC {
|
||||
* @author Steffion
|
||||
*/
|
||||
|
||||
chat_tag ("[" + BlockHunt.pdfFile.getName() + "] ", W.config),
|
||||
chat_normal ("&b", W.config),
|
||||
chat_warning ("&c", W.config),
|
||||
chat_error ("&c", W.config),
|
||||
chat_arg ("&e", W.config),
|
||||
chat_header ("&9", W.config),
|
||||
chat_headerhigh ("%H_______.[ %A%header%%H ]._______", W.config),
|
||||
chat_tag("[" + BlockHunt.pdfFile.getName() + "] ", W.config), chat_normal("&b", W.config), chat_warning("&c", W.config), chat_error("&c", W.config), chat_arg("&e",
|
||||
W.config), chat_header("&9", W.config), chat_headerhigh("%H_______.[ %A%header%%H ]._______", W.config),
|
||||
|
||||
commandEnabled_info (true, W.config),
|
||||
commandEnabled_help (true, W.config),
|
||||
commandEnabled_reload (true, W.config),
|
||||
commandEnabled_join (true, W.config),
|
||||
commandEnabled_leave (true, W.config),
|
||||
commandEnabled_list (true, W.config),
|
||||
commandEnabled_shop (true, W.config),
|
||||
commandEnabled_start (true, W.config),
|
||||
commandEnabled_wand (true, W.config),
|
||||
commandEnabled_create (true, W.config),
|
||||
commandEnabled_set (true, W.config),
|
||||
commandEnabled_setwarp (true, W.config),
|
||||
commandEnabled_remove (true, W.config),
|
||||
commandEnabled_tokens (true, W.config),
|
||||
commandEnabled_info(true, W.config), commandEnabled_help(true, W.config), commandEnabled_reload(true, W.config), commandEnabled_join(true, W.config), commandEnabled_leave(
|
||||
true, W.config), commandEnabled_list(true, W.config), commandEnabled_shop(true, W.config), commandEnabled_start(true, W.config), commandEnabled_wand(true,
|
||||
W.config), commandEnabled_create(true, W.config), commandEnabled_set(true, W.config), commandEnabled_setwarp(true, W.config), commandEnabled_remove(true,
|
||||
W.config), commandEnabled_tokens(true, W.config),
|
||||
|
||||
autoUpdateCheck (true, W.config),
|
||||
autoDownloadUpdate (false, W.config),
|
||||
autoUpdateCheck(true, W.config), autoDownloadUpdate(false, W.config),
|
||||
|
||||
wandIDname ("STICK", W.config),
|
||||
wandName ("%A&l" + BlockHunt.pdfFile.getName() + "%N's selection wand",
|
||||
W.config),
|
||||
wandDescription (new String[] {
|
||||
"%NUse this item to select an arena for your arena.",
|
||||
"%ALeft-Click%N to select point #1.",
|
||||
"%ARight-Click%N to select point #2.",
|
||||
"%NUse the create command to define your arena.",
|
||||
"%A/" + BlockHunt.pdfFile.getName() + " <help|h>" }, W.config),
|
||||
wandIDname("STICK", W.config), wandName("%A&l" + BlockHunt.pdfFile.getName() + "%N's selection wand", W.config), wandDescription(new String[] {
|
||||
"%NUse this item to select an arena for your arena.", "%ALeft-Click%N to select point #1.", "%ARight-Click%N to select point #2.",
|
||||
"%NUse the create command to define your arena.", "%A/" + BlockHunt.pdfFile.getName() + " <help|h>" }, W.config),
|
||||
|
||||
shop_title ("%H&lBlockHunt %NShop", W.config),
|
||||
shop_price ("%NPrice: %A%amount% %Ntokens.", W.config),
|
||||
shop_title("%H&lBlockHunt %NShop", W.config), shop_price("%NPrice: %A%amount% %Ntokens.", W.config),
|
||||
|
||||
shop_blockChooserv1Enabled (true, W.config),
|
||||
shop_blockChooserv1IDname ("BOOK", W.config),
|
||||
shop_blockChooserv1Price (3000, W.config),
|
||||
shop_blockChooserv1Name ("%H&lBlockHunt Chooser", W.config),
|
||||
shop_blockChooserv1Description (new String[] {
|
||||
"%NUse this item before the arena starts.",
|
||||
"%ARight-Click%N in the lobby and choose",
|
||||
"%Nthe block you want to be!", "&6Unlimited uses." }, W.config),
|
||||
shop_blockChooserv1Enabled(true, W.config), shop_blockChooserv1IDname("BOOK", W.config), shop_blockChooserv1Price(3000, W.config), shop_blockChooserv1Name(
|
||||
"%H&lBlockHunt Chooser", W.config), shop_blockChooserv1Description(new String[] { "%NUse this item before the arena starts.",
|
||||
"%ARight-Click%N in the lobby and choose", "%Nthe block you want to be!", "&6Unlimited uses." }, W.config),
|
||||
|
||||
shop_BlockHuntPassv2Enabled (true, W.config),
|
||||
shop_BlockHuntPassv2IDName ("NAME_TAG", W.config),
|
||||
shop_BlockHuntPassv2Price (150, W.config),
|
||||
shop_BlockHuntPassv2Name ("%H&lBlockHunt Pass", W.config),
|
||||
shop_BlockHuntPassv2Description (new String[] {
|
||||
"%NUse this item before the arena starts.",
|
||||
"%ARight-Click%N in the lobby and choose",
|
||||
"%Nif you want to be a Hider or a Seeker!", "&61 time use.", },
|
||||
W.config),
|
||||
shop_BlockHuntPassv2Enabled(true, W.config), shop_BlockHuntPassv2IDName("NAME_TAG", W.config), shop_BlockHuntPassv2Price(150, W.config), shop_BlockHuntPassv2Name(
|
||||
"%H&lBlockHunt Pass", W.config), shop_BlockHuntPassv2Description(new String[] { "%NUse this item before the arena starts.",
|
||||
"%ARight-Click%N in the lobby and choose", "%Nif you want to be a Hider or a Seeker!", "&61 time use.", }, W.config),
|
||||
|
||||
sign_LEAVE (new String[] { "%H[" + BlockHunt.pdfFile.getName() + "%H]",
|
||||
"&4LEAVE", "&8Right-Click", "&8To leave." }, W.config),
|
||||
sign_SHOP (new String[] { "%H[" + BlockHunt.pdfFile.getName() + "%H]",
|
||||
"&4SHOP", "&8Right-Click", "&8To shop." }, W.config),
|
||||
sign_WAITING (new String[] { "%H[" + BlockHunt.pdfFile.getName() + "%H]",
|
||||
"%A%arenaname%", "%A%players%%N/%A%maxplayers%", "&8Waiting..." },
|
||||
W.config),
|
||||
sign_STARTING (new String[] { "%H[" + BlockHunt.pdfFile.getName() + "%H]",
|
||||
"%A%arenaname%", "%A%players%%N/%A%maxplayers%",
|
||||
"&2Start: %A%timeleft%" }, W.config),
|
||||
sign_INGAME (new String[] { "%H[" + BlockHunt.pdfFile.getName() + "%H]",
|
||||
"%A%arenaname%", "%A%players%%N/%A%maxplayers%",
|
||||
"%EIngame: %A%timeleft%" }, W.config),
|
||||
sign_LEAVE(new String[] { "%H[" + BlockHunt.pdfFile.getName() + "%H]", "&4LEAVE", "&8Right-Click", "&8To leave." }, W.config), sign_SHOP(new String[] {
|
||||
"%H[" + BlockHunt.pdfFile.getName() + "%H]", "&4SHOP", "&8Right-Click", "&8To shop." }, W.config), sign_WAITING(new String[] {
|
||||
"%H[" + BlockHunt.pdfFile.getName() + "%H]", "%A%arenaname%", "%A%players%%N/%A%maxplayers%", "&8Waiting..." }, W.config), sign_STARTING(new String[] {
|
||||
"%H[" + BlockHunt.pdfFile.getName() + "%H]", "%A%arenaname%", "%A%players%%N/%A%maxplayers%", "&2Start: %A%timeleft%" }, W.config), sign_INGAME(new String[] {
|
||||
"%H[" + BlockHunt.pdfFile.getName() + "%H]", "%A%arenaname%", "%A%players%%N/%A%maxplayers%", "%EIngame: %A%timeleft%" }, W.config),
|
||||
|
||||
scoreboard_enabled (true, W.config),
|
||||
scoreboard_title ("%H[" + BlockHunt.pdfFile.getName() + "]", W.config),
|
||||
scoreboard_timeleft ("%ATime left:", W.config),
|
||||
scoreboard_seekers ("%NSeekers:", W.config),
|
||||
scoreboard_hiders ("%NHiders:", W.config),
|
||||
scoreboard_enabled(true, W.config), scoreboard_title("%H[" + BlockHunt.pdfFile.getName() + "]", W.config), scoreboard_timeleft("%ATime left:", W.config), scoreboard_seekers(
|
||||
"%NSeekers:", W.config), scoreboard_hiders("%NHiders:", W.config),
|
||||
|
||||
requireInventoryClearOnJoin (false, W.config),
|
||||
requireInventoryClearOnJoin(false, W.config),
|
||||
|
||||
log_enabledPlugin ("%TAG%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.",
|
||||
W.messages),
|
||||
log_disabledPlugin ("%TAG%N%name%&c&k - %N%version% is now Disabled. Made by %A%autors%%N.",
|
||||
W.messages),
|
||||
log_enabledPlugin("%TAG%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.", W.messages), log_disabledPlugin(
|
||||
"%TAG%N%name%&c&k - %N%version% is now Disabled. Made by %A%autors%%N.", W.messages),
|
||||
|
||||
help_info ("%NDisplays the plugin's info.", W.messages),
|
||||
help_help ("%NShows a list of commands.", W.messages),
|
||||
help_reload ("%NReloads all configs.", W.messages),
|
||||
help_join ("%NJoins a " + BlockHunt.pdfFile.getName() + " game.",
|
||||
W.messages),
|
||||
help_leave ("%NLeave a " + BlockHunt.pdfFile.getName() + " game.",
|
||||
W.messages),
|
||||
help_list ("%NShows a list of available arenas.", W.messages),
|
||||
help_shop ("%NOpens the " + BlockHunt.pdfFile.getName() + " shop.",
|
||||
W.messages),
|
||||
help_start ("%NForces an arena to start.", W.messages),
|
||||
help_wand ("%NGives you the wand selection tool.", W.messages),
|
||||
help_create ("%NCreates an arena from your selection.", W.messages),
|
||||
help_set ("%NOpens a panel to set settings.", W.messages),
|
||||
help_setwarp ("%NSets warps for your arena.", W.messages),
|
||||
help_remove ("%NDeletes an Arena.", W.messages),
|
||||
help_tokens ("%NChange someones tokens.", W.messages),
|
||||
help_info("%NDisplays the plugin's info.", W.messages), help_help("%NShows a list of commands.", W.messages), help_reload("%NReloads all configs.", W.messages), help_join(
|
||||
"%NJoins a " + BlockHunt.pdfFile.getName() + " game.", W.messages), help_leave("%NLeave a " + BlockHunt.pdfFile.getName() + " game.", W.messages), help_list(
|
||||
"%NShows a list of available arenas.", W.messages), help_shop("%NOpens the " + BlockHunt.pdfFile.getName() + " shop.", W.messages), help_start(
|
||||
"%NForces an arena to start.", W.messages), help_wand("%NGives you the wand selection tool.", W.messages), help_create(
|
||||
"%NCreates an arena from your selection.", W.messages), help_set("%NOpens a panel to set settings.", W.messages), help_setwarp(
|
||||
"%NSets warps for your arena.", W.messages), help_remove("%NDeletes an Arena.", W.messages), help_tokens("%NChange someones tokens.", W.messages),
|
||||
|
||||
button_add ("%NAdd %A%1%%N to %A%2%%N", W.messages),
|
||||
button_add2 ("Add", W.messages),
|
||||
button_setting ("%NSetting %A%1%%N is now: %A%2%%N.", W.messages),
|
||||
button_remove ("%NRemove %A%1%%N from %A%2%%N", W.messages),
|
||||
button_remove2 ("Remove", W.messages),
|
||||
button_add("%NAdd %A%1%%N to %A%2%%N", W.messages), button_add2("Add", W.messages), button_setting("%NSetting %A%1%%N is now: %A%2%%N.", W.messages), button_remove(
|
||||
"%NRemove %A%1%%N from %A%2%%N", W.messages), button_remove2("Remove", W.messages),
|
||||
|
||||
normal_reloadedConfigs ("%TAG&aReloaded all configs!", W.messages),
|
||||
normal_joinJoinedArena ("%TAG%A%playername%%N joined your arena. (%A%1%%N/%A%2%%N)",
|
||||
W.messages),
|
||||
normal_leaveYouLeft ("%TAG%NYou left the arena! Thanks for playing!",
|
||||
W.messages),
|
||||
normal_leaveLeftArena ("%TAG%A%playername%%N left your arena. (%A%1%%N/%A%2%%N)",
|
||||
W.messages),
|
||||
normal_startForced ("%TAG%NYou forced to start arena '%A%arenaname%%N'!",
|
||||
W.messages),
|
||||
normal_wandGaveWand ("%TAG%NHere you go! &o(Use the %A&o%type%%N&o!)",
|
||||
W.messages),
|
||||
normal_wandSetPosition ("%TAG%NSet position %A#%number%%N to location: (%A%x%%N, %A%y%%N, %A%z%%N).",
|
||||
W.messages),
|
||||
normal_createCreatedArena ("%TAG%NCreated an arena with the name '%A%name%%N'.",
|
||||
W.messages),
|
||||
normal_lobbyArenaIsStarting ("%TAG%NThe arena will start in %A%1%%N second(s)!",
|
||||
W.messages),
|
||||
normal_lobbyArenaStarted ("%TAG%NThe arena has been started! The seeker is coming to find you in %A%secs%%N seconds!",
|
||||
W.messages),
|
||||
normal_ingameSeekerChoosen ("%TAG%NPlayer %A%seeker%%N has been choosen as seeker!",
|
||||
W.messages),
|
||||
normal_ingameBlock ("%TAG%NYou're disguised as a(n) '%A%block%%N' block.",
|
||||
W.messages),
|
||||
normal_ingameArenaEnd ("%TAG%NThe arena will end in %A%1%%N second(s)!",
|
||||
W.messages),
|
||||
normal_ingameSeekerSpawned ("%TAG%A%playername%%N has spawned as a seeker!",
|
||||
W.messages),
|
||||
normal_ingameGivenSword ("%TAG%NYou were given a sword!", W.messages),
|
||||
normal_ingameHiderDied ("%TAG%NHider %A%playername%%N was killed by %A%killer%%N!",
|
||||
W.messages),
|
||||
normal_ingameHidersLeft ("%NHider(s) left: %A%left%%N",
|
||||
W.messages),
|
||||
normal_ingameSeekerDied ("%TAG%NSeeker %A%playername%%N died and will respawn in %A%secs%%N seconds!",
|
||||
W.messages),
|
||||
normal_winSeekers ("%TAG%NThe %ASEEKERS%N have won!", W.messages),
|
||||
normal_winHiders ("%TAG%NThe %AHIDERS%N have won!", W.messages),
|
||||
normal_setwarpWarpSet ("%TAG%NSet warp '%A%warp%%N' to your location!",
|
||||
W.messages),
|
||||
normal_addedToken ("%TAG%A%amount%%N tokens were added to your account!",
|
||||
W.messages),
|
||||
normal_removeRemovedArena ("%TAG%NRemoved arena '%A%name%%N'!", W.messages),
|
||||
normal_tokensChanged ("%TAG%N%option% %A%amount%%N tokens %option2% %A%playername%%N.",
|
||||
W.messages),
|
||||
normal_tokensChangedPerson ("%TAG%NPlayer %A%playername%%N %N%option% %A%amount%%N %option2% your tokens.",
|
||||
W.messages),
|
||||
normal_ingameNowSolid ("%TAG%NYou're now a solid '%A%block%%N' block!",
|
||||
W.messages),
|
||||
normal_ingameNoMoreSolid ("%TAG%NYou're no longer a solid block!",
|
||||
W.messages),
|
||||
normal_shopBoughtItem ("%TAG%NYou've bought the '%A%itemname%%N' item!",
|
||||
W.messages),
|
||||
normal_shopChoosenBlock ("%TAG%NYou've choosen to be a(n) '%A%block%%N' block!",
|
||||
W.messages),
|
||||
normal_shopChoosenSeeker ("%TAG%NYou've choosen to be a %Aseeker%N!",
|
||||
W.messages),
|
||||
normal_shopChoosenHiders ("%TAG%NYou've choosen to be a %Ahider%N!",
|
||||
W.messages),
|
||||
normal_reloadedConfigs("%TAG&aReloaded all configs!", W.messages), normal_joinJoinedArena("%TAG%A%playername%%N joined your arena. (%A%1%%N/%A%2%%N)", W.messages), normal_leaveYouLeft(
|
||||
"%TAG%NYou left the arena! Thanks for playing!", W.messages), normal_leaveLeftArena("%TAG%A%playername%%N left your arena. (%A%1%%N/%A%2%%N)", W.messages), normal_startForced(
|
||||
"%TAG%NYou forced to start arena '%A%arenaname%%N'!", W.messages), normal_wandGaveWand("%TAG%NHere you go! &o(Use the %A&o%type%%N&o!)", W.messages), normal_wandSetPosition(
|
||||
"%TAG%NSet position %A#%number%%N to location: (%A%x%%N, %A%y%%N, %A%z%%N).", W.messages), normal_createCreatedArena(
|
||||
"%TAG%NCreated an arena with the name '%A%name%%N'.", W.messages), normal_lobbyArenaIsStarting("%TAG%NThe arena will start in %A%1%%N second(s)!", W.messages), normal_lobbyArenaStarted(
|
||||
"%TAG%NThe arena has been started! The seeker is coming to find you in %A%secs%%N seconds!", W.messages), normal_ingameSeekerChoosen(
|
||||
"%TAG%NPlayer %A%seeker%%N has been choosen as seeker!", W.messages), normal_ingameBlock("%TAG%NYou're disguised as a(n) '%A%block%%N' block.", W.messages), normal_ingameArenaEnd(
|
||||
"%TAG%NThe arena will end in %A%1%%N second(s)!", W.messages), normal_ingameSeekerSpawned("%TAG%A%playername%%N has spawned as a seeker!", W.messages), normal_ingameGivenSword(
|
||||
"%TAG%NYou were given a sword!", W.messages), normal_ingameHiderDied("%TAG%NHider %A%playername%%N was killed by %A%killer%%N!", W.messages), normal_ingameHidersLeft(
|
||||
"%NHider(s) left: %A%left%%N", W.messages), normal_ingameSeekerDied("%TAG%NSeeker %A%playername%%N died and will respawn in %A%secs%%N seconds!", W.messages), normal_winSeekers(
|
||||
"%TAG%NThe %ASEEKERS%N have won!", W.messages), normal_winHiders("%TAG%NThe %AHIDERS%N have won!", W.messages), normal_setwarpWarpSet(
|
||||
"%TAG%NSet warp '%A%warp%%N' to your location!", W.messages), normal_addedToken("%TAG%A%amount%%N tokens were added to your account!", W.messages), normal_removeRemovedArena(
|
||||
"%TAG%NRemoved arena '%A%name%%N'!", W.messages), normal_tokensChanged("%TAG%N%option% %A%amount%%N tokens %option2% %A%playername%%N.", W.messages), normal_tokensChangedPerson(
|
||||
"%TAG%NPlayer %A%playername%%N %N%option% %A%amount%%N %option2% your tokens.", W.messages), normal_ingameNowSolid(
|
||||
"%TAG%NYou're now a solid '%A%block%%N' block!", W.messages), normal_ingameNoMoreSolid("%TAG%NYou're no longer a solid block!", W.messages), normal_shopBoughtItem(
|
||||
"%TAG%NYou've bought the '%A%itemname%%N' item!", W.messages), normal_shopChoosenBlock("%TAG%NYou've choosen to be a(n) '%A%block%%N' block!", W.messages), normal_shopChoosenSeeker(
|
||||
"%TAG%NYou've choosen to be a %Aseeker%N!", W.messages), normal_shopChoosenHiders("%TAG%NYou've choosen to be a %Ahider%N!", W.messages),
|
||||
|
||||
warning_lobbyNeedAtleast ("%TAG%WYou need atleast %A%1%%W player(s) to start the game!",
|
||||
W.messages),
|
||||
warning_ingameNEWSeekerChoosen ("%TAG%WThe last seeker left and a new seeker has been choosen!",
|
||||
W.messages),
|
||||
warning_unableToCommand ("%TAG%WSorry but that command is disabled in the arena.",
|
||||
W.messages),
|
||||
warning_ingameNoSolidPlace ("%TAG%WThat's not a valid place to become solid!",
|
||||
W.messages),
|
||||
warning_arenaStopped ("%TAG%WThe arena has been forced to stop!",
|
||||
W.messages),
|
||||
warning_lobbyNeedAtleast("%TAG%WYou need atleast %A%1%%W player(s) to start the game!", W.messages), warning_ingameNEWSeekerChoosen(
|
||||
"%TAG%WThe last seeker left and a new seeker has been choosen!", W.messages), warning_unableToCommand(
|
||||
"%TAG%WSorry but that command is disabled in the arena.", W.messages), warning_ingameNoSolidPlace("%TAG%WThat's not a valid place to become solid!",
|
||||
W.messages), warning_arenaStopped("%TAG%WThe arena has been forced to stop!", W.messages),
|
||||
|
||||
error_noPermission ("%TAG%EYou don't have the permissions to do that!",
|
||||
W.messages),
|
||||
error_notANumber ("%TAG%E'%A%1%%E' is not a number!", W.messages),
|
||||
error_commandNotEnabled ("%TAG%EThis command has been disabled!",
|
||||
W.messages),
|
||||
error_commandNotFound ("%TAG%ECouldn't find the command. Try %A/"
|
||||
+ BlockHunt.pdfFile.getName() + " help %Efor more info.",
|
||||
W.messages),
|
||||
error_notEnoughArguments ("%TAG%EYou're missing arguments, correct syntax: %A%syntax%",
|
||||
W.messages),
|
||||
error_libsDisguisesNotInstalled ("%TAG%EThe plugin '%ALib's Disguises%E' is required to run this plugin! Intall it or it won't work!",
|
||||
W.messages),
|
||||
error_protocolLibNotInstalled ("%TAG%EThe plugin '%AProtocolLib%E' is required to run this plugin! Intall it or it won't work!",
|
||||
W.messages),
|
||||
error_noArena ("%TAG%ENo arena found with the name '%A%name%%E'.",
|
||||
W.messages),
|
||||
error_onlyIngame ("%TAG%EThis is an only in-game command!", W.messages),
|
||||
error_joinAlreadyJoined ("%TAG%EYou've already joined an arena!",
|
||||
W.messages),
|
||||
error_joinNoBlocksSet ("%TAG%EThere are none blocks set for this arena. Notify the administrator.",
|
||||
W.messages),
|
||||
error_joinWarpsNotSet ("%TAG%EThere are no warps set for this arena. Notify the administrator.",
|
||||
W.messages),
|
||||
error_joinArenaIngame ("%TAG%EThis game has already started.", W.messages),
|
||||
error_joinFull ("%TAG%EUnable to join this arena. It's full!", W.messages),
|
||||
error_joinInventoryNotEmpty ("%TAG%EYour inventory should be empty before joining!",
|
||||
W.messages),
|
||||
error_leaveNotInArena ("%TAG%EYou're not in an arena!", W.messages),
|
||||
error_createSelectionFirst ("%TAG%EMake a selection first. Use the wand command: %A/"
|
||||
+ BlockHunt.pdfFile.getName() + " <wand|w>%E.",
|
||||
W.messages),
|
||||
error_createNotSameWorld ("%TAG%EMake your selection points in the same world!",
|
||||
W.messages),
|
||||
error_setTooHighNumber ("%TAG%EThat amount is too high! Max amount is: %A%max%%E.",
|
||||
W.messages),
|
||||
error_setTooLowNumber ("%TAG%EThat amount is too low! Minimal amount is: %A%min%%E.",
|
||||
W.messages),
|
||||
error_setNotABlock ("%TAG%EThat is not a block!", W.messages),
|
||||
error_setwarpWarpNotFound ("%TAG%EWarp '%A%warp%%E' is not valid!",
|
||||
W.messages),
|
||||
error_tokensPlayerNotOnline ("%TAG%ENo player found with the name '%A%playername%%E'!",
|
||||
W.messages),
|
||||
error_tokensUnknownsetting ("%TAG%E'%A%option%%E' is not a known option!",
|
||||
W.messages),
|
||||
error_shopNeedMoreTokens ("%TAG%EYou need more tokens before you can buy this item.",
|
||||
W.messages),
|
||||
error_shopMaxSeekersReached ("%TAG%ESorry, the maximum amount of seekers has been reached!",
|
||||
W.messages),
|
||||
error_shopMaxHidersReached ("%TAG%ESorry, the maximum amount of hiders has been reached!",
|
||||
W.messages);
|
||||
error_noPermission("%TAG%EYou don't have the permissions to do that!", W.messages), error_notANumber("%TAG%E'%A%1%%E' is not a number!", W.messages), error_commandNotEnabled(
|
||||
"%TAG%EThis command has been disabled!", W.messages), error_commandNotFound("%TAG%ECouldn't find the command. Try %A/" + BlockHunt.pdfFile.getName()
|
||||
+ " help %Efor more info.", W.messages), error_notEnoughArguments("%TAG%EYou're missing arguments, correct syntax: %A%syntax%", W.messages), error_libsDisguisesNotInstalled(
|
||||
"%TAG%EThe plugin '%ALib's Disguises%E' is required to run this plugin! Intall it or it won't work!", W.messages), error_protocolLibNotInstalled(
|
||||
"%TAG%EThe plugin '%AProtocolLib%E' is required to run this plugin! Intall it or it won't work!", W.messages), error_noArena(
|
||||
"%TAG%ENo arena found with the name '%A%name%%E'.", W.messages), error_onlyIngame("%TAG%EThis is an only in-game command!", W.messages), error_joinAlreadyJoined(
|
||||
"%TAG%EYou've already joined an arena!", W.messages), error_joinNoBlocksSet("%TAG%EThere are none blocks set for this arena. Notify the administrator.",
|
||||
W.messages), error_joinWarpsNotSet("%TAG%EThere are no warps set for this arena. Notify the administrator.", W.messages), error_joinArenaIngame(
|
||||
"%TAG%EThis game has already started.", W.messages), error_joinFull("%TAG%EUnable to join this arena. It's full!", W.messages), error_joinInventoryNotEmpty(
|
||||
"%TAG%EYour inventory should be empty before joining!", W.messages), error_leaveNotInArena("%TAG%EYou're not in an arena!", W.messages), error_createSelectionFirst(
|
||||
"%TAG%EMake a selection first. Use the wand command: %A/" + BlockHunt.pdfFile.getName() + " <wand|w>%E.", W.messages), error_createNotSameWorld(
|
||||
"%TAG%EMake your selection points in the same world!", W.messages), error_setTooHighNumber("%TAG%EThat amount is too high! Max amount is: %A%max%%E.",
|
||||
W.messages), error_setTooLowNumber("%TAG%EThat amount is too low! Minimal amount is: %A%min%%E.", W.messages), error_setNotABlock(
|
||||
"%TAG%EThat is not a block!", W.messages), error_setwarpWarpNotFound("%TAG%EWarp '%A%warp%%E' is not valid!", W.messages), error_tokensPlayerNotOnline(
|
||||
"%TAG%ENo player found with the name '%A%playername%%E'!", W.messages), error_tokensUnknownsetting("%TAG%E'%A%option%%E' is not a known option!", W.messages), error_shopNeedMoreTokens(
|
||||
"%TAG%EYou need more tokens before you can buy this item.", W.messages), error_shopMaxSeekersReached(
|
||||
"%TAG%ESorry, the maximum amount of seekers has been reached!", W.messages), error_shopMaxHidersReached(
|
||||
"%TAG%ESorry, the maximum amount of hiders has been reached!", W.messages);
|
||||
|
||||
public Object value;
|
||||
public ConfigM config;
|
||||
@ -256,7 +117,7 @@ public enum ConfigC {
|
||||
* @param config
|
||||
* The config file.
|
||||
*/
|
||||
private ConfigC (Object value, ConfigM config) {
|
||||
private ConfigC(Object value, ConfigM config) {
|
||||
this.value = value;
|
||||
this.config = config;
|
||||
this.location = this.name().replaceAll("_", ".");
|
||||
|
@ -31,146 +31,98 @@ public class InventoryHandler {
|
||||
arenaname = arena.arenaName;
|
||||
if (shorten.length() > 6)
|
||||
shorten = shorten.substring(0, 6);
|
||||
Inventory panel = Bukkit
|
||||
.createInventory(
|
||||
null,
|
||||
54,
|
||||
MessageM.replaceAll("\u00A7r%N&lBlockHunt Arena: %A"
|
||||
+ shorten));
|
||||
Inventory panel = Bukkit.createInventory(null, 54, MessageM.replaceAll("\u00A7r%N&lBlockHunt Arena: %A" + shorten));
|
||||
|
||||
ItemStack arenaNameNote = new ItemStack(Material.PAPER, 1);
|
||||
ItemMeta arenaNameNote_IM = arenaNameNote.getItemMeta();
|
||||
arenaNameNote_IM.setDisplayName(MessageM
|
||||
.replaceAll("%NBlockHunt arena: %A" + arena.arenaName));
|
||||
arenaNameNote_IM.setDisplayName(MessageM.replaceAll("%NBlockHunt arena: %A" + arena.arenaName));
|
||||
arenaNameNote.setItemMeta(arenaNameNote_IM);
|
||||
panel.setItem(0, arenaNameNote);
|
||||
|
||||
//
|
||||
|
||||
ItemStack maxPlayers_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
ItemStack maxPlayers = new ItemStack(Material.BEDROCK,
|
||||
arena.maxPlayers);
|
||||
ItemStack maxPlayers = new ItemStack(Material.BEDROCK, arena.maxPlayers);
|
||||
ItemStack maxPlayers_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
|
||||
ItemStack minPlayers_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
ItemStack minPlayers = new ItemStack(Material.BEDROCK,
|
||||
arena.minPlayers);
|
||||
ItemStack minPlayers = new ItemStack(Material.BEDROCK, arena.minPlayers);
|
||||
ItemStack minPlayers_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
|
||||
ItemStack amountSeekersOnStart_UP = new ItemStack(
|
||||
Material.GOLD_NUGGET, 1);
|
||||
ItemStack amountSeekersOnStart = new ItemStack(
|
||||
Material.BEDROCK, arena.amountSeekersOnStart);
|
||||
ItemStack amountSeekersOnStart_DOWN = new ItemStack(
|
||||
Material.GOLD_NUGGET, 1);
|
||||
ItemStack amountSeekersOnStart_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
ItemStack amountSeekersOnStart = new ItemStack(Material.BEDROCK, arena.amountSeekersOnStart);
|
||||
ItemStack amountSeekersOnStart_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
|
||||
ItemStack timeInLobbyUntilStart_UP = new ItemStack(
|
||||
Material.GOLD_NUGGET, 1);
|
||||
ItemStack timeInLobbyUntilStart = new ItemStack(
|
||||
Material.BEDROCK, arena.timeInLobbyUntilStart);
|
||||
ItemStack timeInLobbyUntilStart_DOWN = new ItemStack(
|
||||
Material.GOLD_NUGGET, 1);
|
||||
ItemStack timeInLobbyUntilStart_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
ItemStack timeInLobbyUntilStart = new ItemStack(Material.BEDROCK, arena.timeInLobbyUntilStart);
|
||||
ItemStack timeInLobbyUntilStart_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
|
||||
ItemStack waitingTimeSeeker_UP = new ItemStack(
|
||||
Material.GOLD_NUGGET, 1);
|
||||
ItemStack waitingTimeSeeker = new ItemStack(
|
||||
Material.BEDROCK, arena.waitingTimeSeeker);
|
||||
ItemStack waitingTimeSeeker_DOWN = new ItemStack(
|
||||
Material.GOLD_NUGGET, 1);
|
||||
ItemStack waitingTimeSeeker_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
ItemStack waitingTimeSeeker = new ItemStack(Material.BEDROCK, arena.waitingTimeSeeker);
|
||||
ItemStack waitingTimeSeeker_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
|
||||
ItemStack gameTime_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
ItemStack gameTime = new ItemStack(Material.BEDROCK,
|
||||
arena.gameTime);
|
||||
ItemStack gameTime = new ItemStack(Material.BEDROCK, arena.gameTime);
|
||||
ItemStack gameTime_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
|
||||
ItemStack disguiseBlocks_NOTE = new ItemStack(Material.BOOK, 1);
|
||||
ItemMeta disguiseBlocks_NOTE_IM = disguiseBlocks_NOTE.getItemMeta();
|
||||
disguiseBlocks_NOTE_IM.setDisplayName(MessageM
|
||||
.replaceAll("%NSet the %AdisguiseBlocks%N."));
|
||||
disguiseBlocks_NOTE_IM.setDisplayName(MessageM.replaceAll("%NSet the %AdisguiseBlocks%N."));
|
||||
disguiseBlocks_NOTE.setItemMeta(disguiseBlocks_NOTE_IM);
|
||||
panel.setItem(37, disguiseBlocks_NOTE);
|
||||
|
||||
ItemStack timeUntilHidersSword_UP = new ItemStack(
|
||||
Material.GOLD_NUGGET, 1);
|
||||
ItemStack timeUntilHidersSword = new ItemStack(
|
||||
Material.BEDROCK, arena.timeUntilHidersSword);
|
||||
ItemStack timeUntilHidersSword_DOWN = new ItemStack(
|
||||
Material.GOLD_NUGGET, 1);
|
||||
ItemStack timeUntilHidersSword_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
ItemStack timeUntilHidersSword = new ItemStack(Material.BEDROCK, arena.timeUntilHidersSword);
|
||||
ItemStack timeUntilHidersSword_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
|
||||
ItemStack hidersTokenWin_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
ItemStack hidersTokenWin = new ItemStack(
|
||||
Material.BEDROCK, arena.hidersTokenWin);
|
||||
ItemStack hidersTokenWin_DOWN = new ItemStack(Material.GOLD_NUGGET,
|
||||
1);
|
||||
ItemStack hidersTokenWin = new ItemStack(Material.BEDROCK, arena.hidersTokenWin);
|
||||
ItemStack hidersTokenWin_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
|
||||
ItemStack seekersTokenWin_UP = new ItemStack(Material.GOLD_NUGGET,
|
||||
1);
|
||||
ItemStack seekersTokenWin = new ItemStack(
|
||||
Material.BEDROCK, arena.seekersTokenWin);
|
||||
ItemStack seekersTokenWin_DOWN = new ItemStack(
|
||||
Material.GOLD_NUGGET, 1);
|
||||
ItemStack seekersTokenWin_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
ItemStack seekersTokenWin = new ItemStack(Material.BEDROCK, arena.seekersTokenWin);
|
||||
ItemStack seekersTokenWin_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
|
||||
ItemStack killTokens_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
ItemStack killTokens = new ItemStack(Material.BEDROCK,
|
||||
arena.killTokens);
|
||||
ItemStack killTokens = new ItemStack(Material.BEDROCK, arena.killTokens);
|
||||
ItemStack killTokens_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||
|
||||
//
|
||||
|
||||
updownButton(panel, arena, ArenaType.maxPlayers, "maxPlayers", "1",
|
||||
maxPlayers_UP, maxPlayers, maxPlayers_DOWN, 1, 10, 19);
|
||||
updownButton(panel, arena, ArenaType.maxPlayers, "maxPlayers", "1", maxPlayers_UP, maxPlayers, maxPlayers_DOWN, 1, 10, 19);
|
||||
|
||||
updownButton(panel, arena, ArenaType.minPlayers, "minPlayers", "1",
|
||||
minPlayers_UP, minPlayers, minPlayers_DOWN, 2, 11, 20);
|
||||
updownButton(panel, arena, ArenaType.minPlayers, "minPlayers", "1", minPlayers_UP, minPlayers, minPlayers_DOWN, 2, 11, 20);
|
||||
|
||||
updownButton(panel, arena, ArenaType.amountSeekersOnStart,
|
||||
"amountSeekersOnStart", "1", amountSeekersOnStart_UP,
|
||||
amountSeekersOnStart, amountSeekersOnStart_DOWN, 4, 13, 22);
|
||||
updownButton(panel, arena, ArenaType.amountSeekersOnStart, "amountSeekersOnStart", "1", amountSeekersOnStart_UP, amountSeekersOnStart,
|
||||
amountSeekersOnStart_DOWN, 4, 13, 22);
|
||||
|
||||
updownButton(panel, arena, ArenaType.timeInLobbyUntilStart,
|
||||
"timeInLobbyUntilStart", "1 %Nsecond",
|
||||
timeInLobbyUntilStart_UP, timeInLobbyUntilStart,
|
||||
updownButton(panel, arena, ArenaType.timeInLobbyUntilStart, "timeInLobbyUntilStart", "1 %Nsecond", timeInLobbyUntilStart_UP, timeInLobbyUntilStart,
|
||||
timeInLobbyUntilStart_DOWN, 6, 15, 24);
|
||||
|
||||
updownButton(panel, arena, ArenaType.waitingTimeSeeker,
|
||||
"waitingTimeSeeker", "1 %Nsecond", waitingTimeSeeker_UP,
|
||||
waitingTimeSeeker, waitingTimeSeeker_DOWN, 7, 16, 25);
|
||||
updownButton(panel, arena, ArenaType.waitingTimeSeeker, "waitingTimeSeeker", "1 %Nsecond", waitingTimeSeeker_UP, waitingTimeSeeker, waitingTimeSeeker_DOWN,
|
||||
7, 16, 25);
|
||||
|
||||
updownButton(panel, arena, ArenaType.gameTime, "gameTime",
|
||||
"1 %Nsecond", gameTime_UP, gameTime, gameTime_DOWN, 8, 17,
|
||||
26);
|
||||
updownButton(panel, arena, ArenaType.gameTime, "gameTime", "1 %Nsecond", gameTime_UP, gameTime, gameTime_DOWN, 8, 17, 26);
|
||||
|
||||
updownButton(panel, arena, ArenaType.timeUntilHidersSword,
|
||||
"timeUntilHidersSword", "1 %Nsecond",
|
||||
timeUntilHidersSword_UP, timeUntilHidersSword,
|
||||
updownButton(panel, arena, ArenaType.timeUntilHidersSword, "timeUntilHidersSword", "1 %Nsecond", timeUntilHidersSword_UP, timeUntilHidersSword,
|
||||
timeUntilHidersSword_DOWN, 30, 39, 48);
|
||||
|
||||
updownButton(panel, arena, ArenaType.hidersTokenWin,
|
||||
"hidersTokenWin", "1 %Ntoken", hidersTokenWin_UP,
|
||||
hidersTokenWin, hidersTokenWin_DOWN, 32, 41, 50);
|
||||
updownButton(panel, arena, ArenaType.hidersTokenWin, "hidersTokenWin", "1 %Ntoken", hidersTokenWin_UP, hidersTokenWin, hidersTokenWin_DOWN, 32, 41, 50);
|
||||
|
||||
updownButton(panel, arena, ArenaType.seekersTokenWin,
|
||||
"seekersTokenWin", "1 %Ntoken", seekersTokenWin_UP,
|
||||
seekersTokenWin, seekersTokenWin_DOWN, 33, 42, 51);
|
||||
updownButton(panel, arena, ArenaType.seekersTokenWin, "seekersTokenWin", "1 %Ntoken", seekersTokenWin_UP, seekersTokenWin, seekersTokenWin_DOWN, 33, 42, 51);
|
||||
|
||||
updownButton(panel, arena, ArenaType.killTokens, "killTokens",
|
||||
"1 %Ntoken", killTokens_UP, killTokens, killTokens_DOWN,
|
||||
34, 43, 52);
|
||||
updownButton(panel, arena, ArenaType.killTokens, "killTokens", "1 %Ntoken", killTokens_UP, killTokens, killTokens_DOWN, 34, 43, 52);
|
||||
|
||||
player.openInventory(panel);
|
||||
} else {
|
||||
MessageM.sendFMessage(player, ConfigC.error_noArena, "name-"
|
||||
+ arenaname);
|
||||
MessageM.sendFMessage(player, ConfigC.error_noArena, "name-" + arenaname);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updownButton(Inventory panel, Arena arena, ArenaType at,
|
||||
String option, String addremove, ItemStack UP, ItemStack BUTTON,
|
||||
ItemStack DOWN, int up, int button, int down) {
|
||||
public static void updownButton(Inventory panel, Arena arena, ArenaType at, String option, String addremove, ItemStack UP, ItemStack BUTTON, ItemStack DOWN, int up,
|
||||
int button, int down) {
|
||||
ItemMeta UP_IM = UP.getItemMeta();
|
||||
UP_IM.setDisplayName(MessageM.replaceAll(
|
||||
(String) W.messages.get(ConfigC.button_add), "1-" + addremove,
|
||||
"2-" + option));
|
||||
UP_IM.setDisplayName(MessageM.replaceAll((String) W.messages.get(ConfigC.button_add), "1-" + addremove, "2-" + option));
|
||||
UP.setItemMeta(UP_IM);
|
||||
|
||||
int setting = 0;
|
||||
@ -208,15 +160,11 @@ public class InventoryHandler {
|
||||
}
|
||||
|
||||
ItemMeta BUTTON_IM = BUTTON.getItemMeta();
|
||||
BUTTON_IM.setDisplayName(MessageM.replaceAll(
|
||||
(String) W.messages.get(ConfigC.button_setting), "1-" + option,
|
||||
"2-" + setting));
|
||||
BUTTON_IM.setDisplayName(MessageM.replaceAll((String) W.messages.get(ConfigC.button_setting), "1-" + option, "2-" + setting));
|
||||
BUTTON.setItemMeta(BUTTON_IM);
|
||||
|
||||
ItemMeta DOWN_IM = DOWN.getItemMeta();
|
||||
DOWN_IM.setDisplayName(MessageM.replaceAll(
|
||||
(String) W.messages.get(ConfigC.button_remove), "1-"
|
||||
+ addremove, "2-" + option));
|
||||
DOWN_IM.setDisplayName(MessageM.replaceAll((String) W.messages.get(ConfigC.button_remove), "1-" + addremove, "2-" + option));
|
||||
DOWN.setItemMeta(DOWN_IM);
|
||||
|
||||
panel.setItem(up, UP);
|
||||
@ -226,16 +174,13 @@ public class InventoryHandler {
|
||||
|
||||
public static void openDisguiseBlocks(Arena arena, Player player) {
|
||||
String arenaname = arena.arenaName;
|
||||
Inventory panel = Bukkit.createInventory(null, 36,
|
||||
MessageM.replaceAll("%N&lDisguiseBlocks"));
|
||||
Inventory panel = Bukkit.createInventory(null, 36, MessageM.replaceAll("%N&lDisguiseBlocks"));
|
||||
|
||||
ItemStack arenaNameNote = new ItemStack(Material.PAPER, 1);
|
||||
ItemMeta arenaNameNote_IM = arenaNameNote.getItemMeta();
|
||||
arenaNameNote_IM.setDisplayName(MessageM
|
||||
.replaceAll("%NDisguiseBlocks of arena: %A" + arenaname));
|
||||
arenaNameNote_IM.setDisplayName(MessageM.replaceAll("%NDisguiseBlocks of arena: %A" + arenaname));
|
||||
ArrayList<String> lores = new ArrayList<String>();
|
||||
lores.add(MessageM
|
||||
.replaceAll("%NPlace the DisguiseBlocks inside this inventory."));
|
||||
lores.add(MessageM.replaceAll("%NPlace the DisguiseBlocks inside this inventory."));
|
||||
arenaNameNote_IM.setLore(lores);
|
||||
arenaNameNote.setItemMeta(arenaNameNote_IM);
|
||||
panel.setItem(0, arenaNameNote);
|
||||
@ -248,73 +193,51 @@ public class InventoryHandler {
|
||||
}
|
||||
|
||||
public static void openShop(Player player) {
|
||||
Inventory shop = Bukkit.createInventory(
|
||||
null,
|
||||
9,
|
||||
MessageM.replaceAll("\u00A7r"
|
||||
+ W.config.get(ConfigC.shop_title)));
|
||||
Inventory shop = Bukkit.createInventory(null, 9, MessageM.replaceAll("\u00A7r" + W.config.get(ConfigC.shop_title)));
|
||||
if (W.shop.getFile().get(player.getName() + ".tokens") == null) {
|
||||
W.shop.getFile().set(player.getName() + ".tokens", 0);
|
||||
W.shop.save();
|
||||
}
|
||||
int playerTokens = W.shop.getFile()
|
||||
.getInt(player.getName() + ".tokens");
|
||||
int playerTokens = W.shop.getFile().getInt(player.getName() + ".tokens");
|
||||
List<String> lores = new ArrayList<String>();
|
||||
List<String> lores2 = new ArrayList<String>();
|
||||
|
||||
ItemStack shopTokens = new ItemStack(Material.EMERALD, 1);
|
||||
ItemMeta shopTokens_IM = shopTokens.getItemMeta();
|
||||
shopTokens_IM.setDisplayName(MessageM.replaceAll("%N&lTokens: %A"
|
||||
+ playerTokens));
|
||||
shopTokens_IM.setDisplayName(MessageM.replaceAll("%N&lTokens: %A" + playerTokens));
|
||||
shopTokens.setItemMeta(shopTokens_IM);
|
||||
|
||||
ItemStack shopBlockChooser = new ItemStack(
|
||||
Material.getMaterial((String) W.config
|
||||
.get(ConfigC.shop_blockChooserv1IDname)), 1);
|
||||
ItemStack shopBlockChooser = new ItemStack(Material.getMaterial((String) W.config.get(ConfigC.shop_blockChooserv1IDname)), 1);
|
||||
ItemMeta shopBlockChooser_IM = shopBlockChooser.getItemMeta();
|
||||
shopBlockChooser_IM.setDisplayName(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.shop_blockChooserv1Name)));
|
||||
lores = W.config.getFile().getStringList(
|
||||
ConfigC.shop_blockChooserv1Description.location);
|
||||
shopBlockChooser_IM.setDisplayName(MessageM.replaceAll((String) W.config.get(ConfigC.shop_blockChooserv1Name)));
|
||||
lores = W.config.getFile().getStringList(ConfigC.shop_blockChooserv1Description.location);
|
||||
lores2 = new ArrayList<String>();
|
||||
for (String lore : lores) {
|
||||
lores2.add(MessageM.replaceAll(lore));
|
||||
}
|
||||
|
||||
lores2.add(MessageM.replaceAll(
|
||||
(String) W.config.get(ConfigC.shop_price),
|
||||
"amount-" + W.config.get(ConfigC.shop_blockChooserv1Price)));
|
||||
lores2.add(MessageM.replaceAll((String) W.config.get(ConfigC.shop_price), "amount-" + W.config.get(ConfigC.shop_blockChooserv1Price)));
|
||||
|
||||
shopBlockChooser_IM.setLore(lores2);
|
||||
shopBlockChooser.setItemMeta(shopBlockChooser_IM);
|
||||
|
||||
ItemStack shopBlockHuntPass = new ItemStack(
|
||||
Material.getMaterial((String) W.config
|
||||
.get(ConfigC.shop_BlockHuntPassv2IDName)), 1);
|
||||
ItemStack shopBlockHuntPass = new ItemStack(Material.getMaterial((String) W.config.get(ConfigC.shop_BlockHuntPassv2IDName)), 1);
|
||||
ItemMeta shopBlockHuntPass_IM = shopBlockHuntPass.getItemMeta();
|
||||
shopBlockHuntPass_IM.setDisplayName(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.shop_BlockHuntPassv2Name)));
|
||||
lores = W.config.getFile().getStringList(
|
||||
ConfigC.shop_BlockHuntPassv2Description.location);
|
||||
shopBlockHuntPass_IM.setDisplayName(MessageM.replaceAll((String) W.config.get(ConfigC.shop_BlockHuntPassv2Name)));
|
||||
lores = W.config.getFile().getStringList(ConfigC.shop_BlockHuntPassv2Description.location);
|
||||
lores2 = new ArrayList<String>();
|
||||
for (String lore : lores) {
|
||||
lores2.add(MessageM.replaceAll(lore));
|
||||
}
|
||||
|
||||
lores2.add(MessageM.replaceAll(
|
||||
(String) W.config.get(ConfigC.shop_price),
|
||||
"amount-" + W.config.get(ConfigC.shop_BlockHuntPassv2Price)));
|
||||
lores2.add(MessageM.replaceAll((String) W.config.get(ConfigC.shop_price), "amount-" + W.config.get(ConfigC.shop_BlockHuntPassv2Price)));
|
||||
|
||||
shopBlockHuntPass_IM.setLore(lores2);
|
||||
shopBlockHuntPass.setItemMeta(shopBlockHuntPass_IM);
|
||||
|
||||
shop.setItem(0, shopTokens);
|
||||
if ((Boolean) W.config.get(ConfigC.shop_blockChooserv1Enabled) == true
|
||||
&& ((Boolean) W.shop.getFile().get(
|
||||
player.getName() + ".blockchooser") == null && !PermissionsM
|
||||
.hasPerm(player, Permissions.shopblockchooser, false))) {
|
||||
&& ((Boolean) W.shop.getFile().get(player.getName() + ".blockchooser") == null && !PermissionsM.hasPerm(player, Permissions.shopblockchooser, false))) {
|
||||
shop.setItem(1, shopBlockChooser);
|
||||
}
|
||||
if ((Boolean) W.config.get(ConfigC.shop_BlockHuntPassv2Enabled) == true) {
|
||||
|
@ -14,7 +14,7 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
public class OnBlockBreakEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockBreakEvent(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
@ -24,8 +24,7 @@ public class OnBlockBreakEvent implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getBlock().equals(Material.SIGN_POST)
|
||||
|| event.getBlock().equals(Material.WALL_SIGN)) {
|
||||
if (event.getBlock().equals(Material.SIGN_POST) || event.getBlock().equals(Material.WALL_SIGN)) {
|
||||
if (!PermissionsM.hasPerm(player, Permissions.signcreate, true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
public class OnBlockPlaceEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockPlaceEvent(BlockPlaceEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
|
@ -24,7 +24,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
public class OnEntityDamageByEntityEvent implements Listener {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
|
||||
Player player = null;
|
||||
if (event.getEntity() instanceof Player) {
|
||||
@ -41,22 +41,16 @@ public class OnEntityDamageByEntityEvent implements Listener {
|
||||
if (player != null) {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
if (arena.gameState == ArenaState.WAITING
|
||||
|| arena.gameState == ArenaState.STARTING) {
|
||||
if (arena.gameState == ArenaState.WAITING || arena.gameState == ArenaState.STARTING) {
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
if (arena.seekers.contains(player)
|
||||
&& arena.seekers.contains(event.getDamager())) {
|
||||
if (arena.seekers.contains(player) && arena.seekers.contains(event.getDamager())) {
|
||||
event.setCancelled(true);
|
||||
} else if (arena.playersInArena.contains(player)
|
||||
&& arena.playersInArena.contains(event
|
||||
.getDamager())
|
||||
&& !arena.seekers.contains(event.getDamager())
|
||||
&& !arena.seekers.contains(player)) {
|
||||
} else if (arena.playersInArena.contains(player) && arena.playersInArena.contains(event.getDamager())
|
||||
&& !arena.seekers.contains(event.getDamager()) && !arena.seekers.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
player.getWorld().playSound(player.getLocation(),
|
||||
Sound.HURT_FLESH, 1, 1);
|
||||
player.getWorld().playSound(player.getLocation(), Sound.HURT_FLESH, 1, 1);
|
||||
|
||||
if (event.getDamage() >= player.getHealth()) {
|
||||
player.setHealth(20);
|
||||
@ -66,90 +60,76 @@ public class OnEntityDamageByEntityEvent implements Listener {
|
||||
W.pBlock.remove(player);
|
||||
|
||||
if (!arena.seekers.contains(player)) {
|
||||
if (W.shop.getFile().get(
|
||||
damager.getName() + ".tokens") == null) {
|
||||
W.shop.getFile().set(
|
||||
damager.getName() + ".tokens",
|
||||
0);
|
||||
if (W.shop.getFile().get(damager.getName() + ".tokens") == null) {
|
||||
W.shop.getFile().set(damager.getName() + ".tokens", 0);
|
||||
W.shop.save();
|
||||
}
|
||||
int damagerTokens = W.shop.getFile()
|
||||
.getInt(damager.getName()
|
||||
+ ".tokens");
|
||||
W.shop.getFile().set(
|
||||
damager.getName() + ".tokens",
|
||||
damagerTokens + arena.killTokens);
|
||||
int damagerTokens = W.shop.getFile().getInt(damager.getName() + ".tokens");
|
||||
W.shop.getFile().set(damager.getName() + ".tokens", damagerTokens + arena.killTokens);
|
||||
W.shop.save();
|
||||
|
||||
MessageM.sendFMessage(damager,
|
||||
ConfigC.normal_addedToken,
|
||||
"amount-" + arena.killTokens);
|
||||
MessageM.sendFMessage(damager, ConfigC.normal_addedToken, "amount-" + arena.killTokens);
|
||||
|
||||
if (W.shop.getFile().get(
|
||||
player.getName() + ".tokens") == null) {
|
||||
W.shop.getFile()
|
||||
.set(player.getName()
|
||||
+ ".tokens", 0);
|
||||
if (W.shop.getFile().get(player.getName() + ".tokens") == null) {
|
||||
W.shop.getFile().set(player.getName() + ".tokens", 0);
|
||||
W.shop.save();
|
||||
}
|
||||
int playerTokens = W.shop.getFile().getInt(
|
||||
player.getName() + ".tokens");
|
||||
int playerTokens = W.shop.getFile().getInt(player.getName() + ".tokens");
|
||||
float addingTokens = ((float) arena.hidersTokenWin - (((float) arena.timer / (float) arena.gameTime) * (float) arena.hidersTokenWin));
|
||||
W.shop.getFile().set(
|
||||
player.getName() + ".tokens",
|
||||
playerTokens + (int) addingTokens);
|
||||
W.shop.getFile().set(player.getName() + ".tokens", playerTokens + (int) addingTokens);
|
||||
W.shop.save();
|
||||
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.normal_addedToken,
|
||||
"amount-" + (int) addingTokens);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_addedToken, "amount-" + (int) addingTokens);
|
||||
|
||||
arena.seekers.add(player);
|
||||
ArenaHandler
|
||||
.sendFMessage(
|
||||
arena,
|
||||
ConfigC.normal_ingameHiderDied,
|
||||
"playername-" + player.getName(),
|
||||
"killer-" + damagername);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHiderDied, "playername-" + player.getName(), "killer-" + damagername);
|
||||
|
||||
int hidercount = (arena.playersInArena.size() - arena.seekers.size());
|
||||
if ((hidercount <= 3) && (hidercount > 0)) {
|
||||
List<String> hiders = new ArrayList<String>();
|
||||
for (Player p : arena.playersInArena) {
|
||||
if (!arena.seekers.contains(p)) {
|
||||
hiders.add(p.getName());
|
||||
}
|
||||
}
|
||||
Collections.sort(hiders);
|
||||
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameHidersLeft,
|
||||
"left-" + StringUtils.join(hiders.toArray(), ", "));
|
||||
} else {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameHidersLeft,
|
||||
"left-" + hidercount);
|
||||
}
|
||||
int hidercount = (arena.playersInArena.size() - arena.seekers.size());
|
||||
if ((hidercount <= 3) && (hidercount > 0)) {
|
||||
List<String> hiders = new ArrayList<String>();
|
||||
for (Player p : arena.playersInArena) {
|
||||
if (!arena.seekers.contains(p)) {
|
||||
hiders.add(p.getName());
|
||||
}
|
||||
}
|
||||
Collections.sort(hiders);
|
||||
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHidersLeft, "left-" + StringUtils.join(hiders.toArray(), ", "));
|
||||
} else {
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHidersLeft, "left-" + hidercount);
|
||||
}
|
||||
}
|
||||
|
||||
player.getInventory().clear();
|
||||
player.updateInventory();
|
||||
|
||||
if (arena.seekers.size() >= arena.playersInArena
|
||||
.size()) {
|
||||
if (arena.seekers.size() >= arena.playersInArena.size()) {
|
||||
ArenaHandler.seekersWin(arena);
|
||||
} else {
|
||||
DisguiseAPI.undisguiseToAll(player);
|
||||
W.seekertime.put(player,
|
||||
arena.waitingTimeSeeker);
|
||||
W.seekertime.put(player, arena.waitingTimeSeeker);
|
||||
player.teleport(arena.seekersWarp);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.setWalkSpeed(0.25F);
|
||||
|
||||
// Fix for client not showing players after they join
|
||||
// Fix for client not showing players after
|
||||
// they join
|
||||
for (Player otherplayer : arena.playersInArena) {
|
||||
if (otherplayer.canSee(player)) otherplayer.showPlayer(player); // Make new player visible to others
|
||||
if (player.canSee(otherplayer)) player.showPlayer(otherplayer); // Make other players visible to new player
|
||||
if (otherplayer.canSee(player))
|
||||
otherplayer.showPlayer(player); // Make
|
||||
// new
|
||||
// player
|
||||
// visible
|
||||
// to
|
||||
// others
|
||||
if (player.canSee(otherplayer))
|
||||
player.showPlayer(otherplayer); // Make
|
||||
// other
|
||||
// players
|
||||
// visible
|
||||
// to
|
||||
// new
|
||||
// player
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
public class OnEntityDamageEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onEntityDamageEvent(EntityDamageEvent event) {
|
||||
Entity ent = event.getEntity();
|
||||
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
|
||||
public class OnFoodLevelChangeEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onFoodLevelChangeEvent(FoodLevelChangeEvent event) {
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
|
@ -22,13 +22,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class OnInventoryClickEvent implements Listener {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onInventoryClickEvent(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)
|
||||
&& !arena.seekers.contains(player)) {
|
||||
if (arena.playersInArena.contains(player) && !arena.seekers.contains(player)) {
|
||||
if (event.getSlot() == 8 || event.getSlot() == 39) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -40,140 +39,82 @@ public class OnInventoryClickEvent implements Listener {
|
||||
if (inv.getName().contains("DisguiseBlocks")) {
|
||||
if (event.getCurrentItem() != null) {
|
||||
if (!event.getCurrentItem().getType().isBlock()) {
|
||||
if (!event.getCurrentItem().getType()
|
||||
.equals(Material.FLOWER_POT_ITEM)) {
|
||||
if (!event.getCurrentItem().getType().equals(Material.FLOWER_POT_ITEM)) {
|
||||
event.setCancelled(true);
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_setNotABlock);
|
||||
MessageM.sendFMessage(player, ConfigC.error_setNotABlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Early exit if this isnt a blockhunt inventory
|
||||
if (!inv.getName().contains("BlockHunt")) return;
|
||||
|
||||
if (!inv.getName().contains("BlockHunt"))
|
||||
return;
|
||||
|
||||
if (inv.getName().startsWith("\u00A7r")) {
|
||||
if (inv.getName().equals(
|
||||
MessageM.replaceAll((String) "\u00A7r"
|
||||
+ W.config.get(ConfigC.shop_title)))) {
|
||||
if (inv.getName().equals(MessageM.replaceAll((String) "\u00A7r" + W.config.get(ConfigC.shop_title)))) {
|
||||
event.setCancelled(true);
|
||||
ItemStack item = event.getCurrentItem();
|
||||
if (W.shop.getFile().get(player.getName() + ".tokens") == null) {
|
||||
W.shop.getFile().set(player.getName() + ".tokens", 0);
|
||||
W.shop.save();
|
||||
}
|
||||
int playerTokens = W.shop.getFile().getInt(
|
||||
player.getName() + ".tokens");
|
||||
int playerTokens = W.shop.getFile().getInt(player.getName() + ".tokens");
|
||||
if (item == null)
|
||||
return;
|
||||
if (item.getType().equals(Material.AIR))
|
||||
return;
|
||||
if (item.getItemMeta().getDisplayName() == null)
|
||||
return;
|
||||
if (item.getItemMeta()
|
||||
.getDisplayName()
|
||||
.equals(MessageM
|
||||
.replaceAll(W.config.get(
|
||||
ConfigC.shop_blockChooserv1Name)
|
||||
.toString()))) {
|
||||
if (playerTokens >= (Integer) W.config
|
||||
.get(ConfigC.shop_blockChooserv1Price)) {
|
||||
W.shop.getFile().set(
|
||||
player.getName() + ".blockchooser", true);
|
||||
W.shop.getFile()
|
||||
.set(player.getName() + ".tokens",
|
||||
playerTokens
|
||||
- (Integer) W.config
|
||||
.get(ConfigC.shop_blockChooserv1Price));
|
||||
if (item.getItemMeta().getDisplayName().equals(MessageM.replaceAll(W.config.get(ConfigC.shop_blockChooserv1Name).toString()))) {
|
||||
if (playerTokens >= (Integer) W.config.get(ConfigC.shop_blockChooserv1Price)) {
|
||||
W.shop.getFile().set(player.getName() + ".blockchooser", true);
|
||||
W.shop.getFile().set(player.getName() + ".tokens", playerTokens - (Integer) W.config.get(ConfigC.shop_blockChooserv1Price));
|
||||
W.shop.save();
|
||||
MessageM.sendFMessage(
|
||||
player,
|
||||
ConfigC.normal_shopBoughtItem,
|
||||
"itemname-"
|
||||
+ W.config
|
||||
.get(ConfigC.shop_blockChooserv1Name));
|
||||
MessageM.sendFMessage(player, ConfigC.normal_shopBoughtItem, "itemname-" + W.config.get(ConfigC.shop_blockChooserv1Name));
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_shopNeedMoreTokens);
|
||||
MessageM.sendFMessage(player, ConfigC.error_shopNeedMoreTokens);
|
||||
}
|
||||
} else if (item
|
||||
.getItemMeta()
|
||||
.getDisplayName()
|
||||
.equals(MessageM.replaceAll(W.config.get(
|
||||
ConfigC.shop_BlockHuntPassv2Name)
|
||||
.toString()))) {
|
||||
if (playerTokens >= (Integer) W.config
|
||||
.get(ConfigC.shop_BlockHuntPassv2Price)) {
|
||||
if (W.shop.getFile().get(
|
||||
player.getName() + ".blockhuntpass") == null) {
|
||||
W.shop.getFile().set(
|
||||
player.getName() + ".blockhuntpass", 0);
|
||||
} else if (item.getItemMeta().getDisplayName().equals(MessageM.replaceAll(W.config.get(ConfigC.shop_BlockHuntPassv2Name).toString()))) {
|
||||
if (playerTokens >= (Integer) W.config.get(ConfigC.shop_BlockHuntPassv2Price)) {
|
||||
if (W.shop.getFile().get(player.getName() + ".blockhuntpass") == null) {
|
||||
W.shop.getFile().set(player.getName() + ".blockhuntpass", 0);
|
||||
W.shop.save();
|
||||
}
|
||||
|
||||
W.shop.getFile().set(
|
||||
player.getName() + ".blockhuntpass",
|
||||
(Integer) W.shop.getFile()
|
||||
.get(player.getName()
|
||||
+ ".blockhuntpass") + 1);
|
||||
W.shop.getFile()
|
||||
.set(player.getName() + ".tokens",
|
||||
playerTokens
|
||||
- (Integer) W.config
|
||||
.get(ConfigC.shop_BlockHuntPassv2Price));
|
||||
W.shop.getFile().set(player.getName() + ".blockhuntpass", (Integer) W.shop.getFile().get(player.getName() + ".blockhuntpass") + 1);
|
||||
W.shop.getFile().set(player.getName() + ".tokens", playerTokens - (Integer) W.config.get(ConfigC.shop_BlockHuntPassv2Price));
|
||||
W.shop.save();
|
||||
MessageM.sendFMessage(
|
||||
player,
|
||||
ConfigC.normal_shopBoughtItem,
|
||||
"itemname-"
|
||||
+ W.config
|
||||
.get(ConfigC.shop_BlockHuntPassv2Name));
|
||||
MessageM.sendFMessage(player, ConfigC.normal_shopBoughtItem, "itemname-" + W.config.get(ConfigC.shop_BlockHuntPassv2Name));
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_shopNeedMoreTokens);
|
||||
MessageM.sendFMessage(player, ConfigC.error_shopNeedMoreTokens);
|
||||
}
|
||||
}
|
||||
|
||||
InventoryHandler.openShop(player);
|
||||
} else if (inv.getName().contains(
|
||||
MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.shop_blockChooserv1Name)))) {
|
||||
} else if (inv.getName().contains(MessageM.replaceAll((String) W.config.get(ConfigC.shop_blockChooserv1Name)))) {
|
||||
event.setCancelled(true);
|
||||
if (event.getCurrentItem().getType() != Material.AIR) {
|
||||
if (event.getCurrentItem().getType().isBlock()) {
|
||||
W.choosenBlock.put(player, event.getCurrentItem());
|
||||
MessageM.sendFMessage(
|
||||
player,
|
||||
ConfigC.normal_shopChoosenBlock,
|
||||
"block-"
|
||||
+ event.getCurrentItem().getType()
|
||||
.toString()
|
||||
.replaceAll("_", "")
|
||||
.replaceAll("BLOCK", "")
|
||||
.toLowerCase());
|
||||
MessageM.sendFMessage(player, ConfigC.normal_shopChoosenBlock, "block-"
|
||||
+ event.getCurrentItem().getType().toString().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase());
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_setNotABlock);
|
||||
MessageM.sendFMessage(player, ConfigC.error_setNotABlock);
|
||||
}
|
||||
}
|
||||
} else if (inv.getName().contains(
|
||||
MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.shop_BlockHuntPassv2Name)))) {
|
||||
} else if (inv.getName().contains(MessageM.replaceAll((String) W.config.get(ConfigC.shop_BlockHuntPassv2Name)))) {
|
||||
event.setCancelled(true);
|
||||
if (event.getCurrentItem().getType() != Material.AIR) {
|
||||
if (event.getCurrentItem().getType()
|
||||
.equals(Material.WOOL)
|
||||
&& event.getCurrentItem().getDurability() == (short) 11) {
|
||||
if (event.getCurrentItem().getType().equals(Material.WOOL) && event.getCurrentItem().getDurability() == (short) 11) {
|
||||
int i = 0;
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
for (Player playerCheck : arena.playersInArena) {
|
||||
if (W.choosenSeeker.get(playerCheck) != null) {
|
||||
if (W.choosenSeeker
|
||||
.get(playerCheck) == true) {
|
||||
if (W.choosenSeeker.get(playerCheck) == true) {
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
@ -181,47 +122,30 @@ public class OnInventoryClickEvent implements Listener {
|
||||
}
|
||||
|
||||
if (i >= arena.amountSeekersOnStart) {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_shopMaxSeekersReached);
|
||||
MessageM.sendFMessage(player, ConfigC.error_shopMaxSeekersReached);
|
||||
} else {
|
||||
W.choosenSeeker.put(player, true);
|
||||
player.getInventory().setItemInHand(
|
||||
new ItemStack(Material.AIR));
|
||||
player.getInventory().setItemInHand(new ItemStack(Material.AIR));
|
||||
player.updateInventory();
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.normal_shopChoosenSeeker);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_shopChoosenSeeker);
|
||||
inv.clear();
|
||||
if (W.shop.getFile()
|
||||
.getInt(player.getName()
|
||||
+ ".blockhuntpass") == 1) {
|
||||
W.shop.getFile().set(
|
||||
player.getName()
|
||||
+ ".blockhuntpass",
|
||||
null);
|
||||
if (W.shop.getFile().getInt(player.getName() + ".blockhuntpass") == 1) {
|
||||
W.shop.getFile().set(player.getName() + ".blockhuntpass", null);
|
||||
W.shop.save();
|
||||
} else {
|
||||
W.shop.getFile()
|
||||
.set(player.getName()
|
||||
+ ".blockhuntpass",
|
||||
W.shop.getFile()
|
||||
.getInt(player
|
||||
.getName()
|
||||
+ ".blockhuntpass") - 1);
|
||||
W.shop.getFile().set(player.getName() + ".blockhuntpass", W.shop.getFile().getInt(player.getName() + ".blockhuntpass") - 1);
|
||||
W.shop.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (event.getCurrentItem().getType()
|
||||
.equals(Material.WOOL)
|
||||
&& event.getCurrentItem().getDurability() == (short) 14) {
|
||||
} else if (event.getCurrentItem().getType().equals(Material.WOOL) && event.getCurrentItem().getDurability() == (short) 14) {
|
||||
int i = 0;
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
for (Player playerCheck : arena.playersInArena) {
|
||||
if (W.choosenSeeker.get(playerCheck) != null) {
|
||||
if (W.choosenSeeker
|
||||
.get(playerCheck) == false) {
|
||||
if (W.choosenSeeker.get(playerCheck) == false) {
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
@ -229,32 +153,18 @@ public class OnInventoryClickEvent implements Listener {
|
||||
}
|
||||
|
||||
if (i >= (arena.playersInArena.size() - 1)) {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_shopMaxHidersReached);
|
||||
MessageM.sendFMessage(player, ConfigC.error_shopMaxHidersReached);
|
||||
} else {
|
||||
W.choosenSeeker.put(player, false);
|
||||
player.getInventory().setItemInHand(
|
||||
new ItemStack(Material.AIR));
|
||||
player.getInventory().setItemInHand(new ItemStack(Material.AIR));
|
||||
player.updateInventory();
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.normal_shopChoosenHiders);
|
||||
MessageM.sendFMessage(player, ConfigC.normal_shopChoosenHiders);
|
||||
inv.clear();
|
||||
if (W.shop.getFile()
|
||||
.getInt(player.getName()
|
||||
+ ".blockhuntpass") == 1) {
|
||||
W.shop.getFile().set(
|
||||
player.getName()
|
||||
+ ".blockhuntpass",
|
||||
null);
|
||||
if (W.shop.getFile().getInt(player.getName() + ".blockhuntpass") == 1) {
|
||||
W.shop.getFile().set(player.getName() + ".blockhuntpass", null);
|
||||
W.shop.save();
|
||||
} else {
|
||||
W.shop.getFile()
|
||||
.set(player.getName()
|
||||
+ ".blockhuntpass",
|
||||
W.shop.getFile()
|
||||
.getInt(player
|
||||
.getName()
|
||||
+ ".blockhuntpass") - 1);
|
||||
W.shop.getFile().set(player.getName() + ".blockhuntpass", W.shop.getFile().getInt(player.getName() + ".blockhuntpass") - 1);
|
||||
W.shop.save();
|
||||
}
|
||||
}
|
||||
@ -264,13 +174,7 @@ public class OnInventoryClickEvent implements Listener {
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
ItemStack item = event.getCurrentItem();
|
||||
String arenaname = inv
|
||||
.getItem(0)
|
||||
.getItemMeta()
|
||||
.getDisplayName()
|
||||
.replaceAll(
|
||||
MessageM.replaceAll("%NBlockHunt arena: %A"),
|
||||
"");
|
||||
String arenaname = inv.getItem(0).getItemMeta().getDisplayName().replaceAll(MessageM.replaceAll("%NBlockHunt arena: %A"), "");
|
||||
|
||||
Arena arena = null;
|
||||
for (Arena arena2 : W.arenaList) {
|
||||
@ -286,65 +190,33 @@ public class OnInventoryClickEvent implements Listener {
|
||||
if (!item.getItemMeta().hasDisplayName())
|
||||
return;
|
||||
if (item.getType().equals(Material.GOLD_NUGGET)) {
|
||||
if (item.getItemMeta().getDisplayName()
|
||||
.contains("maxPlayers")) {
|
||||
updownButton(player, item, arena,
|
||||
ArenaType.maxPlayers, arena.maxPlayers,
|
||||
Bukkit.getMaxPlayers(), 2, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName()
|
||||
.contains("minPlayers")) {
|
||||
updownButton(player, item, arena,
|
||||
ArenaType.minPlayers, arena.minPlayers,
|
||||
Bukkit.getMaxPlayers() - 1, 2, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName()
|
||||
.contains("amountSeekersOnStart")) {
|
||||
updownButton(player, item, arena,
|
||||
ArenaType.amountSeekersOnStart,
|
||||
arena.amountSeekersOnStart,
|
||||
arena.maxPlayers - 1, 1, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName()
|
||||
.contains("timeInLobbyUntilStart")) {
|
||||
updownButton(player, item, arena,
|
||||
ArenaType.timeInLobbyUntilStart,
|
||||
arena.timeInLobbyUntilStart, 1000, 5, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName()
|
||||
.contains("waitingTimeSeeker")) {
|
||||
updownButton(player, item, arena,
|
||||
ArenaType.waitingTimeSeeker,
|
||||
arena.waitingTimeSeeker, 1000, 5, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName()
|
||||
.contains("gameTime")) {
|
||||
updownButton(player, item, arena,
|
||||
ArenaType.gameTime, arena.gameTime, 1000,
|
||||
5, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName()
|
||||
.contains("timeUntilHidersSword")) {
|
||||
updownButton(player, item, arena,
|
||||
ArenaType.timeUntilHidersSword,
|
||||
arena.timeUntilHidersSword, 1000, 0, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName()
|
||||
.contains("hidersTokenWin")) {
|
||||
updownButton(player, item, arena,
|
||||
ArenaType.hidersTokenWin,
|
||||
arena.hidersTokenWin, 1000, 0, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName()
|
||||
.contains("seekersTokenWin")) {
|
||||
updownButton(player, item, arena,
|
||||
ArenaType.seekersTokenWin,
|
||||
arena.seekersTokenWin, 1000, 0, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName()
|
||||
.contains("killTokens")) {
|
||||
updownButton(player, item, arena,
|
||||
ArenaType.killTokens, arena.killTokens,
|
||||
1000, 0, 1, 1);
|
||||
if (item.getItemMeta().getDisplayName().contains("maxPlayers")) {
|
||||
updownButton(player, item, arena, ArenaType.maxPlayers, arena.maxPlayers, Bukkit.getMaxPlayers(), 2, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("minPlayers")) {
|
||||
updownButton(player, item, arena, ArenaType.minPlayers, arena.minPlayers, Bukkit.getMaxPlayers() - 1, 2, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("amountSeekersOnStart")) {
|
||||
updownButton(player, item, arena, ArenaType.amountSeekersOnStart, arena.amountSeekersOnStart, arena.maxPlayers - 1, 1, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("timeInLobbyUntilStart")) {
|
||||
updownButton(player, item, arena, ArenaType.timeInLobbyUntilStart, arena.timeInLobbyUntilStart, 1000, 5, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("waitingTimeSeeker")) {
|
||||
updownButton(player, item, arena, ArenaType.waitingTimeSeeker, arena.waitingTimeSeeker, 1000, 5, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("gameTime")) {
|
||||
updownButton(player, item, arena, ArenaType.gameTime, arena.gameTime, 1000, 5, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("timeUntilHidersSword")) {
|
||||
updownButton(player, item, arena, ArenaType.timeUntilHidersSword, arena.timeUntilHidersSword, 1000, 0, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("hidersTokenWin")) {
|
||||
updownButton(player, item, arena, ArenaType.hidersTokenWin, arena.hidersTokenWin, 1000, 0, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("seekersTokenWin")) {
|
||||
updownButton(player, item, arena, ArenaType.seekersTokenWin, arena.seekersTokenWin, 1000, 0, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("killTokens")) {
|
||||
updownButton(player, item, arena, ArenaType.killTokens, arena.killTokens, 1000, 0, 1, 1);
|
||||
}
|
||||
|
||||
save(arena);
|
||||
InventoryHandler.openPanel(player, arena.arenaName);
|
||||
|
||||
} else if (item.getType().equals(Material.BOOK)) {
|
||||
if (item.getItemMeta().getDisplayName()
|
||||
.contains("disguiseBlocks")) {
|
||||
if (item.getItemMeta().getDisplayName().contains("disguiseBlocks")) {
|
||||
InventoryHandler.openDisguiseBlocks(arena, player);
|
||||
}
|
||||
}
|
||||
@ -359,10 +231,8 @@ public class OnInventoryClickEvent implements Listener {
|
||||
ArenaHandler.loadArenas();
|
||||
}
|
||||
|
||||
public static void updownButton(Player player, ItemStack item, Arena arena,
|
||||
ArenaType at, int option, int max, int min, int add, int remove) {
|
||||
if (item.getItemMeta().getDisplayName()
|
||||
.contains((String) W.messages.get(ConfigC.button_add2))) {
|
||||
public static void updownButton(Player player, ItemStack item, Arena arena, ArenaType at, int option, int max, int min, int add, int remove) {
|
||||
if (item.getItemMeta().getDisplayName().contains((String) W.messages.get(ConfigC.button_add2))) {
|
||||
if (option < max) {
|
||||
switch (at) {
|
||||
case maxPlayers:
|
||||
@ -397,11 +267,9 @@ public class OnInventoryClickEvent implements Listener {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player, ConfigC.error_setTooHighNumber,
|
||||
"max-" + max);
|
||||
MessageM.sendFMessage(player, ConfigC.error_setTooHighNumber, "max-" + max);
|
||||
}
|
||||
} else if (item.getItemMeta().getDisplayName()
|
||||
.contains((String) W.messages.get(ConfigC.button_remove2))) {
|
||||
} else if (item.getItemMeta().getDisplayName().contains((String) W.messages.get(ConfigC.button_remove2))) {
|
||||
if (option > min) {
|
||||
switch (at) {
|
||||
case maxPlayers:
|
||||
@ -436,8 +304,7 @@ public class OnInventoryClickEvent implements Listener {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player, ConfigC.error_setTooLowNumber,
|
||||
"min-" + min);
|
||||
MessageM.sendFMessage(player, ConfigC.error_setTooLowNumber, "min-" + min);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,18 +18,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class OnInventoryCloseEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onInventoryCloseEvent(InventoryCloseEvent event) {
|
||||
Inventory inv = event.getInventory();
|
||||
if (inv.getType().equals(InventoryType.CHEST)) {
|
||||
if (inv.getName().contains("DisguiseBlocks")) {
|
||||
String arenaname = inv
|
||||
.getItem(0)
|
||||
.getItemMeta()
|
||||
.getDisplayName()
|
||||
.replaceAll(
|
||||
MessageM.replaceAll("%NDisguiseBlocks of arena: %A"),
|
||||
"");
|
||||
String arenaname = inv.getItem(0).getItemMeta().getDisplayName().replaceAll(MessageM.replaceAll("%NDisguiseBlocks of arena: %A"), "");
|
||||
|
||||
Arena arena = null;
|
||||
for (Arena arena2 : W.arenaList) {
|
||||
|
@ -15,22 +15,16 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
public class OnPlayerCommandPreprocessEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled=true)
|
||||
public void onPlayerCommandPreprocessEvent(
|
||||
PlayerCommandPreprocessEvent event) {
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
String m = event.getMessage();
|
||||
if (m.startsWith("/blockhunt") || m.startsWith("/bh")
|
||||
|| m.startsWith("/seekandfind")
|
||||
|| m.startsWith("/seekandfind") || m.startsWith("/saf")
|
||||
|| m.startsWith("/sf") || m.startsWith("/hideandseek")
|
||||
|| m.startsWith("/has") || m.startsWith("/hs")
|
||||
|| m.startsWith("/ban") || m.startsWith("/kick")
|
||||
|| m.startsWith("/tempban") || m.startsWith("/mute")
|
||||
|| m.startsWith("/reload")) {
|
||||
if (m.startsWith("/blockhunt") || m.startsWith("/bh") || m.startsWith("/seekandfind") || m.startsWith("/seekandfind") || m.startsWith("/saf")
|
||||
|| m.startsWith("/sf") || m.startsWith("/hideandseek") || m.startsWith("/has") || m.startsWith("/hs") || m.startsWith("/ban")
|
||||
|| m.startsWith("/kick") || m.startsWith("/tempban") || m.startsWith("/mute") || m.startsWith("/reload")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -40,8 +34,7 @@ public class OnPlayerCommandPreprocessEvent implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (PermissionsM
|
||||
.hasPerm(player, Permissions.allcommands, false)) {
|
||||
if (PermissionsM.hasPerm(player, Permissions.allcommands, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
|
||||
public class OnPlayerDropItemEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerDropItemEvent(PlayerDropItemEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
|
@ -31,7 +31,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class OnPlayerInteractEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerInteractEvent(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock();
|
||||
@ -40,49 +40,24 @@ public class OnPlayerInteractEvent implements Listener {
|
||||
if (item.getType() != Material.AIR) {
|
||||
if (item.getItemMeta().hasDisplayName()) {
|
||||
ItemMeta im = item.getItemMeta();
|
||||
if (im.getDisplayName().equals(
|
||||
MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.wandName)))) {
|
||||
if (im.getDisplayName().equals(MessageM.replaceAll((String) W.config.get(ConfigC.wandName)))) {
|
||||
Action action = event.getAction();
|
||||
if (event.hasBlock()) {
|
||||
LocationSerializable location = new LocationSerializable(
|
||||
event.getClickedBlock().getLocation());
|
||||
LocationSerializable location = new LocationSerializable(event.getClickedBlock().getLocation());
|
||||
if (action.equals(Action.LEFT_CLICK_BLOCK)) {
|
||||
event.setCancelled(true);
|
||||
if (W.pos1.get(player) == null
|
||||
|| !W.pos1.get(player).equals(location)) {
|
||||
MessageM.sendFMessage(
|
||||
player,
|
||||
ConfigC.normal_wandSetPosition,
|
||||
"number-1",
|
||||
"pos-%N(%A" + location.getBlockX()
|
||||
+ "%N, %A"
|
||||
+ location.getBlockY()
|
||||
+ "%N, %A"
|
||||
+ location.getBlockZ()
|
||||
+ "%N)",
|
||||
"x-" + location.getBlockX(), "y-"
|
||||
+ location.getBlockY(),
|
||||
"z-" + location.getBlockZ());
|
||||
if (W.pos1.get(player) == null || !W.pos1.get(player).equals(location)) {
|
||||
MessageM.sendFMessage(player, ConfigC.normal_wandSetPosition, "number-1",
|
||||
"pos-%N(%A" + location.getBlockX() + "%N, %A" + location.getBlockY() + "%N, %A" + location.getBlockZ() + "%N)", "x-"
|
||||
+ location.getBlockX(), "y-" + location.getBlockY(), "z-" + location.getBlockZ());
|
||||
W.pos1.put(player, location);
|
||||
}
|
||||
} else if (action.equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||
event.setCancelled(true);
|
||||
if (W.pos2.get(player) == null
|
||||
|| !W.pos2.get(player).equals(location)) {
|
||||
MessageM.sendFMessage(
|
||||
player,
|
||||
ConfigC.normal_wandSetPosition,
|
||||
"number-2",
|
||||
"pos-%N(%A" + location.getBlockX()
|
||||
+ "%N, %A"
|
||||
+ location.getBlockY()
|
||||
+ "%N, %A"
|
||||
+ location.getBlockZ()
|
||||
+ "%N)",
|
||||
"x-" + location.getBlockX(), "y-"
|
||||
+ location.getBlockY(),
|
||||
"z-" + location.getBlockZ());
|
||||
if (W.pos2.get(player) == null || !W.pos2.get(player).equals(location)) {
|
||||
MessageM.sendFMessage(player, ConfigC.normal_wandSetPosition, "number-2",
|
||||
"pos-%N(%A" + location.getBlockX() + "%N, %A" + location.getBlockY() + "%N, %A" + location.getBlockZ() + "%N)", "x-"
|
||||
+ location.getBlockX(), "y-" + location.getBlockY(), "z-" + location.getBlockZ());
|
||||
W.pos2.put(player, location);
|
||||
}
|
||||
}
|
||||
@ -94,44 +69,23 @@ public class OnPlayerInteractEvent implements Listener {
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (event.getClickedBlock() != null) {
|
||||
if (event.getClickedBlock().getType()
|
||||
.equals(Material.SIGN_POST)
|
||||
|| event.getClickedBlock().getType()
|
||||
.equals(Material.WALL_SIGN)) {
|
||||
if (SignsHandler.isSign(new LocationSerializable(event
|
||||
.getClickedBlock().getLocation()))) {
|
||||
if (event.getClickedBlock().getType().equals(Material.SIGN_POST) || event.getClickedBlock().getType().equals(Material.WALL_SIGN)) {
|
||||
if (SignsHandler.isSign(new LocationSerializable(event.getClickedBlock().getLocation()))) {
|
||||
Sign sign = (Sign) event.getClickedBlock().getState();
|
||||
if (sign.getLine(1) != null) {
|
||||
if (sign.getLine(1)
|
||||
.equals(MessageM
|
||||
.replaceAll(W.config
|
||||
.getFile()
|
||||
.getStringList(
|
||||
ConfigC.sign_LEAVE.location)
|
||||
.get(1)))) {
|
||||
if (PermissionsM.hasPerm(player,
|
||||
Permissions.joinsign, true)) {
|
||||
ArenaHandler.playerLeaveArena(player, true,
|
||||
true);
|
||||
if (sign.getLine(1).equals(MessageM.replaceAll(W.config.getFile().getStringList(ConfigC.sign_LEAVE.location).get(1)))) {
|
||||
if (PermissionsM.hasPerm(player, Permissions.joinsign, true)) {
|
||||
ArenaHandler.playerLeaveArena(player, true, true);
|
||||
}
|
||||
} else if (sign.getLine(1).equals(
|
||||
MessageM.replaceAll(W.config
|
||||
.getFile()
|
||||
.getStringList(
|
||||
ConfigC.sign_SHOP.location)
|
||||
.get(1)))) {
|
||||
if (PermissionsM.hasPerm(player,
|
||||
Permissions.shop, true)) {
|
||||
} else if (sign.getLine(1).equals(MessageM.replaceAll(W.config.getFile().getStringList(ConfigC.sign_SHOP.location).get(1)))) {
|
||||
if (PermissionsM.hasPerm(player, Permissions.shop, true)) {
|
||||
InventoryHandler.openShop(player);
|
||||
}
|
||||
} else {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (sign.getLines()[1]
|
||||
.contains(arena.arenaName)) {
|
||||
if (PermissionsM.hasPerm(player,
|
||||
Permissions.joinsign, true)) {
|
||||
ArenaHandler.playerJoinArena(
|
||||
player, arena.arenaName);
|
||||
if (sign.getLines()[1].contains(arena.arenaName)) {
|
||||
if (PermissionsM.hasPerm(player, Permissions.joinsign, true)) {
|
||||
ArenaHandler.playerJoinArena(player, arena.arenaName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -142,24 +96,12 @@ public class OnPlayerInteractEvent implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK
|
||||
|| event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
if (event.getClickedBlock().getType() != Material.AIR) {
|
||||
if (event.getClickedBlock().getType()
|
||||
.equals(Material.ENCHANTMENT_TABLE)
|
||||
|| event.getClickedBlock().getType()
|
||||
.equals(Material.WORKBENCH)
|
||||
|| event.getClickedBlock().getType()
|
||||
.equals(Material.FURNACE)
|
||||
|| event.getClickedBlock().getType()
|
||||
.equals(Material.CHEST)
|
||||
|| event.getClickedBlock().getType()
|
||||
.equals(Material.ANVIL)
|
||||
|| event.getClickedBlock().getType()
|
||||
.equals(Material.ENDER_CHEST)
|
||||
|| event.getClickedBlock().getType()
|
||||
.equals(Material.JUKEBOX)
|
||||
|| block.getFace(block).equals(Material.FIRE)) {
|
||||
if (event.getClickedBlock().getType().equals(Material.ENCHANTMENT_TABLE) || event.getClickedBlock().getType().equals(Material.WORKBENCH)
|
||||
|| event.getClickedBlock().getType().equals(Material.FURNACE) || event.getClickedBlock().getType().equals(Material.CHEST)
|
||||
|| event.getClickedBlock().getType().equals(Material.ANVIL) || event.getClickedBlock().getType().equals(Material.ENDER_CHEST)
|
||||
|| event.getClickedBlock().getType().equals(Material.JUKEBOX) || block.getFace(block).equals(Material.FIRE)) {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
@ -169,21 +111,16 @@ public class OnPlayerInteractEvent implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK
|
||||
|| event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.seekers.contains(player)) {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
if (W.hiddenLoc.get(pl) != null) {
|
||||
Block pLoc = event.getClickedBlock();
|
||||
Block moveLocBlock = W.hiddenLoc.get(pl).getBlock();
|
||||
if (moveLocBlock.getX() == pLoc.getX()
|
||||
&& moveLocBlock.getY() == pLoc.getY()
|
||||
&& moveLocBlock.getZ() == pLoc.getZ()) {
|
||||
W.moveLoc.put(pl, new Location(pl.getWorld(),
|
||||
0, 0, 0));
|
||||
pl.getWorld().playSound(player.getLocation(),
|
||||
Sound.HURT_FLESH, 1, 1);
|
||||
if (moveLocBlock.getX() == pLoc.getX() && moveLocBlock.getY() == pLoc.getY() && moveLocBlock.getZ() == pLoc.getZ()) {
|
||||
W.moveLoc.put(pl, new Location(pl.getWorld(), 0, 0, 0));
|
||||
pl.getWorld().playSound(player.getLocation(), Sound.HURT_FLESH, 1, 1);
|
||||
SolidBlockHandler.makePlayerUnsolid(pl);
|
||||
}
|
||||
}
|
||||
@ -193,58 +130,32 @@ public class OnPlayerInteractEvent implements Listener {
|
||||
}
|
||||
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)
|
||||
&& (arena.gameState.equals(ArenaState.WAITING) || arena.gameState
|
||||
.equals(ArenaState.STARTING))) {
|
||||
if (arena.playersInArena.contains(player) && (arena.gameState.equals(ArenaState.WAITING) || arena.gameState.equals(ArenaState.STARTING))) {
|
||||
event.setCancelled(true);
|
||||
ItemStack item = player.getInventory().getItemInHand();
|
||||
if (item.getType() != Material.AIR) {
|
||||
if (item.getItemMeta().getDisplayName() != null) {
|
||||
if (item.getItemMeta()
|
||||
.getDisplayName()
|
||||
.equals(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.shop_blockChooserv1Name)))) {
|
||||
Inventory blockChooser = Bukkit
|
||||
.createInventory(
|
||||
null,
|
||||
36,
|
||||
MessageM.replaceAll("\u00A7r"
|
||||
+ W.config
|
||||
.get(ConfigC.shop_blockChooserv1Name)));
|
||||
if (item.getItemMeta().getDisplayName().equals(MessageM.replaceAll((String) W.config.get(ConfigC.shop_blockChooserv1Name)))) {
|
||||
Inventory blockChooser = Bukkit.createInventory(null, 36, MessageM.replaceAll("\u00A7r" + W.config.get(ConfigC.shop_blockChooserv1Name)));
|
||||
if (arena.disguiseBlocks != null) {
|
||||
for (int i = arena.disguiseBlocks.size(); i > 0; i = i - 1) {
|
||||
blockChooser.setItem(i - 1,
|
||||
arena.disguiseBlocks.get(i - 1));
|
||||
blockChooser.setItem(i - 1, arena.disguiseBlocks.get(i - 1));
|
||||
}
|
||||
}
|
||||
|
||||
player.openInventory(blockChooser);
|
||||
}
|
||||
|
||||
if (item.getItemMeta()
|
||||
.getDisplayName()
|
||||
.equals(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.shop_BlockHuntPassv2Name)))) {
|
||||
Inventory BlockHuntPass = Bukkit
|
||||
.createInventory(
|
||||
null,
|
||||
9,
|
||||
MessageM.replaceAll("\u00A7r"
|
||||
+ W.config
|
||||
.get(ConfigC.shop_BlockHuntPassv2Name)));
|
||||
ItemStack BlockHuntPassSEEKER = new ItemStack(
|
||||
Material.WOOL, 1, (short) 11);
|
||||
ItemMeta BlockHuntPassIM = BlockHuntPassSEEKER
|
||||
.getItemMeta();
|
||||
BlockHuntPassIM.setDisplayName(MessageM
|
||||
.replaceAll("&eSEEKER"));
|
||||
if (item.getItemMeta().getDisplayName().equals(MessageM.replaceAll((String) W.config.get(ConfigC.shop_BlockHuntPassv2Name)))) {
|
||||
Inventory BlockHuntPass = Bukkit.createInventory(null, 9, MessageM.replaceAll("\u00A7r" + W.config.get(ConfigC.shop_BlockHuntPassv2Name)));
|
||||
ItemStack BlockHuntPassSEEKER = new ItemStack(Material.WOOL, 1, (short) 11);
|
||||
ItemMeta BlockHuntPassIM = BlockHuntPassSEEKER.getItemMeta();
|
||||
BlockHuntPassIM.setDisplayName(MessageM.replaceAll("&eSEEKER"));
|
||||
BlockHuntPassSEEKER.setItemMeta(BlockHuntPassIM);
|
||||
BlockHuntPass.setItem(1, BlockHuntPassSEEKER);
|
||||
|
||||
ItemStack BlockHuntPassHIDER = new ItemStack(
|
||||
Material.WOOL, 1, (short) 14);
|
||||
BlockHuntPassIM.setDisplayName(MessageM
|
||||
.replaceAll("&eHIDER"));
|
||||
ItemStack BlockHuntPassHIDER = new ItemStack(Material.WOOL, 1, (short) 14);
|
||||
BlockHuntPassIM.setDisplayName(MessageM.replaceAll("&eHIDER"));
|
||||
BlockHuntPassHIDER.setItemMeta(BlockHuntPassIM);
|
||||
BlockHuntPass.setItem(7, BlockHuntPassHIDER);
|
||||
|
||||
|
@ -15,7 +15,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class OnPlayerMoveEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerMoveEvent(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
@ -23,18 +23,12 @@ public class OnPlayerMoveEvent implements Listener {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
if (arena.gameState == ArenaState.INGAME) {
|
||||
W.moveLoc.put(player, player.getLocation());
|
||||
double maxX = Math
|
||||
.max(arena.pos1.getX(), arena.pos2.getX());
|
||||
double minX = Math
|
||||
.min(arena.pos1.getX(), arena.pos2.getX());
|
||||
double maxY = Math
|
||||
.max(arena.pos1.getY(), arena.pos2.getY());
|
||||
double minY = Math
|
||||
.min(arena.pos1.getY(), arena.pos2.getY());
|
||||
double maxZ = Math
|
||||
.max(arena.pos1.getZ(), arena.pos2.getZ());
|
||||
double minZ = Math
|
||||
.min(arena.pos1.getZ(), arena.pos2.getZ());
|
||||
double maxX = Math.max(arena.pos1.getX(), arena.pos2.getX());
|
||||
double minX = Math.min(arena.pos1.getX(), arena.pos2.getX());
|
||||
double maxY = Math.max(arena.pos1.getY(), arena.pos2.getY());
|
||||
double minY = Math.min(arena.pos1.getY(), arena.pos2.getY());
|
||||
double maxZ = Math.max(arena.pos1.getZ(), arena.pos2.getZ());
|
||||
double minZ = Math.min(arena.pos1.getZ(), arena.pos2.getZ());
|
||||
|
||||
Location loc = player.getLocation();
|
||||
if (loc.getBlockX() > maxX) {
|
||||
|
@ -14,17 +14,14 @@ import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
public class OnSignChangeEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onSignChangeEvent(SignChangeEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
String[] lines = event.getLines();
|
||||
if (lines[0] != null) {
|
||||
if (lines[0].equalsIgnoreCase("[" + BlockHunt.pdfFile.getName()
|
||||
+ "]")) {
|
||||
if (lines[0].equalsIgnoreCase("[" + BlockHunt.pdfFile.getName() + "]")) {
|
||||
if (PermissionsM.hasPerm(player, Permissions.signcreate, true)) {
|
||||
SignsHandler.createSign(event, lines,
|
||||
new LocationSerializable(event.getBlock()
|
||||
.getLocation()));
|
||||
SignsHandler.createSign(event, lines, new LocationSerializable(event.getBlock().getLocation()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,9 +31,8 @@ public class CommandM {
|
||||
public DefaultCMD CMD;
|
||||
public String usage;
|
||||
|
||||
public CommandM (String name, String label, String args, String argsalias,
|
||||
Permissions permission, ConfigC help, Boolean enabled,
|
||||
List<String> mainTABlist, DefaultCMD CMD, String usage) {
|
||||
public CommandM(String name, String label, String args, String argsalias, Permissions permission, ConfigC help, Boolean enabled, List<String> mainTABlist,
|
||||
DefaultCMD CMD, String usage) {
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.args = args;
|
||||
|
@ -35,10 +35,9 @@ public class ConfigM {
|
||||
* @param fileName
|
||||
* Name of the file.
|
||||
*/
|
||||
public ConfigM (String fileName) {
|
||||
public ConfigM(String fileName) {
|
||||
this.fileName = fileName;
|
||||
this.file = new File("plugins/" + BlockHunt.pdfFile.getName(),
|
||||
fileName + ".yml");
|
||||
this.file = new File("plugins/" + BlockHunt.pdfFile.getName(), fileName + ".yml");
|
||||
this.fileLocation = BlockHunt.pdfFile.getName();
|
||||
this.fileC = new YamlConfiguration();
|
||||
this.checkFile();
|
||||
@ -54,12 +53,10 @@ public class ConfigM {
|
||||
* @param fileLocation
|
||||
* Sub-Location of the file.
|
||||
*/
|
||||
public ConfigM (String fileName, String fileLocation) {
|
||||
public ConfigM(String fileName, String fileLocation) {
|
||||
this.fileName = fileName;
|
||||
this.file = new File("plugins/" + BlockHunt.pdfFile.getName()
|
||||
+ "/" + fileLocation, fileName + ".yml");
|
||||
this.fileLocation = BlockHunt.pdfFile.getName() + "/"
|
||||
+ fileLocation;
|
||||
this.file = new File("plugins/" + BlockHunt.pdfFile.getName() + "/" + fileLocation, fileName + ".yml");
|
||||
this.fileLocation = BlockHunt.pdfFile.getName() + "/" + fileLocation;
|
||||
this.fileC = new YamlConfiguration();
|
||||
this.checkFile();
|
||||
this.fileCS = fileC.getConfigurationSection("");
|
||||
@ -73,10 +70,7 @@ public class ConfigM {
|
||||
public static void newFiles() {
|
||||
ConfigM.setDefaults();
|
||||
for (String fileName : W.newFiles) {
|
||||
MessageM.sendMessage(
|
||||
null,
|
||||
"%TAG%WCouldn't find '%A%fileName%.yml%W' creating new one.",
|
||||
"fileName-" + fileName);
|
||||
MessageM.sendMessage(null, "%TAG%WCouldn't find '%A%fileName%.yml%W' creating new one.", "fileName-" + fileName);
|
||||
}
|
||||
|
||||
W.newFiles.clear();
|
||||
|
@ -31,15 +31,11 @@ public class MessageM {
|
||||
* Variables. Seperated with a - . Ex: "playerName-" +
|
||||
* player.getName();
|
||||
*/
|
||||
public static void sendMessage(Player player, String message,
|
||||
String... vars) {
|
||||
public static void sendMessage(Player player, String message, String... vars) {
|
||||
if (player == null) {
|
||||
Bukkit.getConsoleSender().sendMessage(
|
||||
MessageM.replaceAll(
|
||||
message.replaceAll("%player%", "Console"), vars));
|
||||
Bukkit.getConsoleSender().sendMessage(MessageM.replaceAll(message.replaceAll("%player%", "Console"), vars));
|
||||
} else {
|
||||
player.sendMessage(MessageM.replaceAll(
|
||||
message.replaceAll("%player%", player.getName()), vars));
|
||||
player.sendMessage(MessageM.replaceAll(message.replaceAll("%player%", player.getName()), vars));
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,18 +51,12 @@ public class MessageM {
|
||||
* Variables. Seperated with a - . Ex: "playerName-" +
|
||||
* player.getName();
|
||||
*/
|
||||
public static void sendFMessage(Player player, ConfigC location,
|
||||
String... vars) {
|
||||
public static void sendFMessage(Player player, ConfigC location, String... vars) {
|
||||
if (player == null) {
|
||||
Bukkit.getConsoleSender().sendMessage(
|
||||
MessageM.replaceAll(
|
||||
location.config.getFile().get(location.location)
|
||||
.toString()
|
||||
.replaceAll("%player%", "Console"), vars));
|
||||
MessageM.replaceAll(location.config.getFile().get(location.location).toString().replaceAll("%player%", "Console"), vars));
|
||||
} else {
|
||||
player.sendMessage(MessageM.replaceAll(
|
||||
location.config.getFile().get(location.location).toString()
|
||||
.replaceAll("%player%", player.getName()), vars));
|
||||
player.sendMessage(MessageM.replaceAll(location.config.getFile().get(location.location).toString().replaceAll("%player%", player.getName()), vars));
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,13 +74,10 @@ public class MessageM {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
// String pMessage = message.replaceAll("%player%",
|
||||
// player.getName());
|
||||
player.sendMessage(MessageM.replaceAll(
|
||||
message.replaceAll("%player%", player.getName()), vars));
|
||||
player.sendMessage(MessageM.replaceAll(message.replaceAll("%player%", player.getName()), vars));
|
||||
}
|
||||
// message = message.replaceAll("%player%", "Console");
|
||||
Bukkit.getConsoleSender().sendMessage(
|
||||
MessageM.replaceAll(message.replaceAll("%player%", "Console"),
|
||||
vars));
|
||||
Bukkit.getConsoleSender().sendMessage(MessageM.replaceAll(message.replaceAll("%player%", "Console"), vars));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,17 +95,11 @@ public class MessageM {
|
||||
// String pMessage =
|
||||
// location.config.getFile().get(location.location)
|
||||
// .toString().replaceAll("%player%", player.getName());
|
||||
player.sendMessage(MessageM.replaceAll(
|
||||
location.config.getFile().get(location.location).toString()
|
||||
.replaceAll("%player%", player.getName()), vars));
|
||||
player.sendMessage(MessageM.replaceAll(location.config.getFile().get(location.location).toString().replaceAll("%player%", player.getName()), vars));
|
||||
}
|
||||
// String message = location.config.getFile().get(location.location)
|
||||
// .toString().replaceAll("%player%", "Console");
|
||||
Bukkit.getConsoleSender().sendMessage(
|
||||
MessageM.replaceAll(
|
||||
location.config.getFile().get(location.location)
|
||||
.toString().replaceAll("%player%", "Console"),
|
||||
vars));
|
||||
Bukkit.getConsoleSender().sendMessage(MessageM.replaceAll(location.config.getFile().get(location.location).toString().replaceAll("%player%", "Console"), vars));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,8 +113,7 @@ public class MessageM {
|
||||
* @return
|
||||
*/
|
||||
public static String replaceAll(String message, String... vars) {
|
||||
return MessageM.replaceColours(MessageM.replaceColourVars(MessageM
|
||||
.replaceVars(message, vars)));
|
||||
return MessageM.replaceColours(MessageM.replaceColourVars(MessageM.replaceVars(message, vars)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -205,9 +185,7 @@ public class MessageM {
|
||||
}
|
||||
|
||||
public static String TAG() {
|
||||
return (String) W.config.get(ConfigC.chat_header)
|
||||
+ (String) W.config.get(ConfigC.chat_tag)
|
||||
+ (String) W.config.get(ConfigC.chat_normal);
|
||||
return (String) W.config.get(ConfigC.chat_header) + (String) W.config.get(ConfigC.chat_tag) + (String) W.config.get(ConfigC.chat_normal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,7 @@ public class PermissionsM {
|
||||
* permission.
|
||||
* @return True/False when either the player has the permission.
|
||||
*/
|
||||
public static boolean hasPerm(Player player, Permissions perm,
|
||||
Boolean message) {
|
||||
public static boolean hasPerm(Player player, Permissions perm, Boolean message) {
|
||||
PType type = perm.type;
|
||||
if (player == null) {
|
||||
return true;
|
||||
@ -91,8 +90,7 @@ public class PermissionsM {
|
||||
* permission.
|
||||
* @return True/False when either the player has the permission.
|
||||
*/
|
||||
public static boolean hasRawPerm(Player player, PType type, String perm,
|
||||
Boolean message) {
|
||||
public static boolean hasRawPerm(Player player, PType type, String perm, Boolean message) {
|
||||
if (player == null) {
|
||||
return true;
|
||||
}
|
||||
|
@ -20,29 +20,15 @@ public class PermissionsC {
|
||||
}
|
||||
|
||||
public enum Permissions {
|
||||
info ("info", PType.ALL),
|
||||
help ("help", PType.ALL),
|
||||
reload ("reload", PType.ADMIN),
|
||||
join ("join", PType.PLAYER),
|
||||
joinfull ("joinfull", PType.MODERATOR),
|
||||
joinsign ("joinsign", PType.PLAYER),
|
||||
leave ("leave", PType.PLAYER),
|
||||
list ("list", PType.PLAYER),
|
||||
shop ("shop", PType.PLAYER),
|
||||
shopblockchooser ("shop.blockchooser", PType.ADMIN),
|
||||
start ("start", PType.MODERATOR),
|
||||
create ("create", PType.ADMIN),
|
||||
set ("set", PType.MODERATOR),
|
||||
setwarp ("setwarp", PType.MODERATOR),
|
||||
signcreate ("signcreate", PType.MODERATOR),
|
||||
remove ("remove", PType.ADMIN),
|
||||
tokens ("tokens", PType.ADMIN),
|
||||
allcommands ("allcommands", PType.OP);
|
||||
info("info", PType.ALL), help("help", PType.ALL), reload("reload", PType.ADMIN), join("join", PType.PLAYER), joinfull("joinfull", PType.MODERATOR), joinsign(
|
||||
"joinsign", PType.PLAYER), leave("leave", PType.PLAYER), list("list", PType.PLAYER), shop("shop", PType.PLAYER), shopblockchooser("shop.blockchooser",
|
||||
PType.ADMIN), start("start", PType.MODERATOR), create("create", PType.ADMIN), set("set", PType.MODERATOR), setwarp("setwarp", PType.MODERATOR), signcreate(
|
||||
"signcreate", PType.MODERATOR), remove("remove", PType.ADMIN), tokens("tokens", PType.ADMIN), allcommands("allcommands", PType.OP);
|
||||
|
||||
public String perm;
|
||||
public PType type;
|
||||
|
||||
private Permissions (String perm, PType type) {
|
||||
private Permissions(String perm, PType type) {
|
||||
this.perm = perm;
|
||||
this.type = type;
|
||||
}
|
||||
|
@ -18,9 +18,7 @@ public class PlayerArenaData {
|
||||
public Collection<PotionEffect> pPotionEffects;
|
||||
public boolean pFlying;
|
||||
|
||||
public PlayerArenaData (Location pLocation, GameMode pGameMode,
|
||||
ItemStack[] pInventory, ItemStack[] pArmor, Float pEXP,
|
||||
Integer pEXPL, Double pHealth, Integer pFood,
|
||||
public PlayerArenaData(Location pLocation, GameMode pGameMode, ItemStack[] pInventory, ItemStack[] pArmor, Float pEXP, Integer pEXPL, Double pHealth, Integer pFood,
|
||||
Collection<PotionEffect> pPotionEffects, boolean pFlying) {
|
||||
this.pGameMode = pGameMode;
|
||||
this.pInventory = pInventory;
|
||||
|
@ -4,6 +4,7 @@ import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
@ -19,32 +20,30 @@ public class ScoreboardHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
Objective object = board.registerNewObjective(
|
||||
BlockHunt.cutString(arena.arenaName, 32), "dummy");
|
||||
Objective object = board.registerNewObjective(BlockHunt.cutString(arena.arenaName, 32), "dummy");
|
||||
|
||||
object.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
object.setDisplayName(BlockHunt.cutString(
|
||||
MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_title)), 32));
|
||||
Score timeleft = object.getScore(Bukkit.getOfflinePlayer(BlockHunt
|
||||
.cutString(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_timeleft)), 32)));
|
||||
object.setDisplayName(BlockHunt.cutString(MessageM.replaceAll((String) W.config.get(ConfigC.scoreboard_title)), 32));
|
||||
|
||||
String temp = BlockHunt.cutString(MessageM.replaceAll((String) W.config.get(ConfigC.scoreboard_timeleft)), 32);
|
||||
Score timeleft = object.getScore(Bukkit.getOfflinePlayer(ChatColor.RESET + temp));
|
||||
timeleft.setScore(arena.timer);
|
||||
Score seekers = object.getScore(Bukkit.getOfflinePlayer(BlockHunt
|
||||
.cutString(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_seekers)), 32)));
|
||||
|
||||
temp = BlockHunt.cutString(MessageM.replaceAll((String) W.config.get(ConfigC.scoreboard_seekers)), 32);
|
||||
Score seekers = object.getScore(Bukkit.getOfflinePlayer(ChatColor.RESET + temp));
|
||||
seekers.setScore(arena.seekers.size());
|
||||
Score hiders = object.getScore(Bukkit.getOfflinePlayer(BlockHunt
|
||||
.cutString(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_hiders)), 32)));
|
||||
|
||||
temp = BlockHunt.cutString(MessageM.replaceAll((String) W.config.get(ConfigC.scoreboard_hiders)), 32);
|
||||
Score hiders = object.getScore(Bukkit.getOfflinePlayer(ChatColor.RESET + temp));
|
||||
hiders.setScore(arena.playersInArena.size() - arena.seekers.size());
|
||||
|
||||
if (arena.gameState == ArenaState.INGAME) {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setScoreboard(board);
|
||||
}
|
||||
} else {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setScoreboard(Bukkit.getScoreboardManager()
|
||||
.getNewScoreboard());
|
||||
pl.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -54,29 +53,27 @@ public class ScoreboardHandler {
|
||||
if ((Boolean) W.config.get(ConfigC.scoreboard_enabled) == true) {
|
||||
Scoreboard board = arena.scoreboard;
|
||||
Objective object = board.getObjective(DisplaySlot.SIDEBAR);
|
||||
object.setDisplayName(BlockHunt.cutString(
|
||||
MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_title)), 32));
|
||||
Score timeleft = object.getScore(Bukkit.getOfflinePlayer(BlockHunt
|
||||
.cutString(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_timeleft)), 32)));
|
||||
object.setDisplayName(BlockHunt.cutString(MessageM.replaceAll((String) W.config.get(ConfigC.scoreboard_title)), 32));
|
||||
|
||||
String temp = BlockHunt.cutString(MessageM.replaceAll((String) W.config.get(ConfigC.scoreboard_timeleft)), 32);
|
||||
Score timeleft = object.getScore(Bukkit.getOfflinePlayer(ChatColor.RESET + temp));
|
||||
timeleft.setScore(arena.timer);
|
||||
Score seekers = object.getScore(Bukkit.getOfflinePlayer(BlockHunt
|
||||
.cutString(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_seekers)), 32)));
|
||||
|
||||
temp = BlockHunt.cutString(MessageM.replaceAll((String) W.config.get(ConfigC.scoreboard_seekers)), 32);
|
||||
Score seekers = object.getScore(Bukkit.getOfflinePlayer(ChatColor.RESET + temp));
|
||||
seekers.setScore(arena.seekers.size());
|
||||
Score hiders = object.getScore(Bukkit.getOfflinePlayer(BlockHunt
|
||||
.cutString(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_hiders)), 32)));
|
||||
|
||||
temp = BlockHunt.cutString(MessageM.replaceAll((String) W.config.get(ConfigC.scoreboard_hiders)), 32);
|
||||
Score hiders = object.getScore(Bukkit.getOfflinePlayer(ChatColor.RESET + temp));
|
||||
hiders.setScore(arena.playersInArena.size() - arena.seekers.size());
|
||||
|
||||
if (arena.gameState == ArenaState.INGAME) {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setScoreboard(board);
|
||||
}
|
||||
} else {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setScoreboard(Bukkit.getScoreboardManager()
|
||||
.getNewScoreboard());
|
||||
pl.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,26 +12,21 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
@SerializableAs("BlockHuntLocation")
|
||||
public class LocationSerializable extends Location implements
|
||||
ConfigurationSerializable {
|
||||
public LocationSerializable (World world, double x, double y, double z,
|
||||
float yaw, float pitch) {
|
||||
public class LocationSerializable extends Location implements ConfigurationSerializable {
|
||||
public LocationSerializable(World world, double x, double y, double z, float yaw, float pitch) {
|
||||
super(world, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
public LocationSerializable (Location loc) {
|
||||
super(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(),
|
||||
loc.getPitch());
|
||||
public LocationSerializable(Location loc) {
|
||||
super(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof LocationSerializable || o instanceof Location) {
|
||||
Location loc = (Location) o;
|
||||
return loc.getWorld().getName().equals(getWorld().getName())
|
||||
&& loc.getX() == getX() && loc.getY() == getY()
|
||||
&& loc.getZ() == getZ() && loc.getYaw() == getYaw()
|
||||
&& loc.getPitch() == getPitch();
|
||||
return loc.getWorld().getName().equals(getWorld().getName()) && loc.getX() == getX() && loc.getY() == getY() && loc.getZ() == getZ()
|
||||
&& loc.getYaw() == getYaw() && loc.getPitch() == getPitch();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -53,15 +48,10 @@ public class LocationSerializable extends Location implements
|
||||
public static LocationSerializable deserialize(Map<String, Object> map) {
|
||||
World w = Bukkit.getWorld((String) M.g(map, "w", ""));
|
||||
if (w == null) {
|
||||
MessageM.sendMessage(
|
||||
null,
|
||||
"%EError deserializing LocationSerializable - world not found! (%A%w%%E)",
|
||||
"w-" + w);
|
||||
MessageM.sendMessage(null, "%EError deserializing LocationSerializable - world not found! (%A%w%%E)", "w-" + w);
|
||||
return null;
|
||||
}
|
||||
return new LocationSerializable(w, (Double) M.g(map, "x", 0D),
|
||||
(Double) M.g(map, "y", 0D), (Double) M.g(map, "z", 0D),
|
||||
((Double) M.g(map, "a", 0D)).floatValue(), ((Double) M.g(map,
|
||||
"p", 0D)).floatValue());
|
||||
return new LocationSerializable(w, (Double) M.g(map, "x", 0D), (Double) M.g(map, "y", 0D), (Double) M.g(map, "z", 0D), ((Double) M.g(map, "a", 0D)).floatValue(),
|
||||
((Double) M.g(map, "p", 0D)).floatValue());
|
||||
}
|
||||
}
|
||||
|
@ -11,18 +11,15 @@ import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
public class SignsHandler {
|
||||
|
||||
public static void createSign(SignChangeEvent event, String[] lines,
|
||||
LocationSerializable location) {
|
||||
public static void createSign(SignChangeEvent event, String[] lines, LocationSerializable location) {
|
||||
if (lines[1] != null) {
|
||||
if (lines[1].equalsIgnoreCase("leave")) {
|
||||
boolean saved = false;
|
||||
int number = 1;
|
||||
while (!saved) {
|
||||
if (W.signs.getFile().get("leave_" + number) == null) {
|
||||
W.signs.getFile().set("leave_" + number + ".arenaName",
|
||||
"leave");
|
||||
W.signs.getFile().set("leave_" + number + ".location",
|
||||
location);
|
||||
W.signs.getFile().set("leave_" + number + ".arenaName", "leave");
|
||||
W.signs.getFile().set("leave_" + number + ".location", location);
|
||||
W.signs.save();
|
||||
|
||||
saved = true;
|
||||
@ -35,10 +32,8 @@ public class SignsHandler {
|
||||
int number = 1;
|
||||
while (!saved) {
|
||||
if (W.signs.getFile().get("shop_" + number) == null) {
|
||||
W.signs.getFile().set("shop_" + number + ".arenaName",
|
||||
"shop");
|
||||
W.signs.getFile().set("shop_" + number + ".location",
|
||||
location);
|
||||
W.signs.getFile().set("shop_" + number + ".arenaName", "shop");
|
||||
W.signs.getFile().set("shop_" + number + ".location", location);
|
||||
W.signs.save();
|
||||
|
||||
saved = true;
|
||||
@ -52,14 +47,9 @@ public class SignsHandler {
|
||||
if (lines[1].equals(arena.arenaName)) {
|
||||
int number = 1;
|
||||
while (!saved) {
|
||||
if (W.signs.getFile().get(
|
||||
arena.arenaName + "_" + number) == null) {
|
||||
W.signs.getFile().set(
|
||||
arena.arenaName + "_" + number
|
||||
+ ".arenaName", lines[1]);
|
||||
W.signs.getFile().set(
|
||||
arena.arenaName + "_" + number
|
||||
+ ".location", location);
|
||||
if (W.signs.getFile().get(arena.arenaName + "_" + number) == null) {
|
||||
W.signs.getFile().set(arena.arenaName + "_" + number + ".arenaName", lines[1]);
|
||||
W.signs.getFile().set(arena.arenaName + "_" + number + ".location", location);
|
||||
W.signs.save();
|
||||
|
||||
saved = true;
|
||||
@ -71,8 +61,7 @@ public class SignsHandler {
|
||||
}
|
||||
|
||||
if (!saved) {
|
||||
MessageM.sendFMessage(event.getPlayer(),
|
||||
ConfigC.error_noArena, "name-" + lines[1]);
|
||||
MessageM.sendFMessage(event.getPlayer(), ConfigC.error_noArena, "name-" + lines[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -80,9 +69,7 @@ public class SignsHandler {
|
||||
|
||||
public static void removeSign(LocationSerializable location) {
|
||||
for (String sign : W.signs.getFile().getKeys(false)) {
|
||||
LocationSerializable loc = new LocationSerializable(
|
||||
(LocationSerializable) W.signs.getFile().get(
|
||||
sign + ".location"));
|
||||
LocationSerializable loc = new LocationSerializable((LocationSerializable) W.signs.getFile().get(sign + ".location"));
|
||||
if (loc.equals(location)) {
|
||||
W.signs.getFile().set(sign, null);
|
||||
W.signs.save();
|
||||
@ -92,9 +79,7 @@ public class SignsHandler {
|
||||
|
||||
public static boolean isSign(LocationSerializable location) {
|
||||
for (String sign : W.signs.getFile().getKeys(false)) {
|
||||
LocationSerializable loc = new LocationSerializable(
|
||||
(LocationSerializable) W.signs.getFile().get(
|
||||
sign + ".location"));
|
||||
LocationSerializable loc = new LocationSerializable((LocationSerializable) W.signs.getFile().get(sign + ".location"));
|
||||
if (loc.equals(location)) {
|
||||
return true;
|
||||
}
|
||||
@ -107,34 +92,27 @@ public class SignsHandler {
|
||||
public static void updateSigns() {
|
||||
W.signs.load();
|
||||
for (String sign : W.signs.getFile().getKeys(false)) {
|
||||
LocationSerializable loc = new LocationSerializable(
|
||||
(LocationSerializable) W.signs.getFile().get(
|
||||
sign + ".location"));
|
||||
if (loc.getBlock().getType().equals(Material.SIGN_POST)
|
||||
|| loc.getBlock().getType().equals(Material.WALL_SIGN)) {
|
||||
LocationSerializable loc = new LocationSerializable((LocationSerializable) W.signs.getFile().get(sign + ".location"));
|
||||
if (loc.getBlock().getType().equals(Material.SIGN_POST) || loc.getBlock().getType().equals(Material.WALL_SIGN)) {
|
||||
Sign signblock = (Sign) loc.getBlock().getState();
|
||||
String[] lines = signblock.getLines();
|
||||
if (sign.contains("leave")) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config
|
||||
.getFile().getList(ConfigC.sign_LEAVE.location);
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getList(ConfigC.sign_LEAVE.location);
|
||||
int linecount = 0;
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock.setLine(linecount,
|
||||
MessageM.replaceAll(line));
|
||||
signblock.setLine(linecount, MessageM.replaceAll(line));
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
signblock.update();
|
||||
} else if (sign.contains("shop")) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config
|
||||
.getFile().getList(ConfigC.sign_SHOP.location);
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getList(ConfigC.sign_SHOP.location);
|
||||
int linecount = 0;
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock.setLine(linecount,
|
||||
MessageM.replaceAll(line));
|
||||
signblock.setLine(linecount, MessageM.replaceAll(line));
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
@ -144,85 +122,47 @@ public class SignsHandler {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (lines[1].endsWith(arena.arenaName)) {
|
||||
if (arena.gameState.equals(ArenaState.WAITING)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config
|
||||
.getFile().getList(
|
||||
ConfigC.sign_WAITING.location);
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getList(ConfigC.sign_WAITING.location);
|
||||
int linecount = 0;
|
||||
if (signLines != null) {
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock
|
||||
.setLine(
|
||||
linecount,
|
||||
MessageM.replaceAll(
|
||||
line,
|
||||
"arenaname-"
|
||||
+ arena.arenaName,
|
||||
"players-"
|
||||
+ arena.playersInArena
|
||||
.size(),
|
||||
"maxplayers-"
|
||||
+ arena.maxPlayers,
|
||||
"timeleft-"
|
||||
+ arena.timer));
|
||||
signblock.setLine(
|
||||
linecount,
|
||||
MessageM.replaceAll(line, "arenaname-" + arena.arenaName, "players-" + arena.playersInArena.size(), "maxplayers-"
|
||||
+ arena.maxPlayers, "timeleft-" + arena.timer));
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
}
|
||||
signblock.update();
|
||||
} else if (arena.gameState
|
||||
.equals(ArenaState.STARTING)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config
|
||||
.getFile().getList(
|
||||
ConfigC.sign_STARTING.location);
|
||||
} else if (arena.gameState.equals(ArenaState.STARTING)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getList(ConfigC.sign_STARTING.location);
|
||||
int linecount = 0;
|
||||
if (signLines != null) {
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock
|
||||
.setLine(
|
||||
linecount,
|
||||
MessageM.replaceAll(
|
||||
line,
|
||||
"arenaname-"
|
||||
+ arena.arenaName,
|
||||
"players-"
|
||||
+ arena.playersInArena
|
||||
.size(),
|
||||
"maxplayers-"
|
||||
+ arena.maxPlayers,
|
||||
"timeleft-"
|
||||
+ arena.timer));
|
||||
signblock.setLine(
|
||||
linecount,
|
||||
MessageM.replaceAll(line, "arenaname-" + arena.arenaName, "players-" + arena.playersInArena.size(), "maxplayers-"
|
||||
+ arena.maxPlayers, "timeleft-" + arena.timer));
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
}
|
||||
signblock.update();
|
||||
} else if (arena.gameState
|
||||
.equals(ArenaState.INGAME)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config
|
||||
.getFile().getList(
|
||||
ConfigC.sign_INGAME.location);
|
||||
} else if (arena.gameState.equals(ArenaState.INGAME)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getList(ConfigC.sign_INGAME.location);
|
||||
int linecount = 0;
|
||||
if (signLines != null) {
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock
|
||||
.setLine(
|
||||
linecount,
|
||||
MessageM.replaceAll(
|
||||
line,
|
||||
"arenaname-"
|
||||
+ arena.arenaName,
|
||||
"players-"
|
||||
+ arena.playersInArena
|
||||
.size(),
|
||||
"maxplayers-"
|
||||
+ arena.maxPlayers,
|
||||
"timeleft-"
|
||||
+ arena.timer));
|
||||
signblock.setLine(
|
||||
linecount,
|
||||
MessageM.replaceAll(line, "arenaname-" + arena.arenaName, "players-" + arena.playersInArena.size(), "maxplayers-"
|
||||
+ arena.maxPlayers, "timeleft-" + arena.timer));
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
|
@ -28,15 +28,12 @@ public class SolidBlockHandler {
|
||||
if (!pl.equals(player)) {
|
||||
if (W.hiddenLocWater.get(player) != null) {
|
||||
if (W.hiddenLocWater.get(player)) {
|
||||
pl.sendBlockChange(pBlock.getLocation(),
|
||||
Material.STATIONARY_WATER, (byte) 0);
|
||||
pl.sendBlockChange(pBlock.getLocation(), Material.STATIONARY_WATER, (byte) 0);
|
||||
} else {
|
||||
pl.sendBlockChange(pBlock.getLocation(), Material.AIR,
|
||||
(byte) 0);
|
||||
pl.sendBlockChange(pBlock.getLocation(), Material.AIR, (byte) 0);
|
||||
}
|
||||
} else {
|
||||
pl.sendBlockChange(pBlock.getLocation(), Material.AIR,
|
||||
(byte) 0);
|
||||
pl.sendBlockChange(pBlock.getLocation(), Material.AIR, (byte) 0);
|
||||
}
|
||||
|
||||
W.hiddenLocWater.remove(player);
|
||||
@ -50,8 +47,7 @@ public class SolidBlockHandler {
|
||||
playerShow.showPlayer(player);
|
||||
}
|
||||
|
||||
MiscDisguise disguise = new MiscDisguise(DisguiseType.FALLING_BLOCK,
|
||||
block.getTypeId(), block.getDurability());
|
||||
MiscDisguise disguise = new MiscDisguise(DisguiseType.FALLING_BLOCK, block.getTypeId(), block.getDurability());
|
||||
DisguiseAPI.disguiseToAll(player, disguise);
|
||||
|
||||
MessageM.sendFMessage(player, ConfigC.normal_ingameNoMoreSolid);
|
||||
|
@ -1,641 +0,0 @@
|
||||
/*
|
||||
* Updater for Bukkit.
|
||||
*
|
||||
* This class provides the means to safetly and easily update a plugin, or check to see if it is updated using dev.bukkit.org
|
||||
*/
|
||||
|
||||
package nl.Steffion.BlockHunt;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Check dev.bukkit.org to find updates for a given plugin, and download the
|
||||
* updates if needed.
|
||||
* <p>
|
||||
* <b>VERY, VERY IMPORTANT</b>: Because there are no standards for adding
|
||||
* auto-update toggles in your plugin's config, this system provides NO CHECK
|
||||
* WITH YOUR CONFIG to make sure the user has allowed auto-updating. <br>
|
||||
* It is a <b>BUKKIT POLICY</b> that you include a boolean value in your config
|
||||
* that prevents the auto-updater from running <b>AT ALL</b>. <br>
|
||||
* If you fail to include this option in your config, your plugin will be
|
||||
* <b>REJECTED</b> when you attempt to submit it to dev.bukkit.org.
|
||||
* <p>
|
||||
* An example of a good configuration option would be something similar to
|
||||
* 'auto-update: true' - if this value is set to false you may NOT run the
|
||||
* auto-updater. <br>
|
||||
* If you are unsure about these rules, please read the plugin submission
|
||||
* guidelines: http://goo.gl/8iU5l
|
||||
*
|
||||
* @author H31IX
|
||||
*/
|
||||
|
||||
public class Updater {
|
||||
private Plugin plugin;
|
||||
private UpdateType type;
|
||||
private String versionTitle;
|
||||
private String versionLink;
|
||||
private long totalSize; // Holds the total size of the file
|
||||
// private double downloadedSize; TODO: Holds the number of bytes downloaded
|
||||
private int sizeLine; // Used for detecting file size
|
||||
private int multiplier; // Used for determining when to broadcast download
|
||||
// updates
|
||||
private boolean announce; // Whether to announce file downloads
|
||||
private URL url; // Connecting to RSS
|
||||
private File file; // The plugin's file
|
||||
private Thread thread; // Updater thread
|
||||
private static final String DBOUrl = "http://dev.bukkit.org/bukkit-plugins/"; // Slugs
|
||||
// will
|
||||
// be
|
||||
// appended
|
||||
// to
|
||||
// this
|
||||
// to
|
||||
// get
|
||||
// to
|
||||
// the
|
||||
// project's
|
||||
// RSS
|
||||
// feed
|
||||
private String[] noUpdateTag = { "-DEV", "-PRE", "-SNAPSHOT" }; // If the
|
||||
// version
|
||||
// number
|
||||
// contains
|
||||
// one of
|
||||
// these,
|
||||
// don't
|
||||
// update.
|
||||
private static final int BYTE_SIZE = 1024; // Used for downloading files
|
||||
private String updateFolder = YamlConfiguration.loadConfiguration(
|
||||
new File("bukkit.yml")).getString("settings.update-folder"); // The
|
||||
// folder
|
||||
// that
|
||||
// downloads
|
||||
// will
|
||||
// be
|
||||
// placed
|
||||
// in
|
||||
private Updater.UpdateResult result = Updater.UpdateResult.SUCCESS; // Used
|
||||
// for
|
||||
// determining
|
||||
// the
|
||||
// outcome
|
||||
// of
|
||||
// the
|
||||
// update
|
||||
// process
|
||||
// Strings for reading RSS
|
||||
private static final String TITLE = "title";
|
||||
private static final String LINK = "link";
|
||||
private static final String ITEM = "item";
|
||||
|
||||
/**
|
||||
* Gives the dev the result of the update process. Can be obtained by called
|
||||
* getResult().
|
||||
*/
|
||||
public enum UpdateResult {
|
||||
/**
|
||||
* The updater found an update, and has readied it to be loaded the next
|
||||
* time the server restarts/reloads.
|
||||
*/
|
||||
SUCCESS,
|
||||
/**
|
||||
* The updater did not find an update, and nothing was downloaded.
|
||||
*/
|
||||
NO_UPDATE,
|
||||
/**
|
||||
* The updater found an update, but was unable to download it.
|
||||
*/
|
||||
FAIL_DOWNLOAD,
|
||||
/**
|
||||
* For some reason, the updater was unable to contact dev.bukkit.org to
|
||||
* download the file.
|
||||
*/
|
||||
FAIL_DBO,
|
||||
/**
|
||||
* When running the version check, the file on DBO did not contain the a
|
||||
* version in the format 'vVersion' such as 'v1.0'.
|
||||
*/
|
||||
FAIL_NOVERSION,
|
||||
/**
|
||||
* The slug provided by the plugin running the updater was invalid and
|
||||
* doesn't exist on DBO.
|
||||
*/
|
||||
FAIL_BADSLUG,
|
||||
/**
|
||||
* The updater found an update, but because of the UpdateType being set
|
||||
* to NO_DOWNLOAD, it wasn't downloaded.
|
||||
*/
|
||||
UPDATE_AVAILABLE
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the dev to specify the type of update that will be run.
|
||||
*/
|
||||
public enum UpdateType {
|
||||
/**
|
||||
* Run a version check, and then if the file is out of date, download
|
||||
* the newest version.
|
||||
*/
|
||||
DEFAULT,
|
||||
/**
|
||||
* Don't run a version check, just find the latest update and download
|
||||
* it.
|
||||
*/
|
||||
NO_VERSION_CHECK,
|
||||
/**
|
||||
* Get information about the version and the download size, but don't
|
||||
* actually download anything.
|
||||
*/
|
||||
NO_DOWNLOAD
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the updater
|
||||
*
|
||||
* @param plugin
|
||||
* The plugin that is checking for an update.
|
||||
* @param slug
|
||||
* The dev.bukkit.org slug of the project
|
||||
* (http://dev.bukkit.org/server-mods/SLUG_IS_HERE)
|
||||
* @param file
|
||||
* The file that the plugin is running from, get this by doing
|
||||
* this.getFile() from within your main class.
|
||||
* @param type
|
||||
* Specify the type of update this will be. See
|
||||
* {@link UpdateType}
|
||||
* @param announce
|
||||
* True if the program should announce the progress of new
|
||||
* updates in console
|
||||
*/
|
||||
public Updater (Plugin plugin, String slug, File file, UpdateType type,
|
||||
boolean announce) {
|
||||
this.plugin = plugin;
|
||||
this.type = type;
|
||||
this.announce = announce;
|
||||
this.file = file;
|
||||
try {
|
||||
// Obtain the results of the project's file feed
|
||||
url = new URL(DBOUrl + slug + "/files.rss");
|
||||
} catch (MalformedURLException ex) {
|
||||
// Invalid slug
|
||||
MessageM.sendMessage(null, "%TAG%WThe author of this plugin ("
|
||||
+ plugin.getDescription().getAuthors().get(0)
|
||||
+ ") has misconfigured their Auto Update system");
|
||||
MessageM.sendMessage(null, "%TAG%WThe project slug given ('" + slug
|
||||
+ "') is invalid. Please nag the author about this.");
|
||||
result = Updater.UpdateResult.FAIL_BADSLUG; // Bad slug! Bad!
|
||||
}
|
||||
thread = new Thread(new UpdateRunnable());
|
||||
thread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the result of the update process.
|
||||
*/
|
||||
public Updater.UpdateResult getResult() {
|
||||
waitForThread();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total bytes of the file (can only be used after running a version
|
||||
* check or a normal run).
|
||||
*/
|
||||
public long getFileSize() {
|
||||
waitForThread();
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the version string latest file avaliable online.
|
||||
*/
|
||||
public String getLatestVersionString() {
|
||||
waitForThread();
|
||||
return versionTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* As the result of Updater output depends on the thread's completion, it is
|
||||
* necessary to wait for the thread to finish before alloowing anyone to
|
||||
* check the result.
|
||||
*/
|
||||
public void waitForThread() {
|
||||
if (thread.isAlive()) {
|
||||
try {
|
||||
thread.join();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save an update from dev.bukkit.org into the server's update folder.
|
||||
*/
|
||||
private void saveFile(File folder, String file, String u) {
|
||||
if (!folder.exists()) {
|
||||
folder.mkdir();
|
||||
}
|
||||
BufferedInputStream in = null;
|
||||
FileOutputStream fout = null;
|
||||
try {
|
||||
// Download the file
|
||||
URL url = new URL(u);
|
||||
int fileLength = url.openConnection().getContentLength();
|
||||
in = new BufferedInputStream(url.openStream());
|
||||
fout = new FileOutputStream(folder.getAbsolutePath() + "/" + file);
|
||||
|
||||
byte[] data = new byte[BYTE_SIZE];
|
||||
int count;
|
||||
if (announce)
|
||||
MessageM.sendMessage(null,
|
||||
"%TAG%NAbout to download a new update: " + versionTitle);
|
||||
long downloaded = 0;
|
||||
while ((count = in.read(data, 0, BYTE_SIZE)) != -1) {
|
||||
downloaded += count;
|
||||
fout.write(data, 0, count);
|
||||
int percent = (int) (downloaded * 100 / fileLength);
|
||||
if (announce & (percent % 10 == 0)) {
|
||||
MessageM.sendMessage(null, "%TAG%NDownloading update: "
|
||||
+ percent + "% of " + fileLength + " bytes.");
|
||||
}
|
||||
}
|
||||
// Just a quick check to make sure we didn't leave any files from
|
||||
// last time...
|
||||
for (File xFile : new File("plugins/" + updateFolder).listFiles()) {
|
||||
if (xFile.getName().endsWith(".zip")) {
|
||||
xFile.delete();
|
||||
}
|
||||
}
|
||||
// Check to see if it's a zip file, if it is, unzip it.
|
||||
File dFile = new File(folder.getAbsolutePath() + "/" + file);
|
||||
if (dFile.getName().endsWith(".zip")) {
|
||||
// Unzip
|
||||
unzip(dFile.getCanonicalPath());
|
||||
}
|
||||
if (announce)
|
||||
MessageM.sendMessage(null, "%TAG%NFinished updating.");
|
||||
} catch (Exception ex) {
|
||||
MessageM.sendMessage(null,
|
||||
"%TAG%WThe auto-updater tried to download a new update, but was unsuccessful.");
|
||||
result = Updater.UpdateResult.FAIL_DOWNLOAD;
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
if (fout != null) {
|
||||
fout.close();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of Zip-File-Extractor, modified by H31IX for use with Bukkit
|
||||
*/
|
||||
private void unzip(String file) {
|
||||
try {
|
||||
File fSourceZip = new File(file);
|
||||
String zipPath = file.substring(0, file.length() - 4);
|
||||
ZipFile zipFile = new ZipFile(fSourceZip);
|
||||
Enumeration<? extends ZipEntry> e = zipFile.entries();
|
||||
while (e.hasMoreElements()) {
|
||||
ZipEntry entry = (ZipEntry) e.nextElement();
|
||||
File destinationFilePath = new File(zipPath, entry.getName());
|
||||
destinationFilePath.getParentFile().mkdirs();
|
||||
if (entry.isDirectory()) {
|
||||
continue;
|
||||
} else {
|
||||
BufferedInputStream bis = new BufferedInputStream(
|
||||
zipFile.getInputStream(entry));
|
||||
int b;
|
||||
byte buffer[] = new byte[BYTE_SIZE];
|
||||
FileOutputStream fos = new FileOutputStream(
|
||||
destinationFilePath);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(fos,
|
||||
BYTE_SIZE);
|
||||
while ((b = bis.read(buffer, 0, BYTE_SIZE)) != -1) {
|
||||
bos.write(buffer, 0, b);
|
||||
}
|
||||
bos.flush();
|
||||
bos.close();
|
||||
bis.close();
|
||||
String name = destinationFilePath.getName();
|
||||
if (name.endsWith(".jar") && pluginFile(name)) {
|
||||
destinationFilePath.renameTo(new File("plugins/"
|
||||
+ updateFolder + "/" + name));
|
||||
}
|
||||
}
|
||||
entry = null;
|
||||
destinationFilePath = null;
|
||||
}
|
||||
e = null;
|
||||
zipFile.close();
|
||||
zipFile = null;
|
||||
// Move any plugin data folders that were included to the right
|
||||
// place, Bukkit won't do this for us.
|
||||
for (File dFile : new File(zipPath).listFiles()) {
|
||||
if (dFile.isDirectory()) {
|
||||
if (pluginFile(dFile.getName())) {
|
||||
File oFile = new File("plugins/" + dFile.getName()); // Get
|
||||
// current
|
||||
// dir
|
||||
File[] contents = oFile.listFiles(); // List of existing
|
||||
// files in the
|
||||
// current dir
|
||||
for (File cFile : dFile.listFiles()) // Loop through all
|
||||
// the files in
|
||||
// the new dir
|
||||
{
|
||||
boolean found = false;
|
||||
for (File xFile : contents) // Loop through contents
|
||||
// to see if it exists
|
||||
{
|
||||
if (xFile.getName().equals(cFile.getName())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
// Move the new file into the current dir
|
||||
cFile.renameTo(new File(oFile
|
||||
.getCanonicalFile()
|
||||
+ "/"
|
||||
+ cFile.getName()));
|
||||
} else {
|
||||
// This file already exists, so we don't need it
|
||||
// anymore.
|
||||
cFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dFile.delete();
|
||||
}
|
||||
new File(zipPath).delete();
|
||||
fSourceZip.delete();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
MessageM.sendMessage(
|
||||
null,
|
||||
"%TAG%WThe auto-updater tried to unzip a new update file, but was unsuccessful.");
|
||||
result = Updater.UpdateResult.FAIL_DOWNLOAD;
|
||||
}
|
||||
new File(file).delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the name of a jar is one of the plugins currently installed,
|
||||
* used for extracting the correct files out of a zip.
|
||||
*/
|
||||
public boolean pluginFile(String name) {
|
||||
for (File file : new File("plugins").listFiles()) {
|
||||
if (file.getName().equals(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the direct download file url from the file's page.
|
||||
*/
|
||||
private String getFile(String link) {
|
||||
String download = null;
|
||||
try {
|
||||
// Open a connection to the page
|
||||
URL url = new URL(link);
|
||||
URLConnection urlConn = url.openConnection();
|
||||
InputStreamReader inStream = new InputStreamReader(
|
||||
urlConn.getInputStream());
|
||||
BufferedReader buff = new BufferedReader(inStream);
|
||||
|
||||
int counter = 0;
|
||||
String line;
|
||||
while ((line = buff.readLine()) != null) {
|
||||
counter++;
|
||||
// Search for the download link
|
||||
if (line.contains("<li class=\"user-action user-action-download\">")) {
|
||||
// Get the raw link
|
||||
download = line.split("<a href=\"")[1]
|
||||
.split("\">Download</a>")[0];
|
||||
}
|
||||
// Search for size
|
||||
else if (line.contains("<dt>Size</dt>")) {
|
||||
sizeLine = counter + 1;
|
||||
} else if (counter == sizeLine) {
|
||||
String size = line.replaceAll("<dd>", "").replaceAll(
|
||||
"</dd>", "");
|
||||
multiplier = size.contains("MiB") ? 1048576 : 1024;
|
||||
size = size.replace(" KiB", "").replace(" MiB", "");
|
||||
totalSize = (long) (Double.parseDouble(size) * multiplier);
|
||||
}
|
||||
}
|
||||
urlConn = null;
|
||||
inStream = null;
|
||||
buff.close();
|
||||
buff = null;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
MessageM.sendMessage(null,
|
||||
"%TAG%WThe auto-updater tried to contact dev.bukkit.org, but was unsuccessful.");
|
||||
result = Updater.UpdateResult.FAIL_DBO;
|
||||
return null;
|
||||
}
|
||||
return download;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the program should continue by evaluation whether the
|
||||
* plugin is already updated, or shouldn't be updated
|
||||
*/
|
||||
private boolean versionCheck(String title) {
|
||||
if (type != UpdateType.NO_VERSION_CHECK) {
|
||||
String version = plugin.getDescription().getVersion();
|
||||
if (title.split(" v").length == 2) {
|
||||
String remoteVersion = title.split(" v")[1].split(" ")[0]; // Get
|
||||
// the
|
||||
// newest
|
||||
// file's
|
||||
// version
|
||||
// number
|
||||
int remVer = -1, curVer = 0;
|
||||
try {
|
||||
remVer = calVer(remoteVersion);
|
||||
curVer = calVer(version);
|
||||
} catch (NumberFormatException nfe) {
|
||||
remVer = -1;
|
||||
}
|
||||
if (hasTag(version) || version.equalsIgnoreCase(remoteVersion)
|
||||
|| curVer >= remVer) {
|
||||
// We already have the latest version, or this build is
|
||||
// tagged for no-update
|
||||
result = Updater.UpdateResult.NO_UPDATE;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// The file's name did not contain the string 'vVersion'
|
||||
MessageM.sendMessage(null, "%TAG%WThe author of this plugin ("
|
||||
+ plugin.getDescription().getAuthors().get(0)
|
||||
+ ") has misconfigured their Auto Update system");
|
||||
MessageM.sendMessage(
|
||||
null,
|
||||
"%TAG%WFiles uploaded to BukkitDev should contain the version number, seperated from the name by a 'v', such as PluginName v1.0");
|
||||
result = Updater.UpdateResult.FAIL_NOVERSION;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to calculate the version string as an Integer
|
||||
*/
|
||||
private Integer calVer(String s) throws NumberFormatException {
|
||||
if (s.contains(".")) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
Character c = s.charAt(i);
|
||||
if (Character.isLetterOrDigit(c)) {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
return Integer.parseInt(sb.toString());
|
||||
}
|
||||
return Integer.parseInt(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate whether the version number is marked showing that it should not
|
||||
* be updated by this program
|
||||
*/
|
||||
private boolean hasTag(String version) {
|
||||
for (String string : noUpdateTag) {
|
||||
if (version.contains(string)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of RSS Reader by Vogella, modified by H31IX for use with Bukkit
|
||||
*/
|
||||
private boolean readFeed() {
|
||||
try {
|
||||
// Set header values intial to the empty string
|
||||
String title = "";
|
||||
String link = "";
|
||||
// First create a new XMLInputFactory
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
// Setup a new eventReader
|
||||
InputStream in = read();
|
||||
if (in != null) {
|
||||
XMLEventReader eventReader = inputFactory
|
||||
.createXMLEventReader(in);
|
||||
// Read the XML document
|
||||
while (eventReader.hasNext()) {
|
||||
XMLEvent event = eventReader.nextEvent();
|
||||
if (event.isStartElement()) {
|
||||
if (event.asStartElement().getName().getLocalPart()
|
||||
.equals(TITLE)) {
|
||||
event = eventReader.nextEvent();
|
||||
title = event.asCharacters().getData();
|
||||
continue;
|
||||
}
|
||||
if (event.asStartElement().getName().getLocalPart()
|
||||
.equals(LINK)) {
|
||||
event = eventReader.nextEvent();
|
||||
link = event.asCharacters().getData();
|
||||
continue;
|
||||
}
|
||||
} else if (event.isEndElement()) {
|
||||
if (event.asEndElement().getName().getLocalPart()
|
||||
.equals(ITEM)) {
|
||||
// Store the title and link of the first entry we
|
||||
// get - the first file on the list is all we need
|
||||
versionTitle = title;
|
||||
versionLink = link;
|
||||
// All done, we don't need to know about older
|
||||
// files.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (XMLStreamException e) {
|
||||
MessageM.sendMessage(null,
|
||||
"%TAG%WCould not reach dev.bukkit.org for update checking. Is it offline?");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the RSS feed
|
||||
*/
|
||||
private InputStream read() {
|
||||
try {
|
||||
return url.openStream();
|
||||
} catch (IOException e) {
|
||||
MessageM.sendMessage(
|
||||
null,
|
||||
"%TAG%WCould not reach BukkitDev file stream for update checking. Is dev.bukkit.org offline?");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class UpdateRunnable implements Runnable {
|
||||
|
||||
public void run() {
|
||||
if (url != null) {
|
||||
// Obtain the results of the project's file feed
|
||||
if (readFeed()) {
|
||||
if (versionCheck(versionTitle)) {
|
||||
String fileLink = getFile(versionLink);
|
||||
if (fileLink != null && type != UpdateType.NO_DOWNLOAD) {
|
||||
String name = file.getName();
|
||||
// If it's a zip file, it shouldn't be downloaded as
|
||||
// the plugin's name
|
||||
if (fileLink.endsWith(".zip")) {
|
||||
String[] split = fileLink.split("/");
|
||||
name = split[split.length - 1];
|
||||
}
|
||||
saveFile(new File("plugins/" + updateFolder), name,
|
||||
fileLink);
|
||||
} else {
|
||||
result = UpdateResult.UPDATE_AVAILABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,651 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2013 Tyler Blair. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and contributors and should not be interpreted as representing official policies,
|
||||
* either expressed or implied, of anybody else.
|
||||
*/
|
||||
package nl.Steffion.BlockHunt.mcstats;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* <p> The metrics class obtains data about a plugin and submits statistics about it to the metrics backend. </p> <p>
|
||||
* Public methods provided by this class: </p>
|
||||
* <code>
|
||||
* Graph createGraph(String name); <br/>
|
||||
* void addCustomData(BukkitMetrics.Plotter plotter); <br/>
|
||||
* void start(); <br/>
|
||||
* </code>
|
||||
*/
|
||||
public class Metrics {
|
||||
|
||||
/**
|
||||
* The current revision number
|
||||
*/
|
||||
private final static int REVISION = 6;
|
||||
/**
|
||||
* The base url of the metrics domain
|
||||
*/
|
||||
private static final String BASE_URL = "http://mcstats.org";
|
||||
/**
|
||||
* The url used to report a server's status
|
||||
*/
|
||||
private static final String REPORT_URL = "/report/%s";
|
||||
/**
|
||||
* The separator to use for custom data. This MUST NOT change unless you are hosting your own version of metrics and
|
||||
* want to change it.
|
||||
*/
|
||||
private static final String CUSTOM_DATA_SEPARATOR = "~~";
|
||||
/**
|
||||
* Interval of time to ping (in minutes)
|
||||
*/
|
||||
private static final int PING_INTERVAL = 10;
|
||||
/**
|
||||
* The plugin this metrics submits for
|
||||
*/
|
||||
private final Plugin plugin;
|
||||
/**
|
||||
* All of the custom graphs to submit to metrics
|
||||
*/
|
||||
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
|
||||
/**
|
||||
* The default graph, used for addCustomData when you don't want a specific graph
|
||||
*/
|
||||
private final Graph defaultGraph = new Graph("Default");
|
||||
/**
|
||||
* The plugin configuration file
|
||||
*/
|
||||
public final YamlConfiguration configuration;
|
||||
/**
|
||||
* The plugin configuration file
|
||||
*/
|
||||
private final File configurationFile;
|
||||
/**
|
||||
* Unique server id
|
||||
*/
|
||||
private final String guid;
|
||||
/**
|
||||
* Debug mode
|
||||
*/
|
||||
private final boolean debug;
|
||||
/**
|
||||
* Lock for synchronization
|
||||
*/
|
||||
private final Object optOutLock = new Object();
|
||||
/**
|
||||
* The scheduled task
|
||||
*/
|
||||
private volatile BukkitTask task = null;
|
||||
|
||||
public Metrics(final Plugin plugin) throws IOException {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
|
||||
this.plugin = plugin;
|
||||
|
||||
// load the config
|
||||
configurationFile = getConfigFile();
|
||||
configuration = YamlConfiguration.loadConfiguration(configurationFile);
|
||||
|
||||
// add some defaults
|
||||
configuration.addDefault("opt-out", false);
|
||||
configuration.addDefault("guid", UUID.randomUUID().toString());
|
||||
configuration.addDefault("debug", false);
|
||||
|
||||
// Do we need to create the file?
|
||||
if (configuration.get("guid", null) == null) {
|
||||
configuration.options().header("http://mcstats.org").copyDefaults(true);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Load the guid then
|
||||
guid = configuration.getString("guid");
|
||||
debug = configuration.getBoolean("debug", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics
|
||||
* website. Plotters can be added to the graph object returned.
|
||||
*
|
||||
* @param name The name of the graph
|
||||
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
|
||||
*/
|
||||
public Graph createGraph(final String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Graph name cannot be null");
|
||||
}
|
||||
|
||||
// Construct the graph object
|
||||
final Graph graph = new Graph(name);
|
||||
|
||||
// Now we can add our graph
|
||||
graphs.add(graph);
|
||||
|
||||
// and return back
|
||||
return graph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend
|
||||
*
|
||||
* @param graph The name of the graph
|
||||
*/
|
||||
public void addGraph(final Graph graph) {
|
||||
if (graph == null) {
|
||||
throw new IllegalArgumentException("Graph cannot be null");
|
||||
}
|
||||
|
||||
graphs.add(graph);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom data plotter to the default graph
|
||||
*
|
||||
* @param plotter The plotter to use to plot custom data
|
||||
*/
|
||||
public void addCustomData(final Plotter plotter) {
|
||||
if (plotter == null) {
|
||||
throw new IllegalArgumentException("Plotter cannot be null");
|
||||
}
|
||||
|
||||
// Add the plotter to the graph o/
|
||||
defaultGraph.addPlotter(plotter);
|
||||
|
||||
// Ensure the default graph is included in the submitted graphs
|
||||
graphs.add(defaultGraph);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send the
|
||||
* initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200
|
||||
* ticks.
|
||||
*
|
||||
* @return True if statistics measuring is running, otherwise false.
|
||||
*/
|
||||
public boolean start() {
|
||||
synchronized (optOutLock) {
|
||||
// Did we opt out?
|
||||
if (isOptOut()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is metrics already running?
|
||||
if (task != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Begin hitting the server with glorious data
|
||||
task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
|
||||
private boolean firstPost = true;
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
// This has to be synchronized or it can collide with the disable method.
|
||||
synchronized (optOutLock) {
|
||||
// Disable Task, if it is running and the server owner decided to opt-out
|
||||
if (isOptOut() && task != null) {
|
||||
task.cancel();
|
||||
task = null;
|
||||
// Tell all plotters to stop gathering information.
|
||||
for (Graph graph : graphs) {
|
||||
graph.onOptOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We use the inverse of firstPost because if it is the first time we are posting,
|
||||
// it is not a interval ping, so it evaluates to FALSE
|
||||
// Each time thereafter it will evaluate to TRUE, i.e PING!
|
||||
postPlugin(!firstPost);
|
||||
|
||||
// After the first post we set firstPost to false
|
||||
// Each post thereafter will be a ping
|
||||
firstPost = false;
|
||||
} catch (IOException e) {
|
||||
if (debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, PING_INTERVAL * 1200);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the server owner denied plugin metrics?
|
||||
*
|
||||
* @return true if metrics should be opted out of it
|
||||
*/
|
||||
public boolean isOptOut() {
|
||||
synchronized (optOutLock) {
|
||||
try {
|
||||
// Reload the metrics file
|
||||
configuration.load(getConfigFile());
|
||||
} catch (IOException ex) {
|
||||
if (debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
if (debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return configuration.getBoolean("opt-out", false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void enable() throws IOException {
|
||||
// This has to be synchronized or it can collide with the check in the task.
|
||||
synchronized (optOutLock) {
|
||||
// Check if the server owner has already set opt-out, if not, set it.
|
||||
if (isOptOut()) {
|
||||
configuration.set("opt-out", false);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Enable Task, if it is not running
|
||||
if (task == null) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void disable() throws IOException {
|
||||
// This has to be synchronized or it can collide with the check in the task.
|
||||
synchronized (optOutLock) {
|
||||
// Check if the server owner has already set opt-out, if not, set it.
|
||||
if (!isOptOut()) {
|
||||
configuration.set("opt-out", true);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Disable Task, if it is running
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
task = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the File object of the config file that should be used to store data such as the GUID and opt-out status
|
||||
*
|
||||
* @return the File object for the config file
|
||||
*/
|
||||
public File getConfigFile() {
|
||||
// I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
|
||||
// is to abuse the plugin object we already have
|
||||
// plugin.getDataFolder() => base/plugins/PluginA/
|
||||
// pluginsFolder => base/plugins/
|
||||
// The base is not necessarily relative to the startup directory.
|
||||
File pluginsFolder = plugin.getDataFolder().getParentFile();
|
||||
|
||||
// return => base/plugins/PluginMetrics/config.yml
|
||||
return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method that posts a plugin to the metrics website
|
||||
*/
|
||||
private void postPlugin(final boolean isPing) throws IOException {
|
||||
// Server software specific section
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
String pluginName = description.getName();
|
||||
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||
String pluginVersion = description.getVersion();
|
||||
String serverVersion = Bukkit.getVersion();
|
||||
int playersOnline = Bukkit.getServer().getOnlinePlayers().length;
|
||||
|
||||
// END server software specific section -- all code below does not use any code outside of this class / Java
|
||||
|
||||
// Construct the post data
|
||||
final StringBuilder data = new StringBuilder();
|
||||
|
||||
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
||||
data.append(encode("guid")).append('=').append(encode(guid));
|
||||
encodeDataPair(data, "version", pluginVersion);
|
||||
encodeDataPair(data, "server", serverVersion);
|
||||
encodeDataPair(data, "players", Integer.toString(playersOnline));
|
||||
encodeDataPair(data, "revision", String.valueOf(REVISION));
|
||||
|
||||
// New data as of R6
|
||||
String osname = System.getProperty("os.name");
|
||||
String osarch = System.getProperty("os.arch");
|
||||
String osversion = System.getProperty("os.version");
|
||||
String java_version = System.getProperty("java.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
// normalize os arch .. amd64 -> x86_64
|
||||
if (osarch.equals("amd64")) {
|
||||
osarch = "x86_64";
|
||||
}
|
||||
|
||||
encodeDataPair(data, "osname", osname);
|
||||
encodeDataPair(data, "osarch", osarch);
|
||||
encodeDataPair(data, "osversion", osversion);
|
||||
encodeDataPair(data, "cores", Integer.toString(coreCount));
|
||||
encodeDataPair(data, "online-mode", Boolean.toString(onlineMode));
|
||||
encodeDataPair(data, "java_version", java_version);
|
||||
|
||||
// If we're pinging, append it
|
||||
if (isPing) {
|
||||
encodeDataPair(data, "ping", "true");
|
||||
}
|
||||
|
||||
// Acquire a lock on the graphs, which lets us make the assumption we also lock everything
|
||||
// inside of the graph (e.g plotters)
|
||||
synchronized (graphs) {
|
||||
final Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
final Graph graph = iter.next();
|
||||
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
// The key name to send to the metrics server
|
||||
// The format is C-GRAPHNAME-PLOTTERNAME where separator - is defined at the top
|
||||
// Legacy (R4) submitters use the format Custom%s, or CustomPLOTTERNAME
|
||||
final String key = String.format("C%s%s%s%s", CUSTOM_DATA_SEPARATOR, graph.getName(), CUSTOM_DATA_SEPARATOR, plotter.getColumnName());
|
||||
|
||||
// The value to send, which for the foreseeable future is just the string
|
||||
// value of plotter.getValue()
|
||||
final String value = Integer.toString(plotter.getValue());
|
||||
|
||||
// Add it to the http post data :)
|
||||
encodeDataPair(data, key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create the url
|
||||
URL url = new URL(BASE_URL + String.format(REPORT_URL, encode(pluginName)));
|
||||
|
||||
// Connect to the website
|
||||
URLConnection connection;
|
||||
|
||||
// Mineshafter creates a socks proxy, so we can safely bypass it
|
||||
// It does not reroute POST requests so we need to go around it
|
||||
if (isMineshafterPresent()) {
|
||||
connection = url.openConnection(Proxy.NO_PROXY);
|
||||
} else {
|
||||
connection = url.openConnection();
|
||||
}
|
||||
|
||||
connection.setDoOutput(true);
|
||||
|
||||
// Write the data
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
|
||||
writer.write(data.toString());
|
||||
writer.flush();
|
||||
|
||||
// Now read the response
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
final String response = reader.readLine();
|
||||
|
||||
// close resources
|
||||
writer.close();
|
||||
reader.close();
|
||||
|
||||
if (response == null || response.startsWith("ERR")) {
|
||||
throw new IOException(response); //Throw the exception
|
||||
} else {
|
||||
// Is this the first update this hour?
|
||||
if (response.contains("OK This is your first update this hour")) {
|
||||
synchronized (graphs) {
|
||||
final Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
final Graph graph = iter.next();
|
||||
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
plotter.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
|
||||
*
|
||||
* @return true if mineshafter is installed on the server
|
||||
*/
|
||||
private boolean isMineshafterPresent() {
|
||||
try {
|
||||
Class.forName("mineshafter.MineServer");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Encode a key/value data pair to be used in a HTTP post request. This INCLUDES a & so the first key/value pair
|
||||
* MUST be included manually, e.g:</p>
|
||||
* <code>
|
||||
* StringBuffer data = new StringBuffer();
|
||||
* data.append(encode("guid")).append('=').append(encode(guid));
|
||||
* encodeDataPair(data, "version", description.getVersion());
|
||||
* </code>
|
||||
*
|
||||
* @param buffer the stringbuilder to append the data pair onto
|
||||
* @param key the key value
|
||||
* @param value the value
|
||||
*/
|
||||
private static void encodeDataPair(final StringBuilder buffer, final String key, final String value) throws UnsupportedEncodingException {
|
||||
buffer.append('&').append(encode(key)).append('=').append(encode(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode text as UTF-8
|
||||
*
|
||||
* @param text the text to encode
|
||||
* @return the encoded text, as UTF-8
|
||||
*/
|
||||
private static String encode(final String text) throws UnsupportedEncodingException {
|
||||
return URLEncoder.encode(text, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom graph on the website
|
||||
*/
|
||||
public static class Graph {
|
||||
|
||||
/**
|
||||
* The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is
|
||||
* rejected
|
||||
*/
|
||||
private final String name;
|
||||
/**
|
||||
* The set of plotters that are contained within this graph
|
||||
*/
|
||||
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
||||
|
||||
private Graph(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the graph's name
|
||||
*
|
||||
* @return the Graph's name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a plotter to the graph, which will be used to plot entries
|
||||
*
|
||||
* @param plotter the plotter to add to the graph
|
||||
*/
|
||||
public void addPlotter(final Plotter plotter) {
|
||||
plotters.add(plotter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a plotter from the graph
|
||||
*
|
||||
* @param plotter the plotter to remove from the graph
|
||||
*/
|
||||
public void removePlotter(final Plotter plotter) {
|
||||
plotters.remove(plotter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
|
||||
*
|
||||
* @return an unmodifiable {@link java.util.Set} of the plotter objects
|
||||
*/
|
||||
public Set<Plotter> getPlotters() {
|
||||
return Collections.unmodifiableSet(plotters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object) {
|
||||
if (!(object instanceof Graph)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Graph graph = (Graph) object;
|
||||
return graph.name.equals(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the server owner decides to opt-out of BukkitMetrics while the server is running.
|
||||
*/
|
||||
protected void onOptOut() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface used to collect custom data for a plugin
|
||||
*/
|
||||
public static abstract class Plotter {
|
||||
|
||||
/**
|
||||
* The plot's name
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Construct a plotter with the default plot name
|
||||
*/
|
||||
public Plotter() {
|
||||
this("Default");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a plotter with a specific plot name
|
||||
*
|
||||
* @param name the name of the plotter to use, which will show up on the website
|
||||
*/
|
||||
public Plotter(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value for the plotted point. Since this function defers to an external function it may or may
|
||||
* not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called
|
||||
* from any thread so care should be taken when accessing resources that need to be synchronized.
|
||||
*
|
||||
* @return the current value for the point to be plotted.
|
||||
*/
|
||||
public abstract int getValue();
|
||||
|
||||
/**
|
||||
* Get the column name for the plotted point
|
||||
*
|
||||
* @return the plotted point's column name
|
||||
*/
|
||||
public String getColumnName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the website graphs have been updated
|
||||
*/
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getColumnName().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object) {
|
||||
if (!(object instanceof Plotter)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Plotter plotter = (Plotter) object;
|
||||
return plotter.name.equals(name) && plotter.getValue() == getValue();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user