Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bece76fa8c |
57
.github/CONTRIBUTING.md
vendored
57
.github/CONTRIBUTING.md
vendored
@@ -1,57 +0,0 @@
|
|||||||
Contributing to BlockHunt
|
|
||||||
====
|
|
||||||
|
|
||||||
If you want to contribute to BlockHunt you're welcome to do so!
|
|
||||||
Just code what you would like to see or help with "Accepted" issues.
|
|
||||||
|
|
||||||
When committing use the following symbols:
|
|
||||||
|
|
||||||
*
|
|
||||||
+ For new features/code.
|
|
||||||
*
|
|
||||||
- For removed code.
|
|
||||||
*
|
|
||||||
* For fixes, like bugs.
|
|
||||||
* ~ Changed stuff/others.
|
|
||||||
|
|
||||||
Thanks for helping!
|
|
||||||
|
|
||||||
Read before posting issue
|
|
||||||
====
|
|
||||||
So if you have an issue regarding BlockHunt that's fine, just go through this check list before you go writing up new
|
|
||||||
issues that we have to deal with.
|
|
||||||
|
|
||||||
1: Plugins - The plugins that BlockHunt requires are ProtocolLib and LibsDisguise, both of these should be updated and
|
|
||||||
should be tested to see if they are working.
|
|
||||||
|
|
||||||
2: Bugs - Have you found a bug? Make sure it isn't anything else to do with the plugin. If you are reporting a bug after
|
|
||||||
you have updated to a new Bukkit/Spigot version then that is ok because with every new version comes new bugs
|
|
||||||
|
|
||||||
3: Conflicting plugin - These are the most common issue with BlockHunt, if you have installed a plugin and BlockHunt is
|
|
||||||
giving an error, then remove that plugin and don't go putting issues on that are not needed.
|
|
||||||
|
|
||||||
4: Ideas - New ideas are needed as always but please don't go spamming us saying "Add MySQL", Add this and that and
|
|
||||||
that. Some things we will add to improve BlockHunt but if we say that were not going to implement an idea into BlockHunt
|
|
||||||
then we won't
|
|
||||||
|
|
||||||
5: False Reports - Adding false issues to this page will only make our lives more difficult, if you're going to troll
|
|
||||||
then do it on someone else's plugin because personally that is the last thing on my mind.
|
|
||||||
|
|
||||||
6: Check everything - If you can't PVP in a BlockHunt arena then check every single last setting including your
|
|
||||||
WorldGuard settings and even your server.properties file as that has a true/false check for PVP
|
|
||||||
|
|
||||||
7: Check if the issue already exists - Look on GitHub at all the issues first before you go posting an issue, we are
|
|
||||||
again sick of marking issues as duplicates and then closing them
|
|
||||||
|
|
||||||
8: If it truly is an issue, report it, and we will deal with it as soon as ;3
|
|
||||||
|
|
||||||
NOTE: Bugs will always be fixed first before implementing ideas so please don't spam us.
|
|
||||||
|
|
||||||
Also, please do not message us via Bukkit as it is irritating, and we only respond to Plugin Developers
|
|
||||||
|
|
||||||
Thank you for reading this. The reason I have written this up is that we are sick to the back teeth of issues that don't
|
|
||||||
need to be reported.
|
|
||||||
|
|
||||||
Thank you,
|
|
||||||
|
|
||||||
Steffion, RandomPanda30, tempszz.
|
|
||||||
@@ -4,7 +4,7 @@ import me.libraryaddict.disguise.DisguiseAPI;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
|
import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
|
||||||
import net.knarcraft.blockhunt.arena.Arena;
|
import net.knarcraft.blockhunt.arena.Arena;
|
||||||
import net.knarcraft.blockhunt.arena.ArenaState;
|
import net.knarcraft.blockhunt.arena.ArenaGameState;
|
||||||
import net.knarcraft.blockhunt.config.MessageKey;
|
import net.knarcraft.blockhunt.config.MessageKey;
|
||||||
import net.knarcraft.blockhunt.listener.OnBlockBreakEvent;
|
import net.knarcraft.blockhunt.listener.OnBlockBreakEvent;
|
||||||
import net.knarcraft.blockhunt.listener.OnBlockPlaceEvent;
|
import net.knarcraft.blockhunt.listener.OnBlockPlaceEvent;
|
||||||
@@ -113,7 +113,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||||
String cause = "[BlockHunt] Arena " + arena.arenaName + " has been stopped";
|
String cause = "[BlockHunt] Arena " + arena.getArenaOptions().arenaName() + " has been stopped";
|
||||||
ArenaHelper.stopArena(arena, cause, MessageKey.WARNING_ARENA_STOPPED);
|
ArenaHelper.stopArena(arena, cause, MessageKey.WARNING_ARENA_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,28 +143,28 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
private void updateArenaStates() {
|
private void updateArenaStates() {
|
||||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||||
if (arena.gameState == ArenaState.WAITING) {
|
if (arena.getGameState() == ArenaGameState.WAITING) {
|
||||||
if (arena.playersInArena.size() >= arena.minPlayers) {
|
if (arena.getPlayersInArena().size() >= arena.getMinPlayers()) {
|
||||||
arena.gameState = ArenaState.STARTING;
|
arena.setGameState(ArenaGameState.STARTING);
|
||||||
arena.timer = arena.timeInLobbyUntilStart;
|
arena.setTimer(arena.getTimeInLobbyUntilStart());
|
||||||
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_LOBBY_ARENA_IS_STARTING, "1-" +
|
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_LOBBY_ARENA_IS_STARTING, "1-" +
|
||||||
arena.timeInLobbyUntilStart);
|
arena.getTimeInLobbyUntilStart());
|
||||||
}
|
}
|
||||||
} else if (arena.gameState == ArenaState.STARTING) {
|
} else if (arena.getGameState() == ArenaGameState.STARTING) {
|
||||||
updateStartingArena(arena);
|
updateStartingArena(arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Figure out a better way to do this. Currently, individual seeker timers are used to allow another
|
// TODO: Figure out a better way to do this. Currently, individual seeker timers are used to allow another
|
||||||
// player to take over if a seeker leaves the game. But assuming the game is already running, wouldn't it
|
// player to take over if a seeker leaves the game. But assuming the game is already running, wouldn't it
|
||||||
// make more sense to allow the seeker to seek immediately?
|
// make more sense to allow the seeker to seek immediately?
|
||||||
for (Player player : arena.seekers) {
|
for (Player player : arena.getSeekers()) {
|
||||||
// Reduce the seeker wait timer if necessary
|
// Reduce the seeker wait timer if necessary
|
||||||
Integer seekerTime = MemoryStorage.seekerTime.get(player);
|
Integer seekerTime = MemoryStorage.seekerTime.get(player);
|
||||||
if (seekerTime != null) {
|
if (seekerTime != null) {
|
||||||
MemoryStorage.seekerTime.put(player, --seekerTime);
|
MemoryStorage.seekerTime.put(player, --seekerTime);
|
||||||
if (seekerTime <= 0) {
|
if (seekerTime <= 0) {
|
||||||
// Teleport the seeker to the hiders warp, and allow them to seek
|
// Teleport the seeker to the hiders warp, and allow them to seek
|
||||||
PlayerHelper.teleport(player, arena.arenaLocations.getHidersWarp());
|
PlayerHelper.teleport(player, arena.getArenaLocations().getHidersWarp());
|
||||||
MemoryStorage.seekerTime.remove(player);
|
MemoryStorage.seekerTime.remove(player);
|
||||||
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_IN_GAME_SEEKER_SPAWNED,
|
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_IN_GAME_SEEKER_SPAWNED,
|
||||||
"%playerName%-" + player.getName());
|
"%playerName%-" + player.getName());
|
||||||
@@ -172,14 +172,14 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.gameState == ArenaState.IN_GAME) {
|
if (arena.getGameState() == ArenaGameState.IN_GAME) {
|
||||||
updateInGameArena(arena);
|
updateInGameArena(arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display countdown as the player's XP level
|
// Display countdown as the player's XP level
|
||||||
for (Player player : arena.playersInArena) {
|
for (Player player : arena.getPlayersInArena()) {
|
||||||
player.setLevel(arena.timer);
|
player.setLevel(arena.getTimer());
|
||||||
if (arena.seekers.contains(player)) {
|
if (arena.getSeekers().contains(player)) {
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
} else {
|
} else {
|
||||||
player.setGameMode(GameMode.ADVENTURE);
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
@@ -196,24 +196,24 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
*/
|
*/
|
||||||
private void updateStartingArena(Arena arena) {
|
private void updateStartingArena(Arena arena) {
|
||||||
// Reduce the arena's timer
|
// Reduce the arena's timer
|
||||||
arena.timer -= 1;
|
arena.setTimer(arena.getTimer() - 1);
|
||||||
if (arena.timer > 0) {
|
if (arena.getTimer() > 0) {
|
||||||
if (arena.timer == 60 || arena.timer == 30 || arena.timer == 10) {
|
if (arena.getTimer() == 60 || arena.getTimer() == 30 || arena.getTimer() == 10) {
|
||||||
// Announce when the arena starts
|
// Announce when the arena starts
|
||||||
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_LOBBY_ARENA_IS_STARTING, "1-" + arena.timer);
|
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_LOBBY_ARENA_IS_STARTING, "1-" + arena.getTimer());
|
||||||
} else if (arena.timer <= 5) {
|
} else if (arena.getTimer() <= 5) {
|
||||||
// Count down from 5 seconds
|
// Count down from 5 seconds
|
||||||
World world = null;
|
World world = null;
|
||||||
Location warp = arena.arenaLocations.getLobbyWarp();
|
Location warp = arena.getArenaLocations().getLobbyWarp();
|
||||||
if (warp != null) {
|
if (warp != null) {
|
||||||
world = warp.getWorld();
|
world = warp.getWorld();
|
||||||
}
|
}
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
int pitch = (int) (2 - Math.floor(arena.timer / 2.0));
|
int pitch = (int) (2 - Math.floor(arena.getTimer() / 2.0));
|
||||||
world.playSound(arena.arenaLocations.getLobbyWarp(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1,
|
world.playSound(arena.getArenaLocations().getLobbyWarp(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1,
|
||||||
pitch);
|
pitch);
|
||||||
}
|
}
|
||||||
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_LOBBY_ARENA_IS_STARTING, "1-" + arena.timer);
|
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_LOBBY_ARENA_IS_STARTING, "1-" + arena.getTimer());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
startArena(arena);
|
startArena(arena);
|
||||||
@@ -227,8 +227,8 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
*/
|
*/
|
||||||
private void startArena(Arena arena) {
|
private void startArena(Arena arena) {
|
||||||
// Update the game state, and set the timer to count down from the specified game-time
|
// Update the game state, and set the timer to count down from the specified game-time
|
||||||
arena.gameState = ArenaState.IN_GAME;
|
arena.setGameState(ArenaGameState.IN_GAME);
|
||||||
arena.timer = arena.gameTime;
|
arena.setTimer(arena.getGameTime());
|
||||||
|
|
||||||
// Assign the necessary seekers
|
// Assign the necessary seekers
|
||||||
assignSeekers(arena);
|
assignSeekers(arena);
|
||||||
@@ -236,10 +236,10 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
// Assign the necessary hiders
|
// Assign the necessary hiders
|
||||||
assignHiders(arena);
|
assignHiders(arena);
|
||||||
|
|
||||||
MessageHelper.broadcastMessage(arena.hiders, MessageKey.NORMAL_LOBBY_ARENA_STARTED_HIDERS,
|
MessageHelper.broadcastMessage(arena.getHiders(), MessageKey.NORMAL_LOBBY_ARENA_STARTED_HIDERS,
|
||||||
"seconds-" + arena.waitingTimeSeeker);
|
"seconds-" + arena.getWaitingTimeSeeker());
|
||||||
MessageHelper.broadcastMessage(arena.seekers, MessageKey.NORMAL_LOBBY_ARENA_STARTED_SEEKERS,
|
MessageHelper.broadcastMessage(arena.getSeekers(), MessageKey.NORMAL_LOBBY_ARENA_STARTED_SEEKERS,
|
||||||
"seconds-" + arena.waitingTimeSeeker);
|
"seconds-" + arena.getWaitingTimeSeeker());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -248,17 +248,17 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
* @param arena <p>The arena to assign hiders for</p>
|
* @param arena <p>The arena to assign hiders for</p>
|
||||||
*/
|
*/
|
||||||
private void assignHiders(Arena arena) {
|
private void assignHiders(Arena arena) {
|
||||||
List<Player> possibleHiders = new ArrayList<>(arena.playersInArena);
|
List<Player> possibleHiders = new ArrayList<>(arena.getPlayersInArena());
|
||||||
possibleHiders.removeAll(arena.seekers);
|
possibleHiders.removeAll(arena.getSeekers());
|
||||||
|
|
||||||
// Assign all non-seekers to hiders
|
// Assign all non-seekers to hiders
|
||||||
for (Player arenaPlayer : possibleHiders) {
|
for (Player arenaPlayer : possibleHiders) {
|
||||||
arena.hiders.add(arenaPlayer);
|
arena.getHiders().add(arenaPlayer);
|
||||||
// Clear the player's inventory
|
// Clear the player's inventory
|
||||||
arenaPlayer.getInventory().clear();
|
arenaPlayer.getInventory().clear();
|
||||||
|
|
||||||
// Assign a random disguise block
|
// Assign a random disguise block
|
||||||
ItemStack block = arena.disguiseBlocks.get(MemoryStorage.random.nextInt(arena.disguiseBlocks.size()));
|
ItemStack block = arena.getDisguiseBlocks().get(MemoryStorage.random.nextInt(arena.getDisguiseBlocks().size()));
|
||||||
// If the player has chosen their block type, use that instead
|
// If the player has chosen their block type, use that instead
|
||||||
if (MemoryStorage.chosenBlock.get(arenaPlayer) != null) {
|
if (MemoryStorage.chosenBlock.get(arenaPlayer) != null) {
|
||||||
block = MemoryStorage.chosenBlock.get(arenaPlayer);
|
block = MemoryStorage.chosenBlock.get(arenaPlayer);
|
||||||
@@ -270,7 +270,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
DisguiseAPI.disguiseToAll(arenaPlayer, disguise);
|
DisguiseAPI.disguiseToAll(arenaPlayer, disguise);
|
||||||
|
|
||||||
// Teleport to the hiders warp
|
// Teleport to the hiders warp
|
||||||
PlayerHelper.teleport(arenaPlayer, arena.arenaLocations.getHidersWarp());
|
PlayerHelper.teleport(arenaPlayer, arena.getArenaLocations().getHidersWarp());
|
||||||
|
|
||||||
// Put the block in the player's inventory and on the player's head, so they know which block they are
|
// Put the block in the player's inventory and on the player's head, so they know which block they are
|
||||||
ItemStack blockTimer = new ItemStack(block.getType(), 5);
|
ItemStack blockTimer = new ItemStack(block.getType(), 5);
|
||||||
@@ -292,11 +292,11 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
* @param arena <p>The arena to assign seekers to</p>
|
* @param arena <p>The arena to assign seekers to</p>
|
||||||
*/
|
*/
|
||||||
private void assignSeekers(Arena arena) {
|
private void assignSeekers(Arena arena) {
|
||||||
List<Player> possibleSeekers = new ArrayList<>(arena.playersInArena);
|
List<Player> possibleSeekers = new ArrayList<>(arena.getPlayersInArena());
|
||||||
|
|
||||||
// Prioritize players that have asked to be seekers
|
// Prioritize players that have asked to be seekers
|
||||||
int seekers = 0;
|
int seekers = 0;
|
||||||
for (Player player : arena.playersInArena) {
|
for (Player player : arena.getPlayersInArena()) {
|
||||||
/* Add the player as a seeker if they prefer to be a seeker, or remove them from possible seekers if they
|
/* Add the player as a seeker if they prefer to be a seeker, or remove them from possible seekers if they
|
||||||
have set themselves as a hider */
|
have set themselves as a hider */
|
||||||
Boolean chosenSeeker = MemoryStorage.chosenSeeker.get(player);
|
Boolean chosenSeeker = MemoryStorage.chosenSeeker.get(player);
|
||||||
@@ -308,13 +308,13 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prevent more than the max amount of seekers from being assigned
|
// Prevent more than the max amount of seekers from being assigned
|
||||||
if (seekers >= arena.amountSeekersOnStart) {
|
if (seekers >= arena.getAmountSeekersOnStart()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Randomly assign the required amount of seekers
|
// Randomly assign the required amount of seekers
|
||||||
for (int i = seekers; i < arena.amountSeekersOnStart; i++) {
|
for (int i = seekers; i < arena.getAmountSeekersOnStart(); i++) {
|
||||||
// Prevent an infinite loop if it's impossible to assign the required amount of seekers
|
// Prevent an infinite loop if it's impossible to assign the required amount of seekers
|
||||||
if (possibleSeekers.size() == 0) {
|
if (possibleSeekers.size() == 0) {
|
||||||
break;
|
break;
|
||||||
@@ -334,11 +334,11 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
*/
|
*/
|
||||||
private void addSeeker(Arena arena, Player player) {
|
private void addSeeker(Arena arena, Player player) {
|
||||||
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_IN_GAME_SEEKER_CHOSEN, "seeker-" + player.getName());
|
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_IN_GAME_SEEKER_CHOSEN, "seeker-" + player.getName());
|
||||||
arena.seekers.add(player);
|
arena.getSeekers().add(player);
|
||||||
PlayerHelper.teleport(player, arena.arenaLocations.getSeekersWarp());
|
PlayerHelper.teleport(player, arena.getArenaLocations().getSeekersWarp());
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
player.setWalkSpeed(0.3F);
|
player.setWalkSpeed(0.3F);
|
||||||
MemoryStorage.seekerTime.put(player, arena.waitingTimeSeeker);
|
MemoryStorage.seekerTime.put(player, arena.getWaitingTimeSeeker());
|
||||||
|
|
||||||
// Give the seeker their armor and sword
|
// Give the seeker their armor and sword
|
||||||
giveSeekerItems(player);
|
giveSeekerItems(player);
|
||||||
@@ -372,29 +372,29 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
* @param arena <P>The arena to update</P>
|
* @param arena <P>The arena to update</P>
|
||||||
*/
|
*/
|
||||||
private void updateInGameArena(Arena arena) {
|
private void updateInGameArena(Arena arena) {
|
||||||
arena.timer--;
|
arena.setTimer(arena.getTimer() - 1);
|
||||||
|
|
||||||
// If the game ends, trigger the hiders' win
|
// If the game ends, trigger the hiders' win
|
||||||
if (arena.timer <= 0) {
|
if (arena.getTimer() <= 0) {
|
||||||
ArenaHelper.hidersWin(arena);
|
ArenaHelper.hidersWin(arena);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If "timeUntilHidersSword" has passed, give the hiders their sword
|
// If "timeUntilHidersSword" has passed, give the hiders their sword
|
||||||
if (arena.timer == arena.gameTime - arena.timeUntilHidersSword) {
|
if (arena.getTimer() == arena.getGameTime() - arena.getTimeUntilHidersSword()) {
|
||||||
ItemStack sword = new ItemStack(Material.WOODEN_SWORD, 1);
|
ItemStack sword = new ItemStack(Material.WOODEN_SWORD, 1);
|
||||||
sword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2);
|
sword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2);
|
||||||
|
|
||||||
for (Player arenaPlayer : arena.hiders) {
|
for (Player arenaPlayer : arena.getHiders()) {
|
||||||
arenaPlayer.getInventory().addItem(sword);
|
arenaPlayer.getInventory().addItem(sword);
|
||||||
MessageHelper.sendMessage(arenaPlayer, MessageKey.NORMAL_IN_GAME_GIVEN_SWORD);
|
MessageHelper.sendMessage(arenaPlayer, MessageKey.NORMAL_IN_GAME_GIVEN_SWORD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Announce the type of blocks the remaining hiders are disguised as
|
// Announce the type of blocks the remaining hiders are disguised as
|
||||||
if (arena.blockAnnouncerTime > 0 && arena.timer == arena.blockAnnouncerTime) {
|
if (arena.getBlockAnnouncerTime() > 0 && arena.getTimer() == arena.getBlockAnnouncerTime()) {
|
||||||
Set<String> remainingBlocks = new HashSet<>();
|
Set<String> remainingBlocks = new HashSet<>();
|
||||||
for (Player arenaPlayer : arena.hiders) {
|
for (Player arenaPlayer : arena.getHiders()) {
|
||||||
ItemStack item = arenaPlayer.getInventory().getItem(8);
|
ItemStack item = arenaPlayer.getInventory().getItem(8);
|
||||||
String block = (item == null ? Material.AIR : item.getType()).name();
|
String block = (item == null ? Material.AIR : item.getType()).name();
|
||||||
remainingBlocks.add(uppercaseAllFirst(block.replace("_", " ")));
|
remainingBlocks.add(uppercaseAllFirst(block.replace("_", " ")));
|
||||||
@@ -404,61 +404,24 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Count down towards the end of the arena
|
// Count down towards the end of the arena
|
||||||
if (arena.timer == 190 || arena.timer == 60 || arena.timer == 30 || arena.timer == 10 || arena.timer <= 5) {
|
if (arena.getTimer() == 190 || arena.getTimer() == 60 || arena.getTimer() == 30 || arena.getTimer() == 10 || arena.getTimer() <= 5) {
|
||||||
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_IN_GAME_ARENA_END, "1-" + arena.timer);
|
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_IN_GAME_ARENA_END, "1-" + arena.getTimer());
|
||||||
}
|
}
|
||||||
// Play a sound for the last 5 seconds of the arena game's duration
|
// Play a sound for the last 5 seconds of the arena game's duration
|
||||||
if (arena.timer <= 5) {
|
if (arena.getTimer() <= 5) {
|
||||||
Location location = arena.arenaLocations.getLobbyWarp();
|
Location location = arena.getArenaLocations().getLobbyWarp();
|
||||||
if (location != null && location.getWorld() != null) {
|
if (location != null && location.getWorld() != null) {
|
||||||
int pitch = (int) (2 - Math.floor(arena.timer / 2.0));
|
int pitch = (int) (2 - Math.floor(arena.getTimer() / 2.0));
|
||||||
location.getWorld().playSound(arena.arenaLocations.getLobbyWarp(),
|
location.getWorld().playSound(arena.getArenaLocations().getLobbyWarp(),
|
||||||
Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, pitch);
|
Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, pitch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player player : arena.hiders) {
|
for (Player player : arena.getHiders()) {
|
||||||
updateHiddenState(player);
|
VisibilityHelper.updateHiddenState(player);
|
||||||
}
|
}
|
||||||
ScoreboardHelper.updateScoreboard(arena); // TODO Only do this when needed (player added/removed)
|
ScoreboardHelper.updateScoreboard(arena); // TODO Only do this when needed (player added/removed)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the hidden state of the given hider
|
|
||||||
*
|
|
||||||
* @param player <p>A player that's currently a hider</p>
|
|
||||||
*/
|
|
||||||
private void updateHiddenState(Player player) {
|
|
||||||
Location playerLocation = player.getLocation();
|
|
||||||
Location moveLocation = MemoryStorage.moveLocation.get(player);
|
|
||||||
|
|
||||||
// If the hider has somehow lost their disguise block from their inventory,
|
|
||||||
ItemStack inventoryBlock = player.getInventory().getItem(8);
|
|
||||||
if (inventoryBlock == null && MemoryStorage.playerBlock.get(player) != null) {
|
|
||||||
inventoryBlock = MemoryStorage.playerBlock.get(player);
|
|
||||||
player.getInventory().setItem(8, inventoryBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (moveLocation == null || inventoryBlock == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the player is standing still, try to turn the player into a solid block
|
|
||||||
if (moveLocation.getX() == playerLocation.getX() && moveLocation.getY() == playerLocation.getY() &&
|
|
||||||
moveLocation.getZ() == playerLocation.getZ()) {
|
|
||||||
if (inventoryBlock.getAmount() > 1) {
|
|
||||||
// Just decrease the timer
|
|
||||||
inventoryBlock.setAmount(inventoryBlock.getAmount() - 1);
|
|
||||||
} else {
|
|
||||||
VisibilityHelper.makePlayerSolid(player, inventoryBlock);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// The player moved. Un-hide and reset the hide timer
|
|
||||||
inventoryBlock.setAmount(5);
|
|
||||||
if (!DisguiseAPI.isDisguised(player)) {
|
|
||||||
VisibilityHelper.makePlayerUnSolid(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,142 +18,58 @@ import java.util.Map;
|
|||||||
@SerializableAs("BlockHuntArena")
|
@SerializableAs("BlockHuntArena")
|
||||||
public class Arena implements ConfigurationSerializable {
|
public class Arena implements ConfigurationSerializable {
|
||||||
|
|
||||||
/**
|
private int maxPlayers;
|
||||||
* The name of this arena
|
private int minPlayers;
|
||||||
*/
|
private int amountSeekersOnStart;
|
||||||
public final String arenaName;
|
private int timeInLobbyUntilStart;
|
||||||
|
private int waitingTimeSeeker;
|
||||||
|
private int gameTime;
|
||||||
|
private int timeUntilHidersSword;
|
||||||
|
private int blockAnnouncerTime;
|
||||||
|
private List<ItemStack> disguiseBlocks;
|
||||||
|
private int seekersTokenWin;
|
||||||
|
private int hidersTokenWin;
|
||||||
|
private int killTokens;
|
||||||
|
private ArenaGameState gameState;
|
||||||
|
private final ArenaOptions arenaOptions;
|
||||||
|
private final ArenaLocations arenaLocations;
|
||||||
|
private int timer;
|
||||||
|
|
||||||
|
private final List<Player> playersInArena;
|
||||||
|
private final List<Player> seekers;
|
||||||
|
private final List<Player> hiders;
|
||||||
|
private final Scoreboard scoreboard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum amount of players that can join at once
|
* Instantiates a new arena
|
||||||
|
*
|
||||||
|
* @param arenaOptions <p>The arena's immutable options</p>
|
||||||
|
* @param arenaLocations <p>The various locations for the arena</p>
|
||||||
|
* @param maxPlayers <p>The maximum amount of players that can join at once</p>
|
||||||
|
* @param minPlayers <p>The minimum amount of players required for the arena to start</p>
|
||||||
|
* @param amountSeekersOnStart <p>The amount of players made into seekers when this arena starts</p>
|
||||||
|
* @param timeInLobbyUntilStart <p>The amount of seconds players have to wait in the lobby before this arena starts</p>
|
||||||
|
* @param waitingTimeSeeker <p>The amount of time seekers have to wait before they can start seeking</p>
|
||||||
|
* @param gameTime <p>The amount of seconds the game will last before hiders automatically win</p>
|
||||||
|
* @param timeUntilHidersSword <p>The amount of seconds until hiders get swords to defend themselves</p>
|
||||||
|
* @param blockAnnouncerTime <p>The amount of seconds left of the game when remaining hidden blocks are announced</p>
|
||||||
|
* @param disguiseBlocks <p>The blocks players can disguise into when playing in the arena</p>
|
||||||
|
* @param seekersTokenWin <p>The amount of tokens granted to each seeker if seekers win</p>
|
||||||
|
* @param hidersTokenWin <p>The amount of tokens granted to each hider if hiders win</p>
|
||||||
|
* @param killTokens <p>The amount of tokens granted for killing another player</p>
|
||||||
|
* @param playersInArena <p>The players currently in this arena</p>
|
||||||
|
* @param gameState <p>The current game state of this arena</p>
|
||||||
|
* @param timer <p>The current value of this arena's game timer</p>
|
||||||
|
* @param seekers <p>The seekers currently in this arena</p>
|
||||||
|
* @param scoreboard <p>This arena's scoreboard</p>
|
||||||
*/
|
*/
|
||||||
public int maxPlayers;
|
public Arena(ArenaOptions arenaOptions, ArenaLocations arenaLocations, int maxPlayers, int minPlayers,
|
||||||
|
|
||||||
/**
|
|
||||||
* The minimum amount of players required for the arena to start
|
|
||||||
*/
|
|
||||||
public int minPlayers;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The amount of players made into seekers when this arena starts
|
|
||||||
*/
|
|
||||||
public int amountSeekersOnStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The amount of seconds players have to wait in the lobby before this arena starts
|
|
||||||
*/
|
|
||||||
public int timeInLobbyUntilStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The amount of time seekers have to wait before they can start seeking
|
|
||||||
*/
|
|
||||||
public int waitingTimeSeeker;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The amount of seconds the game will last before hiders automatically win
|
|
||||||
*/
|
|
||||||
public int gameTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The amount of seconds until hiders get swords to defend themselves
|
|
||||||
*/
|
|
||||||
public int timeUntilHidersSword;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The amount of seconds left of the game when remaining hidden blocks are announced
|
|
||||||
*/
|
|
||||||
public int blockAnnouncerTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether seekers can hurt other seekers
|
|
||||||
*/
|
|
||||||
public final boolean seekersCanHurtSeekers;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether hiders can hurt seekers
|
|
||||||
*/
|
|
||||||
public final boolean hidersCanHurtSeekers;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether hiders can hurt other hiders
|
|
||||||
*/
|
|
||||||
public final boolean hidersCanHurtHiders;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether seekers take fall damage
|
|
||||||
*/
|
|
||||||
public final boolean seekersTakeFallDamage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether hiders take fall damage
|
|
||||||
*/
|
|
||||||
public final boolean hidersTakeFallDamage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The blocks allowed for disguises
|
|
||||||
*/
|
|
||||||
public List<ItemStack> disguiseBlocks;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The commands to be run on the seekers if the seekers win (%player%)
|
|
||||||
*/
|
|
||||||
public final List<String> seekersWinCommands;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The commands to be run on the hiders if the hiders win (%player%)
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The amount of tokens granted to each seeker if seekers win
|
|
||||||
*/
|
|
||||||
public int seekersTokenWin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The amount of tokens granted to each hider if hiders win
|
|
||||||
*/
|
|
||||||
public int hidersTokenWin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The amount of tokens granted for killing another player
|
|
||||||
*/
|
|
||||||
public int killTokens;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The players currently in this arena
|
|
||||||
*/
|
|
||||||
public final List<Player> playersInArena;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current state of this arena
|
|
||||||
*/
|
|
||||||
public ArenaState gameState;
|
|
||||||
|
|
||||||
public final ArenaLocations arenaLocations;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A timer that counts from the game duration towards 0
|
|
||||||
*/
|
|
||||||
public int timer;
|
|
||||||
public final List<Player> seekers;
|
|
||||||
public final List<Player> hiders;
|
|
||||||
public final Scoreboard scoreboard;
|
|
||||||
|
|
||||||
public Arena(String arenaName, Location corner1, Location corner2, int maxPlayers, int minPlayers,
|
|
||||||
int amountSeekersOnStart, int timeInLobbyUntilStart, int waitingTimeSeeker, int gameTime,
|
int amountSeekersOnStart, int timeInLobbyUntilStart, int waitingTimeSeeker, int gameTime,
|
||||||
int timeUntilHidersSword, int blockAnnouncerTime, boolean seekersCanHurtSeekers,
|
int timeUntilHidersSword, int blockAnnouncerTime,
|
||||||
boolean hidersCanHurtSeekers, boolean hidersCanHurtHiders, boolean seekersTakeFallDamage,
|
List<ItemStack> disguiseBlocks, int seekersTokenWin, int hidersTokenWin,
|
||||||
boolean hidersTakeFallDamage, List<ItemStack> disguiseBlocks, Location lobbyWarp, Location hidersWarp,
|
int killTokens, List<Player> playersInArena, ArenaGameState gameState, int timer, List<Player> seekers,
|
||||||
Location seekersWarp, Location spawnWarp, List<String> seekersWinCommands,
|
|
||||||
List<String> hidersWinCommands, List<String> allowedCommands, int seekersTokenWin, int hidersTokenWin,
|
|
||||||
int killTokens, List<Player> playersInArena, ArenaState gameState, int timer, List<Player> seekers,
|
|
||||||
Scoreboard scoreboard) {
|
Scoreboard scoreboard) {
|
||||||
this.arenaName = arenaName;
|
this.arenaOptions = arenaOptions;
|
||||||
this.maxPlayers = maxPlayers;
|
this.maxPlayers = maxPlayers;
|
||||||
this.minPlayers = minPlayers;
|
this.minPlayers = minPlayers;
|
||||||
this.amountSeekersOnStart = amountSeekersOnStart;
|
this.amountSeekersOnStart = amountSeekersOnStart;
|
||||||
@@ -162,15 +78,7 @@ public class Arena implements ConfigurationSerializable {
|
|||||||
this.gameTime = gameTime;
|
this.gameTime = gameTime;
|
||||||
this.timeUntilHidersSword = timeUntilHidersSword;
|
this.timeUntilHidersSword = timeUntilHidersSword;
|
||||||
this.blockAnnouncerTime = blockAnnouncerTime;
|
this.blockAnnouncerTime = blockAnnouncerTime;
|
||||||
this.seekersCanHurtSeekers = seekersCanHurtSeekers;
|
|
||||||
this.hidersCanHurtHiders = hidersCanHurtHiders;
|
|
||||||
this.hidersCanHurtSeekers = hidersCanHurtSeekers;
|
|
||||||
this.seekersTakeFallDamage = seekersTakeFallDamage;
|
|
||||||
this.hidersTakeFallDamage = hidersTakeFallDamage;
|
|
||||||
this.disguiseBlocks = disguiseBlocks;
|
this.disguiseBlocks = disguiseBlocks;
|
||||||
this.seekersWinCommands = seekersWinCommands;
|
|
||||||
this.hidersWinCommands = hidersWinCommands;
|
|
||||||
this.allowedCommands = allowedCommands;
|
|
||||||
this.seekersTokenWin = seekersTokenWin;
|
this.seekersTokenWin = seekersTokenWin;
|
||||||
this.hidersTokenWin = hidersTokenWin;
|
this.hidersTokenWin = hidersTokenWin;
|
||||||
this.killTokens = killTokens;
|
this.killTokens = killTokens;
|
||||||
@@ -181,13 +89,309 @@ public class Arena implements ConfigurationSerializable {
|
|||||||
this.hiders = new ArrayList<>(playersInArena);
|
this.hiders = new ArrayList<>(playersInArena);
|
||||||
this.hiders.removeAll(seekers);
|
this.hiders.removeAll(seekers);
|
||||||
this.scoreboard = scoreboard;
|
this.scoreboard = scoreboard;
|
||||||
this.arenaLocations = new ArenaLocations(corner1, corner2, lobbyWarp, hidersWarp, seekersWarp, spawnWarp);
|
this.arenaLocations = arenaLocations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the maximum amount of players that can join at once
|
||||||
|
*
|
||||||
|
* @return <p>The maximum amount of players that can join at once</p>
|
||||||
|
*/
|
||||||
|
public int getMaxPlayers() {
|
||||||
|
return maxPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the maximum amount of players that can join at once
|
||||||
|
*
|
||||||
|
* @param maxPlayers <p>The maximum amount of players that can join at once</p>
|
||||||
|
*/
|
||||||
|
public void setMaxPlayers(int maxPlayers) {
|
||||||
|
if (maxPlayers > 1) {
|
||||||
|
this.maxPlayers = maxPlayers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the minimum amount of players required for this arena to start
|
||||||
|
*
|
||||||
|
* @return <p>The minimum amount of players required for this arena to start</p>
|
||||||
|
*/
|
||||||
|
public int getMinPlayers() {
|
||||||
|
return minPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the minimum amount of players required for this arena to start
|
||||||
|
*
|
||||||
|
* @param minPlayers <p>The minimum amount of players required for this arena to start</p>
|
||||||
|
*/
|
||||||
|
public void setMinPlayers(int minPlayers) {
|
||||||
|
if (minPlayers > 0 && minPlayers <= maxPlayers) {
|
||||||
|
this.minPlayers = minPlayers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of players made into seekers when this arena starts
|
||||||
|
*
|
||||||
|
* @return <p>The amount of players made into seekers when this arena starts</p>
|
||||||
|
*/
|
||||||
|
public int getAmountSeekersOnStart() {
|
||||||
|
return amountSeekersOnStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the amount of players made into seekers when this arena starts
|
||||||
|
*
|
||||||
|
* @param amountSeekersOnStart <p>The amount of players made into seekers when this arena starts</p>
|
||||||
|
*/
|
||||||
|
public void setAmountSeekersOnStart(int amountSeekersOnStart) {
|
||||||
|
this.amountSeekersOnStart = amountSeekersOnStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of seconds players have to wait in the lobby before this arena starts
|
||||||
|
*
|
||||||
|
* @return <p>The amount of seconds players have to wait in the lobby before this arena starts</p>
|
||||||
|
*/
|
||||||
|
public int getTimeInLobbyUntilStart() {
|
||||||
|
return timeInLobbyUntilStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the amount of seconds players have to wait in the lobby before this arena starts
|
||||||
|
*
|
||||||
|
* @param timeInLobbyUntilStart <p>The amount of seconds players have to wait in the lobby before this arena starts</p>
|
||||||
|
*/
|
||||||
|
public void setTimeInLobbyUntilStart(int timeInLobbyUntilStart) {
|
||||||
|
if (timeInLobbyUntilStart >= 0) {
|
||||||
|
this.timeInLobbyUntilStart = timeInLobbyUntilStart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of time seekers have to wait before they can start seeking
|
||||||
|
*
|
||||||
|
* @return <p>The amount of time seekers have to wait before they can start seeking</p>
|
||||||
|
*/
|
||||||
|
public int getWaitingTimeSeeker() {
|
||||||
|
return waitingTimeSeeker;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the amount of time seekers have to wait before they can start seeking
|
||||||
|
*
|
||||||
|
* @param waitingTimeSeeker <p>The amount of time seekers have to wait before they can start seeking</p>
|
||||||
|
*/
|
||||||
|
public void setWaitingTimeSeeker(int waitingTimeSeeker) {
|
||||||
|
if (waitingTimeSeeker > 0) {
|
||||||
|
this.waitingTimeSeeker = waitingTimeSeeker;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of seconds the game will last before hiders automatically win
|
||||||
|
*
|
||||||
|
* @return <p>The amount of seconds the game will last before hiders automatically win</p>
|
||||||
|
*/
|
||||||
|
public int getGameTime() {
|
||||||
|
return gameTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the amount of seconds the game will last before hiders automatically win
|
||||||
|
*
|
||||||
|
* @param gameTime <p>The amount of seconds the game will last before hiders automatically win</p>
|
||||||
|
*/
|
||||||
|
public void setGameTime(int gameTime) {
|
||||||
|
if (gameTime > 0) {
|
||||||
|
this.gameTime = gameTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of seconds until hiders get swords to defend themselves
|
||||||
|
*
|
||||||
|
* @return <p>The amount of seconds until hiders get swords to defend themselves</p>
|
||||||
|
*/
|
||||||
|
public int getTimeUntilHidersSword() {
|
||||||
|
return timeUntilHidersSword;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the amount of seconds until hiders get swords to defend themselves
|
||||||
|
*
|
||||||
|
* @param timeUntilHidersSword <p>The amount of seconds until hiders get swords to defend themselves</p>
|
||||||
|
*/
|
||||||
|
public void setTimeUntilHidersSword(int timeUntilHidersSword) {
|
||||||
|
if (timeUntilHidersSword >= 0) {
|
||||||
|
this.timeUntilHidersSword = timeUntilHidersSword;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of seconds left of the game when remaining hidden blocks are announced
|
||||||
|
*
|
||||||
|
* @return <p>The amount of seconds left of the game when remaining hidden blocks are announced</p>
|
||||||
|
*/
|
||||||
|
public int getBlockAnnouncerTime() {
|
||||||
|
return blockAnnouncerTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the amount of seconds left of the game when remaining hidden blocks are announced
|
||||||
|
*
|
||||||
|
* @param blockAnnouncerTime <p>The amount of seconds left of the game when remaining hidden blocks are announced</p>
|
||||||
|
*/
|
||||||
|
public void setBlockAnnouncerTime(int blockAnnouncerTime) {
|
||||||
|
if (blockAnnouncerTime >= 0) {
|
||||||
|
this.blockAnnouncerTime = blockAnnouncerTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the blocks players can disguise into when playing in this arena
|
||||||
|
*
|
||||||
|
* @return <p>The blocks players can disguise into when playing in this arena</p>
|
||||||
|
*/
|
||||||
|
public List<ItemStack> getDisguiseBlocks() {
|
||||||
|
return disguiseBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the blocks players can disguise into when playing in this arena
|
||||||
|
*
|
||||||
|
* @param disguiseBlocks <p>The blocks players can disguise into when playing in this arena</p>
|
||||||
|
*/
|
||||||
|
public void setDisguiseBlocks(@NotNull List<ItemStack> disguiseBlocks) {
|
||||||
|
this.disguiseBlocks = disguiseBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of tokens granted to each seeker if seekers win
|
||||||
|
*
|
||||||
|
* @return <p>The amount of tokens granted to each seeker if seekers win</p>
|
||||||
|
*/
|
||||||
|
public int getSeekersTokenWin() {
|
||||||
|
return seekersTokenWin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the amount of tokens granted to each seeker if seekers win
|
||||||
|
*
|
||||||
|
* @param seekersTokenWin <p>The amount of tokens granted to each seeker if seekers win</p>
|
||||||
|
*/
|
||||||
|
public void setSeekersTokenWin(int seekersTokenWin) {
|
||||||
|
if (seekersTokenWin >= 0) {
|
||||||
|
this.seekersTokenWin = seekersTokenWin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of tokens granted to each hider if hiders win
|
||||||
|
*
|
||||||
|
* @return <p>The amount of tokens granted to each hider if hiders win</p>
|
||||||
|
*/
|
||||||
|
public int getHidersTokenWin() {
|
||||||
|
return hidersTokenWin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the amount of tokens granted to each hider if hiders win
|
||||||
|
*
|
||||||
|
* @param hidersTokenWin <p>The amount of tokens granted to each hider if hiders win</p>
|
||||||
|
*/
|
||||||
|
public void setHidersTokenWin(int hidersTokenWin) {
|
||||||
|
if (hidersTokenWin >= 0) {
|
||||||
|
this.hidersTokenWin = hidersTokenWin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of tokens granted for killing another player
|
||||||
|
*
|
||||||
|
* @return <p>The amount of tokens granted for killing another player</p>
|
||||||
|
*/
|
||||||
|
public int getKillTokens() {
|
||||||
|
return killTokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the amount of tokens granted for killing another player
|
||||||
|
*
|
||||||
|
* @param killTokens <p>The amount of tokens granted for killing another player</p>
|
||||||
|
*/
|
||||||
|
public void setKillTokens(int killTokens) {
|
||||||
|
if (killTokens >= 0) {
|
||||||
|
this.killTokens = killTokens;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current game state of this arena
|
||||||
|
*
|
||||||
|
* @return <p>The current game state of this arena</p>
|
||||||
|
*/
|
||||||
|
public ArenaGameState getGameState() {
|
||||||
|
return gameState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current game state of this arena
|
||||||
|
*
|
||||||
|
* @param gameState <p>The current game state of this arena</p>
|
||||||
|
*/
|
||||||
|
public void setGameState(@NotNull ArenaGameState gameState) {
|
||||||
|
this.gameState = gameState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets this arena's immutable options
|
||||||
|
*
|
||||||
|
* @return <p>This arena's immutable options</p>
|
||||||
|
*/
|
||||||
|
public ArenaOptions getArenaOptions() {
|
||||||
|
return arenaOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the various locations for this arena
|
||||||
|
*
|
||||||
|
* @return <p>The various locations for this arena</p>
|
||||||
|
*/
|
||||||
|
public ArenaLocations getArenaLocations() {
|
||||||
|
return arenaLocations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTimer() {
|
||||||
|
return timer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimer(int timer) {
|
||||||
|
this.timer = timer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> getPlayersInArena() {
|
||||||
|
return playersInArena;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> getSeekers() {
|
||||||
|
return seekers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> getHiders() {
|
||||||
|
return hiders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Scoreboard getScoreboard() {
|
||||||
|
return scoreboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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", arenaOptions.arenaName());
|
||||||
map.put("pos1", arenaLocations.getCorner1());
|
map.put("pos1", arenaLocations.getCorner1());
|
||||||
map.put("pos2", arenaLocations.getCorner2());
|
map.put("pos2", arenaLocations.getCorner2());
|
||||||
map.put("maxPlayers", maxPlayers);
|
map.put("maxPlayers", maxPlayers);
|
||||||
@@ -198,19 +402,19 @@ public class Arena implements ConfigurationSerializable {
|
|||||||
map.put("gameTime", gameTime);
|
map.put("gameTime", gameTime);
|
||||||
map.put("timeUntilHidersSword", timeUntilHidersSword);
|
map.put("timeUntilHidersSword", timeUntilHidersSword);
|
||||||
map.put("blockAnnouncerTime", blockAnnouncerTime);
|
map.put("blockAnnouncerTime", blockAnnouncerTime);
|
||||||
map.put("seekersCanHurtSeekers", seekersCanHurtSeekers);
|
map.put("seekersCanHurtSeekers", arenaOptions.seekersCanHurtSeekers());
|
||||||
map.put("hidersCanHurtSeekers", hidersCanHurtSeekers);
|
map.put("hidersCanHurtSeekers", arenaOptions.hidersCanHurtSeekers());
|
||||||
map.put("hidersCanHurtHiders", hidersCanHurtHiders);
|
map.put("hidersCanHurtHiders", arenaOptions.hidersCanHurtHiders());
|
||||||
map.put("seekersTakeFallDamage", seekersTakeFallDamage);
|
map.put("seekersTakeFallDamage", arenaOptions.seekersTakeFallDamage());
|
||||||
map.put("hidersTakeFallDamage", hidersTakeFallDamage);
|
map.put("hidersTakeFallDamage", arenaOptions.hidersTakeFallDamage());
|
||||||
map.put("disguiseBlocks", disguiseBlocks);
|
map.put("disguiseBlocks", disguiseBlocks);
|
||||||
map.put("lobbyWarp", arenaLocations.getLobbyWarp());
|
map.put("lobbyWarp", arenaLocations.getLobbyWarp());
|
||||||
map.put("hidersWarp", arenaLocations.getHidersWarp());
|
map.put("hidersWarp", arenaLocations.getHidersWarp());
|
||||||
map.put("seekersWarp", arenaLocations.getSeekersWarp());
|
map.put("seekersWarp", arenaLocations.getSeekersWarp());
|
||||||
map.put("spawnWarp", arenaLocations.getExitWarp());
|
map.put("spawnWarp", arenaLocations.getExitWarp());
|
||||||
map.put("seekersWinCommands", seekersWinCommands);
|
map.put("seekersWinCommands", arenaOptions.seekersWinCommands());
|
||||||
map.put("hidersWinCommands", hidersWinCommands);
|
map.put("hidersWinCommands", arenaOptions.hidersWinCommands());
|
||||||
map.put("allowedCommands", allowedCommands);
|
map.put("allowedCommands", arenaOptions.allowedCommands());
|
||||||
map.put("seekersTokenWin", seekersTokenWin);
|
map.put("seekersTokenWin", seekersTokenWin);
|
||||||
map.put("hidersTokenWin", hidersTokenWin);
|
map.put("hidersTokenWin", hidersTokenWin);
|
||||||
map.put("killTokens", killTokens);
|
map.put("killTokens", killTokens);
|
||||||
@@ -226,9 +430,21 @@ public class Arena implements ConfigurationSerializable {
|
|||||||
scoreboard = scoreboardManager.getNewScoreboard();
|
scoreboard = scoreboardManager.getNewScoreboard();
|
||||||
}
|
}
|
||||||
return new Arena(
|
return new Arena(
|
||||||
(String) map.getOrDefault("arenaName", "UNKNOWN_NAME"),
|
new ArenaOptions((String) map.getOrDefault("arenaName", "UNKNOWN_NAME"),
|
||||||
(Location) map.getOrDefault("pos1", loc),
|
(Boolean) map.getOrDefault("seekersCanHurtSeekers", false),
|
||||||
(Location) map.getOrDefault("pos2", loc),
|
(Boolean) map.getOrDefault("hidersCanHurtSeekers", true),
|
||||||
|
(Boolean) map.getOrDefault("hidersCanHurtHiders", false),
|
||||||
|
(Boolean) map.getOrDefault("seekersTakeFallDamage", false),
|
||||||
|
(Boolean) map.getOrDefault("hidersTakeFallDamage", false),
|
||||||
|
(List<String>) map.getOrDefault("seekersWinCommands", new ArrayList<String>()),
|
||||||
|
(List<String>) map.getOrDefault("hidersWinCommands", new ArrayList<String>()),
|
||||||
|
(List<String>) map.getOrDefault("allowedCommands", new ArrayList<String>())),
|
||||||
|
new ArenaLocations((Location) map.getOrDefault("pos1", loc),
|
||||||
|
(Location) map.getOrDefault("pos2", loc),
|
||||||
|
(Location) map.getOrDefault("lobbyWarp", loc),
|
||||||
|
(Location) map.getOrDefault("hidersWarp", loc),
|
||||||
|
(Location) map.getOrDefault("seekersWarp", loc),
|
||||||
|
(Location) map.getOrDefault("spawnWarp", loc)),
|
||||||
(Integer) map.getOrDefault("maxPlayers", 12),
|
(Integer) map.getOrDefault("maxPlayers", 12),
|
||||||
(Integer) map.getOrDefault("minPlayers", 3),
|
(Integer) map.getOrDefault("minPlayers", 3),
|
||||||
(Integer) map.getOrDefault("amountSeekersOnStart", 1),
|
(Integer) map.getOrDefault("amountSeekersOnStart", 1),
|
||||||
@@ -237,24 +453,11 @@ public class Arena implements ConfigurationSerializable {
|
|||||||
(Integer) map.getOrDefault("gameTime", 200),
|
(Integer) map.getOrDefault("gameTime", 200),
|
||||||
(Integer) map.getOrDefault("timeUntilHidersSword", 30),
|
(Integer) map.getOrDefault("timeUntilHidersSword", 30),
|
||||||
(Integer) map.getOrDefault("blockAnnouncerTime", 45),
|
(Integer) map.getOrDefault("blockAnnouncerTime", 45),
|
||||||
(Boolean) map.getOrDefault("seekersCanHurtSeekers", false),
|
|
||||||
(Boolean) map.getOrDefault("hidersCanHurtSeekers", true),
|
|
||||||
(Boolean) map.getOrDefault("hidersCanHurtHiders", false),
|
|
||||||
(Boolean) map.getOrDefault("seekersTakeFallDamage", false),
|
|
||||||
(Boolean) map.getOrDefault("hidersTakeFallDamage", false),
|
|
||||||
(List<ItemStack>) map.getOrDefault("disguiseBlocks", new ArrayList<ItemStack>()),
|
(List<ItemStack>) map.getOrDefault("disguiseBlocks", new ArrayList<ItemStack>()),
|
||||||
(Location) map.getOrDefault("lobbyWarp", loc),
|
|
||||||
(Location) map.getOrDefault("hidersWarp", loc),
|
|
||||||
(Location) map.getOrDefault("seekersWarp", loc),
|
|
||||||
(Location) map.getOrDefault("spawnWarp", loc),
|
|
||||||
(List<String>) map.getOrDefault("seekersWinCommands", new ArrayList<String>()),
|
|
||||||
(List<String>) map.getOrDefault("hidersWinCommands", new ArrayList<String>()),
|
|
||||||
(List<String>) map.getOrDefault("allowedCommands", new ArrayList<String>()),
|
|
||||||
(Integer) map.getOrDefault("seekersTokenWin", 10),
|
(Integer) map.getOrDefault("seekersTokenWin", 10),
|
||||||
(Integer) map.getOrDefault("hidersTokenWin", 50),
|
(Integer) map.getOrDefault("hidersTokenWin", 50),
|
||||||
(Integer) map.getOrDefault("killTokens", 8),
|
(Integer) map.getOrDefault("killTokens", 8),
|
||||||
new ArrayList<>(), ArenaState.WAITING, 0, new ArrayList<>(), scoreboard
|
new ArrayList<>(), ArenaGameState.WAITING, 0, new ArrayList<>(), scoreboard);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ package net.knarcraft.blockhunt.arena;
|
|||||||
/**
|
/**
|
||||||
* The current state of an arena
|
* The current state of an arena
|
||||||
*/
|
*/
|
||||||
public enum ArenaState {
|
public enum ArenaGameState {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The arena is waiting for enough players
|
* The arena is waiting for enough players
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package net.knarcraft.blockhunt.arena;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A record of an arena's permanent properties only editable by changing the arena file
|
||||||
|
*
|
||||||
|
* <p>This record is completely immutable</p>
|
||||||
|
*
|
||||||
|
* @param arenaName <p>The name of the arena</p>
|
||||||
|
* @param seekersCanHurtSeekers <p>Whether seekers can hurt other seekers</p>
|
||||||
|
* @param hidersCanHurtSeekers <p>Whether hiders can hurt seekers</p>
|
||||||
|
* @param hidersCanHurtHiders <p>Whether hiders can hurt other hiders</p>
|
||||||
|
* @param seekersTakeFallDamage <p>Whether seekers take fall damage</p>
|
||||||
|
* @param hidersTakeFallDamage <p>Whether hiders take fall damage</p>
|
||||||
|
* @param seekersWinCommands <p>The commands to be run on the seekers if the seekers win (%player%)</p>
|
||||||
|
* @param hidersWinCommands <p>The commands to be run on the hiders if the hiders win (%player%)</p>
|
||||||
|
* @param allowedCommands <p>The commands players are allowed to use while in this arena</p> //TODO: Not properly implemented
|
||||||
|
*/
|
||||||
|
public record ArenaOptions(String arenaName,
|
||||||
|
boolean seekersCanHurtSeekers,
|
||||||
|
boolean hidersCanHurtSeekers,
|
||||||
|
boolean hidersCanHurtHiders,
|
||||||
|
boolean seekersTakeFallDamage,
|
||||||
|
boolean hidersTakeFallDamage,
|
||||||
|
List<String> seekersWinCommands,
|
||||||
|
List<String> hidersWinCommands,
|
||||||
|
List<String> allowedCommands) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> seekersWinCommands() {
|
||||||
|
return new ArrayList<>(seekersWinCommands);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> hidersWinCommands() {
|
||||||
|
return new ArrayList<>(hidersWinCommands);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> allowedCommands() {
|
||||||
|
return new ArrayList<>(allowedCommands);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,7 +2,9 @@ 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.ArenaState;
|
import net.knarcraft.blockhunt.arena.ArenaGameState;
|
||||||
|
import net.knarcraft.blockhunt.arena.ArenaLocations;
|
||||||
|
import net.knarcraft.blockhunt.arena.ArenaOptions;
|
||||||
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.util.MessageHelper;
|
import net.knarcraft.blockhunt.util.MessageHelper;
|
||||||
@@ -27,13 +29,16 @@ public class CreateCommand extends DefaultCommand {
|
|||||||
} else {
|
} else {
|
||||||
if (MemoryStorage.pos1.get(player) != null && MemoryStorage.pos2.get(player) != null) {
|
if (MemoryStorage.pos1.get(player) != null && MemoryStorage.pos2.get(player) != null) {
|
||||||
if (MemoryStorage.pos1.get(player).getWorld().equals(MemoryStorage.pos2.get(player).getWorld())) {
|
if (MemoryStorage.pos1.get(player).getWorld().equals(MemoryStorage.pos2.get(player).getWorld())) {
|
||||||
Arena arena = new Arena(args[1], MemoryStorage.pos1.get(player), MemoryStorage.pos2.get(player),
|
ArenaOptions arenaOptions = new ArenaOptions(args[1], false,
|
||||||
|
false, false, false,
|
||||||
|
false, new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
|
||||||
|
ArenaLocations arenaLocations = new ArenaLocations(MemoryStorage.pos1.get(player),
|
||||||
|
MemoryStorage.pos2.get(player), null, null, null, null);
|
||||||
|
Arena arena = new Arena(arenaOptions, arenaLocations,
|
||||||
12, 3, 1, 50, 20,
|
12, 3, 1, 50, 20,
|
||||||
300, 30, 45, false,
|
300, 30, 45,
|
||||||
false, false, false, false,
|
new ArrayList<>(), 10, 50,
|
||||||
new ArrayList<>(), null, null, null, null,
|
8, new ArrayList<>(), ArenaGameState.WAITING, 0, new ArrayList<>(),
|
||||||
new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), 10, 50,
|
|
||||||
8, new ArrayList<>(), ArenaState.WAITING, 0, new ArrayList<>(),
|
|
||||||
Bukkit.getScoreboardManager().getNewScoreboard());
|
Bukkit.getScoreboardManager().getNewScoreboard());
|
||||||
MemoryStorage.arenas.getFileConfiguration().set(args[1], arena);
|
MemoryStorage.arenas.getFileConfiguration().set(args[1], arena);
|
||||||
MemoryStorage.arenas.save();
|
MemoryStorage.arenas.save();
|
||||||
|
|||||||
@@ -11,11 +11,12 @@ public class ListCommand extends DefaultCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Player player, String[] args) {
|
public boolean execute(Player player, String[] args) {
|
||||||
MessageHelper.sendMessage(player, ConfigKey.CHAT_HEADER_HIGH, "header-" + BlockHunt.getPluginDescriptionFile().getName());
|
MessageHelper.sendMessage(player, ConfigKey.CHAT_HEADER_HIGH, "header-" +
|
||||||
|
BlockHunt.getPluginDescriptionFile().getName());
|
||||||
if (MemoryStorage.arenaMap.size() >= 1) {
|
if (MemoryStorage.arenaMap.size() >= 1) {
|
||||||
MessageHelper.sendMessage(player, "&7Available arena(s):");
|
MessageHelper.sendMessage(player, "&7Available arena(s):");
|
||||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||||
MessageHelper.sendMessage(player, "%A" + arena.arenaName);
|
MessageHelper.sendMessage(player, "%A" + arena.getArenaOptions().arenaName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageHelper.sendMessage(player, "&7&oNo arenas available...");
|
MessageHelper.sendMessage(player, "&7&oNo arenas available...");
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class ReloadCommand extends DefaultCommand {
|
|||||||
MemoryStorage.signs.load();
|
MemoryStorage.signs.load();
|
||||||
MemoryStorage.shop.load();
|
MemoryStorage.shop.load();
|
||||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||||
String cause = "[BlockHunt] Arena " + arena.arenaName + " has been stopped";
|
String cause = "[BlockHunt] Arena " + arena.getArenaOptions().arenaName() + " has been stopped";
|
||||||
ArenaHelper.stopArena(arena, cause, MessageKey.WARNING_ARENA_STOPPED);
|
ArenaHelper.stopArena(arena, cause, MessageKey.WARNING_ARENA_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class RemoveCommand extends DefaultCommand {
|
|||||||
MemoryStorage.arenas.save();
|
MemoryStorage.arenas.save();
|
||||||
MemoryStorage.signs.load();
|
MemoryStorage.signs.load();
|
||||||
|
|
||||||
MemoryStorage.arenaMap.remove(arena.arenaName.toLowerCase());
|
MemoryStorage.arenaMap.remove(arena.getArenaOptions().arenaName().toLowerCase());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class SetWarpCommand extends DefaultCommand {
|
|||||||
|
|
||||||
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
ArenaLocations locations = arena.arenaLocations;
|
ArenaLocations locations = arena.getArenaLocations();
|
||||||
Location playerLocation = player.getLocation();
|
Location playerLocation = player.getLocation();
|
||||||
if (warpName.equalsIgnoreCase("lobby")) {
|
if (warpName.equalsIgnoreCase("lobby")) {
|
||||||
locations.setLobbyWarp(playerLocation);
|
locations.setLobbyWarp(playerLocation);
|
||||||
@@ -56,7 +56,7 @@ public class SetWarpCommand extends DefaultCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save(Arena arena) {
|
public void save(Arena arena) {
|
||||||
MemoryStorage.arenas.getFileConfiguration().set(arena.arenaName, arena);
|
MemoryStorage.arenas.getFileConfiguration().set(arena.getArenaOptions().arenaName(), arena);
|
||||||
MemoryStorage.arenas.save();
|
MemoryStorage.arenas.save();
|
||||||
ArenaHelper.loadArenas();
|
ArenaHelper.loadArenas();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,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.ArenaState;
|
import net.knarcraft.blockhunt.arena.ArenaGameState;
|
||||||
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.util.MessageHelper;
|
import net.knarcraft.blockhunt.util.MessageHelper;
|
||||||
@@ -20,24 +20,26 @@ public class StartCommand extends DefaultCommand {
|
|||||||
Arena arena = MemoryStorage.arenaMap.get(args[1].toLowerCase());
|
Arena arena = MemoryStorage.arenaMap.get(args[1].toLowerCase());
|
||||||
|
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
if (arena.gameState.equals(ArenaState.WAITING)) {
|
if (arena.getGameState().equals(ArenaGameState.WAITING)) {
|
||||||
if (arena.playersInArena.size() >= 2) {
|
if (arena.getPlayersInArena().size() >= 2) {
|
||||||
arena.timer = 11;
|
arena.setTimer(11);
|
||||||
arena.gameState = ArenaState.STARTING;
|
arena.setGameState(ArenaGameState.STARTING);
|
||||||
MessageHelper.sendMessage(player, MessageKey.NORMAL_START_FORCED, "arenaName-" + arena.arenaName);
|
MessageHelper.sendMessage(player, MessageKey.NORMAL_START_FORCED, "arenaName-" +
|
||||||
|
arena.getArenaOptions().arenaName());
|
||||||
} else {
|
} else {
|
||||||
MessageHelper.sendMessage(player, MessageKey.WARNING_LOBBY_NEED_AT_LEAST, "1-2");
|
MessageHelper.sendMessage(player, MessageKey.WARNING_LOBBY_NEED_AT_LEAST, "1-2");
|
||||||
}
|
}
|
||||||
} else if (arena.gameState.equals(ArenaState.STARTING)) {
|
} else if (arena.getGameState().equals(ArenaGameState.STARTING)) {
|
||||||
if (arena.playersInArena.size() < arena.maxPlayers) {
|
if (arena.getPlayersInArena().size() < arena.getMaxPlayers()) {
|
||||||
if (arena.timer >= 10) {
|
if (arena.getTimer() >= 10) {
|
||||||
arena.timer = 11;
|
arena.setTimer(11);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
arena.timer = 1;
|
arena.setTimer(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageHelper.sendMessage(player, MessageKey.NORMAL_START_FORCED, "arenaName-" + arena.arenaName);
|
MessageHelper.sendMessage(player, MessageKey.NORMAL_START_FORCED, "arenaName-" +
|
||||||
|
arena.getArenaOptions().arenaName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageHelper.sendMessage(player, MessageKey.ERROR_NO_ARENA, "name-" + args[1]);
|
MessageHelper.sendMessage(player, MessageKey.ERROR_NO_ARENA, "name-" + args[1]);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import me.libraryaddict.disguise.DisguiseAPI;
|
|||||||
import net.knarcraft.blockhunt.BlockHunt;
|
import net.knarcraft.blockhunt.BlockHunt;
|
||||||
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.ArenaState;
|
import net.knarcraft.blockhunt.arena.ArenaGameState;
|
||||||
import net.knarcraft.blockhunt.config.MessageKey;
|
import net.knarcraft.blockhunt.config.MessageKey;
|
||||||
import net.knarcraft.blockhunt.util.ArenaHelper;
|
import net.knarcraft.blockhunt.util.ArenaHelper;
|
||||||
import net.knarcraft.blockhunt.util.MessageHelper;
|
import net.knarcraft.blockhunt.util.MessageHelper;
|
||||||
@@ -65,30 +65,30 @@ public class OnEntityDamageByEntityEvent implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.gameState == ArenaState.WAITING || arena.gameState == ArenaState.STARTING) {
|
if (arena.getGameState() == ArenaGameState.WAITING || arena.getGameState() == ArenaGameState.STARTING) {
|
||||||
// Always cancel damage when players are waiting
|
// Always cancel damage when players are waiting
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Seeker receiving damage
|
// Seeker receiving damage
|
||||||
if (arena.seekers.contains(player)) {
|
if (arena.getSeekers().contains(player)) {
|
||||||
if (arena.seekers.contains(damageDealer)) {
|
if (arena.getSeekers().contains(damageDealer)) {
|
||||||
// Seeker damaged by seeker
|
// Seeker damaged by seeker
|
||||||
if (!arena.seekersCanHurtSeekers) {
|
if (!arena.getArenaOptions().seekersCanHurtSeekers()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Seeker damaged by hider
|
// Seeker damaged by hider
|
||||||
if (!arena.hidersCanHurtSeekers) {
|
if (!arena.getArenaOptions().hidersCanHurtSeekers()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Hider damaged by hider
|
// Hider damaged by hider
|
||||||
if (!arena.hidersCanHurtHiders && !arena.seekers.contains(damageDealer)) {
|
if (!arena.getArenaOptions().hidersCanHurtHiders() && !arena.getSeekers().contains(damageDealer)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -122,18 +122,18 @@ public class OnEntityDamageByEntityEvent implements Listener {
|
|||||||
DisguiseAPI.undisguiseToAll(player);
|
DisguiseAPI.undisguiseToAll(player);
|
||||||
MemoryStorage.playerBlock.remove(player);
|
MemoryStorage.playerBlock.remove(player);
|
||||||
|
|
||||||
if (arena.hiders.contains(player)) {
|
if (arena.getHiders().contains(player)) {
|
||||||
killHider(arena, player, finalDamageDealer);
|
killHider(arena, player, finalDamageDealer);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
|
|
||||||
if (arena.seekers.size() >= arena.playersInArena.size()) {
|
if (arena.getSeekers().size() >= arena.getPlayersInArena().size()) {
|
||||||
ArenaHelper.seekersWin(arena);
|
ArenaHelper.seekersWin(arena);
|
||||||
} else {
|
} else {
|
||||||
DisguiseAPI.undisguiseToAll(player);
|
DisguiseAPI.undisguiseToAll(player);
|
||||||
MemoryStorage.seekerTime.put(player, arena.waitingTimeSeeker);
|
MemoryStorage.seekerTime.put(player, arena.getWaitingTimeSeeker());
|
||||||
PlayerHelper.teleport(player, arena.arenaLocations.getSeekersWarp());
|
PlayerHelper.teleport(player, arena.getArenaLocations().getSeekersWarp());
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
player.setWalkSpeed(0.3F);
|
player.setWalkSpeed(0.3F);
|
||||||
|
|
||||||
@@ -151,27 +151,27 @@ public class OnEntityDamageByEntityEvent implements Listener {
|
|||||||
*/
|
*/
|
||||||
private void killHider(Arena arena, Player player, Player finalDamageDealer) {
|
private void killHider(Arena arena, Player player, Player finalDamageDealer) {
|
||||||
int damageDealerTokens = TokensHelper.getTokens(finalDamageDealer);
|
int damageDealerTokens = TokensHelper.getTokens(finalDamageDealer);
|
||||||
TokensHelper.setTokens(finalDamageDealer, damageDealerTokens + arena.killTokens);
|
TokensHelper.setTokens(finalDamageDealer, damageDealerTokens + arena.getKillTokens());
|
||||||
|
|
||||||
MessageHelper.sendMessage(finalDamageDealer, MessageKey.NORMAL_ADDED_TOKEN, "amount-" + arena.killTokens);
|
MessageHelper.sendMessage(finalDamageDealer, MessageKey.NORMAL_ADDED_TOKEN, "amount-" + arena.getKillTokens());
|
||||||
|
|
||||||
int playerTokens = TokensHelper.getTokens(player);
|
int playerTokens = TokensHelper.getTokens(player);
|
||||||
float addedTokens = ((float) arena.hidersTokenWin - (((float) arena.timer / (float) arena.gameTime) *
|
float addedTokens = ((float) arena.getHidersTokenWin() - (((float) arena.getTimer() / (float) arena.getGameTime()) *
|
||||||
(float) arena.hidersTokenWin));
|
(float) arena.getHidersTokenWin()));
|
||||||
TokensHelper.setTokens(player, playerTokens + (int) addedTokens);
|
TokensHelper.setTokens(player, playerTokens + (int) addedTokens);
|
||||||
|
|
||||||
MessageHelper.sendMessage(player, MessageKey.NORMAL_ADDED_TOKEN, "amount-" + (int) addedTokens);
|
MessageHelper.sendMessage(player, MessageKey.NORMAL_ADDED_TOKEN, "amount-" + (int) addedTokens);
|
||||||
|
|
||||||
arena.seekers.add(player);
|
arena.getSeekers().add(player);
|
||||||
player.setWalkSpeed(0.3F);
|
player.setWalkSpeed(0.3F);
|
||||||
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_IN_GAME_HIDER_DIED,
|
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_IN_GAME_HIDER_DIED,
|
||||||
"%playerName%-" + player.getDisplayName(), "killer-" + finalDamageDealer.getDisplayName());
|
"%playerName%-" + player.getDisplayName(), "killer-" + finalDamageDealer.getDisplayName());
|
||||||
|
|
||||||
int hiderCount = arena.hiders.size();
|
int hiderCount = arena.getHiders().size();
|
||||||
if ((hiderCount <= 3) && (hiderCount > 0)) {
|
if ((hiderCount <= 3) && (hiderCount > 0)) {
|
||||||
List<String> hiders = new ArrayList<>();
|
List<String> hiders = new ArrayList<>();
|
||||||
for (Player p : arena.playersInArena) {
|
for (Player p : arena.getPlayersInArena()) {
|
||||||
if (!arena.seekers.contains(p)) {
|
if (!arena.getSeekers().contains(p)) {
|
||||||
hiders.add(p.getName());
|
hiders.add(p.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ public class OnEntityDamageEvent implements Listener {
|
|||||||
break;
|
break;
|
||||||
case FALL:
|
case FALL:
|
||||||
// Prevent seeker/hider fall damage (if configured)
|
// Prevent seeker/hider fall damage (if configured)
|
||||||
if ((arena.seekers.contains(player) && !arena.seekersTakeFallDamage) ||
|
if ((arena.getSeekers().contains(player) && !arena.getArenaOptions().seekersTakeFallDamage()) ||
|
||||||
(arena.hiders.contains(player) && !arena.hidersTakeFallDamage)) {
|
(arena.getHiders().contains(player) && !arena.getArenaOptions().hidersTakeFallDamage())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ public class OnInventoryClickEvent implements Listener {
|
|||||||
if (event.getCurrentItem().getType().equals(Material.BLUE_WOOL)) {
|
if (event.getCurrentItem().getType().equals(Material.BLUE_WOOL)) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||||
if (arena.playersInArena.contains(player)) {
|
if (arena.getPlayersInArena().contains(player)) {
|
||||||
for (Player playerCheck : arena.playersInArena) {
|
for (Player playerCheck : arena.getPlayersInArena()) {
|
||||||
if (MemoryStorage.chosenSeeker.get(playerCheck) != null &&
|
if (MemoryStorage.chosenSeeker.get(playerCheck) != null &&
|
||||||
MemoryStorage.chosenSeeker.get(playerCheck)) {
|
MemoryStorage.chosenSeeker.get(playerCheck)) {
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
@@ -120,7 +120,7 @@ public class OnInventoryClickEvent implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= arena.amountSeekersOnStart) {
|
if (i >= arena.getAmountSeekersOnStart()) {
|
||||||
MessageHelper.sendMessage(player, MessageKey.ERROR_SHOP_MAX_SEEKERS_REACHED);
|
MessageHelper.sendMessage(player, MessageKey.ERROR_SHOP_MAX_SEEKERS_REACHED);
|
||||||
} else {
|
} else {
|
||||||
MemoryStorage.chosenSeeker.put(player, true);
|
MemoryStorage.chosenSeeker.put(player, true);
|
||||||
@@ -140,8 +140,8 @@ public class OnInventoryClickEvent implements Listener {
|
|||||||
} else if (event.getCurrentItem().getType().equals(Material.RED_WOOL)) {
|
} else if (event.getCurrentItem().getType().equals(Material.RED_WOOL)) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||||
if (arena.playersInArena.contains(player)) {
|
if (arena.getPlayersInArena().contains(player)) {
|
||||||
for (Player playerCheck : arena.playersInArena) {
|
for (Player playerCheck : arena.getPlayersInArena()) {
|
||||||
if (MemoryStorage.chosenSeeker.get(playerCheck) != null) {
|
if (MemoryStorage.chosenSeeker.get(playerCheck) != null) {
|
||||||
if (!MemoryStorage.chosenSeeker.get(playerCheck)) {
|
if (!MemoryStorage.chosenSeeker.get(playerCheck)) {
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
@@ -150,7 +150,7 @@ public class OnInventoryClickEvent implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= (arena.playersInArena.size() - 1)) {
|
if (i >= (arena.getPlayersInArena().size() - 1)) {
|
||||||
MessageHelper.sendMessage(player, MessageKey.ERROR_SHOP_MAX_HIDERS_REACHED);
|
MessageHelper.sendMessage(player, MessageKey.ERROR_SHOP_MAX_HIDERS_REACHED);
|
||||||
} else {
|
} else {
|
||||||
MemoryStorage.chosenSeeker.put(player, false);
|
MemoryStorage.chosenSeeker.put(player, false);
|
||||||
@@ -181,31 +181,31 @@ public class OnInventoryClickEvent implements Listener {
|
|||||||
}
|
}
|
||||||
if (item.getType().equals(Material.GOLD_NUGGET)) {
|
if (item.getType().equals(Material.GOLD_NUGGET)) {
|
||||||
if (item.getItemMeta().getDisplayName().contains("maxPlayers")) {
|
if (item.getItemMeta().getDisplayName().contains("maxPlayers")) {
|
||||||
upDownButton(player, item, arena, ArenaProperty.MAX_PLAYERS, arena.maxPlayers, Bukkit.getMaxPlayers(), 2, 1, 1);
|
upDownButton(player, item, arena, ArenaProperty.MAX_PLAYERS, arena.getMaxPlayers(), Bukkit.getMaxPlayers(), 2, 1, 1);
|
||||||
} else if (item.getItemMeta().getDisplayName().contains("minPlayers")) {
|
} else if (item.getItemMeta().getDisplayName().contains("minPlayers")) {
|
||||||
upDownButton(player, item, arena, ArenaProperty.MIN_PLAYERS, arena.minPlayers, Bukkit.getMaxPlayers() - 1, 2, 1, 1);
|
upDownButton(player, item, arena, ArenaProperty.MIN_PLAYERS, arena.getMinPlayers(), Bukkit.getMaxPlayers() - 1, 2, 1, 1);
|
||||||
} else if (item.getItemMeta().getDisplayName().contains("amountSeekersOnStart")) {
|
} else if (item.getItemMeta().getDisplayName().contains("amountSeekersOnStart")) {
|
||||||
upDownButton(player, item, arena, ArenaProperty.AMOUNT_SEEKERS_ON_START, arena.amountSeekersOnStart, arena.maxPlayers - 1, 1, 1, 1);
|
upDownButton(player, item, arena, ArenaProperty.AMOUNT_SEEKERS_ON_START, arena.getAmountSeekersOnStart(), arena.getMaxPlayers() - 1, 1, 1, 1);
|
||||||
} else if (item.getItemMeta().getDisplayName().contains("timeInLobbyUntilStart")) {
|
} else if (item.getItemMeta().getDisplayName().contains("timeInLobbyUntilStart")) {
|
||||||
upDownButton(player, item, arena, ArenaProperty.TIME_IN_LOBBY_UNTIL_START, arena.timeInLobbyUntilStart, 1000, 5, 1, 1);
|
upDownButton(player, item, arena, ArenaProperty.TIME_IN_LOBBY_UNTIL_START, arena.getTimeInLobbyUntilStart(), 1000, 5, 1, 1);
|
||||||
} else if (item.getItemMeta().getDisplayName().contains("waitingTimeSeeker")) {
|
} else if (item.getItemMeta().getDisplayName().contains("waitingTimeSeeker")) {
|
||||||
upDownButton(player, item, arena, ArenaProperty.WAITING_TIME_SEEKER, arena.waitingTimeSeeker, 1000, 5, 1, 1);
|
upDownButton(player, item, arena, ArenaProperty.WAITING_TIME_SEEKER, arena.getWaitingTimeSeeker(), 1000, 5, 1, 1);
|
||||||
} else if (item.getItemMeta().getDisplayName().contains("gameTime")) {
|
} else if (item.getItemMeta().getDisplayName().contains("gameTime")) {
|
||||||
upDownButton(player, item, arena, ArenaProperty.GAME_TIME, arena.gameTime, 1000, 5, 1, 1);
|
upDownButton(player, item, arena, ArenaProperty.GAME_TIME, arena.getGameTime(), 1000, 5, 1, 1);
|
||||||
} else if (item.getItemMeta().getDisplayName().contains("blockAnnouncerTime")) {
|
} else if (item.getItemMeta().getDisplayName().contains("blockAnnouncerTime")) {
|
||||||
upDownButton(player, item, arena, ArenaProperty.BLOCK_ANNOUNCER_TIME, arena.blockAnnouncerTime, 1000, 0, 5, 5);
|
upDownButton(player, item, arena, ArenaProperty.BLOCK_ANNOUNCER_TIME, arena.getBlockAnnouncerTime(), 1000, 0, 5, 5);
|
||||||
} else if (item.getItemMeta().getDisplayName().contains("timeUntilHidersSword")) {
|
} else if (item.getItemMeta().getDisplayName().contains("timeUntilHidersSword")) {
|
||||||
upDownButton(player, item, arena, ArenaProperty.TIME_UNTIL_HIDERS_SWORD, arena.timeUntilHidersSword, 1000, 0, 1, 1);
|
upDownButton(player, item, arena, ArenaProperty.TIME_UNTIL_HIDERS_SWORD, arena.getTimeUntilHidersSword(), 1000, 0, 1, 1);
|
||||||
} else if (item.getItemMeta().getDisplayName().contains("hidersTokenWin")) {
|
} else if (item.getItemMeta().getDisplayName().contains("hidersTokenWin")) {
|
||||||
upDownButton(player, item, arena, ArenaProperty.HIDERS_TOKEN_WIN, arena.hidersTokenWin, 1000, 0, 1, 1);
|
upDownButton(player, item, arena, ArenaProperty.HIDERS_TOKEN_WIN, arena.getHidersTokenWin(), 1000, 0, 1, 1);
|
||||||
} else if (item.getItemMeta().getDisplayName().contains("seekersTokenWin")) {
|
} else if (item.getItemMeta().getDisplayName().contains("seekersTokenWin")) {
|
||||||
upDownButton(player, item, arena, ArenaProperty.SEEKERS_TOKEN_WIN, arena.seekersTokenWin, 1000, 0, 1, 1);
|
upDownButton(player, item, arena, ArenaProperty.SEEKERS_TOKEN_WIN, arena.getSeekersTokenWin(), 1000, 0, 1, 1);
|
||||||
} else if (item.getItemMeta().getDisplayName().contains("killTokens")) {
|
} else if (item.getItemMeta().getDisplayName().contains("killTokens")) {
|
||||||
upDownButton(player, item, arena, ArenaProperty.KILL_TOKENS, arena.killTokens, 1000, 0, 1, 1);
|
upDownButton(player, item, arena, ArenaProperty.KILL_TOKENS, arena.getKillTokens(), 1000, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
save(arena);
|
save(arena);
|
||||||
InventoryHelper.openPanel(player, arena.arenaName);
|
InventoryHelper.openPanel(player, arena.getArenaOptions().arenaName());
|
||||||
|
|
||||||
} else if (item.getType().equals(Material.BOOK)) {
|
} else if (item.getType().equals(Material.BOOK)) {
|
||||||
if (item.getItemMeta().getDisplayName().contains("disguiseBlocks")) {
|
if (item.getItemMeta().getDisplayName().contains("disguiseBlocks")) {
|
||||||
@@ -216,7 +216,7 @@ public class OnInventoryClickEvent implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save(Arena arena) {
|
public void save(Arena arena) {
|
||||||
MemoryStorage.arenas.getFileConfiguration().set(arena.arenaName, arena);
|
MemoryStorage.arenas.getFileConfiguration().set(arena.getArenaOptions().arenaName(), arena);
|
||||||
MemoryStorage.arenas.save();
|
MemoryStorage.arenas.save();
|
||||||
ArenaHelper.loadArenas();
|
ArenaHelper.loadArenas();
|
||||||
}
|
}
|
||||||
@@ -226,17 +226,17 @@ public class OnInventoryClickEvent implements Listener {
|
|||||||
if (item.getItemMeta().getDisplayName().contains((String) MemoryStorage.messages.get(MessageKey.BUTTON_ADD_2))) {
|
if (item.getItemMeta().getDisplayName().contains((String) MemoryStorage.messages.get(MessageKey.BUTTON_ADD_2))) {
|
||||||
if (option < max) {
|
if (option < max) {
|
||||||
switch (at) {
|
switch (at) {
|
||||||
case MAX_PLAYERS -> arena.maxPlayers = option + add;
|
case MAX_PLAYERS -> arena.setMaxPlayers(option + add);
|
||||||
case MIN_PLAYERS -> arena.minPlayers = option + add;
|
case MIN_PLAYERS -> arena.setMinPlayers(option + add);
|
||||||
case AMOUNT_SEEKERS_ON_START -> arena.amountSeekersOnStart = option + add;
|
case AMOUNT_SEEKERS_ON_START -> arena.setAmountSeekersOnStart(option + add);
|
||||||
case TIME_IN_LOBBY_UNTIL_START -> arena.timeInLobbyUntilStart = option + add;
|
case TIME_IN_LOBBY_UNTIL_START -> arena.setTimeInLobbyUntilStart(option + add);
|
||||||
case WAITING_TIME_SEEKER -> arena.waitingTimeSeeker = option + add;
|
case WAITING_TIME_SEEKER -> arena.setWaitingTimeSeeker(option + add);
|
||||||
case GAME_TIME -> arena.gameTime = option + add;
|
case GAME_TIME -> arena.setGameTime(option + add);
|
||||||
case BLOCK_ANNOUNCER_TIME -> arena.blockAnnouncerTime = option + add;
|
case BLOCK_ANNOUNCER_TIME -> arena.setBlockAnnouncerTime(option + add);
|
||||||
case TIME_UNTIL_HIDERS_SWORD -> arena.timeUntilHidersSword = option + add;
|
case TIME_UNTIL_HIDERS_SWORD -> arena.setTimeUntilHidersSword(option + add);
|
||||||
case HIDERS_TOKEN_WIN -> arena.hidersTokenWin = option + add;
|
case HIDERS_TOKEN_WIN -> arena.setHidersTokenWin(option + add);
|
||||||
case SEEKERS_TOKEN_WIN -> arena.seekersTokenWin = option + add;
|
case SEEKERS_TOKEN_WIN -> arena.setSeekersTokenWin(option + add);
|
||||||
case KILL_TOKENS -> arena.killTokens = option + add;
|
case KILL_TOKENS -> arena.setKillTokens(option + add);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageHelper.sendMessage(player, MessageKey.ERROR_SET_TOO_HIGH_NUMBER, "max-" + max);
|
MessageHelper.sendMessage(player, MessageKey.ERROR_SET_TOO_HIGH_NUMBER, "max-" + max);
|
||||||
@@ -244,17 +244,17 @@ public class OnInventoryClickEvent implements Listener {
|
|||||||
} else if (item.getItemMeta().getDisplayName().contains((String) MemoryStorage.messages.get(MessageKey.BUTTON_REMOVE_2))) {
|
} else if (item.getItemMeta().getDisplayName().contains((String) MemoryStorage.messages.get(MessageKey.BUTTON_REMOVE_2))) {
|
||||||
if (option > min) {
|
if (option > min) {
|
||||||
switch (at) {
|
switch (at) {
|
||||||
case MAX_PLAYERS -> arena.maxPlayers = option - remove;
|
case MAX_PLAYERS -> arena.setMaxPlayers(option - remove);
|
||||||
case MIN_PLAYERS -> arena.minPlayers = option - remove;
|
case MIN_PLAYERS -> arena.setMinPlayers(option - remove);
|
||||||
case AMOUNT_SEEKERS_ON_START -> arena.amountSeekersOnStart = option - remove;
|
case AMOUNT_SEEKERS_ON_START -> arena.setAmountSeekersOnStart(option - remove);
|
||||||
case TIME_IN_LOBBY_UNTIL_START -> arena.timeInLobbyUntilStart = option - remove;
|
case TIME_IN_LOBBY_UNTIL_START -> arena.setTimeInLobbyUntilStart(option - remove);
|
||||||
case WAITING_TIME_SEEKER -> arena.waitingTimeSeeker = option - remove;
|
case WAITING_TIME_SEEKER -> arena.setWaitingTimeSeeker(option - remove);
|
||||||
case GAME_TIME -> arena.gameTime = option - remove;
|
case GAME_TIME -> arena.setGameTime(option - remove);
|
||||||
case BLOCK_ANNOUNCER_TIME -> arena.blockAnnouncerTime = option - remove;
|
case BLOCK_ANNOUNCER_TIME -> arena.setBlockAnnouncerTime(option - remove);
|
||||||
case TIME_UNTIL_HIDERS_SWORD -> arena.timeUntilHidersSword = option - remove;
|
case TIME_UNTIL_HIDERS_SWORD -> arena.setTimeUntilHidersSword(option - remove);
|
||||||
case HIDERS_TOKEN_WIN -> arena.hidersTokenWin = option - remove;
|
case HIDERS_TOKEN_WIN -> arena.setHidersTokenWin(option - remove);
|
||||||
case SEEKERS_TOKEN_WIN -> arena.seekersTokenWin = option - remove;
|
case SEEKERS_TOKEN_WIN -> arena.setSeekersTokenWin(option - remove);
|
||||||
case KILL_TOKENS -> arena.killTokens = option - remove;
|
case KILL_TOKENS -> arena.setKillTokens(option - remove);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageHelper.sendMessage(player, MessageKey.ERROR_SET_TOO_LOW_NUMBER, "min-" + min);
|
MessageHelper.sendMessage(player, MessageKey.ERROR_SET_TOO_LOW_NUMBER, "min-" + min);
|
||||||
|
|||||||
@@ -43,14 +43,14 @@ public class OnInventoryCloseEvent implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.disguiseBlocks = blocks;
|
arena.setDisguiseBlocks(blocks);
|
||||||
save(arena);
|
save(arena);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(Arena arena) {
|
public void save(Arena arena) {
|
||||||
MemoryStorage.arenas.getFileConfiguration().set(arena.arenaName, arena);
|
MemoryStorage.arenas.getFileConfiguration().set(arena.getArenaOptions().arenaName(), arena);
|
||||||
MemoryStorage.arenas.save();
|
MemoryStorage.arenas.save();
|
||||||
ArenaHelper.loadArenas();
|
ArenaHelper.loadArenas();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package net.knarcraft.blockhunt.listener;
|
|||||||
|
|
||||||
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.ArenaState;
|
import net.knarcraft.blockhunt.arena.ArenaGameState;
|
||||||
import net.knarcraft.blockhunt.config.ConfigKey;
|
import net.knarcraft.blockhunt.config.ConfigKey;
|
||||||
import net.knarcraft.blockhunt.config.MessageKey;
|
import net.knarcraft.blockhunt.config.MessageKey;
|
||||||
import net.knarcraft.blockhunt.config.Permission;
|
import net.knarcraft.blockhunt.config.Permission;
|
||||||
@@ -69,8 +69,8 @@ public class OnPlayerInteractEvent implements Listener {
|
|||||||
// TODO: Do this more efficiently and directly, for example by mapping location vector to player instead of
|
// TODO: Do this more efficiently and directly, for example by mapping location vector to player instead of
|
||||||
// the other way around.
|
// the other way around.
|
||||||
Arena arena = MemoryStorage.playerArena.get(event.getPlayer());
|
Arena arena = MemoryStorage.playerArena.get(event.getPlayer());
|
||||||
if (arena != null && arena.seekers.contains(player)) {
|
if (arena != null && arena.getSeekers().contains(player)) {
|
||||||
for (Player arenaPlayer : arena.playersInArena) {
|
for (Player arenaPlayer : arena.getPlayersInArena()) {
|
||||||
// Check all hidden players
|
// Check all hidden players
|
||||||
if (MemoryStorage.hiddenLocation.get(arenaPlayer) == null) {
|
if (MemoryStorage.hiddenLocation.get(arenaPlayer) == null) {
|
||||||
continue;
|
continue;
|
||||||
@@ -96,7 +96,7 @@ public class OnPlayerInteractEvent implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arena.gameState.equals(ArenaState.WAITING) && !arena.gameState.equals(ArenaState.STARTING)) {
|
if (!arena.getGameState().equals(ArenaGameState.WAITING) && !arena.getGameState().equals(ArenaGameState.STARTING)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,9 +112,9 @@ public class OnPlayerInteractEvent implements Listener {
|
|||||||
Inventory blockChooser = Bukkit.createInventory(null, 36,
|
Inventory blockChooser = Bukkit.createInventory(null, 36,
|
||||||
MessageHelper.replaceAll("\u00A7r" + MemoryStorage.config.get(
|
MessageHelper.replaceAll("\u00A7r" + MemoryStorage.config.get(
|
||||||
ConfigKey.SHOP_BLOCK_CHOOSER_V_1_NAME)));
|
ConfigKey.SHOP_BLOCK_CHOOSER_V_1_NAME)));
|
||||||
if (arena.disguiseBlocks != null) {
|
if (arena.getDisguiseBlocks() != null) {
|
||||||
for (int i = arena.disguiseBlocks.size(); i > 0; i = i - 1) {
|
for (int i = arena.getDisguiseBlocks().size(); i > 0; i = i - 1) {
|
||||||
blockChooser.setItem(i - 1, arena.disguiseBlocks.get(i - 1));
|
blockChooser.setItem(i - 1, arena.getDisguiseBlocks().get(i - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ public class OnPlayerInteractEvent implements Listener {
|
|||||||
signIdentifier.toLowerCase()));
|
signIdentifier.toLowerCase()));
|
||||||
Arena arena = MemoryStorage.arenaMap.get(cleanName);
|
Arena arena = MemoryStorage.arenaMap.get(cleanName);
|
||||||
if (arena != null && PermissionsManager.hasPermission(player, Permission.JOIN_SIGN, true)) {
|
if (arena != null && PermissionsManager.hasPermission(player, Permission.JOIN_SIGN, true)) {
|
||||||
ArenaHelper.playerJoinArena(player, arena.arenaName);
|
ArenaHelper.playerJoinArena(player, arena.getArenaOptions().arenaName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package net.knarcraft.blockhunt.listener;
|
|||||||
|
|
||||||
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.ArenaGameState;
|
||||||
import net.knarcraft.blockhunt.arena.ArenaLocations;
|
import net.knarcraft.blockhunt.arena.ArenaLocations;
|
||||||
import net.knarcraft.blockhunt.arena.ArenaState;
|
|
||||||
import net.knarcraft.blockhunt.util.PlayerHelper;
|
import net.knarcraft.blockhunt.util.PlayerHelper;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -23,7 +23,7 @@ public class OnPlayerMoveEvent implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Arena arena = MemoryStorage.playerArena.get(player);
|
Arena arena = MemoryStorage.playerArena.get(player);
|
||||||
|
|
||||||
if (arena == null || arena.gameState != ArenaState.IN_GAME) {
|
if (arena == null || arena.getGameState() != ArenaGameState.IN_GAME) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ public class OnPlayerMoveEvent implements Listener {
|
|||||||
MemoryStorage.moveLocation.put(player, player.getLocation());
|
MemoryStorage.moveLocation.put(player, player.getLocation());
|
||||||
|
|
||||||
// Force the player back in bounds if they are about to leave the arena
|
// Force the player back in bounds if they are about to leave the arena
|
||||||
ArenaLocations locations = arena.arenaLocations;
|
ArenaLocations locations = arena.getArenaLocations();
|
||||||
Location maxLocation = getRelativeLocation(locations.getCorner1(), locations.getCorner2(), Math::max);
|
Location maxLocation = getRelativeLocation(locations.getCorner1(), locations.getCorner2(), Math::max);
|
||||||
Location minLocation = getRelativeLocation(locations.getCorner1(), locations.getCorner2(), Math::min);
|
Location minLocation = getRelativeLocation(locations.getCorner1(), locations.getCorner2(), Math::min);
|
||||||
Location playerLocation = player.getLocation();
|
Location playerLocation = player.getLocation();
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import net.knarcraft.blockhunt.BlockHunt;
|
|||||||
import net.knarcraft.blockhunt.MemoryStorage;
|
import net.knarcraft.blockhunt.MemoryStorage;
|
||||||
import net.knarcraft.blockhunt.PlayerArenaData;
|
import net.knarcraft.blockhunt.PlayerArenaData;
|
||||||
import net.knarcraft.blockhunt.arena.Arena;
|
import net.knarcraft.blockhunt.arena.Arena;
|
||||||
|
import net.knarcraft.blockhunt.arena.ArenaGameState;
|
||||||
import net.knarcraft.blockhunt.arena.ArenaLocations;
|
import net.knarcraft.blockhunt.arena.ArenaLocations;
|
||||||
import net.knarcraft.blockhunt.arena.ArenaState;
|
|
||||||
import net.knarcraft.blockhunt.config.ConfigKey;
|
import net.knarcraft.blockhunt.config.ConfigKey;
|
||||||
import net.knarcraft.blockhunt.config.MessageKey;
|
import net.knarcraft.blockhunt.config.MessageKey;
|
||||||
import net.knarcraft.blockhunt.config.Permission;
|
import net.knarcraft.blockhunt.config.Permission;
|
||||||
@@ -63,7 +63,7 @@ public final class ArenaHelper {
|
|||||||
* @param variables <p>The variables to replace in the message</p>
|
* @param variables <p>The variables to replace in the message</p>
|
||||||
*/
|
*/
|
||||||
public static void sendMessage(Arena arena, String message, String... variables) {
|
public static void sendMessage(Arena arena, String message, String... variables) {
|
||||||
MessageHelper.broadcastMessage(arena.playersInArena, message, variables);
|
MessageHelper.broadcastMessage(arena.getPlayersInArena(), message, variables);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,7 +74,7 @@ public final class ArenaHelper {
|
|||||||
* @param variables <p>The variables to replace in the message</p>
|
* @param variables <p>The variables to replace in the message</p>
|
||||||
*/
|
*/
|
||||||
public static void sendMessage(Arena arena, MessageKey messageKey, String... variables) {
|
public static void sendMessage(Arena arena, MessageKey messageKey, String... variables) {
|
||||||
MessageHelper.broadcastMessage(arena.playersInArena, messageKey, variables);
|
MessageHelper.broadcastMessage(arena.getPlayersInArena(), messageKey, variables);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void playerJoinArena(Player player, String arenaName) {
|
public static void playerJoinArena(Player player, String arenaName) {
|
||||||
@@ -86,7 +86,7 @@ public final class ArenaHelper {
|
|||||||
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
// TODO: Use a disabled arena state instead of checking this condition every time
|
// TODO: Use a disabled arena state instead of checking this condition every time
|
||||||
if (arena.disguiseBlocks.isEmpty()) {
|
if (arena.getDisguiseBlocks().isEmpty()) {
|
||||||
MessageHelper.sendMessage(player, MessageKey.ERROR_JOIN_NO_BLOCKS_SET);
|
MessageHelper.sendMessage(player, MessageKey.ERROR_JOIN_NO_BLOCKS_SET);
|
||||||
} else {
|
} else {
|
||||||
joinLobby(arena, player);
|
joinLobby(arena, player);
|
||||||
@@ -107,7 +107,7 @@ public final class ArenaHelper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockHunt.plugin.getLogger().log(Level.INFO, player.getName() + " has left " + arena.arenaName);
|
BlockHunt.plugin.getLogger().log(Level.INFO, player.getName() + " has left " + arena.getArenaOptions().arenaName());
|
||||||
LeaveArenaEvent event = new LeaveArenaEvent(player, arena);
|
LeaveArenaEvent event = new LeaveArenaEvent(player, arena);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ public final class ArenaHelper {
|
|||||||
player.setHealth(playerArenaData.playerHealth());
|
player.setHealth(playerArenaData.playerHealth());
|
||||||
player.setFoodLevel(playerArenaData.playerFood());
|
player.setFoodLevel(playerArenaData.playerFood());
|
||||||
player.addPotionEffects(playerArenaData.playerPotionEffects());
|
player.addPotionEffects(playerArenaData.playerPotionEffects());
|
||||||
PlayerHelper.teleport(player, arena.arenaLocations.getExitWarp());
|
PlayerHelper.teleport(player, arena.getArenaLocations().getExitWarp());
|
||||||
player.setGameMode(playerArenaData.playerGameMode());
|
player.setGameMode(playerArenaData.playerGameMode());
|
||||||
player.setAllowFlight(playerArenaData.playerFlying());
|
player.setAllowFlight(playerArenaData.playerFlying());
|
||||||
player.setFlying(playerArenaData.playerFlying());
|
player.setFlying(playerArenaData.playerFlying());
|
||||||
@@ -154,40 +154,40 @@ public final class ArenaHelper {
|
|||||||
MessageHelper.sendMessage(player, MessageKey.NORMAL_LEAVE_YOU_LEFT);
|
MessageHelper.sendMessage(player, MessageKey.NORMAL_LEAVE_YOU_LEFT);
|
||||||
if (message) {
|
if (message) {
|
||||||
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_LEAVE_LEFT_ARENA, "%playerName%-" +
|
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_LEAVE_LEFT_ARENA, "%playerName%-" +
|
||||||
player.getName(), "1-" + arena.playersInArena.size(), "2-" + arena.maxPlayers);
|
player.getName(), "1-" + arena.getPlayersInArena().size(), "2-" + arena.getMaxPlayers());
|
||||||
}
|
}
|
||||||
|
|
||||||
SignsHelper.updateSigns();
|
SignsHelper.updateSigns();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void cleanup(Arena arena, Player player) {
|
private static void cleanup(Arena arena, Player player) {
|
||||||
arena.playersInArena.remove(player);
|
arena.getPlayersInArena().remove(player);
|
||||||
MemoryStorage.playerArena.remove(player);
|
MemoryStorage.playerArena.remove(player);
|
||||||
arena.seekers.remove(player);
|
arena.getSeekers().remove(player);
|
||||||
arena.hiders.remove(player);
|
arena.getHiders().remove(player);
|
||||||
MemoryStorage.playerArena.remove(player);
|
MemoryStorage.playerArena.remove(player);
|
||||||
|
|
||||||
if (arena.playersInArena.size() < arena.minPlayers && arena.gameState.equals(ArenaState.STARTING)) {
|
if (arena.getPlayersInArena().size() < arena.getMinPlayers() && arena.getGameState().equals(ArenaGameState.STARTING)) {
|
||||||
arena.gameState = ArenaState.WAITING;
|
arena.setGameState(ArenaGameState.WAITING);
|
||||||
arena.timer = 0;
|
arena.setTimer(0);
|
||||||
|
|
||||||
sendMessage(arena, MessageKey.WARNING_LOBBY_NEED_AT_LEAST, "1-" + arena.minPlayers);
|
sendMessage(arena, MessageKey.WARNING_LOBBY_NEED_AT_LEAST, "1-" + arena.getMinPlayers());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.playersInArena.size() <= 1 && arena.gameState == ArenaState.IN_GAME) {
|
if (arena.getPlayersInArena().size() <= 1 && arena.getGameState() == ArenaGameState.IN_GAME) {
|
||||||
if (arena.seekers.size() >= arena.playersInArena.size()) {
|
if (arena.getSeekers().size() >= arena.getPlayersInArena().size()) {
|
||||||
ArenaHelper.seekersWin(arena);
|
ArenaHelper.seekersWin(arena);
|
||||||
} else {
|
} else {
|
||||||
ArenaHelper.hidersWin(arena);
|
ArenaHelper.hidersWin(arena);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.seekers.size() >= arena.playersInArena.size()) {
|
if (arena.getSeekers().size() >= arena.getPlayersInArena().size()) {
|
||||||
ArenaHelper.seekersWin(arena);
|
ArenaHelper.seekersWin(arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.seekers.size() == 0 && arena.gameState == ArenaState.IN_GAME) {
|
if (arena.getSeekers().size() == 0 && arena.getGameState() == ArenaGameState.IN_GAME) {
|
||||||
Player seeker = arena.playersInArena.get(MemoryStorage.random.nextInt(arena.playersInArena.size()));
|
Player seeker = arena.getPlayersInArena().get(MemoryStorage.random.nextInt(arena.getPlayersInArena().size()));
|
||||||
ArenaHelper.sendMessage(arena, MessageKey.WARNING_IN_GAME_NEW_SEEKER_CHOSEN, "seeker-" + seeker.getName());
|
ArenaHelper.sendMessage(arena, MessageKey.WARNING_IN_GAME_NEW_SEEKER_CHOSEN, "seeker-" + seeker.getName());
|
||||||
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_IN_GAME_SEEKER_CHOSEN, "seeker-" + seeker.getName());
|
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_IN_GAME_SEEKER_CHOSEN, "seeker-" + seeker.getName());
|
||||||
DisguiseAPI.undisguiseToAll(seeker);
|
DisguiseAPI.undisguiseToAll(seeker);
|
||||||
@@ -195,9 +195,9 @@ public final class ArenaHelper {
|
|||||||
pl.showPlayer(BlockHunt.plugin, seeker);
|
pl.showPlayer(BlockHunt.plugin, seeker);
|
||||||
}
|
}
|
||||||
seeker.getInventory().clear();
|
seeker.getInventory().clear();
|
||||||
arena.seekers.add(seeker);
|
arena.getSeekers().add(seeker);
|
||||||
PlayerHelper.teleport(seeker, arena.arenaLocations.getSeekersWarp());
|
PlayerHelper.teleport(seeker, arena.getArenaLocations().getSeekersWarp());
|
||||||
MemoryStorage.seekerTime.put(seeker, arena.waitingTimeSeeker);
|
MemoryStorage.seekerTime.put(seeker, arena.getWaitingTimeSeeker());
|
||||||
seeker.setWalkSpeed(0.3F);
|
seeker.setWalkSpeed(0.3F);
|
||||||
|
|
||||||
// Fix for client not showing players after they join
|
// Fix for client not showing players after they join
|
||||||
@@ -211,8 +211,8 @@ public final class ArenaHelper {
|
|||||||
* @param arena <p>The arena in which the seekers won</p>
|
* @param arena <p>The arena in which the seekers won</p>
|
||||||
*/
|
*/
|
||||||
public static void seekersWin(Arena arena) {
|
public static void seekersWin(Arena arena) {
|
||||||
String cause = "[BlockHunt] Seekers have won " + arena.arenaName;
|
String cause = "[BlockHunt] Seekers have won " + arena.getArenaOptions().arenaName();
|
||||||
rewardWinnersAndStop(arena, cause, arena.seekers, arena.seekersWinCommands, arena.seekersTokenWin,
|
rewardWinnersAndStop(arena, cause, arena.getSeekers(), arena.getArenaOptions().seekersWinCommands(), arena.getSeekersTokenWin(),
|
||||||
MessageKey.NORMAL_WIN_SEEKERS);
|
MessageKey.NORMAL_WIN_SEEKERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,8 +222,8 @@ public final class ArenaHelper {
|
|||||||
* @param arena <p>The arena in which the hiders won</p>
|
* @param arena <p>The arena in which the hiders won</p>
|
||||||
*/
|
*/
|
||||||
public static void hidersWin(Arena arena) {
|
public static void hidersWin(Arena arena) {
|
||||||
String cause = "[BlockHunt] Hiders have won " + arena.arenaName;
|
String cause = "[BlockHunt] Hiders have won " + arena.getArenaOptions().arenaName();
|
||||||
rewardWinnersAndStop(arena, cause, arena.hiders, arena.hidersWinCommands, arena.hidersTokenWin,
|
rewardWinnersAndStop(arena, cause, arena.getHiders(), arena.getArenaOptions().hidersWinCommands(), arena.getHidersTokenWin(),
|
||||||
MessageKey.NORMAL_WIN_HIDERS);
|
MessageKey.NORMAL_WIN_HIDERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ public final class ArenaHelper {
|
|||||||
List<Player> winners = new ArrayList<>();
|
List<Player> winners = new ArrayList<>();
|
||||||
List<Player> losers = new ArrayList<>();
|
List<Player> losers = new ArrayList<>();
|
||||||
|
|
||||||
for (Player player : arena.playersInArena) {
|
for (Player player : arena.getPlayersInArena()) {
|
||||||
if (winnerTeam.contains(player)) {
|
if (winnerTeam.contains(player)) {
|
||||||
winners.add(player);
|
winners.add(player);
|
||||||
grantRewards(player, winCommands, winTokens);
|
grantRewards(player, winCommands, winTokens);
|
||||||
@@ -306,18 +306,18 @@ public final class ArenaHelper {
|
|||||||
public static void stopArena(Arena arena, String cause, MessageKey message) {
|
public static void stopArena(Arena arena, String cause, MessageKey message) {
|
||||||
BlockHunt.plugin.getLogger().log(Level.INFO, cause);
|
BlockHunt.plugin.getLogger().log(Level.INFO, cause);
|
||||||
ArenaHelper.sendMessage(arena, message);
|
ArenaHelper.sendMessage(arena, message);
|
||||||
arena.seekers.clear();
|
arena.getSeekers().clear();
|
||||||
arena.hiders.clear();
|
arena.getHiders().clear();
|
||||||
|
|
||||||
for (Player player : arena.playersInArena) {
|
for (Player player : arena.getPlayersInArena()) {
|
||||||
playerLeaveArena(player, false, false);
|
playerLeaveArena(player, false, false);
|
||||||
MemoryStorage.playerArena.remove(player);
|
MemoryStorage.playerArena.remove(player);
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
|
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.gameState = ArenaState.WAITING;
|
arena.setGameState(ArenaGameState.WAITING);
|
||||||
arena.timer = 0;
|
arena.setTimer(0);
|
||||||
arena.playersInArena.clear();
|
arena.getPlayersInArena().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -328,7 +328,7 @@ public final class ArenaHelper {
|
|||||||
public static boolean noPlayersInArenas() {
|
public static boolean noPlayersInArenas() {
|
||||||
// Check if there are any players in any arena (quick way to early exit for event handlers)
|
// Check if there are any players in any arena (quick way to early exit for event handlers)
|
||||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||||
if (arena.playersInArena.size() > 0) {
|
if (arena.getPlayersInArena().size() > 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -350,20 +350,20 @@ public final class ArenaHelper {
|
|||||||
|
|
||||||
// Check that the arena has been properly set up before allowing the player to play
|
// Check that the arena has been properly set up before allowing the player to play
|
||||||
// TODO: It would be better to have a DISABLED state for arenas until they are properly set up.
|
// TODO: It would be better to have a DISABLED state for arenas until they are properly set up.
|
||||||
ArenaLocations locations = arena.arenaLocations;
|
ArenaLocations locations = arena.getArenaLocations();
|
||||||
if (!areWarpsSet(locations, player.getWorld())) {
|
if (!areWarpsSet(locations, player.getWorld())) {
|
||||||
MessageHelper.sendMessage(player, MessageKey.ERROR_JOIN_WARPS_NOT_SET);
|
MessageHelper.sendMessage(player, MessageKey.ERROR_JOIN_WARPS_NOT_SET);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the game isn't already running
|
// Make sure the game isn't already running
|
||||||
if (arena.gameState == ArenaState.IN_GAME) {
|
if (arena.getGameState() == ArenaGameState.IN_GAME) {
|
||||||
MessageHelper.sendMessage(player, MessageKey.ERROR_JOIN_ARENA_IN_GAME);
|
MessageHelper.sendMessage(player, MessageKey.ERROR_JOIN_ARENA_IN_GAME);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the arena is already full
|
// Check if the arena is already full
|
||||||
if (arena.playersInArena.size() >= arena.maxPlayers &&
|
if (arena.getPlayersInArena().size() >= arena.getMaxPlayers() &&
|
||||||
!PermissionsManager.hasPermission(player, Permission.JOIN_FULL, false)) {
|
!PermissionsManager.hasPermission(player, Permission.JOIN_FULL, false)) {
|
||||||
MessageHelper.sendMessage(player, MessageKey.ERROR_JOIN_FULL);
|
MessageHelper.sendMessage(player, MessageKey.ERROR_JOIN_FULL);
|
||||||
return;
|
return;
|
||||||
@@ -376,8 +376,8 @@ public final class ArenaHelper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockHunt.plugin.getLogger().log(Level.INFO, player.getName() + " has joined " + arena.arenaName);
|
BlockHunt.plugin.getLogger().log(Level.INFO, player.getName() + " has joined " + arena.getArenaOptions().arenaName());
|
||||||
arena.playersInArena.add(player);
|
arena.getPlayersInArena().add(player);
|
||||||
MemoryStorage.playerArena.put(player, arena);
|
MemoryStorage.playerArena.put(player, arena);
|
||||||
// Call the join event for any add-ons
|
// Call the join event for any add-ons
|
||||||
Bukkit.getPluginManager().callEvent(new JoinArenaEvent(player, arena));
|
Bukkit.getPluginManager().callEvent(new JoinArenaEvent(player, arena));
|
||||||
@@ -408,10 +408,10 @@ public final class ArenaHelper {
|
|||||||
|
|
||||||
// Announce that the player joined
|
// Announce that the player joined
|
||||||
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_JOIN_JOINED_ARENA, "%playerName%-" + player.getName(),
|
ArenaHelper.sendMessage(arena, MessageKey.NORMAL_JOIN_JOINED_ARENA, "%playerName%-" + player.getName(),
|
||||||
"1-" + arena.playersInArena.size(), "2-" + arena.maxPlayers);
|
"1-" + arena.getPlayersInArena().size(), "2-" + arena.getMaxPlayers());
|
||||||
if (arena.playersInArena.size() < arena.minPlayers) {
|
if (arena.getPlayersInArena().size() < arena.getMinPlayers()) {
|
||||||
// Announce that additional players are required for the arena to start
|
// Announce that additional players are required for the arena to start
|
||||||
sendMessage(arena, MessageKey.WARNING_LOBBY_NEED_AT_LEAST, "1-" + arena.minPlayers);
|
sendMessage(arena, MessageKey.WARNING_LOBBY_NEED_AT_LEAST, "1-" + arena.getMinPlayers());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -520,7 +520,7 @@ public final class ArenaHelper {
|
|||||||
if (healthAttribute != null) {
|
if (healthAttribute != null) {
|
||||||
healthAttribute.setBaseValue(20);
|
healthAttribute.setBaseValue(20);
|
||||||
}
|
}
|
||||||
player.setLevel(arena.timer);
|
player.setLevel(arena.getTimer());
|
||||||
player.setExp(0);
|
player.setExp(0);
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
player.getInventory().setHelmet(new ItemStack(Material.AIR));
|
player.getInventory().setHelmet(new ItemStack(Material.AIR));
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public final class InventoryHelper {
|
|||||||
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
Arena arena = MemoryStorage.arenaMap.get(arenaName.toLowerCase());
|
||||||
|
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
String shorten = arena.arenaName;
|
String shorten = arena.getArenaOptions().arenaName();
|
||||||
if (shorten.length() > 6) {
|
if (shorten.length() > 6) {
|
||||||
shorten = shorten.substring(0, 6);
|
shorten = shorten.substring(0, 6);
|
||||||
}
|
}
|
||||||
@@ -36,34 +36,34 @@ public final class InventoryHelper {
|
|||||||
|
|
||||||
ItemStack arenaNameNote = new ItemStack(Material.PAPER, 1);
|
ItemStack arenaNameNote = new ItemStack(Material.PAPER, 1);
|
||||||
ItemMeta arenaNameNote_IM = arenaNameNote.getItemMeta();
|
ItemMeta arenaNameNote_IM = arenaNameNote.getItemMeta();
|
||||||
arenaNameNote_IM.setDisplayName(MessageHelper.replaceAll("%NBlockHunt arena: %A" + arena.arenaName));
|
arenaNameNote_IM.setDisplayName(MessageHelper.replaceAll("%NBlockHunt arena: %A" + arena.getArenaOptions().arenaName()));
|
||||||
arenaNameNote.setItemMeta(arenaNameNote_IM);
|
arenaNameNote.setItemMeta(arenaNameNote_IM);
|
||||||
panel.setItem(0, arenaNameNote);
|
panel.setItem(0, arenaNameNote);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
ItemStack maxPlayers_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack maxPlayers_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
ItemStack maxPlayers = new ItemStack(Material.BEDROCK, arena.maxPlayers);
|
ItemStack maxPlayers = new ItemStack(Material.BEDROCK, arena.getMaxPlayers());
|
||||||
ItemStack maxPlayers_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack maxPlayers_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
|
|
||||||
ItemStack minPlayers_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack minPlayers_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
ItemStack minPlayers = new ItemStack(Material.BEDROCK, arena.minPlayers);
|
ItemStack minPlayers = new ItemStack(Material.BEDROCK, arena.getMinPlayers());
|
||||||
ItemStack minPlayers_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack minPlayers_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
|
|
||||||
ItemStack amountSeekersOnStart_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack amountSeekersOnStart_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
ItemStack amountSeekersOnStart = new ItemStack(Material.BEDROCK, arena.amountSeekersOnStart);
|
ItemStack amountSeekersOnStart = new ItemStack(Material.BEDROCK, arena.getAmountSeekersOnStart());
|
||||||
ItemStack amountSeekersOnStart_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack amountSeekersOnStart_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
|
|
||||||
ItemStack timeInLobbyUntilStart_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack timeInLobbyUntilStart_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
ItemStack timeInLobbyUntilStart = new ItemStack(Material.BEDROCK, arena.timeInLobbyUntilStart);
|
ItemStack timeInLobbyUntilStart = new ItemStack(Material.BEDROCK, arena.getTimeInLobbyUntilStart());
|
||||||
ItemStack timeInLobbyUntilStart_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack timeInLobbyUntilStart_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
|
|
||||||
ItemStack waitingTimeSeeker_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack waitingTimeSeeker_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
ItemStack waitingTimeSeeker = new ItemStack(Material.BEDROCK, arena.waitingTimeSeeker);
|
ItemStack waitingTimeSeeker = new ItemStack(Material.BEDROCK, arena.getWaitingTimeSeeker());
|
||||||
ItemStack waitingTimeSeeker_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack waitingTimeSeeker_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
|
|
||||||
ItemStack gameTime_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack gameTime_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
ItemStack gameTime = new ItemStack(Material.BEDROCK, arena.gameTime);
|
ItemStack gameTime = new ItemStack(Material.BEDROCK, arena.getGameTime());
|
||||||
ItemStack gameTime_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack gameTime_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
|
|
||||||
ItemStack disguiseBlocks_NOTE = new ItemStack(Material.BOOK, 1);
|
ItemStack disguiseBlocks_NOTE = new ItemStack(Material.BOOK, 1);
|
||||||
@@ -73,23 +73,23 @@ public final class InventoryHelper {
|
|||||||
panel.setItem(36, disguiseBlocks_NOTE);
|
panel.setItem(36, disguiseBlocks_NOTE);
|
||||||
|
|
||||||
ItemStack blockAnnouncerTime_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack blockAnnouncerTime_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
ItemStack blockAnnouncerTime = new ItemStack(Material.BEDROCK, arena.blockAnnouncerTime);
|
ItemStack blockAnnouncerTime = new ItemStack(Material.BEDROCK, arena.getBlockAnnouncerTime());
|
||||||
ItemStack blockAnnouncerTime_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack blockAnnouncerTime_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
|
|
||||||
ItemStack timeUntilHidersSword_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack timeUntilHidersSword_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
ItemStack timeUntilHidersSword = new ItemStack(Material.BEDROCK, arena.timeUntilHidersSword);
|
ItemStack timeUntilHidersSword = new ItemStack(Material.BEDROCK, arena.getTimeUntilHidersSword());
|
||||||
ItemStack timeUntilHidersSword_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack timeUntilHidersSword_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
|
|
||||||
ItemStack hidersTokenWin_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack hidersTokenWin_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
ItemStack hidersTokenWin = new ItemStack(Material.BEDROCK, arena.hidersTokenWin);
|
ItemStack hidersTokenWin = new ItemStack(Material.BEDROCK, arena.getHidersTokenWin());
|
||||||
ItemStack hidersTokenWin_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack hidersTokenWin_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
|
|
||||||
ItemStack seekersTokenWin_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack seekersTokenWin_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
ItemStack seekersTokenWin = new ItemStack(Material.BEDROCK, arena.seekersTokenWin);
|
ItemStack seekersTokenWin = new ItemStack(Material.BEDROCK, arena.getSeekersTokenWin());
|
||||||
ItemStack seekersTokenWin_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack seekersTokenWin_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
|
|
||||||
ItemStack killTokens_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack killTokens_UP = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
ItemStack killTokens = new ItemStack(Material.BEDROCK, arena.killTokens);
|
ItemStack killTokens = new ItemStack(Material.BEDROCK, arena.getKillTokens());
|
||||||
ItemStack killTokens_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
ItemStack killTokens_DOWN = new ItemStack(Material.GOLD_NUGGET, 1);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -136,17 +136,17 @@ public final class InventoryHelper {
|
|||||||
upItem.setItemMeta(upItemItemMeta);
|
upItem.setItemMeta(upItemItemMeta);
|
||||||
|
|
||||||
int setting = switch (arenaProperty) {
|
int setting = switch (arenaProperty) {
|
||||||
case MAX_PLAYERS -> arena.maxPlayers;
|
case MAX_PLAYERS -> arena.getMaxPlayers();
|
||||||
case MIN_PLAYERS -> arena.minPlayers;
|
case MIN_PLAYERS -> arena.getMinPlayers();
|
||||||
case AMOUNT_SEEKERS_ON_START -> arena.amountSeekersOnStart;
|
case AMOUNT_SEEKERS_ON_START -> arena.getAmountSeekersOnStart();
|
||||||
case TIME_IN_LOBBY_UNTIL_START -> arena.timeInLobbyUntilStart;
|
case TIME_IN_LOBBY_UNTIL_START -> arena.getTimeInLobbyUntilStart();
|
||||||
case WAITING_TIME_SEEKER -> arena.waitingTimeSeeker;
|
case WAITING_TIME_SEEKER -> arena.getWaitingTimeSeeker();
|
||||||
case GAME_TIME -> arena.gameTime;
|
case GAME_TIME -> arena.getGameTime();
|
||||||
case TIME_UNTIL_HIDERS_SWORD -> arena.timeUntilHidersSword;
|
case TIME_UNTIL_HIDERS_SWORD -> arena.getTimeUntilHidersSword();
|
||||||
case BLOCK_ANNOUNCER_TIME -> arena.blockAnnouncerTime;
|
case BLOCK_ANNOUNCER_TIME -> arena.getBlockAnnouncerTime();
|
||||||
case HIDERS_TOKEN_WIN -> arena.hidersTokenWin;
|
case HIDERS_TOKEN_WIN -> arena.getHidersTokenWin();
|
||||||
case SEEKERS_TOKEN_WIN -> arena.seekersTokenWin;
|
case SEEKERS_TOKEN_WIN -> arena.getSeekersTokenWin();
|
||||||
case KILL_TOKENS -> arena.killTokens;
|
case KILL_TOKENS -> arena.getKillTokens();
|
||||||
};
|
};
|
||||||
|
|
||||||
ItemMeta buttonItemMeta = buttonItem.getItemMeta();
|
ItemMeta buttonItemMeta = buttonItem.getItemMeta();
|
||||||
@@ -165,7 +165,7 @@ public final class InventoryHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void openDisguiseBlocks(Arena arena, Player player) {
|
public static void openDisguiseBlocks(Arena arena, Player player) {
|
||||||
String arenaName = arena.arenaName;
|
String arenaName = arena.getArenaOptions().arenaName();
|
||||||
Inventory panel = Bukkit.createInventory(null, 36, MessageHelper.replaceAll("%N&lDisguiseBlocks"));
|
Inventory panel = Bukkit.createInventory(null, 36, MessageHelper.replaceAll("%N&lDisguiseBlocks"));
|
||||||
|
|
||||||
ItemStack arenaNameNote = new ItemStack(Material.PAPER, 1);
|
ItemStack arenaNameNote = new ItemStack(Material.PAPER, 1);
|
||||||
@@ -176,9 +176,9 @@ public final class InventoryHelper {
|
|||||||
arenaNameNoteItemMeta.setLore(loreLines);
|
arenaNameNoteItemMeta.setLore(loreLines);
|
||||||
arenaNameNote.setItemMeta(arenaNameNoteItemMeta);
|
arenaNameNote.setItemMeta(arenaNameNoteItemMeta);
|
||||||
panel.setItem(0, arenaNameNote);
|
panel.setItem(0, arenaNameNote);
|
||||||
if (arena.disguiseBlocks != null) {
|
if (arena.getDisguiseBlocks() != null) {
|
||||||
for (int i = arena.disguiseBlocks.size(); i > 0; i = i - 1) {
|
for (int i = arena.getDisguiseBlocks().size(); i > 0; i = i - 1) {
|
||||||
panel.setItem(i, arena.disguiseBlocks.get(i - 1));
|
panel.setItem(i, arena.getDisguiseBlocks().get(i - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.openInventory(panel);
|
player.openInventory(panel);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package net.knarcraft.blockhunt.util;
|
|||||||
import net.knarcraft.blockhunt.BlockHunt;
|
import net.knarcraft.blockhunt.BlockHunt;
|
||||||
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.ArenaState;
|
import net.knarcraft.blockhunt.arena.ArenaGameState;
|
||||||
import net.knarcraft.blockhunt.config.ConfigKey;
|
import net.knarcraft.blockhunt.config.ConfigKey;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -21,37 +21,37 @@ public final class ScoreboardHelper {
|
|||||||
|
|
||||||
public static void createScoreboard(Arena arena) {
|
public static void createScoreboard(Arena arena) {
|
||||||
if ((Boolean) MemoryStorage.config.get(ConfigKey.SCOREBOARD_ENABLED)) {
|
if ((Boolean) MemoryStorage.config.get(ConfigKey.SCOREBOARD_ENABLED)) {
|
||||||
Scoreboard board = arena.scoreboard;
|
Scoreboard board = arena.getScoreboard();
|
||||||
if (board.getObjective(arena.arenaName) != null) {
|
if (board.getObjective(arena.getArenaOptions().arenaName()) != null) {
|
||||||
updateScoreboard(arena);
|
updateScoreboard(arena);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String displayName = BlockHunt.cutString(MessageHelper.replaceAll(
|
String displayName = BlockHunt.cutString(MessageHelper.replaceAll(
|
||||||
(String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_TITLE)), 32);
|
(String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_TITLE)), 32);
|
||||||
Objective object = board.registerNewObjective(BlockHunt.cutString(arena.arenaName, 32),
|
Objective object = board.registerNewObjective(BlockHunt.cutString(arena.getArenaOptions().arenaName(), 32),
|
||||||
Criteria.DUMMY, displayName);
|
Criteria.DUMMY, displayName);
|
||||||
|
|
||||||
object.setDisplaySlot(DisplaySlot.SIDEBAR);
|
object.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
|
|
||||||
String temp = BlockHunt.cutString(MessageHelper.replaceAll((String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_TIME_LEFT)), 32);
|
String temp = BlockHunt.cutString(MessageHelper.replaceAll((String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_TIME_LEFT)), 32);
|
||||||
Score timeleft = object.getScore(temp);
|
Score timeleft = object.getScore(temp);
|
||||||
timeleft.setScore(arena.timer);
|
timeleft.setScore(arena.getTimer());
|
||||||
|
|
||||||
temp = BlockHunt.cutString(MessageHelper.replaceAll((String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_SEEKERS)), 32);
|
temp = BlockHunt.cutString(MessageHelper.replaceAll((String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_SEEKERS)), 32);
|
||||||
Score seekers = object.getScore(temp);
|
Score seekers = object.getScore(temp);
|
||||||
seekers.setScore(arena.seekers.size());
|
seekers.setScore(arena.getSeekers().size());
|
||||||
|
|
||||||
temp = BlockHunt.cutString(MessageHelper.replaceAll((String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_HIDERS)), 32);
|
temp = BlockHunt.cutString(MessageHelper.replaceAll((String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_HIDERS)), 32);
|
||||||
Score hiders = object.getScore(temp);
|
Score hiders = object.getScore(temp);
|
||||||
hiders.setScore(arena.playersInArena.size() - arena.seekers.size());
|
hiders.setScore(arena.getPlayersInArena().size() - arena.getSeekers().size());
|
||||||
|
|
||||||
if (arena.gameState == ArenaState.IN_GAME) {
|
if (arena.getGameState() == ArenaGameState.IN_GAME) {
|
||||||
for (Player pl : arena.playersInArena) {
|
for (Player pl : arena.getPlayersInArena()) {
|
||||||
pl.setScoreboard(board);
|
pl.setScoreboard(board);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Player pl : arena.playersInArena) {
|
for (Player pl : arena.getPlayersInArena()) {
|
||||||
pl.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
pl.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,28 +60,28 @@ public final class ScoreboardHelper {
|
|||||||
|
|
||||||
public static void updateScoreboard(Arena arena) {
|
public static void updateScoreboard(Arena arena) {
|
||||||
if ((Boolean) MemoryStorage.config.get(ConfigKey.SCOREBOARD_ENABLED)) {
|
if ((Boolean) MemoryStorage.config.get(ConfigKey.SCOREBOARD_ENABLED)) {
|
||||||
Scoreboard board = arena.scoreboard;
|
Scoreboard board = arena.getScoreboard();
|
||||||
Objective object = board.getObjective(DisplaySlot.SIDEBAR);
|
Objective object = board.getObjective(DisplaySlot.SIDEBAR);
|
||||||
object.setDisplayName(BlockHunt.cutString(MessageHelper.replaceAll((String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_TITLE)), 32));
|
object.setDisplayName(BlockHunt.cutString(MessageHelper.replaceAll((String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_TITLE)), 32));
|
||||||
|
|
||||||
String temp = BlockHunt.cutString(MessageHelper.replaceAll((String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_TIME_LEFT)), 32);
|
String temp = BlockHunt.cutString(MessageHelper.replaceAll((String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_TIME_LEFT)), 32);
|
||||||
Score timeleft = object.getScore(temp);
|
Score timeleft = object.getScore(temp);
|
||||||
timeleft.setScore(arena.timer);
|
timeleft.setScore(arena.getTimer());
|
||||||
|
|
||||||
temp = BlockHunt.cutString(MessageHelper.replaceAll((String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_SEEKERS)), 32);
|
temp = BlockHunt.cutString(MessageHelper.replaceAll((String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_SEEKERS)), 32);
|
||||||
Score seekers = object.getScore(temp);
|
Score seekers = object.getScore(temp);
|
||||||
seekers.setScore(arena.seekers.size());
|
seekers.setScore(arena.getSeekers().size());
|
||||||
|
|
||||||
temp = BlockHunt.cutString(MessageHelper.replaceAll((String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_HIDERS)), 32);
|
temp = BlockHunt.cutString(MessageHelper.replaceAll((String) MemoryStorage.config.get(ConfigKey.SCOREBOARD_HIDERS)), 32);
|
||||||
Score hiders = object.getScore(temp);
|
Score hiders = object.getScore(temp);
|
||||||
hiders.setScore(arena.playersInArena.size() - arena.seekers.size());
|
hiders.setScore(arena.getPlayersInArena().size() - arena.getSeekers().size());
|
||||||
|
|
||||||
if (arena.gameState == ArenaState.IN_GAME) {
|
if (arena.getGameState() == ArenaGameState.IN_GAME) {
|
||||||
for (Player pl : arena.playersInArena) {
|
for (Player pl : arena.getPlayersInArena()) {
|
||||||
pl.setScoreboard(board);
|
pl.setScoreboard(board);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Player pl : arena.playersInArena) {
|
for (Player pl : arena.getPlayersInArena()) {
|
||||||
pl.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
pl.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package net.knarcraft.blockhunt.util;
|
|||||||
|
|
||||||
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.ArenaState;
|
import net.knarcraft.blockhunt.arena.ArenaGameState;
|
||||||
import net.knarcraft.blockhunt.config.ConfigKey;
|
import net.knarcraft.blockhunt.config.ConfigKey;
|
||||||
import net.knarcraft.blockhunt.config.MessageKey;
|
import net.knarcraft.blockhunt.config.MessageKey;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -28,7 +28,7 @@ public final class SignsHelper {
|
|||||||
boolean saved = false;
|
boolean saved = false;
|
||||||
Arena arena = MemoryStorage.arenaMap.get(lines[1].toLowerCase());
|
Arena arena = MemoryStorage.arenaMap.get(lines[1].toLowerCase());
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
saveSign(arena.arenaName, location);
|
saveSign(arena.getArenaOptions().arenaName(), location);
|
||||||
saved = true;
|
saved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,22 +117,22 @@ public final class SignsHelper {
|
|||||||
//TODO: Store the relationships between signs and arenas directly
|
//TODO: Store the relationships between signs and arenas directly
|
||||||
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
for (Arena arena : MemoryStorage.arenaMap.values()) {
|
||||||
//Find the correct arena
|
//Find the correct arena
|
||||||
if (!arenaName.endsWith(arena.arenaName)) {
|
if (!arenaName.endsWith(arena.getArenaOptions().arenaName())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (arena.gameState.equals(ArenaState.WAITING)) {
|
if (arena.getGameState().equals(ArenaGameState.WAITING)) {
|
||||||
drawSign(MemoryStorage.config.getFileConfiguration().getStringList(ConfigKey.SIGN_WAITING.getPath()), signBlock, arena);
|
drawSign(MemoryStorage.config.getFileConfiguration().getStringList(ConfigKey.SIGN_WAITING.getPath()), signBlock, arena);
|
||||||
} else if (arena.gameState.equals(ArenaState.STARTING)) {
|
} else if (arena.getGameState().equals(ArenaGameState.STARTING)) {
|
||||||
drawSign(MemoryStorage.config.getFileConfiguration().getStringList(ConfigKey.SIGN_STARTING.getPath()), signBlock, arena);
|
drawSign(MemoryStorage.config.getFileConfiguration().getStringList(ConfigKey.SIGN_STARTING.getPath()), signBlock, arena);
|
||||||
} else if (arena.gameState.equals(ArenaState.IN_GAME)) {
|
} else if (arena.getGameState().equals(ArenaGameState.IN_GAME)) {
|
||||||
drawSign(MemoryStorage.config.getFileConfiguration().getStringList(ConfigKey.SIGN_IN_GAME.getPath()), signBlock, arena);
|
drawSign(MemoryStorage.config.getFileConfiguration().getStringList(ConfigKey.SIGN_IN_GAME.getPath()), signBlock, arena);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void drawSign(List<String> signLines, Sign signBlock, Arena arena) {
|
private static void drawSign(List<String> signLines, Sign signBlock, Arena arena) {
|
||||||
drawSign(signLines, signBlock, "arenaName-" + arena.arenaName, "players-" + arena.playersInArena.size(),
|
drawSign(signLines, signBlock, "arenaName-" + arena.getArenaOptions().arenaName(), "players-" +
|
||||||
"maxplayers-" + arena.maxPlayers, "timeleft-" + arena.timer);
|
arena.getPlayersInArena().size(), "maxplayers-" + arena.getMaxPlayers(), "timeleft-" + arena.getTimer());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void drawSign(List<String> signLines, Sign signBlock, String... variables) {
|
private static void drawSign(List<String> signLines, Sign signBlock, String... variables) {
|
||||||
|
|||||||
@@ -32,6 +32,44 @@ public final class VisibilityHelper {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the hidden state of the given hider
|
||||||
|
*
|
||||||
|
* @param player <p>A player that's currently a hider</p>
|
||||||
|
*/
|
||||||
|
public static void updateHiddenState(Player player) {
|
||||||
|
Location playerLocation = player.getLocation();
|
||||||
|
Location moveLocation = MemoryStorage.moveLocation.get(player);
|
||||||
|
|
||||||
|
// If the hider has somehow lost their disguise block from their inventory,
|
||||||
|
ItemStack inventoryBlock = player.getInventory().getItem(8);
|
||||||
|
if (inventoryBlock == null && MemoryStorage.playerBlock.get(player) != null) {
|
||||||
|
inventoryBlock = MemoryStorage.playerBlock.get(player);
|
||||||
|
player.getInventory().setItem(8, inventoryBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (moveLocation == null || inventoryBlock == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the player is standing still, try to turn the player into a solid block
|
||||||
|
if (moveLocation.getX() == playerLocation.getX() && moveLocation.getY() == playerLocation.getY() &&
|
||||||
|
moveLocation.getZ() == playerLocation.getZ()) {
|
||||||
|
if (inventoryBlock.getAmount() > 1) {
|
||||||
|
// Just decrease the timer
|
||||||
|
inventoryBlock.setAmount(inventoryBlock.getAmount() - 1);
|
||||||
|
} else {
|
||||||
|
VisibilityHelper.makePlayerSolid(player, inventoryBlock);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// The player moved. Un-hide and reset the hide timer
|
||||||
|
inventoryBlock.setAmount(5);
|
||||||
|
if (!DisguiseAPI.isDisguised(player)) {
|
||||||
|
VisibilityHelper.makePlayerUnSolid(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a player visible to players in an arena and the other way around
|
* Makes a player visible to players in an arena and the other way around
|
||||||
*
|
*
|
||||||
@@ -39,7 +77,7 @@ public final class VisibilityHelper {
|
|||||||
* @param player <p>The player to make visible</p>
|
* @param player <p>The player to make visible</p>
|
||||||
*/
|
*/
|
||||||
public static void makePlayerVisible(Arena arena, Player player) {
|
public static void makePlayerVisible(Arena arena, Player player) {
|
||||||
for (Player otherPlayer : arena.playersInArena) {
|
for (Player otherPlayer : arena.getPlayersInArena()) {
|
||||||
if (otherPlayer.canSee(player)) {
|
if (otherPlayer.canSee(player)) {
|
||||||
// Make player visible to others
|
// Make player visible to others
|
||||||
otherPlayer.showPlayer(BlockHunt.plugin, player);
|
otherPlayer.showPlayer(BlockHunt.plugin, player);
|
||||||
@@ -133,7 +171,7 @@ public final class VisibilityHelper {
|
|||||||
* @param player <p>The player to make solid</p>
|
* @param player <p>The player to make solid</p>
|
||||||
* @param solidBlock <p>The block to solidify the player as</p>
|
* @param solidBlock <p>The block to solidify the player as</p>
|
||||||
*/
|
*/
|
||||||
public static void makePlayerSolid(Player player, ItemStack solidBlock) {
|
private static void makePlayerSolid(Player player, ItemStack solidBlock) {
|
||||||
Block playerBlock = player.getLocation().getBlock();
|
Block playerBlock = player.getLocation().getBlock();
|
||||||
BlockData playerBlockData = playerBlock.getBlockData();
|
BlockData playerBlockData = playerBlock.getBlockData();
|
||||||
if (playerBlockData.getMaterial().isAir() || !playerBlockData.getMaterial().isSolid()) {
|
if (playerBlockData.getMaterial().isAir() || !playerBlockData.getMaterial().isSolid()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user