Moves arena-related locations to their own class
This commit is contained in:
parent
cc0007fb1b
commit
79cd565cb5
@ -43,6 +43,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockHunt extends JavaPlugin implements Listener {
|
public class BlockHunt extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
@ -111,10 +112,10 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
if (arena.timer == 60 || arena.timer == 30 || arena.timer == 10) {
|
if (arena.timer == 60 || arena.timer == 30 || arena.timer == 10) {
|
||||||
ArenaHandler.sendFMessage(arena, MessageKey.NORMAL_LOBBY_ARENA_IS_STARTING, "1-" + arena.timer);
|
ArenaHandler.sendFMessage(arena, MessageKey.NORMAL_LOBBY_ARENA_IS_STARTING, "1-" + arena.timer);
|
||||||
} else if (arena.timer <= 5) {
|
} else if (arena.timer <= 5) {
|
||||||
World world = arena.lobbyWarp.getWorld();
|
World world = arena.arenaLocations.getLobbyWarp().getWorld();
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
int pitch = (int) (2 - Math.floor(arena.timer / 2.0));
|
int pitch = (int) (2 - Math.floor(arena.timer / 2.0));
|
||||||
world.playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, pitch);
|
world.playSound(arena.arenaLocations.getLobbyWarp(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, pitch);
|
||||||
}
|
}
|
||||||
ArenaHandler.sendFMessage(arena, MessageKey.NORMAL_LOBBY_ARENA_IS_STARTING, "1-" + arena.timer);
|
ArenaHandler.sendFMessage(arena, MessageKey.NORMAL_LOBBY_ARENA_IS_STARTING, "1-" + arena.timer);
|
||||||
}
|
}
|
||||||
@ -145,7 +146,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
if (!arena.seekers.contains(seeker)) {
|
if (!arena.seekers.contains(seeker)) {
|
||||||
ArenaHandler.sendFMessage(arena, MessageKey.NORMAL_IN_GAME_SEEKER_CHOSEN, "seeker-" + seeker.getName());
|
ArenaHandler.sendFMessage(arena, MessageKey.NORMAL_IN_GAME_SEEKER_CHOSEN, "seeker-" + seeker.getName());
|
||||||
arena.seekers.add(seeker);
|
arena.seekers.add(seeker);
|
||||||
PlayerHandler.teleport(seeker, arena.seekersWarp);
|
PlayerHandler.teleport(seeker, arena.arenaLocations.getSeekersWarp());
|
||||||
seeker.getInventory().clear();
|
seeker.getInventory().clear();
|
||||||
seeker.updateInventory();
|
seeker.updateInventory();
|
||||||
seeker.setWalkSpeed(0.3F);
|
seeker.setWalkSpeed(0.3F);
|
||||||
@ -169,7 +170,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
MiscDisguise disguise = new MiscDisguise(DisguiseType.FALLING_BLOCK, block.getType());
|
MiscDisguise disguise = new MiscDisguise(DisguiseType.FALLING_BLOCK, block.getType());
|
||||||
DisguiseAPI.disguiseToAll(arenaPlayer, disguise);
|
DisguiseAPI.disguiseToAll(arenaPlayer, disguise);
|
||||||
PlayerHandler.teleport(arenaPlayer, arena.hidersWarp);
|
PlayerHandler.teleport(arenaPlayer, arena.arenaLocations.getHidersWarp());
|
||||||
ItemStack blockCount = new ItemStack(block.getType(), 5);
|
ItemStack blockCount = new ItemStack(block.getType(), 5);
|
||||||
arenaPlayer.getInventory().setItem(8, blockCount);
|
arenaPlayer.getInventory().setItem(8, blockCount);
|
||||||
arenaPlayer.getInventory().setHelmet(new ItemStack(block));
|
arenaPlayer.getInventory().setHelmet(new ItemStack(block));
|
||||||
@ -204,7 +205,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
if (MemoryStorage.seekerTime.get(player) != null) {
|
if (MemoryStorage.seekerTime.get(player) != null) {
|
||||||
MemoryStorage.seekerTime.put(player, MemoryStorage.seekerTime.get(player) - 1);
|
MemoryStorage.seekerTime.put(player, MemoryStorage.seekerTime.get(player) - 1);
|
||||||
if (MemoryStorage.seekerTime.get(player) <= 0) {
|
if (MemoryStorage.seekerTime.get(player) <= 0) {
|
||||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
PlayerHandler.teleport(player, arena.arenaLocations.getHidersWarp());
|
||||||
MemoryStorage.seekerTime.remove(player);
|
MemoryStorage.seekerTime.remove(player);
|
||||||
ArenaHandler.sendFMessage(arena, MessageKey.NORMAL_IN_GAME_SEEKER_SPAWNED,
|
ArenaHandler.sendFMessage(arena, MessageKey.NORMAL_IN_GAME_SEEKER_SPAWNED,
|
||||||
"%playerName%-" + player.getName());
|
"%playerName%-" + player.getName());
|
||||||
@ -228,7 +229,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
// blockAnnouncer code.
|
// blockAnnouncer code.
|
||||||
if ((arena.blockAnnouncerTime > 0) && (arena.timer == arena.blockAnnouncerTime)) {
|
if ((arena.blockAnnouncerTime > 0) && (arena.timer == arena.blockAnnouncerTime)) {
|
||||||
ArrayList<String> remainingBlocks = new ArrayList<>();
|
List<String> remainingBlocks = new ArrayList<>();
|
||||||
for (Player arenaPlayer : arena.playersInArena) {
|
for (Player arenaPlayer : arena.playersInArena) {
|
||||||
if (!arena.seekers.contains(arenaPlayer)) {
|
if (!arena.seekers.contains(arenaPlayer)) {
|
||||||
ItemStack item = arenaPlayer.getInventory().getItem(8);
|
ItemStack item = arenaPlayer.getInventory().getItem(8);
|
||||||
@ -246,10 +247,10 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
if (arena.timer == 190 || arena.timer == 60 || arena.timer == 30 || arena.timer == 10) {
|
if (arena.timer == 190 || arena.timer == 60 || arena.timer == 30 || arena.timer == 10) {
|
||||||
ArenaHandler.sendFMessage(arena, MessageKey.NORMAL_IN_GAME_ARENA_END, "1-" + arena.timer);
|
ArenaHandler.sendFMessage(arena, MessageKey.NORMAL_IN_GAME_ARENA_END, "1-" + arena.timer);
|
||||||
} else if (arena.timer <= 5) {
|
} else if (arena.timer <= 5) {
|
||||||
World world = arena.lobbyWarp.getWorld();
|
World world = arena.arenaLocations.getLobbyWarp().getWorld();
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
int pitch = (int) (2 - Math.floor(arena.timer / 2.0));
|
int pitch = (int) (2 - Math.floor(arena.timer / 2.0));
|
||||||
world.playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, pitch);
|
world.playSound(arena.arenaLocations.getLobbyWarp(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, pitch);
|
||||||
}
|
}
|
||||||
ArenaHandler.sendFMessage(arena, MessageKey.NORMAL_LOBBY_ARENA_IS_STARTING, "1-" + arena.timer);
|
ArenaHandler.sendFMessage(arena, MessageKey.NORMAL_LOBBY_ARENA_IS_STARTING, "1-" + arena.timer);
|
||||||
}
|
}
|
||||||
|
@ -90,32 +90,32 @@ public class InventoryHandler {
|
|||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
updownButton(panel, arena, ArenaProperty.MAX_PLAYERS, "maxPlayers", "1", maxPlayers_UP, maxPlayers, maxPlayers_DOWN, 1, 10, 19);
|
upDownButton(panel, arena, ArenaProperty.MAX_PLAYERS, "maxPlayers", "1", maxPlayers_UP, maxPlayers, maxPlayers_DOWN, 1, 10, 19);
|
||||||
|
|
||||||
updownButton(panel, arena, ArenaProperty.MIN_PLAYERS, "minPlayers", "1", minPlayers_UP, minPlayers, minPlayers_DOWN, 2, 11, 20);
|
upDownButton(panel, arena, ArenaProperty.MIN_PLAYERS, "minPlayers", "1", minPlayers_UP, minPlayers, minPlayers_DOWN, 2, 11, 20);
|
||||||
|
|
||||||
updownButton(panel, arena, ArenaProperty.AMOUNT_SEEKERS_ON_START, "amountSeekersOnStart", "1", amountSeekersOnStart_UP, amountSeekersOnStart,
|
upDownButton(panel, arena, ArenaProperty.AMOUNT_SEEKERS_ON_START, "amountSeekersOnStart", "1", amountSeekersOnStart_UP, amountSeekersOnStart,
|
||||||
amountSeekersOnStart_DOWN, 4, 13, 22);
|
amountSeekersOnStart_DOWN, 4, 13, 22);
|
||||||
|
|
||||||
updownButton(panel, arena, ArenaProperty.TIME_IN_LOBBY_UNTIL_START, "timeInLobbyUntilStart", "1 %Nsecond", timeInLobbyUntilStart_UP, timeInLobbyUntilStart,
|
upDownButton(panel, arena, ArenaProperty.TIME_IN_LOBBY_UNTIL_START, "timeInLobbyUntilStart", "1 %Nsecond", timeInLobbyUntilStart_UP, timeInLobbyUntilStart,
|
||||||
timeInLobbyUntilStart_DOWN, 6, 15, 24);
|
timeInLobbyUntilStart_DOWN, 6, 15, 24);
|
||||||
|
|
||||||
updownButton(panel, arena, ArenaProperty.WAITING_TIME_SEEKER, "waitingTimeSeeker", "1 %Nsecond", waitingTimeSeeker_UP, waitingTimeSeeker, waitingTimeSeeker_DOWN,
|
upDownButton(panel, arena, ArenaProperty.WAITING_TIME_SEEKER, "waitingTimeSeeker", "1 %Nsecond", waitingTimeSeeker_UP, waitingTimeSeeker, waitingTimeSeeker_DOWN,
|
||||||
7, 16, 25);
|
7, 16, 25);
|
||||||
|
|
||||||
updownButton(panel, arena, ArenaProperty.GAME_TIME, "gameTime", "1 %Nsecond", gameTime_UP, gameTime, gameTime_DOWN, 8, 17, 26);
|
upDownButton(panel, arena, ArenaProperty.GAME_TIME, "gameTime", "1 %Nsecond", gameTime_UP, gameTime, gameTime_DOWN, 8, 17, 26);
|
||||||
|
|
||||||
updownButton(panel, arena, ArenaProperty.BLOCK_ANNOUNCER_TIME, "blockAnnouncerTime", "5 %Nseconds", blockAnnouncerTime_UP, blockAnnouncerTime,
|
upDownButton(panel, arena, ArenaProperty.BLOCK_ANNOUNCER_TIME, "blockAnnouncerTime", "5 %Nseconds", blockAnnouncerTime_UP, blockAnnouncerTime,
|
||||||
blockAnnouncerTime_DOWN, 29, 38, 47);
|
blockAnnouncerTime_DOWN, 29, 38, 47);
|
||||||
|
|
||||||
updownButton(panel, arena, ArenaProperty.TIME_UNTIL_HIDERS_SWORD, "timeUntilHidersSword", "1 %Nsecond", timeUntilHidersSword_UP, timeUntilHidersSword,
|
upDownButton(panel, arena, ArenaProperty.TIME_UNTIL_HIDERS_SWORD, "timeUntilHidersSword", "1 %Nsecond", timeUntilHidersSword_UP, timeUntilHidersSword,
|
||||||
timeUntilHidersSword_DOWN, 30, 39, 48);
|
timeUntilHidersSword_DOWN, 30, 39, 48);
|
||||||
|
|
||||||
updownButton(panel, arena, ArenaProperty.HIDERS_TOKEN_WIN, "hidersTokenWin", "1 %Ntoken", hidersTokenWin_UP, hidersTokenWin, hidersTokenWin_DOWN, 32, 41, 50);
|
upDownButton(panel, arena, ArenaProperty.HIDERS_TOKEN_WIN, "hidersTokenWin", "1 %Ntoken", hidersTokenWin_UP, hidersTokenWin, hidersTokenWin_DOWN, 32, 41, 50);
|
||||||
|
|
||||||
updownButton(panel, arena, ArenaProperty.SEEKERS_TOKEN_WIN, "seekersTokenWin", "1 %Ntoken", seekersTokenWin_UP, seekersTokenWin, seekersTokenWin_DOWN, 33, 42, 51);
|
upDownButton(panel, arena, ArenaProperty.SEEKERS_TOKEN_WIN, "seekersTokenWin", "1 %Ntoken", seekersTokenWin_UP, seekersTokenWin, seekersTokenWin_DOWN, 33, 42, 51);
|
||||||
|
|
||||||
updownButton(panel, arena, ArenaProperty.KILL_TOKENS, "killTokens", "1 %Ntoken", killTokens_UP, killTokens, killTokens_DOWN, 34, 43, 52);
|
upDownButton(panel, arena, ArenaProperty.KILL_TOKENS, "killTokens", "1 %Ntoken", killTokens_UP, killTokens, killTokens_DOWN, 34, 43, 52);
|
||||||
|
|
||||||
player.openInventory(panel);
|
player.openInventory(panel);
|
||||||
} else {
|
} else {
|
||||||
@ -123,13 +123,15 @@ public class InventoryHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updownButton(Inventory panel, Arena arena, ArenaProperty at, String option, String addremove, ItemStack UP, ItemStack BUTTON, ItemStack DOWN, int up,
|
public static void upDownButton(Inventory panel, Arena arena, ArenaProperty arenaProperty, String option,
|
||||||
int button, int down) {
|
String addRemove, ItemStack upItem, ItemStack buttonItem, ItemStack downItem,
|
||||||
ItemMeta UP_IM = UP.getItemMeta();
|
int up, int button, int down) {
|
||||||
UP_IM.setDisplayName(MessageManager.replaceAll((String) MemoryStorage.messages.get(MessageKey.BUTTON_ADD), "1-" + addremove, "2-" + option));
|
ItemMeta upItemItemMeta = upItem.getItemMeta();
|
||||||
UP.setItemMeta(UP_IM);
|
upItemItemMeta.setDisplayName(MessageManager.replaceAll((String) MemoryStorage.messages.get(MessageKey.BUTTON_ADD),
|
||||||
|
"1-" + addRemove, "2-" + option));
|
||||||
|
upItem.setItemMeta(upItemItemMeta);
|
||||||
|
|
||||||
int setting = switch (at) {
|
int setting = switch (arenaProperty) {
|
||||||
case MAX_PLAYERS -> arena.maxPlayers;
|
case MAX_PLAYERS -> arena.maxPlayers;
|
||||||
case MIN_PLAYERS -> arena.minPlayers;
|
case MIN_PLAYERS -> arena.minPlayers;
|
||||||
case AMOUNT_SEEKERS_ON_START -> arena.amountSeekersOnStart;
|
case AMOUNT_SEEKERS_ON_START -> arena.amountSeekersOnStart;
|
||||||
@ -141,20 +143,21 @@ public class InventoryHandler {
|
|||||||
case HIDERS_TOKEN_WIN -> arena.hidersTokenWin;
|
case HIDERS_TOKEN_WIN -> arena.hidersTokenWin;
|
||||||
case SEEKERS_TOKEN_WIN -> arena.seekersTokenWin;
|
case SEEKERS_TOKEN_WIN -> arena.seekersTokenWin;
|
||||||
case KILL_TOKENS -> arena.killTokens;
|
case KILL_TOKENS -> arena.killTokens;
|
||||||
default -> 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ItemMeta BUTTON_IM = BUTTON.getItemMeta();
|
ItemMeta buttonItemMeta = buttonItem.getItemMeta();
|
||||||
BUTTON_IM.setDisplayName(MessageManager.replaceAll((String) MemoryStorage.messages.get(MessageKey.BUTTON_SETTING), "1-" + option, "2-" + setting));
|
buttonItemMeta.setDisplayName(MessageManager.replaceAll(
|
||||||
BUTTON.setItemMeta(BUTTON_IM);
|
(String) MemoryStorage.messages.get(MessageKey.BUTTON_SETTING), "1-" + option, "2-" + setting));
|
||||||
|
buttonItem.setItemMeta(buttonItemMeta);
|
||||||
|
|
||||||
ItemMeta DOWN_IM = DOWN.getItemMeta();
|
ItemMeta DOWN_IM = downItem.getItemMeta();
|
||||||
DOWN_IM.setDisplayName(MessageManager.replaceAll((String) MemoryStorage.messages.get(MessageKey.BUTTON_REMOVE), "1-" + addremove, "2-" + option));
|
DOWN_IM.setDisplayName(MessageManager.replaceAll(
|
||||||
DOWN.setItemMeta(DOWN_IM);
|
(String) MemoryStorage.messages.get(MessageKey.BUTTON_REMOVE), "1-" + addRemove, "2-" + option));
|
||||||
|
downItem.setItemMeta(DOWN_IM);
|
||||||
|
|
||||||
panel.setItem(up, UP);
|
panel.setItem(up, upItem);
|
||||||
panel.setItem(button, BUTTON);
|
panel.setItem(button, buttonItem);
|
||||||
panel.setItem(down, DOWN);
|
panel.setItem(down, downItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openDisguiseBlocks(Arena arena, Player player) {
|
public static void openDisguiseBlocks(Arena arena, Player player) {
|
||||||
@ -162,12 +165,12 @@ public class InventoryHandler {
|
|||||||
Inventory panel = Bukkit.createInventory(null, 36, MessageManager.replaceAll("%N&lDisguiseBlocks"));
|
Inventory panel = Bukkit.createInventory(null, 36, MessageManager.replaceAll("%N&lDisguiseBlocks"));
|
||||||
|
|
||||||
ItemStack arenaNameNote = new ItemStack(Material.PAPER, 1);
|
ItemStack arenaNameNote = new ItemStack(Material.PAPER, 1);
|
||||||
ItemMeta arenaNameNote_IM = arenaNameNote.getItemMeta();
|
ItemMeta arenaNameNoteItemMeta = arenaNameNote.getItemMeta();
|
||||||
arenaNameNote_IM.setDisplayName(MessageManager.replaceAll("%NDisguiseBlocks of arena: %A" + arenaName));
|
arenaNameNoteItemMeta.setDisplayName(MessageManager.replaceAll("%NDisguiseBlocks of arena: %A" + arenaName));
|
||||||
ArrayList<String> lores = new ArrayList<>();
|
List<String> loreLines = new ArrayList<>();
|
||||||
lores.add(MessageManager.replaceAll("%NPlace the DisguiseBlocks inside this inventory."));
|
loreLines.add(MessageManager.replaceAll("%NPlace the DisguiseBlocks inside this inventory."));
|
||||||
arenaNameNote_IM.setLore(lores);
|
arenaNameNoteItemMeta.setLore(loreLines);
|
||||||
arenaNameNote.setItemMeta(arenaNameNote_IM);
|
arenaNameNote.setItemMeta(arenaNameNoteItemMeta);
|
||||||
panel.setItem(0, arenaNameNote);
|
panel.setItem(0, arenaNameNote);
|
||||||
if (arena.disguiseBlocks != null) {
|
if (arena.disguiseBlocks != null) {
|
||||||
for (int i = arena.disguiseBlocks.size(); i > 0; i = i - 1) {
|
for (int i = arena.disguiseBlocks.size(); i > 0; i = i - 1) {
|
||||||
@ -178,51 +181,59 @@ public class InventoryHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void openShop(Player player) {
|
public static void openShop(Player player) {
|
||||||
Inventory shop = Bukkit.createInventory(null, 9, MessageManager.replaceAll("\u00A7r" + MemoryStorage.config.get(ConfigKey.SHOP_TITLE)));
|
Inventory shop = Bukkit.createInventory(null, 9, MessageManager.replaceAll("\u00A7r" +
|
||||||
|
MemoryStorage.config.get(ConfigKey.SHOP_TITLE)));
|
||||||
if (MemoryStorage.shop.getFile().get(player.getName() + ".tokens") == null) {
|
if (MemoryStorage.shop.getFile().get(player.getName() + ".tokens") == null) {
|
||||||
MemoryStorage.shop.getFile().set(player.getName() + ".tokens", 0);
|
MemoryStorage.shop.getFile().set(player.getName() + ".tokens", 0);
|
||||||
MemoryStorage.shop.save();
|
MemoryStorage.shop.save();
|
||||||
}
|
}
|
||||||
int playerTokens = MemoryStorage.shop.getFile().getInt(player.getName() + ".tokens");
|
int playerTokens = MemoryStorage.shop.getFile().getInt(player.getName() + ".tokens");
|
||||||
List<String> lores = new ArrayList<>();
|
List<String> loreLines;
|
||||||
List<String> lores2 = new ArrayList<>();
|
List<String> loreLines2;
|
||||||
|
|
||||||
ItemStack shopTokens = new ItemStack(Material.EMERALD, 1);
|
ItemStack shopTokens = new ItemStack(Material.EMERALD, 1);
|
||||||
ItemMeta shopTokens_IM = shopTokens.getItemMeta();
|
ItemMeta shopTokens_IM = shopTokens.getItemMeta();
|
||||||
shopTokens_IM.setDisplayName(MessageManager.replaceAll("%N&lTokens: %A" + playerTokens));
|
shopTokens_IM.setDisplayName(MessageManager.replaceAll("%N&lTokens: %A" + playerTokens));
|
||||||
shopTokens.setItemMeta(shopTokens_IM);
|
shopTokens.setItemMeta(shopTokens_IM);
|
||||||
|
|
||||||
ItemStack shopBlockChooser = new ItemStack(Material.getMaterial((String) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_ID_NAME)), 1);
|
ItemStack shopBlockChooser = new ItemStack(Material.getMaterial((String) MemoryStorage.config.get(
|
||||||
|
ConfigKey.SHOP_BLOCK_CHOOSER_V_1_ID_NAME)), 1);
|
||||||
ItemMeta shopBlockChooser_IM = shopBlockChooser.getItemMeta();
|
ItemMeta shopBlockChooser_IM = shopBlockChooser.getItemMeta();
|
||||||
shopBlockChooser_IM.setDisplayName(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_NAME)));
|
shopBlockChooser_IM.setDisplayName(MessageManager.replaceAll((String) MemoryStorage.config.get(
|
||||||
lores = MemoryStorage.config.getFile().getStringList(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_DESCRIPTION.getPath());
|
ConfigKey.SHOP_BLOCK_CHOOSER_V_1_NAME)));
|
||||||
lores2 = new ArrayList<>();
|
loreLines = MemoryStorage.config.getFile().getStringList(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_DESCRIPTION.getPath());
|
||||||
for (String lore : lores) {
|
loreLines2 = new ArrayList<>();
|
||||||
lores2.add(MessageManager.replaceAll(lore));
|
for (String lore : loreLines) {
|
||||||
|
loreLines2.add(MessageManager.replaceAll(lore));
|
||||||
}
|
}
|
||||||
|
|
||||||
lores2.add(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigKey.SHOP_PRICE), "amount-" + MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_PRICE)));
|
loreLines2.add(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigKey.SHOP_PRICE),
|
||||||
|
"amount-" + MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_PRICE)));
|
||||||
|
|
||||||
shopBlockChooser_IM.setLore(lores2);
|
shopBlockChooser_IM.setLore(loreLines2);
|
||||||
shopBlockChooser.setItemMeta(shopBlockChooser_IM);
|
shopBlockChooser.setItemMeta(shopBlockChooser_IM);
|
||||||
|
|
||||||
ItemStack shopBlockHuntPass = new ItemStack(Material.getMaterial((String) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_ID_NAME)), 1);
|
ItemStack shopBlockHuntPass = new ItemStack(Material.getMaterial((String) MemoryStorage.config.get(
|
||||||
|
ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_ID_NAME)), 1);
|
||||||
ItemMeta shopBlockHuntPass_IM = shopBlockHuntPass.getItemMeta();
|
ItemMeta shopBlockHuntPass_IM = shopBlockHuntPass.getItemMeta();
|
||||||
shopBlockHuntPass_IM.setDisplayName(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_NAME)));
|
shopBlockHuntPass_IM.setDisplayName(MessageManager.replaceAll((String) MemoryStorage.config.get(
|
||||||
lores = MemoryStorage.config.getFile().getStringList(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_DESCRIPTION.getPath());
|
ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_NAME)));
|
||||||
lores2 = new ArrayList<>();
|
loreLines = MemoryStorage.config.getFile().getStringList(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_DESCRIPTION.getPath());
|
||||||
for (String lore : lores) {
|
loreLines2 = new ArrayList<>();
|
||||||
lores2.add(MessageManager.replaceAll(lore));
|
for (String lore : loreLines) {
|
||||||
|
loreLines2.add(MessageManager.replaceAll(lore));
|
||||||
}
|
}
|
||||||
|
|
||||||
lores2.add(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigKey.SHOP_PRICE), "amount-" + MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_PRICE)));
|
loreLines2.add(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigKey.SHOP_PRICE),
|
||||||
|
"amount-" + MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_PRICE)));
|
||||||
|
|
||||||
shopBlockHuntPass_IM.setLore(lores2);
|
shopBlockHuntPass_IM.setLore(loreLines2);
|
||||||
shopBlockHuntPass.setItemMeta(shopBlockHuntPass_IM);
|
shopBlockHuntPass.setItemMeta(shopBlockHuntPass_IM);
|
||||||
|
|
||||||
shop.setItem(0, shopTokens);
|
shop.setItem(0, shopTokens);
|
||||||
if ((Boolean) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_ENABLED)
|
if ((Boolean) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_CHOOSER_V_1_ENABLED)
|
||||||
&& (MemoryStorage.shop.getFile().get(player.getName() + ".blockchooser") == null && !PermissionsManager.hasPermission(player, Permission.SHOP_BLOCK_CHOOSER, false))) {
|
&& (MemoryStorage.shop.getFile().get(player.getName() + ".blockchooser") == null &&
|
||||||
|
!PermissionsManager.hasPermission(player, Permission.SHOP_BLOCK_CHOOSER, false))) {
|
||||||
shop.setItem(1, shopBlockChooser);
|
shop.setItem(1, shopBlockChooser);
|
||||||
}
|
}
|
||||||
if ((Boolean) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_ENABLED)) {
|
if ((Boolean) MemoryStorage.config.get(ConfigKey.SHOP_BLOCK_HUNT_PASS_V_2_ENABLED)) {
|
||||||
|
@ -18,36 +18,127 @@ import java.util.Map;
|
|||||||
@SerializableAs("BlockHuntArena")
|
@SerializableAs("BlockHuntArena")
|
||||||
public class Arena implements ConfigurationSerializable {
|
public class Arena implements ConfigurationSerializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of this arena
|
||||||
|
*/
|
||||||
public final String arenaName;
|
public final String arenaName;
|
||||||
public final Location corner1;
|
|
||||||
public final Location corner2;
|
/**
|
||||||
|
* The maximum amount of players that can join at once
|
||||||
|
*/
|
||||||
public int maxPlayers;
|
public int maxPlayers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum amount of players required for the arena to start
|
||||||
|
*/
|
||||||
public int minPlayers;
|
public int minPlayers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of players made into seekers when this arena starts
|
||||||
|
*/
|
||||||
public int amountSeekersOnStart;
|
public int amountSeekersOnStart;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of seconds players have to wait in the lobby before this arena starts
|
||||||
|
*/
|
||||||
public int timeInLobbyUntilStart;
|
public int timeInLobbyUntilStart;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of time seekers have to wait before they can start seeking
|
||||||
|
*/
|
||||||
public int waitingTimeSeeker;
|
public int waitingTimeSeeker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of seconds the game will last before hiders automatically win
|
||||||
|
*/
|
||||||
public int gameTime;
|
public int gameTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of seconds until hiders get swords to defend themselves
|
||||||
|
*/
|
||||||
public int timeUntilHidersSword;
|
public int timeUntilHidersSword;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of seconds left of the game when remaining hidden blocks are announced
|
||||||
|
*/
|
||||||
public int blockAnnouncerTime;
|
public int blockAnnouncerTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether seekers can hurt other seekers
|
||||||
|
*/
|
||||||
public final boolean seekersCanHurtSeekers;
|
public final boolean seekersCanHurtSeekers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether hiders can hurt seekers
|
||||||
|
*/
|
||||||
public final boolean hidersCanHurtSeekers;
|
public final boolean hidersCanHurtSeekers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether hiders can hurt other hiders
|
||||||
|
*/
|
||||||
public final boolean hidersCanHurtHiders;
|
public final boolean hidersCanHurtHiders;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether seekers take fall damage
|
||||||
|
*/
|
||||||
public final boolean seekersTakeFallDamage;
|
public final boolean seekersTakeFallDamage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether hiders take fall damage
|
||||||
|
*/
|
||||||
public final boolean hidersTakeFallDamage;
|
public final boolean hidersTakeFallDamage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The blocks allowed for disguises
|
||||||
|
*/
|
||||||
public List<ItemStack> disguiseBlocks;
|
public List<ItemStack> disguiseBlocks;
|
||||||
public Location lobbyWarp;
|
|
||||||
public Location hidersWarp;
|
/**
|
||||||
public Location seekersWarp;
|
* The commands to be run on the seekers if the seekers win (%player%)
|
||||||
public Location spawnWarp;
|
*/
|
||||||
public final List<String> seekersWinCommands;
|
public final List<String> seekersWinCommands;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The commands to be run on the hiders if the hiders win (%player%)
|
||||||
|
*/
|
||||||
public final List<String> hidersWinCommands;
|
public final List<String> hidersWinCommands;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The commands players are allowed to use while in this arena
|
||||||
|
* TODO: This seems to be missing a proper implementation
|
||||||
|
*/
|
||||||
public final List<String> allowedCommands;
|
public final List<String> allowedCommands;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of tokens granted to each seeker if seekers win
|
||||||
|
*/
|
||||||
public int seekersTokenWin;
|
public int seekersTokenWin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of tokens granted to each hider if hiders win
|
||||||
|
*/
|
||||||
public int hidersTokenWin;
|
public int hidersTokenWin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of tokens granted for killing another player
|
||||||
|
*/
|
||||||
public int killTokens;
|
public int killTokens;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The players currently in this arena
|
||||||
|
*/
|
||||||
public final List<Player> playersInArena;
|
public final List<Player> playersInArena;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current state of this arena
|
||||||
|
*/
|
||||||
public ArenaState gameState;
|
public ArenaState gameState;
|
||||||
|
|
||||||
|
public ArenaLocations arenaLocations;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A timer that counts from the game duration towards 0
|
||||||
|
*/
|
||||||
public int timer;
|
public int timer;
|
||||||
public final List<Player> seekers;
|
public final List<Player> seekers;
|
||||||
public final Scoreboard scoreboard;
|
public final Scoreboard scoreboard;
|
||||||
@ -62,8 +153,6 @@ public class Arena implements ConfigurationSerializable {
|
|||||||
List<Player> playersInArena, ArenaState gameState, int timer, List<Player> seekers,
|
List<Player> playersInArena, ArenaState gameState, int timer, List<Player> seekers,
|
||||||
Scoreboard scoreboard) {
|
Scoreboard scoreboard) {
|
||||||
this.arenaName = arenaName;
|
this.arenaName = arenaName;
|
||||||
this.corner1 = corner1;
|
|
||||||
this.corner2 = corner2;
|
|
||||||
this.maxPlayers = maxPlayers;
|
this.maxPlayers = maxPlayers;
|
||||||
this.minPlayers = minPlayers;
|
this.minPlayers = minPlayers;
|
||||||
this.amountSeekersOnStart = amountSeekersOnStart;
|
this.amountSeekersOnStart = amountSeekersOnStart;
|
||||||
@ -78,10 +167,6 @@ public class Arena implements ConfigurationSerializable {
|
|||||||
this.seekersTakeFallDamage = seekersTakeFallDamage;
|
this.seekersTakeFallDamage = seekersTakeFallDamage;
|
||||||
this.hidersTakeFallDamage = hidersTakeFallDamage;
|
this.hidersTakeFallDamage = hidersTakeFallDamage;
|
||||||
this.disguiseBlocks = disguiseBlocks;
|
this.disguiseBlocks = disguiseBlocks;
|
||||||
this.lobbyWarp = lobbyWarp;
|
|
||||||
this.hidersWarp = hidersWarp;
|
|
||||||
this.seekersWarp = seekersWarp;
|
|
||||||
this.spawnWarp = spawnWarp;
|
|
||||||
this.seekersWinCommands = seekersWinCommands;
|
this.seekersWinCommands = seekersWinCommands;
|
||||||
this.hidersWinCommands = hidersWinCommands;
|
this.hidersWinCommands = hidersWinCommands;
|
||||||
this.allowedCommands = allowedCommands;
|
this.allowedCommands = allowedCommands;
|
||||||
@ -93,14 +178,15 @@ public class Arena implements ConfigurationSerializable {
|
|||||||
this.timer = timer;
|
this.timer = timer;
|
||||||
this.seekers = seekers;
|
this.seekers = seekers;
|
||||||
this.scoreboard = scoreboard;
|
this.scoreboard = scoreboard;
|
||||||
|
this.arenaLocations = new ArenaLocations(corner1, corner2, lobbyWarp, hidersWarp, seekersWarp, spawnWarp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Map<String, Object> serialize() {
|
public @NotNull Map<String, Object> serialize() {
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("arenaName", arenaName);
|
map.put("arenaName", arenaName);
|
||||||
map.put("pos1", corner1);
|
map.put("pos1", arenaLocations.getCorner1());
|
||||||
map.put("pos2", corner2);
|
map.put("pos2", arenaLocations.getCorner2());
|
||||||
map.put("maxPlayers", maxPlayers);
|
map.put("maxPlayers", maxPlayers);
|
||||||
map.put("minPlayers", minPlayers);
|
map.put("minPlayers", minPlayers);
|
||||||
map.put("amountSeekersOnStart", amountSeekersOnStart);
|
map.put("amountSeekersOnStart", amountSeekersOnStart);
|
||||||
@ -115,10 +201,10 @@ public class Arena implements ConfigurationSerializable {
|
|||||||
map.put("seekersTakeFallDamage", seekersTakeFallDamage);
|
map.put("seekersTakeFallDamage", seekersTakeFallDamage);
|
||||||
map.put("hidersTakeFallDamage", hidersTakeFallDamage);
|
map.put("hidersTakeFallDamage", hidersTakeFallDamage);
|
||||||
map.put("disguiseBlocks", disguiseBlocks);
|
map.put("disguiseBlocks", disguiseBlocks);
|
||||||
map.put("lobbyWarp", lobbyWarp);
|
map.put("lobbyWarp", arenaLocations.getLobbyWarp());
|
||||||
map.put("hidersWarp", hidersWarp);
|
map.put("hidersWarp", arenaLocations.getHidersWarp());
|
||||||
map.put("seekersWarp", seekersWarp);
|
map.put("seekersWarp", arenaLocations.getSeekersWarp());
|
||||||
map.put("spawnWarp", spawnWarp);
|
map.put("spawnWarp", arenaLocations.getSpawnWarp());
|
||||||
map.put("seekersWinCommands", seekersWinCommands);
|
map.put("seekersWinCommands", seekersWinCommands);
|
||||||
map.put("hidersWinCommands", hidersWinCommands);
|
map.put("hidersWinCommands", hidersWinCommands);
|
||||||
map.put("allowedCommands", allowedCommands);
|
map.put("allowedCommands", allowedCommands);
|
||||||
|
@ -106,9 +106,11 @@ public class ArenaHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Location zero = new Location(Bukkit.getWorld(player.getWorld().getName()), 0, 0, 0, 0, 0);
|
Location zero = new Location(Bukkit.getWorld(player.getWorld().getName()), 0, 0, 0, 0, 0);
|
||||||
if (arena.lobbyWarp != null && arena.hidersWarp != null && arena.seekersWarp != null && arena.spawnWarp != null) {
|
ArenaLocations locations = arena.arenaLocations;
|
||||||
if (!arena.lobbyWarp.equals(zero) && !arena.hidersWarp.equals(zero) &&
|
if (locations.getLobbyWarp() != null && locations.getHidersWarp() != null &&
|
||||||
!arena.seekersWarp.equals(zero) && !arena.spawnWarp.equals(zero)) {
|
locations.getSeekersWarp() != null && locations.getSpawnWarp() != null) {
|
||||||
|
if (!locations.getLobbyWarp().equals(zero) && !locations.getHidersWarp().equals(zero) &&
|
||||||
|
!locations.getSeekersWarp().equals(zero) && !locations.getSpawnWarp().equals(zero)) {
|
||||||
if (arena.gameState == ArenaState.WAITING || arena.gameState == ArenaState.STARTING) {
|
if (arena.gameState == ArenaState.WAITING || arena.gameState == ArenaState.STARTING) {
|
||||||
if (arena.playersInArena.size() >= arena.maxPlayers &&
|
if (arena.playersInArena.size() >= arena.maxPlayers &&
|
||||||
!PermissionsManager.hasPermission(player, Permission.JOIN_FULL, false)) {
|
!PermissionsManager.hasPermission(player, Permission.JOIN_FULL, false)) {
|
||||||
@ -116,7 +118,7 @@ public class ArenaHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean canWarp = PlayerHandler.teleport(player, arena.lobbyWarp);
|
boolean canWarp = PlayerHandler.teleport(player, locations.getLobbyWarp());
|
||||||
if (!canWarp) {
|
if (!canWarp) {
|
||||||
MessageManager.sendFMessage(player, MessageKey.ERROR_TELEPORT_FAILED);
|
MessageManager.sendFMessage(player, MessageKey.ERROR_TELEPORT_FAILED);
|
||||||
return;
|
return;
|
||||||
@ -285,7 +287,7 @@ public class ArenaHandler {
|
|||||||
}
|
}
|
||||||
seeker.getInventory().clear();
|
seeker.getInventory().clear();
|
||||||
arena.seekers.add(seeker);
|
arena.seekers.add(seeker);
|
||||||
PlayerHandler.teleport(seeker, arena.seekersWarp);
|
PlayerHandler.teleport(seeker, arena.arenaLocations.getSeekersWarp());
|
||||||
MemoryStorage.seekerTime.put(seeker, arena.waitingTimeSeeker);
|
MemoryStorage.seekerTime.put(seeker, arena.waitingTimeSeeker);
|
||||||
seeker.setWalkSpeed(0.3F);
|
seeker.setWalkSpeed(0.3F);
|
||||||
|
|
||||||
@ -320,7 +322,7 @@ public class ArenaHandler {
|
|||||||
player.setHealth(pad.playerHealth());
|
player.setHealth(pad.playerHealth());
|
||||||
player.setFoodLevel(pad.playerFood());
|
player.setFoodLevel(pad.playerFood());
|
||||||
player.addPotionEffects(pad.playerPotionEffects());
|
player.addPotionEffects(pad.playerPotionEffects());
|
||||||
PlayerHandler.teleport(player, arena.spawnWarp);
|
PlayerHandler.teleport(player, arena.arenaLocations.getSpawnWarp());
|
||||||
player.setGameMode(pad.playerGameMode());
|
player.setGameMode(pad.playerGameMode());
|
||||||
player.setAllowFlight(pad.playerFlying());
|
player.setAllowFlight(pad.playerFlying());
|
||||||
if (player.getAllowFlight()) {
|
if (player.getAllowFlight()) {
|
||||||
|
133
src/main/java/net/knarcraft/blockhunt/arena/ArenaLocations.java
Normal file
133
src/main/java/net/knarcraft/blockhunt/arena/ArenaLocations.java
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
package net.knarcraft.blockhunt.arena;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The locations of an arena
|
||||||
|
*/
|
||||||
|
public class ArenaLocations {
|
||||||
|
|
||||||
|
private final @NotNull Location corner1;
|
||||||
|
private final @NotNull Location corner2;
|
||||||
|
private Location lobbyWarp;
|
||||||
|
private Location hidersWarp;
|
||||||
|
private Location seekersWarp;
|
||||||
|
private Location spawnWarp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new arena locations container
|
||||||
|
*
|
||||||
|
* @param corner1 <p>First corner of this arena's region</p>
|
||||||
|
* @param corner2 <p>Second corner of this arena's region</p>
|
||||||
|
* @param lobbyWarp <p>The location of the lobby's warp</p>
|
||||||
|
* @param hidersWarp <p>The location of the hiders' warp</p>
|
||||||
|
* @param seekersWarp <p>The location of the temporary seekers warp (should not be able to see hiders from this location)</p>
|
||||||
|
* @param spawnWarp <p>The location of the spawn warp where players are sent once this arena's game ends</p>
|
||||||
|
*/
|
||||||
|
public ArenaLocations(@NotNull Location corner1, @NotNull Location corner2, @Nullable Location lobbyWarp,
|
||||||
|
@Nullable Location hidersWarp, @Nullable Location seekersWarp, @Nullable Location spawnWarp) {
|
||||||
|
this.corner1 = corner1;
|
||||||
|
this.corner2 = corner2;
|
||||||
|
this.lobbyWarp = lobbyWarp;
|
||||||
|
this.hidersWarp = hidersWarp;
|
||||||
|
this.seekersWarp = seekersWarp;
|
||||||
|
this.spawnWarp = spawnWarp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the first corner of this arena's region
|
||||||
|
*
|
||||||
|
* @return <p>The first corner of this arena's region</p>
|
||||||
|
*/
|
||||||
|
public @NotNull Location getCorner1() {
|
||||||
|
return corner1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the second corner of this arena's region
|
||||||
|
*
|
||||||
|
* @return <p>The second corner of this arena's region</p>
|
||||||
|
*/
|
||||||
|
public @NotNull Location getCorner2() {
|
||||||
|
return corner2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the location of the lobby's warp
|
||||||
|
*
|
||||||
|
* @return <p>The location of the lobby's warp</p>
|
||||||
|
*/
|
||||||
|
public @Nullable Location getLobbyWarp() {
|
||||||
|
return lobbyWarp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the location of the lobby's warp
|
||||||
|
*
|
||||||
|
* @param lobbyWarp <p>The new location of the lobby's warp</p>
|
||||||
|
*/
|
||||||
|
public void setLobbyWarp(@NotNull Location lobbyWarp) {
|
||||||
|
this.lobbyWarp = lobbyWarp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the location of the hiders' warp
|
||||||
|
*
|
||||||
|
* @return <p>The location of the hiders' warp</p>
|
||||||
|
*/
|
||||||
|
public @Nullable Location getHidersWarp() {
|
||||||
|
return hidersWarp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the location of the hiders' warp
|
||||||
|
*
|
||||||
|
* @param hidersWarp <p>The new location of the hiders' warp</p>
|
||||||
|
*/
|
||||||
|
public void setHidersWarp(@NotNull Location hidersWarp) {
|
||||||
|
this.hidersWarp = hidersWarp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the location of the seekers' initial warp
|
||||||
|
*
|
||||||
|
* <p>Seekers are teleported here while the hiders are given time to hide.</p>
|
||||||
|
*
|
||||||
|
* @return <p>The location of the seekers' initial warp</p>
|
||||||
|
*/
|
||||||
|
public @Nullable Location getSeekersWarp() {
|
||||||
|
return seekersWarp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the location of the seekers' initial warp
|
||||||
|
*
|
||||||
|
* @param seekersWarp <p>The new location of the seekers' initial warp</p>
|
||||||
|
*/
|
||||||
|
public void setSeekersWarp(@NotNull Location seekersWarp) {
|
||||||
|
this.seekersWarp = seekersWarp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the location of the "spawn" warp
|
||||||
|
*
|
||||||
|
* <p>This location is where players are teleported to when leaving the arena</p>
|
||||||
|
*
|
||||||
|
* @return <p>The location of the "spawn" warp</p>
|
||||||
|
*/
|
||||||
|
public @Nullable Location getSpawnWarp() {
|
||||||
|
return spawnWarp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the location of the "spawn" warp
|
||||||
|
*
|
||||||
|
* @param spawnWarp <p>The location of the "spawn" warp</p>
|
||||||
|
*/
|
||||||
|
public void setSpawnWarp(@NotNull Location spawnWarp) {
|
||||||
|
this.spawnWarp = spawnWarp;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,17 +1,63 @@
|
|||||||
package net.knarcraft.blockhunt.arena;
|
package net.knarcraft.blockhunt.arena;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The arena properties that can be edited through a GUI
|
||||||
|
*/
|
||||||
public enum ArenaProperty {
|
public enum ArenaProperty {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum amount of players that can play at once
|
||||||
|
*/
|
||||||
MAX_PLAYERS,
|
MAX_PLAYERS,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum amount of players required for the arena to start
|
||||||
|
*/
|
||||||
MIN_PLAYERS,
|
MIN_PLAYERS,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of players made into seekers when the arena starts
|
||||||
|
*/
|
||||||
AMOUNT_SEEKERS_ON_START,
|
AMOUNT_SEEKERS_ON_START,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of seconds the players are kept in the lobby to allow more players to join
|
||||||
|
*/
|
||||||
TIME_IN_LOBBY_UNTIL_START,
|
TIME_IN_LOBBY_UNTIL_START,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of seconds the hiders have to hide before the seekers start seeking
|
||||||
|
*/
|
||||||
WAITING_TIME_SEEKER,
|
WAITING_TIME_SEEKER,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of time until the game ends, unless all hiders are killed
|
||||||
|
*/
|
||||||
GAME_TIME,
|
GAME_TIME,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of seconds until hiders are granted a sword to defend themselves with
|
||||||
|
*/
|
||||||
TIME_UNTIL_HIDERS_SWORD,
|
TIME_UNTIL_HIDERS_SWORD,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of tokens given to each hider if they win
|
||||||
|
*/
|
||||||
HIDERS_TOKEN_WIN,
|
HIDERS_TOKEN_WIN,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of tokens given to each seeker if they win
|
||||||
|
*/
|
||||||
SEEKERS_TOKEN_WIN,
|
SEEKERS_TOKEN_WIN,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of tokens given to a seeker when they kill a hider
|
||||||
|
*/
|
||||||
KILL_TOKENS,
|
KILL_TOKENS,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of seconds left on the arena timer when the types of hidden blocks are announced
|
||||||
|
*/
|
||||||
BLOCK_ANNOUNCER_TIME
|
BLOCK_ANNOUNCER_TIME
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,23 @@
|
|||||||
package net.knarcraft.blockhunt.arena;
|
package net.knarcraft.blockhunt.arena;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current state of an arena
|
||||||
|
*/
|
||||||
public enum ArenaState {
|
public enum ArenaState {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The arena is waiting for enough players
|
||||||
|
*/
|
||||||
WAITING,
|
WAITING,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The arena is about to start, and is counting down while players are kept in the lobby
|
||||||
|
*/
|
||||||
STARTING,
|
STARTING,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The arena has an active game
|
||||||
|
*/
|
||||||
IN_GAME,
|
IN_GAME,
|
||||||
RESTARTING,
|
|
||||||
DISABLED
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package net.knarcraft.blockhunt.command;
|
|||||||
import net.knarcraft.blockhunt.MemoryStorage;
|
import net.knarcraft.blockhunt.MemoryStorage;
|
||||||
import net.knarcraft.blockhunt.arena.Arena;
|
import net.knarcraft.blockhunt.arena.Arena;
|
||||||
import net.knarcraft.blockhunt.arena.ArenaHandler;
|
import net.knarcraft.blockhunt.arena.ArenaHandler;
|
||||||
|
import net.knarcraft.blockhunt.arena.ArenaLocations;
|
||||||
import net.knarcraft.blockhunt.config.MessageKey;
|
import net.knarcraft.blockhunt.config.MessageKey;
|
||||||
import net.knarcraft.blockhunt.manager.CommandManager;
|
import net.knarcraft.blockhunt.manager.CommandManager;
|
||||||
import net.knarcraft.blockhunt.manager.MessageManager;
|
import net.knarcraft.blockhunt.manager.MessageManager;
|
||||||
@ -19,29 +20,30 @@ public class SetWarpCommand extends DefaultCommand {
|
|||||||
CommandManager.setWarpCommand().usage());
|
CommandManager.setWarpCommand().usage());
|
||||||
} else {
|
} else {
|
||||||
String arenaName = args[2];
|
String arenaName = args[2];
|
||||||
String warpname = args[1];
|
String warpName = args[1];
|
||||||
|
|
||||||
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
Location loc = player.getLocation();
|
ArenaLocations locations = arena.arenaLocations;
|
||||||
if (warpname.equalsIgnoreCase("lobby")) {
|
Location playerLocation = player.getLocation();
|
||||||
arena.lobbyWarp = loc;
|
if (warpName.equalsIgnoreCase("lobby")) {
|
||||||
|
locations.setLobbyWarp(playerLocation);
|
||||||
save(arena);
|
save(arena);
|
||||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_SET_WARP_WARP_SET, "warp-" + warpname);
|
MessageManager.sendFMessage(player, MessageKey.NORMAL_SET_WARP_WARP_SET, "warp-" + warpName);
|
||||||
} else if (warpname.equalsIgnoreCase("hiders")) {
|
} else if (warpName.equalsIgnoreCase("hiders")) {
|
||||||
arena.hidersWarp = loc;
|
locations.setHidersWarp(playerLocation);
|
||||||
save(arena);
|
save(arena);
|
||||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_SET_WARP_WARP_SET, "warp-" + warpname);
|
MessageManager.sendFMessage(player, MessageKey.NORMAL_SET_WARP_WARP_SET, "warp-" + warpName);
|
||||||
} else if (warpname.equalsIgnoreCase("seekers")) {
|
} else if (warpName.equalsIgnoreCase("seekers")) {
|
||||||
arena.seekersWarp = loc;
|
locations.setSeekersWarp(playerLocation);
|
||||||
save(arena);
|
save(arena);
|
||||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_SET_WARP_WARP_SET, "warp-" + warpname);
|
MessageManager.sendFMessage(player, MessageKey.NORMAL_SET_WARP_WARP_SET, "warp-" + warpName);
|
||||||
} else if (warpname.equalsIgnoreCase("spawn")) {
|
} else if (warpName.equalsIgnoreCase("spawn")) {
|
||||||
arena.spawnWarp = loc;
|
locations.setSpawnWarp(playerLocation);
|
||||||
save(arena);
|
save(arena);
|
||||||
MessageManager.sendFMessage(player, MessageKey.NORMAL_SET_WARP_WARP_SET, "warp-" + warpname);
|
MessageManager.sendFMessage(player, MessageKey.NORMAL_SET_WARP_WARP_SET, "warp-" + warpName);
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendFMessage(player, MessageKey.ERROR_SET_WARP_WARP_NOT_FOUND, "warp-" + warpname);
|
MessageManager.sendFMessage(player, MessageKey.ERROR_SET_WARP_WARP_NOT_FOUND, "warp-" + warpName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendFMessage(player, MessageKey.ERROR_NO_ARENA, "name-" + arenaName);
|
MessageManager.sendFMessage(player, MessageKey.ERROR_NO_ARENA, "name-" + arenaName);
|
||||||
|
@ -151,7 +151,7 @@ public class OnEntityDamageByEntityEvent implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
DisguiseAPI.undisguiseToAll(player);
|
DisguiseAPI.undisguiseToAll(player);
|
||||||
MemoryStorage.seekerTime.put(player, arena.waitingTimeSeeker);
|
MemoryStorage.seekerTime.put(player, arena.waitingTimeSeeker);
|
||||||
PlayerHandler.teleport(player, arena.seekersWarp);
|
PlayerHandler.teleport(player, arena.arenaLocations.getSeekersWarp());
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
player.setWalkSpeed(0.3F);
|
player.setWalkSpeed(0.3F);
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import org.bukkit.inventory.InventoryView;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class OnInventoryCloseEvent implements Listener {
|
public class OnInventoryCloseEvent implements Listener {
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ public class OnInventoryCloseEvent implements Listener {
|
|||||||
|
|
||||||
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
||||||
|
|
||||||
ArrayList<ItemStack> blocks = new ArrayList<>();
|
List<ItemStack> blocks = new ArrayList<>();
|
||||||
for (ItemStack item : inv.getContents()) {
|
for (ItemStack item : inv.getContents()) {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
if (!item.getType().equals(Material.PAPER)) {
|
if (!item.getType().equals(Material.PAPER)) {
|
||||||
|
@ -5,6 +5,7 @@ import net.knarcraft.blockhunt.MemoryStorage;
|
|||||||
import net.knarcraft.blockhunt.PlayerHandler;
|
import net.knarcraft.blockhunt.PlayerHandler;
|
||||||
import net.knarcraft.blockhunt.arena.Arena;
|
import net.knarcraft.blockhunt.arena.Arena;
|
||||||
import net.knarcraft.blockhunt.arena.ArenaHandler;
|
import net.knarcraft.blockhunt.arena.ArenaHandler;
|
||||||
|
import net.knarcraft.blockhunt.arena.ArenaLocations;
|
||||||
import net.knarcraft.blockhunt.arena.ArenaState;
|
import net.knarcraft.blockhunt.arena.ArenaState;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -15,6 +16,8 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
public class OnPlayerMoveEvent implements Listener {
|
public class OnPlayerMoveEvent implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
@ -25,63 +28,70 @@ public class OnPlayerMoveEvent implements Listener {
|
|||||||
}
|
}
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||||
if (arena.playersInArena.contains(player)) {
|
//TODO: Optimize this to runtime O(1)
|
||||||
if (arena.gameState == ArenaState.IN_GAME) {
|
if (!arena.playersInArena.contains(player)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arena.gameState != ArenaState.IN_GAME) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArenaLocations locations = arena.arenaLocations;
|
||||||
MemoryStorage.moveLoc.put(player, player.getLocation());
|
MemoryStorage.moveLoc.put(player, player.getLocation());
|
||||||
if (arena.corner1 == null || arena.corner2 == null) {
|
if (locations.getCorner1() == null || locations.getCorner2() == null) {
|
||||||
BlockHunt.plugin.getLogger().info("Arena:" +
|
BlockHunt.plugin.getLogger().info("Arena:" +
|
||||||
arena.arenaName + " appears to have bad coords : pos1:" +
|
arena.arenaName + " appears to have bad coords : pos1:" +
|
||||||
((arena.corner1 != null) ? arena.corner1.toString() : " NULL") + " Pos2:" +
|
((locations.getCorner1() != null) ? locations.getCorner1().toString() : " NULL") + " Pos2:" +
|
||||||
((arena.corner2 != null) ? arena.corner2.toString() : " NULL"));
|
((locations.getCorner2() != null) ? locations.getCorner2().toString() : " NULL"));
|
||||||
BlockHunt.plugin.getLogger().info("Player has been returned to hiderswarp due to bad arena state");
|
BlockHunt.plugin.getLogger().info("Player has been returned to hiderswarp due to bad arena state");
|
||||||
//event.setCancelled(true);
|
//event.setCancelled(true);
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
||||||
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
||||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
PlayerHandler.teleport(player, locations.getHidersWarp());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double maxX = Math.max(arena.corner1.getX(), arena.corner2.getX());
|
|
||||||
double minX = Math.min(arena.corner1.getX(), arena.corner2.getX());
|
|
||||||
double maxY = Math.max(arena.corner1.getY(), arena.corner2.getY());
|
|
||||||
double minY = Math.min(arena.corner1.getY(), arena.corner2.getY());
|
|
||||||
double maxZ = Math.max(arena.corner1.getZ(), arena.corner2.getZ());
|
|
||||||
double minZ = Math.min(arena.corner1.getZ(), arena.corner2.getZ());
|
|
||||||
|
|
||||||
Location loc = player.getLocation();
|
// Force the player back in bounds if they are about to leave the arena
|
||||||
if (loc.getBlockX() > maxX) {
|
Location maxLocation = getRelativeLocation(locations.getCorner1(), locations.getCorner2(), Math::max);
|
||||||
//event.setCancelled(true);
|
Location minLocation = getRelativeLocation(locations.getCorner1(), locations.getCorner2(), Math::min);
|
||||||
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
Location playerLocation = player.getLocation();
|
||||||
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
if (!areIntersecting(playerLocation, minLocation, maxLocation)) {
|
||||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
player.playEffect(playerLocation, Effect.ENDER_SIGNAL, null);
|
||||||
} else if (loc.getBlockX() < minX) {
|
player.playSound(playerLocation, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
||||||
//event.setCancelled(true);
|
PlayerHandler.teleport(player, locations.getHidersWarp());
|
||||||
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
}
|
||||||
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
return;
|
||||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
|
||||||
} else if (loc.getBlockZ() > maxZ) {
|
|
||||||
//event.setCancelled(true);
|
|
||||||
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
|
||||||
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
|
||||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
|
||||||
} else if (loc.getBlockZ() < minZ) {
|
|
||||||
//event.setCancelled(true);
|
|
||||||
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
|
||||||
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
|
||||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
|
||||||
} else if (loc.getBlockY() > maxY) {
|
|
||||||
//event.setCancelled(true);
|
|
||||||
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
|
||||||
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
|
||||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
|
||||||
} else if (loc.getBlockY() < minY) {
|
|
||||||
//event.setCancelled(true);
|
|
||||||
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
|
||||||
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
|
||||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a location relative to the two given locations
|
||||||
|
*
|
||||||
|
* @param location1 <p>The first location</p>
|
||||||
|
* @param location2 <p>The second location</p>
|
||||||
|
* @param function <p>The function to apply on the two locations' X, Y, Z properties to get new X, Y, Z values</p>
|
||||||
|
* @return <p>A location relative to the two input locations</p>
|
||||||
|
*/
|
||||||
|
private Location getRelativeLocation(Location location1, Location location2,
|
||||||
|
BiFunction<Double, Double, Double> function) {
|
||||||
|
return new Location(location1.getWorld(), function.apply(location1.getX(), location2.getX()),
|
||||||
|
function.apply(location1.getY(), location2.getY()), function.apply(location1.getZ(), location2.getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the given location is intersecting with the hit-box defined by the given location pair
|
||||||
|
*
|
||||||
|
* @param point <p>The point to check for intersection</p>
|
||||||
|
* @param locationMin <p>The minimum corner of the hit-box to check against</p>
|
||||||
|
* @param locationMax <p>The maximum corner of the hit-box to check against</p>
|
||||||
|
* @return <p>True if the point is intersecting with the hit-box</p>
|
||||||
|
*/
|
||||||
|
private static boolean areIntersecting(Location point, Location locationMin, Location locationMax) {
|
||||||
|
return (point.getBlockX() >= locationMin.getBlockX() && point.getBlockX() <= locationMax.getBlockX()) &&
|
||||||
|
(point.getBlockY() >= locationMin.getBlockY() && point.getBlockY() <= locationMax.getBlockY()) &&
|
||||||
|
(point.getBlockZ() >= locationMin.getBlockZ() && point.getBlockZ() <= locationMax.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user