summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/util
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2021-12-30 12:17:32 -0500
committerGitHub <noreply@github.com>2021-12-30 12:17:32 -0500
commit31d60d7d23715aa3f063241c0c420ea0b0bf003b (patch)
treeca43ffa540d9629f6f0faf2ab3d5e5941db0f352 /src/main/java/net/tylermurphy/hideAndSeek/util
parentMerge pull request #16 from tylermurphy534/1.3.2 (diff)
parent1.3.3 rc5 (diff)
downloadkenshinshideandseek-31d60d7d23715aa3f063241c0c420ea0b0bf003b.tar.gz
kenshinshideandseek-31d60d7d23715aa3f063241c0c420ea0b0bf003b.tar.bz2
kenshinshideandseek-31d60d7d23715aa3f063241c0c420ea0b0bf003b.zip
Merge pull request #20 from tylermurphy534/1.3.3
1.3.3
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/util')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/util/Board.java257
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/util/CustomBoard.java121
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/util/Packet.java21
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/util/Status.java26
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/util/TabCompleter.java60
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/util/UUIDFetcher.java106
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/util/Util.java85
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/util/WinType.java26
8 files changed, 238 insertions, 464 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/Board.java b/src/main/java/net/tylermurphy/hideAndSeek/util/Board.java
deleted file mode 100644
index 9d856b5..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/util/Board.java
+++ /dev/null
@@ -1,257 +0,0 @@
-package net.tylermurphy.hideAndSeek.util;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.scoreboard.DisplaySlot;
-import org.bukkit.scoreboard.Objective;
-import org.bukkit.scoreboard.Score;
-import org.bukkit.scoreboard.Scoreboard;
-import org.bukkit.scoreboard.Team;
-import org.bukkit.scoreboard.Team.Option;
-import org.bukkit.scoreboard.Team.OptionStatus;
-
-import net.tylermurphy.hideAndSeek.Main;
-
-public class Board {
-
- private List<String> Hider, Seeker, Spectator;
- private Map<String, Player> playerList = new HashMap<String,Player>();
- private Map<String, CustomBoard> customBoards = new HashMap<String, CustomBoard>();
-
- public boolean isPlayer(Player player) {
- return playerList.containsKey(player.getName());
- }
-
- public boolean isPlayer(CommandSender sender) {
- return playerList.containsKey(sender.getName());
- }
-
- public boolean isHider(Player player) {
- return Hider.contains(player.getName());
- }
-
- public boolean isSeeker(Player player) {
- return Seeker.contains(player.getName());
- }
-
- public boolean isSpectator(Player player) {
- return Spectator.contains(player.getName());
- }
-
- public int sizeHider() {
- return Hider.size();
- }
-
- public int sizeSeeker() {
- return Seeker.size();
- }
-
- public int sizeSpectator() {
- return Spectator.size();
- }
-
- public int size() {
- return playerList.values().size();
- }
-
- public List<Player> getHiders(){
- return Hider.stream().map(playerName -> playerList.get(playerName)).collect(Collectors.toList());
- }
-
- public List<Player> getSeekers(){
- return Seeker.stream().map(playerName -> playerList.get(playerName)).collect(Collectors.toList());
- }
-
- public List<Player> getSpectators(){
- return Spectator.stream().map(playerName -> playerList.get(playerName)).collect(Collectors.toList());
- }
-
- public List<Player> getPlayers(){
- return new ArrayList<Player>(playerList.values());
- }
-
- public Player getPlayer(String name) {
- return playerList.get(name);
- }
-
- public void addHider(Player player) {
- Hider.add(player.getName());
- Seeker.remove(player.getName());
- Spectator.remove(player.getName());
- playerList.put(player.getName(), player);
- }
-
- public void addSeeker(Player player) {
- Hider.remove(player.getName());
- Seeker.add(player.getName());
- Spectator.remove(player.getName());
- playerList.put(player.getName(), player);
- }
-
- public void addSpectator(Player player) {
- Hider.remove(player.getName());
- Seeker.remove(player.getName());
- Spectator.add(player.getName());
- playerList.put(player.getName(), player);
- }
-
- public void remove(Player player) {
- Hider.remove(player.getName());
- Seeker.remove(player.getName());
- Spectator.remove(player.getName());
- playerList.remove(player.getName());
- }
-
- public boolean onSameTeam(Player player1, Player player2) {
- if(Hider.contains(player1.getName()) && Hider.contains(player2.getName())) return true;
- else if(Seeker.contains(player1.getName()) && Seeker.contains(player2.getName())) return true;
- else if(Spectator.contains(player1.getName()) && Spectator.contains(player2.getName())) return true;
- else return false;
- }
-
- public void reload() {
- Hider = new ArrayList<String>();
- Seeker = new ArrayList<String>();
- Spectator = new ArrayList<String>();
- }
-
- public void reset() {
- Hider.clear();
- Seeker.clear();
- Spectator.clear();
- }
-
- private void createTeamsForBoard(Scoreboard board) {
- Team hiderTeam = board.registerNewTeam("Hider");
- for(String name : Hider)
- hiderTeam.addEntry(name);
- Team seekerTeam = board.registerNewTeam("Seeker");
- for(String name : Seeker)
- seekerTeam.addEntry(name);
- if(nametagsVisible) {
- hiderTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OWN_TEAM);
- seekerTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OTHER_TEAMS);
- } else {
- hiderTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
- seekerTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
- }
- }
-
- public void createLobbyBoard(Player player) {
- createLobbyBoard(player, true);
- }
-
- private void createLobbyBoard(Player player, boolean recreate) {
- CustomBoard board = customBoards.get(player.getName());
- if(recreate) {
- board = new CustomBoard(player, "&l&eHIDE AND SEEK");
- board.updateTeams();
- }
- board.setLine("hiders", ChatColor.BOLD + "" + ChatColor.YELLOW + "HIDER%" + ChatColor.WHITE + getHiderPercent());
- board.setLine("seekers", ChatColor.BOLD + "" + ChatColor.RED + "SEEKER%" + ChatColor.WHITE + getSeekerPercent());
- board.addBlank();
- board.setLine("players", "Players: " + playerList.values().size());
- board.addBlank();
- board.setLine("waiting", "Waiting to start...");
- board.display();
- customBoards.put(player.getName(), board);
- }
-
- public void createGameBoard(Player player){
- createGameBoard(player, true);
- }
-
- private void createGameBoard(Player player, boolean recreate){
- CustomBoard board = customBoards.get(player.getName());
- if(recreate) {
- board = new CustomBoard(player, "&l&eHIDE AND SEEK");
- }
- board.setLine("hiders", ChatColor.BOLD + "" + ChatColor.YELLOW + "HIDERS:" + ChatColor.WHITE + " " + Hider.size());
- board.setLine("seekers", ChatColor.BOLD + "" + ChatColor.RED + "SEEKERS:" + ChatColor.WHITE + " " + Seeker.size());
- board.addBlank();
- if(glowEnabled){
- if(Main.plugin.glow == null || Main.plugin.status.equals("Starting") || !Main.plugin.glow.isRunning())
- board.setLine("glow", "Glow: " + ChatColor.RED + "Inactive");
- else
- board.setLine("glow", "Glow: " + ChatColor.GREEN + "Active");
- }
- if(tauntEnabled && tauntCountdown){
- if(Main.plugin.taunt == null || Main.plugin.status.equals("Starting"))
- board.setLine("taunt", "Taunt: " + ChatColor.YELLOW + "0m0s");
- else if(!tauntLast && Hider.size() == 1){
- board.setLine("taunt", "Taunt: " + ChatColor.YELLOW + "Expired");
- } else if(!Main.plugin.taunt.isRunning())
- board.setLine("taunt", "Taunt: " + ChatColor.YELLOW + Main.plugin.taunt.getDelay()/60 + "m" + Main.plugin.taunt.getDelay()%60 + "s");
- else
- board.setLine("taunt", "Taunt: " + ChatColor.YELLOW + "Active");
- }
- if(worldborderEnabled){
- if(Main.plugin.worldborder == null || Main.plugin.status.equals("Starting")){
- board.setLine("board", "WorldBorder: " + ChatColor.YELLOW + "0m0s");
- } else if(!Main.plugin.worldborder.isRunning()) {
- board.setLine("board", "WorldBorder: " + ChatColor.YELLOW + Main.plugin.worldborder.getDelay()/60 + "m" + Main.plugin.worldborder.getDelay()%60 + "s");
- } else {
- board.setLine("board", "WorldBorder: " + ChatColor.YELLOW + "Decreasing");
- }
- }
- if(glowEnabled || (tauntEnabled && tauntCountdown) || worldborderEnabled)
- board.addBlank();
- board.setLine("time", "Time Left: " + ChatColor.GREEN + Main.plugin.timeLeft/60 + "m" + Main.plugin.timeLeft%60 + "s");
- board.addBlank();
- board.setLine("team", "Team: " + getTeam(player));
- board.display();
- customBoards.put(player.getName(), board);
- }
-
- public void removeBoard(Player player) {
- player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
- customBoards.remove(player.getName());
- }
-
- public void reloadLobbyBoards() {
- for(Player player : playerList.values())
- createLobbyBoard(player, false);
- }
-
- public void reloadGameBoards() {
- for(Player player : playerList.values())
- createGameBoard(player, false);
- }
-
- public void reloadBoardTeams() {
- for(CustomBoard board : customBoards.values())
- board.updateTeams();
- }
-
- private String getSeekerPercent() {
- if(playerList.values().size() < 2)
- return " --";
- else
- return " "+(int)(100*(1.0/playerList.size()));
- }
-
- private String getHiderPercent() {
- if(playerList.size() < 2)
- return " --";
- else
- return " "+(int)(100-100*(1.0/playerList.size()));
- }
-
- private String getTeam(Player player) {
- if(isHider(player)) return ChatColor.GOLD + "HIDER";
- else if(isSeeker(player)) return ChatColor.RED + "SEEKER";
- else if(isSpectator(player)) return ChatColor.GRAY + "SPECTATOR";
- else return ChatColor.WHITE + "UNKNOWN";
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/CustomBoard.java b/src/main/java/net/tylermurphy/hideAndSeek/util/CustomBoard.java
deleted file mode 100644
index 69d865a..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/util/CustomBoard.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package net.tylermurphy.hideAndSeek.util;
-
-import net.tylermurphy.hideAndSeek.Main;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-import org.bukkit.scoreboard.*;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
-public class CustomBoard {
-
- private final Scoreboard board;
- private final Objective obj;
- private final Player player;
- private final Map<String,Line> LINES;
- private int blanks;
- private boolean displayed;
-
- public CustomBoard(Player player, String title){
- this.board = Bukkit.getScoreboardManager().getNewScoreboard();
- this.LINES = new HashMap<String,Line>();
- this.player = player;
- this.obj = board.registerNewObjective(
- "Scoreboard", "dummy", ChatColor.translateAlternateColorCodes('&', title));
- this.blanks = 0;
- this.displayed = false;
- this.updateTeams();
- }
-
- public void updateTeams() {
- try{ board.registerNewTeam("Hider"); } catch (Exception e){}
- try{ board.registerNewTeam("Seeker"); } catch (Exception e){}
- Team hiderTeam = board.getTeam("Hider");
- for(String entry : hiderTeam.getEntries())
- hiderTeam.removeEntry(entry);
- for(Player player : Main.plugin.board.getHiders())
- hiderTeam.addEntry(player.getName());
- Team seekerTeam = board.getTeam("Seeker");
- for(String entry : seekerTeam.getEntries())
- seekerTeam.removeEntry(entry);
- for(Player player : Main.plugin.board.getSeekers())
- seekerTeam.addEntry(player.getName());
- if(nametagsVisible) {
- hiderTeam.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
- seekerTeam.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OTHER_TEAMS);
- } else {
- hiderTeam.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
- seekerTeam.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
- }
- hiderTeam.setColor(ChatColor.GOLD);
- seekerTeam.setColor(ChatColor.RED);
- }
-
- public void setLine(String key, String message){
- Line line = LINES.get(key);
- if(line == null)
- addLine(key, message);
- else
- updateLine(key, message);
- }
-
- private void addLine(String key, String message){
- Score score = obj.getScore(message);
- score.setScore(LINES.values().size()+1);
- Line line = new Line(LINES.values().size()+1, message);
- LINES.put(key, line);
- }
-
- public void addBlank(){
- if(displayed) return;
- String temp = "";
- for(int i = 0; i <= blanks; i ++)
- temp += ChatColor.RESET;
- blanks++;
- addLine("blank"+blanks, temp);
- }
-
- private void updateLine(String key, String message){
- Line line = LINES.get(key);
- board.resetScores(line.getMessage());
- line.setMessage(message);
- Score newScore = obj.getScore(message);
-
- newScore.setScore(line.getScore());
- }
-
- public void display() {
- displayed = true;
- obj.setDisplaySlot(DisplaySlot.SIDEBAR);
- player.setScoreboard(board);
- }
-
-}
-
-class Line {
-
- private int score;
- private String message;
-
- public Line(int score, String message){
- this.score = score;
- this.message = message;
- }
-
- public int getScore() {
- return score;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/Packet.java b/src/main/java/net/tylermurphy/hideAndSeek/util/Packet.java
index 564916a..18913da 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/util/Packet.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/util/Packet.java
@@ -1,3 +1,22 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2021 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
package net.tylermurphy.hideAndSeek.util;
import java.lang.reflect.InvocationTargetException;
@@ -16,7 +35,7 @@ import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
public class Packet {
- private static ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
+ private static final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
public static void playSound(Player player, Sound sound, float volume, float pitch) {
PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.NAMED_SOUND_EFFECT);
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/Status.java b/src/main/java/net/tylermurphy/hideAndSeek/util/Status.java
new file mode 100644
index 0000000..44a3e42
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/util/Status.java
@@ -0,0 +1,26 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2021 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package net.tylermurphy.hideAndSeek.util;
+
+public enum Status {
+ STANDBY,
+ STARTING,
+ PLAYING
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/TabCompleter.java b/src/main/java/net/tylermurphy/hideAndSeek/util/TabCompleter.java
new file mode 100644
index 0000000..4c949e1
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/util/TabCompleter.java
@@ -0,0 +1,60 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2021 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package net.tylermurphy.hideAndSeek.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
+
+import net.tylermurphy.hideAndSeek.game.CommandHandler;
+import org.bukkit.command.CommandSender;
+
+public class TabCompleter{
+
+ public static List<String> handleTabComplete(CommandSender sender, String[] args) {
+ if(args.length == 1) {
+ return new ArrayList<>(CommandHandler.COMMAND_REGISTER.keySet())
+ .stream()
+ .filter(handle -> sender.hasPermission("hideandseek."+handle.toLowerCase()) && handle.toLowerCase().startsWith(args[0].toLowerCase(Locale.ROOT)))
+ .collect(Collectors.toList());
+ } else if(args.length > 1) {
+ if(!CommandHandler.COMMAND_REGISTER.containsKey(args[0].toLowerCase())) {
+ return null;
+ } else {
+ String[] usage = CommandHandler.COMMAND_REGISTER.get(args[0].toLowerCase()).getUsage().split(" ");
+ if(args.length - 2 < usage.length) {
+ String parameter = usage[args.length-2];
+ if(parameter.equals("<player>")) {
+ return null;
+ } else {
+ List<String> temp = new ArrayList<>();
+ temp.add(parameter.replace("<", "").replace(">", ""));
+ return temp;
+ }
+ } else {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/UUIDFetcher.java b/src/main/java/net/tylermurphy/hideAndSeek/util/UUIDFetcher.java
new file mode 100644
index 0000000..ef65af3
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/util/UUIDFetcher.java
@@ -0,0 +1,106 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2021 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package net.tylermurphy.hideAndSeek.util;
+
+import net.tylermurphy.hideAndSeek.Main;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public final class UUIDFetcher {
+
+ private static final Map<String,UUID> CACHE = new HashMap<>();
+
+ private static final String UUID_URL = "https://api.mojang.com/users/profiles/minecraft/";
+ private static int cacheTask;
+
+ public static void init(){
+ cacheTask = Main.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(Main.plugin, CACHE::clear,600*20, 600*20);
+ }
+
+ public static void cleanup(){
+ Main.plugin.getServer().getScheduler().cancelTask(cacheTask);
+ }
+
+ public static UUID getUUID(String playername) {
+
+ if(CACHE.containsKey(playername)) return CACHE.get(playername);
+
+ String output = callURL(UUID_URL + playername);
+ StringBuilder result = new StringBuilder();
+ readData(output, result);
+ String u = result.toString();
+ StringBuilder uuid = new StringBuilder();
+ for (int i = 0; i <= 31; i++) {
+ uuid.append(u.charAt(i));
+ if (i == 7 || i == 11 || i == 15 || i == 19) {
+ uuid.append('-');
+ }
+ }
+
+ CACHE.put(playername, UUID.fromString(uuid.toString()));
+
+ return UUID.fromString(uuid.toString());
+ }
+
+ private static void readData(String toRead, StringBuilder result) {
+ for (int i = toRead.length() - 3; i >= 0; i--) {
+ if (toRead.charAt(i) != '"') {
+ result.insert(0, toRead.charAt(i));
+ } else {
+ break;
+ }
+ }
+ }
+
+ private static String callURL(String urlStr) {
+ StringBuilder sb = new StringBuilder();
+ URLConnection urlConn;
+ InputStreamReader in;
+ try {
+ URL url = new URL(urlStr);
+ urlConn = url.openConnection();
+ if (urlConn != null) {
+ urlConn.setReadTimeout(60 * 1000);
+ }
+ if (urlConn != null && urlConn.getInputStream() != null) {
+ in = new InputStreamReader(urlConn.getInputStream(),
+ Charset.defaultCharset());
+ BufferedReader bufferedReader = new BufferedReader(in);
+ int cp;
+ while ((cp = bufferedReader.read()) != -1) {
+ sb.append((char) cp);
+ }
+ bufferedReader.close();
+ in.close();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return sb.toString();
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java b/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java
deleted file mode 100644
index c24936b..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/util/Util.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package net.tylermurphy.hideAndSeek.util;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.List;
-
-import net.md_5.bungee.api.ChatColor;
-import net.tylermurphy.hideAndSeek.configuration.Items;
-import net.tylermurphy.hideAndSeek.configuration.LocalizationString;
-import org.bukkit.Bukkit;
-import org.bukkit.Material;
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.enchantments.Enchantment;
-import org.bukkit.entity.Player;
-
-import net.tylermurphy.hideAndSeek.Main;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.ItemMeta;
-import org.bukkit.inventory.meta.PotionMeta;
-import org.bukkit.potion.PotionData;
-import org.bukkit.potion.PotionEffect;
-import org.bukkit.potion.PotionEffectType;
-import org.bukkit.potion.PotionType;
-
-public class Util {
-
- public static void broadcastMessage(String message) {
- for(Player player : Main.plugin.board.getPlayers()) {
- player.sendMessage(message);
- }
- }
-
- public static boolean isSetup() {
- if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) return false;
- if(lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) return false;
- if(exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) return false;
- File destenation = new File(Main.root+File.separator+"hideandseek_"+spawnWorld);
- if(!destenation.exists()) return false;
- if(saveMinX == 0 || saveMinZ == 0 || saveMaxX == 0 || saveMaxZ == 0) return false;
- return true;
- }
-
- public static void sendDelayedMessage(String message, int gameId, int delay) {
- Bukkit.getScheduler().runTaskLaterAsynchronously(Main.plugin, new Runnable() {
- public void run() {
- if(gameId == Main.plugin.gameId)
- Util.broadcastMessage(message);
- }
- }, delay);
- }
-
- public static void resetPlayer(Player player) {
- player.getInventory().clear();
- for (PotionEffect effect : player.getActivePotionEffects()) {
- player.removePotionEffect(effect.getType());
- }
- if (Main.plugin.board.isSeeker(player)) {
- if(pvpEnabled)
- for(ItemStack item : Items.SEEKER_ITEMS)
- player.getInventory().addItem(item);
- for(PotionEffect effect : Items.SEEKER_EFFECTS)
- player.addPotionEffect(effect);
- } else if (Main.plugin.board.isHider(player)) {
- if(pvpEnabled)
- for(ItemStack item : Items.HIDER_ITEMS)
- player.getInventory().addItem(item);
- for(PotionEffect effect : Items.HIDER_EFFECTS)
- player.addPotionEffect(effect);
- if(glowEnabled) {
- ItemStack snowball = new ItemStack(Material.SNOWBALL, 1);
- ItemMeta snowballMeta = snowball.getItemMeta();
- snowballMeta.setDisplayName("Glow Powerup");
- List<String> snowballLore = new ArrayList<String>();
- snowballLore.add("Throw to make all seekers glow");
- snowballLore.add("Last 30s, all hiders can see it");
- snowballLore.add("Time stacks on multi use");
- snowballMeta.setLore(snowballLore);
- snowball.setItemMeta(snowballMeta);
- player.getInventory().addItem(snowball);
- }
- }
- }
-} \ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/WinType.java b/src/main/java/net/tylermurphy/hideAndSeek/util/WinType.java
new file mode 100644
index 0000000..3c555cc
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/util/WinType.java
@@ -0,0 +1,26 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2021 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package net.tylermurphy.hideAndSeek.util;
+
+public enum WinType {
+ HIDER_WIN,
+ SEEKER_WIN,
+ NONE
+}