Improves efficiency for arena selection
This commit is contained in:
parent
ae9c614066
commit
cc0007fb1b
@ -98,7 +98,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
|
||||
// Welcome to the massive game loop!!
|
||||
getServer().getScheduler().runTaskTimer(this, () -> {
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.gameState == ArenaState.WAITING) {
|
||||
if (arena.playersInArena.size() >= arena.minPlayers) {
|
||||
arena.gameState = ArenaState.STARTING;
|
||||
@ -149,7 +149,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
seeker.getInventory().clear();
|
||||
seeker.updateInventory();
|
||||
seeker.setWalkSpeed(0.3F);
|
||||
MemoryStorage.seekertime.put(seeker, arena.waitingTimeSeeker);
|
||||
MemoryStorage.seekerTime.put(seeker, arena.waitingTimeSeeker);
|
||||
} else {
|
||||
i = i + 1;
|
||||
}
|
||||
@ -201,11 +201,11 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, 1, 1);
|
||||
}
|
||||
|
||||
if (MemoryStorage.seekertime.get(player) != null) {
|
||||
MemoryStorage.seekertime.put(player, MemoryStorage.seekertime.get(player) - 1);
|
||||
if (MemoryStorage.seekertime.get(player) <= 0) {
|
||||
if (MemoryStorage.seekerTime.get(player) != null) {
|
||||
MemoryStorage.seekerTime.put(player, MemoryStorage.seekerTime.get(player) - 1);
|
||||
if (MemoryStorage.seekerTime.get(player) <= 0) {
|
||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
||||
MemoryStorage.seekertime.remove(player);
|
||||
MemoryStorage.seekerTime.remove(player);
|
||||
ArenaHandler.sendFMessage(arena, MessageKey.NORMAL_IN_GAME_SEEKER_SPAWNED,
|
||||
"%playerName%-" + player.getName());
|
||||
}
|
||||
@ -340,7 +340,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
String cause = "[BlockHunt] Arena " + arena.arenaName + " has been stopped";
|
||||
ArenaHandler.stopArena(arena, cause, MessageKey.WARNING_ARENA_STOPPED);
|
||||
}
|
||||
|
@ -21,16 +21,10 @@ public class InventoryHandler {
|
||||
|
||||
public static void openPanel(Player player, String arenaName) {
|
||||
|
||||
Arena arena = null;
|
||||
for (Arena arena2 : MemoryStorage.arenaList) {
|
||||
if (arena2.arenaName.equalsIgnoreCase(arenaName)) {
|
||||
arena = arena2;
|
||||
}
|
||||
}
|
||||
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
||||
|
||||
if (arena != null) {
|
||||
String shorten = arena.arenaName;
|
||||
arenaName = arena.arenaName;
|
||||
if (shorten.length() > 6) {
|
||||
shorten = shorten.substring(0, 6);
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
@ -17,8 +18,8 @@ public class MemoryStorage {
|
||||
/*
|
||||
* Standard stuff.
|
||||
*/
|
||||
public static final ArrayList<String> newFiles = new ArrayList<>();
|
||||
public static final ArrayList<Command> commands = new ArrayList<>();
|
||||
public static final List<String> newFiles = new ArrayList<>();
|
||||
public static final List<Command> commands = new ArrayList<>();
|
||||
|
||||
/*
|
||||
* If you want another file to be created. Copy and paste this line.
|
||||
@ -33,21 +34,22 @@ public class MemoryStorage {
|
||||
* Add any variable you need in different classes here:
|
||||
*/
|
||||
|
||||
public static final HashMap<Player, Location> pos1 = new HashMap<>();
|
||||
public static final HashMap<Player, Location> pos2 = new HashMap<>();
|
||||
public static final Map<Player, Location> pos1 = new HashMap<>();
|
||||
public static final Map<Player, Location> pos2 = new HashMap<>();
|
||||
|
||||
public static final ArrayList<Arena> arenaList = new ArrayList<>();
|
||||
public static final Map<String, Arena> arenaMap = new HashMap<>();
|
||||
public static final Random random = new Random();
|
||||
public static final HashMap<Player, Integer> seekertime = new HashMap<>();
|
||||
public static final Map<Player, Integer> seekerTime = new HashMap<>();
|
||||
|
||||
public static final HashMap<Player, PlayerArenaData> pData = new HashMap<>();
|
||||
public static final HashMap<Player, ItemStack> chosenBlock = new HashMap<>();
|
||||
public static final HashMap<Player, Boolean> chosenSeeker = new HashMap<>();
|
||||
public static final Map<Player, PlayerArenaData> pData = new HashMap<>();
|
||||
public static final Map<Player, ItemStack> chosenBlock = new HashMap<>();
|
||||
public static final Map<Player, Boolean> chosenSeeker = new HashMap<>();
|
||||
|
||||
public static final HashMap<Player, ItemStack> pBlock = new HashMap<>();
|
||||
public static final HashMap<Player, Location> moveLoc = new HashMap<>();
|
||||
public static final HashMap<Player, Location> hiddenLoc = new HashMap<>();
|
||||
public static final HashMap<Player, Boolean> hiddenLocWater = new HashMap<>();
|
||||
public static final Map<Player, ItemStack> pBlock = new HashMap<>();
|
||||
public static final Map<Player, Location> moveLoc = new HashMap<>();
|
||||
public static final Map<Player, Location> hiddenLoc = new HashMap<>();
|
||||
public static final Map<Player, Boolean> hiddenLocWater = new HashMap<>();
|
||||
|
||||
public static final Map<Player, Location> teleportLoc = new HashMap<>();
|
||||
|
||||
}
|
||||
|
@ -21,11 +21,10 @@ public class SignsHandler {
|
||||
saveSign("shop", location);
|
||||
} else {
|
||||
boolean saved = false;
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
if (lines[1].equals(arena.arenaName)) {
|
||||
saveSign(arena.arenaName, location);
|
||||
saved = true;
|
||||
}
|
||||
Arena arena = MemoryStorage.arenaMap.get(lines[1].toLowerCase());
|
||||
if (arena != null) {
|
||||
saveSign(arena.arenaName, location);
|
||||
saved = true;
|
||||
}
|
||||
|
||||
if (!saved) {
|
||||
@ -110,7 +109,8 @@ public class SignsHandler {
|
||||
}
|
||||
|
||||
private static void drawArenaSign(String arenaName, Sign signBlock) {
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
//TODO: Store the relationships between signs and arenas directly
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
//Find the correct arena
|
||||
if (!arenaName.endsWith(arena.arenaName)) {
|
||||
continue;
|
||||
|
@ -35,12 +35,12 @@ import java.util.logging.Level;
|
||||
public class ArenaHandler {
|
||||
|
||||
public static void loadArenas() {
|
||||
MemoryStorage.arenaList.clear();
|
||||
MemoryStorage.arenaMap.clear();
|
||||
for (String arenaName : MemoryStorage.arenas.getFile().getKeys(false)) {
|
||||
MemoryStorage.arenaList.add((Arena) MemoryStorage.arenas.getFile().get(arenaName));
|
||||
MemoryStorage.arenaMap.put(arenaName.toLowerCase(), (Arena) MemoryStorage.arenas.getFile().get(arenaName));
|
||||
}
|
||||
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
ScoreboardHandler.createScoreboard(arena);
|
||||
}
|
||||
}
|
||||
@ -64,9 +64,9 @@ public class ArenaHandler {
|
||||
}
|
||||
|
||||
public static void playerJoinArena(Player player, String arenaName) {
|
||||
boolean found = false;
|
||||
boolean found;
|
||||
boolean alreadyJoined = false;
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena != null && arena.playersInArena.contains(player)) {
|
||||
alreadyJoined = true;
|
||||
break;
|
||||
@ -78,11 +78,8 @@ public class ArenaHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
if (!arena.arenaName.equalsIgnoreCase(arenaName)) {
|
||||
continue;
|
||||
}
|
||||
found = true;
|
||||
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
||||
if (arena != null) {
|
||||
if (arena.disguiseBlocks.isEmpty()) {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_JOIN_NO_BLOCKS_SET);
|
||||
} else {
|
||||
@ -232,9 +229,7 @@ public class ArenaHandler {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_JOIN_WARPS_NOT_SET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
} else {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_NO_ARENA, "name-" + arenaName);
|
||||
}
|
||||
|
||||
@ -244,7 +239,7 @@ public class ArenaHandler {
|
||||
public static void playerLeaveArena(Player player, boolean message, boolean cleanup) {
|
||||
|
||||
Arena arena = null;
|
||||
for (Arena arena2 : MemoryStorage.arenaList) {
|
||||
for (Arena arena2 : MemoryStorage.arenaMap.values()) {
|
||||
if (arena2.playersInArena != null) {
|
||||
if (arena2.playersInArena.contains(player)) {
|
||||
arena = arena2;
|
||||
@ -291,7 +286,7 @@ public class ArenaHandler {
|
||||
seeker.getInventory().clear();
|
||||
arena.seekers.add(seeker);
|
||||
PlayerHandler.teleport(seeker, arena.seekersWarp);
|
||||
MemoryStorage.seekertime.put(seeker, arena.waitingTimeSeeker);
|
||||
MemoryStorage.seekerTime.put(seeker, arena.waitingTimeSeeker);
|
||||
seeker.setWalkSpeed(0.3F);
|
||||
|
||||
// Fix for client not showing players after they join
|
||||
@ -463,7 +458,7 @@ public class ArenaHandler {
|
||||
|
||||
public static boolean noPlayersInArenas() {
|
||||
// Check if there are any players in any arena (quick way to early exit for event handlers)
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.size() > 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class CreateCommand extends DefaultCommand {
|
||||
MemoryStorage.arenas.save();
|
||||
MemoryStorage.signs.load();
|
||||
|
||||
MemoryStorage.arenaList.add(arena);
|
||||
MemoryStorage.arenaMap.put(args[1].toLowerCase(), arena);
|
||||
ScoreboardHandler.createScoreboard(arena);
|
||||
|
||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_CREATE_CREATED_ARENA, "name-" + args[1]);
|
||||
|
@ -12,9 +12,9 @@ public class ListCommand extends DefaultCommand {
|
||||
@Override
|
||||
public boolean execute(Player player, String[] args) {
|
||||
MessageManager.sendFMessage(player, ConfigKey.CHAT_HEADER_HIGH, "header-" + BlockHunt.getPluginDescriptionFile().getName());
|
||||
if (MemoryStorage.arenaList.size() >= 1) {
|
||||
if (MemoryStorage.arenaMap.size() >= 1) {
|
||||
MessageManager.sendMessage(player, "&7Available arena(s):");
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
MessageManager.sendMessage(player, "%A" + arena.arenaName);
|
||||
}
|
||||
} else {
|
||||
|
@ -20,7 +20,7 @@ public class ReloadCommand extends DefaultCommand {
|
||||
MemoryStorage.arenas.load();
|
||||
MemoryStorage.signs.load();
|
||||
MemoryStorage.shop.load();
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
String cause = "[BlockHunt] Arena " + arena.arenaName + " has been stopped";
|
||||
ArenaHandler.stopArena(arena, cause, MessageKey.WARNING_ARENA_STOPPED);
|
||||
}
|
||||
|
@ -20,26 +20,25 @@ public class RemoveCommand extends DefaultCommand {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_NOT_ENOUGH_ARGUMENTS, "syntax-" +
|
||||
CommandManager.getRemoveCommand().usage());
|
||||
} else {
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
if (args[1].equalsIgnoreCase(arena.arenaName)) {
|
||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_REMOVE_REMOVED_ARENA, "name-" + args[1]);
|
||||
MemoryStorage.arenas.getFile().set(args[1], null);
|
||||
for (String sign : MemoryStorage.signs.getFile().getKeys(false)) {
|
||||
if (MemoryStorage.signs.getFile().get(sign + ".arenaName").toString().equalsIgnoreCase(args[1])) {
|
||||
Location signLoc = (Location) MemoryStorage.signs.getFile().get(sign + ".location");
|
||||
signLoc.getBlock().setType(Material.AIR);
|
||||
signLoc.getWorld().playEffect(signLoc, Effect.MOBSPAWNER_FLAMES, 0);
|
||||
signLoc.getWorld().playSound(signLoc, Sound.ENTITY_ENDER_DRAGON_FLAP, 1, 1);
|
||||
MemoryStorage.signs.getFile().set(sign, null);
|
||||
}
|
||||
Arena arena = MemoryStorage.arenaMap.get(args[1].toLowerCase());
|
||||
if (arena != null) {
|
||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_REMOVE_REMOVED_ARENA, "name-" + args[1]);
|
||||
MemoryStorage.arenas.getFile().set(args[1], null);
|
||||
for (String sign : MemoryStorage.signs.getFile().getKeys(false)) {
|
||||
if (MemoryStorage.signs.getFile().get(sign + ".arenaName").toString().equalsIgnoreCase(args[1])) {
|
||||
Location signLoc = (Location) MemoryStorage.signs.getFile().get(sign + ".location");
|
||||
signLoc.getBlock().setType(Material.AIR);
|
||||
signLoc.getWorld().playEffect(signLoc, Effect.MOBSPAWNER_FLAMES, 0);
|
||||
signLoc.getWorld().playSound(signLoc, Sound.ENTITY_ENDER_DRAGON_FLAP, 1, 1);
|
||||
MemoryStorage.signs.getFile().set(sign, null);
|
||||
}
|
||||
|
||||
MemoryStorage.arenas.save();
|
||||
MemoryStorage.signs.load();
|
||||
|
||||
MemoryStorage.arenaList.remove(arena);
|
||||
return true;
|
||||
}
|
||||
|
||||
MemoryStorage.arenas.save();
|
||||
MemoryStorage.signs.load();
|
||||
|
||||
MemoryStorage.arenaMap.remove(arena.arenaName.toLowerCase());
|
||||
return true;
|
||||
}
|
||||
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_NO_ARENA, "name-" + args[1]);
|
||||
|
@ -21,12 +21,7 @@ public class SetWarpCommand extends DefaultCommand {
|
||||
String arenaName = args[2];
|
||||
String warpname = args[1];
|
||||
|
||||
Arena arena = null;
|
||||
for (Arena arena2 : MemoryStorage.arenaList) {
|
||||
if (arena2.arenaName.equalsIgnoreCase(arenaName)) {
|
||||
arena = arena2;
|
||||
}
|
||||
}
|
||||
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
||||
if (arena != null) {
|
||||
Location loc = player.getLocation();
|
||||
if (warpname.equalsIgnoreCase("lobby")) {
|
||||
@ -63,4 +58,5 @@ public class SetWarpCommand extends DefaultCommand {
|
||||
MemoryStorage.arenas.save();
|
||||
ArenaHandler.loadArenas();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,12 +17,7 @@ public class StartCommand extends DefaultCommand {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_NOT_ENOUGH_ARGUMENTS, "syntax-" +
|
||||
CommandManager.getStartCommand().usage());
|
||||
} else {
|
||||
Arena arena = null;
|
||||
for (Arena arena2 : MemoryStorage.arenaList) {
|
||||
if (arena2.arenaName.equalsIgnoreCase(args[1])) {
|
||||
arena = arena2;
|
||||
}
|
||||
}
|
||||
Arena arena = MemoryStorage.arenaMap.get(args[1].toLowerCase());
|
||||
|
||||
if (arena != null) {
|
||||
if (arena.gameState.equals(ArenaState.WAITING)) {
|
||||
|
@ -19,7 +19,7 @@ public class OnBlockBreakEvent implements Listener {
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class OnBlockPlaceEvent implements Listener {
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class OnEntityDamageByEntityEvent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
if (arena.gameState == ArenaState.WAITING || arena.gameState == ArenaState.STARTING) {
|
||||
// Always cancel damage when players are waiting
|
||||
@ -150,7 +150,7 @@ public class OnEntityDamageByEntityEvent implements Listener {
|
||||
ArenaHandler.seekersWin(arena);
|
||||
} else {
|
||||
DisguiseAPI.undisguiseToAll(player);
|
||||
MemoryStorage.seekertime.put(player, arena.waitingTimeSeeker);
|
||||
MemoryStorage.seekerTime.put(player, arena.waitingTimeSeeker);
|
||||
PlayerHandler.teleport(player, arena.seekersWarp);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.setWalkSpeed(0.3F);
|
||||
|
@ -23,7 +23,7 @@ public class OnEntityDamageEvent implements Listener {
|
||||
Entity ent = event.getEntity();
|
||||
if (ent instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
DamageCause cause = event.getCause();
|
||||
switch (cause) {
|
||||
|
@ -14,7 +14,7 @@ public class OnFoodLevelChangeEvent implements Listener {
|
||||
public void onFoodLevelChangeEvent(FoodLevelChangeEvent event) {
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class OnInventoryClickEvent implements Listener {
|
||||
public void onInventoryClickEvent(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -35,202 +35,192 @@ public class OnInventoryClickEvent implements Listener {
|
||||
|
||||
Inventory inv = event.getInventory();
|
||||
InventoryView invView = event.getView();
|
||||
if (inv.getType().equals(InventoryType.CHEST)) {
|
||||
if (invView.getTitle().contains("DisguiseBlocks")) {
|
||||
if (event.getCurrentItem() != null) {
|
||||
if (!event.getCurrentItem().getType().isBlock()) {
|
||||
if (!event.getCurrentItem().getType().equals(Material.FLOWER_POT)) {
|
||||
event.setCancelled(true);
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_SET_NOT_A_BLOCK);
|
||||
|
||||
if (!inv.getType().equals(InventoryType.CHEST)) {
|
||||
return;
|
||||
}
|
||||
if (invView.getTitle().contains("DisguiseBlocks")) {
|
||||
if (event.getCurrentItem() != null && !event.getCurrentItem().getType().isBlock() &&
|
||||
!event.getCurrentItem().getType().equals(Material.FLOWER_POT)) {
|
||||
event.setCancelled(true);
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_SET_NOT_A_BLOCK);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Early exit if this isn't a block-hunt inventory
|
||||
if (!invView.getTitle().contains("BlockHunt")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!invView.getTitle().startsWith("\u00A7r")) {
|
||||
return;
|
||||
}
|
||||
if (invView.getTitle().equals(MessageManager.replaceAll("\u00A7r" + MemoryStorage.config.get(ConfigKey.SHOP_TITLE)))) {
|
||||
event.setCancelled(true);
|
||||
ItemStack item = event.getCurrentItem();
|
||||
if (MemoryStorage.shop.getFile().get(player.getName() + ".tokens") == null) {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".tokens", 0);
|
||||
MemoryStorage.shop.save();
|
||||
}
|
||||
int playerTokens = MemoryStorage.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(MessageManager.replaceAll(MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_NAME).toString()))) {
|
||||
if (playerTokens >= (Integer) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_PRICE)) {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".blockchooser", true);
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".tokens", playerTokens - (Integer) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_PRICE));
|
||||
MemoryStorage.shop.save();
|
||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_SHOP_BOUGHT_ITEM, "itemName-" + MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_NAME));
|
||||
} else {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_SHOP_NEED_MORE_TOKENS);
|
||||
}
|
||||
} else if (item.getItemMeta().getDisplayName().equals(MessageManager.replaceAll(MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_NAME).toString()))) {
|
||||
if (playerTokens >= (Integer) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_PRICE)) {
|
||||
if (MemoryStorage.shop.getFile().get(player.getName() + ".blockhuntpass") == null) {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".blockhuntpass", 0);
|
||||
MemoryStorage.shop.save();
|
||||
}
|
||||
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".blockhuntpass", (Integer) MemoryStorage.shop.getFile().get(player.getName() + ".blockhuntpass") + 1);
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".tokens", playerTokens - (Integer) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_PRICE));
|
||||
MemoryStorage.shop.save();
|
||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_SHOP_BOUGHT_ITEM, "itemName-" + MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_NAME));
|
||||
} else {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_SHOP_NEED_MORE_TOKENS);
|
||||
}
|
||||
}
|
||||
|
||||
InventoryHandler.openShop(player);
|
||||
} else if (invView.getTitle().contains(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_NAME)))) {
|
||||
event.setCancelled(true);
|
||||
if (event.getCurrentItem() != null) {
|
||||
if (event.getCurrentItem().getType().isBlock()) {
|
||||
MemoryStorage.chosenBlock.put(player, event.getCurrentItem());
|
||||
String blockName = event.getCurrentItem().getType().name();
|
||||
blockName = WordUtils.capitalizeFully(blockName.replace("_", " "));
|
||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_SHOP_CHOSEN_BLOCK, "block-"
|
||||
+ blockName);
|
||||
} else {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_SET_NOT_A_BLOCK);
|
||||
}
|
||||
}
|
||||
} else if (invView.getTitle().contains(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_NAME)))) {
|
||||
event.setCancelled(true);
|
||||
if (event.getCurrentItem() != null) {
|
||||
if (event.getCurrentItem().getType().equals(Material.BLUE_WOOL)) {
|
||||
int i = 0;
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
for (Player playerCheck : arena.playersInArena) {
|
||||
if (MemoryStorage.chosenSeeker.get(playerCheck) != null) {
|
||||
if (MemoryStorage.chosenSeeker.get(playerCheck)) {
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= arena.amountSeekersOnStart) {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_SHOP_MAX_SEEKERS_REACHED);
|
||||
} else {
|
||||
MemoryStorage.chosenSeeker.put(player, true);
|
||||
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
player.updateInventory();
|
||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_SHOP_CHOSEN_SEEKER);
|
||||
inv.clear();
|
||||
if (MemoryStorage.shop.getFile().getInt(player.getName() + ".blockhuntpass") == 1) {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".blockhuntpass", null);
|
||||
MemoryStorage.shop.save();
|
||||
} else {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".blockhuntpass", MemoryStorage.shop.getFile().getInt(player.getName() + ".blockhuntpass") - 1);
|
||||
MemoryStorage.shop.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (event.getCurrentItem().getType().equals(Material.RED_WOOL)) {
|
||||
int i = 0;
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
for (Player playerCheck : arena.playersInArena) {
|
||||
if (MemoryStorage.chosenSeeker.get(playerCheck) != null) {
|
||||
if (!MemoryStorage.chosenSeeker.get(playerCheck)) {
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= (arena.playersInArena.size() - 1)) {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_SHOP_MAX_HIDERS_REACHED);
|
||||
} else {
|
||||
MemoryStorage.chosenSeeker.put(player, false);
|
||||
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
player.updateInventory();
|
||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_SHOP_CHOSEN_HIDERS);
|
||||
inv.clear();
|
||||
if (MemoryStorage.shop.getFile().getInt(player.getName() + ".blockhuntpass") == 1) {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".blockhuntpass", null);
|
||||
MemoryStorage.shop.save();
|
||||
} else {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".blockhuntpass", MemoryStorage.shop.getFile().getInt(player.getName() + ".blockhuntpass") - 1);
|
||||
MemoryStorage.shop.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
ItemStack item = event.getCurrentItem();
|
||||
String arenaName = inv.getItem(0).getItemMeta().getDisplayName().replaceAll(MessageManager.replaceAll("%NBlockHunt arena: %A"), "");
|
||||
|
||||
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
||||
|
||||
if (item == null || item.getType().equals(Material.AIR) || item.getItemMeta() == null ||
|
||||
!item.getItemMeta().hasDisplayName()) {
|
||||
return;
|
||||
}
|
||||
if (item.getType().equals(Material.GOLD_NUGGET)) {
|
||||
if (item.getItemMeta().getDisplayName().contains("maxPlayers")) {
|
||||
upDownButton(player, item, arena, ArenaProperty.MAX_PLAYERS, arena.maxPlayers, Bukkit.getMaxPlayers(), 2, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("minPlayers")) {
|
||||
upDownButton(player, item, arena, ArenaProperty.MIN_PLAYERS, arena.minPlayers, Bukkit.getMaxPlayers() - 1, 2, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("amountSeekersOnStart")) {
|
||||
upDownButton(player, item, arena, ArenaProperty.AMOUNT_SEEKERS_ON_START, arena.amountSeekersOnStart, arena.maxPlayers - 1, 1, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("timeInLobbyUntilStart")) {
|
||||
upDownButton(player, item, arena, ArenaProperty.TIME_IN_LOBBY_UNTIL_START, arena.timeInLobbyUntilStart, 1000, 5, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("waitingTimeSeeker")) {
|
||||
upDownButton(player, item, arena, ArenaProperty.WAITING_TIME_SEEKER, arena.waitingTimeSeeker, 1000, 5, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("gameTime")) {
|
||||
upDownButton(player, item, arena, ArenaProperty.GAME_TIME, arena.gameTime, 1000, 5, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("blockAnnouncerTime")) {
|
||||
upDownButton(player, item, arena, ArenaProperty.BLOCK_ANNOUNCER_TIME, arena.blockAnnouncerTime, 1000, 0, 5, 5);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("timeUntilHidersSword")) {
|
||||
upDownButton(player, item, arena, ArenaProperty.TIME_UNTIL_HIDERS_SWORD, arena.timeUntilHidersSword, 1000, 0, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("hidersTokenWin")) {
|
||||
upDownButton(player, item, arena, ArenaProperty.HIDERS_TOKEN_WIN, arena.hidersTokenWin, 1000, 0, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("seekersTokenWin")) {
|
||||
upDownButton(player, item, arena, ArenaProperty.SEEKERS_TOKEN_WIN, arena.seekersTokenWin, 1000, 0, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("killTokens")) {
|
||||
upDownButton(player, item, arena, ArenaProperty.KILL_TOKENS, arena.killTokens, 1000, 0, 1, 1);
|
||||
}
|
||||
|
||||
// Early exit if this isn't a block-hunt inventory
|
||||
if (!invView.getTitle().contains("BlockHunt")) {
|
||||
return;
|
||||
}
|
||||
save(arena);
|
||||
InventoryHandler.openPanel(player, arena.arenaName);
|
||||
|
||||
if (invView.getTitle().startsWith("\u00A7r")) {
|
||||
if (invView.getTitle().equals(MessageManager.replaceAll("\u00A7r" + MemoryStorage.config.get(ConfigKey.SHOP_TITLE)))) {
|
||||
event.setCancelled(true);
|
||||
ItemStack item = event.getCurrentItem();
|
||||
if (MemoryStorage.shop.getFile().get(player.getName() + ".tokens") == null) {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".tokens", 0);
|
||||
MemoryStorage.shop.save();
|
||||
}
|
||||
int playerTokens = MemoryStorage.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(MessageManager.replaceAll(MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_NAME).toString()))) {
|
||||
if (playerTokens >= (Integer) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_PRICE)) {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".blockchooser", true);
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".tokens", playerTokens - (Integer) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_PRICE));
|
||||
MemoryStorage.shop.save();
|
||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_SHOP_BOUGHT_ITEM, "itemName-" + MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_NAME));
|
||||
} else {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_SHOP_NEED_MORE_TOKENS);
|
||||
}
|
||||
} else if (item.getItemMeta().getDisplayName().equals(MessageManager.replaceAll(MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_NAME).toString()))) {
|
||||
if (playerTokens >= (Integer) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_PRICE)) {
|
||||
if (MemoryStorage.shop.getFile().get(player.getName() + ".blockhuntpass") == null) {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".blockhuntpass", 0);
|
||||
MemoryStorage.shop.save();
|
||||
}
|
||||
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".blockhuntpass", (Integer) MemoryStorage.shop.getFile().get(player.getName() + ".blockhuntpass") + 1);
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".tokens", playerTokens - (Integer) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_PRICE));
|
||||
MemoryStorage.shop.save();
|
||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_SHOP_BOUGHT_ITEM, "itemName-" + MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_NAME));
|
||||
} else {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_SHOP_NEED_MORE_TOKENS);
|
||||
}
|
||||
}
|
||||
|
||||
InventoryHandler.openShop(player);
|
||||
} else if (invView.getTitle().contains(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_NAME)))) {
|
||||
event.setCancelled(true);
|
||||
if (event.getCurrentItem() != null) {
|
||||
if (event.getCurrentItem().getType().isBlock()) {
|
||||
MemoryStorage.chosenBlock.put(player, event.getCurrentItem());
|
||||
String blockName = event.getCurrentItem().getType().name();
|
||||
blockName = WordUtils.capitalizeFully(blockName.replace("_", " "));
|
||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_SHOP_CHOSEN_BLOCK, "block-"
|
||||
+ blockName);
|
||||
} else {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_SET_NOT_A_BLOCK);
|
||||
}
|
||||
}
|
||||
} else if (invView.getTitle().contains(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_NAME)))) {
|
||||
event.setCancelled(true);
|
||||
if (event.getCurrentItem() != null) {
|
||||
if (event.getCurrentItem().getType().equals(Material.BLUE_WOOL)) {
|
||||
int i = 0;
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
for (Player playerCheck : arena.playersInArena) {
|
||||
if (MemoryStorage.chosenSeeker.get(playerCheck) != null) {
|
||||
if (MemoryStorage.chosenSeeker.get(playerCheck)) {
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= arena.amountSeekersOnStart) {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_SHOP_MAX_SEEKERS_REACHED);
|
||||
} else {
|
||||
MemoryStorage.chosenSeeker.put(player, true);
|
||||
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
player.updateInventory();
|
||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_SHOP_CHOSEN_SEEKER);
|
||||
inv.clear();
|
||||
if (MemoryStorage.shop.getFile().getInt(player.getName() + ".blockhuntpass") == 1) {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".blockhuntpass", null);
|
||||
MemoryStorage.shop.save();
|
||||
} else {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".blockhuntpass", MemoryStorage.shop.getFile().getInt(player.getName() + ".blockhuntpass") - 1);
|
||||
MemoryStorage.shop.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (event.getCurrentItem().getType().equals(Material.RED_WOOL)) {
|
||||
int i = 0;
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
for (Player playerCheck : arena.playersInArena) {
|
||||
if (MemoryStorage.chosenSeeker.get(playerCheck) != null) {
|
||||
if (!MemoryStorage.chosenSeeker.get(playerCheck)) {
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= (arena.playersInArena.size() - 1)) {
|
||||
MessageManager.sendFMessage(player, MessageKey.ERROR_SHOP_MAX_HIDERS_REACHED);
|
||||
} else {
|
||||
MemoryStorage.chosenSeeker.put(player, false);
|
||||
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
player.updateInventory();
|
||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_SHOP_CHOSEN_HIDERS);
|
||||
inv.clear();
|
||||
if (MemoryStorage.shop.getFile().getInt(player.getName() + ".blockhuntpass") == 1) {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".blockhuntpass", null);
|
||||
MemoryStorage.shop.save();
|
||||
} else {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".blockhuntpass", MemoryStorage.shop.getFile().getInt(player.getName() + ".blockhuntpass") - 1);
|
||||
MemoryStorage.shop.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
ItemStack item = event.getCurrentItem();
|
||||
String arenaName = inv.getItem(0).getItemMeta().getDisplayName().replaceAll(MessageManager.replaceAll("%NBlockHunt arena: %A"), "");
|
||||
|
||||
Arena arena = null;
|
||||
for (Arena arena2 : MemoryStorage.arenaList) {
|
||||
if (arena2.arenaName.equalsIgnoreCase(arenaName)) {
|
||||
arena = arena2;
|
||||
}
|
||||
}
|
||||
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
if (item.getType().equals(Material.AIR)) {
|
||||
return;
|
||||
}
|
||||
if (!item.getItemMeta().hasDisplayName()) {
|
||||
return;
|
||||
}
|
||||
if (item.getType().equals(Material.GOLD_NUGGET)) {
|
||||
if (item.getItemMeta().getDisplayName().contains("maxPlayers")) {
|
||||
updownButton(player, item, arena, ArenaProperty.MAX_PLAYERS, arena.maxPlayers, Bukkit.getMaxPlayers(), 2, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("minPlayers")) {
|
||||
updownButton(player, item, arena, ArenaProperty.MIN_PLAYERS, arena.minPlayers, Bukkit.getMaxPlayers() - 1, 2, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("amountSeekersOnStart")) {
|
||||
updownButton(player, item, arena, ArenaProperty.AMOUNT_SEEKERS_ON_START, arena.amountSeekersOnStart, arena.maxPlayers - 1, 1, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("timeInLobbyUntilStart")) {
|
||||
updownButton(player, item, arena, ArenaProperty.TIME_IN_LOBBY_UNTIL_START, arena.timeInLobbyUntilStart, 1000, 5, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("waitingTimeSeeker")) {
|
||||
updownButton(player, item, arena, ArenaProperty.WAITING_TIME_SEEKER, arena.waitingTimeSeeker, 1000, 5, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("gameTime")) {
|
||||
updownButton(player, item, arena, ArenaProperty.GAME_TIME, arena.gameTime, 1000, 5, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("blockAnnouncerTime")) {
|
||||
updownButton(player, item, arena, ArenaProperty.BLOCK_ANNOUNCER_TIME, arena.blockAnnouncerTime, 1000, 0, 5, 5);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("timeUntilHidersSword")) {
|
||||
updownButton(player, item, arena, ArenaProperty.TIME_UNTIL_HIDERS_SWORD, arena.timeUntilHidersSword, 1000, 0, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("hidersTokenWin")) {
|
||||
updownButton(player, item, arena, ArenaProperty.HIDERS_TOKEN_WIN, arena.hidersTokenWin, 1000, 0, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("seekersTokenWin")) {
|
||||
updownButton(player, item, arena, ArenaProperty.SEEKERS_TOKEN_WIN, arena.seekersTokenWin, 1000, 0, 1, 1);
|
||||
} else if (item.getItemMeta().getDisplayName().contains("killTokens")) {
|
||||
updownButton(player, item, arena, ArenaProperty.KILL_TOKENS, 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")) {
|
||||
InventoryHandler.openDisguiseBlocks(arena, player);
|
||||
}
|
||||
}
|
||||
} else if (item.getType().equals(Material.BOOK)) {
|
||||
if (item.getItemMeta().getDisplayName().contains("disguiseBlocks")) {
|
||||
InventoryHandler.openDisguiseBlocks(arena, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -242,7 +232,8 @@ public class OnInventoryClickEvent implements Listener {
|
||||
ArenaHandler.loadArenas();
|
||||
}
|
||||
|
||||
public static void updownButton(Player player, ItemStack item, Arena arena, ArenaProperty at, int option, int max, int min, int add, int remove) {
|
||||
public static void upDownButton(Player player, ItemStack item, Arena arena, ArenaProperty at, int option, int max,
|
||||
int min, int add, int remove) {
|
||||
if (item.getItemMeta().getDisplayName().contains((String) MemoryStorage.messages.get(MessageKey.BUTTON_ADD_2))) {
|
||||
if (option < max) {
|
||||
switch (at) {
|
||||
|
@ -26,12 +26,7 @@ public class OnInventoryCloseEvent implements Listener {
|
||||
if (invView.getTitle().contains("DisguiseBlocks")) {
|
||||
String arenaName = inv.getItem(0).getItemMeta().getDisplayName().replaceAll(MessageManager.replaceAll("%NDisguiseBlocks of arena: %A"), "");
|
||||
|
||||
Arena arena = null;
|
||||
for (Arena arena2 : MemoryStorage.arenaList) {
|
||||
if (arena2.arenaName.equalsIgnoreCase(arenaName)) {
|
||||
arena = arena2;
|
||||
}
|
||||
}
|
||||
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
||||
|
||||
ArrayList<ItemStack> blocks = new ArrayList<>();
|
||||
for (ItemStack item : inv.getContents()) {
|
||||
|
@ -14,7 +14,7 @@ public class OnPlayerDropItemEvent implements Listener {
|
||||
public void onPlayerDropItemEvent(PlayerDropItemEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -81,11 +81,10 @@ public class OnPlayerInteractEvent implements Listener {
|
||||
InventoryHandler.openShop(player);
|
||||
}
|
||||
} else {
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
if (sign.getLines()[1].contains(arena.arenaName)) {
|
||||
if (PermissionsManager.hasPermission(player, Permission.JOIN_SIGN, true)) {
|
||||
ArenaHandler.playerJoinArena(player, arena.arenaName);
|
||||
}
|
||||
Arena arena = MemoryStorage.arenaMap.get(sign.getLines()[1].toLowerCase());
|
||||
if (arena != null) {
|
||||
if (PermissionsManager.hasPermission(player, Permission.JOIN_SIGN, true)) {
|
||||
ArenaHandler.playerJoinArena(player, arena.arenaName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,7 +100,7 @@ public class OnPlayerInteractEvent implements Listener {
|
||||
|| 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.getRelative(event.getBlockFace()).getType().equals(Material.FIRE)) {
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -111,7 +110,7 @@ public class OnPlayerInteractEvent implements Listener {
|
||||
}
|
||||
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.seekers.contains(player)) {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
if (MemoryStorage.hiddenLoc.get(pl) != null) {
|
||||
@ -128,7 +127,7 @@ public class OnPlayerInteractEvent implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.contains(player) && (arena.gameState.equals(ArenaState.WAITING) || arena.gameState.equals(ArenaState.STARTING))) {
|
||||
event.setCancelled(true);
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
|
@ -24,7 +24,7 @@ public class OnPlayerMoveEvent implements Listener {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
if (arena.gameState == ArenaState.IN_GAME) {
|
||||
MemoryStorage.moveLoc.put(player, player.getLocation());
|
||||
|
@ -15,7 +15,7 @@ public class OnPlayerQuitEvent implements Listener {
|
||||
public void onPlayerQuitEvent(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
ArenaHandler.playerLeaveArena(player, true, true);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class OnPlayerSwapHandItemsEvent implements Listener {
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user