From 2bc5c48e50ce20ccd936ce0ab54ad530458a7654 Mon Sep 17 00:00:00 2001 From: PoutineQc Date: Fri, 27 May 2016 02:03:14 -0400 Subject: [PATCH] Blocs don't end bug --- Bukkit_1.8/plugin.yml | 2 +- .../me/poutineqc/cuberunner/CubeRunner.java | 27 +++++++++---------- .../me/poutineqc/cuberunner/games/Arena.java | 17 +++++++----- .../cuberunner/games/PlayerDamage.java | 6 ++--- Bukkit_1.9/plugin.yml | 2 +- .../me/poutineqc/cuberunner/CubeRunner.java | 27 +++++++++---------- .../me/poutineqc/cuberunner/games/Arena.java | 17 +++++++----- .../cuberunner/games/PlayerDamage.java | 6 ++--- 8 files changed, 56 insertions(+), 48 deletions(-) diff --git a/Bukkit_1.8/plugin.yml b/Bukkit_1.8/plugin.yml index bcd971f..974fc7b 100644 --- a/Bukkit_1.8/plugin.yml +++ b/Bukkit_1.8/plugin.yml @@ -1,6 +1,6 @@ name: CubeRunner main : me.poutineqc.cuberunner.CubeRunner -version: 2.2 +version: 2.2.1 description: Blocks are falling over your head! Can you outrun them? load: postworld author: PoutineQc diff --git a/Bukkit_1.8/src/me/poutineqc/cuberunner/CubeRunner.java b/Bukkit_1.8/src/me/poutineqc/cuberunner/CubeRunner.java index c1a8072..8ee6f8f 100644 --- a/Bukkit_1.8/src/me/poutineqc/cuberunner/CubeRunner.java +++ b/Bukkit_1.8/src/me/poutineqc/cuberunner/CubeRunner.java @@ -41,7 +41,7 @@ public class CubeRunner extends JavaPlugin { private static Economy economy; public void onEnable() { - PluginDescriptionFile pdfFile = getDescription(); + final PluginDescriptionFile pdfFile = getDescription(); final Logger logger = getLogger(); config = new Configuration(this); @@ -64,18 +64,6 @@ public void onEnable() { enableListeners(); getCommand("cuberunner").setExecutor(playerCommands); - if (!playerData.isLatestVersion()) { - logger.info("----------------------------"); - logger.info("CubeRunner Updater"); - logger.info(""); - logger.info("An update for CubeRunner has been found!"); - logger.info("CubeRunner " + playerData.getLatestVersion()); - logger.info("You are running " + pdfFile.getVersion()); - logger.info(""); - logger.info("Download at https://www.spigotmc.org/resources/cuberunner.19715/"); - logger.info("----------------------------"); - } - try { Metrics metrics; metrics = new Metrics(this); @@ -86,6 +74,17 @@ public void onEnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { + if (!playerData.isLatestVersion()) { + logger.info("----------------------------"); + logger.info("CubeRunner Updater"); + logger.info(""); + logger.info("An update for CubeRunner has been found!"); + logger.info("CubeRunner " + playerData.getLatestVersion()); + logger.info("You are running " + pdfFile.getVersion()); + logger.info(""); + logger.info("Download at https://www.spigotmc.org/resources/cuberunner.19715/"); + logger.info("----------------------------"); + } Arena.loadExistingArenas(); } }, 1L); @@ -166,7 +165,7 @@ public boolean initialiseEconomy() { if (!setupEconomy()) { getLogger().warning("Vault not found."); getLogger().warning("Add Vault to your plugins or disable monetary rewards in the config."); - getLogger().info("Disabling DeACoudre..."); + getLogger().info("Disabling CubeRunner..."); getServer().getPluginManager().disablePlugin(this); return false; } diff --git a/Bukkit_1.8/src/me/poutineqc/cuberunner/games/Arena.java b/Bukkit_1.8/src/me/poutineqc/cuberunner/games/Arena.java index 2b8b56c..b58fa8b 100644 --- a/Bukkit_1.8/src/me/poutineqc/cuberunner/games/Arena.java +++ b/Bukkit_1.8/src/me/poutineqc/cuberunner/games/Arena.java @@ -779,8 +779,8 @@ public void run() { ItemStackManager fallingBlock = arena.colorManager.getRandomAvailableBlock(); - FallingSand clay = (FallingSand) player.getWorld().spawnFallingBlock(l, - fallingBlock.getMaterial(), (byte) fallingBlock.getData()); + FallingSand clay = (FallingSand) player.getWorld().spawnFallingBlock(l, fallingBlock.getMaterial(), + (byte) fallingBlock.getData()); clay.setDropItem(false); clay.setHurtEntities(true); @@ -954,11 +954,11 @@ private void endingSequence() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { public void run() { - kickUsers(); + kickUsers(false); } }, 100L); } else - kickUsers(); + kickUsers(true); } @@ -979,14 +979,19 @@ private static int getAmountInGame(Arena arena) { return i; } - private void kickUsers() { + private void kickUsers(boolean wait) { for (User user : users) { user.quit(); user.returnStats(); } users.clear(); - gameState = GameState.READY; + + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + public void run() { + gameState = GameState.READY; + } + }, wait ? 5L : 0L); } public void removeUser(Player player) { diff --git a/Bukkit_1.8/src/me/poutineqc/cuberunner/games/PlayerDamage.java b/Bukkit_1.8/src/me/poutineqc/cuberunner/games/PlayerDamage.java index 2f59a02..11f3ac5 100644 --- a/Bukkit_1.8/src/me/poutineqc/cuberunner/games/PlayerDamage.java +++ b/Bukkit_1.8/src/me/poutineqc/cuberunner/games/PlayerDamage.java @@ -59,6 +59,9 @@ public void onPlayerDamageByEntity(EntityDamageByEntityEvent event) { return; } + event.setDamage(0); + arena.eliminateUser(arena.getUser(player), false); + String dammagerUUID = event.getDamager().getCustomName(); if (!dammagerUUID.equalsIgnoreCase(player.getUniqueId().toString())) { int kills = 0; @@ -82,9 +85,6 @@ public void onPlayerDamageByEntity(EntityDamageByEntityEvent event) { achievements.checkAchievement(AchievementType.AMOUNT_KILLS, arena.getPlayerFromUUID(dammagerUUID)); } - - event.setDamage(0); - arena.eliminateUser(arena.getUser(player), false); } @EventHandler diff --git a/Bukkit_1.9/plugin.yml b/Bukkit_1.9/plugin.yml index bcd971f..974fc7b 100644 --- a/Bukkit_1.9/plugin.yml +++ b/Bukkit_1.9/plugin.yml @@ -1,6 +1,6 @@ name: CubeRunner main : me.poutineqc.cuberunner.CubeRunner -version: 2.2 +version: 2.2.1 description: Blocks are falling over your head! Can you outrun them? load: postworld author: PoutineQc diff --git a/Bukkit_1.9/src/me/poutineqc/cuberunner/CubeRunner.java b/Bukkit_1.9/src/me/poutineqc/cuberunner/CubeRunner.java index c1a8072..8ee6f8f 100644 --- a/Bukkit_1.9/src/me/poutineqc/cuberunner/CubeRunner.java +++ b/Bukkit_1.9/src/me/poutineqc/cuberunner/CubeRunner.java @@ -41,7 +41,7 @@ public class CubeRunner extends JavaPlugin { private static Economy economy; public void onEnable() { - PluginDescriptionFile pdfFile = getDescription(); + final PluginDescriptionFile pdfFile = getDescription(); final Logger logger = getLogger(); config = new Configuration(this); @@ -64,18 +64,6 @@ public void onEnable() { enableListeners(); getCommand("cuberunner").setExecutor(playerCommands); - if (!playerData.isLatestVersion()) { - logger.info("----------------------------"); - logger.info("CubeRunner Updater"); - logger.info(""); - logger.info("An update for CubeRunner has been found!"); - logger.info("CubeRunner " + playerData.getLatestVersion()); - logger.info("You are running " + pdfFile.getVersion()); - logger.info(""); - logger.info("Download at https://www.spigotmc.org/resources/cuberunner.19715/"); - logger.info("----------------------------"); - } - try { Metrics metrics; metrics = new Metrics(this); @@ -86,6 +74,17 @@ public void onEnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { + if (!playerData.isLatestVersion()) { + logger.info("----------------------------"); + logger.info("CubeRunner Updater"); + logger.info(""); + logger.info("An update for CubeRunner has been found!"); + logger.info("CubeRunner " + playerData.getLatestVersion()); + logger.info("You are running " + pdfFile.getVersion()); + logger.info(""); + logger.info("Download at https://www.spigotmc.org/resources/cuberunner.19715/"); + logger.info("----------------------------"); + } Arena.loadExistingArenas(); } }, 1L); @@ -166,7 +165,7 @@ public boolean initialiseEconomy() { if (!setupEconomy()) { getLogger().warning("Vault not found."); getLogger().warning("Add Vault to your plugins or disable monetary rewards in the config."); - getLogger().info("Disabling DeACoudre..."); + getLogger().info("Disabling CubeRunner..."); getServer().getPluginManager().disablePlugin(this); return false; } diff --git a/Bukkit_1.9/src/me/poutineqc/cuberunner/games/Arena.java b/Bukkit_1.9/src/me/poutineqc/cuberunner/games/Arena.java index b9b2ae3..cab7d70 100644 --- a/Bukkit_1.9/src/me/poutineqc/cuberunner/games/Arena.java +++ b/Bukkit_1.9/src/me/poutineqc/cuberunner/games/Arena.java @@ -779,8 +779,8 @@ public void run() { ItemStackManager fallingBlock = arena.colorManager.getRandomAvailableBlock(); - FallingSand clay = (FallingSand) player.getWorld().spawnFallingBlock(l, - fallingBlock.getMaterial(), (byte) fallingBlock.getData()); + FallingSand clay = (FallingSand) player.getWorld().spawnFallingBlock(l, fallingBlock.getMaterial(), + (byte) fallingBlock.getData()); clay.setDropItem(false); clay.setHurtEntities(true); @@ -954,11 +954,11 @@ private void endingSequence() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { public void run() { - kickUsers(); + kickUsers(false); } }, 100L); } else - kickUsers(); + kickUsers(true); } @@ -979,14 +979,19 @@ private static int getAmountInGame(Arena arena) { return i; } - private void kickUsers() { + private void kickUsers(boolean wait) { for (User user : users) { user.quit(); user.returnStats(); } users.clear(); - gameState = GameState.READY; + + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + public void run() { + gameState = GameState.READY; + } + }, wait ? 5L : 0L); } public void removeUser(Player player) { diff --git a/Bukkit_1.9/src/me/poutineqc/cuberunner/games/PlayerDamage.java b/Bukkit_1.9/src/me/poutineqc/cuberunner/games/PlayerDamage.java index 2f59a02..11f3ac5 100644 --- a/Bukkit_1.9/src/me/poutineqc/cuberunner/games/PlayerDamage.java +++ b/Bukkit_1.9/src/me/poutineqc/cuberunner/games/PlayerDamage.java @@ -59,6 +59,9 @@ public void onPlayerDamageByEntity(EntityDamageByEntityEvent event) { return; } + event.setDamage(0); + arena.eliminateUser(arena.getUser(player), false); + String dammagerUUID = event.getDamager().getCustomName(); if (!dammagerUUID.equalsIgnoreCase(player.getUniqueId().toString())) { int kills = 0; @@ -82,9 +85,6 @@ public void onPlayerDamageByEntity(EntityDamageByEntityEvent event) { achievements.checkAchievement(AchievementType.AMOUNT_KILLS, arena.getPlayerFromUUID(dammagerUUID)); } - - event.setDamage(0); - arena.eliminateUser(arena.getUser(player), false); } @EventHandler