diff --git a/Bukkit/plugin.yml b/Bukkit/plugin.yml index 404263b..af8cc45 100644 --- a/Bukkit/plugin.yml +++ b/Bukkit/plugin.yml @@ -1,6 +1,6 @@ name: CubeRunner main : me.poutineqc.cuberunner.CubeRunner -version: 2.4.1 +version: 2.4.2 description: Blocks are falling over your head! Can you outrun them? load: postworld author: PoutineQc diff --git a/Bukkit/src/me/poutineqc/cuberunner/commands/inventories/CRInventory.java b/Bukkit/src/me/poutineqc/cuberunner/commands/inventories/CRInventory.java index a8f3f0d..173bc5b 100644 --- a/Bukkit/src/me/poutineqc/cuberunner/commands/inventories/CRInventory.java +++ b/Bukkit/src/me/poutineqc/cuberunner/commands/inventories/CRInventory.java @@ -11,39 +11,41 @@ import me.poutineqc.cuberunner.Language.Messages; public abstract class CRInventory { - protected Inventory inventory; - protected CRPlayer crPlayer; - protected int amountOfRows; - protected String title; - - public CRInventory(CRPlayer crPlayer) { - this.crPlayer = crPlayer; - } - - public abstract void fillInventory() throws PlayerStatsException; - - public abstract void update(ItemStack itemStack, InventoryAction action); - - public static boolean areEqualOnColorStrip(String itemA, String itemB) { - return ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', itemA)) - .equalsIgnoreCase(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', itemB))); - } - - protected void createInventory() { - inventory = Bukkit.createInventory(crPlayer.getPlayer(), amountOfRows * 9, getFullTitle()); - } - - protected String getFullTitle() { - return ChatColor.translateAlternateColorCodes('&', crPlayer.getLanguage().get(Messages.PREFIX_LONG) + " " + title); - } - - protected void openInventory() { - crPlayer.getPlayer().openInventory(inventory); - crPlayer.setCurrentInventory(this); - } - - protected void closeInventory() { - crPlayer.getPlayer().closeInventory(); - crPlayer.setCurrentInventory(null); - } + protected Inventory inventory; + protected CRPlayer crPlayer; + protected int amountOfRows; + protected String title; + + public CRInventory(CRPlayer crPlayer) { + this.crPlayer = crPlayer; + } + + public abstract void fillInventory() throws PlayerStatsException; + + public abstract void update(ItemStack itemStack, InventoryAction action); + + public static boolean areEqualOnColorStrip(String itemA, String itemB) { + return ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', itemA)) + .equalsIgnoreCase(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', itemB))); + } + + protected void createInventory() { + inventory = Bukkit.createInventory(crPlayer.getPlayer(), amountOfRows * 9, getFullTitle()); + } + + protected String getFullTitle() { + String title = ChatColor.translateAlternateColorCodes('&', + crPlayer.getLanguage().get(Messages.PREFIX_SHORT) + " " + this.title); + return title; + } + + protected void openInventory() { + crPlayer.getPlayer().openInventory(inventory); + crPlayer.setCurrentInventory(this); + } + + protected void closeInventory() { + crPlayer.getPlayer().closeInventory(); + crPlayer.setCurrentInventory(null); + } } diff --git a/Bukkit/src/me/poutineqc/cuberunner/game/Arena.java b/Bukkit/src/me/poutineqc/cuberunner/game/Arena.java index 595a511..ac5f098 100644 --- a/Bukkit/src/me/poutineqc/cuberunner/game/Arena.java +++ b/Bukkit/src/me/poutineqc/cuberunner/game/Arena.java @@ -85,7 +85,8 @@ public static void loadExistingArenas() { if (mysql.hasConnection()) { try { - ResultSet arenas = mysql.query("SELECT * FROM " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS;"); + ResultSet arenas = mysql + .query("SELECT * FROM " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS;"); while (arenas.next()) { String name = arenas.getString("name"); Long colorIndice = arenas.getLong("colorIndice"); @@ -211,10 +212,10 @@ public Arena(String name, Player player) { resetScoreboard(); if (mysql.hasConnection()) { - mysql.update("INSERT INTO " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS (name, world) " + "VALUES ('" + name + "','" - + world.getName() + "');"); - mysql.update("UPDATE " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS SET colorIndice=" + (long) 1 + " WHERE name='" + name - + "';"); + mysql.update("INSERT INTO " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS (name, world) " + + "VALUES ('" + name + "','" + world.getName() + "');"); + mysql.update("UPDATE " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS SET colorIndice=" + + (long) 1 + " WHERE name='" + name + "';"); } else { arenaData.getData().set("arenas." + name + ".world", world.getName()); arenaData.getData().set("arenas." + name + ".colorIndice", (long) 1); @@ -245,7 +246,8 @@ public void delete(Player player) { arenas.remove(this); if (mysql.hasConnection()) { - mysql.update("DELETE FROM " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS WHERE name='" + name + "';"); + mysql.update("DELETE FROM " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS WHERE name='" + name + + "';"); } else { arenaData.getData().set("arenas." + name, null); arenaData.saveArenaData(); @@ -272,10 +274,10 @@ public void setArena(Player player) { local.sendMsg(player, local.get(Messages.EDIT_REGION).replace("%arena%", name)); if (mysql.hasConnection()) { - mysql.update("UPDATE " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS SET world='" + world.getName() + "',minPointX=" - + minPoint.getBlockX() + ",minPointY=" + minPoint.getBlockY() + ",minPointZ=" + minPoint.getBlockZ() - + ",maxPointX=" + maxPoint.getBlockX() + ",maxPointY=" + maxPoint.getBlockY() + ",maxPointZ=" - + maxPoint.getBlockZ() + " WHERE name='" + name + "';"); + mysql.update("UPDATE " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS SET world='" + + world.getName() + "',minPointX=" + minPoint.getBlockX() + ",minPointY=" + minPoint.getBlockY() + + ",minPointZ=" + minPoint.getBlockZ() + ",maxPointX=" + maxPoint.getBlockX() + ",maxPointY=" + + maxPoint.getBlockY() + ",maxPointZ=" + maxPoint.getBlockZ() + " WHERE name='" + name + "';"); } else { arenaData.getData().set("arenas." + name + ".world", world.getName()); arenaData.getData().set("arenas." + name + ".minPoint.X", minPoint.getBlockX()); @@ -301,9 +303,10 @@ public void setLobby(Player player) { local.sendMsg(player, local.get(Messages.EDIT_LOBBY).replace("%arena%", name)); if (mysql.hasConnection()) { - mysql.update("UPDATE " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS SET world='" + world.getName() + "',lobbyX=" - + lobby.getX() + ",lobbyY=" + lobby.getY() + ",lobbyZ=" + lobby.getZ() + ",lobbyPitch=" - + lobby.getPitch() + ",lobbyYaw=" + lobby.getYaw() + " WHERE name='" + name + "';"); + mysql.update("UPDATE " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS SET world='" + + world.getName() + "',lobbyX=" + lobby.getX() + ",lobbyY=" + lobby.getY() + ",lobbyZ=" + + lobby.getZ() + ",lobbyPitch=" + lobby.getPitch() + ",lobbyYaw=" + lobby.getYaw() + " WHERE name='" + + name + "';"); } else { arenaData.getData().set("arenas." + name + ".world", world.getName()); arenaData.getData().set("arenas." + name + ".lobby.X", lobby.getX()); @@ -328,10 +331,10 @@ public void setStartPoint(Player player) { local.sendMsg(player, local.get(Messages.EDIT_STARTPOINT).replace("%arena%", name)); if (mysql.hasConnection()) { - mysql.update("UPDATE " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS SET world='" + world.getName() + "',startPointX=" - + startPoint.getX() + ",startPointY=" + startPoint.getY() + ",startPointZ=" + startPoint.getZ() - + ",startPointPitch=" + startPoint.getPitch() + ",startPointYaw=" + startPoint.getYaw() - + " WHERE name='" + name + "';"); + mysql.update("UPDATE " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS SET world='" + + world.getName() + "',startPointX=" + startPoint.getX() + ",startPointY=" + startPoint.getY() + + ",startPointZ=" + startPoint.getZ() + ",startPointPitch=" + startPoint.getPitch() + + ",startPointYaw=" + startPoint.getYaw() + " WHERE name='" + name + "';"); } else { arenaData.getData().set("arenas." + name + ".world", world.getName()); arenaData.getData().set("arenas." + name + ".startPoint.X", startPoint.getX()); @@ -370,8 +373,8 @@ public void setMinPlayer(int amount, Player player) { } if (mysql.hasConnection()) { - mysql.update("UPDATE " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS SET minAmountPlayer=" + amount + " WHERE name='" - + name + "';"); + mysql.update("UPDATE " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS SET minAmountPlayer=" + + amount + " WHERE name='" + name + "';"); } else { arenaData.getData().set("arenas." + name + ".minAmountPlayer", amount); arenaData.saveArenaData(); @@ -402,8 +405,8 @@ public void setMaxPlayer(int amount, Player player) { } if (mysql.hasConnection()) { - mysql.update("UPDATE " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS SET maxAmountPlayer=" + amount + " WHERE name='" - + name + "';"); + mysql.update("UPDATE " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS SET maxAmountPlayer=" + + amount + " WHERE name='" + name + "';"); } else { arenaData.getData().set("arenas." + name + ".maxAmountPlayer", amount); arenaData.saveArenaData(); @@ -536,8 +539,8 @@ public void addPlayer(Player player, boolean teleport) { User user = null; if (teleport || gameState != GameState.ACTIVE) { - user = new User(CubeRunner.get().getConfiguration(), CubeRunner.get().getCRPlayer(player), this, gameState == GameState.ACTIVE, - teleport); + user = new User(CubeRunner.get().getConfiguration(), CubeRunner.get().getCRPlayer(player), this, + gameState == GameState.ACTIVE, teleport); users.add(user); CRSign.updateSigns(this); } @@ -565,7 +568,8 @@ public void addPlayer(Player player, boolean teleport) { localAlt.sendMsg(u, localAlt.get(Messages.JOIN_OTHERS).replace("%player%", player.getDisplayName())); } - if (gameState == GameState.READY && CubeRunner.get().getConfiguration().autostart && getAmountOfPlayerInGame() >= minAmountPlayer) + if (gameState == GameState.READY && CubeRunner.get().getConfiguration().autostart + && getAmountOfPlayerInGame() >= minAmountPlayer) initiateGame(null); } @@ -817,7 +821,7 @@ public void run() { for (User user : arena.users) { if (user.isEliminated()) continue; - + if (user.getLastTreeSecondsDistance() < 1 && user.getScore() >= 2) arena.eliminateUser(user, LeavingReason.HIDING); @@ -832,10 +836,10 @@ public void run() { player.getLocation().getZ()); NumberFormat formater = new DecimalFormat("#.#####"); - double xOffset = Double - .parseDouble(formater.format(l.getX() > 0 ? l.getX() % 1 : 1 + (l.getX() % 1))); - double zOffset = Double - .parseDouble(formater.format(l.getZ() > 0 ? l.getZ() % 1 : 1 + (l.getZ() % 1))); + double xOffset = Double.parseDouble( + formater.format(l.getX() > 0 ? l.getX() % 1 : 1 + (l.getX() % 1)).replace(",", ".")); + double zOffset = Double.parseDouble( + formater.format(l.getZ() > 0 ? l.getZ() % 1 : 1 + (l.getZ() % 1)).replace(",", ".")); if (xOffset <= 0.7 && xOffset >= 0.3) l.setX(Math.floor(l.getX()) + 0.5D); @@ -1075,8 +1079,9 @@ private void endingSequence() { } if (mysql.hasConnection()) { - mysql.update("UPDATE " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS SET highestScore='" + user.getScore() - + "', highestPlayer='" + user.getPlayer().getName() + "' WHERE name='" + name + "';"); + mysql.update("UPDATE " + CubeRunner.get().getConfiguration().tablePrefix + "ARENAS SET highestScore='" + + user.getScore() + "', highestPlayer='" + user.getPlayer().getName() + "' WHERE name='" + name + + "';"); } else { arenaData.getData().set("arenas." + name + ".highestScore.score", highestScore); arenaData.getData().set("arenas." + name + ".highestScore.player", user.getPlayer().getName());