diff --git a/.gitignore b/.gitignore index 36fe02146..81e05ca00 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,17 @@ zSotanna2 /.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments_1 /.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/write.lock /Pocket +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_ +/RemoteSystemsTempFiles +/.recommenders/caches + +target/ + +# IntelliJ IDEA Files +*.iml +.idea/ + +# Eclipse +.settings/ +.classpath +.project diff --git a/Patches/CraftBukkit-Patches/0177-Server-freezing-fix-fake-yaw-pitch.patch b/Patches/CraftBukkit-Patches/0177-Server-freezing-fix-fake-yaw-pitch.patch new file mode 100644 index 000000000..a7bd7eef1 --- /dev/null +++ b/Patches/CraftBukkit-Patches/0177-Server-freezing-fix-fake-yaw-pitch.patch @@ -0,0 +1,68 @@ +From 3b4526267e3bd53d9e70578ec1c7a8cd13038e73 Mon Sep 17 00:00:00 2001 +From: libraryaddict +Date: Fri, 27 Nov 2015 22:26:34 +1300 +Subject: [PATCH] Server freezing, fix fake yaw/pitch + + +diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java +index 7165579..4f366da 100644 +--- a/src/main/java/net/minecraft/server/Entity.java ++++ b/src/main/java/net/minecraft/server/Entity.java +@@ -5,6 +5,7 @@ import java.util.List; + import java.util.Random; + import java.util.UUID; + import java.util.concurrent.Callable; ++import com.google.common.primitives.Doubles; + + // CraftBukkit start + import org.bukkit.Bukkit; +@@ -153,6 +154,12 @@ public abstract class Entity implements ICommandListener { + public void setFakeHead(boolean fakeHead) + { + _fakeHead = fakeHead; ++ ++ if (!isFakeHead()) ++ { ++ this.fakeYaw = yaw; ++ this.fakePitch = pitch; ++ } + } + + public boolean isSilent() +@@ -1024,9 +1031,18 @@ public abstract class Entity implements ICommandListener { + this.lastX = this.locX = d0; + this.lastY = this.locY = d1; + this.lastZ = this.locZ = d2; +- this.lastYaw = this.yaw = fakeYaw = f; +- this.lastPitch = this.pitch = fakePitch = f1; ++ this.lastYaw = this.yaw = f; ++ this.lastPitch = this.pitch = f1; ++ ++ if (!isFakeHead()) ++ { ++ this.fakeYaw = yaw; ++ this.fakePitch = pitch; ++ } + ++ if (!Doubles.isFinite(locX) || !Doubles.isFinite(locY) || !Doubles.isFinite(locZ)) ++ Thread.dumpStack(); ++ + if (this instanceof EntityLiving) + ((EntityLiving) this).aK = f; + +diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java +index 5edef3e..d3b1586 100644 +--- a/src/main/java/net/minecraft/server/PlayerConnection.java ++++ b/src/main/java/net/minecraft/server/PlayerConnection.java +@@ -208,7 +208,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList + + public void a(PacketPlayInFlying packetplayinflying) { + PlayerConnectionUtils.ensureMainThread(packetplayinflying, this, this.player.u()); +- if (this.b(packetplayinflying)) { ++ if (this.b(packetplayinflying) || !Doubles.isFinite(player.locX) || !Doubles.isFinite(player.locY) || !Doubles.isFinite(player.locZ)) { + this.disconnect("Invalid move packet received"); + } else { + WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); +-- +1.9.5.msysgit.0 + diff --git a/Patches/CraftBukkit-Patches/0178-Sound-and-vehicle-fixes.patch b/Patches/CraftBukkit-Patches/0178-Sound-and-vehicle-fixes.patch new file mode 100644 index 000000000..db2d14f2d --- /dev/null +++ b/Patches/CraftBukkit-Patches/0178-Sound-and-vehicle-fixes.patch @@ -0,0 +1,47 @@ +From 2522a926e6cc670f4f10657ea5494b5ffe81eb37 Mon Sep 17 00:00:00 2001 +From: libraryaddict +Date: Tue, 12 Jan 2016 19:56:07 +1300 +Subject: [PATCH] Sound and vehicle fixes + + +diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java +index 4f366da..fc9cce0 100644 +--- a/src/main/java/net/minecraft/server/Entity.java ++++ b/src/main/java/net/minecraft/server/Entity.java +@@ -1628,11 +1628,13 @@ public abstract class Entity implements ICommandListener { + EntityDismountEvent exitEvent1 = null; + if (this.vehicle != null) { + if ((this.bukkitEntity instanceof LivingEntity) && (entity.getBukkitEntity() instanceof Vehicle)) ++ { + exitEvent = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity); +- pluginManager.callEvent(exitEvent); ++ pluginManager.callEvent(exitEvent); + +- if (exitEvent.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) { +- return; ++ if (exitEvent.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) { ++ return; ++ } + } + + exitEvent1 = new EntityDismountEvent(this.vehicle.getBukkitEntity(), this.bukkitEntity); +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java +index 0cc8f9b..dd07600 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java +@@ -14,9 +14,9 @@ public class CraftSound { + set(AMBIENCE_RAIN, "ambient.weather.rain"); + set(AMBIENCE_THUNDER, "ambient.weather.thunder"); + // Damage +- set(HURT_FLESH, "game.neutral.hurt"); +- set(FALL_BIG, "game.neutral.hurt.fall.big"); +- set(FALL_SMALL, "game.neutral.hurt.fall.small"); ++ set(HURT_FLESH, "game.player.hurt"); ++ set(FALL_BIG, "game.player.hurt.fall.big"); ++ set(FALL_SMALL, "game.player.hurt.fall.small"); + // Dig Sounds + set(DIG_WOOL, "dig.cloth"); + set(DIG_GRASS, "dig.grass"); +-- +1.9.5.msysgit.0 + diff --git a/Patches/CraftBukkit-Patches/0179-md_5-s-player-interaction-for-specs-patch.patch b/Patches/CraftBukkit-Patches/0179-md_5-s-player-interaction-for-specs-patch.patch new file mode 100644 index 000000000..8ef283ea6 --- /dev/null +++ b/Patches/CraftBukkit-Patches/0179-md_5-s-player-interaction-for-specs-patch.patch @@ -0,0 +1,31 @@ +From 3d0c2e6b1409ca0c42b7aafbffae4b517d7db48c Mon Sep 17 00:00:00 2001 +From: libraryaddict +Date: Fri, 29 Jan 2016 16:59:00 +1300 +Subject: [PATCH] md_5's player interaction for specs patch + + +diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java +index d3b1586..6fd49b3 100644 +--- a/src/main/java/net/minecraft/server/PlayerConnection.java ++++ b/src/main/java/net/minecraft/server/PlayerConnection.java +@@ -1206,6 +1206,17 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList + if (movingobjectposition == null || movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) { + CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand()); + } ++ // Spigot start ++ else if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.BLOCK ++ && (player.playerInteractManager.getGameMode() == WorldSettings.EnumGamemode.ADVENTURE || player.playerInteractManager.getGameMode() == WorldSettings.EnumGamemode.SPECTATOR)) { ++ // RIGHT_CLICK_BLOCK sets this flag ++ if (player.playerInteractManager.firedInteract) { ++ player.playerInteractManager.firedInteract = false; ++ } else { ++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, movingobjectposition.a(), movingobjectposition.direction, player.inventory.getItemInHand(), true); ++ } ++ } ++ // Spigot end + + // Arm swing animation + PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer()); +-- +1.9.5.msysgit.0 + diff --git a/Patches/CraftBukkit-Patches/0180-Fix-enderman-teleporting-when-vegetated.patch b/Patches/CraftBukkit-Patches/0180-Fix-enderman-teleporting-when-vegetated.patch new file mode 100644 index 000000000..dc539b4a4 --- /dev/null +++ b/Patches/CraftBukkit-Patches/0180-Fix-enderman-teleporting-when-vegetated.patch @@ -0,0 +1,25 @@ +From c0e8d43f419d7f489cd0ae348618f897e95b0402 Mon Sep 17 00:00:00 2001 +From: libraryaddict +Date: Fri, 29 Jan 2016 16:59:12 +1300 +Subject: [PATCH] Fix enderman teleporting when vegetated + + +diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java +index a250062..5ad2d07 100644 +--- a/src/main/java/net/minecraft/server/EntityEnderman.java ++++ b/src/main/java/net/minecraft/server/EntityEnderman.java +@@ -157,6 +157,11 @@ public class EntityEnderman extends EntityMonster { + } + + protected boolean k(double d0, double d1, double d2) { ++ if (isVegetated()) ++ { ++ return false; ++ } ++ + double d3 = this.locX; + double d4 = this.locY; + double d5 = this.locZ; +-- +1.9.5.msysgit.0 + diff --git a/Plugins/.idea/.name b/Plugins/.idea/.name deleted file mode 100644 index 179eb2ecc..000000000 --- a/Plugins/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -Mineplex \ No newline at end of file diff --git a/Plugins/.idea/artifacts/Mineplex_Bungee_Mineplexer_jar.xml b/Plugins/.idea/artifacts/Mineplex_Bungee_Mineplexer_jar.xml deleted file mode 100644 index dddcd68e4..000000000 --- a/Plugins/.idea/artifacts/Mineplex_Bungee_Mineplexer_jar.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - $PROJECT_DIR$/bin - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/artifacts/Mineplex_Bungee_Mineplexer_test.xml b/Plugins/.idea/artifacts/Mineplex_Bungee_Mineplexer_test.xml deleted file mode 100644 index 3febfc9cc..000000000 --- a/Plugins/.idea/artifacts/Mineplex_Bungee_Mineplexer_test.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - $PROJECT_DIR$/../Testing/Bungee/plugins - - - - - \ No newline at end of file diff --git a/Plugins/.idea/artifacts/Mineplex_Game_Clans_jar.xml b/Plugins/.idea/artifacts/Mineplex_Game_Clans_jar.xml deleted file mode 100644 index cc62eda71..000000000 --- a/Plugins/.idea/artifacts/Mineplex_Game_Clans_jar.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - $PROJECT_DIR$/bin - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/artifacts/Mineplex_Game_Clans_test.xml b/Plugins/.idea/artifacts/Mineplex_Game_Clans_test.xml deleted file mode 100644 index 99c131976..000000000 --- a/Plugins/.idea/artifacts/Mineplex_Game_Clans_test.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - $PROJECT_DIR$/../Testing/Clans/plugins - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/artifacts/Mineplex_Hub_jar.xml b/Plugins/.idea/artifacts/Mineplex_Hub_jar.xml deleted file mode 100644 index 8ac831c95..000000000 --- a/Plugins/.idea/artifacts/Mineplex_Hub_jar.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - $PROJECT_DIR$/bin - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/artifacts/Mineplex_Hub_test.xml b/Plugins/.idea/artifacts/Mineplex_Hub_test.xml deleted file mode 100644 index 0527ee7d4..000000000 --- a/Plugins/.idea/artifacts/Mineplex_Hub_test.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - $PROJECT_DIR$/../Testing/Hub/plugins - - - - - \ No newline at end of file diff --git a/Plugins/.idea/artifacts/Mineplex_MapParser_jar.xml b/Plugins/.idea/artifacts/Mineplex_MapParser_jar.xml deleted file mode 100644 index 84ebf306c..000000000 --- a/Plugins/.idea/artifacts/Mineplex_MapParser_jar.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - $PROJECT_DIR$/bin - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/artifacts/Mineplex_MapParser_test.xml b/Plugins/.idea/artifacts/Mineplex_MapParser_test.xml deleted file mode 100644 index ec67fdbc2..000000000 --- a/Plugins/.idea/artifacts/Mineplex_MapParser_test.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - $PROJECT_DIR$/../Testing/MapParser/plugins - - - - - \ No newline at end of file diff --git a/Plugins/.idea/artifacts/Mineplex_ServerMonitor_jar.xml b/Plugins/.idea/artifacts/Mineplex_ServerMonitor_jar.xml deleted file mode 100644 index 6dad4b8f3..000000000 --- a/Plugins/.idea/artifacts/Mineplex_ServerMonitor_jar.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - $PROJECT_DIR$/bin - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml b/Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml deleted file mode 100644 index 372114469..000000000 --- a/Plugins/.idea/artifacts/Mineplex_Votifier_jar.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - $PROJECT_DIR$/out/artifacts/ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml b/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml deleted file mode 100644 index 79c3170ce..000000000 --- a/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - $PROJECT_DIR$/bin - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/artifacts/Nautilus_Game_Arcade_test.xml b/Plugins/.idea/artifacts/Nautilus_Game_Arcade_test.xml deleted file mode 100644 index 8b3142e4c..000000000 --- a/Plugins/.idea/artifacts/Nautilus_Game_Arcade_test.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - $PROJECT_DIR$/../Testing/Arcade/plugins - - - - - \ No newline at end of file diff --git a/Plugins/.idea/codeStyleSettings.xml b/Plugins/.idea/codeStyleSettings.xml deleted file mode 100644 index f750af4b9..000000000 --- a/Plugins/.idea/codeStyleSettings.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/compiler.xml b/Plugins/.idea/compiler.xml deleted file mode 100644 index ec08cea77..000000000 --- a/Plugins/.idea/compiler.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/dataSources.xml b/Plugins/.idea/dataSources.xml deleted file mode 100644 index 3aa4d521d..000000000 --- a/Plugins/.idea/dataSources.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - mysql - true - com.mysql.jdbc.Driver - jdbc:mysql://db.mineplex.com:3306/Account - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/encodings.xml b/Plugins/.idea/encodings.xml deleted file mode 100644 index f75895965..000000000 --- a/Plugins/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/BungeeCord.xml b/Plugins/.idea/libraries/BungeeCord.xml deleted file mode 100644 index 0ac775186..000000000 --- a/Plugins/.idea/libraries/BungeeCord.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/NoCheatPlus.xml b/Plugins/.idea/libraries/NoCheatPlus.xml deleted file mode 100644 index 92bd59440..000000000 --- a/Plugins/.idea/libraries/NoCheatPlus.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/commons_codec.xml b/Plugins/.idea/libraries/commons_codec.xml deleted file mode 100644 index 0fad66459..000000000 --- a/Plugins/.idea/libraries/commons_codec.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/commons_dbcp2.xml b/Plugins/.idea/libraries/commons_dbcp2.xml deleted file mode 100644 index 2985dea2c..000000000 --- a/Plugins/.idea/libraries/commons_dbcp2.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/commons_io.xml b/Plugins/.idea/libraries/commons_io.xml deleted file mode 100644 index fd63b1467..000000000 --- a/Plugins/.idea/libraries/commons_io.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/commons_logging.xml b/Plugins/.idea/libraries/commons_logging.xml deleted file mode 100644 index 15f402d2f..000000000 --- a/Plugins/.idea/libraries/commons_logging.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/commons_pool2.xml b/Plugins/.idea/libraries/commons_pool2.xml deleted file mode 100644 index 1f63d0077..000000000 --- a/Plugins/.idea/libraries/commons_pool2.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/craftbukkit.xml b/Plugins/.idea/libraries/craftbukkit.xml deleted file mode 100644 index 757400be0..000000000 --- a/Plugins/.idea/libraries/craftbukkit.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/gson.xml b/Plugins/.idea/libraries/gson.xml deleted file mode 100644 index c235da675..000000000 --- a/Plugins/.idea/libraries/gson.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/httpclient.xml b/Plugins/.idea/libraries/httpclient.xml deleted file mode 100644 index 6fd5de945..000000000 --- a/Plugins/.idea/libraries/httpclient.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/httpcore.xml b/Plugins/.idea/libraries/httpcore.xml deleted file mode 100644 index 9ea23f380..000000000 --- a/Plugins/.idea/libraries/httpcore.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/jedis.xml b/Plugins/.idea/libraries/jedis.xml deleted file mode 100644 index c215cf0ed..000000000 --- a/Plugins/.idea/libraries/jedis.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/jooq.xml b/Plugins/.idea/libraries/jooq.xml deleted file mode 100644 index 77a1232b0..000000000 --- a/Plugins/.idea/libraries/jooq.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/jooq_codegen.xml b/Plugins/.idea/libraries/jooq_codegen.xml deleted file mode 100644 index 06b90a890..000000000 --- a/Plugins/.idea/libraries/jooq_codegen.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/libraries/mysql_connector.xml b/Plugins/.idea/libraries/mysql_connector.xml deleted file mode 100644 index 34f02f1ee..000000000 --- a/Plugins/.idea/libraries/mysql_connector.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/misc.xml b/Plugins/.idea/misc.xml deleted file mode 100644 index 0f016238b..000000000 --- a/Plugins/.idea/misc.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/modules.xml b/Plugins/.idea/modules.xml deleted file mode 100644 index c3f549fab..000000000 --- a/Plugins/.idea/modules.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/.idea/runConfigurations/Arcade.xml b/Plugins/.idea/runConfigurations/Arcade.xml deleted file mode 100644 index f57362a28..000000000 --- a/Plugins/.idea/runConfigurations/Arcade.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Plugins/.idea/runConfigurations/Bungee.xml b/Plugins/.idea/runConfigurations/Bungee.xml deleted file mode 100644 index 5c4651df7..000000000 --- a/Plugins/.idea/runConfigurations/Bungee.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Plugins/.idea/runConfigurations/Clans.xml b/Plugins/.idea/runConfigurations/Clans.xml deleted file mode 100644 index 7ffd70d27..000000000 --- a/Plugins/.idea/runConfigurations/Clans.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Plugins/.idea/runConfigurations/Database.xml b/Plugins/.idea/runConfigurations/Database.xml deleted file mode 100644 index 434e772ba..000000000 --- a/Plugins/.idea/runConfigurations/Database.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Plugins/.idea/runConfigurations/Hub.xml b/Plugins/.idea/runConfigurations/Hub.xml deleted file mode 100644 index 031f03cce..000000000 --- a/Plugins/.idea/runConfigurations/Hub.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Plugins/.idea/runConfigurations/MapParser.xml b/Plugins/.idea/runConfigurations/MapParser.xml deleted file mode 100644 index 85f2a671e..000000000 --- a/Plugins/.idea/runConfigurations/MapParser.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Plugins/.idea/scopes/scope_settings.xml b/Plugins/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b84..000000000 --- a/Plugins/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/Plugins/.idea/uiDesigner.xml b/Plugins/.idea/uiDesigner.xml deleted file mode 100644 index 3b0002030..000000000 --- a/Plugins/.idea/uiDesigner.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Plugins/.idea/vcs.xml b/Plugins/.idea/vcs.xml deleted file mode 100644 index 21cbaa607..000000000 --- a/Plugins/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Plugins/BuildFiles/EnjinTranslator.xml b/Plugins/BuildFiles/EnjinTranslator.xml deleted file mode 100644 index 6cd7bf62d..000000000 --- a/Plugins/BuildFiles/EnjinTranslator.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/BuildFiles/common.xml b/Plugins/BuildFiles/common.xml deleted file mode 100644 index 234d9f195..000000000 --- a/Plugins/BuildFiles/common.xml +++ /dev/null @@ -1,540 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/Classpath.Dummy/Classpath.Dummy.iml b/Plugins/Classpath.Dummy/Classpath.Dummy.iml deleted file mode 100644 index 62272ae21..000000000 --- a/Plugins/Classpath.Dummy/Classpath.Dummy.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/JedisTest/JedisTest.iml b/Plugins/JedisTest/JedisTest.iml deleted file mode 100644 index c47b983ea..000000000 --- a/Plugins/JedisTest/JedisTest.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/Main.java b/Plugins/JedisTest/src/ca/phinary/jedistest/Main.java deleted file mode 100644 index de4481d4b..000000000 --- a/Plugins/JedisTest/src/ca/phinary/jedistest/Main.java +++ /dev/null @@ -1,93 +0,0 @@ -package ca.phinary.jedistest; - -import javax.swing.*; - -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; - -import ca.phinary.jedistest.gui.ChatFrame; -import ca.phinary.jedistest.model.JedisChat; - -public class Main -{ - public static void main(String[] args) - { - SwingUtilities.invokeLater(new Runnable() - { - @Override - public void run() - { - try - { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } - catch (ClassNotFoundException e) - { - e.printStackTrace(); - } - catch (InstantiationException e) - { - e.printStackTrace(); - } - catch (IllegalAccessException e) - { - e.printStackTrace(); - } - catch (UnsupportedLookAndFeelException e) - { - e.printStackTrace(); - } - - ChatFrame chatFrame = new ChatFrame(); - final JedisChat jedisChat = new JedisChat(chatFrame, "phinaryTest", "10.33.53.16", 6379); - - chatFrame.addWindowListener(new WindowListener() - { - @Override - public void windowOpened(WindowEvent e) - { - - } - - @Override - public void windowClosing(WindowEvent e) - { - - } - - @Override - public void windowClosed(WindowEvent e) - { - jedisChat.close(); - } - - @Override - public void windowIconified(WindowEvent e) - { - - } - - @Override - public void windowDeiconified(WindowEvent e) - { - - } - - @Override - public void windowActivated(WindowEvent e) - { - - } - - @Override - public void windowDeactivated(WindowEvent e) - { - - } - }); - } - }); - - } - -} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/api/Chat.java b/Plugins/JedisTest/src/ca/phinary/jedistest/api/Chat.java deleted file mode 100644 index adfee2df0..000000000 --- a/Plugins/JedisTest/src/ca/phinary/jedistest/api/Chat.java +++ /dev/null @@ -1,8 +0,0 @@ -package ca.phinary.jedistest.api; - -public interface Chat -{ - public void addListener(ChatListener chatListener); - - public void clearListeners(); -} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/api/ChatListener.java b/Plugins/JedisTest/src/ca/phinary/jedistest/api/ChatListener.java deleted file mode 100644 index d650ac563..000000000 --- a/Plugins/JedisTest/src/ca/phinary/jedistest/api/ChatListener.java +++ /dev/null @@ -1,6 +0,0 @@ -package ca.phinary.jedistest.api; - -public interface ChatListener -{ - public void onChat(String message); -} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/api/Console.java b/Plugins/JedisTest/src/ca/phinary/jedistest/api/Console.java deleted file mode 100644 index fa899383f..000000000 --- a/Plugins/JedisTest/src/ca/phinary/jedistest/api/Console.java +++ /dev/null @@ -1,6 +0,0 @@ -package ca.phinary.jedistest.api; - -public interface Console -{ - public void println(String line); -} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/api/Messenger.java b/Plugins/JedisTest/src/ca/phinary/jedistest/api/Messenger.java deleted file mode 100644 index bf94b9e42..000000000 --- a/Plugins/JedisTest/src/ca/phinary/jedistest/api/Messenger.java +++ /dev/null @@ -1,9 +0,0 @@ -package ca.phinary.jedistest.api; - -public interface Messenger -{ - public Chat getChat(); - - public Console getConsole(); - -} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ChatFrame.java b/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ChatFrame.java deleted file mode 100644 index 7ae888aa6..000000000 --- a/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ChatFrame.java +++ /dev/null @@ -1,42 +0,0 @@ -package ca.phinary.jedistest.gui; - -import javax.swing.*; - -import java.awt.*; - -import ca.phinary.jedistest.api.Chat; -import ca.phinary.jedistest.api.Console; -import ca.phinary.jedistest.api.Messenger; - -public class ChatFrame extends JFrame implements Messenger -{ - private ConsolePane _console; - private ChatPane _chat; - - public ChatFrame() - { - setLayout(new BorderLayout()); - - _console = new ConsolePane(); - _chat = new ChatPane(this); - - add(_console, BorderLayout.CENTER); - add(_chat, BorderLayout.SOUTH); - - setTitle("Phinary's Redis Chat"); - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - pack(); - setLocationRelativeTo(null); - setVisible(true); - } - - public Console getConsole() - { - return _console; - } - - public Chat getChat() - { - return _chat; - } -} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ChatPane.java b/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ChatPane.java deleted file mode 100644 index 8234bff85..000000000 --- a/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ChatPane.java +++ /dev/null @@ -1,60 +0,0 @@ -package ca.phinary.jedistest.gui; - -import javax.swing.*; -import javax.swing.border.Border; -import javax.swing.border.EmptyBorder; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; - -import ca.phinary.jedistest.api.Chat; -import ca.phinary.jedistest.api.ChatListener; - -public class ChatPane extends JPanel implements ActionListener, Chat -{ - private ArrayList _chatListeners; - - private JTextField _textField; - private JButton _sendButton; - - public ChatPane(JFrame frame) - { - _chatListeners = new ArrayList(); - - _textField = new JTextField(); - _sendButton = new JButton("Send"); - - setBorder(new EmptyBorder(5, 10, 5, 10)); - setLayout(new BorderLayout()); - - add(_textField, BorderLayout.CENTER); - add(_sendButton, BorderLayout.EAST); - - _sendButton.addActionListener(this); - frame.getRootPane().setDefaultButton(_sendButton); - } - - @Override - public void actionPerformed(ActionEvent e) - { - String text = _textField.getText(); - for (ChatListener listener : _chatListeners) - { - listener.onChat(text); - } - _textField.setText(""); - } - - @Override - public void addListener(ChatListener chatListener) - { - _chatListeners.add(chatListener); - } - - @Override - public void clearListeners() - { - _chatListeners.clear(); - } -} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ConsolePane.java b/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ConsolePane.java deleted file mode 100644 index 2fb0293c3..000000000 --- a/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ConsolePane.java +++ /dev/null @@ -1,33 +0,0 @@ -package ca.phinary.jedistest.gui; - -import javax.swing.*; -import javax.swing.border.TitledBorder; -import java.awt.*; - -import ca.phinary.jedistest.api.Console; - -public class ConsolePane extends JPanel implements Console -{ - private JScrollPane _scrollPane; - private JTextArea _textArea; - - public ConsolePane() - { - _textArea = new JTextArea(); - _textArea.setEditable(false); - _textArea.setPreferredSize(new Dimension(800, 400)); - _scrollPane = new JScrollPane(_textArea); - _scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); - - setLayout(new BorderLayout()); - setBorder(new TitledBorder("Console")); - - add(_scrollPane, BorderLayout.CENTER); - } - - public synchronized void println(String line) - { - _textArea.append(line + "\n"); - } - -} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisChat.java b/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisChat.java deleted file mode 100644 index ff37cdf67..000000000 --- a/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisChat.java +++ /dev/null @@ -1,51 +0,0 @@ -package ca.phinary.jedistest.model; - -import ca.phinary.jedistest.api.Messenger; -import redis.clients.jedis.Jedis; -import redis.clients.jedis.JedisPool; -import redis.clients.jedis.JedisPoolConfig; - -public class JedisChat -{ - private JedisPool _jedisPool; - private String _channel; - - private Messenger _messenger; - private JedisPublisher _publisher; - - public JedisChat(Messenger messenger, final String channel, String host, int port) - { - _jedisPool = new JedisPool(new JedisPoolConfig(), host, port); - _channel = channel; - _messenger = messenger; - - _publisher = new JedisPublisher(messenger.getConsole(), _jedisPool, channel); - _messenger.getChat().addListener(_publisher); - - startListen(); - } - - public void startListen() - { - _messenger.getConsole().println("Attempting to connect to redis server..."); - try - { - final Jedis jedis = _jedisPool.getResource(); - - _messenger.getConsole().println("Successfully connected!"); - - SubscribeWorker worker = new SubscribeWorker(_messenger.getConsole(), _jedisPool, _channel); - worker.execute(); - - } catch (Exception e) - { - _messenger.getConsole().println("Failed to connect to redis server!"); - } - } - - public void close() - { - System.out.println("close"); - _publisher.close(); - } -} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisPublisher.java b/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisPublisher.java deleted file mode 100644 index 445c338f3..000000000 --- a/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisPublisher.java +++ /dev/null @@ -1,93 +0,0 @@ -package ca.phinary.jedistest.model; - -import javax.swing.*; -import java.net.InetAddress; -import java.util.List; - -import ca.phinary.jedistest.api.ChatListener; -import ca.phinary.jedistest.api.Console; -import redis.clients.jedis.JedisPool; - -public class JedisPublisher implements ChatListener -{ - private Console _console; - private JedisPool _jedisPool; - private String _channelName; - - public JedisPublisher(Console console, JedisPool jedisPool, String channelName) - { - _console = console; - _jedisPool = jedisPool; - _channelName = channelName; - - sendConnectMessage(); - } - - @Override - public void onChat(String message) - { - String hostName = "Unknown"; - - try - { - hostName = InetAddress.getLocalHost().toString(); - } - catch(Exception e) { }; - - message(hostName + " > " + message); - } - - private void sendConnectMessage() - { - String hostName = "Unknown"; - - try - { - hostName = InetAddress.getLocalHost().toString(); - } - catch(Exception e) { }; - - message(hostName + " has connected to the channel"); - } - - public void close() - { - String hostName = "Unknown"; - - try - { - hostName = InetAddress.getLocalHost().toString(); - } - catch(Exception e) { }; - - - message(hostName + " has disconnected from the channel"); - } - - private void message(final String text) - { - new SwingWorker() - { - @Override - protected Void doInBackground() throws Exception - { - try - { - _jedisPool.getResource().publish(_channelName, text); - } - catch (Exception e) - { - publish("Failed to send message: " + e.getMessage()); - } - return null; - } - - @Override - protected void process(List chunks) - { - for (String s : chunks) - _console.println(s); - } - }.execute(); - } -} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisSubscriber.java b/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisSubscriber.java deleted file mode 100644 index a1df8dedd..000000000 --- a/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisSubscriber.java +++ /dev/null @@ -1,49 +0,0 @@ -package ca.phinary.jedistest.model; - -import redis.clients.jedis.JedisPubSub; - -public class JedisSubscriber extends JedisPubSub -{ - private SubscribeWorker _jedisWorker; - - public JedisSubscriber(SubscribeWorker jedisWorker) - { - _jedisWorker = jedisWorker; - } - - @Override - public void onMessage(String channel, String message) - { - _jedisWorker.onMessage(message); - } - - @Override - public void onPMessage(String s, String s1, String s2) - { - System.out.println("Pmessage:" + s + " " + s1 + " " + s2); - } - - @Override - public void onSubscribe(String s, int i) - { - System.out.println("Subcribe: s " + i); - } - - @Override - public void onUnsubscribe(String s, int i) - { - System.out.println("UnSubcribe: s " + i); - } - - @Override - public void onPUnsubscribe(String s, int i) - { - System.out.println("PUnSubcribe: s " + i); - } - - @Override - public void onPSubscribe(String s, int i) - { - System.out.println("Subcribe: s " + i); - } -} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/model/SubscribeWorker.java b/Plugins/JedisTest/src/ca/phinary/jedistest/model/SubscribeWorker.java deleted file mode 100644 index 27b159657..000000000 --- a/Plugins/JedisTest/src/ca/phinary/jedistest/model/SubscribeWorker.java +++ /dev/null @@ -1,56 +0,0 @@ -package ca.phinary.jedistest.model; - -import javax.swing.*; - -import java.util.List; - -import ca.phinary.jedistest.api.Console; -import redis.clients.jedis.Jedis; -import redis.clients.jedis.JedisPool; - -public class SubscribeWorker extends SwingWorker -{ - private Console _console; - private JedisPool _jedisPool; - private JedisSubscriber _jedisSubscriber; - private String _channel; - - public SubscribeWorker(Console console, JedisPool jedisPool, String channel) - { - _console = console; - _jedisPool = jedisPool; - _jedisSubscriber = new JedisSubscriber(this); - _channel = channel; - } - - @Override - protected Void doInBackground() throws Exception - { - publish("Attempting to connect to channel: " + _channel); - try - { - Jedis j = _jedisPool.getResource(); - publish("Successfully connected to channel!"); - _jedisPool.getResource().subscribe(_jedisSubscriber, _channel); - } catch (Exception e) - { - publish("Connection to channel failed:" + e.getMessage()); - } - - return null; - } - - public void onMessage(String s) - { - publish(s); - } - - @Override - protected void process(List chunks) - { - for (String s : chunks) - { - _console.println(s); - } - } -} diff --git a/Plugins/Libraries/BungeeCord.jar b/Plugins/Libraries/BungeeCord.jar deleted file mode 100644 index 895238443..000000000 Binary files a/Plugins/Libraries/BungeeCord.jar and /dev/null differ diff --git a/Plugins/Libraries/NoCheatPlus.jar b/Plugins/Libraries/NoCheatPlus.jar deleted file mode 100644 index 8f367f996..000000000 Binary files a/Plugins/Libraries/NoCheatPlus.jar and /dev/null differ diff --git a/Plugins/Libraries/TerrainControl.jar b/Plugins/Libraries/TerrainControl.jar deleted file mode 100644 index e023e8be7..000000000 Binary files a/Plugins/Libraries/TerrainControl.jar and /dev/null differ diff --git a/Plugins/Libraries/Votifier.jar b/Plugins/Libraries/Votifier.jar deleted file mode 100644 index 9751f180a..000000000 Binary files a/Plugins/Libraries/Votifier.jar and /dev/null differ diff --git a/Plugins/Libraries/bcprov-jdk15on-147.jar b/Plugins/Libraries/bcprov-jdk15on-147.jar deleted file mode 100644 index 0b80922e6..000000000 Binary files a/Plugins/Libraries/bcprov-jdk15on-147.jar and /dev/null differ diff --git a/Plugins/Libraries/bukkit.jar b/Plugins/Libraries/bukkit.jar deleted file mode 100644 index 460e80d24..000000000 Binary files a/Plugins/Libraries/bukkit.jar and /dev/null differ diff --git a/Plugins/Libraries/commons-codec-1.6.jar b/Plugins/Libraries/commons-codec-1.6.jar deleted file mode 100644 index ee1bc49ac..000000000 Binary files a/Plugins/Libraries/commons-codec-1.6.jar and /dev/null differ diff --git a/Plugins/Libraries/commons-dbcp2-2.0.1.jar b/Plugins/Libraries/commons-dbcp2-2.0.1.jar deleted file mode 100644 index 5e8d142dd..000000000 Binary files a/Plugins/Libraries/commons-dbcp2-2.0.1.jar and /dev/null differ diff --git a/Plugins/Libraries/commons-io-2.4.jar b/Plugins/Libraries/commons-io-2.4.jar deleted file mode 100644 index 90035a4fe..000000000 Binary files a/Plugins/Libraries/commons-io-2.4.jar and /dev/null differ diff --git a/Plugins/Libraries/commons-lang3-3.1.jar b/Plugins/Libraries/commons-lang3-3.1.jar deleted file mode 100644 index a85e539b1..000000000 Binary files a/Plugins/Libraries/commons-lang3-3.1.jar and /dev/null differ diff --git a/Plugins/Libraries/commons-logging-1.1.1.jar b/Plugins/Libraries/commons-logging-1.1.1.jar deleted file mode 100644 index 1deef144c..000000000 Binary files a/Plugins/Libraries/commons-logging-1.1.1.jar and /dev/null differ diff --git a/Plugins/Libraries/commons-pool2-2.2.jar b/Plugins/Libraries/commons-pool2-2.2.jar deleted file mode 100644 index 6a3eb38ac..000000000 Binary files a/Plugins/Libraries/commons-pool2-2.2.jar and /dev/null differ diff --git a/Plugins/Libraries/craftbukkit.jar b/Plugins/Libraries/craftbukkit.jar index a585cf020..c7cb7fa92 100644 Binary files a/Plugins/Libraries/craftbukkit.jar and b/Plugins/Libraries/craftbukkit.jar differ diff --git a/Plugins/Libraries/cxf-bundle-2.7.16.jar b/Plugins/Libraries/cxf-bundle-2.7.16.jar deleted file mode 100644 index 3c1182633..000000000 Binary files a/Plugins/Libraries/cxf-bundle-2.7.16.jar and /dev/null differ diff --git a/Plugins/Libraries/cxf-bundle-2.7.2.jar b/Plugins/Libraries/cxf-bundle-2.7.2.jar deleted file mode 100644 index e94b68339..000000000 Binary files a/Plugins/Libraries/cxf-bundle-2.7.2.jar and /dev/null differ diff --git a/Plugins/Libraries/cxf-rt-ws-policy-2.7.2.jar b/Plugins/Libraries/cxf-rt-ws-policy-2.7.2.jar deleted file mode 100644 index df3d2d646..000000000 Binary files a/Plugins/Libraries/cxf-rt-ws-policy-2.7.2.jar and /dev/null differ diff --git a/Plugins/Libraries/ebean-2.7.7.jar b/Plugins/Libraries/ebean-2.7.7.jar deleted file mode 100644 index 6232038f3..000000000 Binary files a/Plugins/Libraries/ebean-2.7.7.jar and /dev/null differ diff --git a/Plugins/Libraries/fluent-hc-4.2.jar b/Plugins/Libraries/fluent-hc-4.2.jar deleted file mode 100644 index 1f0e5d711..000000000 Binary files a/Plugins/Libraries/fluent-hc-4.2.jar and /dev/null differ diff --git a/Plugins/Libraries/gson-2.2.1.jar b/Plugins/Libraries/gson-2.2.1.jar deleted file mode 100644 index 93ac6d70b..000000000 Binary files a/Plugins/Libraries/gson-2.2.1.jar and /dev/null differ diff --git a/Plugins/Libraries/guava-r07.jar b/Plugins/Libraries/guava-r07.jar deleted file mode 100644 index 9ff5f8905..000000000 Binary files a/Plugins/Libraries/guava-r07.jar and /dev/null differ diff --git a/Plugins/Libraries/httpclient-4.2.jar b/Plugins/Libraries/httpclient-4.2.jar deleted file mode 100644 index 9e0df5098..000000000 Binary files a/Plugins/Libraries/httpclient-4.2.jar and /dev/null differ diff --git a/Plugins/Libraries/httpclient-cache-4.2.jar b/Plugins/Libraries/httpclient-cache-4.2.jar deleted file mode 100644 index a06f4bc66..000000000 Binary files a/Plugins/Libraries/httpclient-cache-4.2.jar and /dev/null differ diff --git a/Plugins/Libraries/httpcore-4.2.jar b/Plugins/Libraries/httpcore-4.2.jar deleted file mode 100644 index 20214eabd..000000000 Binary files a/Plugins/Libraries/httpcore-4.2.jar and /dev/null differ diff --git a/Plugins/Libraries/httpmime-4.2.jar b/Plugins/Libraries/httpmime-4.2.jar deleted file mode 100644 index 8cec2fc23..000000000 Binary files a/Plugins/Libraries/httpmime-4.2.jar and /dev/null differ diff --git a/Plugins/Libraries/jackson-annotations-2.5.0.jar b/Plugins/Libraries/jackson-annotations-2.5.0.jar deleted file mode 100644 index 62521310a..000000000 Binary files a/Plugins/Libraries/jackson-annotations-2.5.0.jar and /dev/null differ diff --git a/Plugins/Libraries/jackson-core-2.5.1.jar b/Plugins/Libraries/jackson-core-2.5.1.jar deleted file mode 100644 index 8c9c4e0e4..000000000 Binary files a/Plugins/Libraries/jackson-core-2.5.1.jar and /dev/null differ diff --git a/Plugins/Libraries/jackson-databind-2.5.1.jar b/Plugins/Libraries/jackson-databind-2.5.1.jar deleted file mode 100644 index 9b82e3fa5..000000000 Binary files a/Plugins/Libraries/jackson-databind-2.5.1.jar and /dev/null differ diff --git a/Plugins/Libraries/jansi-1.3.jar b/Plugins/Libraries/jansi-1.3.jar deleted file mode 100644 index 680d5758e..000000000 Binary files a/Plugins/Libraries/jansi-1.3.jar and /dev/null differ diff --git a/Plugins/Libraries/javax.mail.jar b/Plugins/Libraries/javax.mail.jar deleted file mode 100644 index ca7eca7d9..000000000 Binary files a/Plugins/Libraries/javax.mail.jar and /dev/null differ diff --git a/Plugins/Libraries/jedis-2.4.2.jar b/Plugins/Libraries/jedis-2.4.2.jar deleted file mode 100644 index 21fdcabf7..000000000 Binary files a/Plugins/Libraries/jedis-2.4.2.jar and /dev/null differ diff --git a/Plugins/Libraries/jersey-apache-client-1.19.jar b/Plugins/Libraries/jersey-apache-client-1.19.jar deleted file mode 100644 index ac11e75f7..000000000 Binary files a/Plugins/Libraries/jersey-apache-client-1.19.jar and /dev/null differ diff --git a/Plugins/Libraries/jersey-bundle-1.17.jar b/Plugins/Libraries/jersey-bundle-1.17.jar deleted file mode 100644 index f25c713ce..000000000 Binary files a/Plugins/Libraries/jersey-bundle-1.17.jar and /dev/null differ diff --git a/Plugins/Libraries/jersey-multipart-1.19.jar b/Plugins/Libraries/jersey-multipart-1.19.jar deleted file mode 100644 index 75d77090a..000000000 Binary files a/Plugins/Libraries/jersey-multipart-1.19.jar and /dev/null differ diff --git a/Plugins/Libraries/jline-2.6.jar b/Plugins/Libraries/jline-2.6.jar deleted file mode 100644 index 0e32654ff..000000000 Binary files a/Plugins/Libraries/jline-2.6.jar and /dev/null differ diff --git a/Plugins/Libraries/jooq-3.5.2-javadoc.jar b/Plugins/Libraries/jooq-3.5.2-javadoc.jar deleted file mode 100644 index 5ac17c5ae..000000000 Binary files a/Plugins/Libraries/jooq-3.5.2-javadoc.jar and /dev/null differ diff --git a/Plugins/Libraries/jooq-3.5.2-sources.jar b/Plugins/Libraries/jooq-3.5.2-sources.jar deleted file mode 100644 index e3248a62a..000000000 Binary files a/Plugins/Libraries/jooq-3.5.2-sources.jar and /dev/null differ diff --git a/Plugins/Libraries/jooq-3.5.2.jar b/Plugins/Libraries/jooq-3.5.2.jar deleted file mode 100644 index d5b87d85b..000000000 Binary files a/Plugins/Libraries/jooq-3.5.2.jar and /dev/null differ diff --git a/Plugins/Libraries/jooq-codegen-3.5.2.jar b/Plugins/Libraries/jooq-codegen-3.5.2.jar deleted file mode 100644 index 9d6c2f5ff..000000000 Binary files a/Plugins/Libraries/jooq-codegen-3.5.2.jar and /dev/null differ diff --git a/Plugins/Libraries/jooq-meta-3.5.2.jar b/Plugins/Libraries/jooq-meta-3.5.2.jar deleted file mode 100644 index 0ca368194..000000000 Binary files a/Plugins/Libraries/jooq-meta-3.5.2.jar and /dev/null differ diff --git a/Plugins/Libraries/jopt-simple-3.2.jar b/Plugins/Libraries/jopt-simple-3.2.jar deleted file mode 100644 index 563736216..000000000 Binary files a/Plugins/Libraries/jopt-simple-3.2.jar and /dev/null differ diff --git a/Plugins/Libraries/mysql-connector-java-5.1.32-bin.jar b/Plugins/Libraries/mysql-connector-java-5.1.32-bin.jar deleted file mode 100644 index 822b714e5..000000000 Binary files a/Plugins/Libraries/mysql-connector-java-5.1.32-bin.jar and /dev/null differ diff --git a/Plugins/Libraries/mysql.zip b/Plugins/Libraries/mysql.zip deleted file mode 100644 index 13f3b4c2a..000000000 Binary files a/Plugins/Libraries/mysql.zip and /dev/null differ diff --git a/Plugins/Libraries/org-apache-commons-lang.jar b/Plugins/Libraries/org-apache-commons-lang.jar deleted file mode 100644 index 5d0113f3a..000000000 Binary files a/Plugins/Libraries/org-apache-commons-lang.jar and /dev/null differ diff --git a/Plugins/Libraries/slf4j-api-1.7.10.jar b/Plugins/Libraries/slf4j-api-1.7.10.jar deleted file mode 100644 index ac7da374a..000000000 Binary files a/Plugins/Libraries/slf4j-api-1.7.10.jar and /dev/null differ diff --git a/Plugins/Libraries/snakeyaml-1.10.jar b/Plugins/Libraries/snakeyaml-1.10.jar deleted file mode 100644 index 75a4e7d43..000000000 Binary files a/Plugins/Libraries/snakeyaml-1.10.jar and /dev/null differ diff --git a/Plugins/Libraries/wss4j-1.6.9.jar b/Plugins/Libraries/wss4j-1.6.9.jar deleted file mode 100644 index 89b8febe1..000000000 Binary files a/Plugins/Libraries/wss4j-1.6.9.jar and /dev/null differ diff --git a/Plugins/Mineplex.Bungee.Mineplexer/.classpath b/Plugins/Mineplex.Bungee.Mineplexer/.classpath deleted file mode 100644 index c06b6c559..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/.classpath +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Bungee.Mineplexer/.externalToolBuilders/Mineplexer2.launch b/Plugins/Mineplex.Bungee.Mineplexer/.externalToolBuilders/Mineplexer2.launch deleted file mode 100644 index bab52abb3..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/.externalToolBuilders/Mineplexer2.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Bungee.Mineplexer/.project b/Plugins/Mineplex.Bungee.Mineplexer/.project deleted file mode 100644 index 414ef170a..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - Mineplex.Bungee.Mineplexer - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/Mineplexer2.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.Bungee.Mineplexer/.settings/org.eclipse.core.resources.prefs b/Plugins/Mineplex.Bungee.Mineplexer/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/Plugins/Mineplex.Bungee.Mineplexer/Mineplex.Bungee.Mineplexer.iml b/Plugins/Mineplex.Bungee.Mineplexer/Mineplex.Bungee.Mineplexer.iml deleted file mode 100644 index a1a0bd8bf..000000000 --- a/Plugins/Mineplex.Bungee.Mineplexer/Mineplex.Bungee.Mineplexer.iml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/Mineplex.Bungee.Mineplexer/pom.xml b/Plugins/Mineplex.Bungee.Mineplexer/pom.xml new file mode 100644 index 000000000..4b46f2b44 --- /dev/null +++ b/Plugins/Mineplex.Bungee.Mineplexer/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + + + com.mineplex + mineplex-plugin + dev-SNAPSHOT + ../plugin.xml + + + Mineplexer + mineplex-bungee-mineplexer + + + + ${project.groupId} + mineplex-cache + ${project.version} + + + ${project.groupId} + mineplex-serverdata + ${project.version} + + + commons-codec + commons-codec + + + net.md-5 + bungeecord-proxy + + + diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java index fadc89543..5f7153ae9 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java @@ -38,7 +38,7 @@ public class LobbyBalancer implements Listener, Runnable loadLobbyServers(); _plugin.getProxy().getPluginManager().registerListener(_plugin, this); - _plugin.getProxy().getScheduler().schedule(_plugin, this, 250L, 250L, TimeUnit.MILLISECONDS); + _plugin.getProxy().getScheduler().schedule(_plugin, this, 500L, 500L, TimeUnit.MILLISECONDS); } @EventHandler diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCount.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCount.java index 2b97f9b62..61767b81d 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCount.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCount.java @@ -36,7 +36,7 @@ public class PlayerCount implements Listener, Runnable _region = !new File("eu.dat").exists() ? Region.US : Region.EU; _plugin = plugin; - _plugin.getProxy().getScheduler().schedule(_plugin, this, 500L, 500L, TimeUnit.MILLISECONDS); + _plugin.getProxy().getScheduler().schedule(_plugin, this, 4L, 4L, TimeUnit.SECONDS); _plugin.getProxy().getPluginManager().registerListener(_plugin, this); _listenerInfo = _plugin.getProxy().getConfigurationAdapter().getListeners().iterator().next(); diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerJoinHandler.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerJoinHandler.java index 8e56dab88..36c4f37c8 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerJoinHandler.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerJoinHandler.java @@ -1,5 +1,6 @@ package mineplex.bungee.playerTracker; +import java.util.UUID; import mineplex.serverdata.commands.CommandCallback; import mineplex.serverdata.commands.PlayerJoinCommand; import mineplex.serverdata.commands.ServerCommand; @@ -21,7 +22,7 @@ public class PlayerJoinHandler implements CommandCallback { PlayerJoinCommand joinCommand = (PlayerJoinCommand)command; - _playerTracker.kickPlayerIfOnline(joinCommand.getUuid()); + _playerTracker.kickPlayerIfOnline(UUID.fromString(joinCommand.getUuid())); } } } diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java index 8d0a2cf99..a7b2d004e 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerTracker/PlayerTracker.java @@ -2,6 +2,7 @@ package mineplex.bungee.playerTracker; import java.io.File; import java.util.HashSet; +import java.util.Set; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -27,7 +28,7 @@ public class PlayerTracker implements Listener, Runnable // Repository storing player status' across network. private DataRepository _repository; - private HashSet _onlineUUIDs = new HashSet(); + private Set _onlineUUIDs = new HashSet<>(); private Plugin _plugin; @@ -76,32 +77,32 @@ public class PlayerTracker implements Listener, Runnable @EventHandler public void playerConnect(final PostLoginEvent event) { - _onlineUUIDs.add(event.getPlayer().getUniqueId().toString()); + _onlineUUIDs.add(event.getPlayer().getUniqueId()); } @Override public void run() { - HashSet onlineUUIDs = new HashSet(); + Set onlineUUIDs = new HashSet<>(); for (ProxiedPlayer player : _plugin.getProxy().getPlayers()) { - onlineUUIDs.add(player.getUniqueId().toString()); + onlineUUIDs.add(player.getUniqueId()); } _onlineUUIDs = onlineUUIDs; } - public boolean isPlayerOnline(String uuid) + public boolean isPlayerOnline(UUID uuid) { return _onlineUUIDs.contains(uuid); } - public void kickPlayerIfOnline(String uuid) + public void kickPlayerIfOnline(UUID uuid) { if (_onlineUUIDs.contains(uuid)) { - ProxiedPlayer player = _plugin.getProxy().getPlayer(UUID.fromString(uuid)); + ProxiedPlayer player = _plugin.getProxy().getPlayer(uuid); if (player != null) player.disconnect("You have logged in from another location."); diff --git a/Plugins/Mineplex.BungeeRotator/.classpath b/Plugins/Mineplex.BungeeRotator/.classpath deleted file mode 100644 index e952c3e6a..000000000 --- a/Plugins/Mineplex.BungeeRotator/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.BungeeRotator/.externalToolBuilders/BungeeRotator.launch b/Plugins/Mineplex.BungeeRotator/.externalToolBuilders/BungeeRotator.launch deleted file mode 100644 index 894d3947c..000000000 --- a/Plugins/Mineplex.BungeeRotator/.externalToolBuilders/BungeeRotator.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.BungeeRotator/.project b/Plugins/Mineplex.BungeeRotator/.project deleted file mode 100644 index 6378b1f50..000000000 --- a/Plugins/Mineplex.BungeeRotator/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - Mineplex.BungeeRotator - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/BungeeRotator.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.BungeeRotator/pom.xml b/Plugins/Mineplex.BungeeRotator/pom.xml new file mode 100644 index 000000000..7fff9dd5a --- /dev/null +++ b/Plugins/Mineplex.BungeeRotator/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + + com.mineplex + mineplex-app + dev-SNAPSHOT + ../app.xml + + + BungeeRotator + mineplex-bungeerotator + + + + ${project.groupId} + mineplex-serverdata + ${project.version} + + + org.apache.cxf + cxf-bundle + + + org.apache.ws.security + wss4j + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + mineplex.bungee.BungeeRotator + + + + + + + diff --git a/Plugins/Mineplex.Cache/.classpath b/Plugins/Mineplex.Cache/.classpath deleted file mode 100644 index e5ed569d5..000000000 --- a/Plugins/Mineplex.Cache/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Plugins/Mineplex.Cache/.project b/Plugins/Mineplex.Cache/.project deleted file mode 100644 index 5321c2157..000000000 --- a/Plugins/Mineplex.Cache/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - Mineplex.Cache - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.Cache/Mineplex.Cache.iml b/Plugins/Mineplex.Cache/Mineplex.Cache.iml deleted file mode 100644 index 54892e832..000000000 --- a/Plugins/Mineplex.Cache/Mineplex.Cache.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/Mineplex.Cache/pom.xml b/Plugins/Mineplex.Cache/pom.xml new file mode 100644 index 000000000..5a9cafabd --- /dev/null +++ b/Plugins/Mineplex.Cache/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + + com.mineplex + mineplex-parent + dev-SNAPSHOT + + + mineplex-cache + + + + ${project.groupId} + mineplex-serverdata + ${project.version} + + + diff --git a/Plugins/Mineplex.Cache/src/mineplex/cache/player/PlayerCache.java b/Plugins/Mineplex.Cache/src/mineplex/cache/player/PlayerCache.java index e83eabf74..3bfb1bf00 100644 --- a/Plugins/Mineplex.Cache/src/mineplex/cache/player/PlayerCache.java +++ b/Plugins/Mineplex.Cache/src/mineplex/cache/player/PlayerCache.java @@ -39,7 +39,7 @@ public class PlayerCache catch (Exception exception) { System.out.println("Error adding player info in PlayerCache : " + exception.getMessage()); - exception.printStackTrace(); +// exception.printStackTrace(); } } diff --git a/Plugins/Mineplex.ChestConverter/.classpath b/Plugins/Mineplex.ChestConverter/.classpath deleted file mode 100644 index 49e473eb4..000000000 --- a/Plugins/Mineplex.ChestConverter/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/Plugins/Mineplex.ChestConverter/.externalToolBuilders/Chest.launch b/Plugins/Mineplex.ChestConverter/.externalToolBuilders/Chest.launch deleted file mode 100644 index ecc42cfd7..000000000 --- a/Plugins/Mineplex.ChestConverter/.externalToolBuilders/Chest.launch +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.ChestConverter/.externalToolBuilders/New_Builder.launch b/Plugins/Mineplex.ChestConverter/.externalToolBuilders/New_Builder.launch deleted file mode 100644 index 0c6e0f696..000000000 --- a/Plugins/Mineplex.ChestConverter/.externalToolBuilders/New_Builder.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.ChestConverter/.externalToolBuilders/ServerMonitor.launch b/Plugins/Mineplex.ChestConverter/.externalToolBuilders/ServerMonitor.launch deleted file mode 100644 index d07871b9a..000000000 --- a/Plugins/Mineplex.ChestConverter/.externalToolBuilders/ServerMonitor.launch +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.ChestConverter/.project b/Plugins/Mineplex.ChestConverter/.project deleted file mode 100644 index d1d373e2c..000000000 --- a/Plugins/Mineplex.ChestConverter/.project +++ /dev/null @@ -1,37 +0,0 @@ - - - Mineplex.ChestConverter - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/ServerMonitor.launch - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/Chest.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.ChestConverter/.settings/org.eclipse.core.resources.prefs b/Plugins/Mineplex.ChestConverter/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/Plugins/Mineplex.ChestConverter/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/Plugins/Mineplex.ChestConverter/.settings/org.eclipse.jdt.core.prefs b/Plugins/Mineplex.ChestConverter/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7341ab168..000000000 --- a/Plugins/Mineplex.ChestConverter/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/Plugins/Mineplex.ChestConverter/Mineplex.ServerMonitor.iml b/Plugins/Mineplex.ChestConverter/Mineplex.ServerMonitor.iml deleted file mode 100644 index 53e69d8e1..000000000 --- a/Plugins/Mineplex.ChestConverter/Mineplex.ServerMonitor.iml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Core.Common/.classpath b/Plugins/Mineplex.Core.Common/.classpath deleted file mode 100644 index a028ce814..000000000 --- a/Plugins/Mineplex.Core.Common/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Plugins/Mineplex.Core.Common/.project b/Plugins/Mineplex.Core.Common/.project deleted file mode 100644 index 801869e42..000000000 --- a/Plugins/Mineplex.Core.Common/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - Mineplex.Core.Common - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.Core.Common/.settings/org.eclipse.core.resources.prefs b/Plugins/Mineplex.Core.Common/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/Plugins/Mineplex.Core.Common/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/Plugins/Mineplex.Core.Common/Mineplex.Core.Common.iml b/Plugins/Mineplex.Core.Common/Mineplex.Core.Common.iml deleted file mode 100644 index b59695f8a..000000000 --- a/Plugins/Mineplex.Core.Common/Mineplex.Core.Common.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/ascii.png b/Plugins/Mineplex.Core.Common/ascii.png similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/ascii.png rename to Plugins/Mineplex.Core.Common/ascii.png diff --git a/Plugins/Mineplex.Core.Common/pom.xml b/Plugins/Mineplex.Core.Common/pom.xml new file mode 100644 index 000000000..c2512a855 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + + com.mineplex + mineplex-parent + dev-SNAPSHOT + + + mineplex-core-common + + + + com.mineplex + spigot + + + + + + + + + ascii.png + + + + + diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index d76d2428e..2ecf63c1f 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -4,68 +4,86 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; public enum Rank { //Staff - LT("Leader", ChatColor.GOLD), - OWNER("Owner", ChatColor.GOLD), - DEVELOPER("Dev", ChatColor.GOLD), - ADMIN("Admin", ChatColor.GOLD), - JNR_DEV("Jr.Dev", ChatColor.GOLD), - SUPPORT("Support", ChatColor.BLUE), - SNR_MODERATOR("Sr.Mod", ChatColor.GOLD), - MODERATOR("Mod", ChatColor.GOLD), - HELPER("Trainee", ChatColor.DARK_AQUA), - MAPLEAD("MapLead", ChatColor.BLUE), - MAPDEV("Builder", ChatColor.BLUE), - MEDIA("Media", ChatColor.BLUE), - - EVENT("Event", ChatColor.WHITE), + LT("Leader", ChatColor.GOLD, "Leaders manage the operation of their respective team \nor projects. They usually operate on affairs within \nthe staff, development, or management team."), + OWNER("Owner", ChatColor.GOLD, "Owners are the founders of Mineplex. \nEach owner manages a different aspect of the \nserver and ensures its efficient operation."), + DEVELOPER("Dev", ChatColor.GOLD, "Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience."), + ADMIN("Admin", ChatColor.GOLD, "An Administrator’s role is to manage \ntheir respective Senior Moderator team \nand all moderators within it."), + JNR_DEV("Jr.Dev", ChatColor.GOLD, "Junior Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience."), + SUPPORT("Support", ChatColor.BLUE, "Support agents handle tickets and \nprovide customer service."), + CMOD("C.Mod", ChatColor.GOLD, "Clans Moderators are members of the Clans Management Senior Mod team. \nTheir duties include moderation and support within the Clans servers. \n\nFor assistance, contact them using " + F.elem("/a ") + "."), + SNR_MODERATOR("Sr.Mod", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + "."), + MODERATOR("Mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + "."), + HELPER("Trainee", ChatColor.DARK_AQUA, "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + "."), + MAPLEAD("MapLead", ChatColor.BLUE, "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders."), + MAPDEV("Builder", ChatColor.BLUE, "Builders are members of the Mineplex Build Team. \nThey create many of the maps used across Mineplex."), + MEDIA("Media", ChatColor.BLUE, "The Media rank is given to talented artists who are\n endorsed to create content for Mineplex."), + + EVENT("Event", ChatColor.WHITE, "A member of the official Mineplex Events team!"), //Media - YOUTUBE("YouTube", ChatColor.RED), - YOUTUBE_SMALL("YT", ChatColor.DARK_PURPLE), - TWITCH("Twitch", ChatColor.DARK_PURPLE), - + YOUTUBE("YouTube", ChatColor.RED, "A YouTuber who creates content for \nor related to Mineplex."), + YOUTUBE_SMALL("YT", ChatColor.DARK_PURPLE, "A YouTuber who creates content for \nor related to Mineplex. \n\nThey have fewer subscribers than full YouTubers."), + TWITCH("Twitch", ChatColor.DARK_PURPLE, "A Twitch streamer who often features \nMineplex in their streams."), + //Player - TITAN("Titan", ChatColor.RED, true), - LEGEND("Legend", ChatColor.GREEN, true), - HERO("Hero", ChatColor.LIGHT_PURPLE, true), - ULTRA("Ultra", ChatColor.AQUA, true), - ALL("", ChatColor.WHITE); + TITAN("Titan", ChatColor.RED, true, "Ancient myths spoke of a gigantic being \nwith immense power... \n\nPurchase Titan at www.mineplex.com/shop"), + LEGEND("Legend", ChatColor.GREEN, true, "Mineplex's third premium rank. \n\nPurchase Legend at www.mineplex.com/shop"), + HERO("Hero", ChatColor.LIGHT_PURPLE, true, "There are many stories of a \nvaliant Hero who was brave enough to \ntame the most fearsome dragon in the land. \n\nPurchase Hero at www.mineplex.com/shop"), + ULTRA("Ultra", ChatColor.AQUA, true, "Mineplex's first premium rank. \n\nPurchase Ultra at www.mineplex.com/shop"), + ALL("", ChatColor.WHITE, null); private ChatColor _color; private boolean _donor; - + private String _description; + public String Name; - - Rank(String name, ChatColor color) + + Rank(String name, ChatColor color, String description) { _color = color; Name = name; _donor = false; + _description = description; } - - Rank(String name, ChatColor color, boolean donor) + + Rank(String name, ChatColor color, boolean donor, String description) { _color = color; Name = name; _donor = donor; + _description = description; } - + + public String getDescription() + { + return _description; + } + + public String getRawTag() + { + if (Name.equalsIgnoreCase("ALL")) + return ""; + + return Name; + } + public boolean has(Rank rank) { return has(null, rank, false); } - - public boolean has(Player player, Rank rank, boolean inform) + + public boolean has(Player player, Rank rank, boolean inform) { return has(player, rank, null, inform); } - - public boolean has(Player player, Rank rank, Rank[] specific, boolean inform) + + public boolean has(Player player, Rank rank, Rank[] specific, boolean inform) { //Specific Rank if (specific != null) @@ -76,52 +94,44 @@ public enum Rank { return true; } - } + } } - + // if (compareTo(rank) <= 0) return true; - + if (inform) { - UtilPlayer.message(player, C.mHead + "Permissions> " + - C.mBody + "This requires Permission Rank [" + + UtilPlayer.message(player, C.mHead + "Permissions> " + + C.mBody + "This requires Permission Rank [" + C.mHead + rank.Name.toUpperCase() + C.mBody + "]."); } - + return false; } - + public String getTag(boolean bold, boolean uppercase) { if (Name.equalsIgnoreCase("ALL")) return ""; - + String name = Name; if (uppercase) name = Name.toUpperCase(); - + if (bold) return _color + C.Bold + name; else return _color + name; } - + public ChatColor getColor() { return _color; } - public boolean isDonor() + public boolean isDonor() { return _donor; } - - public String getRawTag() - { - if (Name.equalsIgnoreCase("ALL")) - return ""; - - return Name; - } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/ServerShutdownEvent.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/ServerShutdownEvent.java new file mode 100644 index 000000000..70bf8f99d --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/ServerShutdownEvent.java @@ -0,0 +1,33 @@ +package mineplex.core.common.events; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.plugin.java.JavaPlugin; + +public class ServerShutdownEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private JavaPlugin _plugin; + + public ServerShutdownEvent(JavaPlugin plugin) + { + _plugin = plugin; + } + + public JavaPlugin getPlugin() + { + return _plugin; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ColorFader.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ColorFader.java new file mode 100644 index 000000000..01143886b --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ColorFader.java @@ -0,0 +1,62 @@ +package mineplex.core.common.util; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +public class ColorFader { + + private final int _loopsBetween; + + private final List _colors; + private final LoopIterator _iterator; + private int _loopsSinceLast; + + public ColorFader(int loopsBetweenColors, RGBData... colors) + { + this(loopsBetweenColors, Arrays.asList(colors)); + } + + public ColorFader(int loopsBetweenColors, List colors) + { + _loopsBetween = loopsBetweenColors; + + _colors = new LinkedList<>(colors); + _iterator = new LoopIterator<>(_colors); + } + + public RGBData next() + { + RGBData rgb; + + if (_loopsSinceLast >= _loopsBetween) + { + rgb = _iterator.next(); + _loopsSinceLast = 0; + } + else + { + int redStep = (_iterator.peekNext().getFullRed() - _iterator.current().getFullRed()) / _loopsBetween; + int greenStep = (_iterator.peekNext().getFullGreen() - _iterator.current().getFullGreen()) / _loopsBetween; + int blueStep = (_iterator.peekNext().getFullBlue() - _iterator.current().getFullBlue()) / _loopsBetween; + + int red = _iterator.current().getFullRed(); + int green = _iterator.current().getFullGreen(); + int blue = _iterator.current().getFullBlue(); + + for (int i = 0; i < _loopsSinceLast; i++) + { + red += redStep; + green += greenStep; + blue += blueStep; + } + + rgb = new RGBData(red, green, blue); + } + + _loopsSinceLast++; + + return rgb; + } + +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java index fd2a34ec6..998b57d7c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java @@ -2,6 +2,8 @@ package mineplex.core.common.util; import mineplex.core.common.Rank; +import java.util.LinkedList; + import org.bukkit.ChatColor; public class F @@ -42,9 +44,9 @@ public class F return C.sysHead + head + "> " + C.sysBody + body; } - public static String elem(String elem) + public static String elem(Object elem) { - return C.mElem + elem + ChatColor.RESET + C.mBody; + return C.mElem + elem.toString() + ChatColor.RESET + C.mBody; } public static String name(String elem) @@ -198,5 +200,19 @@ public class F return out; } - + public static String vowelAN(String word) + { + return word.toLowerCase().startsWith("a") + || word.toLowerCase().startsWith("A") + || word.toLowerCase().startsWith("e") + || word.toLowerCase().startsWith("E") + || word.toLowerCase().startsWith("i") + || word.toLowerCase().startsWith("I") + || word.toLowerCase().startsWith("o") + || word.toLowerCase().startsWith("O") + || word.toLowerCase().startsWith("u") + || word.toLowerCase().startsWith("U") + ? "an" : "a"; + } + } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/LoopIterator.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/LoopIterator.java new file mode 100644 index 000000000..b5829a851 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/LoopIterator.java @@ -0,0 +1,83 @@ +package mineplex.core.common.util; + +import java.util.List; + +public class LoopIterator +{ + private List _list; + private int _pointer; + + public LoopIterator(List list) + { + _list = list; + } + + public T next() + { + if (_list.isEmpty()) + { + return null; + } + + if (++_pointer == _list.size()) + { + _pointer = 0; + } + + return _list.get(_pointer); + } + + public T peekNext() + { + if (_list.isEmpty()) + { + return null; + } + + int pointer = _pointer; + + if (++pointer == _list.size()) + { + pointer = 0; + } + + return _list.get(pointer); + } + + public T peekPrev() + { + if (_list.isEmpty()) + { + return null; + } + + int pointer = _pointer; + + if (--pointer < 0) + { + pointer = _list.size() - 1; + } + + return _list.get(pointer); + } + + public T prev() + { + if (_list.isEmpty()) + { + return null; + } + + if (--_pointer < 0) + { + _pointer = _list.size() - 1; + } + + return _list.get(_pointer); + } + + public T current() + { + return _list.get(_pointer); + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NonFinalInteger.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NonFinalInteger.java new file mode 100644 index 000000000..6638cbed9 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NonFinalInteger.java @@ -0,0 +1,33 @@ +package mineplex.core.common.util; + +public class NonFinalInteger +{ + private int _value; + + public NonFinalInteger() + { + this(0); + } + + public NonFinalInteger(int value) + { + _value = value; + } + + public NonFinalInteger add(int value) + { + _value += value; + return this; + } + + public NonFinalInteger subtract(int value) + { + _value -= value; + return this; + } + + public int get() + { + return _value; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NumericalPulser.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NumericalPulser.java new file mode 100644 index 000000000..e0de3e7d2 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NumericalPulser.java @@ -0,0 +1,42 @@ +package mineplex.core.common.util; + +public class NumericalPulser +{ + private double _min; + private double _max; + private double _modifyPerCall; + + private double _cur; + private boolean _up; + + public NumericalPulser(double min, double max, double modify) + { + _min = min; + _max = max; + _modifyPerCall = modify; + } + + public double pulse() + { + if (_up) + { + _cur = UtilMath.clamp(_cur += _modifyPerCall, _min, _max); + + if (_cur >= _max) + { + _up = false; + } + } + else + { + _cur = UtilMath.clamp(_cur -= _modifyPerCall, _min, _max); + + if (_cur <= _min) + { + _up = true; + } + } + + return _cur; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/RGBData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/RGBData.java new file mode 100644 index 000000000..912516d17 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/RGBData.java @@ -0,0 +1,53 @@ +package mineplex.core.common.util; + +public class RGBData +{ + private double _red; + private double _green; + private double _blue; + + public RGBData(int red, int green, int blue) + { + _red = UtilMath.clamp(((double) red) / 255.d, 0, 1); + _green = UtilMath.clamp(((double) green) / 255.d, 0, 1); + _blue = UtilMath.clamp(((double) blue) / 255.d, 0, 1); + } + + public int getFullRed() + { + return (int) (_red * 255); + } + + public int getFullGreen() + { + return (int) (_green * 255); + } + + public int getFullBlue() + { + return (int) (_blue * 255); + } + + public double getRed() + { + return _red; + } + + public double getGreen() + { + return _green; + } + + public double getBlue() + { + return _blue; + } + + public String toString() + { + return "RGB[" + + "red=" + (int) (_red * 255) + ", " + + "green=" + (int) (_green * 255) + ", " + + "blue=" + (int) (_blue * 255) + "]"; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java index 6045f4d9e..d01556e40 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java @@ -15,7 +15,7 @@ import org.bukkit.entity.Player; import org.bukkit.util.EulerAngle; import org.bukkit.util.Vector; -import net.minecraft.server.v1_8_R3.EnumDirection; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; public class UtilAlg { @@ -152,6 +152,21 @@ public class UtilAlg return list.get(UtilMath.r(list.size())); } + public static T Random(List list, List exclude) + { + int attempts = 0; + T element; + + do + { + element = Random(list); + attempts++; + } + while (element != null && exclude.contains(element) && attempts < 15); + + return element; + } + public static boolean inBoundingBox(Location loc, Location cornerA, Location cornerB) { if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false; @@ -510,4 +525,10 @@ public class UtilAlg Math.toRadians(UtilAlg.GetYaw(vector)), 0); } + + public static AxisAlignedBB toBoundingBox(Location a, Location b) + { + return new AxisAlignedBB(a.getX(), a.getY(), a.getZ(), b.getX(), b.getY(), b.getZ()); + } + } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index c0a7f5f3b..3acb09f70 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -1405,6 +1405,9 @@ public class UtilBlock itemStack.setType(Material.DARK_OAK_DOOR_ITEM); itemStack.setDurability((short) 0); break; + case ANVIL: + itemStack.setDurability((short) (itemStack.getDurability() / 4)); + break; } return itemStacks; diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java index e04ddf689..32244ece9 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilColor.java @@ -7,6 +7,9 @@ import org.bukkit.ChatColor; */ public class UtilColor { + public static final RGBData RgbRed = hexToRgb(0xee0100); + public static final RGBData RgbGold = hexToRgb(0xffd014); + public static final RGBData RgbLightBlue = hexToRgb(0x61fff7); public static byte chatColorToClayData(ChatColor chatColor) { @@ -66,4 +69,19 @@ public class UtilColor return 0; } } + + public static RGBData hexToRgb(int hex) + { + return new RGBData(hex >> 16, hex >> 8 & 0xFF, hex & 0xFF); + } + + public static int rgbToHex(RGBData rgb) + { + return (rgb.getFullRed() << 16 | rgb.getFullGreen() << 8 | rgb.getFullBlue()); + } + + public static int rgbToHex(int red, int green, int blue) + { + return (red << 16 | green << 8 | blue); + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java index 5a300322c..07a5bcf51 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java @@ -10,6 +10,7 @@ import java.util.Map; import java.util.Map.Entry; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -89,14 +90,14 @@ public class UtilItem _materials.put(Material.FURNACE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.GUI)); _materials.put(Material.BURNING_FURNACE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.LIGHT_EMITTING, ItemCategory.GUI)); _materials.put(Material.SIGN_POST, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS)); - _materials.put(Material.WOODEN_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); + _materials.put(Material.WOODEN_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.DOOR)); _materials.put(Material.LADDER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.CLIMBABLE)); _materials.put(Material.RAILS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS)); _materials.put(Material.COBBLESTONE_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); _materials.put(Material.WALL_SIGN, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS)); _materials.put(Material.LEVER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS)); _materials.put(Material.STONE_PLATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS)); - _materials.put(Material.IRON_DOOR_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); + _materials.put(Material.IRON_DOOR_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.DOOR)); _materials.put(Material.WOOD_PLATE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.BOUNDLESS)); _materials.put(Material.REDSTONE_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.REDSTONE)); _materials.put(Material.GLOWING_REDSTONE_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.REDSTONE)); @@ -121,7 +122,7 @@ public class UtilItem _materials.put(Material.DIODE_BLOCK_OFF, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.REDSTONE)); _materials.put(Material.DIODE_BLOCK_ON, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.REDSTONE)); _materials.put(Material.STAINED_GLASS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GLASS)); - _materials.put(Material.TRAP_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); + _materials.put(Material.TRAP_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.DOOR)); _materials.put(Material.MONSTER_EGGS, EnumSet.of(ItemCategory.BLOCK)); _materials.put(Material.SMOOTH_BRICK, EnumSet.of(ItemCategory.BLOCK)); _materials.put(Material.HUGE_MUSHROOM_1, EnumSet.of(ItemCategory.BLOCK)); @@ -199,7 +200,7 @@ public class UtilItem _materials.put(Material.SLIME_BLOCK, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); _materials.put(Material.BARRIER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); - _materials.put(Material.IRON_TRAPDOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); + _materials.put(Material.IRON_TRAPDOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.DOOR)); _materials.put(Material.PRISMARINE, EnumSet.of(ItemCategory.BLOCK)); _materials.put(Material.SEA_LANTERN, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.LIGHT_EMITTING)); _materials.put(Material.STANDING_BANNER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); @@ -217,16 +218,16 @@ public class UtilItem _materials.put(Material.SPRUCE_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); _materials.put(Material.BIRCH_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); _materials.put(Material.JUNGLE_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); - _materials.put(Material.SPRUCE_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); - _materials.put(Material.BIRCH_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); - _materials.put(Material.JUNGLE_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); - _materials.put(Material.ACACIA_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); - _materials.put(Material.DARK_OAK_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.SPRUCE_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD, ItemCategory.DOOR)); + _materials.put(Material.BIRCH_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD, ItemCategory.DOOR)); + _materials.put(Material.JUNGLE_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD, ItemCategory.DOOR)); + _materials.put(Material.ACACIA_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD, ItemCategory.DOOR)); + _materials.put(Material.DARK_OAK_DOOR, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD, ItemCategory.DOOR)); _materials.put(Material.DARK_OAK_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); _materials.put(Material.ACACIA_FENCE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); - _materials.put(Material.DARK_OAK_DOOR_ITEM, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD)); + _materials.put(Material.DARK_OAK_DOOR_ITEM, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.WOOD, ItemCategory.DOOR)); // Items @@ -241,10 +242,10 @@ public class UtilItem _materials.put(Material.MUTTON, EnumSet.of(ItemCategory.ITEM, ItemCategory.RAW_FOOD, ItemCategory.EDIBLE)); _materials.put(Material.COOKED_MUTTON, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE)); _materials.put(Material.BANNER, EnumSet.of(ItemCategory.ITEM)); - _materials.put(Material.SPRUCE_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD)); - _materials.put(Material.BIRCH_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD)); - _materials.put(Material.JUNGLE_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD)); - _materials.put(Material.ACACIA_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD)); + _materials.put(Material.SPRUCE_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD, ItemCategory.DOOR)); + _materials.put(Material.BIRCH_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD, ItemCategory.DOOR)); + _materials.put(Material.JUNGLE_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD, ItemCategory.DOOR)); + _materials.put(Material.ACACIA_DOOR_ITEM, EnumSet.of(ItemCategory.ITEM, ItemCategory.WOOD, ItemCategory.DOOR)); _materials.put(Material.IRON_SPADE, EnumSet.of(ItemCategory.ITEM, ItemCategory.IRON, ItemCategory.TOOL, ItemCategory.SHOVEL)); @@ -315,13 +316,13 @@ public class UtilItem _materials.put(Material.PAINTING, EnumSet.of(ItemCategory.ITEM)); _materials.put(Material.GOLDEN_APPLE, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE)); _materials.put(Material.SIGN, EnumSet.of(ItemCategory.ITEM)); - _materials.put(Material.WOOD_DOOR, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK)); + _materials.put(Material.WOOD_DOOR, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK, ItemCategory.DOOR)); _materials.put(Material.BUCKET, EnumSet.of(ItemCategory.ITEM)); _materials.put(Material.WATER_BUCKET, EnumSet.of(ItemCategory.ITEM)); _materials.put(Material.LAVA_BUCKET, EnumSet.of(ItemCategory.ITEM)); _materials.put(Material.MINECART, EnumSet.of(ItemCategory.ITEM, ItemCategory.VEHICLE)); _materials.put(Material.SADDLE, EnumSet.of(ItemCategory.ITEM)); - _materials.put(Material.IRON_DOOR, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK)); + _materials.put(Material.IRON_DOOR, EnumSet.of(ItemCategory.ITEM, ItemCategory.ITEM_BLOCK, ItemCategory.DOOR)); _materials.put(Material.REDSTONE, EnumSet.of(ItemCategory.ITEM, ItemCategory.REDSTONE)); _materials.put(Material.SNOW_BALL, EnumSet.of(ItemCategory.ITEM, ItemCategory.THROWABLE)); _materials.put(Material.BOAT, EnumSet.of(ItemCategory.ITEM, ItemCategory.VEHICLE)); @@ -977,6 +978,16 @@ public class UtilItem return isArmor(stack == null ? null : stack.getType()); } + public static boolean is(ItemStack stack, ItemCategory category) + { + return stack == null ? false : contains(stack.getType(), category); + } + + public static boolean is(Block block, ItemCategory category) + { + return block == null ? false : contains(block.getType(), category); + } + private static boolean contains(Material material, ItemCategory category) { EnumSet set = _materials.get(material); @@ -1047,7 +1058,8 @@ public class UtilItem BLOCK, ITEM_BLOCK, LOG, - LEAVES; + LEAVES, + DOOR } public enum ArmorMaterial diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java index 3d48c098f..2c950b705 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java @@ -2,6 +2,7 @@ package mineplex.core.common.util; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; +import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Random; @@ -116,4 +117,24 @@ public class UtilMath { return num < min ? min : (num > max ? max : num); } + + public static List digits(int i) { + List digits = new ArrayList(); + while(i > 0) { + digits.add(i % 10); + i /= 10; + } + return digits; + } + + public static double random(double min, double max) + { + min = Math.abs(min); + + int rand = -random.nextInt((int)(min * 100)); + + rand += random.nextInt((int)(max * 100)); + + return ((double) rand) / 100.d; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index f1e17e2df..268a3cbc8 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -14,6 +14,7 @@ import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory; diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java index 38e540824..fe42fdf3c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java @@ -13,16 +13,18 @@ import mineplex.core.common.CurrencyType; import org.apache.commons.lang.WordUtils; import org.bukkit.ChatColor; +import org.bukkit.entity.Player; public class UtilText { private static HashMap _characters = new HashMap(); + private static HashMap _characterImages = new HashMap(); static { try { - InputStream inputStream = CurrencyType.class.getResourceAsStream("ascii.png"); + InputStream inputStream = CurrencyType.class.getResourceAsStream("/ascii.png"); BufferedImage image = ImageIO.read(inputStream); char[] text = new char[] @@ -166,7 +168,7 @@ public class UtilText return fillLine(" ", div) + string + fillLine(" ", div); } - + public static String alignRight(String string, LineFormat lineFormat) { int length = getLength(string); @@ -263,13 +265,13 @@ public class UtilText public static String[] splitLinesToArray(String[] strings, LineFormat lineFormat) { ArrayList lineList = splitLines(strings, lineFormat); - + String[] lineArray = new String[lineList.size()]; lineArray = lineList.toArray(lineArray); - + return lineArray; } - + public static ArrayList splitLines(String[] strings, LineFormat lineFormat) { ArrayList lines = new ArrayList(); @@ -281,35 +283,35 @@ public class UtilText return lines; } - + public static String[] splitLineToArray(String string, LineFormat lineFormat) { ArrayList lineList = splitLine(string, lineFormat); - + String[] lineArray = new String[lineList.size()]; lineArray = lineList.toArray(lineArray); - + return lineArray; } public static ArrayList splitLine(String string, LineFormat lineFormat) { ArrayList strings = new ArrayList(); - - //Ignore lines with # + + // Ignore lines with # if (string.startsWith("#")) { strings.add(string.substring(1, string.length())); return strings; } - - //Empty + + // Empty if (string.equals("") || string.equals(" ")) { strings.add(string); return strings; } - + String current = ""; int currentLength = 0; String[] split = string.split(" "); @@ -453,35 +455,63 @@ public class UtilText private static void grab(Character character, BufferedImage image, int imageX, int imageY) { + BufferedImage newImage = image.getSubimage(imageX, imageY, 8, 8); + + int width = 8; + if (character == ' ') { - _characters.put(character, 3); - return; + width = 3; } - - for (int x = 0; x < 8; x++) + else { - boolean isTransparentLine = true; - - for (int y = 0; y < 8; y++) + for (int x = 0; x < 8; x++) { - int pixel = image.getRGB(imageX + x, imageY + y); + boolean isTransparentLine = true; - if ((pixel >> 24) != 0x00) + for (int y = 0; y < 8; y++) { - isTransparentLine = false; + int pixel = image.getRGB(imageX + x, imageY + y); + + if ((pixel >> 24) != 0x00) + { + isTransparentLine = false; + break; + } + } + + if (isTransparentLine) + { + width = x + 1; break; } } - - if (isTransparentLine) - { - _characters.put(character, x); - return; - } } - _characters.put(character, 8); + newImage = newImage.getSubimage(0, 0, width, 8); + + _characterImages.put(character, newImage); + _characters.put(character, width); + } + + public static int getLength(char character) + { + if (!_characters.containsKey(character)) + { + return 16; + } + + return _characters.get(character); + } + + public static BufferedImage getImage(char character) + { + if (!_characterImages.containsKey(character)) + { + character = '?'; + } + + return _characterImages.get(character); } public static boolean isStringSimilar(String newString, String oldString, float matchRequirement) @@ -621,5 +651,28 @@ public class UtilText { return arrayToString(array, null); } + + public static String getProgress(String prefix, double amount, String suffix, boolean progressDirectionSwap) + { + if (progressDirectionSwap) + amount = 1 - amount; + + //Generate Bar + int bars = 24; + String progressBar = C.cGreen + ""; + boolean colorChange = false; + for (int i=0 ; i= amount) + { + progressBar += C.cRed; + colorChange = true; + } + + progressBar += "▌"; + } + return(prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar + (suffix == null ? "" : ChatColor.RESET + " " + suffix); + } + } \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java index 5d5174f16..8484e58fd 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java @@ -30,6 +30,12 @@ public class UtilTime SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_DAY); return sdf.format(cal.getTime()); } + + public static String date(long date) + { + SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_DAY); + return sdf.format(date); + } public static String getDayOfMonthSuffix(final int n) { diff --git a/Plugins/Mineplex.Core/.classpath b/Plugins/Mineplex.Core/.classpath deleted file mode 100644 index e223d6129..000000000 --- a/Plugins/Mineplex.Core/.classpath +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Core/.externalToolBuilders/asdf.launch b/Plugins/Mineplex.Core/.externalToolBuilders/asdf.launch deleted file mode 100644 index 881f2f585..000000000 --- a/Plugins/Mineplex.Core/.externalToolBuilders/asdf.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Core/.project b/Plugins/Mineplex.Core/.project deleted file mode 100644 index 83838c414..000000000 --- a/Plugins/Mineplex.Core/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - Mineplex.Core - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/asdf.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.Core/.settings/org.eclipse.core.resources.prefs b/Plugins/Mineplex.Core/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/Plugins/Mineplex.Core/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/Plugins/Mineplex.Core/.settings/org.eclipse.jdt.core.prefs b/Plugins/Mineplex.Core/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index a698e5967..000000000 --- a/Plugins/Mineplex.Core/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Plugins/Mineplex.Core/Mineplex.Core.iml b/Plugins/Mineplex.Core/Mineplex.Core.iml deleted file mode 100644 index c6de528e3..000000000 --- a/Plugins/Mineplex.Core/Mineplex.Core.iml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/Mineplex.Core/pom.xml b/Plugins/Mineplex.Core/pom.xml new file mode 100644 index 000000000..2a88ca1ca --- /dev/null +++ b/Plugins/Mineplex.Core/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + + + com.mineplex + mineplex-parent + dev-SNAPSHOT + + + mineplex-core + + + + ${project.groupId} + mineplex-cache + ${project.version} + + + ${project.groupId} + mineplex-core-common + ${project.version} + + + ${project.groupId} + mineplex-database + ${project.version} + + + ${project.groupId} + mineplex-serverdata + ${project.version} + + + fr.neatmonster + nocheatplus + + + org.apache.commons + commons-dbcp2 + + + org.apache.httpcomponents + httpclient + + + + + + + + + version.properties + + true + + + + diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java index af619626b..6dd6d2c29 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java @@ -69,8 +69,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutNamedEntitySpawn.class, PacketPlayInUseEntity.class, PacketPlayOutAttachEntity.class); - NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this); - NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this); +// NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this); +// NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this); NCPHookManager.addHook(CheckType.ALL, this); } @@ -80,7 +80,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook _entityMap.remove(event.getPlayer().getName()); _entityNameMap.remove(event.getPlayer().getName()); _entityRiding.remove(event.getPlayer().getName()); - _loggedIn.remove(event.getPlayer()); + _loggedIn.remove(event.getPlayer().getName()); } @EventHandler(priority = EventPriority.LOW) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 7228b671e..1f2dc672d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -135,6 +135,11 @@ public class CoreClientManager extends MiniPlugin } } + public boolean Contains(String name) + { + return _clientList.containsKey(name); + } + public CoreClient Get(Player player) { return Get(player.getName()); @@ -208,6 +213,11 @@ public class CoreClientManager extends MiniPlugin _clientsConnecting.decrementAndGet(); } } + + public void loadAccountIdFromUUID(UUID uuid, Callback callback) + { + _repository.getAccountId(uuid, callback); + } public void loadClientByName(final String playerName, final Runnable runnable) { @@ -285,6 +295,76 @@ public class CoreClientManager extends MiniPlugin }); } + public void loadClientByNameSync(final String playerName, final Runnable runnable) + { + try + { + ClientToken token = null; + Gson gson = new Gson(); + + // Fails if not in DB and if duplicate. + UUID uuid = loadUUIDFromDB(playerName); + + if (uuid == null) + { + try + { + uuid = UUIDFetcher.getUUIDOf(playerName); + } + catch (Exception exception) + { + System.out.println("Error fetching uuid from mojang : " + exception.getMessage()); + } + } + + String response = ""; + + if (uuid == null) + { + response = _repository.getClientByName(playerName); + } + else + { + response = _repository.getClientByUUID(uuid); + } + + token = gson.fromJson(response, ClientToken.class); + + CoreClient client = Add(playerName); + client.SetRank(Rank.valueOf(token.Rank), false); + client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName())); + + // JSON sql response + Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); + + if (client.getAccountId() > 0) + { + PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); + + if (playerInfo != null) + { + playerInfo.setAccountId(client.getAccountId()); + PlayerCache.getInstance().addPlayer(playerInfo); + } + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + finally + { + Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable() + { + public void run() + { + if (runnable != null) + runnable.run(); + } + }); + } + } + public boolean LoadClient(final CoreClient client, final UUID uuid, String ipAddress) { TimingManager.start(client.GetPlayerName() + " LoadClient Total."); @@ -391,6 +471,13 @@ public class CoreClientManager extends MiniPlugin if (event.getReason().contains("You logged in from another location")) { _duplicateLoginGlitchPreventionList.add(event.getPlayer().getName()); + Bukkit.getScheduler().runTask(_plugin, new Runnable() { + public void run() { + if(!_clientList.containsKey(event.getPlayer().getName())) return; + Player p = _clientList.get(event.getPlayer().getName()).GetPlayer(); + p.kickPlayer("You're already logged in."); + } + }); } } @@ -398,7 +485,7 @@ public class CoreClientManager extends MiniPlugin public void Quit(PlayerQuitEvent event) { // When an account is logged in to this server and the same account name logs in - // Then it Fires events in this order (original, new for accounts) + // Then it Fires events in this order (original, new for acco unts) // AsyncPreLogin -> new // PlayerLogin -> new // PlayerKick -> old diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java index d11b9a081..658c984ed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -41,6 +41,7 @@ public class AccountRepository extends RepositoryBase private static String UPDATE_ACCOUNT_NULL_RANK = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=?, rankExpire=? WHERE uuid = ? AND rank IS NULL;"; private static String SELECT_ACCOUNT_UUID_BY_NAME = "SELECT uuid FROM accounts WHERE name = ? ORDER BY lastLogin DESC;"; + private static String SELECT_ACCOUNT_ID_BY_UUID = "SELECT id FROM accounts WHERE accounts.uuid = ? LIMIT 1"; private String _webAddress; @@ -160,6 +161,15 @@ public class AccountRepository extends RepositoryBase return accountId; } + + public void getAccountId(UUID uuid, Callback callback) + { + executeQuery(SELECT_ACCOUNT_ID_BY_UUID, resultSet -> { + int accountId = -1; + while (resultSet.next()) accountId = resultSet.getInt(1); + callback.run(accountId); + }, new ColumnVarChar("uuid", 100, uuid.toString())); + } public String GetClient(String name, UUID uuid, String ipAddress) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index d7e71c18e..ab07c5147 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -854,7 +854,37 @@ public enum Achievement new String[]{"Type Wars.Wins"}, new String[]{"Win 30 Games"}, new int[]{30}, - AchievementCategory.TYPE_WARS); + AchievementCategory.TYPE_WARS), + + SPEED_BUILDERS_SPEED_MASTER("Speed Master", 800, + new String[]{"Speed Builders.Wins"}, + new String[]{"Win 10 Games of Speed Builder"}, + new int[]{10}, + AchievementCategory.SPEED_BUILDERS), + + SPEED_BUILDERS_DEPENDABLE("Dependable", 1200, + new String[]{"Speed Builders.PerfectBuild"}, + new String[]{"Complete 50 Perfect Builds"}, + new int[]{50}, + AchievementCategory.SPEED_BUILDERS), + + SPEED_BUILDERS_FIRST_BUILD("First Build!", 1800, + new String[]{"Speed Builders.PerfectFirst"}, + new String[]{"Be the first person to complete a build in the game 10 times"}, + new int[]{10}, + AchievementCategory.SPEED_BUILDERS), + + SPEED_BUILDERS_PERFECTIONIST("Perfectionist", 2200, + new String[]{"Speed Builders.PerfectWins"}, + new String[]{"Win a game of Speed Builder with a perfect build every round"}, + new int[]{1}, + AchievementCategory.SPEED_BUILDERS), + + SPEED_BUILDERS_SPEEDIEST("Speediest Builderizer", 2000, + new String[]{"Speed Builders.SpeediestBuilderizer"}, + new String[]{"Perfect a build in less than 10 seconds"}, + new int[]{1}, + AchievementCategory.SPEED_BUILDERS); private String _name; private String[] _desc; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 4a12d45cb..ca55d520f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -2,10 +2,6 @@ package mineplex.core.achievement; import java.util.List; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; - import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -14,6 +10,10 @@ import mineplex.core.game.GameDisplay; import mineplex.core.stats.PlayerStats; import mineplex.core.stats.StatsManager; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; + public enum AchievementCategory { GLOBAL("Global", null, @@ -157,7 +157,11 @@ public enum AchievementCategory TYPE_WARS("Type Wars", null, new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Minions killed", "MinionKills"), new StatDisplay("Words Per Minute", false, true, "MinionKills", "TimeInGame"), StatDisplay.GEMS_EARNED}, - Material.NAME_TAG, 0, GameCategory.CLASSICS, null); + Material.NAME_TAG, 0, GameCategory.CLASSICS, null), + + SPEED_BUILDERS("Speed Builders", null, + new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, new StatDisplay("Perfect Builds", "PerfectBuild")}, + Material.QUARTZ_BLOCK, 0, GameCategory.CLASSICS, null); private String _name; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java index 0d6badd6e..a4dc577ed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java @@ -81,7 +81,7 @@ public class StatDisplay formattedStats[i] = gameDisplay.getName() + "." + stats[i]; } - return new StatDisplay(name, true, formattedStats); + return new StatDisplay(name, true, false, formattedStats); } public static final StatDisplay WINS = new StatDisplay("Wins"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java index 40ec84525..3817df163 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java @@ -49,7 +49,7 @@ public class AchievementMainPage extends ShopPageBase implements I private HologramManager _hologramManager; private RewardManager _rewardManager; private StatsManager _statsManager; + private FacebookManager _facebookManager; public boolean _enabled; private Npc _carlNpc; private AnimationCarl _animation; @@ -168,7 +170,7 @@ public class BonusManager extends MiniClientPlugin implements I updateOffSet(); } - public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, GiveawayManager giveawayManager) + public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, GiveawayManager giveawayManager, FacebookManager facebookManager) { super("Bonus", plugin); _repository = new BonusRepository(plugin, this, donationManager); @@ -187,6 +189,7 @@ public class BonusManager extends MiniClientPlugin implements I _pollManager = pollManager; _statsManager = statsManager; + _facebookManager = facebookManager; _voteList = new ArrayList(); _voteList.add("http://vote1.mineplex.com"); @@ -440,6 +443,7 @@ public class BonusManager extends MiniClientPlugin implements I incrementDailyStreak(player); awardBonus(player, amount); updateCreeperVisual(player, true, C.cAqua); + UtilPlayer.message(player, F.main("Carl", "Come back tomorrow for more!")); _statsManager.incrementStat(player, "Global.DailyReward", 1); } @@ -481,6 +485,7 @@ public class BonusManager extends MiniClientPlugin implements I { awardBonus(player, getRankBonusAmount(player)); updateCreeperVisual(player, true, C.cAqua); + UtilPlayer.message(player, F.main("Carl", "Come back next month for more!")); } result.run(aBoolean); @@ -814,9 +819,6 @@ public class BonusManager extends MiniClientPlugin implements I _statsManager.incrementStat(player, "Global.ExpEarned", experience); UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(experience + " Experience"))); } - - UtilPlayer.message(player, F.main("Carl", "Come back tomorrow for more!")); - } @EventHandler @@ -829,7 +831,7 @@ public class BonusManager extends MiniClientPlugin implements I if (entity.equals(_carlNpc.getEntity())) { updateDailyStreak(event.getPlayer()); - new BonusGui(_plugin, event.getPlayer(), this, _rewardManager).openInventory(); + new BonusGui(_plugin, event.getPlayer(), this, _rewardManager, _facebookManager).openInventory(); } } @@ -845,7 +847,7 @@ public class BonusManager extends MiniClientPlugin implements I if (event.getEntity().equals(_carlNpc.getEntity())) { updateDailyStreak(player); - new BonusGui(_plugin, player, this, _rewardManager).openInventory(); + new BonusGui(_plugin, player, this, _rewardManager, _facebookManager).openInventory(); } } } @@ -910,6 +912,7 @@ public class BonusManager extends MiniClientPlugin implements I if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++; if (canDaily(player)) availableRewards++; if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++; + if (!_facebookManager.hasRedeemed(player)) availableRewards++; Hologram hologram; @@ -1046,9 +1049,12 @@ public class BonusManager extends MiniClientPlugin implements I { return _pollManager; } - - - + + public FacebookManager getFacebookManager() + { + return _facebookManager; + } + @EventHandler public void Join(final PlayerJoinEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java index ccc55a251..d68a85d73 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java @@ -17,7 +17,7 @@ public class GuiCommand extends CommandBase{ @Override public void Execute(Player caller, String[] args) { - new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager()).openInventory(); + new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager(), Plugin.getFacebookManager()).openInventory(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java index 8306c84d5..7c8f448dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java @@ -1,5 +1,7 @@ package mineplex.core.bonuses.gui; +import mineplex.core.bonuses.gui.buttons.FacebookButton; +import mineplex.core.facebook.FacebookManager; import mineplex.core.gui.SimpleGui; import mineplex.core.reward.RewardManager; import mineplex.core.bonuses.BonusManager; @@ -17,19 +19,21 @@ public class BonusGui extends SimpleGui private BonusManager manager; - public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager) + public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager, FacebookManager facebookManager) { super(plugin, player, player.getName() + "'s Bonuses", 5 * 9); this.manager = manager; - setItem(10, new VoteButton(plugin, player, this, manager)); + setItem(9, new VoteButton(plugin, player, this, manager)); - setItem(12, new RankBonusButton(getPlugin(), player, this, manager)); + setItem(11, new RankBonusButton(getPlugin(), player, this, manager)); - setItem(14, new DailyBonusButton(getPlugin(), player, this, manager)); + setItem(13, new DailyBonusButton(getPlugin(), player, this, manager)); - setItem(16, new PollButton(getPlugin(), player, manager.getPollManager(), manager.getClientManager(), this, manager)); + setItem(15, new PollButton(getPlugin(), player, manager.getPollManager(), manager.getClientManager(), this, manager)); + + setItem(17, new FacebookButton(player, facebookManager)); setItem(31, new CarlSpinButton(getPlugin(), player, manager, rewardManager)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/FacebookButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/FacebookButton.java new file mode 100644 index 000000000..9b9d41350 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/FacebookButton.java @@ -0,0 +1,77 @@ +package mineplex.core.bonuses.gui.buttons; + +import java.util.ArrayList; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.bonuses.BonusAmount; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; +import mineplex.core.facebook.FacebookManager; +import mineplex.core.gui.GuiItem; +import mineplex.core.itemstack.ItemStackFactory; + +public class FacebookButton implements GuiItem +{ + private Player _player; + private FacebookManager _facebookManager; + + public FacebookButton(Player player, FacebookManager facebookManager) + { + _player = player; + _facebookManager = facebookManager; + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } + + @Override + public void click(ClickType clickType) + { + _player.closeInventory(); + + new JsonMessage(C.cAquaB + "Click here to claim Facebook Prize!").click(ClickEvent.OPEN_URL, "https://www.facebook.com/MineplexGames/app/185301094822359/").sendToPlayer(_player); + } + + private boolean isAvailable() + { + return !_facebookManager.hasRedeemed(_player); + } + + @Override + public ItemStack getObject() + { + ArrayList lore = new ArrayList(); + + if (isAvailable()) + { + lore.add(" "); + BonusAmount bonus = new BonusAmount(); + bonus.setAncientChests(10); + bonus.addLore(lore); + lore.add(" "); + lore.add(C.cGreen + "Click to visit us on Facebook!"); + return ItemStackFactory.Instance.CreateStack(Material.WATER_BUCKET, (byte) 0, 1, C.cGreen + C.Bold + "Visit us on Facebook", lore); + } + else + { + lore.add(" "); + lore.add(C.cWhite + "You have already claimed the Facebook reward!"); + return ItemStackFactory.Instance.CreateStack(Material.REDSTONE_BLOCK, (byte) 0, 1, ChatColor.RED + C.Bold + "Visit us on Facebook", lore); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index 8954b07c0..eca038bb7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -232,7 +232,7 @@ public class Chat extends MiniPlugin } } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.LOWEST) public void filterChat(AsyncPlayerChatEvent event) { if (event.isCancelled()) @@ -240,14 +240,7 @@ public class Chat extends MiniPlugin if (event.isAsynchronous()) { - String filteredMessage = getFilteredMessage(event.getPlayer(), event.getMessage()); - - for (Player onlinePlayer : event.getRecipients()) - { - onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), filteredMessage)); - } - - event.setCancelled(true); + event.setMessage(getFilteredMessage(event.getPlayer(), event.getMessage())); } } @@ -296,7 +289,7 @@ public class Chat extends MiniPlugin } } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOW) public void HandleChat(AsyncPlayerChatEvent event) { if (event.isCancelled()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java index 9394628ae..3afb1ae7e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java @@ -108,7 +108,7 @@ public class CosmeticManager extends MiniPlugin if (event.getPlayer().isOnline()) { event.getPlayer().getInventory().remove(Material.CHEST); - event.getPlayer().getInventory().setItem(_interfaceSlot, ItemStackFactory.Instance.CreateStack(Material.CHEST, (byte)0, 1, ChatColor.RESET + C.cGreen + "Inventory Menu")); + event.getPlayer().getInventory().setItem(_interfaceSlot, ItemStackFactory.Instance.CreateStack(Material.CHEST, (byte)0, 1, ChatColor.RESET + C.cGreen + "Cosmetic Menu")); event.getPlayer().updateInventory(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 76077f8f6..3954e1edc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -160,12 +160,12 @@ public class Menu extends ShopPageBase if (enabled.containsKey(type)) addGlow(deathSlot); type = GadgetType.Item; - lore = getLore(ownedCount.get(type), maxCount.get(type), "All sorts of zaney contraptions to use on your friends and foes.", "Usable in Lobbies", enabled.get(type)); + lore = getLore(ownedCount.get(type), maxCount.get(type), "All sorts of zany contraptions to use on your friends and foes.", "Usable in Lobbies", enabled.get(type)); addButton(gadgetSlot, new ShopItem(Material.MELON_BLOCK, "Gadgets", lore, 1, false), new OpenGadgets(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(gadgetSlot); type = GadgetType.Morph; - lore = getLore(ownedCount.get(type), maxCount.get(type), "Ever want to be a tiger? Well, you can’t be a tiger! That’s silly! But you can be many other things!", "Usable in Lobbies", enabled.get(type)); + lore = getLore(ownedCount.get(type), maxCount.get(type), "Have you ever wanted to be a tiger? Well, you can't be a tiger! That's silly! But you can be many other things!", "Usable in Lobbies", enabled.get(type)); addButton(morphSlot, new ShopItem(Material.LEATHER, "Morphs", lore, 1, false), new OpenMorphs(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(morphSlot); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java index 4e796c47e..114b700ce 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java @@ -193,7 +193,7 @@ public class PetPage extends ShopPageBase } else if (getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.WITHER) { - addButton(slot, new ShopItem(petExtra.GetMaterial(), (byte) 0, "Rename " + getPlugin().getPetManager().getActivePet(getPlayer().getName()).getCustomName() + " for " + C.cYellow + petExtra.GetCost(CurrencyType.Coins) + C.cGreen + " Coins", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); + addButton(slot, new ShopItem(petExtra.GetMaterial(), (byte) 0, "Rename " + getPlugin().getPetManager().getActivePet(getPlayer().getName()).getCustomName() + " for " + C.cYellow + petExtra.GetCost(CurrencyType.Coins) + C.cGreen + " Shards", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); } slot++; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java index cd0543674..26652d24a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java @@ -48,10 +48,15 @@ public class CustomDataManager extends MiniDbClientPlugin return new PlayerCustomData(_repository); } - @Override - public void saveData(String name, int accountId) + public void saveAsync(Player player) { - _repository.saveData(name, accountId); + final int accountId = getClientManager().getAccountId(player); + final String name = player.getName(); + + if (accountId == -1) + return; + + runAsync(() -> _repository.saveData(name, accountId)); } public CorePlayer getCorePlayer(Player player) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java index e49f75211..bf350f843 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java @@ -27,10 +27,11 @@ public abstract class MineplexPlayer return ""; } - public void put(String key, int data) + public void put(String key, int data, boolean save) { key = getKeyPrefix() + key; _customDataManager.Get(getPlayer()).setData(key, data); + if (save) _customDataManager.saveAsync(_player); } public int get(String key) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java index 328aa6e6f..c896f2a03 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java @@ -3,6 +3,7 @@ package mineplex.core.customdata.repository; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Map; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -71,20 +72,20 @@ public class CustomDataRepository extends RepositoryBase { PlayerCustomData data = _customDataManager.Get(name); - for (CustomData cd : data.getDataMap().keySet()) + for (Map.Entry entry : data.getDataMap().entrySet()) { if (executeUpdate( UPDATE_DATA, - new ColumnInt("data", data.getDataMap().get(cd)), + new ColumnInt("data", entry.getValue()), new ColumnInt("account", accountId), - new ColumnInt("customData", cd.getId())) < 1) + new ColumnInt("customData", entry.getKey().getId())) < 1) { // Not already in the DB executeUpdate( INSERT_DATA, new ColumnInt("account", accountId), - new ColumnInt("customData", cd.getId()), - new ColumnInt("data", data.getDataMap().get(cd)) + new ColumnInt("customData", entry.getKey().getId()), + new ColumnInt("data", entry.getValue()) ); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java new file mode 100644 index 000000000..bd02855fe --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTask.java @@ -0,0 +1,65 @@ +package mineplex.core.delayedtask; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniClientPlugin; +import mineplex.core.common.util.Callback; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class DelayedTask extends MiniClientPlugin +{ + public static DelayedTask Instance; + + public DelayedTask(JavaPlugin plugin) + { + super("Delayed Task", plugin); + } + + public static void Initialize(JavaPlugin plugin) + { + Instance = new DelayedTask(plugin); + } + + public void doDelay(Player player, String task, Callback end, Callback tick, Callback cancel, long wait, boolean allowMovement) + { + Get(player).insert(new Task(Get(player), task, end, tick, cancel, wait, allowMovement)); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Player player : Bukkit.getOnlinePlayers()) + { + Get(player).tick(); + } + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) + { + Get(event.getPlayer()).cleanup(); + } + + @EventHandler + public void onPlayerKick(PlayerKickEvent event) + { + Get(event.getPlayer()).cleanup(); + } + + @Override + protected DelayedTaskClient AddPlayer(String player) + { + return new DelayedTaskClient(Bukkit.getPlayer(player)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTaskClient.java b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTaskClient.java new file mode 100644 index 000000000..636b48294 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/DelayedTaskClient.java @@ -0,0 +1,82 @@ +package mineplex.core.delayedtask; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.entity.Player; + +public class DelayedTaskClient +{ + public Map Tasks = new HashMap<>(); + + private Player _player; + + public DelayedTaskClient(Player player) + { + _player = player; + } + + public void insert(Task task) + { + Tasks.put(task.getName(), task); + } + + public long getTimeLeft(String task) + { + if (!Tasks.containsKey(task)) return -1; + + return getEndTime(task) - System.currentTimeMillis(); + } + + public long getEndTime(String task) + { + if (!Tasks.containsKey(task)) return -1; + + return Tasks.get(task).getEndTime(); + } + + public long getStartTime(String task) + { + if (!Tasks.containsKey(task)) return -1; + + return Tasks.get(task).getStartTime(); + } + + public void cleanup() + { + if (Tasks == null) + { + Tasks = new HashMap<>(); + } + + Tasks.clear(); + Tasks = null; + } + + public void cleanup(String task) + { + Tasks.remove(task); + } + + public void tick() + { + if (Tasks == null) + { + Tasks = new HashMap<>(); + } + + for (Task task : Tasks.values()) + { + if (task.getTick() != null) + { + task.tick(); + } + } + } + + public Player getPlayer() + { + return _player; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java new file mode 100644 index 000000000..681eb9c57 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/delayedtask/Task.java @@ -0,0 +1,90 @@ +package mineplex.core.delayedtask; + +import org.bukkit.Location; + +import mineplex.core.common.util.Callback; + +public class Task +{ + private DelayedTaskClient _client; + + private Callback _end; + private Callback _tick; + private Callback _cancel; + + private String _name; + + private long _startTime; + private long _endTime; + + private Location _startPos; + private boolean _allowMovement; + + public Task(DelayedTaskClient client, String task, Callback end, Callback tick, Callback cancel, long taskLength, boolean allowMovement) + { + _client = client; + + _name = task; + _end = end; + _tick = tick; + _cancel = cancel; + + _startPos = client.getPlayer().getLocation(); + + _allowMovement = allowMovement; + + _startTime = System.currentTimeMillis(); + _endTime = _startTime + taskLength; + } + + public String getName() + { + return _name; + } + + public Callback getEnd() + { + return _end; + } + + public Callback getTick() + { + return _tick; + } + + public long getEndTime() + { + return _endTime; + } + + public long getStartTime() + { + return _startTime; + } + + public void tick() + { + _tick.run(_client); + + if (!_allowMovement && _startPos.distance(_client.getPlayer().getLocation()) > 0.3) + { + if (_cancel != null) + { + _cancel.run(_client); + } + + _client.cleanup(_name); + return; + } + + if (System.currentTimeMillis() >= _endTime) + { + if (_end != null) + { + _end.run(_client); + } + + _client.cleanup(_name); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java new file mode 100644 index 000000000..3403768bb --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguisePlayerBean.java @@ -0,0 +1,34 @@ +package mineplex.core.disguise; + +import mineplex.serverdata.data.Data; + +public class DisguisePlayerBean implements Data +{ + private int _accountID; + private String _disguisedPlayer; + private String _playerName; + public DisguisePlayerBean(int playerAccountID, String playerName, String disguiseAs) + { + this._accountID = playerAccountID; + this._disguisedPlayer = disguiseAs; + this._playerName = playerName; + + } + public int getAccountID() + { + return _accountID; + } + public String getDisguisedPlayer() + { + return _disguisedPlayer; + } + public String getPlayerName() + { + return _playerName; + } + @Override + public String getDataId() + { + return _accountID+_playerName; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java new file mode 100644 index 000000000..82e27bb5f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerDisguiseManager.java @@ -0,0 +1,71 @@ +package mineplex.core.disguise; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.serverdata.Region; +import mineplex.serverdata.redis.RedisDataRepository; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + +public class PlayerDisguiseManager extends MiniPlugin +{ + private CoreClientManager _clients; + private RedisDataRepository _redis; + public PlayerDisguiseManager(JavaPlugin plugin, CoreClientManager clients) + { + super("Player Disguise Manager", plugin); + this._clients = clients; + + _redis = new RedisDataRepository(Region.ALL, DisguisePlayerBean.class, "disguisedPlayer"); + } + + @EventHandler + public void onDisguisedPlayerQuit(PlayerQuitEvent event) + { + CoreClient client = _clients.Get(event.getPlayer()); + if(client.isDisguised()) + { + _redis.addElement(new DisguisePlayerBean(client.getAccountId(), client.GetPlayerName(), client.getDisguisedAs()), 60*60*12); // 12 hours + } + } + + @EventHandler + public void onDisguisedPlayerJoin(PlayerJoinEvent event) + { + new BukkitRunnable() + { + @Override + public void run() + { + CoreClient client = _clients.Get(event.getPlayer()); + + if(!client.GetRank().has(Rank.JNR_DEV) && client.GetRank() != Rank.YOUTUBE_SMALL && client.GetRank() != Rank.TWITCH && client.GetRank() != Rank.YOUTUBE) + return; + + if(_redis.elementExists(client.getAccountId()+client.GetPlayerName())) + { + DisguisePlayerBean bean = _redis.getElement(client.getAccountId()+client.GetPlayerName()); + Bukkit.getPluginManager().callEvent(new PlayerCommandPreprocessEvent(event.getPlayer(), "/Disguise " + bean.getDisguisedPlayer())); + event.setJoinMessage(""); + } + } + }.runTaskLater(getPlugin(), 7); + } + + @EventHandler + public void onPlayerUndisguise(PlayerUndisguiseEvent event) + { + CoreClient client = _clients.Get(event.getPlayer()); + _redis.removeElement(client.getAccountId()+client.GetPlayerName()); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java new file mode 100644 index 000000000..ad8d9a9d0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/PlayerUndisguiseEvent.java @@ -0,0 +1,31 @@ +package mineplex.core.disguise; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PlayerUndisguiseEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + private Player _player; + public PlayerUndisguiseEvent(Player disguisee) + { + this._player = disguisee; + } + + public Player getPlayer() + { + return _player; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 813873d73..91a071484 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -18,9 +18,10 @@ import mineplex.core.account.event.ClientWebResponseEvent; import mineplex.core.common.CurrencyType; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; -import mineplex.core.donation.command.CoinCommand; +import mineplex.core.donation.command.ShardCommand; import mineplex.core.donation.command.GemCommand; import mineplex.core.donation.command.GoldCommand; +import mineplex.core.donation.command.SetGoldCommand; import mineplex.core.donation.repository.DonationRepository; import mineplex.core.donation.repository.token.DonorTokenWrapper; import mineplex.core.server.util.TransactionResponse; @@ -47,8 +48,9 @@ public class DonationManager extends MiniDbClientPlugin { // TODO: Re-add commands? Where are command implementations, seen as missing at the moment. addCommand(new GemCommand(this)); - addCommand(new CoinCommand(this)); + addCommand(new ShardCommand(this)); addCommand(new GoldCommand(this)); + addCommand(new SetGoldCommand(this)); } @EventHandler @@ -336,6 +338,35 @@ public class DonationManager extends MiniDbClientPlugin }, caller, name, accountId, amount); } + public void setGold(final Callback callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal) + { + _repository.setGold(new Callback() + { + public void run(Boolean success) + { + if (success) + { + if (updateTotal) + { + Donor donor = Get(name); + + if (donor != null) + { + donor.setGold(amount); + } + } + } + else + { + System.out.println("SET GOLD FAILED..."); + } + + if (callback != null) + callback.run(success); + } + }, caller, name, accountId, amount); + } + public void RewardGoldLater(final String caller, final Player player, final int amount) { if (!_goldQueue.containsKey(player)) @@ -414,7 +445,7 @@ public class DonationManager extends MiniDbClientPlugin @Override public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException { - Get(playerName).addGold(_repository.retrieveDonorInfo(resultSet).getGold()); + Get(playerName).setGold(_repository.retrieveDonorInfo(resultSet).getGold()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java index 7145b3dab..c6e583835 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java @@ -152,7 +152,11 @@ public class Donor public void addGold(int amount) { _gold = Math.max(0, _gold + amount); - + } + + public void setGold(int amount) + { + _gold = Math.max(0, amount); } public List getCoinTransactions() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/SetGoldCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/SetGoldCommand.java new file mode 100644 index 000000000..d477f5b8f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/SetGoldCommand.java @@ -0,0 +1,75 @@ +package mineplex.core.donation.command; + +import mineplex.core.account.CoreClient; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; + +import org.bukkit.entity.Player; + +public class SetGoldCommand extends CommandBase +{ + public SetGoldCommand(DonationManager plugin) + { + super(plugin, Rank.ADMIN, "setgold"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args == null || args.length < 2) + { + UtilPlayer.message(caller, F.main("Clans", "Error! Usage: " + F.elem("/setgold "))); + return; + } + + final String targetName = args[0]; + final String goldString = args[1]; + Player target = UtilPlayer.searchExact(targetName); + + try + { + if (target == null) + { + Plugin.getClientManager().loadClientByName(targetName, new Runnable() + { + public void run() + { + CoreClient client = Plugin.getClientManager().Get(targetName); + + if (client != null) + { + setGold(caller, null, targetName, client.getAccountId(), Integer.parseInt(goldString)); + } + else + { + UtilPlayer.message(caller, F.main("Gold", "Could not find player " + F.name(targetName))); + } + } + }); + } + else + { + setGold(caller, target, target.getName(), Plugin.getClientManager().Get(target).getAccountId(), Integer.parseInt(goldString)); + } + } + catch (Exception e) + { + UtilPlayer.message(target, F.main("Clans", "You must provide a valid number in the gold parameter.")); + } + } + + private void setGold(final Player caller, final Player target, final String targetName, final int accountId, final int gold) + { + Plugin.setGold(new Callback() + { + public void run(Boolean completed) + { + UtilPlayer.message(caller, F.main("Gold", "You set " + F.name(targetName) + "'s Gold to " + F.elem(gold) + ".")); + } + }, caller.getName(), targetName, accountId, gold, true); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/CoinCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java similarity index 67% rename from Plugins/Mineplex.Core/src/mineplex/core/donation/command/CoinCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java index 4886bb8e2..c65df1a4a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/CoinCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java @@ -10,11 +10,11 @@ import mineplex.core.donation.DonationManager; import org.bukkit.entity.Player; -public class CoinCommand extends CommandBase +public class ShardCommand extends CommandBase { - public CoinCommand(DonationManager plugin) + public ShardCommand(DonationManager plugin) { - super(plugin, Rank.ADMIN, "coin"); + super(plugin, Rank.ADMIN, "coin", "shard", "shards"); } @Override @@ -22,7 +22,7 @@ public class CoinCommand extends CommandBase { if (args.length < 2) { - UtilPlayer.message(caller, F.main("Coin", "Missing Args: " + F.elem("/coin "))); + UtilPlayer.message(caller, F.main("Shards", "Missing Args: " + F.elem("/shard "))); return; } @@ -42,7 +42,7 @@ public class CoinCommand extends CommandBase rewardCoins(caller, null, targetName, client.getAccountId(), coinsString); else { - UtilPlayer.message(caller, F.main("Coin", "Could not find player " + F.name(targetName))); + UtilPlayer.message(caller, F.main("Shards", "Could not find player " + F.name(targetName))); } } }); @@ -62,7 +62,7 @@ public class CoinCommand extends CommandBase } catch (Exception e) { - UtilPlayer.message(caller, F.main("Coin", "Invalid Coins Amount")); + UtilPlayer.message(caller, F.main("Shards", "Invalid Shards Amount")); } } @@ -74,16 +74,16 @@ public class CoinCommand extends CommandBase { if (completed) { - UtilPlayer.message(caller, F.main("Coin", "You gave " + F.elem(coins + " Coins") + " to " + F.name(targetName) + ".")); + UtilPlayer.message(caller, F.main("Shards", "You gave " + F.elem(coins + " Treasure Shards") + " to " + F.name(targetName) + ".")); if (target != null) { - UtilPlayer.message(target, F.main("Coin", F.name(caller.getName()) + " gave you " + F.elem(coins + " Coins") + ".")); + UtilPlayer.message(target, F.main("Shards", F.name(caller.getName()) + " gave you " + F.elem(coins + " Treasure Shards") + ".")); } } else { - UtilPlayer.message(caller, F.main("Coin", "There was an error giving " + F.elem(coins + "Coins") + " to " + F.name(targetName) + ".")); + UtilPlayer.message(caller, F.main("Shards", "There was an error giving " + F.elem(coins + "Treasure Shards") + " to " + F.name(targetName) + ".")); } } }, caller.getName(), targetName, accountId, coins); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java index 98999dbf3..b30b30b92 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java @@ -31,6 +31,7 @@ public class DonationRepository extends RepositoryBase private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accountId, reason, coins) VALUES(?, ?, ?);"; private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE id = ?;"; private static String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? WHERE id = ?;"; + private static String SET_ACCOUNT_GOLD = "UPDATE accounts SET gold = ? WHERE id = ?;"; private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE id = ? AND gems IS NULL AND coins IS NULL;"; private String _webAddress; @@ -198,6 +199,18 @@ public class DonationRepository extends RepositoryBase } }), "Error updating player gold amount in DonationRepository : "); } + + public void setGold(final Callback callback, final String giver, final String name, final int accountId, final int gold) + { + handleDatabaseCall(new DatabaseRunnable(new Runnable() + { + public void run() + { + boolean success = executeUpdate(SET_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId)) > 0; + callback.run(success); + } + }), "Error updating player gold amount in DonationRepository : "); + } @Override protected void initialize() @@ -233,7 +246,7 @@ public class DonationRepository extends RepositoryBase while (resultSet.next()) { - donor.addGold(resultSet.getInt(1)); + donor.setGold(resultSet.getInt(1)); } return donor; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookClient.java b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookClient.java new file mode 100644 index 000000000..2fd480912 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookClient.java @@ -0,0 +1,26 @@ +package mineplex.core.facebook; + +/** + * Created by phict on 1/28/2016. + */ +public class FacebookClient +{ + // Has the player already redeemed a facebook code + // This is used so we have instant access for Carl the Creeper + private boolean _redeemed; + + public FacebookClient(boolean redeemed) + { + _redeemed = redeemed; + } + + public boolean hasRedeemed() + { + return _redeemed; + } + + public void setRedeemed(boolean redeemed) + { + _redeemed = redeemed; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookCode.java b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookCode.java new file mode 100644 index 000000000..1a36ebce5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookCode.java @@ -0,0 +1,23 @@ +package mineplex.core.facebook; + +public class FacebookCode +{ + private final String _code; + private final boolean _activated; + + public FacebookCode(String code, boolean activated) + { + _code = code; + _activated = activated; + } + + public String getCode() + { + return _code; + } + + public boolean isActivated() + { + return _activated; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java new file mode 100644 index 000000000..054ac2c79 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java @@ -0,0 +1,126 @@ +package mineplex.core.facebook; + +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniClientPlugin; +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; +import mineplex.core.facebook.command.FacebookCommand; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.treasure.TreasureType; +import org.apache.commons.lang.StringUtils; + +public class FacebookManager extends MiniDbClientPlugin +{ + private CoreClientManager _clientManager; + private DonationManager _donationManager; + private InventoryManager _inventoryManager; + + private FacebookRepository _repository; + + public FacebookManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager) + { + super("Facebook", plugin, clientManager); + + _clientManager = clientManager; + _donationManager = donationManager; + _inventoryManager = inventoryManager; + + _repository = new FacebookRepository(plugin); + } + + @Override + public void addCommands() + { + addCommand(new FacebookCommand(this)); + } + + public void tryCode(Player player, String code) + { + if (!StringUtils.isAlphanumeric(code) || code.length() != 8) + { + message(player, "Invalid Code"); + return; + } + + final int accountId = _clientManager.getAccountId(player); + + runAsync(new Runnable() + { + @Override + public void run() + { + _repository.getCode(code, new Callback() + { + @Override + public void run(FacebookCode data) + { + if (data == null) + { + message(player, "Invalid Code"); + } + else if (data.isActivated()) + { + message(player, "Code has already been redeemed"); + } + else + { + boolean completed = _repository.activateCode(code, accountId); + if (completed) + { + _inventoryManager.addItemToInventory(player, TreasureType.ANCIENT.getItemName(), 10); + message(player, "Thanks! You earned " + F.elem("10 Ancient Chests")); + player.playSound(player.getLocation(), Sound.NOTE_PIANO, 1f, 1f); +// _donationManager.RewardCoinsLater(getName(), player, 20000); + } + else + { + message(player, "You have already redeemed a code!"); + } + } + } + }); + } + }); + + } + + public boolean hasRedeemed(Player player) + { + return Get(player).hasRedeemed(); + } + + private void message(Player player, String message) + { + UtilPlayer.message(player, F.main("Facebook", message)); + } + + @Override + protected FacebookClient AddPlayer(String player) + { + return new FacebookClient(false); + } + + @Override + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + { + boolean hasRow = resultSet.next(); + Set(playerName, new FacebookClient(hasRow)); + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT * FROM facebook WHERE accountId = " + accountId + ";"; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookRepository.java new file mode 100644 index 000000000..08b6edf93 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookRepository.java @@ -0,0 +1,62 @@ +package mineplex.core.facebook; + +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.common.util.Callback; +import mineplex.core.database.DBPool; +import mineplex.core.database.RepositoryBase; +import mineplex.core.database.ResultSetCallable; +import mineplex.core.database.column.ColumnInt; +import mineplex.core.database.column.ColumnVarChar; + +public class FacebookRepository extends RepositoryBase +{ + private static final String GET_CODE = "SELECT code, activated FROM facebook WHERE code = ?"; + private static final String ACTIVATE_CODE = "UPDATE facebook SET activated = 1, accountId = ?, activationTime = NOW() WHERE code = ?"; + + public FacebookRepository(JavaPlugin plugin) + { + super(plugin, DBPool.getAccount()); + } + + @Override + protected void initialize() + { + + } + + @Override + protected void update() + { + + } + + public void getCode(String codeName, Callback callback) + { + executeQuery(GET_CODE, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + FacebookCode facebookCode = null; + + while (resultSet.next()) + { + String code = resultSet.getString(1); + boolean activated = resultSet.getBoolean(2); + facebookCode = new FacebookCode(code, activated); + } + + callback.run(facebookCode); + } + }, new ColumnVarChar("code", 8, codeName)); + } + + public boolean activateCode(String codeName, int accountId) + { + return executeUpdate(ACTIVATE_CODE, new ColumnInt("accountId", accountId), new ColumnVarChar("code", 8, codeName)) == 1; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/facebook/command/FacebookCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/facebook/command/FacebookCommand.java new file mode 100644 index 000000000..ff53f4ac9 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/facebook/command/FacebookCommand.java @@ -0,0 +1,36 @@ +package mineplex.core.facebook.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.facebook.FacebookManager; +import mineplex.core.recharge.Recharge; + +public class FacebookCommand extends CommandBase +{ + public FacebookCommand(FacebookManager plugin) + { + super(plugin, Rank.ALL, "facebook", "redeem"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args == null || args.length != 1) + { + UtilPlayer.message(caller, F.main("Facebook", "Usage: /facebook ")); + UtilPlayer.message(caller, F.main("Facebook", "Get a redemption code at " + F.elem("facebook.com/MineplexGames"))); + return; + } + + if (!Recharge.Instance.use(caller, "Facebook Command", 10000, true, false, false)) + { + return; + } + + Plugin.tryCode(caller, args[0]); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java index 88d7db15c..7f2f27f1d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java @@ -131,7 +131,7 @@ public class FriendsGUI implements Listener ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0)); builder.setTitle(C.cWhite + C.Bold + friend.Name); -// builder.setPlayerHead(friend.Name); + builder.setPlayerHead(friend.Name); builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline")); @@ -276,7 +276,7 @@ public class FriendsGUI implements Listener ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0)); builder.setTitle(C.cWhite + C.Bold + friend.Name); -// builder.setPlayerHead(friend.Name); + builder.setPlayerHead(friend.Name); builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java index ec6b33ba6..d528c4a7c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java @@ -20,7 +20,7 @@ public class ArrowTrailCandyCane extends ArrowEffectGadget public ArrowTrailCandyCane(GadgetManager manager) { super(manager, "Candy Cane Arrows", - UtilText.splitLineToArray(C.cGray + "The real reason no one visits the North Pole? Santa’s Elves are deadly shots.", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "The real reason no one visits the North Pole? Santa's Elves are deadly shots.", LineFormat.LORE), -3, Material.INK_SACK, (byte)1); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java index 171860cd5..3a7c910b5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java @@ -18,7 +18,7 @@ public class ArrowTrailFrostLord extends ArrowEffectGadget public ArrowTrailFrostLord(GadgetManager manager) { super(manager, "Arrows of the Frost Lord", - UtilText.splitLineToArray(C.cGray + "The Frost Lord’s arrows bring a blast of winter in the wind of their passing.", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "The Frost Lord's arrows bring a blast of winter in the wind of their passing.", LineFormat.LORE), -3, Material.SNOW_BALL, (byte)0, "Frost Lord"); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java index a6ccbda55..58bb91a1b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java @@ -19,7 +19,7 @@ public class DeathCandyCane extends DeathEffectGadget public DeathCandyCane(GadgetManager manager) { super(manager, "Candy Cane Remains", - UtilText.splitLineToArray(C.cGray + "The biggest enemy of the Holidays, is January.", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "The biggest enemy of the Holidays is January.", LineFormat.LORE), -3, Material.INK_SACK, (byte)1); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatCoal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatCoal.java index 7897272a8..c83e00ed4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatCoal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatCoal.java @@ -15,7 +15,7 @@ public class HatCoal extends HatGadget public HatCoal(GadgetManager manager) { super(manager, "Lump of Coal Hat", - UtilText.splitLineToArray(C.cGray + "When life gives you coal, make a wierd cube hat out it!", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "When life gives you coal, make a weird cube hat out it!", LineFormat.LORE), -1, new ItemStack(Material.COAL_BLOCK)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatGrinch.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatGrinch.java index 9ef68b04a..747d969d0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatGrinch.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatGrinch.java @@ -13,7 +13,7 @@ public class HatGrinch extends HatGadget public HatGrinch(GadgetManager manager) { super(manager, "The Grinch", - UtilText.splitLineToArray(C.cGray + "Great! Now where’s the Roast Beast?!", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "Great! Now where's the Roast Beast?!", LineFormat.LORE), -3, SkinData.THE_GRINCH.getSkull(), "The Grinch Hat"); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatPresent.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatPresent.java index e92b2b398..12ccc8db2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatPresent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatPresent.java @@ -13,7 +13,7 @@ public class HatPresent extends HatGadget public HatPresent(GadgetManager manager) { super(manager, "Present", - UtilText.splitLineToArray(C.cGray + "WHAT IN THE PRESENT? Oh, it's just you...", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "WHAT'S IN THE PRESENT? Oh, it's just you...", LineFormat.LORE), -3, SkinData.PRESENT.getSkull()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatRudolph.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatRudolph.java index 1dfd9fa5c..574508d1e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatRudolph.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatRudolph.java @@ -13,7 +13,7 @@ public class HatRudolph extends HatGadget public HatRudolph(GadgetManager manager) { super(manager, "Rudolph", - UtilText.splitLineToArray(C.cGray + "WHAT IN THE PRESENT? Oh, it's just you...", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "HEY YOU! Wanna lead Santa's sleigh team?", LineFormat.LORE), -3, SkinData.RUDOLPH.getSkull()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java index 72af832fd..9a8096e9b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java @@ -130,6 +130,20 @@ public class ItemBatGun extends ItemGadget } } } + + public boolean isThrownBat(Bat bat) + { + for (ArrayList batArray : _bats.values()) + { + for (Bat thrownBat : batArray) + { + if (bat.equals(thrownBat)) + return true; + } + } + + return false; + } public void Clear(Player player) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoinBomb.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoinBomb.java index d0039cd87..1f9f69217 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoinBomb.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoinBomb.java @@ -38,7 +38,7 @@ public class ItemCoinBomb extends ItemGadget public ItemCoinBomb(GadgetManager manager) { super(manager, "Treasure Party Bomb", - UtilText.splitLineToArray(C.cWhite + "It's party time! You'll be everyones favourite player when you use one of these!", LineFormat.LORE), + UtilText.splitLineToArray(C.cWhite + "It's party time! You'll be everyone's favourite player when you use one of these!", LineFormat.LORE), -1, Material.PRISMARINE, (byte)0, 30000, new Ammo("Treasure Party Bomb", "1 Coin Party Bomb", Material.PRISMARINE, (byte)0, new String[] { C.cWhite + "1 Treasure Party Bomb" }, 2000, 1)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemDuelingSword.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemDuelingSword.java index c8ced1f05..bb4a64339 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemDuelingSword.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemDuelingSword.java @@ -22,7 +22,7 @@ public class ItemDuelingSword extends ItemGadget }, -3, Material.GOLD_SWORD, (byte)0, - 1000, new Ammo("Dueling Sword", "10 Swords", Material.WOOD_SWORD, (byte)0, new String[] { C.cWhite + "10 Swords to duel with" }, 1000, 10)); + 1000, new Ammo("Dueling Sword", "10 Swords", Material.WOOD_SWORD, (byte)0, new String[] { C.cWhite + "10 Swords to duel with" }, 1000, 10), true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemPartyPopper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemPartyPopper.java index 92da2218c..c3ea07224 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemPartyPopper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemPartyPopper.java @@ -32,7 +32,7 @@ public class ItemPartyPopper extends ItemGadget implements IThrown public ItemPartyPopper(GadgetManager manager) { super(manager, "Party Popper", - UtilText.splitLineToArray(C.cWhite + "Celebrate by blasting confetti into peoples eyes!", LineFormat.LORE), + UtilText.splitLineToArray(C.cWhite + "Celebrate by blasting confetti into peoples' eyes!", LineFormat.LORE), 1, Material.GOLDEN_CARROT, (byte) 0, 1000, new Ammo("Party Popper", "1 Party Popper", Material.GOLDEN_CARROT, (byte) 0, new String[] { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java index 55f67dc0d..50d789985 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java @@ -59,7 +59,7 @@ public class MorphBunny extends MorphGadget "#" + C.cWhite + "Charge Crouch to use Super Jump", "#" + C.cWhite + "Left Click to use Hide Easter Egg", C.blankLine, - "#" + C.cRed +C.Bold + "WARNING: " + ChatColor.RESET + "Hide Easter Egg uses 500 Coins" , + "#" + C.cRed +C.Bold + "WARNING: " + ChatColor.RESET + "Hide Easter Egg uses 500 Shards" , }, LineFormat.LORE), -5, Material.MONSTER_EGG, (byte)98); @@ -154,7 +154,7 @@ public class MorphBunny extends MorphGadget if (Manager.getDonationManager().Get(player.getName()).GetBalance(CurrencyType.Coins) < 500) { - UtilPlayer.message(player, F.main("Gadget", "You do not have enough Coins.")); + UtilPlayer.message(player, F.main("Gadget", "You do not have enough Shards.")); return; } @@ -183,7 +183,7 @@ public class MorphBunny extends MorphGadget ChatColor.RESET + C.Bold + " hid an " + C.cYellow + C.Bold + "Easter Egg" + ChatColor.RESET + C.Bold + " worth " + - C.cYellow + C.Bold + "450 Coins"); + C.cYellow + C.Bold + "450 Shards"); for (Player other : UtilServer.getPlayers()) other.playSound(other.getLocation(), Sound.CAT_HIT, 1.5f, 1.5f); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java index 7a8430173..7e539bf90 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java @@ -29,7 +29,7 @@ public class MorphSlime extends MorphGadget { super(manager, "Big Larry Morph", UtilText.splitLinesToArray(new String[] { - C.cGray + "Have you ever looked at Big Larry and thought, \'I really want to be that guy!\'? Well, today is your lucky day!", + C.cGray + "Have you ever looked at Big Larry and thought, \'I really want to be that guy\'!? Well, today is your lucky day!", C.blankLine, "#" + C.cWhite + "Left Click to use Bounce", C.blankLine, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java index 13fe0ee14..68091b674 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java @@ -46,7 +46,7 @@ public class MorphTitan extends MorphGadget { super(manager, "Elder Guardian Morph", UtilText.splitLinesToArray(new String[] { - C.cGray + "From the depths of the sea, the Elder Guardian posseses powers more amazing than any seen before!", + C.cGray + "From the depths of the sea, the Elder Guardian possesses powers more amazing than any seen before!", C.blankLine, "#" + C.cWhite + "Left-Click to use Guardians Laser", }, LineFormat.LORE), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java index d36ca5021..2d9c8c8c7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java @@ -29,7 +29,7 @@ public class ParticleCandyCane extends ParticleGadget public ParticleCandyCane(GadgetManager manager) { super(manager, "Crushed Candy Cane", - UtilText.splitLineToArray(C.cGray + "There’s no such thing as too much Christmas Candy. Don’t listen to your dentist.", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "There's no such thing as too much Christmas Candy. Don't listen to your dentist.", LineFormat.LORE), -3, Material.INK_SACK, (byte)1); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java index 2ccb3701e..24910dd2e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java @@ -33,6 +33,9 @@ public class ParticleCoalFumes extends ParticleGadget for(Player p : GetActive()) { + if (!shouldDisplay(p)) + continue; + UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, p.getLocation(), 0.8f, 0, 0.8f, 0, 12, ViewDist.NORMAL); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java index 230705505..43319483c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java @@ -22,7 +22,7 @@ public class ParticleEnchant extends ParticleGadget public ParticleEnchant(GadgetManager manager) { super(manager, "Enchanted", - UtilText.splitLineToArray(C.cGray + "The wisdom of the universe suddenly find you extremely attractive, and wants to \'enchant\' you.", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "The wisdom of the universe suddenly finds you extremely attractive, and wants to \'enchant\' you.", LineFormat.LORE), -2, Material.BOOK, (byte)0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java index 035615c59..aaaa4d79c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java @@ -28,7 +28,7 @@ public class ParticleFrostLord extends ParticleGadget public ParticleFrostLord(GadgetManager manager) { super(manager, "Wind of the Frost Lord", - UtilText.splitLineToArray(C.cGray + "He’s not passing wind okay? HE HAS A CONDITION!", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "He's not passing wind, okay? HE HAS A CONDITION!", LineFormat.LORE), -3, Material.SNOW_BALL, (byte)0, "Frost Lord"); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleGreen.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleGreen.java index a9bd2739d..68304788a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleGreen.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleGreen.java @@ -24,7 +24,7 @@ public class ParticleGreen extends ParticleGadget public ParticleGreen(GadgetManager manager) { super(manager, "Green Ring", - UtilText.splitLineToArray(C.cGray + "With these sparkles, you can sparkle while sparkle with CaptainSparklez!", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "With these sparkles, you can sparkle while sparkling with CaptainSparklez!", LineFormat.LORE), -2, Material.EMERALD, (byte)0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHelix.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHelix.java index a9336927b..9e33bdc52 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHelix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHelix.java @@ -24,7 +24,7 @@ public class ParticleHelix extends ParticleGadget public ParticleHelix(GadgetManager manager) { super(manager, "Blood Helix", - UtilText.splitLineToArray(C.cGray + "Blood magic is very dangerous... but also very cool!", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "Blood magic is very dangerous...but also very cool!", LineFormat.LORE), -2, Material.REDSTONE, (byte)0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java index 6998e2a51..fff8bd8c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java @@ -102,9 +102,8 @@ public abstract class Gadget extends SalesPackageBase implements Listener Manager.removeActive(player, this); GadgetDisableEvent event = new GadgetDisableEvent(player, this); Bukkit.getServer().getPluginManager().callEvent(event); + DisableCustom(player); } - - DisableCustom(player); } public abstract void EnableCustom(Player player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java index b0d7bdae6..9dfa14563 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java @@ -27,6 +27,7 @@ import mineplex.core.recharge.Recharge; public abstract class ItemGadget extends Gadget { + private boolean _preserveStaticItem; private Ammo _ammo; protected long _recharge; @@ -40,6 +41,14 @@ public abstract class ItemGadget extends Gadget Free = true; } + public ItemGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, + long recharge, Ammo ammo, boolean preserveStaticItem) + { + this(manager, name, desc, cost, mat, data, recharge, ammo); + + _preserveStaticItem = preserveStaticItem; + } + @Override public void EnableCustom(Player player) { @@ -81,9 +90,12 @@ public abstract class ItemGadget extends Gadget @EventHandler public void orderThatChest(PlayerDropItemEvent event) - { + { if (IsActive(event.getPlayer()) && event.getItemDrop().getItemStack().getType() == GetDisplayMaterial()) { + if (_preserveStaticItem) + return; + final Player player = event.getPlayer(); Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() @@ -172,4 +184,4 @@ public abstract class ItemGadget extends Gadget } public abstract void ActivateCustom(Player player); -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 8ae12ae88..5d90a1b98 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -67,6 +67,9 @@ public enum GameDisplay MonsterLeague("Monster League", Material.MINECART, (byte)0, GameCategory.ARCADE, 56), Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54), + + SpeedBuilders("Speed Builders", Material.QUARTZ_BLOCK, (byte) 0, GameCategory.CLASSICS, 60), + ChampionsCTF("Champions CTF", "Champions", Material.BANNER, DyeColor.RED.getDyeData(), GameCategory.CHAMPIONS, 56), BouncyBalls("Bouncy Balls", Material.SLIME_BALL, (byte)0, GameCategory.ARCADE, 57), Gladiators("Gladiators", Material.IRON_SWORD, (byte)0, GameCategory.ARCADE, 58), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index a10dd5e73..4d3431275 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -23,6 +23,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import mineplex.cache.player.PlayerCache; +import mineplex.cache.player.PlayerInfo; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.Callback; @@ -138,17 +139,28 @@ public class InventoryManager extends MiniDbClientPlugin { public void run() { - try + PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); + if (playerInfo != null) { - addItemToInventoryForOffline(callback, PlayerCache.getInstance().getPlayer(uuid).getAccountId(), item, count); + addItemToInventoryForOffline(callback, playerInfo.getAccountId(), item, count); } - catch (Exception e) + else { - e.printStackTrace(); - - System.out.println("-----DEBUG-----"); - System.out.println("PlayerCache Instance: " + (PlayerCache.getInstance() == null)); - System.out.println("PlayerCache Player Object: " + (PlayerCache.getInstance().getPlayer(uuid) == null)); + ClientManager.loadAccountIdFromUUID(uuid, new Callback() + { + @Override + public void run(Integer id) + { + if (id > 0) + { + addItemToInventoryForOffline(callback, id, item, count); + } + else + { + runSync(() -> callback.run(false)); + } + } + }); } } }); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java index ce6804e86..94e726ad8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java @@ -55,19 +55,27 @@ public class GiveItemCommand extends CommandBase } else { - Plugin.getClientManager().loadClientByName(playerName, new Runnable() + Plugin.runAsync(new Runnable() { + @Override public void run() { UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName); - + if (uuid != null) { Plugin.addItemToInventoryForOffline(new Callback() { public void run (Boolean success) { - UtilPlayer.message(caller, F.main("Item", "You gave " + F.elem(amount + " " + itemName) + " to offline player " + F.name(playerName))); + if (success) + { + UtilPlayer.message(caller, F.main("Item", "You gave " + F.elem(amount + " " + itemName) + " to offline player " + F.name(playerName))); + } + else + { + UtilPlayer.message(caller, F.main("Item", "An error occured while trying to give item to " + F.name(playerName) + "!")); + } } }, uuid, item.Name, amount); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java index fa7070511..4f555ab3d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java @@ -173,6 +173,7 @@ public class ItemBuilder { for (String lore : lores) { + if (lore == null) continue; _lore.add(C.cGray + lore); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java b/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java index d11f032dc..3fcc5d2fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/MapText.java @@ -2,14 +2,9 @@ package mineplex.core.map; import java.awt.Graphics; import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; -import java.util.HashMap; - -import javax.imageio.ImageIO; - import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -20,86 +15,6 @@ import org.bukkit.map.MapView; public class MapText { - private static HashMap _characters = new HashMap(); - - private void loadCharacters() - { - try - { - InputStream inputStream = getClass().getResourceAsStream("ascii.png"); - BufferedImage image = ImageIO.read(inputStream); - - char[] text = new char[] - { - ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', - '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', - 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', - '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', - 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~' - }; - - int x = 0; - int y = 16; - - for (char c : text) - { - grab(c, image, x, y); - - if (x < 15 * 8) - { - x += 8; - } - else - { - x = 0; - y += 8; - } - } - - inputStream.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - - private static void grab(Character character, BufferedImage image, int imageX, int imageY) - { - BufferedImage newImage = image.getSubimage(imageX, imageY, 8, 8); - - int width = character == ' ' ? 4 : 0; - - if (width == 0) - { - for (int x = 0; x < 8; x++) - { - width++; - boolean foundNonTrans = false; - - for (int y = 0; y < 8; y++) - { - int pixel = newImage.getRGB(x, y); - - if ((pixel >> 24) != 0x00) - { - foundNonTrans = true; - break; - } - } - - if (!foundNonTrans) - { - break; - } - } - } - - newImage = newImage.getSubimage(0, 0, width, 8); - - _characters.put(character, newImage); - } - private ArrayList split(String text) { ArrayList returns = new ArrayList(); @@ -112,7 +27,7 @@ public class MapText for (char c : word.toCharArray()) { - length += _characters.get(c).getWidth(); + length += UtilText.getImage(c).getWidth(); } if (lineWidth + length >= 127) @@ -133,11 +48,6 @@ public class MapText public ItemStack getMap(boolean sendToServer, String... text) { - if (_characters.isEmpty()) - { - loadCharacters(); - } - BufferedImage image = new BufferedImage(128, 128, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); int height = 1; @@ -150,13 +60,7 @@ public class MapText for (char c : line.toCharArray()) { - BufferedImage img = _characters.get(c); - - if (img == null) - { - System.out.print("Error: '" + c + "' has no image associated"); - continue; - } + BufferedImage img = UtilText.getImage(c); g.drawImage(img, length, height, null); @@ -179,7 +83,7 @@ public class MapText ItemStack item = new ItemStack(Material.MAP); item.setDurability(map.getId()); - + if (sendToServer) { for (Player player : UtilServer.getPlayers()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/ascii.png b/Plugins/Mineplex.Core/src/mineplex/core/map/ascii.png deleted file mode 100644 index 587966dc3..000000000 Binary files a/Plugins/Mineplex.Core/src/mineplex/core/map/ascii.png and /dev/null differ diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java index 5735a2dc4..f9c2242d1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java @@ -10,6 +10,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.message.MessageManager; +import mineplex.core.visibility.VisibilityManager; public class AdminCommand extends CommandBase { @@ -52,7 +53,12 @@ public class AdminCommand extends CommandBase { if (!to.equals(caller)) UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message); - + + if(Plugin.GetClientManager().Get(to).GetRank().has(Rank.JNR_DEV)) + { + if(Plugin.GetClientManager().Get(to).isDisguised() || !caller.canSee(to)) + continue; + } staff = true; //Sound diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountBabyReindeer.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountBabyReindeer.java index 64e56f971..da0c765bc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountBabyReindeer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountBabyReindeer.java @@ -32,7 +32,7 @@ public class MountBabyReindeer extends HorseMount public MountBabyReindeer(MountManager manager) { super(manager, "Baby Reindeer", - UtilText.splitLineToArray(C.cGray + "One of Santas baby reindeers. He's still learning how to fly...", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "One of Santa's baby reindeers. He's still learning how to fly...", LineFormat.LORE), Material.GOLDEN_CARROT, (byte) 0, -3, Color.CREAMY, Style.WHITEFIELD, Variant.HORSE, 0, null); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java index 8e4cb3dc7..64cb728bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java @@ -52,8 +52,8 @@ public class NotificationManager extends MiniPlugin // if (event.getType() == UpdateType.MIN_16) // sale(); - if (event.getType() == UpdateType.MIN_08) - christmasSale(); +// if (event.getType() == UpdateType.MIN_08) +// christmasSale(); } private void christmasSale() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playerCount/PlayerCountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/playerCount/PlayerCountManager.java index 71595c42a..ee1e1ddfb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playerCount/PlayerCountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playerCount/PlayerCountManager.java @@ -64,7 +64,7 @@ public class PlayerCountManager extends MiniPlugin @EventHandler public void refresh(UpdateEvent event) { - if (event.getType() != UpdateType.SLOW) + if (event.getType() != UpdateType.SEC_08) return; runAsync(this::updatePlayerCount); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java index 79afa7b23..2cde41914 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java @@ -124,7 +124,7 @@ public class ExclusivePreferencesPage extends ShopPageBase _punishClients; @@ -98,7 +100,7 @@ public class Punish extends MiniPlugin } } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOW) public void PunishChatEvent(AsyncPlayerChatEvent event) { PunishClient client = GetClient(event.getPlayer().getName()); @@ -110,6 +112,18 @@ public class Punish extends MiniPlugin } } + @EventHandler(priority = EventPriority.LOWEST) + public void PunishSignEvent(SignChangeEvent event) + { + PunishClient client = GetClient(event.getPlayer().getName()); + + if (client != null && client.IsMuted()) + { + event.getPlayer().sendMessage(F.main(getName(), "Shh, you're muted because " + client.GetPunishment(PunishmentSentence.Mute).GetReason() + " by " + client.GetPunishment(PunishmentSentence.Mute).GetAdmin() + " for " + C.cGreen + UtilTime.convertString(client.GetPunishment(PunishmentSentence.Mute).GetRemaining(), 1, TimeUnit.FIT) + ".")); + event.setCancelled(true); + } + } + @EventHandler public void banRefresh(UpdateEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index 1aa921c2d..ae88b6cb1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -15,6 +15,7 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilServer; import mineplex.core.stats.command.GiveStatCommand; +import mineplex.core.stats.command.MasterBuilderUnban; import mineplex.core.stats.command.TimeCommand; import mineplex.core.stats.event.StatChangeEvent; @@ -26,6 +27,8 @@ public class StatsManager extends MiniDbClientPlugin private NautHashMap _stats = new NautHashMap(); private NautHashMap> _statUploadQueue = new NautHashMap>(); + private NautHashMap> _statUploadQueueOverRidable = new NautHashMap>(); + private Runnable _saveRunnable; public StatsManager(JavaPlugin plugin, CoreClientManager clientManager) @@ -41,6 +44,7 @@ public class StatsManager extends MiniDbClientPlugin public void run() { saveStats(); + overRidableSaveStats(); } }; @@ -81,6 +85,11 @@ public class StatsManager extends MiniDbClientPlugin } public void incrementStat(final Player player, final String statName, final long value) + { + incrementStat(player, statName, value, false); + } + + public void incrementStat(final Player player, final String statName, final long value, boolean overRide) { if (value <= 0) return; @@ -96,11 +105,80 @@ public class StatsManager extends MiniDbClientPlugin @Override public void run() { - addToQueue(statName, player, value); + if(overRide) + { + addToOverRidableQueue(statName, player, value); + } + else + { + addToQueue(statName, player, value); + } } }); } + private void addToOverRidableQueue(String statName, Player player, long value) + { + synchronized (_statSync) + { + if (!_statUploadQueueOverRidable.containsKey(player)) + _statUploadQueueOverRidable.put(player, new NautHashMap()); + + if (!_statUploadQueueOverRidable.get(player).containsKey(statName)) + _statUploadQueueOverRidable.get(player).put(statName, 0L); + + _statUploadQueueOverRidable.get(player).put(statName, _statUploadQueueOverRidable.get(player).get(statName) + value); + } + } + + protected void overRidableSaveStats() + { + if (_statUploadQueueOverRidable.isEmpty()) + return; + + try + { + NautHashMap> uploadQueue = new NautHashMap>(); + + synchronized (_statSync) + { + for (Iterator statIterator = _statUploadQueueOverRidable.keySet().iterator(); statIterator.hasNext();) + { + Player player = statIterator.next(); + + if (player.isOnline()) + continue; + + try + { + int uploadKey = PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(); + + uploadQueue.put(uploadKey, new NautHashMap()); + + for (String statName : _statUploadQueueOverRidable.get(player).keySet()) + { + int statId = _stats.get(statName); + uploadQueue.get(uploadKey).put(statId, _statUploadQueueOverRidable.get(player).get(statName)); + System.out.println(player.getName() + " saving stat : " + statName + " overriding " + _statUploadQueueOverRidable.get(player).get(statName)); + } + + statIterator.remove(); + } + catch (Exception e) + { + //System.out.println("[StatsManager] AccountId was not set for " + player.getName()); + } + } + } + + _repository.saveStats(uploadQueue, true); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } + private void addToQueue(String statName, Player player, long value) { synchronized (_statSync) @@ -162,8 +240,13 @@ public class StatsManager extends MiniDbClientPlugin exception.printStackTrace(); } } - + public boolean incrementStat(final int accountId, final String statName, final long value) + { + return incrementStat(accountId, statName, value, false); + } + + public boolean incrementStat(final int accountId, final String statName, final long value, boolean overRide) { // This will register a new stat if we don't have one, otherwise it will just run the callback registerNewStat(statName, new Runnable() @@ -175,7 +258,7 @@ public class StatsManager extends MiniDbClientPlugin uploadQueue.put(accountId, new NautHashMap()); uploadQueue.get(accountId).put(_stats.get(statName), value); - _repository.saveStats(uploadQueue); + _repository.saveStats(uploadQueue, overRide); } }); @@ -237,6 +320,7 @@ public class StatsManager extends MiniDbClientPlugin { addCommand(new TimeCommand(this)); addCommand(new GiveStatCommand(this)); + addCommand(new MasterBuilderUnban(this)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java index 12deca990..e8ac03479 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java @@ -6,16 +6,14 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.common.util.NautHashMap; import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.core.database.ResultSetCallable; import mineplex.core.database.column.ColumnVarChar; import mineplex.database.Tables; -import net.md_5.bungee.chat.TranslatableComponentSerializer; +import org.bukkit.plugin.java.JavaPlugin; import org.jooq.DSLContext; import org.jooq.Insert; import org.jooq.Record2; @@ -29,6 +27,7 @@ public class StatsRepository extends RepositoryBase { private static String RETRIEVE_STATS = "SELECT id, name FROM stats;"; private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);"; + public StatsRepository(JavaPlugin plugin) { @@ -68,9 +67,15 @@ public class StatsRepository extends RepositoryBase { executeUpdate(INSERT_STAT, new ColumnVarChar("name", 100, name)); } + + public void saveStats(NautHashMap> uploadQueue) + { + saveStats(uploadQueue, false); + } + @SuppressWarnings("rawtypes") - public void saveStats(NautHashMap> uploadQueue) + public void saveStats(NautHashMap> uploadQueue, boolean overRideStat) { try { @@ -83,13 +88,24 @@ public class StatsRepository extends RepositoryBase { for (Integer statId : uploadQueue.get(accountId).keySet()) { - Update update = context + if(overRideStat) + { + Update update = context + .update(Tables.accountStat) + .set(Tables.accountStat.value, ULong.valueOf(uploadQueue.get(accountId).get(statId))) + .where(Tables.accountStat.accountId.eq(accountId)) + .and(Tables.accountStat.statId.eq(statId)); + updates.add(update); + } + else + { + Update update = context .update(Tables.accountStat) .set(Tables.accountStat.value, Tables.accountStat.value.plus(uploadQueue.get(accountId).get(statId))) .where(Tables.accountStat.accountId.eq(accountId)) .and(Tables.accountStat.statId.eq(statId)); - - updates.add(update); + updates.add(update); + } Insert insert = context .insertInto(Tables.accountStat) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java new file mode 100644 index 000000000..a8075985a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java @@ -0,0 +1,104 @@ +package mineplex.core.stats.command; + +import java.util.Iterator; +import java.util.List; + +import mineplex.core.account.CoreClient; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.stats.StatsManager; + +import org.bukkit.entity.Player; + +public class MasterBuilderUnban extends CommandBase +{ + + public MasterBuilderUnban(StatsManager plugin) + { + super(plugin, Rank.ADMIN, "buildunban"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if(args.length != 1) + { + UtilPlayer.message(caller, F.main("MasterBuilder Unban", "/buildunban ")); + return; + } + + try + { + Plugin.getClientManager().getRepository().matchPlayerName(new Callback>() + { + + @Override + public void run(List matches) + { + boolean matchedExact = false; + + for (String match : matches) + { + if (match.equalsIgnoreCase(args[0])) + { + matchedExact = true; + } + } + + if (matchedExact) + { + for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext();) + { + if (!matchIterator.next().equalsIgnoreCase(args[0])) + { + matchIterator.remove(); + } + } + } + UtilPlayer.searchOffline(matches, new Callback() + { + @Override + public void run(String target) + { + if(target == null) + { + caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + args[0] + "'s account!")); + return; + } + Plugin.getClientManager().loadClientByName(target, new Runnable() + { + @Override + public void run() + { + CoreClient theClient = Plugin.getClientManager().Get(target); + + if(theClient != null) + { + Plugin.incrementStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0, true); // True = Resets the stat + caller.sendMessage(F.main("MasterBuilder Unban", "The user " + target + " has been unbanned from Master Builders")); + } + else + { + caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + target + "'s client!")); + return; + } + } + }); + } + }, caller, args[0], false); + } + + }, args[0]); + + } + catch(Exception e) + { + e.printStackTrace(); + caller.sendMessage(F.main("MasterBuilder Unban", "Exception caught! Please contact Morten and explain what happened.")); + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java index bab37072b..159bd4f83 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java @@ -8,13 +8,13 @@ import mineplex.core.reward.RewardType; public enum TreasureType { - OLD(C.cYellow + "Old Treasure", "Old Chest", "Old", RewardType.OldChest, Material.CHEST, TreasureStyle.OLD, RewardPool.Type.NORMAL), + OLD(C.cYellow + "Old Treasure", "Old Chest", "Old", RewardType.OldChest, Material.CHEST, TreasureStyle.OLD, RewardPool.Type.NORMAL, true, 1000), - ANCIENT(C.cGold + "Ancient Treasure", "Ancient Chest", "Ancient", RewardType.AncientChest, Material.TRAPPED_CHEST, TreasureStyle.ANCIENT, RewardPool.Type.NORMAL), + ANCIENT(C.cGold + "Ancient Treasure", "Ancient Chest", "Ancient", RewardType.AncientChest, Material.TRAPPED_CHEST, TreasureStyle.ANCIENT, RewardPool.Type.NORMAL, true, 5000), - MYTHICAL(C.cRed + "Mythical Treasure", "Mythical Chest", "Mythical", RewardType.MythicalChest, Material.ENDER_CHEST, TreasureStyle.MYTHICAL, RewardPool.Type.NORMAL), + MYTHICAL(C.cRed + "Mythical Treasure", "Mythical Chest", "Mythical", RewardType.MythicalChest, Material.ENDER_CHEST, TreasureStyle.MYTHICAL, RewardPool.Type.NORMAL, true, 10000), - CHRISTMAS(C.cDGreen + "Winter Holiday Treasure", "Winter Chest", "Christmas", RewardType.WinterChest, Material.CHEST, TreasureStyle.CHRISTMAS, RewardPool.Type.WINTER_HOLIDAY); + CHRISTMAS(C.cDGreen + "Winter Holiday Treasure", "Winter Chest", "Christmas", RewardType.WinterChest, Material.CHEST, TreasureStyle.CHRISTMAS, RewardPool.Type.WINTER_HOLIDAY, false, 15000); private final String _name; private final RewardType _rewardType; @@ -23,8 +23,10 @@ public enum TreasureType private final String _itemName; private final String _statName; private final RewardPool.Type _rewardPool; + private final int _purchasePrice; + private final boolean _purchasable; - TreasureType(String name, String itemName, String statName, RewardType rewardType, Material material, TreasureStyle treasureStyle, RewardPool.Type rewardPool) + TreasureType(String name, String itemName, String statName, RewardType rewardType, Material material, TreasureStyle treasureStyle, RewardPool.Type rewardPool, boolean purchasable, int purchasePrice) { _name = name; _itemName = itemName; @@ -33,6 +35,8 @@ public enum TreasureType _material = material; _treasureStyle = treasureStyle; _rewardPool = rewardPool; + _purchasePrice = purchasePrice; + _purchasable = purchasable; } public RewardType getRewardType() @@ -69,4 +73,14 @@ public enum TreasureType { return _rewardPool; } + + public int getPurchasePrice() + { + return _purchasePrice; + } + + public boolean isPurchasable() + { + return _purchasable; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index a0ad48354..ca2ddc8b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -122,9 +122,11 @@ public class TreasurePage extends ShopPageBase christmasLore.add(ChatColor.RESET + C.cGreen + "Click to Open!"); else { + /* christmasLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "15000 Treasure Shards"); christmasLore.add(" "); christmasLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop"); + */ } List cosmicLore = new ArrayList(); @@ -143,18 +145,21 @@ public class TreasurePage extends ShopPageBase addItem(40, shards); - if (basicCount > 0) addButton(20, basic, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.OLD)); - else addButton(20, basic, new BuyChestButton(getPlayer(), _inventoryManager, this, "Old Chest", Material.CHEST, 1000)); - - if (heroicCount > 0) addButton(22, heroic, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.ANCIENT)); - else addButton(22, heroic, new BuyChestButton(getPlayer(), _inventoryManager, this, "Ancient Chest", Material.CHEST, 5000)); - - if (legendaryCount > 0) addButton(24, legendary, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.MYTHICAL)); - else addButton(24, legendary, new BuyChestButton(getPlayer(), _inventoryManager, this, "Mythical Chest", Material.ENDER_CHEST, 10000)); - - if (christmasCount > 0) addButton(12, christmas, new OpenTreasureButton(getPlayer(), _treasureLocation, TreasureType.CHRISTMAS)); - else addButton(12, christmas, new BuyChestButton(getPlayer(), _inventoryManager, this, TreasureType.CHRISTMAS.getItemName(), Material.SNOW_BALL, 15000)); + addChest(20, basic, TreasureType.OLD, basicCount); + addChest(22, heroic, TreasureType.ANCIENT, heroicCount); + addChest(24, legendary, TreasureType.MYTHICAL, legendaryCount); + addChest(12, christmas, TreasureType.CHRISTMAS, christmasCount); addItem(14, cosmic); } + + private void addChest(int slot, ItemStack item, TreasureType treasureType, int owned) + { + if (owned > 0) + addButton(slot, item, new OpenTreasureButton(getPlayer(), _treasureLocation, treasureType)); + else if (treasureType.isPurchasable()) + addButton(slot, item, new BuyChestButton(getPlayer(), _inventoryManager, this, treasureType.getItemName(), Material.CHEST, treasureType.getPurchasePrice())); + else + setItem(slot, item); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java index 4b11a5e29..5df3e3a33 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java @@ -4,7 +4,10 @@ import java.io.File; import java.io.FileInputStream; import java.io.FilenameFilter; import java.io.IOException; +import java.util.Properties; +import mineplex.core.updater.command.BuildVersionCommand; +import mineplex.core.updater.command.RestartServerCommand; import org.apache.commons.codec.digest.DigestUtils; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -34,28 +37,33 @@ public class FileUpdater extends MiniPlugin private boolean _needUpdate; private boolean _enabled = true; + + private Properties _buildProperties; public FileUpdater(JavaPlugin plugin, Portal portal, String serverName, Region region) { super("File Updater", plugin); - + _portal = portal; _serverName = serverName; _region = region; - + GetPluginMd5s(); - + if (new File("IgnoreUpdates.dat").exists()) _enabled = false; - + // Register the server command type for future use ServerCommandManager.getInstance().registerCommandType("RestartCommand", RestartCommand.class, new RestartHandler(plugin, _serverName, _region)); + + loadBuildProperties(); } - + @Override public void addCommands() { addCommand(new RestartServerCommand(this)); + addCommand(new BuildVersionCommand(this)); } @EventHandler @@ -224,6 +232,25 @@ public class FileUpdater extends MiniPlugin } } + private void loadBuildProperties() + { + _buildProperties = new Properties(); + + try + { + _buildProperties.load(this.getClass().getResourceAsStream("/version.properties")); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + public Properties getBuildProperties() + { + return _buildProperties; + } + public Region getRegion() { return _region; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/command/BuildVersionCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/command/BuildVersionCommand.java new file mode 100644 index 000000000..0e5e2b10f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/command/BuildVersionCommand.java @@ -0,0 +1,33 @@ +package mineplex.core.updater.command; + +import java.util.Properties; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.updater.FileUpdater; + +public class BuildVersionCommand extends CommandBase +{ + public BuildVersionCommand(FileUpdater plugin) + { + super(plugin, Rank.MODERATOR, "bversion"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Properties buildProperties = Plugin.getBuildProperties(); + + String git = buildProperties.getProperty("build.git", "Unknown"); + String date = buildProperties.getProperty("build.date", "Unknown"); + String user = buildProperties.getProperty("build.user", "Unknown"); + + caller.sendMessage(C.cRedB + "Build Version;"); + caller.sendMessage(" " + C.cGold + "Date " + C.cWhite + date); + caller.sendMessage(" " + C.cGold + "User " + C.cWhite + user); + caller.sendMessage(" " + C.cGold + "Git " + C.cWhite + git); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/RestartServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/command/RestartServerCommand.java similarity index 93% rename from Plugins/Mineplex.Core/src/mineplex/core/updater/RestartServerCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/updater/command/RestartServerCommand.java index 1067506b0..544ae231e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/RestartServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/command/RestartServerCommand.java @@ -1,4 +1,4 @@ -package mineplex.core.updater; +package mineplex.core.updater.command; import org.bukkit.entity.Player; @@ -9,6 +9,7 @@ import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.portal.Portal; +import mineplex.core.updater.FileUpdater; import mineplex.serverdata.commands.RestartCommand; public class RestartServerCommand extends CommandBase diff --git a/Plugins/Mineplex.Core/version.properties b/Plugins/Mineplex.Core/version.properties new file mode 100644 index 000000000..6678e7153 --- /dev/null +++ b/Plugins/Mineplex.Core/version.properties @@ -0,0 +1,3 @@ +build.git=${describe} +build.date=${timestamp} +build.user=${user.name} \ No newline at end of file diff --git a/Plugins/Mineplex.DDoSProtectionSwitcher/.classpath b/Plugins/Mineplex.DDoSProtectionSwitcher/.classpath deleted file mode 100644 index 3cc5b666a..000000000 --- a/Plugins/Mineplex.DDoSProtectionSwitcher/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/Plugins/Mineplex.DDoSProtectionSwitcher/.externalToolBuilders/DDoSProtectionSwitcher.launch b/Plugins/Mineplex.DDoSProtectionSwitcher/.externalToolBuilders/DDoSProtectionSwitcher.launch deleted file mode 100644 index ae42dca77..000000000 --- a/Plugins/Mineplex.DDoSProtectionSwitcher/.externalToolBuilders/DDoSProtectionSwitcher.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.DDoSProtectionSwitcher/.project b/Plugins/Mineplex.DDoSProtectionSwitcher/.project deleted file mode 100644 index 487269c99..000000000 --- a/Plugins/Mineplex.DDoSProtectionSwitcher/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - Mineplex.DDoSProtectionSwitcher - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/DDoSProtectionSwitcher.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.DDoSProtectionSwitcher/pom.xml b/Plugins/Mineplex.DDoSProtectionSwitcher/pom.xml new file mode 100644 index 000000000..2eadc0add --- /dev/null +++ b/Plugins/Mineplex.DDoSProtectionSwitcher/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + + + com.mineplex + mineplex-app + dev-SNAPSHOT + ../app.xml + + + DDoSProtectionSwitcher + mineplex-ddosprotectionswitcher + + + + com.google.code.gson + gson + + + javax.mail + mail + + + org.apache.httpcomponents + httpclient + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + mineplex.ddos.DDoSProtectionSwitcher + + + + + + + diff --git a/Plugins/Mineplex.Database/.classpath b/Plugins/Mineplex.Database/.classpath deleted file mode 100644 index cc5554790..000000000 --- a/Plugins/Mineplex.Database/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/Plugins/Mineplex.Database/.project b/Plugins/Mineplex.Database/.project deleted file mode 100644 index 202b668eb..000000000 --- a/Plugins/Mineplex.Database/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - Mineplex.Database - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.Database/Mineplex.Database.iml b/Plugins/Mineplex.Database/Mineplex.Database.iml deleted file mode 100644 index fa0ef0ae0..000000000 --- a/Plugins/Mineplex.Database/Mineplex.Database.iml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Database/pom.xml b/Plugins/Mineplex.Database/pom.xml new file mode 100644 index 000000000..f00a8d581 --- /dev/null +++ b/Plugins/Mineplex.Database/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + + com.mineplex + mineplex-parent + dev-SNAPSHOT + + + mineplex-database + + + + org.jooq + jooq-codegen + + + diff --git a/Plugins/Mineplex.EnjinTranslator/.classpath b/Plugins/Mineplex.EnjinTranslator/.classpath deleted file mode 100644 index 224f11ab1..000000000 --- a/Plugins/Mineplex.EnjinTranslator/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Plugins/Mineplex.EnjinTranslator/.externalToolBuilders/EnjinTranslator.launch b/Plugins/Mineplex.EnjinTranslator/.externalToolBuilders/EnjinTranslator.launch deleted file mode 100644 index 30d5b0d95..000000000 --- a/Plugins/Mineplex.EnjinTranslator/.externalToolBuilders/EnjinTranslator.launch +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.EnjinTranslator/.externalToolBuilders/Translator.launch b/Plugins/Mineplex.EnjinTranslator/.externalToolBuilders/Translator.launch deleted file mode 100644 index 12d9261c3..000000000 --- a/Plugins/Mineplex.EnjinTranslator/.externalToolBuilders/Translator.launch +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.EnjinTranslator/.project b/Plugins/Mineplex.EnjinTranslator/.project deleted file mode 100644 index b8d031388..000000000 --- a/Plugins/Mineplex.EnjinTranslator/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - EnjinTranslator - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/Translator.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.EnjinTranslator/.settings/org.eclipse.core.resources.prefs b/Plugins/Mineplex.EnjinTranslator/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/Plugins/Mineplex.EnjinTranslator/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/Plugins/Mineplex.EnjinTranslator/EnjinTranslator.iml b/Plugins/Mineplex.EnjinTranslator/EnjinTranslator.iml deleted file mode 100644 index 950a6d03a..000000000 --- a/Plugins/Mineplex.EnjinTranslator/EnjinTranslator.iml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.EnjinTranslator/pom.xml b/Plugins/Mineplex.EnjinTranslator/pom.xml new file mode 100644 index 000000000..bb8ce5969 --- /dev/null +++ b/Plugins/Mineplex.EnjinTranslator/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + + com.mineplex + mineplex-plugin + dev-SNAPSHOT + ../plugin.xml + + + EnjinTranslator + mineplex-enjintranslator + + + + ${project.groupId} + mineplex-core + ${project.version} + + + diff --git a/Plugins/Mineplex.Game.Clans.Core/.classpath b/Plugins/Mineplex.Game.Clans.Core/.classpath deleted file mode 100644 index c6a118cbe..000000000 --- a/Plugins/Mineplex.Game.Clans.Core/.classpath +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Game.Clans.Core/.project b/Plugins/Mineplex.Game.Clans.Core/.project deleted file mode 100644 index fb0cce853..000000000 --- a/Plugins/Mineplex.Game.Clans.Core/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - Mineplex.Game.Clans.Core - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.Game.Clans.Core/Mineplex.Game.Clans.Core.iml b/Plugins/Mineplex.Game.Clans.Core/Mineplex.Game.Clans.Core.iml deleted file mode 100644 index d33a27278..000000000 --- a/Plugins/Mineplex.Game.Clans.Core/Mineplex.Game.Clans.Core.iml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans.Core/pom.xml b/Plugins/Mineplex.Game.Clans.Core/pom.xml new file mode 100644 index 000000000..8a51dd13a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans.Core/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + + com.mineplex + mineplex-parent + dev-SNAPSHOT + + + mineplex-game-clans-core + + + + ${project.groupId} + mineplex-core + ${project.version} + + + diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/war/ClanWarData.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/war/ClanWarData.java index 6fdb566fc..d286b6977 100644 --- a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/war/ClanWarData.java +++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/war/ClanWarData.java @@ -103,6 +103,17 @@ public class ClanWarData _clanAPoints--; else throw new RuntimeException("ClanWarData::increment Invalid Clan for War. ClanA: " + _clanA + ", ClanB: " + _clanB + ", Lookup Clan: " + clan); } + + public void set(String clan, int points) + { + update(); + + if (_clanA.equals(clan)) + _clanAPoints++; + else if (_clanB.equals(clan)) + _clanAPoints--; + else throw new RuntimeException("ClanWarData::increment Invalid Clan for War. ClanA: " + _clanA + ", ClanB: " + _clanB + ", Lookup Clan: " + clan); + } private void update() { diff --git a/Plugins/Mineplex.Game.Clans/.classpath b/Plugins/Mineplex.Game.Clans/.classpath deleted file mode 100644 index 4a7e01944..000000000 --- a/Plugins/Mineplex.Game.Clans/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Game.Clans/.externalToolBuilders/ClansBuilder.launch b/Plugins/Mineplex.Game.Clans/.externalToolBuilders/ClansBuilder.launch deleted file mode 100644 index 32132a71e..000000000 --- a/Plugins/Mineplex.Game.Clans/.externalToolBuilders/ClansBuilder.launch +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Game.Clans/.project b/Plugins/Mineplex.Game.Clans/.project deleted file mode 100644 index d9fd96609..000000000 --- a/Plugins/Mineplex.Game.Clans/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - Mineplex.Game.Clans - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/ClansBuilder.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.Game.Clans/Mineplex.Game.Clans.iml b/Plugins/Mineplex.Game.Clans/Mineplex.Game.Clans.iml deleted file mode 100644 index c5914c65c..000000000 --- a/Plugins/Mineplex.Game.Clans/Mineplex.Game.Clans.iml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/pom.xml b/Plugins/Mineplex.Game.Clans/pom.xml new file mode 100644 index 000000000..73a6d5ad9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + + com.mineplex + mineplex-plugin + dev-SNAPSHOT + ../plugin.xml + + + Clans + mineplex-game-clans + + + + ${project.groupId} + mineplex-game-clans-core + ${project.version} + + + ${project.groupId} + mineplex-minecraft-game-classcombat + ${project.version} + + + diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index fd1887256..69a6891d4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -13,6 +13,8 @@ import mineplex.core.antihack.AntiHack; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; +import mineplex.core.common.events.ServerShutdownEvent; +import mineplex.core.delayedtask.DelayedTask; import mineplex.core.donation.DonationManager; import mineplex.core.explosion.Explosion; import mineplex.core.friend.FriendManager; @@ -39,6 +41,7 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.visibility.VisibilityManager; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.items.GearManager; import mineplex.game.clans.shop.building.BuildingShop; import mineplex.game.clans.shop.farming.FarmingShop; @@ -50,7 +53,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer; public class Clans extends JavaPlugin { - public static final String VERSION = "0.17d"; + public static final String VERSION = "0.19"; private String WEB_CONFIG = "webServer"; // Modules @@ -77,6 +80,8 @@ public class Clans extends JavaPlugin ItemStackFactory.Initialize(this, false); + DelayedTask.Initialize(this); + Recharge.Initialize(this); VisibilityManager.Initialize(this); // new ProfileCacheManager(this); @@ -96,7 +101,9 @@ public class Clans extends JavaPlugin Teleport teleport = new Teleport(this, _clientManager); Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - + + new ClansBanManager(this, _clientManager, _donationManager); + Punish punish = new Punish(this, webServerAddress, _clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); AntiHack.Instance.setKick(false); @@ -124,7 +131,7 @@ public class Clans extends JavaPlugin GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager); HologramManager hologram = new HologramManager(this, packetHandler); - _clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), packetHandler, _clientManager, _donationManager, preferenceManager, blockRestore, teleport, chat, customGear, hologram, webServerAddress); + _clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, teleport, chat, customGear, hologram, webServerAddress); new Recipes(this); new Farming(this); new BuildingShop(_clansManager, _clientManager, _donationManager); @@ -169,5 +176,7 @@ public class Clans extends JavaPlugin // Need to notify WorldEventManager of server shutdown, this seemed like // the only decent way to do it _clansManager.onDisable(); + + getServer().getPluginManager().callEvent(new ServerShutdownEvent(this)); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java index 5e82714fe..fac283def 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java @@ -20,19 +20,19 @@ import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.clans.ClansUtility.ClanRelation; -import mineplex.game.clans.core.war.ClanWarData; -import net.minecraft.server.v1_8_R3.Material; +import mineplex.game.clans.clans.tntGenerator.TntGenerator; import mineplex.game.clans.core.repository.tokens.ClanAllianceToken; import mineplex.game.clans.core.repository.tokens.ClanMemberToken; import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken; import mineplex.game.clans.core.repository.tokens.ClanToken; - -import mineplex.game.clans.clans.tntGenerator.TntGenerator; import mineplex.game.clans.core.repository.tokens.ClanWarToken; +import mineplex.game.clans.core.war.ClanWarData; +import net.minecraft.server.v1_8_R3.Material; public class ClanInfo { @@ -374,6 +374,22 @@ public class ClanInfo player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 2f); } } + + public void inform(String top, String bottom, String ignore) + { + for (UUID cur : getMembers().keySet()) + { + Player player = UtilPlayer.searchExact(cur); + + if (player == null) + continue; + + if (player.getName().equals(ignore)) + continue; + + UtilTextMiddle.display(top, bottom, 20, 100, 20, player); + } + } public String getName() { @@ -507,6 +523,11 @@ public class ClanInfo public int getEnergy() { + if (_energy > getEnergyMax()) + { + _energy = getEnergyMax(); + } + return _energy; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java index 2de32fd0b..13e07c1cb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java @@ -10,6 +10,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.core.repository.ClanTerritory; +import mineplex.game.clans.core.war.ClanWarData; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -25,7 +26,7 @@ public class ClansAdmin public void command(Player caller, String[] args) { - if (!Clans.getClientManager().hasRank(caller, Rank.ADMIN) && !caller.isOp()) + if (!Clans.getClientManager().hasRank(caller, Rank.ADMIN) && !Clans.getClientManager().Get(caller).GetRank().equals(Rank.CMOD) && !caller.isOp()) { return; } @@ -80,6 +81,9 @@ public class ClansAdmin else if (args[1].equalsIgnoreCase("autoclaim")) autoclaim(caller); + + else if (args[1].equalsIgnoreCase("wp")) + wp(caller, args); else help(caller); @@ -89,23 +93,24 @@ public class ClansAdmin { UtilPlayer.message(caller, F.main("Clans Admin", "Admin Commands List;")); - UtilPlayer.message(caller, F.help("/c x create ", "Create Admin Clan", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/c x create ", "Create Admin Clan", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x set ", "Set Mimic Clan", Rank.ALL)); + UtilPlayer.message(caller, F.help("/c x set ", "Set Mimic Clan", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x wp [remove/set/add] ", "Modify war points", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x home (set)", "Teleport to Mimic Home", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c x invite ", "Invite Player to Mimic", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c x promote ", "Promote Player in Mimic", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c x demote ", "Demote Player in Mimic", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c x kick ", "Kick Player from Mimic", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c x ally ", "Send Alliance to Mimic", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c x trust ", "Give Trust to Clan", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c x neutral ", "Set Neutrality", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c x enemy ", "Start Invasion", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c x claim", "Claim Territory for Mimic", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c x unclaim (all)", "Unclaim Territory for Mimic", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c x delete", "Delete Mimic Clan", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c x autoclaim", "AutoClaim for Mimic Clan", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/c x home (set)", "Teleport to Mimic Home", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x invite ", "Invite Player to Mimic", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x promote ", "Promote Player in Mimic", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x demote ", "Demote Player in Mimic", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x kick ", "Kick Player from Mimic", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x ally ", "Send Alliance to Mimic", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x trust ", "Give Trust to Clan", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x neutral ", "Set Neutrality", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x enemy ", "Start Invasion", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x claim", "Claim Territory for Mimic", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x unclaim (all)", "Unclaim Territory for Mimic", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x delete", "Delete Mimic Clan", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x autoclaim", "AutoClaim for Mimic Clan", Rank.CMOD)); UtilPlayer.message(caller, F.main("Mimic Clan", Clans.Get(caller).getMimic())); } @@ -269,6 +274,64 @@ public class ClansAdmin } }); } + + public void wp(Player caller, String[] args) + { + ClanInfo clan = getMimic(caller, true); + + if (clan == null) + return; + + if (args.length < 5) + { + UtilPlayer.message(caller, F.main("Clans Admin", "You did not supply an operation, value, and clan name.")); + return; + } + + ClanInfo clanAgainst = Clans.getClan(args[4]); + + if (clanAgainst == null) + { + UtilPlayer.message(caller, F.main("Clans Admin", "Invalid Clan against provided.")); + return; + } + + String operation = args[2]; + int value; + + try + { + value = Integer.parseInt(args[3]); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main("Clans Admin", "Invalid value provided.")); + return; + } + + if (operation.equalsIgnoreCase("remove")) + { + ClanWarData war = clan.getWarData(clanAgainst); + +// war.set +// +// Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success -> { +// UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB()))); +// }); + } + else if (operation.equalsIgnoreCase("set")) + { + + } + else if (operation.equalsIgnoreCase("add")) + { + + } + else + { + UtilPlayer.message(caller, F.main("Clans Admin", "Invalid operation provided.")); + } + } public void invite(Player caller, String[] args) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBlacklist.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBlacklist.java index dc0b837f7..1483b9949 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBlacklist.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansBlacklist.java @@ -38,8 +38,4 @@ public class ClansBlacklist return true; } - - public static void addBlacklist(String blacklist) { - BLACKLISTED_NAMES.add(blacklist); - } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java index 9d06f8fa4..b848e7d28 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java @@ -532,8 +532,8 @@ public class ClansDataAccessLayer } // Log - // _manager.log("Added Claim for [" + name + "] at [" + chunk + "] by [" - // + player + "]."); + _manager.log("Added Claim for [" + name + "] at [" + chunk + "] by [" + + player + "]."); return true; } @@ -595,6 +595,8 @@ public class ClansDataAccessLayer // Log if (player != null) _manager.log("Removed Claim for [" + clan.getName() + "] at [" + chunk + "] by [" + player + "]."); + else + _manager.log("Removed Claim for [" + clan.getName() + "] at [" + chunk + "] by [NO ONE?!]."); // Bed Removal if (clan.getHome() != null && UtilWorld.chunkToStr(clan.getHome().getChunk()).equals(chunk)) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java index 7e8723996..46f5a3708 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java @@ -65,7 +65,9 @@ public class ClansDisplay extends MiniPlugin boolean safe = Clans.getClanUtility().isSafe(player); - UtilServer.getServer().getPluginManager().callEvent(new PlayerEnterTerritoryEvent(player, client.getOwner(), owner, owner.equals("Wilderness") ? false : Clans.getClanUtility().getClaim(player.getLocation()).isSafe(player.getLocation()))); + PlayerEnterTerritoryEvent event = new PlayerEnterTerritoryEvent(player, client.getOwner(), owner, owner.equals("Wilderness") ? false : Clans.getClanUtility().getClaim(player.getLocation()).isSafe(player.getLocation()), true); + + UtilServer.getServer().getPluginManager().callEvent(event); if (!client.isMapOn()) { @@ -87,13 +89,13 @@ public class ClansDisplay extends MiniPlugin if (showChange) { - displayOwner(player); - // Event + if (event.willSendMessage()) displayOwner(player); } } else { - displayOwner(player); + if (event.willSendMessage()) displayOwner(player); + displayMap(player); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index d51bb3f24..218d7947b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -1,9 +1,9 @@ package mineplex.game.clans.clans; import java.io.File; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.TimeZone; @@ -16,6 +16,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; +import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; @@ -28,14 +29,17 @@ import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.Recipe; import org.bukkit.plugin.java.JavaPlugin; +import com.google.common.io.ByteArrayDataOutput; +import com.google.common.io.ByteStreams; + import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; +import mineplex.core.chat.MessageData; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -58,6 +62,8 @@ import mineplex.core.packethandler.PacketHandler; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; +import mineplex.core.punish.Punish; +import mineplex.core.punish.PunishClient; import mineplex.core.stats.StatsManager; import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; @@ -72,6 +78,7 @@ import mineplex.game.clans.clans.commands.ClansCommand; import mineplex.game.clans.clans.commands.ClansLoginManager; import mineplex.game.clans.clans.commands.KillCommand; import mineplex.game.clans.clans.commands.MapCommand; +import mineplex.game.clans.clans.commands.Meow; import mineplex.game.clans.clans.commands.RegionsCommand; import mineplex.game.clans.clans.data.PlayerClan; import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; @@ -79,6 +86,7 @@ import mineplex.game.clans.clans.gui.ClanShop; import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.map.ItemMapManager; import mineplex.game.clans.clans.observer.ObserverManager; +import mineplex.game.clans.clans.outpost.OutpostManager; import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.potato.PotatoManager; import mineplex.game.clans.clans.pvptimer.PvpTimer; @@ -176,6 +184,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati private Explosion _explosion; private GoldManager _goldManager; + private Punish _punish; + private int _inviteExpire = 2; private int _nameMin = 3; private int _nameMax = 10; @@ -199,12 +209,19 @@ public class ClansManager extends MiniClientPluginimplements IRelati // Spawn area - public ClansManager(JavaPlugin plugin, String serverName, PacketHandler packetHandler, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) + public ClansManager(JavaPlugin plugin, String serverName, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) { super("Clans Manager", plugin); + if (serverName.equals("GarboClans-1")) + { + addCommand(new Meow(new OutpostManager(this))); + } + _instance = this; + _punish = punish; + _serverName = serverName; _clientManager = clientManager; _combatManager = new CombatManager(plugin); @@ -245,7 +262,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati _explosion = new Explosion(plugin, blockRestore); - new ClansLoginManager(getPlugin(), clientManager, _serverName); +// new ClansLoginManager(getPlugin(), clientManager, _serverName); _clanShop = new ClanShop(this, clientManager, donationManager); @@ -366,17 +383,26 @@ public class ClansManager extends MiniClientPluginimplements IRelati hologram.start(); } - // Disables beds from being crafted - Iterator it = _plugin.getServer().recipeIterator(); - Recipe recipe; - while (it.hasNext()) - { - recipe = it.next(); - if (recipe != null && recipe.getResult().getType() == Material.BED) - { - it.remove(); - } - } +// Iterator it = _plugin.getServer().recipeIterator(); +// Recipe recipe; +// while (it.hasNext()) +// { +// recipe = it.next(); +// if (recipe != null) +// { +// if (recipe.getResult().getType() == Material.SMOOTH_BRICK) +// { +// it.remove(); +// } +// } +// } +// +// final ShapedRecipe brrecipe = new ShapedRecipe(new ItemStack(Material.SMOOTH_BRICK, 1)); +// brrecipe.shape("XX", "XX", ""); +// brrecipe.setIngredient('X', Material.STONE); +// UtilServer.getServer().addRecipe(brrecipe); +// + Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict"); } @Override @@ -578,12 +604,42 @@ public class ClansManager extends MiniClientPluginimplements IRelati clanInfo.playerOnline(player); } - if (_clientManager.hasRank(player, Rank.DEVELOPER) || player.getName().equals("NewGarbo")) + if (_clientManager.hasRank(player, Rank.DEVELOPER) || player.getUniqueId().toString().equals("d8646a35-33a8-43c6-9e7c-2e871a6b86c9")) { player.setOp(true); } } + @EventHandler + public void disallowReplayMod(PlayerJoinEvent event) + { + // happens 20 ticks later because player channels don't + // seem to work immediately after joining. + runSyncLater(() -> { + ByteArrayDataOutput bado = ByteStreams.newDataOutput(); + + bado.writeUTF("no_xray"); + bado.writeBoolean(true); + + bado.writeUTF("no_noclip"); + bado.writeBoolean(true); + + bado.writeUTF("only_recording_player"); + bado.writeBoolean(true); + + event.getPlayer().sendPluginMessage(_plugin, "Replay|Restrict", bado.toByteArray()); + }, 20L); + } + + @EventHandler + public void disableFlyKick(PlayerKickEvent event) + { + if (event.getReason().toLowerCase().contains("flying is not enabled on this server")) + { + event.setCancelled(true); + } + } + @EventHandler public void denyBow(EntityShootBowEvent event) { @@ -610,13 +666,121 @@ public class ClansManager extends MiniClientPluginimplements IRelati } } + private void handleClanChat(Player player, String message, ClanInfo clan, String rank) + { + for (Player cur : clan.getOnlinePlayers()) + { + message = _chat.getFilteredMessage(player, message); + + UtilPlayer.message(cur, String.format(rank + C.cAqua + "%s " + C.cDAqua + "%s", player.getName(), message)); + } + } + + private void handleAllyChat(Player player, String message, ClanInfo clan, String rank) + { + List recipients = new ArrayList<>(); + + clan.getOnlinePlayers().forEach(recipients::add); + + for (String allyName : clan.getAllyMap().keySet()) + { + ClanInfo ally = _clanUtility.getClanByClanName(allyName); + if (ally == null) continue; + + ally.getOnlinePlayers().forEach(recipients::add); + } + + final String filtered = _chat.getFilteredMessage(player, message); + + recipients.forEach(p -> UtilPlayer.message(p, String.format(rank + C.cDGreen + clan.getName() + " " + C.cDGreen + "%s " + C.cGreen + "%s", player.getName(), filtered))); + + recipients.clear(); + } + + private void handleRegularChat(AsyncPlayerChatEvent event, ClanInfo clan, String rank) + { + if (clan == null) + { + UtilServer.broadcast(String.format(rank + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), _chat.getFilteredMessage(event.getPlayer(), event.getMessage()))); + return; + } + + List recipients = new ArrayList<>(); + + for (Player other : UtilServer.getPlayers()) + { + ClanInfo otherClan = _clanUtility.getClanByPlayer(other); + + if (otherClan == null) + { + recipients.add(other); + } + else + { + String message = _chat.getFilteredMessage(event.getPlayer(), event.getMessage()); + ClanRelation rel = _clanUtility.rel(clan, otherClan); + + other.sendMessage(rank + rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + C.cWhite + message); + } + } + + recipients.forEach(p -> p.sendMessage(String.format(rank + C.cGold + clan.getName() + " " + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), event.getMessage()))); + + recipients.clear(); + } + @EventHandler + public void onSignChange(SignChangeEvent event) + { + PunishClient punishclient = _punish.GetClient(event.getPlayer().getName()); + + if (punishclient != null && punishclient.IsMuted()) + { + for (int i = 0; i < event.getLines().length; i++) + { + event.setLine(i, ""); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST) public void handlePlayerChat(AsyncPlayerChatEvent event) { + event.setCancelled(false); + + _chat.HandleChat(event); + if (event.isCancelled()) { return; } + else + { + event.setCancelled(true); + } + + +// PunishClient punishclient = _punish.GetClient(event.getPlayer().getName()); +// +// if (punishclient != null && punishclient.IsMuted()) +// { +// return; +// } +// +// if (_chat.SilenceCheck(event.getPlayer())) +// { +// return; +// } + + + +// MessageData lastMessage = _chat.lastMessage(event.getPlayer()); +// long chatSlowTime = 1000L * _chat.getChatSlow(); +// long timeDiff = System.currentTimeMillis() - lastMessage.getTimeSent(); +// if (timeDiff < chatSlowTime && !_clientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER)) +// { +// +// } ClientClan client = Get(event.getPlayer()); @@ -634,91 +798,21 @@ public class ClansManager extends MiniClientPluginimplements IRelati if (client.isClanChat() && clan != null) { - event.setFormat(rank+ C.cAqua + "%1$s " + C.cDAqua + "%2$s"); - event.getRecipients().clear(); - - for (ClansPlayer cur : clan.getMembers().values()) - { - Player player = UtilPlayer.searchExact(cur.getUuid()); - - if (player == null) continue; - - event.getRecipients().add(player); - } + handleClanChat(event.getPlayer(), event.getMessage(), clan, rank); } else if (client.isAllyChat() && clan != null) { - event.setFormat(rank+ C.cDGreen + clan.getName() + " " + C.cDGreen + "%1$s " + C.cGreen + "%2$s"); - event.getRecipients().clear(); - - for (ClansPlayer cur : clan.getMembers().values()) - { - Player player = UtilPlayer.searchExact(cur.getUuid()); - - if (player == null) continue; - - event.getRecipients().add(player); - } - - for (String allyName : clan.getAllyMap().keySet()) - { - ClanInfo ally = _clanUtility.getClanByClanName(allyName); - if (ally == null) continue; - - for (ClansPlayer cur : ally.getMembers().values()) - { - Player player = UtilPlayer.searchExact(cur.getUuid()); - - if (player == null) continue; - - event.getRecipients().add(player); - } - } + handleAllyChat(event.getPlayer(), event.getMessage(), clan, rank); } else { - if (clan == null) - { - event.setFormat(rank + C.cYellow + "%1$s " + C.cWhite + "%2$s"); - System.out.println(_clientManager.Get(event.getPlayer()).GetRank().name() + " " + event.getPlayer().getName() + " " + event.getMessage()); - return; - } - - event.getRecipients().clear(); - event.setFormat(rank + C.cGold + clan.getName() + " " + C.cYellow + "%1$s " + C.cWhite + "%2$s"); - - for (Player other : UtilServer.getPlayers()) - { - ClanInfo otherClan = _clanUtility.getClanByPlayer(other); - - if (otherClan == null) - { - event.getRecipients().add(other); - } - else - { - String message = event.getMessage(); - message = _chat.getFilteredMessage(event.getPlayer(), message); - ClanRelation rel = _clanUtility.rel(clan, otherClan); - String formatted = rank + rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + C.cWhite + message; - other.sendMessage(formatted); - } - } + handleRegularChat(event, clan, rank); } System.out.println((clan == null ? "" : clan.getName()) + " " + _clientManager.Get(event.getPlayer()).GetRank().name() + " " + event.getPlayer().getName() + " " + event.getMessage()); } - @EventHandler - public void command(PlayerCommandPreprocessEvent event){ - if (event.getMessage().startsWith("/blacklist ")){ - String blacklist = event.getMessage().split(" ")[1]; - - ClansBlacklist.addBlacklist(blacklist); - } - } - public void messageClan(ClanInfo clan, String message) { for (Player player : clan.getOnlinePlayers()) @@ -747,22 +841,22 @@ public class ClansManager extends MiniClientPluginimplements IRelati public void chatClan(ClanInfo clan, Player caller, String message) { - messageClan(clan, C.cAqua + caller.getName() + " " + C.cDAqua + message); + String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " "; + + if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH)) + rank = ""; + + handleClanChat(caller, message, clan, rank); } public void chatAlly(ClanInfo clan, Player caller, String message) { - String sendMessage = C.cDGreen + clan.getName() + " " + C.cDGreen + caller.getName() + " " + C.cGreen + message; + String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " "; - messageClan(clan, sendMessage); + if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH)) + rank = ""; - for (String allyName : clan.getAllyMap().keySet()) - { - ClanInfo ally = _clanUtility.getClanByClanName(allyName); - if (ally == null) continue; - - messageClan(ally, sendMessage); - } + handleAllyChat(caller, message, clan, rank); } public int getNameMin() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayer.java index 5b3e166ac..b18b93eff 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayer.java @@ -8,7 +8,7 @@ public class ClansPlayer private UUID _uuid; private ClanRole _role; private boolean _online; - + public ClansPlayer(String playerName, UUID uuid, ClanRole role) { _playerName = playerName; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayerTasks.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayerTasks.java new file mode 100644 index 000000000..1cd37cb5a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayerTasks.java @@ -0,0 +1,18 @@ +package mineplex.game.clans.clans; + +public enum ClansPlayerTasks +{ + FIRST_SESSION("Clans.FirstSession"); + + private String _id; + + ClansPlayerTasks(String id) + { + _id = id; + } + + public String id() + { + return _id; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java new file mode 100644 index 000000000..dbc3c970f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java @@ -0,0 +1,85 @@ +package mineplex.game.clans.clans.ban; + +import java.sql.Timestamp; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTime; + +public class ClansBan +{ + private int _id; + private int _accountId; + private String _reason; + private Timestamp _banTime; + private Timestamp _unbanTime; + private boolean _permanent; + private boolean _removed; + + public ClansBan(int id, int accountId, String reason, Timestamp banTime, Timestamp unbanTime, boolean permanent, boolean removed) + { + _id = id; + _accountId = accountId; + _reason = reason; + _banTime = banTime; + _unbanTime = unbanTime; + _permanent = permanent; + _removed = removed; + } + + public int getId() + { + return _id; + } + + public int getAccountId() + { + return _accountId; + } + + public String getReason() + { + return _reason; + } + + public Timestamp getBanTime() + { + return _banTime; + } + + public long getLength() + { + return _unbanTime.getTime() - _banTime.getTime(); + } + + public long getTimeLeft() + { + return Math.max(0, _unbanTime.getTime() - System.currentTimeMillis()); + } + + public Timestamp getUnbanTime() + { + return _unbanTime; + } + + public boolean isPermanent() + { + return _permanent; + } + + public String getBanTimeFormatted(boolean wording) + { + long time = getTimeLeft(); + + return time == -1 ? F.time("permanently") : (wording ? "for " : "") + F.time(UtilTime.MakeStr(time)); + } + + public boolean isRemoved() + { + return _removed; + } + + public boolean isActive() + { + return (isPermanent() || getTimeLeft() > 0) && !isRemoved(); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java new file mode 100644 index 000000000..57565214f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java @@ -0,0 +1,86 @@ +package mineplex.game.clans.clans.ban; + +import java.util.List; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTime; + +public class ClansBanClient +{ + public int AccountId; + public List Bans; + + public ClansBanClient(int accountId, List bans) + { + AccountId = accountId; + Bans = bans; + } + + public boolean isBanned() + { + for (ClansBan ban : Bans) + { + if (ban.isActive()) + { + return true; + } + } + + return false; + } + + public long getBanTime() + { + long time = 0; + + for (ClansBan ban : Bans) + { + if (!ban.isActive()) + { + continue; + } + + if (ban.isPermanent()) + { + return -1; + } + + time += ban.getTimeLeft(); + } + + return time; + } + + public String getBanTimeFormatted() + { + long time = getBanTime(); + + return time == -1 ? F.time("permanently") : "for " + F.time(UtilTime.MakeStr(time)); + } + + public ClansBan getLongestBan() + { + ClansBan longest = null; + + for (ClansBan ban : Bans) + { + if (!ban.isActive()) + { + continue; + } + + if (longest == null) + { + longest = ban; + continue; + } + + if (ban.getTimeLeft() > longest.getTimeLeft()) + { + longest = ban; + } + } + + return longest; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java new file mode 100644 index 000000000..eae662f37 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java @@ -0,0 +1,254 @@ +package mineplex.game.clans.clans.ban; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.collect.Lists; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.donation.DonationManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.ban.commands.ClansBanCommand; +import mineplex.game.clans.clans.ban.commands.ClansBanListCommand; +import mineplex.game.clans.clans.ban.ui.ClansBanListShop; +import mineplex.game.clans.clans.ban.ui.ClansBanShop; + +public class ClansBanManager extends MiniPlugin +{ + private CoreClientManager _clientManager; + private ClansBanRepository _repository; + private Map _clients; + private Map _cache; + private ClansBanShop _shop; + private ClansBanListShop _shop2; + + private Object _lock = new Object(); + + public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) + { + super("Blacklist", plugin); + + _clientManager = clientManager; + + _repository = new ClansBanRepository(plugin, this); + + _clients = new HashMap<>(); + _cache = new HashMap<>(); + + _shop = new ClansBanShop(this, clientManager, donationManager); + _shop2 = new ClansBanListShop(this, clientManager, donationManager); + } + + @Override + public void addCommands() + { + addCommand(new ClansBanCommand(this)); + addCommand(new ClansBanListCommand(this)); + } + + @EventHandler + public void clearOldClients(UpdateEvent event) + { + if (!event.getType().equals(UpdateType.MIN_01)) + { + return; + } + + synchronized (_lock) + { + List purge = Lists.newArrayList(); + + _clients.keySet().stream().filter(name -> Bukkit.getPlayer(name) == null).forEach(purge::add); + + purge.forEach(this::UnloadClient); + } + } + + public void ban(ClansBanClient client, String name, long time, String reason, Callback callback) + { + _repository.ban(client.AccountId, time, reason, time == -1); + + LoadClient(name, callback); + } + + public CoreClientManager getClientManager() + { + return _clientManager; + } + + public ClansBanRepository GetRepository() + { + return _repository; + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) + { + LoadClient(event.getPlayer().getName(), client -> { + if (client.isBanned()) + { + String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT); + + if (client.getLongestBan().isPermanent()) + time = "Permanent"; + + String reason = C.cRedB + "You are banned from Clans for " + time + + "\n" + C.cWhite + client.getLongestBan().getReason() + ; + + event.getPlayer().kickPlayer(reason); + + ClanInfo clan = ClansManager.getInstance().getClan(event.getPlayer()); + String name = event.getPlayer().getName(); + + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> clan.playerOffline(name), 20L); + } + else + { + UtilServer.broadcast(F.sys("Join", event.getPlayer().getName())); + } + }); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerQuit(PlayerQuitEvent event) + { + if (Get(event.getPlayer().getName()) == null) + { + return; + } + + if (Get(event.getPlayer().getName()).isBanned()) + { + event.setQuitMessage(null); + } + + UnloadClient(Get(event.getPlayer().getName())); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerKicked(PlayerKickEvent event) + { + if (Get(event.getPlayer().getName()) == null) + { + return; + } + + if (Get(event.getPlayer().getName()).isBanned()) + { + event.setLeaveMessage(null); + } + + UnloadClient(Get(event.getPlayer().getName())); + } + + public void UnloadClient(ClansBanClient client) + { + synchronized (_lock) + { + String name = ""; + + for (Entry entry : _clients.entrySet()) + { + if (entry.getValue().equals(client)) + { + name = entry.getKey(); + break; + } + } + + _clients.remove(name); + } + } + + public void UnloadClient(String name) + { + synchronized (_lock) + { + _clients.remove(name); + } + } + + public void LoadClient(final String name, Callback callback) + { + GetRepository().loadBans(name, client -> { + synchronized (_lock) + { + _clients.put(name, client); + System.out.println("> CLIENTS: " + _clients); + if (callback != null) callback.run(client); + } + }); + } + + public ClansBanClient Get(String name) + { + synchronized (_lock) + { + return _clients.get(name.toLowerCase()); + } + } + + public ClansBanShop getShop() + { + return _shop; + } + + public ClansBanListShop getShop2() + { + return _shop2; + } + + public void cache(Player player, String playerName) + { + _cache.put(player.getName(), playerName); + } + + public String getCachedName(Player player) + { + return _cache.get(player.getName()); + } + + public void clearCachedName(String name) + { + _cache.remove(name); + } + + public void unban(ClansBanClient target, ClansBan ban, String name, Callback callback) + { + if (target.AccountId != ban.getAccountId()) + { + return; + } + + _repository.removeBan(ban); + + LoadClient(name, callback); + } + + public void listRecordedNames(Callback> callback) + { + GetRepository().loadAll(callback); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java new file mode 100644 index 000000000..5ec0f6fc0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java @@ -0,0 +1,163 @@ +package mineplex.game.clans.clans.ban; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.account.CoreClient; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.NonFinalInteger; +import mineplex.core.database.DBPool; +import mineplex.core.database.RepositoryBase; +import mineplex.core.database.ResultSetCallable; +import mineplex.core.database.column.ColumnBoolean; +import mineplex.core.database.column.ColumnInt; +import mineplex.core.database.column.ColumnTimestamp; +import mineplex.core.database.column.ColumnVarChar; + +public class ClansBanRepository extends RepositoryBase +{ + private ClansBanManager _manager; + + private static final String GET_LONGEST_BAN = "SELECT * FROM clanBans WHERE (NOW() < unbanTime OR permanent=1) AND accountId = ? ORDER BY permanent DESC, unbanTime DESC LIMIT 1;"; + private static final String BAN_PLAYER = "INSERT INTO clanBans (accountId, reason, banTime, unbanTime, permanent, removed) VALUES (?, ?, ?, ?, ?, ?);"; + private static final String REMOVE_BAN = "UPDATE clanBans SET removed = 1 WHERE id = ?;"; + private static final String GET_ALL_BANS = "SELECT * FROM clanBans WHERE accountId = ?;"; + private static final String GET_ALL_ACCOUNTS = "SELECT DISTINCT accountId FROM clanBans;"; + + public ClansBanRepository(JavaPlugin plugin, ClansBanManager manager) + { + super(plugin, DBPool.getAccount()); + + _manager = manager; + } + + public void ban(int accountId, long time, String reason, boolean permanent) + { + executeInsert(BAN_PLAYER, null, + new ColumnInt("accountId", accountId), + new ColumnVarChar("reason", 128, reason), + new ColumnTimestamp("banTime", new Timestamp(System.currentTimeMillis())), + new ColumnTimestamp("unbanTime", new Timestamp(System.currentTimeMillis() + time)), + new ColumnBoolean("permanent", permanent), + new ColumnBoolean("removed", false) + ); + } + + public void loadBans(final String name, final Callback callback) + { + System.out.println(">> Attempting to load Clans Bans for \"" + name + "\""); + loadClientByName(name, client -> { + System.out.println("> Successfully loaded CoreClient"); + + executeQuery(GET_ALL_BANS, resultSet -> { + System.out.println("> Successfully executed query, result set object: " + resultSet); + + final List list = new ArrayList(); + + while (resultSet.next()) + { + int id = resultSet.getInt(1); + int accountId = resultSet.getInt(2); + String reason = resultSet.getString(3); + Timestamp banTime = resultSet.getTimestamp(4); + Timestamp unbanTime = resultSet.getTimestamp(5); + boolean permanent = resultSet.getBoolean(6); + boolean removed = resultSet.getBoolean(7); + + list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); + } + + callback.run(new ClansBanClient(client.getAccountId(), list)); + + System.out.println("> Successfully handled result"); + System.out.println(">> FINISH"); + }, new ColumnInt("accountId", client.getAccountId())); + }); + } + + public void getLongestBan(final String name, final Callback callback) + { + if (callback == null) + { + return; + } + + loadClientByName(name, client -> { + executeQuery(GET_LONGEST_BAN, resultSet -> { + while (resultSet.next()) + { + int id = resultSet.getInt(1); + int accountId = resultSet.getInt(2); + String reason = resultSet.getString(3); + Timestamp banTime = resultSet.getTimestamp(4); + Timestamp unbanTime = resultSet.getTimestamp(5); + boolean permanent = resultSet.getBoolean(6); + boolean removed = resultSet.getBoolean(7); + + callback.run(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); + } + }, new ColumnInt("accountId", client.getAccountId())); + }); + } + + public void loadClientByName(String name, Callback client) + { + if (_manager.getClientManager().Contains(name)) + { + client.run(_manager.getClientManager().Get(name)); + } + else + { + _manager.getClientManager().loadClientByName(name, () -> client.run(_manager.getClientManager().Get(name))); + } + } + + public void loadAll(Callback> callback) + { + _manager.runAsync(() -> { + executeQuery(GET_ALL_ACCOUNTS, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + final List clients = new ArrayList<>(); + final NonFinalInteger resultsProcessed = new NonFinalInteger(); + int resultsFound = 0; + + while (resultSet.next()) + { + resultsFound++; + + int accountId = resultSet.getInt(0); + +// loadBans(_manager.getClientManager().) + + } + + System.out.println("Found: " + resultsFound + ", Processed: " + resultsProcessed); + } + }); + }); + } + + @Override + protected void initialize() + { + } + + @Override + protected void update() + { + } + + public void removeBan(ClansBan ban) + { + executeUpdate(REMOVE_BAN, new ColumnInt("id", ban.getId())); + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java new file mode 100644 index 000000000..1d62e32d3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java @@ -0,0 +1,93 @@ +package mineplex.game.clans.clans.ban.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ban.ClansBanManager; + +public class ClansBanCommand extends CommandBase +{ + public ClansBanCommand(ClansBanManager plugin) + { + super(plugin, Rank.CMOD, "cbans", "cb"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args == null || args.length < 1) + { + UtilPlayer.message(caller, C.cGold + "/cb - Bans the specified player for the specified amount of time"); + UtilPlayer.message(caller, C.cGold + "/cb - Displays the \"Clans Punish\" UI, and will display all of the player's past bans (including current ones)"); + } + else if (args.length == 1) + { + final String playerName = args[0]; + + Plugin.cache(caller, playerName); + Plugin.getShop().attemptShopOpen(caller); + } + else if (args.length > 2) + { + final String playerName = args[0]; + final float time; + final boolean permanent = args[1].startsWith("p"); + + if (!permanent) + { + try + { + time = Float.parseFloat(args[1]); + } + catch(NumberFormatException e) + { + UtilPlayer.message(caller, F.main("Clans", "You must provide a valid floating point number for the time (in days). e.g. " + F.elem("1.5") + ", " + F.elem("3.2") + ".")); + return; + } + } + else + { + //Required for compilation reasons + time = 0; + } + + String reason = args[2]; + + for (int i = 3; i < args.length; i++) + { + reason += " " + args[i]; + } + + final String finalReason = reason; + + //Match exact online first + Player target = UtilPlayer.searchExact(playerName); + if (target != null) + { + Plugin.LoadClient(playerName, client -> { + Plugin.ban(client, target.getName(), permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason, c -> { + UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + F.time(c.getBanTimeFormatted()) + ".")); + Plugin.runSync(() -> target.kickPlayer(C.cRedB + "You have been banned from Clans " + c.getBanTimeFormatted() + ".")); + }); + }); + + return; + } + + Plugin.LoadClient(playerName, client -> { + Plugin.ban(client, playerName, permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason, c -> { + UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + c.getBanTimeFormatted() + ".")); + }); + }); + } + else + { + UtilPlayer.message(caller, C.cGold + "/cp - Bans the specified player for the specified amount of time"); + UtilPlayer.message(caller, C.cGold + "/cp - Displays the \"Clans Punish\" UI, and will display all of the player's past bans (including current ones)"); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanListCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanListCommand.java new file mode 100644 index 000000000..d4727bb4d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanListCommand.java @@ -0,0 +1,21 @@ +package mineplex.game.clans.clans.ban.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.game.clans.clans.ban.ClansBanManager; + +public class ClansBanListCommand extends CommandBase +{ + public ClansBanListCommand(ClansBanManager plugin) + { + super(plugin, Rank.ADMIN, "listbans"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + Plugin.getShop2().attemptShopOpen(caller); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanListPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanListPage.java new file mode 100644 index 000000000..22c58a21d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanListPage.java @@ -0,0 +1,32 @@ +package mineplex.game.clans.clans.ban.ui; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ban.ClansBanClient; +import mineplex.game.clans.clans.ban.ClansBanManager; + +public class ClansBanListPage extends ShopPageBase +{ + public ClansBanListPage(final ClansBanManager banManager, final ClansBanListShop shop, final CoreClientManager clientManager, final DonationManager donationManager, final String name, final Player player) + { + super(banManager, shop, clientManager, donationManager, name, player); + + buildPage(); + } + + protected void buildPage() + { + getPlugin().listRecordedNames(clients -> { + for (ClansBanClient client : clients) + { + } + }); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanListShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanListShop.java new file mode 100644 index 000000000..d3086d620 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanListShop.java @@ -0,0 +1,24 @@ +package mineplex.game.clans.clans.ban.ui; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ban.ClansBanManager; + +public class ClansBanListShop extends ShopBase +{ + public ClansBanListShop(final ClansBanManager plugin, final CoreClientManager clientManager, final DonationManager donationManager) + { + super(plugin, clientManager, donationManager, "Clans Punish"); + } + + @Override + protected ShopPageBase> buildPagesFor(final Player player) + { + return new ClansBanListPage(getPlugin(), this, getClientManager(), getDonationManager(), "Clans Punish", player); + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java new file mode 100644 index 000000000..962ee17bf --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java @@ -0,0 +1,62 @@ +package mineplex.game.clans.clans.ban.ui; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilTime; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ban.ClansBan; +import mineplex.game.clans.clans.ban.ClansBanManager; + +public class ClansBanPage extends ShopPageBase +{ + public ClansBanPage(final ClansBanManager banManager, final ClansBanShop shop, final CoreClientManager clientManager, final DonationManager donationManager, final String name, final Player player) + { + super(banManager, shop, clientManager, donationManager, name, player); + + buildPage(); + } + + protected void buildPage() + { + String name = getPlugin().getCachedName(getPlayer()); + getPlugin().LoadClient(name, client -> { + int slot = 0; + + for (ClansBan ban : client.Bans) + { + ItemStack item = + new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK) + .setTitle(ban.isActive() ? C.cGreenB + "Active" : C.cRedB + "Inactive") + + .addLore(" ") + .addLore("Date banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime())) + .addLore("Time left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None")) + .addLore("Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No")) + .addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16) + .addLore("Is Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No")) + .addLore(!ban.isActive() ? null : C.cDAqua + "Left-Click to disable ban") + + .build(); + + if (ban.isActive()) + { + UtilInv.addDullEnchantment(item); + } + + addButton(slot++, item, (player, click) -> { + if (ban.isActive()) + { + getPlugin().unban(client, ban, name, c -> refresh()); + } + }); + } + }); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java new file mode 100644 index 000000000..f24554858 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java @@ -0,0 +1,24 @@ +package mineplex.game.clans.clans.ban.ui; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ban.ClansBanManager; + +public class ClansBanShop extends ShopBase +{ + public ClansBanShop(final ClansBanManager plugin, final CoreClientManager clientManager, final DonationManager donationManager) + { + super(plugin, clientManager, donationManager, "Clans Punish"); + } + + @Override + protected ShopPageBase> buildPagesFor(final Player player) + { + return new ClansBanPage(getPlugin(), this, getClientManager(), getDonationManager(), "Clans Punish", player); + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java index 40bebfb6e..36619c1ef 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java @@ -38,7 +38,7 @@ public class ClansChatCommand extends CommandBase if (!Plugin.Get(caller).isClanChat()) { ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); - if (clan == null) + if (clan == null) UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); else Plugin.chatClan(clan, caller, F.combine(args, 0, null, false)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 3fda15789..cbc4c02dc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -15,9 +15,12 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilInput; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilWorld; +import mineplex.core.delayedtask.DelayedTask; +import mineplex.core.delayedtask.DelayedTaskClient; import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanRole; @@ -27,14 +30,11 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClientClan; import mineplex.game.clans.clans.event.ClanJoinEvent; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; -import mineplex.game.clans.tutorials.Tutorial; -import mineplex.game.clans.tutorials.TutorialManager; import net.minecraft.server.v1_8_R3.EnumDirection; public class ClansCommand extends CommandBase { private ClansManager _manager; - public ClansCommand(ClansManager plugin) { super(plugin, Rank.ALL, "c", "clan", "clans", "factions"); @@ -127,7 +127,7 @@ public class ClansCommand extends CommandBase private void forceJoin(Player caller, String[] args) { - if (!Plugin.getClientManager().hasRank(caller, Rank.ADMIN) && !caller.getName().equals("NewGarbo")) + if (!Plugin.getClientManager().hasRank(caller, Rank.ADMIN) && !caller.getUniqueId().toString().equals("d8646a35-33a8-43c6-9e7c-2e871a6b86c9") /* My UUID (NewGarbo) */) { _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This requires ADMIN+ permission.")); return; @@ -741,7 +741,7 @@ public class ClansCommand extends CommandBase Plugin.getItemMapManager().setMap(caller); } - public void home(Player caller, String[] args) + public void home(final Player caller, String[] args) { if (args.length > 1) { @@ -752,7 +752,7 @@ public class ClansCommand extends CommandBase } } - ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); + final ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); if (clan == null) { @@ -772,18 +772,6 @@ public class ClansCommand extends CommandBase return; } - if (!Plugin.getClanUtility().isSafe(caller.getLocation())) - { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can only use Clan Home from Spawn.")); - return; - } - - if (!Plugin.getClanUtility().isSpecial(caller.getLocation(), "Spawn")) - { - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can only use Clan Home from Spawn.")); - return; - } - Location home = clan.getHome(); if (!(home.getBlock().getType().equals(Material.BED_BLOCK) && home.add(0, 1, 0).getBlock().getType().equals(Material.AIR)) && home.add(0, 2, 0).getBlock().getType().equals(Material.AIR)) @@ -802,14 +790,31 @@ public class ClansCommand extends CommandBase * } */ - // if (!Recharge.Instance.use(caller, "Clans Teleport", "Clans - // Teleport", 300000, true, false, false, false)) return; + if (!Recharge.Instance.use(caller, "Home Teleport", 5 * 60 * 1000, true, false)) + { + return; + } - // Do - Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0)); - - // Inform - _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + ".")); + DelayedTask.Instance.doDelay(caller, "Home Teleport", new Callback() { + public void run(DelayedTaskClient player) + { + // Do + Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0)); + + // Inform + _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + ".")); + } + }, new Callback() { + public void run(DelayedTaskClient client) + { + UtilTextMiddle.display("", "Teleporting to Clan Home in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Home Teleport")))), 0, 5, 0, client.getPlayer()); + } + }, new Callback() { + public void run(DelayedTaskClient client) + { + UtilPlayer.message(client.getPlayer(), F.main("Clans", "Teleport has been cancelled due to movement.")); + } + }, (Plugin.getClanUtility().getClaim(caller.getLocation()) != null ? 30 : 20) * 1000, false); } public void homeSet(Player caller) @@ -881,7 +886,9 @@ public class ClansCommand extends CommandBase } public void infoClan(Player caller, String search) - {System.out.println(search); + { + System.out.println(search); + if (search == null) { _manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a search parameter.")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java index 1267209fb..7432c7a66 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java @@ -14,6 +14,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; +import mineplex.core.common.Rank; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.portal.Portal; @@ -25,7 +26,9 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor private boolean _enabled; private String _serverName; private ConcurrentLinkedQueue _queue; - + + private CoreClientManager _clientManager; + public ClansLoginManager(JavaPlugin plugin, CoreClientManager clientManager, String serverName) { super("Clans Login Manager", plugin); @@ -34,12 +37,13 @@ public class ClansLoginManager extends MiniPlugin implements ILoginProcessor _enabled = true; _queue = new ConcurrentLinkedQueue(); clientManager.addStoredProcedureLoginProcessor(this); + _clientManager = clientManager; } @EventHandler public void onPlayerJoin(PlayerLoginEvent event) { - if (_queue.contains(event.getPlayer().getName()) && !event.getPlayer().isOp()) + if (_queue.contains(event.getPlayer().getName()) && !event.getPlayer().isOp() && _clientManager.hasRank(event.getPlayer(), Rank.CMOD)) { event.setKickMessage("This is not your Clans home server"); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/Meow.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/Meow.java new file mode 100644 index 000000000..b6bc54b64 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/Meow.java @@ -0,0 +1,22 @@ +package mineplex.game.clans.clans.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.game.clans.clans.outpost.Outpost; +import mineplex.game.clans.clans.outpost.OutpostManager; + +public class Meow extends CommandBase +{ + public Meow(OutpostManager plugin) + { + super(plugin, Rank.ALL, "meow"); + } + + @Override + public void Execute(Player caller, String[] args) + { + caller.getInventory().addItem(Outpost.OUTPOST_ITEM); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerEnterTerritoryEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerEnterTerritoryEvent.java index 7a8d6aa41..80e9a4a4d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerEnterTerritoryEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerEnterTerritoryEvent.java @@ -12,9 +12,11 @@ public class PlayerEnterTerritoryEvent extends Event private String _lastTerritory; private Player _player; + private boolean _sendMessage; + private boolean _safe; - public PlayerEnterTerritoryEvent(Player player, String lastTerritory, String newTerritory, boolean safe) + public PlayerEnterTerritoryEvent(Player player, String lastTerritory, String newTerritory, boolean safe, boolean sendMessage) { _player = player; _lastTerritory = lastTerritory; @@ -27,6 +29,16 @@ public class PlayerEnterTerritoryEvent extends Event return _player; } + public boolean willSendMessage() + { + return _sendMessage; + } + + public void setSendMessage(boolean flag) + { + _sendMessage = flag; + } + public String getLastTerritory() { return _lastTerritory; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java index bc6240df7..dd417956c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanWhoPage.java @@ -31,7 +31,7 @@ public class ClanWhoPage extends ClanPageBase public ClanWhoPage(ClansManager plugin, ClanShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, ClanInfo lookupClan, boolean showBackButton) { - super(plugin, shop, clientManager, donationManager, lookupClan.getName(), player, 36); + super(plugin, shop, clientManager, donationManager, lookupClan.getName(), player, 45); _lookupClan = lookupClan; _showBackButton = showBackButton; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java index 59055ea02..7e84a14af 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java @@ -136,7 +136,7 @@ public class ObserverManager extends MiniPlugin if (_observerMap.containsKey(event.getPlayer())) { restore(event.getPlayer(), _observerMap.get(event.getPlayer())); - _observerMap.remove(_plugin); + _observerMap.remove(event.getPlayer()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java new file mode 100644 index 000000000..94f61dfe4 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/Outpost.java @@ -0,0 +1,483 @@ +package mineplex.game.clans.clans.outpost; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.FallingBlock; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.ColorFader; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LoopIterator; +import mineplex.core.common.util.NonFinalInteger; +import mineplex.core.common.util.RGBData; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.hologram.Hologram; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansBlacklist; +import mineplex.game.clans.core.repository.ClanTerritory; +import net.minecraft.server.v1_8_R3.AxisAlignedBB; + +public class Outpost implements Listener +{ + protected static final long MAX_LIFETIME = 5 * 60 * 1000; // 30 minutes + public static final ItemStack OUTPOST_ITEM = new ItemBuilder(Material.NETHERRACK, 1).setRawTitle(C.cBlue + "Outpost").setLore(C.cWhite + "It appears to be a contraption of some sort!").build(); + public static final byte OUTPOST_BLOCK_DATA = (byte) 137; + + private OutpostManager _host; + + private ClanInfo _clan; + + private Location _startCorner; + private Location _origin; + private Location _endCorner; + + private Location _forceFieldStart; + private Location _forceFieldEnd; + + private Location _core; + + private LinkedHashMap _blocks; + private LinkedHashMap _buildQueue; + + protected OutpostType _type; + private OutpostState _state; + + private Hologram _preHologram; + private Hologram _preHologram2; + + private LoopIterator _circleStages; + private LoopIterator _reverseCircleStages; + + private List _builders; + + private List _removalQueue; + + private ColorFader _fader = new ColorFader(30, UtilColor.hexToRgb(0x00A296), UtilColor.hexToRgb(0x29E6B6)); + + private long _spawnTime; + + public Outpost(OutpostManager host, ClanInfo clan, Location location, OutpostType type) + { + _host = host; + + _clan = clan; + + _startCorner = location.clone().subtract(type._size, 1, type._size); + _endCorner = location.clone().add(type._size + .9, type._ySize - 1, type._size + .9); + + _builders = new ArrayList<>(); + _removalQueue = new ArrayList<>(); + + _forceFieldStart = _startCorner.clone().subtract(3, 0, 3); + _forceFieldEnd = _endCorner.clone().add(3, 0, 3); + + _origin = location.clone(); + + _type = type; + + _spawnTime = System.currentTimeMillis(); + + _core = _type.getCoreLocation(_origin); + + _preHologram = new Hologram(_clan.Clans.getHologramManager(), _origin.clone().add(0.5, 2.3, 0.5), F.elem(_clan.getName()) + C.cWhite + "'s Outpost block"); + _preHologram2 = new Hologram(_clan.Clans.getHologramManager(), _origin.clone().add(0.5, 3, 0.5), "Despawning: " + UtilText.getProgress(null, 0, null, true)); + + _preHologram.start(); + _preHologram2.start(); + + _state = OutpostState.AWAITING; + } + + private void cleanup() + { + _blocks = null; + + if (_preHologram != null) _preHologram.stop(); + if (_preHologram2 != null) _preHologram2.stop(); + + _preHologram = null; + _preHologram2 = null; + + _state = OutpostState.DEAD; + + _host.queueForRemoval(_clan.getName()); + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (getState() != OutpostState.AWAITING) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + { + return; + } + + if (getLifetime() <= 2000) + { + return; + } + + if (!_clan.equals(_clan.Clans.getClanUtility().getClanByPlayer(event.getPlayer()))) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "This is not yours to activate!")); + return; + } + + if (event.getClickedBlock() != null && _origin.equals(event.getClickedBlock().getLocation())) + { + if (event.getClickedBlock().getType().equals(Material.NETHERRACK)) + { + _origin.getBlock().setType(Material.AIR); + beginConstruction(); + } + } + } + + @EventHandler + public void onBlockDamage(BlockDamageEvent event) + { + if (event.getBlock().getLocation().equals(_core) && getState() == OutpostState.LIVE) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have destroyed " + F.elem(_clan.getName()) + "'s Outpost!")); + + _core.getBlock().setType(Material.AIR); + + _clan.inform("Your Outpost has been destroyed!", null); + UtilTextMiddle.display("Siege", "Your Outpost has been destroyed", 20, 100, 20, _clan.getOnlinePlayersArray()); + + if (getState() == OutpostState.AWAITING) + { + cleanup(); + } + else + { + kill(); + } + + event.setCancelled(true); + } + } + + @EventHandler + public void onBlockBreak(BlockBreakEvent event) + { + if (getState() == OutpostState.AWAITING && event.getBlock().getLocation().equals(_origin)) + { + _origin.getBlock().setType(Material.AIR); + _origin.getWorld().dropItem(_origin, OUTPOST_ITEM); + _clan.inform("Your Outpost block has been destroyed.", null); + cleanup(); + event.setCancelled(true); + return; + } + + System.out.println(_blocks); + _blocks.values().stream().filter(event.getBlock().getLocation()::equals).forEach(block -> { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not break blocks in Outposts.")); + event.setCancelled(true); + }); + } + + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) + { + if (UtilAlg.inBoundingBox(event.getBlock().getLocation(), _startCorner, _endCorner)) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not place blocks in Outposts.")); + event.setCancelled(true); + } + } + + protected void update() + { + if (_state == OutpostState.AWAITING) + { + if (getLifetime() > 60000) + { + _origin.getBlock().setType(Material.AIR); + _clan.inform("You have lost your Outpost block, as no one activated it fast enough!", null); + cleanup(); + return; + } + + _preHologram2.setText(UtilText.getProgress(null, UtilMath.clamp(getLifetime(), 0., 60000.) / 60000., null, true)); + + RGBData color = UtilColor.RgbLightBlue; + + for (int x = -_type._size; x <= _type._size; x++) + { + for (int z = -_type._size; z <= _type._size; z++) + { + if (x == -_type._size || x == _type._size || z == -_type._size || z == _type._size) + { + UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, UtilBlock.getHighest(_origin.getWorld(), _origin.clone().add(x + .5, .1, z + .5).getBlockX(), _origin.clone().add(x + .5, .1, z + .5).getBlockZ()).getLocation().add(0.5, 0, 0.5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 1f, 0, ViewDist.NORMAL); + } + } + } + + return; + } + + if (_state == OutpostState.CONSTRUCTING) + { + if (_buildQueue.isEmpty()) + { + _state = OutpostState.LIVE; + + return; + } + else + { + Iterator iterator = _buildQueue.keySet().iterator(); + + if (iterator.hasNext()) + { + _buildQueue.remove(iterator.next()).set(); + } + } + + // Forcefield + RGBData color = UtilColor.RgbLightBlue; + + for (int x = -_type._size; x <= _type._size; x++) + { + for (int z = -_type._size; z <= _type._size; z++) + { + if (x == -_type._size || x == _type._size || z == -_type._size || z == _type._size) + { + UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, _origin.clone().add(x + .5, .1, z + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 1f, 0, ViewDist.NORMAL); + } + } + } + } + + RGBData next = _fader.next(); + + { + RGBData color = _state == OutpostState.LIVE ? next : UtilColor.RgbRed; + + Vector nextCircleStage = _circleStages.next(); + + double circleX = nextCircleStage.getX(); + double circleZ = nextCircleStage.getZ(); + + UtilParticle.PlayParticleToAll(ParticleType.MOB_SPELL, _core.clone().add(circleX + .5, 1.1d, circleZ + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 5.f, 0, ViewDist.NORMAL); + } + + { + RGBData color = _state == OutpostState.LIVE ? next : UtilColor.RgbRed; + + Vector nextCircleStage = _reverseCircleStages.next(); + + double circleX = nextCircleStage.getX(); + double circleZ = nextCircleStage.getZ(); + + UtilParticle.PlayParticleToAll(ParticleType.MOB_SPELL, _core.clone().add(circleX + .5, 1.1d, circleZ + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 5.f, 0, ViewDist.NORMAL); + } + } + + @EventHandler + public void forcefield(UpdateEvent event) + { + if (!_removalQueue.isEmpty()) + { + _builders.remove(_removalQueue.remove(0)); + } + + if (event.getType() == UpdateType.TICK && getState() == OutpostState.CONSTRUCTING) + { + for (OutpostBuilder builder : _builders) + { + builder.tick(); + } + } + + if (event.getType() != UpdateType.FAST && getState() == OutpostState.CONSTRUCTING) + { + return; + } + + UtilServer.getPlayersCollection().stream() + .filter(player -> !_clan.isMember(player)) + .filter(player -> UtilAlg.inBoundingBox(player.getLocation(), _forceFieldStart, _forceFieldEnd)) + .forEach(player -> { + UtilAction.velocity(player, UtilAlg.getTrajectory2d(_core, player.getLocation()), 1, true, 0.8, 0, 1.1, true); + UtilPlayer.message(player, F.main("Clans", "This Outpost is still under construction!")); + player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0f, 1.0f); + }); + } + + public void beginConstruction() + { + // Cleanup pre-Outpost stuff + _preHologram.stop(); + _preHologram2.stop(); + + _preHologram = null; + _preHologram = null; + + _state = OutpostState.CONSTRUCTING; + _blocks = new LinkedHashMap<>(_buildQueue = _type.createBuildQueue(_origin, _clan.Clans)); + + { + Location pos = UtilBlock.getHighest(_startCorner.getWorld(), _startCorner.clone().subtract(1, 0, 1).getBlockX(), _startCorner.clone().subtract(1, 0, 1).getBlockZ()).getLocation(); + + _builders.add(new OutpostBuilder(pos, "Peasant", _type.getWallLocations(_origin), this)); + } + + _clan.inform("Siege", "Your Outpost is now being constructed.", null); + + _circleStages = new LoopIterator(circleAround(new Vector(0., 0., 0.), 40, .6d)); + + List reverse = circleAround(new Vector(0., 0., 0.), 40, .6d); + Collections.reverse(reverse); + _reverseCircleStages = new LoopIterator(reverse); + + //Inform nearby Clans + for (int chunkX = -3; chunkX < 3; chunkX++) + { + for (int chunkZ = -3; chunkZ < 3; chunkZ++) + { + ClanTerritory territory = _clan.Clans.getClanUtility().getClaim(_origin.getWorld().getChunkAt(_origin.getChunk().getX() + chunkX, _origin.getChunk().getZ() + chunkZ)); + + if (territory != null && ClansBlacklist.isValidClanName(territory.Owner)) + { + ClanInfo clan = _clan.Clans.getClanUtility().getClanByClanName(territory.Owner); + + clan.inform("A siege has begun near your territory!", null); + UtilTextMiddle.display("Siege", "A Siege has been declared on your Clan!", 20, 100, 20, clan.getOnlinePlayersArray()); + } + } + } + } + + private List circleAround(Vector origin, int points, double radius) + { + List list = new LinkedList<>(); + + double slice = 2 * Math.PI / points; + + for (int point = 0; point < points; point++) + { + double angle = slice * point; + list.add(new Vector(origin.getX() + radius * Math.cos(angle), 0, origin.getZ() + radius * Math.sin(angle))); + } + + return list; + } + + public void instakill() + { + _blocks.values().forEach(OutpostBlock::restore); + + cleanup(); + } + + public void kill() + { + _state = OutpostState.DESTRUCTING; + + NonFinalInteger wait = new NonFinalInteger(0); + + _blocks.values().stream().filter(block -> UtilMath.random.nextBoolean() && UtilMath.random.nextBoolean() && UtilMath.random.nextBoolean() && UtilMath.random.nextBoolean()).forEach(block -> + _host.runSyncLater(() -> { + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, block._loc, new Vector(0,0,0), 1f, 1, ViewDist.NORMAL); + _origin.getWorld().playSound(block._loc, Sound.EXPLODE, 1.0f, 1.0f); + }, wait.add(4 + UtilMath.random.nextInt(4)).get()) + ); + + _host.runSyncLater(() -> { + _blocks.values().forEach(block -> { + Material mat = Material.getMaterial(block._id); + + if (UtilItem.isTranslucent(mat)) + { + block.restore(); + return; + } + + FallingBlock fall = block._loc.getWorld().spawnFallingBlock(block._loc, block._id, block._data); + fall.setDropItem(false); + Vector vec = UtilAlg.getTrajectory(fall.getLocation(), getExactMiddle()); + + UtilAction.velocity(fall, vec, 1, false, 0, 0.6, 10, false); + + fall.setMetadata("ClansOutpost", new FixedMetadataValue(_clan.Clans.getPlugin(), _clan.getName())); + + block.restore(); + }); + + cleanup(); + }, wait.get() + 5L); + + _clan.inform("Your Clan's Outpost has been destroyed.", null); + } + + public ClanInfo getClan() + { + return _clan; + } + + public long getLifetime() + { + return System.currentTimeMillis() - _spawnTime; + } + + public AxisAlignedBB getBounds() + { + return UtilAlg.toBoundingBox(_startCorner, _endCorner); + } + + public Location getExactMiddle() + { + return UtilAlg.getMidpoint(_startCorner, _endCorner); + } + + public OutpostState getState() + { + return _state; + } + + public void queueForRemoval(OutpostBuilder builder) + { + _removalQueue.add(builder); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostBlock.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostBlock.java new file mode 100644 index 000000000..cf5b4dac9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostBlock.java @@ -0,0 +1,57 @@ +package mineplex.game.clans.clans.outpost; + +import java.util.Map; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockState; + +import mineplex.core.common.util.UtilWorld; + +public class OutpostBlock +{ + protected Location _loc; + protected int _id; + protected byte _data; + + protected int _originalId; + protected byte _originalData; + + public OutpostBlock(Map blocks, Location loc, int id, byte data) + { + _loc = loc; + _id = id; + _data = data; + + String locStr = UtilWorld.locToStr(loc); + + if (blocks.containsKey(locStr)) + { + _originalId = blocks.get(locStr)._originalId; + _originalData = blocks.get(locStr)._originalData; + } + else + { + _originalId = _loc.getBlock().getTypeId(); + _originalData = _loc.getBlock().getData(); + } + } + + public void set() + { + _loc.getBlock().setTypeIdAndData(_id, _data, false); + if (_id != 0) + { + _loc.getWorld().playEffect(_loc, Effect.STEP_SOUND, Material.getMaterial(_id), 10); + } + } + + public void restore() + { + BlockState state = _loc.getBlock().getState(); + state.setTypeId(_originalId); + state.setRawData(_originalData); + state.update(true, false); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostBuilder.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostBuilder.java new file mode 100644 index 000000000..51b0724ad --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostBuilder.java @@ -0,0 +1,130 @@ +package mineplex.game.clans.clans.outpost; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.inventory.ItemStack; + +import com.mojang.authlib.GameProfile; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.game.clans.clans.outpost.pathing.AStar; +import mineplex.game.clans.clans.outpost.pathing.AStar.InvalidPathException; +import mineplex.game.clans.clans.outpost.pathing.PathingResult; +import mineplex.game.clans.clans.outpost.pathing.Tile; + +public class OutpostBuilder +{ + private Skeleton _entity; + + private List _path; + private int _pathPos; + private List _moveLocations; + private int _nextLocation; + private long _arrivedTime; + private long _lastMovement; + + private Outpost _host; + + public OutpostBuilder(Location pos, String name, List locations, Outpost host) + { + _host = host; + + Location spawnLoc = pos; + Skeleton skel = pos.getWorld().spawn(spawnLoc, Skeleton.class); + skel.teleport(spawnLoc); + skel.setHealth(20); + UtilEnt.Vegetate(skel); + UtilEnt.silence(skel, true); + + skel.getEquipment().setHelmet(new ItemStack(Material.NETHER_BRICK_ITEM, 1)); + skel.getEquipment().setItemInHand(new ItemStack(Material.IRON_PICKAXE, 1)); + + // Get in range + List inRange = UtilPlayer.getNearby(spawnLoc, 75d); + + // Disguise + DisguisePlayer disguise = new DisguisePlayer(skel, new GameProfile(Bukkit.getOfflinePlayer("Chiss").getUniqueId(), "Chiss")); + host.getClan().Clans.getDisguiseManager().disguise(disguise, inRange.toArray(new Player[inRange.size()])); + + _entity = skel; + + _moveLocations = locations; + } + + public void tick() + { + if (_path == null || _arrivedTime != -1) + { + _nextLocation = UtilMath.random.nextInt(_moveLocations.size()); + _path = calculatePath(); + _pathPos = 0; + return; + } + + if (System.currentTimeMillis() - _lastMovement >= 500) + { + if (_pathPos == _path.size() - 1) + { + _arrivedTime = 1; + } + else + { + _entity.teleport(_path.get(++_pathPos)); + _arrivedTime = -1; + } + + _lastMovement = System.currentTimeMillis(); + } + } + + private List calculatePath() + { + Location start = _entity.getLocation(); + Location end = _moveLocations.get(_nextLocation); + int range = _host._type._size * 2; + + try + { + AStar pathFinder = new AStar(start, end, range); + ArrayList route = pathFinder.iterate(); + PathingResult res = pathFinder.getPathingResult(); + + if (res == PathingResult.NO_PATH) + { + return Arrays.asList(_moveLocations.get(_nextLocation)); + } + + List list = new ArrayList<>(); + + for (Tile tile : route) + { + list.add(tile.getLocation(start)); + } + + return list; + } + catch (InvalidPathException e) + { + cleanup(); + + return null; + } + } + + private void cleanup() + { + _entity.remove(); + _host.queueForRemoval(this); + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java new file mode 100644 index 000000000..355baa093 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostManager.java @@ -0,0 +1,212 @@ +package mineplex.game.clans.clans.outpost; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.events.ServerShutdownEvent; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; + +public class OutpostManager extends MiniPlugin +{ + private ClansManager _clansManager; + + private Map _outposts = new HashMap<>(); + + private List _removalQueue; + + public OutpostManager(ClansManager clansManager) + { + super("Outpost Manager", clansManager.getPlugin()); + + _clansManager = clansManager; + + _removalQueue = new ArrayList<>(); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPlaceBlock(BlockPlaceEvent event) + { + if (event.getItemInHand().isSimilar(Outpost.OUTPOST_ITEM)) + { + if (Spawn(event.getPlayer(), event.getBlock().getLocation(), OutpostType.MK2)) + { + event.getBlock().setData((byte) Outpost.OUTPOST_BLOCK_DATA); + } + else + { + event.setCancelled(true); + } + } + } + + public boolean Spawn(Player player, Location location, OutpostType type) + { + if (!_clansManager.isInClan(player)) + { + UtilPlayer.message(player, F.main("Clans", "You must be in a Clan to place an Outpost.")); + return false; + } + + if (location.getBlockY() < 10) + { + UtilPlayer.message(player, F.main("Clans", "You cannot place an Outpost this deep.")); + return false; + } + + ClanInfo clan = _clansManager.getClan(player); + + if (UtilItem.isBoundless(location.clone().subtract(0, 1, 0).getBlock().getType())) + { + UtilPlayer.message(player, F.main("Clans", "An Outpost must not be placed floating.")); + return false; + } + + if (Get(clan) != null) + { + UtilPlayer.message(player, F.main("Clans", "Your clan already has an outpost")); + return false; + } + + if (_clansManager.getClanUtility().getClaim(location) != null) + { + UtilPlayer.message(player, F.main("Clans", "An Outpost must be placed in the Wilderness.")); + return false; + } + + for (Outpost outpost : _outposts.values()) + { + if (UtilMath.offset(location, outpost.getExactMiddle()) < 14) + { + UtilPlayer.message(player, F.main("Clans", "You cannot place an Outpost near other Outposts.")); + return false; + } + } + + for (int x = -type._size; x < type._size; x++) + { + for (int y = -1; y < type._ySize; y++) + { + for (int z = -type._size; z < type._size; z++) + { + Location loc = location.clone().add(x, y, z); + + if (_clansManager.getClanUtility().isClaimed(loc)) + { + UtilPlayer.message(player, F.main("Clans", "You cannot place an Outpost where it may intersect with claimed territory.")); + return false; + } + + if (UtilBlock.airFoliage(location.clone().add(x, -1, z).getBlock())) + { + UtilPlayer.message(player, F.main("Clans", "An Outpost cannot be placed floating.")); + return false; + } + } + } + } + + _outposts.put(clan.getName(), new Outpost(this, clan, location, type)); + + _plugin.getServer().getPluginManager().registerEvents(_outposts.get(clan.getName()), _plugin); + + return true; + } + + @EventHandler + public void onBlockFall(EntityChangeBlockEvent event) + { + if (event.getEntity().hasMetadata("ClansOutpost")) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onServerShutdown(ServerShutdownEvent event) + { + for (Outpost outpost : _outposts.values()) + { + outpost.instakill(); + } + } + + @EventHandler + public void onClaim(PlayerClaimTerritoryEvent event) + { + for (Outpost outpost : _outposts.values()) + { + if (outpost.getBounds().b(UtilAlg.toBoundingBox(event.getClaimedChunk().getBlock(0, 0, 0).getLocation(), event.getClaimedChunk().getBlock(15, 254, 15).getLocation()))) + { + event.setCancelled(true); + UtilPlayer.message(event.getClaimer(), F.main("Clans", "You cannot claim this territory as it overlaps with " + F.elem(outpost.getClan().getName()) + "'s Outpost.")); + break; + } + } + } + + @EventHandler + public void update(UpdateEvent event) + { + for (Outpost outpost : _outposts.values()) + { + if (outpost.getState() != OutpostState.DEAD) + { + if (outpost.getState() == OutpostState.CONSTRUCTING ? event.getType() == UpdateType.TICK : event.getType() == UpdateType.TICK) + { + outpost.update(); + } + } + } + + if (event.getType() == UpdateType.FASTER) + { + if (!_removalQueue.isEmpty()) + { + HandlerList.unregisterAll(_outposts.remove(_removalQueue.remove(0))); + } + } + + if (event.getType() == UpdateType.TWOSEC) + { + for (Outpost outpost : _outposts.values()) + { + if (outpost.getState() == OutpostState.LIVE && outpost.getLifetime() > Outpost.MAX_LIFETIME) + { + outpost.kill(); + } + } + } + } + + public Outpost Get(ClanInfo clan) + { + return _outposts.get(clan.getName().toLowerCase()); + } + + public void queueForRemoval(String name) + { + _removalQueue.add(name); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostState.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostState.java new file mode 100644 index 000000000..310e9bb59 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostState.java @@ -0,0 +1,10 @@ +package mineplex.game.clans.clans.outpost; + +public enum OutpostState +{ + AWAITING, + CONSTRUCTING, + LIVE, + DESTRUCTING, + DEAD; +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostType.java new file mode 100644 index 000000000..d7e04055b --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/OutpostType.java @@ -0,0 +1,307 @@ +package mineplex.game.clans.clans.outpost; + +import java.io.File; +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; + +import mineplex.core.common.block.schematic.Schematic; +import mineplex.core.common.block.schematic.UtilSchematic; +import mineplex.core.common.util.UtilWorld; +import mineplex.game.clans.clans.ClansManager; +import net.minecraft.server.v1_8_R3.NBTTagCompound; + +public enum OutpostType +{ + ORIGINAL_CLANS(3, 6) { + public LinkedHashMap createBuildQueue(Location location, ClansManager clans) + { + LinkedHashMap build = new LinkedHashMap<>(); + + for (int y = -1; y <= _ySize; y++) + { + for (int x = -_size; x <= _size; x++) + { + for (int z = -_size; z <= _size; z++) + { + Location loc = new Location(location.getWorld(), location.getX()+x, location.getY()+y, location.getZ()+z); + + if (clans.getClanUtility().isClaimed(loc)) + { + continue; + } + + boolean added = false; + + //Floor + if (y == -1 && Math.abs(x) <= _size-1 && Math.abs(z) <= _size-1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 98, (byte)0)); + added = true; + } + + //Walls + if (Math.abs(x) == _size || Math.abs(z) == _size) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 98, (byte)0)); + added = true; + } + + //Roof + if (y == 5 && Math.abs(x) <= _size-1 && Math.abs(z) <= _size-1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 44, (byte)13)); + added = true; + } + + //Clear + if (!added) + { + if (loc.getBlock().getTypeId() != 0) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 0, (byte) 0)); + } + } + } + } + } + + for (int y= -1; y <= _ySize; y++) + { + for (int x = -_size; x <= _size; x++) + { + for (int z = -_size; z <= _size; z++) + { + Location loc = new Location(location.getWorld(), location.getX()+x, location.getY()+y, location.getZ()+z); + + if (clans.getClanUtility().isClaimed(loc)) + { + continue; + } + + //Doors + if (y == 0 || y == 1) + { + if (x == 0 && z == _size) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 71, (byte)(y * 8 + 2 + 4))); + } + + if (x == 0 && z == -_size) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 71, (byte)(y * 8 + 4))); + } + + if (x == _size && z == 0) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 71, (byte)(y * 8 + 3 + 4))); + } + + if (x == -_size && z == 0) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 71, (byte)(y * 8 + 1 + 4))); + } + } + + //Platform + if (y == 2) + { + if (Math.abs(x) == _size-1 && Math.abs(z) < _size) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 44, (byte)13)); + } + + if (Math.abs(z) == _size-1 && Math.abs(x) < _size) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 44, (byte)13)); + } + } + + //Windows + if (y == 4) + { + if (Math.abs(x) == _size && Math.abs(z) < _size-1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 0, (byte)0)); + } + + if (Math.abs(z) == _size && Math.abs(x) < _size-1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 0, (byte)0)); + } + } + + //Ladders + if (y >= 0 && y < 3) + { + if (x == _size-1 && z == _size-1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 65, (byte)2)); + } + + if (x == (-_size)+1 && z == (-_size)+1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 65, (byte)3)); + } + } + + //Chests + if (y == 0) + { + if (x == _size-1 && z == (-_size)+1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 54, (byte)0)); + } + + if (x == (-_size)+1 && z == _size-1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 54, (byte)0)); + } + + if (x == _size-2 && z == (-_size)+1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 54, (byte)0)); + } + + if (x == (-_size)+2 && z == _size-1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 54, (byte)0)); + } + } + + //Beacon Floor + if (y == -1) + { + if (Math.abs(x) <= 1 && Math.abs(z) <= 1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 42, (byte)0)); + } + } + + //Beacon Roof + if (y == 5) + { + if (Math.abs(x) == 1 && Math.abs(z) <= 1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 98, (byte)0)); + } + + if (Math.abs(z) == 1 && Math.abs(x) <= 1) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 98, (byte)0)); + } + } + + //Beacon Glass + if (y == 5 && x == 0 && z == 0) + { + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 20, (byte)0)); + } + } + } + } + + //Core + build.put(UtilWorld.locToStr(getCoreLocation(location)), new OutpostBlock(build, getCoreLocation(location), Material.DIAMOND_BLOCK.getId(), (byte)0)); + + return build; + } + + public List getWallLocations(Location middle) + { + List list = new ArrayList<>(); + + list.add(middle.clone().add(_size / 2, 0, 0).add(1, 0, 0)); + list.add(middle.clone().add(_size / 2, 0, -(_size / 2)).add(1, 0, -1)); + list.add(middle.clone().add(-(_size / 2), 0, -(_size / 2)).add(-1, 0, -1)); + list.add(middle.clone().add(-(_size / 2), 0, 0).add(-1, 0, 0)); + + return list; + } + + public Location getCoreLocation(Location location) + { + return location.clone().subtract(0, 1, 0); + } + }, + MK2(5, 25) { + public LinkedHashMap createBuildQueue(Location location, ClansManager clans) + { + try + { + LinkedHashMap build = new LinkedHashMap<>(); + + File file = new File("schematic" + File.separator + "outpost_mk_II.schematic"); + System.out.println(file.getAbsolutePath()); + Schematic schematic = UtilSchematic.loadSchematic(file); + + for (int y = 0; y < schematic.getHeight(); y++) + { + for (int x = 0; x < schematic.getWidth(); x++) + { + for (int z = 0; z < schematic.getLength(); z++) + { + int relativeX = -(schematic.getWidth() / 2) + x; + int relativeZ = -(schematic.getLength() / 2) + z; + + Location loc = location.clone().add(relativeX, y - 1, relativeZ); + + if (schematic.getBlock(x, y, z) == 0 && loc.getBlock().getType() == Material.AIR) + { + continue; + } + + build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, schematic.getBlock(x, y, z), schematic.getData(x, y, z))); + } + } + } + + //Core + build.put(UtilWorld.locToStr(getCoreLocation(location)), new OutpostBlock(build, getCoreLocation(location), Material.DIAMOND_BLOCK.getId(), (byte)0)); + + return build; + } + catch(Exception e) + { + e.printStackTrace(); + return null; + } + } + + public List getWallLocations(Location middle) + { + List list = new ArrayList<>(); + + list.add(middle.clone().add(_size / 2, 0, 0).add(1, 0, 0)); + list.add(middle.clone().add(_size / 2, 0, -(_size / 2)).add(1, 0, -1)); + list.add(middle.clone().add(-(_size / 2), 0, -(_size / 2)).add(-1, 0, -1)); + list.add(middle.clone().add(-(_size / 2), 0, 0).add(-1, 0, 0)); + + return list; + } + + public Location getCoreLocation(Location location) + { + return location.clone().subtract(0, 1, 0); + } + }; + + protected int _size; + protected int _ySize; + + OutpostType(int size, int ySize) + { + _size = size; + _ySize = ySize; + } + + public abstract LinkedHashMap createBuildQueue(Location location, ClansManager clans); + + public abstract Location getCoreLocation(Location location); + + public abstract List getWallLocations(Location location); +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/pathing/AStar.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/pathing/AStar.java new file mode 100644 index 000000000..b3da829eb --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/pathing/AStar.java @@ -0,0 +1,391 @@ +/* + * By @Adamki11s + */ + +package mineplex.game.clans.clans.outpost.pathing; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.material.Gate; + +/** + * Not made by meee (NewGarbo) + * https://bukkit.org/threads/lib-a-pathfinding-algorithm.129786/ + */ +public class AStar +{ + private final int _sx; + private final int _sy; + private final int _sz; + private final int _ex; + private final int _ey; + private final int _ez; + private final World _world; + + private PathingResult _result; + + private HashMap _open = new HashMap(); + private HashMap _closed = new HashMap(); + + private void addToOpenList(Tile t, boolean modify) + { + if (_open.containsKey(t.getUID())) + { + if (modify) + { + _open.put(t.getUID(), t); + } + } + else + { + _open.put(t.getUID(), t); + } + } + + private void addToClosedList(Tile t) + { + if (!_closed.containsKey(t.getUID())) + { + _closed.put(t.getUID(), t); + } + } + + private final int _range; + private final String _endUID; + + public AStar(Location start, Location end, int range) throws InvalidPathException + { + boolean s = true, e = true; + + if (!(s = isLocationWalkable(start)) || !(e = isLocationWalkable(end))) + { + throw new InvalidPathException(s, e); + } + + _world = start.getWorld(); + _sx = start.getBlockX(); + _sy = start.getBlockY(); + _sz = start.getBlockZ(); + _ex = end.getBlockX(); + _ey = end.getBlockY(); + _ez = end.getBlockZ(); + + _range = range; + + short sh = 0; + Tile t = new Tile(sh, sh, sh, null); + t.calculateBoth(_sx, _sy, _sz, _ex, _ey, _ez, true); + _open.put(t.getUID(), t); + processAdjacentTiles(t); + + StringBuilder b = new StringBuilder(); + b.append(_ex - _sx).append(_ey - _sy).append(_ez - _sz); + _endUID = b.toString(); + } + + public Location getEndLocation() + { + return new Location(_world, _ex, _ey, _ez); + } + + public PathingResult getPathingResult() + { + return _result; + } + + protected boolean _checkOnce = false; + + private int abs(int i) + { + return (i < 0 ? -i : i); + } + + public ArrayList iterate() + { + if (!_checkOnce) + { + // invert the boolean flag + _checkOnce ^= true; + if ((abs(_sx - _ex) > _range) || (abs(_sy - _ey) > _range) || (abs(_sz - _ez) > _range)) + { + _result = PathingResult.NO_PATH; + return null;// jump out + } + } + // while not at end + Tile current = null; + + while (canContinue()) + { + + // get lowest F cost square on open list + current = getLowestFTile(); + + // process tiles + processAdjacentTiles(current); + } + + if (_result != PathingResult.SUCCESS) + { + return null; + } + else + { + // path found + LinkedList routeTrace = new LinkedList(); + Tile parent; + + routeTrace.add(current); + + while ((parent = current.getParent()) != null) + { + routeTrace.add(parent); + current = parent; + } + + Collections.reverse(routeTrace); + + return new ArrayList(routeTrace); + } + } + + private boolean canContinue() + { + // check if open list is empty, if it is no path has been found + if (_open.size() == 0) + { + _result = PathingResult.NO_PATH; + return false; + } + else + { + if (_closed.containsKey(_endUID)) + { + _result = PathingResult.SUCCESS; + return false; + } + else + { + return true; + } + } + } + + private Tile getLowestFTile() + { + double f = 0; + Tile drop = null; + + // get lowest F cost square + for (Tile t : _open.values()) + { + if (f == 0) + { + t.calculateBoth(_sx, _sy, _sz, _ex, _ey, _ez, true); + f = t.getF(); + drop = t; + } + else + { + t.calculateBoth(_sx, _sy, _sz, _ex, _ey, _ez, true); + double posF = t.getF(); + if (posF < f) + { + f = posF; + drop = t; + } + } + } + + // drop from open list and add to closed + + _open.remove(drop.getUID()); + addToClosedList(drop); + + return drop; + } + + private boolean isOnClosedList(Tile t) + { + return _closed.containsKey(t.getUID()); + } + + // pass in the current tile as the parent + private void processAdjacentTiles(Tile current) + { + + // set of possible walk to locations adjacent to current tile + HashSet possible = new HashSet(26); + + for (byte x = -1; x <= 1; x++) + { + for (byte y = -1; y <= 1; y++) + { + for (byte z = -1; z <= 1; z++) + { + + if (x == 0 && y == 0 && z == 0) + { + continue;// don't check current square + } + + Tile t = new Tile((short) (current.getX() + x), (short) (current.getY() + y), (short) (current.getZ() + z), current); + + if (!t.isInRange(_range)) + { + // if block is out of bounds continue + continue; + } + + if (x != 0 && z != 0 && (y == 0 || y == 1)) + { + // check to stop jumping through diagonal blocks + Tile xOff = new Tile((short) (current.getX() + x), (short) (current.getY() + y), (short) (current.getZ()), current), zOff = new Tile((short) (current.getX()), (short) (current.getY() + y), (short) (current.getZ() + z), current); + if (!isTileWalkable(xOff) && !isTileWalkable(zOff)) + { + continue; + } + } + + if (isOnClosedList(t)) + { + // ignore tile + continue; + } + + // only process the tile if it can be walked on + if (isTileWalkable(t)) + { + t.calculateBoth(_sx, _sy, _sz, _ex, _ey, _ez, true); + possible.add(t); + } + + } + } + } + + for (Tile t : possible) + { + // get the reference of the object in the array + Tile openRef = null; + if ((openRef = isOnOpenList(t)) == null) + { + // not on open list, so add + addToOpenList(t, false); + } + else + { + // is on open list, check if path to that square is better using + // G cost + if (t.getG() < openRef.getG()) + { + // if current path is better, change parent + openRef.setParent(current); + // force updates of F, G and H values. + openRef.calculateBoth(_sx, _sy, _sz, _ex, _ey, _ez, true); + } + + } + } + + } + + private Tile isOnOpenList(Tile t) + { + return (_open.containsKey(t.getUID()) ? _open.get(t.getUID()) : null); + /* + * for (Tile o : open) { if (o.equals(t)) { return o; } } return null; + */ + } + + private boolean isTileWalkable(Tile t) + { + Location l = new Location(_world, (_sx + t.getX()), (_sy + t.getY()), (_sz + t.getZ())); + Block b = l.getBlock(); + int i = b.getTypeId(); + + // lava, fire, wheat and ladders cannot be walked on, and of course air + // 85, 107 and 113 stops npcs climbing fences and fence gates + if (i != 10 && i != 11 && i != 51 && i != 59 && i != 65 && i != 0 && i != 85 && i != 107 && i != 113 && !canBlockBeWalkedThrough(i)) + { + // make sure the blocks above are air + + if (b.getRelative(0, 1, 0).getTypeId() == 107) + { + // fench gate check, if closed continue + Gate g = new Gate(b.getRelative(0, 1, 0).getData()); + return (g.isOpen() ? (b.getRelative(0, 2, 0).getTypeId() == 0) : false); + } + return (canBlockBeWalkedThrough(b.getRelative(0, 1, 0).getTypeId()) && b.getRelative(0, 2, 0).getTypeId() == 0); + + } + else + { + return false; + } + } + + private boolean isLocationWalkable(Location l) + { + Block b = l.getBlock(); + int i = b.getTypeId(); + + if (i != 10 && i != 11 && i != 51 && i != 59 && i != 65 && i != 0 && !canBlockBeWalkedThrough(i)) + { + // make sure the blocks above are air or can be walked through + return (canBlockBeWalkedThrough(b.getRelative(0, 1, 0).getTypeId()) && b.getRelative(0, 2, 0).getTypeId() == 0); + } + else + { + return false; + } + } + + private boolean canBlockBeWalkedThrough(int id) + { + return (id == 0 || id == 6 || id == 50 || id == 63 || id == 30 || id == 31 || id == 32 || id == 37 || id == 38 || id == 39 || id == 40 || id == 55 || id == 66 || id == 75 || id == 76 || id == 78); + } + + @SuppressWarnings("serial") + public class InvalidPathException extends Exception + { + private final boolean _s, _e; + + public InvalidPathException(boolean s, boolean e) + { + _s = s; + _e = e; + } + + public String getErrorReason() + { + StringBuilder sb = new StringBuilder(); + if (!_s) + { + sb.append("Start Location was air. "); + } + if (!_e) + { + sb.append("End Location was air."); + } + return sb.toString(); + } + + public boolean isStartNotSolid() + { + return (!_s); + } + + public boolean isEndNotSolid() + { + return (!_e); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/pathing/PathingResult.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/pathing/PathingResult.java new file mode 100644 index 000000000..06e0084dc --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/pathing/PathingResult.java @@ -0,0 +1,23 @@ +package mineplex.game.clans.clans.outpost.pathing; + +/** + * Not made by meee (NewGarbo) + * https://bukkit.org/threads/lib-a-pathfinding-algorithm.129786/ + */ +public enum PathingResult +{ + SUCCESS(0), + NO_PATH(-1); + + private final int _ec; + + PathingResult(int ec) + { + _ec = ec; + } + + public int getEndCode() + { + return _ec; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/pathing/Tile.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/pathing/Tile.java new file mode 100644 index 000000000..133d67278 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/outpost/pathing/Tile.java @@ -0,0 +1,183 @@ +/* + * By @Adamki11s + */ + +package mineplex.game.clans.clans.outpost.pathing; + +import org.bukkit.Location; + +/** + * Not made by meee (NewGarbo) + * https://bukkit.org/threads/lib-a-pathfinding-algorithm.129786/ + */ +public class Tile +{ + // as offset from starting point + private final short _x; + private final short _y; + private final short _z; + + private double _g = -1; + private double _h = -1; + + private Tile _parent = null; + + private final String _uid; + + public Tile(short x, short y, short z, Tile parent) + { + _x = x; + _y = y; + _z = z; + _parent = parent; + + StringBuilder b = new StringBuilder(); + b.append(x); + b.append(y); + b.append(z); + _uid = b.toString(); + + } + + public boolean isInRange(int range) + { + return ((range - abs(_x) >= 0) && (range - abs(_y) >= 0) && (range - abs(_z) >= 0)); + } + + public void setParent(Tile parent) + { + _parent = parent; + } + + public Location getLocation(Location start) + { + return new Location(start.getWorld(), start.getBlockX() + _x, start.getBlockY() + _y, start.getBlockZ() + _z); + } + + public Tile getParent() + { + return _parent; + } + + public short getX() + { + return _x; + } + + public int getX(Location i) + { + return (i.getBlockX() + _x); + } + + public short getY() + { + return _y; + } + + public int getY(Location i) + { + return (i.getBlockY() + _y); + } + + public short getZ() + { + return _z; + } + + public int getZ(Location i) + { + return (i.getBlockZ() + _z); + } + + public String getUID() + { + return _uid; + } + + public boolean equals(Tile t) + { + return (t.getX() == _x && t.getY() == _y && t.getZ() == _z); + } + + public void calculateBoth(int sx, int sy, int sz, int ex, int ey, int ez, boolean update) + { + calculateG(sx, sy, sz, update); + calculateH(sx, sy, sz, ex, ey, ez, update); + } + + public void calculateH(int sx, int sy, int sz, int ex, int ey, int ez, boolean update) + { + // only update if h hasn't been calculated or if forced + if ((!update && _h == -1) || update) + { + int hx = sx + _x, hy = sy + _y, hz = sz + _z; + _h = getEuclideanDistance(hx, hy, hz, ex, ey, ez); + } + } + + // G = the movement cost to move from the starting point A to a given square + // on the grid, following the path generated to get there. + public void calculateG(int sx, int sy, int sz, boolean update) + { + if ((!update && _g == -1) || update) + { + // only update if g hasn't been calculated or if forced + Tile currentParent = getParent(), currentTile = this; + int gCost = 0; + // follow path back to start + while ((currentParent = currentTile.getParent()) != null) + { + int dx = currentTile.getX() - currentParent.getX(), dy = currentTile.getY() - currentParent.getY(), dz = currentTile.getZ() - currentParent.getZ(); + + dx = abs(dx); + dy = abs(dy); + dz = abs(dz); + + if (dx == 1 && dy == 1 && dz == 1) + { + gCost += 1.7; + } else if (((dx == 1 || dz == 1) && dy == 1) || ((dx == 1 || dz == 1) && dy == 0)) + { + gCost += 1.4; + } + else + { + gCost += 1.0; + } + + // move backwards a tile + currentTile = currentParent; + } + _g = gCost; + } + + } + + public double getG() + { + return _g; + } + + public double getH() + { + return _h; + } + + public double getF() + { + // f = h + g + return (_h + _g); + } + + private double getEuclideanDistance(int sx, int sy, int sz, int ex, int ey, int ez) + { + double dx = sx - ex, dy = sy - ey, dz = sz - ez; + return Math.sqrt((dx * dx) + (dy * dy) + (dz * dz)); + } + + private int abs(int i) + { + return (i < 0 ? -i : i); + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java index fd68d2949..dcbad45bd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java @@ -1,13 +1,18 @@ package mineplex.game.clans.clans.playtime; +import org.bukkit.entity.Player; + +import mineplex.core.task.TaskManager; +import mineplex.game.clans.clans.ClansPlayerTasks; + public class PlayingClient { public long StartTime; public boolean FirstSession; - public PlayingClient(boolean first) + public PlayingClient(Player player, TaskManager taskManager) { StartTime = System.currentTimeMillis(); - FirstSession = first; + FirstSession = taskManager.hasCompletedTask(player, ClansPlayerTasks.FIRST_SESSION.id()); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java index 0a433efb7..806a00fa1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java @@ -9,6 +9,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.MiniClientPlugin; import mineplex.core.stats.StatsManager; +import mineplex.core.task.TaskManager; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansPlayerStats; import mineplex.game.clans.clans.playtime.command.PlayTimeCommand; @@ -75,7 +76,7 @@ public class Playtime extends MiniClientPlugin @Override protected PlayingClient AddPlayer(String player) { - return new PlayingClient(_statsManager.Get(player).getStat(ClansPlayerStats.PLAY_TIME.id()) == 0); + return new PlayingClient(Bukkit.getPlayer(player), TaskManager.Instance); } // Seconds diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java index 9dc1c22fe..d170200be 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java @@ -21,7 +21,7 @@ public class cemde extends CommandBase @Override public void Execute(final Player caller, final String[] args) { - Plugin.Get(caller).setStat(ClansPlayerStats.PLAY_TIME.id(), 0); + Plugin.Get(caller).setStat(ClansPlayerStats.PLAY_TIME.id(), args.length == 0 ? 0 : Integer.parseInt(args[0])); _timer.Get(caller).Skipped = false; _timer.Get(caller).InformedTimes.clear(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java index c2eccc0d4..6e9150c54 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java @@ -1,16 +1,23 @@ package mineplex.game.clans.clans.pvptimer; +import java.util.Iterator; + import org.bukkit.Bukkit; import org.bukkit.Sound; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.MiniClientPlugin; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; @@ -18,17 +25,26 @@ import mineplex.core.stats.StatsManager; import mineplex.core.task.TaskManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClanTipEvent; +import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.playtime.command.cemde; import mineplex.game.clans.clans.pvptimer.command.PvPTimerCommand; +import mineplex.game.clans.core.repository.ClanTerritory; +import mineplex.game.clans.spawn.Spawn; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.classcombat.event.FireballHitEntityEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class PvpTimer extends MiniClientPlugin { - private Playtime _tracker; - public static final String SKIPPED_TASK = "PvpTimer.Skipped"; + private final int[] DISPLAY_TIMES = { 5, 10, 30, 1 * 60, 2 * 60, 5 * 60, 10 * 60, 20 * 60 }; + + private ClansManager _clansManager; + private Playtime _tracker; private static long TIMER_LENGTH = 30 * 60; @@ -36,6 +52,7 @@ public class PvpTimer extends MiniClientPlugin { super("PvP Timer", clans.getPlugin()); _tracker = playtime; + _clansManager = clans; addCommand(new cemde(statsManager, this)); } @@ -58,6 +75,59 @@ public class PvpTimer extends MiniClientPlugin }, caller, "PvpTimer.Skipped"); } + @EventHandler + public void outYouGo(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + if (!hasTimer(player)) continue; + + ClanTerritory territory = _clansManager.getClanUtility().getClaim(player.getLocation()); + + if (territory != null && territory.Owner.equals("Borderlands")) + { + UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), Spawn.ORIGIN), 2.6, true, 0.5, 1, 1.35, true); + player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0f, 1.0f); + + UtilPlayer.message(player, " "); + + UtilPlayer.message(player, C.cDRedB + ">>" + C.cRed + " You are not permitted to enter the Borderlands while under PvP Safety."); + + new JsonMessage(C.cGoldB + "> " + C.cGold + "To permanently disable PvP Safety, click ") + .extra("here") + .color("yellow") + .click(ClickEvent.RUN_COMMAND, "/pvptimer yesiconfirmthatiwouldliketodisablemypvptimerforever") + .extra(".") + .color("gray") + .sendToPlayer(player); + + UtilPlayer.message(player, " "); + } + } + } + } + + @EventHandler + public void territoryEnter(PlayerEnterTerritoryEvent event) + { + String from = event.getLastTerritory(); + String to = event.getNewTerritory(); + + if (from == null && "Borderlands".equals(to) + || to == null && "Borderlands".equals(from)) + { + event.setSendMessage(false); + } + } + + @EventHandler + public void clanTip(ClanTipEvent event) + { + event.setCancelled(hasTimer(event.getPlayer()) && event.getTip() == TipType.ENTER_BORDERLANDS); + } + @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { @@ -68,13 +138,13 @@ public class PvpTimer extends MiniClientPlugin Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { public void run() { - UtilTextMiddle.display(C.cGold + "PvP Timer", "will end in " + UtilTime.MakeStr(getPvPTimerLeft(player) * 1000), 40, 70, 40, player); + UtilTextMiddle.display(C.cGreen + "PvP Safety", C.cGray + "will end in " + UtilTime.MakeStr(getPvPTimerLeft(player) * 1000), 40, 70, 40, player); } }, 10); - UtilPlayer.message(player, F.main("Clans", "You are currently on your PvP timer. It will end in " + F.elem(UtilTime.MakeStr(getPvPTimerLeft(player) * 1000)))); + UtilPlayer.message(player, F.main("Clans", "You are currently safe from PvP because you are a new player. This safety will end in " + F.elem(UtilTime.MakeStr(getPvPTimerLeft(player) * 1000)))); UtilPlayer.message(player, F.main("Clans", "Until it ends, you are immune to, and unable to deal PvP damage.")); - UtilPlayer.message(player, F.main("Clans", "If you would like to disable the PvP timer permanently, then type " + F.elem("/pvptimer") + ", and follow the instructions given.")); + UtilPlayer.message(player, F.main("Clans", "If you would like to disable the PvP safety permanently, then type " + F.elem("/pvp") + ".")); } } @@ -90,67 +160,60 @@ public class PvpTimer extends MiniClientPlugin long time = getPvPTimerLeft(player); PvpTimerClient client = Get(player); - // end if (time <= 2) { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " has ended!")); + UtilPlayer.message(player, F.main("Clans", "PvP Safety has ended!")); UtilPlayer.message(player, F.main("Clans", "You are now completely open to attacks, and you can also attack others.")); player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 0.75f); + continue; } - // 5 secs - else if (time <= 5 && !client.InformedTimes.contains(5)) + + for (int unit : DISPLAY_TIMES) { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("5.0 Seconds"))); - UtilTextMiddle.display("Pvp Timer", "ending in 5 Seconds"); - client.InformedTimes.add(5); - } - // 10 secs - else if (time <= 10 && !client.InformedTimes.contains(10)) - { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("10.0 Seconds"))); - UtilTextMiddle.display("Pvp Timer", "ending in 10 Seconds"); - client.InformedTimes.add(10); - } - // 30 secs - else if (time <= 30 && !client.InformedTimes.contains(30)) - { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("30.0 Seconds"))); - UtilTextMiddle.display("Pvp Timer", "ending in 30 Seconds"); - client.InformedTimes.add(30); - } - // 1 minute - else if (time <= 1 * 60 && !client.InformedTimes.contains(1 * 60)) - { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("1.0 Minute"))); - UtilTextMiddle.display("Pvp Timer", "ending in 1 Minute"); - client.InformedTimes.add(5); - } - // 5 minutes - else if (time <= 5 * 60 && !client.InformedTimes.contains(5 * 60)) - { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("5.0 Minutes"))); - UtilTextMiddle.display("Pvp Timer", "ending in 5 Minutes"); - client.InformedTimes.add(5 * 60); - } - // 10 minutes - else if (time <= 10 * 60 && !client.InformedTimes.contains(10 * 60)) - { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("10.0 Minutes"))); - UtilTextMiddle.display("Pvp Timer", "ending in 10 Minutes"); - client.InformedTimes.add(10 * 60); - } - // 20 minutes - else if (time <= 20 * 60 && !client.InformedTimes.contains(20 * 60)) - { - UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("20.0 Minutes"))); - UtilTextMiddle.display("Pvp Timer", "ending in 20 Minutes"); - client.InformedTimes.add(20 * 60); + if (time <= unit && !client.InformedTimes.contains(unit)) + { + UtilPlayer.message(player, F.main("Clans", "PvP Safety will end in " + F.time(UtilTime.MakeStr(unit * 1000)))); + UtilTextMiddle.display(C.cGreen + "Pvp Safety", C.cGray + "ending in " + UtilTime.MakeStr(unit * 1000), 20, 80, 20, player); + client.InformedTimes.add(unit); + } } } } } } + @EventHandler + public void onSkill(SkillTriggerEvent event) + { + if (event.GetTargets() == null) + { + return; + } + + if (event.GetTargets().size() == 1 + && event.GetTargets().get(0) instanceof Player + && hasTimer((Player) event.GetTargets().get(0))) + { + event.SetCancelled(true); + } + + for (Iterator iterator = event.GetTargets().iterator(); iterator.hasNext();) + { + Entity entity = iterator.next(); + + if (entity instanceof Player && hasTimer((Player) entity)) + { + iterator.remove(); + } + } + } + + @EventHandler + public void onFireballHit(FireballHitEntityEvent event) + { + event.setCancelled(event.getHitEntity() instanceof Player && hasTimer((Player) event.getHitEntity())); + } + @EventHandler(priority = EventPriority.LOWEST) public void onPlayerAttack(CustomDamageEvent event) { @@ -170,12 +233,12 @@ public class PvpTimer extends MiniClientPlugin { if (damagerTimer) { - UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still on your PvP timer. Type " + F.elem("/pvptimer") + " to disable.")); + UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still protected from PvP. Type " + F.elem("/pvp") + " to disable.")); bothMsg = true; } else if (damager != null) { - UtilPlayer.message(damager, F.main("Clans", F.name(victim.getName()) + " is still on their Pvp timer.")); + UtilPlayer.message(damager, F.main("Clans", F.name(victim.getName()) + " is still protected from PvP.")); } event.SetCancelled("Pvp Timer"); @@ -185,11 +248,11 @@ public class PvpTimer extends MiniClientPlugin { if (victimTimer) { - if (!bothMsg) UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still on your PvP timer. Type " + F.elem("/pvptimer") + " to disable.")); + if (!bothMsg) UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still under PvP Safety. Type " + F.elem("/pvp") + " to disable.")); } else if (damager != null) { - UtilPlayer.message(damager, F.main("Clans", "You are still on your PvP timer.")); + UtilPlayer.message(damager, F.main("Clans", "You are still under PvP Safety.")); } event.SetCancelled("PvP Timer"); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java index b8c04949e..104c4155d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java @@ -6,6 +6,7 @@ import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; @@ -25,7 +26,7 @@ public class PvPTimerCommand extends CommandBase { if (Plugin.Get(caller).Skipped) { - UtilPlayer.message(caller, F.main("Clans", "You have skipped your PvP timer.")); + UtilPlayer.message(caller, F.main("Clans", "You have permanently disabled PvP Safety.")); return; } @@ -33,12 +34,12 @@ public class PvPTimerCommand extends CommandBase if (pvpTimerLeft == 0) { - UtilPlayer.message(caller, F.main("Clans", "Your PvP timer has ended.")); + UtilPlayer.message(caller, F.main("Clans", "PvP Safety has already ended.")); } else { - UtilPlayer.message(caller, F.main("Clans", "You have " + F.elem(UtilTime.MakeStr(pvpTimerLeft * 1000)) + " before your PvP timer runs out.")); - new JsonMessage(F.main("Clans", "If you would like to permanently disable Pvp timer, click ")) + UtilPlayer.message(caller, F.main("Clans", "You have " + F.elem(UtilTime.MakeStr(pvpTimerLeft * 1000)) + " before PvP Safety runs out for you.")); + new JsonMessage(F.main("Clans", "If you would like to permanently disable " + C.mBody + "PvP Safety, click ")) .extra("here") .color("green") .click(ClickEvent.RUN_COMMAND, "/pvptimer yesiconfirmthatiwouldliketodisablemypvptimerforever") @@ -53,7 +54,8 @@ public class PvPTimerCommand extends CommandBase if (args[0].equalsIgnoreCase("yesiconfirmthatiwouldliketodisablemypvptimerforever")) { Plugin.disableFor(caller); - UtilPlayer.message(caller, F.main("Clans", "You have disabled your Pvp timer.")); + UtilPlayer.message(caller, F.main("Clans", "You have disabled PvP Safety.")); + UtilPlayer.message(caller, F.main("Clans", "You are now completely open to attacks, and you can also attack others.")); } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java index 21cf7f5cb..bb80a711e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/regions/ClansRegions.java @@ -211,7 +211,7 @@ public class ClansRegions extends MiniPlugin if (_manager.getClaimMap().containsKey(chunkStr)) { - System.out.println("get claim map contains " + chunkStr); +// System.out.println("get claim map contains " + chunkStr); // this is really really slowing server startup down. just saying. continue; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java index 4512180ba..152d6ba2c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java @@ -10,7 +10,7 @@ public class WorldEventCommand extends MultiCommandBase { public WorldEventCommand(WorldEventManager plugin) { - super(plugin, Rank.EVENT, "worldevent", "we", "event"); + super(plugin, Rank.CMOD, "worldevent", "we", "event"); AddCommand(new StartCommand(Plugin)); AddCommand(new ClearCommand(Plugin)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java index 5b6195a54..abeabf652 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/CustomRecipes.java @@ -1,20 +1,18 @@ package mineplex.game.clans.gameplay; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; - import org.bukkit.Material; import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.inventory.Recipe; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + public class CustomRecipes implements Listener { - - private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.JUKEBOX, Material.FISHING_ROD }; + private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.JUKEBOX, Material.FISHING_ROD, Material.BED }; @EventHandler public void onPlayerCraftItem(CraftItemEvent event) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index e5c4b62b9..ed9bbd104 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -6,11 +6,11 @@ import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.DyeColor; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -39,32 +39,36 @@ import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent.State; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.material.Dye; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; +import mineplex.core.common.weight.Weight; +import mineplex.core.common.weight.WeightSet; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; -import mineplex.core.common.weight.Weight; -import mineplex.core.common.weight.WeightSet; +import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent; +import mineplex.minecraft.game.classcombat.Skill.event.BlockTossLandEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.DamageManager; @@ -101,6 +105,20 @@ public class Gameplay extends MiniPlugin // } // } + @EventHandler + public void stopBlockTossExploit(BlockTossLandEvent event) + { + int id = event.Entity.getBlockId(); + if (_clansManager.getClanUtility().isClaimed(event.getLocation()) + && (Material.getMaterial(id).name().endsWith("_PLATE") + || id == Material.STONE_BUTTON.getId() + || id == Material.WOOD_BUTTON.getId() + || id == Material.LEVER.getId())) + { + event.setCancelled(true); + } + } + @EventHandler public void onPlayerFishing(PlayerFishEvent event) { @@ -149,7 +167,6 @@ public class Gameplay extends MiniPlugin } } } - @EventHandler public void BucketEmpty(PlayerBucketEmptyEvent event) { @@ -429,57 +446,130 @@ public class Gameplay extends MiniPlugin event.setCancelled(true); } - @EventHandler(priority = EventPriority.LOWEST) - public void replantTree(BlockBreakEvent event) + @EventHandler(priority = EventPriority.HIGHEST) + public void disableSaplings(BlockPlaceEvent event) { - final Block block = event.getBlock(); - - if (_clansManager.getClanUtility().isSafe(block.getLocation())) + if (!event.getItemInHand().getType().equals(Material.SAPLING)) { return; } - if (!UtilItem.isLog(block.getType())) + Block block = event.getBlock(); + ClanInfo clan = _clansManager.getClanUtility().getClanByPlayer(event.getPlayer()); + + for (int cX = -32; cX < 32; cX++) { - return; - } - - if (UtilItem.isLog(block.getRelative(BlockFace.DOWN).getType())) - { - return; - } - - if (UtilItem.isLeaf(block.getRelative(BlockFace.DOWN).getType())) - { - return; - } - - if (block.getRelative(BlockFace.DOWN).getType() != Material.DIRT && block.getRelative(BlockFace.DOWN).getType() != Material.GRASS) - { - return; - } - - final byte data = block.getData(); - - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { - public void run() + for (int cZ = -32; cZ < 32; cZ++) { - block.setType(Material.SAPLING); - block.setData(data); + ClanTerritory claim = _clansManager.getClanUtility().getClaim(block.getLocation().add(cX, 0, cZ)); + + if (claim != null && (clan == null || !claim.Owner.equals(clan.getName()))) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not place saplings near other clan's claims.")); + event.setCancelled(true); + return; + } } - }, 20 * 5); + } + + if (clan == null || (!clan.equals(_clansManager.getClanUtility().getOwner(block.getLocation())))) + { + if (UtilBlock.getInRadius(block, 10) + .keySet() + .stream() + .filter(other -> other.getType().equals(Material.SAPLING)) + .filter(other -> !other.getLocation().equals(block.getLocation())) + .toArray().length > 0) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not place this block close to any other saplings, unless in your territory.")); + event.setCancelled(true); + return; + } + } + + if (!Recharge.Instance.use(event.getPlayer(), "Place Sapling", 20 * 60 * 1000, true, false)) + { + event.setCancelled(true); + return; + } } + + @EventHandler + public void blockDispenser(BlockDispenseEvent event) + { + // Block bonemeal + if (event.getItem().getType() == Material.INK_SACK && ((Dye) event.getItem().getData()).getColor() == DyeColor.WHITE) + { + event.setCancelled(true); + } + + // Block flint-and-steal + if (event.getItem().getType() == Material.FLINT_AND_STEEL) + { + event.setCancelled(true); + } + + if (event.getItem().getType() == Material.FIREWORK_CHARGE) + { + event.setCancelled(true); + } + + if (event.getItem().getType() == Material.SAPLING) + { + event.setCancelled(true); + } + + if (event.getItem().getType() == Material.TNT) + { + event.setCancelled(true); + } + } + +// @EventHandler(priority = EventPriority.LOWEST) +// public void replantTree(BlockBreakEvent event) +// { +// final Block block = event.getBlock(); +// +// if (_clansManager.getClanUtility().getClaim(block.getLocation()) != null) +// { +// return; +// } +// +// if (!UtilItem.isLog(block.getType())) +// { +// return; +// } +// +// if (UtilItem.isLog(block.getRelative(BlockFace.DOWN).getType())) +// { +// return; +// } +// +// if (UtilItem.isLeaf(block.getRelative(BlockFace.DOWN).getType())) +// { +// return; +// } +// +// if (block.getRelative(BlockFace.DOWN).getType() != Material.DIRT && block.getRelative(BlockFace.DOWN).getType() != Material.GRASS) +// { +// return; +// } +// +// final byte data = block.getData(); +// +// UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { +// public void run() +// { +// block.setType(Material.SAPLING); +// block.setData(data); +// } +// }, 20 * 5); +// } @EventHandler - public void killRain(UpdateEvent event) + public void killRain(WeatherChangeEvent event) { - if (event.getType() != UpdateType.TWOSEC){ - for (World world : Bukkit.getWorlds()){ - world.setWeatherDuration(0); - world.setThunderDuration(0); - world.setThundering(false); - } - } + event.setCancelled(event.toWeatherState()); } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java index 9539a639e..f07a24ea6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java @@ -1,9 +1,12 @@ package mineplex.game.clans.gameplay.safelog; import java.io.File; +import java.util.ArrayList; +import java.util.List; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -19,8 +22,8 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; -import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClanTips.TipType; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; public class SafeLog extends MiniPlugin @@ -48,6 +51,12 @@ public class SafeLog extends MiniPlugin isSafeLog = true; } + if (_flying.contains(player.getName())) + { + _flying.remove(player.getName()); + return; + } + if (!isSafeLog) { NPCManager.getInstance().spawnLogoutNpc(player); @@ -93,20 +102,35 @@ public class SafeLog extends MiniPlugin } } - @EventHandler + private List _flying = new ArrayList<>(); + + @EventHandler(priority = EventPriority.LOWEST) public void onPlayerQuit(PlayerQuitEvent event) { - event.setQuitMessage(null); - UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName())); + event.setQuitMessage(F.sys("Quit", event.getPlayer().getName())); onPlayerQuit(event.getPlayer()); } + + @EventHandler(priority = EventPriority.HIGHEST) + public void flyCheck(PlayerKickEvent event) + { + if (event.getPlayer().getItemInHand() != null && event.getPlayer().getItemInHand().getItemMeta() != null && (C.cGold + "Wind Blade").equals(event.getPlayer().getItemInHand().getItemMeta().getDisplayName())) + if (event.getReason().contains("flying is not enabled")) + return; + + _flying.add(event.getPlayer().getName()); + } - @EventHandler + @EventHandler(priority = EventPriority.LOWEST) public void onPlayerKicked(PlayerKickEvent event) { - event.setLeaveMessage(null); - UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName())); + if (event.isCancelled()) return; + if (event.getPlayer().getItemInHand() != null && event.getPlayer().getItemInHand().getItemMeta() != null && (C.cGold + "Wind Blade").equals(event.getPlayer().getItemInHand().getItemMeta().getDisplayName())) + if (event.getReason().contains("flying is not enabled")) + return; + + event.setLeaveMessage(F.sys("Quit", event.getPlayer().getName())); onPlayerQuit(event.getPlayer()); } @@ -115,7 +139,6 @@ public class SafeLog extends MiniPlugin public void onPlayerJoin(PlayerJoinEvent event) { event.setJoinMessage(null); - UtilServer.broadcast(F.sys("Join", event.getPlayer().getName())); onPlayerJoin(event.getPlayer()); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java index 9d4e04f83..c37e78a56 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/CombatLogNPC.java @@ -13,6 +13,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; +import org.bukkit.metadata.FixedMetadataValue; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -20,7 +21,6 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFile; import mineplex.core.common.util.UtilFile.ChunkType; import mineplex.core.common.util.UtilFile.DataFileChunk; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -28,6 +28,8 @@ import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; +import mineplex.game.clans.Clans; +import mineplex.game.clans.clans.ClansManager; public class CombatLogNPC { @@ -188,6 +190,7 @@ public class CombatLogNPC { Location spawnLoc = player.getLocation(); Skeleton skel = player.getWorld().spawn(spawnLoc, Skeleton.class); + skel.setMetadata("CombatLogNPC", new FixedMetadataValue(ClansManager.getInstance().getPlugin(), player.getUniqueId().toString())); skel.teleport(spawnLoc); skel.setHealth(_spawnHealth); UtilEnt.Vegetate(skel); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/NPCManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/NPCManager.java index 57b3ae3c2..451149aad 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/NPCManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/npc/NPCManager.java @@ -4,15 +4,19 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.world.ChunkUnloadEvent; +import org.bukkit.metadata.FixedMetadataValue; import mineplex.core.MiniPlugin; import mineplex.core.hologram.HologramManager; @@ -20,6 +24,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.spawn.Spawn; import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class NPCManager extends MiniPlugin @@ -74,6 +79,18 @@ public class NPCManager extends MiniPlugin } } + @EventHandler + public void killNpcs(PlayerJoinEvent event) + { + for (LivingEntity entity : Spawn.getSpawnWorld().getLivingEntities()) + { + if (entity.hasMetadata("CombatLogNPC") && ((FixedMetadataValue) entity.getMetadata("CombatLogNPC").get(0)).asString().equals(event.getPlayer().getUniqueId().toString())) + { + entity.remove(); + } + } + } + public void despawnLogoutNpc(Player player) { CombatLogNPC npc = getLogoutNpc(player); @@ -194,15 +211,22 @@ public class NPCManager extends MiniPlugin { CombatLogNPC npc = iterator.next(); + if (Bukkit.getPlayer(npc.getPlayerInfo().getPlayerName()) != null) + { + System.out.println("{NPCMANAGER} ORIGINAL PLAYER ALIVE AND DESPAWNING"); + npc.despawn(); + iterator.remove(); + } + if (!npc.isAlive()) { - System.out.println("NOT ALIVE AND REMOVING"); + System.out.println("{NPCMANAGER} NOT ALIVE AND REMOVING"); npc.remove(); iterator.remove(); } else if (npc.getAliveDuation() > COMBAT_LOG_DURATION) { - System.out.println("DESPAWNING"); + System.out.println("{NPCMANAGER} DESPAWNING"); npc.despawn(); iterator.remove(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java index 83a5c7dcc..ab9a84425 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java @@ -55,6 +55,8 @@ public class CustomItem private boolean _dullEnchantment; + public String OriginalOwner = null; + public String getUuid() { return _uuid; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index 1c30244f5..b6505c23b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -8,7 +8,9 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; @@ -23,6 +25,7 @@ import com.google.gson.GsonBuilder; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -64,7 +67,6 @@ import mineplex.game.clans.items.legendaries.WindBlade; import mineplex.game.clans.items.smelting.SmeltingListener; import mineplex.game.clans.items.ui.GearShop; import mineplex.serverdata.serialization.RuntimeTypeAdapterFactory; - import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; @@ -361,6 +363,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable } catch (Exception exception) { + exception.printStackTrace(); System.out.println("=========="); System.out.println("GearManager parse problem :"); System.out.println(serialization); @@ -481,7 +484,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable if (packet instanceof PacketPlayOutSetSlot) { PacketPlayOutSetSlot slotPacket = (PacketPlayOutSetSlot) packet; - slotPacket.c = maskItem(slotPacket.c); // Mask all out-going item + slotPacket.c = maskItem(slotPacket.c, packetInfo.getPlayer()); // Mask all out-going item // packets } else if (packet instanceof PacketPlayOutWindowItems) @@ -490,7 +493,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable for (int i = 0; i < itemsPacket.b.length; i++) { - itemsPacket.b[i] = maskItem(itemsPacket.b[i]); // Mask all + itemsPacket.b[i] = maskItem(itemsPacket.b[i], packetInfo.getPlayer()); // Mask all // out-going // item packets ItemStack item = CraftItemStack.asCraftMirror(itemsPacket.b[i]); @@ -514,7 +517,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable return item; } - private net.minecraft.server.v1_8_R3.ItemStack maskItem(net.minecraft.server.v1_8_R3.ItemStack item) + private net.minecraft.server.v1_8_R3.ItemStack maskItem(net.minecraft.server.v1_8_R3.ItemStack item, Player player) { // Cannot mask a null item if (item == null) @@ -533,18 +536,21 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable List lore = new ArrayList(); + CustomItem ci = parseItem(originalItem); + for (String line : originalMeta.getLore()) { - if (!line.startsWith(ITEM_SERIALIZATION_TAG)) // Remove - // serialization - // lines from - // out-going lore + if (!line.startsWith(ITEM_SERIALIZATION_TAG)) { lore.add(line); - }else{ } } + if (ci != null && _legendaryWeights.elements().contains(ci.getClass())) + { + lore.add(C.cWhite + "Original Owner: " + C.cYellow + (ci.OriginalOwner == null ? "You" : Bukkit.getOfflinePlayer(UUID.fromString(ci.OriginalOwner)).getName())); + } + net.minecraft.server.v1_8_R3.ItemStack newItem = CraftItemStack.asNMSCopy(originalItem); CraftItemStack newCopy = CraftItemStack.asCraftMirror(newItem); ItemMeta newMeta = newCopy.getItemMeta(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java index fbc03131d..a57bdc824 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java @@ -3,17 +3,20 @@ package mineplex.game.clans.items; import java.util.HashSet; import java.util.Set; -import mineplex.game.clans.items.legendaries.LegendaryItem; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.game.clans.items.legendaries.LegendaryItem; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + /** * PlayerGear caches and manages a players set of {@link CustomItem}s that they * currently wield. @@ -55,7 +58,14 @@ public class PlayerGear if (item != null && item instanceof LegendaryItem) { LegendaryItem legendary = (LegendaryItem) item; + legendary.preUpdate(getPlayer()); legendary.update(getPlayer()); + + if (legendary.OriginalOwner == null) + { + legendary.OriginalOwner = getPlayer().getUniqueId().toString(); + getPlayer().setItemInHand(legendary.toItemStack()); + } } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/InverseAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/InverseAttribute.java index 6c3026887..c37d120c9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/InverseAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/InverseAttribute.java @@ -5,11 +5,9 @@ import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import org.bukkit.entity.Entity; - public class InverseAttribute extends ItemAttribute { -private static ValueDistribution knockbackGen = generateDistribution(-0.5d, 1.0d); +private static ValueDistribution knockbackGen = generateDistribution(0.d, 1.d); private double _knockbackModifier; @@ -29,7 +27,7 @@ private static ValueDistribution knockbackGen = generateDistribution(-0.5d, 1.0d @Override public String getDescription() { - return String.format("Reverse knockback and modify amount to %.2f percent", (1.0d + _knockbackModifier) * 100d); + return String.format("Reverse knockback and modify amount to %.2f percent", (.5d + _knockbackModifier) * 100d); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/LeechingAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/LeechingAttribute.java index 2ae4632d6..bfc0daf85 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/LeechingAttribute.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/bow/LeechingAttribute.java @@ -1,5 +1,6 @@ package mineplex.game.clans.items.attributes.bow; +import mineplex.core.common.util.UtilMath; import mineplex.game.clans.items.attributes.AttributeType; import mineplex.game.clans.items.attributes.ItemAttribute; import mineplex.game.clans.items.generation.ValueDistribution; @@ -45,6 +46,6 @@ public class LeechingAttribute extends ItemAttribute private void heal(Player player, double healAmount) { - player.setHealth(player.getHealth() + healAmount); + player.setHealth(UtilMath.clamp(player.getHealth() + healAmount, 0, 20)); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java index d28524af0..a04ba08c5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java @@ -62,7 +62,7 @@ public class GiantsBroadsword extends LegendaryItem private void buffPlayer(Player player) { - grantPotionEffect(player, PotionEffectType.SLOW, 20, 10); - grantPotionEffect(player, PotionEffectType.REGENERATION, 1, 10); + grantPotionEffect(player, PotionEffectType.SLOW, 40, 43); + grantPotionEffect(player, PotionEffectType.REGENERATION, 2, 43); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java index ffa649364..13094784a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java @@ -30,6 +30,10 @@ public class LegendaryItem extends CustomItem // Leave implementation to potential subtypes } + public void preUpdate(Player wielder) + { + } + public void onAttack(CustomDamageEvent event, Player wielder) { // Leave implementation to potential subtypes diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java index 921f00d61..1ef288b15 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java @@ -74,7 +74,7 @@ public class WindBlade extends LegendaryItem _burnoutThreshold = 0; } - if (_messageTimer % 20 == 0) + if (_messageTimer % 5 == 0) { UtilPlayer.message(wielder, F.main("Wind Blade", "Flight power damaged whilst scraping the ground! Repairs will be finish in " + F.time(UtilTime.MakeStr(burnoutRemaining)) + ".")); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java index 78169ea47..459a18701 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java @@ -89,7 +89,6 @@ public abstract class ClansShopPage> extends Sh addShopItem(index, item, (byte) 0, displayName, 1); } - public void addShopItem(int index, ClansShopItem item) { addShopItem(index, item, (byte) 0); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java index 53ef5e8a1..a04d444d0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -54,6 +54,7 @@ public class Spawn extends MiniPlugin public static final int SHOP_RADIUS = 48; public static final String COMBAT_TAG_NAME = "Unsafe"; public static final long COMBAT_TAG_DURATION = 15000; + public static final Location ORIGIN = new Location(getSpawnWorld(), 0, 0, 0); private static Spawn _instance; public static Spawn getInstance() { return _instance; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java index cc785d827..ac0f637e4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import org.bukkit.Color; import org.bukkit.FireworkEffect.Type; @@ -31,24 +30,21 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.donation.DonationManager; -import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; -import mineplex.core.packethandler.PacketInfo; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.scoreboard.elements.ScoreboardElement; import mineplex.core.task.TaskManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.ClansPlayerTasks; import mineplex.game.clans.clans.event.ClanJoinEvent; import mineplex.game.clans.clans.event.ClanTipEvent; import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.economy.GoldManager; -import net.minecraft.server.v1_8_R3.PacketPlayOutChat; /** * @@ -286,6 +282,13 @@ public abstract class Tutorial implements ScoreboardElement, Listener _inTutorial.remove(player.getName()); onFinished(player); + if (_playtime.Get(player).FirstSession) + { + _playtime.Get(player).StartTime = System.currentTimeMillis(); + _playtime.Get(player).FirstSession = false; + TaskManager.Instance.completedTask(null, player, ClansPlayerTasks.FIRST_SESSION.id()); + } + _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() { public void run() @@ -441,6 +444,13 @@ public abstract class Tutorial implements ScoreboardElement, Listener player.showPlayer(other); } } + + if (_playtime.Get(player).FirstSession) + { + _playtime.Get(player).StartTime = System.currentTimeMillis(); + _playtime.Get(player).FirstSession = false; + TaskManager.Instance.completedTask(null, player, ClansPlayerTasks.FIRST_SESSION.id()); + } } public boolean isInTutorial(final Player player) @@ -503,12 +513,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener { public void run(Boolean data) { - if (_playtime.Get(player).FirstSession) - { - _playtime.Get(player).StartTime = System.currentTimeMillis(); - _playtime.Get(player).FirstSession = false; - } - cancelFor(player); } }, player, String.format(SKIPPED_TASK, _technicalName)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java index c91e87436..6e924c468 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java @@ -53,12 +53,6 @@ public class TutorialGettingStarted extends Tutorial { player.resetPlayerTime(); player.teleport(Spawn.getEastSpawn()); - - if (_playtime.Get(player).FirstSession) - { - _playtime.Get(player).StartTime = System.currentTimeMillis(); - _playtime.Get(player).FirstSession = false; - } } @Override diff --git a/Plugins/Mineplex.Hub/.classpath b/Plugins/Mineplex.Hub/.classpath deleted file mode 100644 index 92e1e93d4..000000000 --- a/Plugins/Mineplex.Hub/.classpath +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Hub/.externalToolBuilders/Hub Builder.launch b/Plugins/Mineplex.Hub/.externalToolBuilders/Hub Builder.launch deleted file mode 100644 index 25bfb413a..000000000 --- a/Plugins/Mineplex.Hub/.externalToolBuilders/Hub Builder.launch +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Hub/.project b/Plugins/Mineplex.Hub/.project deleted file mode 100644 index 3230745dd..000000000 --- a/Plugins/Mineplex.Hub/.project +++ /dev/null @@ -1,26 +0,0 @@ - - - Mineplex.Hub - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - - - LaunchConfigHandle - <project>/.externalToolBuilders/Hub Builder.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.Hub/.settings/org.eclipse.core.resources.prefs b/Plugins/Mineplex.Hub/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/Plugins/Mineplex.Hub/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/Plugins/Mineplex.Hub/Mineplex.Hub.iml b/Plugins/Mineplex.Hub/Mineplex.Hub.iml deleted file mode 100644 index 474bfecac..000000000 --- a/Plugins/Mineplex.Hub/Mineplex.Hub.iml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/pom.xml b/Plugins/Mineplex.Hub/pom.xml new file mode 100644 index 000000000..feb5a3f6e --- /dev/null +++ b/Plugins/Mineplex.Hub/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + + com.mineplex + mineplex-plugin + dev-SNAPSHOT + ../plugin.xml + + + Hub + mineplex-hub + + + + ${project.groupId} + mineplex-game-clans-core + ${project.version} + + + ${project.groupId} + mineplex-minecraft-game-classcombat + ${project.version} + + + diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index bfac5e555..de561f590 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -13,6 +13,7 @@ import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; +import mineplex.core.common.events.ServerShutdownEvent; import mineplex.core.creature.Creature; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; @@ -54,6 +55,7 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; +import mineplex.hub.modules.NewYearCountdown; import mineplex.hub.modules.StackerManager; import mineplex.hub.queue.QueueManager; import mineplex.hub.server.ServerManager; @@ -65,7 +67,6 @@ import mineplex.minecraft.game.classcombat.shop.ClassCombatShop; import mineplex.minecraft.game.classcombat.shop.ClassShopManager; import mineplex.minecraft.game.core.IRelation; import mineplex.minecraft.game.core.combat.CombatManager; -import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; @@ -188,7 +189,7 @@ public class Hub extends JavaPlugin implements IRelation @Override public void onDisable() { - + getServer().getPluginManager().callEvent(new ServerShutdownEvent(this)); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 55d00076d..3828bda01 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -4,7 +4,6 @@ import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.nio.file.Files; import java.util.ArrayList; import java.util.HashMap; import java.util.Random; @@ -19,10 +18,9 @@ import mineplex.core.blockrestore.BlockRestore; import mineplex.core.bonuses.BonusManager; import mineplex.core.botspam.BotSpamManager; import mineplex.core.common.Rank; +import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -33,11 +31,13 @@ import mineplex.core.common.util.UtilWorld; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.PlayerDisguiseManager; import mineplex.core.disguise.disguises.DisguiseSlime; import mineplex.core.donation.DonationManager; +import mineplex.core.facebook.FacebookManager; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.event.GadgetCollideEntityEvent; +import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.types.GadgetType; import mineplex.core.giveaway.GiveawayManager; import mineplex.core.hologram.HologramManager; @@ -90,9 +90,18 @@ import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.condition.ConditionManager; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.HoverEvent.Action; +import net.md_5.bungee.api.chat.TextComponent; +import org.jooq.tools.json.JSONObject; + +import net.minecraft.server.v1_8_R3.ChatMessage; import net.minecraft.server.v1_8_R3.EntityInsentient; import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.IChatBaseComponent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -104,11 +113,8 @@ import org.bukkit.entity.Egg; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityTargetEvent.TargetReason; @@ -125,7 +131,6 @@ import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.world.ChunkLoadEvent; -import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; @@ -134,7 +139,7 @@ import org.bukkit.scoreboard.Scoreboard; public class HubManager extends MiniClientPlugin { // ☃❅ Snowman! - public HubType Type = HubType.Christmas; + public HubType Type = HubType.Normal; private BlockRestore _blockRestore; private CoreClientManager _clientManager; @@ -162,6 +167,7 @@ public class HubManager extends MiniClientPlugin private PersonalServerManager _personalServerManager; private PlayerCountManager _playerCountManager; private CustomDataManager _customDataManager; + private Punish _punishManager; // private HalloweenSpookinessManager _halloweenManager; // private TrickOrTreatManager _trickOrTreatManager; @@ -244,20 +250,23 @@ public class HubManager extends MiniClientPlugin ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; - new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager); + FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); + new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager, facebookManager); // _halloweenManager = new HalloweenSpookinessManager(this); - new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); - +// new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); + new PlayerDisguiseManager(plugin, _clientManager); // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // new MailManager(_plugin, notificationManager); _playerCountManager = new PlayerCountManager(plugin); _customDataManager = new CustomDataManager(plugin, clientManager); - + _songs = new ArrayList(); + + _punishManager = punish; try { @@ -295,6 +304,9 @@ public class HubManager extends MiniClientPlugin private void playNextSong() { + if (Type != HubType.Christmas) + return; + if (_songs.isEmpty()) return; @@ -626,6 +638,21 @@ public class HubManager extends MiniClientPlugin } else { + TextComponent rankComponent = new TextComponent(rankStr); + TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + playerName); + TextComponent component = new TextComponent(); + + rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()).create())); + + component.setText(levelStr); + component.addExtra(rankComponent); + component.addExtra(playerNameText); + component.addExtra(" " + ChatColor.WHITE + event.getMessage()); + +// JsonMessage jsonMessage = new JsonMessage(levelStr) +// .extra(JSONObject.escape(rankStr)).hover("show_text", rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()) +// .add(JSONObject.escape(C.cYellow + playerName + " " + ChatColor.WHITE + event.getMessage())); + for (Player other : UtilServer.getPlayers()) { if (_tutorialManager.InTutorial(other)) @@ -634,9 +661,12 @@ public class HubManager extends MiniClientPlugin continue; } - event.setMessage(event.getMessage()); - event.setFormat(levelStr + rankStr + C.cYellow + playerName + " " + C.cWhite + "%2$s"); + // event.setMessage(event.getMessage()); + // event.setFormat(levelStr + rankStr + C.cYellow + playerName + " " + C.cWhite + "%2$s"); + if(!event.isCancelled()) + other.spigot().sendMessage(component); } + event.setCancelled(true); } } @@ -867,6 +897,11 @@ public class HubManager extends MiniClientPlugin { return _customDataManager; } + + public Punish getPunishments() + { + return _punishManager; + } // public HalloweenSpookinessManager getHalloweenManager() // { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java index bb078b3bb..fa0c65c2b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/DisguiseCommand.java @@ -1,9 +1,9 @@ package mineplex.hub.commands; import java.lang.reflect.Field; +import java.util.List; import java.util.UUID; -import mineplex.core.NCPDataManFix; import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; @@ -14,17 +14,29 @@ import mineplex.core.common.util.ProfileLoader; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.PlayerUndisguiseEvent; import mineplex.core.disguise.disguises.DisguisePlayer; -import mineplex.core.donation.Donor; import mineplex.core.gadget.event.GadgetEnableEvent; -import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; +import mineplex.core.punish.Category; +import mineplex.core.punish.PunishClient; +import mineplex.core.punish.Punishment; import mineplex.core.treasure.event.TreasureStartEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; +import net.minecraft.server.v1_8_R3.ChatComponentText; import net.minecraft.server.v1_8_R3.EntityHuman; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.EnumDifficulty; +import net.minecraft.server.v1_8_R3.IChatBaseComponent; import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData; +import net.minecraft.server.v1_8_R3.PacketPlayOutRespawn; +import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode; +import net.minecraft.server.v1_8_R3.WorldType; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -38,13 +50,12 @@ import org.bukkit.event.block.Action; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.event.player.PlayerLoginEvent.Result; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.scoreboard.Team; import com.mojang.authlib.GameProfile; -import com.mysql.jdbc.BalanceStrategy; public class DisguiseCommand extends CommandBase implements Listener { @@ -55,11 +66,9 @@ public class DisguiseCommand extends CommandBase implements Listener public DisguiseCommand(HubManager plugin) { - super(plugin, Rank.JNR_DEV, new Rank[] - { - Rank.YOUTUBE, Rank.TWITCH }, "disguise"); + super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, "disguise"); + plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); - new NCPDataManFix(); } @Override @@ -69,36 +78,57 @@ public class DisguiseCommand extends CommandBase implements Listener { if(!Plugin.GetDisguise().isDisguised(caller)) { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); return; } try { + GameProfile profile = _disguisedPlayers.get(caller); _disguisedPlayers.remove(caller); _disguisedPlayerDisguises.remove(caller); Plugin.GetDisguise().undisguise(caller); String playerName = _disguisedPlayersNames.get(caller); + Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller)); CoreClient client = Plugin.GetClients().Get(caller); client.setDisguisedRank(null); client.setDisguisedAs(null); client.setDisguised(false); - changeName(caller, playerName); + changeName(caller, playerName, true); + + for(Player other : UtilServer.getPlayers()) + updateTabInfo(((CraftPlayer) caller).getProfile(), profile, other, false); + Field field; + try + { + field = GameProfile.class.getDeclaredField("id"); + field.setAccessible(true); + UUID old = ((CraftPlayer) caller).getProfile().getId(); + UUID newUUID = profile.getId(); + field.set(profile, old); + field.set(((CraftPlayer) caller).getProfile(), newUUID); + } + catch(Exception e) + { + e.printStackTrace(); + } + + // removed "due to Kicked for Flying" + //PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); + //UtilPlayer.sendPacket(caller, packet); + for(Player other : UtilServer.getPlayers()) { for(Team team : other.getScoreboard().getTeams()) { - if(team.hasPlayer(caller)) - { - team.removePlayer(caller); - } + team.removePlayer(caller); } other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); } - UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); + UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!")); return; } catch(Exception ex) { @@ -107,12 +137,10 @@ public class DisguiseCommand extends CommandBase implements Listener } if(args != null && args.length > 1) { - UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); + UtilPlayer.message(caller, F.main("Disguise", "/disguise ")); return; } - final Rank rank = Plugin.GetClients().Get(caller).GetRank(); - Bukkit.getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() { @Override @@ -120,55 +148,68 @@ public class DisguiseCommand extends CommandBase implements Listener { if(Plugin.GetDisguise().isDisguised(caller)) { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); return; } for(Player other : UtilServer.getPlayers()) { if(other.getName().equalsIgnoreCase(args[0])) { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); return; } } if(_disguisedPlayersNames.containsValue(args[0])) { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); return; } if(args[0].length() > 16) { - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); return; } try { CoreClient client = Plugin.GetClients().Get(caller); - UUID uuid = UUIDFetcher.getUUIDOf(args[0]); + UUID uuid = UUID.randomUUID(); GameProfile profile = null; try { + uuid = UUIDFetcher.getUUIDOf(args[0]); profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } catch(Exception e) + } catch (Exception e) { - uuid = UUIDFetcher.getUUIDOf("Alex"); - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + uuid = UUID.randomUUID(); + profile = new ProfileLoader(null, args[0]).loadProfile(); } Rank otherRank = Rank.ALL; + CoreClient other = null; try { - CoreClient other = new CoreClient(args[0]); + other = new CoreClient(args[0]); Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); otherRank = other.GetRank(); } catch(NullPointerException exception) - {} - if(otherRank.has(Rank.TWITCH) && !rank.has(Rank.OWNER)) { - UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); + other = null; + } + if(otherRank.has(Rank.TWITCH)) + { + UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, Youtubers or Twitchers!")); return; } + if(other != null) + { + PunishClient pclient = Plugin.getPunishments().GetClient(args[0]); + if(pclient.IsBanned() || pclient.IsMuted()) + { + UtilPlayer.message(caller, F.main("Disguise", "Unable to disguise as this Player!")); + return; + } + } _disguisedPlayers.put(caller, profile); _disguisedPlayersNames.put(caller, caller.getName()); client.setDisguisedRank(otherRank); @@ -176,20 +217,100 @@ public class DisguiseCommand extends CommandBase implements Listener client.setDisguisedAs(args[0]); - changeName(caller, args[0]); + changeName(caller, args[0], true); Plugin.GetGadget().removeGadgetType(caller, GadgetType.Item); - UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); + // Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); + UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + args[0])); + + Field field; + try + { + field = GameProfile.class.getDeclaredField("id"); + field.setAccessible(true); + UUID old = ((CraftPlayer) caller).getProfile().getId(); + UUID newUUID = profile.getId(); + field.set(profile, old); + field.set(((CraftPlayer) caller).getProfile(), newUUID); + } + catch(Exception e) + { + e.printStackTrace(); + } + + // removed "due to Kicked for Flying" + //PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); + //UtilPlayer.sendPacket(caller, packet); + + tablistRefresh(caller); } catch(Exception e) { e.printStackTrace(); - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); return; } } }); } + + @EventHandler + public void refreshTabNames(UpdateEvent event) + { + if(event.getType() != UpdateType.FAST) + return; + + for(Player player : _disguisedPlayers.keySet()) + { + if(!player.isOnline()) + return; + + tablistRefresh(player); + } + } + + public void tablistRefresh(Player player) + { + for (Player other : UtilServer.getPlayers()) + { + if (player.canSee(other)) + { + updateTabInfo(_disguisedPlayers.get(player), ((CraftPlayer) player).getProfile(), other, false); + } + } + } + + public void updateTabInfo(GameProfile profileToAdd, GameProfile profileToRemove, Player target, boolean refreshOnly) + { + ChatColor team = ChatColor.WHITE; + Player player = Bukkit.getPlayer(profileToAdd.getName()); + EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + String tag = Plugin.GetClients().Get(player).GetRank().getTag(true, true) + " "; + if(Plugin.GetClients().Get(player).isDisguised()) + { + tag = Plugin.GetClients().Get(player).getDisguisedRank().getTag(true, true) + " "; + } + + IChatBaseComponent component = new ChatComponentText(tag + team + player.getName()); + + if(!refreshOnly) + { + PacketPlayOutPlayerInfo removePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); + PlayerInfoData removeData = removePacket.new PlayerInfoData(profileToRemove, entityPlayer.ping, EnumGamemode.SURVIVAL, component); + removePacket.b.add(removeData); + UtilPlayer.sendPacket(target, removePacket); + + PacketPlayOutPlayerInfo addPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER); + PlayerInfoData addData = addPacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); + addPacket.b.add(addData); + UtilPlayer.sendPacket(target, addPacket); + } + + PacketPlayOutPlayerInfo updatePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME); + PlayerInfoData updateData = updatePacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); + updatePacket.b.add(updateData); + UtilPlayer.sendPacket(target, updatePacket); + } @EventHandler public void updateDisguises(UpdateEvent event) @@ -206,15 +327,11 @@ public class DisguiseCommand extends CommandBase implements Listener { try { - for(Team team : other.getScoreboard().getTeams()) + if(other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).getPlayers().contains(player)) { - if(team.hasPlayer(player)) - { - team.removePlayer(player); - } + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).GetRank().Name).removePlayer(player); + other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); } - other.getScoreboard().getTeam(Plugin.GetClients().Get(player).getDisguisedRank().Name).addPlayer(player); - } catch(NullPointerException exp) {} } @@ -228,18 +345,17 @@ public class DisguiseCommand extends CommandBase implements Listener } } - public void changeName(Player player, String changedName) + public void changeName(final Player player, String changedName, boolean skin) { try { - Field name = GameProfile.class.getDeclaredField("name"); - Field declaredProfile = EntityHuman.class.getDeclaredField("bH"); - declaredProfile.setAccessible(true); - GameProfile gameProfile = (GameProfile) declaredProfile.get(((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); + GameProfile gameProfile = ((CraftPlayer) player).getProfile(); + Field name = GameProfile.class.getDeclaredField("name"); name.setAccessible(true); name.set(gameProfile, changedName); name.setAccessible(false); + } catch(Exception ex) { ex.printStackTrace(); @@ -266,7 +382,7 @@ public class DisguiseCommand extends CommandBase implements Listener client.setDisguisedAs(null); client.setDisguised(false); - changeName(player, playerName); + changeName(player, playerName, true); } catch(Exception ex) { ex.printStackTrace(); @@ -321,6 +437,21 @@ public class DisguiseCommand extends CommandBase implements Listener } } + @EventHandler + public void onPlayerLeftClick(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + { + if(_disguisedPlayers.containsKey(player)) + { + EntityHuman human = (((CraftHumanEntity) ((CraftPlayer) player)).getHandle()); + human.world.broadcastEntityEffect(human, (byte) 0); + } + } + } + @EventHandler(priority = EventPriority.LOWEST) public void onDPlayerChat(AsyncPlayerChatEvent event) { @@ -353,5 +484,4 @@ public class DisguiseCommand extends CommandBase implements Listener } } } - } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java new file mode 100644 index 000000000..2e1ec8432 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java @@ -0,0 +1,67 @@ +package mineplex.hub.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.hub.modules.NewYearCountdown; +import mineplex.hub.modules.newyear.NewYearMessage; + +/** + * Created by William (WilliamTiger). + * 29/12/15 + */ +public class NewYearCommand extends CommandBase +{ + public NewYearCommand(NewYearCountdown plugin) + { + super(plugin, Rank.JNR_DEV, "newyear", "nycountdown", "nyc"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (Plugin.isInProgress()) + { + caller.sendMessage(F.main("NYC", C.cRed + "A new year countdown event is already in progress!")); + return; + } + + if (args.length != 3) + { + caller.sendMessage(F.main("NYC", C.cRed + "/newyear ")); + return; + } + + if (!(validateInteger(args[0]) && validateInteger(args[1]) && validateInteger(args[2]))) + { + caller.sendMessage(F.main("NYC", C.cRed + "You have entered invalid hours/minutes/seconds.")); + return; + } + + int hours = Integer.valueOf(args[0]); + int mins = Integer.valueOf(args[1]); + int secs = Integer.valueOf(args[2]); + int total = secs + (mins * 60) + (hours * 60 * 60); + + caller.sendMessage(F.main("NYC", "Sent command to all lobbies to start with " + F.elem(total + "") + " seconds.")); + new NewYearMessage(total).publish(); + } + + private boolean validateInteger(String str) + { + boolean passed = false; + try + { + int i = Integer.valueOf(str); + passed = true; + } + catch (Exception e) + { + } + return passed; + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java index c52990ac1..107fd8aa6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java @@ -42,7 +42,7 @@ public class ForcefieldManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { - if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH)) + if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE_SMALL)) { for (Player other : UtilServer.getPlayers()) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java index 1733a2fcc..75abcbfbd 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java @@ -63,20 +63,22 @@ public class HubVisibilityManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { + Rank rank = Manager.GetClients().Get(player).GetRank(); boolean hideMe = Manager.GetTutorial().InTutorial(player) || UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 || - (Manager.getPreferences().Get(player).Invisibility && Manager.GetClients().Get(player).GetRank().has(Rank.MODERATOR)) || + (Manager.getPreferences().Get(player).Invisibility && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) || _hiddenPlayers.contains(player); for (Player other : UtilServer.getPlayers()) { + boolean localHideMe = hideMe; if (player.equals(other)) continue; if(Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR)) - hideMe = false; + localHideMe = false; - if (hideMe || + if (localHideMe || !Manager.getPreferences().Get(other).ShowPlayers || Manager.GetTutorial().InTutorial(other)) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java index fb2c0090e..e0367bdba 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java @@ -10,6 +10,7 @@ import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; @@ -42,8 +43,9 @@ public class JumpManager extends MiniPlugin if (player.getGameMode() == GameMode.CREATIVE) return; - - if (Manager.getPreferences().Get(player).Invisibility) + + Rank rank = Manager.GetClients().Get(player).GetRank(); + if (Manager.getPreferences().Get(player).Invisibility && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) { return; } @@ -82,8 +84,9 @@ public class JumpManager extends MiniPlugin { if (player.getGameMode() == GameMode.CREATIVE) continue; - - if (Manager.getPreferences().Get(player).Invisibility) + + Rank rank = Manager.GetClients().Get(player).GetRank(); + if (Manager.getPreferences().Get(player).Invisibility && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) { player.setAllowFlight(true); continue; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java new file mode 100644 index 000000000..9ebd311a6 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -0,0 +1,283 @@ +package mineplex.hub.modules; + +import java.awt.*; +import java.awt.font.FontRenderContext; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.*; +import java.util.List; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Firework; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.inventory.meta.FireworkMeta; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +import mineplex.core.MiniPlugin; +import mineplex.core.command.CommandCenter; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.commands.NewYearCommand; +import mineplex.hub.modules.newyear.NewYearHandler; +import mineplex.hub.modules.newyear.NewYearMessage; +import mineplex.serverdata.commands.ServerCommandManager; + +/** + * Created by William (WilliamTiger). + * 29/12/15 + */ +public class NewYearCountdown extends MiniPlugin +{ + private boolean _inProgress; + private Location _center; + private Location _spawn; + private int _stage; + private long _targetTime; + private BufferedImage _currentFrame; + + public NewYearCountdown(JavaPlugin plugin) + { + super("New Year Countdown", plugin); + + ServerCommandManager.getInstance().registerCommandType("NewYearMessage", + NewYearMessage.class, new NewYearHandler(this)); + + _center = new Location(UtilWorld.getWorld("world"), 0.5, 85, 37.5); + _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5); + _inProgress = false; + } + + @Override + public void addCommands() + { + CommandCenter.Instance.AddCommand(new NewYearCommand(this)); + } + + public boolean isInProgress() + { + return _inProgress; + } + + public void start(int seconds) + { + _inProgress = true; + _stage = seconds; + UtilWorld.getWorld("world").setTime(18000); + _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); + _targetTime = System.currentTimeMillis() + (seconds * 1000); + } + + @EventHandler + public void updateStage(UpdateEvent e) + { + if (e.getType() != UpdateType.TICK) + return; + + if (!_inProgress) + return; + + int stageAttempt = (int) ((_targetTime - System.currentTimeMillis()) / 1000); + + if (stageAttempt != _stage) + { + _stage = stageAttempt; + + if (_stage > 0 && _stage <= 10) + for (Player p : UtilServer.getPlayers()) + p.playSound(p.getLocation(), Sound.NOTE_BASS, 1f, 1f); + + if (_stage <= 0) + return; + + UtilTextBottom.display(C.cWhiteB + "New Year's Countdown - " + C.cGoldB + formatTimer(_stage), UtilServer.getPlayers()); + + _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 36), formatTimer(_stage)); + } + } + + @EventHandler + public void update(UpdateEvent e) + { + if (e.getType() != UpdateType.FASTER) + return; + + if (!_inProgress) + return; + + if (_stage == 0) + { + _currentFrame = stringToBufferedImage(new Font("Tahoma", Font.PLAIN, 20), "Happy New Year"); + UtilTextMiddle.display(C.cGoldB + "2016", C.cYellowB + "Happy New Year!", UtilServer.getPlayers()); + //fireworkCircle(); + } + + if (_stage <= -120) + { + //End of event. + _inProgress = false; + _currentFrame = null; + UtilWorld.getWorld("world").setTime(0); + return; + } + + if (_stage <= 0) + { + randomFirework(offsetLoc(_center)); + randomFirework(offsetLoc(_center)); + randomFirework(offsetLoc(_center)); + } + + new BukkitRunnable(){ + ArrayList line = UtilShapes.getLinesDistancedPoints(offsetLoc(_center), offsetLoc(_center), 0.2); + UtilParticle.ParticleType type = getRandomParticle(); + @Override + public void run() + { + UtilParticle.PlayParticle(type, line.get(0), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); + line.remove(0); + + if (line.isEmpty()) + this.cancel(); + } + }.runTaskTimer(getPlugin(), 0L, 1L); + + if (_currentFrame == null) + return; + + for (int y = 0; y < _currentFrame.getHeight(); y++) + for (int x = 0; x < _currentFrame.getWidth(); x++) + { + if (java.awt.Color.black.getRGB() != _currentFrame.getRGB(x, y)) + continue; + + Vector v = new Vector((float) _currentFrame.getWidth() / 2 - x, (float) _currentFrame.getHeight() / 2 - y, 0).multiply(0.5); + UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, _center.add(v), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); + _center.subtract(v); + } + } + + private BufferedImage stringToBufferedImage(Font font, String s) + { + BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR); + Graphics g = img.getGraphics(); + g.setFont(font); + + FontRenderContext frc = g.getFontMetrics().getFontRenderContext(); + Rectangle2D rect = font.getStringBounds(s, frc); + g.dispose(); + + img = new BufferedImage((int) Math.ceil(rect.getWidth()), (int) Math.ceil(rect.getHeight()), BufferedImage.TYPE_4BYTE_ABGR); + g = img.getGraphics(); + g.setColor(java.awt.Color.black); + g.setFont(font); + + FontMetrics fm = g.getFontMetrics(); + int x = 0; + int y = fm.getAscent(); + + g.drawString(s, x, y); + g.dispose(); + + return img; + } + + private String formatTimer(long seconds) + { + long minutes = seconds / 60; + long hours = minutes / 60; + + if ((hours % 60) > 0) + return zeroNumber(hours % 60) + ":" + zeroNumber(minutes % 60) + ":" + zeroNumber(seconds % 60); + + if ((minutes % 60) > 0) + return zeroNumber(minutes % 60) + ":" + zeroNumber(seconds % 60); + + return zeroNumber(seconds % 60); + } + + private String zeroNumber(long time) + { + return (time < 10 ? "0" : "") + time; + } + + private Location offsetLoc(Location loc) + { + Random random = new Random(); + return loc.clone().add((random.nextInt(100) - 50) + random.nextDouble() - 0.5, random.nextInt(20) + random.nextDouble() - 0.5, (random.nextInt(100) - 50) + random.nextDouble() - 0.5); + } + + public static void randomFirework(Location l) + { + Color c = Color.RED; + int r = new Random().nextInt(4); + if (r == 0) + { + c = Color.AQUA; + } + else if (r == 1) + { + c = Color.YELLOW; + } + else if (r == 2) + { + c = Color.RED; + } else if (r == 3) + { + c = Color.LIME; + } + FireworkEffect.Type t = FireworkEffect.Type.BALL; + int rType = new Random().nextInt(4); + if (rType == 0) + { + t = FireworkEffect.Type.BALL_LARGE; + } + else if (rType == 1) + { + t = FireworkEffect.Type.BURST; + } + else if (rType == 2) + { + t = FireworkEffect.Type.STAR; + } + else if (rType == 3) + { + t = FireworkEffect.Type.CREEPER; + } + Firework f = l.getWorld().spawn(l, Firework.class); + FireworkMeta fm = f.getFireworkMeta(); + fm.addEffect(FireworkEffect.builder().with(t).withColor(c).build()); + fm.setPower(0 + new Random().nextInt(2)); + f.setFireworkMeta(fm); + } + + private void fireworkCircle() + { + for (Location cur : UtilShapes.getPointsInCircle(_spawn, 35, 30)) + { + UtilFirework.launchFirework(cur, FireworkEffect.Type.BALL, Color.FUCHSIA, false, true, cur.toVector().setY(3).multiply(1), 2); + } + } + + public UtilParticle.ParticleType getRandomParticle() + { + List types = Arrays.asList(UtilParticle.ParticleType.FLAME, UtilParticle.ParticleType.HAPPY_VILLAGER, UtilParticle.ParticleType.RED_DUST, UtilParticle.ParticleType.FIREWORKS_SPARK); + return types.get(new Random().nextInt(types.size())); + } + +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index 424a582a1..1172751de 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -262,34 +262,33 @@ public class NewsManager extends MiniPlugin { _animationIndex = (_animationIndex + 1) % 40; - if (_animationIndex == 0) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 5" + C.cWhiteB + "0% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 1) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50" + C.cWhiteB + "% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 2) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% " + C.cWhiteB + "OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 3) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% O" + C.cWhiteB + "FF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 4) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OF" + C.cWhiteB + "F ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 5) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF " + C.cWhiteB + "ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 6) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF A" + C.cWhiteB + "LL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 7) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF AL" + C.cWhiteB + "L RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 8) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL " + C.cWhiteB + "RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 9) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL R" + C.cWhiteB + "ANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 10) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RA" + C.cWhiteB + "NKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 11) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RAN" + C.cWhiteB + "KS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 12) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANK" + C.cWhiteB + "S " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 13) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 2) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " U" + C.cWhiteB + "P TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 3) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP" + C.cWhiteB + " TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 4) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP " + C.cWhiteB + "TO 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 5) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP T" + C.cWhiteB + "O 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 6) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO" + C.cWhiteB + " 50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 7) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO " + C.cWhiteB + "50% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 8) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 5" + C.cWhiteB + "0% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 9) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50" + C.cWhiteB + "% OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 10) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50%" + C.cWhiteB + " OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 11) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% " + C.cWhiteB + "OFF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 11) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% O" + C.cWhiteB + "FF " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 12) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OF" + C.cWhiteB + "F " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 13) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 14) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 15) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 16) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 17) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 18) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 19) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 20) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 21) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 22) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 23) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 24) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 25) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " 50% OFF ALL RANKS" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - if (_animationIndex == 26) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " 50% OFF ALL RANKS" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 14) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 15) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 16) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 17) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 18) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 19) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 20) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 21) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 22) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 23) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 24) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 25) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cWhiteB + " UP TO 50% OFF" + C.cGreenB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; + if (_animationIndex == 26) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " UP TO 50% OFF" + C.cWhiteB + " " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; if (_animationIndex >= 27) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " " + C.cWhiteB + "50% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java index 0fa87552c..9c52e18a3 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java @@ -7,6 +7,8 @@ import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCrafting; +import org.bukkit.entity.Bat; import org.bukkit.entity.EnderDragon; import org.bukkit.entity.Entity; import org.bukkit.entity.Horse; @@ -16,6 +18,8 @@ import org.bukkit.entity.Wither; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; @@ -28,8 +32,10 @@ import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilPlayer; import mineplex.core.event.StackerEvent; +import mineplex.core.gadget.gadgets.item.ItemBatGun; import mineplex.core.gadget.gadgets.morph.MorphBlock; import mineplex.core.gadget.types.GadgetType; +import mineplex.core.pet.PetManager; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileManager; import mineplex.core.projectile.ProjectileUser; @@ -94,7 +100,9 @@ public class StackerManager extends MiniPlugin implements IThrown //Parkour Disable if (Manager.GetParkour().InsideParkour(stacker.getLocation())) { - UtilPlayer.message(stacker, F.main("Parkour", "You cannot Stack/Throw near Parkour Challenges.")); + if (!stackee.isCustomNameVisible()) + UtilPlayer.message(stacker, F.main("Parkour", "You cannot Stack/Throw near Parkour Challenges.")); + return; } @@ -120,30 +128,68 @@ public class StackerManager extends MiniPlugin implements IThrown if (stackee instanceof Player) { + Player stackeePlayer = (Player) stackee; + if (!Manager.hasPlayerStackingEnabled(stacker)) { UtilPlayer.message(stacker, F.main("Stacker", "You have player stacking disabled.")); return; } - if (!Manager.hasPlayerStackingEnabled(((Player)stackee))) + if (!Manager.hasPlayerStackingEnabled((stackeePlayer))) { UtilPlayer.message(stacker, F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " has player stacking disabled.")); return; } - if (Manager.GetTreasure().isOpening((Player) stackee)) + if (Manager.GetTreasure().isOpening(stackeePlayer)) { UtilPlayer.message(stacker, F.main("Stacker", F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " is opening a chest!"))); return; } - } + + Inventory top = stackeePlayer.getOpenInventory().getTopInventory(); + + if (!(top instanceof CraftInventoryCrafting) && hasItems(top)) + { + String message = F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " cannot be stacked right now."); + + if (top.getHolder() != null) + { + if (top.getHolder().equals(stackeePlayer)) + { + UtilPlayer.message(stacker, message); + return; + } + } + + UtilPlayer.message(stacker, message); + return; + } + } if (stackee instanceof LivingEntity) { - if (Manager.getPetManager().getPets().contains(stackee) || stackee instanceof Wither || stackee instanceof EnderDragon || ((LivingEntity)stackee).isCustomNameVisible()) + ItemBatGun batGun = (ItemBatGun) Manager.GetGadget().getGadget(ItemBatGun.class); + + if (stackee instanceof Bat) { - UtilPlayer.message(stacker, F.main("Stacker", "You cannot stack this entity.")); + Bat bat = (Bat) stackee; + + if (batGun.isThrownBat(bat)) + return; + } + + PetManager petManager = Manager.getPetManager(); + LivingEntity livingStackee = (LivingEntity) stackee; + boolean cannotStack = petManager.getPets().contains(stackee) || stackee instanceof Wither || stackee instanceof EnderDragon; + + if (cannotStack || livingStackee.isCustomNameVisible()) + { + // Prevent from showing this message when players right-click on game npc's. + if (cannotStack) + UtilPlayer.message(stacker, F.main("Stacker", "You cannot stack this entity.")); + return; } } @@ -163,8 +209,8 @@ public class StackerManager extends MiniPlugin implements IThrown top.setPassenger(stackee); - UtilPlayer.message(stacker, F.main("Stacker", "You stacked " + F.name(UtilEnt.getName(stackee) + "."))); - UtilPlayer.message(stackee, F.main("Stacker", "You were stacked by " + F.name(stacker.getName() + "."))); + UtilPlayer.message(stacker, F.main("Stacker", "You stacked " + F.name(UtilEnt.getName(stackee)) + ".")); + UtilPlayer.message(stackee, F.main("Stacker", "You were stacked by " + F.name(stacker.getName()) + ".")); UtilPlayer.message(stackee, F.main("Stacker", "Push " + F.skill("Crouch") + " to escape!")); //Portal Delay @@ -224,8 +270,8 @@ public class StackerManager extends MiniPlugin implements IThrown return; } - UtilPlayer.message(thrower, F.main("Stacker", "You threw " + F.name(UtilEnt.getName(throwee)))); - UtilPlayer.message(throwee, F.main("Stacker", "You were thrown by " + F.name(thrower.getName()))); + UtilPlayer.message(thrower, F.main("Stacker", "You threw " + F.name(UtilEnt.getName(throwee)) + ".")); + UtilPlayer.message(throwee, F.main("Stacker", "You were thrown by " + F.name(thrower.getName()) + ".")); System.out.println("Stacker throw."); @@ -274,6 +320,17 @@ public class StackerManager extends MiniPlugin implements IThrown //Portal Delay Manager.SetPortalDelay(target); } + + private boolean hasItems(Inventory inventory) + { + for (ItemStack item : inventory.getContents()) + { + if (item != null) + return true; + } + + return false; + } @Override public void Idle(ProjectileUser data) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearHandler.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearHandler.java new file mode 100644 index 000000000..7f2f3cf80 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearHandler.java @@ -0,0 +1,28 @@ +package mineplex.hub.modules.newyear; + +import mineplex.hub.modules.NewYearCountdown; +import mineplex.serverdata.commands.CommandCallback; +import mineplex.serverdata.commands.ServerCommand; + +/** + * Created by William (WilliamTiger). + * 31/12/15 + */ +public class NewYearHandler implements CommandCallback +{ + private NewYearCountdown _newYear; + + public NewYearHandler(NewYearCountdown newYear) + { + _newYear = newYear; + } + + @Override + public void run(ServerCommand command) + { + if (command instanceof NewYearMessage) + { + _newYear.start(((NewYearMessage)command).getSeconds()); + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearMessage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearMessage.java new file mode 100644 index 000000000..aaf21447f --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/newyear/NewYearMessage.java @@ -0,0 +1,29 @@ +package mineplex.hub.modules.newyear; + +import mineplex.serverdata.commands.ServerCommand; + +/** + * Created by William (WilliamTiger). + * 31/12/15 + */ +public class NewYearMessage extends ServerCommand +{ + + private int seconds; + + public NewYearMessage(int seconds) + { + this.seconds = seconds; + } + + public int getSeconds() + { + return seconds; + } + + @Override + public void run() + { + + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 0b54138c0..0782488fc 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -86,7 +86,7 @@ public class ServerManager extends MiniPlugin private NautHashMap _serverNpcShopMap = new NautHashMap(); private NautHashMap _serverInfoMap = new NautHashMap(); private NautHashMap _serverUpdate = new NautHashMap(); - private NautHashMap _serverPortalLocations = new NautHashMap(); + private NautHashMap _portalToServerKey = new NautHashMap(); private ClansServerShop _clansShop; @@ -185,15 +185,16 @@ public class ServerManager extends MiniPlugin return; } - String serverName = _serverPortalLocations.get(player.getLocation().getBlock().getLocation().toVector()); + String serverKey = _portalToServerKey.get(player.getLocation().getBlock().getLocation().toVector()); - if (serverName != null) + if (serverKey != null) { List serverList = new ArrayList(); - - if (hasServerNpc(serverName)) - serverList.addAll(getServerList(serverName)); - + + Collection servers = getServerList(serverKey); + if (servers != null && servers.size() > 0) + serverList.addAll(servers); + int slots = 1; if (serverList.size() > 0) @@ -294,17 +295,7 @@ public class ServerManager extends MiniPlugin return timeLeft; } - - public void removeServer(String serverName) - { - for (String key : _serverKeyInfoMap.keySet()) - { - _serverKeyInfoMap.get(key).remove(serverName); - } - - _serverInfoMap.remove(serverName); - } - + public void addServerGroup(ServerGroup serverGroup) { _serverKeyInfoMap.put(serverGroup.getPrefix(), new HashSet()); @@ -347,9 +338,9 @@ public class ServerManager extends MiniPlugin } } - public Collection getServerList(String serverNpcName) + public Collection getServerList(String serverKey) { - return _serverKeyInfoMap.get(serverNpcName); + return _serverKeyInfoMap.get(serverKey); } public Set getAllServers() @@ -362,11 +353,6 @@ public class ServerManager extends MiniPlugin return _serverInfoMap.get(serverName); } - public boolean hasServerNpc(String serverNpcName) - { - return _serverKeyInfoMap.containsKey(serverNpcName); - } - @EventHandler public void updatePages(UpdateEvent event) { @@ -711,7 +697,7 @@ public class ServerManager extends MiniPlugin while (blocks < 10 && (bottomVector.getBlockX() != topVector.getBlockX() || bottomVector.getBlockZ() != topVector.getBlockZ())) { - _serverPortalLocations.put(new Vector(bottomVector.getBlockX(), bottomVector.getBlockY(), bottomVector.getBlockZ()), serverGroup.getServerNpcName()); + _portalToServerKey.put(new Vector(bottomVector.getBlockX(), bottomVector.getBlockY(), bottomVector.getBlockZ()), serverGroup.getPrefix()); if (bottomVector.getBlockX() != topVector.getBlockX()) { @@ -725,7 +711,7 @@ public class ServerManager extends MiniPlugin blocks++; } - _serverPortalLocations.put(bottomVector, serverGroup.getServerNpcName()); + _portalToServerKey.put(bottomVector, serverGroup.getPrefix()); } } } @@ -822,6 +808,11 @@ public class ServerManager extends MiniPlugin return _serverNpcShopMap.get("Survival Games"); } + public ServerNpcShop getSpeedBuildersShop() + { + return _serverNpcShopMap.get("Speed Builders"); + } + public ServerNpcShop getBlockHuntShop() { return _serverNpcShopMap.get("Block Hunt"); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 3a062a401..0df7aac78 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -15,26 +15,7 @@ import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.shop.page.ShopPageBase; import mineplex.hub.server.ServerManager; -import mineplex.hub.server.ui.button.SelectBETAButton; -import mineplex.hub.server.ui.button.SelectBHButton; -import mineplex.hub.server.ui.button.SelectBLDButton; -import mineplex.hub.server.ui.button.SelectBRButton; -import mineplex.hub.server.ui.button.SelectCLANSButton; -import mineplex.hub.server.ui.button.SelectCSButton; -import mineplex.hub.server.ui.button.SelectCTFButton; -import mineplex.hub.server.ui.button.SelectDMTButton; -import mineplex.hub.server.ui.button.SelectDOMButton; -import mineplex.hub.server.ui.button.SelectFEATButton; -import mineplex.hub.server.ui.button.SelectMINButton; -import mineplex.hub.server.ui.button.SelectMSButton; -import mineplex.hub.server.ui.button.SelectPLAYERButton; -import mineplex.hub.server.ui.button.SelectSGButton; -import mineplex.hub.server.ui.button.SelectSKYButton; -import mineplex.hub.server.ui.button.SelectSSMButton; -import mineplex.hub.server.ui.button.SelectTDMButton; -import mineplex.hub.server.ui.button.SelectTWButton; -import mineplex.hub.server.ui.button.SelectUHCButton; -import mineplex.hub.server.ui.button.SelectWIZButton; +import mineplex.hub.server.ui.button.*; public class ServerGameMenu extends ShopPageBase { @@ -59,7 +40,7 @@ public class ServerGameMenu extends ShopPageBase @Override protected void buildPage() { - addButton(3, new ItemBuilder(Material.NAME_TAG).setTitle(C.cYellowB + "Type Wars " + C.cGray + "Team Deathmatch").addLore(new String[] + addButton(2, new ItemBuilder(Material.NAME_TAG).setTitle(C.cYellowB + "Type Wars " + C.cGray + "Team Deathmatch").addLore(new String[] { (_extraValue ? C.cAquaB : C.cWhiteB) + "NEW GAME", C.Reset + "", @@ -71,7 +52,19 @@ public class ServerGameMenu extends ShopPageBase C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("TW") + C.Reset + " other players!", }).setHideInfo(true).build(), new SelectTWButton(this)); - addButton(5, new ItemBuilder(Material.IRON_SWORD).setTitle(C.cYellowB + "Gladiators" + C.cGray + " Bracketted Deathmatch").addLore(new String[] + addButton(4, new ItemBuilder(Material.QUARTZ_BLOCK).setTitle(C.cYellowB + "Speed Builders " + C.cGray + "Competitive Building").addLore(new String[] + { + (_extraValue ? C.cAquaB : C.cWhiteB) + "NEW GAME", + C.Reset + "", + C.Reset + "Memorize Gwen the Guardian's builds", + C.Reset + "Then recreate them in a short amount of time.", + C.Reset + "The least correct builder is eliminated.", + C.Reset + "", + C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("SB") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectSBButton(this)); + + /* + addButton(6, new ItemBuilder(Material.IRON_SWORD).setTitle(C.cYellowB + "Gladiators" + C.cGray + " Bracketted Deathmatch").addLore(new String[] { (_extraValue ? C.cAquaB : C.cWhiteB) + "FEATURED ARCADE GAME", C.Reset + "", @@ -81,6 +74,18 @@ public class ServerGameMenu extends ShopPageBase C.Reset + "", C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("GLD") + C.Reset + " other players!" }).setHideInfo(true).build(), new SelectFEATButton(this, "Gladiators")); + */ + + addButton(6, new ItemBuilder(Material.LAVA_BUCKET).setTitle(C.cYellowB + "Micro Battle" + C.cGray + " 4 Team Deathmatch").addLore(new String[] + { + (_extraValue ? C.cAquaB : C.cWhiteB) + "FEATURED ARCADE GAME", + C.Reset + "", + C.Reset + "4 teams stand alone", + C.Reset + "Who shall remain victorious", + C.Reset + "You decide", + C.Reset + "", + C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("MB") + C.Reset + " other players!" + }).setHideInfo(true).build(), new SelectFEATButton(this, "Micro Battle")); addButton(9, new ItemBuilder(Material.IRON_PICKAXE).setTitle(C.cYellowB + "The Bridges " + C.cGray + "4 Team Survival").addLore(new String[] { @@ -219,6 +224,7 @@ public class ServerGameMenu extends ShopPageBase C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BLD") + C.Reset + " other players!", }).setHideInfo(true).build(), new SelectBLDButton(this)); + /* addButton(37, new ItemBuilder(Material.SNOW_BALL).setTitle(C.cYellowB + "Snow Fight " + C.cGray + "Team Survival").addLore(new String[] { (_extraValue ? C.cAquaB : C.cWhiteB) + "LIMITED TIME", @@ -229,6 +235,7 @@ public class ServerGameMenu extends ShopPageBase C.Reset + "", C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("SF") + C.Reset + " other players!", }).setHideInfo(true).build(), new SelectFEATButton(this, "Snow Fight")); + */ addButton(39, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.cYellowB + "Player Servers " + C.cGray + "Player Hosted Games").addLore(new String[] { @@ -260,6 +267,7 @@ public class ServerGameMenu extends ShopPageBase C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BETA") + C.Reset + " other players!", }).setHideInfo(true).build(), new SelectBETAButton(this)); + /* addButton(43, new ItemBuilder(Material.BOOKSHELF).setTitle(C.cYellowB + "Christmas Chaos " + C.cGray + "Help Save Christmas").addLore(new String[] { (_extraValue ? C.cAquaB : C.cWhiteB) + "LIMITED TIME", @@ -270,6 +278,7 @@ public class ServerGameMenu extends ShopPageBase C.Reset + "", C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("CC") + C.Reset + " other players!", }).setHideInfo(true).build(), new SelectFEATButton(this, "Christmas Chaos")); + */ } private void createMinigameCycle() @@ -608,6 +617,11 @@ public class ServerGameMenu extends ShopPageBase getPlugin().getSurvivalGamesShop().attemptShopOpen(player); } + public void OpenSB(Player player) + { + getPlugin().getSpeedBuildersShop().attemptShopOpen(player); + } + public void openDMT(Player player) { getPlugin().getDrawMyThingShop().attemptShopOpen(player); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectSBButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectSBButton.java new file mode 100644 index 000000000..9de9fee19 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectSBButton.java @@ -0,0 +1,23 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectSBButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectSBButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.OpenSB(player); + } +} diff --git a/Plugins/Mineplex.MapParser/.classpath b/Plugins/Mineplex.MapParser/.classpath deleted file mode 100644 index 972ce62be..000000000 --- a/Plugins/Mineplex.MapParser/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/Plugins/Mineplex.MapParser/.externalToolBuilders/MapParser Builder.launch b/Plugins/Mineplex.MapParser/.externalToolBuilders/MapParser Builder.launch deleted file mode 100644 index 2c1f162ea..000000000 --- a/Plugins/Mineplex.MapParser/.externalToolBuilders/MapParser Builder.launch +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.MapParser/.project b/Plugins/Mineplex.MapParser/.project deleted file mode 100644 index 03de90b0d..000000000 --- a/Plugins/Mineplex.MapParser/.project +++ /dev/null @@ -1,26 +0,0 @@ - - - Mineplex.MapParser - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - - - LaunchConfigHandle - <project>/.externalToolBuilders/MapParser Builder.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.MapParser/Mineplex.MapParser.iml b/Plugins/Mineplex.MapParser/Mineplex.MapParser.iml deleted file mode 100644 index 86ec89ce9..000000000 --- a/Plugins/Mineplex.MapParser/Mineplex.MapParser.iml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/Mineplex.MapParser/pom.xml b/Plugins/Mineplex.MapParser/pom.xml new file mode 100644 index 000000000..65a7236aa --- /dev/null +++ b/Plugins/Mineplex.MapParser/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + + com.mineplex + mineplex-plugin + dev-SNAPSHOT + ../plugin.xml + + + MapParser + mineplex-mapparser + + + + ${project.groupId} + mineplex-core-common + ${project.version} + + + diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/Parse.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/Parse.java index a4702cc64..79d74e141 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/Parse.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/Parse.java @@ -128,8 +128,19 @@ public class Parse String name = ""; try - { + { name = s.getLine(0); + + if (s.getLine(1) != null && s.getLine(1).length() > 0) + name += " " + s.getLine(1); + + if (s.getLine(2) != null && s.getLine(2).length() > 0) + name += " " + s.getLine(2); + + if (s.getLine(3) != null && s.getLine(3).length() > 0) + name += " " + s.getLine(3); + + System.out.println("Custom Location: " + name); } catch (Exception e) { diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath b/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath deleted file mode 100644 index f7ec39e88..000000000 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/.externalToolBuilders/ClassCombat.launch b/Plugins/Mineplex.Minecraft.Game.ClassCombat/.externalToolBuilders/ClassCombat.launch deleted file mode 100644 index 79a45c65c..000000000 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/.externalToolBuilders/ClassCombat.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/.project b/Plugins/Mineplex.Minecraft.Game.ClassCombat/.project deleted file mode 100644 index 21323ed3c..000000000 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - Mineplex.Minecraft.Game.ClassCombat - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/ClassCombat.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/.settings/org.eclipse.core.resources.prefs b/Plugins/Mineplex.Minecraft.Game.ClassCombat/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml b/Plugins/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml deleted file mode 100644 index b3324f1c3..000000000 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/pom.xml b/Plugins/Mineplex.Minecraft.Game.ClassCombat/pom.xml new file mode 100644 index 000000000..01c80f78b --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + + com.mineplex + mineplex-parent + dev-SNAPSHOT + + + mineplex-minecraft-game-classcombat + + + + ${project.groupId} + mineplex-minecraft-game-core + ${project.version} + + + diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index 74e19ca6d..bddac25dd 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -369,7 +369,7 @@ public class ClientClass UtilPlayer.message(caller, F.main("Skill", "Listing Class Skills:")); for (SkillType type : SkillType.values()) - if (caller.isOp() || type != SkillType.Class) + if ((caller != null && caller.isOp()) || type != SkillType.Class) if (_skillMap.containsKey(type)) UtilPlayer.message(caller, F.desc(type.toString(), _skillMap.get(type).GetName() + " Lvl" + _skillMap.get(type).getLevel(caller))); } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java index 3ce6e3a7a..494900104 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java @@ -15,6 +15,7 @@ import org.bukkit.event.block.Action; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; +import mineplex.core.common.util.UtilItem; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.core.common.util.F; import mineplex.core.updater.event.UpdateEvent; @@ -156,6 +157,10 @@ public class Flash extends SkillActive if(aboveTargetData <= 7) aboveTargetSlabIsBottom = true; } + + // Doors + if (UtilItem.is(newTarget.getBlock(), UtilItem.ItemCategory.DOOR)) + break; if ((!newTargetSlabIsBottom && UtilBlock.fullSolid(newTarget.getBlock())) || (!aboveTargetSlabIsBottom && UtilBlock.fullSolid(aboveTarget.getBlock()))) break; diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java index 7aa2a2253..cd7af9243 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java @@ -1,33 +1,33 @@ package mineplex.minecraft.game.classcombat.Skill.Assassin; -import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.minecraft.game.classcombat.Skill.Skill; -import mineplex.minecraft.game.classcombat.Skill.SkillFactory; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.player.PlayerDropItemEvent; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; +import mineplex.minecraft.game.classcombat.Skill.Skill; +import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; + public class Recall extends Skill { private HashMap> _locMap = new HashMap>(); @@ -111,7 +111,19 @@ public class Recall extends Skill current = current.add(UtilAlg.getTrajectory(current, target).multiply(0.1)); } } - + + @EventHandler + public void closeInv(InventoryCloseEvent event) + { + if (getLevel(event.getPlayer()) == 0) + { + return; + } + + event.getPlayer().getInventory().addItem(event.getPlayer().getItemOnCursor()); + event.getPlayer().setItemOnCursor(null); + } + @EventHandler public void storeLocation(UpdateEvent event) { diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java index e7fcc5bd5..cde190a34 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java @@ -37,6 +37,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.classcombat.Skill.SkillCharge; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent; import mineplex.minecraft.game.classcombat.Skill.event.BlockTossExpireEvent; import mineplex.minecraft.game.classcombat.Skill.event.BlockTossLandEvent; import mineplex.minecraft.game.classcombat.Skill.event.SkillEvent; @@ -61,7 +62,14 @@ public class BlockToss extends SkillCharge implements IThrown Material.BURNING_FURNACE, Material.WORKBENCH, Material.WATER, - Material.LAVA + Material.LAVA, + Material.STONE_PLATE, + Material.WOOD_PLATE, + Material.GOLD_PLATE, + Material.IRON_PLATE, + Material.STONE_BUTTON, + Material.WOOD_BUTTON, + Material.LEVER, }; public BlockToss(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) @@ -126,8 +134,10 @@ public class BlockToss extends SkillCharge implements IThrown //Blacklist for (Material mat : _blacklist) if (mat == grab.getType()) + { + UtilPlayer.message(player, F.main("Game", "You cannot grab this block.")); return; - + } //Usable if (UtilBlock.usable(grab)) return; @@ -239,13 +249,15 @@ public class BlockToss extends SkillCharge implements IThrown //Throw cur.eject(); double mult = Math.max(0.4, charge * 2); - + + Material mat = Material.getMaterial(block.getBlockId()); + //Action UtilAction.velocity(block, cur.getLocation().getDirection(), mult, false, 0, 0, 1, true); Factory.Projectile().AddThrow(block, cur, this, -1, true, true, true, true, null, 0, 0, null, 0, UpdateType.FASTEST, 1.2f); - //Event + // Generic Event UtilServer.getServer().getPluginManager().callEvent(new SkillEvent(cur, GetName(), ClassType.Brute)); } } @@ -369,7 +381,7 @@ public class BlockToss extends SkillCharge implements IThrown { if (!event.getBlock().getType().isSolid()) // Falling block is landing and turning block from air to type { - BlockTossLandEvent landEvent = new BlockTossLandEvent(event.getBlock()); + BlockTossLandEvent landEvent = new BlockTossLandEvent(event.getBlock(), ((FallingBlock) event.getEntity())); Bukkit.getServer().getPluginManager().callEvent(landEvent); if (landEvent.isCancelled()) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FireBlast.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FireBlast.java index 46ec2eaba..f205452ae 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FireBlast.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FireBlast.java @@ -21,8 +21,10 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.event.FireballHitEntityEvent; public class FireBlast extends SkillActive { @@ -93,7 +95,7 @@ public class FireBlast extends SkillActive if (!(proj.getShooter() instanceof Player)) return; - + Player player = (Player)proj.getShooter(); //Level @@ -105,7 +107,16 @@ public class FireBlast extends SkillActive for (LivingEntity cur : hitMap.keySet()) { double range = hitMap.get(cur); - + + FireballHitEntityEvent evt = new FireballHitEntityEvent(proj, cur); + + UtilServer.getServer().getPluginManager().callEvent(evt); + + if (evt.isCancelled()) + { + continue; + } + //Damage Event Factory.Condition().Factory().Ignite(GetName(), cur, player, (2 + (1 * level)) * range, false, false); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/event/BlockTossLandEvent.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/event/BlockTossLandEvent.java index 4cc50dd18..908e13720 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/event/BlockTossLandEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/event/BlockTossLandEvent.java @@ -9,9 +9,11 @@ import org.bukkit.event.HandlerList; public class BlockTossLandEvent extends BlockTossEvent { - - public BlockTossLandEvent(Block block) + public FallingBlock Entity; + + public BlockTossLandEvent(Block block, FallingBlock fallingBlock) { super(block); + Entity = fallingBlock; } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/FireballHitEntityEvent.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/FireballHitEntityEvent.java new file mode 100644 index 000000000..43c9b1555 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/event/FireballHitEntityEvent.java @@ -0,0 +1,52 @@ +package mineplex.minecraft.game.classcombat.event; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class FireballHitEntityEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Projectile _projectile; + private LivingEntity _hitEntity; + + private boolean _cancelled; + + public FireballHitEntityEvent(Projectile proj, LivingEntity entity) + { + _projectile = proj; + _hitEntity = entity; + } + + public Projectile getProjectile() + { + return _projectile; + } + + public LivingEntity getHitEntity() + { + return _hitEntity; + } + + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + public boolean isCancelled() + { + return _cancelled; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.Core/.classpath b/Plugins/Mineplex.Minecraft.Game.Core/.classpath deleted file mode 100644 index 0c60eb1ca..000000000 --- a/Plugins/Mineplex.Minecraft.Game.Core/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/Plugins/Mineplex.Minecraft.Game.Core/.project b/Plugins/Mineplex.Minecraft.Game.Core/.project deleted file mode 100644 index 0e7e5acdb..000000000 --- a/Plugins/Mineplex.Minecraft.Game.Core/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - Mineplex.Minecraft.Game.Core - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.Minecraft.Game.Core/.settings/org.eclipse.core.resources.prefs b/Plugins/Mineplex.Minecraft.Game.Core/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/Plugins/Mineplex.Minecraft.Game.Core/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/Plugins/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml b/Plugins/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml deleted file mode 100644 index 6882d9ec9..000000000 --- a/Plugins/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Minecraft.Game.Core/pom.xml b/Plugins/Mineplex.Minecraft.Game.Core/pom.xml new file mode 100644 index 000000000..e8440a3f0 --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.Core/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + + com.mineplex + mineplex-parent + dev-SNAPSHOT + + + mineplex-minecraft-game-core + + + + ${project.groupId} + mineplex-core + ${project.version} + + + diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java index 0ec29781a..3781f2a5b 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java @@ -332,8 +332,7 @@ public abstract class WorldEvent implements Listener, ScoreboardElement } }); - task.setBlocksPerTick(_isArcade ? 2000000 : 1000); // TODO: CHANGE THIS - // BACK + task.setBlocksPerTick(_isArcade ? 2000000 : 1000); task.start(); } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/conditions/Burning.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/conditions/Burning.java index ed772a92a..73c868066 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/conditions/Burning.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/conditions/Burning.java @@ -20,7 +20,6 @@ public class Burning extends Condition @Override public void Add() { - } @Override @@ -32,9 +31,9 @@ public class Burning extends Condition @Override public void OnConditionAdd() { - if (_ent.getFireTicks() > 0) + if (_ent.getFireTicks() > 0 && IsAdd()) _ent.setFireTicks(_ent.getFireTicks() + _ticksTotal); - else + else if (_ent.getFireTicks() < _ticksTotal) _ent.setFireTicks(_ticksTotal); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java index 8d3d35d16..d5c6f0bf4 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java @@ -37,10 +37,10 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityCombustByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; @@ -122,6 +122,15 @@ public class DamageManager extends MiniPlugin event.setCancelled(true); } + @EventHandler + public void onEntityCombust(EntityCombustByEntityEvent event) + { + if (!(event.getCombuster() instanceof Player || event.getCombuster() instanceof Arrow)) + return; + + event.setCancelled(true); + } + @EventHandler(priority = EventPriority.HIGHEST) public void removeDemArrowsCrazyMan(EntityDamageEvent event) { @@ -307,12 +316,18 @@ public class DamageManager extends MiniPlugin else if (e.equals(Enchantment.ARROW_DAMAGE) || e.equals(Enchantment.DAMAGE_ALL)) event.AddMod("Enchant", "Ench Damage", 0.5 * (double)enchants.get(e), true); - else if (e.equals(Enchantment.ARROW_FIRE) || e.equals(Enchantment.FIRE_ASPECT)) + else if (e.equals(Enchantment.FIRE_ASPECT)) if (_conditionManager != null) _conditionManager.Factory().Ignite("Ench Fire", event.GetDamageeEntity(), damager, - 1 * (double)enchants.get(e), false, false); + 4 * (double)enchants.get(e), false, false); } } + + if (event.GetProjectile() instanceof Arrow && event.GetProjectile().getFireTicks() > 0) + { + if (_conditionManager != null) + _conditionManager.Factory().Ignite("Arrow Fire", event.GetDamageeEntity(), damager, 5, false, false); + } } @EventHandler(priority = EventPriority.MONITOR) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/explosion/CustomExplosion.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/explosion/CustomExplosion.java index d5c86a91f..fed9d16ff 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/explosion/CustomExplosion.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/explosion/CustomExplosion.java @@ -356,12 +356,10 @@ public class CustomExplosion extends Explosion if (_fallingBlockExplosion) { - Collection blocks = event.GetBlocks(); + List blocks = new ArrayList<>(event.GetBlocks()); if (blocks.size() > _maxFallingBlocks) { - blocks = new ArrayList(blocks); - Collections.shuffle((ArrayList) blocks); int toRemove = blocks.size() - _maxFallingBlocks; diff --git a/Plugins/Mineplex.Queue.Core/.project b/Plugins/Mineplex.Queue.Core/.project deleted file mode 100644 index 669fb734b..000000000 --- a/Plugins/Mineplex.Queue.Core/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - Mineplex.Queue.Core - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.Queuer/.classpath b/Plugins/Mineplex.Queuer/.classpath deleted file mode 100644 index 945e9a997..000000000 --- a/Plugins/Mineplex.Queuer/.classpath +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Queuer/.externalToolBuilders/New_Builder.launch b/Plugins/Mineplex.Queuer/.externalToolBuilders/New_Builder.launch deleted file mode 100644 index 0c6e0f696..000000000 --- a/Plugins/Mineplex.Queuer/.externalToolBuilders/New_Builder.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Queuer/.externalToolBuilders/Queuer.launch b/Plugins/Mineplex.Queuer/.externalToolBuilders/Queuer.launch deleted file mode 100644 index 7fe0fe5da..000000000 --- a/Plugins/Mineplex.Queuer/.externalToolBuilders/Queuer.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Queuer/.gitignore b/Plugins/Mineplex.Queuer/.gitignore deleted file mode 100644 index 167fb2c02..000000000 --- a/Plugins/Mineplex.Queuer/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin -/bin diff --git a/Plugins/Mineplex.Queuer/.project b/Plugins/Mineplex.Queuer/.project deleted file mode 100644 index e799bd1fc..000000000 --- a/Plugins/Mineplex.Queuer/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - Mineplex.Queuer - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/Queuer.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.Queuer/.settings/org.eclipse.jdt.core.prefs b/Plugins/Mineplex.Queuer/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7341ab168..000000000 --- a/Plugins/Mineplex.Queuer/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/Plugins/Mineplex.Queuer/Mineplex.Queuer.iml b/Plugins/Mineplex.Queuer/Mineplex.Queuer.iml deleted file mode 100644 index c68cf7cf9..000000000 --- a/Plugins/Mineplex.Queuer/Mineplex.Queuer.iml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.ServerData/.classpath b/Plugins/Mineplex.ServerData/.classpath deleted file mode 100644 index b90da709c..000000000 --- a/Plugins/Mineplex.ServerData/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/Plugins/Mineplex.ServerData/.externalToolBuilders/New_Builder.launch b/Plugins/Mineplex.ServerData/.externalToolBuilders/New_Builder.launch deleted file mode 100644 index 0c6e0f696..000000000 --- a/Plugins/Mineplex.ServerData/.externalToolBuilders/New_Builder.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.ServerData/.externalToolBuilders/ServerData.launch b/Plugins/Mineplex.ServerData/.externalToolBuilders/ServerData.launch deleted file mode 100644 index b9ea00f1f..000000000 --- a/Plugins/Mineplex.ServerData/.externalToolBuilders/ServerData.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.ServerData/.project b/Plugins/Mineplex.ServerData/.project deleted file mode 100644 index 87c600cb6..000000000 --- a/Plugins/Mineplex.ServerData/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - Mineplex.ServerData - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/ServerData.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.ServerData/Mineplex.ServerData.iml b/Plugins/Mineplex.ServerData/Mineplex.ServerData.iml deleted file mode 100644 index d65267f31..000000000 --- a/Plugins/Mineplex.ServerData/Mineplex.ServerData.iml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.ServerData/build.xml b/Plugins/Mineplex.ServerData/build.xml deleted file mode 100644 index 411a60854..000000000 --- a/Plugins/Mineplex.ServerData/build.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.ServerData/pom.xml b/Plugins/Mineplex.ServerData/pom.xml new file mode 100644 index 000000000..b7e313ba5 --- /dev/null +++ b/Plugins/Mineplex.ServerData/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + + com.mineplex + mineplex-parent + dev-SNAPSHOT + + + mineplex-serverdata + + + + com.google.code.gson + gson + + + redis.clients + jedis + + + diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java index 5258c948e..f80fe0b7c 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java @@ -113,7 +113,7 @@ public class Utility JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); jedisPoolConfig.setMaxWaitMillis(1000); jedisPoolConfig.setMinIdle(5); - jedisPoolConfig.setTestOnBorrow(true); +// jedisPoolConfig.setTestOnBorrow(true); jedisPoolConfig.setMaxTotal(20); jedisPoolConfig.setBlockWhenExhausted(true); diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisDataRepository.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisDataRepository.java index a49de5b64..caea6188b 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisDataRepository.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisDataRepository.java @@ -55,6 +55,7 @@ public class RedisDataRepository implements DataRepository _region = region; _elementType = elementType; _elementLabel = elementLabel; + } public RedisDataRepository(ConnectionData conn, Region region, Class elementType, String elementLabel) diff --git a/Plugins/Mineplex.ServerMonitor/.classpath b/Plugins/Mineplex.ServerMonitor/.classpath deleted file mode 100644 index 49e473eb4..000000000 --- a/Plugins/Mineplex.ServerMonitor/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/Plugins/Mineplex.ServerMonitor/.externalToolBuilders/New_Builder.launch b/Plugins/Mineplex.ServerMonitor/.externalToolBuilders/New_Builder.launch deleted file mode 100644 index 0c6e0f696..000000000 --- a/Plugins/Mineplex.ServerMonitor/.externalToolBuilders/New_Builder.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.ServerMonitor/.externalToolBuilders/ServerMonitor.launch b/Plugins/Mineplex.ServerMonitor/.externalToolBuilders/ServerMonitor.launch deleted file mode 100644 index 0c6e0f696..000000000 --- a/Plugins/Mineplex.ServerMonitor/.externalToolBuilders/ServerMonitor.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.ServerMonitor/.project b/Plugins/Mineplex.ServerMonitor/.project deleted file mode 100644 index 77e4dc132..000000000 --- a/Plugins/Mineplex.ServerMonitor/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - Mineplex.ServerMonitor - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/ServerMonitor.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.ServerMonitor/.settings/org.eclipse.core.resources.prefs b/Plugins/Mineplex.ServerMonitor/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/Plugins/Mineplex.ServerMonitor/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/Plugins/Mineplex.ServerMonitor/.settings/org.eclipse.jdt.core.prefs b/Plugins/Mineplex.ServerMonitor/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7341ab168..000000000 --- a/Plugins/Mineplex.ServerMonitor/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/Plugins/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml b/Plugins/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml deleted file mode 100644 index 53e69d8e1..000000000 --- a/Plugins/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.ServerMonitor/pom.xml b/Plugins/Mineplex.ServerMonitor/pom.xml new file mode 100644 index 000000000..d9dc9bf60 --- /dev/null +++ b/Plugins/Mineplex.ServerMonitor/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + + com.mineplex + mineplex-app + dev-SNAPSHOT + ../app.xml + + + ServerMonitor + mineplex-servermonitor + + + + ${project.groupId} + mineplex-core-common + ${project.version} + + + ${project.groupId} + mineplex-serverdata + ${project.version} + + + org.apache.httpcomponents + httpclient + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + mineplex.servermonitor.ServerMonitor + + + + + + + diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index cb57dc313..2bb711a58 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -206,7 +206,7 @@ public class ServerMonitor if (groupStatus.getServerType().equalsIgnoreCase("Player")) { _repository.removeServerGroup(groupStatus); - _serverGroupMap.remove(groupStatus); + _serverGroupMap.remove(groupStatus.getName()); groupStatusIterator.remove(); System.out.println("Removed MPS : " + groupStatus.getName()); @@ -449,7 +449,7 @@ public class ServerMonitor if (serverGroup != null && serverGroup.getHost() != null && !serverGroup.getHost().isEmpty() && serverGroup.getServerCount() <= 1) { _repository.removeServerGroup(serverGroup); - _serverGroupMap.remove(serverGroup); + _serverGroupMap.remove(serverGroup.getName()); _serverGroups.remove(serverGroup); System.out.println("Removed ServerGroup : " + serverGroup.getName()); } diff --git a/Plugins/Mineplex.ServerProcesses/.project b/Plugins/Mineplex.ServerProcesses/.project deleted file mode 100644 index 66b31cde0..000000000 --- a/Plugins/Mineplex.ServerProcesses/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - Mineplex.ServerProcesses - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.StaffServer/.classpath b/Plugins/Mineplex.StaffServer/.classpath deleted file mode 100644 index 52e5e02bf..000000000 --- a/Plugins/Mineplex.StaffServer/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.StaffServer/.externalToolBuilders/StaffBuilder.launch b/Plugins/Mineplex.StaffServer/.externalToolBuilders/StaffBuilder.launch deleted file mode 100644 index 6eb51c35e..000000000 --- a/Plugins/Mineplex.StaffServer/.externalToolBuilders/StaffBuilder.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.StaffServer/.project b/Plugins/Mineplex.StaffServer/.project deleted file mode 100644 index 055073ad3..000000000 --- a/Plugins/Mineplex.StaffServer/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - Mineplex.StaffServer - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/StaffBuilder.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Mineplex.StaffServer/pom.xml b/Plugins/Mineplex.StaffServer/pom.xml new file mode 100644 index 000000000..1b4ffcbef --- /dev/null +++ b/Plugins/Mineplex.StaffServer/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + + com.mineplex + mineplex-plugin + dev-SNAPSHOT + ../plugin.xml + + + StaffServer + mineplex-staffserver + + + + ${project.groupId} + mineplex-core + ${project.version} + + + diff --git a/Plugins/Mineplex.Votifier/Mineplex.Votifier.iml b/Plugins/Mineplex.Votifier/Mineplex.Votifier.iml deleted file mode 100644 index c5e840788..000000000 --- a/Plugins/Mineplex.Votifier/Mineplex.Votifier.iml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/Mineplex.Votifier/pom.xml b/Plugins/Mineplex.Votifier/pom.xml new file mode 100644 index 000000000..0d3e1464c --- /dev/null +++ b/Plugins/Mineplex.Votifier/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + + com.mineplex + mineplex-plugin + dev-SNAPSHOT + ../plugin.xml + + + MineplexVotifier + mineplex-votifier + + + + ${project.groupId} + mineplex-core + ${project.version} + + + com.vexsoftware + votifier + + + diff --git a/Plugins/Nautilus.Game.Arcade/.classpath b/Plugins/Nautilus.Game.Arcade/.classpath deleted file mode 100644 index 315ba497a..000000000 --- a/Plugins/Nautilus.Game.Arcade/.classpath +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/Plugins/Nautilus.Game.Arcade/.externalToolBuilders/Arcade Builder.launch b/Plugins/Nautilus.Game.Arcade/.externalToolBuilders/Arcade Builder.launch deleted file mode 100644 index 2507dff2a..000000000 --- a/Plugins/Nautilus.Game.Arcade/.externalToolBuilders/Arcade Builder.launch +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/Plugins/Nautilus.Game.Arcade/.project b/Plugins/Nautilus.Game.Arcade/.project deleted file mode 100644 index 3f89e9760..000000000 --- a/Plugins/Nautilus.Game.Arcade/.project +++ /dev/null @@ -1,26 +0,0 @@ - - - Nautilus.Game.Arcade - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - - - LaunchConfigHandle - <project>/.externalToolBuilders/Arcade Builder.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.core.resources.prefs b/Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.jdt.ui.prefs b/Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index fe89f28bc..000000000 --- a/Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -formatter_settings_version=12 diff --git a/Plugins/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml b/Plugins/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml deleted file mode 100644 index 471754299..000000000 --- a/Plugins/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/Plugins/Nautilus.Game.Arcade/pom.xml b/Plugins/Nautilus.Game.Arcade/pom.xml new file mode 100644 index 000000000..6c69780d2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + + com.mineplex + mineplex-plugin + dev-SNAPSHOT + ../plugin.xml + + + Arcade + nautilus-game-arcade + + + + ${project.groupId} + mineplex-minecraft-game-classcombat + ${project.version} + + + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index e2ca772b3..cf2b849dc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -6,15 +6,9 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; import mineplex.core.PacketsInteractionFix; -import mineplex.core.account.CoreClient; -import mineplex.core.customdata.CustomDataManager; -import mineplex.core.giveaway.GiveawayManager; -import mineplex.core.globalpacket.GlobalPacketManager; -import net.minecraft.server.v1_8_R3.BiomeBase; -import net.minecraft.server.v1_8_R3.MinecraftServer; -import mineplex.core.CustomTagFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; @@ -22,15 +16,19 @@ import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; +import mineplex.core.common.events.ServerShutdownEvent; import mineplex.core.common.util.FileUtil; import mineplex.core.common.util.UtilServer; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; +import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.friend.FriendManager; import mineplex.core.gadget.GadgetManager; import mineplex.core.give.Give; +import mineplex.core.giveaway.GiveawayManager; +import mineplex.core.globalpacket.GlobalPacketManager; import mineplex.core.hologram.HologramManager; import mineplex.core.ignore.IgnoreManager; import mineplex.core.inventory.InventoryManager; @@ -61,6 +59,8 @@ import mineplex.core.visibility.VisibilityManager; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import nautilus.game.arcade.game.GameServerConfig; +import net.minecraft.server.v1_8_R3.BiomeBase; +import net.minecraft.server.v1_8_R3.MinecraftServer; public class Arcade extends JavaPlugin { @@ -156,7 +156,7 @@ public class Arcade extends JavaPlugin //Arcade Manager PollManager pollManager = new PollManager(this, _clientManager, _donationManager); - _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, giveawayManager, customDataManager); + _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, giveawayManager, customDataManager, punish); new MemoryFix(this); new CustomTagFix(this, packetHandler); @@ -186,6 +186,8 @@ public class Arcade extends JavaPlugin if (_gameManager.GetGame() != null) if (_gameManager.GetGame().WorldData != null) _gameManager.GetGame().WorldData.Uninitialize(); + + getServer().getPluginManager().callEvent(new ServerShutdownEvent(this)); } public GameServerConfig ReadServerConfig() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 943be1a3e..4e574f3cf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -3,33 +3,6 @@ package nautilus.game.arcade; import java.io.File; import java.util.ArrayList; import java.util.HashSet; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockSpreadEvent; -import org.bukkit.event.block.LeavesDecayEvent; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.server.ServerListPingEvent; -import org.bukkit.potion.PotionEffect; -import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; @@ -51,11 +24,15 @@ import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.PlayerDisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; import mineplex.core.energy.Energy; import mineplex.core.explosion.Explosion; import mineplex.core.explosion.ExplosionEvent; +import mineplex.core.facebook.FacebookManager; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; import mineplex.core.giveaway.GiveawayManager; import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; @@ -69,6 +46,7 @@ import mineplex.core.poll.PollManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; +import mineplex.core.punish.Punish; import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.reward.RewardData; import mineplex.core.reward.RewardRarity; @@ -107,7 +85,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.event.EventModule; import nautilus.game.arcade.game.games.uhc.UHC; import nautilus.game.arcade.managers.GameAchievementManager; -import nautilus.game.arcade.managers.GameChatManager; +import nautilus.game.arcade.managers.chat.GameChatManager; import nautilus.game.arcade.managers.GameCreationManager; import nautilus.game.arcade.managers.GameFlagManager; import nautilus.game.arcade.managers.GameGemManager; @@ -126,6 +104,34 @@ import nautilus.game.arcade.managers.IdleManager; import nautilus.game.arcade.managers.MiscManager; import nautilus.game.arcade.player.ArcadePlayer; import nautilus.game.arcade.shop.ArcadeShop; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.util.Vector; public class ArcadeManager extends MiniPlugin implements IRelation { @@ -168,6 +174,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation private GameTournamentManager _gameTournamentManager; private GameWorldManager _gameWorldManager; private GameHostManager _gameHostManager; + private GameChatManager _gameChatManager; private ServerStatusManager _serverStatusManager; private InventoryManager _inventoryManager; private CosmeticManager _cosmeticManager; @@ -180,6 +187,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation private GiveawayManager _giveawayManager; private ResourcePackManager _resourcePackManager; private CustomDataManager _customDataManager; + private Punish _punishmentManager; private TaskManager _taskManager; private PacketHandler _packetHandler; @@ -204,7 +212,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation StatsManager statsManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat, Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler, CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, - NpcManager npcManager, GiveawayManager giveawayManager, CustomDataManager customDataManager) + NpcManager npcManager, GiveawayManager giveawayManager, CustomDataManager customDataManager, Punish punish) { super("Game Manager", plugin); @@ -271,7 +279,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _arcadeShop = new ArcadeShop(this, clientManager, donationManager); // Managers - new GameChatManager(this); + _gameChatManager = new GameChatManager(this); _gameCreationManager = new GameCreationManager(this); _gameGemManager = new GameGemManager(this); _gameManager = new GameManager(this); @@ -289,16 +297,18 @@ public class ArcadeManager extends MiniPlugin implements IRelation _hologramManager = hologramManager; _idleManager = new IdleManager(this); TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager); - new HolidayManager(this, titanGiveaway); +// new HolidayManager(this, titanGiveaway); new GameTestingManager(this); + new PlayerDisguiseManager(plugin, _clientManager); // Game Addons new CompassAddon(plugin, this); new SoupAddon(plugin, this); new TeamArmorAddon(plugin, this); - - new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager); - + + FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); + new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager, facebookManager); + //Champions Modules _energy = new Energy(plugin); @@ -318,6 +328,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation _eloManager = new EloManager(_plugin, clientManager); + _punishmentManager = punish; + if (GetHost() != null && !GetHost().isEmpty()) { Bukkit.getScheduler().runTaskLater(plugin, new Runnable() @@ -342,6 +354,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation addCommand(new RequiredRankCommand(this)); } + public GameChatManager getGameChatManager() + { + return _gameChatManager; + } + public GameServerConfig GetServerConfig() { return _serverConfig; @@ -446,6 +463,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation { return _projectileManager; } + + public Punish getPunishments() + { + return _punishmentManager; + } public Portal GetPortal() { @@ -887,6 +909,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation HubClock(player); GetDisguise().undisguise(player); + + Gadget morph = getCosmeticManager().getGadgetManager().getActive(player, GadgetType.Morph); + if (morph != null && morph.IsActive(player)) + morph.Disable(player); } public ArrayList LoadFiles(String gameName) @@ -1152,6 +1178,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation if (event.GetState() == GameState.Recruit) { getCosmeticManager().setActive(true); + getCosmeticManager().setHideParticles(false); } else if (event.GetState() == GameState.Prepare || event.GetState() == GameState.Loading || event.GetState() == GameState.Dead) { @@ -1163,6 +1190,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation getCosmeticManager().disableItemsForGame(); } } + + if (!event.GetGame().AllowParticles) + getCosmeticManager().setHideParticles(true); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 5f647dcd9..58fe9a3a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -1,7 +1,5 @@ package nautilus.game.arcade; -import org.bukkit.Material; - import mineplex.core.game.GameCategory; import mineplex.core.game.GameDisplay; import nautilus.game.arcade.game.Game; @@ -54,6 +52,7 @@ import nautilus.game.arcade.game.games.smash.TeamSuperSmash; import nautilus.game.arcade.game.games.snake.Snake; import nautilus.game.arcade.game.games.sneakyassassins.SneakyAssassins; import nautilus.game.arcade.game.games.snowfight.SnowFight; +import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; import nautilus.game.arcade.game.games.spleef.Spleef; import nautilus.game.arcade.game.games.spleef.SpleefTeams; import nautilus.game.arcade.game.games.squidshooter.SquidShooter; @@ -68,6 +67,8 @@ import nautilus.game.arcade.game.games.wither.WitherGame; import nautilus.game.arcade.game.games.wizards.Wizards; import nautilus.game.arcade.game.games.zombiesurvival.ZombieSurvival; +import org.bukkit.Material; + public enum GameType { //Mini @@ -113,6 +114,7 @@ public enum GameType Snake(Snake.class, GameDisplay.Snake), SneakyAssassins(SneakyAssassins.class, GameDisplay.SneakyAssassins), SnowFight(SnowFight.class, GameDisplay.SnowFight), + SpeedBuilders(SpeedBuilders.class, GameDisplay.SpeedBuilders), Spleef(Spleef.class, GameDisplay.Spleef), SpleefTeams(SpleefTeams.class, GameDisplay.SpleefTeams), SquidShooter(SquidShooter.class, GameDisplay.SquidShooter), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java index 7111ae370..632317ab5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/DisguiseCommand.java @@ -1,9 +1,9 @@ package nautilus.game.arcade.command; import java.lang.reflect.Field; +import java.util.List; import java.util.UUID; -import mineplex.core.NCPDataManFix; import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; @@ -14,15 +14,30 @@ import mineplex.core.common.util.ProfileLoader; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.PlayerUndisguiseEvent; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.types.GadgetType; +import mineplex.core.punish.Category; +import mineplex.core.punish.PunishClient; +import mineplex.core.punish.Punishment; import mineplex.core.treasure.event.TreasureStartEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game.GameState; +import net.minecraft.server.v1_8_R3.ChatComponentText; import net.minecraft.server.v1_8_R3.EntityHuman; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.EnumDifficulty; +import net.minecraft.server.v1_8_R3.IChatBaseComponent; import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData; +import net.minecraft.server.v1_8_R3.PacketPlayOutRespawn; +import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode; +import net.minecraft.server.v1_8_R3.WorldType; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -52,10 +67,9 @@ public class DisguiseCommand extends CommandBase implements Liste public DisguiseCommand(ArcadeManager plugin) { - super(plugin, Rank.JNR_DEV, new Rank[] - { Rank.YOUTUBE, Rank.TWITCH }, "disguise"); + super(plugin, Rank.JNR_DEV, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, "disguise"); + plugin.getPluginManager().registerEvents(this, Plugin.getPlugin()); - new NCPDataManFix(); } @Override @@ -65,15 +79,17 @@ public class DisguiseCommand extends CommandBase implements Liste { if(!Plugin.GetDisguise().isDisguised(caller)) { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); return; } try { + GameProfile profile = _disguisedPlayers.get(caller); _disguisedPlayers.remove(caller); _disguisedPlayerDisguises.remove(caller); Plugin.GetDisguise().undisguise(caller); String playerName = _disguisedPlayersNames.get(caller); + Plugin.getPluginManager().callEvent(new PlayerUndisguiseEvent(caller)); CoreClient client = Plugin.GetClients().Get(caller); client.setDisguisedRank(null); @@ -81,7 +97,30 @@ public class DisguiseCommand extends CommandBase implements Liste client.setDisguised(false); changeName(caller, playerName, true); + + for(Player other : UtilServer.getPlayers()) + updateTabInfo(((CraftPlayer) caller).getProfile(), profile, other, false); + Field field; + try + { + field = GameProfile.class.getDeclaredField("id"); + field.setAccessible(true); + UUID old = ((CraftPlayer) caller).getProfile().getId(); + UUID newUUID = profile.getId(); + field.set(profile, old); + field.set(((CraftPlayer) caller).getProfile(), newUUID); + } + catch(Exception e) + { + e.printStackTrace(); + } + + + // removed "due to Kicked for Flying" + //PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); + //UtilPlayer.sendPacket(caller, packet); + for(Player other : UtilServer.getPlayers()) { for(Team team : other.getScoreboard().getTeams()) @@ -91,7 +130,7 @@ public class DisguiseCommand extends CommandBase implements Liste other.getScoreboard().getTeam(Plugin.GetClients().Get(caller).GetRank().Name).addPlayer(caller); } - UtilPlayer.message(caller, C.cRed + C.Bold + "You are no longer disguised!"); + UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!")); return; } catch(Exception ex) { @@ -100,7 +139,7 @@ public class DisguiseCommand extends CommandBase implements Liste } if(args != null && args.length > 1) { - UtilPlayer.message(caller, C.cRed + C.Bold + "/disguise "); + UtilPlayer.message(caller, F.main("Disguise", "/disguise ")); return; } @@ -111,55 +150,69 @@ public class DisguiseCommand extends CommandBase implements Liste { if(Plugin.GetDisguise().isDisguised(caller)) { - UtilPlayer.message(caller, C.cRed + C.Bold + "please use /disguise first"); + UtilPlayer.message(caller, F.main("Disguise", "please use /disguise first")); return; } for(Player other : UtilServer.getPlayers()) { if(other.getName().equalsIgnoreCase(args[0])) { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); return; } } if(_disguisedPlayersNames.containsValue(args[0])) { - UtilPlayer.message(caller, C.cRed + C.Bold + "this name is already in use!"); + UtilPlayer.message(caller, C.cRed + F.main("Disguise", "this name is already in use!")); return; } if(args[0].length() > 16) { - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); return; } try { CoreClient client = Plugin.GetClients().Get(caller); - UUID uuid = UUIDFetcher.getUUIDOf(args[0]); + UUID uuid = UUID.randomUUID(); GameProfile profile = null; try { + uuid = UUIDFetcher.getUUIDOf(args[0]); profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); - } catch(Exception e) + } catch (Exception e) { - uuid = UUIDFetcher.getUUIDOf("Alex"); - profile = new ProfileLoader(uuid.toString(), args[0]).loadProfile(); + uuid = UUID.randomUUID(); + profile = new ProfileLoader(null, args[0]).loadProfile(); } Rank otherRank = Rank.ALL; + CoreClient other = null; try { - CoreClient other = new CoreClient(args[0]); + other = new CoreClient(args[0]); Plugin.GetClients().LoadClient(other, uuid, caller.getAddress().getAddress().getAddress().toString()); otherRank = other.GetRank(); } catch(NullPointerException exception) - {} + { + other = null; + } if(otherRank.has(Rank.TWITCH)) { - UtilPlayer.message(caller, C.cRed + C.Bold + "You can't disguise as staff!"); + UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, Youtubers or Twitchers!")); return; } + if(other != null) + { + PunishClient pclient = Plugin.getPunishments().GetClient(args[0]); + if(pclient.IsBanned() || pclient.IsMuted()) + { + UtilPlayer.message(caller, F.main("Disguise", "Unable to disguise as this Player!")); + return; + } + } + _disguisedPlayers.put(caller, profile); _disguisedPlayersNames.put(caller, caller.getName()); client.setDisguisedRank(otherRank); @@ -171,17 +224,102 @@ public class DisguiseCommand extends CommandBase implements Liste Plugin.getCosmeticManager().getGadgetManager().removeGadgetType(caller, GadgetType.Item); - Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); - UtilPlayer.message(caller, C.cGreen + C.Bold + "Disguise Active: " + ChatColor.RESET + args[0]); + // Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "Quit> " + ChatColor.GRAY + _disguisedPlayersNames.get(caller)); + UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + args[0])); + + Field field; + try + { + field = GameProfile.class.getDeclaredField("id"); + field.setAccessible(true); + UUID old = ((CraftPlayer) caller).getProfile().getId(); + UUID newUUID = profile.getId(); + field.set(profile, old); + field.set(((CraftPlayer) caller).getProfile(), newUUID); + } + catch(Exception e) + { + e.printStackTrace(); + } + + // removed "due to Kicked for Flying" + //PacketPlayOutRespawn packet = new PacketPlayOutRespawn(0, EnumDifficulty.getById(caller.getWorld().getDifficulty().getValue()), WorldType.NORMAL, EnumGamemode.getById(caller.getGameMode().getValue())); + //UtilPlayer.sendPacket(caller, packet); + + tablistRefresh(caller); } catch(Exception e) { e.printStackTrace(); - UtilPlayer.message(caller, C.cRed + C.Bold + "Invalid Disguise Name: " + ChatColor.RESET + args[0]); + UtilPlayer.message(caller, F.main("Disguise", "Invalid Disguise Name: " + ChatColor.RESET + args[0])); return; } } }); } + + @EventHandler + public void refreshTabNames(UpdateEvent event) + { + if(event.getType() != UpdateType.FAST) + return; + + for(Player player : _disguisedPlayers.keySet()) + { + if(!player.isOnline()) + return; + + tablistRefresh(player); + } + } + + public void tablistRefresh(Player player) + { + for (Player other : UtilServer.getPlayers()) + { + if (player.canSee(other)) + { + updateTabInfo(_disguisedPlayers.get(player), ((CraftPlayer) player).getProfile(), other, false); + } + } + } + + public void updateTabInfo(GameProfile profileToAdd, GameProfile profileToRemove, Player target, boolean refreshOnly) + { + ChatColor team = ChatColor.WHITE; + Player player = Bukkit.getPlayer(profileToAdd.getName()); + EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + if(Plugin.GetGame().GetTeam(player) != null) + { + team = Plugin.GetGame().GetTeam(player).GetColor(); + } + String tag = Plugin.GetClients().Get(player).GetRank().getTag(true, true) + " "; + if(Plugin.GetClients().Get(player).isDisguised()) + { + tag = Plugin.GetClients().Get(player).getDisguisedRank().getTag(true, true) + " "; + } + if(Plugin.GetGame().GetState() != GameState.Recruit) + tag = ""; + + IChatBaseComponent component = new ChatComponentText(tag + team + player.getName()); + + if(!refreshOnly) + { + PacketPlayOutPlayerInfo removePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER); + PlayerInfoData removeData = removePacket.new PlayerInfoData(profileToRemove, entityPlayer.ping, EnumGamemode.SURVIVAL, component); + removePacket.b.add(removeData); + UtilPlayer.sendPacket(target, removePacket); + + PacketPlayOutPlayerInfo addPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER); + PlayerInfoData addData = addPacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); + addPacket.b.add(addData); + UtilPlayer.sendPacket(target, addPacket); + } + + PacketPlayOutPlayerInfo updatePacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME); + PlayerInfoData updateData = updatePacket.new PlayerInfoData(profileToAdd, entityPlayer.ping, EnumGamemode.SURVIVAL, component); + updatePacket.b.add(updateData); + UtilPlayer.sendPacket(target, updatePacket); + } @EventHandler public void updateDisguises(UpdateEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 6eec52eb7..79e46c510 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -74,6 +74,7 @@ import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.managers.GameLobbyManager; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.scoreboard.GameScoreboard; import nautilus.game.arcade.stats.AssistsStatTracker; import nautilus.game.arcade.stats.DamageDealtStatTracker; @@ -271,6 +272,21 @@ public abstract class Game implements Listener public long PrepareTime = 9000; public boolean PlaySoundGameStart = true; + // Chat Stats + public final ChatStatData Kills = new ChatStatData("Kills", "Kills", true); + public final ChatStatData Assists = new ChatStatData("Assists", "Assists", true); + public final ChatStatData DamageDealt = new ChatStatData("Damage Dealt", "Damage Dealt", true); + public final ChatStatData DamageTaken = new ChatStatData("Damage Taken", "Damage Taken", true); + public final ChatStatData DamageTakenPVP = new ChatStatData("Damage Taken PvP", "Damage Taken", true); + public final ChatStatData Deaths = new ChatStatData("Deaths", "Deaths", true); + public final ChatStatData ExpEarned = new ChatStatData("ExpEarned", "Exp Earned", true); + public final ChatStatData GamesPlayed = new ChatStatData("GamesPlayed", "Games Played", true); + public final ChatStatData GemsEarned = new ChatStatData("GemsEarned", "Gems Earned", true); + public final ChatStatData Losses = new ChatStatData("Losses", "Losses", true); + public final ChatStatData Wins = new ChatStatData("Wins", "Wins", true); + public final ChatStatData KDRatio = new ChatStatData("KDRatio", "KD-Ratio", true); + public final ChatStatData BlankLine = new ChatStatData().blankLine(); + // Gems public double GemMultiplier = 1; public boolean GemHunterEnabled = true; @@ -311,6 +327,8 @@ public abstract class Game implements Listener public boolean EnableTutorials = false; public boolean FixSpawnFacing = true; + + public boolean AllowEntitySpectate = true; private IPacketHandler _useEntityPacketHandler; private int _deadBodyCount; @@ -1420,6 +1438,11 @@ public abstract class Game implements Listener } } + public void registerChatStats(ChatStatData... stats) + { + Manager.getGameChatManager().setGameChatStats(stats); + } + public Collection> getStatTrackers() { return _statTrackers; @@ -1751,4 +1774,6 @@ public abstract class Game implements Listener } public void addTutorials(){} + + public void disable(){} } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java index 0ee17ce94..adc29452f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java @@ -38,6 +38,16 @@ public class BaconBrawl extends SoloGame DamageTeamSelf = true; HungerSet = 20; PrepareFreeze = false; + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageDealt, + DamageTaken + ); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java index 9a769fe02..c48e919eb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java @@ -15,6 +15,8 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.barbarians.kits.*; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; +import nautilus.game.arcade.stats.BlockBreakStatTracker; public class Barbarians extends SoloGame { @@ -58,6 +60,22 @@ public class Barbarians extends SoloGame this.BlockBreakAllow.add(134); this.BlockBreakAllow.add(135); this.BlockBreakAllow.add(136); + + registerStatTrackers( + new BlockBreakStatTracker(this, true) + ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageDealt, + DamageTaken, + BlankLine, + new ChatStatData("BlockBreak", "Blocks Broken", true) + ); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java index ca6253aab..0ecfe91f4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java @@ -58,6 +58,9 @@ public class BossBattles extends TeamGame HungerSet = 20; CreatureAllowOverride = true; PrepareFreeze = false; + +// registerChatStats(Kills); +// Game giving constant errors when loading. } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bouncyballs/BouncyBalls.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bouncyballs/BouncyBalls.java index bfd3cc0a1..ce464297f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bouncyballs/BouncyBalls.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bouncyballs/BouncyBalls.java @@ -15,6 +15,7 @@ import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.bouncyballs.kits.*; import nautilus.game.arcade.game.games.bouncyballs.Ball; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; public class BouncyBalls extends SoloGame { @@ -35,6 +36,8 @@ public class BouncyBalls extends SoloGame }); this.HungerSet = 20; + +// registerChatStats(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index e10942288..fa198fe45 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -4,8 +4,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.UUID; - import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -51,9 +51,9 @@ import nautilus.game.arcade.stats.DeathBomberStatTracker; import nautilus.game.arcade.stats.FoodForTheMassesStatTracker; import nautilus.game.arcade.stats.KillFastStatTracker; import nautilus.game.arcade.stats.TntMinerStatTracker; - import org.bukkit.ChatColor; import org.bukkit.Effect; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -144,10 +144,6 @@ public class Bridge extends TeamGame implements OreObsfucation private HashMap _tournamentKills = new HashMap(); private long _tournamentKillMessageTimer = 0; - //Item pickup delay for players that don't break the block - private HashMap _blockToUUIDMap = new HashMap(); - - public Bridge(ArcadeManager manager) { super(manager, GameType.Bridge, @@ -233,6 +229,16 @@ public class Bridge extends TeamGame implements OreObsfucation new KillFastStatTracker(this, 4, 10, "Rampage"), new DeathBomberStatTracker(this, 5) ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageTaken, + DamageDealt + ); } @EventHandler @@ -1130,11 +1136,13 @@ public class Bridge extends TeamGame implements OreObsfucation { // Reveal ore that are inside the explosion _ore.Explosion(event); + + NautHashMap> lootDrops = new NautHashMap>(); // Handle block ownership for explosion if (event.getOwner() != null) { - for (Block cur : event.GetBlocks()) + for (Block cur : new HashSet(event.GetBlocks())) { // These are the only blocks that will drop from the explosion so they are the only ones // we need to worry about for keeping owner data of @@ -1143,19 +1151,32 @@ public class Bridge extends TeamGame implements OreObsfucation cur.getType() == Material.GOLD_ORE || cur.getType() == Material.DIAMOND_ORE) { - _blockToUUIDMap.put(cur, event.getOwner().getUniqueId()); + event.GetBlocks().remove(cur); + lootDrops.put(cur, new HashSet()); + + lootDrops.get(cur).addAll(cur.getDrops()); } } } - } - @EventHandler(priority = EventPriority.MONITOR) - public void OreReveal(BlockBreakEvent event) - { - if (event.isCancelled()) - return; + Manager.runSyncLater(new Runnable() // Run after the explosion has already happened + { + @Override + public void run() + { + for (Block block : new HashSet(lootDrops.keySet())) + { + block.setType(Material.AIR); + Location drop = block.getLocation().clone().add(.5, .5, .5); - _ore.BlockBreak(event); + for (ItemStack stack : lootDrops.remove(block)) + { + Item item = block.getWorld().dropItem(drop, stack); + item.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), event.getOwner().getUniqueId())); + } + } + } + }, 1); } @EventHandler(priority = EventPriority.LOW) @@ -1280,40 +1301,43 @@ public class Bridge extends TeamGame implements OreObsfucation } } - private void addBlockPickupDelay(Player owner, Block block) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void dropItem(BlockBreakEvent event) { - Material blockMaterial = block.getType(); - boolean shouldAddToMap = false; + _ore.BlockBreak(event); - for (int i = 0; i < PLAYER_DROP_DELAY_MATERIALS.length && !shouldAddToMap; i++) + if (!IsLive()) + return; + + if (!IsAlive(event.getPlayer())) + return; + + if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + return; + + List drops = new ArrayList(); + + for (Material mat : PLAYER_DROP_DELAY_MATERIALS) { - if (blockMaterial.equals(PLAYER_DROP_DELAY_MATERIALS[i])) + if (event.getBlock().getType() == mat) { - shouldAddToMap = true; + drops.addAll(event.getBlock().getDrops()); + break; } } - if (shouldAddToMap) - _blockToUUIDMap.put(block, owner.getUniqueId()); - } + if (drops.isEmpty()) + return; + + event.setCancelled(true); + event.getBlock().setType(Material.AIR); - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void dropItem(BlockBreakEvent event) - { - addBlockPickupDelay(event.getPlayer(), event.getBlock()); - } + Location loc = event.getBlock().getLocation().clone().add(.5, .5, .5); - @EventHandler - public void itemSpawn(ItemSpawnEvent event) - { - Item item = event.getEntity(); - Block block = event.getLocation().getBlock(); - - UUID uuid = _blockToUUIDMap.remove(block); - - if (uuid != null) + for (ItemStack item : drops) { - item.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), uuid)); + Item drop = loc.getWorld().dropItem(loc, item); + drop.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), event.getPlayer().getUniqueId())); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java index a066fd174..5828ce042 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java @@ -2,6 +2,8 @@ package nautilus.game.arcade.game.games.build; import java.util.AbstractMap; import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.Map.Entry; import mineplex.core.common.util.C; @@ -37,6 +39,10 @@ import nautilus.game.arcade.game.games.build.gui.MobShop; import nautilus.game.arcade.game.games.build.gui.OptionsShop; import nautilus.game.arcade.game.games.build.kits.KitBuilder; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; +import nautilus.game.arcade.stats.BlockBreakStatTracker; +import nautilus.game.arcade.stats.BlockPlaceStatTracker; +import java.util.UUID; import org.bukkit.ChatColor; import org.bukkit.Effect; @@ -119,6 +125,7 @@ public class Build extends SoloGame private String[] _words; private String[] _holidayWords; + private boolean _useHolidayWords = false; private String _word = "?"; @@ -141,6 +148,8 @@ public class Build extends SoloGame private ChatColor _hintColor = ChatColor.YELLOW; private ChatColor _firstHintColor = ChatColor.YELLOW; + private UUID _winnerUUID = null; + public Build(ArcadeManager manager) { super(manager, GameType.Build, @@ -215,6 +224,16 @@ public class Build extends SoloGame _mobShop = new MobShop(getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation()); _optionsShop = new OptionsShop(this, getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation()); _shopItem = ItemStackFactory.Instance.CreateStack(Material.DIAMOND, (byte) 0, 1, C.cGreen + "Options"); + + registerStatTrackers( + new BlockBreakStatTracker(this, false), + new BlockPlaceStatTracker(this, new Material[]{}) + ); + + registerChatStats( + new ChatStatData("BlocksPlaced", "Blocks Placed", true), + new ChatStatData("BlocksBroken", "Blocks Broken", true) + ); } @EventHandler @@ -249,7 +268,7 @@ public class Build extends SoloGame player.setFlySpeed(0.1f); } - if (Math.random() >= 0.5) + if (!_useHolidayWords || Math.random() >= 0.5) _word = _words[UtilMath.r(_words.length)]; else _word = _holidayWords[UtilMath.r(_holidayWords.length)]; @@ -537,7 +556,10 @@ public class Build extends SoloGame //Gems if (places.size() >= 1) + { + _winnerUUID = places.get(0).getUniqueId(); AddGems(places.get(0), 20, "1st Place", false, false); + } if (places.size() >= 2) AddGems(places.get(1), 15, "2nd Place", false, false); @@ -1541,4 +1563,14 @@ public class Build extends SoloGame } } } + + @Override + public List getWinners() + { + Player player = UtilPlayer.searchExact(_winnerUUID); + if (player == null) + return null; + + return Arrays.asList(player); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java index 8943458b7..e890a34a2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java @@ -70,6 +70,8 @@ public class Cards extends SoloGame this.PrepareFreeze = false; _cardFactory = new CardFactory(); + + registerChatStats(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java index c6a53e65b..2aced88d1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java @@ -71,6 +71,7 @@ import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadGhoul; import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadZombie; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.BloodThirstyStatTracker; import nautilus.game.arcade.stats.KingDamageStatTracker; import nautilus.game.arcade.stats.KingSlayerStatTracker; @@ -211,7 +212,6 @@ public class CastleSiege extends TeamGame } registerStatTrackers( - new WinAsTeamStatTracker(this, notRedTeam, "ForTheKing"), new KingSlayerStatTracker(this), new BloodThirstyStatTracker(this), new KingDamageStatTracker(this), @@ -219,6 +219,18 @@ public class CastleSiege extends TeamGame new TeamDeathsStatTracker(this), new TeamKillsStatTracker(this) ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageDealt, + DamageTaken + ); + + registerChatStats(); } @Override @@ -260,6 +272,30 @@ public class CastleSiege extends TeamGame } } + @EventHandler(priority = EventPriority.HIGH) + public void registerTeamTracker(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Recruit) + { + GameTeam notRed = null; + + for (GameTeam team : GetTeamList()) + { + if (team.GetColor() == ChatColor.RED) + continue; + + notRed = team; + break; + } + + if (notRed != null) + { + registerStatTrackers(new WinAsTeamStatTracker(this, notRed, "ForTheKing")); + System.out.println("Successfully registered For the King StatTrak"); + } + } + } + @EventHandler public void MoveKits(GameStateChangeEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java index 209a620ab..c2633e3b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java @@ -18,6 +18,7 @@ import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.common.CaptureTheFlag; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.CapturesStatTracker; import nautilus.game.arcade.stats.ClutchStatTracker; import nautilus.game.arcade.stats.ElectrocutionStatTracker; @@ -37,20 +38,20 @@ import org.bukkit.event.inventory.InventoryType; public class ChampionsCTF extends CaptureTheFlag { public ChampionsCTF(ArcadeManager manager) - { + { super(manager, GameType.ChampionsCTF, - - new Kit[] - { - new KitBrute(manager), - new KitRanger(manager), + + new Kit[] + { + new KitBrute(manager), + new KitRanger(manager), new KitKnight(manager), new KitMage(manager), new KitAssassin(manager), }); - - _help = new String[] - { + + _help = new String[] + { "Make sure you use all of your Skill/Item Tokens", "Collect Resupply Chests to restock your inventory", "Customize your Class to suit your play style", @@ -59,7 +60,7 @@ public class ChampionsCTF extends CaptureTheFlag "Gold/Iron Weapons deal 6 damage", "Diamond Weapons deal 7 damage", - }; + }; Manager.GetDamage().UseSimpleWeaponDamage = false; Manager.getCosmeticManager().setHideParticles(true); @@ -86,6 +87,18 @@ public class ChampionsCTF extends CaptureTheFlag new ClutchStatTracker(this, "Clutch"), new SpecialWinStatTracker(this, "SpecialWin") ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageDealt, + DamageTaken, + BlankLine, + new ChatStatData("Captures", "Flag Captures", true) + ); new ChampionsFixes(this); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java index be521f530..83b44d9de 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java @@ -16,6 +16,7 @@ import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.common.Domination; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.ElectrocutionStatTracker; import nautilus.game.arcade.stats.KillReasonStatTracker; import nautilus.game.arcade.stats.SeismicSlamStatTracker; @@ -78,6 +79,16 @@ public class ChampionsDominate extends Domination new TheLongestShotStatTracker(this), new SeismicSlamStatTracker(this) ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageDealt, + DamageTaken + ); new ChampionsFixes(this); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java index f4cd3ea49..73bbb3812 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java @@ -16,6 +16,7 @@ import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.common.TeamDeathmatch; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.ElectrocutionStatTracker; import nautilus.game.arcade.stats.KillAllOpposingStatTracker; import nautilus.game.arcade.stats.KillReasonStatTracker; @@ -78,6 +79,16 @@ public class ChampionsTDM extends TeamDeathmatch new TheLongestShotStatTracker(this), new SeismicSlamStatTracker(this) ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageDealt, + DamageTaken + ); new ChampionsFixes(this); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java index 23b3ec1b1..5e68140ee 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java @@ -152,6 +152,11 @@ public class Christmas extends SoloGame HungerSet = 20; WorldTimeSet = 2000; PrepareFreeze = false; + + registerChatStats( + DamageDealt, + DamageTaken + ); } //parse 129 19 47 48 103 86 137 56 22 45 121 14 15 16 87 88 89 153 173 172 162 @@ -465,7 +470,7 @@ public class Christmas extends SoloGame { SantaSay("Well done! You've saved Christmas!", ChristmasAudio.END_WIN2); - for (Player player : GetPlayers(false)) + for (final Player player : GetPlayers(false)) { if (Manager.IsRewardItems()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part.java index ea8e171cc..80c3a276e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part.java @@ -223,7 +223,7 @@ public abstract class Part implements Listener Host.GetSleigh().AddPresent(present.getBlock().getLocation()); - Host.SantaSay("Well done " + event.getPlayer().getName() + "! You collected a present!", null); + Host.SantaSay("Well done, " + event.getPlayer().getName() + "! You collected a present!", null); } public void SetObjectiveText(String text, double percent) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part5.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part5.java index 2dceaca60..b91aa0d13 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part5.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part5.java @@ -143,7 +143,7 @@ public class Part5 extends Part _a = true; _dialogueDelay = System.currentTimeMillis(); - Host.SantaSay("WHAT IS THIS?! Who's castle is this?!", ChristmasAudio.BANTER_A); + Host.SantaSay("WHAT IS THIS?! Whose castle is this?!", ChristmasAudio.BANTER_A); } else if (_a && !_b && UtilTime.elapsed(_dialogueDelay, _delayTime)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java index a521de32a..859257fcb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java @@ -73,6 +73,12 @@ public class DeathTag extends SoloGame this.PrepareFreeze = false; registerStatTrackers(new ComeAtMeBroStatTracker(this)); + + registerChatStats( + Kills, + Deaths, + KDRatio + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index a3970305c..3cbd0c28d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -52,6 +52,8 @@ import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.dragonescape.kits.*; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; +import nautilus.game.arcade.stats.DistanceTraveledStatTracker; import nautilus.game.arcade.stats.ParalympicsStatTracker; import nautilus.game.arcade.stats.WinMapStatTracker; @@ -118,7 +120,14 @@ public class DragonEscape extends SoloGame registerStatTrackers( new ParalympicsStatTracker(this), - new WinMapStatTracker(this) + new WinMapStatTracker(this), + new DistanceTraveledStatTracker(this, "MarathonRunner") + ); + + registerChatStats( + new ChatStatData("MarathonRunner", "Distance ran", true), + BlankLine, + new ChatStatData("kit", "Kit", true) ); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java index e03d66bb6..0b6764bb5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeTeams.java @@ -45,6 +45,7 @@ import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.dragonescape.kits.*; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; public class DragonEscapeTeams extends TeamGame { @@ -84,6 +85,13 @@ public class DragonEscapeTeams extends TeamGame this.HungerSet = 20; this.TeamArmorHotbar = true; + + registerChatStats( + Deaths, + DamageTaken, + BlankLine, + new ChatStatData("kit", "Kit", true) + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonriders/DragonRiders.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonriders/DragonRiders.java index 608879f82..bccf6f3a1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonriders/DragonRiders.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonriders/DragonRiders.java @@ -24,5 +24,8 @@ public class DragonRiders extends SoloGame this.Damage = false; this.HungerSet = 20; + + //Chat stats + registerChatStats(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/Dragons.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/Dragons.java index d489ad2da..2ec7e7daa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/Dragons.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/Dragons.java @@ -18,11 +18,7 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -31,11 +27,11 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.games.dragons.DragonData; import nautilus.game.arcade.game.games.dragons.kits.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.PerkSparkler; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.SparklezStatTracker; public class Dragons extends SoloGame @@ -70,6 +66,13 @@ public class Dragons extends SoloGame registerStatTrackers( new SparklezStatTracker(this) ); + + registerChatStats( + DamageDealt, + DamageTaken, + BlankLine, + new ChatStatData("kit", "Kit", true) + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/DragonsTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/DragonsTeams.java index 07dab3d2c..9743a5aaf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/DragonsTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragons/DragonsTeams.java @@ -35,6 +35,7 @@ import nautilus.game.arcade.game.games.dragons.kits.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.PerkSparkler; +import nautilus.game.arcade.managers.chat.ChatStatData; public class DragonsTeams extends TeamGame { @@ -72,6 +73,13 @@ public class DragonsTeams extends TeamGame this.TeamArmor = true; this.TeamArmorHotbar = true; + + registerChatStats( + Deaths, + DamageTaken, + BlankLine, + new ChatStatData("kit", "Kit", true) + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index 53d88aeda..640766261 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -51,6 +51,8 @@ import nautilus.game.arcade.game.games.GameScore; import nautilus.game.arcade.game.games.draw.kits.*; import nautilus.game.arcade.game.games.draw.tools.*; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; +import nautilus.game.arcade.stats.DrawGuessStatTracker; import nautilus.game.arcade.stats.KeenEyeStatTracker; import nautilus.game.arcade.stats.MrSquiggleStatTracker; import nautilus.game.arcade.stats.PureLuckStatTracker; @@ -84,6 +86,7 @@ public class Draw extends SoloGame private HashSet _tools; private String[] _words; private String[] _holidayWords; + private boolean _useHolidayWords = false; private HashSet _usedWords = new HashSet(); public Draw(ArcadeManager manager) @@ -132,7 +135,13 @@ public class Draw extends SoloGame registerStatTrackers( new MrSquiggleStatTracker(this), new KeenEyeStatTracker(this), - new PureLuckStatTracker(this) + new PureLuckStatTracker(this), + new DrawGuessStatTracker(this) + ); + + registerChatStats( + new ChatStatData("TotalGuess", "Total Guess'", true), + new ChatStatData("PureLuck", "Lucky Guess'", true) ); Manager.GetChat().setThreeSecondDelay(false); @@ -302,7 +311,7 @@ public class Draw extends SoloGame private String getRandomWord() { - if (Math.random() >= 0.30) + if (!_useHolidayWords || Math.random() >= 0.30) { return _words[UtilMath.r(_words.length)]; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java index bfcd5896f..e8b4ead2e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java @@ -162,6 +162,16 @@ public class Evolution extends SoloGame new NoMeleeTracker(this), new KillsWhileEvolvingTracker(this) ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageDealt, + DamageTaken + ); } public EvolveManager getEvolve() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index a9fcae09a..fbf5edc54 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -22,7 +22,6 @@ import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -57,6 +56,8 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.gladiators.events.PlayerChangeArenaEvent; import nautilus.game.arcade.game.games.gladiators.events.RoundStartEvent; +import nautilus.game.arcade.game.games.gladiators.hotbar.HotbarEditor; +import nautilus.game.arcade.game.games.gladiators.hotbar.HotbarLayout; import nautilus.game.arcade.game.games.gladiators.kits.KitGladiator; import nautilus.game.arcade.game.games.gladiators.trackers.BrawlerTracker; import nautilus.game.arcade.game.games.gladiators.trackers.FlawlessTracker; @@ -66,6 +67,7 @@ import nautilus.game.arcade.game.games.gladiators.trackers.UntouchableTracker; import nautilus.game.arcade.game.games.gladiators.tutorial.TutorialGladiators; import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; /** * Created by William (WilliamTiger). @@ -85,6 +87,8 @@ public class Gladiators extends SoloGame private boolean _firstRound; + private HotbarEditor _hotbarEditor; + public Gladiators(ArcadeManager manager) { super(manager, GameType.Gladiators, @@ -120,10 +124,22 @@ public class Gladiators extends SoloGame new SwiftKillTracker(this) ); + registerChatStats( + Kills, + Assists, + BlankLine, + new ChatStatData("Untouchable", "Untouchable", true), + BlankLine, + DamageDealt, + DamageTaken + ); + _playerArenas = new HashMap<>(); _roundState = RoundState.WAITING; _firstRound = true; + + _hotbarEditor = new HotbarEditor(manager.getPlugin(), this); } @EventHandler @@ -181,6 +197,9 @@ public class Gladiators extends SoloGame if (e.getType() != UpdateType.FASTEST) return; + if (!IsLive()) + return; + if (GetState() != GameState.Prepare) return; @@ -739,13 +758,15 @@ public class Gladiators extends SoloGame if (!GetPlayers(true).contains(p)) return; + HotbarLayout layout = _hotbarEditor.getLayout(p); + p.getInventory().clear(); p.getInventory().setArmorContents(null); - p.getInventory().setItem(0, UtilItem.makeUnbreakable(type.getLoadout().getSword())); - p.getInventory().setItem(1, UtilItem.makeUnbreakable(type.getLoadout().getRod())); - p.getInventory().setItem(2, type.getLoadout().getBow()); - p.getInventory().setItem(8, type.getLoadout().getArrows()); + p.getInventory().setItem(layout.getSword(), UtilItem.makeUnbreakable(type.getLoadout().getSword())); + p.getInventory().setItem(layout.getRod(), UtilItem.makeUnbreakable(type.getLoadout().getRod())); + p.getInventory().setItem(layout.getBow(), type.getLoadout().getBow()); + p.getInventory().setItem(layout.getArrows(), type.getLoadout().getArrows()); p.getInventory().setHelmet(type.getLoadout().getHelmet()); p.getInventory().setChestplate(type.getLoadout().getChestplate()); @@ -1085,4 +1106,11 @@ public class Gladiators extends SoloGame Scoreboard.Draw(); } + + @Override + public void disable() + { + _hotbarEditor.deregisterSelf(); // De-register as listener + _hotbarEditor.onDisable(); // Fully disable + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java new file mode 100644 index 000000000..da6897997 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java @@ -0,0 +1,199 @@ +package nautilus.game.arcade.game.games.gladiators.hotbar; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.collect.Lists; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.gladiators.Gladiators; + +/** + * Created by William (WilliamTiger). + * 18/12/15 + */ +public class HotbarEditor extends MiniPlugin +{ + private Gladiators _host; + private ItemStack _item; + private Listener _pageListener; + + public HotbarEditor(JavaPlugin plugin, Gladiators gladiators) + { + super("Hotbar Editor", plugin); + + _host = gladiators; + _item = new ItemBuilder(Material.NAME_TAG).setTitle(C.cGold + "Hotbar Editor") + .addLore(C.cGray + "Right click to edit your Gladiators hotbar").build(); + + _pageListener = new HotbarPageListener(this); + getPluginManager().registerEvents(_pageListener, getPlugin()); + } + + @Override + public void disable() + { + HandlerList.unregisterAll(_pageListener); + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + if (_host.Manager.GetGame() != _host) + return; + + if (_host.GetState() == Game.GameState.Recruit || _host.GetState() == Game.GameState.Live) + { + event.getPlayer().getInventory().setItem(0, _item); + } + } + + @EventHandler + public void onDeath(final PlayerDeathEvent event) + { + Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() + { + public void run() + { + if (_host.IsLive()) + { + event.getEntity().getInventory().setItem(0, _item); + } + } + }); + } + + @EventHandler(priority = EventPriority.HIGH) + public void Observer(PlayerCommandPreprocessEvent event) + { + if (event.getMessage().equalsIgnoreCase("/spec")) + { + if (_host == null) + return; + + if (!_host.IsAlive(event.getPlayer()) + && !UtilInv.contains(event.getPlayer(), _item.getType(), (byte) 0, 1)) + { + event.getPlayer().getInventory().setItem(0, _item); + } + } + } + + @EventHandler + public void onJoin(GameStateChangeEvent event) + { + if (event.GetGame() != _host) + return; + + if (event.GetState() == Game.GameState.Recruit) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + player.getInventory().setItem(0, _item); + } + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (event.getAction() != Action.PHYSICAL && event.getAction().name().contains("RIGHT")) + { + ItemStack item = event.getItem(); + + if (item != null && item.isSimilar(_item)) + { + + HotbarInventory.open(event.getPlayer(), this); + } + } + } + + public Gladiators getHost() + { + return _host; + } + + public HotbarLayout getLayout(Player player) + { + int data = _host.Manager.getArcadePlayer(player).get("hotbar"); + data = (data == -1 ? 1239 : data); + + List ints = new ArrayList<>(); + for (int i : UtilMath.digits(data)) + ints.add(i - 1); + ints = Lists.reverse(ints); + + return new HotbarLayout(ints.get(0), ints.get(1), ints.get(2), ints.get(3)); + } + + public void saveLayout(Player player, Inventory inv) + { + List items = Arrays.asList(inv.getContents()); + ItemStack sword = null, rod = null, bow = null, arrows = null; + for (ItemStack i : items) + { + if (i == null || i.getType() == null) + continue; + + if (i.getType().equals(Material.DIAMOND_SWORD)) + sword = i; + else if (i.getType().equals(Material.FISHING_ROD)) + rod = i; + else if (i.getType().equals(Material.BOW)) + bow = i; + else if (i.getType().equals(Material.ARROW)) + arrows = i; + } + + HotbarLayout save = new HotbarLayout( + items.indexOf(sword) - 9, + items.indexOf(rod) - 9, + items.indexOf(bow) - 9, + items.indexOf(arrows) - 9 + ); + + if (save.getArrows() > 8 || save.getArrows() < 0) + { + save.setArrows(save.getEmpty()); + } + if (save.getBow() > 8 || save.getBow() < 0) + { + save.setBow(save.getEmpty()); + } + if (save.getSword() > 8 || save.getSword() < 0) + { + save.setSword(save.getEmpty()); + } + if (save.getRod() > 8 || save.getRod() < 0) + { + save.setRod(save.getEmpty()); + } + + _host.Manager.getArcadePlayer(player).put("hotbar", save.toDataSaveNumber(), true); + player.sendMessage(F.main("Game", "Saved new hotbar layout!")); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarInventory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarInventory.java new file mode 100644 index 000000000..9ffc569ae --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarInventory.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.gladiators.hotbar; + +import java.util.Arrays; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; + +/** + * Created by William (WilliamTiger). + * 18/12/15 + */ +public class HotbarInventory +{ + public static void open(Player player, HotbarEditor editor) + { + Inventory inv = UtilServer.getServer().createInventory(null, 36, "Hotbar Editor"); + + for (int slot : Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 18, 19, 20, 21, 22, 23, 24, 25, 26)) + { + inv.setItem(slot, getGlass(slot)); + } + + HotbarLayout layout = editor.getLayout(player); + + inv.setItem(layout.getSword() + 9, new ItemStack(Material.DIAMOND_SWORD, 1)); + inv.setItem(layout.getRod() + 9, new ItemStack(Material.FISHING_ROD, 1)); + inv.setItem(layout.getBow() + 9, new ItemStack(Material.BOW, 1)); + inv.setItem(layout.getArrows() + 9, new ItemStack(Material.ARROW, 1)); + + inv.setItem(30, new ItemBuilder(Material.EMERALD_BLOCK).setTitle(C.cGreen + C.Bold + "Save").setLore(C.cGray + "Click to save layout.").build()); + inv.setItem(32, new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cRed + C.Bold + "Cancel").setLore(C.cGray + "Click to cancel layout.").build()); + + player.openInventory(inv); + } + + private static ItemStack getGlass(int slot) + { + return new ItemBuilder(Material.STAINED_GLASS_PANE) + .setData((short) 15) + .setTitle((slot < 10 ? C.cAquaB + "⬇ Arrange Your Hotbar ⬇" : C.cAquaB + "⬆ Arrange Your Hotbar ⬆")) + .build(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java new file mode 100644 index 000000000..ad4d024be --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java @@ -0,0 +1,93 @@ +package nautilus.game.arcade.game.games.gladiators.hotbar; + +/** + * Created by William (WilliamTiger). + * 18/12/15 + */ +public class HotbarLayout +{ + private int sword; + private int rod; + private int bow; + private int arrows; + + public HotbarLayout(int sword, int rod, int bow, int arrows) + { + this.sword = sword; + this.rod = rod; + this.bow = bow; + this.arrows = arrows; + } + + public int getSword() + { + return sword; + } + + public int getRod() + { + return rod; + } + + public int getBow() + { + return bow; + } + + public int getArrows() + { + return arrows; + } + + public void setSword(int sword) + { + this.sword = sword; + } + + public void setRod(int rod) + { + this.rod = rod; + } + + public void setBow(int bow) + { + this.bow = bow; + } + + public void setArrows(int arrows) + { + this.arrows = arrows; + } + + public int toDataSaveNumber() + { + String str = ""; + str += (getSword() + 1); + str += (getRod() + 1); + str += (getBow() + 1); + str += (getArrows() + 1); + + System.out.println("sword = " + sword); + System.out.println("rod = " + rod); + System.out.println("bow = " + bow); + System.out.println("arrows = " + arrows); + System.out.println("string = " + str); + System.out.println("integer = " + Integer.parseInt(str)); + + + return Integer.parseInt(str); + } + + public int getEmpty() + { + for (int i = 0; i < 9; i++) + { + if (i == sword || i == rod || i == bow || i == arrows) + continue; + + return i; + } + + return 0; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java new file mode 100644 index 000000000..736de92df --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java @@ -0,0 +1,143 @@ +package nautilus.game.arcade.game.games.gladiators.hotbar; + +import org.bukkit.Material; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.PlayerInventory; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; + +/** + * Created by William (WilliamTiger). + * 18/12/15 + */ +public class HotbarPageListener implements Listener +{ + private HotbarEditor _editor; + + public HotbarPageListener(HotbarEditor editor) + { + _editor = editor; + } + + @EventHandler + public void onClick(InventoryClickEvent e) + { + if (!e.getInventory().getName().equals("Hotbar Editor")) + return; + + if (e.getCurrentItem() == null) + return; + + if (e.getAction().equals(InventoryAction.HOTBAR_SWAP) || e.getAction().equals(InventoryAction.HOTBAR_MOVE_AND_READD)){ + e.setCancelled(true); + return; + } + + if (e.getClick().isShiftClick()) + { + e.setCancelled(true); + return; + } + + System.out.println(e.getClickedInventory().getName() + " : " + e.getInventory().getName()); + + if (e.getCurrentItem().getType().equals(Material.REDSTONE_BLOCK)) + { + e.setCancelled(true); + e.getWhoClicked().closeInventory(); + return; + } + + if (e.getClickedInventory() instanceof PlayerInventory || e.getInventory() instanceof PlayerInventory){ + e.setCancelled(true); + return; + } + + if (e.getCurrentItem().getType().equals(Material.EMERALD_BLOCK)) + { + if (!e.getAction().equals(InventoryAction.PICKUP_ALL)){ + e.setCancelled(true); + return; + } + + e.setCancelled(true); + e.getWhoClicked().closeInventory(); + _editor.saveLayout(((Player) e.getWhoClicked()), e.getClickedInventory()); + return; + } + + if ((e.getSlot() < 9 || e.getSlot() > 17)) + { + e.setCancelled(true); + return; + } + + if (e.getCurrentItem().getType().equals(Material.STAINED_GLASS_PANE)) + { + e.setCancelled(true); + return; + } + + if (!(e.getAction().equals(InventoryAction.PICKUP_ONE) || e.getAction().equals(InventoryAction.PLACE_ONE))){ + + if (!(e.getSlot() > 8 && e.getSlot() < 18)) + { + e.setCancelled(true); + return; + } + + return; + } + +// if (e.getAction().equals(InventoryAction.PLACE_ALL) +// || e.getAction().equals(InventoryAction.PLACE_ONE) +// || e.getAction().equals(InventoryAction.PLACE_SOME)) +// { +// if (!(e.getSlot() > 8 && e.getSlot() < 18)) +// { +// e.setCancelled(true); +// return; +// } +// } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onDrop(PlayerDropItemEvent e){ + if (e.getPlayer().getOpenInventory() == null) + return; + + if (e.getPlayer().getOpenInventory().getTopInventory() == null) + return; + + if (!e.getPlayer().getOpenInventory().getTopInventory().getName().equals("Hotbar Editor")) + return; + + if (!e.isCancelled()) + return; + + e.setCancelled(false); + Item i = e.getItemDrop(); + Inventory inv = e.getPlayer().getOpenInventory().getTopInventory(); + + if (i.getItemStack().getType().equals(Material.EMERALD_BLOCK)) + inv.setItem(30, new ItemBuilder(Material.EMERALD_BLOCK).setTitle(C.cGreen + C.Bold + "Save").setLore(C.cGray + "Click to save layout.").build()); + else if (i.getItemStack().getType().equals(Material.REDSTONE_BLOCK)) + inv.setItem(32, new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cRed + C.Bold + "Cancel").setLore(C.cGray + "Click to cancel layout.").build()); + else + inv.addItem(i.getItemStack()); + + e.getPlayer().updateInventory(); + e.getPlayer().setItemOnCursor(null); + + i.remove(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/PrecisionTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/PrecisionTracker.java index 975e040be..b9856eedd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/PrecisionTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/PrecisionTracker.java @@ -1,16 +1,18 @@ package nautilus.game.arcade.game.games.gladiators.trackers; -import java.util.HashMap; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.ProjectileHitEvent; - +import java.util.List; +import java.util.UUID; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.gladiators.Gladiators; import nautilus.game.arcade.stats.StatTracker; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; /** * Created by William (WilliamTiger). @@ -18,15 +20,13 @@ import nautilus.game.arcade.stats.StatTracker; */ public class PrecisionTracker extends StatTracker { - private HashMap _shot; - private HashMap _hit; + private NautHashMap _current = new NautHashMap(); + private NautHashMap _shot = new NautHashMap(); + private NautHashMap _hit = new NautHashMap(); public PrecisionTracker(Gladiators game) { super(game); - - _shot = new HashMap<>(); - _hit = new HashMap<>(); } @EventHandler @@ -35,15 +35,15 @@ public class PrecisionTracker extends StatTracker if (e.GetState() != Game.GameState.End) return; - for (Player p : getGame().getWinners()) + List winners = getGame().getWinners(); + if (winners == null) + return; + + for (Player p : winners) { - if (_shot.containsKey(p.getName()) && _hit.containsKey(p.getName())) + if (getShot(p) == getHit(p) && getShot(p) >= 3) { - if (_shot.get(p.getName()) == _hit.get(p.getName())) - { - if (_shot.get(p.getName()) >= 3) - addStat(p, "Precision", 1, true, false); - } + addStat(p, "Precision", 1, true, false); } } } @@ -56,24 +56,30 @@ public class PrecisionTracker extends StatTracker Player p = (Player) e.getEntity(); - if (_shot.containsKey(p.getName())) - _shot.put(p.getName(), _shot.get(p.getName()) + 1); - else - _shot.put(p.getName(), 1); + _shot.put(p.getUniqueId(), getShot(p) + 1); + _current.put((Projectile) e.getProjectile(), p.getUniqueId()); } @EventHandler public void hit(ProjectileHitEvent e) { - if (e.getEntity().getShooter() instanceof Player) - { - Player p = (Player) e.getEntity().getShooter(); + if (!_current.containsKey(e.getEntity())) + return; - if (_hit.containsKey(p.getName())) - _hit.put(p.getName(), _hit.get(p.getName()) + 1); - else - _hit.put(p.getName(), 1); - } + Player player = UtilPlayer.searchExact(_current.remove(e.getEntity())); + if (player == null) + return; + + _hit.put(player.getUniqueId(), getHit(player) + 1); } + private int getShot(Player player) + { + return _shot.containsKey(player.getUniqueId()) ? _shot.get(player.getUniqueId()) : 0; + } + + private int getHit(Player player) + { + return _hit.containsKey(player.getUniqueId()) ? _hit.get(player.getUniqueId()) : 0; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/Gravity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/Gravity.java index f4b381560..6178db711 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/Gravity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/Gravity.java @@ -115,6 +115,11 @@ public class Gravity extends SoloGame this.CompassEnabled = true; this.WorldBoundaryKill = false; + + registerChatStats( + Kills, + Assists + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java index 2906a56e7..4ccc70136 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/Halloween.java @@ -38,6 +38,8 @@ import nautilus.game.arcade.game.games.halloween.waves.WaveBase; import nautilus.game.arcade.game.games.halloween.waves.WaveBoss; import nautilus.game.arcade.game.games.halloween.waves.WaveVictory; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; + import net.minecraft.server.v1_8_R3.PacketPlayOutNamedSoundEffect; import org.bukkit.ChatColor; @@ -135,6 +137,13 @@ public class Halloween extends SoloGame this.WorldBoundaryKill = false; this.DontAllowOverfill = true; + + registerChatStats( + DamageDealt, + DamageTaken, + BlankLine, + new ChatStatData("kit", "Kit", true) + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java index e4652e638..f360e190a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java @@ -341,8 +341,16 @@ public class HideSeek extends TeamGame Manager.GetExplosion().SetTNTSpread(false); Manager.getCosmeticManager().setHideParticles(true); - registerStatTrackers(new HunterKillerStatTracker(this), new MeowStatTracker(this), new HunterKillerStatTracker(this), - new HunterOfTheYearStatTracker(this), new BadHiderStatTracker(this)); + registerStatTrackers( + new HunterKillerStatTracker(this), + new MeowStatTracker(this), + new HunterKillerStatTracker(this), + new HunterOfTheYearStatTracker(this), + new BadHiderStatTracker(this) + ); + + //Need ideas for this one + registerChatStats(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/holeinwall/HoleInTheWall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/holeinwall/HoleInTheWall.java index 63e30ce89..29abe0ef7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/holeinwall/HoleInTheWall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/holeinwall/HoleInTheWall.java @@ -57,6 +57,8 @@ public class HoleInTheWall extends SoloGame DamageFall = false; HungerSet = 20; WorldTimeSet = 8000; + + registerChatStats(); } private ArrayList> getWall() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/horsecharge/Horse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/horsecharge/Horse.java index ee3c1e223..a8f4ecab5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/horsecharge/Horse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/horsecharge/Horse.java @@ -18,23 +18,25 @@ public class Horse extends TeamGame { super(manager, GameType.Horse, - new Kit[] - { - new KitHorseKnight(manager), - new NullKit(manager), - new KitDefenceArcher(manager), - }, + new Kit[] + { + new KitHorseKnight(manager), + new NullKit(manager), + new KitDefenceArcher(manager), + }, - new String[] - { - "Horsemen must charge the ruins", - "Horsemen win if they rid the ruins of Undead.", - "", - "Undead must defend the ruins", - "Undead win when all Horsemen are dead.", - "", - "Teams swap after game is over" - }); + new String[] + { + "Horsemen must charge the ruins", + "Horsemen win if they rid the ruins of Undead.", + "", + "Undead must defend the ruins", + "Undead win when all Horsemen are dead.", + "", + "Teams swap after game is over" + }); + + registerChatStats(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java index 2e519edc8..93d9bb2bd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/lobbers/BombLobbers.java @@ -42,6 +42,7 @@ import nautilus.game.arcade.game.games.lobbers.trackers.TrackerDirectHit; import nautilus.game.arcade.game.games.lobbers.trackers.TrackerNoDamage; import nautilus.game.arcade.game.games.lobbers.trackers.TrackerTNTThrown; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -74,19 +75,23 @@ public class BombLobbers extends TeamGame implements IThrown @SuppressWarnings("unchecked") public BombLobbers(ArcadeManager manager) { - super(manager, GameType.Lobbers, new Kit[] - { - new KitJumper(manager), - new KitArmorer(manager), - new KitPitcher(manager), - new KitWaller(manager) - }, new String[] - { - "Fight against your enemies using", - "the power of explosives!", - "Left click TNT to throw at your enemy.", - "Last team alive wins!" - }); + super(manager, GameType.Lobbers, + new Kit[] + { + new KitJumper(manager), + new KitArmorer(manager), + new KitPitcher(manager), + new KitWaller(manager) + }, + + new String[] + { + "Fight against your enemies using", + "the power of explosives!", + "Left click TNT to throw at your enemy.", + "Last team alive wins!" + }); + DamageFall = true; DamageEvP = true; @@ -110,7 +115,21 @@ public class BombLobbers extends TeamGame implements IThrown WorldTimeSet = 6000; - registerStatTrackers(new Tracker6Kill(this), new TrackerBlastProof(this), new TrackerNoDamage(this), new TrackerTNTThrown(this), new TrackerDirectHit(this)); + registerStatTrackers( + new Tracker6Kill(this), + new TrackerBlastProof(this), + new TrackerNoDamage(this), + new TrackerTNTThrown(this), + new TrackerDirectHit(this) + ); + + registerChatStats( + Kills, + Assists, + DamageTaken, + BlankLine, + new ChatStatData("Thrown", "Bombs Lobbed", true) + ); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/Micro.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/Micro.java index 5deda46b0..3fea362b0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/Micro.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/Micro.java @@ -22,6 +22,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.micro.kits.*; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.KillsWithinGameStatTracker; public class Micro extends TeamGame @@ -58,7 +59,17 @@ public class Micro extends TeamGame this.BlockBreak = true; this.BlockPlace = true; - registerStatTrackers(new KillsWithinGameStatTracker(this, 8, "Annihilation")); + registerStatTrackers( + new KillsWithinGameStatTracker(this, 8, "Annihilation") + ); + + registerChatStats( + Kills, + Assists, + BlankLine, + DamageTaken, + DamageDealt + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java index ac0054a2e..d4c95961f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java @@ -74,29 +74,33 @@ public class MilkCow extends SoloGame super(manager, GameType.MilkCow, new Kit[] - { - new KitFarmerJump(manager), - new KitSturdyFarmhand(manager), - new NullKit(manager), - new KitCow(manager), - }, + { + new KitFarmerJump(manager), + new KitSturdyFarmhand(manager), + new NullKit(manager), + new KitCow(manager), + }, - new String[] - { - "Farmers get 1 point for drinking milk.", - "You lose 5 points for dying!", - "", - "Cows get 1 point for killing farmers.", - "Defend your herd to stop farmers!", - "", - "First player to 15 points wins!" - }); + new String[] + { + "Farmers get 1 point for drinking milk.", + "You lose 5 points for dying!", + "", + "Cows get 1 point for killing farmers.", + "Defend your herd to stop farmers!", + "", + "First player to 15 points wins!" + }); this.CompassEnabled = true; this.DeathOut = false; _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Milk", "dummy"); _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); + + registerChatStats( + Kills + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java index 1024a5338..c4cbf7053 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java @@ -104,6 +104,7 @@ import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats; import nautilus.game.arcade.game.games.minestrike.items.guns.GunType; import nautilus.game.arcade.game.games.minestrike.kits.KitPlayer; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.KaboomStatTracker; import nautilus.game.arcade.stats.KillAllOpposingMineStrikeRoundStatTracker; import nautilus.game.arcade.stats.KillFastStatTracker; @@ -243,57 +244,57 @@ public class MineStrike extends TeamGame { super(manager, GameType.MineStrike, - new Kit[] - { - new KitPlayer(manager), + new Kit[] + { + new KitPlayer(manager), }, - new String[] - { - C.cAqua + "SWAT" + C.cWhite + " Defend the Bomb Sites", - C.cAqua + "SWAT" + C.cWhite + " Kill the Bombers", - " ", - C.cRed + "Bombers" + C.cWhite + " Plant the Bomb at Bomb Site", - C.cRed + "Bombers" + C.cWhite + " Kill the SWAT Team", - }); + new String[] + { + C.cAqua + "SWAT" + C.cWhite + " Defend the Bomb Sites", + C.cAqua + "SWAT" + C.cWhite + " Kill the Bombers", + " ", + C.cRed + "Bombers" + C.cWhite + " Plant the Bomb at Bomb Site", + C.cRed + "Bombers" + C.cWhite + " Kill the SWAT Team", + }); _shopManager = new ShopManager(this); this.StrictAntiHack = true; - + AnnounceStay = false; - + this.HungerSet = 20; this.ItemDrop = true; this.DeathTeleport = false; - + this.InventoryClick = true; this.JoinInProgress = true; - + this.DontAllowOverfill = true; _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("HP", "dummy"); _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); - - this._help = new String[] + + this._help = new String[] { - //"Tap Crouch when close to an ally to Boost", - "Open Inventory at spawn to buy guns", - "Hold Right-Click to Plant Bomb", - "Look at the Bomb to Defuse it", - "Moving decreases accuracy", - "Sprinting heavily decreases accuracy", - "Jumping massively decreases accuracy", - "Crouching increases accuracy", - "Left-Click to drop Grenades", - "Right-Click to throw Grenades", - "Burst Fire for greater accuracy", - "Sniper Rifles are only accurate while scoped", - "Rifles have 30% recoil reduction while scoped", - "Pick up better weapons from dead players" + //"Tap Crouch when close to an ally to Boost", + "Open Inventory at spawn to buy guns", + "Hold Right-Click to Plant Bomb", + "Look at the Bomb to Defuse it", + "Moving decreases accuracy", + "Sprinting heavily decreases accuracy", + "Jumping massively decreases accuracy", + "Crouching increases accuracy", + "Left-Click to drop Grenades", + "Right-Click to throw Grenades", + "Burst Fire for greater accuracy", + "Sniper Rifles are only accurate while scoped", + "Rifles have 30% recoil reduction while scoped", + "Pick up better weapons from dead players" }; registerStatTrackers( @@ -304,10 +305,19 @@ public class MineStrike extends TeamGame new MineStrikeLastAliveKillStatTracker(this), new KillFastStatTracker(this, 4, 5, "KillingSpree"), new KillsWithConditionStatTracker(this, "Blindfolded", ConditionType.BLINDNESS, "Flash Bang", 2), - + new TeamDeathsStatTracker(this), new TeamKillsStatTracker(this) ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + new ChatStatData("BoomHeadshot", "Headshots", true), + Assists + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java index 1634b5c6c..ca74c8d3a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java @@ -84,6 +84,8 @@ public class MineWare extends SoloGame Manager.GetCreature().SetDisableCustomDrops(true); PopulateOrders(); + + registerChatStats(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 59f55652b..3879c4b3b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -31,6 +31,8 @@ public class Moba extends TeamGame this.DeathSpectateSecs = 8; this.HungerSet = 20; + + registerChatStats(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/MonsterLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/MonsterLeague.java index adc100bb1..bc413c4da 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/MonsterLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/MonsterLeague.java @@ -63,6 +63,8 @@ public class MonsterLeague extends TeamGame this.TeamArmor = true; this.TeamArmorHotbar = true; + + registerChatStats(); } //Supports anywhere from 2-4 teams on a map diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/MonsterMaze.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/MonsterMaze.java index 1a7128081..d52c5039b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/MonsterMaze.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monstermaze/MonsterMaze.java @@ -33,6 +33,7 @@ import nautilus.game.arcade.game.games.monstermaze.trackers.PilotTracker; import nautilus.game.arcade.game.games.monstermaze.trackers.SnowmanHitTracker; import nautilus.game.arcade.game.games.monstermaze.trackers.SurvivePast10thSafepadTracker; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import org.bukkit.Bukkit; import org.bukkit.Effect; @@ -101,6 +102,13 @@ public class MonsterMaze extends SoloGame new SurvivePast10thSafepadTracker(this) ); //_maze = new SnowmanMaze(this, WorldData.GetDataLocs("GRAY")/*, WorldData.GetCustomLocs("103")*/); + + registerChatStats(//first to beacon + new ChatStatData("Ninja", "Times Hit", true), + new ChatStatData("Speed", "First to safe pad", true), + BlankLine, + new ChatStatData("kit", "Kit", true) + ); } public Maze getMaze() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/oldmineware/OldMineWare.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/oldmineware/OldMineWare.java index 919e9de19..e127ed2aa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/oldmineware/OldMineWare.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/oldmineware/OldMineWare.java @@ -88,6 +88,8 @@ public class OldMineWare extends SoloGame InventoryClick = true; PopulateOrders(); + + registerChatStats(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java index f509b43dd..5f4d7b2b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java @@ -114,6 +114,16 @@ public class Paintball extends TeamGame new WinFastStatTracker(this, 30, "Speedrunner"), new LastStandStatTracker(this) ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageTaken, + DamageDealt + ); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java index 731d049e4..e3a2bf311 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java @@ -92,6 +92,16 @@ public class Quiver extends SoloGame new SharpShooterStatTracker(this), new WinWithoutBowStatTracker(this, "WhatsABow") ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageTaken, + DamageDealt + ); } @EventHandler(priority = EventPriority.HIGH) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java index 2d871d801..4626d4f24 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java @@ -65,6 +65,16 @@ public class QuiverTeams extends TeamGame this.TeamArmor = true; this.TeamArmorHotbar = true; + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageTaken, + DamageDealt + ); } @EventHandler(priority = EventPriority.HIGH) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/runner/Runner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/runner/Runner.java index 1cd250deb..10f901cd1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/runner/Runner.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/runner/Runner.java @@ -32,6 +32,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.runner.kits.*; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.DistanceTraveledStatTracker; import net.minecraft.server.v1_8_R3.EntityArrow; @@ -66,6 +67,12 @@ public class Runner extends SoloGame implements IThrown this.PrepareFreeze = false; registerStatTrackers(new DistanceTraveledStatTracker(this, "MarathonRunner")); + + registerChatStats( + new ChatStatData("MarathonRunner", "Distance ran", true), + BlankLine, + new ChatStatData("kit", "Kit", true) + ); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java index e4005cf25..ebb419815 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java @@ -72,6 +72,11 @@ public class SearchAndDestroy extends TeamGame DamageSelf = false; Manager.GetDamage().GetCombatManager().setUseWeaponName(AttackReason.DefaultWeaponName); + + registerChatStats( + Kills, + Assists + ); } public ArrayList getBombs() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java index 5a0457a8d..09c03515c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/SheepGame.java @@ -53,6 +53,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.sheep.kits.*; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.SheepDropStatTracker; import nautilus.game.arcade.stats.SheepThiefStatTracker; import nautilus.game.arcade.stats.WinWithSheepStatTracker; @@ -155,6 +156,15 @@ public class SheepGame extends TeamGame new SheepDropStatTracker(this), new WinWithSheepStatTracker(this) ); + + registerChatStats( + new ChatStatData("AnimalRescue", "Captures", true), + new ChatStatData("Thief", "Stolen", true), + BlankLine, + Kills, + Deaths, + KDRatio + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java index 835afefc4..70cb11fd8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java @@ -46,6 +46,7 @@ import nautilus.game.arcade.game.games.skywars.kits.KitDestructor; import nautilus.game.arcade.game.games.skywars.kits.KitMiner; import nautilus.game.arcade.game.games.skywars.kits.KitMadScientist; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.ore.OreHider; import nautilus.game.arcade.stats.DeathBomberStatTracker; import nautilus.game.arcade.stats.SkywarsKillZombieStatTracker; @@ -204,6 +205,16 @@ public abstract class Skywars extends Game new WinWithoutOpeningChestStatTracker(this), new WinWithoutWearingArmorStatTracker(this)); + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageTaken, + DamageDealt + ); + } public void ParseData() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java index b9ba7a26b..c8c1a5082 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java @@ -16,6 +16,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.managers.chat.ChatStatData; public class SoloSuperSmash extends SuperSmash { @@ -32,6 +33,18 @@ public class SoloSuperSmash extends SuperSmash }); this.DamageTeamSelf = true; + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageTaken, + DamageDealt, + BlankLine, + new ChatStatData("kit", "Kit", true) + ); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmashDominate.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmashDominate.java index bf643a201..9c74d0c25 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmashDominate.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmashDominate.java @@ -24,7 +24,8 @@ import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.common.Domination; import nautilus.game.arcade.game.games.smash.kits.*; import nautilus.game.arcade.kit.Kit; - +import nautilus.game.arcade.managers.chat.ChatStatData; + public class SuperSmashDominate extends Domination { public SuperSmashDominate(ArcadeManager manager) @@ -55,6 +56,18 @@ public class SuperSmashDominate extends Domination new KitMagmaCube(manager), }); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageTaken, + DamageDealt, + BlankLine, + new ChatStatData("kit", "Kit", true) + ); } @EventHandler(priority = EventPriority.LOWEST) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java index 2ffd3f82d..8ae71d3b9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java @@ -15,6 +15,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.managers.chat.ChatStatData; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -53,6 +54,18 @@ public class TeamSuperSmash extends SuperSmash this.TeamArmorHotbar = true; this.DontAllowOverfill = true; + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageTaken, + DamageDealt, + BlankLine, + new ChatStatData("kit", "Kit", true) + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java index 06b78a82e..0a403c85e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSkySquid.java @@ -38,7 +38,7 @@ public class KitSkySquid extends SmashKit new PerkSmashStats(6, 1.5, 0.25, 5), new PerkDoubleJump("Double Jump", 0.9, 0.9, false), new PerkSuperSquid(), - new PerkInkBlast(), + new PerkInkBlast(7, 2), new PerkFishFlurry(), new PerkStormSquid() }, @@ -56,7 +56,7 @@ public class KitSkySquid extends SmashKit C.cYellow + C.Bold + "Right-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Ink Shotgun", new String[] { - ChatColor.RESET + "Blasts 6 ink pellets out at high velocity.", + ChatColor.RESET + "Blasts 7 ink pellets out at high velocity.", ChatColor.RESET + "They explode upon hitting something, dealing", ChatColor.RESET + "damage and knockback.", })); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snake/Snake.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snake/Snake.java index 9a289d7b5..4fc2b6043 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snake/Snake.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snake/Snake.java @@ -56,6 +56,7 @@ import nautilus.game.arcade.game.games.snake.kits.KitInvulnerable; import nautilus.game.arcade.game.games.snake.kits.KitReverser; import nautilus.game.arcade.game.games.snake.kits.KitSpeed; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.ChooChooStatTracker; import nautilus.game.arcade.stats.KillsWithinGameStatTracker; import nautilus.game.arcade.stats.SlimySheepStatTracker; @@ -157,6 +158,15 @@ public class Snake extends SoloGame new ChooChooStatTracker(this), new SlimySheepStatTracker(this) ); + + registerChatStats(//slimes eaten, kills, length + new ChatStatData("Cannibal", "Kills", true), + BlankLine, + new ChatStatData("ChooChoo", "Tail Length", true), + new ChatStatData("SlimySheep", "Slimes Eaten", true), + BlankLine, + new ChatStatData("kit", "Kit", true) + ); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java index 474567032..0c19539cf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java @@ -92,6 +92,14 @@ public class SneakyAssassins extends SoloGame new RevealStatTracker(this, "ISeeYou"), _killEntityStatTracker ); + + registerChatStats(//assists + Kills, + Assists, + BlankLine, + DamageTaken, + DamageDealt + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java index cb278885d..9aaf3396d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java @@ -104,6 +104,14 @@ public class SnowFight extends TeamGame this.TeamArmor = true; this.TeamArmorHotbar = true; + + registerChatStats(//damage, collected + Kills, + Assists, + BlankLine, + DamageTaken, + DamageDealt + ); // this.WorldWeatherEnabled = true; // this.WorldTimeSet = 4000; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java new file mode 100644 index 000000000..34a82c937 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java @@ -0,0 +1,1747 @@ +package nautilus.game.arcade.game.games.speedbuilders; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map.Entry; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguiseGuardian; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.speedbuilders.data.BuildData; +import nautilus.game.arcade.game.games.speedbuilders.data.DemolitionData; +import nautilus.game.arcade.game.games.speedbuilders.data.MobData; +import nautilus.game.arcade.game.games.speedbuilders.data.RecreationData; +import nautilus.game.arcade.game.games.speedbuilders.events.PerfectBuildEvent; +import nautilus.game.arcade.game.games.speedbuilders.kits.DefaultKit; +import nautilus.game.arcade.game.games.speedbuilders.stattrackers.DependableTracker; +import nautilus.game.arcade.game.games.speedbuilders.stattrackers.FirstBuildTracker; +import nautilus.game.arcade.game.games.speedbuilders.stattrackers.PerfectionistTracker; +import nautilus.game.arcade.game.games.speedbuilders.stattrackers.SpeediestBuilderizerTracker; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; +import nautilus.game.arcade.stats.BlockPlaceStatTracker; + +import net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockGrowEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.ItemMergeEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerBucketFillEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.world.StructureGrowEvent; +import org.bukkit.material.Bed; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; + +public class SpeedBuilders extends SoloGame +{ + private static final String GUARDIAN_NAME = "Gwen the Guardian"; + + //Build Size and some other values used commonly + public int BuildSize = 7; + public int BuildSizeDiv2 = BuildSize / 2; + public int BuildSizeMin1 = BuildSize - 1; + public int BuildSizePow3 = BuildSize * BuildSize * BuildSize; + + public boolean InstaBreak = true; + + private SpeedBuildersState _state = SpeedBuildersState.VIEWING; + private long _stateTime = System.currentTimeMillis(); + + private int _roundsPlayed; + + private int _buildCountStage; + private int _viewCountStage; + + private int _buildTimeTracker = 40; + private int _buildTime = 40; + private int _viewTime = 10; + + private Location _buildMiddle; + + private ArrayList _buildData = new ArrayList(); + private ArrayList _usedBuilds = new ArrayList<>(); + private BuildData _currentBuild; + + private BlockState[][] _defaultMiddleGround = new BlockState[BuildSize][BuildSize]; + private ArrayList _middleMobs = new ArrayList(); + + private NautHashMap _buildRecreations = new NautHashMap(); + + private ArmorStand _judgeEntity; + private DisguiseGuardian _judgeDisguise; + private Location _judgeSpawn; + private ArmorStand _judgeLaserTarget; + + private ArrayList _toEliminate = new ArrayList(); + private long _lastElimination; + private boolean _eliminating; + // Track the time we switch to review so we can give players 8 seconds to look around + private long _reviewStartTime; + + private NautHashMap _perfectBuild = new NautHashMap(); + private boolean _allPerfect; + + private Location _lookTarget; + private ArmorStand _lookStand; + private long _targetReached; + private long _stayTime; + private RecreationData _lastRecreationTarget; + private double _standMoveProgress; + private Location _standStart; + + private BuildData _nextBuild; + + public SpeedBuilders(ArcadeManager manager) + { + super(manager, GameType.SpeedBuilders, + new Kit[] + { + new DefaultKit(manager) + }, + new String[] + { + "Recreate the build shown to you.", + "The least correct build is eliminated.", + "Last person left wins!" + }); + + Damage = false; + + HungerSet = 20; + HealthSet = 20; + + DontAllowOverfill = true; + + DeathMessages = false; + + FixSpawnFacing = false; + + AllowParticles = false; + + InventoryClick = true; + + registerStatTrackers( + new DependableTracker(this), + new FirstBuildTracker(this), + new PerfectionistTracker(this), + new SpeediestBuilderizerTracker(this), + new BlockPlaceStatTracker(this, new Material[] {}) + ); + + registerChatStats( + new ChatStatData("BlocksPlaced", "Blocks Placed", true), + new ChatStatData("BlocksBroken", "Blocks Broken", true) + ); + } + + @Override + public void ParseData() + { + _buildMiddle = WorldData.GetDataLocs("RED").get(0).clone().subtract(0.5, 0, 0.5); + + _judgeSpawn = _buildMiddle.clone().add(0.5, BuildSize, 0.5); + + Location groundMin = _buildMiddle.clone().subtract(BuildSizeDiv2, 1, BuildSizeDiv2); + + for (int x = 0; x < BuildSize; x++) + { + for (int z = 0; z < BuildSize; z++) + { + _defaultMiddleGround[x][z] = groundMin.clone().add(x, 0, z).getBlock().getState(); + } + } + + for (Entry> entry : WorldData.GetAllCustomLocs().entrySet()) + { + BuildData buildData = new BuildData(entry.getValue().get(0).clone().subtract(0.5, 0, 0.5), ChatColor.translateAlternateColorCodes('&', entry.getKey()), this); + boolean add = false; + for (int x = 0; x < BuildSize && !add; x++) + { + for (int y = 0; y < BuildSize && !add; y++) + { + for (int z = 0; z < BuildSize && !add; z++) + { + if (buildData.Build[x][y][z] != null && buildData.Build[x][y][z].getType() != Material.AIR) + add = true; + } + } + } + + if (!buildData.Mobs.isEmpty()) + add = true; + + if (add) + _buildData.add(buildData); + } + + for (Location loc : WorldData.GetDataLocs("YELLOW")) + { + loc.subtract(0.5, 0, 0.5); + } + + for (Location loc : GetTeamList().get(0).GetSpawns()) + { + loc.setDirection(UtilAlg.getTrajectory(loc, _buildMiddle.clone().add(0.5, 0, 0.5))); + } + } + + public void setSpeedBuilderState(SpeedBuildersState state) + { + _state = state; + _stateTime = System.currentTimeMillis(); + } + + public SpeedBuildersState getSpeedBuilderState() + { + return _state; + } + + public long getSpeedBuilderStateTime() + { + return _stateTime; + } + + public int getRoundsPlayed() + { + return _roundsPlayed; + } + + public void clearCenterArea(boolean resetGround) + { + Location buildMin = _buildMiddle.clone().subtract(BuildSizeDiv2, 0, BuildSizeDiv2); + Location buildMax = _buildMiddle.clone().add(BuildSizeDiv2, BuildSizeMin1, BuildSizeDiv2); + + for (Block block : UtilBlock.getInBoundingBox(buildMin, buildMax)) + { + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR); + } + + for (Entity entity : _middleMobs) + { + entity.remove(); + } + + _middleMobs.clear(); + + if (resetGround) + { + for (int x = 0; x < BuildSize; x++) + { + for (int z = 0; z < BuildSize; z++) + { + MapUtil.QuickChangeBlockAt(buildMin.clone().add(x, -1, z), _defaultMiddleGround[x][z].getType(), _defaultMiddleGround[x][z].getRawData()); + } + } + } + } + + public void pasteBuildInCenter(BuildData buildData) + { + clearCenterArea(true); + + Location groundMin = _buildMiddle.clone().subtract(BuildSizeDiv2, 1, BuildSizeDiv2); + + for (int x = 0; x < BuildSize; x++) + { + for (int z = 0; z < BuildSize; z++) + { + MapUtil.QuickChangeBlockAt(groundMin.clone().add(x, 0, z), buildData.Ground[x][z].getType(), buildData.Ground[x][z].getRawData()); + } + } + + Location buildMin = _buildMiddle.clone().subtract(BuildSizeDiv2, 0, BuildSizeDiv2); + + for (int x = 0; x < BuildSize; x++) + { + for (int y = 0; y < BuildSize; y++) + { + for (int z = 0; z < BuildSize; z++) + { + MapUtil.QuickChangeBlockAt(buildMin.clone().add(x, y, z), buildData.Build[x][y][z].getType(), buildData.Build[x][y][z].getRawData()); + } + } + } + + CreatureAllowOverride = true; + + for (MobData mobData : buildData.Mobs) + { + Location loc = buildMin.clone().add(mobData.DX + 0.5, mobData.DY, mobData.DZ + 0.5); + + Entity entity = loc.getWorld().spawnEntity(loc, mobData.EntityType); + + UtilEnt.Vegetate(entity, true); + UtilEnt.ghost(entity, true, false); + + _middleMobs.add(entity); + } + + CreatureAllowOverride = false; + } + + public void spawnJudge() + { + CreatureAllowOverride = true; + + _judgeEntity = _judgeSpawn.getWorld().spawn(_judgeSpawn, ArmorStand.class); + + CreatureAllowOverride = false; + + _judgeEntity.setVisible(false); + _judgeEntity.setGravity(false); + _judgeEntity.setSmall(true); + + _judgeDisguise = new DisguiseGuardian(_judgeEntity); + + _judgeDisguise.setElder(true); + _judgeDisguise.setCustomNameVisible(true); + _judgeDisguise.setName(GUARDIAN_NAME); + + Manager.GetDisguise().disguise(_judgeDisguise); + } + + public void despawnJudge() + { + Manager.GetDisguise().undisguise(_judgeEntity); + + _judgeEntity.remove(); + + _judgeDisguise = null; + _judgeEntity = null; + } + + public void judgeTargetLocation(Location loc) + { + if (loc == null) + { + if (_judgeLaserTarget == null) + return; + + _judgeLaserTarget.remove(); + + _judgeLaserTarget = null; + + _judgeDisguise.setTarget(0); + + Manager.GetDisguise().updateDisguise(_judgeDisguise); + } + else + { + if (_judgeLaserTarget != null) + judgeTargetLocation(null); + + CreatureAllowOverride = true; + + _judgeLaserTarget = _judgeEntity.getWorld().spawn(loc, ArmorStand.class); + + CreatureAllowOverride = false; + + _judgeLaserTarget.setVisible(false); + _judgeLaserTarget.setGravity(false); + _judgeLaserTarget.setSmall(true); + + UtilEnt.CreatureLook(_judgeEntity, _judgeLaserTarget.getLocation()); + + _judgeDisguise.setTarget(_judgeLaserTarget.getEntityId()); + + Manager.GetDisguise().updateDisguise(_judgeDisguise); + } + } + + public void moveToGuardians(Player player, boolean elimination) + { + if (elimination) + { + GetTeamList().get(0).SetPlacement(player, PlayerState.OUT); + GetTeamList().get(0).RemovePlayer(player); + } + + GetTeamList().get(1).AddPlayer(player, true); + + DisguiseGuardian disguise = new DisguiseGuardian(player); + disguise.setName(C.cGray + player.getName()); + disguise.setCustomNameVisible(true); + + Manager.GetDisguise().disguise(disguise); + + player.setGameMode(GameMode.SURVIVAL); + + player.setAllowFlight(true); + player.setFlying(true); + + EndCheck(); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void teamGen(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + return; + + //Add 1 spawn so it doesn't freak out + ArrayList spawns = new ArrayList(); + spawns.add(GetSpectatorLocation()); + + GameTeam guardians = new GameTeam(this, "Guardians", ChatColor.GRAY, spawns); + + AddTeam(guardians); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPrepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + return; + + spawnJudge(); + //GUARDIAN LAZORZ WILL ROXORZ YOUR BOXORZ + + ArrayList players = GetPlayers(true); + + for (int i = 0; i < players.size(); i++) + { + if (i >= WorldData.GetDataLocs("YELLOW").size()) + { + Manager.addSpectator(players.get(i), true); + GetTeamList().get(0).RemovePlayer(players.get(i)); + } + } + } + + @EventHandler + public void onLive(GameStateChangeEvent event) + { + if (!IsLive()) + return; + + if (WorldData.GetDataLocs("YELLOW").size() < GetPlayers(true).size()) + { + Announce(C.Bold + "Too many players..."); + SetState(GameState.End); + return; + } + + if (_nextBuild != null) + _currentBuild = _nextBuild; + else + _currentBuild = UtilAlg.Random(_buildData, _usedBuilds); + + _nextBuild = null; + _usedBuilds.add(_currentBuild); + _buildTime = _currentBuild.getBuildTime(_buildTimeTracker); + + HashSet usedBuildLocs = new HashSet(); + + for (Player player : GetPlayers(true)) + { + Location buildLoc = UtilAlg.findClosest(player.getLocation(), WorldData.GetDataLocs("YELLOW")); + Location spawnLoc = UtilAlg.findClosest(buildLoc, GetTeamList().get(0).GetSpawns()); + + _buildRecreations.put(player, new RecreationData(this, player, buildLoc, spawnLoc)); + + _buildRecreations.get(player).pasteBuildData(_currentBuild); + + usedBuildLocs.add(buildLoc); + } + + for (Location loc : WorldData.GetDataLocs("YELLOW")) + { + if (!usedBuildLocs.contains(loc)) + { + HashSet blocks = UtilBlock.findConnectedBlocks(loc.getBlock(), loc.getBlock(), null, 2000, 8); + + Manager.GetExplosion().BlockExplosion(blocks, loc, false, true); + } + } + + for (Player player : GetTeamList().get(0).GetPlayers(true)) + { + UtilPlayer.message(player, F.main("Build", "Recreate the build shown.")); + } + + UtilTextMiddle.display("", C.cGold + _currentBuild.BuildText, 0, 80, 10); + + _roundsPlayed++; + + setSpeedBuilderState(SpeedBuildersState.VIEWING); + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) + { + if (GetTeamList().size() > 1 && GetTeamList().get(1).HasPlayer(event.getPlayer())) + GetTeamList().get(1).RemovePlayer(event.getPlayer()); + + RecreationData recreation = null; + + if (_buildRecreations.containsKey(event.getPlayer())) + recreation = _buildRecreations.remove(event.getPlayer()); + + if (recreation != null) + { + HashSet blocks = UtilBlock.findConnectedBlocks(recreation.OriginalBuildLocation.getBlock(), recreation.OriginalBuildLocation.getBlock(), null, 2000, 8); + + //Sets should remove duplicates + blocks.addAll(recreation.getBlocks()); + + Manager.GetExplosion().BlockExplosion(blocks, recreation.getMidpoint(), false, true); + + recreation.clearBuildArea(false); + + if (_toEliminate.contains(recreation)) + _toEliminate.remove(recreation); + } + } + + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) + { + if (_state != SpeedBuildersState.BUILDING) + return; + + if (!_buildRecreations.containsKey(event.getPlayer())) + return; + + if (_perfectBuild.containsKey(event.getPlayer())) + { + event.setCancelled(true); + return; + } + + if (_buildRecreations.get(event.getPlayer()).isQueuedForDemolition(event.getBlock())) + { + event.setCancelled(true); + return; + } + + if (_buildRecreations.get(event.getPlayer()).inBuildArea(event.getBlock()) && event.getBlock().getType() != Material.BED_BLOCK) + return; + else if (event.getBlock().getType() == Material.BED_BLOCK) + { + Bed bed = (Bed) event.getBlock().getState().getData(); + + if (bed.isHeadOfBed()) + { + Block foot = event.getBlock().getRelative(bed.getFacing().getOppositeFace()); + + if (_buildRecreations.get(event.getPlayer()).inBuildArea(foot)) + return; + } + else + { + Block head = event.getBlock().getRelative(bed.getFacing()); + + if (_buildRecreations.get(event.getPlayer()).inBuildArea(head)) + return; + } + } + + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Build", "Cannot build outside your area!")); + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onBuildFinish(final BlockPlaceEvent event) + { + checkPerfectBuild(event.getPlayer()); + } + + //This is here because if you open a door then close it you won't be informed of a perfect build + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void interactInformSuccess(PlayerInteractEvent event) + { + checkPerfectBuild(event.getPlayer()); + } + + public void checkPerfectBuild(Player player) + { + if (_perfectBuild.containsKey(player)) + return; + + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + if (!IsLive()) + return; + + if (_state != SpeedBuildersState.BUILDING) + return; + + if (!_buildRecreations.containsKey(player)) + return; + + if (_perfectBuild.containsKey(player)) + return; + + if (_buildRecreations.get(player).calculateScoreFromBuild(_currentBuild) == _currentBuild.getPerfectScore()) + { + long timeElapsed = System.currentTimeMillis() - _stateTime; + PerfectBuildEvent perfectBuildEvent = new PerfectBuildEvent(player, timeElapsed, SpeedBuilders.this); + + Bukkit.getServer().getPluginManager().callEvent(perfectBuildEvent); + + player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 10F, 1F); + + String time = UtilTime.convertString(timeElapsed, 1, UtilTime.TimeUnit.SECONDS); + Announce(F.main("Build", F.name(player.getName()) + " got a perfect build in " + F.time(time) + "!")); + + _perfectBuild.put(player, System.currentTimeMillis()); + + if (_perfectBuild.size() == GetTeamList().get(0).GetPlayers(false).size()) + { + // Everyone has a perfect build + _allPerfect = true; + } + else + { + // Don't display middle text if everyone now has a perfect build + UtilTextMiddle.display("", C.cGreen + "Perfect Match", 0, 30, 10, player); + } + } + } + }, 1L); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPlayerPickupItem(PlayerPickupItemEvent event) + { + if (_state != SpeedBuildersState.BUILDING) + return; + + if (!_buildRecreations.containsKey(event.getPlayer())) + return; + + if (_buildRecreations.get(event.getPlayer()).DroppedItems.containsKey(event.getItem())) + _buildRecreations.get(event.getPlayer()).DroppedItems.remove(event.getItem()); + else + event.setCancelled(true); + } + + @EventHandler + public void stopItemMerge(ItemMergeEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void stopMoveOffArea(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (!IsLive()) + return; + + for (Player player : GetPlayers(true)) + { + if (!_buildRecreations.containsKey(player)) + continue; + + RecreationData recreation = _buildRecreations.get(player); + double dist = UtilMath.offsetSquared(player.getLocation(), recreation.OriginalBuildLocation.clone().add(0.5, 0, 0.5)); + + for (Location loc : WorldData.GetDataLocs("YELLOW")) + { + if (loc.equals(recreation.OriginalBuildLocation)) + continue; + + double distFromOther = UtilMath.offsetSquared(player.getLocation(), loc.clone().add(0.5, 0, 0.5)); + + if (player.getGameMode() != GameMode.SPECTATOR && (dist > distFromOther || player.getLocation().getY() < recreation.OriginalBuildLocation.getY() - 2)) + { + player.teleport(recreation.PlayerSpawn); + + UtilPlayer.message(player, F.main("Build", "You cannot leave your area!")); + UtilTextMiddle.display("", C.cRed + "You cannot leave your area!", 0, 30, 10, player); + + break; + } + } + } + } + + @EventHandler + public void stopGuardiansBuildEnter(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + if (!IsLive()) + return; + + for (Player player : GetTeamList().get(1).GetPlayers(false)) + { + for (RecreationData recreation : _buildRecreations.values()) + { + Vector vec = player.getLocation().getDirection().multiply(-1); + + if (UtilMath.offsetSquared(player.getLocation(), recreation.getMidpoint()) < 64) + { + player.playSound(player.getEyeLocation(), Sound.NOTE_PLING, 10F, 0.5F); + UtilAction.velocity(player, vec, 1.6, false, 0, 0.4, vec.length(), false); + } + } + } + } + + @EventHandler + public void border(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (!InProgress()) + return; + + Location specLocation = GetSpectatorLocation(); + + //This can be done like this cause nobody should be outside + for (Player player : UtilServer.getPlayers()) + { + if (!isInsideMap(player)) + player.teleport(specLocation); + } + } + + @EventHandler + public void stateUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!IsLive()) + return; + + if (_state == SpeedBuildersState.VIEWING) + { + if (UtilTime.elapsed(_stateTime, _viewTime * 1000)) + { + for (RecreationData recreation : _buildRecreations.values()) + { + recreation.breakAndDropItems(); + } + + ItemPickup = true; + BlockPlace = true; + + _buildCountStage = 0; + + //Sometimes it doesn't show in the update method + UtilTextMiddle.display("", C.cRed + "View Time Over!", 0, 30, 10); + + for (Player player : GetTeamList().get(0).GetPlayers(true)) + { + UtilPlayer.message(player, F.main("Build", "Recreate the build shown.")); + } + + setSpeedBuilderState(SpeedBuildersState.BUILDING); + } + } + else if (_state == SpeedBuildersState.BUILDING) + { + if (UtilTime.elapsed(_stateTime, _buildTime * 1000) || _allPerfect) + { + for (RecreationData recreation : _buildRecreations.values()) + { + for (Item item : recreation.DroppedItems.keySet()) + { + item.remove(); + } + + recreation.DroppedItems.clear(); + + UtilInv.Clear(recreation.Player); + } + + //Sometimes it stops on 0.1 and has one bar green + UtilTextBottom.displayProgress("Time Left:", 0, UtilTime.MakeStr(0), UtilServer.getPlayers()); + + if (_allPerfect) + { + UtilTextMiddle.display("", C.cAqua + GUARDIAN_NAME + " is Impressed!", 0, 100, 10); + _allPerfect = false; + } + else + { + //Sometimes doesn't show in the update method + UtilTextMiddle.display("", C.cRed + "TIME'S UP!", 0, 30, 10); + + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + UtilTextMiddle.display("", C.cAqua + GUARDIAN_NAME + " is Judging", 0, 40, 10); + } + }, 40L); + } + + for (Player player : UtilServer.getPlayers()) + { +// player.setGameMode(GameMode.SPECTATOR); +// player.setSpectatorTarget(_judgeEntity); + +// Manager.GetCondition().Factory().Cloak("Guardian POV", player, null, 999999999, false, false); + + PacketPlayOutGameStateChange packet = new PacketPlayOutGameStateChange(10, 0.0F); + UtilPlayer.sendPacket(player, packet); + } + + _perfectBuild.clear(); + + ItemPickup = false; + BlockPlace = false; + + RecreationData lowest = null; + int lowestScore = -1; + + boolean allPerfectMatch = !_buildRecreations.isEmpty(); + boolean allPlayersEqual = true; + + for (RecreationData recreation : _buildRecreations.values()) + { + int score = recreation.calculateScoreFromBuild(_currentBuild); + + if (lowest != null && lowestScore != score) + { + allPlayersEqual = false; + } + + if (lowest == null || lowestScore > score) + { + lowest = recreation; + lowestScore = score; + } + + if (score != _currentBuild.getPerfectScore()) + allPerfectMatch = false; + + if (recreation.isEmptyBuild(_currentBuild)) + _toEliminate.add(recreation); + } + + if (!allPerfectMatch && !allPlayersEqual && lowest != null && !_toEliminate.contains(lowest)) + _toEliminate.add(lowest); + + if (!_toEliminate.isEmpty()) + { + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + for (Player player : GetTeamList().get(0).GetPlayers(true)) + { + if (!_buildRecreations.containsKey(player)) + return; + + int percent = (int) (((double) _buildRecreations.get(player).calculateScoreFromBuild(_currentBuild) / _currentBuild.getPerfectScore()) * 100d); + + UtilTextMiddle.display("", getPercentPrefix(percent) + "You scored " + percent + " Percent", 0, 40, 10, player); + } + } + }, 130L); + } + + _lastElimination = System.currentTimeMillis(); + _reviewStartTime = System.currentTimeMillis(); + + pasteBuildInCenter(_currentBuild); + + setSpeedBuilderState(SpeedBuildersState.REVIEWING); + + for (Player player : GetTeamList().get(0).GetPlayers(true)) + { + player.setGameMode(GameMode.SPECTATOR); +// player.setAllowFlight(true); +// player.setFlying(true); + } + } + } + else if (_state == SpeedBuildersState.REVIEWING) + { + if (_toEliminate.isEmpty()) + { + if (!UtilTime.elapsed(_lastElimination, 3000)) + return; + + clearCenterArea(true); + + if (_nextBuild != null) + _currentBuild = _nextBuild; + else + _currentBuild = UtilAlg.Random(_buildData, _usedBuilds); + + _nextBuild = null; + _usedBuilds.add(_currentBuild); + _buildTime = _currentBuild.getBuildTime(_buildTimeTracker); + + for (Player player : GetTeamList().get(0).GetPlayers(true)) + { + player.setGameMode(GameMode.SURVIVAL); +// player.setAllowFlight(false); +// player.setFlying(false); + } + + for (RecreationData recreation : _buildRecreations.values()) + { + recreation.Player.teleport(recreation.PlayerSpawn); + + recreation.pasteBuildData(_currentBuild); + } + +// Location specLocation = GetSpectatorLocation(); +// double avgDist = 0; +// +// //Add up all the distances +// for (Location loc : GetTeamList().get(0).GetSpawns()) +// { +// avgDist += UtilMath.offset2d(specLocation, loc); +// } +// +// //Get the average by dividing +// avgDist /= GetTeamList().get(0).GetSpawns().size(); +// +// for (Player player : UtilServer.getPlayers()) +// { +// player.setGameMode(GameMode.SURVIVAL); +// +// Manager.GetCondition().EndCondition(player, ConditionType.CLOAK, "Guardian POV"); +// +// if (_buildRecreations.containsKey(player)) +// player.teleport(_buildRecreations.get(player).PlayerSpawn); +// +// if (!IsAlive(player) || GetTeamList().get(1).HasPlayer(player)) +// { +// player.setAllowFlight(true); +// player.setFlying(true); +// +// Location toTeleport = specLocation.clone(); +// +// //Spread players by getting a random x and z in that radius +// toTeleport.setX(toTeleport.getX() + (Math.random() * avgDist * 2 - avgDist)); +// toTeleport.setZ(toTeleport.getZ() + (Math.random() * avgDist * 2 - avgDist)); +// +// toTeleport.setDirection(UtilAlg.getTrajectory(toTeleport, _buildMiddle.clone().add(0.5, 0, 0.5))); +// +// player.teleport(toTeleport); +// } +// } + + _roundsPlayed++; + + if (_buildTimeTracker > 1) + _buildTimeTracker--; + + _viewCountStage = 0; + + for (Player player : GetTeamList().get(0).GetPlayers(true)) + { + UtilPlayer.message(player, F.main("Build", "You will recreate this build.")); + } + + UtilTextMiddle.display("", C.cGold + _currentBuild.BuildText, 0, 80, 10); + + setSpeedBuilderState(SpeedBuildersState.VIEWING); + } + else + { + if (UtilTime.elapsed(_reviewStartTime, 10000) && UtilTime.elapsed(_lastElimination, 2000) && !_eliminating) + { + //Eliminate in order This also means that the empty builds are eliminated first + final RecreationData eliminating = _toEliminate.get(0); + + judgeTargetLocation(eliminating.OriginalBuildLocation.clone().subtract(0, 1.7, 0)); + + UtilTextMiddle.display("", C.cRed + eliminating.Player.getName() + C.cGreen + " was eliminated!", 0, 30, 10); + + _eliminating = true; + + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + _lastElimination = System.currentTimeMillis(); + + _eliminating = false; + + if (!_toEliminate.contains(eliminating)) + return; + + WorldData.World.playEffect(eliminating.getMidpoint(), Effect.EXPLOSION_HUGE, 0); + + for (Player player : UtilServer.getPlayers()) + { + player.playSound(player.getEyeLocation(), Sound.ZOMBIE_REMEDY, 1F, 1F); + } + + HashSet blocks = UtilBlock.findConnectedBlocks(eliminating.OriginalBuildLocation.getBlock(), eliminating.OriginalBuildLocation.getBlock(), null, 2000, 8); + + //Sets should remove duplicates + blocks.addAll(eliminating.getBlocks()); + + Manager.GetExplosion().BlockExplosion(blocks, eliminating.getMidpoint(), false, true); + + eliminating.clearBuildArea(false); + eliminating.removeHologram(); + + judgeTargetLocation(null); + + _toEliminate.remove(eliminating); + + _buildRecreations.remove(eliminating.Player); + + moveToGuardians(eliminating.Player, true); + } + }, 100L); + } + else if (!_eliminating) + { + double speed = 10d; + + double oX = -Math.sin(_judgeEntity.getTicksLived() / speed) * 12; + double oY = 0; + double oZ = Math.cos(_judgeEntity.getTicksLived() / speed) * 12; + + Location toLook = _judgeEntity.getLocation().add(new Vector(oX, oY, oZ)); + + UtilEnt.CreatureLook(_judgeEntity, toLook); + } + } + } + } + + private String getPercentPrefix(int percent) + { + if (percent >= 75) + return C.cAqua; + else if (percent >= 50) + return C.cGreen; + else if (percent >= 25) + return C.cYellow; + else + return C.cRed; + } + + @EventHandler + public void buildTimeProgressBar(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!IsLive()) + return; + + if (_state != SpeedBuildersState.BUILDING) + return; + + long timeLeft = 1000 * _buildTime - (System.currentTimeMillis() - _stateTime); + + if (timeLeft < 0) + timeLeft = 0; + + UtilTextBottom.displayProgress("Time Left", timeLeft / (_buildTime * 1000.0D), UtilTime.MakeStr(timeLeft), UtilServer.getPlayers()); + } + + @EventHandler + public void buildEndCountdown(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!IsLive()) + return; + + if (_state != SpeedBuildersState.BUILDING) + return; + + if (UtilTime.elapsed(_stateTime, 1000 * _buildCountStage)) + { + ArrayList players = new ArrayList(UtilServer.getServer().getOnlinePlayers()); + + for (Entry entry : _perfectBuild.entrySet()) + { + if (!UtilTime.elapsed(entry.getValue(), 5000)) + players.remove(entry.getKey()); + } + + if (_buildCountStage == _buildTime) + UtilTextMiddle.display("", C.cRed + "TIME'S UP!", 0, 30, 10); + else if (_buildCountStage >= _buildTime - 5) + UtilTextMiddle.display("", C.cGreen + (_buildTime - _buildCountStage), 0, 30, 10, players.toArray(new Player[players.size()])); + + if (_buildCountStage >= _buildTime - 5) + { + for (Player player : UtilServer.getPlayers()) + { + player.playSound(player.getEyeLocation(), Sound.NOTE_PLING, 1F, 1F - (float) (0.1 * (_buildTime - _buildCountStage))); + } + } + + _buildCountStage++; + } + } + + @EventHandler + public void viewCountdown(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!IsLive()) + return; + + if (_state != SpeedBuildersState.VIEWING) + return; + + if (UtilTime.elapsed(_stateTime, _viewCountStage * 1000)) + { + if (_viewCountStage == _viewTime) + UtilTextMiddle.display("", C.cRed + "View Time Over!", 0, 30, 10); + else if (_viewCountStage > 3) + UtilTextMiddle.display("", C.cGreen + (_viewTime - _viewCountStage), 0, 30, 10); + + if (_viewCountStage > 3) + { + for (Player player : UtilServer.getPlayers()) + { + player.playSound(player.getEyeLocation(), Sound.NOTE_PLING, 1F, 1F - (float) (0.1 * (_viewTime - _viewCountStage))); + } + } + + _viewCountStage++; + } + } + + @EventHandler + public void markBlockForDemolition(PlayerInteractEvent event) + { + if (_state != SpeedBuildersState.BUILDING) + return; + + if (!_buildRecreations.containsKey(event.getPlayer())) + return; + + if (!UtilEvent.isAction(event, ActionType.L_BLOCK)) + return; + + if (_perfectBuild.containsKey(event.getPlayer())) + return; + + if (!_buildRecreations.get(event.getPlayer()).inBuildArea(event.getClickedBlock())) + return; + + if (event.getClickedBlock().getType() == Material.AIR) + return; + + _buildRecreations.get(event.getPlayer()).addToDemolition(event.getClickedBlock()); + } + + @EventHandler + public void markMobForDemolition(EntityDamageByEntityEvent event) + { + if (!(event.getDamager() instanceof Player)) + return; + + Player player = (Player) event.getDamager(); + + if (_state != SpeedBuildersState.BUILDING) + return; + + if (!_buildRecreations.containsKey(player)) + return; + + if (_perfectBuild.containsKey(player)) + return; + + if (!_buildRecreations.get(player).inBuildArea(event.getEntity().getLocation())) + return; + + _buildRecreations.get(player).addToDemolition(event.getEntity()); + } + + @EventHandler + public void updateDemolitionBlocks(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (RecreationData recreation : _buildRecreations.values()) + { + ArrayList blocksForDemolition = new ArrayList(recreation.BlocksForDemolition); + + for (DemolitionData demolition : blocksForDemolition) + { + if (_state != SpeedBuildersState.BUILDING || _perfectBuild.containsKey(demolition.Parent.Player)) + demolition.cancelBreak(); + else + demolition.update(); + } + } + } + + @EventHandler + public void preventBlockGrowth(BlockGrowEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void preventStructureGrowth(StructureGrowEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void judgeLooking(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + return; + + if (!InProgress()) + return; + + if (_state != SpeedBuildersState.BUILDING && _state != SpeedBuildersState.VIEWING) + return; + + if (_buildRecreations.isEmpty()) + return; + + if (_lookTarget == null || (UtilTime.elapsed(_targetReached, _stayTime) && _standMoveProgress > 1)) + { + + RecreationData target = null; + + do + { + target = _buildRecreations.get(UtilAlg.Random(_buildRecreations.keySet())); + } + while (target.equals(_lastRecreationTarget) && _buildRecreations.size() > 1); + + _lookTarget = target.getMidpoint().subtract(UtilAlg.getTrajectory(_judgeEntity.getEyeLocation(), target.getMidpoint()).multiply(5)); + _stayTime = UtilMath.rRange(4000, 8000); + _lastRecreationTarget = target; + _standMoveProgress = 0; + + if (_lookStand != null) + _standStart = _lookStand.getLocation(); + } + + if (_lookStand == null) + { + _lookStand = WorldData.World.spawn(_judgeEntity.getEyeLocation().add(_judgeEntity.getEyeLocation().getDirection().multiply(10)), ArmorStand.class); + + _lookStand.setGravity(false); + _lookStand.setSmall(true); + _lookStand.setVisible(false); + _lookStand.setGhost(true); + _lookStand.setMarker(false); + + _standStart = _lookStand.getLocation(); + } + + if (_standMoveProgress > 1) + return; + + Location newLoc = _standStart.clone().add(UtilAlg.getTrajectory(_standStart, _lookTarget).multiply(UtilMath.offset(_standStart, _lookTarget) * _standMoveProgress)); + + moveEntity(newLoc, _lookStand); + + UtilEnt.CreatureLook(_judgeEntity, _lookStand); + + _standMoveProgress += 0.2; + + if (_standMoveProgress > 1) + _targetReached = System.currentTimeMillis(); + } + + private void moveEntity(Location loc, Entity entity) + { + double dx = loc.getX() - entity.getLocation().getX(); + double dy = loc.getY() - entity.getLocation().getY(); + double dz = loc.getZ() - entity.getLocation().getZ(); + + ((CraftEntity) entity).getHandle().move(dx, dy, dz); + } + + @EventHandler + public void specNightVision(UpdateEvent event) + { + if (!InProgress()) + return; + + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (UtilPlayer.isSpectator(player) || (GetTeamList().size() > 1 && GetTeamList().get(1).HasPlayer(player))) + { + player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, true, false), true); + player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, Integer.MAX_VALUE, 0, true, false), true); + } + } + } + +// @EventHandler +// public void stopJudgeUnspec(UpdateEvent event) +// { +// if (event.getType() != UpdateType.TICK) +// return; +// +// if (!IsLive()) +// return; +// +// if (_state != SpeedBuilderState.REVIEWING) +// return; +// +// for (Player player : UtilServer.getPlayers()) +// { +// player.setGameMode(GameMode.SPECTATOR); +// player.setSpectatorTarget(_judgeEntity); +// +// if (!Manager.GetCondition().HasCondition(player, ConditionType.CLOAK, "Guardian POV")) +// Manager.GetCondition().Factory().Cloak("Guardian POV", player, null, 999999999, false, false); +// } +// } + + @EventHandler + public void stopGuardianSpecPickup(PlayerPickupItemEvent event) + { + if (GetState().ordinal() < GameState.Prepare.ordinal()) + return; + + if (Manager.isSpectator(event.getPlayer()) || GetTeamList().get(1).HasPlayer(event.getPlayer())) + event.setCancelled(true); + } + + @EventHandler + public void stopGuardianSpecPlace(BlockPlaceEvent event) + { + if (GetState().ordinal() < GameState.Prepare.ordinal()) + return; + + if (Manager.isSpectator(event.getPlayer()) || GetTeamList().get(1).HasPlayer(event.getPlayer())) + event.setCancelled(true); + } + + @EventHandler + public void stopEntityChangeBlock(EntityChangeBlockEvent event) + { + if (!IsLive()) + return; + + event.setCancelled(true); + } + + @EventHandler + public void stopBlockFade(BlockFadeEvent event) + { + if (!IsLive()) + return; + + event.setCancelled(true); + } + + @EventHandler + public void stopBlockBurn(BlockBurnEvent event) + { + if (!IsLive()) + return; + + event.setCancelled(true); + } + + @EventHandler + public void stopLeavesDecay(LeavesDecayEvent event) + { + if (!IsLive()) + return; + + event.setCancelled(true); + } + + @EventHandler + public void stopBlockForm(BlockFormEvent event) + { + if (!IsLive()) + return; + + event.setCancelled(true); + } + + @EventHandler + public void stopBlockSpread(BlockSpreadEvent event) + { + if (!IsLive()) + return; + + event.setCancelled(true); + } + + @EventHandler + public void stopLiquidLeaks(BlockFromToEvent event) + { + for (RecreationData recreation : _buildRecreations.values()) + { + if ((recreation.inBuildArea(event.getBlock()) && !recreation.inBuildArea(event.getToBlock())) || (!recreation.inBuildArea(event.getBlock()) && recreation.inBuildArea(event.getToBlock()))) + event.setCancelled(true); + } + } + + @EventHandler + public void stopPhysics(BlockPhysicsEvent event) + { + if (!IsLive()) + return; + + event.setCancelled(true); + } + + @EventHandler + public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) + { + if (!IsLive()) + return; + + if (_state != SpeedBuildersState.BUILDING) + return; + + if (!_buildRecreations.containsKey(event.getPlayer())) + return; + + if (_perfectBuild.containsKey(event.getPlayer())) + { + event.setCancelled(true); + return; + } + + Block liquid = event.getBlockClicked().getRelative(event.getBlockFace()); + + if (!_buildRecreations.get(event.getPlayer()).inBuildArea(liquid)) + { + event.setCancelled(true); + + UtilPlayer.message(event.getPlayer(), F.main("Build", "Cannot build outside your area!")); + } + } + + @EventHandler + public void onPlayerBucketFill(PlayerBucketFillEvent event) + { + if (!IsLive()) + return; + + if (_state != SpeedBuildersState.BUILDING) + return; + + if (!_buildRecreations.containsKey(event.getPlayer())) + return; + + if (_perfectBuild.containsKey(event.getPlayer())) + { + event.setCancelled(true); + return; + } + + Block liquid = event.getBlockClicked().getRelative(event.getBlockFace()); + + if (!_buildRecreations.get(event.getPlayer()).inBuildArea(liquid)) + { + event.setCancelled(true); + + UtilPlayer.message(event.getPlayer(), F.main("Build", "Cannot build outside your area!")); + } + } + + @EventHandler + public void addMob(PlayerInteractEvent event) + { + if (!IsLive()) + return; + + if (_state != SpeedBuildersState.BUILDING) + return; + + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + return; + + if (event.getItem() == null) + return; + + if (event.getItem().getType() != Material.MONSTER_EGG) + return; + + if (!_buildRecreations.containsKey(event.getPlayer())) + return; + + EntityType type = EntityType.fromId(event.getItem().getDurability()); + + Block block = event.getClickedBlock().getRelative(event.getBlockFace()); + + if (!_buildRecreations.get(event.getPlayer()).inBuildArea(block)) + return; + + CreatureAllowOverride = true; + + Entity entity = block.getWorld().spawnEntity(block.getLocation().add(0.5, 0, 0.5), type); + + UtilEnt.Vegetate(entity, true); + UtilEnt.ghost(entity, true, false); + + CreatureAllowOverride = false; + + _buildRecreations.get(event.getPlayer()).Mobs.add(entity); + + UtilInv.remove(event.getPlayer(), Material.MONSTER_EGG, (byte) event.getItem().getDurability(), 1); + } + + @EventHandler + public void stopCombust(EntityCombustEvent event) + { + if (!IsLive()) + return; + + event.setCancelled(true); + } + + //Add to guardians before arcade manager adds to spectator to trick it into thinking the player is "alive" + @EventHandler(priority = EventPriority.LOW) + public void joinAddGuardian(PlayerJoinEvent event) + { + if (!InProgress()) + return; + + moveToGuardians(event.getPlayer(), false); + event.getPlayer().teleport(GetSpectatorLocation()); + + //We need to disguise a tick after + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + DisguiseGuardian disguise = new DisguiseGuardian(event.getPlayer()); + disguise.setName(C.cGray + event.getPlayer().getName()); + disguise.setCustomNameVisible(true); + + Manager.GetDisguise().disguise(disguise); + + event.getPlayer().setAllowFlight(true); + event.getPlayer().setFlying(true); + } + }, 1); + } + + @EventHandler + public void setNextBuild(PlayerCommandPreprocessEvent event) + { + if (!event.getMessage().startsWith("/setnext ")) + return; + + event.setCancelled(true); + + if (!Manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.MAPDEV, true)) + return; + + if (!Manager.getPlugin().getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing")) + { + UtilPlayer.message(event.getPlayer(), F.main("Build", C.cYellow + "You can only use this on testing servers!")); + + return; + } + + String buildName = event.getMessage().substring(9); + + BuildData build = null; + + for (BuildData buildData : _buildData) + { + if (buildData.BuildText.toUpperCase().startsWith(buildName.toUpperCase())) + { + build = buildData; + + break; + } + } + + if (build == null) + UtilPlayer.message(event.getPlayer(), F.main("Build", "That build does not exist!")); + else + { + _nextBuild = build; + + UtilPlayer.message(event.getPlayer(), F.main("Build", "Set next build to " + F.elem(build.BuildText))); + } + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + GameTeam playersTeam = GetTeamList().get(0); + + if (playersTeam.GetPlayers(true).size() <= 1) + { + ArrayList places = playersTeam.GetPlacements(true); + + //Announce + AnnounceEnd(places); + + //Gems + if (places.size() >= 1) + AddGems(places.get(0), 20, "1st Place", false, false); + + if (places.size() >= 2) + AddGems(places.get(1), 15, "2nd Place", false, false); + + if (places.size() >= 3) + AddGems(places.get(2), 10, "3rd Place", false, false); + + for (Player player : GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + + //End + SetState(GameState.End); + } + } + + @Override + public List getLosers() + { + List winners = getWinners(); + + if (winners == null) + return null; + + if (GetTeamList().size() < 2) + return new ArrayList(); + + List losers = GetTeamList().get(1).GetPlayers(false); + + losers.removeAll(winners); + losers.retainAll(GetTeamList().get(0).GetPlacements(true)); + + return losers; + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (GetTeamList().isEmpty()) + return; + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + + Scoreboard.Write(C.cYellowB + "Build"); + + if (_currentBuild == null) + Scoreboard.Write("(None)"); + else + Scoreboard.Write(C.cWhite + _currentBuild.BuildText); + + Scoreboard.WriteBlank(); + + Scoreboard.Write(C.cYellowB + "Round"); + Scoreboard.Write("" + _roundsPlayed); + + Scoreboard.WriteBlank(); + + List playersAlive = GetTeamList().get(0).GetPlayers(true); + + List playersDead = new ArrayList(); + + if (GetTeamList().size() > 1) + playersDead.addAll(GetTeamList().get(1).GetPlayers(false)); + + Scoreboard.Write(C.cYellowB + "Players"); + + for (Player player : playersAlive) + { + Scoreboard.Write(player.getName()); + } + + for (Player player : playersDead) + { + Scoreboard.Write(C.cGray + player.getName()); + } + + Scoreboard.Draw(); + } + + public Location getJudgeSpawn() + { + return _judgeSpawn; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuildersState.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuildersState.java new file mode 100644 index 000000000..d79445240 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuildersState.java @@ -0,0 +1,10 @@ +package nautilus.game.arcade.game.games.speedbuilders; + +public enum SpeedBuildersState +{ + + VIEWING, + BUILDING, + REVIEWING; + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/data/BuildData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/data/BuildData.java new file mode 100644 index 000000000..1f56c816d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/data/BuildData.java @@ -0,0 +1,198 @@ +package nautilus.game.arcade.game.games.speedbuilders.data; + +import java.util.ArrayList; + +import mineplex.core.common.util.MapUtil; +import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; +import net.minecraft.server.v1_8_R3.BlockPosition; +import net.minecraft.server.v1_8_R3.BlockStairs; +import net.minecraft.server.v1_8_R3.BlockStairs.EnumStairShape; +import net.minecraft.server.v1_8_R3.IBlockData; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.block.Sign; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers; +import org.bukkit.entity.EntityType; +import org.bukkit.material.Stairs; + +public class BuildData +{ + public SpeedBuilders Game; + + public Location BuildMin; + + public BlockState[][][] Build; + public BlockState[][] Ground; + + //Store stair shapes for stair fix + public EnumStairShape[][][] StairShapes; + + public String BuildText; + + public ArrayList Mobs = new ArrayList(); + + private int _timeAdd = 0; + private int _timeSubtract = 0; + private int _timeEqual = -1; + private double _timeMultiplier = 1.0; + + public BuildData(Location loc, String buildText, SpeedBuilders game) + { + Build = new BlockState[game.BuildSize][game.BuildSize][game.BuildSize]; + Ground = new BlockState[game.BuildSize][game.BuildSize]; + + StairShapes = new EnumStairShape[game.BuildSize][game.BuildSize][game.BuildSize]; + + Game = game; + + Location groundMin = loc.clone().subtract(game.BuildSizeDiv2, 11, game.BuildSizeDiv2); + + for (int x = 0; x < game.BuildSize; x++) + { + for (int z = 0; z < game.BuildSize; z++) + { + Ground[x][z] = groundMin.clone().add(x, 0, z).getBlock().getState(); + } + } + + parseText(buildText); + + Location buildMin = loc.clone().subtract(game.BuildSizeDiv2, 10, game.BuildSizeDiv2); + + BuildMin = buildMin; + + for (int x = 0; x < game.BuildSize; x++) + { + for (int y = 0; y < game.BuildSize; y++) + { + for (int z = 0; z < game.BuildSize; z++) + { + Block block = buildMin.clone().add(x, y, z).getBlock(); + + if (block.getType() == Material.SIGN_POST) + { + Sign sign = (Sign) block.getState(); + + EntityType type = null; + + try + { + type = EntityType.valueOf(sign.getLine(0).toUpperCase()); + } + catch (IllegalArgumentException e) + { + // Not a entity sign or someone messed up... + } + + if (type != null) + { + Mobs.add(new MobData(type, x, y, z)); + + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR); + } + } + + Build[x][y][z] = block.getState(); + + if (block.getState().getData() instanceof Stairs) + { + net.minecraft.server.v1_8_R3.Block nmsBlock = CraftMagicNumbers.getBlock(block); + + IBlockData blockData = nmsBlock.getBlockData(); + blockData = nmsBlock.updateState(blockData, ((CraftWorld) block.getWorld()).getHandle(), new BlockPosition(block.getX(), block.getY(), block.getZ())); + + StairShapes[x][y][z] = blockData.get(BlockStairs.SHAPE); + } + } + } + } + } + + private void parseText(String buildText) + { + StringBuilder sb = new StringBuilder(); + for (String part : buildText.split(" ")) + { + if (part.matches("^time[\\Q+-=\\E][0-9]+$")) + { + // + - = add subtract or set seconds + try + { + int num = Integer.parseInt(part.substring(5)); + switch (part.charAt(4)) + { + case '-': + _timeSubtract = num; + break; + case '=': + _timeEqual = num; + break; + default: + _timeAdd = num; + } + } + catch (NumberFormatException e) + { + System.out.println("Failed parsing data for customloc: " + buildText); + e.printStackTrace(); + } + } + else if (part.matches("^time\\*[0-9]*\\.?[0-9]+$")) + { + // * multiply by a number + try + { + double num = Double.parseDouble(part.substring(5)); + _timeMultiplier = num; + } + catch (NumberFormatException e) + { + System.out.println("Failed parsing data for customloc: " + buildText); + e.printStackTrace(); + } + } + else + { + sb.append(part + " "); + } + } + + BuildText = sb.toString().trim(); + } + + public int getBuildTime(int unmodified) + { + int newTime = unmodified; + newTime += _timeAdd; + newTime -= _timeSubtract; + newTime = (int) (_timeMultiplier * newTime); + if (_timeEqual != -1) newTime = _timeEqual; + + // limit to range of 5-60 seconds + return Math.min(Math.max(newTime, 5), 60); + } + + public int getPerfectScore() + { + int nonAirBlocks = 0; + + for (int x = 0; x < Game.BuildSize; x++) + { + for (int y = 0; y < Game.BuildSize; y++) + { + for (int z = 0; z < Game.BuildSize; z++) + { + if (Build[x][y][z].getType() != Material.AIR) + nonAirBlocks++; + } + } + } + + return nonAirBlocks + Mobs.size(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/data/DemolitionData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/data/DemolitionData.java new file mode 100644 index 000000000..f53f653c0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/data/DemolitionData.java @@ -0,0 +1,227 @@ +package nautilus.game.arcade.game.games.speedbuilders.data; + +import java.util.ArrayList; + +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilTime; +import mineplex.core.hologram.Hologram; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Bed; +import org.bukkit.material.Door; + +public class DemolitionData +{ + + public RecreationData Parent; + + public NautHashMap Blocks; + public ArrayList Mobs; + + public long Start; + + private Hologram _hologram; + + private boolean _flickerAir = true; + private long _lastFlicker = System.currentTimeMillis(); + + public DemolitionData(RecreationData parent, ArrayList blocks, ArrayList mobs) + { + Parent = parent; + + Blocks = new NautHashMap(); + Mobs = mobs; + + for (Block block : blocks) + { + Blocks.put(block, block.getState()); + } + + Start = System.currentTimeMillis(); + + spawnHologram(); + } + + public void spawnHologram() + { + if (Parent.Game.InstaBreak) + return; + + Location loc = Parent.getMidpoint(); + + if (!Blocks.isEmpty()) + loc = Blocks.keySet().iterator().next().getLocation().add(0.5, 0.5, 0.5); + else if (!Mobs.isEmpty()) + loc = UtilAlg.Random(Mobs).getLocation().add(0, 1, 0); + + _hologram = new Hologram(Parent.Game.Manager.getHologramManager(), loc, "3"); + + _hologram.start(); + } + + public void despawnHologram() + { + if (_hologram == null) + return; + + _hologram.stop(); + + _hologram = null; + } + + public void update() + { + if (Parent.Game.InstaBreak) + { + breakBlocks(); + + return; + } + + if (_hologram == null) + spawnHologram(); + + int secondsLeft = (int) Math.ceil((3000 - (System.currentTimeMillis() - Start)) / 1000.0D); + + if (secondsLeft < 0) + secondsLeft = 0; + + _hologram.setText("" + secondsLeft); + + if (UtilTime.elapsed(_lastFlicker, 500)) + { + _lastFlicker = System.currentTimeMillis(); + + for (Block block : Blocks.keySet()) + { + if (_flickerAir) + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR); + else + Blocks.get(block).update(true, false); + } + + for (Entity entity : Mobs) + { + if (_flickerAir) + UtilEnt.ghost(entity, true, true); + else + UtilEnt.ghost(entity, true, false); + } + + _flickerAir = !_flickerAir; + } + + if (secondsLeft == 0) + breakBlocks(); + } + + public void cancelBreak() + { + despawnHologram(); + + for (Block block : Blocks.keySet()) + { + Blocks.get(block).update(true, false); + } + + for (Entity entity : Mobs) + { + UtilEnt.ghost(entity, true, false); + } + + Parent.BlocksForDemolition.remove(this); + } + + public void breakBlocks() + { + despawnHologram(); + + //Effect will play for all blocks even two-parted ones + for (Block block : Blocks.keySet()) + { + Blocks.get(block).update(true, false); + + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); + } + + for (Block block : Blocks.keySet()) + { + if (block.getType() == Material.AIR) + continue; + + //Ignore top double plant blocks + if (block.getType() == Material.DOUBLE_PLANT) + { + if (block.getData() > 7) + continue; + } + + for (ItemStack itemStack : UtilBlock.blockToInventoryItemStacks(block)) + { + Item item = block.getWorld().dropItem(block.getLocation().add(0.5, 0.5, 0.5), itemStack); + + Parent.DroppedItems.put(item, System.currentTimeMillis()); + } + + //Destroy the other part + if (block.getType() == Material.BED_BLOCK) + { + Bed bed = (Bed) block.getState().getData(); + + if (bed.isHeadOfBed()) + MapUtil.QuickChangeBlockAt(block.getRelative(bed.getFacing().getOppositeFace()).getLocation(), Material.AIR); + else + MapUtil.QuickChangeBlockAt(block.getRelative(bed.getFacing()).getLocation(), Material.AIR); + } + else if (block.getType() == Material.WOODEN_DOOR || block.getType() == Material.IRON_DOOR_BLOCK || block.getType() == Material.SPRUCE_DOOR || block.getType() == Material.BIRCH_DOOR || block.getType() == Material.JUNGLE_DOOR || block.getType() == Material.ACACIA_DOOR || block.getType() == Material.DARK_OAK_DOOR) + { + Door door = (Door) block.getState().getData(); + + if (door.isTopHalf()) + MapUtil.QuickChangeBlockAt(block.getRelative(BlockFace.DOWN).getLocation(), Material.AIR); + else + MapUtil.QuickChangeBlockAt(block.getRelative(BlockFace.UP).getLocation(), Material.AIR); + } + else if (block.getType() == Material.DOUBLE_PLANT) + { + //The top block does not carry the correct data + if (block.getData() <= 7) + MapUtil.QuickChangeBlockAt(block.getRelative(BlockFace.UP).getLocation(), Material.AIR); + else + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR); + } + + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR); + } + + for (Entity entity : Mobs) + { + ItemStack spawnEgg = new ItemStack(Material.MONSTER_EGG, 1, entity.getType().getTypeId()); + + Item item = entity.getWorld().dropItem(entity.getLocation().add(0, 1, 0), spawnEgg); + + Parent.DroppedItems.put(item, System.currentTimeMillis()); + + entity.remove(); + + Parent.Mobs.remove(entity); + } + + Parent.BlocksForDemolition.remove(this); + + Parent.Game.checkPerfectBuild(Parent.Player); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/data/MobData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/data/MobData.java new file mode 100644 index 000000000..51858381c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/data/MobData.java @@ -0,0 +1,23 @@ +package nautilus.game.arcade.game.games.speedbuilders.data; + +import org.bukkit.entity.EntityType; + +public class MobData +{ + + public EntityType EntityType; + + public int DX; + public int DY; + public int DZ; + + public MobData(EntityType entityType, int dx, int dy, int dz) + { + EntityType = entityType; + + DX = dx; + DY = dy; + DZ = dz; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/data/RecreationData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/data/RecreationData.java new file mode 100644 index 000000000..11aaac85a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/data/RecreationData.java @@ -0,0 +1,444 @@ +package nautilus.game.arcade.game.games.speedbuilders.data; + +import java.util.ArrayList; +import java.util.List; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import mineplex.core.hologram.Hologram; +import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; +import net.minecraft.server.v1_8_R3.BlockPosition; +import net.minecraft.server.v1_8_R3.BlockStairs; +import net.minecraft.server.v1_8_R3.BlockStairs.EnumStairShape; +import net.minecraft.server.v1_8_R3.IBlockData; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Bed; +import org.bukkit.material.Door; +import org.bukkit.material.Stairs; +import org.bukkit.util.Vector; + +public class RecreationData +{ + + public SpeedBuilders Game; + + public Player Player; + + public BlockState[][] DefaultGround; + + public Location OriginalBuildLocation; + + public Location CornerA; + public Location CornerB; + + public Location PlayerSpawn; + + public NautHashMap DroppedItems = new NautHashMap(); + + public ArrayList BlocksForDemolition = new ArrayList(); + + public ArrayList Mobs = new ArrayList(); + + private Hologram _hologram; + + public RecreationData(SpeedBuilders game, Player player, Location loc, Location playerSpawn) + { + Game = game; + + DefaultGround = new BlockState[game.BuildSize][game.BuildSize]; + + Player = player; + + OriginalBuildLocation = loc; + + CornerA = loc.clone().subtract(game.BuildSizeDiv2, 0, game.BuildSizeDiv2); + CornerB = loc.clone().add(game.BuildSizeDiv2, game.BuildSizeMin1, game.BuildSizeDiv2); + + PlayerSpawn = playerSpawn; + + for (int x = 0; x < game.BuildSize; x++) + { + for (int z = 0; z < game.BuildSize; z++) + { + DefaultGround[x][z] = CornerA.clone().add(x, -1, z).getBlock().getState(); + } + } + + Vector mid = game.getJudgeSpawn().toVector().subtract(loc.toVector()).multiply(0.4); + Location hologramLocation = loc.clone().add(mid).add(0, 1, 0); + Location above = loc.clone().add(0.5, game.BuildSize + 0.5, 0.5); + _hologram = new Hologram(game.getArcadeManager().getHologramManager(), hologramLocation, C.cYellow + player.getName()); + _hologram.start(); + } + + public boolean inBuildArea(Block block) + { + if (block.getX() < Math.min(CornerA.getBlockX(), CornerB.getBlockX())) + return false; + + if (block.getY() < Math.min(CornerA.getBlockY(), CornerB.getBlockY())) + return false; + + if (block.getZ() < Math.min(CornerA.getBlockZ(), CornerB.getBlockZ())) + return false; + + if (block.getX() > Math.max(CornerA.getBlockX(), CornerB.getBlockX())) + return false; + + if (block.getY() > Math.max(CornerA.getBlockY(), CornerB.getBlockY())) + return false; + + if (block.getZ() > Math.max(CornerA.getBlockZ(), CornerB.getBlockZ())) + return false; + + return true; + } + + public boolean inBuildArea(Location loc) + { + if (loc.getX() < Math.min(CornerA.getBlockX(), CornerB.getBlockX())) + return false; + + if (loc.getY() < Math.min(CornerA.getBlockY(), CornerB.getBlockY())) + return false; + + if (loc.getZ() < Math.min(CornerA.getBlockZ(), CornerB.getBlockZ())) + return false; + + if (loc.getX() > Math.max(CornerA.getBlockX(), CornerB.getBlockX()) + 1) + return false; + + if (loc.getY() > Math.max(CornerA.getBlockY(), CornerB.getBlockY()) + 1) + return false; + + if (loc.getZ() > Math.max(CornerA.getBlockZ(), CornerB.getBlockZ()) + 1) + return false; + + return true; + } + + public void clearBuildArea(boolean resetGround) + { + for (Block block : getBlocks()) + { + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR); + } + + for (Entity entity : Mobs) + { + entity.remove(); + } + + Mobs.clear(); + + if (resetGround) + { + for (int x = 0; x < Game.BuildSize; x++) + { + for (int z = 0; z < Game.BuildSize; z++) + { + MapUtil.QuickChangeBlockAt(CornerA.clone().add(x, -1, z), DefaultGround[x][z].getType(), DefaultGround[x][z].getRawData()); + } + } + } + } + + public void pasteBuildData(BuildData buildData) + { + clearBuildArea(true); + + for (int x = 0; x < Game.BuildSize; x++) + { + for (int z = 0; z < Game.BuildSize; z++) + { + MapUtil.QuickChangeBlockAt(CornerA.clone().add(x, -1, z), buildData.Ground[x][z].getType(), buildData.Ground[x][z].getRawData()); + } + } + + for (int x = 0; x < Game.BuildSize; x++) + { + for (int y = 0; y < Game.BuildSize; y++) + { + for (int z = 0; z < Game.BuildSize; z++) + { + MapUtil.QuickChangeBlockAt(CornerA.clone().add(x, y, z), buildData.Build[x][y][z].getType(), buildData.Build[x][y][z].getRawData()); + } + } + } + + Game.CreatureAllowOverride = true; + + for (MobData mobData : buildData.Mobs) + { + Location loc = CornerA.clone().add(mobData.DX + 0.5, mobData.DY, mobData.DZ + 0.5); + + Entity entity = loc.getWorld().spawnEntity(loc, mobData.EntityType); + + UtilEnt.Vegetate(entity, true); + UtilEnt.ghost(entity, true, false); + + Mobs.add(entity); + } + + Game.CreatureAllowOverride = false; + } + + public void breakAndDropItems() + { + for (Block block : getBlocks()) + { + if (block.getType() == Material.AIR) + continue; + + //Ignore top double plant blocks + if (block.getType() == Material.DOUBLE_PLANT) + { + if (block.getData() > 7) + continue; + } + + for (ItemStack itemStack : UtilBlock.blockToInventoryItemStacks(block)) + { + UtilInv.insert(Player, itemStack); + } + + //Destroy the other part + if (block.getType() == Material.BED_BLOCK) + { + Bed bed = (Bed) block.getState().getData(); + + if (bed.isHeadOfBed()) + MapUtil.QuickChangeBlockAt(block.getRelative(bed.getFacing().getOppositeFace()).getLocation(), Material.AIR); + else + MapUtil.QuickChangeBlockAt(block.getRelative(bed.getFacing()).getLocation(), Material.AIR); + } + else if (block.getType() == Material.WOODEN_DOOR || block.getType() == Material.IRON_DOOR_BLOCK || block.getType() == Material.SPRUCE_DOOR || block.getType() == Material.BIRCH_DOOR || block.getType() == Material.JUNGLE_DOOR || block.getType() == Material.ACACIA_DOOR || block.getType() == Material.DARK_OAK_DOOR) + { + Door door = (Door) block.getState().getData(); + + if (door.isTopHalf()) + MapUtil.QuickChangeBlockAt(block.getRelative(BlockFace.DOWN).getLocation(), Material.AIR); + else + MapUtil.QuickChangeBlockAt(block.getRelative(BlockFace.UP).getLocation(), Material.AIR); + } + else if (block.getType() == Material.DOUBLE_PLANT) + { + //The top block does not carry the correct data + if (block.getData() <= 7) + MapUtil.QuickChangeBlockAt(block.getRelative(BlockFace.UP).getLocation(), Material.AIR); + else + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR); + } + } + + for (Entity entity : Mobs) + { + ItemStack spawnEgg = new ItemStack(Material.MONSTER_EGG, 1, entity.getType().getTypeId()); + + UtilInv.insert(Player, spawnEgg); + } + + CornerA.getWorld().playEffect(getMidpoint(), Effect.STEP_SOUND, Material.LOG.getId()); + + clearBuildArea(false); + } + + public boolean isEmptyBuild(BuildData buildData) + { + for (Block block : getBlocks()) + { + if (block.getType() != Material.AIR) + return false; + } + + if (!buildData.Mobs.isEmpty()) + return Mobs.isEmpty(); + + return true; + } + + public int calculateScoreFromBuild(BuildData buildData) + { + int score = 0; + + for (int x = 0; x < Game.BuildSize; x++) + { + for (int y = 0; y < Game.BuildSize; y++) + { + for (int z = 0; z < Game.BuildSize; z++) + { + Block currentBlock = CornerA.clone().add(x, y, z).getBlock(); + BlockState expectedState = buildData.Build[x][y][z]; + + if (expectedState.getType() == Material.AIR) + continue; + + if (expectedState.getType() == currentBlock.getType() && expectedState.getRawData() == currentBlock.getData()) + { + score++; + continue; + } + + //Ender portal direction fix & 0x4 is a check to see if the frame has an ender eye in it + if (currentBlock.getType() == Material.ENDER_PORTAL_FRAME && expectedState.getType() == Material.ENDER_PORTAL_FRAME && (currentBlock.getData() & 0x4) == (expectedState.getRawData() & 0x4)) + { + score++; + continue; + } + + //Sapling growth fix + if (expectedState.getType() == Material.SAPLING && currentBlock.getType() == Material.SAPLING) + { + if (currentBlock.getData() % 8 == expectedState.getRawData() % 8) + score++; + } + + //Fix for leaves decay flags + if ((expectedState.getType() == Material.LEAVES && currentBlock.getType() == Material.LEAVES) || ((expectedState.getType() == Material.LEAVES_2 && currentBlock.getType() == Material.LEAVES_2))) + { + if (currentBlock.getData() % 4 == expectedState.getRawData() % 4) + score++; + } + + //Fix for corner stair shape + if (currentBlock.getState().getData() instanceof Stairs && expectedState.getData() instanceof Stairs) + { + net.minecraft.server.v1_8_R3.Block nmsBlock = CraftMagicNumbers.getBlock(currentBlock); + + IBlockData blockData = nmsBlock.getBlockData(); + blockData = nmsBlock.updateState(blockData, ((CraftWorld) currentBlock.getWorld()).getHandle(), new BlockPosition(currentBlock.getX(), currentBlock.getY(), currentBlock.getZ())); + + EnumStairShape expectedShape = buildData.StairShapes[x][y][z]; + EnumStairShape currentShape = blockData.get(BlockStairs.SHAPE); + + if ((expectedShape == EnumStairShape.INNER_LEFT && currentShape == EnumStairShape.INNER_RIGHT) || (expectedShape == EnumStairShape.INNER_RIGHT && currentShape == EnumStairShape.INNER_LEFT) || (expectedShape == EnumStairShape.OUTER_LEFT && currentShape == EnumStairShape.OUTER_RIGHT) || (expectedShape == EnumStairShape.OUTER_RIGHT && currentShape == EnumStairShape.OUTER_LEFT)) + score++; + } + } + } + } + + for (MobData mobData : buildData.Mobs) + { + for (Entity entity : Mobs) + { + int dx = (int) (entity.getLocation().getX() - (CornerA.getX() + 0.5)); + int dy = (int) (entity.getLocation().getY() - CornerA.getY()); + int dz = (int) (entity.getLocation().getZ() - (CornerA.getZ() + 0.5)); + + if (mobData.EntityType == entity.getType() && mobData.DX == dx && mobData.DY == dy && mobData.DZ == dz) + { + score++; + + break; + } + } + } + + return score; + } + + public Location getMidpoint() + { + return UtilAlg.getMidpoint(CornerA, CornerB.clone().add(1, 1, 1)); + } + + public List getBlocks() + { + return UtilBlock.getInBoundingBox(CornerA, CornerB); + } + + public boolean isQueuedForDemolition(Block block) + { + for (DemolitionData demolition : BlocksForDemolition) + { + if (demolition.Blocks.containsKey(block)) + return true; + } + + return false; + } + + public boolean isQueuedForDemolition(Entity entity) + { + for (DemolitionData demolition : BlocksForDemolition) + { + if (demolition.Mobs.contains(entity)) + return true; + } + + return false; + } + + public void addToDemolition(Block block) + { + if (isQueuedForDemolition(block)) + return; + + ArrayList blocks = new ArrayList(); + blocks.add(block); + + //Add the other part of the block + if (block.getType() == Material.BED_BLOCK) + { + Bed bed = (Bed) block.getState().getData(); + + if (bed.isHeadOfBed()) + blocks.add(block.getRelative(bed.getFacing().getOppositeFace())); + else + blocks.add(block.getRelative(bed.getFacing())); + } + else if (block.getType() == Material.WOODEN_DOOR || block.getType() == Material.IRON_DOOR_BLOCK || block.getType() == Material.SPRUCE_DOOR || block.getType() == Material.BIRCH_DOOR || block.getType() == Material.JUNGLE_DOOR || block.getType() == Material.ACACIA_DOOR || block.getType() == Material.DARK_OAK_DOOR) + { + Door door = (Door) block.getState().getData(); + + if (door.isTopHalf()) + blocks.add(block.getRelative(BlockFace.DOWN)); + else + blocks.add(block.getRelative(BlockFace.UP)); + } + else if (block.getType() == Material.DOUBLE_PLANT) + { + if (block.getData() > 7) + blocks.add(block.getRelative(BlockFace.DOWN)); + else + blocks.add(block.getRelative(BlockFace.UP)); + } + + BlocksForDemolition.add(new DemolitionData(this, blocks, new ArrayList())); + } + + public void addToDemolition(Entity entity) + { + if (isQueuedForDemolition(entity)) + return; + + ArrayList mobs = new ArrayList(); + mobs.add(entity); + + BlocksForDemolition.add(new DemolitionData(this, new ArrayList(), mobs)); + } + + public void removeHologram() + { + _hologram.stop(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/events/PerfectBuildEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/events/PerfectBuildEvent.java new file mode 100644 index 000000000..a2fcc31e9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/events/PerfectBuildEvent.java @@ -0,0 +1,50 @@ +package nautilus.game.arcade.game.games.speedbuilders.events; + +import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PerfectBuildEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _player; + private SpeedBuilders _game; + private long _timeElapsed; // Build time elapsed in ms + + public PerfectBuildEvent(Player player, long timeElapsed, SpeedBuilders game) + { + _player = player; + _timeElapsed = timeElapsed; + _game = game; + } + + public Player getPlayer() + { + return _player; + } + + public long getTimeElapsed() + { + return _timeElapsed; + } + + public SpeedBuilders getGame() + { + return _game; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return handlers; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/kits/DefaultKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/kits/DefaultKit.java new file mode 100644 index 000000000..ff79b7fc0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/kits/DefaultKit.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.game.games.speedbuilders.kits; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +public class DefaultKit extends Kit +{ + + public DefaultKit(ArcadeManager manager) + { + super(manager, "Speed Builder", KitAvailability.Free, + new String[] + { + "Professional build recreator!", + }, + new Perk[] + { + + }, + EntityType.ZOMBIE, null); + } + + @Override + public void GiveItems(Player player) + { + + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/DependableTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/DependableTracker.java new file mode 100644 index 000000000..2996d9db2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/DependableTracker.java @@ -0,0 +1,23 @@ +package nautilus.game.arcade.game.games.speedbuilders.stattrackers; + +import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; +import nautilus.game.arcade.game.games.speedbuilders.events.PerfectBuildEvent; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.event.EventHandler; + +public class DependableTracker extends StatTracker +{ + + public DependableTracker(SpeedBuilders game) + { + super(game); + } + + @EventHandler + public void onPerfectBuild(PerfectBuildEvent event) + { + addStat(event.getPlayer(), "PerfectBuild", 1, false, false); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/FirstBuildTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/FirstBuildTracker.java new file mode 100644 index 000000000..c79c55e41 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/FirstBuildTracker.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.speedbuilders.stattrackers; + +import org.bukkit.event.EventHandler; + +import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; +import nautilus.game.arcade.game.games.speedbuilders.events.PerfectBuildEvent; +import nautilus.game.arcade.stats.StatTracker; + +public class FirstBuildTracker extends StatTracker +{ + + private boolean _first = true; + + public FirstBuildTracker(SpeedBuilders game) + { + super(game); + } + + @EventHandler + public void onPerfectBuild(PerfectBuildEvent event) + { + if (_first) + { + addStat(event.getPlayer(), "PerfectFirst", 1, false, false); + + _first = false; + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/PerfectionistTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/PerfectionistTracker.java new file mode 100644 index 000000000..02de00fc5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/PerfectionistTracker.java @@ -0,0 +1,50 @@ +package nautilus.game.arcade.game.games.speedbuilders.stattrackers; + +import java.util.Map.Entry; + +import mineplex.core.common.util.NautHashMap; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; +import nautilus.game.arcade.game.games.speedbuilders.events.PerfectBuildEvent; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class PerfectionistTracker extends StatTracker +{ + + private SpeedBuilders _game; + + private NautHashMap _perfectBuilds = new NautHashMap(); + + public PerfectionistTracker(SpeedBuilders game) + { + super(game); + + _game = game; + } + + @EventHandler + public void onPerfectBuild(PerfectBuildEvent event) + { + int previousPerfectBuilds = _perfectBuilds.containsKey(event.getPlayer()) ? _perfectBuilds.get(event.getPlayer()) : 0; + + _perfectBuilds.put(event.getPlayer(), previousPerfectBuilds + 1); + } + + @EventHandler + public void onEnd(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + return; + + for (Entry entry : _perfectBuilds.entrySet()) + { + if (entry.getValue().intValue() == _game.getRoundsPlayed()) + addStat(entry.getKey(), "PerfectWins", 1, true, false); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/SpeediestBuilderizerTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/SpeediestBuilderizerTracker.java new file mode 100644 index 000000000..800277a22 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/stattrackers/SpeediestBuilderizerTracker.java @@ -0,0 +1,23 @@ +package nautilus.game.arcade.game.games.speedbuilders.stattrackers; + +import org.bukkit.event.EventHandler; + +import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; +import nautilus.game.arcade.game.games.speedbuilders.events.PerfectBuildEvent; +import nautilus.game.arcade.stats.StatTracker; + +public class SpeediestBuilderizerTracker extends StatTracker +{ + public SpeediestBuilderizerTracker(SpeedBuilders game) + { + super(game); + } + + @EventHandler + public void onPerfectBuild(PerfectBuildEvent event) + { + if (event.getTimeElapsed() < 10000) // 10 Seconds + addStat(event.getPlayer(), "SpeediestBuilderizer", 1, true, false); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java index 73d245050..a06235e88 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java @@ -32,6 +32,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.SpleefBlockDestroyStatTracker; import net.minecraft.server.v1_8_R3.EntityArrow; @@ -62,11 +63,23 @@ public class Spleef extends SoloGame this.PrepareFreeze = false; registerStatTrackers(new SpleefBlockDestroyStatTracker(this)); + + registerChatStats( + DamageTaken, + DamageDealt, + BlankLine, + new ChatStatData("SpleefBlocks", "Blocks Broken", true), + BlankLine, + new ChatStatData("kit", "Kit", true) + ); } @EventHandler public void SnowballDamage(ProjectileHitEvent event) { + if (!IsLive()) + return; + if (!(event.getEntity() instanceof Snowball)) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/SpleefTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/SpleefTeams.java index 33477cd48..47ea38230 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/SpleefTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/SpleefTeams.java @@ -30,6 +30,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.spleef.kits.*; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import net.minecraft.server.v1_8_R3.EntityArrow; @@ -59,6 +60,15 @@ public class SpleefTeams extends TeamGame this.TeamArmor = true; this.TeamArmorHotbar = true; + + registerChatStats( + Kills, + Assists, + BlankLine, + new ChatStatData("BlocksBroken", "Blocks Broken", true), + BlankLine, + new ChatStatData("kit", "Kit", true) + ); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java index 8842a3799..a77b8817b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java @@ -50,6 +50,8 @@ public class SquidShooter extends SoloGame this.PrepareFreeze = false; this.CompassEnabled = true; this.KitRegisterState = GameState.Prepare; + + registerChatStats(); } @EventHandler public void Death(CombatDeathEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/stacker/Stacker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/stacker/Stacker.java index 5757baaad..93fd43c1e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/stacker/Stacker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/stacker/Stacker.java @@ -54,6 +54,8 @@ public class Stacker extends SoloGame implements IThrown "Players lose 5 stacked animals if they get hit.", "First to stack 16 high wins!" }); + + registerChatStats(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java index 8085bf2ed..2c71759e9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java @@ -14,6 +14,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.managers.chat.ChatStatData; import org.bukkit.ChatColor; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index b0c034a8f..b39c25164 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -87,6 +87,7 @@ import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.survivalgames.kit.*; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker; import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker; import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker; @@ -260,6 +261,16 @@ public abstract class SurvivalGames extends Game new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"), new FirstSupplyDropOpenStatTracker(this), new SimultaneousSkeletonStatTracker(this, 5)); + + registerChatStats( + Kills, + Assists, + BlankLine, + DamageTaken, + DamageDealt, + BlankLine, + new ChatStatData("SupplyDropsOpened", "Event chests opened", true) + ); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java index f6385469e..9222cd907 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java @@ -50,6 +50,7 @@ import nautilus.game.arcade.game.games.survivalgames.kit.KitHorseman; import nautilus.game.arcade.game.games.survivalgames.kit.KitKnight; import nautilus.game.arcade.game.games.survivalgames.kit.KitLooter; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import org.bukkit.Bukkit; import org.bukkit.ChatColor; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java index baf59a0bf..6b3c717da 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java @@ -17,6 +17,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.managers.chat.ChatStatData; import org.bukkit.ChatColor; import org.bukkit.Location; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/Tug.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/Tug.java index 47e69f1d8..30a7e7a17 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/Tug.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/tug/Tug.java @@ -75,6 +75,8 @@ public class Tug extends TeamGame this.DeathOut = false; this.DeathSpectateSecs = 20; + + registerChatStats(); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index 9494c868e..7b5a20b00 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -4,7 +4,6 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.UUID; @@ -19,23 +18,23 @@ import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArrow; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Arrow; -import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; +import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; -import net.minecraft.server.v1_8_R3.EntityArrow; -import net.minecraft.server.v1_8_R3.Item; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; @@ -53,7 +52,6 @@ import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; @@ -61,7 +59,10 @@ import nautilus.game.arcade.game.games.turfforts.kits.KitInfiltrator; import nautilus.game.arcade.game.games.turfforts.kits.KitMarksman; import nautilus.game.arcade.game.games.turfforts.kits.KitShredder; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.BehindEnemyLinesStatTracker; +import nautilus.game.arcade.stats.BlockBreakStatTracker; +import nautilus.game.arcade.stats.BlockPlaceStatTracker; import nautilus.game.arcade.stats.BlockShreadStatTracker; import nautilus.game.arcade.stats.TheComebackStatTracker; import net.minecraft.server.v1_8_R3.EntityArrow; @@ -114,6 +115,8 @@ public class TurfForts extends TeamGame private long _fightTime = 90000; private boolean _fight = false; private int _lines = 0; + + private BlockBreakStatTracker _breakStatTracker; private HashMap _enemyTurf = new HashMap(); @@ -148,10 +151,23 @@ public class TurfForts extends TeamGame this.DamageSelf = false; this.DeathSpectateSecs = 4; + _breakStatTracker = new BlockBreakStatTracker(this, false); + registerStatTrackers( new BlockShreadStatTracker(this), new BehindEnemyLinesStatTracker(this), - new TheComebackStatTracker(this) + new TheComebackStatTracker(this), + new BlockPlaceStatTracker(this, new Material[]{}), + _breakStatTracker + ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + new ChatStatData("BlocksPlaced", "Blocks Placed", true), + new ChatStatData("BlocksBroken", "Blocks Broken", true) ); } @@ -428,10 +444,12 @@ public class TurfForts extends TeamGame if (block.getData() == 14 /* && team.GetColor() != ChatColor.RED */) { block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK.getId()); + _breakStatTracker.addStat(shooter); } else if (block.getData() == 3 /* && team.GetColor() != ChatColor.AQUA */) { block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId()); + _breakStatTracker.addStat(shooter); } Bukkit.getPluginManager().callEvent(new ShredBlockEvent(block, arrow)); @@ -694,6 +712,32 @@ public class TurfForts extends TeamGame continue; Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); + + // Apply velocity even if the player is sneaking near turf edges. + + if (block.isEmpty() && player.isOnGround()) + { + Block[] nearby = { + block.getRelative(BlockFace.NORTH), + block.getRelative(BlockFace.SOUTH), + block.getRelative(BlockFace.WEST), + block.getRelative(BlockFace.EAST), + block.getRelative(BlockFace.NORTH_EAST), + block.getRelative(BlockFace.NORTH_WEST), + block.getRelative(BlockFace.SOUTH_EAST), + block.getRelative(BlockFace.SOUTH_WEST) + }; + + for (Block near : nearby) + { + if (near.getType() == Material.STAINED_CLAY || near.getType() == Material.WOOL) + { + block = near; + break; + } + } + } + while (block.getTypeId() != 159 && block.getY() > 0) block = block.getRelative(BlockFace.DOWN); @@ -732,8 +776,8 @@ public class TurfForts extends TeamGame player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); UtilPlayer.message(player, F.main("Game", "You cannot walk on the enemies turf!")); } - - return; + + // return; } //On Own Turf else if ((team.GetColor() == ChatColor.RED && data == 14) || (team.GetColor() == ChatColor.AQUA && data == 3)) @@ -815,4 +859,58 @@ public class TurfForts extends TeamGame { return _enemyTurf.get(player); } -} + + // Fixed by TeddyDev. + @EventHandler + public void blockGlitchFix(PlayerInteractEvent event) + { + if(event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if(event.getPlayer().isOnGround()) + return; + + Block block = event.getClickedBlock(); + if(block.getType() == Material.STAINED_CLAY || block.getType() == Material.WOOL) + return; + + Player player = event.getPlayer(); + Block ground = player.getLocation().getBlock(); + while (ground.getType() == Material.AIR && ground.getLocation().getBlockY() >= 0) + { + ground = ground.getRelative(BlockFace.DOWN); + } + + if(ground.isLiquid()) + { + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.VOID, 9001, false, false, false, + "Border", "Border Damage"); + player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); + return; + } + + if(player.getLocation().distance(ground.getLocation()) < 4) + return; + + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.VOID, 9001, false, false, false, + "Border", "Border Damage"); + player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); + } + + // Keep ladders placed on ice when block updates occur. + @EventHandler + public void ladderDestroyFix(BlockPhysicsEvent event) + { + if (!IsLive()) + return; + + Block block = event.getBlock(); + + if (block.getType() == Material.LADDER) + { + event.setCancelled(true); + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Minion.java index b4c4832cf..91d05aef2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Minion.java @@ -122,7 +122,7 @@ public class Minion "Purpose", "Symptom", "Sticks", "Measure", "Slimes", "Greece", "Spooky", "Coffee", "Aliens", "Cities", "Bikini", "Mortal", "Serena", "Future", "Bottle", "Helmet", "Crunch", "Afraid", "Threat", "Static", "Happy", "Knife", "Scary", "Lapis", "Skirt", "Waves", "Calem", "Clock", "Taste", "Lucas", - "Anger", "Spork", "Maike", "Candy", "Shirt", "Tides", "Ocean", "Crawl", "Smell", "React", + "Anger", "Spork", "Make", "Candy", "Shirt", "Tides", "Ocean", "Crawl", "Smell", "React", "Dolls", "Roses", "Trips", "Flute", "Pants", "Brick", "Three", "Ethan", "Uncle", "Lunch", "Legos", "Tulip", "Beach", "Wipes", "Heels", "Straw", "Seven", "Hands", "Queen", "Books", "Couch", "Grass", "Clans", "Frame", "Nails", "Cream", "Eight", "Belly", "Crown", "Polls", diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java new file mode 100644 index 000000000..dc6a87727 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java @@ -0,0 +1,101 @@ +package nautilus.game.arcade.game.games.typewars; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.typewars.TypeWars.KillType; + +public class StaffKillMonitorManager implements Listener +{ + /** + * Created by: Mysticate + * Timestamp: December 30, 2015 + */ + + private TypeWars _host; + private String _command = "/words"; + + private NautHashMap _monitoring = new NautHashMap(); + + public StaffKillMonitorManager(TypeWars host) + { + _host = host; + + host.Manager.registerEvents(this);; + } + + public TypeWars getHost() + { + return _host; + } + + @EventHandler + public void onEnd(GameStateChangeEvent event) + { + if (event.GetState() == GameState.End) + HandlerList.unregisterAll(this); + } + + @EventHandler + public void onKill(MinionKillEvent event) + { + if (event.getType() == KillType.SPELL) + return; + + for (Player staff : _monitoring.keySet()) + { + if (_monitoring.get(staff) == event.getPlayer()) + { + UtilPlayer.message(staff, F.elem(C.cRedB + ">>") + F.name(event.getPlayer().getName()) + " killed " + F.elem(C.cGold + event.getMinion().getName()) + "."); + } + } + } + + @EventHandler + public void onCommand(PlayerCommandPreprocessEvent event) + { + if (!_host.IsLive()) + return; + + if (!_host.Manager.GetClients().hasRank(event.getPlayer(), Rank.HELPER)) + return; + + event.setCancelled(true); + + String[] message = event.getMessage().toLowerCase().split(" "); + if (message.length == 0 || !message[0].equalsIgnoreCase(_command)) + return; + + if (message.length == 1) + { + if (_monitoring.containsKey(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("TypeWars", "You are no longer monitoring " + F.name(_monitoring.remove(event.getPlayer()).getName()) + ".")); + } + else + { + UtilPlayer.message(event.getPlayer(), F.main("TypeWars", "Please enter a player to monitor!")); + } + return; + } + + String playerName = message[1]; + + Player player = UtilPlayer.searchOnline(event.getPlayer(), playerName, true); + if (player == null) + return; + + _monitoring.put(event.getPlayer(), player); + UtilPlayer.message(event.getPlayer(), F.main("TypeWars", "You are now monitoring " + F.name(player.getName()) + ". Type " + F.elem(_command) + " to stop.")); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java index e8786ddbc..fd5ad26b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java @@ -5,6 +5,27 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Giant; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.util.Vector; + import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -45,33 +66,12 @@ import nautilus.game.arcade.game.games.typewars.tutorial.TutorialTypeWars; import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent; import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.TimeInGameStatTracker; import nautilus.game.arcade.world.WorldData; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Giant; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntitySpawnEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.util.Vector; - public class TypeWars extends TeamGame -{ - +{ private ArrayList _activeMinions; private ArrayList _deadMinions; private ArrayList _finishedMinions; @@ -114,6 +114,8 @@ public class TypeWars extends TeamGame "Kill your enemies Giant before they kill yours!" }); + new StaffKillMonitorManager(this); + this.DeathOut = false; this.DamageTeamSelf = false; this.DamageSelf = false; @@ -167,6 +169,10 @@ public class TypeWars extends TeamGame new KillsStatTracker(this), new TimeInGameTracker(this) ); + + registerChatStats( + new ChatStatData("MinionKills", "Kills", true) + ); manager.GetCreature().SetDisableCustomDrops(true); manager.GetChat().setThreeSecondDelay(false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index e1523f86c..d543c505a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -207,6 +207,14 @@ public class UHC extends TeamGame _createTime = System.currentTimeMillis(); _serverTime = Utility.currentTimeMillis(); + + registerChatStats( + Kills, + Assists, + BlankLine, + DamageTaken, + DamageDealt + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java index c224dcedf..efa9c8342 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java @@ -66,6 +66,7 @@ import nautilus.game.arcade.game.games.wither.kit.KitWitherMinion; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; import nautilus.game.arcade.kit.perks.data.IBlockRestorer; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.TeamDeathsStatTracker; import nautilus.game.arcade.stats.TeamKillsStatTracker; @@ -148,6 +149,14 @@ public class WitherGame extends TeamGame implements IBlockRestorer new TeamDeathsStatTracker(this), new TeamKillsStatTracker(this) ); + + registerChatStats( + Deaths, + DamageTaken, + DamageDealt, + BlankLine, + new ChatStatData("kit", "Kit", true) + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java index 64afb0d14..9ab574b9b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java @@ -54,6 +54,7 @@ import net.minecraft.server.v1_8_R3.EntityFireball; import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; +import nautilus.game.arcade.managers.chat.ChatStatData; import org.apache.commons.lang.IllegalClassException; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -166,6 +167,16 @@ public class Wizards extends SoloGame SoupEnabled = false; DamageTeamSelf = true; + registerChatStats( + Kills, + Assists, + BlankLine, + DamageTaken, + DamageDealt, + BlankLine, + new ChatStatData("kit", "Kit", true) + ); + Manager.getCosmeticManager().setHideParticles(true); // Manager.GetDamage().GetCombatManager().setUseWeaponName(AttackReason.DefaultWeaponName); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java index 3d1a0247d..3f118fbb9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java @@ -71,6 +71,11 @@ public class ZombieSurvival extends SoloGame this.HungerSet = 20; this.CompassEnabled = true; + + registerChatStats( + Kills, + Assists + ); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/button/SpectatorButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/button/SpectatorButton.java index fa5b7e111..d2f170f5f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/button/SpectatorButton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/button/SpectatorButton.java @@ -1,10 +1,15 @@ package nautilus.game.arcade.gui.spectatorMenu.button; +import org.bukkit.GameMode; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextBottom; import mineplex.core.shop.item.IButton; import nautilus.game.arcade.ArcadeManager; @@ -33,7 +38,26 @@ public class SpectatorButton implements IButton if (_arcadeManager.IsAlive(_target)) { - _player.teleport(_target.getLocation().add(0, 1, 0)); + if(clickType == ClickType.RIGHT) + { + _player.closeInventory(); + _player.teleport(_target.getLocation().add(0, 1, 0)); + _arcadeManager.runSyncLater(new Runnable() + { + @Override + public void run() + { + _player.setGameMode(GameMode.SPECTATOR); + _player.setSpectatorTarget(_target); + UtilTextBottom.display(C.cYellow + "You are spectating " + F.game(_target.getName()), player); + UtilPlayer.message(_player, F.main("Game", "Sneak to stop spectating")); + } + }, 3); + } + else + { + _player.teleport(_target.getLocation().add(0, 1, 0)); + } } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java index 1b687bb71..5a2a4fe36 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java @@ -228,7 +228,8 @@ public class SpectatorPage extends lore.add(ChatColor.RESET + C.cYellow + "Height Difference: " + C.cWhite + UtilMath.trim(1, heightDifference)); lore.add(" "); - lore.add(ChatColor.RESET + C.Line + "Click to Spectate"); + lore.add(ChatColor.YELLOW + "Left Click" + ChatColor.RESET + " Teleport"); + lore.add(ChatColor.YELLOW + "Right Click" + ChatColor.RESET + " Spectate"); SkullMeta skullMeta = ((SkullMeta) item.getItemMeta()); skullMeta.setOwner(other.getName()); skullMeta.setDisplayName(team.GetColor() + other.getName()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java index 99a6f459e..fee34747e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInkBlast.java @@ -33,12 +33,18 @@ import nautilus.game.arcade.kit.SmashPerk; public class PerkInkBlast extends SmashPerk implements IThrown { - public PerkInkBlast() + private int _bullets; + private double _damagePerBullet; + + public PerkInkBlast(int bullets, double damagePerBullet) { super("Ink Shotgun", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Ink Shotgun" }); + + _bullets = bullets; + _damagePerBullet = damagePerBullet; } @@ -75,7 +81,7 @@ public class PerkInkBlast extends SmashPerk implements IThrown UtilInv.Update(player); - for (int i=0 ; i<7 ; i++) + for (int i=0 ; i < _bullets ; i++) { org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(Material.INK_SACK, (byte)0, 1, "Ink" + Math.random())); @@ -113,7 +119,7 @@ public class PerkInkBlast extends SmashPerk implements IThrown //Damage Event Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null, - DamageCause.PROJECTILE, 3, true, true, false, + DamageCause.PROJECTILE, _damagePerBullet, true, true, false, UtilEnt.getName(data.GetThrower()), GetName()); UtilParticle.PlayParticle(ParticleType.EXPLODE, target.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0, 12, ViewDist.LONG, UtilServer.getPlayers()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java deleted file mode 100644 index 4b520c4d8..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java +++ /dev/null @@ -1,177 +0,0 @@ -package nautilus.game.arcade.managers; - -import java.util.Iterator; - -import mineplex.core.account.CoreClient; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.party.Party; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.GameTeam; - -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; - -public class GameChatManager implements Listener -{ - ArcadeManager Manager; - - public GameChatManager(ArcadeManager manager) - { - Manager = manager; - - Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); - } - - @EventHandler - public void MeCancel(PlayerCommandPreprocessEvent event) - { - if (event.getMessage().startsWith("/me ")) - { - event.getPlayer().sendMessage(F.main("Mirror", "You can't see /me messages, are you a vampire?")); - event.setCancelled(true); - } - } - - @EventHandler - public void HandleChat(AsyncPlayerChatEvent event) - { - if (event.isCancelled()) - return; - - Player sender = event.getPlayer(); - String senderName = sender.getName(); - - //Dead Prefix - String dead = ""; - if (Manager.GetGame() != null) - if (Manager.GetGame().GetTeam(sender) != null) - if (!Manager.GetGame().IsAlive(sender)) - dead = C.cGray + "Dead "; - - Rank rank = Manager.GetClients().Get(sender).GetRank(); - String disguiseTag = ""; - if(Manager.GetClients().Get(sender).isDisguised()) - { - CoreClient cc = Manager.GetClients().Get(sender); - rank = cc.getDisguisedRank(); - - if(!cc.GetRank().has(Rank.JNR_DEV)) - { - disguiseTag = ChatColor.BLACK + " "; - } - } - - boolean ownsUltra = false; - - if (Manager.GetGame() != null) - ownsUltra= Manager.GetDonation().Get(sender.getName()).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA"); - - //Level - String levelStr = ""; - if (!Manager.GetGameHostManager().isPrivateServer()) - levelStr = Manager.GetAchievement().getMineplexLevel(sender, rank); - - String rankStr = ""; - //Rank Prefix & MPS Host Prefix - if (Manager.GetGameHostManager().isHost(event.getPlayer())) - { - if (Manager.GetGameHostManager().isEventServer()) - rankStr = C.cDGreen + C.Bold + "Event Host "; - else - rankStr = C.cDGreen + C.Bold + "MPS Host "; - } - else if (Manager.GetGameHostManager().isAdmin(event.getPlayer(), false)) - { - if (Manager.GetGameHostManager().isEventServer()) - rankStr = C.cDGreen + C.Bold + "Event Co-Host "; - else - rankStr = C.cDGreen + C.Bold + "MPS Co-Host "; - } - else - { - if (rank != Rank.ALL) - rankStr = rank.getTag(true, true) + " "; - - if (ownsUltra && !rank.has(Rank.ULTRA)) - rankStr = Rank.ULTRA.getTag(true, true) + " "; - } - - if (event.getMessage().charAt(0) == '@') - { - //Party Chat - Party party = Manager.getPartyManager().GetParty(sender); - - if (party != null) - { - event.getRecipients().clear(); - - event.setMessage(event.getMessage().substring(1, event.getMessage().length())); - event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + senderName + " " + C.cPurple + "%2$s"); - - event.getRecipients().addAll(party.GetPlayersOnline()); - - return; - } - } - - //Base Format - event.setFormat(disguiseTag + dead + levelStr + rankStr + Manager.GetColor(sender) + senderName + " " + ChatColor.WHITE + "%2$s"); - - //Public/Private (Not If Player Dead) - if (Manager.GetGame() != null && Manager.GetGame().GetState() == GameState.Live) - { - boolean globalMessage = false; - - //Team - GameTeam team = Manager.GetGame().GetTeam(sender); - - if (team != null) - { - //Team Chat - if (event.getMessage().charAt(0) == '@') - { - event.setMessage(event.getMessage().substring(1, event.getMessage().length())); - event.setFormat(disguiseTag + C.cWhite + C.Bold + "Team" + " " + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); - } - //All Chat - else - { - globalMessage = true; - event.setFormat(disguiseTag + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); - } - } - - if (globalMessage) - return; - - //Team Message Remove Recipient - Iterator recipientIterator = event.getRecipients().iterator(); - - while (recipientIterator.hasNext()) - { - Player receiver = recipientIterator.next(); - - if (!Manager.GetServerConfig().Tournament && Manager.GetClients().Get(receiver).GetRank().has(Rank.MODERATOR)) - continue; - - GameTeam recTeam = Manager.GetGame().GetTeam(receiver); - GameTeam sendTeam = Manager.GetGame().GetTeam(sender); - - if (recTeam == null || sendTeam == null) - { - continue; - } - - if (!recTeam.equals(sendTeam)) - recipientIterator.remove(); - } - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java index 1e51b1d42..ef31b741b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java @@ -97,6 +97,7 @@ public class GameCreationManager implements Listener { Game game = gameIterator.next(); + game.disable(); HandlerList.unregisterAll(game); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index f0533de91..ff47122fb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -888,7 +888,7 @@ public class GameFlagManager implements Listener for (Player player : UtilServer.getPlayers()) { if (!game.isInsideMap(player) && game.IsAlive(player)) - { + { //Riding a Projectile, edgecase if (player.getVehicle() != null && player.getVehicle() instanceof Projectile) { @@ -897,38 +897,36 @@ public class GameFlagManager implements Listener ((CraftPlayer)player).getHandle().spectating = false; } - if (!Manager.IsAlive(player) || ((CraftPlayer)player).getHandle().spectating) + if (!game.WorldBoundaryKill) { - player.teleport(game.GetSpectatorLocation()); + UtilPlayer.message(player, C.cRed + C.Bold + "WARNING: " + C.cWhite + C.Bold + "RETURN TO PLAYABLE AREA!"); + + if (game.GetType() != GameType.Gravity) + { + if (player.getLocation().getY() > game.WorldData.MaxY) + UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0, 0, 10, true); + else + UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0.4, 0, 10, true); + } + + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.VOID, 4, false, false, false, + "Border", "Border Damage"); + + player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); + player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); } else { - if (!game.WorldBoundaryKill) - { - UtilPlayer.message(player, C.cRed + C.Bold + "WARNING: " + C.cWhite + C.Bold + "RETURN TO PLAYABLE AREA!"); - - if (game.GetType() != GameType.Gravity) - { - if (player.getLocation().getY() > game.WorldData.MaxY) - UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0, 0, 10, true); - else - UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0.4, 0, 10, true); - } - - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.VOID, 4, false, false, false, - "Border", "Border Damage"); - - player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); - player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); - } - else - { - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.VOID, 9001, false, false, false, - "Border", "Border Damage"); - } - } + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.VOID, 9001, false, false, false, + "Border", "Border Damage"); + } + } + + if (!game.isInsideMap(player) && (!Manager.IsAlive(player) || ((CraftPlayer)player).getHandle().spectating)) + { + player.teleport(game.GetSpectatorLocation()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 0b81cdb41..4217217d9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -96,6 +96,7 @@ public class GameHostManager implements Listener ultraGames.add(GameType.Lobbers); ultraGames.add(GameType.Evolution); ultraGames.add(GameType.MonsterMaze); + ultraGames.add(GameType.Gladiators); //Hero Games heroGames.add(GameType.ChampionsDominate); @@ -114,6 +115,7 @@ public class GameHostManager implements Listener legendGames.add(GameType.UHC); legendGames.add(GameType.MineStrike); legendGames.add(GameType.Skywars); + legendGames.add(GameType.SpeedBuilders); // Team variants - Currently being remade. /* legendGames.add(GameType.DragonEscapeTeams); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index c3fd7777d..be185ed2b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -61,7 +61,8 @@ public class GameManager implements Listener Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); } - + + /* @EventHandler public void displaySale(UpdateEvent event) { @@ -78,6 +79,7 @@ public class GameManager implements Listener player.sendMessage(C.cWhite + " "); } } + */ @EventHandler public void DisplayIP(UpdateEvent event) @@ -97,7 +99,7 @@ public class GameManager implements Listener - + /* //Christmas _animationIndex = (_animationIndex + 1) % 40; @@ -132,7 +134,7 @@ public class GameManager implements Listener if (_animationIndex >= 27) text = C.cWhite + " ❄ " + C.cRed + " Massive Winter Sale " + C.cGreenB + " " + C.cWhiteB + "50% OFF ALL RANKS " + C.cYellow + " www.mineplex.com/shop " + C.cWhite + " ❄"; - + */ diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java index f82d75403..0082fc1ce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java @@ -1,15 +1,34 @@ package nautilus.game.arcade.managers; +import java.util.List; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.event.vehicle.VehicleDamageEvent; +import org.bukkit.inventory.ItemStack; public class GameSpectatorManager implements Listener { @@ -22,9 +41,9 @@ public class GameSpectatorManager implements Listener Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); } - @EventHandler(priority = EventPriority.LOW) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void interactCancel(PlayerInteractEvent event) - { + { if (Manager.GetGame() == null) return; @@ -32,6 +51,56 @@ public class GameSpectatorManager implements Listener if (!Manager.GetGame().IsAlive(player)) event.setCancelled(true); + + processClick(player, event.getAction()); + } + + public void processClick(Player player, Action action) + { + if (Manager.GetGame() == null) + return; + + if(!Manager.GetGame().AllowEntitySpectate) + return; + + if(!Manager.GetGame().IsLive()) + return; + + if(player.getGameMode() != GameMode.SPECTATOR) + return; + + if(player.getSpectatorTarget() == null) + return; + + if(!(player.getSpectatorTarget() instanceof Player)) + return; + + List players = Manager.GetGame().GetPlayers(true); + int currentPlayer = 0; + for(Player otherPlayer : players) + { + currentPlayer++; + if(((Player) player.getSpectatorTarget()) == otherPlayer) + break; + } + + if(action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) + currentPlayer = currentPlayer - 2; + else + return; + + if(currentPlayer < 0) + currentPlayer = players.size() - 1; + + if(currentPlayer >= players.size()) + currentPlayer = 0; + + if(players.get(currentPlayer) == null) + return; + + Player specPlayer = players.get(currentPlayer); + + setSpectating(player, specPlayer); } @EventHandler(priority = EventPriority.LOW) @@ -51,7 +120,127 @@ public class GameSpectatorManager implements Listener } if (!Manager.GetGame().IsAlive(player)) + { event.setCancelled(true); + if(Manager.GetGame().IsLive()) + { + if(Manager.GetGame().AllowEntitySpectate) + { + setSpectating(player, event.getRightClicked()); + } + } + } + } + + @EventHandler + public void updateSpecEntitys(UpdateEvent event) + { + if(event.getType() != UpdateType.FASTER) + return; + + if(Manager.GetGame() == null) + return; + + if(Manager.GetGame().IsLive() || Manager.GetGame().GetState() == GameState.End) + { + if(Manager.GetGame().AllowEntitySpectate) + { + for(Player player : UtilServer.getPlayers()) + { + if (!Manager.GetGame().IsAlive(player)) + { + if(player.getGameMode() == GameMode.SPECTATOR) + { + if(player.getSpectatorTarget() == null) + { + player.setGameMode(GameMode.SURVIVAL); + player.setAllowFlight(true); + } + } + } + } + } + } + } + + @EventHandler(priority = EventPriority.LOW) + public void spectatedEntityDeath(PlayerDeathEvent event) + { + if(Manager.GetGame() == null) + return; + + if(Manager.GetGame().IsLive() || Manager.GetGame().GetState() == GameState.End) + { + if(Manager.GetGame().AllowEntitySpectate) + { + for(Player player : UtilServer.getPlayers()) + { + if (!Manager.GetGame().IsAlive(player)) + { + if(player.getGameMode() == GameMode.SPECTATOR) + { + if(player.getSpectatorTarget() == event.getEntity()) + { + if(Manager.GetGame().GetPlayers(true).size() >= 1) + { + setSpectating(player, Manager.GetGame().GetPlayers(true).get(UtilMath.r(Manager.GetGame().GetPlayers(true).size()))); + return; + } + player.setGameMode(GameMode.SURVIVAL); + player.setAllowFlight(true); + } + } + } + } + } + } + } + + @EventHandler(priority = EventPriority.LOW) + public void dismountEntity(PlayerToggleSneakEvent event) + { + if(Manager.GetGame() == null) + return; + + if(Manager.GetGame().IsLive() || Manager.GetGame().GetState() == GameState.End) + { + if(Manager.GetGame().AllowEntitySpectate) + { + if(!Manager.GetGame().IsAlive(event.getPlayer())) + { + if(event.getPlayer().getGameMode() == GameMode.SPECTATOR) + { + event.getPlayer().setGameMode(GameMode.SURVIVAL); + event.getPlayer().setAllowFlight(true); + } + } + } + } + } + + private void setSpectating(Player player, Entity target) + { + player.setGameMode(GameMode.SURVIVAL); + player.teleport(target.getLocation().add(0, 1, 0)); + player.getInventory().setHeldItemSlot(5); + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + if(target instanceof Player) + { + if(!Manager.GetGame().IsAlive(target)) + return; + } + player.setGameMode(GameMode.SPECTATOR); + player.setSpectatorTarget(target); + if(target instanceof Player) + UtilTextBottom.display(C.cYellow + "You are spectating " + F.game(((Player) target).getName()), player); + + UtilPlayer.message(player, F.main("Game", "Sneak to stop spectating")); + } + }, 3); } @EventHandler(priority = EventPriority.LOW) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/ChatStatData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/ChatStatData.java new file mode 100644 index 000000000..e5a692036 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/ChatStatData.java @@ -0,0 +1,56 @@ +package nautilus.game.arcade.managers.chat; + +/** + * Created by TeddyDev on 10/01/2016. + */ +public class ChatStatData +{ + private String _stat; + private String _display; + private boolean _isValue; + + public ChatStatData() + { + + } + + public ChatStatData(String stat, String display, boolean isValue) + { + _stat = stat; + _display = display; + _isValue = isValue; + } + + public ChatStatData blankLine() + { + _stat = null; + _display = " "; + _isValue = false; + + return this; + } + + public ChatStatData plainText(String text) + { + _stat = null; + _display = text; + _isValue = false; + + return this; + } + + public String getStat() + { + return _stat; + } + + public String getDisplay() + { + return _display; + } + + public boolean isValue() + { + return _isValue; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java new file mode 100644 index 000000000..8ba8039e8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java @@ -0,0 +1,383 @@ +package nautilus.game.arcade.managers.chat; + +import java.text.DecimalFormat; +import java.util.AbstractMap; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Map; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; + +import mineplex.core.account.CoreClient; +import mineplex.core.common.Rank; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.party.Party; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import org.jooq.tools.json.JSONObject; + +public class GameChatManager implements Listener +{ + + private ArcadeManager _manager; + + private LinkedList _chatStats; + + public GameChatManager(ArcadeManager manager) + { + _manager = manager; + + _manager.getPluginManager().registerEvents(this, _manager.getPlugin()); + + _chatStats = new LinkedList(); + } + + @EventHandler + public void MeCancel(PlayerCommandPreprocessEvent event) + { + if (event.getMessage().startsWith("/me ")) + { + UtilPlayer.message(event.getPlayer(), F.main("Mirror", "You can't see /me messages, are you a vampire?")); + event.setCancelled(true); + } + } + + @EventHandler + public void HandleChat(AsyncPlayerChatEvent event) + { + if (event.isCancelled()) + return; + + Player sender = event.getPlayer(); + String senderName = sender.getName(); + + String format = ""; + String name = ""; + String message = ""; + + + //Dead Prefix + String dead = ""; + if (_manager.GetGame() != null) + if (_manager.GetGame().GetTeam(sender) != null) + if (!_manager.GetGame().IsAlive(sender)) + dead = C.cGray + "Dead " + C.Reset; + + Rank rank = _manager.GetClients().Get(sender).GetRank(); + String disguiseTag = ""; + if(_manager.GetClients().Get(sender).isDisguised()) + { + CoreClient cc = _manager.GetClients().Get(sender); + rank = cc.getDisguisedRank(); + + if(!cc.GetRank().has(Rank.JNR_DEV)) + { + disguiseTag = ChatColor.BLACK + " "; + } + } + + boolean ownsUltra = false; + + if (_manager.GetGame() != null) + ownsUltra = _manager.GetDonation().Get(sender.getName()).OwnsUnknownPackage(_manager.GetServerConfig().ServerType + " ULTRA"); + + //Level + String levelStr = ""; + if (!_manager.GetGameHostManager().isPrivateServer()) + levelStr = _manager.GetAchievement().getMineplexLevel(sender, rank); + + String rankStr = ""; + //Rank Prefix & MPS Host Prefix + if (_manager.GetGameHostManager().isHost(event.getPlayer())) + { + if (_manager.GetGameHostManager().isEventServer()) + rankStr = C.cDGreen + C.Bold + "Event Host " + C.Reset; + else + rankStr = C.cDGreen + C.Bold + "MPS Host " + C.Reset; + } + else if (_manager.GetGameHostManager().isAdmin(event.getPlayer(), false)) + { + if (_manager.GetGameHostManager().isEventServer()) + rankStr = C.cDGreen + C.Bold + "Event Co-Host " + C.Reset; + else + rankStr = C.cDGreen + C.Bold + "MPS Co-Host " + C.Reset; + } + else + { + if (rank != Rank.ALL) + rankStr = rank.getTag(true, true) + " " + C.Reset; + + if (ownsUltra && !rank.has(Rank.ULTRA)) + rankStr = Rank.ULTRA.getTag(true, true) + " " + C.Reset; + } + + if (event.getMessage().charAt(0) == '@') + { + //Party Chat + Party party = _manager.getPartyManager().GetParty(sender); + + if (party != null) + { + event.getRecipients().clear(); + + rankStr = C.cDPurpleB + "Party " + C.Reset; + + event.setMessage(event.getMessage().substring(1, event.getMessage().length())); + event.setFormat(levelStr + rankStr + C.cWhiteB + senderName + " " + C.cPurple + "%2$s"); + + format = event.getFormat().split(rankStr)[0]; + name = C.cWhiteB + sender.getName() + C.Reset; + message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage()); + + if(safeSend(sender, format, rankStr, rank, name, message, party.GetPlayersOnline())) + { + event.setCancelled(true); + } + + return; + } + } + + event.setFormat(levelStr + rankStr + senderName + " " + C.cWhite + "%2$s"); + + if(rankStr.equals("")) + format = levelStr; + else + format = event.getFormat().split(rankStr)[0]; + + name = _manager.GetColor(sender) + sender.getName() + C.Reset; + message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage()); + + if (_manager.GetGame().GetState() != GameState.Live) + { + event.setFormat(levelStr + rankStr + senderName + " " + C.cWhite + "%2$s"); + + if(safeSend(sender, format, rankStr, rank, name, message, event.getRecipients())) + { + event.setCancelled(true); + } + + return; + } + + //Base Format + event.setFormat(disguiseTag + dead + levelStr + rankStr + _manager.GetColor(sender) + senderName + " " + C.cWhite + "%2$s"); + + //Public/Private (Not If Player Dead) + if (_manager.GetGame() != null && _manager.GetGame().GetState() == GameState.Live) + { + boolean globalMessage = false; + + //Team + GameTeam team = _manager.GetGame().GetTeam(sender); + + if (team != null) + { + boolean isPriv = event.getMessage().charAt(0) == '@'; + + if(isPriv) + event.setMessage(event.getMessage().substring(1, event.getMessage().length())); + else + globalMessage = true; + + event.setFormat(isPriv ? disguiseTag + C.cWhiteB + "Team " + dead + levelStr + rankStr + senderName + " " + C.cWhite + "%2$s" : disguiseTag + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); + + if(rankStr.equals("")) + format = isPriv ? disguiseTag + C.cWhiteB + "Team " + dead + levelStr : disguiseTag + dead + levelStr; + else + format = event.getFormat().split(rankStr)[0]; + + name = isPriv ? team.GetColor() + sender.getName() : _manager.GetColor(sender) + sender.getName(); + } + else + { + globalMessage = true; + event.setFormat(disguiseTag + dead + levelStr + rankStr + senderName + " " + C.cWhite + "%2$s"); + + if(rankStr.equals("")) + format = disguiseTag + dead + levelStr; + else + format = event.getFormat().split(rankStr)[0]; + + name = _manager.GetColor(sender) + sender.getName(); + } + + if (globalMessage) + { + if(safeSend(sender, format, rankStr, rank, name, message, event.getRecipients())) + { + event.setCancelled(true); + } + return; + } + + //Team Message Remove Recipient + Iterator recipientIterator = event.getRecipients().iterator(); + + while (recipientIterator.hasNext()) + { + Player receiver = recipientIterator.next(); + + if (!_manager.GetServerConfig().Tournament && _manager.GetClients().Get(receiver).GetRank().has(Rank.MODERATOR)) + continue; + + GameTeam recTeam = _manager.GetGame().GetTeam(receiver); + GameTeam sendTeam = _manager.GetGame().GetTeam(sender); + + if (recTeam == null || sendTeam == null) + { + continue; + } + + if (!recTeam.equals(sendTeam)) + recipientIterator.remove(); + } + + if(safeSend(sender, format, rankStr, rank, name, message, event.getRecipients())) + { + event.setCancelled(true); + } + } + } + + public boolean safeSend(Player sender, String prefix, String rankStr, Rank rank, String name, String message, Collection sendto) + { + final JsonMessage json = buildJSON(sender, prefix, rankStr, rank, name, _chatStats, message); + try + { + json.send(JsonMessage.MessageType.CHAT_BOX, sendto.toArray(new Player[sendto.size()])); + return true; + } + catch (Exception e) + { + System.out.println("ChatStats Failed to send JSON message.."); + System.out.println(json); + return false; + } + } + + public void setGameChatStats(ChatStatData... stats) + { + _chatStats = new LinkedList(); + for(ChatStatData chatStat : stats) + { + _chatStats.add(chatStat); + } + } + + private JsonMessage buildJSON(Player player, String prefix, String rankStr, Rank rank, String name, LinkedList hoverText, String message) + { + if(_manager.GetGame().GetState() != GameState.Prepare && _manager.GetGame().GetState() != GameState.Live && _manager.GetGame().GetState() != GameState.End) + { + if(rank == Rank.ALL) + { + return new JsonMessage("").extra(JSONObject.escape(prefix)) + .add(JSONObject.escape(rankStr)).add(JSONObject.escape(name)).add(JSONObject.escape(message)); + } + + return new JsonMessage("").extra(JSONObject.escape(prefix)) + .add(JSONObject.escape(rankStr)).hover("show_text", rank.getColor() + rank.getTag(true, true) + C.cWhite + "\n" + rank.getDescription()) + .add(JSONObject.escape(name)).add(JSONObject.escape(message)); + } + + LinkedList> temp = new LinkedList>(); + ChatColor teamColor = _manager.GetColor(player); + + temp.add(new AbstractMap.SimpleEntry(teamColor + C.Bold + ChatColor.stripColor(name) + teamColor + "'s stats", "")); + temp.add(new AbstractMap.SimpleEntry(" ", "")); + + Game game = _manager.GetGame(); + String gameName = game.GetName(); + + for (int i = 0; i < hoverText.size(); i++) + { + if (!_manager.GetGame().GetStats().containsKey(player)) + { + temp.add(new AbstractMap.SimpleEntry(C.cGray + "Retrieving stats..", "")); + break; + } + + ChatStatData chatStatData = hoverText.get(i); + String display = (chatStatData.getDisplay() == null ? chatStatData.getStat() : chatStatData.getDisplay()); + + if(!chatStatData.isValue()) + { + temp.add(new AbstractMap.SimpleEntry(chatStatData.getDisplay(), "")); + continue; + } + + if (chatStatData.getStat().equalsIgnoreCase("kit")) + { + temp.add(new AbstractMap.SimpleEntry(display + ": ", game.GetKit(player).GetName())); + continue; + } + + if (chatStatData.getStat().equalsIgnoreCase("kdratio")) + { + int kills; + int deaths; + + if (game.GetStats().get(player).containsKey(gameName + ".Kills")) + kills = game.GetStats().get(player).get(gameName + ".Kills"); + else + kills = 0; + + if (game.GetStats().get(player).containsKey(gameName + ".Deaths")) + deaths = game.GetStats().get(player).get(gameName + ".Deaths"); + else + deaths = 0; + + temp.add(new AbstractMap.SimpleEntry(display + ": ", "" + getRatio(kills, deaths, "##.##"))); + continue; + } + + if (game.GetStats().get(player).containsKey(gameName + "." + chatStatData.getStat())) + { + temp.add(new AbstractMap.SimpleEntry(display + ": ", (game.GetStats().get(player).get(gameName + "." + chatStatData.getStat()).toString()))); + } + else + { + temp.add(new AbstractMap.SimpleEntry(display + ": ", "0")); + } + } + + String stats = ""; + for (int i = 0; i < temp.size(); i++) + { + stats += C.cWhite + JSONObject.escape(temp.get(i).getKey()) + C.cGray + JSONObject.escape(temp.get(i).getValue()) + (i >= temp.size()-1 ? "" : "\\n"); + } + + if(rank == Rank.ALL) + { + return new JsonMessage("").extra(JSONObject.escape(prefix)) + .add(JSONObject.escape(rankStr)).add(JSONObject.escape(name)).hover("show_text", stats).add(JSONObject.escape(message)); + } + + return new JsonMessage("").extra(JSONObject.escape(prefix)) + .add(JSONObject.escape(rankStr)).hover("show_text", rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()) + .add(JSONObject.escape(name)).hover("show_text", stats).add(JSONObject.escape(message)); + } + + public double getRatio(int var1, int var2, String format) + { + double ratio = 0.0; + + if(var1 <= 0) ratio = 0d; + else if(var2 <= 1) ratio = (double) var1; + else if(var1 <= 0 && var2 <= 0) ratio = 0d; + else ratio = ((double) var1 / var2); + + return Double.parseDouble(new DecimalFormat(format).format(ratio)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java index 24225cd61..c9ae60414 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java @@ -1,12 +1,10 @@ package nautilus.game.arcade.scoreboard; import java.util.ArrayList; - import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -122,14 +120,20 @@ public class GameScoreboard for (GameTeam team : Game.GetTeamList()) { System.out.println("Scoreboard Team: " + team.GetName().toUpperCase()); - if(team.GetDisplaytag()) + if (team.GetDisplaytag()) { - _scoreboard.registerNewTeam(ParseTeamName(team.GetName().toUpperCase())).setPrefix(team.GetColor() + C.Bold + team.GetName() + team.GetColor() + " "); + Team group = _scoreboard.registerNewTeam(ParseTeamName(team.GetName().toUpperCase())); + + group.setPrefix(team.GetColor() + C.Bold + team.GetName() + team.GetColor() + " "); + group.setSuffix(C.Reset); } else { - _scoreboard.registerNewTeam(ParseTeamName(team.GetName().toUpperCase())).setPrefix(team.GetColor() + ""); - } + Team group = _scoreboard.registerNewTeam(ParseTeamName(team.GetName().toUpperCase())); + + group.setPrefix(team.GetColor() + ""); + group.setSuffix(C.Reset); + } } /* diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockBreakStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockBreakStatTracker.java new file mode 100644 index 000000000..c4817a188 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockBreakStatTracker.java @@ -0,0 +1,71 @@ +package nautilus.game.arcade.stats; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockDamageEvent; + +import nautilus.game.arcade.game.Game; + +/** + * Created by TeddehDev on 15/01/2016. + */ +public class BlockBreakStatTracker extends StatTracker +{ + private boolean _blockDamage; + + /** + * @param blockDamage + * - true = triggers block damage event + * - false = triggers block break event + */ + public BlockBreakStatTracker(Game game, boolean blockDamage) + { + super(game); + + _blockDamage = blockDamage; + } + + @EventHandler + public void blockBreak(BlockBreakEvent event) + { + if(!getGame().IsLive()) + return; + + if(event.isCancelled()) + return; + + if(_blockDamage) + return; + + Player player = event.getPlayer(); + if(player == null) + return; + + addStat(player, "BlocksBroken", 1, false, false); + } + + @EventHandler + public void blockBreak(BlockDamageEvent event) + { + if(!getGame().IsLive()) + return; + + if(event.isCancelled()) + return; + + if(!_blockDamage) + return; + + Player player = event.getPlayer(); + if(player == null) + return; + + addStat(player, "BlocksBroken", 1, false, false); + } + + public void addStat(Player player) + { + addStat(player, "BlocksBroken", 1, false, false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockPlaceStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockPlaceStatTracker.java new file mode 100644 index 000000000..ff95b96e5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockPlaceStatTracker.java @@ -0,0 +1,48 @@ +package nautilus.game.arcade.stats; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockPlaceEvent; + +import nautilus.game.arcade.game.Game; + +/** + * Created by TeddehDev on 15/01/2016. + */ +public class BlockPlaceStatTracker extends StatTracker +{ + private Material[] _ignore; + + public BlockPlaceStatTracker(Game game, Material[] ignore) + { + super(game); + + _ignore = ignore; + } + + @EventHandler + public void blockPlace(BlockPlaceEvent event) + { + if(!getGame().IsLive()) + return; + + if(event.isCancelled()) + return; + + Player player = event.getPlayer(); + if(player == null) + return; + + if(_ignore.length == 0) + addStat(event.getPlayer(), "BlocksPlaced", 1, false, false); + + for(Material material : _ignore) + { + if(event.getBlock().getType() == material) + continue; + + addStat(event.getPlayer(), "BlocksPlaced", 1, false, false); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BridgesSniperStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BridgesSniperStatTracker.java index 2322950cb..04d76de05 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BridgesSniperStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BridgesSniperStatTracker.java @@ -3,7 +3,6 @@ package nautilus.game.arcade.stats; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.games.bridge.Bridge; - import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -49,7 +48,7 @@ public class BridgesSniperStatTracker extends StatTracker if (player == killer) return; - if (event.GetLog().GetLastDamager().GetLastDamageSource().contains("Archery")) + if (event.GetLog().GetKiller().GetBestWeapon().contains("Archery")) { addStat(killer, "Sniper", 1, true, false); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DrawGuessStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DrawGuessStatTracker.java new file mode 100644 index 000000000..61c239b2a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DrawGuessStatTracker.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.stats; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.AsyncPlayerChatEvent; + +import nautilus.game.arcade.game.Game; + +/** + * Created by luke1 on 28/01/2016. + */ +public class DrawGuessStatTracker extends StatTracker +{ + public DrawGuessStatTracker(Game game) + { + super(game); + } + + @EventHandler + public void guess(AsyncPlayerChatEvent event) + { + if(getGame().GetState() != Game.GameState.Live) + return; + + int i = 0; + if(event.getMessage().contains(" ")) + { + for(char c : event.getMessage().toCharArray()) + { + System.out.println(c); + if(c != ' ') + continue; + + i++; + } + } + + if(i <= 1) + addStat(event.getPlayer(), "TotalGuess", 1, false, false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java index 10f9893b6..d13edc1f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java @@ -24,12 +24,12 @@ public class FirstSupplyDropOpenStatTracker extends StatTracker { if (getGame().GetState() != Game.GameState.Live) return; - + System.out.println("DEBUG 1"); if (_opened.contains(event.getChest())) return; _opened.add(event.getChest()); - + System.out.println("DEBUG 2"); addStat(event.getPlayer(), "SupplyDropsOpened", 1, false, false); } } diff --git a/Plugins/Nautilus.Game.MineKart/.classpath b/Plugins/Nautilus.Game.MineKart/.classpath deleted file mode 100644 index 7d34fcad1..000000000 --- a/Plugins/Nautilus.Game.MineKart/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/Plugins/Nautilus.Game.MineKart/.externalToolBuilders/MineKart Builder.launch b/Plugins/Nautilus.Game.MineKart/.externalToolBuilders/MineKart Builder.launch deleted file mode 100644 index 21979608a..000000000 --- a/Plugins/Nautilus.Game.MineKart/.externalToolBuilders/MineKart Builder.launch +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/Plugins/Nautilus.Game.MineKart/.project b/Plugins/Nautilus.Game.MineKart/.project deleted file mode 100644 index 50f9fe4d1..000000000 --- a/Plugins/Nautilus.Game.MineKart/.project +++ /dev/null @@ -1,26 +0,0 @@ - - - Nautilus.Game.MineKart - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - - - LaunchConfigHandle - <project>/.externalToolBuilders/MineKart Builder.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Nautilus.Game.MineKart/.settings/org.eclipse.jdt.core.prefs b/Plugins/Nautilus.Game.MineKart/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7341ab168..000000000 --- a/Plugins/Nautilus.Game.MineKart/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/Plugins/Nautilus.Game.PvP/.classpath b/Plugins/Nautilus.Game.PvP/.classpath deleted file mode 100644 index f2ec6207b..000000000 --- a/Plugins/Nautilus.Game.PvP/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/Plugins/Nautilus.Game.PvP/.externalToolBuilders/Nautilus.Game.PvP.launch b/Plugins/Nautilus.Game.PvP/.externalToolBuilders/Nautilus.Game.PvP.launch deleted file mode 100644 index dcb9a797b..000000000 --- a/Plugins/Nautilus.Game.PvP/.externalToolBuilders/Nautilus.Game.PvP.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Nautilus.Game.PvP/.externalToolBuilders/PvP Builder.launch b/Plugins/Nautilus.Game.PvP/.externalToolBuilders/PvP Builder.launch deleted file mode 100644 index dcb9a797b..000000000 --- a/Plugins/Nautilus.Game.PvP/.externalToolBuilders/PvP Builder.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Nautilus.Game.PvP/.project b/Plugins/Nautilus.Game.PvP/.project deleted file mode 100644 index b6a75da4c..000000000 --- a/Plugins/Nautilus.Game.PvP/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - Nautilus.Game.PvP - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/PvP Builder.launch - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/Plugins/Nautilus.Game.PvP/.settings/org.eclipse.core.resources.prefs b/Plugins/Nautilus.Game.PvP/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/Plugins/Nautilus.Game.PvP/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/Plugins/Nautilus.Game.PvP/.settings/org.eclipse.jdt.core.prefs b/Plugins/Nautilus.Game.PvP/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7341ab168..000000000 --- a/Plugins/Nautilus.Game.PvP/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/Plugins/Nautilus.Game.PvP/Nautilus.Game.PvP.iml b/Plugins/Nautilus.Game.PvP/Nautilus.Game.PvP.iml deleted file mode 100644 index 0a2adb96d..000000000 --- a/Plugins/Nautilus.Game.PvP/Nautilus.Game.PvP.iml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/Nautilus.Game.PvP/PvP.xml b/Plugins/Nautilus.Game.PvP/PvP.xml deleted file mode 100644 index e129fb89e..000000000 --- a/Plugins/Nautilus.Game.PvP/PvP.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/clans/ClansOutpost.java b/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/clans/ClansOutpost.java index a120c8bfa..79061f49c 100644 --- a/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/clans/ClansOutpost.java +++ b/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/clans/ClansOutpost.java @@ -34,7 +34,6 @@ public class ClansOutpost public void Build() { - _build = new ArrayList(); for (int y=-1 ; y <= 6 ; y++) diff --git a/Plugins/app.xml b/Plugins/app.xml new file mode 100644 index 000000000..aa91bc8fc --- /dev/null +++ b/Plugins/app.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + + + com.mineplex + mineplex-parent + dev-SNAPSHOT + pom.xml + + + mineplex-app + pom + + + + + org.apache.maven.plugins + maven-jar-plugin + + ../out + + + + org.apache.maven.plugins + maven-shade-plugin + + + package + + shade + + + + + + + com.mineplex:spigot + + + + + + + diff --git a/Plugins/plugin.xml b/Plugins/plugin.xml new file mode 100644 index 000000000..c6ed635aa --- /dev/null +++ b/Plugins/plugin.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + + com.mineplex + mineplex-parent + dev-SNAPSHOT + pom.xml + + + mineplex-plugin + pom + + + + + + + plugin.yml + + + + + + org.apache.maven.plugins + maven-jar-plugin + + ../out + + + + org.apache.maven.plugins + maven-shade-plugin + + + package + + shade + + + + + + + com.google.code.gson:gson + com.mineplex:spigot + + + + + + + diff --git a/Plugins/pom.xml b/Plugins/pom.xml new file mode 100644 index 000000000..49d4c7329 --- /dev/null +++ b/Plugins/pom.xml @@ -0,0 +1,206 @@ + + + 4.0.0 + + com.mineplex + mineplex-parent + dev-SNAPSHOT + pom + + + 1.8 + 1.8 + UTF-8 + ${maven.build.timestamp} + yyyy-MM-dd HH:mm + + + + Mineplex.Bungee.Mineplexer + Mineplex.BungeeRotator + Mineplex.Cache + Mineplex.Core + Mineplex.Core.Common + Mineplex.Database + Mineplex.DDoSProtectionSwitcher + Mineplex.EnjinTranslator + Mineplex.Game.Clans + Mineplex.Game.Clans.Core + Mineplex.Hub + Mineplex.MapParser + Mineplex.Minecraft.Game.ClassCombat + Mineplex.Minecraft.Game.Core + Mineplex.ServerData + Mineplex.ServerMonitor + Mineplex.StaffServer + Mineplex.Votifier + Nautilus.Game.Arcade + + + + + mineplex + http://dev.mineplex.com:8081/nexus/content/groups/public/ + + + + + + + commons-codec + commons-codec + 1.6 + compile + + + com.google.code.gson + gson + 2.2.1 + compile + + + com.vexsoftware + votifier + 1.9 + provided + + + fr.neatmonster + nocheatplus + 3.12.1-SNAPSHOT + provided + + + javax.mail + mail + 1.4.7 + compile + + + net.md-5 + bungeecord-proxy + 1.8-SNAPSHOT + provided + + + org.apache.commons + commons-dbcp2 + 2.0.1 + compile + + + org.apache.cxf + cxf-bundle + 2.7.2 + compile + + + org.apache.httpcomponents + httpclient + 4.2 + compile + + + org.apache.ws.security + wss4j + 1.6.9 + compile + + + org.jooq + jooq-codegen + 3.5.2 + compile + + + com.mineplex + spigot + 1.8.8-R0.1-SNAPSHOT + compile + + + redis.clients + jedis + 2.6.2 + compile + + + + + + ${project.name} + ${project.basedir}/src + + + net.md-5 + scriptus + 0.3.1 + + + initialize + + describe + + + + + git:${project.name}:%s:${maven.build.timestamp} + + + + org.apache.maven.plugins + maven-jar-plugin + + + + ${describe} + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.6 + + + org.apache.maven.plugins + maven-shade-plugin + 2.4.2 + + false + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + net.md-5 + scriptus + [0.3.1,) + + describe + + + + + + + + + + + + + + diff --git a/Plugins/settings.xml b/Plugins/settings.xml new file mode 100644 index 000000000..bb53f5e93 --- /dev/null +++ b/Plugins/settings.xml @@ -0,0 +1,18 @@ + + + + + + + mineplex + mineplex + sZhnBKND9c + + +