1.7.5 rc2
This commit is contained in:
parent
dd9a6dfd88
commit
062defa285
7 changed files with 202 additions and 24 deletions
|
@ -11,8 +11,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.minPlayers;
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
|
||||||
public class Start implements ICommand {
|
public class Start implements ICommand {
|
||||||
|
@ -40,14 +39,22 @@ public class Start implements ICommand {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
List<Player> initialSeekers = new ArrayList<>(args.length);
|
List<Player> initialSeekers = new ArrayList<>();
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 0; i < args.length; i++) {
|
||||||
Player seeker = Bukkit.getPlayer(args[i]);
|
Player seeker = Bukkit.getPlayer(args[i]);
|
||||||
if (seeker == null || !Main.getInstance().getBoard().contains(seeker) || initialSeekers.contains(seeker)) {
|
if (seeker == null || !Main.getInstance().getBoard().contains(seeker) || initialSeekers.contains(seeker)) {
|
||||||
sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(args[i]));
|
sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(args[i]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
initialSeekers.add(seeker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int minHiders = minPlayers - startingSeekerCount;
|
||||||
|
if (Main.getInstance().getBoard().size() - initialSeekers.size() < minHiders) {
|
||||||
|
sender.sendMessage(errorPrefix + message("START_MIN_PLAYERS").addAmount(minPlayers));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Main.getInstance().getGame().start(initialSeekers);
|
Main.getInstance().getGame().start(initialSeekers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,12 @@ import java.util.List;
|
||||||
public class Items {
|
public class Items {
|
||||||
|
|
||||||
public static List<ItemStack> HIDER_ITEMS, SEEKER_ITEMS;
|
public static List<ItemStack> HIDER_ITEMS, SEEKER_ITEMS;
|
||||||
|
public static ItemStack
|
||||||
|
HIDER_HELM, SEEKER_HELM,
|
||||||
|
HIDER_CHEST, SEEKER_CHEST,
|
||||||
|
HIDER_LEGS, SEEKER_LEGS,
|
||||||
|
HIDER_BOOTS, SEEKER_BOOTS;
|
||||||
|
|
||||||
public static List<PotionEffect> HIDER_EFFECTS, SEEKER_EFFECTS;
|
public static List<PotionEffect> HIDER_EFFECTS, SEEKER_EFFECTS;
|
||||||
|
|
||||||
public static void loadItems() {
|
public static void loadItems() {
|
||||||
|
@ -23,24 +29,60 @@ public class Items {
|
||||||
ConfigManager manager = ConfigManager.create("items.yml");
|
ConfigManager manager = ConfigManager.create("items.yml");
|
||||||
|
|
||||||
SEEKER_ITEMS = new ArrayList<>();
|
SEEKER_ITEMS = new ArrayList<>();
|
||||||
|
SEEKER_HELM = null;
|
||||||
|
SEEKER_CHEST = null;
|
||||||
|
SEEKER_LEGS = null;
|
||||||
|
SEEKER_BOOTS = null;
|
||||||
ConfigurationSection SeekerItems = manager.getConfigurationSection("items.seeker");
|
ConfigurationSection SeekerItems = manager.getConfigurationSection("items.seeker");
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while (true) {
|
while (true) {
|
||||||
ConfigurationSection section = SeekerItems.getConfigurationSection(String.valueOf(i));
|
ConfigurationSection section = SeekerItems.getConfigurationSection(String.valueOf(i));
|
||||||
if (section == null) break;
|
if (section == null) break;
|
||||||
ItemStack item = createItem(section);
|
ItemStack item = createItem(section);
|
||||||
if (item != null) SEEKER_ITEMS.add(item);
|
if (item == null) continue;
|
||||||
|
String loc = section.getString("location");
|
||||||
|
if (loc == null) {
|
||||||
|
SEEKER_ITEMS.add(item);
|
||||||
|
} else if (loc.equals("helmet")) {
|
||||||
|
SEEKER_HELM = item;
|
||||||
|
} else if (loc.equals("chestplate")) {
|
||||||
|
SEEKER_CHEST = item;
|
||||||
|
} else if (loc.equals("leggings")) {
|
||||||
|
SEEKER_LEGS = item;
|
||||||
|
} else if (loc.equals("boots")) {
|
||||||
|
SEEKER_BOOTS = item;
|
||||||
|
} else {
|
||||||
|
SEEKER_ITEMS.add(item);
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
HIDER_ITEMS = new ArrayList<>();
|
HIDER_ITEMS = new ArrayList<>();
|
||||||
|
HIDER_HELM = null;
|
||||||
|
HIDER_CHEST = null;
|
||||||
|
HIDER_LEGS = null;
|
||||||
|
HIDER_BOOTS = null;
|
||||||
ConfigurationSection HiderItems = manager.getConfigurationSection("items.hider");
|
ConfigurationSection HiderItems = manager.getConfigurationSection("items.hider");
|
||||||
i = 1;
|
i = 1;
|
||||||
while (true) {
|
while (true) {
|
||||||
ConfigurationSection section = HiderItems.getConfigurationSection(String.valueOf(i));
|
ConfigurationSection section = HiderItems.getConfigurationSection(String.valueOf(i));
|
||||||
if (section == null) break;
|
if (section == null) break;
|
||||||
ItemStack item = createItem(section);
|
ItemStack item = createItem(section);
|
||||||
if (item != null) HIDER_ITEMS.add(item);
|
if (item == null) continue;
|
||||||
|
String loc = section.getString("location");
|
||||||
|
if (loc == null) {
|
||||||
|
HIDER_ITEMS.add(item);
|
||||||
|
} else if (loc.equals("helmet")) {
|
||||||
|
HIDER_HELM = item;
|
||||||
|
} else if (loc.equals("chestplate")) {
|
||||||
|
HIDER_CHEST = item;
|
||||||
|
} else if (loc.equals("leggings")) {
|
||||||
|
HIDER_LEGS = item;
|
||||||
|
} else if (loc.equals("boots")) {
|
||||||
|
HIDER_BOOTS = item;
|
||||||
|
} else {
|
||||||
|
HIDER_ITEMS.add(item);
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
SEEKER_EFFECTS = new ArrayList<>();
|
SEEKER_EFFECTS = new ArrayList<>();
|
||||||
|
@ -64,7 +106,6 @@ public class Items {
|
||||||
if (effect != null) HIDER_EFFECTS.add(effect);
|
if (effect != null) HIDER_EFFECTS.add(effect);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ItemStack createItem(ConfigurationSection item) {
|
private static ItemStack createItem(ConfigurationSection item) {
|
||||||
|
|
|
@ -58,6 +58,8 @@ public class Game {
|
||||||
private int gameTimer;
|
private int gameTimer;
|
||||||
private boolean hiderLeft;
|
private boolean hiderLeft;
|
||||||
|
|
||||||
|
private Random random;
|
||||||
|
|
||||||
public Game(Map map, Board board) {
|
public Game(Map map, Board board) {
|
||||||
|
|
||||||
this.currentMap = map;
|
this.currentMap = map;
|
||||||
|
@ -74,6 +76,8 @@ public class Game {
|
||||||
this.startingTimer = -1;
|
this.startingTimer = -1;
|
||||||
this.gameTimer = 0;
|
this.gameTimer = 0;
|
||||||
this.hiderLeft = false;
|
this.hiderLeft = false;
|
||||||
|
|
||||||
|
this.random = new Random();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Status getStatus(){
|
public Status getStatus(){
|
||||||
|
@ -101,7 +105,7 @@ public class Game {
|
||||||
List<Player> pool = board.getPlayers();
|
List<Player> pool = board.getPlayers();
|
||||||
for (int i = 0; i < startingSeekerCount; i++) {
|
for (int i = 0; i < startingSeekerCount; i++) {
|
||||||
try {
|
try {
|
||||||
int rand = new Random().nextInt(0, pool.size()-1);
|
int rand = random.nextInt(0, pool.size());
|
||||||
seekers.add(pool.remove(rand));
|
seekers.add(pool.remove(rand));
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
Main.getInstance().getLogger().warning("Failed to select random seeker.");
|
Main.getInstance().getLogger().warning("Failed to select random seeker.");
|
||||||
|
|
|
@ -82,15 +82,33 @@ public class PlayerLoader {
|
||||||
if(board.isSpectator(player)) return;
|
if(board.isSpectator(player)) return;
|
||||||
loadPlayer(player);
|
loadPlayer(player);
|
||||||
if (board.isSeeker(player)) {
|
if (board.isSeeker(player)) {
|
||||||
if (pvpEnabled)
|
if (pvpEnabled) {
|
||||||
for(ItemStack item : Items.SEEKER_ITEMS)
|
for(ItemStack item : Items.SEEKER_ITEMS)
|
||||||
player.getInventory().addItem(item);
|
player.getInventory().addItem(item);
|
||||||
|
if (Items.SEEKER_HELM != null)
|
||||||
|
player.getInventory().setHelmet(Items.SEEKER_HELM);
|
||||||
|
if (Items.SEEKER_CHEST != null)
|
||||||
|
player.getInventory().setChestplate(Items.SEEKER_CHEST);
|
||||||
|
if (Items.SEEKER_LEGS != null)
|
||||||
|
player.getInventory().setLeggings(Items.SEEKER_LEGS);
|
||||||
|
if (Items.SEEKER_BOOTS != null)
|
||||||
|
player.getInventory().setBoots(Items.SEEKER_BOOTS);
|
||||||
|
}
|
||||||
for(PotionEffect effect : Items.SEEKER_EFFECTS)
|
for(PotionEffect effect : Items.SEEKER_EFFECTS)
|
||||||
player.addPotionEffect(effect);
|
player.addPotionEffect(effect);
|
||||||
} else if (board.isHider(player)) {
|
} else if (board.isHider(player)) {
|
||||||
if (pvpEnabled)
|
if (pvpEnabled) {
|
||||||
for(ItemStack item : Items.HIDER_ITEMS)
|
for(ItemStack item : Items.HIDER_ITEMS)
|
||||||
player.getInventory().addItem(item);
|
player.getInventory().addItem(item);
|
||||||
|
if (Items.HIDER_HELM != null)
|
||||||
|
player.getInventory().setHelmet(Items.HIDER_HELM);
|
||||||
|
if (Items.HIDER_CHEST != null)
|
||||||
|
player.getInventory().setChestplate(Items.HIDER_CHEST);
|
||||||
|
if (Items.HIDER_LEGS != null)
|
||||||
|
player.getInventory().setLeggings(Items.HIDER_LEGS);
|
||||||
|
if (Items.HIDER_BOOTS != null)
|
||||||
|
player.getInventory().setBoots(Items.HIDER_BOOTS);
|
||||||
|
}
|
||||||
for(PotionEffect effect : Items.HIDER_EFFECTS)
|
for(PotionEffect effect : Items.HIDER_EFFECTS)
|
||||||
player.addPotionEffect(effect);
|
player.addPotionEffect(effect);
|
||||||
if (glowEnabled) {
|
if (glowEnabled) {
|
||||||
|
|
|
@ -3,8 +3,10 @@ package net.tylermurphy.hideAndSeek.game.listener;
|
||||||
import com.cryptomorin.xseries.XMaterial;
|
import com.cryptomorin.xseries.XMaterial;
|
||||||
import com.cryptomorin.xseries.messages.ActionBar;
|
import com.cryptomorin.xseries.messages.ActionBar;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
import net.tylermurphy.hideAndSeek.game.Board;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.Status;
|
import net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
@ -13,6 +15,8 @@ import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.BookMeta;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -94,17 +98,82 @@ public class InteractHandler implements Listener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(temp.isSimilar(teleportItem)){
|
if(temp.isSimilar(teleportItem)){
|
||||||
int amount = Main.getInstance().getBoard().getHiders().size() + Main.getInstance().getBoard().getSeekers().size();
|
// int amount = Main.getInstance().getBoard().getHiders().size() + Main.getInstance().getBoard().getSeekers().size();
|
||||||
Inventory teleportMenu = Main.getInstance().getServer().createInventory(null, 9*(((amount-1)/9)+1), ChatColor.stripColor(teleportItem.getItemMeta().getDisplayName()));
|
// Inventory teleportMenu = Main.getInstance().getServer().createInventory(null, 9*(((amount-1)/9)+1), ChatColor.stripColor(teleportItem.getItemMeta().getDisplayName()));
|
||||||
List<String> hider_lore = new ArrayList<>(); hider_lore.add(message("HIDER_TEAM_NAME").toString());
|
// List<String> hider_lore = new ArrayList<>(); hider_lore.add(message("HIDER_TEAM_NAME").toString());
|
||||||
Main.getInstance().getBoard().getHiders().forEach(hider -> teleportMenu.addItem(getSkull(hider, hider_lore)));
|
// Main.getInstance().getBoard().getHiders().forEach(hider -> teleportMenu.addItem(getSkull(hider, hider_lore)));
|
||||||
List<String> seeker_lore = new ArrayList<>(); seeker_lore.add(message("SEEKER_TEAM_NAME").toString());
|
// List<String> seeker_lore = new ArrayList<>(); seeker_lore.add(message("SEEKER_TEAM_NAME").toString());
|
||||||
Main.getInstance().getBoard().getSeekers().forEach(seeker -> teleportMenu.addItem(getSkull(seeker, seeker_lore)));
|
// Main.getInstance().getBoard().getSeekers().forEach(seeker -> teleportMenu.addItem(getSkull(seeker, seeker_lore)));
|
||||||
event.getPlayer().openInventory(teleportMenu);
|
// event.getPlayer().openInventory(teleportMenu);
|
||||||
|
createSpectatorTeleportPage(event.getPlayer(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack getSkull(Player player, List<String> lore){
|
public static void createSpectatorTeleportPage(Player player, int page) {
|
||||||
|
|
||||||
|
if (page < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Board board = Main.getInstance().getBoard();
|
||||||
|
List<Player> players = new ArrayList<>();
|
||||||
|
players.addAll(board.getHiders());
|
||||||
|
players.addAll(board.getSeekers());
|
||||||
|
|
||||||
|
final int page_size = 9 * 5;
|
||||||
|
final int amount = players.size();
|
||||||
|
final int start = page * page_size;
|
||||||
|
|
||||||
|
int page_amount = amount - start;
|
||||||
|
|
||||||
|
if (page_amount < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean next = false, prev = true;
|
||||||
|
|
||||||
|
if (page_amount > page_size) {
|
||||||
|
page_amount = page_size;
|
||||||
|
next = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (page == 0) {
|
||||||
|
prev = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final int rows = ((amount - 1) / 9) + 2;
|
||||||
|
|
||||||
|
final Inventory teleportMenu = Main.getInstance().getServer().createInventory(null, 9 * rows, ChatColor.stripColor(teleportItem.getItemMeta().getDisplayName()));
|
||||||
|
|
||||||
|
final List<String> hider_lore = new ArrayList<>(); hider_lore.add(message("HIDER_TEAM_NAME").toString());
|
||||||
|
final List<String> seeker_lore = new ArrayList<>(); seeker_lore.add(message("SEEKER_TEAM_NAME").toString());
|
||||||
|
|
||||||
|
for (int i = 0; i < page_amount; i++) {
|
||||||
|
Player plr = players.get(i);
|
||||||
|
teleportMenu.addItem(getSkull(plr, board.isHider(plr) ? hider_lore : seeker_lore));
|
||||||
|
}
|
||||||
|
|
||||||
|
final int lastRow = (rows - 1) * 9;
|
||||||
|
if (prev) {
|
||||||
|
teleportMenu.setItem(lastRow, getPageItem(page - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (next) {
|
||||||
|
teleportMenu.setItem(lastRow + 8, getPageItem(page + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
player.openInventory(teleportMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ItemStack getPageItem(int page) {
|
||||||
|
ItemStack prevItem = new ItemStack(XMaterial.ENCHANTED_BOOK.parseMaterial(), page + 1);
|
||||||
|
ItemMeta meta = prevItem.getItemMeta();
|
||||||
|
meta.setDisplayName("Page " + (page+1));
|
||||||
|
prevItem.setItemMeta(meta);
|
||||||
|
return prevItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ItemStack getSkull(Player player, List<String> lore){
|
||||||
assert XMaterial.PLAYER_HEAD.parseMaterial() != null;
|
assert XMaterial.PLAYER_HEAD.parseMaterial() != null;
|
||||||
ItemStack playerHead = new ItemStack(XMaterial.PLAYER_HEAD.parseMaterial(), 1, (byte) 3);
|
ItemStack playerHead = new ItemStack(XMaterial.PLAYER_HEAD.parseMaterial(), 1, (byte) 3);
|
||||||
SkullMeta playerHeadMeta = (SkullMeta) playerHead.getItemMeta();
|
SkullMeta playerHeadMeta = (SkullMeta) playerHead.getItemMeta();
|
||||||
|
|
|
@ -32,6 +32,8 @@ import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
public class InventoryHandler implements Listener {
|
public class InventoryHandler implements Listener {
|
||||||
|
|
||||||
|
@ -52,13 +54,30 @@ public class InventoryHandler implements Listener {
|
||||||
|
|
||||||
private void checkForSpectatorTeleportMenu(InventoryClickEvent event){
|
private void checkForSpectatorTeleportMenu(InventoryClickEvent event){
|
||||||
Player player = (Player) event.getWhoClicked();
|
Player player = (Player) event.getWhoClicked();
|
||||||
if (Main.getInstance().getBoard().isSpectator(player) && event.getCurrentItem().getType() == XMaterial.PLAYER_HEAD.parseMaterial()) {
|
|
||||||
|
ItemStack item = event.getCurrentItem();
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
String name = meta.getDisplayName();
|
||||||
|
|
||||||
|
if (Main.getInstance().getBoard().isSpectator(player)) {
|
||||||
|
if (XMaterial.PLAYER_HEAD.isSimilar(item)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
String name = event.getCurrentItem().getItemMeta().getDisplayName();
|
|
||||||
Player clicked = Main.getInstance().getServer().getPlayer(name);
|
Player clicked = Main.getInstance().getServer().getPlayer(name);
|
||||||
if (clicked == null) return;
|
if (clicked == null) return;
|
||||||
player.teleport(clicked);
|
player.teleport(clicked);
|
||||||
|
} else if (XMaterial.ENCHANTED_BOOK.isSimilar(item)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
player.closeInventory();
|
||||||
|
if (!name.startsWith("Page ")) return;
|
||||||
|
String number_str = name.substring(5);
|
||||||
|
try {
|
||||||
|
int page = Integer.parseInt(number_str);
|
||||||
|
InteractHandler.createSpectatorTeleportPage(player, page - 1);
|
||||||
|
} catch(Exception ignored) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.database.Database;
|
import net.tylermurphy.hideAndSeek.database.Database;
|
||||||
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
|
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
|
||||||
|
import net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@ -41,8 +43,26 @@ public class PAPIExpansion extends PlaceholderExpansion {
|
||||||
public String onRequest(OfflinePlayer player, @NotNull String params) {
|
public String onRequest(OfflinePlayer player, @NotNull String params) {
|
||||||
Database database = Main.getInstance().getDatabase();
|
Database database = Main.getInstance().getDatabase();
|
||||||
String[] args = params.split("_");
|
String[] args = params.split("_");
|
||||||
|
Status status = Main.getInstance().getGame().getStatus();
|
||||||
|
|
||||||
if (args.length < 1) return null;
|
if (args.length < 1) return null;
|
||||||
|
|
||||||
|
if (args.length == 1 && args[0] == "hiders") {
|
||||||
|
if (status == Status.PLAYING || status == Status.STARTING) {
|
||||||
|
return "" + Main.getInstance().getBoard().getHiders().size();
|
||||||
|
} else {
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 1 && args[0] == "seekers") {
|
||||||
|
if (status == Status.PLAYING || status == Status.STARTING) {
|
||||||
|
return "" + Main.getInstance().getBoard().getSeekers().size();
|
||||||
|
} else {
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((args.length == 2 || args.length == 3) && (args[0].equals("stats") || args[0].equals("rank-place"))) {
|
if ((args.length == 2 || args.length == 3) && (args[0].equals("stats") || args[0].equals("rank-place"))) {
|
||||||
Optional<PlayerInfo> info = this.getPlayerInfo(args.length == 2 ? player.getUniqueId() : database.getNameData().getUUID(args[2]));
|
Optional<PlayerInfo> info = this.getPlayerInfo(args.length == 2 ? player.getUniqueId() : database.getNameData().getUUID(args[2]));
|
||||||
if (info.isPresent()) {
|
if (info.isPresent()) {
|
||||||
|
|
Loading…
Reference in a new issue