commit
61455cec88
13 changed files with 159 additions and 19 deletions
2
pom.xml
2
pom.xml
|
@ -1,7 +1,7 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion>
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.tylermurphy</groupId>
|
<groupId>net.tylermurphy</groupId>
|
||||||
<artifactId>KenshinsHideAndSeek</artifactId>
|
<artifactId>KenshinsHideAndSeek</artifactId>
|
||||||
<version>1.5.0</version>
|
<version>1.5.1</version>
|
||||||
<name>Hide and Seek Plugin</name>
|
<name>Hide and Seek Plugin</name>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|
|
@ -62,7 +62,6 @@ public class Main extends JavaPlugin implements Listener {
|
||||||
public Main() {
|
public Main() {
|
||||||
super();
|
super();
|
||||||
onConstructed();
|
onConstructed();
|
||||||
|
|
||||||
board = new Board();
|
board = new Board();
|
||||||
database = new Database();
|
database = new Database();
|
||||||
}
|
}
|
||||||
|
@ -70,7 +69,6 @@ public class Main extends JavaPlugin implements Listener {
|
||||||
protected Main(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
|
protected Main(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
|
||||||
super(loader, description, dataFolder, file);
|
super(loader, description, dataFolder, file);
|
||||||
onConstructed();
|
onConstructed();
|
||||||
|
|
||||||
board = new Board();
|
board = new Board();
|
||||||
database = new Database();
|
database = new Database();
|
||||||
}
|
}
|
||||||
|
@ -89,7 +87,6 @@ public class Main extends JavaPlugin implements Listener {
|
||||||
Config.loadConfig();
|
Config.loadConfig();
|
||||||
Localization.loadLocalization();
|
Localization.loadLocalization();
|
||||||
Items.loadItems();
|
Items.loadItems();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class About implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
sender.sendMessage(
|
sender.sendMessage(
|
||||||
String.format("%s%sHide and Seek %s(%s1.5.0%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
|
String.format("%s%sHide and Seek %s(%s1.5.1%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
|
||||||
String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
|
String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
|
||||||
String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
|
String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
|
||||||
);
|
);
|
||||||
|
|
|
@ -89,7 +89,8 @@ public class Config {
|
||||||
lobbyItemStartAdmin,
|
lobbyItemStartAdmin,
|
||||||
leaveOnEnd,
|
leaveOnEnd,
|
||||||
mapSaveEnabled,
|
mapSaveEnabled,
|
||||||
allowNaturalCauses;
|
allowNaturalCauses,
|
||||||
|
saveInventory;
|
||||||
|
|
||||||
public static int
|
public static int
|
||||||
minPlayers,
|
minPlayers,
|
||||||
|
@ -267,6 +268,7 @@ public class Config {
|
||||||
leaveOnEnd = config.getBoolean("leaveOnEnd");
|
leaveOnEnd = config.getBoolean("leaveOnEnd");
|
||||||
placeholderError = config.getString("placeholder.incorrect");
|
placeholderError = config.getString("placeholder.incorrect");
|
||||||
placeholderNoData = config.getString("placeholder.noData");
|
placeholderNoData = config.getString("placeholder.noData");
|
||||||
|
saveInventory = config.getBoolean("saveInventory");
|
||||||
try {
|
try {
|
||||||
countdownDisplay = CountdownDisplay.valueOf(config.getString("hideCountdownDisplay"));
|
countdownDisplay = CountdownDisplay.valueOf(config.getString("hideCountdownDisplay"));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class Database {
|
||||||
|
|
||||||
private final GameDataTable playerInfo;
|
private final GameDataTable playerInfo;
|
||||||
private final NameDataTable nameInfo;
|
private final NameDataTable nameInfo;
|
||||||
|
private final InventoryTable inventoryInfo;
|
||||||
private final DatabaseConnection connection;
|
private final DatabaseConnection connection;
|
||||||
|
|
||||||
public Database(){
|
public Database(){
|
||||||
|
@ -53,6 +54,8 @@ public class Database {
|
||||||
|
|
||||||
nameInfo = new NameDataTable(this);
|
nameInfo = new NameDataTable(this);
|
||||||
|
|
||||||
|
inventoryInfo = new InventoryTable(this);
|
||||||
|
|
||||||
LegacyTable legacyTable = new LegacyTable(this);
|
LegacyTable legacyTable = new LegacyTable(this);
|
||||||
if(legacyTable.exists()){
|
if(legacyTable.exists()){
|
||||||
if(legacyTable.copyData()){
|
if(legacyTable.copyData()){
|
||||||
|
@ -69,6 +72,8 @@ public class Database {
|
||||||
|
|
||||||
public NameDataTable getNameData() { return nameInfo; }
|
public NameDataTable getNameData() { return nameInfo; }
|
||||||
|
|
||||||
|
public InventoryTable getInventoryData() { return inventoryInfo; }
|
||||||
|
|
||||||
protected Connection connect() {
|
protected Connection connect() {
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
|
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
|
||||||
import net.tylermurphy.hideAndSeek.game.Board;
|
import net.tylermurphy.hideAndSeek.game.Board;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.WinType;
|
import net.tylermurphy.hideAndSeek.game.util.WinType;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
@ -91,7 +92,7 @@ public class GameDataTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public PlayerInfo getInfoRanking(String order, int place) {
|
public PlayerInfo getInfoRanking(@NotNull String order, int place) {
|
||||||
String sql = "SELECT * FROM hs_data ORDER BY "+order+" DESC LIMIT 1 OFFSET ?;";
|
String sql = "SELECT * FROM hs_data ORDER BY "+order+" DESC LIMIT 1 OFFSET ?;";
|
||||||
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
|
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
|
||||||
statement.setInt(1, place-1);
|
statement.setInt(1, place-1);
|
||||||
|
@ -154,7 +155,7 @@ public class GameDataTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Integer getRanking(String order, UUID uuid) {
|
public Integer getRanking(@NotNull String order, @NotNull UUID uuid) {
|
||||||
String sql = "SELECT count(*) AS total FROM hs_data WHERE "+order+" >= (SELECT "+order+" FROM hs_data WHERE uuid = ?) AND "+order+" > 0;";
|
String sql = "SELECT count(*) AS total FROM hs_data WHERE "+order+" >= (SELECT "+order+" FROM hs_data WHERE uuid = ?) AND "+order+" > 0;";
|
||||||
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
|
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
|
||||||
statement.setBytes(1, database.encodeUUID(uuid));
|
statement.setBytes(1, database.encodeUUID(uuid));
|
||||||
|
@ -170,7 +171,16 @@ public class GameDataTable {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addWins(Board board, List<UUID> uuids, List<UUID> winners, Map<String,Integer> hider_kills, Map<String,Integer> hider_deaths, Map<String,Integer> seeker_kills, Map<String,Integer> seeker_deaths, WinType type) {
|
public void addWins(
|
||||||
|
@NotNull Board board,
|
||||||
|
@NotNull List<UUID> uuids,
|
||||||
|
@NotNull List<UUID> winners,
|
||||||
|
@NotNull Map<String,Integer> hider_kills,
|
||||||
|
@NotNull Map<String,Integer> hider_deaths,
|
||||||
|
@NotNull Map<String,Integer> seeker_kills,
|
||||||
|
@NotNull Map<String,Integer> seeker_deaths,
|
||||||
|
@NotNull WinType type
|
||||||
|
) {
|
||||||
for(UUID uuid : uuids) {
|
for(UUID uuid : uuids) {
|
||||||
PlayerInfo info = getInfo(uuid);
|
PlayerInfo info = getInfo(uuid);
|
||||||
if(info == null){
|
if(info == null){
|
||||||
|
@ -190,7 +200,7 @@ public class GameDataTable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean 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){
|
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;
|
boolean success;
|
||||||
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 (?,?,?,?,?,?,?,?,?)";
|
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)) {
|
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
|
||||||
|
@ -211,7 +221,7 @@ public class GameDataTable {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
success = false;
|
success = false;
|
||||||
} finally {
|
} finally {
|
||||||
CACHE.remove(uuid);
|
CACHE.remove(database.decodeUUID(uuid));
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
package net.tylermurphy.hideAndSeek.database;
|
||||||
|
|
||||||
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.util.io.BukkitObjectInputStream;
|
||||||
|
import org.bukkit.util.io.BukkitObjectOutputStream;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class InventoryTable {
|
||||||
|
|
||||||
|
private final Database database;
|
||||||
|
|
||||||
|
protected InventoryTable(Database database) {
|
||||||
|
|
||||||
|
String sql = "CREATE TABLE IF NOT EXISTS hs_inventory (\n"
|
||||||
|
+ " uuid BINARY(16) NOT NULL,\n"
|
||||||
|
+ " inventory TEXT NOT NULL,\n"
|
||||||
|
+ " PRIMARY KEY (uuid)\n"
|
||||||
|
+ ");";
|
||||||
|
|
||||||
|
try(Connection connection = database.connect(); Statement statement = connection.createStatement()) {
|
||||||
|
statement.executeUpdate(sql);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Main.getInstance().getLogger().severe("SQL Error: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.database = database;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public ItemStack[] getInventory(@NotNull UUID uuid) {
|
||||||
|
String sql = "SELECT * FROM hs_inventory WHERE uuid = ?;";
|
||||||
|
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
|
||||||
|
statement.setBytes(1, database.encodeUUID(uuid));
|
||||||
|
ResultSet rs = statement.executeQuery();
|
||||||
|
if (rs.next()) {
|
||||||
|
String data = rs.getString("inventory");
|
||||||
|
if(data == null) return null;
|
||||||
|
return itemStackArrayFromBase64(data);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Main.getInstance().getLogger().severe("SQL Error: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Main.getInstance().getLogger().severe("IO Error: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String itemStackArrayToBase64(ItemStack[] itemArray) throws IllegalStateException {
|
||||||
|
try {
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
|
||||||
|
|
||||||
|
dataOutput.writeObject(itemArray);
|
||||||
|
|
||||||
|
dataOutput.close();
|
||||||
|
|
||||||
|
return Base64Coder.encodeLines(outputStream.toByteArray());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IllegalStateException("Error whilst saving items, Please contact the developer", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
|
||||||
|
try {
|
||||||
|
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
|
||||||
|
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
|
||||||
|
|
||||||
|
ItemStack[] itemArray = (ItemStack[]) dataInput.readObject();
|
||||||
|
|
||||||
|
dataInput.close();
|
||||||
|
return itemArray;
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
throw new IOException("Error whilst loading items, Please contact the developer", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ package net.tylermurphy.hideAndSeek.database;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.lang.management.BufferPoolMXBean;
|
import java.lang.management.BufferPoolMXBean;
|
||||||
|
@ -51,7 +52,7 @@ public class NameDataTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getName(UUID uuid) {
|
public String getName(@NotNull UUID uuid) {
|
||||||
String sql = "SELECT * FROM hs_names WHERE uuid = ?;";
|
String sql = "SELECT * FROM hs_names WHERE uuid = ?;";
|
||||||
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
|
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
|
||||||
statement.setBytes(1, database.encodeUUID(uuid));
|
statement.setBytes(1, database.encodeUUID(uuid));
|
||||||
|
@ -73,7 +74,7 @@ public class NameDataTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public UUID getUUID(String name) {
|
public UUID getUUID(@NotNull String name) {
|
||||||
String sql = "SELECT * FROM hs_names WHERE name = ?;";
|
String sql = "SELECT * FROM hs_names WHERE name = ?;";
|
||||||
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
|
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
|
||||||
statement.setString(1, name);
|
statement.setString(1, name);
|
||||||
|
@ -94,7 +95,7 @@ public class NameDataTable {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean update(UUID uuid, String name){
|
public boolean update(@NotNull UUID uuid, @NotNull String name){
|
||||||
String sql = "INSERT OR REPLACE INTO hs_names (uuid, name) VALUES (?,?)";
|
String sql = "INSERT OR REPLACE INTO hs_names (uuid, name) VALUES (?,?)";
|
||||||
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
|
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
|
||||||
statement.setBytes(1, database.encodeUUID(uuid));
|
statement.setBytes(1, database.encodeUUID(uuid));
|
||||||
|
|
|
@ -33,6 +33,7 @@ import net.tylermurphy.hideAndSeek.world.WorldLoader;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -169,6 +170,10 @@ public class Game {
|
||||||
|
|
||||||
public void join(Player player) {
|
public void join(Player player) {
|
||||||
if (status != Status.STARTING && status != Status.PLAYING) {
|
if (status != Status.STARTING && status != Status.PLAYING) {
|
||||||
|
if(saveInventory) {
|
||||||
|
ItemStack[] data = player.getInventory().getContents();
|
||||||
|
Main.getInstance().getDatabase().getInventoryData().saveInventory(player.getUniqueId(), data);
|
||||||
|
}
|
||||||
PlayerLoader.joinPlayer(player);
|
PlayerLoader.joinPlayer(player);
|
||||||
board.addHider(player);
|
board.addHider(player);
|
||||||
board.createLobbyBoard(player);
|
board.createLobbyBoard(player);
|
||||||
|
@ -185,6 +190,10 @@ public class Game {
|
||||||
|
|
||||||
public void leave(Player player) {
|
public void leave(Player player) {
|
||||||
PlayerLoader.unloadPlayer(player);
|
PlayerLoader.unloadPlayer(player);
|
||||||
|
if(saveInventory) {
|
||||||
|
ItemStack[] data = Main.getInstance().getDatabase().getInventoryData().getInventory(player.getUniqueId());
|
||||||
|
player.getInventory().setContents(data);
|
||||||
|
}
|
||||||
if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player));
|
if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player));
|
||||||
else broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player));
|
else broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player));
|
||||||
if (board.isHider(player) && status != Status.ENDING && status != Status.STANDBY) {
|
if (board.isHider(player) && status != Status.ENDING && status != Status.STANDBY) {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package net.tylermurphy.hideAndSeek.game;
|
package net.tylermurphy.hideAndSeek.game;
|
||||||
|
|
||||||
|
import com.cryptomorin.xseries.XItemStack;
|
||||||
import com.cryptomorin.xseries.messages.Titles;
|
import com.cryptomorin.xseries.messages.Titles;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.tylermurphy.hideAndSeek.game.listener;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.configuration.Items;
|
import net.tylermurphy.hideAndSeek.configuration.Items;
|
||||||
|
import net.tylermurphy.hideAndSeek.game.PlayerLoader;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.Status;
|
import net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
@ -59,16 +60,18 @@ public class JoinLeaveHandler implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleLeave(Player player) {
|
private void handleLeave(Player player) {
|
||||||
|
if(!Main.getInstance().getBoard().contains(player)) return;
|
||||||
|
PlayerLoader.unloadPlayer(player);
|
||||||
Main.getInstance().getBoard().remove(player);
|
Main.getInstance().getBoard().remove(player);
|
||||||
|
if(saveInventory) {
|
||||||
|
ItemStack[] data = Main.getInstance().getDatabase().getInventoryData().getInventory(player.getUniqueId());
|
||||||
|
player.getInventory().setContents(data);
|
||||||
|
}
|
||||||
if (Main.getInstance().getGame().getStatus() == Status.STANDBY) {
|
if (Main.getInstance().getGame().getStatus() == Status.STANDBY) {
|
||||||
Main.getInstance().getBoard().reloadLobbyBoards();
|
Main.getInstance().getBoard().reloadLobbyBoards();
|
||||||
} else {
|
} else {
|
||||||
Main.getInstance().getBoard().reloadGameBoards();
|
Main.getInstance().getBoard().reloadGameBoards();
|
||||||
}
|
}
|
||||||
for(PotionEffect effect : player.getActivePotionEffects()) {
|
|
||||||
player.removePotionEffect(effect.getType());
|
|
||||||
}
|
|
||||||
removeItems(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeItems(Player player) {
|
private void removeItems(Player player) {
|
||||||
|
|
|
@ -94,6 +94,12 @@ leaveServer: hub
|
||||||
# default: true
|
# default: true
|
||||||
mapSaveEnabled: true
|
mapSaveEnabled: true
|
||||||
|
|
||||||
|
# By default, the plugin clears your inventory when joining the game. This is something it will always do. But you don't get what you used to have
|
||||||
|
# in your inventory back after you leave the game. You can allow the plugin to save a players inventory before joining the lobby, and give it back
|
||||||
|
# after leaving the game.
|
||||||
|
# default: false
|
||||||
|
saveInventory: false
|
||||||
|
|
||||||
# How you want to store game data. If you are running a single server, sqlite is fine, as no setup is necessary.
|
# How you want to store game data. If you are running a single server, sqlite is fine, as no setup is necessary.
|
||||||
# But if you want the data to go across multiple servers, you can switch it to mysql.
|
# But if you want the data to go across multiple servers, you can switch it to mysql.
|
||||||
# WARNING: Data is not saved across databases. You have to migrate the data yourself!
|
# WARNING: Data is not saved across databases. You have to migrate the data yourself!
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: KenshinsHideAndSeek
|
name: KenshinsHideAndSeek
|
||||||
main: net.tylermurphy.hideAndSeek.Main
|
main: net.tylermurphy.hideAndSeek.Main
|
||||||
version: 1.5.0
|
version: 1.5.1
|
||||||
author: KenshinEto
|
author: KenshinEto
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
|
Loading…
Reference in a new issue