diff --git a/pom.xml b/pom.xml
index cb6097e..e6ff5de 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,71 +3,84 @@
KenshinsHideAndSeek
1.6.0
Hide and Seek Plugin
-
- UTF-8
-
+
+ clean install
+ src/main/java
+
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 2.3.2
-
-
- 8
-
-
org.apache.maven.plugins
maven-shade-plugin
3.2.4
-
- false
-
-
- com.cryptomorin.xseries
- net.tylermurphy.dependencies.xseries
-
-
-
-
- com.github.cryptomorin:XSeries
- org.xerial:sqlite-jdbc
- org.mariadb.jdbc:mariadb-java-client
- com.zaxxer:HikariCP
-
-
-
-
- *:*
-
- META-INF/*.MF
- META-INF/*.MD
- META-INF/*.SF
- META-INF/*.DSA
- META-INF/*.RSA
- sqlite-jdbc.properties
-
-
-
-
-
- META-INF/services/java.sql.Driver
-
-
- true
-
package
shade
+
+ false
+
+
+ com.cryptomorin.xseries
+ net.tylermurphy.dependencies.xseries
+
+
+ com.zaxxer.hikari
+ net.tylermurphy.dependencies.hikari
+
+
+ org.ibex.nestedvm
+ net.tylermurphy.dependencies.nestedvm
+
+
+ org.sqlite
+ net.tylermurphy.dependencies.sqlite
+
+
+
+
+ com.github.cryptomorin:XSeries
+ org.xerial:sqlite-jdbc
+ org.mariadb.jdbc:mariadb-java-client
+ com.zaxxer:HikariCP
+
+
+
+
+ *:*
+
+ META-INF/**
+ sqlite-jdbc.properties
+ mariadb.properties
+
+
+
+
+
+ META-INF/services/java.sql.Driver
+
+
+ true
+
+
+
+ maven-compiler-plugin
+ 2.3.2
+
+
+ 1.8
+
+
+
+
+
spigot-repo
@@ -87,8 +100,14 @@
org.spigotmc
spigot-api
1.13-R0.1-SNAPSHOT
- jar
provided
+
+
+ junit
+ *
+
+
+ jar
com.comphenix.protocol
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/Main.java b/src/main/java/net/tylermurphy/hideAndSeek/Main.java
index c4666df..08f1d3e 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/Main.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/Main.java
@@ -34,9 +34,7 @@ import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
-import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
-import org.bukkit.plugin.java.JavaPluginLoader;
import org.jetbrains.annotations.NotNull;
import java.io.File;
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java
index 7ddc72c..61d0c46 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java
@@ -73,16 +73,10 @@ public class Debug implements ICommand {
}
player.teleport(new Location(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
}));
- debugMenu.setItem(7, createOption(7, Material.ENDER_PEARL, "&d&lTeleport: &fLobby", 2, player -> {
- player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(), lobbyPosition.getY(), lobbyPosition.getZ()));
- }));
- debugMenu.setItem(8, createOption(8, Material.ENDER_PEARL, "&d&lTeleport: &fExit", 3, player -> {
- player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
- }));
+ debugMenu.setItem(7, createOption(7, Material.ENDER_PEARL, "&d&lTeleport: &fLobby", 2, player -> player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(), lobbyPosition.getY(), lobbyPosition.getZ()))));
+ debugMenu.setItem(8, createOption(8, Material.ENDER_PEARL, "&d&lTeleport: &fExit", 3, player -> player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()))));
debugMenu.setItem(9, createOption(9, XMaterial.GLASS.parseMaterial(), "&dEnable Disguise", 1, PlayerLoader::openBlockHuntPicker));
- debugMenu.setItem(10, createOption(10, XMaterial.PLAYER_HEAD.parseMaterial(), "&dDisable Disguise", 1, player -> {
- Main.getInstance().getDisguiser().reveal(player);
- }));
+ debugMenu.setItem(10, createOption(10, XMaterial.PLAYER_HEAD.parseMaterial(), "&dDisable Disguise", 1, player -> Main.getInstance().getDisguiser().reveal(player)));
}
private ItemStack createOption(int slow, Material material, String name, int amount, Consumer callback){
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
index 45e66b9..b456e6a 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
@@ -68,10 +68,9 @@ public class SetBorder implements ICommand {
return;
}
Vector vec = new Vector();
- Player player = (Player) sender;
- vec.setX(player.getLocation().getBlockX());
+ vec.setX(sender.getLocation().getBlockX());
vec.setY(0);
- vec.setZ(player.getLocation().getBlockZ());
+ vec.setZ(sender.getLocation().getBlockZ());
if (spawnPosition.distance(vec) > 100) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
return;
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java
index 90ecb28..434e4a6 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java
@@ -37,12 +37,11 @@ public class SetBounds implements ICommand {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
return;
}
- Player player = (Player) sender;
- if (!player.getWorld().getName().equals(spawnWorld)) {
+ if (!sender.getWorld().getName().equals(spawnWorld)) {
sender.sendMessage(errorPrefix + message("BOUNDS_WRONG_WORLD"));
return;
}
- if (player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0) {
+ if (sender.getLocation().getBlockX() == 0 || sender.getLocation().getBlockZ() == 0) {
sender.sendMessage(errorPrefix + message("NOT_AT_ZERO"));
return;
}
@@ -51,32 +50,32 @@ public class SetBounds implements ICommand {
saveMinX = 0; saveMinZ= 0; saveMaxX = 0; saveMaxZ = 0;
}
if (saveMaxX == 0) {
- addToConfig("bounds.max.x", player.getLocation().getBlockX());
- saveMaxX = player.getLocation().getBlockX();
- } else if (saveMaxX < player.getLocation().getBlockX()) {
+ addToConfig("bounds.max.x", sender.getLocation().getBlockX());
+ saveMaxX = sender.getLocation().getBlockX();
+ } else if (saveMaxX < sender.getLocation().getBlockX()) {
first = false;
- addToConfig("bounds.max.x", player.getLocation().getBlockX());
+ addToConfig("bounds.max.x", sender.getLocation().getBlockX());
addToConfig("bounds.min.x", saveMaxX);
saveMinX = saveMaxX;
- saveMaxX = player.getLocation().getBlockX();
+ saveMaxX = sender.getLocation().getBlockX();
} else {
first = false;
- addToConfig("bounds.min.x", player.getLocation().getBlockX());
- saveMinX = player.getLocation().getBlockX();
+ addToConfig("bounds.min.x", sender.getLocation().getBlockX());
+ saveMinX = sender.getLocation().getBlockX();
}
if (saveMaxZ == 0) {
- addToConfig("bounds.max.z", player.getLocation().getBlockZ());
- saveMaxZ = player.getLocation().getBlockZ();
- } else if (saveMaxZ < player.getLocation().getBlockZ()) {
+ addToConfig("bounds.max.z", sender.getLocation().getBlockZ());
+ saveMaxZ = sender.getLocation().getBlockZ();
+ } else if (saveMaxZ < sender.getLocation().getBlockZ()) {
first = false;
- addToConfig("bounds.max.z", player.getLocation().getBlockZ());
+ addToConfig("bounds.max.z", sender.getLocation().getBlockZ());
addToConfig("bounds.min.z", saveMaxZ);
saveMinZ = saveMaxZ;
- saveMaxZ = player.getLocation().getBlockZ();
+ saveMaxZ = sender.getLocation().getBlockZ();
} else {
first = false;
- addToConfig("bounds.min.z", player.getLocation().getBlockZ());
- saveMinZ = player.getLocation().getBlockZ();
+ addToConfig("bounds.min.z", sender.getLocation().getBlockZ());
+ saveMinZ = sender.getLocation().getBlockZ();
}
sender.sendMessage(messagePrefix + message("BOUNDS").addAmount(first ? 1 : 2));
saveConfig();
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java
index 6125a00..72a695c 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java
@@ -21,9 +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;
import java.util.List;
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/Database.java b/src/main/java/net/tylermurphy/hideAndSeek/database/Database.java
index 8afc4ba..e7bfb26 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/database/Database.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/Database.java
@@ -104,6 +104,7 @@ public class Database {
}
}
+ @SuppressWarnings("UnstableApiUsage")
protected UUID decodeUUID(byte[] bytes) {
InputStream is = new ByteArrayInputStream(bytes);
ByteBuffer buffer = ByteBuffer.allocate(16);
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/GameDataTable.java b/src/main/java/net/tylermurphy/hideAndSeek/database/GameDataTable.java
index 929356e..8f0ddde 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/database/GameDataTable.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/GameDataTable.java
@@ -200,8 +200,7 @@ public class GameDataTable {
}
}
- protected boolean updateInfo(@NotNull byte[] uuid, int hider_wins, int seeker_wins, int hider_games, int seeker_games, int hider_kills, int seeker_kills, int hider_deaths, int seeker_deaths){
- boolean success;
+ protected void updateInfo(byte[] uuid, int hider_wins, int seeker_wins, int hider_games, int seeker_games, int hider_kills, int seeker_kills, int hider_deaths, int seeker_deaths){
String sql = "INSERT OR REPLACE INTO hs_data (uuid, hider_wins, seeker_wins, hider_games, seeker_games, hider_kills, seeker_kills, hider_deaths, seeker_deaths) VALUES (?,?,?,?,?,?,?,?,?)";
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
statement.setBytes(1, uuid);
@@ -214,16 +213,12 @@ public class GameDataTable {
statement.setInt(8, hider_deaths);
statement.setInt(9, seeker_deaths);
statement.execute();
- statement.close();
- success = true;
} catch (SQLException e) {
Main.getInstance().getLogger().severe("SQL Error: " + e.getMessage());
e.printStackTrace();
- success = false;
} finally {
CACHE.remove(database.decodeUUID(uuid));
}
- return success;
}
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/InventoryTable.java b/src/main/java/net/tylermurphy/hideAndSeek/database/InventoryTable.java
index 814ea5e..0ff2225 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/database/InventoryTable.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/InventoryTable.java
@@ -58,19 +58,16 @@ public class InventoryTable {
return null;
}
- public boolean saveInventory(@NotNull UUID uuid, @NotNull ItemStack[] itemArray) {
+ public void saveInventory(@NotNull UUID uuid, @NotNull ItemStack[] itemArray) {
String sql = "INSERT OR REPLACE INTO hs_inventory (uuid, inventory) VALUES (?,?)";
String data = itemStackArrayToBase64(itemArray);
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
statement.setBytes(1, database.encodeUUID(uuid));
statement.setString(2, data);
statement.execute();
- statement.close();
- return true;
} catch (SQLException e) {
Main.getInstance().getLogger().severe("SQL Error: " + e.getMessage());
e.printStackTrace();
- return false;
}
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/LegacyTable.java b/src/main/java/net/tylermurphy/hideAndSeek/database/LegacyTable.java
index 580c2f5..e134c22 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/database/LegacyTable.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/LegacyTable.java
@@ -19,8 +19,6 @@
package net.tylermurphy.hideAndSeek.database;
-import net.tylermurphy.hideAndSeek.Main;
-import net.tylermurphy.hideAndSeek.database.Database;
import net.tylermurphy.hideAndSeek.database.util.LegacyPlayerInfo;
import java.sql.Connection;
@@ -63,7 +61,6 @@ public class LegacyTable {
while(resultSet.next()){
legacyPlayerInfoList.add(new LegacyPlayerInfo(
resultSet.getBytes("uuid"),
- resultSet.getInt("wins"),
resultSet.getInt("hider_wins"),
resultSet.getInt("seeker_wins"),
resultSet.getInt("games_played")
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/NameDataTable.java b/src/main/java/net/tylermurphy/hideAndSeek/database/NameDataTable.java
index dd32507..02d90cf 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/database/NameDataTable.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/NameDataTable.java
@@ -25,7 +25,6 @@ import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.lang.management.BufferPoolMXBean;
import java.sql.*;
import java.util.UUID;
@@ -66,13 +65,14 @@ public class NameDataTable {
e.printStackTrace();
}
OfflinePlayer retry = Bukkit.getOfflinePlayer(uuid);
- if(retry != null){
+ if(retry != null && retry.getName() != null){
this.update(uuid, retry.getName());
return retry.getName();
}
return null;
}
+ @SuppressWarnings("deprecation")
@Nullable
public UUID getUUID(@NotNull String name) {
String sql = "SELECT * FROM hs_names WHERE name = ?;";
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/util/LegacyPlayerInfo.java b/src/main/java/net/tylermurphy/hideAndSeek/database/util/LegacyPlayerInfo.java
index 5b59779..067ab0b 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/database/util/LegacyPlayerInfo.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/util/LegacyPlayerInfo.java
@@ -19,19 +19,15 @@
package net.tylermurphy.hideAndSeek.database.util;
-import java.util.UUID;
-
public class LegacyPlayerInfo {
private final byte[] uniqueId;
- private final int totalWins;
private final int hiderWins;
private final int seekerWins;
private final int gamesPlayed;
- public LegacyPlayerInfo(byte[] uniqueId, int totalWins, int hiderWins, int seekerWins, int gamesPlayed) {
+ public LegacyPlayerInfo(byte[] uniqueId, int hiderWins, int seekerWins, int gamesPlayed) {
this.uniqueId = uniqueId;
- this.totalWins = totalWins;
this.hiderWins = hiderWins;
this.seekerWins = seekerWins;
this.gamesPlayed = gamesPlayed;
@@ -41,8 +37,6 @@ public class LegacyPlayerInfo {
return uniqueId;
}
- public int getTotalWins() { return totalWins; }
-
public int getHiderWins() {
return hiderWins;
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java
index cf91c23..6bf0bfb 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Board.java
@@ -35,6 +35,7 @@ import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+@SuppressWarnings("deprecation")
public class Board {
private final List Hider = new ArrayList<>(), Seeker = new ArrayList<>(), Spectator = new ArrayList<>();
@@ -363,6 +364,7 @@ public class Board {
}
+@SuppressWarnings("deprecation")
class CustomBoard {
private final Scoreboard board;
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/EntityHider.java b/src/main/java/net/tylermurphy/hideAndSeek/game/EntityHider.java
index 9dcb0ab..8274655 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/EntityHider.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/EntityHider.java
@@ -3,7 +3,7 @@ package net.tylermurphy.hideAndSeek.game;
import static com.comphenix.protocol.PacketType.Play.Server.*;
import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.Map;
import org.bukkit.entity.Entity;
@@ -30,9 +30,9 @@ public class EntityHider implements Listener {
protected Table observerEntityMap = HashBasedTable.create();
private static final PacketType[] ENTITY_PACKETS = {
- ENTITY_EQUIPMENT, BED, ANIMATION, NAMED_ENTITY_SPAWN,
+ ENTITY_EQUIPMENT, ANIMATION, NAMED_ENTITY_SPAWN,
COLLECT, SPAWN_ENTITY, SPAWN_ENTITY_LIVING, SPAWN_ENTITY_PAINTING, SPAWN_ENTITY_EXPERIENCE_ORB,
- ENTITY_VELOCITY, REL_ENTITY_MOVE, ENTITY_LOOK, ENTITY_MOVE_LOOK, ENTITY_MOVE_LOOK,
+ ENTITY_VELOCITY, REL_ENTITY_MOVE, ENTITY_LOOK,
ENTITY_TELEPORT, ENTITY_HEAD_ROTATION, ENTITY_STATUS, ATTACH_ENTITY, ENTITY_METADATA,
ENTITY_EFFECT, REMOVE_ENTITY_EFFECT, BLOCK_BREAK_ANIMATION
};
@@ -193,6 +193,7 @@ public class EntityHider implements Listener {
* @param entity - the entity to toggle.
* @return TRUE if the entity was visible before, FALSE otherwise.
*/
+ @SuppressWarnings("unused")
public final boolean toggleEntity(Player observer, Entity entity) {
if (isVisible(observer, entity.getEntityId())) {
return hideEntity(observer, entity);
@@ -213,7 +214,7 @@ public class EntityHider implements Listener {
// Resend packets
if (manager != null && hiddenBefore) {
- manager.updateEntity(entity, Arrays.asList(observer));
+ manager.updateEntity(entity, Collections.singletonList(observer));
}
return hiddenBefore;
}
@@ -253,6 +254,7 @@ public class EntityHider implements Listener {
* @param entity - the entity that may be hidden.
* @return TRUE if the player may see the entity, FALSE if the entity has been hidden.
*/
+ @SuppressWarnings("unused")
public final boolean canSee(Player observer, Entity entity) {
validate(observer, entity);
@@ -268,10 +270,12 @@ public class EntityHider implements Listener {
* Retrieve the current visibility policy.
* @return The current visibility policy.
*/
+ @SuppressWarnings("unused")
public Policy getPolicy() {
return policy;
}
+ @SuppressWarnings("unused")
public void close() {
if (manager != null) {
HandlerList.unregisterAll(bukkitListener);
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java
index 87fa4a2..b3fd457 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java
@@ -107,7 +107,8 @@ public class Game {
public void start() {
try {
Optional rand = board.getPlayers().stream().skip(new Random().nextInt(board.size())).findFirst();
- String seekerName = rand.get().getName();
+ Player picked = rand.orElse(board.getPlayers().get(0));
+ String seekerName = picked.getName();
Player temp = Bukkit.getPlayer(seekerName);
Player seeker = board.getPlayer(temp.getUniqueId());
start(seeker);
@@ -210,6 +211,7 @@ public class Game {
handleBungeeLeave(player);
}
+ @SuppressWarnings("UnstableApiUsage")
private void handleBungeeLeave(Player player) {
if (bungeeLeave) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/PlayerLoader.java b/src/main/java/net/tylermurphy/hideAndSeek/game/PlayerLoader.java
index 0447111..bd35ab5 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/PlayerLoader.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/PlayerLoader.java
@@ -19,7 +19,6 @@
package net.tylermurphy.hideAndSeek.game;
-import com.cryptomorin.xseries.XItemStack;
import com.cryptomorin.xseries.messages.Titles;
import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.Main;
@@ -27,7 +26,6 @@ import net.tylermurphy.hideAndSeek.configuration.Items;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
-import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.entity.Player;
@@ -40,6 +38,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Config.lobbyPosition;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+@SuppressWarnings("deprecation")
public class PlayerLoader {
public static void loadHider(Player player, String gameWorld){
@@ -69,9 +68,7 @@ public class PlayerLoader {
player.setFallDistance(0.0F);
player.getInventory().setItem(flightToggleItemPosition, flightToggleItem);
player.getInventory().setItem(teleportItemPosition, teleportItem);
- Main.getInstance().getBoard().getPlayers().forEach(otherPlayer -> {
- otherPlayer.hidePlayer(player);
- });
+ Main.getInstance().getBoard().getPlayers().forEach(otherPlayer -> otherPlayer.hidePlayer(player));
Titles.sendTitle(player, 10, 70, 20, ChatColor.GRAY + "" + ChatColor.BOLD + "SPECTATING", ChatColor.WHITE + message("SPECTATOR_SUBTITLE").toString());
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/DisguiseHandler.java b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/DisguiseHandler.java
index 587fab9..50c45fb 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/DisguiseHandler.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/DisguiseHandler.java
@@ -7,7 +7,6 @@ import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
-import com.comphenix.protocol.wrappers.BlockPosition;
import com.cryptomorin.xseries.XMaterial;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.util.Disguise;
@@ -27,19 +26,17 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
-import org.bukkit.util.BlockVector;
import java.util.ArrayList;
import java.util.List;
+@SuppressWarnings("deprecation")
public class DisguiseHandler implements Listener {
private static final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
- private final PacketAdapter packetListener;
public DisguiseHandler(){
- packetListener = createProtocol();
- protocolManager.addPacketListener(packetListener);
+ protocolManager.addPacketListener(createProtocol());
}
@EventHandler(priority = EventPriority.HIGHEST)
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/InteractHandler.java b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/InteractHandler.java
index c8dd488..3440780 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/InteractHandler.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/InteractHandler.java
@@ -22,6 +22,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Config.glowPowerupItem;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+@SuppressWarnings("deprecation")
public class InteractHandler implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
@@ -96,25 +97,21 @@ public class InteractHandler implements Listener {
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()));
List 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 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);
}
}
private ItemStack getSkull(Player player, List lore){
assert XMaterial.PLAYER_HEAD.parseMaterial() != null;
- ItemStack playerhead = new ItemStack(XMaterial.PLAYER_HEAD.parseMaterial(), 1, (byte) 3);
- SkullMeta playerheadmeta = (SkullMeta) playerhead.getItemMeta();
- playerheadmeta.setOwner(player.getName());
- playerheadmeta.setDisplayName(player.getName());
- playerheadmeta.setLore(lore);
- playerhead.setItemMeta(playerheadmeta);
- return playerhead;
+ ItemStack playerHead = new ItemStack(XMaterial.PLAYER_HEAD.parseMaterial(), 1, (byte) 3);
+ SkullMeta playerHeadMeta = (SkullMeta) playerHead.getItemMeta();
+ playerHeadMeta.setOwner(player.getName());
+ playerHeadMeta.setDisplayName(player.getName());
+ playerHeadMeta.setLore(lore);
+ playerHead.setItemMeta(playerHeadMeta);
+ return playerHead;
}
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/JoinLeaveHandler.java b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/JoinLeaveHandler.java
index 82369c8..6d88ebf 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/JoinLeaveHandler.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/JoinLeaveHandler.java
@@ -15,7 +15,6 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.potion.PotionEffect;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Config.exitPosition;
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/MovementHandler.java b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/MovementHandler.java
index d38c512..e6e32f6 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/listener/MovementHandler.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/listener/MovementHandler.java
@@ -1,6 +1,5 @@
package net.tylermurphy.hideAndSeek.game.listener;
-import com.comphenix.protocol.PacketType;
import com.google.common.collect.Sets;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.listener.events.PlayerJumpEvent;
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/util/Disguise.java b/src/main/java/net/tylermurphy/hideAndSeek/game/util/Disguise.java
index 330aefe..b0f18a9 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/util/Disguise.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/util/Disguise.java
@@ -1,12 +1,8 @@
package net.tylermurphy.hideAndSeek.game.util;
-import com.comphenix.protocol.PacketType;
-import com.comphenix.protocol.ProtocolLibrary;
-import com.comphenix.protocol.ProtocolManager;
-import com.comphenix.protocol.events.PacketContainer;
-import com.comphenix.protocol.wrappers.BlockPosition;
-import com.comphenix.protocol.wrappers.WrappedBlockData;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.util.packet.BlockChangePacket;
+import net.tylermurphy.hideAndSeek.util.packet.EntityTeleportPacket;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -16,17 +12,14 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
-import java.lang.reflect.InvocationTargetException;
-
+@SuppressWarnings("deprecation")
public class Disguise {
- private static final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
-
final Player hider;
final Material material;
FallingBlock block;
Horse hitBox;
- Location solidLocation;
+ Location blockLocation;
boolean solid, solidify;
static Team hidden;
@@ -64,7 +57,7 @@ public class Disguise {
hitBox.remove();
}
if(solid)
- sendBlockUpdate(Material.AIR);
+ sendBlockUpdate(blockLocation, Material.AIR);
hider.removePotionEffect(PotionEffectType.INVISIBILITY);
if(Main.getInstance().supports(9)) {
hidden.removeEntry(hider.getName());
@@ -97,18 +90,18 @@ public class Disguise {
if(solidify){
if(!solid) {
solid = true;
- solidLocation = hider.getLocation().getBlock().getLocation();
- respawnHotbox();
- teleportEntity(hitBox, false);
+ blockLocation = hider.getLocation().getBlock().getLocation();
+ respawnHitbox();
+ teleportEntity(hitBox, true);
}
- sendBlockUpdate(material);
+ sendBlockUpdate(blockLocation, material);
} else if(solid){
solid = false;
if(Main.getInstance().supports(9))
hidden.removeEntry(hitBox.getUniqueId().toString());
hitBox.remove();
hitBox = null;
- sendBlockUpdate(Material.AIR);
+ sendBlockUpdate(blockLocation, Material.AIR);
}
toggleEntityVisibility(block, !solid);
teleportEntity(block, solid);
@@ -118,38 +111,33 @@ public class Disguise {
this.solidify = value;
}
- private void sendBlockUpdate(Material material){
- final PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.BLOCK_CHANGE);
- packet.getModifier().writeDefaults();
- packet.getBlockPositionModifier().write(0, new BlockPosition(solidLocation.toVector()));
- packet.getBlockData().write(0, WrappedBlockData.createData(material));
+ private void sendBlockUpdate(Location location, Material material){
+ BlockChangePacket packet = new BlockChangePacket();
+ packet.setBlockPosition(location);
+ packet.setMaterial(material);
Bukkit.getOnlinePlayers().forEach(receiver -> {
- if(receiver == hider) return;
- try {
- protocolManager.sendServerPacket(receiver, packet);
- } catch (InvocationTargetException ignored) {}
+ if(receiver.getName().equals(hider.getName())) return;
+ packet.send(receiver);
});
}
private void teleportEntity(Entity entity, boolean center) {
- final PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.ENTITY_TELEPORT);
- Location location = hider.getLocation();
- packet.getModifier().writeDefaults();
- packet.getIntegers().write(0, entity.getEntityId());
+ EntityTeleportPacket packet = new EntityTeleportPacket();
+ packet.setEntity(entity);
+ double x,y,z;
if(center){
- packet.getDoubles().write(0, Math.round(location.getX()+.5)-.5);
- packet.getDoubles().write(1, (double)Math.round(location.getY()));
- packet.getDoubles().write(2, Math.round(location.getZ()+.5)-.5);
+ x = Math.round(hider.getLocation().getX()+.5)-.5;
+ y = Math.round(hider.getLocation().getY());
+ z = Math.round(hider.getLocation().getZ()+.5)-.5;
} else {
- packet.getDoubles().write(0, location.getX());
- packet.getDoubles().write(1, location.getY());
- packet.getDoubles().write(2, location.getZ());
+ x = hider.getLocation().getX();
+ y = hider.getLocation().getY();
+ z = hider.getLocation().getZ();
}
- Bukkit.getOnlinePlayers().forEach(receiver -> {
- try {
- protocolManager.sendServerPacket(receiver, packet);
- } catch (InvocationTargetException ignored) {}
- });
+ packet.setX(x);
+ packet.setY(y);
+ packet.setZ(z);
+ Bukkit.getOnlinePlayers().forEach(packet::send);
}
private void toggleEntityVisibility(Entity entity, boolean show){
@@ -164,13 +152,13 @@ public class Disguise {
}
private void respawnFallingBlock(){
- block = hider.getLocation().getWorld().spawnFallingBlock(hider.getLocation(), material, (byte)0);
+ block = hider.getLocation().getWorld().spawnFallingBlock(hider.getLocation().add(0, 1000, 0), material, (byte)0);
block.setGravity(false);
block.setDropItem(false);
block.setInvulnerable(true);
}
- private void respawnHotbox(){
+ private void respawnHitbox(){
hitBox = (Horse) hider.getLocation().getWorld().spawnEntity(hider.getLocation().add(0, 1000, 0), EntityType.HORSE);
hitBox.setAI(false);
hitBox.setGravity(false);
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java b/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java
index 032deca..8e4078e 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/util/PAPIExpansion.java
@@ -36,6 +36,7 @@ public class PAPIExpansion extends PlaceholderExpansion {
return true;
}
+ @SuppressWarnings("ConstantConditions")
@Override
public String onRequest(OfflinePlayer player, @NotNull String params) {
Database database = Main.getInstance().getDatabase();
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/packet/AbstractPacket.java b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/AbstractPacket.java
new file mode 100644
index 0000000..9293beb
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/AbstractPacket.java
@@ -0,0 +1,31 @@
+package net.tylermurphy.hideAndSeek.util.packet;
+
+import com.comphenix.protocol.PacketType;
+import com.comphenix.protocol.ProtocolLibrary;
+import com.comphenix.protocol.ProtocolManager;
+import com.comphenix.protocol.events.PacketContainer;
+import org.bukkit.entity.Player;
+
+import java.lang.reflect.InvocationTargetException;
+
+public class AbstractPacket {
+
+ private static final ProtocolManager protocolManager;
+ static {
+ protocolManager = ProtocolLibrary.getProtocolManager();
+ }
+
+ protected final PacketContainer packet;
+
+ protected AbstractPacket(PacketType type){
+ packet = protocolManager.createPacket(type);
+ packet.getModifier().writeDefaults();
+ }
+
+ public void send(Player player){
+ try {
+ protocolManager.sendServerPacket(player, packet);
+ } catch (InvocationTargetException ignored) {}
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/packet/BlockChangePacket.java b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/BlockChangePacket.java
new file mode 100644
index 0000000..53f3f9c
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/BlockChangePacket.java
@@ -0,0 +1,24 @@
+package net.tylermurphy.hideAndSeek.util.packet;
+
+import com.comphenix.protocol.PacketType;
+import com.comphenix.protocol.wrappers.BlockPosition;
+import com.comphenix.protocol.wrappers.WrappedBlockData;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.jetbrains.annotations.NotNull;
+
+public class BlockChangePacket extends AbstractPacket {
+
+ public BlockChangePacket(){
+ super(PacketType.Play.Server.BLOCK_CHANGE);
+ }
+
+ public void setBlockPosition(@NotNull Location location){
+ super.packet.getBlockPositionModifier().write(0, new BlockPosition(location.toVector()));
+ }
+
+ public void setMaterial(Material material){
+ super.packet.getBlockData().write(0, WrappedBlockData.createData(material));
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/packet/EntityTeleportPacket.java b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/EntityTeleportPacket.java
new file mode 100644
index 0000000..b3c7734
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/EntityTeleportPacket.java
@@ -0,0 +1,29 @@
+package net.tylermurphy.hideAndSeek.util.packet;
+
+import com.comphenix.protocol.PacketType;
+import org.bukkit.entity.Entity;
+import org.jetbrains.annotations.NotNull;
+
+public class EntityTeleportPacket extends AbstractPacket {
+
+ public EntityTeleportPacket(){
+ super(PacketType.Play.Server.ENTITY_TELEPORT);
+ }
+
+ public void setEntity(@NotNull Entity entity){
+ super.packet.getIntegers().write(0, entity.getEntityId());
+ }
+
+ public void setX(double x){
+ super.packet.getDoubles().write(0, x);
+ }
+
+ public void setY(double y){
+ super.packet.getDoubles().write(1, y);
+ }
+
+ public void setZ(double z){
+ super.packet.getDoubles().write(2, z);
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java b/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java
index cf4b062..a81aa51 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java
@@ -28,8 +28,10 @@ import java.util.Collections;
import java.util.List;
import java.util.Random;
+@SuppressWarnings({"unused"})
public class VoidGenerator extends ChunkGenerator{
+ // 1.14 And On
public @NotNull List getDefaultPopulators(@NotNull World world) {
return Collections.emptyList();
}
@@ -66,7 +68,7 @@ public class VoidGenerator extends ChunkGenerator{
return true;
}
- // Backwards compatibility
+ // 1.13 And Prev
public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome) { return createChunkData(world); }
}