From 6b4bef24c05747280c60f48063ce57b5f654ce04 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Thu, 19 May 2022 17:14:01 -0400 Subject: [PATCH] 1.5.0 Release Canidate 3 --- .../net/tylermurphy/hideAndSeek/command/Top.java | 9 ++------- .../net/tylermurphy/hideAndSeek/command/Wins.java | 6 +----- .../hideAndSeek/database/NameDataTable.java | 13 +++++++++++++ .../java/net/tylermurphy/hideAndSeek/game/Game.java | 5 ++--- .../tylermurphy/hideAndSeek/util/PAPIExpansion.java | 4 ++-- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java index 9b55c9f..6125a00 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java @@ -21,6 +21,7 @@ package net.tylermurphy.hideAndSeek.command; import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.database.util.PlayerInfo; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -55,13 +56,7 @@ public class Top implements ICommand { return; } for(PlayerInfo info : infos) { - OfflinePlayer temp = Main.getInstance().getServer().getOfflinePlayer(info.getUniqueId()); - String name; - if(temp == null){ - name = Main.getInstance().getDatabase().getNameData().getName(info.getUniqueId()); - } else { - name = temp.getName(); - } + String name = Main.getInstance().getDatabase().getNameData().getName(info.getUniqueId()); ChatColor color; switch (i) { case 1: color = ChatColor.YELLOW; break; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java index 491c9a4..e12d2d4 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java @@ -42,11 +42,7 @@ public class Wins implements ICommand { } else { name = args[0]; - if(Main.getInstance().getServer().getOfflinePlayer(args[0]) == null){ - uuid = Main.getInstance().getDatabase().getNameData().getUUID(args[0]); - } else { - uuid = Main.getInstance().getServer().getOfflinePlayer(args[0]).getUniqueId(); - } + uuid = Main.getInstance().getDatabase().getNameData().getUUID(args[0]); } if(uuid == null){ sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(args[0])); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/NameDataTable.java b/src/main/java/net/tylermurphy/hideAndSeek/database/NameDataTable.java index cbf410a..e5ac4bb 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/database/NameDataTable.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/database/NameDataTable.java @@ -20,8 +20,11 @@ package net.tylermurphy.hideAndSeek.database; import net.tylermurphy.hideAndSeek.Main; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; import org.jetbrains.annotations.Nullable; +import java.lang.management.BufferPoolMXBean; import java.sql.*; import java.util.UUID; @@ -61,6 +64,11 @@ public class NameDataTable { Main.getInstance().getLogger().severe("SQL Error: " + e.getMessage()); e.printStackTrace(); } + OfflinePlayer retry = Bukkit.getOfflinePlayer(uuid); + if(retry != null){ + this.update(uuid, retry.getName()); + return retry.getName(); + } return null; } @@ -78,6 +86,11 @@ public class NameDataTable { Main.getInstance().getLogger().severe("SQL Error: " + e.getMessage()); e.printStackTrace(); } + OfflinePlayer retry = Bukkit.getOfflinePlayer(name); + if(retry != null){ + this.update(retry.getUniqueId(), name); + return retry.getUniqueId(); + } return null; } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java index 34f3a46..78c5e01 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java @@ -223,7 +223,7 @@ public class Game { private void whileWaiting() { if (!lobbyCountdownEnabled) return; if (lobbyMin <= board.size()) { - if (gameTimer == -1) + if (lobbyTimer < 0) lobbyTimer = countdown; if (board.size() >= changeCountdown) lobbyTimer = Math.min(lobbyTimer, 10); @@ -240,7 +240,6 @@ public class Game { } private void whileStarting() { - if(gameTick % 20 == 0) { if (startingTimer % 5 == 0 || startingTimer < 5) { String message; @@ -259,7 +258,7 @@ public class Game { } else if (countdownDisplay == CountdownDisplay.ACTIONBAR) { ActionBar.clearActionBar(player); ActionBar.sendActionBar(player, messagePrefix + message); - } else if (countdownDisplay == CountdownDisplay.TITLE) { + } else if (countdownDisplay == CountdownDisplay.TITLE && startingTimer != 30) { Titles.clearTitle(player); Titles.sendTitle(player, 10, 40, 10, " ", message); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java b/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java index 7823fe9..f1a1ce1 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java @@ -45,7 +45,7 @@ public class PAPIExpansion extends PlaceholderExpansion { database.getGameData().getInfo(player.getUniqueId()); } else { UUID uuid; - try { uuid = Main.getInstance().getServer().getOfflinePlayer(args[2]).getUniqueId(); } catch (Exception e) { return placeholderError; } + try { uuid = Main.getInstance().getDatabase().getNameData().getUUID(args[2]); } catch (Exception e) { return placeholderError; } info = database.getGameData().getInfo(uuid); } if (info == null) return placeholderNoData; @@ -69,7 +69,7 @@ public class PAPIExpansion extends PlaceholderExpansion { database.getGameData().getInfo(player.getUniqueId()); } else { UUID uuid; - try { uuid = Main.getInstance().getServer().getOfflinePlayer(args[2]).getUniqueId(); } catch (Exception e) { return placeholderError; } + try { uuid = Main.getInstance().getDatabase().getNameData().getUUID(args[2]); } catch (Exception e) { return placeholderError; } info = database.getGameData().getInfo(uuid); } if (info == null) return placeholderNoData;