diff --git a/Patches/Bukkit-Patches/0001-Update-groupId.patch b/Patches/Bukkit-Patches/0001-Update-groupId.patch new file mode 100644 index 000000000..f767a0d97 --- /dev/null +++ b/Patches/Bukkit-Patches/0001-Update-groupId.patch @@ -0,0 +1,22 @@ +From b3604650ac6e2813f9e1b4d54862ce79c37e001e Mon Sep 17 00:00:00 2001 +From: md_5 +Date: Mon, 15 Feb 2016 09:39:33 +1100 +Subject: [PATCH] Update groupId + + +diff --git a/pom.xml b/pom.xml +index cb142f2..378fd01 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -9,7 +9,7 @@ + 9 + + +- org.spigotmc ++ com.mineplex + spigot-api + 1.8.8-R0.1-SNAPSHOT + jar +-- +2.5.0 + diff --git a/Patches/Bukkit-Patches/0030-LivingEntity-changes.patch b/Patches/Bukkit-Patches/0002-LivingEntity-changes.patch similarity index 92% rename from Patches/Bukkit-Patches/0030-LivingEntity-changes.patch rename to Patches/Bukkit-Patches/0002-LivingEntity-changes.patch index 88e53c48c..c859889b2 100644 --- a/Patches/Bukkit-Patches/0030-LivingEntity-changes.patch +++ b/Patches/Bukkit-Patches/0002-LivingEntity-changes.patch @@ -1,4 +1,4 @@ -From f037882f13b3ea9d0a0137260e365a4332a8e751 Mon Sep 17 00:00:00 2001 +From 41b16c2e04b2bc8ada5d0ed363e4ea5e6b466ee1 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 23 Oct 2015 21:23:18 +1300 Subject: [PATCH] LivingEntity changes @@ -30,5 +30,5 @@ index 48e2508..fb623ae 100644 + public void setGhost(boolean ghost); } -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/Bukkit-Patches/0031-EntityDismountEvent.patch b/Patches/Bukkit-Patches/0003-EntityDismountEvent.patch similarity index 94% rename from Patches/Bukkit-Patches/0031-EntityDismountEvent.patch rename to Patches/Bukkit-Patches/0003-EntityDismountEvent.patch index 72f7c9718..3acb7e51a 100644 --- a/Patches/Bukkit-Patches/0031-EntityDismountEvent.patch +++ b/Patches/Bukkit-Patches/0003-EntityDismountEvent.patch @@ -1,4 +1,4 @@ -From c6e51ae8ffc31d0fc059d33ca159df31c2b7a83e Mon Sep 17 00:00:00 2001 +From 1bb1629f460d9c8ababad25722bebd0fedf2b269 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 22 Nov 2015 14:37:11 +1300 Subject: [PATCH] EntityDismountEvent @@ -43,5 +43,5 @@ index 24d4942..02943d6 100644 + } -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0001-Update-groupId.patch b/Patches/CraftBukkit-Patches/0001-Update-groupId.patch new file mode 100644 index 000000000..5a96169f0 --- /dev/null +++ b/Patches/CraftBukkit-Patches/0001-Update-groupId.patch @@ -0,0 +1,31 @@ +From 409122f500f205b8a9b0fdec56900d83cee9f1ba Mon Sep 17 00:00:00 2001 +From: md_5 +Date: Mon, 15 Feb 2016 09:56:14 +1100 +Subject: [PATCH] Update groupId + + +diff --git a/pom.xml b/pom.xml +index 91627ff..c1d1fb7 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -1,7 +1,7 @@ + + 4.0.0 +- org.spigotmc ++ com.mineplex + spigot + jar + 1.8.8-R0.1-SNAPSHOT +@@ -34,7 +34,7 @@ + 3.0.3 + + +- org.spigotmc ++ com.mineplex + spigot-api + ${project.version} + jar +-- +2.5.0 + diff --git a/Patches/CraftBukkit-Patches/0161-Modify-packets-to-public.patch b/Patches/CraftBukkit-Patches/0002-Modify-packets-to-public.patch similarity index 99% rename from Patches/CraftBukkit-Patches/0161-Modify-packets-to-public.patch rename to Patches/CraftBukkit-Patches/0002-Modify-packets-to-public.patch index dcf211601..26caaf86b 100644 --- a/Patches/CraftBukkit-Patches/0161-Modify-packets-to-public.patch +++ b/Patches/CraftBukkit-Patches/0002-Modify-packets-to-public.patch @@ -1,4 +1,4 @@ -From b9014b76bbb262a39ce2d70cbe831ceb07acf68d Mon Sep 17 00:00:00 2001 +From 687c7ed26e1733b8ed688243cd6df91c45db148a Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 23 Oct 2015 21:14:50 +1300 Subject: [PATCH] Modify packets to public @@ -2033,5 +2033,5 @@ index 0000000..4c2705b +} \ No newline at end of file -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0162-Modifiy-entity.patch b/Patches/CraftBukkit-Patches/0003-Modifiy-entity.patch similarity index 99% rename from Patches/CraftBukkit-Patches/0162-Modifiy-entity.patch rename to Patches/CraftBukkit-Patches/0003-Modifiy-entity.patch index dc07a0c75..dfb641d99 100644 --- a/Patches/CraftBukkit-Patches/0162-Modifiy-entity.patch +++ b/Patches/CraftBukkit-Patches/0003-Modifiy-entity.patch @@ -1,4 +1,4 @@ -From 9f12f0f7abe2a94fe4a724a7c17245b9c0f33a70 Mon Sep 17 00:00:00 2001 +From ca990c7ca61006f0933d0e117f1003822b887667 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 23 Oct 2015 21:16:07 +1300 Subject: [PATCH] Modifiy entity @@ -677,7 +677,7 @@ index a8a327d..b7647bc 100644 this.bp = null; if (!this.world.isClientSide && flag1) { diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index 3c852fd..b861dbe 100644 +index f643b29..f75b0b1 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -101,6 +101,18 @@ public abstract class EntityLiving extends Entity { @@ -699,7 +699,7 @@ index 3c852fd..b861dbe 100644 public EntityLiving(World world) { super(world); this.initAttributes(); -@@ -1783,7 +1795,7 @@ public abstract class EntityLiving extends Entity { +@@ -1784,7 +1796,7 @@ public abstract class EntityLiving extends Entity { } public boolean ad() { @@ -800,5 +800,5 @@ index 5317cff..60e8584 100644 return Math.min(Math.max(0, getHandle().getHealth()), getMaxHealth()); } -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0163-Chunk-changes.patch b/Patches/CraftBukkit-Patches/0004-Chunk-changes.patch similarity index 98% rename from Patches/CraftBukkit-Patches/0163-Chunk-changes.patch rename to Patches/CraftBukkit-Patches/0004-Chunk-changes.patch index 7901d3dae..84166192b 100644 --- a/Patches/CraftBukkit-Patches/0163-Chunk-changes.patch +++ b/Patches/CraftBukkit-Patches/0004-Chunk-changes.patch @@ -1,4 +1,4 @@ -From 71c20f9d0c8bfa388f6bf0ba1a7b765a83e9de2a Mon Sep 17 00:00:00 2001 +From c8c2e86ef3ac3baf774afacf5fe2fab0b39a39a6 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 23 Oct 2015 21:21:32 +1300 Subject: [PATCH] Chunk changes @@ -231,5 +231,5 @@ index 975d666..a55bd6c 100644 /* * If it's a new world, the first few chunks are generated inside -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0164-Packet-listener-changes.patch b/Patches/CraftBukkit-Patches/0005-Packet-listener-changes.patch similarity index 99% rename from Patches/CraftBukkit-Patches/0164-Packet-listener-changes.patch rename to Patches/CraftBukkit-Patches/0005-Packet-listener-changes.patch index cb217719b..ac582299e 100644 --- a/Patches/CraftBukkit-Patches/0164-Packet-listener-changes.patch +++ b/Patches/CraftBukkit-Patches/0005-Packet-listener-changes.patch @@ -1,4 +1,4 @@ -From 47c08a6099856faf0049c0b0cdde495a8ae4166e Mon Sep 17 00:00:00 2001 +From 04418c14f74d251cebe99e4bc6315d619b0a4440 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 23 Oct 2015 21:22:05 +1300 Subject: [PATCH] Packet listener changes @@ -349,5 +349,5 @@ index 5740e49..5edef3e 100644 public void a(PacketPlayInWindowClick packetplayinwindowclick) { -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0006-Inventory-changes.patch b/Patches/CraftBukkit-Patches/0006-Inventory-changes.patch new file mode 100644 index 000000000..66ff83ba8 --- /dev/null +++ b/Patches/CraftBukkit-Patches/0006-Inventory-changes.patch @@ -0,0 +1,70 @@ +From 413c649570b54e6d7a50da7aa888cfb20018f523 Mon Sep 17 00:00:00 2001 +From: libraryaddict +Date: Fri, 23 Oct 2015 21:22:36 +1300 +Subject: [PATCH] Inventory changes + + +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +index e99b8cc..428836c 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +@@ -32,7 +32,7 @@ public class CraftInventoryCustom extends CraftInventory { + super(new MinecraftInventory(owner, size, title)); + } + +- static class MinecraftInventory implements IInventory { ++ public static class MinecraftInventory implements IInventory { + private final ItemStack[] items; + private int maxStack = MAX_STACK; + private final List viewers; +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +index 23f05f4..fdaf026 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +@@ -26,7 +26,7 @@ import net.minecraft.server.NBTTagString; + import org.bukkit.craftbukkit.util.CraftChatMessage; + + @DelegateDeserialization(ItemStack.class) +-public final class CraftItemStack extends ItemStack { ++public class CraftItemStack extends ItemStack { + + public static net.minecraft.server.ItemStack asNMSCopy(ItemStack original) { + if (original instanceof CraftItemStack) { +@@ -95,26 +95,30 @@ public final class CraftItemStack extends ItemStack { + /** + * Mirror + */ +- private CraftItemStack(net.minecraft.server.ItemStack item) { ++ protected CraftItemStack(net.minecraft.server.ItemStack item) { + this.handle = item; + } + +- private CraftItemStack(ItemStack item) { ++ protected CraftItemStack(ItemStack item) { + this(item.getTypeId(), item.getAmount(), item.getDurability(), item.hasItemMeta() ? item.getItemMeta() : null); + } + +- private CraftItemStack(Material type, int amount, short durability, ItemMeta itemMeta) { ++ protected CraftItemStack(Material type, int amount, short durability, ItemMeta itemMeta) { + setType(type); + setAmount(amount); + setDurability(durability); + setItemMeta(itemMeta); + } + +- private CraftItemStack(int typeId, int amount, short durability, ItemMeta itemMeta) { ++ protected CraftItemStack(int typeId, int amount, short durability, ItemMeta itemMeta) { + this(Material.getMaterial(typeId), amount, durability, itemMeta); + + } + ++ public net.minecraft.server.ItemStack getHandle() { ++ return handle; ++ } ++ + @Override + public int getTypeId() { + return handle != null ? CraftMagicNumbers.getId(handle.getItem()) : 0; +-- +2.5.0 + diff --git a/Patches/CraftBukkit-Patches/0166-Misc-changes.patch b/Patches/CraftBukkit-Patches/0007-Misc-changes.patch similarity index 99% rename from Patches/CraftBukkit-Patches/0166-Misc-changes.patch rename to Patches/CraftBukkit-Patches/0007-Misc-changes.patch index 4d2a01c93..b122a625f 100644 --- a/Patches/CraftBukkit-Patches/0166-Misc-changes.patch +++ b/Patches/CraftBukkit-Patches/0007-Misc-changes.patch @@ -1,4 +1,4 @@ -From 088fc9372c061edac80ee5cce669382ebed0b1e3 Mon Sep 17 00:00:00 2001 +From 7772a2a9b83ee223c01ac2003ba32a1b95a7c0cd Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 23 Oct 2015 21:23:00 +1300 Subject: [PATCH] Misc changes @@ -273,5 +273,5 @@ index 29082aa..e979f69 100644 } -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0167-EntityGuardian-is-now-vegetateable.patch b/Patches/CraftBukkit-Patches/0008-EntityGuardian-is-now-vegetateable.patch similarity index 99% rename from Patches/CraftBukkit-Patches/0167-EntityGuardian-is-now-vegetateable.patch rename to Patches/CraftBukkit-Patches/0008-EntityGuardian-is-now-vegetateable.patch index 49cf31e7d..3be012487 100644 --- a/Patches/CraftBukkit-Patches/0167-EntityGuardian-is-now-vegetateable.patch +++ b/Patches/CraftBukkit-Patches/0008-EntityGuardian-is-now-vegetateable.patch @@ -1,4 +1,4 @@ -From 9aded83bc47bf6ba8076fc2ed03ebbe480df1296 Mon Sep 17 00:00:00 2001 +From 969a70f201e6eda7d990e11e292e0dacc35f8ddf Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 28 Oct 2015 09:00:24 +1300 Subject: [PATCH] EntityGuardian is now vegetateable @@ -601,5 +601,5 @@ index 0000000..c14caf2 + public PathfinderGoalRandomStroll goalRandomStroll; +} -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0168-Controller-look-vegetateHead-Entity-collide-changes.patch b/Patches/CraftBukkit-Patches/0009-Controller-look-vegetateHead-Entity-collide-changes.patch similarity index 95% rename from Patches/CraftBukkit-Patches/0168-Controller-look-vegetateHead-Entity-collide-changes.patch rename to Patches/CraftBukkit-Patches/0009-Controller-look-vegetateHead-Entity-collide-changes.patch index 7b161eb37..9b3e7ea07 100644 --- a/Patches/CraftBukkit-Patches/0168-Controller-look-vegetateHead-Entity-collide-changes.patch +++ b/Patches/CraftBukkit-Patches/0009-Controller-look-vegetateHead-Entity-collide-changes.patch @@ -1,4 +1,4 @@ -From d3b44ea22080f4d15bf45b74b46b989b29f7b039 Mon Sep 17 00:00:00 2001 +From a48503259a76ca5b9fec3bd7ec06e0e5c1d3f8e1 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 30 Oct 2015 20:02:58 +1300 Subject: [PATCH] Controller look vegetateHead, Entity collide changes @@ -39,5 +39,5 @@ index cb9ba53..8660762 100644 double d0 = entity.locX - this.locX; double d1 = entity.locZ - this.locZ; -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0169-Vegetate-head-ai.patch b/Patches/CraftBukkit-Patches/0010-Vegetate-head-ai.patch similarity index 97% rename from Patches/CraftBukkit-Patches/0169-Vegetate-head-ai.patch rename to Patches/CraftBukkit-Patches/0010-Vegetate-head-ai.patch index a9b886dbb..47abce5ae 100644 --- a/Patches/CraftBukkit-Patches/0169-Vegetate-head-ai.patch +++ b/Patches/CraftBukkit-Patches/0010-Vegetate-head-ai.patch @@ -1,4 +1,4 @@ -From a793ae3653b54c211b2c40147e031449d3e1cf72 Mon Sep 17 00:00:00 2001 +From bafc21b97584c9207f29804520942285752d6b53 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Tue, 3 Nov 2015 21:21:02 +1300 Subject: [PATCH] Vegetate head ai @@ -95,7 +95,7 @@ index b7647bc..c2ef000 100644 this.yaw = this.b(this.yaw, f2, f); } diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index b861dbe..4de7e4c 100644 +index f75b0b1..e384c2c 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -113,6 +113,18 @@ public abstract class EntityLiving extends Entity { @@ -135,5 +135,5 @@ index b861dbe..4de7e4c 100644 } else if (!this.bM()) { this.motX *= 0.98D; -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0170-Modifications-to-cb.patch b/Patches/CraftBukkit-Patches/0011-Modifications-to-cb.patch similarity index 99% rename from Patches/CraftBukkit-Patches/0170-Modifications-to-cb.patch rename to Patches/CraftBukkit-Patches/0011-Modifications-to-cb.patch index dca7f1e11..d2b605177 100644 --- a/Patches/CraftBukkit-Patches/0170-Modifications-to-cb.patch +++ b/Patches/CraftBukkit-Patches/0011-Modifications-to-cb.patch @@ -1,4 +1,4 @@ -From afb13529d05ad4adb0afa8cf8430e942d3e65e90 Mon Sep 17 00:00:00 2001 +From 5e1591dec2adb9001c9c3aafd0908d95eadff484 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 8 Nov 2015 17:57:05 +1300 Subject: [PATCH] Modifications to cb @@ -104,7 +104,7 @@ index c2ef000..b7647bc 100644 this.yaw = this.b(this.yaw, f2, f); } diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index 4de7e4c..b861dbe 100644 +index e384c2c..f75b0b1 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -113,18 +113,6 @@ public abstract class EntityLiving extends Entity { @@ -1614,5 +1614,5 @@ index 0000000..fdf0e10 + } +} -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0171-Add-IEntitySelector-have-isGhost-return-the-same-as-.patch b/Patches/CraftBukkit-Patches/0012-Add-IEntitySelector-have-isGhost-return-the-same-as-.patch similarity index 97% rename from Patches/CraftBukkit-Patches/0171-Add-IEntitySelector-have-isGhost-return-the-same-as-.patch rename to Patches/CraftBukkit-Patches/0012-Add-IEntitySelector-have-isGhost-return-the-same-as-.patch index a6166c4bd..f205717f5 100644 --- a/Patches/CraftBukkit-Patches/0171-Add-IEntitySelector-have-isGhost-return-the-same-as-.patch +++ b/Patches/CraftBukkit-Patches/0012-Add-IEntitySelector-have-isGhost-return-the-same-as-.patch @@ -1,4 +1,4 @@ -From cddf775b575f0db92e478c858283869ac0b9bdc2 Mon Sep 17 00:00:00 2001 +From d57744e41ed408a6f924665509bb03fac0590cfa Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 9 Nov 2015 00:07:26 +1300 Subject: [PATCH] Add IEntitySelector, have isGhost() return the same as @@ -115,5 +115,5 @@ index 0000000..1536600 + +} -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0172-Add-player-spectator.patch b/Patches/CraftBukkit-Patches/0013-Add-player-spectator.patch similarity index 90% rename from Patches/CraftBukkit-Patches/0172-Add-player-spectator.patch rename to Patches/CraftBukkit-Patches/0013-Add-player-spectator.patch index 585ef7b7a..cd7fa9b6a 100644 --- a/Patches/CraftBukkit-Patches/0172-Add-player-spectator.patch +++ b/Patches/CraftBukkit-Patches/0013-Add-player-spectator.patch @@ -1,4 +1,4 @@ -From e81762b9aa4f28474b2ccd06ae6ad5b7c840e1ba Mon Sep 17 00:00:00 2001 +From c6967f167cb74718389c7d87a0e4847d2824e855 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 9 Nov 2015 00:13:21 +1300 Subject: [PATCH] Add player spectator @@ -18,5 +18,5 @@ index 1536600..f86cf48 100644 public boolean apply(Object obj) -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0173-Fixed-ai-typo.patch b/Patches/CraftBukkit-Patches/0014-Fixed-ai-typo.patch similarity index 91% rename from Patches/CraftBukkit-Patches/0173-Fixed-ai-typo.patch rename to Patches/CraftBukkit-Patches/0014-Fixed-ai-typo.patch index b6fd20b9d..ed9bbd6a7 100644 --- a/Patches/CraftBukkit-Patches/0173-Fixed-ai-typo.patch +++ b/Patches/CraftBukkit-Patches/0014-Fixed-ai-typo.patch @@ -1,4 +1,4 @@ -From 5dac54f90504022449cbd5ea23e5306f17523fe2 Mon Sep 17 00:00:00 2001 +From 9eb0754b8eaed3dd60355206dd53c6b4dacab361 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 9 Nov 2015 02:41:31 +1300 Subject: [PATCH] Fixed ai typo @@ -18,5 +18,5 @@ index f86cf48..b4d70ad 100644 public boolean apply(Object obj) -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0174-Fix-casting-bug.patch b/Patches/CraftBukkit-Patches/0015-Fix-casting-bug.patch similarity index 96% rename from Patches/CraftBukkit-Patches/0174-Fix-casting-bug.patch rename to Patches/CraftBukkit-Patches/0015-Fix-casting-bug.patch index a6436cd56..6e2da8f3f 100644 --- a/Patches/CraftBukkit-Patches/0174-Fix-casting-bug.patch +++ b/Patches/CraftBukkit-Patches/0015-Fix-casting-bug.patch @@ -1,4 +1,4 @@ -From ea74383b4c0f5160f0d890d9377bd0d72e31db0c Mon Sep 17 00:00:00 2001 +From d37159de8e6c19ed8e232666661572cc399dc82a Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 11 Nov 2015 00:21:54 +1300 Subject: [PATCH] Fix casting bug @@ -60,5 +60,5 @@ index 60e8584..746961e 100644 public boolean isGhost() -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0175-Fix-schedulers.patch b/Patches/CraftBukkit-Patches/0016-Fix-schedulers.patch similarity index 94% rename from Patches/CraftBukkit-Patches/0175-Fix-schedulers.patch rename to Patches/CraftBukkit-Patches/0016-Fix-schedulers.patch index e6e990d00..b555316ac 100644 --- a/Patches/CraftBukkit-Patches/0175-Fix-schedulers.patch +++ b/Patches/CraftBukkit-Patches/0016-Fix-schedulers.patch @@ -1,4 +1,4 @@ -From 896df3218cf190a29901619e762b5399517dbfbd Mon Sep 17 00:00:00 2001 +From c881d98fee52e719e60a5c8f5eeb9497357dd597 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 11 Nov 2015 11:43:17 +1300 Subject: [PATCH] Fix schedulers @@ -33,5 +33,5 @@ index 1d29ae7..55e2afd 100644 SpigotTimings.processQueueTimer.startTiming(); // Spigot while (!processQueue.isEmpty()) { -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0176-EntityDismountEvent-teleport-crash-fix.patch b/Patches/CraftBukkit-Patches/0017-EntityDismountEvent-teleport-crash-fix.patch similarity index 74% rename from Patches/CraftBukkit-Patches/0176-EntityDismountEvent-teleport-crash-fix.patch rename to Patches/CraftBukkit-Patches/0017-EntityDismountEvent-teleport-crash-fix.patch index 6a7278e9a..aa9d1ee4c 100644 --- a/Patches/CraftBukkit-Patches/0176-EntityDismountEvent-teleport-crash-fix.patch +++ b/Patches/CraftBukkit-Patches/0017-EntityDismountEvent-teleport-crash-fix.patch @@ -1,37 +1,27 @@ -From bc86c3b02f2efa4c1194fc908e8d1ee8723f62c5 Mon Sep 17 00:00:00 2001 +From b0eb73047d9e8e06c2822142dc8c443efa9eda2e Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 22 Nov 2015 14:41:11 +1300 Subject: [PATCH] EntityDismountEvent & teleport crash fix diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 81ca499..7165579 100644 +index 81ca499..2a4f819 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -23,6 +23,8 @@ import org.bukkit.event.painting.PaintingBreakByEntityEvent; - import org.bukkit.event.vehicle.VehicleBlockCollisionEvent; - import org.bukkit.event.vehicle.VehicleEnterEvent; - import org.bukkit.event.vehicle.VehicleExitEvent; -+import org.spigotmc.event.entity.EntityDismountEvent; -+import org.spigotmc.event.entity.EntityMountEvent; - import org.bukkit.craftbukkit.CraftWorld; - import org.bukkit.craftbukkit.entity.CraftEntity; - import org.bukkit.craftbukkit.entity.CraftPlayer; -@@ -1591,7 +1593,12 @@ public abstract class Entity implements ICommandListener { +@@ -1591,7 +1591,11 @@ public abstract class Entity implements ICommandListener { } } // CraftBukkit end - pluginManager.callEvent( new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ) ); // Spigot -+ EntityDismountEvent event = new org.spigotmc.event.entity.EntityDismountEvent(this.getBukkitEntity(), this.vehicle.getBukkitEntity()); ++ org.spigotmc.event.entity.EntityDismountEvent event = new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ); // Spigot + pluginManager.callEvent(event); // Spigot -+ + if (event.isCancelled() || vehicle != originalVehicle) { + return; -+ } // Spigot ++ } this.setPositionRotation(this.vehicle.locX, this.vehicle.getBoundingBox().b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch); this.vehicle.passenger = null; } -@@ -1599,44 +1606,45 @@ public abstract class Entity implements ICommandListener { +@@ -1599,44 +1603,44 @@ public abstract class Entity implements ICommandListener { this.vehicle = null; } else { // CraftBukkit start @@ -39,24 +29,25 @@ index 81ca499..7165579 100644 + if (entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4, true)) { // It's possible to move from one vehicle to another. We need to check if they're already in a vehicle, and fire an exit event if they are. VehicleExitEvent exitEvent = null; -+ EntityDismountEvent exitEvent1 = null; ++ org.spigotmc.event.entity.EntityDismountEvent exitEvent1 = null; if (this.vehicle != null) { - exitEvent = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity); -+ if ((this.bukkitEntity instanceof LivingEntity) && (entity.getBukkitEntity() instanceof Vehicle)) +- pluginManager.callEvent(exitEvent); ++ 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; ++ } ++ } ++ exitEvent1 = new org.spigotmc.event.entity.EntityDismountEvent(this.vehicle.getBukkitEntity(), this.bukkitEntity); ++ pluginManager.callEvent(exitEvent1); - if (exitEvent.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) { +- if (exitEvent.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) { ++ if (exitEvent1.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) { return; } -+ -+ exitEvent1 = new EntityDismountEvent(this.vehicle.getBukkitEntity(), this.bukkitEntity); -+ -+ pluginManager.callEvent(exitEvent1); -+ -+ if (exitEvent1.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) { -+ return; -+ } } - VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.bukkitEntity); @@ -101,36 +92,25 @@ index 81ca499..7165579 100644 if (this.vehicle != null) { this.vehicle.passenger = null; diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index b861dbe..96b3905 100644 +index f75b0b1..19fc521 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java -@@ -21,6 +21,7 @@ import org.bukkit.event.entity.EntityDamageEvent; - import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; - import org.bukkit.event.entity.EntityRegainHealthEvent; - import org.bukkit.event.vehicle.VehicleExitEvent; -+import org.spigotmc.event.entity.EntityDismountEvent; - // CraftBukkit end - - import org.bukkit.craftbukkit.SpigotTimings; // Spigot -@@ -1725,8 +1726,15 @@ public abstract class EntityLiving extends Entity { +@@ -1725,6 +1725,13 @@ public abstract class EntityLiving extends Entity { return; } } + -+ EntityDismountEvent event = new EntityDismountEvent(this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity); ++ org.spigotmc.event.entity.EntityDismountEvent event = new org.spigotmc.event.entity.EntityDismountEvent(this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity); + getBukkitEntity().getServer().getPluginManager().callEvent(event); + + if (event.isCancelled() || vehicle != originalVehicle) { + return; + } // CraftBukkit end -- -+ - if (!this.world.isClientSide) { - this.q(this.vehicle); - } + org.bukkit.Bukkit.getPluginManager().callEvent( new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ) ); // Spigot + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index efbf1a8..dbc7b54 100644 +index efbf1a8..ad53590 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -1,6 +1,7 @@ @@ -141,19 +121,17 @@ index efbf1a8..dbc7b54 100644 import java.util.ArrayList; import java.util.Collection; import java.util.List; -@@ -234,6 +235,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -233,6 +234,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { + // If this entity is riding another entity, we must dismount before teleporting. entity.mount(null); - -+ if (!Doubles.isFinite(location.getX()) || !Doubles.isFinite(location.getY()) || !Doubles.isFinite(location.getZ())) -+ { ++ if (!Doubles.isFinite(location.getX()) || !Doubles.isFinite(location.getY()) || !Doubles.isFinite(location.getZ())) { + Thread.dumpStack(); + return false; + } -+ + // Spigot start if (!location.getWorld().equals(getWorld())) { - entity.teleportTo(location, cause.equals(TeleportCause.NETHER_PORTAL)); -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0177-Server-freezing-fix-fake-yaw-pitch.patch b/Patches/CraftBukkit-Patches/0018-Server-freezing-fix-fake-yaw-pitch.patch similarity index 91% rename from Patches/CraftBukkit-Patches/0177-Server-freezing-fix-fake-yaw-pitch.patch rename to Patches/CraftBukkit-Patches/0018-Server-freezing-fix-fake-yaw-pitch.patch index a7bd7eef1..17ceb565f 100644 --- a/Patches/CraftBukkit-Patches/0177-Server-freezing-fix-fake-yaw-pitch.patch +++ b/Patches/CraftBukkit-Patches/0018-Server-freezing-fix-fake-yaw-pitch.patch @@ -1,11 +1,11 @@ -From 3b4526267e3bd53d9e70578ec1c7a8cd13038e73 Mon Sep 17 00:00:00 2001 +From 6514e2834135adf7d133d11bbcad9377544d73f0 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 +index 2a4f819..721d0e6 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; @@ -16,7 +16,7 @@ index 7165579..4f366da 100644 // CraftBukkit start import org.bukkit.Bukkit; -@@ -153,6 +154,12 @@ public abstract class Entity implements ICommandListener { +@@ -151,6 +152,12 @@ public abstract class Entity implements ICommandListener { public void setFakeHead(boolean fakeHead) { _fakeHead = fakeHead; @@ -29,7 +29,7 @@ index 7165579..4f366da 100644 } public boolean isSilent() -@@ -1024,9 +1031,18 @@ public abstract class Entity implements ICommandListener { +@@ -1022,9 +1029,18 @@ public abstract class Entity implements ICommandListener { this.lastX = this.locX = d0; this.lastY = this.locY = d1; this.lastZ = this.locZ = d2; @@ -64,5 +64,5 @@ index 5edef3e..d3b1586 100644 } else { WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0019-Sound-and-vehicle-fixes.patch b/Patches/CraftBukkit-Patches/0019-Sound-and-vehicle-fixes.patch new file mode 100644 index 000000000..210afef18 --- /dev/null +++ b/Patches/CraftBukkit-Patches/0019-Sound-and-vehicle-fixes.patch @@ -0,0 +1,26 @@ +From 22472882d2708e0eb4e35f0d31978b70d2c4b4f5 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/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"); +-- +2.5.0 + diff --git a/Patches/CraftBukkit-Patches/0179-md_5-s-player-interaction-for-specs-patch.patch b/Patches/CraftBukkit-Patches/0020-md_5-s-player-interaction-for-specs-patch.patch similarity index 95% rename from Patches/CraftBukkit-Patches/0179-md_5-s-player-interaction-for-specs-patch.patch rename to Patches/CraftBukkit-Patches/0020-md_5-s-player-interaction-for-specs-patch.patch index 8ef283ea6..0da7d8679 100644 --- a/Patches/CraftBukkit-Patches/0179-md_5-s-player-interaction-for-specs-patch.patch +++ b/Patches/CraftBukkit-Patches/0020-md_5-s-player-interaction-for-specs-patch.patch @@ -1,4 +1,4 @@ -From 3d0c2e6b1409ca0c42b7aafbffae4b517d7db48c Mon Sep 17 00:00:00 2001 +From 1e687cfb7b343f9c2a2e3cfdef346a896be747bb 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 @@ -27,5 +27,5 @@ index d3b1586..6fd49b3 100644 // Arm swing animation PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer()); -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0180-Fix-enderman-teleporting-when-vegetated.patch b/Patches/CraftBukkit-Patches/0021-Fix-enderman-teleporting-when-vegetated.patch similarity index 90% rename from Patches/CraftBukkit-Patches/0180-Fix-enderman-teleporting-when-vegetated.patch rename to Patches/CraftBukkit-Patches/0021-Fix-enderman-teleporting-when-vegetated.patch index dc539b4a4..15a0ffa0f 100644 --- a/Patches/CraftBukkit-Patches/0180-Fix-enderman-teleporting-when-vegetated.patch +++ b/Patches/CraftBukkit-Patches/0021-Fix-enderman-teleporting-when-vegetated.patch @@ -1,4 +1,4 @@ -From c0e8d43f419d7f489cd0ae348618f897e95b0402 Mon Sep 17 00:00:00 2001 +From 125596ec9aee25d141781b4010eac881c7b36eb5 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 @@ -21,5 +21,5 @@ index a250062..5ad2d07 100644 double d4 = this.locY; double d5 = this.locZ; -- -1.9.5.msysgit.0 +2.5.0 diff --git a/Patches/CraftBukkit-Patches/0022-Implement-Sentry-for-exception-monitoring.patch b/Patches/CraftBukkit-Patches/0022-Implement-Sentry-for-exception-monitoring.patch new file mode 100644 index 000000000..65f2b6897 --- /dev/null +++ b/Patches/CraftBukkit-Patches/0022-Implement-Sentry-for-exception-monitoring.patch @@ -0,0 +1,327 @@ +From 742d6b5d828128519f06f7c6f5e188847263e609 Mon Sep 17 00:00:00 2001 +From: md_5 +Date: Sun, 7 Feb 2016 20:28:54 +1100 +Subject: [PATCH] Implement Sentry for exception monitoring. + + +diff --git a/pom.xml b/pom.xml +index c1d1fb7..ceb3ec2 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -29,6 +29,12 @@ + + + ++ net.kencochrane.raven ++ raven-log4j2 ++ 6.0.0 ++ compile ++ ++ + net.sf.trove4j + trove4j + 3.0.3 +@@ -202,6 +208,20 @@ + shade + + ++ ++ ++ *:* ++ ++ META-INF/org/apache/logging/log4j/core/config/plugins/ ++ ++ ++ ++ *:minecraft-server ++ ++ org/apache/logging/log4j/ ++ ++ ++ + + + joptsimple +diff --git a/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java b/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java +deleted file mode 100644 +index 341eaa3..0000000 +--- a/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java ++++ /dev/null +@@ -1,245 +0,0 @@ +-/* +- * Licensed to the Apache Software Foundation (ASF) under one or more +- * contributor license agreements. See the NOTICE file distributed with +- * this work for additional information regarding copyright ownership. +- * The ASF licenses this file to You under the Apache license, Version 2.0 +- * (the "License"); you may not use this file except in compliance with +- * the License. You may obtain a copy of the License at +- * +- * http://www.apache.org/licenses/LICENSE-2.0 +- * +- * Unless required by applicable law or agreed to in writing, software +- * distributed under the License is distributed on an "AS IS" BASIS, +- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +- * See the license for the specific language governing permissions and +- * limitations under the license. +- */ +-package org.apache.logging.log4j.core.appender; +- +-import java.io.IOException; +-import java.io.OutputStream; +-import java.io.PrintStream; +-import java.io.Serializable; +-import java.io.UnsupportedEncodingException; +-import java.lang.reflect.Constructor; +-import java.nio.charset.Charset; +- +-import org.apache.logging.log4j.core.Filter; +-import org.apache.logging.log4j.core.Layout; +-import org.apache.logging.log4j.core.config.plugins.Plugin; +-import org.apache.logging.log4j.core.config.plugins.PluginAttribute; +-import org.apache.logging.log4j.core.config.plugins.PluginElement; +-import org.apache.logging.log4j.core.config.plugins.PluginFactory; +-import org.apache.logging.log4j.core.helpers.Booleans; +-import org.apache.logging.log4j.core.helpers.Loader; +-import org.apache.logging.log4j.core.layout.PatternLayout; +-import org.apache.logging.log4j.util.PropertiesUtil; +- +-/** +- * ConsoleAppender appends log events to System.out or +- * System.err using a layout specified by the user. The +- * default target is System.out. +- * @doubt accessing System.out or .err as a byte stream instead of a writer +- * bypasses the JVM's knowledge of the proper encoding. (RG) Encoding +- * is handled within the Layout. Typically, a Layout will generate a String +- * and then call getBytes which may use a configured encoding or the system +- * default. OTOH, a Writer cannot print byte streams. +- */ +-@Plugin(name = "Console", category = "Core", elementType = "appender", printObject = true) +-public final class ConsoleAppender extends AbstractOutputStreamAppender { +- +- private static final String JANSI_CLASS = "org.fusesource.jansi.WindowsAnsiOutputStream"; +- private static ConsoleManagerFactory factory = new ConsoleManagerFactory(); +- +- /** +- * Enumeration of console destinations. +- */ +- public enum Target { +- /** Standard output. */ +- SYSTEM_OUT, +- /** Standard error output. */ +- SYSTEM_ERR +- } +- +- private ConsoleAppender(final String name, final Layout layout, final Filter filter, +- final OutputStreamManager manager, +- final boolean ignoreExceptions) { +- super(name, layout, filter, ignoreExceptions, true, manager); +- } +- +- /** +- * Create a Console Appender. +- * @param layout The layout to use (required). +- * @param filter The Filter or null. +- * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT". +- * @param follow If true will follow changes to the underlying output stream. +- * @param name The name of the Appender (required). +- * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise +- * they are propagated to the caller. +- * @return The ConsoleAppender. +- */ +- @PluginFactory +- public static ConsoleAppender createAppender( +- @PluginElement("Layout") Layout layout, +- @PluginElement("Filters") final Filter filter, +- @PluginAttribute("target") final String t, +- @PluginAttribute("name") final String name, +- @PluginAttribute("follow") final String follow, +- @PluginAttribute("ignoreExceptions") final String ignore) { +- if (name == null) { +- LOGGER.error("No name provided for ConsoleAppender"); +- return null; +- } +- if (layout == null) { +- layout = PatternLayout.createLayout(null, null, null, null, null); +- } +- final boolean isFollow = Boolean.parseBoolean(follow); +- final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true); +- final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t); +- return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions); +- } +- +- private static OutputStreamManager getManager(final boolean follow, final Target target, final Layout layout) { +- final String type = target.name(); +- final OutputStream os = getOutputStream(follow, target); +- return OutputStreamManager.getManager(target.name() + "." + follow, new FactoryData(os, type, layout), factory); +- } +- +- private static OutputStream getOutputStream(final boolean follow, final Target target) { +- final String enc = Charset.defaultCharset().name(); +- PrintStream printStream = null; +- try { +- printStream = target == Target.SYSTEM_OUT ? +- follow ? new PrintStream(new SystemOutStream(), true, enc) : System.out : +- follow ? new PrintStream(new SystemErrStream(), true, enc) : System.err; +- } catch (final UnsupportedEncodingException ex) { // should never happen +- throw new IllegalStateException("Unsupported default encoding " + enc, ex); +- } +- final PropertiesUtil propsUtil = PropertiesUtil.getProperties(); +- if (!propsUtil.getStringProperty("os.name").startsWith("Windows") || +- propsUtil.getBooleanProperty("log4j.skipJansi")) { +- return printStream; +- } +- try { +- final ClassLoader loader = Loader.getClassLoader(); +- // We type the parameter as a wildcard to avoid a hard reference to Jansi. +- final Class clazz = loader.loadClass(JANSI_CLASS); +- final Constructor constructor = clazz.getConstructor(OutputStream.class); +- return (OutputStream) constructor.newInstance(printStream); +- } catch (final ClassNotFoundException cnfe) { +- LOGGER.debug("Jansi is not installed, cannot find {}", JANSI_CLASS); +- } catch (final NoSuchMethodException nsme) { +- LOGGER.warn("{} is missing the proper constructor", JANSI_CLASS); +- } catch (final Throwable ex) { // CraftBukkit - Exception -> Throwable +- LOGGER.warn("Unable to instantiate {}", JANSI_CLASS); +- } +- return printStream; +- } +- +- /** +- * An implementation of OutputStream that redirects to the current System.err. +- */ +- private static class SystemErrStream extends OutputStream { +- public SystemErrStream() { +- } +- +- @Override +- public void close() { +- // do not close sys err! +- } +- +- @Override +- public void flush() { +- System.err.flush(); +- } +- +- @Override +- public void write(final byte[] b) throws IOException { +- System.err.write(b); +- } +- +- @Override +- public void write(final byte[] b, final int off, final int len) +- throws IOException { +- System.err.write(b, off, len); +- } +- +- @Override +- public void write(final int b) { +- System.err.write(b); +- } +- } +- +- /** +- * An implementation of OutputStream that redirects to the current System.out. +- */ +- private static class SystemOutStream extends OutputStream { +- public SystemOutStream() { +- } +- +- @Override +- public void close() { +- // do not close sys out! +- } +- +- @Override +- public void flush() { +- System.out.flush(); +- } +- +- @Override +- public void write(final byte[] b) throws IOException { +- System.out.write(b); +- } +- +- @Override +- public void write(final byte[] b, final int off, final int len) +- throws IOException { +- System.out.write(b, off, len); +- } +- +- @Override +- public void write(final int b) throws IOException { +- System.out.write(b); +- } +- } +- +- /** +- * Data to pass to factory method. +- */ +- private static class FactoryData { +- private final OutputStream os; +- private final String type; +- private final Layout layout; +- +- /** +- * Constructor. +- * @param os The OutputStream. +- * @param type The name of the target. +- * @param layout A Serializable layout +- */ +- public FactoryData(final OutputStream os, final String type, final Layout layout) { +- this.os = os; +- this.type = type; +- this.layout = layout; +- } +- } +- +- /** +- * Factory to create the Appender. +- */ +- private static class ConsoleManagerFactory implements ManagerFactory { +- +- /** +- * Create an OutputStreamManager. +- * @param name The name of the entity to manage. +- * @param data The data required to create the entity. +- * @return The OutputStreamManager +- */ +- @Override +- public OutputStreamManager createManager(final String name, final FactoryData data) { +- return new OutputStreamManager(data.os, data.type, data.layout); +- } +- } +- +-} +diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml +index f37d1c2..b9d8704 100644 +--- a/src/main/resources/log4j2.xml ++++ b/src/main/resources/log4j2.xml +@@ -1,5 +1,5 @@ + +- ++ + + + +@@ -12,6 +12,9 @@ + + + ++ ++ https://9dbb188a495a4145998c3478534c7052:89fefe0909f34090a6a7ad9397a31bd7@app.getsentry.com/66319 ++ + + + +@@ -21,6 +24,7 @@ + + + ++ + + + +-- +2.5.0 + diff --git a/Patches/CraftBukkit-Patches/0165-Inventory-changes.patch b/Patches/CraftBukkit-Patches/0165-Inventory-changes.patch deleted file mode 100644 index 16d404512..000000000 --- a/Patches/CraftBukkit-Patches/0165-Inventory-changes.patch +++ /dev/null @@ -1,428 +0,0 @@ -From 702360d29859ed580b44255ccb7f2f124e6aa24b Mon Sep 17 00:00:00 2001 -From: libraryaddict -Date: Fri, 23 Oct 2015 21:22:36 +1300 -Subject: [PATCH] Inventory changes - - -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java -index e9a3c50..9fd6359 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java -@@ -441,8 +441,8 @@ public class CraftInventory implements Inventory { - return InventoryType.ENCHANTING; - } else if (inventory instanceof TileEntityBrewingStand) { - return InventoryType.BREWING; -- } else if (inventory instanceof CraftInventoryCustom.MinecraftInventory) { -- return ((CraftInventoryCustom.MinecraftInventory) inventory).getType(); -+ } else if (inventory instanceof MinecraftInventory) { -+ return ((MinecraftInventory) inventory).getType(); - } else if (inventory instanceof InventoryEnderChest) { - return InventoryType.ENDER_CHEST; - } else if (inventory instanceof InventoryMerchant) { -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java -index 947c493..eed9afa 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java -@@ -31,168 +31,4 @@ public class CraftInventoryCustom extends CraftInventory { - public CraftInventoryCustom(InventoryHolder owner, int size, String title) { - super(new MinecraftInventory(owner, size, title)); - } -- -- static class MinecraftInventory implements IInventory { -- private final ItemStack[] items; -- private int maxStack = MAX_STACK; -- private final List viewers; -- private final String title; -- private InventoryType type; -- private final InventoryHolder owner; -- -- public MinecraftInventory(InventoryHolder owner, InventoryType type) { -- this(owner, type.getDefaultSize(), type.getDefaultTitle()); -- this.type = type; -- } -- -- public MinecraftInventory(InventoryHolder owner, InventoryType type, String title) { -- this(owner, type.getDefaultSize(), title); -- this.type = type; -- } -- -- public MinecraftInventory(InventoryHolder owner, int size) { -- this(owner, size, "Chest"); -- } -- -- public MinecraftInventory(InventoryHolder owner, int size, String title) { -- Validate.notNull(title, "Title cannot be null"); -- Validate.isTrue(title.length() <= 32, "Title cannot be longer than 32 characters"); -- this.items = new ItemStack[size]; -- this.title = title; -- this.viewers = new ArrayList(); -- this.owner = owner; -- this.type = InventoryType.CHEST; -- } -- -- public int getSize() { -- return items.length; -- } -- -- public ItemStack getItem(int i) { -- return items[i]; -- } -- -- public ItemStack splitStack(int i, int j) { -- ItemStack stack = this.getItem(i); -- ItemStack result; -- if (stack == null) return null; -- if (stack.count <= j) { -- this.setItem(i, null); -- result = stack; -- } else { -- result = CraftItemStack.copyNMSStack(stack, j); -- stack.count -= j; -- } -- this.update(); -- return result; -- } -- -- public ItemStack splitWithoutUpdate(int i) { -- ItemStack stack = this.getItem(i); -- ItemStack result; -- if (stack == null) return null; -- if (stack.count <= 1) { -- this.setItem(i, null); -- result = stack; -- } else { -- result = CraftItemStack.copyNMSStack(stack, 1); -- stack.count -= 1; -- } -- return result; -- } -- -- public void setItem(int i, ItemStack itemstack) { -- items[i] = itemstack; -- if (itemstack != null && this.getMaxStackSize() > 0 && itemstack.count > this.getMaxStackSize()) { -- itemstack.count = this.getMaxStackSize(); -- } -- } -- -- public int getMaxStackSize() { -- return maxStack; -- } -- -- public void setMaxStackSize(int size) { -- maxStack = size; -- } -- -- public void update() {} -- -- public boolean a(EntityHuman entityhuman) { -- return true; -- } -- -- public ItemStack[] getContents() { -- return items; -- } -- -- public void onOpen(CraftHumanEntity who) { -- viewers.add(who); -- } -- -- public void onClose(CraftHumanEntity who) { -- viewers.remove(who); -- } -- -- public List getViewers() { -- return viewers; -- } -- -- public InventoryType getType() { -- return type; -- } -- -- public InventoryHolder getOwner() { -- return owner; -- } -- -- public boolean b(int i, ItemStack itemstack) { -- return true; -- } -- -- @Override -- public void startOpen(EntityHuman entityHuman) { -- -- } -- -- @Override -- public void closeContainer(EntityHuman entityHuman) { -- -- } -- -- @Override -- public int getProperty(int i) { -- return 0; -- } -- -- @Override -- public void b(int i, int i1) { -- -- } -- -- @Override -- public int g() { -- return 0; -- } -- -- @Override -- public void l() { -- -- } -- -- @Override -- public String getName() { -- return title; -- } -- -- @Override -- public boolean hasCustomName() { -- return title != null; -- } -- -- @Override -- public IChatBaseComponent getScoreboardDisplayName() { -- return new ChatComponentText(title); -- } -- } - } -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -index 23f05f4..fdaf026 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -@@ -26,7 +26,7 @@ import net.minecraft.server.NBTTagString; - import org.bukkit.craftbukkit.util.CraftChatMessage; - - @DelegateDeserialization(ItemStack.class) --public final class CraftItemStack extends ItemStack { -+public class CraftItemStack extends ItemStack { - - public static net.minecraft.server.ItemStack asNMSCopy(ItemStack original) { - if (original instanceof CraftItemStack) { -@@ -95,26 +95,30 @@ public final class CraftItemStack extends ItemStack { - /** - * Mirror - */ -- private CraftItemStack(net.minecraft.server.ItemStack item) { -+ protected CraftItemStack(net.minecraft.server.ItemStack item) { - this.handle = item; - } - -- private CraftItemStack(ItemStack item) { -+ protected CraftItemStack(ItemStack item) { - this(item.getTypeId(), item.getAmount(), item.getDurability(), item.hasItemMeta() ? item.getItemMeta() : null); - } - -- private CraftItemStack(Material type, int amount, short durability, ItemMeta itemMeta) { -+ protected CraftItemStack(Material type, int amount, short durability, ItemMeta itemMeta) { - setType(type); - setAmount(amount); - setDurability(durability); - setItemMeta(itemMeta); - } - -- private CraftItemStack(int typeId, int amount, short durability, ItemMeta itemMeta) { -+ protected CraftItemStack(int typeId, int amount, short durability, ItemMeta itemMeta) { - this(Material.getMaterial(typeId), amount, durability, itemMeta); - - } - -+ public net.minecraft.server.ItemStack getHandle() { -+ return handle; -+ } -+ - @Override - public int getTypeId() { - return handle != null ? CraftMagicNumbers.getId(handle.getItem()) : 0; -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/MinecraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/MinecraftInventory.java -new file mode 100644 -index 0000000..f0d8f81 ---- /dev/null -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/MinecraftInventory.java -@@ -0,0 +1,177 @@ -+package org.bukkit.craftbukkit.inventory; -+ -+import net.minecraft.server.*; -+import org.apache.commons.lang.Validate; -+import org.bukkit.craftbukkit.entity.CraftHumanEntity; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.entity.HumanEntity; -+import org.bukkit.event.inventory.InventoryType; -+import org.bukkit.inventory.InventoryHolder; -+ -+import java.util.ArrayList; -+import java.util.List; -+ -+public class MinecraftInventory implements IInventory -+{ -+ private final ItemStack[] items; -+ private int maxStack = MAX_STACK; -+ private final List viewers; -+ private final String title; -+ private InventoryType type; -+ private final InventoryHolder owner; -+ -+ public MinecraftInventory(InventoryHolder owner, InventoryType type) { -+ this(owner, type.getDefaultSize(), type.getDefaultTitle()); -+ this.type = type; -+ } -+ -+ public MinecraftInventory(InventoryHolder owner, InventoryType type, String title) { -+ this(owner, type.getDefaultSize(), title); -+ this.type = type; -+ } -+ -+ public MinecraftInventory(InventoryHolder owner, int size) { -+ this(owner, size, "Chest"); -+ } -+ -+ public MinecraftInventory(InventoryHolder owner, int size, String title) { -+ Validate.notNull(title, "Title cannot be null"); -+ Validate.isTrue(title.length() <= 32, "Title cannot be longer than 32 characters"); -+ this.items = new ItemStack[size]; -+ this.title = title; -+ this.viewers = new ArrayList(); -+ this.owner = owner; -+ this.type = InventoryType.CHEST; -+ } -+ -+ public int getSize() { -+ return items.length; -+ } -+ -+ public ItemStack getItem(int i) { -+ return items[i]; -+ } -+ -+ public ItemStack splitStack(int i, int j) { -+ ItemStack stack = this.getItem(i); -+ ItemStack result; -+ if (stack == null) return null; -+ if (stack.count <= j) { -+ this.setItem(i, null); -+ result = stack; -+ } else { -+ result = CraftItemStack.copyNMSStack(stack, j); -+ stack.count -= j; -+ } -+ this.update(); -+ return result; -+ } -+ -+ public ItemStack splitWithoutUpdate(int i) { -+ ItemStack stack = this.getItem(i); -+ ItemStack result; -+ if (stack == null) return null; -+ if (stack.count <= 1) { -+ this.setItem(i, null); -+ result = stack; -+ } else { -+ result = CraftItemStack.copyNMSStack(stack, 1); -+ stack.count -= 1; -+ } -+ return result; -+ } -+ -+ public void setItem(int i, ItemStack itemstack) { -+ items[i] = itemstack; -+ if (itemstack != null && this.getMaxStackSize() > 0 && itemstack.count > this.getMaxStackSize()) { -+ itemstack.count = this.getMaxStackSize(); -+ } -+ } -+ -+ public int getMaxStackSize() { -+ return maxStack; -+ } -+ -+ public void setMaxStackSize(int size) { -+ maxStack = size; -+ } -+ -+ public void update() {} -+ -+ public boolean a(EntityHuman entityhuman) { -+ return true; -+ } -+ -+ public ItemStack[] getContents() { -+ return items; -+ } -+ -+ public void onOpen(CraftHumanEntity who) { -+ viewers.add(who); -+ } -+ -+ public void onClose(CraftHumanEntity who) { -+ viewers.remove(who); -+ } -+ -+ public List getViewers() { -+ return viewers; -+ } -+ -+ public InventoryType getType() { -+ return type; -+ } -+ -+ public InventoryHolder getOwner() { -+ return owner; -+ } -+ -+ public boolean b(int i, ItemStack itemstack) { -+ return true; -+ } -+ -+ @Override -+ public void startOpen(EntityHuman entityHuman) { -+ -+ } -+ -+ @Override -+ public void closeContainer(EntityHuman entityHuman) { -+ -+ } -+ -+ @Override -+ public int getProperty(int i) { -+ return 0; -+ } -+ -+ @Override -+ public void b(int i, int i1) { -+ -+ } -+ -+ @Override -+ public int g() { -+ return 0; -+ } -+ -+ @Override -+ public void l() { -+ -+ } -+ -+ @Override -+ public String getName() { -+ return title; -+ } -+ -+ @Override -+ public boolean hasCustomName() { -+ return title != null; -+ } -+ -+ @Override -+ public IChatBaseComponent getScoreboardDisplayName() { -+ return new ChatComponentText(title); -+ } -+} --- -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 deleted file mode 100644 index db2d14f2d..000000000 --- a/Patches/CraftBukkit-Patches/0178-Sound-and-vehicle-fixes.patch +++ /dev/null @@ -1,47 +0,0 @@ -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/Plugins/Libraries/craftbukkit.jar b/Patches/craftbukkit.jar similarity index 87% rename from Plugins/Libraries/craftbukkit.jar rename to Patches/craftbukkit.jar index c7cb7fa92..cef2d1023 100644 Binary files a/Plugins/Libraries/craftbukkit.jar and b/Patches/craftbukkit.jar differ diff --git a/Plugins/Mineplex.Bungee.Mineplexer/pom.xml b/Plugins/Mineplex.Bungee.Mineplexer/pom.xml index 4b46f2b44..dceb4ba39 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/pom.xml +++ b/Plugins/Mineplex.Bungee.Mineplexer/pom.xml @@ -28,6 +28,10 @@ commons-codec commons-codec + + net.kencochrane.raven + raven-log4j2 + net.md-5 bungeecord-proxy diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java index 8ac4d3860..a5d48c5ee 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/Mineplexer.java @@ -1,11 +1,15 @@ package mineplex.bungee; +import java.util.logging.Handler; +import java.util.logging.Level; import mineplex.bungee.lobbyBalancer.LobbyBalancer; import mineplex.bungee.motd.MotdManager; import mineplex.bungee.playerCount.PlayerCount; import mineplex.bungee.playerStats.PlayerStats; import mineplex.bungee.playerTracker.PlayerTracker; import mineplex.bungee.status.InternetStatus; +import net.kencochrane.raven.RavenFactory; +import net.kencochrane.raven.jul.SentryHandler; import net.md_5.bungee.api.plugin.Plugin; public class Mineplexer extends Plugin @@ -13,6 +17,11 @@ public class Mineplexer extends Plugin @Override public void onEnable() { + // Sentry setup + Handler sentry = new SentryHandler(RavenFactory.ravenInstance("https://470f12378af3453ba089e0c0a0c9aae6:292516b722594784807aebb06db8ec38@app.getsentry.com/66323")); + sentry.setLevel(Level.WARNING); + getProxy().getLogger().addHandler(sentry); + new MotdManager(this); new LobbyBalancer(this); PlayerCount playerCount = new PlayerCount(this); diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStatsRepository.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStatsRepository.java index 5227ab818..f46641165 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStatsRepository.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStatsRepository.java @@ -10,14 +10,13 @@ import java.util.UUID; import mineplex.bungee.playerStats.data.IpInfo; import mineplex.cache.player.PlayerInfo; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; -public class PlayerStatsRepository +import javax.sql.DataSource; + +public class PlayerStatsRepository extends RepositoryBase { - private Connection _connection = null; - private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/PlayerStats?autoReconnect=true&failOverReadOnly=false&maxReconnects=10&allowMultiQueries=true"; - private String _userName = "root"; - private String _password = "tAbechAk3wR7tuTh"; - private static String INSERT_PLAYERINFO = "INSERT INTO playerInfo (uuid, name, version) VALUES (?, ?, ?);"; private static String SELECT_PLAYERINFO = "SELECT id, name, version FROM playerInfo WHERE uuid = ?;"; private static String UPDATE_PLAYERINFO = "UPDATE playerInfo SET name = ?, version = ? WHERE id = ?;"; @@ -30,34 +29,33 @@ public class PlayerStatsRepository + "INSERT IGNORE INTO playerLoginSessions (playerInfoId, loginTime) values(?, now());"; private static String UPDATE_LOGINSESSION = "UPDATE playerLoginSessions SET timeInGame = TIME_TO_SEC(TIMEDIFF(now(), loginTime)) / 60 WHERE id = ?;"; - + + public PlayerStatsRepository() + { + super(DBPool.getStats()); + } + + @Override public void initialize() { - try - { - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - } - catch (Exception exception) - { - exception.printStackTrace(); - } - - System.out.println("Initialized PlayerStats."); + } - + + @Override + protected void update() + { + + } + public PlayerInfo getPlayer(UUID uuid, String name, int version) { PlayerInfo playerInfo = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; - try + try(Connection connection = getConnection()) { - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - - preparedStatement = _connection.prepareStatement(SELECT_PLAYERINFO); + preparedStatement = connection.prepareStatement(SELECT_PLAYERINFO); preparedStatement.setString(1, uuid.toString()); @@ -73,7 +71,7 @@ public class PlayerStatsRepository if (playerInfo == null) { - preparedStatement = _connection.prepareStatement(INSERT_PLAYERINFO, Statement.RETURN_GENERATED_KEYS); + preparedStatement = connection.prepareStatement(INSERT_PLAYERINFO, Statement.RETURN_GENERATED_KEYS); preparedStatement.setString(1, uuid.toString()); preparedStatement.setString(2, name); preparedStatement.setInt(3, version); @@ -96,7 +94,7 @@ public class PlayerStatsRepository } else if (!playerInfo.getName().equalsIgnoreCase(name) || playerInfo.getVersion() != version) { - preparedStatement = _connection.prepareStatement(UPDATE_PLAYERINFO); + preparedStatement = connection.prepareStatement(UPDATE_PLAYERINFO); preparedStatement.setString(1, name); preparedStatement.setInt(2, version); preparedStatement.setInt(3, playerInfo.getId()); @@ -145,12 +143,9 @@ public class PlayerStatsRepository PreparedStatement preparedStatement = null; ResultSet resultSet = null; - try + try(Connection connection = getConnection()) { - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - - preparedStatement = _connection.prepareStatement(SELECT_IPINFO); + preparedStatement = connection.prepareStatement(SELECT_IPINFO); preparedStatement.setString(1, ipAddress); resultSet = preparedStatement.executeQuery(); @@ -167,7 +162,7 @@ public class PlayerStatsRepository if (ipInfo == null) { - preparedStatement = _connection.prepareStatement(INSERT_IPINFO, Statement.RETURN_GENERATED_KEYS); + preparedStatement = connection.prepareStatement(INSERT_IPINFO, Statement.RETURN_GENERATED_KEYS); preparedStatement.setString(1, ipAddress); preparedStatement.executeUpdate(); @@ -228,12 +223,9 @@ public class PlayerStatsRepository Statement statement = null; ResultSet resultSet= null; - try + try(Connection connection = getConnection()) { - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - - statement = _connection.createStatement(); + statement = connection.createStatement(); String queryString = UPDATE_PLAYERSTATS; queryString = queryString.replaceFirst("\\?", playerId + ""); @@ -286,12 +278,9 @@ public class PlayerStatsRepository { PreparedStatement preparedStatement = null; - try + try(Connection connection = getConnection()) { - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - - preparedStatement = _connection.prepareStatement(UPDATE_LOGINSESSION); + preparedStatement = connection.prepareStatement(UPDATE_LOGINSESSION); preparedStatement.setInt(1, loginSessionId); preparedStatement.executeUpdate(); diff --git a/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/PlayerStatsRepository.java b/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/PlayerStatsRepository.java index f5b298ae9..c664fedb7 100644 --- a/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/PlayerStatsRepository.java +++ b/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/PlayerStatsRepository.java @@ -1,50 +1,43 @@ package mineplex.bungee; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; + +import java.sql.*; import java.util.ArrayList; import java.util.List; -public class PlayerStatsRepository +public class PlayerStatsRepository extends RepositoryBase { - private Connection _connection = null; - private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/PlayerStats?autoReconnect=true&failOverReadOnly=false&maxReconnects=10&allowMultiQueries=true"; - private String _userName = "root"; - private String _password = "tAbechAk3wR7tuTh"; - private static String SELECT_IPINFO = "SELECT id, ipAddress FROM ipInfo WHERE regionName IS NULL LIMIT 1000;"; private static String UPDATE_IPINFO = "UPDATE ipInfo SET countryCode = ?, countryName = ?, regionCode = ?, regionName = ?, city = ?, zipCode = ?, timeZone = ?, latitude = ?, longitude = ?, metroCode = ? WHERE id = ?;"; - - public void initialize() + + public PlayerStatsRepository() { - try - { - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - } - catch (Exception exception) - { - exception.printStackTrace(); - } - - System.out.println("Initialized PlayerStats."); + super(DBPool.getStats()); } - + + @Override + protected void initialize() + { + + } + + @Override + protected void update() + { + + } + public List getIpAddresses() { List ipinfos = new ArrayList(1000); PreparedStatement preparedStatement = null; ResultSet resultSet = null; - try + try(Connection connection = getConnection()) { - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - - preparedStatement = _connection.prepareStatement(SELECT_IPINFO); + preparedStatement = connection.prepareStatement(SELECT_IPINFO); resultSet = preparedStatement.executeQuery(); @@ -98,12 +91,9 @@ public class PlayerStatsRepository { PreparedStatement preparedStatement = null; - try + try(Connection connection = getConnection()) { - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - - preparedStatement = _connection.prepareStatement(UPDATE_IPINFO); + preparedStatement = connection.prepareStatement(UPDATE_IPINFO); for (IpInfo ipInfo : ips) { diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/ConfigContainer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/ConfigContainer.java new file mode 100644 index 000000000..9974025c0 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/ConfigContainer.java @@ -0,0 +1,46 @@ +package mineplex.core.common; + +import java.io.File; +import java.io.IOException; +import java.util.logging.Level; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.Plugin; + +public class ConfigContainer +{ + + private final Plugin _plugin; + private File _configFile; + private FileConfiguration _config; + + public ConfigContainer(Plugin plugin, String configFile) + { + this._plugin = plugin; + this._configFile = new File(configFile); + } + + public FileConfiguration getConfig() { + if (_config == null) + { + if (_configFile.isFile()) + { + _config = YamlConfiguration.loadConfiguration(_configFile); + } else { + _config = _plugin.getConfig(); + _configFile = new File(_plugin.getDataFolder(), "config.yml"); + } + } + + return _config; + } + + public void saveConfig() { + try + { + getConfig().save(_configFile); + } catch (IOException ex) { + _plugin.getLogger().log(Level.SEVERE, "Could not save config to " + _configFile, ex); + } + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index f53e986b2..ebc0fdb1b 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -28,6 +28,10 @@ public class SkinData public final static SkinData PRESENT = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk3MDIxNjIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2U2YzRkZWQwNTdjMjhiMTU0NjVkYzQzNmFmODIyYTNkZTY4NzgyZTZjMzgyOGMzMmFhYWE4ZjRiOTIzOWVjIn19fQ==","rJNlxTqHHmOoWwbXdMQLcj0P9w/PIr/hWKXH0nbhm/S2CFo/zfefffZlnQmpKCgn1Y8tXvcRwLGQ4CLpm9m2ZrKprSWRhrnOtZWYabrhExQESEammS3TY81VoNt+4On0pAGBippz/bRfWLuDne2rDbhuljnqvxjROmxpky7gRCU06VMlm2WLFC5XYJkiAaOXBqzpiHMMRPNnCvtcbtpILKi/Luj302eyN8nRKjHHbbiDmttwvlshxZ8UxJHvALtM506IUHba10Q6QX2zCeDAU5/WYRKa6e19r8plROcgGbKYFSq8JW5cWuWT3/rveZM6FnU6ABn9DWsCyfQ5wr2jdBd+xaevGTAScRHA5J493GqL1bBZYKj9yhQFtxJHCAf0++raAVPCZgyPtwTth4TAQisn8gnhM5R+txnW6xK+oflLy0dwEN1YdPLN/h7yuDnyjSMDe9RZT2NKMjok2C6Kux4WBI0KFXKC5Gqwa3Htku4v3WEOWMaVoWOtchQ9BzpQ/etD0ylmzjALQLB+HtndEEm1Jd3tmob42X4hBE8hCce7C3EtGINB33dlx4CK1xBqyGTJEqi69DJRzVL99u98+7kJ1Db9+MaPOfI4B2RY3XbvnSYwecandY//A3bb19FGSdl299ZXbp4zpm8fivzeB1rUAhhmtaA3Iwu/nEQNMkU="); public final static SkinData RUDOLPH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk1NjgxODIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2IzZjdlMjhiNTJkZjJjZjhlZWM2NDk2ZmM0NWFlMGQ2NTM0Njc5OGIxYWRjNzM3ZDcxYzBmOTRlNDIyMSJ9fX0=","uUBOTe63CL+qRvtsb2g4AjB2YzxE3N6AUqIsTv8n0jYyPsuXpuOmZPSMEdgDVONywEJ1L4XRx05sjnGu56A8vuXmGI/uHQWuMZzbOSjiFfT3DkEm8zEl5AWpH9dz/t8nZ1WYUIwy0pN5VrZqIr1DAkF6AMh/Qy+FGDw1GG9ReRr80eJ0JiRskpkCpCZIGGjrgwNKAM8JOuNZ4gCQOTRC3etrcfls3qmUMFcVlhuB4bydxSR01i2w0A4b5KpufsJjLKw4InWn2+m/druo8hl9sYuusTeItW0MQmZqCAqXCc9YBnRPQ0hDXFgnPxOh3RwGWiZvL4MnWUVmLwZWh/Fk9QmyVbd7zVao0lxS8YNsKtP8j5B+hs4l9qNohhf0A07bt4oPeTtd5fQeOU5N87fUGuUAcpC4gP9U5WpVY5FFPBvLvGbXdV5jpuAQz4lLSoo1grsP9baR2IBvdN/0awjQWoPJfGOttegubkBHwz3LNcVqvZLtX/M13IDHZa6zQZEX0wsnMX60LeWgBWfTON1l2cSgaPTerHFS2EifJ2LvTBife3s9/4XR6Zth3FLFqxI3MSlqT2hVFRPLke6rBqfqPoWOj2MCykQ70IAwb3oTHcJDJ86V2DdNaU2bZ8V4TjaP+nRobsLJOImoPYEPq23MP36X8gbXEIjmuu8S5xRlrrc="); public final static SkinData THE_GRINCH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTYxNDMwMDQsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzg4ZWRlOTI3ZDQzOWVmMzliMzFhYzFkYzJhODM5NGZlNzlhY2U4NDMyNzBjYmUxMjg2ZGM3NTE3ZjMxYTk2In19fQ==","ELo594vTzPq9ZmPYOtVr4kim/k19gzmoxEIK1ehS87gwgag5HcgM+P1FMnHIyrmSvTVaMh0NxwXmNS+JETFL7OrmgRYNpkxkkO4VBA0pfSn3dA9ujnXpDnDiWEPxKdMgQspIOOI0Z3esNt3pj8qIj6dWPtGwtso48tjHl2o/kazfa82yvGORlFhGkeEJKQMno/Buc12C0foQw39XI8GjvlSkFN2eH4Fp16RLu8/hf7SqJQC3L1KacvzMW1d8BWEIgACCJDni29+YqxflSqSyYrV4Z+D66S0jYvUUL/vM4/q/p/YWX/vs/FtMtHQTj4PCpAmMNTgfkahuhb6rCvKHukbjA+WhUdwyxSqXU5YnpXCu1M2dzZgiXjIi+fnyn4CmXKindWCQtSwu+mCA2ILv/6vEHoYJgdlz+DXyRkFx+DH4Sl74HBCOXTOq5AGjq5h3LYfsre+UjCCUv8VgxbVprOyj35So7K0m+6faCFVSt35T3RgicDQfdiWUrW7kmHQVvJpvaq9Vu+63F/0X93cwqwaR0buMirxRx7qkFrRunSI4T+9fsN02t1fAieeu80lBSv83wr7BFneSsLsdVAND9xttTb6fClg7anr8/XVEVIkylB4B+ZcWQbH61XP1nn7oFP2VBg1h6XuuLp8FGSgYf/LW+54/KZci/MnanqQE6QQ="); + public final static SkinData TEDDY_BEAR = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMDkzOTE4MjYsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzQ0OTU4ZDdjNjlhZTQ4NGM2NWYzMTM0N2NkY2M5MmM2OWY1NDA2ODA1YjUzNjUyYTc1YThlZDc5OWRmNyJ9fX0=", "sNTRV9jTjLszUmyaqyEG7N8d5RM1jbwMSXi34S2EkVmIjWsowfSMnHRQqqgZfxcyqBM5I7MljtB84IeQWu4rqhyFrM9blWvtowjijFIOgKCs97q2sswv9iauU6ohvgTpgN5B0Q16MJmMIgZU8d8TATtEaIzq2eg6Ve1AJlNnW4huGNsoNfm8WdVU1tZmsYAwtVP/ryvhyj7mHyVF27m0Sm4fZRf/lHH5gEJYB4JHSAoEhjPIQOdkgRMJRrWGOfhhiGs3kEWmsRGfIPFo2ZJfcu+TFV2rd4Q+A1LmY8kimnzdKX3InXeKbk8qzcgqGNro4XFnSiHo1d6/B+N0JeYOTITYRQ6u24rNSUh5ezbG01iikVFCfrgb7UR6utoLK15F4/fmhpex+BJpmyZoXAqk08tZws/5wsIWQ1okrGcbBKWEHhw2ekUc82US21/W53vd657UBg7FuqM4FhkAqmsYPvYLMpNYxxmDJaI8uJyU7cnGFYyBaFlqUxfJUfcFTwWo10JO3yp5FjqeCQa7rFvfpsqw3w2mBpJmlZ5HRjfS5pmhk0QiY0TRfwZfFemkuZYnNbO82qLUm+6zTm0fbC90Swt8nNr/42ajzEoUjnL6VsERIXS5/fPwjftbQAC60ujy8yo66Sp3sSAALNg5zjM+Uizkq2f9Axc+kind22hp10M="); + public final static SkinData COMPANION_CUBE = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMDk5NjI0NjEsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2MyMTVkYmRhNTY1ZjVjYjhlYjEyZjU1NWY1ZTNkYTBlYTVmNTUxOTg5MWNjNWM1ZDY3NmZkODJjNjIifX19", "vaAQbhnhnTOs64ToFWLg7o4JmqkIl07HWJ6l7xibfISaOcU4BvYBxsfGvmoxlVdsUeCunAJ8/05qVLl5zZYd8Dt+To6JSY0RlqV8piRaaj3FztYWV2ZvG3YZxPxiD3HRJTAQnDobSuxHyPa1e3khjAFp9xJo4q1oqQ28oI2WDuoT+IHqxwkKVbGzO7UD5lzz5chjQC46E8SxddNKp9aqwbbccrkHYT4gteoonOXu4MFxZniJN12LqUCb6+G15rU8MijlBkWx0xE5NMUloeTGuJZItbHun9fysLk/+HE5xJOKYtpZNMuWX+DB/O5ds9dXrOoSAg+Vn0QU4CZbwcxzLii5ILOfEEBtePuEAgzROri+iCKp59CqlEMBrCsd3Um0MCdbuOfvkXGBHBz+bqX7VJY1ujlSdMefmbJtHAkDANnsaaVb+eli9Dk6139041sptsLytD+EfJzaitX6crBwKZ2WDx2P6LHo8B+iSOzOJxjf/08zlXqFw1vsk62IN6lisuZ89QyZw23RvOx3obLAGYs1GxAlMl9qQdpXcmuE1+lPR3g8gZ0BfnTeYwflC2wbR1tuwGG98lyUGCvGLyqNKAQTN87XV4IFQWR81mi1c5CcasoWhKf9D9nAik9aK7A915fEE5IvpeuUdZseDxDVVN5dBIs5q2PIHFAS0rDsDBc="); + public final static SkinData LOVESTRUCK = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMTAyNDMyNjUsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzczMTY5YWQwZTUyYjM1N2NiZGYxZDU0NGVkNGNmOWJmOTI4YmI0ZWNlMDhlY2YyY2M0YmYyYTlmMjJhODI4MmQifX19", "LL4RiSKQoTZamRQ4QG6izpvhgFu5gAqW4eZxcWAihk7GkhyxifpJpBTOzKrj5hH9fCUfYkkijVWUYTEcVSVRWhocp2HXW59TbKfxOeMvHU5vTMwgpwm6PnUfwuTsRPSLC7WMnEreI3cjOxPVmXbTniOSd+o8j4oOIgwFS+VLPiYLh5Jl16i5I/9ekafl3/x41NISKWl62geqO2jPWehlk+r3soiRJsxaKw20T61GSNLu19iA96Rz2T2tUHB4opm8hbLgoiNL2g1affTjq3cZPLHH4JWF3vPhqLB5uw6xb55vFLM/PP0YiEMIi7YZOfRGeaPp7uXbXgHeew+7PG9UDVMfqbwANQY4ndECijZoei54+xX3MDXkMhQsc5S+FLnGH6e4d008v81eEOyzJUPkKbGxLCBgTUb1s4IHwomCr30twPlo1IuFBOY1qeVvZUfAfPJsREuj5q/oCAoYFgupmb3ClWECnwwaH/T4wdHjfSBHoZQdLzcgDOAl0b5EXxWmYBECqk/WA4TrYIDVGdwkqjI0RkPLUoxTj6135KO+F7P7PwhU9WBGeW8hHq918DBL0fjQVHjrzvolTqwmw6nySSePnPOxFX/iwtHWzpBa9V6kUNNN+V7OGTgRr0H/yUxB+oq1F8UBqyqT4YpqxXCSD36derF/Xt5IdpTbEbGBpm0="); + public final static SkinData SECRET_PACKAGE = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTUxMTAzNzE3OTIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2QyNWI5YTRjOWRhOThkZTliZmIwZDNjOWI1M2MzMjJhMjgxN2IyMTMxOTQzY2E1YWM2NTBjZThmMzEzZjdhIn19fQ==", "Wb5T0Zhp1RVt78V/i8dYrwZCNT0xZIRe3LvL0bngH498f8Jrl43KHgTi4f299zE9giVynkTogGhJ8inq/xqFCRctl7Nn9L3LVu78uQwt+fs+o+kw/Qc+lggFSjEIc+fc13AZndpec0Df46Kh/OGD7NXbtbLb6TE/0dU2RwQlvZrZ/QHYJb8OJ6aUcnHvAZim8NUtG/nlZtSClepHVSuKdNnfzoF9rFVFA/x4jTr6mZYPZ33YgQd2oTAPk+qE3iN+0InjZQNs2YLoKFmFrgzn+tGvNApC0siF0HEZGQCFIwJOtnBsasGoxujIrln/ZdOil+5ac4VWInXr8lKgY0Q3Ocy8/0cJl+E/XqB+ztG29zhB8B1zdHBfJr+MgeSIqBCPx4SCtY6r7gnMlQYG+uVx5NP3S5aJW/cEfDyXmpCykIcBPzeErnKC0SiAqXkCVNjWJpX6qRWvWMXqS69w6ht6qHvEY2GxlZUb5AP+JgFlsl3hJDms6EPvM4zNL0Ko4oWIBzwYRQXiemrP9TGgyo0aL1RcQ0JgBFO2hSo37PK0YL3tUPgteJXzm21wu0TiZLkLCWSgMUfYfvVnhTa+xzod0xvfujpN6Y1DUTdcf8WS8TRYw2JigSkWrRW0fXPBCtTtQN5jiwM5/HrTpNLzg03J6SpfZ+rr8Rhq0S/8beQOMas="); private Property _skinProperty; 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 d01556e40..744cc2462 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 @@ -255,6 +255,25 @@ public class UtilAlg return vec; } + + public static Entity findClosest(Entity mid, ArrayList locs) + { + Entity bestLoc = null; + double bestDist = 0; + + for (Entity loc : locs) + { + double dist = UtilMath.offset(mid, loc); + + if (bestLoc == null || dist < bestDist) + { + bestLoc = loc; + bestDist = dist; + } + } + + return bestLoc; + } public static Location findClosest(Location mid, ArrayList locs) { 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 1f84fdaaa..c632a1f99 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 @@ -1413,6 +1413,11 @@ public class UtilBlock case ANVIL: itemStack.setDurability((short) (itemStack.getDurability() / 4)); break; + case QUARTZ_BLOCK: + if (itemStack.getDurability() == 4 || itemStack.getDurability() == 3) + itemStack.setDurability((short) 2); + + break; } return itemStacks; diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 566be1092..f4f73003a 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -634,10 +634,7 @@ public class UtilEnt //Fences/Walls Material beneath = player.getLocation().add(x, -1.5, z).getBlock().getType(); if (player.getLocation().getY() % 0.5 == 0 && - (beneath == Material.FENCE || - beneath == Material.FENCE_GATE || - beneath == Material.NETHER_FENCE || - beneath == Material.COBBLE_WALL)) + (beneath.toString().contains("FENCE") || beneath == Material.COBBLE_WALL)) return true; } } 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 658c984ed..746b3cf6b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -10,6 +10,7 @@ import java.util.LinkedList; import java.util.List; import java.util.UUID; +import mineplex.core.database.MinecraftRepository; import org.bukkit.Bukkit; import com.google.gson.reflect.TypeToken; import org.bukkit.plugin.java.JavaPlugin; @@ -21,16 +22,16 @@ import mineplex.core.account.repository.token.RankUpdateToken; import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; -import mineplex.core.database.DBPool; -import mineplex.core.database.DatabaseRunnable; -import mineplex.core.database.RepositoryBase; -import mineplex.core.database.ResultSetCallable; -import mineplex.core.database.column.ColumnBoolean; -import mineplex.core.database.column.ColumnTimestamp; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.DatabaseRunnable; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnBoolean; +import mineplex.serverdata.database.column.ColumnTimestamp; +import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.core.server.remotecall.JsonWebCall; -public class AccountRepository extends RepositoryBase +public class AccountRepository extends MinecraftRepository { private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, rank VARCHAR(40), rankPerm BOOL, rankExpire LONG, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuid), UNIQUE INDEX nameIndex (name), INDEX rankIndex (rank));"; private static String ACCOUNT_LOGIN_NEW = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now());"; @@ -234,7 +235,7 @@ public class AccountRepository extends RepositoryBase executeUpdate(UPDATE_ACCOUNT_RANK, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString())); } - Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable() + Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable() { @Override public void run() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index ab07c5147..ad8b468ac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -29,7 +29,21 @@ public enum Achievement "during Christmas 2015!"}, new int[]{200}, AchievementCategory.HOLIDAY), - + + GLOBAL_GIFT_GIVER_2016("2016 Gift Giver", 0, + new String[]{"Global.Valentines2016.GiftsGiven"}, + new String[]{"Give 3 Valentines Gifts", + "during Valentines 2016!"}, + new int[]{3}, + AchievementCategory.HOLIDAY), + + GLOBAL_GIFT_GETTER_2016("2016 People Love Me", 2000, + new String[]{"Global.Valentines2016.GiftsReceived"}, + new String[]{"Receive 10 Gifts", + "during Valentines 2016!"}, + new int[]{10}, + AchievementCategory.HOLIDAY), + //Bridges BRIDGES_WINS("Bridge Champion", 600, new String[]{"The Bridges.Wins"}, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java index 6c736e5be..39ad8f19d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java @@ -199,7 +199,7 @@ public class AchievementManager extends MiniPlugin level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel()); if (sender.getName().equalsIgnoreCase("Phinary")) - level = -level; + level = 0; return level; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java index 23a0694b0..d80308172 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java @@ -4,7 +4,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -import mineplex.core.database.DBPool; +import mineplex.serverdata.database.DBPool; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManagerRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManagerRepository.java index eb5628130..60af1605a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManagerRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManagerRepository.java @@ -3,14 +3,15 @@ package mineplex.core.benefit; import java.sql.ResultSet; import java.sql.SQLException; -import mineplex.core.database.DBPool; -import mineplex.core.database.RepositoryBase; -import mineplex.core.database.column.ColumnInt; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.core.database.MinecraftRepository; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; import org.bukkit.plugin.java.JavaPlugin; -public class BenefitManagerRepository extends RepositoryBase +public class BenefitManagerRepository extends MinecraftRepository { private static String CREATE_BENEFIT_TABLE = "CREATE TABLE IF NOT EXISTS rankBenefits (id INT NOT NULL AUTO_INCREMENT, accountId INT, benefit VARCHAR(100), PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));"; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index 0aa8652cf..1dd545c93 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -7,8 +7,6 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedList; import java.util.Queue; import java.util.TimeZone; @@ -17,7 +15,6 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; -import mineplex.core.account.IQuerylessLoginProcessor; import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.bonuses.redis.VoteHandler; import mineplex.core.bonuses.redis.VotifierCommand; @@ -30,10 +27,10 @@ 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.core.database.DBPool; +import mineplex.serverdata.database.DBPool; import mineplex.core.donation.DonationManager; +import mineplex.core.donation.GiveDonorData; import mineplex.core.facebook.FacebookManager; -import mineplex.core.giveaway.GiveawayManager; import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; @@ -59,7 +56,6 @@ import mineplex.core.bonuses.gui.SpinGui; import mineplex.core.poll.PollManager; import mineplex.serverdata.commands.ServerCommandManager; -import org.jooq.DSLContext; import org.jooq.SQLDialect; import org.jooq.impl.DSL; import org.bukkit.Bukkit; @@ -68,8 +64,9 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -170,7 +167,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, FacebookManager facebookManager) + public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager) { super("Bonus", plugin); _repository = new BonusRepository(plugin, this, donationManager); @@ -180,7 +177,7 @@ public class BonusManager extends MiniClientPlugin implements I _hologramManager = hologramManager; _inventoryManager = inventoryManager; - _rewardManager = new RewardManager(clientManager, statusManager, donationManager, inventoryManager, petManager, statsManager, giveawayManager, + _rewardManager = new RewardManager(clientManager, statusManager, donationManager, inventoryManager, petManager, statsManager, 100, 250, 500, 1000, 4000, 6000, @@ -755,7 +752,7 @@ public class BonusManager extends MiniClientPlugin implements I if (gems > 0) { UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gems + " Gems"))); - _gemQueue.add(new GiveDonorData(player.getName(), coreClient.getAccountId(), player.getUniqueId(), gems)); + _gemQueue.add(new GiveDonorData(null, player.getName(), "Treasure", player.getUniqueId(), coreClient.getAccountId(), gems)); } if (gold > 0) @@ -780,7 +777,7 @@ public class BonusManager extends MiniClientPlugin implements I if (coins > 0) { UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(coins + " Treasure Shards"))); - _coinQueue.add(new GiveDonorData(player.getName(), coreClient.getAccountId(), player.getUniqueId(), coins)); + _coinQueue.add(new GiveDonorData(null, player.getName(), "Treasure", player.getUniqueId(), coreClient.getAccountId(), coins)); } if (tickets > 0) @@ -821,8 +818,8 @@ public class BonusManager extends MiniClientPlugin implements I } } - @EventHandler - public void openGui(PlayerInteractEntityEvent event) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void openGui(PlayerInteractAtEntityEvent event) { if (!_enabled) return; @@ -851,7 +848,7 @@ public class BonusManager extends MiniClientPlugin implements I } } } - + public static long getNextVoteTime(long time) { Calendar calendar = Calendar.getInstance(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java index 2ce772e8c..a00e6373e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java @@ -10,9 +10,10 @@ import java.sql.Types; import mineplex.core.common.Pair; 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.MinecraftRepository; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; import mineplex.core.donation.DonationManager; import mineplex.core.recharge.Recharge; import mineplex.database.Tables; @@ -28,7 +29,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; -public class BonusRepository extends RepositoryBase +public class BonusRepository extends MinecraftRepository { private static String CREATE_BONUS_TABLE = "CREATE TABLE IF NOT EXISTS bonus (accountId INT NOT NULL AUTO_INCREMENT, dailytime TIMESTAMP NULL DEFAULT NULL, ranktime DATE NULL DEFAULT NULL, PRIMARY KEY (accountId), FOREIGN KEY (accountId) REFERENCES accounts(id));"; private BonusManager _manager; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/GiveDonorData.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/GiveDonorData.java deleted file mode 100644 index 1aa07d0d5..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/GiveDonorData.java +++ /dev/null @@ -1,50 +0,0 @@ -package mineplex.core.bonuses; - -import java.util.UUID; - -public class GiveDonorData -{ - private String _playerName; - private int _accountId; - private UUID _uuid; - private int _giveAmount; - private int _attempts; - - public GiveDonorData(String playerName, int accountId, UUID uuid, int giveAmount) - { - _playerName = playerName; - _accountId = accountId; - _uuid = uuid; - _giveAmount = giveAmount; - } - - public String getPlayerName() - { - return _playerName; - } - - public int getAccountId() - { - return _accountId; - } - - public UUID getUuid() - { - return _uuid; - } - - public int getGiveAmount() - { - return _giveAmount; - } - - public int getAttempts() - { - return _attempts; - } - - public void incrementAttempts() - { - _attempts++; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/repository/BotSpamRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/repository/BotSpamRepository.java index 3af3d0d4f..30d8f0c62 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/repository/BotSpamRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/repository/BotSpamRepository.java @@ -4,16 +4,17 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.database.DBPool; -import mineplex.core.database.RepositoryBase; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; import mineplex.core.botspam.SpamText; -import mineplex.core.database.ResultSetCallable; -import mineplex.core.database.column.ColumnInt; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; -public class BotSpamRepository extends RepositoryBase +public class BotSpamRepository extends MinecraftRepository { private static final String GET_SPAM_TEXT = "SELECT * FROM botSpam"; private static final String ADD_SPAM_TEXT = "INSERT INTO botSpam (text, createdBy, enabledBy) VALUES (?, ?, ?)"; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index eca038bb7..a0166d63b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -55,7 +55,7 @@ public class Chat extends MiniPlugin private AchievementManager _achievements; private String[] _hackusations = {"hack", "hax", "hacker", "hacking", "cheat", "cheater", "cheating", "forcefield", "flyhack", "flyhacking", "autoclick", "aimbot"}; - private String _filterUrl = "https://10.33.53.5:8003/content/item/moderate"; + private String _filterUrl = "https://chat.mineplex.com:8003/content/item/moderate"; private String _appId = "34018d65-466d-4a91-8e92-29ca49f022c4"; private String _apiKey = "oUywMpwZcIzZO5AWnfDx"; private String _serverName; @@ -243,7 +243,10 @@ public class Chat extends MiniPlugin event.setMessage(getFilteredMessage(event.getPlayer(), event.getMessage())); } } - + + /** + * This should only be called from an async thread! + */ public String getFilteredMessage(Player player, String originalMessage) { final String playerName = player.getUniqueId().toString(); @@ -273,7 +276,7 @@ public class Chat extends MiniPlugin */ String filteredMsg = ""; - + filteredMsg = ((JSONObject) JSONValue.parse(response)).get("content").toString(); if (filteredMsg.contains("parts")) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index 264411b62..db83190df 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -4,7 +4,6 @@ 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.inventory.ClickType; @@ -57,8 +56,8 @@ public class GadgetPage extends ShopPageBase slot++; - if (slot == 26) - slot = 28; + if (slot == 26 || slot == 35) + slot += 2; } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() @@ -86,16 +85,16 @@ public class GadgetPage extends ShopPageBase if (gadget.getSet() != null) { itemLore.add(C.cBlack); - itemLore.add(C.cWhite + gadget.getSet().getName() + " Set;"); + itemLore.add(C.cWhite + gadget.getSet().getName() + " Set"); //Elements for (Gadget cur : gadget.getSet().getGadgets()) - itemLore.add(" "+ (cur.ownsGadget(getPlayer()) ? C.cDGreen + '▪' : C.cDRed + '▪' ) + (cur.IsActive(getPlayer()) ? C.cGreen : C.cGray) + cur.GetName()); + itemLore.add(" "+ (cur.ownsGadget(getPlayer()) ? C.cDGreen : C.cDRed) + "▪ " + (cur.IsActive(getPlayer()) ? C.cGreen : C.cGray) + cur.GetName()); itemLore.add(C.cBlack); //Bonus - itemLore.add(C.cWhite + gadget.getSet().getName() + " Set Bonus;"); + itemLore.add(C.cWhite + gadget.getSet().getName() + " Set Bonus"); for (String bonus : gadget.getSet().getBonus()) itemLore.add(" " + (gadget.getSet().isActive(getPlayer()) ? C.cGreen : C.cGray) + bonus); } @@ -127,6 +126,17 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Easter Holiday Treasure"); } + else if (gadget.GetCost(CurrencyType.Coins) == -6) + { + itemLore.add(C.cBlack); + itemLore.add(C.cBlue + "Found in Valentines Gifts"); + } + else if (gadget.GetCost(CurrencyType.Coins) == -7) + { + itemLore.add(C.cBlack); + itemLore.add(C.cBlue + "Purchased from shop.mineplex.com"); + } + //Rank Unlocks else if (gadget.GetCost(CurrencyType.Coins) == -10) { @@ -180,11 +190,11 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Left-Click to Enable"); - addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivateGadgetButton(gadget, this)); + addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false).hideInfo(), new ActivateGadgetButton(gadget, this)); } else { - addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new ActivateGadgetButton(gadget, this)); + addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo(), new ActivateGadgetButton(gadget, this)); } return; @@ -206,7 +216,7 @@ public class GadgetPage extends ShopPageBase im.setLore(itemLore); item.setItemMeta(im); - addButton(slot, new ShopItem(item, false, false), new DeactivateGadgetButton(gadget, this)); + addButton(slot, new ShopItem(item, false, false).hideInfo(), new DeactivateGadgetButton(gadget, this)); } else { @@ -215,7 +225,7 @@ public class GadgetPage extends ShopPageBase im.setLore(itemLore); item.setItemMeta(im); - addButton(slot, new ShopItem(item, false, false), new ActivateGadgetButton(gadget, this)); + addButton(slot, new ShopItem(item, false, false).hideInfo(), new ActivateGadgetButton(gadget, this)); } } else @@ -231,18 +241,18 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); - addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new GadgetButton(gadget, this)); + addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo(), new GadgetButton(gadget, this)); } else if (gadget.GetCost(CurrencyType.Coins) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Not enough Treasure Shards."); - setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo()); } else { - setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo()); } } @@ -257,14 +267,14 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Disable"); - addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivateGadgetButton(gadget, this)); + addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false).hideInfo(), new DeactivateGadgetButton(gadget, this)); } else { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Enable"); - addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivateGadgetButton(gadget, this)); + addButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false).hideInfo(), new ActivateGadgetButton(gadget, this)); } } else @@ -280,18 +290,18 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); - addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new GadgetButton(gadget, this)); + addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo(), new GadgetButton(gadget, this)); } else if (gadget.GetCost(CurrencyType.Coins) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Not enough Treasure Shards."); - setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo()); } else { - setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java index 356635962..12475e8d9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java @@ -87,6 +87,11 @@ public class MountPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Easter Holiday Treasure"); } + else if (mount.GetCost(CurrencyType.Coins) == -6) + { + itemLore.add(C.cBlack); + itemLore.add(C.cBlue + "Found in Valentines Holiday Treasure"); + } //Rank Unlocks else if (mount.GetCost(CurrencyType.Coins) == -10) { @@ -110,7 +115,6 @@ public class MountPage extends ShopPageBase } } - if (getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(mount.GetName())) { if (mount.GetActive().containsKey(getPlayer())) @@ -141,18 +145,18 @@ public class MountPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Purchase"); - addButton(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new MountButton(mount, this)); + addButton(slot, new ShopItem(Material.INK_SACK, (byte) 7, mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new MountButton(mount, this)); } else if (mount.GetCost(CurrencyType.Coins) > 0) { itemLore.add(C.cBlack); itemLore.add(C.cRed + "Not enough Treasure Shards."); - setItem(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + setItem(slot, new ShopItem(Material.INK_SACK, (byte) 7, mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); } else { - setItem(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + setItem(slot, new ShopItem(Material.INK_SACK, (byte) 7, mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); } } 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 c896f2a03..14600c963 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java @@ -5,24 +5,24 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Map; -import org.bukkit.entity.Player; +import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.customdata.CustomData; import mineplex.core.customdata.CustomDataManager; import mineplex.core.customdata.PlayerCustomData; -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; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; /** * Created by William (WilliamTiger). * 16/12/15 */ -public class CustomDataRepository extends RepositoryBase +public class CustomDataRepository extends MinecraftRepository { private static final String SELECT_KEYS = "SELECT id, name FROM customData;"; private static final String INSERT_KEY = "INSERT INTO customData (name) VALUES (?);"; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/MinecraftRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/database/MinecraftRepository.java new file mode 100644 index 000000000..690fc9cc6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/database/MinecraftRepository.java @@ -0,0 +1,112 @@ +package mineplex.core.database; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Iterator; + +import javax.sql.DataSource; + +import mineplex.core.common.util.NautHashMap; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.DatabaseRunnable; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.Column; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.jooq.DSLContext; +import org.jooq.SQLDialect; +import org.jooq.impl.DSL; + +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.plugin.java.JavaPlugin; + +public abstract class MinecraftRepository extends RepositoryBase implements Listener +{ + // Queue for failed processes + private static Object _queueLock = new Object(); + private NautHashMap _failedQueue = new NautHashMap(); + + protected JavaPlugin _plugin; // Plugin responsible for this repository + + /** + * Constructor + * @param plugin - the {@link JavaPlugin} module responsible for this repository. + * @param dataSource - the {@link DataSource} responsible for providing the connection pool to this repository. + */ + public MinecraftRepository(JavaPlugin plugin, DataSource dataSource) + { + super(dataSource); + + _plugin = plugin; + plugin.getServer().getPluginManager().registerEvents(this, plugin); + } + + protected DSLContext jooq() + { + return DSL.using(DBPool.getAccount(), SQLDialect.MYSQL); + } + + protected void handleDatabaseCall(final DatabaseRunnable databaseRunnable, final String errorMessage) + { + Thread asyncThread = new Thread(new Runnable() + { + public void run() + { + try + { + databaseRunnable.run(); + } + catch (Exception exception) + { + processFailedDatabaseCall(databaseRunnable, exception.getMessage(), errorMessage); + } + } + }); + + asyncThread.start(); + } + + protected void processFailedDatabaseCall(DatabaseRunnable databaseRunnable, String errorPreMessage, String runnableMessage) + { + if (databaseRunnable.getFailedCounts() < 4) + { + databaseRunnable.incrementFailCount(); + + synchronized (_queueLock) + { + _failedQueue.put(databaseRunnable, runnableMessage); + } + } + } + + @EventHandler + public void processDatabaseQueue(UpdateEvent event) + { + if (event.getType() != UpdateType.MIN_01) + return; + + processFailedQueue(); + } + + private void processFailedQueue() + { + synchronized (_queueLock) + { + for (Iterator runnablesIterator = _failedQueue.keySet().iterator(); runnablesIterator.hasNext();) + { + DatabaseRunnable databaseRunnable = runnablesIterator.next(); + handleDatabaseCall(databaseRunnable, _failedQueue.get(databaseRunnable)); + } + } + } + + public JavaPlugin getPlugin() + { + return _plugin; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/Row.java b/Plugins/Mineplex.Core/src/mineplex/core/database/Row.java deleted file mode 100644 index 208666a37..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/Row.java +++ /dev/null @@ -1,9 +0,0 @@ -package mineplex.core.database; - -import mineplex.core.common.util.NautHashMap; -import mineplex.core.database.column.Column; - -public class Row -{ - public NautHashMap> Columns = new NautHashMap>(); -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 91a071484..379d048bc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -2,6 +2,8 @@ package mineplex.core.donation; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.LinkedList; +import java.util.Queue; import java.util.UUID; import org.bukkit.Bukkit; @@ -30,17 +32,23 @@ import mineplex.core.updater.event.UpdateEvent; public class DonationManager extends MiniDbClientPlugin { + private final int MAX_GIVE_ATTEMPTS = 10; + private DonationRepository _repository; private NautHashMap> _gemQueue = new NautHashMap>(); private NautHashMap> _coinQueue = new NautHashMap>(); private NautHashMap> _goldQueue = new NautHashMap>(); + + private Queue _coinAttemptQueue; public DonationManager(JavaPlugin plugin, CoreClientManager clientManager, String webAddress) { super("Donation", plugin, clientManager); _repository = new DonationRepository(plugin, webAddress); + + _coinAttemptQueue = new LinkedList<>(); } @Override @@ -204,6 +212,11 @@ public class DonationManager extends MiniDbClientPlugin _gemQueue.clear(); } + public void rewardCoinsUntilSuccess(Callback callback, String caller, String name, int accountId, int amount) + { + _coinAttemptQueue.add(new GiveDonorData(callback, name, caller, accountId, amount)); + } + public void RewardCoins(Callback callback, String caller, String name, int accountId, int amount) { RewardCoins(callback, caller, name, accountId, amount, true); @@ -298,6 +311,57 @@ public class DonationManager extends MiniDbClientPlugin //Clean _coinQueue.clear(); } + + @EventHandler + public void processCoinAttemptQueue(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + GiveDonorData data = _coinAttemptQueue.poll(); + + if (data != null) + { + _repository.rewardCoins(new Callback() + { + @Override + public void run(Boolean success) + { + if (success) + { + Donor donor = Get(data.getPlayerName()); + + if (donor != null) + { + donor.addCoins(data.getGiveAmount()); + } + + if (data.getCallback() != null) data.getCallback().run(true); + + System.out.println("Successfully rewarded shards to player " + data.getPlayerName()); + } + else + { + data.incrementAttempts(); + + if (data.getAttempts() >= MAX_GIVE_ATTEMPTS) + { + // Admit Defeat! + if (data.getCallback() != null) data.getCallback().run(false); + System.out.println("Gave up giving shards to player " + data.getPlayerName()); + } + else + { + // Add again to the back of queue + _coinAttemptQueue.add(data); + System.out.println("Failed to reward shards to player " + data.getPlayerName() + ". Attempts: " + data.getAttempts()); + } + } + } + }, data.getCaller(), data.getPlayerName(), data.getAccountId(), data.getGiveAmount()); + } + + } public void rewardGold(Callback callback, String caller, Player player, int amount) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/GiveDonorData.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/GiveDonorData.java new file mode 100644 index 000000000..eb8f382b8 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/GiveDonorData.java @@ -0,0 +1,71 @@ +package mineplex.core.donation; + +import mineplex.core.common.util.Callback; + +import java.util.UUID; + +public class GiveDonorData +{ + private final String _playerName; + private final String _caller; + private final UUID _uuid; + private final int _accountId; + private final int _giveAmount; + private final Callback _callback; + private int _attempts; + + public GiveDonorData(Callback callback, String playerName, String caller, UUID uuid, int accountId, int giveAmount) + { + _callback = callback; + _playerName = playerName; + _caller = caller; + _uuid = uuid; + _accountId = accountId; + _giveAmount = giveAmount; + } + + public GiveDonorData(Callback callback, String playerName, String caller, int accountId, int giveAmount) + { + this(callback, playerName, caller, null, accountId, giveAmount); + } + + public UUID getUuid() + { + return _uuid; + } + + public Callback getCallback() + { + return _callback; + } + + public String getPlayerName() + { + return _playerName; + } + + public String getCaller() + { + return _caller; + } + + public int getAccountId() + { + return _accountId; + } + + public int getGiveAmount() + { + return _giveAmount; + } + + public int getAttempts() + { + return _attempts; + } + + public void incrementAttempts() + { + _attempts++; + } +} 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 b30b30b92..5e696359e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java @@ -1,21 +1,18 @@ package mineplex.core.donation.repository; -import java.sql.CallableStatement; -import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; -import java.sql.Types; +import mineplex.core.database.MinecraftRepository; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.common.CurrencyType; import mineplex.core.common.util.Callback; -import mineplex.core.database.DBPool; -import mineplex.core.database.DatabaseRunnable; -import mineplex.core.database.RepositoryBase; -import mineplex.core.database.column.ColumnInt; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.DatabaseRunnable; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; import mineplex.core.donation.Donor; import mineplex.core.donation.repository.token.GemRewardToken; import mineplex.core.donation.repository.token.PurchaseToken; @@ -24,7 +21,7 @@ import mineplex.core.server.remotecall.AsyncJsonWebCall; import mineplex.core.server.remotecall.JsonWebCall; import mineplex.core.server.util.TransactionResponse; -public class DonationRepository extends RepositoryBase +public class DonationRepository extends MinecraftRepository { private static String CREATE_COIN_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountCoinTransactions (id INT NOT NULL AUTO_INCREMENT, accountId INT, reason VARCHAR(100), coins INT, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));"; private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accountId INT, reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));"; @@ -54,7 +51,7 @@ public class DonationRepository extends RepositoryBase { public void run(final TransactionResponse response) { - Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable() + Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable() { @Override public void run() @@ -100,7 +97,7 @@ public class DonationRepository extends RepositoryBase } } - Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable() + Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable() { @Override public void run() @@ -131,7 +128,7 @@ public class DonationRepository extends RepositoryBase { public void run(final Boolean response) { - Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable() + Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable() { @Override public void run() @@ -168,7 +165,7 @@ public class DonationRepository extends RepositoryBase //executeUpdate(INSERT_COIN_TRANSACTION, new ColumnInt("id", accountId), new ColumnVarChar("reason", 100, "Rewarded by " + giver), new ColumnInt("coins", coins)); } - Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable() + Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable() { @Override public void run() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java index 2304a75c0..8c0874208 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java @@ -3,14 +3,15 @@ package mineplex.core.elo; import java.sql.ResultSet; import java.sql.SQLException; +import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.database.DBPool; -import mineplex.core.database.RepositoryBase; -import mineplex.core.database.column.ColumnInt; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; -public class EloRepository extends RepositoryBase +public class EloRepository extends MinecraftRepository { private static String CREATE_ELO_TABLE = "CREATE TABLE IF NOT EXISTS eloRating (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), gameType VARCHAR(256), elo INT, PRIMARY KEY (id), UNIQUE INDEX uuid_gameType_index (uuid, gameType));"; private static String INSERT_ELO = "INSERT INTO eloRating (uuid, gameType, elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE elo=VALUES(elo);"; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java index ab9c70d52..31c8f24d7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java @@ -241,7 +241,7 @@ public class Explosion extends MiniPlugin } Block block = cur.getLocation().getBlock(); - block.setTypeIdAndData(0, (byte)0, true); + //block.setTypeIdAndData(0, (byte)0, true); //Block Replace if (_enableDebris) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookRepository.java index 08b6edf93..b9f19f1d9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookRepository.java @@ -3,16 +3,17 @@ package mineplex.core.facebook; import java.sql.ResultSet; import java.sql.SQLException; +import mineplex.core.database.MinecraftRepository; 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; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; -public class FacebookRepository extends RepositoryBase +public class FacebookRepository extends MinecraftRepository { 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 = ?"; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java index c09fe1703..e26721864 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -5,18 +5,18 @@ import java.sql.SQLException; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Set; +import mineplex.core.database.MinecraftRepository; import org.bukkit.entity.Player; 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.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.core.friend.FriendStatusType; import mineplex.serverdata.Region; import mineplex.serverdata.data.DataRepository; @@ -24,7 +24,7 @@ import mineplex.serverdata.data.PlayerStatus; import mineplex.serverdata.redis.RedisDataRepository; import mineplex.serverdata.servers.ServerManager; -public class FriendRepository extends RepositoryBase +public class FriendRepository extends MinecraftRepository { private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), status VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuidSource, uuidTarget));"; private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, status, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget WHERE uuidSource IN "; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 449a4e52f..9ee33c6d9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -5,6 +5,11 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import mineplex.core.gadget.gadgets.hat.HatCompanion; +import mineplex.core.gadget.gadgets.hat.HatLovestruck; +import mineplex.core.gadget.gadgets.hat.HatSecretPackage; +import mineplex.core.gadget.gadgets.hat.HatTeddyBear; +import mineplex.core.gadget.gadgets.item.*; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -32,16 +37,64 @@ import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetEnableEvent; -import mineplex.core.gadget.gadgets.arrowtrail.*; -import mineplex.core.gadget.gadgets.death.*; -import mineplex.core.gadget.gadgets.doublejump.*; -import mineplex.core.gadget.gadgets.hat.*; -import mineplex.core.gadget.gadgets.item.*; -import mineplex.core.gadget.gadgets.morph.*; -import mineplex.core.gadget.gadgets.outfit.*; -import mineplex.core.gadget.gadgets.particle.*; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHearts; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailTitan; +import mineplex.core.gadget.gadgets.death.DeathCandyCane; +import mineplex.core.gadget.gadgets.death.DeathFrostLord; +import mineplex.core.gadget.gadgets.death.DeathHearts; +import mineplex.core.gadget.gadgets.death.DeathTitan; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHearts; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan; +import mineplex.core.gadget.gadgets.hat.HatCoal; +import mineplex.core.gadget.gadgets.hat.HatGrinch; +import mineplex.core.gadget.gadgets.hat.HatPresent; +import mineplex.core.gadget.gadgets.hat.HatRudolph; +import mineplex.core.gadget.gadgets.hat.HatSanta; +import mineplex.core.gadget.gadgets.hat.HatSnowman; +import mineplex.core.gadget.gadgets.morph.MorphBat; +import mineplex.core.gadget.gadgets.morph.MorphBlaze; +import mineplex.core.gadget.gadgets.morph.MorphBlock; +import mineplex.core.gadget.gadgets.morph.MorphBunny; +import mineplex.core.gadget.gadgets.morph.MorphChicken; +import mineplex.core.gadget.gadgets.morph.MorphCow; +import mineplex.core.gadget.gadgets.morph.MorphCreeper; +import mineplex.core.gadget.gadgets.morph.MorphEnderman; +import mineplex.core.gadget.gadgets.morph.MorphPig; +import mineplex.core.gadget.gadgets.morph.MorphPumpkinKing; +import mineplex.core.gadget.gadgets.morph.MorphSlime; +import mineplex.core.gadget.gadgets.morph.MorphSnowman; +import mineplex.core.gadget.gadgets.morph.MorphTitan; +import mineplex.core.gadget.gadgets.morph.MorphVillager; +import mineplex.core.gadget.gadgets.morph.MorphWither; +import mineplex.core.gadget.gadgets.outfit.OutfitRaveSuitBoots; +import mineplex.core.gadget.gadgets.outfit.OutfitRaveSuitChestplate; +import mineplex.core.gadget.gadgets.outfit.OutfitRaveSuitHelmet; +import mineplex.core.gadget.gadgets.outfit.OutfitRaveSuitLeggings; +import mineplex.core.gadget.gadgets.outfit.OutfitSpaceSuitBoots; +import mineplex.core.gadget.gadgets.outfit.OutfitSpaceSuitChestplate; +import mineplex.core.gadget.gadgets.outfit.OutfitSpaceSuitHelmet; +import mineplex.core.gadget.gadgets.outfit.OutfitSpaceSuitLeggings; +import mineplex.core.gadget.gadgets.outfit.OutfitTeam; +import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; +import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes; +import mineplex.core.gadget.gadgets.particle.ParticleEnchant; +import mineplex.core.gadget.gadgets.particle.ParticleFairy; +import mineplex.core.gadget.gadgets.particle.ParticleFireRings; +import mineplex.core.gadget.gadgets.particle.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleGreen; +import mineplex.core.gadget.gadgets.particle.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.ParticleHelix; +import mineplex.core.gadget.gadgets.particle.ParticleLegend; +import mineplex.core.gadget.gadgets.particle.ParticleRain; +import mineplex.core.gadget.gadgets.particle.ParticleTitan; import mineplex.core.gadget.set.SetCandyCane; import mineplex.core.gadget.set.SetFrostLord; +import mineplex.core.gadget.set.SetLove; import mineplex.core.gadget.set.SetRaveSuit; import mineplex.core.gadget.set.SetSpaceSuit; import mineplex.core.gadget.set.SetTitan; @@ -59,6 +112,7 @@ import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.inventory.InventoryManager; import mineplex.core.mount.MountManager; import mineplex.core.mount.event.MountActivateEvent; +import mineplex.core.packethandler.PacketHandler; import mineplex.core.pet.PetManager; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; @@ -75,6 +129,7 @@ public class GadgetManager extends MiniPlugin private ProjectileManager _projectileManager; private AchievementManager _achievementManager; private MountManager _mountManager; + private PacketHandler _packetManager; private NautHashMap> _gadgets; @@ -89,7 +144,8 @@ public class GadgetManager extends MiniPlugin public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager, - DisguiseManager disguiseManager, BlockRestore blockRestore, ProjectileManager projectileManager, AchievementManager achievementManager) + DisguiseManager disguiseManager, BlockRestore blockRestore, ProjectileManager projectileManager, AchievementManager achievementManager, + PacketHandler packetHandler) { super("Gadget Manager", plugin); @@ -102,6 +158,7 @@ public class GadgetManager extends MiniPlugin _blockRestore = blockRestore; _projectileManager = projectileManager; _achievementManager = achievementManager; + _packetManager = packetHandler; _mountManager = mountManager; CreateGadgets(); @@ -114,6 +171,7 @@ public class GadgetManager extends MiniPlugin addSet(new SetFrostLord(this)); addSet(new SetCandyCane(this)); addSet(new SetTitan(this)); + addSet(new SetLove(this)); //Costumes addSet(new SetRaveSuit(this)); @@ -139,6 +197,9 @@ public class GadgetManager extends MiniPlugin addGadget(new ItemCoal(this)); addGadget(new ItemFreezeCannon(this)); addGadget(new ItemSnowball(this)); + addGadget(new ItemBow(this)); + addGadget(new ItemLovePotion(this)); + addGadget(new ItemFlowerGift(this)); // Costume addGadget(new OutfitRaveSuitHelmet(this)); @@ -192,16 +253,19 @@ public class GadgetManager extends MiniPlugin addGadget(new ArrowTrailFrostLord(this)); addGadget(new ArrowTrailTitan(this)); addGadget(new ArrowTrailCandyCane(this)); + addGadget(new ArrowTrailHearts(this)); // Death Effect addGadget(new DeathFrostLord(this)); addGadget(new DeathTitan(this)); addGadget(new DeathCandyCane(this)); + addGadget(new DeathHearts(this)); // Double Jump addGadget(new DoubleJumpFrostLord(this)); addGadget(new DoubleJumpTitan(this)); addGadget(new DoubleJumpCandyCane(this)); + addGadget(new DoubleJumpHearts(this)); // Hat addGadget(new HatSanta(this)); @@ -210,6 +274,10 @@ public class GadgetManager extends MiniPlugin addGadget(new HatCoal(this)); addGadget(new HatRudolph(this)); addGadget(new HatGrinch(this)); + addGadget(new HatLovestruck(this)); + addGadget(new HatSecretPackage(this)); + addGadget(new HatTeddyBear(this)); + addGadget(new HatCompanion(this)); // Music addGadget(new MusicGadget(this, "13 Disc", new String[] {""}, -2, 2256, 178000)); @@ -407,9 +475,9 @@ public class GadgetManager extends MiniPlugin return _inventoryManager; } - public boolean collideEvent(Gadget gadget, Player other) + public boolean collideEvent(Player shooter, Gadget gadget, Player other) { - GadgetCollideEntityEvent collideEvent = new GadgetCollideEntityEvent(gadget, other); + GadgetCollideEntityEvent collideEvent = new GadgetCollideEntityEvent(shooter, gadget, other); Bukkit.getServer().getPluginManager().callEvent(collideEvent); @@ -420,6 +488,11 @@ public class GadgetManager extends MiniPlugin { return _blockRestore; } + + public PacketHandler getPacketManager() + { + return _packetManager; + } @EventHandler public void setMoving(PlayerMoveEvent event) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java index a30648983..0fab27166 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java @@ -1,22 +1,25 @@ package mineplex.core.gadget.event; -import mineplex.core.gadget.types.Gadget; - import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import mineplex.core.gadget.types.Gadget; + public class GadgetCollideEntityEvent extends Event { private static final HandlerList handlers = new HandlerList(); + private Player _gadgetHolder; private Gadget _gadget; private Entity _other; private boolean _cancelled = false; - public GadgetCollideEntityEvent(Gadget gadget, Entity other) + public GadgetCollideEntityEvent(Player player, Gadget gadget, Entity other) { + _gadgetHolder = player; _gadget = gadget; _other = other; } @@ -30,6 +33,11 @@ public class GadgetCollideEntityEvent extends Event { return handlers; } + + public Player getPlayer() + { + return _gadgetHolder; + } public Gadget getGadget() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHearts.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHearts.java new file mode 100644 index 000000000..1c9ca8eec --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHearts.java @@ -0,0 +1,42 @@ +package mineplex.core.gadget.gadgets.arrowtrail; + +import org.bukkit.Material; +import org.bukkit.entity.Arrow; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +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.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ArrowEffectGadget; + +public class ArrowTrailHearts extends ArrowEffectGadget +{ + /** + * Created by: Mysticate + * Timestamp: February 4, 2016 + */ + + public ArrowTrailHearts(GadgetManager manager) + { + super(manager, "Arrows of Cupid", + UtilText.splitLineToArray(C.cGray + "Tether your love to an arrow, then spear someone with it. Maybe they'll fall in love!", LineFormat.LORE), + -6, + Material.APPLE, (byte) 0); + } + + @Override + public void doTrail(Arrow arrow) + { + UtilParticle.PlayParticleToAll(ParticleType.HEART, arrow.getLocation(), .1F, .1F, .1F, 0F, 1, ViewDist.LONGER); + } + + @Override + public void doHitEffect(Arrow arrow) + { + UtilParticle.PlayParticleToAll(ParticleType.HEART, arrow.getLocation(), .5F, .5F, .5F, 0F, 4, ViewDist.LONGER); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathHearts.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathHearts.java new file mode 100644 index 000000000..abdc9e191 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathHearts.java @@ -0,0 +1,53 @@ +package mineplex.core.gadget.gadgets.death; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.blood.BloodEvent; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +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.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.DeathEffectGadget; + +public class DeathHearts extends DeathEffectGadget +{ + /** + * Created by: Mysticate + * Timestamp: February 4, 2016 + */ + + public DeathHearts(GadgetManager manager) + { + super(manager, "Broken Hearted", + UtilText.splitLineToArray(C.cGray + "Nothing hurts more than having your heart broken. Apart from being killed, that is.", LineFormat.LORE), + -6, Material.APPLE, (byte) 0); + } + + @EventHandler + public void onBlood(BloodEvent event) + { + if (IsActive(event.getPlayer())) + event.setItem(Material.AIR, (byte) 0); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onParticles(BloodEvent event) + { + if (event.isCancelled()) + return; + + if (IsActive(event.getPlayer())) + { + Location loc = event.getLocation().clone().add(0, .5, 0); + + UtilParticle.PlayParticleToAll(ParticleType.HEART, loc, 0F, 0F, 0F, 0F, 1, ViewDist.NORMAL); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHearts.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHearts.java new file mode 100644 index 000000000..2b2b7af15 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHearts.java @@ -0,0 +1,35 @@ +package mineplex.core.gadget.gadgets.doublejump; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.DoubleJumpEffectGadget; + +public class DoubleJumpHearts extends DoubleJumpEffectGadget +{ + /** + * Created by: Mysticate + * Timestamp: February 4, 2016 + */ + + public DoubleJumpHearts(GadgetManager manager) + { + super(manager, "Wings of Love", + UtilText.splitLineToArray(C.cGray + "Nothing hurts more than having your heart broken. Apart from being killed, that is.", LineFormat.LORE), + -6, Material.APPLE, (byte) 0); + } + + @Override + public void doEffect(Player player) + { + UtilParticle.PlayParticleToAll(ParticleType.HEART, player.getLocation(), .5F, .5F, .5F, 0F, 4, ViewDist.LONGER); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatCompanion.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatCompanion.java new file mode 100644 index 000000000..e3191207f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatCompanion.java @@ -0,0 +1,19 @@ +package mineplex.core.gadget.gadgets.hat; + +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.HatGadget; + +public class HatCompanion extends HatGadget +{ + public HatCompanion(GadgetManager manager) + { + super(manager, "Companion", + UtilText.splitLineToArray(C.cGray + "The Enrichment Center reminds you that the Weighted Companion Cube will never threaten to stab you and, in fact, cannot speak", LineFormat.LORE), + -6, + SkinData.COMPANION_CUBE.getSkull()); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatLovestruck.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatLovestruck.java new file mode 100644 index 000000000..87a2ea0ee --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatLovestruck.java @@ -0,0 +1,19 @@ +package mineplex.core.gadget.gadgets.hat; + +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.HatGadget; + +public class HatLovestruck extends HatGadget +{ + public HatLovestruck(GadgetManager manager) + { + super(manager, "Lovestruck", + UtilText.splitLineToArray(C.cGray + "I think I'm in love... Wait a minute, did someone use a love potion on me?!", LineFormat.LORE), + -6, + SkinData.LOVESTRUCK.getSkull()); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatSecretPackage.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatSecretPackage.java new file mode 100644 index 000000000..d6b4ca66b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatSecretPackage.java @@ -0,0 +1,19 @@ +package mineplex.core.gadget.gadgets.hat; + +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.HatGadget; + +public class HatSecretPackage extends HatGadget +{ + public HatSecretPackage(GadgetManager manager) + { + super(manager, "Secret Package", + UtilText.splitLineToArray(C.cGray + "I hope Chiss is inside!", LineFormat.LORE), + -6, + SkinData.SECRET_PACKAGE.getSkull()); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatTeddyBear.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatTeddyBear.java new file mode 100644 index 000000000..6a5868d42 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatTeddyBear.java @@ -0,0 +1,19 @@ +package mineplex.core.gadget.gadgets.hat; + +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.HatGadget; + +public class HatTeddyBear extends HatGadget +{ + public HatTeddyBear(GadgetManager manager) + { + super(manager, "Teddy Bear", + UtilText.splitLineToArray(C.cGray + "Aww, it's a cute teddy bear! What shall I name him?", LineFormat.LORE), + -6, + SkinData.TEDDY_BEAR.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 9a8096e9b..ba436a8b2 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 @@ -110,7 +110,7 @@ public class ItemBatGun extends ItemGadget if (UtilEnt.hitBox(bat.getLocation(), other, 2, null)) { - if (Manager.collideEvent(this, other)) + if (Manager.collideEvent(cur, this, other)) continue; //Damage Event diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBow.java new file mode 100644 index 000000000..16e78ec14 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBow.java @@ -0,0 +1,220 @@ +package mineplex.core.gadget.gadgets.item; + +import java.util.HashSet; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilEnt; +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.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.Ammo; +import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketInfo; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; + +public class ItemBow extends ItemGadget +{ + /** + * Created by: Mysticate + * Timestamp: February 4, 2016 + */ + + private HashSet _arrows = new HashSet(); + private boolean _spawning = false; + + private String[] _responses = new String[] + { + "Do you feel the love?", + "Are you in love?", + "(I think they like you!)", + "Ahhh. Young love!", + "Maybe they'll bring you a rose!", + "You should go say Hi to them.", + "They look nice.", + "I love love!", + "Go get 'em, tiger!", + "Don't be TOO flirty, now.", + "That was one of my good arrows!", + "Do you believe in love at first sight?", + "Never gunna give you up, never gunna let you down.", + "I approve this message!", + }; + + private IPacketHandler _packetHandler = new IPacketHandler() + { + @Override + public void handle(PacketInfo packetInfo) + { + if (_spawning) + { + packetInfo.setCancelled(true); + return; + } + + PacketPlayOutSpawnEntity packet = (PacketPlayOutSpawnEntity) packetInfo.getPacket(); + + for (Snowball arrow : _arrows) + { + if (arrow.getEntityId() == packet.a) + { + packetInfo.setCancelled(true); + return; + } + } + } + }; + + @SuppressWarnings("unchecked") + public ItemBow(GadgetManager manager) + { + super(manager, "Cupid's Arrows", + UtilText.splitLineToArray(C.cGray + "This symbol of love will live on with you forever! Mainly because we couldn't attach the cupid wings to it. I guess duct tape can't fix everything!", LineFormat.LORE), + -6, Material.BOW, (byte) 0, 1000, new Ammo("Cupid Arrow", "Cupid's Arrows", Material.ARROW, (byte) 0, UtilText.splitLineToArray(C.cGray + "Use these arrows to shoot love into people's hearts!", LineFormat.LORE), -6, 15)); + + Manager.getPacketManager().addPacketHandler(_packetHandler, PacketPlayOutSpawnEntity.class); + } + + @Override + public void ActivateCustom(Player player) + { + _spawning = true; + Snowball arrow = player.launchProjectile(Snowball.class); + _spawning = false; + + _arrows.add(arrow); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + { + for (Snowball arrow : new HashSet(_arrows)) + { + if (!arrow.isValid()) + { + _arrows.remove(arrow); + continue; + } + + UtilParticle.PlayParticleToAll(ParticleType.HEART, arrow.getLocation(), 0F, 0F, 0F, 0F, 1, ViewDist.LONGER); + } + } + } + + @EventHandler + public void onHit(ProjectileHitEvent event) + { + if (!(event.getEntity() instanceof Snowball)) + return; + + Snowball arrow = (Snowball) event.getEntity(); + + if (!_arrows.contains(arrow)) + return; + + Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + if (_arrows.remove(arrow)) + { + arrow.remove(); + UtilPlayer.message((Player) arrow.getShooter(), F.main(C.cRed + "Cupid", "You missed the shot!")); + } + } + }, 1); + } + + @EventHandler + public void onDamage(EntityDamageByEntityEvent event) + { + if (!(event.getDamager() instanceof Snowball)) + return; + + Snowball arrow = (Snowball) event.getDamager(); + + if (!_arrows.contains(arrow)) + return; + + _arrows.remove(arrow); + arrow.remove(); + + Player shooter = (Player) arrow.getShooter(); + + if (event.getEntity() instanceof Creeper && event.getEntity().getCustomName().equalsIgnoreCase(C.cGreenB + "Carl the Creeper")) + { + UtilPlayer.message(shooter, F.main(C.cRed + "Cupid", "Nobody will ever replace Carla.")); + return; + } + + // Effects + if (event.getEntity() instanceof Player) + { + if (event.getEntity() == shooter) + { + UtilPlayer.message(shooter, F.main(C.cRed + "Cupid", "We've all been there.")); + return; + } + + UtilPlayer.message(shooter, F.main(C.cRed + "Cupid", "You hit " + F.name(UtilEnt.getName(event.getEntity())) + " with an arrow! I wonder how they're feeling...")); + + ((Player) event.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 200, 40, false, false)); + UtilPlayer.message(event.getEntity(), F.main(C.cRed + "Cupid", F.name(UtilEnt.getName(shooter)) + " hit you with an arrow! " + UtilMath.randomElement(_responses))); + } + + UtilParticle.PlayParticleToAll(ParticleType.HEART, event.getEntity().getLocation(), .5F, .5F, .5F, 0F, 4, ViewDist.LONGER); + + UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, 14), event.getEntity().getLocation(), .5F, .5F, .5F, 0.0f, 5, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, 6), event.getEntity().getLocation(), .5F, .5F, .5F, 0.0f, 5, ViewDist.NORMAL); + + shooter.playSound(shooter.getLocation(), Sound.ORB_PICKUP, 0.5f, 0.5f); + +// Entity damaged = event.getEntity(); +// AxisAlignedBB bb = ((CraftEntity) damaged).getHandle().getBoundingBox(); +// +// final Location loc = damaged.getLocation().clone(); +// final AxisAlignedBB bounding = new AxisAlignedBB(bb.a, bb.b, bb.c, bb.d, bb.e, bb.f); // Clone it +// +// int i = 0; +// for (double rise = bounding.b ; rise < bounding.e ; rise += .2) +// { +// i++; +// +// final float y = (float) (rise - bounding.b); +// final float x = (float) (Math.sin(y) * 2); +// final float z = (float) (Math.cos(y) * 2); +// +// Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() +// { +// @Override +// public void run() +// { +// UtilParticle.PlayParticleToAll(ParticleType.HEART, loc.clone().add(x, y, z), 0F, 0F, 0F, 0F, 1, ViewDist.LONGER); +// } +// }, i); +// } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoal.java index 4ef0da13d..71544264e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemCoal.java @@ -69,7 +69,7 @@ public class ItemCoal extends ItemGadget , -1, Material.COAL, (byte) 0, 1000, new Ammo("Coal", "1 Piece of Coal", Material.COAL, (byte) 0, new String[] { C.cDGray + "Exclusive Coal!", - C.cDGray + "Earned by beeing naughty" + C.cDGray + "Earned by being naughty" } , -1, 1)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java index a35ab819d..dfb2526eb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java @@ -68,7 +68,7 @@ public class ItemFleshHook extends ItemGadget implements IThrown return; if (target instanceof Player) - if (Manager.collideEvent(this, (Player) target)) + if (Manager.collideEvent(player, this, (Player) target)) return; //Pull diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFlowerGift.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFlowerGift.java new file mode 100644 index 000000000..085a5a5cb --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFlowerGift.java @@ -0,0 +1,115 @@ +package mineplex.core.gadget.gadgets.item; + +import mineplex.core.common.util.*; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent; +import mineplex.core.gadget.gadgets.Ammo; +import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import mineplex.core.valentines.event.AttemptGiftEvent; +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.block.Action; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; + +public class ItemFlowerGift extends ItemGadget +{ + public ItemFlowerGift(GadgetManager manager) + { + super(manager, + "Valentines Gift", + UtilText.splitLineToArray(C.cGray + "Maybe if Sigils and Phinary used these they wouldn't be so alone", LineFormat.LORE), + -7, + Material.RED_ROSE, + (byte) 0, + 6000, + new Ammo("Valentines Gift", "Valentines Gift", Material.RED_ROSE, (byte) 0, UtilText.splitLineToArray(C.cGray + "Maybe if Sigils and Phinary used these they wouldn't be so alone", LineFormat.LORE), -7, 10)); + } + + @Override + public void ActivateCustom(Player player) + { + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onInteract(PlayerInteractAtEntityEvent event) + { + Player player = event.getPlayer(); + + if (!IsActive(player)) + return; + + if (!UtilGear.isMat(player.getItemInHand(), GetDisplayMaterial())) + return; + + if (!hasAmmo(player)) + { + UtilPlayer.message(player, F.main("Gadget", "You do not have any " + GetName() + " left.")); + + ItemGadgetOutOfAmmoEvent ammoEvent = new ItemGadgetOutOfAmmoEvent(event.getPlayer(), this); + Bukkit.getServer().getPluginManager().callEvent(ammoEvent); + + return; + } + + //Recharge + if (!Recharge.Instance.use(player, GetName(), GetName(), _recharge, _recharge > 1000, true, false, true, "Cosmetics")) + { + UtilInv.Update(player); + return; + } + + if (event.getRightClicked() instanceof Player) + { + Player to = ((Player) event.getRightClicked()); + AttemptGiftEvent giftEvent = new AttemptGiftEvent(player, to); + Bukkit.getPluginManager().callEvent(giftEvent); + } + else + { + UtilPlayer.message(player, F.main("Gadget", "You used " + F.elem(GetName()) + " on " + F.name(event.getRightClicked().getName()) + ". It's not very effective...")); + } + + event.setCancelled(true); + } + + @Override + @EventHandler + public void Activate(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (!IsActive(event.getPlayer())) + return; + + if (!UtilGear.isMat(event.getPlayer().getItemInHand(), GetDisplayMaterial())) + return; + + //Recharge + if (!Recharge.Instance.use(event.getPlayer(), GetName(), GetName(), _recharge, false, true, false, true, "Cosmetics")) + return; + + if (!hasAmmo(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Gadget", "You do not have any " + GetName() + " left.")); + + ItemGadgetOutOfAmmoEvent ammoEvent = new ItemGadgetOutOfAmmoEvent(event.getPlayer(), this); + Bukkit.getServer().getPluginManager().callEvent(ammoEvent); + + return; + } + + event.setCancelled(true); + + // Logic is handled in onInteract (so we can cancel interact events on npc's) + UtilPlayer.message(event.getPlayer(), F.main("Gift", "Nothing happened... Maybe I should try giving this to someone?!")); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemLovePotion.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemLovePotion.java new file mode 100644 index 000000000..1f3346e34 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemLovePotion.java @@ -0,0 +1,191 @@ +package mineplex.core.gadget.gadgets.item; + +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.block.Action; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetCollideEntityEvent; +import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent; +import mineplex.core.gadget.gadgets.Ammo; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; + +public class ItemLovePotion extends ItemGadget +{ + private static final String[] DRINK_MESSAGES = { + "YUCK! This does not taste like it was meant for humans.", + "Gross! Why do I keep drinking this stuff... ", + "BAAAAA BAAAAAAAA. Weird, that made me feel a bit sheepish." + }; + + /** + * Created by: Mysticate + * Timestamp: February 6, 2016 + */ + + public ItemLovePotion(GadgetManager manager) + { + super( + manager, + "Love Potion", + UtilText.splitLineToArray(C.cGray + "It doesn't seem to affect humans..? What kind of love potion is this!?", LineFormat.LORE), + -6, + Material.POTION, + (byte) 8233, + 20000, + + new Ammo( + "Love Potion", + "Love Potion", + Material.POTION, + (byte) 8233, + UtilText.splitLineToArray(C.cGray + "It doesn't seem to affect humans..? What kind of love potion is this!?", LineFormat.LORE), + -6, + 16) + ); + } + + @Override + public void ApplyItem(Player player, boolean inform) + { + Manager.removeGadgetType(player, GadgetType.Item); + + _active.add(player); + + List itemLore = new ArrayList(); + itemLore.addAll(Arrays.asList(GetDescription())); + itemLore.add(C.cBlack); + itemLore.add(C.cWhite + "Your Ammo : " + Manager.getInventoryManager().Get(player).getItemCount(GetName())); + + player.getInventory().setItem(Manager.getActiveItemSlot(), new ItemBuilder(GetDisplayMaterial(), GetDisplayData()).setTitle(F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName())).setHideInfo(true).build()); + + if (inform) + UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(GetName()) + ".")); + } + + @EventHandler + public void onInteract(PlayerInteractEntityEvent event) + { + Player player = event.getPlayer(); + + if (!UtilGear.isMat(event.getPlayer().getItemInHand(), GetDisplayMaterial())) + return; + + if (!IsActive(player)) + return; + + if (!Recharge.Instance.use(player, "Interact Love Potion", 1000, false, false)) + return; + + event.setCancelled(true); + + //Stock + if (!hasAmmo(player)) + { + UtilPlayer.message(player, F.main("Gadget", "You do not have any " + GetName() + " left.")); + + ItemGadgetOutOfAmmoEvent ammoEvent = new ItemGadgetOutOfAmmoEvent(event.getPlayer(), this); + Bukkit.getServer().getPluginManager().callEvent(ammoEvent); + + return; + } + + if (!Recharge.Instance.usable(player, GetName())) + { + UtilInv.Update(player); + return; + } + + GadgetCollideEntityEvent gadgetEvent = new GadgetCollideEntityEvent(player, this, event.getRightClicked()); + gadgetEvent.setCancelled(true); // Pre cancel + + Bukkit.getPluginManager().callEvent(gadgetEvent); + + if (gadgetEvent.isCancelled()) + return; + + Recharge.Instance.use(player, GetName(), GetName(), _recharge, _recharge > 1000, true, false, true, "Cosmetics"); // Cooldown + + Manager.getInventoryManager().addItemToInventory(player, GetName(), -1); + + player.getInventory().setItem(Manager.getActiveItemSlot(), new ItemBuilder(GetDisplayMaterial(), GetDisplayData()).setTitle(F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName())).setHideInfo(true).build()); + } + + @EventHandler + public void Activate(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + if (!UtilGear.isMat(event.getPlayer().getItemInHand(), this.GetDisplayMaterial())) + return; + + Player player = event.getPlayer(); + + if (!IsActive(player)) + return; + + if (!Recharge.Instance.use(player, "Interact Love Potion", 500, false, false)) + return; + + event.setCancelled(true); + + //Stock + if (!hasAmmo(player)) + { + UtilPlayer.message(player, F.main("Gadget", "You do not have any " + GetName() + " left.")); + + ItemGadgetOutOfAmmoEvent ammoEvent = new ItemGadgetOutOfAmmoEvent(event.getPlayer(), this); + Bukkit.getServer().getPluginManager().callEvent(ammoEvent); + + return; + } + + //Recharge + if (!Recharge.Instance.use(player, GetName(), GetName(), _recharge, _recharge > 1000, true, false, true, "Cosmetics")) + { + UtilInv.Update(player); + return; + } + + String message = UtilMath.randomElement(DRINK_MESSAGES); + UtilPlayer.message(player, F.main("Potion", message)); + + Manager.getInventoryManager().addItemToInventory(player, GetName(), -1); + + player.getInventory().setItem(Manager.getActiveItemSlot(), new ItemBuilder(GetDisplayMaterial(), GetDisplayData()).setTitle(F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName())).setHideInfo(true).build()); + + ActivateCustom(event.getPlayer()); + } + + @Override + public void ActivateCustom(Player player) + { + player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 400, 40, false, false)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java index 5e8a9734a..9e27220e4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java @@ -1,7 +1,5 @@ package mineplex.core.gadget.gadgets.item; -import java.util.HashSet; - import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -12,6 +10,7 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; @@ -22,7 +21,7 @@ import mineplex.core.gadget.types.ItemGadget; public class ItemSnowball extends ItemGadget { - private HashSet _snowballs = new HashSet<>(); + private NautHashMap _snowballs = new NautHashMap(); public ItemSnowball(GadgetManager manager) { @@ -40,16 +39,21 @@ public class ItemSnowball extends ItemGadget public void ActivateCustom(Player player) { Snowball ball = player.launchProjectile(Snowball.class); - _snowballs.add(ball); + _snowballs.put(ball, player); ball.getWorld().playSound(ball.getLocation(), Sound.CHICKEN_EGG_POP, 1f, 0.3f); } @EventHandler public void onHit(EntityDamageByEntityEvent event) { - if(!_snowballs.contains(event.getDamager())) return; + if (!(event.getDamager() instanceof Snowball)) + return; - GadgetCollideEntityEvent gevent = new GadgetCollideEntityEvent(this, event.getEntity()); + Snowball ball = (Snowball) event.getDamager(); + + if(!_snowballs.containsKey(ball)) return; + + GadgetCollideEntityEvent gevent = new GadgetCollideEntityEvent(_snowballs.remove(ball), this, event.getEntity()); if(gevent.isCancelled()) return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java index e3b5f01f9..6584046e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java @@ -16,11 +16,11 @@ import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; 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.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.Ammo; import mineplex.core.gadget.types.ItemGadget; @@ -29,7 +29,7 @@ import mineplex.core.updater.event.UpdateEvent; public class ItemTNT extends ItemGadget { - private HashSet _tnt = new HashSet(); + private HashMap _tnt = new HashMap(); public ItemTNT(GadgetManager manager) { @@ -46,7 +46,7 @@ public class ItemTNT extends ItemGadget TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class); tnt.setYield(0.0F); // Added in order to prevent water from being evaporated. UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.6, false, 0, 0.2, 1, false); - _tnt.add(tnt); + _tnt.put(tnt, player); //Inform UtilPlayer.message(player, F.main("Skill", "You threw " + F.skill(GetName()) + ".")); @@ -58,13 +58,15 @@ public class ItemTNT extends ItemGadget if (!(event.getEntity() instanceof TNTPrimed)) return; - if (!_tnt.remove(event.getEntity())) + if (!_tnt.containsKey(event.getEntity())) return; + Player killer = _tnt.get(event.getEntity()); + HashMap players = UtilPlayer.getInRadius(event.getLocation(), 8); for (Player player : players.keySet()) { - if (Manager.collideEvent(this, player)) + if (Manager.collideEvent(killer, this, player)) continue; double mult = players.get(player); @@ -84,16 +86,12 @@ public class ItemTNT extends ItemGadget if (event.getType() != UpdateType.FAST) return; - Iterator tntIterator = _tnt.iterator(); - - while (tntIterator.hasNext()) + for (TNTPrimed tnt : new HashSet(_tnt.keySet())) { - TNTPrimed tnt = tntIterator.next(); - if (!tnt.isValid() || tnt.getTicksLived() > 200) { tnt.remove(); - tntIterator.remove(); + _tnt.remove(tnt); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java index ee5a33290..90478d1eb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java @@ -113,7 +113,7 @@ public class MorphCreeper extends MorphGadget if (other.equals(player)) continue; - if (Manager.collideEvent(this, other)) + if (Manager.collideEvent(player, this, other)) continue; double mult = players.get(other); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java index 59ed09fa0..04fa7c32e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java @@ -135,7 +135,7 @@ public class MorphPig extends MorphGadget if (UtilMath.offset(player, other) > range) continue; - if (Manager.collideEvent(this, other)) + if (Manager.collideEvent(player, this, other)) continue; //Cooldown diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java index 75e5ad743..8834023e1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java @@ -143,7 +143,7 @@ public class MorphSnowman extends MorphGadget if (!_snowball.containsKey(proj)) return; - GadgetCollideEntityEvent gevent = new GadgetCollideEntityEvent(this, event.getEntity()); + GadgetCollideEntityEvent gevent = new GadgetCollideEntityEvent(_snowball.remove(proj), this, event.getEntity()); if(gevent.isCancelled()) return; 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 68091b674..aaed71945 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 @@ -139,7 +139,7 @@ public class MorphTitan extends MorphGadget for (Player ent : players.keySet()) { if (ent instanceof Player) - if (Manager.collideEvent(this, (Player)ent)) + if (Manager.collideEvent(event.GetPlayer(), this, (Player)ent)) continue; double mult = players.get(ent); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java index f327f0551..d2e9f9bad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java @@ -116,7 +116,7 @@ public class MorphVillager extends MorphGadget implements IThrown return; if (target instanceof Player) - if (Manager.collideEvent(this, (Player) target)) + if (Manager.collideEvent((Player) data.GetThrower(), this, (Player) target)) return; //Pull diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java index a2d68070f..f5029d34b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java @@ -128,7 +128,7 @@ public class MorphWither extends MorphGadget HashMap players = UtilPlayer.getInRadius(event.getLocation(), 6); for (Player player : players.keySet()) { - if (Manager.collideEvent(this, player)) + if (Manager.collideEvent((Player) skull.getShooter(), this, player)) continue; double mult = players.get(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java index d07a2b01a..dacc9e9da 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java @@ -33,10 +33,10 @@ public class ParticleHeart extends ParticleGadget { public ParticleHeart(GadgetManager manager) { - super(manager, "I Heart You", - UtilText.splitLineToArray(C.cGray + "Show off how much you love Mineplex and everyone on it!", LineFormat.LORE), + super(manager, "Heartfelt Halo", + UtilText.splitLineToArray(C.cGray + "Share the love you feel in your heart with everybody near you!", LineFormat.LORE), -2, - Material.APPLE, (byte)0); + Material.APPLE, (byte)0, "I Heart You"); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetLove.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetLove.java new file mode 100644 index 000000000..60f474c73 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetLove.java @@ -0,0 +1,25 @@ +package mineplex.core.gadget.set; + +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHearts; +import mineplex.core.gadget.gadgets.death.DeathHearts; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHearts; +import mineplex.core.gadget.gadgets.particle.ParticleHeart; +import mineplex.core.gadget.types.GadgetSet; + +public class SetLove extends GadgetSet +{ + /** + * Created by: Mysticate + * Timestamp: February 4, 2016 + */ + + public SetLove(GadgetManager manager) + { + super(manager, "Lovely!", "Coming Soon", + manager.getGadget(ArrowTrailHearts.class), + manager.getGadget(DeathHearts.class), + manager.getGadget(DoubleJumpHearts.class), + manager.getGadget(ParticleHeart.class)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 5d90a1b98..ac497cd48 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -68,12 +68,14 @@ public enum GameDisplay 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), TypeWars("Type Wars", Material.NAME_TAG, (byte) 0, GameCategory.CLASSICS, 59), + + SpeedBuilders("Speed Builders", Material.QUARTZ_BLOCK, (byte) 0, GameCategory.CLASSICS, 60), + + Valentines("Valentines Vendetta", Material.LEATHER, (byte)0, GameCategory.EXTRA, 60), Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java index 46844bd07..52c0cc50f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java @@ -8,17 +8,17 @@ import java.sql.Types; import java.util.HashMap; import java.util.UUID; -import org.bukkit.Bukkit; +import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; -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; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.serverdata.Region; -public class GiveawayRepository extends RepositoryBase +public class GiveawayRepository extends MinecraftRepository { private static final String INSERT_GIVEAWAY = "INSERT INTO Account.accountGiveaway (giveawayId, accountId, cooldownId, region, serverName, time, uuid) VALUES (?, ?, ?, ?, ?, now(), ?)"; private static final String LOAD_GIVEAWAY = "SELECT id, name, prettyName, header, message, max, notifyNetwork, notifyCooldown, canWinTwice FROM Account.giveaway WHERE enabled = TRUE"; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java index 97257bd98..e6d4a4897 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java @@ -12,7 +12,6 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; -import mineplex.core.giveaway.GiveawayManager; import mineplex.core.globalpacket.command.GlobalPacketCommand; import mineplex.core.globalpacket.listeners.GlobalGiveCoins; import mineplex.core.globalpacket.listeners.GlobalGiveGems; @@ -35,7 +34,7 @@ public class GlobalPacketManager extends MiniPlugin private DonationManager _donationManager; private RewardManager _rewardManager; - public GlobalPacketManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, InventoryManager inventoryManager, DonationManager donationManager, PetManager petManager, StatsManager statsManager, GiveawayManager giveawayManager) + public GlobalPacketManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, InventoryManager inventoryManager, DonationManager donationManager, PetManager petManager, StatsManager statsManager) { super("Global Packet Manager", plugin); @@ -44,7 +43,7 @@ public class GlobalPacketManager extends MiniPlugin _inventoryManager = inventoryManager; _donationManager = donationManager; - _rewardManager = new RewardManager(clientManager, statusManager, donationManager, inventoryManager, petManager, statsManager, giveawayManager, + _rewardManager = new RewardManager(clientManager, statusManager, donationManager, inventoryManager, petManager, statsManager, 100, 250, 500, 1000, 1500, 2500, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java index 14e1918c4..f4ee78ab2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java @@ -3,14 +3,15 @@ package mineplex.core.ignore.data; import java.sql.ResultSet; import java.sql.SQLException; -import mineplex.core.database.DBPool; -import mineplex.core.database.RepositoryBase; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.core.database.MinecraftRepository; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnVarChar; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; -public class IgnoreRepository extends RepositoryBase +public class IgnoreRepository extends MinecraftRepository { private static String ADD_IGNORE_RECORD = "INSERT INTO accountIgnore (uuidIgnorer, uuidIgnored) SELECT fA.uuid AS uuidIgnorer, tA.uuid AS uuidIgnored FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;"; private static String DELETE_IGNORE_RECORD = "DELETE aF FROM accountIgnore AS aF INNER JOIN accounts as fA ON aF.uuidIgnorer = fA.uuid INNER JOIN accounts AS tA ON aF.uuidIgnored = tA.uuid WHERE fA.name = ? AND tA.name = ?;"; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index 4d3431275..72a33d939 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -103,6 +103,13 @@ public class InventoryManager extends MiniDbClientPlugin { System.out.println("Add item to Inventory FAILED for " + player.getName()); } + else + { + if (_items.containsKey(item)) + { + Get(player).addItem(new ClientItem(_items.get(item), count)); + } + } if (callback != null) callback.run(success); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java index 018eb41e9..c13bd99e3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java @@ -5,18 +5,19 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import mineplex.core.database.MinecraftRepository; 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.ColumnInt; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.core.inventory.ClientInventory; import mineplex.core.inventory.ClientItem; -public class InventoryRepository extends RepositoryBase +public class InventoryRepository extends MinecraftRepository { private static String CREATE_INVENTORY_TABLE = "CREATE TABLE IF NOT EXISTS items (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), rarity INT, PRIMARY KEY (id), INDEX mameIndex (name));"; private static String CREATE_INVENTORY_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountInventory (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, itemId INT NOT NULL, count INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (itemId) REFERENCES items(id), UNIQUE INDEX accountItemIndex (accountId, itemId));"; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java index 5f0659c03..fab7b1cc2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java @@ -1,9 +1,10 @@ package mineplex.core.leaderboard; -import mineplex.core.database.DBPool; -import mineplex.core.database.RepositoryBase; -import mineplex.core.database.column.ColumnInt; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.core.database.MinecraftRepository; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; import org.bukkit.plugin.java.JavaPlugin; @@ -15,7 +16,7 @@ import org.bukkit.plugin.java.JavaPlugin; * @author MrTwiggy * */ -public class StatEventsRepository extends RepositoryBase +public class StatEventsRepository extends MinecraftRepository { // Insert or update stat events query diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index 59dc27148..10b0c9707 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -209,8 +209,6 @@ public class MessageManager extends MiniClientPlugin } } - message = _chat.getFilteredMessage(from, message); - // Inform UtilPlayer.message(from, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message); @@ -229,11 +227,6 @@ public class MessageManager extends MiniClientPlugin UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development."); UtilPlayer.message(from, C.cPurple + "Please be patient if she does not reply instantly."); } - - /*if(to.getName().equals("ishh")) - { - UtilPlayer.message(from, C.cPurple + "Hi, my name is ishh. If I don't respond to your message, please be patient and try again later!"); - }*/ // Log // Logger().logChat("Private Message", from, to.getName(), message); @@ -495,26 +488,16 @@ public class MessageManager extends MiniClientPlugin final FriendStatus friendInfo = friend; - new BukkitRunnable() + runAsync(new Runnable() { - final String newMessage = _chat.getFilteredMessage(sender, message); - @Override public void run() { - new BukkitRunnable() - { + final String newMessage = _chat.getFilteredMessage(sender, message); - @Override - public void run() - { - sendMessage(sender, target, newMessage, adminMessage, isReply, friendInfo); - } - - }.runTask(getPlugin()); + runSync(() -> sendMessage(sender, target, newMessage, adminMessage, isReply, friendInfo)); } - - }.runTaskAsynchronously(getPlugin()); + }); } private void sendMessage(final Player sender, String target, String message, final boolean adminMessage, boolean isReply, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java index 814280180..905a61ba4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java @@ -32,6 +32,7 @@ import mineplex.core.mount.types.MountSlime; import mineplex.core.mount.types.MountSpider; import mineplex.core.mount.types.MountTitan; import mineplex.core.mount.types.MountUndead; +import mineplex.core.mount.types.MountValentinesSheep; import mineplex.core.mount.types.MountZombie; public class MountManager extends MiniPlugin @@ -70,6 +71,7 @@ public class MountManager extends MiniPlugin _types.add(new MountZombie(this)); _types.add(new MountTitan(this)); _types.add(new MountBabyReindeer(this)); + _types.add(new MountValentinesSheep(this)); //_types.add(new MountSheep(this)); } 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 da0c765bc..f9d10c5d5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountBabyReindeer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountBabyReindeer.java @@ -36,7 +36,7 @@ public class MountBabyReindeer extends HorseMount Material.GOLDEN_CARROT, (byte) 0, -3, Color.CREAMY, Style.WHITEFIELD, Variant.HORSE, 0, null); } - @EventHandler + @Override public void EnableCustom(Player player) { super.EnableCustom(player); Horse horse = GetActive().get(player).getEntity(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountValentinesSheep.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountValentinesSheep.java new file mode 100644 index 000000000..5213be86b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountValentinesSheep.java @@ -0,0 +1,97 @@ +package mineplex.core.mount.types; + +import org.bukkit.DyeColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilEnt; +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.UtilText; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseSheep; +import mineplex.core.mount.HorseMount; +import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class MountValentinesSheep extends HorseMount +{ + /** + * Created by: Mysticate + * Timestamp: February 4, 2016 + */ + + public MountValentinesSheep(MountManager manager) + { + super(manager, "Loving Sheeples", + UtilText.splitLineToArray(C.cGray + "This symbol of love will live on with you forever! Mainly because we couldn't attach the cupid wings to it. I guess duct tape can't fix everything!", LineFormat.LORE), + Material.WOOL, (byte) 6, -1, Horse.Color.BLACK, Horse.Style.NONE, Horse.Variant.HORSE, 1.0, null); + } + + @Override + public void EnableCustom(Player player) + { + super.EnableCustom(player); + + Horse horse = GetActive().get(player).getEntity(); + + UtilEnt.silence(horse, true); + + DisguiseSheep disguise = new DisguiseSheep(horse); + disguise.setColor(DyeColor.PINK); + + Manager.getDisguiseManager().disguise(disguise); + } + + @EventHandler + public void doAnimations(UpdateEvent event) + { + for (SingleEntityMountData ent : GetActive().values()) + { + if (!ent.getEntity().isValid()) + continue; + + if (event.getType() == UpdateType.FASTEST) + { + Location loc = ent.getEntity().getLocation().clone().add(0, .5, 0); + + UtilParticle.PlayParticleToAll(ParticleType.HEART, loc, .5F, .4F, .5F, 0F, 1, ViewDist.NORMAL); + + UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, 14), loc, .5F, .4F, .5F, 0.0f, 1, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.WOOL, 6), loc, .5F, .4F, .5F, 0.0f, 1, ViewDist.NORMAL); + } + else if (event.getType() == UpdateType.FAST) + { + DisguiseBase disguise = Manager.getDisguiseManager().getDisguise(ent.getEntity()); + + if (disguise instanceof DisguiseSheep) + { + DisguiseSheep sheep = (DisguiseSheep) disguise; + + if (sheep.getColor() == 6) // Pink + { + sheep.setColor(DyeColor.RED); + } + else if (sheep.getColor() == 14) // Red + { + sheep.setColor(DyeColor.MAGENTA); + } + else if (sheep.getColor() == 2) // Magenta + { + sheep.setColor(DyeColor.PINK); + } + + Manager.getDisguiseManager().updateDisguise(sheep); + } + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index 1235a6301..a94be37fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -11,25 +11,12 @@ import java.util.Map; import java.util.Set; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; -import org.bukkit.entity.Ageable; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Slime; -import org.bukkit.entity.Villager; -import org.bukkit.entity.Zombie; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityCombustEvent; @@ -51,7 +38,7 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; import mineplex.core.creature.Creature; import mineplex.core.creature.event.CreatureKillEntitiesEvent; -import mineplex.core.database.DBPool; +import mineplex.serverdata.database.DBPool; import mineplex.core.npc.command.NpcCommand; import mineplex.core.npc.event.NpcDamageByEntityEvent; import mineplex.core.npc.event.NpcInteractEntityEvent; @@ -236,7 +223,7 @@ public class NpcManager extends MiniPlugin event.setCancelled(true); } - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { if (event.getRightClicked() instanceof LivingEntity) @@ -350,6 +337,8 @@ public class NpcManager extends MiniPlugin ((Skeleton) entity).setSkeletonType(Skeleton.SkeletonType.valueOf(npc.getDatabaseRecord().getEntityMeta().toUpperCase())); if (entity instanceof Villager && npc.getDatabaseRecord().getEntityMeta() != null) ((Villager) entity).setProfession(Villager.Profession.valueOf(npc.getDatabaseRecord().getEntityMeta().toUpperCase())); + if (entity instanceof Sheep && npc.getDatabaseRecord().getEntityMeta() != null) + ((Sheep) entity).setColor(DyeColor.valueOf(npc.getDatabaseRecord().getEntityMeta().toUpperCase())); if (entity instanceof org.bukkit.entity.Creature) ((org.bukkit.entity.Creature) entity).setTarget(null); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java index 40c2d2e1c..e607bd0c3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java @@ -2,21 +2,21 @@ package mineplex.core.pet.repository; import java.util.List; +import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; import com.google.gson.reflect.TypeToken; -import mineplex.core.database.DBPool; -import mineplex.core.database.RepositoryBase; -import mineplex.core.database.column.ColumnInt; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.core.pet.repository.token.PetExtraToken; -import mineplex.core.pet.repository.token.PetSalesToken; import mineplex.core.server.remotecall.AsyncJsonWebCall; import mineplex.core.server.remotecall.JsonWebCall; -public class PetRepository extends RepositoryBase +public class PetRepository extends MinecraftRepository { private String _webAddress; @@ -31,7 +31,7 @@ public class PetRepository extends RepositoryBase { new AsyncJsonWebCall(_webAddress + "Pets/AddPet").Execute(token); - Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable() + getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() { public void run() { @@ -49,7 +49,7 @@ public class PetRepository extends RepositoryBase { new AsyncJsonWebCall(_webAddress + "Pets/RemovePet").Execute(token); - Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable() + getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() { public void run() { @@ -72,7 +72,7 @@ public class PetRepository extends RepositoryBase { new AsyncJsonWebCall(_webAddress + "Pets/UpdatePet").Execute(token); - Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable() + getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() { public void run() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java index 9628a5c93..dbf24772d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java @@ -6,18 +6,19 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; +import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; -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; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; /** * Created by Shaun on 8/16/2014. */ -public class PollRepository extends RepositoryBase +public class PollRepository extends MinecraftRepository { private static String CREATE_POLL_TABLE = "CREATE TABLE IF NOT EXISTS polls (id INT NOT NULL AUTO_INCREMENT, enabled BIT(1), question VARCHAR(256) NOT NULL, answerA VARCHAR(256) NOT NULL, answerB VARCHAR(256), answerC VARCHAR(256), answerD VARCHAR(256), coinReward INT NOT NULL, displayType INT DEFAULT 0 NOT NULL, PRIMARY KEY (id));"; private static String CREATE_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountPolls (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, pollId INT NOT NULL, value TINYINT(1) NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (pollId) REFERENCES polls(id), UNIQUE INDEX accountPollIndex (accountId, pollId));"; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java index 3c90a2cce..ac3b06ffe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java @@ -6,14 +6,15 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map.Entry; +import mineplex.core.database.MinecraftRepository; 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.column.ColumnVarChar; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnVarChar; -public class PreferencesRepository extends RepositoryBase +public class PreferencesRepository extends MinecraftRepository { // private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS // accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java index 7b550e058..87f2780ac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java @@ -1,22 +1,14 @@ package mineplex.core.report; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.UUID; -import java.util.Map.Entry; - -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.ColumnInt; -import mineplex.core.database.column.ColumnVarChar; -import mineplex.core.preferences.UserPreferences; +import mineplex.core.database.MinecraftRepository; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; import org.bukkit.plugin.java.JavaPlugin; -public class ReportRepository extends RepositoryBase +public class ReportRepository extends MinecraftRepository { /* * *ReportTicket diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java index b23f91c85..8179dbb98 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java @@ -12,7 +12,7 @@ public class RewardData private final ItemStack _displayItem; private final RewardRarity _rarity; private final boolean _rewardedShards; - private final int _shards; + private int _shards; public RewardData(String header, String friendlyName, ItemStack displayItem, RewardRarity rarity, int shards) { @@ -63,4 +63,9 @@ public class RewardData { return _shards; } + + public void setShards(int value) + { + _shards = value; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index b5a69e120..0e7a97671 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -39,7 +39,6 @@ public class RewardManager private CoreClientManager _clientManager; private DonationManager _donationManager; private ServerStatusManager _statusManager; - private GiveawayManager _giveawayManager; private boolean _doubleGadgetValue; @@ -48,7 +47,7 @@ public class RewardManager private int _legendaryShards = 5000; - public RewardManager(CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, GiveawayManager giveawayManager, + public RewardManager(CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, int commonValueMin, int commonValueMax, int uncommonValueMin, int uncommonValueMax, int rareValueMin, int rareValueMax, @@ -67,7 +66,6 @@ public class RewardManager _clientManager = clientManager; _statusManager = statusManager; _donationManager = donationManager; - _giveawayManager = giveawayManager; _doubleGadgetValue = doubleGadgetValue; _carlSpinner = carlSpinner; @@ -101,6 +99,58 @@ public class RewardManager maxValue *= 2; } + // Valentines + addReward(RewardPool.Type.VALENTINES_GIFT, new InventoryReward(inventoryManager, "Cupid's Arrows", "Cupid's Arrows", 1, 5, + new ItemStack(Material.BOW, 1), rarity, 300, 0)); + // Pets + addReward(RewardPool.Type.VALENTINES_GIFT, new PetReward(petManager, inventoryManager, donationManager, "Cow Pet", "Cow", + EntityType.COW, rarity, 50, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new PetReward(petManager, inventoryManager, donationManager, "Sheep Pet", "Sheep", + EntityType.SHEEP, rarity, 50, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new PetReward(petManager, inventoryManager, donationManager, "Mooshroom Pet", "Mooshroom", + EntityType.MUSHROOM_COW, rarity, 50, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new PetReward(petManager, inventoryManager, donationManager, "Pig Pet", "Pig", + EntityType.PIG, rarity, 50, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new PetReward(petManager, inventoryManager, donationManager, "Ocelot Pet", "Cat", + EntityType.OCELOT, rarity, 50, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new PetReward(petManager, inventoryManager, donationManager, "Chicken Pet", "Chicken", + EntityType.CHICKEN, rarity, 50, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new PetReward(petManager, inventoryManager, donationManager, "Wolf Pet", "Dog", + EntityType.WOLF, rarity, 50, _uncommonShards)); + // Discs + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "13 Disc", "13 Disc", + new ItemStack(2256), rarity, 10, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Cat Disc", "Cat Disc", + new ItemStack(2257), rarity, 10, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Blocks Disc", "Blocks Disc", + new ItemStack(2258), rarity, 10, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Chirp Disc", "Chirp Disc", + new ItemStack(2259), rarity, 10, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Far Disc", "Far Disc", + new ItemStack(2260), rarity, 10, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Mall Disc", "Mall Disc", + new ItemStack(2261), rarity, 10, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Mellohi Disc", "Mellohi Disc", + new ItemStack(2262), rarity, 10, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Stal Disc", "Stal Disc", + new ItemStack(2263), rarity, 10, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Strad Disc", "Strad Disc", + new ItemStack(2264), rarity, 10, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Ward Disc", "Ward Disc", + new ItemStack(2265), rarity, 10, _uncommonShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Music Disc", "Wait Disc", "Wait Disc", + new ItemStack(2267), rarity, 10, _uncommonShards)); + // Mounts + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Mount", "Mule", "Mount Mule", + new ItemStack(Material.HAY_BLOCK), rarity, 4, _rareShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Mount", "Minecart", "Minecart", + new ItemStack(Material.MINECART), rarity, 3, _rareShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Mount", "Slime", "Slime Mount", + new ItemStack(Material.SLIME_BALL), rarity, 2, _rareShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Mount", "Glacial Steed", "Glacial Steed", + new ItemStack(Material.SNOW_BALL), rarity, 1, _rareShards)); + + // Christmas addReward(RewardPool.Type.WINTER_HOLIDAY, new InventoryReward(inventoryManager, "Coal", "Coal", 50, 100, new ItemStack(Material.COAL), rarity, 10, 0)); @@ -162,6 +212,12 @@ public class RewardManager maxValue *= 2; } + // Valentines + addReward(RewardPool.Type.VALENTINES_GIFT, new InventoryReward(inventoryManager, "Love Potion", "Love Potion", 1, 1, + new ItemStack(Material.POTION, 1), rarity, 100, 0)); + addReward(RewardPool.Type.VALENTINES_GIFT, new TreasureShardReward(_clientManager, donationManager, 100, 200, 25, rarity)); + + // Christmas addReward(RewardPool.Type.WINTER_HOLIDAY, new InventoryReward(inventoryManager, "Freeze Cannon", "Freeze Cannon", 5, 10, new ItemStack(Material.ICE), rarity, 10, 0)); addReward(RewardPool.Type.WINTER_HOLIDAY, new InventoryReward(inventoryManager, "Party Popper", "Party Popper", 5, 10, @@ -257,6 +313,19 @@ public class RewardManager // addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 100, RewardRarity.RARE)); } + // Valentines + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Hat", "Companion Hat", "Companion", + SkinData.COMPANION_CUBE.getSkull(), rarity, 100, 0)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Hat", "Lovestruck Hat", "Lovestruck", + SkinData.LOVESTRUCK.getSkull(), rarity, 100, 0)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Hat", "Secret Package Hat", "Secret Package", + SkinData.SECRET_PACKAGE.getSkull(), rarity, 100, 0)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Hat", "Teddy Bear Hat", "Teddy Bear", + SkinData.TEDDY_BEAR.getSkull(), rarity, 100, 0)); + addReward(RewardPool.Type.VALENTINES_GIFT, new InventoryReward(inventoryManager, "Love Potion", "Love Potion", 1, 1, + new ItemStack(Material.POTION, 1), rarity, 1, 0)); + + // Christmas addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Hat", "Santa", "Santa", SkinData.SANTA.getSkull(), rarity, 5, _rareShards)); addReward(RewardPool.Type.WINTER_HOLIDAY, new PetReward(petManager, inventoryManager, donationManager, "Elf", "Christmas Elf", @@ -326,6 +395,19 @@ public class RewardManager // addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, rarity)); } + // Valentines + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Arrow Effect", "Arrows of Cupid", "Arrows of Cupid", + new ItemStack(Material.POTION), rarity, 100, _rareShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Death Effect", "Broken Hearted", "Broken Hearted", + new ItemStack(Material.POTION), rarity, 100, _rareShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Jump Effect", "Wings of Love", "Wings of Love", + new ItemStack(Material.POTION), rarity, 100, _rareShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new UnknownPackageReward(donationManager, "Particles", "Heartfelt Halo", "Heartfelt Halo", + new ItemStack(Material.POTION), rarity, 100, _rareShards)); + addReward(RewardPool.Type.VALENTINES_GIFT, new InventoryReward(inventoryManager, "Love Potion", "Love Potion", 1, 1, + new ItemStack(Material.POTION, 1), rarity, 2, 0)); + + // Christmas addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Hat", "The Grinch", "The Grinch", SkinData.THE_GRINCH.getSkull(), rarity, 5, _legendaryShards)); addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Morph", "Olaf", "Olaf Morph", @@ -480,7 +562,7 @@ public class RewardManager } } - if (!isExcluded) + if (!isExcluded && (pool.getUseDuplicates() || treasure.canGiveReward(player))) { possibleRewards.add(treasure); totalWeight += treasure.getWeight(); @@ -513,7 +595,7 @@ public class RewardManager if (reward.canGiveReward(player)) return reward; else - return new TreasureShardReward(_donationManager, reward, 1, reward.getRarity()); + return new TreasureShardReward(_clientManager, _donationManager, reward, 1, reward.getRarity()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java index 72c38535f..97f4f23c1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java @@ -34,7 +34,20 @@ public class RewardPool public static enum Type { - NORMAL, - WINTER_HOLIDAY; + NORMAL(true), + WINTER_HOLIDAY(true), + VALENTINES_GIFT(false); + + private boolean _useDuplicates; + + Type(boolean useDuplicates) + { + _useDuplicates = useDuplicates; + } + + public boolean getUseDuplicates() + { + return _useDuplicates; + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java index a26c177a7..24773c6b8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java @@ -11,6 +11,7 @@ public enum RewardType AncientChest( 0, 2, 8, 32), MythicalChest( 0.1, 4, 16, 72), WinterChest( 0, 5, 18, 32), + ValentinesGift( 0, 7, 20, 20), SpinnerFiller( 0.1, 1, 4, 20), SpinnerReal( 0.000001, 0.05, 0.4, 5); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/TreasureShardReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/TreasureShardReward.java index a931d2311..5f9c368e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/TreasureShardReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/TreasureShardReward.java @@ -1,5 +1,8 @@ package mineplex.core.reward.rewards; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.UtilMath; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -13,34 +16,62 @@ import mineplex.core.reward.RewardType; public class TreasureShardReward extends Reward { + private CoreClientManager _clientManager; private DonationManager _donationManager; private Reward _otherReward; - private int _shards; + private int _shardsMin = 0; + private int _shardsMax = 0; - public TreasureShardReward(DonationManager donationManager, Reward otherReward, int weight, RewardRarity rarity) + public TreasureShardReward(CoreClientManager clientManager, DonationManager donationManager, Reward otherReward, int weight, RewardRarity rarity) { super(rarity, weight, 0); + _clientManager = clientManager; _donationManager = donationManager; _otherReward = otherReward; - _shards = (int) (otherReward.getShardValue() + (Math.random() * otherReward.getShardValue() / 2.0)); + _shardsMin = (int) (otherReward.getShardValue() + (Math.random() * otherReward.getShardValue() / 2.0)); + _shardsMax = _shardsMin; + } + + public TreasureShardReward(CoreClientManager clientManager, DonationManager donationManager, int min, int max, int weight, RewardRarity rarity) + { + super(rarity, weight, 0); + + _clientManager = clientManager; + _donationManager = donationManager; + + _shardsMin = min; + _shardsMax = max; } @Override public RewardData giveRewardCustom(Player player, RewardType rewardType) { - RewardData fakeData = _otherReward.getFakeRewardData(player); - RewardData rewardData = new RewardData(fakeData.getHeader(), fakeData.getFriendlyName(), fakeData.getDisplayItem(), fakeData.getRarity(), _shards); + RewardData rewardData; + final int shards = UtilMath.rRange(_shardsMin, _shardsMax); - _donationManager.RewardCoins(new Callback() + if (_otherReward != null) + { + RewardData fakeData = _otherReward.getFakeRewardData(player); + rewardData = new RewardData(fakeData.getHeader(), fakeData.getFriendlyName(), fakeData.getDisplayItem(), fakeData.getRarity(), shards); + } + else + { + rewardData = new RewardData(null, getRarity().getColor() + shards + " Treasure Shards", new ItemStack(Material.PRISMARINE_SHARD), getRarity()); + } + + int accountId = _clientManager.getAccountId(player); + + // Give shards 5 seconds later for better effect + Bukkit.getScheduler().runTaskLater(_donationManager.getPlugin(), new Runnable() { @Override - public void run(Boolean data) + public void run() { - + _donationManager.rewardCoinsUntilSuccess(null, "Treasure", player.getName(), accountId, shards); } - }, "Treasure Chest", player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), _shards); + }, 100); return rewardData; } @@ -66,3 +97,4 @@ public class TreasureShardReward extends Reward return false; } } + diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ShopItem.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ShopItem.java index 342784570..d05f7734c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ShopItem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/ShopItem.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -210,4 +211,13 @@ public class ShopItem extends ItemStack return this; } + + public ShopItem hideInfo() + { + ItemMeta meta = getItemMeta(); + meta.addItemFlags(ItemFlag.values()); + setItemMeta(meta); + + return this; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/simpleStats/SimpleStats.java b/Plugins/Mineplex.Core/src/mineplex/core/simpleStats/SimpleStats.java deleted file mode 100644 index f2ea158bf..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/simpleStats/SimpleStats.java +++ /dev/null @@ -1,87 +0,0 @@ -package mineplex.core.simpleStats; - -import org.bukkit.Bukkit; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - -public class SimpleStats extends MiniPlugin -{ - private static Object _transferLock = new Object(); - - private SimpleStatsRepository _repository = new SimpleStatsRepository(); - private NautHashMap _entries = new NautHashMap(); - - public SimpleStats(JavaPlugin plugin) - { - super("SimpleStats", plugin); - - _repository.initialize(); - } - - /* - public NautHashMap getEntries() - { - synchronized (_transferLock) - { - return _entries; - } - }*/ - - @EventHandler - public void storeStatsUpdate(final UpdateEvent updateEvent) - { - if (updateEvent.getType() != UpdateType.SLOW) - return; - - Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - synchronized (_transferLock) - { - _entries = (_repository.retrieveStatRecords()); - } - } - }); - } - - public void store(String statName, String statValue) - { - final String statNameFinal = statName; - final String statValueFinal = statValue; - - Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - synchronized (_transferLock) - { - _repository.storeStatValue(statNameFinal, statValueFinal); - } - } - }); - } - - public NautHashMap getStat(String statName) - { - final String statNameFinal = statName; - - Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - synchronized (_transferLock) - { - _entries = _repository.retrieveStat(statNameFinal); - } - } - }); - - return _entries; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/simpleStats/SimpleStatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/simpleStats/SimpleStatsRepository.java deleted file mode 100644 index ff39bce61..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/simpleStats/SimpleStatsRepository.java +++ /dev/null @@ -1,220 +0,0 @@ -package mineplex.core.simpleStats; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -import mineplex.core.common.util.NautHashMap; - -public class SimpleStatsRepository -{ - private static Object _connectionLock = new Object(); - - private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex?autoReconnect=true&failOverReadOnly=false&maxReconnects=10"; - private String _userName = "root"; - private String _password = "tAbechAk3wR7tuTh"; //try to obfuscate this in the future! - - private static String CREATE_STATS_TABLE = "CREATE TABLE IF NOT EXISTS simpleStats (id INT NOT NULL AUTO_INCREMENT, statName VARCHAR(64), statValue VARCHAR(64), PRIMARY KEY (id));"; - private static String RETRIEVE_STATS_RECORDS = "SELECT simpleStats.statName, simpleStats.statValue FROM simpleStats;"; - private static String STORE_STATS_RECORD = "INSERT INTO simpleStats (statName,statValue) VALUES(?,?);"; - private static String RETRIEVE_STAT_RECORD = "SELECT simpleStats.statName, simpleStats.statValue FROM simpleStats WHERE statName = '?';"; - - private Connection _connection = null; - - public void initialize() - { - /* - PreparedStatement preparedStatement = null; - - try - { - Class.forName("com.mysql.jdbc.Driver"); - - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - - // Create table - preparedStatement = _connection.prepareStatement(CREATE_STATS_TABLE); - preparedStatement.execute(); - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } - */ - } - - public NautHashMap retrieveStatRecords() - { - ResultSet resultSet = null; - PreparedStatement preparedStatement = null; - NautHashMap statRecords = new NautHashMap(); - - try - { - synchronized (_connectionLock) - { - if (_connection.isClosed()) - { - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - } - - preparedStatement = _connection.prepareStatement(RETRIEVE_STATS_RECORDS); - - resultSet = preparedStatement.executeQuery(); - - while (resultSet.next()) - { - statRecords.put(resultSet.getString(1), resultSet.getString(2)); - } - } - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - - if (resultSet != null) - { - try - { - resultSet.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } - - return statRecords; - } - - public void storeStatValue(String statName, String statValue) - { - PreparedStatement preparedStatement = null; - - try - { - synchronized (_connectionLock) - { - if (_connection.isClosed()) - { - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - } - - preparedStatement = _connection.prepareStatement(STORE_STATS_RECORD); - preparedStatement.setString(1, statName); - preparedStatement.setString(2, statValue); - - preparedStatement.executeUpdate(); - } - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } - } - - public NautHashMap retrieveStat(String statName) - { - ResultSet resultSet = null; - PreparedStatement preparedStatement = null; - NautHashMap statRecords = new NautHashMap(); - - try - { - synchronized (_connectionLock) - { - if (_connection.isClosed()) - { - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - } - - preparedStatement = _connection.prepareStatement(RETRIEVE_STAT_RECORD); - preparedStatement.setString(1, statName); - - resultSet = preparedStatement.executeQuery(); - - while (resultSet.next()) - { - statRecords.put(resultSet.getString(1), resultSet.getString(2)); - } - } - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - - if (resultSet != null) - { - try - { - resultSet.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } - - return statRecords; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java index c6f4191a5..78fda20c2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java @@ -5,14 +5,15 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.database.DBPool; -import mineplex.core.database.RepositoryBase; -import mineplex.core.database.ResultSetCallable; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnVarChar; -public class SpawnRepository extends RepositoryBase +public class SpawnRepository extends MinecraftRepository { private static String CREATE_SPAWN_TABLE = "CREATE TABLE IF NOT EXISTS spawns (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(100), location VARCHAR(100), PRIMARY KEY (id), INDEX serverNameIndex (serverName));"; private static String RETRIEVE_SPAWNS = "SELECT location FROM spawns WHERE serverName = ?;"; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java index e8ac03479..cb5ec1320 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java @@ -7,10 +7,11 @@ import java.util.Collections; import java.util.List; 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.core.database.MinecraftRepository; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.database.Tables; import org.bukkit.plugin.java.JavaPlugin; @@ -23,7 +24,7 @@ import org.jooq.Update; import org.jooq.impl.DSL; import org.jooq.types.ULong; -public class StatsRepository extends RepositoryBase +public class StatsRepository extends MinecraftRepository { private static String RETRIEVE_STATS = "SELECT id, name FROM stats;"; private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);"; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/task/repository/TaskRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/task/repository/TaskRepository.java index 51dfe5726..35766c91d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/task/repository/TaskRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/task/repository/TaskRepository.java @@ -5,17 +5,18 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; -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; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.core.task.Task; import mineplex.core.task.TaskClient; -public class TaskRepository extends RepositoryBase +public class TaskRepository extends MinecraftRepository { private static String ADD_ACCOUNT_TASK = "INSERT INTO accountTasks (accountId, taskId) VALUES (?, ?);"; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java index b6d29c68b..29c0d6a88 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java @@ -4,15 +4,16 @@ import java.sql.CallableStatement; import java.sql.Connection; import java.sql.Types; +import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.database.DBPool; -import mineplex.core.database.RepositoryBase; -import mineplex.core.database.column.ColumnInt; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.serverdata.Region; -public class TitanGiveawayRepository extends RepositoryBase +public class TitanGiveawayRepository extends MinecraftRepository { private static final String ADD_TITAN = "INSERT INTO titanGiveaway (accountId, region, serverName) VALUES (?, ?, ?)"; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java index a9eecb3f7..d7c4b5303 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java @@ -117,7 +117,8 @@ public class Treasure reward.giveReward(_rewardType, player, new Callback() { @Override - public void run(RewardData data) { + public void run(RewardData data) + { _rewardData.put(count, data); } }); @@ -350,6 +351,7 @@ public class Treasure public void run(RewardData data) { // Do nothing + System.out.println("Shards: " + data.getShards()); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java index a5c89e0ce..104272137 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java @@ -14,7 +14,6 @@ import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.donation.DonationManager; -import mineplex.core.giveaway.GiveawayManager; import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.pet.PetManager; @@ -38,7 +37,7 @@ public class TreasureManager extends MiniPlugin private StatsManager _statsManager; private List _treasureLocations; - public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager, StatsManager statsManager, GiveawayManager giveawayManager) + public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager, StatsManager statsManager) { super("Treasure", plugin); @@ -47,7 +46,7 @@ public class TreasureManager extends MiniPlugin _blockRestore = blockRestore; _hologramManager = hologramManager; _statsManager = statsManager; - _rewardManager = new RewardManager(clientManager, statusManager, donationManager, _inventoryManager, petManager, statsManager, giveawayManager, + _rewardManager = new RewardManager(clientManager, statusManager, donationManager, _inventoryManager, petManager, statsManager, 100, 250, 500, 1000, 4000, 6000, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java index 2d6e42d38..f319264e9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java @@ -77,7 +77,9 @@ public class BlockChangeAnimation extends Animation continue; _blockInfoList.add(new BlockInfo(b)); + byte data = b.getData(); b.setType(mat); + b.setData(data); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/valentines/GiftEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/valentines/GiftEffect.java new file mode 100644 index 000000000..c8411188c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/valentines/GiftEffect.java @@ -0,0 +1,140 @@ +package mineplex.core.valentines; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextMiddle; + +public class GiftEffect +{ + private static final int ANIMATION_LENGTH = 20 * 5; + private static final double CIRCLE_RADIUS = 3; + private static final double CIRCLE_HEIGHT = 3; + + private Player _from; + private Player _to; + private String _fromGift; + private String _toGift; + private Location _centerLocation; + private boolean _finished; + private int _ticks; + + public GiftEffect(Player from, Player to, String fromGift, String toGift, Location centerLocation) + { + _from = from; + _to = to; + _fromGift = fromGift; + _toGift = toGift; + _centerLocation = centerLocation; + _finished = false; + _ticks = 0; + +// _to.setWalkSpeed(0.0F); +// _from.setWalkSpeed(0.0F); + } + + public void tick() + { + _ticks++; + + if (_ticks == 1) + { + if (_to.isOnline()) + { + UtilTextMiddle.display("", C.cYellow + _from.getName() + C.cPurple + " is sharing a Gift with you", _to); + _to.playSound(_to.getLocation(), Sound.CAT_MEOW, 1f, 1f);; + } + if (_from.isOnline()) + { + UtilTextMiddle.display("", C.cPurple + "You are sharing a Gift with " + C.cYellow + _to.getName(), _from); + _from.playSound(_from.getLocation(), Sound.CAT_MEOW, 1f, 1f); + } + } + else if (_ticks == 40) + { + if (_to.isOnline()) + { + UtilTextMiddle.display("", C.cRed + "3", _to); + _to.playSound(_to.getEyeLocation(), Sound.NOTE_PLING, 1F, 1F - 0.3f); + } + if (_from.isOnline()) + { + UtilTextMiddle.display("", C.cRed + "3", _from); + _from.playSound(_from.getEyeLocation(), Sound.NOTE_PLING, 1F, 1F - 0.3f); + } + } + else if (_ticks == 60) + { + if (_to.isOnline()) + { + UtilTextMiddle.display("", C.cGold + "2", _to); + _to.playSound(_to.getEyeLocation(), Sound.NOTE_PLING, 1F, 1F - 0.2f); + } + if (_from.isOnline()) + { + UtilTextMiddle.display("", C.cGold + "2", _from); + _from.playSound(_from.getEyeLocation(), Sound.NOTE_PLING, 1F, 1F - 0.2f); + } + } + else if (_ticks == 80) + { + if (_to.isOnline()) + { + UtilTextMiddle.display("", C.cGreen + "1", _to); + _to.playSound(_to.getEyeLocation(), Sound.NOTE_PLING, 1F, 1F - 0.1f); + } + if (_from.isOnline()) + { + UtilTextMiddle.display("", C.cGreen + "1", _from); + _from.playSound(_from.getEyeLocation(), Sound.NOTE_PLING, 1F, 1F - 0.1f); + } + } + else if (_ticks == 100) + { + if (_to.isOnline()) + { + UtilTextMiddle.display("", C.cPurple + "You received " + _toGift, _to); + _to.playSound(_to.getEyeLocation(), Sound.LEVEL_UP, 1F, 1F); + UtilPlayer.message(_to, F.main("Gift", "You received " + F.elem(_toGift) + "!")); + UtilPlayer.message(_to, F.main("Gift", F.name(_from.getName()) + " received " + F.elem(_fromGift) + "!")); + } + if (_from.isOnline()) + { + UtilTextMiddle.display("", C.cPurple + "You received " + _fromGift, _from); + _from.playSound(_from.getEyeLocation(), Sound.LEVEL_UP, 1F, 1F); + UtilPlayer.message(_from, F.main("Gift", "You received " + F.elem(_fromGift) + "!")); + UtilPlayer.message(_from, F.main("Gift", F.name(_to.getName()) + " received " + F.elem(_toGift) + "!")); + } + } + + double yAdd = CIRCLE_HEIGHT * ((double) _ticks) / ANIMATION_LENGTH; + double xAdd = CIRCLE_RADIUS * Math.sin(_ticks / 10.0 * Math.PI); + double zAdd = CIRCLE_RADIUS * Math.cos(_ticks / 10.0 * Math.PI); + + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.HEART, _centerLocation.clone().add(xAdd, yAdd, zAdd), 0.5f, 0.5f, 0.5f, 0, 5, UtilParticle.ViewDist.NORMAL); + + if (_ticks % 10 == 0) + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.FIREWORKS_SPARK, _centerLocation.clone().add(0, 1, 0), 3f, 3f, 3f, 0, 10, UtilParticle.ViewDist.NORMAL); + + if (_ticks >= ANIMATION_LENGTH) + { + UtilFirework.playFirework(_centerLocation.clone().add(0, 3, 0), FireworkEffect.builder().with(FireworkEffect.Type.STAR).withColor(Color.RED).withFade(Color.WHITE).withFlicker().build()); + _finished = true; +// if (_to.isOnline()) _to.setWalkSpeed(0.2F); +// if (_from.isOnline()) _from.setWalkSpeed(0.2F); + } + } + + public boolean isFinished() + { + return _finished; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/valentines/ValentinesGiftManager.java b/Plugins/Mineplex.Core/src/mineplex/core/valentines/ValentinesGiftManager.java new file mode 100644 index 000000000..d5b2e5ca6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/valentines/ValentinesGiftManager.java @@ -0,0 +1,143 @@ +package mineplex.core.valentines; + +import java.util.Iterator; +import java.util.LinkedList; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.*; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.reward.*; +import mineplex.core.stats.StatsManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.valentines.event.AttemptGiftEvent; +import net.md_5.bungee.api.ChatColor; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + +public class ValentinesGiftManager extends MiniPlugin +{ + private final String ITEM_NAME = "Valentines Gift"; + private final Material ITEM_MATERIAL = Material.RED_ROSE; + + private CoreClientManager _clientManager; + private RewardManager _rewardManager; + private InventoryManager _inventoryManager; + private GadgetManager _gadgetManager; + private StatsManager _statsManager; + + private ValentinesGiftRepository _repository; + private LinkedList _effects; + + public ValentinesGiftManager(JavaPlugin plugin, CoreClientManager clientManager, RewardManager rewardManager, InventoryManager inventoryManager, GadgetManager gadgetManager, StatsManager statsManager) + { + super("Valentines", plugin); + + _clientManager = clientManager; + _rewardManager = rewardManager; + _inventoryManager = inventoryManager; + _gadgetManager = gadgetManager; + _statsManager = statsManager; + + _repository = new ValentinesGiftRepository(plugin); + _effects = new LinkedList<>(); + } + + @EventHandler + public void onAttemptGift(AttemptGiftEvent event) + { + Player from = event.getFrom(); + Player to = event.getTo(); + + final int fromId = _clientManager.getAccountId(from); + final int toId = _clientManager.getAccountId(to); + + runAsync(() -> { + final boolean complete = _repository.giveGift(fromId, toId); +// final boolean complete = true; + runSync(() -> giveGift(from, to, complete)); + }); + } + + /** + * I apologize for this mess. Love, Shaun + */ + private void giveGift(Player from, Player to, boolean success) + { + if (success) + { + _inventoryManager.addItemToInventory(new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + { + _rewardManager.nextReward(to, RewardPool.Type.VALENTINES_GIFT, null, false, RewardType.ValentinesGift, false).giveReward(RewardType.ValentinesGift, to, new Callback() + { + @Override + public void run(RewardData toData) + { + String toGift = ChatColor.stripColor(toData.getFriendlyName()); + + _rewardManager.nextReward(from, RewardPool.Type.VALENTINES_GIFT, null, false, RewardType.ValentinesGift, false).giveReward(RewardType.ValentinesGift, from, new Callback() + { + @Override + public void run(RewardData fromData) + { + String fromGift = ChatColor.stripColor(fromData.getFriendlyName()); + _effects.add(new GiftEffect(from, to, fromGift, toGift, UtilAlg.getMidpoint(to.getLocation(), from.getLocation()))); + + incrementStat(from, to); + } + }); + } + }); + + from.getInventory().setItem(_gadgetManager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(ITEM_MATERIAL, (byte) 0, 1, F.item(_inventoryManager.Get(from).getItemCount(ITEM_NAME) + " " + ITEM_NAME))); + } + else + { + UtilPlayer.message(from, F.main("Gift", "Error giving gift! Please try again")); + } + } + }, from, ITEM_NAME, -1); + } + else + { + UtilPlayer.message(from, F.main("Gift", "Spread the love! You have already gifted " + F.name(to.getName()))); + } + } + + @EventHandler + public void updateEffects(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + Iterator iterator = _effects.iterator(); + + while (iterator.hasNext()) + { + GiftEffect effect = iterator.next(); + if (effect.isFinished()) + iterator.remove(); + else + effect.tick(); + } + } + + private void incrementStat(Player from, Player to) + { + _statsManager.incrementStat(from, "Global.Valentines2016.GiftsGiven", 1); + _statsManager.incrementStat(to, "Global.Valentines2016.GiftsReceived", 1); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/valentines/ValentinesGiftRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/valentines/ValentinesGiftRepository.java new file mode 100644 index 000000000..0115bd9a3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/valentines/ValentinesGiftRepository.java @@ -0,0 +1,34 @@ +package mineplex.core.valentines; + +import mineplex.core.database.MinecraftRepository; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import org.bukkit.plugin.java.JavaPlugin; + +public class ValentinesGiftRepository extends MinecraftRepository +{ + private String GIVE_GIFT = "INSERT INTO accountValentinesGift (senderId, targetId) VALUES (?, ?);"; + + public ValentinesGiftRepository(JavaPlugin plugin) + { + super(plugin, DBPool.getAccount()); + } + + @Override + protected void initialize() + { + + } + + @Override + protected void update() + { + + } + + public boolean giveGift(int senderId, int targetId) + { + return executeUpdate(GIVE_GIFT, new ColumnInt("senderId", senderId), new ColumnInt("targetId", targetId)) == 1; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/valentines/event/AttemptGiftEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/valentines/event/AttemptGiftEvent.java new file mode 100644 index 000000000..6b5d5f806 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/valentines/event/AttemptGiftEvent.java @@ -0,0 +1,31 @@ +package mineplex.core.valentines.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class AttemptGiftEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + public static HandlerList getHandlerList() { return handlers; } + public HandlerList getHandlers() { return handlers; } + + private Player _from; + private Player _to; + + public AttemptGiftEvent(Player from, Player to) + { + _from = from; + _to = to; + } + + public Player getFrom() + { + return _from; + } + + public Player getTo() + { + return _to; + } +} diff --git a/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DnsMadeEasyRepository.java b/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DnsMadeEasyRepository.java index 2563df862..aebe2bdec 100644 --- a/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DnsMadeEasyRepository.java +++ b/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DnsMadeEasyRepository.java @@ -61,7 +61,7 @@ public class DnsMadeEasyRepository } } } - + public boolean switchToDDOSProt() { Connection connection = null; diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/TempRepository.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/TempRepository.java index e96d4a42a..73cba9a30 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/TempRepository.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/TempRepository.java @@ -1,13 +1,14 @@ package mineplex.enjinTranslator; +import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.database.DBPool; -import mineplex.core.database.RepositoryBase; -import mineplex.core.database.column.ColumnInt; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; -public class TempRepository extends RepositoryBase +public class TempRepository extends MinecraftRepository { private static String INSERT_CLIENT_INVENTORY = "INSERT INTO accountInventory (accountId, itemId, count) SELECT accounts.id, 5, ? FROM accounts WHERE accounts.name = ? ON DUPLICATE KEY UPDATE count=count + VALUES(count);"; diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/purchase/PurchaseManager.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/purchase/PurchaseManager.java index 1897f407e..8f52c28a4 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/purchase/PurchaseManager.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/purchase/PurchaseManager.java @@ -9,7 +9,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.common.util.NautHashMap; -import mineplex.core.database.ResultSetCallable; +import mineplex.serverdata.database.ResultSetCallable; import mineplex.enjinTranslator.purchase.data.PurchaseRepository; import mineplex.enjinTranslator.purchase.data.Package; diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/purchase/data/PurchaseRepository.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/purchase/data/PurchaseRepository.java index 048c1fc99..0c2fe000a 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/purchase/data/PurchaseRepository.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/purchase/data/PurchaseRepository.java @@ -5,16 +5,17 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; -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.ColumnVarChar; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnBoolean; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; -public class PurchaseRepository extends RepositoryBase +public class PurchaseRepository extends MinecraftRepository { private static String INSERT_ACCOUNT_PURCHASE = "INSERT INTO accountPurchases (accountId, packageId, amount, date, success) VALUES (?, ?, ?, now(), ?);"; diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java index 70f9d082b..8e2068a2d 100644 --- a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java +++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java @@ -11,14 +11,15 @@ import java.util.UUID; import mineplex.core.common.util.Callback; 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.Column; -import mineplex.core.database.column.ColumnBoolean; -import mineplex.core.database.column.ColumnInt; -import mineplex.core.database.column.ColumnTimestamp; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.core.database.MinecraftRepository; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.Column; +import mineplex.serverdata.database.column.ColumnBoolean; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnTimestamp; +import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.database.tables.records.ClansRecord; import mineplex.game.clans.core.repository.tokens.ClanAllianceToken; import mineplex.game.clans.core.repository.tokens.ClanMemberToken; @@ -36,7 +37,7 @@ import org.jooq.DSLContext; import static mineplex.database.Tables.*; import static org.jooq.impl.DSL.*; -public class ClanRepository extends RepositoryBase +public class ClanRepository extends MinecraftRepository { private static String CREATE_CLAN_TABLE = "CREATE TABLE IF NOT EXISTS clans (id INT NOT NULL AUTO_INCREMENT, serverId INT NOT NULL, name VARCHAR(100), description VARCHAR(140), home VARCHAR(140), admin BIT(1), dateCreated DATETIME, lastOnline DATETIME, energy INT, PRIMARY KEY (id), INDEX clanName (name));"; private static String CREATE_ACCOUNT_CLAN_TABLE = "CREATE TABLE IF NOT EXISTS accountClan (id INT NOT NULL AUTO_INCREMENT, accountId INT, clanId INT, clanRole VARCHAR(140), PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));"; 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 index 5ec0f6fc0..287d3c1de 100644 --- 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 @@ -6,20 +6,21 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; +import mineplex.core.database.MinecraftRepository; 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; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnBoolean; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnTimestamp; +import mineplex.serverdata.database.column.ColumnVarChar; -public class ClansBanRepository extends RepositoryBase +public class ClansBanRepository extends MinecraftRepository { private ClansBanManager _manager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/repository/FieldRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/repository/FieldRepository.java index 2f36fd067..6e604d3f8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/repository/FieldRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/repository/FieldRepository.java @@ -5,17 +5,18 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.database.DBPool; -import mineplex.core.database.RepositoryBase; -import mineplex.core.database.ResultSetCallable; -import mineplex.core.database.column.ColumnByte; -import mineplex.core.database.column.ColumnDouble; -import mineplex.core.database.column.ColumnInt; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnByte; +import mineplex.serverdata.database.column.ColumnDouble; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; -public class FieldRepository extends RepositoryBase +public class FieldRepository extends MinecraftRepository { private static String ALL_STRING = "ALL"; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index de561f590..b7b8cb0cc 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.ConfigContainer; import mineplex.core.common.events.ServerShutdownEvent; import mineplex.core.creature.Creature; import mineplex.core.customdata.CustomDataManager; @@ -22,7 +23,6 @@ import mineplex.core.elo.EloManager; import mineplex.core.energy.Energy; import mineplex.core.friend.FriendManager; 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; @@ -69,10 +69,22 @@ import mineplex.minecraft.game.core.IRelation; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; +import org.bukkit.configuration.file.FileConfiguration; public class Hub extends JavaPlugin implements IRelation { private String WEB_CONFIG = "webServer"; + private final ConfigContainer _config = new ConfigContainer(this, "mineplex.yml"); + + @Override + public FileConfiguration getConfig() { + return _config.getConfig(); + } + + @Override + public void saveConfig() { + _config.saveConfig(); + } @Override public void onEnable() @@ -117,7 +129,6 @@ public class Hub extends JavaPlugin implements IRelation //Main Modules ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager)); - GiveawayManager giveawayManager = new GiveawayManager(this, clientManager, serverStatusManager); new TitanGiveawayManager(this, clientManager, serverStatusManager); Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); @@ -138,7 +149,7 @@ public class Hub extends JavaPlugin implements IRelation CustomDataManager customDataManager = new CustomDataManager(this, clientManager); PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager); - HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, giveawayManager, customDataManager); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, customDataManager); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); @@ -150,7 +161,7 @@ public class Hub extends JavaPlugin implements IRelation new CustomTagFix(this, packetHandler); new PacketsInteractionFix(this, packetHandler); new ResourcePackManager(this, portal); - new GlobalPacketManager(this, clientManager, serverStatusManager, inventoryManager, donationManager, petManager, statsManager, giveawayManager); + new GlobalPacketManager(this, clientManager, serverStatusManager, inventoryManager, donationManager, petManager, statsManager); //new Replay(this, packetHandler); AprilFoolsManager.Initialize(this, clientManager, disguiseManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 3828bda01..8dfa24518 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -8,6 +8,41 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Random; +import mineplex.core.reward.RewardManager; +import mineplex.core.valentines.ValentinesGiftManager; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.Egg; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetEvent.TargetReason; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; +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.plugin.java.JavaPlugin; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Scoreboard; + import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; @@ -18,7 +53,6 @@ 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.UtilInv; @@ -74,7 +108,6 @@ import mineplex.hub.commands.GadgetToggle; import mineplex.hub.commands.GameModeCommand; import mineplex.hub.commands.NewsCommand; import mineplex.hub.modules.ForcefieldManager; -import mineplex.hub.modules.HolidayGiftManager; import mineplex.hub.modules.HubVisibilityManager; import mineplex.hub.modules.JumpManager; import mineplex.hub.modules.KothManager; @@ -82,6 +115,7 @@ import mineplex.hub.modules.NewsManager; import mineplex.hub.modules.ParkourManager; import mineplex.hub.modules.SoccerManager; import mineplex.hub.modules.TextManager; +import mineplex.hub.modules.ValentinesManager; import mineplex.hub.modules.WorldManager; import mineplex.hub.profile.gui.GUIProfile; import mineplex.hub.tutorial.TutorialManager; @@ -90,51 +124,12 @@ 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 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; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.entity.Egg; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityTargetEvent.TargetReason; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerQuitEvent; -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.plugin.java.JavaPlugin; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Scoreboard; public class HubManager extends MiniClientPlugin { @@ -168,6 +163,7 @@ public class HubManager extends MiniClientPlugin private PlayerCountManager _playerCountManager; private CustomDataManager _customDataManager; private Punish _punishManager; + private ValentinesManager _valentinesManager; // private HalloweenSpookinessManager _halloweenManager; // private TrickOrTreatManager _trickOrTreatManager; @@ -190,7 +186,7 @@ public class HubManager extends MiniClientPlugin // private final String[] _songNames = {"JingleBells.nbs", "TheFirstNoel.nbs", "Hark.nbs", "DeckTheHalls.nbs", "Joy.nbs", "MerryChristmas.nbs"}; private final ArrayList _songs; - public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, GiveawayManager giveawayManager, CustomDataManager customDataManager) + public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager) { super("Hub Manager", plugin); @@ -221,9 +217,9 @@ public class HubManager extends MiniClientPlugin _mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager); _inventoryManager = inventoryManager; new BenefitManager(plugin, clientManager, _inventoryManager); - _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager); + _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager, packetHandler); - _treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager, statsManager, giveawayManager); + _treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager, statsManager); new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager); new SoccerManager(this, _gadgetManager); @@ -251,7 +247,7 @@ public class HubManager extends MiniClientPlugin ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); - new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager, facebookManager); + new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager); // _halloweenManager = new HalloweenSpookinessManager(this); @@ -259,6 +255,12 @@ public class HubManager extends MiniClientPlugin new PlayerDisguiseManager(plugin, _clientManager); // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // new MailManager(_plugin, notificationManager); + new ValentinesGiftManager(plugin, clientManager, new RewardManager(clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, statsManager, + 100, 250, + 500, 1000, + 4000, 6000, + 12000, 22000, + true, false), inventoryManager, _gadgetManager, statsManager); _playerCountManager = new PlayerCountManager(plugin); @@ -267,6 +269,8 @@ public class HubManager extends MiniClientPlugin _songs = new ArrayList(); _punishManager = punish; + + _valentinesManager = new ValentinesManager(plugin, clientManager, donationManager); try { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java index cf07e0012..065728f36 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java @@ -1,20 +1,12 @@ package mineplex.hub; import java.sql.Connection; -import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.database.DBPool; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; +import mineplex.serverdata.database.DBPool; public class HubRepository { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java index ae09e592f..7e7659b83 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java @@ -4,10 +4,11 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.UUID; +import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.database.DBPool; -import mineplex.core.database.RepositoryBase; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; import mineplex.database.Tables; import mineplex.database.tables.records.MailRecord; @@ -15,7 +16,7 @@ import org.jooq.DSLContext; import org.jooq.Result; import org.jooq.impl.DSL; -public class MailRepository extends RepositoryBase +public class MailRepository extends MinecraftRepository { private MailManager _manager; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ValentinesManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ValentinesManager.java new file mode 100644 index 000000000..73bb8bd30 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ValentinesManager.java @@ -0,0 +1,133 @@ +package mineplex.hub.modules; + +import org.bukkit.entity.Player; +import org.bukkit.entity.Sheep; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.CurrencyType; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.event.GadgetCollideEntityEvent; +import mineplex.core.gadget.gadgets.item.ItemLovePotion; +import mineplex.core.server.util.TransactionResponse; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.modules.valentines.Courtship; + +public class ValentinesManager extends MiniPlugin +{ + /** + * Created by: Mysticate + * Timestamp: February 6, 2016 + */ + + private final boolean _enabled = true; + + private final String _prefix = C.cDPurple + "Polly"; + private final String _identifier = "Polly the Pink Sheep"; + private final String _reward = "Loving Sheeples"; // The sales package to reward + + private final float _dropRate = .1F; + + private CoreClientManager _client; + private DonationManager _donation; + + private Courtship _active = null; + private long _lastEnd = -1; + + public ValentinesManager(JavaPlugin plugin, CoreClientManager client, DonationManager donation) + { + super("Valentines Sheep Manager", plugin); + + _client = client; + _donation = donation; + } + + @EventHandler + public void onGadget(GadgetCollideEntityEvent event) + { + if (!_enabled) + return; + + if (!(event.getGadget() instanceof ItemLovePotion)) + return; + + if (!(event.getOther() instanceof Sheep)) + return; + + Player player = event.getPlayer(); + + if (!event.getOther().getCustomName().contains(_identifier)) + return; + + if (_lastEnd != -1 && !UtilTime.elapsed(_lastEnd, 1000)) + return; + + if (_active != null) + { + UtilPlayer.message(player, F.main("Cupid", "Someone is already courting " + F.elem(_prefix) + "!")); + return; + } + + if (_donation.Get(player).OwnsUnknownPackage(_reward)) + { + UtilPlayer.message(player, F.main(_prefix, "I already love you!")); + return; + } + + event.setCancelled(false); // Uncancel + + final boolean success = UtilMath.random.nextFloat() > 1 - _dropRate; + _active = new Courtship(this, player, (Sheep) event.getOther(), _prefix, success); + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (_active == null) + return; + + if (event.getType() == UpdateType.TICK) + { + if (_active.tick()) + { + _active = null; + _lastEnd = System.currentTimeMillis(); + } + } + } + + public void giveReward(Player player) + { + _donation.PurchaseUnknownSalesPackage(new Callback() + { + @Override + public void run(TransactionResponse data) + { +// if (data == TransactionResponse.AlreadyOwns) +// { +// UtilPlayer.message(player, "owned but it worked"); +// } +// + if (data == TransactionResponse.AlreadyOwns || data == TransactionResponse.Failed) + { + UtilPlayer.message(player, F.main("Error", "An error occured while rewarding " + F.elem(_reward) + ".")); + return; + } + + if (data == TransactionResponse.Success) + { + UtilPlayer.message(player, F.main("Reward", "You recieved " + F.elem(_reward + " Mount") + " from " + F.elem(_prefix) + "!")); + } + } + }, player.getName(), _client.getAccountId(player), _reward, CurrencyType.Coins, 0, true); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java new file mode 100644 index 000000000..948a334aa --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/valentines/Courtship.java @@ -0,0 +1,192 @@ +package mineplex.hub.modules.valentines; + +import org.bukkit.DyeColor; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSheep; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Sheep; +import org.bukkit.util.Vector; + +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.UtilEnt; +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.hub.modules.ValentinesManager; + +public class Courtship +{ + private static final String[] FAIL_MESSAGES = { + "Sorry, but you don't seem like the type of person I prefer to associate with.", + "Mmmmmm, that's delicious! But I still don't like you very much.", + "For a moment there, I thought you were my friend... But you're not! Leave me alone!", + "Just because I'm drinking your drink, doesn't mean we're friends!", + "Hmmm... I don't know. I think I have enough friends right now, thanks.", + "Ugh why are you always trying to talk to me?", + "Just because I eat grass sometimes, doesn't mean I'm desperate enough to be your friend." + }; + + /** + * Created by: Mysticate + * Timestamp: February 6, 2016 + */ + + private ValentinesManager _manager; + private Player _player; + private Sheep _sheep; + private String _prefix; + private final boolean _success; + + private int _tick = 0; + + public Courtship(ValentinesManager manager, Player player, Sheep sheep, String prefix, boolean success) + { + _manager = manager; + _player = player; + _sheep = sheep; + _prefix = prefix; + _success = success; + } + + public boolean tick() + { + if (!_player.isOnline()) + return true; + + _tick++; + + { + Vector vec = UtilAlg.getTrajectory(_sheep, _player); + UtilEnt.CreatureForceLook(_sheep, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec)); + } + + for (Player player : UtilPlayer.getNearby(_sheep.getLocation(), 4)) + { + if (player != _player) + { + if (Recharge.Instance.use(player, "Sheep Bump", 500, false, false)) + { + Entity bottom = player; + while (bottom.getVehicle() != null) + bottom = bottom.getVehicle(); + + UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(_sheep, bottom), .5, true, 0.8, 0, 10, true); + player.playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f); + + UtilPlayer.message(player, F.main(_prefix, "I'm talking to someone else right now!")); + } + } + } + + if (_tick == 20) + { + message("What do we have here?"); + _sheep.getWorld().playSound(_sheep.getLocation(), Sound.NOTE_BASS, 1F, 1F); + } + + if (_tick == 40) + { + if (_success) + { + message("I feel weird..."); + _sheep.getWorld().playSound(_sheep.getLocation(), Sound.NOTE_BASS, 2F, 1F); + } + else + { + message("Was that a love potion?"); + _sheep.getWorld().playSound(_sheep.getLocation(), Sound.NOTE_BASS, .5F, 1F); + } + } + + if (_tick > 40 && _tick < 80) + { + if (_tick % 2 == 0) + { + _sheep.getWorld().playSound(_sheep.getLocation(), Sound.DIG_GRASS, 1F, 1F); + + UtilParticle.PlayParticle(ParticleType.HEART, _sheep.getLocation().clone().add(0, 1, 0), new Vector(), 0F, 1, ViewDist.NORMAL, _player); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, _sheep.getLocation(), 1F, 1F, 1F, 0F, 1, ViewDist.NORMAL, _player); + + _sheep.setColor(DyeColor.PINK); + } + else + { + _sheep.setColor(DyeColor.WHITE); + } + } + + if (_tick == 80) + { + if (_success) + { + message("I..."); + _sheep.getWorld().playSound(_sheep.getLocation(), Sound.FIZZ, 1F, 1F); + } + else + { + message(UtilMath.randomElement(FAIL_MESSAGES)); + _sheep.getWorld().playSound(_sheep.getLocation(), Sound.ANVIL_BREAK, 1F, 1F); + _sheep.setColor(DyeColor.BLACK); + } + } + + if (_tick > 80 && _tick < 120 && _success) + { + if (_tick % 2 == 0) + { + _sheep.setColor(DyeColor.PINK); + } + else + { + _sheep.setColor(DyeColor.RED); + } + } + + if (_tick == 90 && _success) + { + message("I think..."); + _sheep.getWorld().playSound(_sheep.getLocation(), Sound.FIZZ, 1F, 1F); + } + + if (_tick == 100 && _success) + { + message("I think I'm in love!"); + _sheep.getWorld().playSound(_sheep.getLocation(), Sound.LEVEL_UP, 1F, 1F); + } + + if (_tick == 120 && _success) + { + message("Here, take this present as a token of my admiration."); + _sheep.getWorld().playSound(_sheep.getLocation(), Sound.LEVEL_UP, 1F, 1F); + + _manager.giveReward(_player); + + _sheep.setColor(DyeColor.RED); + + UtilServer.broadcast(C.cYellowB + _player.getName() + C.cWhiteB + " tricked " + C.cGoldB + "Polly the Pink Sheep" + C.cWhiteB + " with a love potion!"); + } + + if (_tick == 130) + { + _sheep.setColor(DyeColor.PINK); + ((CraftSheep) _sheep).getHandle().setFakeHead(false); + return true; + } + + return false; + } + + private void message(String message) + { + UtilPlayer.message(_player, " "); + UtilPlayer.message(_player, F.main(_prefix, C.cPurple + message)); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/queue/QueueRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/queue/QueueRepository.java index d0b0d0a91..217e4cd49 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/queue/QueueRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/queue/QueueRepository.java @@ -1,14 +1,12 @@ package mineplex.hub.queue; import java.sql.Connection; -import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import mineplex.core.common.util.C; -import mineplex.core.database.DBPool; +import mineplex.serverdata.database.DBPool; public class QueueRepository { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 0782488fc..d6a21481f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -913,4 +913,9 @@ public class ServerManager extends MiniPlugin { return _serverNpcShopMap.get("Type Wars"); } + + public ShopBase getValentinesShop() + { + return _serverNpcShopMap.get("Valentines Vendetta"); + } } 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 0df7aac78..42f56f53e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -40,17 +40,16 @@ public class ServerGameMenu extends ShopPageBase @Override protected void buildPage() { - addButton(2, new ItemBuilder(Material.NAME_TAG).setTitle(C.cYellowB + "Type Wars " + C.cGray + "Team Deathmatch").addLore(new String[] + addButton(2, new ItemBuilder(Material.RED_ROSE).setTitle(C.cYellowB + "Valentines Vendetta " + C.cGray + "Save Valentines!").addLore(new String[] { - (_extraValue ? C.cAquaB : C.cWhiteB) + "NEW GAME", + (_extraValue ? C.cAquaB : C.cWhiteB) + "LIMITED TIME GAME", C.Reset + "", - C.Reset + "Attack your enemies with", - C.Reset + "waves of mobs. Defend your giant", - C.Reset + "by typing the name of an enemy mob", - C.Reset + "to kill it.", + C.Reset + "Calvin the Cow has a Valentines Date,", + C.Reset + "but he was robbed by the nasty pigs!", + C.Reset + "Recover his items, and save the day!", C.Reset + "", - C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("TW") + C.Reset + " other players!", - }).setHideInfo(true).build(), new SelectTWButton(this)); + C.Reset + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("VV") + C.Reset + " other players!", + }).setHideInfo(true).build(), new SelectVVButton(this)); addButton(4, new ItemBuilder(Material.QUARTZ_BLOCK).setTitle(C.cYellowB + "Speed Builders " + C.cGray + "Competitive Building").addLore(new String[] { @@ -76,6 +75,7 @@ public class ServerGameMenu extends ShopPageBase }).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", @@ -86,6 +86,17 @@ public class ServerGameMenu extends ShopPageBase C.Reset + "", C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("MB") + C.Reset + " other players!" }).setHideInfo(true).build(), new SelectFEATButton(this, "Micro Battle")); + */ + + addButton(6, new ItemBuilder(Material.TNT).setTitle(C.cYellowB + "Bomb Lobbers " + C.cGray + "TNT Mayhem").addLore(new String[] + { + (_extraValue ? C.cAquaB : C.cWhiteB) + "FEATURED ARCADE GAME", + C.Reset + "", + C.Reset + "Fight against your enemies using", + C.Reset + "the power of explosives!", + C.Reset + "", + C.Reset + "Join " + C.cGreen + getPlugin().getGroupTagPlayerCount("BL") + C.Reset + " other players!" + }).setHideInfo(true).build(), new SelectFEATButton(this, "Bomb Lobbers")); addButton(9, new ItemBuilder(Material.IRON_PICKAXE).setTitle(C.cYellowB + "The Bridges " + C.cGray + "4 Team Survival").addLore(new String[] { @@ -681,4 +692,9 @@ public class ServerGameMenu extends ShopPageBase { getPlugin().getTypeWarsShop().attemptShopOpen(player); } + + public void openValentines(Player player) + { + getPlugin().getValentinesShop().attemptShopOpen(player); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectVVButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectVVButton.java new file mode 100644 index 000000000..f6a15ba35 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectVVButton.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 SelectVVButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectVVButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.openValentines(player); + } +} 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 d5c6f0bf4..67b2ba1f3 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 @@ -99,6 +99,10 @@ public class DamageManager extends MiniPlugin LivingEntity damager = UtilEvent.GetDamagerEntity(event, true); Projectile projectile = GetProjectile(event); + /* + * Fishing rods are disabled because of their custom properties + * we want them to behave like default MC. + */ if (projectile instanceof Fish) return; @@ -348,9 +352,8 @@ public class DamageManager extends MiniPlugin } } - // TODO: What is this required for? Players with books in regular games are spammed. Is it meant for debugging? - // TODO: Temporarily commenting out - //DisplayDamage(event); + //Debug + DisplayDamage(event); } private void Damage(CustomDamageEvent event) @@ -669,7 +672,7 @@ public class DamageManager extends MiniPlugin event.setDamage(damage); } - private LivingEntity GetDamageeEntity(EntityDamageEvent event) + public LivingEntity GetDamageeEntity(EntityDamageEvent event) { if (event.getEntity() instanceof LivingEntity) return (LivingEntity)event.getEntity(); @@ -677,7 +680,7 @@ public class DamageManager extends MiniPlugin return null; } - private Projectile GetProjectile(EntityDamageEvent event) + public Projectile GetProjectile(EntityDamageEvent event) { if (!(event instanceof EntityDamageByEntityEvent)) return null; diff --git a/Plugins/Mineplex.ServerData/pom.xml b/Plugins/Mineplex.ServerData/pom.xml index b7e313ba5..b89ca0d8f 100644 --- a/Plugins/Mineplex.ServerData/pom.xml +++ b/Plugins/Mineplex.ServerData/pom.xml @@ -20,5 +20,10 @@ redis.clients jedis + + org.apache.commons + commons-dbcp2 + 2.0.1 + diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/DBPool.java similarity index 90% rename from Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java rename to Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/DBPool.java index 06495ff54..d7c85e11a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/DBPool.java @@ -1,4 +1,4 @@ -package mineplex.core.database; +package mineplex.serverdata.database; import javax.sql.DataSource; @@ -6,15 +6,10 @@ import java.io.File; import java.nio.charset.Charset; import java.nio.file.Files; import java.sql.Connection; -import java.util.ArrayList; import java.util.List; import org.apache.commons.dbcp2.BasicDataSource; -import mineplex.serverdata.redis.RedisConfig; -import mineplex.serverdata.servers.ConnectionData; -import mineplex.serverdata.servers.ConnectionData.ConnectionType; - public final class DBPool { private static DataSource ACCOUNT; @@ -110,7 +105,7 @@ public final class DBPool String userName = args[2]; String password = args[3]; - System.out.println(dbSource + " " + dbHost + " " + userName + " " + password); + // System.out.println(dbSource + " " + dbHost + " " + userName + " " + password); if (dbSource.toUpperCase().equalsIgnoreCase("ACCOUNT")) ACCOUNT = openDataSource("jdbc:mysql://" + dbHost, userName, password); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/DatabaseRunnable.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/DatabaseRunnable.java similarity index 90% rename from Plugins/Mineplex.Core/src/mineplex/core/database/DatabaseRunnable.java rename to Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/DatabaseRunnable.java index f5d1899cd..4817a9dc4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/DatabaseRunnable.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/DatabaseRunnable.java @@ -1,4 +1,4 @@ -package mineplex.core.database; +package mineplex.serverdata.database; public class DatabaseRunnable { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/RepositoryBase.java similarity index 55% rename from Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java rename to Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/RepositoryBase.java index 55acc83ed..daa668281 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/RepositoryBase.java @@ -1,57 +1,31 @@ -package mineplex.core.database; +package mineplex.serverdata.database; -import java.sql.CallableStatement; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import java.util.Iterator; import javax.sql.DataSource; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.database.column.Column; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import org.jooq.DSLContext; -import org.jooq.SQLDialect; -import org.jooq.impl.DSL; +import mineplex.serverdata.database.column.Column; -import org.bukkit.Bukkit; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.plugin.java.JavaPlugin; - -public abstract class RepositoryBase implements Listener +public abstract class RepositoryBase { - // Queue for failed processes - private static Object _queueLock = new Object(); - private NautHashMap _failedQueue = new NautHashMap(); - private DataSource _dataSource; // Connection pool - protected JavaPlugin Plugin; // Plugin responsible for this repository - + /** * Constructor - * @param plugin - the {@link JavaPlugin} module responsible for this repository. * @param dataSource - the {@link DataSource} responsible for providing the connection pool to this repository. */ - public RepositoryBase(JavaPlugin plugin, DataSource dataSource) + public RepositoryBase(DataSource dataSource) { - Plugin = plugin; _dataSource = dataSource; - Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() - { - public void run() - { - initialize(); - update(); - } - }); - - plugin.getServer().getPluginManager().registerEvents(this, plugin); + new Thread(() -> { + initialize(); + update(); + }).start(); } protected abstract void initialize(); @@ -66,11 +40,6 @@ public abstract class RepositoryBase implements Listener return _dataSource; } - protected DSLContext jooq() - { - return DSL.using(DBPool.getAccount(), SQLDialect.MYSQL); - } - /** * Requirements: {@link Connection}s must be closed after usage so they may be returned to the pool! * @see Connection#close() @@ -178,58 +147,4 @@ public abstract class RepositoryBase implements Listener exception.printStackTrace(); } } - - protected void handleDatabaseCall(final DatabaseRunnable databaseRunnable, final String errorMessage) - { - Thread asyncThread = new Thread(new Runnable() - { - public void run() - { - try - { - databaseRunnable.run(); - } - catch (Exception exception) - { - processFailedDatabaseCall(databaseRunnable, exception.getMessage(), errorMessage); - } - } - }); - - asyncThread.start(); - } - - protected void processFailedDatabaseCall(DatabaseRunnable databaseRunnable, String errorPreMessage, String runnableMessage) - { - if (databaseRunnable.getFailedCounts() < 4) - { - databaseRunnable.incrementFailCount(); - - synchronized (_queueLock) - { - _failedQueue.put(databaseRunnable, runnableMessage); - } - } - } - - @EventHandler - public void processDatabaseQueue(UpdateEvent event) - { - if (event.getType() != UpdateType.MIN_01) - return; - - processFailedQueue(); - } - - private void processFailedQueue() - { - synchronized (_queueLock) - { - for (Iterator runnablesIterator = _failedQueue.keySet().iterator(); runnablesIterator.hasNext();) - { - DatabaseRunnable databaseRunnable = runnablesIterator.next(); - handleDatabaseCall(databaseRunnable, _failedQueue.get(databaseRunnable)); - } - } - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/ResultSetCallable.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/ResultSetCallable.java similarity index 81% rename from Plugins/Mineplex.Core/src/mineplex/core/database/ResultSetCallable.java rename to Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/ResultSetCallable.java index 2972d5f4a..adac7876d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/ResultSetCallable.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/ResultSetCallable.java @@ -1,4 +1,4 @@ -package mineplex.core.database; +package mineplex.serverdata.database; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/column/Column.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/Column.java similarity index 92% rename from Plugins/Mineplex.Core/src/mineplex/core/database/column/Column.java rename to Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/Column.java index d73d6da05..939e29a83 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/column/Column.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/Column.java @@ -1,4 +1,4 @@ -package mineplex.core.database.column; +package mineplex.serverdata.database.column; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnBoolean.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnBoolean.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnBoolean.java rename to Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnBoolean.java index a7da34f61..4eb6a48c2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnBoolean.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnBoolean.java @@ -1,4 +1,4 @@ -package mineplex.core.database.column; +package mineplex.serverdata.database.column; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnByte.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnByte.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnByte.java rename to Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnByte.java index 40464a318..9a92bdb38 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnByte.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnByte.java @@ -1,4 +1,4 @@ -package mineplex.core.database.column; +package mineplex.serverdata.database.column; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnDouble.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnDouble.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnDouble.java rename to Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnDouble.java index 1163df926..2c7fe76c2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnDouble.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnDouble.java @@ -1,4 +1,4 @@ -package mineplex.core.database.column; +package mineplex.serverdata.database.column; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnInt.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnInt.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnInt.java rename to Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnInt.java index 25ed6a705..348aeb1dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnInt.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnInt.java @@ -1,4 +1,4 @@ -package mineplex.core.database.column; +package mineplex.serverdata.database.column; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnLong.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnLong.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnLong.java rename to Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnLong.java index d8c8815b5..d3eec3a95 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnLong.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnLong.java @@ -1,4 +1,4 @@ -package mineplex.core.database.column; +package mineplex.serverdata.database.column; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnTimestamp.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnTimestamp.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnTimestamp.java rename to Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnTimestamp.java index 1efacd628..6ce17f633 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnTimestamp.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnTimestamp.java @@ -1,4 +1,4 @@ -package mineplex.core.database.column; +package mineplex.serverdata.database.column; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnVarChar.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnVarChar.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnVarChar.java rename to Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnVarChar.java index da5c484c1..a60b3b19d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/column/ColumnVarChar.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/column/ColumnVarChar.java @@ -1,4 +1,4 @@ -package mineplex.core.database.column; +package mineplex.serverdata.database.column; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/StatusHistoryRepository.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/StatusHistoryRepository.java index a85d42848..8f4566b0f 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/StatusHistoryRepository.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/StatusHistoryRepository.java @@ -1,7 +1,6 @@ package mineplex.servermonitor; import java.sql.Connection; -import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.ArrayList; @@ -14,15 +13,13 @@ import mineplex.serverdata.data.BungeeServer; import mineplex.serverdata.data.DataRepository; import mineplex.serverdata.data.DedicatedServer; import mineplex.serverdata.data.ServerGroup; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.redis.RedisDataRepository; import mineplex.serverdata.servers.ServerManager; -public class StatusHistoryRepository +public class StatusHistoryRepository extends RepositoryBase { - private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/ServerStats"; - private String _userName = "root"; - private String _password = "tAbechAk3wR7tuTh"; - private static String CREATE_GROUP_TABLE = "CREATE TABLE IF NOT EXISTS ServerGroupStats (id INT NOT NULL AUTO_INCREMENT, serverGroup VARCHAR(100), updated LONG, players INT, maxPlayers INT, totalNetworkCpuUsage DOUBLE(4,2), totalNetworkRamUsage DOUBLE(4,2), totalCpu MEDIUMINT, totalRam MEDIUMINT, US BOOLEAN NOT NULL DEFAULT '1', PRIMARY KEY (id));"; private static String CREATE_DEDICATED_TABLE = "CREATE TABLE IF NOT EXISTS DedicatedServerStats (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(100), address VARCHAR(25), updated LONG, cpu TINYINT, ram MEDIUMINT, usedCpuPercent DOUBLE(4,2), usedRamPercent DOUBLE(4,2), US BOOLEAN NOT NULL DEFAULT '1', PRIMARY KEY (id));"; private static String CREATE_BUNGEE_TABLE = "CREATE TABLE IF NOT EXISTS BungeeStats (id INT NOT NULL AUTO_INCREMENT, address VARCHAR(25), updated LONG, players INT, maxPlayers INT, alive BOOLEAN NOT NULL, online BOOLEAN NOT NULL, US BOOLEAN NOT NULL DEFAULT '1', PRIMARY KEY (id));"; @@ -33,38 +30,33 @@ public class StatusHistoryRepository private static String INSERT_BUNGEE_STATS = "INSERT INTO BungeeStats (address, updated, players, maxPlayers, alive, online, US) VALUES (?, now(), ?, ?, ?, ?, ?);"; private static String INSERT_NETWORK_STATS = "INSERT INTO NetworkStats (updated, players, totalNetworkCpuUsage, totalNetworkRamUsage, totalCpu, totalRam, US) VALUES (now(), ?, ?, ?, ?, ?, ?);"; - private static Connection _connection; - private static DataRepository _repository; public StatusHistoryRepository() { + super(DBPool.getStats()); + PreparedStatement preparedStatement = null; - - try + + try(Connection connection = getConnection()) { - Class.forName("com.mysql.jdbc.Driver"); - - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - // Create table - preparedStatement = _connection.prepareStatement(CREATE_GROUP_TABLE); + preparedStatement = connection.prepareStatement(CREATE_GROUP_TABLE); preparedStatement.execute(); preparedStatement.close(); // Create table - preparedStatement = _connection.prepareStatement(CREATE_DEDICATED_TABLE); + preparedStatement = connection.prepareStatement(CREATE_DEDICATED_TABLE); preparedStatement.execute(); preparedStatement.close(); // Create table - preparedStatement = _connection.prepareStatement(CREATE_BUNGEE_TABLE); + preparedStatement = connection.prepareStatement(CREATE_BUNGEE_TABLE); preparedStatement.execute(); preparedStatement.close(); // Create table - preparedStatement = _connection.prepareStatement(CREATE_NETWORKSTATS_TABLE); + preparedStatement = connection.prepareStatement(CREATE_NETWORKSTATS_TABLE); preparedStatement.execute(); preparedStatement.close(); @@ -95,12 +87,9 @@ public class StatusHistoryRepository { PreparedStatement preparedStatement = null; - try + try(Connection connection = getConnection()) { - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - - preparedStatement = _connection.prepareStatement(INSERT_SERVERGROUP_STATS); + preparedStatement = connection.prepareStatement(INSERT_SERVERGROUP_STATS); for (ServerGroup serverGroup : collection) { @@ -144,12 +133,9 @@ public class StatusHistoryRepository { PreparedStatement preparedStatement = null; - try + try(Connection connection = getConnection()) { - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - - preparedStatement = _connection.prepareStatement(INSERT_DEDICATEDSERVER_STATS); + preparedStatement = connection.prepareStatement(INSERT_DEDICATEDSERVER_STATS); for (DedicatedServer dedicatedServer : dedicatedServers) { @@ -204,12 +190,9 @@ public class StatusHistoryRepository PreparedStatement preparedStatement = null; - try + try(Connection connection = getConnection()) { - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - - preparedStatement = _connection.prepareStatement(INSERT_BUNGEE_STATS); + preparedStatement = connection.prepareStatement(INSERT_BUNGEE_STATS); for (BungeeServer bungeeStatusData : bungeeServers) { @@ -246,12 +229,9 @@ public class StatusHistoryRepository preparedStatement = null; - try + try(Connection connection = getConnection()) { - if (_connection == null || _connection.isClosed()) - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - - preparedStatement = _connection.prepareStatement(INSERT_NETWORK_STATS); + preparedStatement = connection.prepareStatement(INSERT_NETWORK_STATS); preparedStatement.setInt(1, totalPlayers); preparedStatement.setDouble(2, usedCpuPercent); preparedStatement.setDouble(3, usedRamPercent); @@ -280,4 +260,16 @@ public class StatusHistoryRepository } } } + + @Override + protected void initialize() + { + + } + + @Override + protected void update() + { + + } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 1f12a4982..58e91b517 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -106,6 +106,7 @@ public class CustomerSupport extends MiniPlugin int ancientChestsReceived = 0; int mythicalChestsReceived = 0; int winterChestsReceived = 0; + int valentinesGiftsReceived = 0; for (CoinTransactionToken transaction : donor.getCoinTransactions()) { @@ -160,7 +161,18 @@ public class CustomerSupport extends MiniPlugin else if (transaction.SalesPackageName.split(" ").length == 2) winterChestsReceived += 1; } - + + } + if (transaction.SalesPackageName.startsWith("Valentines Gift")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 3) + valentinesGiftsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]); + else if (transaction.SalesPackageName.split(" ").length == 2) + valentinesGiftsReceived += 1; + } + } } @@ -169,6 +181,7 @@ public class CustomerSupport extends MiniPlugin caller.sendMessage(C.cBlue + "Ancient Chests Received : " + C.cYellow + ancientChestsReceived); caller.sendMessage(C.cBlue + "Mythical Chests Received : " + C.cYellow + mythicalChestsReceived); caller.sendMessage(C.cBlue + "Winter Chests Received : " + C.cYellow + winterChestsReceived); + caller.sendMessage(C.cBlue + "Valentines Gifts Received : " + C.cYellow + valentinesGiftsReceived); caller.sendMessage(C.cDGreen + C.Strike + "============================================="); _salesPackageManager.displaySalesPackages(caller, playerName); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java index 33b63e8a5..07fa746c1 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java @@ -5,14 +5,15 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.database.DBPool; -import mineplex.core.database.RepositoryBase; -import mineplex.core.database.ResultSetCallable; -import mineplex.core.database.column.ColumnVarChar; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnVarChar; -public class PasswordRepository extends RepositoryBase +public class PasswordRepository extends MinecraftRepository { private static String CREATE_SERVER_PASSWORD_TABLE = "CREATE TABLE IF NOT EXISTS serverPassword (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(100), password VARCHAR(100), PRIMARY KEY (id));"; private static String RETRIEVE_SERVER_PASSWORD = "SELECT password FROM serverPassword WHERE server = ?;"; diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index e3ef2eba3..debd2f265 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -21,12 +21,14 @@ import mineplex.staffServer.salespackage.salespackages.FrostLord; import mineplex.staffServer.salespackage.salespackages.GemHunter; import mineplex.staffServer.salespackage.salespackages.LifetimeHero; import mineplex.staffServer.salespackage.salespackages.LifetimeLegend; +import mineplex.staffServer.salespackage.salespackages.LifetimeTitan; import mineplex.staffServer.salespackage.salespackages.LifetimeUltra; import mineplex.staffServer.salespackage.salespackages.MonthlyHero; import mineplex.staffServer.salespackage.salespackages.MonthlyUltra; import mineplex.staffServer.salespackage.salespackages.MythicalChest; import mineplex.staffServer.salespackage.salespackages.SalesPackageBase; import mineplex.staffServer.salespackage.salespackages.OldChest; +import mineplex.staffServer.salespackage.salespackages.ValentinesGift; public class SalesPackageManager extends MiniPlugin { @@ -55,12 +57,14 @@ public class SalesPackageManager extends MiniPlugin AddSalesPackage(new LifetimeUltra(this)); AddSalesPackage(new LifetimeHero(this)); AddSalesPackage(new LifetimeLegend(this)); + AddSalesPackage(new LifetimeTitan(this)); AddSalesPackage(new GemHunter(this, 4)); AddSalesPackage(new GemHunter(this, 8)); AddSalesPackage(new ApplyKits(this)); AddSalesPackage(new OldChest(this)); AddSalesPackage(new AncientChest(this)); AddSalesPackage(new MythicalChest(this)); + AddSalesPackage(new ValentinesGift(this)); AddSalesPackage(new FrostLord(this)); AddSalesPackage(new EasterBunny(this)); } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java index ae576601c..21fad01ea 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java @@ -34,7 +34,7 @@ public class RankCommand extends CommandBase final Rank rankEnum = Rank.valueOf(rank); - if (rankEnum == Rank.HERO || rankEnum == Rank.ULTRA || rankEnum == Rank.LEGEND || rankEnum == Rank.ALL) + if (rankEnum == Rank.HERO || rankEnum == Rank.ULTRA || rankEnum == Rank.LEGEND || rankEnum == Rank.TITAN || rankEnum == Rank.ALL) { Plugin.getClientManager().SaveRank(playerName, uuid, mineplex.core.common.Rank.valueOf(rank), perm); caller.sendMessage(F.main(Plugin.getName(), playerName + "'s rank has been updated to " + rank + "!")); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/LifetimeTitan.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/LifetimeTitan.java new file mode 100644 index 000000000..c2fb03c1a --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/LifetimeTitan.java @@ -0,0 +1,23 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; + +import org.bukkit.entity.Player; + +public class LifetimeTitan extends SalesPackageBase +{ + public LifetimeTitan(SalesPackageManager manager) + { + super(manager, "Lifetime Titan"); + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales rank " + playerName + " TITAN true", " Lifetime Titan."); +// addButton(agent, "/sales item " + playerName + " 1 Molten Snake", "Gives Molten Snake Mount."); +// addButton(agent, "/sales item " + playerName + " 1 Elder Guardian Morph", "Gives Elder Guardian Morph."); +// addButton(agent, "/sales item " + playerName + " 1 Flame of the Titans", "Gives Titan Particle."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ValentinesGift.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ValentinesGift.java new file mode 100644 index 000000000..2e593d682 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/ValentinesGift.java @@ -0,0 +1,20 @@ +package mineplex.staffServer.salespackage.salespackages; + +import mineplex.staffServer.salespackage.SalesPackageManager; + +import org.bukkit.entity.Player; + +public class ValentinesGift extends SalesPackageBase +{ + public ValentinesGift(SalesPackageManager manager) + { + super(manager, "1 Valentines Gift"); + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Item Valentines Gift", "Give 1 Valentines Gift."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} diff --git a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java index 4817371cb..23801e02d 100644 --- a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java +++ b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java @@ -11,12 +11,11 @@ import com.vexsoftware.votifier.model.VotifierEvent; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.bonuses.BonusAmount; -import mineplex.core.bonuses.BonusClientData; import mineplex.core.bonuses.BonusManager; import mineplex.core.common.Pair; import mineplex.core.common.util.Callback; import mineplex.core.common.util.UUIDFetcher; -import mineplex.core.database.DBPool; +import mineplex.serverdata.database.DBPool; import mineplex.core.donation.DonationManager; import mineplex.core.bonuses.redis.VotifierCommand; import mineplex.database.Tables; 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 cf2b849dc..a54d7796b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -16,6 +16,7 @@ import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; +import mineplex.core.common.ConfigContainer; import mineplex.core.common.events.ServerShutdownEvent; import mineplex.core.common.util.FileUtil; import mineplex.core.common.util.UtilServer; @@ -27,7 +28,6 @@ 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; @@ -61,6 +61,7 @@ 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; +import org.bukkit.configuration.file.FileConfiguration; public class Arcade extends JavaPlugin { @@ -74,6 +75,17 @@ public class Arcade extends JavaPlugin private ArcadeManager _gameManager; private ServerConfiguration _serverConfiguration; + private final ConfigContainer _config = new ConfigContainer(this, "mineplex.yml"); + + @Override + public FileConfiguration getConfig() { + return _config.getConfig(); + } + + @Override + public void saveConfig() { + _config.saveConfig(); + } @Override public void onEnable() @@ -144,19 +156,18 @@ public class Arcade extends JavaPlugin InventoryManager inventoryManager = new InventoryManager(this, _clientManager); PetManager petManager = new PetManager(this, _clientManager, _donationManager, inventoryManager, disguiseManager, creature, blockRestore, webServerAddress); MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager); - GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager); + GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler); CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null); cosmeticManager.setInterfaceSlot(7); cosmeticManager.disableTeamArmor(); - GiveawayManager giveawayManager = new GiveawayManager(this, _clientManager, serverStatusManager); CustomDataManager customDataManager = new CustomDataManager(this, _clientManager); - new GlobalPacketManager(this, _clientManager, serverStatusManager, inventoryManager, _donationManager, petManager, statsManager, giveawayManager); + new GlobalPacketManager(this, _clientManager, serverStatusManager, inventoryManager, _donationManager, petManager, statsManager); //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, punish); + _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, customDataManager, punish); new MemoryFix(this); new CustomTagFix(this, packetHandler); 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 4e574f3cf..eadeb8bd7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -33,7 +33,6 @@ 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; import mineplex.core.itemstack.ItemStackFactory; @@ -49,6 +48,7 @@ import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardManager; import mineplex.core.reward.RewardRarity; import mineplex.core.reward.rewards.PetReward; import mineplex.core.stats.StatsManager; @@ -57,6 +57,7 @@ import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.timing.TimingManager; import mineplex.core.titangiveaway.TitanGiveawayManager; +import mineplex.core.valentines.ValentinesGiftManager; import mineplex.minecraft.game.classcombat.Class.ClassManager; import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -184,7 +185,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation private StatsManager _statsManager; private PartyManager _partyManager; private PreferencesManager _preferencesManager; - private GiveawayManager _giveawayManager; private ResourcePackManager _resourcePackManager; private CustomDataManager _customDataManager; private Punish _punishmentManager; @@ -212,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, Punish punish) + NpcManager npcManager, CustomDataManager customDataManager, Punish punish) { super("Game Manager", plugin); @@ -270,7 +270,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation _portal = portal; _petManager = petManager; _eventManager = new EventModule(this, getPlugin()); - _giveawayManager = giveawayManager; _resourcePackManager = new ResourcePackManager(plugin, portal); _customDataManager = customDataManager; @@ -298,6 +297,12 @@ public class ArcadeManager extends MiniPlugin implements IRelation _idleManager = new IdleManager(this); TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager); // new HolidayManager(this, titanGiveaway); + new ValentinesGiftManager(plugin, clientManager, new RewardManager(clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, statsManager, + 100, 250, + 500, 1000, + 4000, 6000, + 12000, 22000, + true, false), inventoryManager, _cosmeticManager.getGadgetManager(), statsManager); new GameTestingManager(this); new PlayerDisguiseManager(plugin, _clientManager); @@ -307,7 +312,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation new TeamArmorAddon(plugin, this); FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); - new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager, facebookManager); + new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager); //Champions Modules _energy = new Energy(plugin); @@ -449,11 +454,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _explosionManager; } - public GiveawayManager getGiveawayManager() - { - return _giveawayManager; - } - public Fire GetFire() { return _fire; @@ -861,6 +861,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation public void Clear(Player player) { + if (player.getGameMode() == GameMode.SPECTATOR) + player.setSpectatorTarget(null); + player.setGameMode(GameMode.SURVIVAL); player.setAllowFlight(false); player.setFlySpeed(0.1F); 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 58fe9a3a5..252d24a03 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -63,6 +63,7 @@ import nautilus.game.arcade.game.games.tug.Tug; import nautilus.game.arcade.game.games.turfforts.TurfForts; import nautilus.game.arcade.game.games.typewars.TypeWars; import nautilus.game.arcade.game.games.uhc.UHC; +import nautilus.game.arcade.game.games.valentines.Valentines; import nautilus.game.arcade.game.games.wither.WitherGame; import nautilus.game.arcade.game.games.wizards.Wizards; import nautilus.game.arcade.game.games.zombiesurvival.ZombieSurvival; @@ -137,6 +138,8 @@ public enum GameType BouncyBalls(BouncyBalls.class, GameDisplay.BouncyBalls), + Valentines(Valentines.class, GameDisplay.Valentines), + Event(EventGame.class, GameDisplay.Event, new GameType[]{ GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, GameType.Cards, GameType.CastleSiege, GameType.ChampionsDominate, GameType.ChampionsTDM, GameType.Christmas, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java index 3d5ca5cf0..6e029034f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java @@ -18,7 +18,7 @@ import nautilus.game.arcade.kit.Kit; public abstract class SoloGame extends Game { - private GameTeam _players; + protected GameTeam _players; public SoloGame(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc) { 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 fa198fe45..d19dc43e7 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 @@ -6,6 +6,46 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.UUID; + +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.BlockFace; +import org.bukkit.block.Chest; +import org.bukkit.craftbukkit.v1_8_R3.block.CraftBlock; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers; +import org.bukkit.entity.Chicken; +import org.bukkit.entity.Cow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Item; +import org.bukkit.entity.Pig; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.CraftingInventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.util.Vector; + import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -18,6 +58,7 @@ 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.UtilTextMiddle; @@ -51,41 +92,6 @@ 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; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.Chest; -import org.bukkit.entity.Chicken; -import org.bukkit.entity.Cow; -import org.bukkit.entity.Entity; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Item; -import org.bukkit.entity.Pig; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockFormEvent; -import org.bukkit.event.block.BlockFromToEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.EntitySpawnEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.inventory.PrepareItemCraftEvent; -import org.bukkit.event.player.PlayerBucketEmptyEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.inventory.CraftingInventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.util.Vector; public class Bridge extends TeamGame implements OreObsfucation { @@ -1332,6 +1338,12 @@ public class Bridge extends TeamGame implements OreObsfucation event.setCancelled(true); event.getBlock().setType(Material.AIR); + if (event.getBlock().getType() == Material.FURNACE || UtilItem.isOre(event.getBlock().getType())) // Can't be broken by fist + { + if (event.getPlayer().getItemInHand() == null || !CraftItemStack.asNMSCopy(event.getPlayer().getItemInHand()).b(CraftMagicNumbers.getBlock((CraftBlock) event.getBlock()))) + return; + } + Location loc = event.getBlock().getLocation().clone().add(.5, .5, .5); for (ItemStack item : drops) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java index b38a8f6af..31508193d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java @@ -211,7 +211,7 @@ public class EventModule extends MiniPlugin @EventHandler(priority = EventPriority.LOWEST) public void commandHandler(PlayerCommandPreprocessEvent event) { - if (!Manager.GetGame().InProgress()) + if (Manager.GetGame() == null || !Manager.GetGame().InProgress()) return; if (!event.getMessage().toLowerCase().startsWith("/e ")) @@ -1837,7 +1837,7 @@ public class EventModule extends MiniPlugin @EventHandler public void StackEntity(PlayerInteractEntityEvent event) { - if (!Manager.GetGame().IsLive()) + if (Manager.GetGame() == null || !Manager.GetGame().IsLive()) return; if (event.getRightClicked().getVehicle() != null) 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 5f4d7b2b4..0d51c64a0 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 @@ -8,6 +8,7 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Effect; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -481,6 +482,10 @@ public class Paintball extends TeamGame } //Settings + if (player.getGameMode() == GameMode.SPECTATOR) + player.setSpectatorTarget(null); + + player.setGameMode(GameMode.SURVIVAL); player.setAllowFlight(false); player.setFlying(false); ((CraftPlayer)player).getHandle().spectating = false; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/data/TNTGenerator.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/data/TNTGenerator.java index e13c98f0f..ebff5b18f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/data/TNTGenerator.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/data/TNTGenerator.java @@ -79,10 +79,7 @@ public class TNTGenerator public void pickup(Player player, Item item) { if (_ent == null) - { - _ent.remove(); return; - } if (!_ent.equals(item)) return; 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 index 34a82c937..ea2b2960e 100644 --- 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 @@ -5,6 +5,52 @@ import java.util.HashSet; import java.util.List; import java.util.Map.Entry; +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.inventory.InventoryPickupItemEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerBucketFillEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleFlightEvent; +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; + import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -45,52 +91,8 @@ import nautilus.game.arcade.game.games.speedbuilders.stattrackers.SpeediestBuild 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"; @@ -147,7 +149,7 @@ public class SpeedBuilders extends SoloGame private RecreationData _lastRecreationTarget; private double _standMoveProgress; private Location _standStart; - + private BuildData _nextBuild; public SpeedBuilders(ArcadeManager manager) @@ -431,10 +433,10 @@ public class SpeedBuilders extends SoloGame EndCheck(); } - @EventHandler(priority = EventPriority.MONITOR) - public void teamGen(GameStateChangeEvent event) + @EventHandler(priority = EventPriority.LOWEST) + public void onPrepare(GameStateChangeEvent event) { - if (event.GetState() != GameState.Live) + if (event.GetState() != GameState.Prepare) return; //Add 1 spawn so it doesn't freak out @@ -444,13 +446,6 @@ public class SpeedBuilders extends SoloGame 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 @@ -461,11 +456,13 @@ public class SpeedBuilders extends SoloGame { if (i >= WorldData.GetDataLocs("YELLOW").size()) { - Manager.addSpectator(players.get(i), true); GetTeamList().get(0).RemovePlayer(players.get(i)); + Manager.addSpectator(players.get(i), true); } } } + + @EventHandler public void onLive(GameStateChangeEvent event) @@ -473,7 +470,7 @@ public class SpeedBuilders extends SoloGame if (!IsLive()) return; - if (WorldData.GetDataLocs("YELLOW").size() < GetPlayers(true).size()) + if (WorldData.GetDataLocs("YELLOW").size() < GetTeamList().get(0).GetPlayers(true).size()) { Announce(C.Bold + "Too many players..."); SetState(GameState.End); @@ -491,7 +488,7 @@ public class SpeedBuilders extends SoloGame HashSet usedBuildLocs = new HashSet(); - for (Player player : GetPlayers(true)) + for (Player player : GetTeamList().get(0).GetPlayers(true)) { Location buildLoc = UtilAlg.findClosest(player.getLocation(), WorldData.GetDataLocs("YELLOW")); Location spawnLoc = UtilAlg.findClosest(buildLoc, GetTeamList().get(0).GetSpawns()); @@ -648,7 +645,7 @@ public class SpeedBuilders extends SoloGame _perfectBuild.put(player, System.currentTimeMillis()); - if (_perfectBuild.size() == GetTeamList().get(0).GetPlayers(false).size()) + if (_perfectBuild.size() == _buildRecreations.size()) { // Everyone has a perfect build _allPerfect = true; @@ -734,12 +731,20 @@ public class SpeedBuilders extends SoloGame { for (RecreationData recreation : _buildRecreations.values()) { - Vector vec = player.getLocation().getDirection().multiply(-1); + Vector vec = UtilAlg.getTrajectory(recreation.getMidpoint(), player.getLocation()); if (UtilMath.offsetSquared(player.getLocation(), recreation.getMidpoint()) < 64) { + Location tpLoc = recreation.getMidpoint().add(vec.clone().multiply(8)); + tpLoc.setDirection(player.getLocation().getDirection()); + + //First tp out this combats hacked clients with anti-KB + player.teleport(tpLoc); + + //Then apply velocity as normal + UtilAction.velocity(player, vec, 1.8, false, 0, 0.4, vec.length(), false); + player.playSound(player.getEyeLocation(), Sound.NOTE_PLING, 10F, 0.5F); - UtilAction.velocity(player, vec, 1.6, false, 0, 0.4, vec.length(), false); } } } @@ -1219,9 +1224,34 @@ public class SpeedBuilders extends SoloGame if (!_buildRecreations.get(player).inBuildArea(event.getEntity().getLocation())) return; + boolean hasMobType = false; + + for (MobData mobData : _currentBuild.Mobs) + { + if (mobData.EntityType == event.getEntityType()) + { + hasMobType = true; + + break; + } + } + + if (!hasMobType) + return; + _buildRecreations.get(player).addToDemolition(event.getEntity()); } + @EventHandler + public void stopBabyEgg(PlayerInteractEntityEvent event) + { + if (!IsLive()) + return; + + if (event.getPlayer().getItemInHand().getType() == Material.MONSTER_EGG) + event.setCancelled(true); + } + @EventHandler public void updateDemolitionBlocks(UpdateEvent event) { @@ -1393,6 +1423,9 @@ public class SpeedBuilders extends SoloGame if (!IsLive()) return; + // Falling blocks disappear for some reason so we update to make it reappear + event.getBlock().getState().update(true, false); + event.setCancelled(true); } @@ -1453,6 +1486,18 @@ public class SpeedBuilders extends SoloGame @EventHandler public void stopPhysics(BlockPhysicsEvent event) + { + if (!IsLive()) + return; + + if (event.getBlock().isLiquid()) + return; + + event.setCancelled(true); + } + + @EventHandler + public void stopInventoryPickup(InventoryPickupItemEvent event) { if (!IsLive()) return; @@ -1567,34 +1612,6 @@ public class SpeedBuilders extends SoloGame 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) { @@ -1637,6 +1654,37 @@ public class SpeedBuilders extends SoloGame } } + @EventHandler + public void moveSetFlight(PlayerMoveEvent event) + { + if (!IsLive()) + return; + + if (_state != SpeedBuildersState.BUILDING) + return; + + if (!GetTeamList().get(0).HasPlayer(event.getPlayer())) + return; + + if (UtilEnt.isGrounded(event.getPlayer()) && !event.getPlayer().isFlying()) + event.getPlayer().setAllowFlight(true); + } + + @EventHandler + public void flightToggleJump(PlayerToggleFlightEvent event) + { + if (!GetTeamList().get(0).HasPlayer(event.getPlayer())) + return; + + event.setCancelled(true); + + event.getPlayer().setAllowFlight(false); + + event.getPlayer().playSound(event.getPlayer().getEyeLocation(), Sound.GHAST_FIREBALL, 1f, 1f); + + UtilAction.velocity(event.getPlayer(), new Vector(0, 1, 0)); + } + @Override public void EndCheck() { @@ -1662,7 +1710,17 @@ public class SpeedBuilders extends SoloGame if (places.size() >= 3) AddGems(places.get(2), 10, "3rd Place", false, false); - for (Player player : GetPlayers(false)) + ArrayList participants = new ArrayList(); + + ArrayList guardians = GetTeamList().get(1).GetPlayers(false); + + participants.addAll(playersTeam.GetPlayers(true)); + + guardians.retainAll(playersTeam.GetPlacements(true)); + + participants.addAll(guardians); + + for (Player player : participants) if (player.isOnline()) AddGems(player, 10, "Participation", false, false); @@ -1734,7 +1792,7 @@ public class SpeedBuilders extends SoloGame for (Player player : playersDead) { - Scoreboard.Write(C.cGray + player.getName()); + Scoreboard.Write(C.cDGray + player.getName()); } Scoreboard.Draw(); 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 index f53f653c0..0f8804aac 100644 --- 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 @@ -2,14 +2,6 @@ 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; @@ -17,11 +9,19 @@ 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; +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.common.util.UtilTime; +import mineplex.core.hologram.Hologram; + public class DemolitionData { @@ -170,9 +170,7 @@ public class DemolitionData 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()); + UtilInv.insert(Parent.Player, itemStack); } //Destroy the other part @@ -210,9 +208,7 @@ public class DemolitionData { 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()); + UtilInv.insert(Parent.Player, spawnEgg); entity.remove(); 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 index 11aaac85a..268434338 100644 --- 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 @@ -297,10 +297,10 @@ public class RecreationData } //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)) + if (currentBlock.getType() == Material.ENDER_PORTAL_FRAME && expectedState.getType() == Material.ENDER_PORTAL_FRAME) { - score++; - continue; + if ((currentBlock.getData() & 0x4) == (expectedState.getRawData() & 0x4)) + score++; } //Sapling growth fix @@ -317,6 +317,13 @@ public class RecreationData score++; } + //Fix for anvil facing direction + if (expectedState.getType() == Material.ANVIL && currentBlock.getType() == Material.ANVIL) + { + if (currentBlock.getData() / 4 == expectedState.getRawData() / 4 && currentBlock.getData() % 2 == expectedState.getRawData() % 2) + score++; + } + //Fix for corner stair shape if (currentBlock.getState().getData() instanceof Stairs && expectedState.getData() instanceof Stairs) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/ValItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/ValItem.java new file mode 100644 index 000000000..6dc6e4bd0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/ValItem.java @@ -0,0 +1,76 @@ +package nautilus.game.arcade.game.games.valentines; + +import org.bukkit.Material; + +public enum ValItem +{ + FLOWER1("Red Rose", + "She will love this bouquet of roses!", + Material.RED_ROSE, 0), + + FLOWER2("Dandelion", + "I hope she's not allergic to these!", + Material.YELLOW_FLOWER, 0), + + FLOWER3("Blue Orchid", + "Thank you! These are her favourites!", + Material.RED_ROSE, 1), + + WINE("Blue Wine", + "This will go great with our steak dinner!", + Material.POTION, 0), + + GRASS("Organic Free Range Grass", + "Yum! This is much tastier than caged grass!", + Material.LONG_GRASS, 1), + + DIAMONDS("Diamond Earings", + "I saved up for months for this gift!", + Material.DIAMOND, 0), + + EMERALDS("Cold Hard Cash", + "They say love don't cost a thing. That's a lie!", + Material.EMERALD, 0), + + BOOK("Love Poems", + "I will use impress her with poetry!", + Material.BOOK, 0), + + WATCH("Fancy Pocket Watch", + "This Moolex Watch sure looks good on me!", + Material.WATCH, 0); + + + private String _title; + private String _endText; + private Material _item; + private byte _itemByte; + + ValItem(String title, String endText, Material item, int data) + { + _title = title; + _item = item; + _endText = endText; + _itemByte = (byte)data; + } + + public String getTitle() + { + return _title; + } + + public Material getMaterial() + { + return _item; + } + + public String getEndText() + { + return _endText; + } + + public byte getData() + { + return _itemByte; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java new file mode 100644 index 000000000..e902d5f44 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java @@ -0,0 +1,850 @@ +package nautilus.game.arcade.game.games.valentines; + +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.stream.Collectors; + +import org.bukkit.EntityEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Cow; +import org.bukkit.entity.Fish; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Pig; +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.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.MapUtil; +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.UtilMath; +import mineplex.core.common.util.UtilParticle; +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.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.noteblock.INoteVerifier; +import mineplex.core.noteblock.NBSReader; +import mineplex.core.noteblock.NotePlayer; +import mineplex.core.noteblock.NoteSong; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.christmas.ChristmasAudio; +import nautilus.game.arcade.game.games.gladiators.tutorial.TutorialGladiators; +import nautilus.game.arcade.game.games.valentines.kit.KitMasterOfLove; +import nautilus.game.arcade.game.games.valentines.tutorial.TutorialValentines; +import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; +import nautilus.game.arcade.kit.Kit; + +public class Valentines extends SoloGame +{ + private String _cowName = "Calvin the Cow"; + + private Cow _cow; + + private NotePlayer _music; + private NoteSong[] _songs; + private NoteSong _finalSong; + + private int _playersOutPerRound = 1; + + + + private HashSet _blocks = new HashSet(); + private int _blockMapHeight = 0; + + private int _round = 0; + private long _roundTime = 0; + private long _roundTimeLimit = 60000; + + private int _roundState = 0; + //1 = Playing + //2 = Between Rounds + + private boolean _finalRound = false; + + private ValItem _item = null; + + private ArrayList _pigSpawns = null; + private HashMap _pigs = new HashMap(); + private HashSet _pigsDead = new HashSet(); + + private ArrayList _hasItem = new ArrayList(); + private ArrayList _completedRound = new ArrayList(); + + private HashSet _unusedGifts = new HashSet(); + + public Valentines(ArcadeManager manager) + { + super(manager, GameType.Valentines, + + new Kit[] + { + new KitMasterOfLove(manager), + }, + + new String[] + { + "Calvin the Cow has a Valentines Date,", + "but he was robbed by the nasty pigs!", + "Recover his items, and save the day!", + "", + "Slowest players are eliminated!" + }); + + this.DamageTeamSelf = true; + this.HungerSet = 20; + this.HealthSet = 20; + + EnableTutorials = true; + + + try + { + _songs = new NoteSong[2]; + _songs[0] = NBSReader.loadSong("../../update/songs/tetris.nbs"); + _songs[1] = NBSReader.loadSong("../../update/songs/gangnam.nbs"); + _finalSong = NBSReader.loadSong("../../update/songs/popcorn.nbs"); + } + catch (FileNotFoundException e) + { + e.printStackTrace(); + } + } + + @Override + public void ParseData() + { + _pigSpawns = WorldData.GetDataLocs("YELLOW"); + + //Scan Map + for (Block block : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("GRAY").get(0), WorldData.GetDataLocs("GRAY").get(1))) + { + if (block.getType() != Material.AIR) + _blocks.add(block); + + if (UtilBlock.solid(block)) + { + if (block.getY() > _blockMapHeight) + _blockMapHeight = block.getY(); + } + } + + System.out.println("Scanned " + _blocks.size() + " Arena Blocks"); + } + + @EventHandler + public void stateChanges(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Prepare) + { + _playersOutPerRound = Math.max(1, (int)(GetPlayers(true).size()/8d)); + + CreatureAllowOverride = true; + _cow = GetSpectatorLocation().getWorld().spawn(GetSpectatorLocation(), Cow.class); + _cow.setCustomName(C.cGreen + C.Bold + _cowName); + _cow.setCustomNameVisible(true); + + UtilEnt.Vegetate(_cow); + UtilEnt.ghost(_cow, true, false); + CreatureAllowOverride = false; + } + if (event.GetState() == GameState.End || event.GetState() == GameState.Dead) + _music.cancel(); + } + + @Override + public void addTutorials() + { + GetTeamList().get(0).setTutorial(new TutorialValentines(this, Manager)); + } + + @EventHandler + public void knockback(CustomDamageEvent event) + { + if (event.GetDamageePlayer() != null) + { + if (event.GetCause() == DamageCause.ENTITY_ATTACK) + event.AddKnockback("Hit Reversal", -1); + } + } + + @EventHandler + public void knockbackRod(EntityDamageEvent event) + { + if (!(event.getEntity() instanceof Player)) + return; + + Player player = ((Player) event.getEntity()); + Projectile projectile = Manager.GetDamage().GetProjectile(event); + + if (!(projectile instanceof Fish)) + return; + +// LivingEntity damagee = Manager.GetDamage().GetDamageeEntity(event); +// LivingEntity damager = UtilEvent.GetDamagerEntity(event, true); + + if (player.getVehicle() != null) + { + UtilTextMiddle.display("", C.cRed + "You were knocked off the pig!", player); + player.getVehicle().eject(); + } + + event.setCancelled(true); + +// damagee.playEffect(EntityEffect.HURT); +// +// UtilAction.velocity(damagee, UtilAlg.getTrajectory(damagee, damager), 0.2, false, 0, 0.1, 1, true); + + projectile.remove(); + } + + @EventHandler + public void grabDamage(CustomDamageEvent event) + { + if (_finalRound) + return; + + if (event.GetDamagerPlayer(false) == null) + return; + + if (_finalRound) + { + event.GetDamageeEntity().eject(); + event.GetDamageeEntity().leaveVehicle(); + } + + if (event.GetDamageeEntity() instanceof Pig) + { + grabItem(event.GetDamagerPlayer(false), (Pig)event.GetDamageeEntity()); + } + + if (!event.IsCancelled()) + { + event.SetCancelled("Pig Cancel"); + + event.GetDamageeEntity().playEffect(EntityEffect.HURT); + } + } + + private void grabItem(Player player, Pig pig) + { + if (!IsAlive(player)) + return; + + if (_hasItem.contains(player) || _completedRound.contains(player)) + return; + + if (!_pigs.containsKey(pig)) + return; + + _pigs.remove(pig); + + pig.damage(9999); +// pig.playEffect(EntityEffect.DEATH); +// _pigsDead.add(pig); + + //Remove Item from Pig + if (pig.getPassenger() != null) + pig.getPassenger().remove(); + + //Give Item to Player + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(_item.getMaterial(), _item.getData())); + + _hasItem.add(player); + + //Effects + player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, 1f); + player.getWorld().playSound(pig.getLocation(), Sound.PIG_DEATH, 1f, 1f); + + //Inform + UtilTextMiddle.display(C.cGreen + C.Bold + "Success", "Take " + _item.getTitle() + " back to Calvin!", 0, 80, 20, player); + + if (_pigs.size() > 0) + UtilTextBottom.display(C.Bold + _pigs.size() + " Items Left", UtilServer.getPlayers()); + } + + @EventHandler + public void returnDamage(CustomDamageEvent event) + { + if (event.GetDamagerPlayer(false) == null) + return; + + if (event.GetDamageeEntity() instanceof Cow) + { + returnItem(event.GetDamagerPlayer(false), (Cow)event.GetDamageeEntity()); + + event.SetCancelled("Cow Damage"); + } + } + + @EventHandler + public void returnInteract(PlayerInteractEntityEvent event) + { + if (event.getRightClicked() instanceof Cow) + { + returnItem(event.getPlayer(), (Cow)event.getRightClicked()); + } + } + + private void returnItem(Player player, Cow cow) + { + if (!IsAlive(player)) + return; + + if (!_hasItem.remove(player) && player.getVehicle() == null) + return; + + + //Remove Item to Player + if (!_finalRound) + { + player.getInventory().remove(_item.getMaterial()); + } + else + { + _pigs.clear(); + } + + _completedRound.add(player); + + //Effects + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); + player.getWorld().playSound(cow.getLocation(), Sound.COW_IDLE, 2f, 1f); + + UtilParticle.PlayParticle(ParticleType.HEART, _cow.getLocation().add(0, 0.5, 0), 1f, 1f, 1f, 0, 10, ViewDist.NORMAL, UtilServer.getPlayers()); + + //Inform + UtilTextMiddle.display(C.cGreen + C.Bold + _cowName, _item.getEndText(), 0, 80, 20, player); + + if (_pigs.size() > 0) + UtilTextBottom.display(C.Bold + _pigs.size() + " Items Left", UtilServer.getPlayers()); + + } + + public double getRadius() + { + return 24 + (GetPlayers(true).size() * 0.5d); + } + + //@EventHandler + public void arenaShrinkUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + double radius = getRadius(); + + Block bestBlock = null; + double bestDist = 0; + + for (Block block : _blocks) + { + double dist = UtilMath.offset2d(GetSpectatorLocation(), block.getLocation().add(0.5, 0.5, 0.5)); + + if (dist < radius) + continue; + + if (bestBlock == null || dist > bestDist) + { + bestBlock = block; + bestDist = dist; + } + } + + //Shuffle Down + while (bestBlock.getRelative(BlockFace.DOWN).getType() != Material.AIR) + bestBlock = bestBlock.getRelative(BlockFace.DOWN); + + _blocks.remove(bestBlock); + + if (bestBlock.getType() != Material.AIR) + MapUtil.QuickChangeBlockAt(bestBlock.getLocation(), Material.AIR); + } + + @EventHandler + public void pigFall(EntityDamageEvent event) + { + if (event.getCause() == DamageCause.FALL) + event.setCancelled(true); + } + + public void pigSpawn() + { + CreatureAllowOverride = true; + + int toSpawn = Math.max(1, GetPlayers(true).size()-_playersOutPerRound); + + if (toSpawn == 1) + _finalRound = true; + + for (int i=0 ; i < toSpawn ; i++) + { + Location loc = UtilAlg.Random(_pigSpawns); + + Pig pig = loc.getWorld().spawn(loc, Pig.class); + _pigs.put(pig, pig.getLocation()); + + UtilEnt.Vegetate(pig); + + //Give Item + if (toSpawn > 1) + { + Item item = pig.getWorld().dropItem(pig.getLocation(),ItemStackFactory.Instance.CreateStack(_item.getMaterial(), _item.getData())); + + if (pig.getPassenger() != null) + pig.getPassenger().remove(); + + pig.setPassenger(item); + } + } + + CreatureAllowOverride = false; + } + + @EventHandler + public void pigUpdate(UpdateEvent event) + { + for (Pig pig : _pigs.keySet()) + { + //Fallen Off Island?! JUMP BACK! + Block block = pig.getLocation().getBlock(); + while (block.getType() == Material.AIR) + { + block = block.getRelative(BlockFace.DOWN); + } + if (block.isLiquid()) + { + UtilAction.velocity(pig, + UtilAlg.getTrajectory(pig.getLocation(), + GetSpectatorLocation().clone().add(Math.random() * 30 - 15, 0, Math.random() * 30 - 15)), + 2 + Math.random(), false, 0, 0.4, 10, true); + + pig.getWorld().playSound(pig.getLocation(), Sound.PIG_IDLE, 2f, 2f); + + continue; + } + + //Player Rider + if (_finalRound && pig.getPassenger() != null && pig.getPassenger() instanceof Player) + { + Location target = pig.getLocation(); + target.add(pig.getPassenger().getLocation().getDirection().multiply(5)); + + UtilEnt.CreatureMoveFast(pig, target, 1.3f); + + continue; + } + + Vector threat = new Vector(0,0,0); + + //waypoint + Location loc = _pigs.get(pig); + + //find new waypoint + if (UtilMath.offset2d(pig.getLocation(), loc) < 5 || targetAtEdge(loc)) + { + Location newLoc = getNewWaypoint(pig); + + if (newLoc != null) + { + loc.setX(newLoc.getX()); + loc.setZ(newLoc.getZ()); + } + } + + threat.add(UtilAlg.getTrajectory2d(pig.getLocation(), loc).multiply(0.4)); + + //run from players + double closestDist = 0; + HashMap ents = UtilEnt.getInRadius(pig.getLocation(), 12); + if (ents.size() > 0) + { + for (LivingEntity ent : ents.keySet()) + { + if (ent instanceof Player) + { + if (ent.equals(pig)) + continue; + + if (!IsAlive((Player)ent)) + continue; + + double score = ents.get(ent); + + //Add scaled threat! + threat.add(UtilAlg.getTrajectory2d(ent, pig).multiply(score)); + + if (score > closestDist) + closestDist = score; + } + if (ent instanceof Pig) + { + if (ents.get(ent) < 0.3) + { + threat.add(UtilAlg.getTrajectory2d(ent, pig).multiply(ents.get(ent) * 0.3)); + } + } + } + } + + threat.normalize(); + + //MOVE + Location target = pig.getLocation().add(threat.multiply(4)); + + //try to skate around edge + int attempts = 0; + while (targetAtEdge(target) && attempts < 10) + { + attempts++; + + target.add(UtilAlg.getTrajectory(target, GetSpectatorLocation())); + + //too cornered! jump back in + if (UtilMath.offset(pig.getLocation(), target) < 2) + { + UtilEnt.CreatureMoveFast(pig, pig.getLocation().add(UtilAlg.getTrajectory(pig.getLocation(), GetSpectatorLocation())), 2f); + + UtilAction.velocity(pig, + UtilAlg.getTrajectory(pig.getLocation(), + GetSpectatorLocation().clone().add(Math.random() * 30 - 15, 0, Math.random() * 30 - 15)), + 2 + Math.random(), false, 0, 0.4, 10, true); + + pig.getWorld().playSound(pig.getLocation(), Sound.PIG_IDLE, 2f, 2f); + } + } + + UtilEnt.CreatureMoveFast(pig, target, 1.3f + (float)(1f * closestDist)); + } + } + + private Location getNewWaypoint(Pig pig) + { + for (int i=0 ; i<50 ; i++) + { + Location loc = pig.getLocation(); + + loc.add(Math.random() * 50 - 25, 0, Math.random() * 50 - 25); + + if (!targetAtEdge(loc)) + return loc; + } + + return null; + } + + private boolean targetAtEdge(Location target) + { + Block block = target.getWorld().getBlockAt(target.getBlockX(), _blockMapHeight, target.getBlockZ()); + + for (int x=-1 ; x <= 1 ; x++) + for (int z=-1 ; z <= 1 ; z++) + { + if (block.getRelative(x, -1, z).getType() == Material.AIR) + return true; + } + + return false; + } + + @EventHandler + public void roundUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + if (_roundState == 0) + { + nextRound(); + } + + else if (_roundState == 1) + { + if (UtilTime.elapsed(_roundTime, _roundTimeLimit) || (_pigs.isEmpty() && _hasItem.isEmpty())) + { + /* + if (_completedRound.isEmpty()) + { + System.out.println("RoundUpdate:604"); + //Announce + AnnounceEnd(new ArrayList()); + + //End + SetState(GameState.End); + + return; + } + */ + + //Kill Failed Players + for (Player player : GetPlayers(true)) + { + if (!_completedRound.contains(player)) + { + UtilTextMiddle.display(C.cRed + C.Bold + "Game Over", "You failed to help Calvin", 0, 80, 20, player); + player.damage(9999); + } + } + + _roundState = 2; + _roundTime = System.currentTimeMillis(); + + + //Cull Excess Pigs + Iterator pigIter = _pigs.keySet().iterator(); + while (pigIter.hasNext()) + { + Pig pig = pigIter.next(); + + if (pig.getPassenger() != null) + pig.getPassenger().remove(); + + _pigsDead.add(pig); + pigIter.remove(); + } + + //Stop Music + _music.cancel(); + } + } + + else if (_roundState == 2 && UtilTime.elapsed(_roundTime, 5000)) + { + nextRound(); + } + } + + private void nextRound() + { + _round++; + + _roundState = 1; + _roundTime = System.currentTimeMillis(); + + _completedRound.clear(); + _hasItem.clear(); + + //Restock Items (only repeat items if required) + if (_unusedGifts.isEmpty()) + for (ValItem gift : ValItem.values()) + _unusedGifts.add(gift); + + //Set Item + _item = UtilAlg.Random(_unusedGifts); + _unusedGifts.remove(_item); + + //Delete Dead Pigs + for (Pig pig : _pigsDead) + pig.remove(); + _pigsDead.clear(); + + //Clean + for (Pig pig : _pigs.keySet()) + { + if (pig.getPassenger() != null) + pig.getPassenger().remove(); + + pig.remove(); + } + _pigs.clear(); + + //Restock Pigs + pigSpawn(); + + + NoteSong noteSong; + //Announce + if (_pigs.size() > 1) + { + UtilTextMiddle.display(C.cYellow + "Round " + _round, _item.getTitle(), 0, 80, 20); + noteSong = _songs[_round % _songs.length]; + } + else + { + UtilTextMiddle.display(C.cYellow + "Final Round", "Capture the Pig!", 0, 80, 20); + + for (Player player : GetPlayers(true)) + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE, (byte)0, 1, "Pig Saddle")); + noteSong = _finalSong; + } + + //Music! + _music = new NotePlayer(Manager.getPlugin(), noteSong, new INoteVerifier() + { + @Override + public boolean shouldPlay(Player player) + { + return Manager.getPreferences().Get(player).HubMusic; + } + }, 0.7F, true); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (GetTeamList().isEmpty()) + return; + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cGreen + "Players Alive"); + Scoreboard.Write("" + GetPlayers(true).size()); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cGreen + "Items Left"); + + if (_roundState == 1) + Scoreboard.Write("" + _pigs.size()); + else + Scoreboard.Write("-"); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cGreen + "Time Left"); + if (_roundState == 1) + Scoreboard.Write("" + UtilTime.MakeStr(_roundTimeLimit - (System.currentTimeMillis() - _roundTime), 0)); + else + Scoreboard.Write("-"); + + Scoreboard.Draw(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + if (GetPlayers(true).size() == 1) + { + ArrayList places = _players.GetPlacements(true); + + System.out.println("EndCheck:760"); + //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); + + + if (GetPlayers(true).size() >= 1) + { + Player winner = places.get(0); + + if (Manager.GetTaskManager().hasCompletedTask(winner, "Valentines Reward 2016")) + { + + } + else + { + SetCustomWinMessage(winner, winner.getName() + " earned " + C.cYellow + "3x Valentines Gift"); + + Manager.GetTaskManager().completedTask(new Callback() + { + @Override + public void run(Boolean data) + { + if (data) + { + Manager.getInventoryManager().addItemToInventory(winner, "Valentines Gift", 3); + } + else + { + UtilPlayer.message(winner, F.main("Inventory", "An error occured while giving you " + C.cRed + "3x Valentines Gift" + C.cGray + ".")); + } + } + }, winner, "Valentines Reward 2016"); + } + } + + //End + SetState(GameState.End); + } + else if (GetPlayers(true).size() == 0) + { + for (Player player : GetPlayers(false)) + { + Manager.GetGame().AddGems(player, 10, "Participation", false, false); + } + + SetCustomWinLine("Moolanie broke up with Calvin..."); + + SetState(GameState.End); + } + } + + @EventHandler + public void displayCalvinMessage(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (!IsLive()) + return; + + if (_item != null) + { + String message = _finalRound ? "Bring the Pig to Calvin!" : "Return " + _item.getTitle() + " to Calvin!"; + + Player[] players = GetPlayers(true).stream().filter(this::canReturnToCow).toArray(size -> new Player[size]); + UtilTextMiddle.display("", C.cGreen + message, players); + } + } + + private boolean canReturnToCow(Player player) + { + return _hasItem.contains(player) || player.getVehicle() != null; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/kit/KitMasterOfLove.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/kit/KitMasterOfLove.java new file mode 100644 index 000000000..cc9d89158 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/kit/KitMasterOfLove.java @@ -0,0 +1,38 @@ +package nautilus.game.arcade.game.games.valentines.kit; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitMasterOfLove extends Kit +{ + public KitMasterOfLove(ArcadeManager manager) + { + super(manager, "Master of Love", KitAvailability.Free, + + new String[] + { + "Ain't no mountain high enough!" + }, + + new Perk[] + { + }, + EntityType.SKELETON, + new ItemStack(Material.BOW)); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.FISHING_ROD, (byte)0, 1, "Cupids Pig Catcher")); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialPhaseValentines.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialPhaseValentines.java new file mode 100644 index 000000000..923fe4947 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialPhaseValentines.java @@ -0,0 +1,52 @@ +package nautilus.game.arcade.game.games.valentines.tutorial; + +import org.bukkit.Sound; + +import mineplex.core.common.util.C; +import nautilus.game.arcade.gametutorial.TutorialPhase; +import nautilus.game.arcade.gametutorial.TutorialText; + +public class TutorialPhaseValentines extends TutorialPhase +{ + + public TutorialPhaseValentines() + { + super(new TutorialText[] + { + new TutorialText(C.cRed + "Moolanie", "Calvin! Did you forget Valentines Day again?!", 1, Sound.COW_IDLE), + new TutorialText(C.cGreen + "Calvin", "Of course not!!!", 2, Sound.COW_IDLE), + new TutorialText(C.cGreen + "Calvin", "I promise this year will be amazing!", 3, Sound.COW_IDLE), + new TutorialText(C.cRed + "Moolanie", "It better be, or we're finished...", 4, Sound.COW_IDLE), + new TutorialText(C.cGreen + "Calvin", "Good thing I prepared this year!", 5, Sound.COW_IDLE), + new TutorialText(C.cGreen + "Calvin", "WHAT?!", 6, Sound.COW_IDLE), + new TutorialText(C.cGreen + "Calvin", "NO!!", 7, Sound.COW_IDLE), + new TutorialText(C.cGreen + "Calvin", "SOMEBODY HELP ME!", 8, Sound.COW_IDLE), + new TutorialText(C.cGreen + "Calvin", "I'M BEING ROBBED!", 9, Sound.COW_IDLE), + + }); + } + + @Override + public int ID() + { + return 1; + } + + @Override + public void onStart() + { + + } + + @Override + public void onEnd() + { + + } + + @Override + public void onMessageDisplay(TutorialText text) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialValentines.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialValentines.java new file mode 100644 index 000000000..386bc5fe1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/tutorial/TutorialValentines.java @@ -0,0 +1,223 @@ +package nautilus.game.arcade.game.games.valentines.tutorial; + +import java.util.HashMap; +import java.util.Map.Entry; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Cow; +import org.bukkit.entity.Item; +import org.bukkit.entity.MushroomCow; +import org.bukkit.entity.Pig; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.valentines.ValItem; +import nautilus.game.arcade.game.games.valentines.Valentines; +import nautilus.game.arcade.gametutorial.GameTutorial; +import nautilus.game.arcade.gametutorial.TutorialPhase; + +public class TutorialValentines extends GameTutorial +{ + private Valentines Host; + + private Cow _cowBoy; + private Cow _cowGirl; + private HashMap _pigs = new HashMap(); + + private Location _pigSpawn; + private Location _pigWaypointA; + private Location _pigWaypointB; + + public TutorialValentines(Valentines valentines, ArcadeManager manager) + { + super(manager, new TutorialPhase[]{new TutorialPhaseValentines()}); + + Host = valentines; + + PlayTutorialSounds = true; + } + + @Override + public void onTick(int tick) + { + if (!hasStarted()) + return; + + if (getCurrentPhase() == null || getCurrentPhase().getCurrentText() == null) + return; + + cowGirlUpdate(tick); + cowBoyUpdate(tick); + pigUpdate(tick); + + lookUpdate(); + + } + + private void lookUpdate() + { + if (getCurrentPhase().getCurrentText().ID() == 2) + getPhase(1).setTarget(_cowBoy.getLocation().add(0, 2, 0)); + + if (getCurrentPhase().getCurrentText().ID() == 3) + getPhase(1).setTarget(_cowBoy.getLocation().add(0, 2, 0)); + + if (getCurrentPhase().getCurrentText().ID() == 4) + getPhase(1).setTarget(Host.WorldData.GetDataLocs("RED").get(0).clone().add(0, 2, 0)); + + if (getCurrentPhase().getCurrentText().ID() == 5) + getPhase(1).setTarget(_pigWaypointA.clone().add(0, 2, 0)); + } + + private void cowGirlUpdate(int tick) + { + if (getCurrentPhase().getCurrentText().ID() >= 4) + { + Location loc = _cowGirl.getLocation().add(UtilAlg.getTrajectory(_pigWaypointA, _cowGirl.getLocation()).multiply(5)); + + UtilEnt.CreatureMoveFast(_cowGirl, loc, 1.4f); + } + } + + private void cowBoyUpdate(int tick) + { + if (getCurrentPhase().getCurrentText().ID() == 5) + { + Location loc = _cowBoy.getLocation().add(UtilAlg.getTrajectory(_cowBoy.getLocation(), _pigSpawn).multiply(5)); + + UtilEnt.CreatureMoveFast(_cowBoy, loc, 1f); + } + } + + private void pigUpdate(int tick) + { + //Pigs + if (getCurrentPhase().getCurrentText().ID() > 5) + { + //Spawn + if (_pigs.size() < 5 && tick % 15 == 0) + { + Host.CreatureAllowOverride = true; + + //Spawn + Pig pig = _pigSpawn.getWorld().spawn(_pigSpawn, Pig.class); + UtilEnt.Vegetate(pig); + + + //Item + Item item = pig.getWorld().dropItem(pig.getLocation(), new ItemStack(Material.CHEST)); + pig.setPassenger(item); + + _pigs.put(pig, 0);; + + Host.CreatureAllowOverride = false; + } + + //Move + for (Entry data : _pigs.entrySet()) + { + //Move + if (data.getValue().intValue() == 0) + { + if (UtilMath.offset(data.getKey().getLocation(), _pigWaypointA) > 1) + { + UtilEnt.CreatureMoveFast(data.getKey(), _pigWaypointA, 1.4f); + } + else + { + data.setValue(1); + } + } + if (data.getValue().intValue() == 1) + { + if (UtilMath.offset(data.getKey().getLocation(), _pigWaypointB) > 1) + { + UtilEnt.CreatureMoveFast(data.getKey(), _pigWaypointB, 1.2f); + } + else + { + data.setValue(2); + } + } + + //Oink + if (Math.random() > 0.98) + { + data.getKey().getWorld().playSound(data.getKey().getLocation(), Sound.PIG_IDLE, 1.5f, 1f); + } + } + } + } + + @Override + public void onStart() + { + //Pig Spawn + _pigSpawn = Host.WorldData.GetDataLocs("PINK").get(0); + + //Pig Waypoints + if (UtilMath.offset(_pigSpawn, Host.WorldData.GetDataLocs("ORANGE").get(0)) < + UtilMath.offset(_pigSpawn, Host.WorldData.GetDataLocs("ORANGE").get(1))) + { + _pigWaypointA = Host.WorldData.GetDataLocs("ORANGE").get(0); + _pigWaypointB = Host.WorldData.GetDataLocs("ORANGE").get(1); + } + else + { + _pigWaypointA = Host.WorldData.GetDataLocs("ORANGE").get(1); + _pigWaypointB = Host.WorldData.GetDataLocs("ORANGE").get(0); + } + + //Spawn Cows + Host.CreatureAllowOverride = true; + + _cowBoy = _pigSpawn.getWorld().spawn(Host.WorldData.GetDataLocs("BROWN").get(0), Cow.class); + _cowBoy.setCustomName(C.cGreenB + "Calvin"); + _cowBoy.setCustomNameVisible(true); + UtilEnt.Vegetate(_cowBoy); + + _cowGirl = _pigSpawn.getWorld().spawn(Host.WorldData.GetDataLocs("RED").get(0), MushroomCow.class); + _cowGirl.setCustomName(C.cRedB + "Moolanie"); + _cowGirl.setCustomNameVisible(true); + UtilEnt.Vegetate(_cowGirl); + + Host.CreatureAllowOverride = false; + + + //Player Data + getPhase(1).setLocation(Host.WorldData.GetDataLocs("WHITE").get(0)); + getPhase(1).setTarget(_cowGirl.getLocation().add(0, 2, 0)); + } + + @Override + public void onEnd() + { + _cowBoy.remove(); + _cowGirl.remove(); + + for (Pig pig : _pigs.keySet()) + { + if (pig.getPassenger() != null) + pig.getPassenger().remove(); + + pig.remove(); + } + _pigs.clear(); + + for (Player player : getPlayers().keySet()) + { + Host.Manager.GetCondition().Factory().Blind("Tutorial End", player, player, 4, 0, false, false, false); + } + + UtilTextMiddle.display(C.cGreenB + "Calvin", "Punch the Pigs to get my items back!", 0, 100, 20, UtilServer.getPlayers()); + } +} 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 efa9c8342..6a6749d96 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 @@ -9,6 +9,7 @@ import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.EntityEffect; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -820,6 +821,10 @@ public class WitherGame extends TeamGame implements IBlockRestorer } // Settings + if (player.getGameMode() == GameMode.SPECTATOR) + player.setSpectatorTarget(null); + + player.setGameMode(GameMode.SURVIVAL); player.setAllowFlight(false); player.setFlying(false); ((CraftPlayer) player).getHandle().spectating = false; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index 96ac7ad5a..3204c2dbb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -303,6 +303,11 @@ public abstract class GameTutorial return _phases; } + public TutorialPhase getCurrentPhase() + { + return _currentPhase; + } + public long getTutorialStart() { return _started; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index 57c4baad5..e94afdbe3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -62,7 +62,7 @@ public abstract class TutorialPhase /** * preparing Pitch/Yaw of the location */ - private void prepareLocations() + public void prepareLocations() { Vector vector = new Vector(_target.getBlockX() - _location.getBlockX(), _target.getBlockY() - _location.getBlockY(), _target.getBlockZ() - _location.getBlockZ()); float pitch = UtilAlg.GetPitch(vector); @@ -158,7 +158,7 @@ public abstract class TutorialPhase i++; } displayMessage(text); - UtilTextMiddle.display("", text.getText(), 0, text.getStayTime(), 0, players); + UtilTextMiddle.display(text.getTitle(), text.getText(), 0, text.getStayTime(), 0, players); try { Thread.sleep(text.getStayTime() * 50); @@ -222,6 +222,11 @@ public abstract class TutorialPhase return _text; } + public TutorialText getCurrentText() + { + return _currentText; + } + public void setText(TutorialText[] text) { _text = text; @@ -240,11 +245,17 @@ public abstract class TutorialPhase public void setLocation(Location location) { _location = location; + + if (_location != null && _target != null) + prepareLocations(); } public void setTarget(Location target) { _target = target; + + if (_location != null && _target != null) + prepareLocations(); } public GameTutorial getTutorial() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java index 2711b10fa..82daa80c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java @@ -7,31 +7,43 @@ public class TutorialText { private String _text; + private String _title; private int _stayTime; private int _id; private Sound _sound; - public TutorialText(String text, int stayTime, int id, Sound sound) + public TutorialText(String title, String text, int stayTime, int id, Sound sound) { _text = text; + _title = title; _id = id; _stayTime = stayTime; _sound = sound; } + public TutorialText(String title, String text, int id, Sound sound) + { + this(title, text, (int) (Math.round(1.2 * text.length()) + 25), id, sound); + } + public TutorialText(String text, int id) { - this(text, (int) (Math.round(1.5 * text.length()) + 25), id, Sound.NOTE_PLING); + this(null, text, (int) (Math.round(1.2 * text.length()) + 25), id, Sound.NOTE_PLING); } public TutorialText(String text, int id, Sound sound) { - this(text, (int) (Math.round(1.5 * text.length()) + 25), id, sound); + this(null, text, (int) (Math.round(1.2 * text.length()) + 25), id, sound); } public TutorialText(String text, int stayTime, int id) { - this(text, stayTime, id, Sound.NOTE_PLING); + this(null, text, stayTime, id, Sound.NOTE_PLING); + } + + public String getTitle() + { + return _title; } public String getText() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMadScientist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMadScientist.java index e25e1b16b..2edeb706a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMadScientist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMadScientist.java @@ -148,6 +148,8 @@ public class PerkMadScientist extends Perk implements IThrown } Zombie zombie = (Zombie) e.getEntity(); + if (zombie.getCustomName() == null) + return; Player targetPlayer = (Player) e.getTarget(); String name = ChatColor 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 4217217d9..7f1126a81 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 @@ -116,6 +116,7 @@ public class GameHostManager implements Listener legendGames.add(GameType.MineStrike); legendGames.add(GameType.Skywars); legendGames.add(GameType.SpeedBuilders); + legendGames.add(GameType.TypeWars); // Team variants - Currently being remade. /* legendGames.add(GameType.DragonEscapeTeams); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java index 60bf68b48..c78bd3771 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java @@ -52,7 +52,7 @@ public class GameLootManager implements Listener Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); - _rewardManager = new RewardManager(Manager.GetClients(), Manager.GetServerStatusManager(), Manager.GetDonation(), Manager.getInventoryManager(), petManager, Manager.GetStatsManager(), Manager.getGiveawayManager(), + _rewardManager = new RewardManager(Manager.GetClients(), Manager.GetServerStatusManager(), Manager.GetDonation(), Manager.getInventoryManager(), petManager, Manager.GetStatsManager(), 100, 250, 500, 1000, 1500, 2500, 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 0082fc1ce..4515bcf47 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 @@ -2,6 +2,19 @@ package nautilus.game.arcade.managers; import java.util.List; +import org.bukkit.GameMode; +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.PlayerToggleSneakEvent; +import org.bukkit.event.vehicle.VehicleDamageEvent; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; @@ -13,23 +26,6 @@ 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 { ArcadeManager Manager; @@ -228,19 +224,25 @@ public class GameSpectatorManager implements Listener @Override public void run() { - if(target instanceof Player) + Player ptarget = null; + if (target instanceof Player) + ptarget = (Player) target; + + if (ptarget != null) { - if(!Manager.GetGame().IsAlive(target)) + if (!Manager.GetGame().IsAlive(ptarget)) 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")); + if (ptarget != null) + UtilTextBottom.display(C.cGray + "You are spectating " + F.elem(Manager.GetGame().GetTeam(ptarget).GetColor() + ptarget.getName()) + ".", player); + + UtilPlayer.message(player, F.main("Game", "Sneak to stop spectating.")); } - }, 3); + }, 1); } @EventHandler(priority = EventPriority.LOW) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java index 500dcd7c0..1923c030f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java @@ -123,7 +123,8 @@ public class MiscManager implements Listener return; // Prevent players from hub warping off clock in Master Builders - if (!player.getItemInHand().getItemMeta().getDisplayName().contains("Hub")) + String displayName = player.getItemInHand().getItemMeta().getDisplayName(); + if (displayName == null || !displayName.contains("Hub")) return; if (!Recharge.Instance.usable(event.getPlayer(), "Return to Hub")) 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 index 8ba8039e8..9a195ef1c 100644 --- 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 @@ -56,7 +56,7 @@ public class GameChatManager implements Listener @EventHandler public void HandleChat(AsyncPlayerChatEvent event) { - if (event.isCancelled()) + if (event.isCancelled() || event.getMessage().isEmpty()) return; Player sender = event.getPlayer(); @@ -159,7 +159,7 @@ public class GameChatManager implements Listener 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) + if (_manager.GetGame() == null || _manager.GetGame().GetState() != GameState.Live) { event.setFormat(levelStr + rankStr + senderName + " " + C.cWhite + "%2$s"); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/titangiveaway/TitanGiveawayRepository.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/titangiveaway/TitanGiveawayRepository.java index 3585b3586..49bc0601b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/titangiveaway/TitanGiveawayRepository.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/titangiveaway/TitanGiveawayRepository.java @@ -4,12 +4,13 @@ import java.sql.CallableStatement; import java.sql.Connection; import java.sql.Types; -import mineplex.core.database.DBPool; -import mineplex.core.database.RepositoryBase; +import mineplex.core.database.MinecraftRepository; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; import org.bukkit.plugin.java.JavaPlugin; -public class TitanGiveawayRepository extends RepositoryBase +public class TitanGiveawayRepository extends MinecraftRepository { private int _titanGiveawayCount; diff --git a/Plugins/pom.xml b/Plugins/pom.xml index 49d4c7329..60205936c 100644 --- a/Plugins/pom.xml +++ b/Plugins/pom.xml @@ -77,6 +77,12 @@ 1.4.7 compile + + net.kencochrane.raven + raven-log4j2 + 6.0.0 + compile + net.md-5 bungeecord-proxy