mysql support, always glow, countdown_last, kill stat change, game board null fix
This commit is contained in:
parent
b74b813636
commit
13e6b38aa9
18 changed files with 146 additions and 110 deletions
6
pom.xml
6
pom.xml
|
@ -41,8 +41,10 @@
|
||||||
<artifact>*:*</artifact>
|
<artifact>*:*</artifact>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>META-INF/*.MF</exclude>
|
<exclude>META-INF/*.MF</exclude>
|
||||||
<exclude>META-INF/*.md</exclude>
|
<exclude>META-INF/*.MD</exclude>
|
||||||
<exclude>META-INF</exclude>
|
<exclude>META-INF/*.SF</exclude>
|
||||||
|
<exclude>META-INF/*.DSA</exclude>
|
||||||
|
<exclude>META-INF/*.RSA</exclude>
|
||||||
<exclude>sqlite-jdbc.properties</exclude>
|
<exclude>sqlite-jdbc.properties</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</filter>
|
</filter>
|
||||||
|
|
|
@ -22,6 +22,7 @@ package net.tylermurphy.hideAndSeek.command;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
|
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -54,7 +55,13 @@ public class Top implements ICommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(PlayerInfo info : infos) {
|
for(PlayerInfo info : infos) {
|
||||||
String name = Main.getInstance().getServer().getOfflinePlayer(info.getUniqueId()).getName();
|
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();
|
||||||
|
}
|
||||||
ChatColor color;
|
ChatColor color;
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 1: color = ChatColor.YELLOW; break;
|
case 1: color = ChatColor.YELLOW; break;
|
||||||
|
|
|
@ -37,23 +37,21 @@ public class Wins implements ICommand {
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
String name;
|
String name;
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
Player player = Main.getInstance().getServer().getPlayer(sender.getName());
|
uuid = sender.getUniqueId();
|
||||||
if (player == null) {
|
|
||||||
sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(sender.getName()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uuid = player.getUniqueId();
|
|
||||||
name = sender.getName();
|
name = sender.getName();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
|
||||||
name = args[0];
|
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().getServer().getOfflinePlayer(args[0]).getUniqueId();
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
}
|
||||||
|
if(uuid == null){
|
||||||
sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(args[0]));
|
sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(args[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
PlayerInfo info = Main.getInstance().getDatabase().getGameData().getInfo(uuid);
|
PlayerInfo info = Main.getInstance().getDatabase().getGameData().getInfo(uuid);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
sender.sendMessage(errorPrefix + message("NO_GAME_INFO"));
|
sender.sendMessage(errorPrefix + message("NO_GAME_INFO"));
|
||||||
|
|
|
@ -55,7 +55,13 @@ public class Config {
|
||||||
locale,
|
locale,
|
||||||
leaveServer,
|
leaveServer,
|
||||||
placeholderError,
|
placeholderError,
|
||||||
placeholderNoData;
|
placeholderNoData,
|
||||||
|
databaseType,
|
||||||
|
databaseHost,
|
||||||
|
databasePort,
|
||||||
|
databaseUser,
|
||||||
|
databasePass,
|
||||||
|
databaseName;
|
||||||
|
|
||||||
public static Vector
|
public static Vector
|
||||||
spawnPosition,
|
spawnPosition,
|
||||||
|
@ -71,6 +77,7 @@ public class Config {
|
||||||
tauntEnabled,
|
tauntEnabled,
|
||||||
tauntCountdown,
|
tauntCountdown,
|
||||||
tauntLast,
|
tauntLast,
|
||||||
|
alwaysGlow,
|
||||||
glowEnabled,
|
glowEnabled,
|
||||||
glowStackable,
|
glowStackable,
|
||||||
pvpEnabled,
|
pvpEnabled,
|
||||||
|
@ -218,9 +225,10 @@ public class Config {
|
||||||
tauntLast = config.getBoolean("taunt.whenLastPerson");
|
tauntLast = config.getBoolean("taunt.whenLastPerson");
|
||||||
|
|
||||||
//Glow
|
//Glow
|
||||||
|
alwaysGlow = config.getBoolean("alwaysGlow") && Main.getInstance().supports(9);
|
||||||
glowLength = Math.max(1, config.getInt("glow.time"));
|
glowLength = Math.max(1, config.getInt("glow.time"));
|
||||||
glowStackable = config.getBoolean("glow.stackable");
|
glowStackable = config.getBoolean("glow.stackable");
|
||||||
glowEnabled = config.getBoolean("glow.enabled") && Main.getInstance().supports(9);
|
glowEnabled = config.getBoolean("glow.enabled") && Main.getInstance().supports(9) && !alwaysGlow;
|
||||||
if (glowEnabled) {
|
if (glowEnabled) {
|
||||||
glowPowerupItem = createItemStack("glow");
|
glowPowerupItem = createItemStack("glow");
|
||||||
}
|
}
|
||||||
|
@ -314,6 +322,19 @@ public class Config {
|
||||||
|
|
||||||
teleportItem = createItemStack("spectatorItems.teleport");
|
teleportItem = createItemStack("spectatorItems.teleport");
|
||||||
teleportItemPosition = config.getInt("spectatorItems.teleport.position");
|
teleportItemPosition = config.getInt("spectatorItems.teleport.position");
|
||||||
|
|
||||||
|
//Database
|
||||||
|
databaseHost = config.getString("databaseHost");
|
||||||
|
databasePort = config.getString("databasePort");
|
||||||
|
databaseUser = config.getString("databaseUser");
|
||||||
|
databasePass = config.getString("databasePass");
|
||||||
|
databaseName = config.getString("databaseName");
|
||||||
|
|
||||||
|
databaseType = config.getString("databaseType").toUpperCase();
|
||||||
|
if(!databaseType.equals("SQLITE") && !databaseType.equals("MYSQL")){
|
||||||
|
Main.getInstance().getLogger().warning("databaseType: "+databaseType+" is not a valid configuration option!");
|
||||||
|
databaseType = "SQLITE";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addToConfig(String path, Object value) {
|
public static void addToConfig(String path, Object value) {
|
||||||
|
|
|
@ -205,6 +205,10 @@ public class ConfigManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConfigurationSection getDefaultConfigurationSection(String path) {
|
||||||
|
return defaultConfig.getConfigurationSection(path);
|
||||||
|
}
|
||||||
|
|
||||||
public void set(String path, Object value) {
|
public void set(String path, Object value) {
|
||||||
config.set(path, value);
|
config.set(path, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Map;
|
||||||
public class Localization {
|
public class Localization {
|
||||||
|
|
||||||
public static final Map<String,LocalizationString> LOCAL = new HashMap<>();
|
public static final Map<String,LocalizationString> LOCAL = new HashMap<>();
|
||||||
|
public static final Map<String,LocalizationString> DEFAULT_LOCAL = new HashMap<>();
|
||||||
|
|
||||||
private static final Map<String,String[][]> CHANGES = new HashMap<String,String[][]>() {{
|
private static final Map<String,String[][]> CHANGES = new HashMap<String,String[][]>() {{
|
||||||
put("en-US", new String[][]{{"WORLDBORDER_DECREASING"},{"START","TAUNTED"}});
|
put("en-US", new String[][]{{"WORLDBORDER_DECREASING"},{"START","TAUNTED"}});
|
||||||
|
@ -65,13 +66,24 @@ public class Localization {
|
||||||
new LocalizationString( ChatColor.translateAlternateColorCodes('&', manager.getString("Localization."+key) ) )
|
new LocalizationString( ChatColor.translateAlternateColorCodes('&', manager.getString("Localization."+key) ) )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(String key : manager.getDefaultConfigurationSection("Localization").getKeys(false)) {
|
||||||
|
DEFAULT_LOCAL.put(
|
||||||
|
key,
|
||||||
|
new LocalizationString( ChatColor.translateAlternateColorCodes('&', manager.getString("Localization."+key) ) )
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LocalizationString message(String key) {
|
public static LocalizationString message(String key) {
|
||||||
LocalizationString temp = LOCAL.get(key);
|
LocalizationString message = LOCAL.get(key);
|
||||||
if (temp == null) {
|
if (message == null) {
|
||||||
|
LocalizationString defaultMessage = DEFAULT_LOCAL.get(key);
|
||||||
|
if(defaultMessage == null) {
|
||||||
return new LocalizationString(ChatColor.RED + "" + ChatColor.ITALIC + key + " is not found in localization.yml. This is a plugin issue, please report it.");
|
return new LocalizationString(ChatColor.RED + "" + ChatColor.ITALIC + key + " is not found in localization.yml. This is a plugin issue, please report it.");
|
||||||
}
|
}
|
||||||
return new LocalizationString(temp.toString());
|
return new LocalizationString(defaultMessage.toString());
|
||||||
|
}
|
||||||
|
return new LocalizationString(message.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ package net.tylermurphy.hideAndSeek.database;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.database.connections.DatabaseConnection;
|
import net.tylermurphy.hideAndSeek.database.connections.DatabaseConnection;
|
||||||
|
import net.tylermurphy.hideAndSeek.database.connections.MySQLConnection;
|
||||||
import net.tylermurphy.hideAndSeek.database.connections.SQLiteConnection;
|
import net.tylermurphy.hideAndSeek.database.connections.SQLiteConnection;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
@ -32,6 +33,8 @@ import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static net.tylermurphy.hideAndSeek.configuration.Config.databaseType;
|
||||||
|
|
||||||
public class Database {
|
public class Database {
|
||||||
|
|
||||||
private final GameDataTable playerInfo;
|
private final GameDataTable playerInfo;
|
||||||
|
@ -40,7 +43,11 @@ public class Database {
|
||||||
|
|
||||||
public Database(){
|
public Database(){
|
||||||
|
|
||||||
|
if(databaseType.equals("SQLITE")) {
|
||||||
connection = new SQLiteConnection();
|
connection = new SQLiteConnection();
|
||||||
|
} else {
|
||||||
|
connection = new MySQLConnection();
|
||||||
|
}
|
||||||
|
|
||||||
playerInfo = new GameDataTable(this);
|
playerInfo = new GameDataTable(this);
|
||||||
|
|
||||||
|
|
|
@ -25,26 +25,22 @@ import com.zaxxer.hikari.HikariDataSource;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
|
|
||||||
public class MySQLConnection implements DatabaseConnection {
|
public class MySQLConnection implements DatabaseConnection {
|
||||||
|
|
||||||
private final HikariConfig config;
|
|
||||||
private final HikariDataSource ds;
|
private final HikariDataSource ds;
|
||||||
|
|
||||||
public MySQLConnection(){
|
public MySQLConnection(){
|
||||||
|
|
||||||
String host = "to be implemented";
|
HikariConfig config = new HikariConfig();
|
||||||
String port = "to be implemented";
|
|
||||||
String user = "to be implemented";
|
|
||||||
String pass = "to be implemented";
|
|
||||||
|
|
||||||
config = new HikariConfig();
|
config.setJdbcUrl("jdbc:mariadb://"+databaseHost+":"+databasePort+"/"+databaseName);
|
||||||
|
|
||||||
config.setJdbcUrl("jdbc:mariadb://"+host+":"+port+"/kenbot");
|
|
||||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||||
config.addDataSourceProperty("user", user);
|
config.addDataSourceProperty("user", databaseUser);
|
||||||
config.addDataSourceProperty("password",pass);
|
config.addDataSourceProperty("password",databasePass);
|
||||||
config.addDataSourceProperty("autoCommit", "true");
|
config.addDataSourceProperty("autoCommit", "true");
|
||||||
config.setAutoCommit(true);
|
config.setAutoCommit(true);
|
||||||
config.setMaximumPoolSize(20);
|
config.setMaximumPoolSize(20);
|
||||||
|
|
|
@ -153,7 +153,7 @@ public class Board {
|
||||||
} else {
|
} else {
|
||||||
hider_kills.put(uuid.toString(), 1);
|
hider_kills.put(uuid.toString(), 1);
|
||||||
}
|
}
|
||||||
} else if (getFirstSeeker().getUniqueId().equals(uuid)) {
|
} else if (Seeker.contains(uuid.toString())) {
|
||||||
if (seeker_kills.containsKey(uuid.toString())) {
|
if (seeker_kills.containsKey(uuid.toString())) {
|
||||||
seeker_kills.put(uuid.toString(), seeker_kills.get(uuid.toString())+1);
|
seeker_kills.put(uuid.toString(), seeker_kills.get(uuid.toString())+1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -169,7 +169,7 @@ public class Board {
|
||||||
} else {
|
} else {
|
||||||
hider_deaths.put(uuid.toString(), 1);
|
hider_deaths.put(uuid.toString(), 1);
|
||||||
}
|
}
|
||||||
} else if (getFirstSeeker().getUniqueId().equals(uuid)) {
|
} else if (Seeker.contains(uuid.toString())) {
|
||||||
if (seeker_deaths.containsKey(uuid.toString())) {
|
if (seeker_deaths.containsKey(uuid.toString())) {
|
||||||
seeker_deaths.put(uuid.toString(), seeker_deaths.get(uuid.toString())+1);
|
seeker_deaths.put(uuid.toString(), seeker_deaths.get(uuid.toString())+1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -234,7 +234,7 @@ public class Board {
|
||||||
|
|
||||||
private void createGameBoard(Player player, boolean recreate) {
|
private void createGameBoard(Player player, boolean recreate) {
|
||||||
CustomBoard board = customBoards.get(player.getUniqueId().toString());
|
CustomBoard board = customBoards.get(player.getUniqueId().toString());
|
||||||
if (recreate) {
|
if (recreate || board == null) {
|
||||||
board = new CustomBoard(player, GAME_TITLE);
|
board = new CustomBoard(player, GAME_TITLE);
|
||||||
board.updateTeams();
|
board.updateTeams();
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,12 +242,14 @@ public class Game {
|
||||||
private void whileStarting() {
|
private void whileStarting() {
|
||||||
|
|
||||||
if(gameTick % 20 == 0) {
|
if(gameTick % 20 == 0) {
|
||||||
if (startingTimer % 5 == 0 || startingTimer < 4) {
|
if (startingTimer % 5 == 0 || startingTimer < 5) {
|
||||||
String message;
|
String message;
|
||||||
if (startingTimer == 0) {
|
if (startingTimer == 0) {
|
||||||
message = message("START").toString();
|
message = message("START").toString();
|
||||||
status = Status.PLAYING;
|
status = Status.PLAYING;
|
||||||
board.getPlayers().forEach(player -> PlayerLoader.resetPlayer(player, board));
|
board.getPlayers().forEach(player -> PlayerLoader.resetPlayer(player, board));
|
||||||
|
} else if (startingTimer == 1){
|
||||||
|
message = message("START_COUNTDOWN_LAST").addAmount(startingTimer).toString();
|
||||||
} else {
|
} else {
|
||||||
message = message("START_COUNTDOWN").addAmount(startingTimer).toString();
|
message = message("START_COUNTDOWN").addAmount(startingTimer).toString();
|
||||||
}
|
}
|
||||||
|
@ -305,7 +307,7 @@ public class Game {
|
||||||
}
|
}
|
||||||
if (worldBorderEnabled) worldBorder.update();
|
if (worldBorderEnabled) worldBorder.update();
|
||||||
if (tauntEnabled) taunt.update();
|
if (tauntEnabled) taunt.update();
|
||||||
if (glowEnabled) glow.update();
|
if (glowEnabled || alwaysGlow) glow.update();
|
||||||
}
|
}
|
||||||
board.getSpectators().forEach(spectator -> spectator.setFlying(spectator.getAllowFlight()));
|
board.getSpectators().forEach(spectator -> spectator.setFlying(spectator.getAllowFlight()));
|
||||||
checkWinConditions();
|
checkWinConditions();
|
||||||
|
|
|
@ -10,8 +10,7 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.glowLength;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.glowStackable;
|
|
||||||
|
|
||||||
public class Glow {
|
public class Glow {
|
||||||
|
|
||||||
|
@ -37,6 +36,10 @@ public class Glow {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
if(alwaysGlow){
|
||||||
|
sendPackets();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (running) {
|
if (running) {
|
||||||
sendPackets();
|
sendPackets();
|
||||||
glowTime--;
|
glowTime--;
|
||||||
|
|
|
@ -96,21 +96,18 @@ public class DamageHandler implements Listener {
|
||||||
// Broadcast player death message
|
// Broadcast player death message
|
||||||
if (board.isSeeker(player)) {
|
if (board.isSeeker(player)) {
|
||||||
game.broadcastMessage(message("GAME_PLAYER_DEATH").addPlayer(player).toString());
|
game.broadcastMessage(message("GAME_PLAYER_DEATH").addPlayer(player).toString());
|
||||||
if (board.getFirstSeeker().getName().equals(player.getName())) {
|
|
||||||
board.addDeath(player.getUniqueId());
|
|
||||||
}
|
|
||||||
} else if (board.isHider(player)) {
|
} else if (board.isHider(player)) {
|
||||||
if (attacker == null) {
|
if (attacker == null) {
|
||||||
game.broadcastMessage(message("GAME_PLAYER_FOUND").addPlayer(player).toString());
|
game.broadcastMessage(message("GAME_PLAYER_FOUND").addPlayer(player).toString());
|
||||||
} else {
|
} else {
|
||||||
game.broadcastMessage(message("GAME_PLAYER_FOUND_BY").addPlayer(player).addPlayer(attacker).toString());
|
game.broadcastMessage(message("GAME_PLAYER_FOUND_BY").addPlayer(player).addPlayer(attacker).toString());
|
||||||
}
|
}
|
||||||
board.addDeath(player.getUniqueId());
|
|
||||||
board.addSeeker(player);
|
board.addSeeker(player);
|
||||||
}
|
}
|
||||||
// Add leaderboard kills if attacker
|
// Add leaderboard stats
|
||||||
if (attacker != null && ( board.isHider(attacker) || board.getFirstSeeker().getName().equals(attacker.getName()) ) )
|
board.addDeath(player.getUniqueId());
|
||||||
board.addKill(attacker.getUniqueId());
|
if (attacker != null) board.addKill(attacker.getUniqueId());
|
||||||
|
//Reload player
|
||||||
PlayerLoader.resetPlayer(player, board);
|
PlayerLoader.resetPlayer(player, board);
|
||||||
board.reloadBoardTeams();
|
board.reloadBoardTeams();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ public class JoinLeaveHandler implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
if(!Main.getInstance().getDatabase().getNameData().update(event.getPlayer().getUniqueId(), event.getPlayer().getDisplayName())){
|
if(!Main.getInstance().getDatabase().getNameData().update(event.getPlayer().getUniqueId(), event.getPlayer().getName())){
|
||||||
Main.getInstance().getLogger().warning("Failed to save name data for user: " + event.getPlayer().getDisplayName());
|
Main.getInstance().getLogger().warning("Failed to save name data for user: " + event.getPlayer().getName());
|
||||||
}
|
}
|
||||||
Main.getInstance().getBoard().remove(event.getPlayer());
|
Main.getInstance().getBoard().remove(event.getPlayer());
|
||||||
removeItems(event.getPlayer());
|
removeItems(event.getPlayer());
|
||||||
|
|
|
@ -39,14 +39,16 @@ public class PAPIExpansion extends PlaceholderExpansion {
|
||||||
Database database = Main.getInstance().getDatabase();
|
Database database = Main.getInstance().getDatabase();
|
||||||
String[] args = params.split("_");
|
String[] args = params.split("_");
|
||||||
if (args.length < 1) return null;
|
if (args.length < 1) return null;
|
||||||
if (args[0].equals("stats") && args.length == 2) {
|
if (args[0].equals("stats") && (args.length == 2 || args.length == 3)) {
|
||||||
PlayerInfo info = database.getGameData().getInfo(player.getUniqueId());
|
PlayerInfo info = null;
|
||||||
if (info == null) return placeholderNoData;
|
if(args.length == 2) {
|
||||||
return getValue(info, args[1]);
|
database.getGameData().getInfo(player.getUniqueId());
|
||||||
} else if (args[0].equals("stats") && args.length == 3) {
|
} else {
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
try { uuid = Main.getInstance().getServer().getOfflinePlayer(args[2]).getUniqueId(); } catch (Exception e) { return placeholderError; }
|
try { uuid = Main.getInstance().getServer().getOfflinePlayer(args[2]).getUniqueId(); } catch (Exception e) { return placeholderError; }
|
||||||
PlayerInfo info = database.getGameData().getInfo(uuid);
|
info = database.getGameData().getInfo(uuid);
|
||||||
|
}
|
||||||
|
if (info == null) return placeholderNoData;
|
||||||
return getValue(info, args[1]);
|
return getValue(info, args[1]);
|
||||||
} else if ((args[0].equals("rank-score") || args[0].equals("rank-name") ) && args.length == 3) {
|
} else if ((args[0].equals("rank-score") || args[0].equals("rank-name") ) && args.length == 3) {
|
||||||
int place;
|
int place;
|
||||||
|
@ -60,24 +62,21 @@ public class PAPIExpansion extends PlaceholderExpansion {
|
||||||
} else {
|
} else {
|
||||||
return Main.getInstance().getServer().getOfflinePlayer(info.getUniqueId()).getName();
|
return Main.getInstance().getServer().getOfflinePlayer(info.getUniqueId()).getName();
|
||||||
}
|
}
|
||||||
} else if (args[0].equals("rank-place") && args.length == 2) {
|
} else if (args[0].equals("rank-place") && (args.length == 2 || args.length == 3)) {
|
||||||
if (getRanking(args[1]) == null) { return placeholderError; }
|
if (getRanking(args[1]) == null) { return placeholderError; }
|
||||||
PlayerInfo info = database.getGameData().getInfo(player.getUniqueId());
|
PlayerInfo info = null;
|
||||||
|
if(args.length == 2){
|
||||||
|
database.getGameData().getInfo(player.getUniqueId());
|
||||||
|
} else {
|
||||||
|
UUID uuid;
|
||||||
|
try { uuid = Main.getInstance().getServer().getOfflinePlayer(args[2]).getUniqueId(); } catch (Exception e) { return placeholderError; }
|
||||||
|
info = database.getGameData().getInfo(uuid);
|
||||||
|
}
|
||||||
if (info == null) return placeholderNoData;
|
if (info == null) return placeholderNoData;
|
||||||
if (getValue(info, args[1]).equals("0")) { return "-"; }
|
if (getValue(info, args[1]).equals("0")) { return "-"; }
|
||||||
Integer count = database.getGameData().getRanking(getRanking(args[1]), player.getUniqueId());
|
Integer count = database.getGameData().getRanking(getRanking(args[1]), player.getUniqueId());
|
||||||
if (count == null) { return placeholderNoData; }
|
if (count == null) { return placeholderNoData; }
|
||||||
return count.toString();
|
return count.toString();
|
||||||
} else if (args[0].equals("rank-place") && args.length == 3) {
|
|
||||||
UUID uuid;
|
|
||||||
try { uuid = Main.getInstance().getServer().getOfflinePlayer(args[2]).getUniqueId(); } catch (Exception e) { return placeholderError; }
|
|
||||||
if (getRanking(args[1]) == null) { return placeholderError; }
|
|
||||||
PlayerInfo info = database.getGameData().getInfo(player.getUniqueId());
|
|
||||||
if (info == null) return placeholderNoData;
|
|
||||||
if (getValue(info, args[1]).equals("0")) { return "-"; }
|
|
||||||
Integer count = database.getGameData().getRanking(getRanking(args[1]), uuid);
|
|
||||||
if (count == null) { return placeholderNoData; }
|
|
||||||
return count.toString();
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,26 @@ leaveServer: hub
|
||||||
# default: true
|
# default: true
|
||||||
mapSaveEnabled: true
|
mapSaveEnabled: true
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
# WARNING: Data is not saved across databases. You have to migrate the data yourself!
|
||||||
|
#
|
||||||
|
# SQLITE - A single database.db file in the plugin folder, good for a single server.
|
||||||
|
#
|
||||||
|
# MYSQL - Uses a mysql server to store data, good for multi-server setups or large servers.
|
||||||
|
#
|
||||||
|
# default: SQLITE
|
||||||
|
databaseType: SQLITE
|
||||||
|
|
||||||
|
# The following settings are used for MYSQL databases ONLY. If you are running SQLITE, these
|
||||||
|
# will be ignored. If you are running MYSQL, you need to provide the database host url, database
|
||||||
|
# host port (usually 3306), database username, and database password.
|
||||||
|
databaseHost: localhost
|
||||||
|
databasePort: 3306
|
||||||
|
databaseUser: root
|
||||||
|
databasePass:
|
||||||
|
databaseName: hideandseek
|
||||||
|
|
||||||
# The world border closes every interval, which is evey [delay] in minutes.
|
# The world border closes every interval, which is evey [delay] in minutes.
|
||||||
# Thw world border starts at [size], and decreases 100 blocks every interval.
|
# Thw world border starts at [size], and decreases 100 blocks every interval.
|
||||||
# x & z are the center location. [enabled] is whenever the border is enabled.
|
# x & z are the center location. [enabled] is whenever the border is enabled.
|
||||||
|
@ -132,6 +152,14 @@ glow:
|
||||||
material: SNOWBALL
|
material: SNOWBALL
|
||||||
model-data: 0
|
model-data: 0
|
||||||
|
|
||||||
|
# This has the same glow effect as the glow powerup in that all seekers positions get
|
||||||
|
# shown to hiders. But enabling this force disables the powerup, and instead always shows
|
||||||
|
# the seekers positions to the hiders. Good for small maps. Since the glow effect wasn't added
|
||||||
|
# until Minecraft 1.9, any server running 1.8 will have this disabled regardless of the
|
||||||
|
# options below.
|
||||||
|
# default: false
|
||||||
|
alwaysGlow: false
|
||||||
|
|
||||||
# The message prefixes displayed before messages. The message contents themselves
|
# The message prefixes displayed before messages. The message contents themselves
|
||||||
# can be changed in localization.yml.
|
# can be changed in localization.yml.
|
||||||
prefix:
|
prefix:
|
||||||
|
|
|
@ -56,6 +56,7 @@ Localization:
|
||||||
START_MIN_PLAYERS: "Um das Spiel zu starten benötigst du mindestens {AMOUNT} Spieler."
|
START_MIN_PLAYERS: "Um das Spiel zu starten benötigst du mindestens {AMOUNT} Spieler."
|
||||||
START_INVALID_NAME: "Ungültiger Spieler: {PLAYER}."
|
START_INVALID_NAME: "Ungültiger Spieler: {PLAYER}."
|
||||||
START_COUNTDOWN: "Die Hider haben {AMOUNT} Sekunden Zeit sich zu verstecken!"
|
START_COUNTDOWN: "Die Hider haben {AMOUNT} Sekunden Zeit sich zu verstecken!"
|
||||||
|
START_COUNTDOWN_LAST: "Die Hider haben {AMOUNT} Sekunde Zeit sich zu verstecken!"
|
||||||
START: "Los, Seeker! Es ist Zeit, die Hider zu finden."
|
START: "Los, Seeker! Es ist Zeit, die Hider zu finden."
|
||||||
STOP: "Das Spiel wurde gestoppt."
|
STOP: "Das Spiel wurde gestoppt."
|
||||||
HIDER_TEAM_NAME: "&6&lHIDER"
|
HIDER_TEAM_NAME: "&6&lHIDER"
|
||||||
|
|
|
@ -57,6 +57,7 @@ Localization:
|
||||||
START_MIN_PLAYERS: "You must have at least {AMOUNT} players to start."
|
START_MIN_PLAYERS: "You must have at least {AMOUNT} players to start."
|
||||||
START_INVALID_NAME: "Invalid player: {PLAYER}."
|
START_INVALID_NAME: "Invalid player: {PLAYER}."
|
||||||
START_COUNTDOWN: "Hiders have {AMOUNT} seconds to hide!"
|
START_COUNTDOWN: "Hiders have {AMOUNT} seconds to hide!"
|
||||||
|
START_COUNTDOWN_LAST: "Hiders have {AMOUNT} second to hide!"
|
||||||
START: "Attention SEEKERS, its time to find the hiders!"
|
START: "Attention SEEKERS, its time to find the hiders!"
|
||||||
STOP: "Game has been force stopped."
|
STOP: "Game has been force stopped."
|
||||||
HIDER_TEAM_NAME: "&6&lHIDER"
|
HIDER_TEAM_NAME: "&6&lHIDER"
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of Kenshins Hide and Seek
|
|
||||||
*
|
|
||||||
* Copyright (c) 2022 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/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
|
||||||
import be.seeseemelk.mockbukkit.ServerMock;
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
|
|
||||||
public class MainTest {
|
|
||||||
|
|
||||||
private ServerMock server;
|
|
||||||
private Main plugin;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
server = MockBukkit.mock();
|
|
||||||
plugin = MockBukkit.load(Main.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
MockBukkit.unmock();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue