From d0e49280a48ce9bb530d0ccd119090c3f11bdf99 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Wed, 28 Oct 2015 13:34:03 -0400 Subject: [PATCH 01/45] Added a sniper kit! :D --- .../game/games/paintball/Paintball.java | 5 + .../games/paintball/kits/KitMachineGun.java | 1 + .../game/games/paintball/kits/KitRifle.java | 1 + .../game/games/paintball/kits/KitShotgun.java | 1 + .../game/games/paintball/kits/KitSniper.java | 77 +++++++++ .../kits}/perks/PerkPaintballMachineGun.java | 2 +- .../kits}/perks/PerkPaintballRifle.java | 2 +- .../kits}/perks/PerkPaintballShotgun.java | 2 +- .../kits/perks/PerkPaintballSniper.java | 147 ++++++++++++++++++ 9 files changed, 235 insertions(+), 3 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/{kit => game/games/paintball/kits}/perks/PerkPaintballMachineGun.java (98%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/{kit => game/games/paintball/kits}/perks/PerkPaintballRifle.java (97%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/{kit => game/games/paintball/kits}/perks/PerkPaintballShotgun.java (97%) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java 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 19ead99b7..57ea34f63 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 @@ -24,6 +24,7 @@ import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.paintball.kits.KitMachineGun; import nautilus.game.arcade.game.games.paintball.kits.KitRifle; import nautilus.game.arcade.game.games.paintball.kits.KitShotgun; +import nautilus.game.arcade.game.games.paintball.kits.KitSniper; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.stats.KillFastStatTracker; import nautilus.game.arcade.stats.LastStandStatTracker; @@ -262,6 +263,10 @@ public class Paintball extends TeamGame { count = 3; } + if (GetKit(damager) instanceof KitSniper) + { + count = ((KitSniper) GetKit(damager)).getPaintDamage(damager); + } } //Out diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java index 3c6db6cc1..04a62d950 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java @@ -11,6 +11,7 @@ import org.bukkit.inventory.meta.PotionMeta; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballMachineGun; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java index 4bbf4b523..ac0f1b480 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java @@ -12,6 +12,7 @@ import org.bukkit.potion.PotionEffectType; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballRifle; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java index a397ccb10..ce2e2db69 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java @@ -11,6 +11,7 @@ import org.bukkit.inventory.meta.PotionMeta; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballShotgun; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java new file mode 100644 index 000000000..8075cd4ee --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java @@ -0,0 +1,77 @@ +package nautilus.game.arcade.game.games.paintball.kits; + +import mineplex.core.achievement.Achievement; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballShotgun; +import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballSniper; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkSlow; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class KitSniper extends Kit +{ + public KitSniper(ArcadeManager manager) + { + super(manager, "Sniper", KitAvailability.Achievement, + + new String[] + { + "Long range sniper rifle", + C.cGold + "Higher damage every second scoped" + }, + + new Perk[] + { + new PerkPaintballShotgun(), + new PerkSlow(0) + }, + EntityType.ZOMBIE, + new ItemStack(Material.STONE_HOE)); + + setAchievementRequirements(new Achievement[] + { + Achievement.SUPER_PAINTBALL_FLAWLESS_VICTORY, + Achievement.SUPER_PAINTBALL_KILLING_SPREE, + Achievement.SUPER_PAINTBALL_LAST_STAND, + Achievement.SUPER_PAINTBALL_MEDIC, + Achievement.SUPER_PAINTBALL_SPEEDRUNNER, + Achievement.SUPER_PAINTBALL_WINS + }); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_HOE, (byte)0, 1, C.cWhite + "Paintball Sniper Rifle")); + + UtilInv.insert(player, ItemStackFactory.Instance.CreateStack(Material.POTION, (byte) 16429, 1, "Water Bomb")); + + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setColor(Color.WHITE).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.WHITE).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.WHITE).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.WHITE).build()); + } + + public int getPaintDamage(Player player) + { + for (Perk perk : this.GetPerks()) + { + if (perk instanceof PerkPaintballSniper) + { + return ((PerkPaintballSniper) perk).getPaintDamage(player); + } + } + return 0; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballMachineGun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballMachineGun.java similarity index 98% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballMachineGun.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballMachineGun.java index f2097476a..9cc331b61 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballMachineGun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballMachineGun.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.paintball.kits.perks; import org.bukkit.ChatColor; import org.bukkit.Material; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballRifle.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballRifle.java similarity index 97% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballRifle.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballRifle.java index d977b8cfc..963da3e0c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballRifle.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballRifle.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.paintball.kits.perks; import org.bukkit.ChatColor; import org.bukkit.Material; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballShotgun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballShotgun.java similarity index 97% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballShotgun.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballShotgun.java index 257f58a15..6c14682f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballShotgun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballShotgun.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.kit.perks; +package nautilus.game.arcade.game.games.paintball.kits.perks; import org.bukkit.ChatColor; import org.bukkit.Material; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java new file mode 100644 index 000000000..fd2d18031 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java @@ -0,0 +1,147 @@ +package nautilus.game.arcade.game.games.paintball.kits.perks; + +import java.util.HashMap; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.core.recharge.RechargedEvent; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Snowball; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; + +public class PerkPaintballSniper extends Perk +{ + private HashMap _crouching = new HashMap(); + + public PerkPaintballSniper() + { + super("Sniper Rifle", new String[] + { + C.cYellow + "Crouch" + C.cGray + " to use " + C.cGreen + "Scope", + C.cYellow + "Right-Click" + C.cGray + " to use " + C.cGreen + "Shotgun" + }); + } + + @EventHandler + public void Recharge(RechargedEvent event) + { + if (!event.GetAbility().equals(GetName())) + return; + + event.GetPlayer().playSound(event.GetPlayer().getLocation(), Sound.NOTE_STICKS, 2f, 1f); + event.GetPlayer().playSound(event.GetPlayer().getLocation(), Sound.NOTE_STICKS, 2f, 1.5f); + } + + @EventHandler + public void Shoot(PlayerInteractEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + if (!UtilGear.isMat(event.getItem(), Material.STONE_HOE)) + return; + + Player player = event.getPlayer(); + + if (!Manager.IsAlive(player)) + return; + + if (UtilPlayer.isSpectator(player)) + return; + + if (!Kit.HasKit(player)) + return; + + event.setCancelled(true); + + if (!Recharge.Instance.use(player, GetName(), 1400, true, false)) + return; + + Projectile proj = player.launchProjectile(Manager.GetGame().GetTeam(player).GetColor() == ChatColor.AQUA ? Snowball.class : EnderPearl.class); + + proj.setVelocity(proj.getVelocity().normalize().multiply(4)); + + //Sound + player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 0.8f, 1f); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + //Cleanup check + HashMap copyMap = new HashMap(); + copyMap.putAll(_crouching); + for (Player player : copyMap.keySet()) + { + boolean remove = false; + if (!Manager.GetGame().IsAlive(player)) + remove = true; + + if (UtilPlayer.isSpectator(player)) + remove = true; + + if (!player.isSneaking()) + remove = true; + + if (remove) + { + _crouching.remove(player); + + // Zoom + if (Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) + Manager.GetCondition().EndCondition(player, ConditionType.SLOW, GetName()); + } + } + + //Add check + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + continue; + + if (!player.isSneaking()) + continue; + + if (_crouching.containsKey(player)) + continue; + + _crouching.put(player, System.currentTimeMillis()); + + // Zoom + if (!Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) + Manager.GetCondition().Factory().Slow(GetName(), player, null, Double.MAX_VALUE, 5, false, false, false, false); + } + } + + public int getPaintDamage(Player player) + { + if (!_crouching.containsKey(player)) + return 1; + + return (int) Math.max(1, Math.floor((System.currentTimeMillis() - _crouching.get(player)) / 1000)); + } +} \ No newline at end of file From a7070065580085448aa48288574312b1a497da24 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Wed, 28 Oct 2015 21:42:41 -0400 Subject: [PATCH 02/45] Work. Deemed unsuitable due to an issue with the paintballs flying wide. --- .../game/games/paintball/Paintball.java | 31 +++- .../game/games/paintball/PlayerCopy.java | 3 - .../games/paintball/kits/KitMachineGun.java | 52 ++----- .../game/games/paintball/kits/KitRifle.java | 57 +++---- .../game/games/paintball/kits/KitShotgun.java | 53 +++---- .../game/games/paintball/kits/KitSniper.java | 32 ++-- .../kits/perks/PerkPaintballSniper.java | 146 ++++++++++++++++-- 7 files changed, 233 insertions(+), 141 deletions(-) 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 57ea34f63..2dd4344b2 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 @@ -7,6 +7,10 @@ import java.util.Iterator; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -56,6 +60,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -98,6 +103,7 @@ public class Paintball extends TeamGame private HashMap _doubles = new HashMap(); + @SuppressWarnings("unchecked") public Paintball(ArcadeManager manager) { super(manager, GameType.Paintball, @@ -107,6 +113,7 @@ public class Paintball extends TeamGame new KitRifle(manager), new KitShotgun(manager), new KitMachineGun(manager), + new KitSniper(manager), }, new String[] @@ -162,6 +169,7 @@ public class Paintball extends TeamGame event.setCancelled(true); } + @SuppressWarnings("deprecation") @EventHandler public void Paint(ProjectileHitEvent event) { @@ -265,7 +273,10 @@ public class Paintball extends TeamGame } if (GetKit(damager) instanceof KitSniper) { - count = ((KitSniper) GetKit(damager)).getPaintDamage(damager); + count = ((KitSniper) GetKit(damager)).getPaintDamage(event.GetProjectile()); + + if (count == -1) + count = 1; } } @@ -517,4 +528,22 @@ public class Paintball extends TeamGame for (Player player : GetPlayers(true)) player.removePotionEffect(PotionEffectType.WATER_BREATHING); } + + @EventHandler + public void onHeal(PlayerInteractEvent event) + { + if (!IsLive()) + return; + + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + if (!UtilGear.isMat(event.getItem(), Material.POTION)) + return; + + if (!IsAlive(event.getPlayer()) || UtilPlayer.isSpectator(event.getPlayer())) + event.setCancelled(true); + + UtilInv.Update(event.getPlayer()); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java index b072dea9a..787c23296 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java @@ -2,12 +2,9 @@ package nautilus.game.arcade.game.games.paintball; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilEnt; -import mineplex.core.disguise.disguises.DisguisePlayer; import nautilus.game.arcade.game.Game; import org.bukkit.ChatColor; -import org.bukkit.EntityEffect; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java index 04a62d950..591abb677 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java @@ -1,21 +1,22 @@ package nautilus.game.arcade.game.games.paintball.kits; -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.inventory.meta.PotionMeta; - import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballMachineGun; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.*; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; public class KitMachineGun extends Kit { @@ -40,36 +41,17 @@ public class KitMachineGun extends Kit @Override public void GiveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BARDING, (byte)0, 1, "Paintball Machine Gun")); + UtilInv.insert(player, ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BARDING, (byte)0, 1, F.item("Paintball Machine Gun"))); ItemStack potion = new ItemStack(Material.POTION, 3, (short)16429); // 16422 PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); - potionMeta.setDisplayName("Water Bomb"); + potionMeta.setDisplayName(F.item("Water Bomb")); potion.setItemMeta(potionMeta); - player.getInventory().addItem(potion); - - ItemStack helm = new ItemStack(Material.LEATHER_HELMET); - LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta(); - metaHelm.setColor(Color.WHITE); - helm.setItemMeta(metaHelm); - player.getInventory().setHelmet(helm); + UtilInv.insert(player, potion); - ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); - LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); - meta.setColor(Color.WHITE); - armor.setItemMeta(meta); - player.getInventory().setChestplate(armor); - - ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS); - LeatherArmorMeta metaLegs = (LeatherArmorMeta)armor.getItemMeta(); - metaLegs.setColor(Color.WHITE); - legs.setItemMeta(metaLegs); - player.getInventory().setLeggings(legs); - - ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); - LeatherArmorMeta metaBoots = (LeatherArmorMeta)armor.getItemMeta(); - metaBoots.setColor(Color.WHITE); - boots.setItemMeta(metaBoots); - player.getInventory().setBoots(boots); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setUnbreakable(true).setColor(Color.WHITE).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java index ac0f1b480..db88ea43c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java @@ -1,22 +1,23 @@ package nautilus.game.arcade.game.games.paintball.kits; -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.potion.PotionEffectType; - import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballRifle; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.*; +import nautilus.game.arcade.kit.perks.PerkSpeed; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; public class KitRifle extends Kit { @@ -42,37 +43,17 @@ public class KitRifle extends Kit @Override public void GiveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_BARDING, (byte)0, 1, "Paintball Rifle")); - - //Potion + UtilInv.insert(player, ItemStackFactory.Instance.CreateStack(Material.IRON_BARDING, (byte)0, 1, F.item("Paintball Rifle"))); + ItemStack potion = new ItemStack(Material.POTION, 3, (short)16429); // 16422 PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); - potionMeta.setDisplayName("Water Bomb"); + potionMeta.setDisplayName(F.item("Water Bomb")); potion.setItemMeta(potionMeta); - player.getInventory().addItem(potion); - - ItemStack helm = new ItemStack(Material.LEATHER_HELMET); - LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta(); - metaHelm.setColor(Color.WHITE); - helm.setItemMeta(metaHelm); - player.getInventory().setHelmet(helm); + UtilInv.insert(player, potion); - ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); - LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); - meta.setColor(Color.WHITE); - armor.setItemMeta(meta); - player.getInventory().setChestplate(armor); - - ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS); - LeatherArmorMeta metaLegs = (LeatherArmorMeta)armor.getItemMeta(); - metaLegs.setColor(Color.WHITE); - legs.setItemMeta(metaLegs); - player.getInventory().setLeggings(legs); - - ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); - LeatherArmorMeta metaBoots = (LeatherArmorMeta)armor.getItemMeta(); - metaBoots.setColor(Color.WHITE); - boots.setItemMeta(metaBoots); - player.getInventory().setBoots(boots); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setUnbreakable(true).setColor(Color.WHITE).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java index ce2e2db69..65275c0a8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java @@ -1,21 +1,23 @@ package nautilus.game.arcade.game.games.paintball.kits; -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.inventory.meta.PotionMeta; - import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballShotgun; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.*; +import nautilus.game.arcade.kit.perks.PerkSpeed; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; public class KitShotgun extends Kit { @@ -41,36 +43,17 @@ public class KitShotgun extends Kit @Override public void GiveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_BARDING, (byte)0, 1, "Paintball Shotgun")); + UtilInv.insert(player, ItemStackFactory.Instance.CreateStack(Material.GOLD_BARDING, (byte)0, 1, F.item("Paintball Shotgun"))); ItemStack potion = new ItemStack(Material.POTION, 3, (short)16429); // 16422 PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); - potionMeta.setDisplayName("Water Bomb"); + potionMeta.setDisplayName(F.item("Water Bomb")); potion.setItemMeta(potionMeta); - player.getInventory().addItem(potion); + UtilInv.insert(player, potion); - ItemStack helm = new ItemStack(Material.LEATHER_HELMET); - LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta(); - metaHelm.setColor(Color.WHITE); - helm.setItemMeta(metaHelm); - player.getInventory().setHelmet(helm); - - ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); - LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); - meta.setColor(Color.WHITE); - armor.setItemMeta(meta); - player.getInventory().setChestplate(armor); - - ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS); - LeatherArmorMeta metaLegs = (LeatherArmorMeta)armor.getItemMeta(); - metaLegs.setColor(Color.WHITE); - legs.setItemMeta(metaLegs); - player.getInventory().setLeggings(legs); - - ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); - LeatherArmorMeta metaBoots = (LeatherArmorMeta)armor.getItemMeta(); - metaBoots.setColor(Color.WHITE); - boots.setItemMeta(metaBoots); - player.getInventory().setBoots(boots); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setUnbreakable(true).setColor(Color.WHITE).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java index 8075cd4ee..4604ddd0e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java @@ -2,22 +2,23 @@ package nautilus.game.arcade.game.games.paintball.kits; import mineplex.core.achievement.Achievement; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilInv; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballShotgun; import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballSniper; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkSlow; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; public class KitSniper extends Kit { @@ -33,8 +34,7 @@ public class KitSniper extends Kit new Perk[] { - new PerkPaintballShotgun(), - new PerkSlow(0) + new PerkPaintballSniper(), }, EntityType.ZOMBIE, new ItemStack(Material.STONE_HOE)); @@ -51,27 +51,31 @@ public class KitSniper extends Kit } @Override - public void GiveItems(Player player) + public void GiveItems(Player player) { player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_HOE, (byte)0, 1, C.cWhite + "Paintball Sniper Rifle")); - UtilInv.insert(player, ItemStackFactory.Instance.CreateStack(Material.POTION, (byte) 16429, 1, "Water Bomb")); + ItemStack potion = new ItemStack(Material.POTION, 2, (short)16429); // 16422 + PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); + potionMeta.setDisplayName(F.item("Water Bomb")); + potion.setItemMeta(potionMeta); + UtilInv.insert(player, potion); - player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setColor(Color.WHITE).build()); - player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.WHITE).build()); - player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.WHITE).build()); - player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.WHITE).build()); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setUnbreakable(true).setColor(Color.WHITE).build()); } - public int getPaintDamage(Player player) + public int getPaintDamage(Projectile proj) { - for (Perk perk : this.GetPerks()) + for (Perk perk : GetPerks()) { if (perk instanceof PerkPaintballSniper) { - return ((PerkPaintballSniper) perk).getPaintDamage(player); + return ((PerkPaintballSniper) perk).getPaintDamage(proj); } } - return 0; + return -1; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java index fd2d18031..71b9bf2b9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java @@ -1,8 +1,10 @@ package nautilus.game.arcade.game.games.paintball.kits.perks; import java.util.HashMap; +import java.util.HashSet; import mineplex.core.common.util.C; +import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; @@ -10,8 +12,11 @@ import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.core.recharge.RechargedEvent; +import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.kit.Perk; import org.bukkit.ChatColor; @@ -22,18 +27,25 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; public class PerkPaintballSniper extends Perk { private HashMap _crouching = new HashMap(); + private HashMap _fired = new HashMap(); + private NautHashMap _damage = new NautHashMap(); + + private double _velocity = 8; public PerkPaintballSniper() { super("Sniper Rifle", new String[] { C.cYellow + "Crouch" + C.cGray + " to use " + C.cGreen + "Scope", - C.cYellow + "Right-Click" + C.cGray + " to use " + C.cGreen + "Shotgun" + C.cYellow + "Right-Click" + C.cGray + " to use " + C.cGreen + "Sniper Rifle", + "Experience Bar represents damage." }); } @@ -75,45 +87,63 @@ public class PerkPaintballSniper extends Perk event.setCancelled(true); - if (!Recharge.Instance.use(player, GetName(), 1400, true, false)) + if (!Recharge.Instance.use(player, GetName(), 1000, true, true)) return; - Projectile proj = player.launchProjectile(Manager.GetGame().GetTeam(player).GetColor() == ChatColor.AQUA ? Snowball.class : EnderPearl.class); - - proj.setVelocity(proj.getVelocity().normalize().multiply(4)); + Projectile proj = player.launchProjectile(Manager.GetGame().GetTeam(player).GetColor() == ChatColor.AQUA ? Snowball.class : EnderPearl.class, player.getEyeLocation().getDirection().clone().multiply(_velocity)); + + _fired.put(proj, proj.getVelocity()); + _damage.put(proj, getPaintDamage(player)); //Sound player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 0.8f, 1f); + + player.setSneaking(false); + + //Effects + removeEffects(player); } @EventHandler public void onUpdate(UpdateEvent event) { - if (!Manager.GetGame().IsLive()) + if (event.getType() != UpdateType.TICK) return; + if (!Manager.GetGame().IsLive()) + return; + //Cleanup check HashMap copyMap = new HashMap(); copyMap.putAll(_crouching); for (Player player : copyMap.keySet()) { boolean remove = false; + if (!player.isOnline()) + remove = true; + if (!Manager.GetGame().IsAlive(player)) remove = true; - + if (UtilPlayer.isSpectator(player)) remove = true; - + if (!player.isSneaking()) remove = true; + if (!Recharge.Instance.usable(player, GetName())) + remove = true; + if (remove) { - _crouching.remove(player); + if (_crouching.containsKey(player)) + _crouching.remove(player); + + player.setExp(0F); + player.setSneaking(false); // Zoom - if (Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) - Manager.GetCondition().EndCondition(player, ConditionType.SLOW, GetName()); + removeEffects(player); } } @@ -123,6 +153,9 @@ public class PerkPaintballSniper extends Perk if (UtilPlayer.isSpectator(player)) continue; + if (!Kit.HasKit(player)) + continue; + if (!player.isSneaking()) continue; @@ -132,12 +165,95 @@ public class PerkPaintballSniper extends Perk _crouching.put(player, System.currentTimeMillis()); // Zoom - if (!Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) - Manager.GetCondition().Factory().Slow(GetName(), player, null, Double.MAX_VALUE, 5, false, false, false, false); - } + addEffects(player); + } + + // Exp check + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + continue; + + if (!Kit.HasKit(player)) + continue; + + if (!_crouching.containsKey(player)) + continue; + + player.setExp((float) Math.min(.999F, player.getExp() + .0125)); + } } - public int getPaintDamage(Player player) + @EventHandler + public void updateProjectiles(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!Manager.GetGame().IsLive()) + return; + + HashSet copySet = new HashSet(_fired.keySet()); + for (Projectile proj : copySet) + { + if (!proj.isValid()) + { + _fired.remove(proj); + + if (_damage.containsKey(proj)) + _damage.remove(proj); + + continue; + } + + proj.setVelocity(_fired.get(proj).clone().normalize().multiply(_velocity)); + } + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void removeEffects(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + return; + + for (Player player : _crouching.keySet()) + { + removeEffects(player); + } + + _crouching.clear(); + } + + private void removeEffects(Player player) + { + // Zoom + if (Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) + Manager.GetCondition().EndCondition(player, ConditionType.SLOW, GetName()); + + if (Manager.GetCondition().HasCondition(player, ConditionType.JUMP, GetName())) + Manager.GetCondition().EndCondition(player, ConditionType.JUMP, GetName()); + } + + private void addEffects(Player player) + { + // Zoom + if (!Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) + Manager.GetCondition().Factory().Slow(GetName(), player, null, Double.MAX_VALUE, 8, false, false, false, false); + +// if (!Manager.GetCondition().HasCondition(player, ConditionType.JUMP, GetName())) +// Manager.GetCondition().Factory().Jump(GetName(), player, null, 9999999, 250, true, false, false); + } + + public int getPaintDamage(Projectile proj) + { + if (!_damage.containsKey(proj)) + return 1; + + return _damage.remove(proj); + } + + private int getPaintDamage(Player player) { if (!_crouching.containsKey(player)) return 1; From 399edbab2940762ad38a8fc38dd97aa604051609 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Sun, 15 Nov 2015 12:47:45 -0500 Subject: [PATCH 03/45] Sniper work --- .../game/games/paintball/Paintball.java | 81 ++++----- .../game/games/paintball/kits/KitSniper.java | 18 +- .../kits/perks/PerkPaintballSniper.java | 158 ++++++++++++++---- 3 files changed, 175 insertions(+), 82 deletions(-) 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 468316016..2384386ef 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 @@ -4,6 +4,40 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.HumanEntity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; +import org.bukkit.entity.ThrownPotion; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; + import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; @@ -36,39 +70,6 @@ import nautilus.game.arcade.stats.MedicStatTracker; import nautilus.game.arcade.stats.WinFastStatTracker; import nautilus.game.arcade.stats.WinWithoutLosingTeammateStatTracker; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.EnderPearl; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Snowball; -import org.bukkit.entity.ThrownPotion; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.util.Vector; - public class Paintball extends TeamGame { public static class ReviveEvent extends PlayerEvent @@ -181,10 +182,13 @@ public class Paintball extends TeamGame return; byte color = 3; - if (event.getEntity() instanceof EnderPearl) + if (event.getEntity() instanceof EnderPearl || (event.getEntity() instanceof Arrow && event.getEntity().hasMetadata("color") && ChatColor.values()[event.getEntity().getMetadata("color").get(0).asInt()] == ChatColor.RED)) color = 14; + + Location loc = event.getEntity().getLocation(); - Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity()); + if (!(event.getEntity() instanceof Arrow)) + loc.add(event.getEntity().getVelocity()); for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet()) { @@ -197,6 +201,7 @@ public class Paintball extends TeamGame if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); + event.getEntity().remove(); } } @@ -234,7 +239,7 @@ public class Paintball extends TeamGame if (event.GetProjectile() == null) return; - if (!(event.GetProjectile() instanceof Snowball) && !(event.GetProjectile() instanceof EnderPearl)) + if (!(event.GetProjectile() instanceof Snowball) && !(event.GetProjectile() instanceof EnderPearl) && !(event.GetProjectile() instanceof Arrow)) return; //Negate @@ -271,9 +276,9 @@ public class Paintball extends TeamGame { count = 3; } - if (GetKit(damager) instanceof KitSniper) + if (GetKit(damager) instanceof KitSniper && event.GetProjectile() instanceof Arrow) { - count = ((KitSniper) GetKit(damager)).getPaintDamage(event.GetProjectile()); + count = ((KitSniper) GetKit(damager)).getPaintDamage((Arrow) event.GetProjectile()); if (count == -1) count = 1; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java index 4604ddd0e..e7d41949a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java @@ -1,5 +1,13 @@ package nautilus.game.arcade.game.games.paintball.kits; +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; + import mineplex.core.achievement.Achievement; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -12,14 +20,6 @@ import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.PotionMeta; - public class KitSniper extends Kit { public KitSniper(ArcadeManager manager) @@ -67,7 +67,7 @@ public class KitSniper extends Kit player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setUnbreakable(true).setColor(Color.WHITE).build()); } - public int getPaintDamage(Projectile proj) + public int getPaintDamage(Arrow proj) { for (Perk perk : GetPerks()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java index 71b9bf2b9..61ce1e918 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java @@ -1,15 +1,33 @@ package nautilus.game.arcade.game.games.paintball.kits.perks; +import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.metadata.FixedMetadataValue; import mineplex.core.common.util.C; import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.recharge.Recharge; import mineplex.core.recharge.RechargedEvent; import mineplex.core.updater.UpdateType; @@ -18,26 +36,22 @@ import mineplex.minecraft.game.core.condition.Condition.ConditionType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.kit.Perk; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EnderPearl; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.entity.Snowball; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; +import net.md_5.bungee.api.ChatColor; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; public class PerkPaintballSniper extends Perk { - private HashMap _crouching = new HashMap(); - private HashMap _fired = new HashMap(); - private NautHashMap _damage = new NautHashMap(); + private static class Bullet + { + public int Damage; + public Location LastSeen; + } - private double _velocity = 8; + private HashMap _crouching = new HashMap(); +// private HashMap _fired = new HashMap(); + private NautHashMap _fired = new NautHashMap(); + + private double _velocity = 15; public PerkPaintballSniper() { @@ -90,10 +104,21 @@ public class PerkPaintballSniper extends Perk if (!Recharge.Instance.use(player, GetName(), 1000, true, true)) return; - Projectile proj = player.launchProjectile(Manager.GetGame().GetTeam(player).GetColor() == ChatColor.AQUA ? Snowball.class : EnderPearl.class, player.getEyeLocation().getDirection().clone().multiply(_velocity)); + Arrow proj = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection().clone().multiply(_velocity)); - _fired.put(proj, proj.getVelocity()); - _damage.put(proj, getPaintDamage(player)); + PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(); + packet.a = new int[]{proj.getEntityId()}; + + for (Player viewer : UtilServer.getPlayers()) + UtilPlayer.sendPacket(viewer, packet); + + proj.setMetadata("color", new FixedMetadataValue(Manager.getPlugin(), Manager.GetGame().GetTeam(player).GetColor().ordinal())); + + Bullet bullet = new Bullet(); + bullet.Damage = getPaintDamage(player); + bullet.LastSeen = proj.getLocation(); + + _fired.put(proj, bullet); //Sound player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 0.8f, 1f); @@ -131,6 +156,9 @@ public class PerkPaintballSniper extends Perk if (!player.isSneaking()) remove = true; + if (!UtilInv.IsItem(player.getItemInHand(), Material.STONE_HOE, (byte) -1)) + remove = true; + if (!Recharge.Instance.usable(player, GetName())) remove = true; @@ -159,6 +187,9 @@ public class PerkPaintballSniper extends Perk if (!player.isSneaking()) continue; + if (!UtilInv.IsItem(player.getItemInHand(), Material.STONE_HOE, (byte) -1)) + continue; + if (_crouching.containsKey(player)) continue; @@ -186,7 +217,7 @@ public class PerkPaintballSniper extends Perk } @EventHandler - public void updateProjectiles(UpdateEvent event) + public void doArrowEffects(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; @@ -194,20 +225,80 @@ public class PerkPaintballSniper extends Perk if (!Manager.GetGame().IsLive()) return; - HashSet copySet = new HashSet(_fired.keySet()); - for (Projectile proj : copySet) + for (Arrow proj : new ArrayList(_fired.keySet())) { if (!proj.isValid()) { _fired.remove(proj); - - if (_damage.containsKey(proj)) - _damage.remove(proj); - continue; } - proj.setVelocity(_fired.get(proj).clone().normalize().multiply(_velocity)); + Bullet bullet = _fired.get(proj); + + double curRange = 0; + double distance = Math.abs(UtilMath.offset(proj.getLocation(), bullet.LastSeen)); + + while (curRange <= distance) + { + Location newTarget = bullet.LastSeen.add(UtilAlg.getTrajectory(bullet.LastSeen, proj.getLocation()).multiply(curRange)); + + //Progress Forwards + curRange += 0.8; + + ChatColor color = ChatColor.values()[proj.getMetadata("color").get(0).asInt()]; + if (color == ChatColor.BLUE || color == ChatColor.AQUA) + { + UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget, -1, 1, 1, 1, 0, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + else + { + UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + + bullet.LastSeen = proj.getLocation(); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void doArrowEffects(ProjectileHitEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!(event.getEntity() instanceof Arrow)) + return; + + Arrow proj = (Arrow) event.getEntity(); + + if (!_fired.containsKey(proj)) + return; + + Bullet bullet = _fired.get(proj); + + double curRange = 0; + double distance = Math.abs(UtilMath.offset(proj.getLocation(), bullet.LastSeen)); + + while (curRange <= distance) + { + Location newTarget = bullet.LastSeen.add(UtilAlg.getTrajectory(bullet.LastSeen, proj.getLocation()).multiply(curRange)); + + //Progress Forwards + curRange += 0.8; + + ChatColor color = ChatColor.values()[proj.getMetadata("color").get(0).asInt()]; + if (color == ChatColor.BLUE || color == ChatColor.AQUA) + { + UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget, -1, 1, 1, 1, 0, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + else + { + UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } } } @@ -240,17 +331,14 @@ public class PerkPaintballSniper extends Perk // Zoom if (!Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) Manager.GetCondition().Factory().Slow(GetName(), player, null, Double.MAX_VALUE, 8, false, false, false, false); - -// if (!Manager.GetCondition().HasCondition(player, ConditionType.JUMP, GetName())) -// Manager.GetCondition().Factory().Jump(GetName(), player, null, 9999999, 250, true, false, false); } - public int getPaintDamage(Projectile proj) + public int getPaintDamage(Arrow proj) { - if (!_damage.containsKey(proj)) + if (!_fired.containsKey(proj)) return 1; - return _damage.remove(proj); + return _fired.get(proj).Damage; } private int getPaintDamage(Player player) @@ -258,6 +346,6 @@ public class PerkPaintballSniper extends Perk if (!_crouching.containsKey(player)) return 1; - return (int) Math.max(1, Math.floor((System.currentTimeMillis() - _crouching.get(player)) / 1000)); + return (int) Math.max(1, Math.min(4, Math.floor((System.currentTimeMillis() - _crouching.get(player)) / 1000))); } } \ No newline at end of file From 448dd33c1a370a1972984d3676aab856499e6dca Mon Sep 17 00:00:00 2001 From: Mysticate Date: Tue, 17 Nov 2015 11:38:02 -0500 Subject: [PATCH 04/45] Switching branches c: --- .../core/achievement/AchievementCategory.java | 4 +- .../game/games/baconbrawl/BaconBrawl.java | 11 ++- .../games/baconbrawl/kits/KitMamaPig.java | 1 - .../game/games/baconbrawl/kits/KitPig.java | 1 - .../games/baconbrawl/kits/KitSheepPig.java | 1 - .../arcade/game/games/bridge/BridgePart.java | 1 + .../game/games/paintball/Paintball.java | 53 +++++++--- .../kits/perks/PerkPaintballSniper.java | 97 +++++++++---------- .../game/arcade/kit/perks/PerkBaconBlast.java | 6 +- .../game/arcade/kit/perks/PerkBodySlam.java | 1 - .../game/arcade/kit/perks/PerkPigCloak.java | 7 +- 11 files changed, 101 insertions(+), 82 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 8eb4305a2..b7a4af7f5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -109,7 +109,7 @@ public enum AchievementCategory SUPER_PAINTBALL("Super Paintball", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, - Material.ENDER_PEARL, 0, GameCategory.ARCADE, null), + Material.ENDER_PEARL, 0, GameCategory.ARCADE, "Sniper Kit"), TURF_WARS("Turf Wars", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, @@ -137,7 +137,7 @@ public enum AchievementCategory MICRO_BATTLE("Micro Battle", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, - Material.LAVA, 0, GameCategory.ARCADE, null), + Material.LAVA_BUCKET, 0, GameCategory.ARCADE, null), BOMB_LOBBERS("Bomb Lobbers", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java index e66165d86..0ee17ce94 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java @@ -5,14 +5,15 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.itemstack.ItemStackFactory; 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.game.SoloGame; -import nautilus.game.arcade.game.games.baconbrawl.kits.*; +import nautilus.game.arcade.game.games.baconbrawl.kits.KitMamaPig; +import nautilus.game.arcade.game.games.baconbrawl.kits.KitPig; +import nautilus.game.arcade.game.games.baconbrawl.kits.KitSheepPig; import nautilus.game.arcade.kit.Kit; public class BaconBrawl extends SoloGame @@ -34,9 +35,9 @@ public class BaconBrawl extends SoloGame "Last pig in the arena wins!" }); - this.DamageTeamSelf = true; - this.HungerSet = 20; - this.PrepareFreeze = false; + DamageTeamSelf = true; + HungerSet = 20; + PrepareFreeze = false; } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitMamaPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitMamaPig.java index 7ab4b7812..c285f9c53 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitMamaPig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitMamaPig.java @@ -11,7 +11,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; import mineplex.core.disguise.disguises.DisguisePig; import mineplex.core.itemstack.ItemStackFactory; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitPig.java index db9071a12..1f54d2eec 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitPig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitPig.java @@ -13,7 +13,6 @@ import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.PerkBodySlam; -import nautilus.game.arcade.kit.perks.PerkJump; public class KitPig extends Kit { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java index 3a63d31ff..5607d41ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.baconbrawl.kits; -import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BridgePart.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BridgePart.java index 86765e9a1..3d810c506 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BridgePart.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BridgePart.java @@ -26,6 +26,7 @@ public class BridgePart Velocity = velocity; } + @SuppressWarnings("deprecation") public boolean Update() { if (!Entity.isValid()) 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 2384386ef..22b6a06d5 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 @@ -172,7 +172,7 @@ public class Paintball extends TeamGame @SuppressWarnings("deprecation") @EventHandler - public void Paint(ProjectileHitEvent event) + public void Paint(final ProjectileHitEvent event) { // Fixed projectile wool painting in waiting lobby. @@ -181,27 +181,48 @@ public class Paintball extends TeamGame if (event.getEntity() instanceof ThrownPotion) return; - byte color = 3; - if (event.getEntity() instanceof EnderPearl || (event.getEntity() instanceof Arrow && event.getEntity().hasMetadata("color") && ChatColor.values()[event.getEntity().getMetadata("color").get(0).asInt()] == ChatColor.RED)) - color = 14; + final byte color = (byte) (event.getEntity() instanceof EnderPearl || (event.getEntity() instanceof Arrow && event.getEntity().hasMetadata("color") && ChatColor.values()[event.getEntity().getMetadata("color").get(0).asInt()] == ChatColor.RED) ? 14 : 3); - Location loc = event.getEntity().getLocation(); + if (event.getEntity() instanceof Arrow) + { + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + Location loc = event.getEntity().getLocation(); + + for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet()) + { + if (block.getType() != Material.WOOL && block.getType() != Material.STAINED_CLAY) + continue; - if (!(event.getEntity() instanceof Arrow)) + block.setData(color); + } + + if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); + else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); + } + }, 1); + } + else + { + Location loc = event.getEntity().getLocation(); loc.add(event.getEntity().getVelocity()); - for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet()) - { - if (block.getType() != Material.WOOL && block.getType() != Material.STAINED_CLAY) - continue; + for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet()) + { + if (block.getType() != Material.WOOL && block.getType() != Material.STAINED_CLAY) + continue; - block.setData(color); + block.setData(color); + } + + if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); + else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); + + event.getEntity().remove(); } - - if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); - else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); - - event.getEntity().remove(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java index 61ce1e918..c8bad2b0a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java @@ -10,7 +10,6 @@ import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.metadata.FixedMetadataValue; @@ -111,7 +110,7 @@ public class PerkPaintballSniper extends Perk for (Player viewer : UtilServer.getPlayers()) UtilPlayer.sendPacket(viewer, packet); - + proj.setMetadata("color", new FixedMetadataValue(Manager.getPlugin(), Manager.GetGame().GetTeam(player).GetColor().ordinal())); Bullet bullet = new Bullet(); @@ -226,13 +225,7 @@ public class PerkPaintballSniper extends Perk return; for (Arrow proj : new ArrayList(_fired.keySet())) - { - if (!proj.isValid()) - { - _fired.remove(proj); - continue; - } - + { Bullet bullet = _fired.get(proj); double curRange = 0; @@ -258,49 +251,55 @@ public class PerkPaintballSniper extends Perk } } + if (!proj.isValid()) + { + _fired.remove(proj); + continue; + } + bullet.LastSeen = proj.getLocation(); } } - - @EventHandler(priority = EventPriority.HIGH) - public void doArrowEffects(ProjectileHitEvent event) - { - if (!Manager.GetGame().IsLive()) - return; - - if (!(event.getEntity() instanceof Arrow)) - return; - - Arrow proj = (Arrow) event.getEntity(); - - if (!_fired.containsKey(proj)) - return; - - Bullet bullet = _fired.get(proj); - - double curRange = 0; - double distance = Math.abs(UtilMath.offset(proj.getLocation(), bullet.LastSeen)); - - while (curRange <= distance) - { - Location newTarget = bullet.LastSeen.add(UtilAlg.getTrajectory(bullet.LastSeen, proj.getLocation()).multiply(curRange)); - - //Progress Forwards - curRange += 0.8; - - ChatColor color = ChatColor.values()[proj.getMetadata("color").get(0).asInt()]; - if (color == ChatColor.BLUE || color == ChatColor.AQUA) - { - UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget, -1, 1, 1, 1, 0, - ViewDist.NORMAL, UtilServer.getPlayers()); - } - else - { - UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget, 0, 0, 0, 0, 1, - ViewDist.NORMAL, UtilServer.getPlayers()); - } - } - } +// +// @EventHandler(priority = EventPriority.HIGH) +// public void doArrowEffects(ProjectileHitEvent event) +// { +// if (!Manager.GetGame().IsLive()) +// return; +// +// if (!(event.getEntity() instanceof Arrow)) +// return; +// +// Arrow proj = (Arrow) event.getEntity(); +// +// if (!_fired.containsKey(proj)) +// return; +// +// Bullet bullet = _fired.get(proj); +// +// double curRange = 0; +// double distance = Math.abs(UtilMath.offset(proj.getLocation(), bullet.LastSeen)); +// +// while (curRange <= distance) +// { +// Location newTarget = bullet.LastSeen.add(UtilAlg.getTrajectory(bullet.LastSeen, proj.getLocation()).multiply(curRange)); +// +// //Progress Forwards +// curRange += 0.8; +// +// ChatColor color = ChatColor.values()[proj.getMetadata("color").get(0).asInt()]; +// if (color == ChatColor.BLUE || color == ChatColor.AQUA) +// { +// UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget, -1, 1, 1, 1, 0, +// ViewDist.NORMAL, UtilServer.getPlayers()); +// } +// else +// { +// UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget, 0, 0, 0, 0, 1, +// ViewDist.NORMAL, UtilServer.getPlayers()); +// } +// } +// } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void removeEffects(GameStateChangeEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java index d69147917..b3869a7cf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java @@ -15,6 +15,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.itemstack.ItemStackFactory; @@ -47,10 +48,7 @@ public class PerkBaconBlast extends Perk implements IThrown if (UtilBlock.usable(event.getClickedBlock())) return; - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) + if (!UtilGear.isAxe(event.getItem())) return; Player player = event.getPlayer(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBodySlam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBodySlam.java index f4e0aaf0f..b438a7440 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBodySlam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBodySlam.java @@ -2,7 +2,6 @@ package nautilus.game.arcade.kit.perks; import java.util.HashMap; -import org.bukkit.GameMode; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigCloak.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigCloak.java index 4b01f97e5..163695218 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigCloak.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigCloak.java @@ -11,7 +11,10 @@ import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.recharge.Recharge; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.kit.Perk; @@ -31,10 +34,10 @@ public class PerkPigCloak extends Perk { Player player = event.getPlayer(); - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + if (!UtilEvent.isAction(event, ActionType.R)) return; - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) + if (!UtilGear.isAxe(event.getItem())) return; if (!Kit.HasKit(player)) From 1342a8ac9f44da62574ec667867bc77081f0e9fb Mon Sep 17 00:00:00 2001 From: Mysticate Date: Tue, 17 Nov 2015 11:38:15 -0500 Subject: [PATCH 05/45] Class --- .../game/arcade/game/games/bridge/BattleCryManager.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BattleCryManager.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BattleCryManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BattleCryManager.java new file mode 100644 index 000000000..7c7e71ba0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BattleCryManager.java @@ -0,0 +1,6 @@ +package nautilus.game.arcade.game.games.bridge; + +public class BattleCryManager +{ + +} From 502f12f00fca6a7790b001254e00e8b88c613baf Mon Sep 17 00:00:00 2001 From: Mysticate Date: Thu, 19 Nov 2015 17:46:07 -0500 Subject: [PATCH 06/45] Fixed paintball to the max. :>> --- .../game/games/paintball/Paintball.java | 78 ++++++------------- .../paintball/events/PaintballEvent.java | 35 +++++++++ .../games/paintball/events/ReviveEvent.java | 35 +++++++++ .../trackers/KillingSpreeTracker.java | 56 +++++++++++++ .../trackers/LastStandStatTracker.java | 42 ++++++++++ .../paintball/trackers}/MedicStatTracker.java | 7 +- .../arcade/stats/LastStandStatTracker.java | 63 --------------- 7 files changed, 195 insertions(+), 121 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/PaintballEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/ReviveEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/KillingSpreeTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/LastStandStatTracker.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/{stats => game/games/paintball/trackers}/MedicStatTracker.java (66%) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java 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 22b6a06d5..8a0854330 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 @@ -22,13 +22,11 @@ import org.bukkit.entity.Snowball; import org.bukkit.entity.ThrownPotion; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent; @@ -59,82 +57,50 @@ import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.paintball.events.PaintballEvent; +import nautilus.game.arcade.game.games.paintball.events.ReviveEvent; import nautilus.game.arcade.game.games.paintball.kits.KitMachineGun; import nautilus.game.arcade.game.games.paintball.kits.KitRifle; import nautilus.game.arcade.game.games.paintball.kits.KitShotgun; import nautilus.game.arcade.game.games.paintball.kits.KitSniper; +import nautilus.game.arcade.game.games.paintball.trackers.KillingSpreeTracker; +import nautilus.game.arcade.game.games.paintball.trackers.LastStandStatTracker; +import nautilus.game.arcade.game.games.paintball.trackers.MedicStatTracker; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.stats.KillFastStatTracker; -import nautilus.game.arcade.stats.LastStandStatTracker; -import nautilus.game.arcade.stats.MedicStatTracker; import nautilus.game.arcade.stats.WinFastStatTracker; import nautilus.game.arcade.stats.WinWithoutLosingTeammateStatTracker; public class Paintball extends TeamGame { - public static class ReviveEvent extends PlayerEvent - { - private static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() - { - return handlers; - } - - @Override - public HandlerList getHandlers() - { - return getHandlerList(); - } - - private final Player _revivedPlayer; - - public ReviveEvent(Player who, Player revivedPlayer) - { - super(who); - - _revivedPlayer = revivedPlayer; - } - - public Player getRevivedPlayer() - { - return _revivedPlayer; - } - } - private HashMap _doubles = new HashMap(); @SuppressWarnings("unchecked") public Paintball(ArcadeManager manager) { - super(manager, GameType.Paintball, + super(manager, GameType.Paintball, new Kit[] + { + new KitRifle(manager), + new KitShotgun(manager), + new KitMachineGun(manager), + new KitSniper(manager), + }, new String[] + { + "Shoot enemies to paint them", + "Revive/heal with Water Bombs", + "Last team alive wins!" + }); - new Kit[] - { - new KitRifle(manager), - new KitShotgun(manager), - new KitMachineGun(manager), - new KitSniper(manager), - }, + StrictAntiHack = true; - new String[] - { - "Shoot enemies to paint them", - "Revive/heal with Water Bombs", - "Last team alive wins!" - }); - - this.StrictAntiHack = true; - - this.HungerSet = 20; + HungerSet = 20; registerStatTrackers( - new KillFastStatTracker(this, 4, 5, "KillingSpree"), + new KillingSpreeTracker(this), new WinWithoutLosingTeammateStatTracker(this, "FlawlessVictory"), new MedicStatTracker(this), new WinFastStatTracker(this, 30, "Speedrunner"), new LastStandStatTracker(this) - ); + ); } @EventHandler @@ -319,6 +285,8 @@ public class Paintball extends TeamGame AddStat(damager, "Kills", 1, false, false); AddStat(damagee, "Deaths", 1, false, false); + + Bukkit.getPluginManager().callEvent(new PaintballEvent(damagee, damager)); } //Hit Sound diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/PaintballEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/PaintballEvent.java new file mode 100644 index 000000000..1805e641e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/PaintballEvent.java @@ -0,0 +1,35 @@ +package nautilus.game.arcade.game.games.paintball.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class PaintballEvent extends PlayerEvent +{ + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private Player _revivedPlayer; + + public PaintballEvent(Player who, Player revivedPlayer) + { + super(who); + + _revivedPlayer = revivedPlayer; + } + + public Player getKiller() + { + return _revivedPlayer; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/ReviveEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/ReviveEvent.java new file mode 100644 index 000000000..53cb01acc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/ReviveEvent.java @@ -0,0 +1,35 @@ +package nautilus.game.arcade.game.games.paintball.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class ReviveEvent extends PlayerEvent +{ + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private Player _revivedPlayer; + + public ReviveEvent(Player who, Player revivedPlayer) + { + super(who); + + _revivedPlayer = revivedPlayer; + } + + public Player getRevivedPlayer() + { + return _revivedPlayer; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/KillingSpreeTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/KillingSpreeTracker.java new file mode 100644 index 000000000..354d64ea9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/KillingSpreeTracker.java @@ -0,0 +1,56 @@ +package nautilus.game.arcade.game.games.paintball.trackers; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.paintball.Paintball; +import nautilus.game.arcade.game.games.paintball.events.PaintballEvent; +import nautilus.game.arcade.stats.StatTracker; + +public class KillingSpreeTracker extends StatTracker +{ + private final Map _killCount = new HashMap<>(); + private final Map _lastKillTime = new HashMap<>(); + + public KillingSpreeTracker(Paintball game) + { + super(game); + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onCombatDeath(PaintballEvent event) + { + if (getGame().GetState() != Game.GameState.Live) + return; + + Long lastTime = _lastKillTime.get(event.getKiller().getUniqueId()); + + long now = System.currentTimeMillis(); + + Integer killCount; + if (lastTime == null || now - lastTime > 5000) + killCount = 0; + else + { + killCount = _killCount.get(event.getKiller().getUniqueId()); + if (killCount == null) + killCount = 0; + } + + killCount++; + + _killCount.put(event.getKiller().getUniqueId(), killCount); + _lastKillTime.put(event.getKiller().getUniqueId(), now); + + _killCount.remove(event.getPlayer().getUniqueId()); + _lastKillTime.remove(event.getPlayer().getUniqueId()); + + if (killCount >= 4) + addStat(event.getKiller(), "KillingSpree", 1, true, false); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/LastStandStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/LastStandStatTracker.java new file mode 100644 index 000000000..6d983b81a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/LastStandStatTracker.java @@ -0,0 +1,42 @@ +package nautilus.game.arcade.game.games.paintball.trackers; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.paintball.Paintball; +import nautilus.game.arcade.game.games.paintball.events.PaintballEvent; +import nautilus.game.arcade.stats.StatTracker; + +public class LastStandStatTracker extends StatTracker +{ + private final Map _kills = new HashMap<>(); + + public LastStandStatTracker(Paintball game) + { + super(game); + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onPaintball(PaintballEvent event) + { + if (getGame().GetState() != Game.GameState.Live) + return; + + if (getGame().GetTeam(event.getKiller()).GetPlayers(true).size() == 1) + { + Integer kills = _kills.get(event.getKiller().getUniqueId()); + + kills = (kills == null ? 0 : kills) + 1; + + _kills.put(event.getKiller().getUniqueId(), kills); + + if (kills >= 3) + addStat(event.getKiller(), "LastStand", 1, true, false); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MedicStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/MedicStatTracker.java similarity index 66% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MedicStatTracker.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/MedicStatTracker.java index 7b3e65e02..ee5b7bf63 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MedicStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/MedicStatTracker.java @@ -1,10 +1,11 @@ -package nautilus.game.arcade.stats; +package nautilus.game.arcade.game.games.paintball.trackers; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.paintball.Paintball; +import nautilus.game.arcade.game.games.paintball.events.ReviveEvent; +import nautilus.game.arcade.stats.StatTracker; public class MedicStatTracker extends StatTracker { @@ -14,7 +15,7 @@ public class MedicStatTracker extends StatTracker } @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onCombatDeath(Paintball.ReviveEvent event) + public void onCombatDeath(ReviveEvent event) { if (getGame().GetState() != Game.GameState.Live) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java deleted file mode 100644 index d1df0b6f5..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java +++ /dev/null @@ -1,63 +0,0 @@ -package nautilus.game.arcade.stats; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import mineplex.core.common.util.UtilPlayer; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.TeamGame; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -public class LastStandStatTracker extends StatTracker -{ - private final Map _kills = new HashMap<>(); - - public LastStandStatTracker(TeamGame game) - { - super(game); - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onCombatDeath(CombatDeathEvent event) - { - if (getGame().GetState() != Game.GameState.Live) - return; - - if (event.GetLog().GetKiller() == null) - return; - - if (!event.GetLog().GetKiller().IsPlayer()) - return; - - Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); - if (killer == null) - return; - - if (event.GetLog().GetPlayer() == null) - return; - - if (!event.GetLog().GetPlayer().IsPlayer()) - return; - - Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); - if (player == null) - return; - - if (getGame().GetTeam(killer).GetPlayers(true).size() == 1) - { - Integer kills = _kills.get(killer.getUniqueId()); - - kills = (kills == null ? 0 : kills) + 1; - - _kills.put(killer.getUniqueId(), kills); - - if (kills >= 3) - addStat(killer, "LastStand", 1, true, false); - } - } -} From e816a79f37825ae577d6dd2226c8448f4fbbbfc8 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Thu, 19 Nov 2015 17:51:25 -0500 Subject: [PATCH 07/45] Reformatted --- .../trackers/LastStandStatTracker.java | 22 +++++++++---------- .../paintball/trackers/MedicStatTracker.java | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/LastStandStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/LastStandStatTracker.java index 6d983b81a..523201a16 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/LastStandStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/LastStandStatTracker.java @@ -1,42 +1,40 @@ package nautilus.game.arcade.game.games.paintball.trackers; -import java.util.HashMap; -import java.util.Map; import java.util.UUID; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import nautilus.game.arcade.game.Game; +import mineplex.core.common.util.NautHashMap; import nautilus.game.arcade.game.games.paintball.Paintball; import nautilus.game.arcade.game.games.paintball.events.PaintballEvent; import nautilus.game.arcade.stats.StatTracker; public class LastStandStatTracker extends StatTracker { - private final Map _kills = new HashMap<>(); + private final NautHashMap _kills = new NautHashMap(); public LastStandStatTracker(Paintball game) { super(game); } - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + @EventHandler public void onPaintball(PaintballEvent event) { - if (getGame().GetState() != Game.GameState.Live) + if (!getGame().IsLive()) return; if (getGame().GetTeam(event.getKiller()).GetPlayers(true).size() == 1) { - Integer kills = _kills.get(event.getKiller().getUniqueId()); - - kills = (kills == null ? 0 : kills) + 1; - - _kills.put(event.getKiller().getUniqueId(), kills); + if (!_kills.containsKey(event.getKiller().getUniqueId())) + _kills.put(event.getKiller().getUniqueId(), 0); + + int kills = _kills.get(event.getKiller().getUniqueId()) + 1; if (kills >= 3) addStat(event.getKiller(), "LastStand", 1, true, false); + + _kills.put(event.getKiller().getUniqueId(), kills); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/MedicStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/MedicStatTracker.java index ee5b7bf63..052412c13 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/MedicStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/MedicStatTracker.java @@ -17,7 +17,7 @@ public class MedicStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(ReviveEvent event) { - if (getGame().GetState() != Game.GameState.Live) + if (!getGame().IsLive()) return; addStat(event.getPlayer(), "Medic", 1, false, false); From f02e2b2e72094427a30bfa989ebd5fffac3c6353 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Thu, 19 Nov 2015 18:02:07 -0500 Subject: [PATCH 08/45] Formatting --- .../game/games/paintball/Paintball.java | 9 ++-- .../paintball/events/PaintballEvent.java | 5 ++ .../games/paintball/events/ReviveEvent.java | 5 ++ .../kits/perks/PerkPaintballSniper.java | 46 ++----------------- .../paintball/trackers/MedicStatTracker.java | 6 +-- 5 files changed, 22 insertions(+), 49 deletions(-) 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 8a0854330..aac5c3853 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 @@ -151,12 +151,13 @@ public class Paintball extends TeamGame if (event.getEntity() instanceof Arrow) { - Manager.runSyncLater(new Runnable() - { + Manager.runSyncLater(new Runnable() // Stupid thing I have to do to make sure the arrow's location is accounted for. Stupid mojang. - Myst + { @Override public void run() { Location loc = event.getEntity().getLocation(); + loc.add(event.getEntity().getVelocity().clone().normalize().multiply(.5)); for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet()) { @@ -174,7 +175,7 @@ public class Paintball extends TeamGame else { Location loc = event.getEntity().getLocation(); - loc.add(event.getEntity().getVelocity()); + loc.add(event.getEntity().getVelocity().clone().normalize().multiply(.5)); for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet()) { @@ -186,8 +187,6 @@ public class Paintball extends TeamGame if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); - - event.getEntity().remove(); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/PaintballEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/PaintballEvent.java index 1805e641e..6de498547 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/PaintballEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/PaintballEvent.java @@ -6,6 +6,11 @@ import org.bukkit.event.player.PlayerEvent; public class PaintballEvent extends PlayerEvent { + /** + * Created by: Mysticate + * Timestamp: November 19, 2015 + */ + private static final HandlerList handlers = new HandlerList(); public static HandlerList getHandlerList() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/ReviveEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/ReviveEvent.java index 53cb01acc..1fb253675 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/ReviveEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/events/ReviveEvent.java @@ -6,6 +6,11 @@ import org.bukkit.event.player.PlayerEvent; public class ReviveEvent extends PlayerEvent { + /** + * Created by: Mysticate + * Timestamp: November 19, 2015 + */ + private static final HandlerList handlers = new HandlerList(); public static HandlerList getHandlerList() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java index c8bad2b0a..80ecdec5c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java @@ -40,6 +40,11 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; public class PerkPaintballSniper extends Perk { + /** + * Created by: Mysticate + * Timestamp: October 27, 2015 + */ + private static class Bullet { public int Damage; @@ -47,7 +52,6 @@ public class PerkPaintballSniper extends Perk } private HashMap _crouching = new HashMap(); -// private HashMap _fired = new HashMap(); private NautHashMap _fired = new NautHashMap(); private double _velocity = 15; @@ -260,46 +264,6 @@ public class PerkPaintballSniper extends Perk bullet.LastSeen = proj.getLocation(); } } -// -// @EventHandler(priority = EventPriority.HIGH) -// public void doArrowEffects(ProjectileHitEvent event) -// { -// if (!Manager.GetGame().IsLive()) -// return; -// -// if (!(event.getEntity() instanceof Arrow)) -// return; -// -// Arrow proj = (Arrow) event.getEntity(); -// -// if (!_fired.containsKey(proj)) -// return; -// -// Bullet bullet = _fired.get(proj); -// -// double curRange = 0; -// double distance = Math.abs(UtilMath.offset(proj.getLocation(), bullet.LastSeen)); -// -// while (curRange <= distance) -// { -// Location newTarget = bullet.LastSeen.add(UtilAlg.getTrajectory(bullet.LastSeen, proj.getLocation()).multiply(curRange)); -// -// //Progress Forwards -// curRange += 0.8; -// -// ChatColor color = ChatColor.values()[proj.getMetadata("color").get(0).asInt()]; -// if (color == ChatColor.BLUE || color == ChatColor.AQUA) -// { -// UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget, -1, 1, 1, 1, 0, -// ViewDist.NORMAL, UtilServer.getPlayers()); -// } -// else -// { -// UtilParticle.PlayParticle(ParticleType.RED_DUST, newTarget, 0, 0, 0, 0, 1, -// ViewDist.NORMAL, UtilServer.getPlayers()); -// } -// } -// } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void removeEffects(GameStateChangeEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/MedicStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/MedicStatTracker.java index 052412c13..cedccaba6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/MedicStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/trackers/MedicStatTracker.java @@ -3,13 +3,13 @@ package nautilus.game.arcade.game.games.paintball.trackers; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.paintball.Paintball; import nautilus.game.arcade.game.games.paintball.events.ReviveEvent; import nautilus.game.arcade.stats.StatTracker; -public class MedicStatTracker extends StatTracker +public class MedicStatTracker extends StatTracker { - public MedicStatTracker(Game game) + public MedicStatTracker(Paintball game) { super(game); } From f7011032bc121989fa2656893b3134aae04918a1 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Thu, 19 Nov 2015 19:49:46 -0500 Subject: [PATCH 09/45] Switching branches --- .../game/games/paintball/Paintball.java | 28 +++++++---- .../game/games/paintball/PlayerCopy.java | 48 ++++++++++++++----- 2 files changed, 55 insertions(+), 21 deletions(-) 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 aac5c3853..3eabf69b5 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 @@ -16,7 +16,6 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Arrow; import org.bukkit.entity.EnderPearl; import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Snowball; import org.bukkit.entity.ThrownPotion; @@ -27,6 +26,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent; @@ -278,7 +278,7 @@ public class Paintball extends TeamGame UtilPlayer.message(player, damageeTeam.GetColor() + damagee.getName() + ChatColor.RESET + " was painted by " + damagerTeam.GetColor() + damager.getName() + ChatColor.RESET + "!"); - PlayerOut(damagee); + PlayerOut(damagee, damager); AddGems(damager, 2, "Kills", true, true); @@ -340,7 +340,7 @@ public class Paintball extends TeamGame return nonColored.isEmpty(); } - public void PlayerOut(Player player) + public void PlayerOut(Player player, Player killer) { //State SetPlayerState(player, PlayerState.OUT); @@ -358,7 +358,7 @@ public class Paintball extends TeamGame UtilAction.velocity(player, new Vector(0,1.2,0)); - _doubles.put(player, new PlayerCopy(this, player, GetTeam(player).GetColor())); + _doubles.put(player, new PlayerCopy(this, player, killer, GetTeam(player).GetColor())); } // @EventHandler @@ -423,7 +423,8 @@ public class Paintball extends TeamGame if (UtilMath.offset(copy.GetEntity().getLocation().add(0,1,0), event.getEntity().getLocation()) > 3) continue; - PlayerIn(copy.GetPlayer(), copy.GetEntity()); + PlayerIn(copy.GetPlayer(), copy); + copyIterator.remove(); AddGems(thrower, 3, "Revived Ally", true, true); @@ -445,7 +446,7 @@ public class Paintball extends TeamGame } } - public void PlayerIn(final Player player, final LivingEntity copy) + public void PlayerIn(final Player player, final PlayerCopy copy) { //State SetPlayerState(player, PlayerState.IN); @@ -455,9 +456,9 @@ public class Paintball extends TeamGame if (copy != null) { Location loc = player.getLocation(); - loc.setX(copy.getLocation().getX()); - loc.setY(copy.getLocation().getY()); - loc.setZ(copy.getLocation().getZ()); + loc.setX(copy.GetEntity().getLocation().getX()); + loc.setY(copy.GetEntity().getLocation().getY()); + loc.setZ(copy.GetEntity().getLocation().getZ()); player.teleport(loc); } @@ -489,7 +490,8 @@ public class Paintball extends TeamGame Manager.GetCondition().EndCondition(player, ConditionType.CLOAK, null); //Remove Copy - copy.remove(); + copy.GetEntity().remove(); + copy.GetHolo().stop(); } }, 4); } @@ -539,4 +541,10 @@ public class Paintball extends TeamGame UtilInv.Update(event.getPlayer()); } + + @EventHandler + public void onInteract(PlayerInteractAtEntityEvent event) + { + event.setCancelled(true); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java index 620c891ea..8dec1c93b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java @@ -1,44 +1,66 @@ package nautilus.game.arcade.game.games.paintball; import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.ArmorStand; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.util.EulerAngle; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; +import mineplex.core.hologram.Hologram; import nautilus.game.arcade.game.Game; public class PlayerCopy { private Game Host; - - private Skeleton _ent; + private Player _owner; - public PlayerCopy(Game host, Player owner, ChatColor nameColor) + private ArmorStand _ent; + private Hologram _holo; + + public PlayerCopy(Game host, Player owner, Player paintedBy, ChatColor nameColor) { Host = host; _owner = owner; Host.CreatureAllowOverride = true; - _ent = owner.getWorld().spawn(owner.getLocation(), Skeleton.class); + _ent = owner.getWorld().spawn(owner.getLocation(), ArmorStand.class); Host.CreatureAllowOverride = false; UtilEnt.ghost(_ent, true, false); UtilEnt.Vegetate(_ent); + _ent.setArms(true); + _ent.setBasePlate(false); + + Location loc = owner.getLocation(); + _ent.teleport(owner); + _ent.setHeadPose(new EulerAngle(UtilAlg.GetYaw(loc.getDirection()), UtilAlg.GetPitch(loc.getDirection()), 0)); + //Armor _ent.getEquipment().setArmorContents(owner.getInventory().getArmorContents()); + _ent.setItemInHand(owner.getItemInHand()); - _ent.setCustomName(C.cWhite + C.Bold + C.Scramble + "XX" + ChatColor.RESET + " " + nameColor + owner.getName() + " " + C.cWhite + C.Bold + C.Scramble + "XX"); - _ent.setCustomNameVisible(true); + //Player skull + ItemStack skull = new ItemStack(Material.SKULL_ITEM, 3); + SkullMeta meta = (SkullMeta) skull.getItemMeta(); + meta.setOwner(owner.getName()); + skull.setItemMeta(meta); + _ent.setHelmet(skull); - //Disguise -// DisguisePlayer disguise = new DisguisePlayer(_ent, ((CraftPlayer)owner).getProfile()); -// Host.Manager.GetDisguise().disguise(disguise); + //Name + _holo = new Hologram(host.Manager.getHologramManager(), _ent.getEyeLocation().clone().add(0, .5, 0)); + _holo.setText(C.cWhite + C.Bold + C.Scramble + "XX" + ChatColor.RESET + " " + nameColor + owner.getName() + " " + C.cWhite + C.Bold + C.Scramble + "XX", C.cWhite + "Painted by " + host.GetTeam(paintedBy).GetColor() + paintedBy.getName()); + _holo.start(); } public LivingEntity GetEntity() @@ -50,5 +72,9 @@ public class PlayerCopy { return _owner; } - + + public Hologram GetHolo() + { + return _holo; + } } From 3f37b893d3f54be9d59af345501ddf8764e169be Mon Sep 17 00:00:00 2001 From: Mysticate Date: Thu, 19 Nov 2015 20:29:20 -0500 Subject: [PATCH 10/45] Worked on double. --- .../game/games/paintball/PlayerCopy.java | 6 +- .../arcade/game/games/wither/PlayerCopy.java | 54 ++++++++++++ .../arcade/game/games/wither/WitherGame.java | 82 ++++++++----------- 3 files changed, 93 insertions(+), 49 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/PlayerCopy.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java index 8dec1c93b..591e35e54 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java @@ -14,6 +14,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.hologram.Hologram; +import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.game.Game; public class PlayerCopy @@ -41,17 +42,18 @@ public class PlayerCopy _ent.setArms(true); _ent.setBasePlate(false); + _ent.setVisible(false); Location loc = owner.getLocation(); _ent.teleport(owner); - _ent.setHeadPose(new EulerAngle(UtilAlg.GetYaw(loc.getDirection()), UtilAlg.GetPitch(loc.getDirection()), 0)); + _ent.setHeadPose(new EulerAngle(Math.toRadians(UtilAlg.GetPitch(loc.getDirection())), Math.toRadians(UtilAlg.GetYaw(loc.getDirection())), 0)); //Armor _ent.getEquipment().setArmorContents(owner.getInventory().getArmorContents()); _ent.setItemInHand(owner.getItemInHand()); //Player skull - ItemStack skull = new ItemStack(Material.SKULL_ITEM, 3); + ItemStack skull = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1); SkullMeta meta = (SkullMeta) skull.getItemMeta(); meta.setOwner(owner.getName()); skull.setItemMeta(meta); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/PlayerCopy.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/PlayerCopy.java new file mode 100644 index 000000000..8101f2b13 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/PlayerCopy.java @@ -0,0 +1,54 @@ +package nautilus.game.arcade.game.games.wither; + +import org.bukkit.ChatColor; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import nautilus.game.arcade.game.Game; + +public class PlayerCopy +{ + private Game Host; + + private Skeleton _ent; + private Player _owner; + + public PlayerCopy(Game host, Player owner, ChatColor nameColor) + { + Host = host; + + _owner = owner; + + Host.CreatureAllowOverride = true; + _ent = owner.getWorld().spawn(owner.getLocation(), Skeleton.class); + Host.CreatureAllowOverride = false; + + UtilEnt.ghost(_ent, true, false); + + UtilEnt.Vegetate(_ent); + + //Armor + _ent.getEquipment().setArmorContents(owner.getInventory().getArmorContents()); + + _ent.setCustomName(C.cWhite + C.Bold + C.Scramble + "XX" + ChatColor.RESET + " " + nameColor + owner.getName() + " " + C.cWhite + C.Bold + C.Scramble + "XX"); + _ent.setCustomNameVisible(true); + + //Disguise +// DisguisePlayer disguise = new DisguisePlayer(_ent, ((CraftPlayer)owner).getProfile()); +// Host.Manager.GetDisguise().disguise(disguise); + } + + public LivingEntity GetEntity() + { + return _ent; + } + + public Player GetPlayer() + { + return _owner; + } + +} 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 ef4cab48f..a79e15922 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 @@ -1,55 +1,11 @@ package nautilus.game.arcade.game.games.wither; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Set; -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.UtilBlock; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.data.BlockData; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; -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.GameTeam; -import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.paintball.PlayerCopy; -import nautilus.game.arcade.game.games.wither.events.HumanReviveEvent; -import nautilus.game.arcade.game.games.wither.kit.KitHumanArcher; -import nautilus.game.arcade.game.games.wither.kit.KitHumanMedic; -import nautilus.game.arcade.game.games.wither.kit.KitHumanEditor; -import nautilus.game.arcade.game.games.wither.kit.KitWitherMinion; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.NullKit; -import nautilus.game.arcade.kit.perks.data.IBlockRestorer; -import nautilus.game.arcade.stats.BloodThirstyStatTracker; -import nautilus.game.arcade.stats.KingDamageStatTracker; -import nautilus.game.arcade.stats.KingSlayerStatTracker; -import nautilus.game.arcade.stats.TeamDeathsStatTracker; -import nautilus.game.arcade.stats.TeamKillsStatTracker; -import nautilus.game.arcade.stats.WinAsTeamStatTracker; -import nautilus.game.arcade.stats.WitherAssaultReviveTracker; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.EntityEffect; @@ -74,13 +30,45 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitRunnable; 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.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.data.BlockData; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +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.GameTeam; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.wither.events.HumanReviveEvent; +import nautilus.game.arcade.game.games.wither.kit.KitHumanArcher; +import nautilus.game.arcade.game.games.wither.kit.KitHumanEditor; +import nautilus.game.arcade.game.games.wither.kit.KitHumanMedic; +import nautilus.game.arcade.game.games.wither.kit.KitWitherMinion; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.NullKit; +import nautilus.game.arcade.kit.perks.data.IBlockRestorer; +import nautilus.game.arcade.stats.TeamDeathsStatTracker; +import nautilus.game.arcade.stats.TeamKillsStatTracker; + public class WitherGame extends TeamGame implements IBlockRestorer { private GameTeam _runners; From 11b2748a5a9a217bc9ac4f9e2bbfecf7b796613d Mon Sep 17 00:00:00 2001 From: Mysticate Date: Sun, 6 Dec 2015 11:45:10 -0500 Subject: [PATCH 11/45] Quick thing before merge --- .../arcade/game/games/paintball/Paintball.java | 17 ++++++----------- .../kits/perks/PerkPaintballSniper.java | 4 ++-- 2 files changed, 8 insertions(+), 13 deletions(-) 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 3eabf69b5..12f0e47f7 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 @@ -15,7 +15,6 @@ import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Arrow; import org.bukkit.entity.EnderPearl; -import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Snowball; import org.bukkit.entity.ThrownPotion; @@ -93,6 +92,8 @@ public class Paintball extends TeamGame StrictAntiHack = true; HungerSet = 20; + + InventoryClick = false; registerStatTrackers( new KillingSpreeTracker(this), @@ -135,7 +136,7 @@ public class Paintball extends TeamGame if (event.getCause() == TeleportCause.ENDER_PEARL) event.setCancelled(true); } - + @SuppressWarnings("deprecation") @EventHandler public void Paint(final ProjectileHitEvent event) @@ -198,9 +199,9 @@ public class Paintball extends TeamGame if (_doubles.containsKey(player)) { - PlayerCopy copy = _doubles.get(player); + PlayerCopy copy = _doubles.remove(player); copy.GetEntity().remove(); - _doubles.remove(player); + copy.GetHolo().stop(); } } @@ -297,14 +298,8 @@ public class Paintball extends TeamGame @EventHandler public void ArmorRemoveCancel(InventoryClickEvent event) { - HumanEntity player = event.getWhoClicked(); - - // Fixed armor being taken off while spectating after being painted. - - if (!IsAlive(player)) - { + if (!IsAlive(event.getWhoClicked())) event.setCancelled(true); - } } public boolean Color(Player player, int amount) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java index 80ecdec5c..657f2e3d7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java @@ -285,8 +285,8 @@ public class PerkPaintballSniper extends Perk if (Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) Manager.GetCondition().EndCondition(player, ConditionType.SLOW, GetName()); - if (Manager.GetCondition().HasCondition(player, ConditionType.JUMP, GetName())) - Manager.GetCondition().EndCondition(player, ConditionType.JUMP, GetName()); +// if (Manager.GetCondition().HasCondition(player, ConditionType.JUMP, GetName())) +// Manager.GetCondition().EndCondition(player, ConditionType.JUMP, GetName()); } private void addEffects(Player player) From 5e57caa94db2ae55b1c4ef6d3d010c9749813a03 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Sun, 6 Dec 2015 17:09:33 -0500 Subject: [PATCH 12/45] Final tweaks to random armorstand --- .../games/paintball/PlayerCopyPaintball.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java index 84e8336c9..595aa9889 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java @@ -11,8 +11,8 @@ import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.util.EulerAngle; 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.hologram.Hologram; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.game.Game; @@ -32,6 +32,9 @@ public class PlayerCopyPaintball _owner = owner; + Location entLoc = owner.getLocation(); + entLoc.setPitch(0F); + Host.CreatureAllowOverride = true; _ent = owner.getWorld().spawn(owner.getLocation(), ArmorStand.class); Host.CreatureAllowOverride = false; @@ -44,9 +47,15 @@ public class PlayerCopyPaintball _ent.setBasePlate(false); _ent.setVisible(false); - Location loc = owner.getLocation(); - _ent.teleport(owner); - _ent.setHeadPose(new EulerAngle(Math.toRadians(UtilAlg.GetPitch(loc.getDirection())), Math.toRadians(UtilAlg.GetYaw(loc.getDirection())), 0)); + //Rand pose + int rA = UtilMath.r(20) - 3; + int lA = UtilMath.r(20) - 3; + int rL = UtilMath.r(20) - 3; + int lL = UtilMath.r(20) - 3; + _ent.setRightArmPose(new EulerAngle(Math.toRadians(rA < 0 ? 360 - rA : rA), 0, Math.toRadians(Math.abs(rA)))); + _ent.setRightLegPose(new EulerAngle(Math.toRadians(rL < 0 ? 360 - rL : rL), 0, Math.toRadians(Math.abs(rL)))); + _ent.setLeftArmPose(new EulerAngle(Math.toRadians(lA < 0 ? 360 - lA : lA), 0, Math.toRadians(360 - Math.abs(lA)))); + _ent.setLeftLegPose(new EulerAngle(Math.toRadians(lL < 0 ? 360 - lL : rA), 0, Math.toRadians(360 - Math.abs(lL)))); //Armor _ent.getEquipment().setArmorContents(owner.getInventory().getArmorContents()); From b5967a12059ccd3cf3bbaba796152e8758937125 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Sun, 6 Dec 2015 17:14:51 -0500 Subject: [PATCH 13/45] Uncommented bouncy balls --- .../src/nautilus/game/arcade/GameType.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 bbde4499e..5eedb306e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -8,6 +8,7 @@ import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl; import nautilus.game.arcade.game.games.barbarians.Barbarians; import nautilus.game.arcade.game.games.bossbattles.BossBattles; +import nautilus.game.arcade.game.games.bouncyballs.BouncyBalls; import nautilus.game.arcade.game.games.bridge.Bridge; import nautilus.game.arcade.game.games.build.Build; import nautilus.game.arcade.game.games.cards.Cards; @@ -128,7 +129,7 @@ public enum GameType MonsterMaze(MonsterMaze.class, GameDisplay.MonsterMaze), MonsterLeague(MonsterLeague.class, GameDisplay.MonsterLeague), -// BouncyBalls(BouncyBalls.class, GameDisplay.BouncyBalls), + BouncyBalls(BouncyBalls.class, GameDisplay.BouncyBalls), Event(EventGame.class, GameDisplay.Event, new GameType[]{ GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, From 09f7a03444e903467e83e966efb8233785a9c849 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Sun, 6 Dec 2015 20:00:22 -0500 Subject: [PATCH 14/45] Quick changes to improve things. --- .../src/mineplex/core/hologram/Hologram.java | 7 +- .../game/core/damage/CustomDamageEvent.java | 15 +++- .../game/core/damage/DamageManager.java | 2 +- .../game/games/paintball/Paintball.java | 86 ++++++++++++++++++ .../games/paintball/PlayerCopyPaintball.java | 28 +++++- .../kits/perks/PerkPaintballSniper.java | 88 +++++++++++++------ 6 files changed, 193 insertions(+), 33 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java index e772427cc..a569b9612 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/hologram/Hologram.java @@ -4,11 +4,14 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; + import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutEntity; @@ -16,8 +19,6 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; public class Hologram { @@ -313,7 +314,7 @@ public class Hologram */ public Hologram removePlayer(Player player) { - return addPlayer(player.getName()); + return removePlayer(player.getName()); } /** diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java index ef2f17d9b..8f2788e66 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java @@ -3,8 +3,6 @@ package mineplex.minecraft.game.core.damage; import java.util.ArrayList; import java.util.HashMap; -import mineplex.core.common.util.C; - import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -15,6 +13,8 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import mineplex.core.common.util.C; + public class CustomDamageEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); @@ -43,6 +43,7 @@ public class CustomDamageEvent extends Event implements Cancellable private boolean _knockback = true; private boolean _damageeBrute = false; private boolean _damageToLevel = true; + private boolean _arrowShow = true; public CustomDamageEvent(LivingEntity damagee, LivingEntity damager, Projectile projectile, Location knockbackOrigin, DamageCause cause, double damage, boolean knockback, boolean ignoreRate, boolean ignoreArmor, String initialSource, @@ -167,6 +168,16 @@ public class CustomDamageEvent extends Event implements Cancellable { return _projectile; } + + public void setShowArrows(boolean show) + { + _arrowShow = show; + } + + public boolean getShowArrows() + { + return _arrowShow; + } public DamageCause GetCause() { 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 af1525e2a..8d3d35d16 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 @@ -378,7 +378,7 @@ public class DamageManager extends MiniPlugin event.GetDamageeEntity().playEffect(EntityEffect.HURT); //Sticky Arrow - if (event.GetCause() == DamageCause.PROJECTILE && event.GetProjectile() != null && event.GetProjectile() instanceof Arrow) + if (event.GetCause() == DamageCause.PROJECTILE && event.GetProjectile() != null && event.GetProjectile() instanceof Arrow && event.getShowArrows()) ((CraftLivingEntity)event.GetDamageeEntity()).getHandle().o(((CraftLivingEntity)event.GetDamageeEntity()).getHandle().bv() + 1); //Knockback 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 ec8a80299..d345843d0 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 @@ -33,8 +33,11 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.potion.PotionEffectType; +import org.bukkit.scoreboard.NameTagVisibility; +import org.bukkit.scoreboard.Team; 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.UtilBlock; @@ -45,6 +48,7 @@ import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.hologram.Hologram.HologramTarget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; @@ -116,6 +120,14 @@ public class Paintball extends TeamGame this.GetTeamList().get(1).SetColor(ChatColor.RED); this.GetTeamList().get(1).SetName("Nether"); } + + @EventHandler + public void onNameTag(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Prepare) + for (Team team : Scoreboard.GetScoreboard().getTeams()) + team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); + } @EventHandler(priority = EventPriority.HIGHEST) public void ColorArmor(PlayerPrepareTeleportEvent event) @@ -170,6 +182,8 @@ public class Paintball extends TeamGame if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); + + event.getEntity().remove(); } }, 1); } @@ -188,7 +202,10 @@ public class Paintball extends TeamGame if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); + + event.getEntity().remove(); } + } } @@ -202,6 +219,7 @@ public class Paintball extends TeamGame PlayerCopyPaintball copy = _doubles.remove(player); copy.GetEntity().remove(); copy.GetHolo().stop(); + copy.GetSaveMe().stop(); } } @@ -235,6 +253,8 @@ public class Paintball extends TeamGame event.AddMod("Paintball", "Paintball", 2, true); event.AddKnockback("Paintball", 2); + + event.setShowArrows(false); Player damagee = event.GetDamageePlayer(); if (damagee == null) @@ -487,6 +507,7 @@ public class Paintball extends TeamGame //Remove Copy copy.GetEntity().remove(); copy.GetHolo().stop(); + copy.GetSaveMe().stop(); } }, 4); } @@ -542,4 +563,69 @@ public class Paintball extends TeamGame { event.setCancelled(true); } + + @EventHandler + public void updateCloneHolograms(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + for (PlayerCopyPaintball clone : _doubles.values()) + { + if (clone.GetHolo().getHologramTarget() == HologramTarget.WHITELIST) + { + //Other team blacklist + clone.GetHolo().setHologramTarget(HologramTarget.BLACKLIST); + + for (Player cur : GetPlayers(false)) + { + if (!IsAlive(cur)) + { + if (clone.GetHolo().containsPlayer(cur)) + clone.GetHolo().removePlayer(cur); + } + else + { + if (GetTeam(cur) != GetTeam(clone.GetPlayer())) + { + if (!clone.GetHolo().containsPlayer(cur)) + clone.GetHolo().addPlayer(cur); + } + else if (clone.GetHolo().containsPlayer(cur)) + { + clone.GetHolo().removePlayer(cur); + } + } + } + clone.GetHolo().start(); + } + + clone.setSaveMeFlop(!clone.getSaveMeFlop()); + clone.GetSaveMe().setText((clone.getSaveMeFlop() ? C.cRedB : C.cWhiteB) + "SAVE ME!"); + + for (Player player : GetTeam(clone.GetPlayer()).GetPlayers(false)) + { + if (!IsAlive(player)) // Remove if it's not alive + { + if (clone.GetSaveMe().containsPlayer(player)) + clone.GetSaveMe().removePlayer(player); + } + else + { + boolean hasPotion = UtilInv.contains(player, Material.POTION, (byte) -1, 1); + if (clone.GetSaveMe().containsPlayer(player)) + { + if (!hasPotion) // No potions left + { + clone.GetSaveMe().removePlayer(player); + } + } + else if (hasPotion) + { + clone.GetSaveMe().addPlayer(player); + } + } + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java index 595aa9889..f89e0c66d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java @@ -14,6 +14,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.Hologram.HologramTarget; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.game.Game; @@ -25,6 +26,9 @@ public class PlayerCopyPaintball private ArmorStand _ent; private Hologram _holo; + private Hologram _saveMe; + + private boolean _saveMeFlop = false; public PlayerCopyPaintball(Game host, Player owner, Player paintedBy, ChatColor nameColor) { @@ -69,9 +73,16 @@ public class PlayerCopyPaintball _ent.setHelmet(skull); //Name - _holo = new Hologram(host.Manager.getHologramManager(), _ent.getEyeLocation().clone().add(0, .5, 0)); + _holo = new Hologram(host.Manager.getHologramManager(), _ent.getLocation().clone().add(0, 2.2, 0)); _holo.setText(C.cWhite + C.Bold + C.Scramble + "XX" + ChatColor.RESET + " " + nameColor + owner.getName() + " " + C.cWhite + C.Bold + C.Scramble + "XX", C.cWhite + "Painted by " + host.GetTeam(paintedBy).GetColor() + paintedBy.getName()); + _holo.setHologramTarget(HologramTarget.WHITELIST); _holo.start(); + + //Save me + _saveMe = new Hologram(host.Manager.getHologramManager(), _ent.getLocation().clone().add(0, 2.8, 0)); + _saveMe.setText(C.cRedB + "SAVE ME!"); + _saveMe.setHologramTarget(HologramTarget.WHITELIST); + _saveMe.start(); } public LivingEntity GetEntity() @@ -88,4 +99,19 @@ public class PlayerCopyPaintball { return _holo; } + + public Hologram GetSaveMe() + { + return _saveMe; + } + + public boolean getSaveMeFlop() + { + return _saveMeFlop; + } + + public void setSaveMeFlop(boolean flop) + { + _saveMeFlop = flop; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java index 657f2e3d7..320a71a1c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java @@ -1,13 +1,16 @@ package nautilus.game.arcade.game.games.paintball.kits.perks; import java.util.ArrayList; -import java.util.HashMap; +import java.util.HashSet; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEvent; @@ -27,6 +30,8 @@ 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.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketInfo; import mineplex.core.recharge.Recharge; import mineplex.core.recharge.RechargedEvent; import mineplex.core.updater.UpdateType; @@ -36,9 +41,10 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.kit.Perk; import net.md_5.bungee.api.ChatColor; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_8_R3.EntityArrow; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; -public class PerkPaintballSniper extends Perk +public class PerkPaintballSniper extends Perk implements IPacketHandler { /** * Created by: Mysticate @@ -47,15 +53,18 @@ public class PerkPaintballSniper extends Perk private static class Bullet { + public Player Shooter; public int Damage; public Location LastSeen; } - private HashMap _crouching = new HashMap(); + private HashSet _crouching = new HashSet(); private NautHashMap _fired = new NautHashMap(); private double _velocity = 15; + private boolean _spawning = false; + public PerkPaintballSniper() { super("Sniper Rifle", new String[] @@ -63,7 +72,14 @@ public class PerkPaintballSniper extends Perk C.cYellow + "Crouch" + C.cGray + " to use " + C.cGreen + "Scope", C.cYellow + "Right-Click" + C.cGray + " to use " + C.cGreen + "Sniper Rifle", "Experience Bar represents damage." - }); + }); + } + + @SuppressWarnings("unchecked") + @Override + public void registeredEvents() + { + Manager.getPacketHandler().addPacketHandler(this, PacketPlayOutSpawnEntity.class); } @EventHandler @@ -107,17 +123,25 @@ public class PerkPaintballSniper extends Perk if (!Recharge.Instance.use(player, GetName(), 1000, true, true)) return; - Arrow proj = player.launchProjectile(Arrow.class, player.getEyeLocation().getDirection().clone().multiply(_velocity)); + net.minecraft.server.v1_8_R3.World world = ((CraftWorld) player.getWorld()).getHandle(); + EntityArrow launch = new EntityArrow(world, ((CraftPlayer) player).getHandle(), 0F); + Location location = player.getEyeLocation(); - PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(); - packet.a = new int[]{proj.getEntityId()}; + launch.projectileSource = player; + launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); - for (Player viewer : UtilServer.getPlayers()) - UtilPlayer.sendPacket(viewer, packet); - + ((Projectile) launch.getBukkitEntity()).setVelocity(player.getEyeLocation().getDirection().clone().multiply(_velocity)); + + _spawning = true; + world.addEntity(launch); + _spawning = false; + + Arrow proj = (Arrow) launch.getBukkitEntity(); + proj.setMetadata("color", new FixedMetadataValue(Manager.getPlugin(), Manager.GetGame().GetTeam(player).GetColor().ordinal())); Bullet bullet = new Bullet(); + bullet.Shooter = player; bullet.Damage = getPaintDamage(player); bullet.LastSeen = proj.getLocation(); @@ -140,11 +164,9 @@ public class PerkPaintballSniper extends Perk if (!Manager.GetGame().IsLive()) return; - + //Cleanup check - HashMap copyMap = new HashMap(); - copyMap.putAll(_crouching); - for (Player player : copyMap.keySet()) + for (Player player : new HashSet(_crouching)) { boolean remove = false; if (!player.isOnline()) @@ -167,7 +189,7 @@ public class PerkPaintballSniper extends Perk if (remove) { - if (_crouching.containsKey(player)) + if (_crouching.contains(player)) _crouching.remove(player); player.setExp(0F); @@ -193,10 +215,10 @@ public class PerkPaintballSniper extends Perk if (!UtilInv.IsItem(player.getItemInHand(), Material.STONE_HOE, (byte) -1)) continue; - if (_crouching.containsKey(player)) + if (_crouching.contains(player)) continue; - _crouching.put(player, System.currentTimeMillis()); + _crouching.add(player); // Zoom addEffects(player); @@ -212,10 +234,10 @@ public class PerkPaintballSniper extends Perk if (!Kit.HasKit(player)) continue; - if (!_crouching.containsKey(player)) + if (!_crouching.contains(player)) continue; - player.setExp((float) Math.min(.999F, player.getExp() + .0125)); + player.setExp((float) Math.min(.999F, player.getExp() + .01666)); } } @@ -238,10 +260,13 @@ public class PerkPaintballSniper extends Perk while (curRange <= distance) { Location newTarget = bullet.LastSeen.add(UtilAlg.getTrajectory(bullet.LastSeen, proj.getLocation()).multiply(curRange)); - + //Progress Forwards curRange += 0.8; + if (UtilMath.offset(bullet.Shooter.getLocation(), newTarget) < 2) + continue; + ChatColor color = ChatColor.values()[proj.getMetadata("color").get(0).asInt()]; if (color == ChatColor.BLUE || color == ChatColor.AQUA) { @@ -266,17 +291,19 @@ public class PerkPaintballSniper extends Perk } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void removeEffects(GameStateChangeEvent event) + public void clean(GameStateChangeEvent event) { if (event.GetState() != GameState.End) return; - for (Player player : _crouching.keySet()) + for (Player player : _crouching) { removeEffects(player); } _crouching.clear(); + + Manager.getPacketHandler().removePacketHandler(this); } private void removeEffects(Player player) @@ -293,7 +320,7 @@ public class PerkPaintballSniper extends Perk { // Zoom if (!Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) - Manager.GetCondition().Factory().Slow(GetName(), player, null, Double.MAX_VALUE, 8, false, false, false, false); + Manager.GetCondition().Factory().Slow(GetName(), player, null, Double.MAX_VALUE, 8, false, false, false, true); } public int getPaintDamage(Arrow proj) @@ -306,9 +333,18 @@ public class PerkPaintballSniper extends Perk private int getPaintDamage(Player player) { - if (!_crouching.containsKey(player)) + if (!_crouching.contains(player)) return 1; - return (int) Math.max(1, Math.min(4, Math.floor((System.currentTimeMillis() - _crouching.get(player)) / 1000))); + return 1 + (int) Math.floor(player.getExp() * 10 / 3); + } + + @Override + public void handle(PacketInfo packetInfo) + { + if (!_spawning) + return; + + packetInfo.setCancelled(true); } } \ No newline at end of file From 667f0762020813d19458493c5cd95e4dc17988ed Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Wed, 9 Dec 2015 10:46:05 +0000 Subject: [PATCH 15/45] fixed unsafe timer --- .../src/mineplex/game/clans/spawn/Spawn.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java index 50a251707..36ebdea21 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -22,10 +22,8 @@ import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; @@ -45,7 +43,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.items.generation.WeightSet; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; -import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; import mineplex.minecraft.game.classcombat.item.event.WebTossEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -203,7 +200,7 @@ public class Spawn extends MiniPlugin + ChatColor.YELLOW + F.time(UtilTime.convertString(COMBAT_TAG_DURATION - duration, 1, TimeUnit.FIT)); UtilTextMiddle.display(null, message, 0, 20, 0, cur); - _clansManager.getCondition().Factory().Custom(COMBAT_TAG_NAME, cur, cur, ConditionType.CUSTOM, 1, 0, false, Material.FIRE, (byte)0, true); + _clansManager.getCondition().Factory().Custom(COMBAT_TAG_NAME, cur, cur, ConditionType.CUSTOM, COMBAT_TAG_DURATION / 1000, 0, false, Material.FIRE, (byte)0, true); playUnsafeParticles(cur); } else if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION + 600)) @@ -325,7 +322,7 @@ public class Spawn extends MiniPlugin if (isInSpawn(monster)) { - int size = event.getDrops().size(); +// int size = event.getDrops().size(); event.getDrops().clear(); } } From 9137fcfe4063ef88dfba3de0b9e9776a4511d83c Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Mon, 14 Dec 2015 12:39:00 +0000 Subject: [PATCH 16/45] loads of changes (pvp timer, unsafe stuff) --- .../src/mineplex/core/stats/PlayerStats.java | 9 +- .../mineplex/core/stats/StatsRepository.java | 6 +- .../game/clans/clans/ClansManager.java | 34 +-- .../game/clans/clans/ClansPlayerStats.java | 18 ++ .../game/clans/clans/ClansUtility.java | 3 +- .../clans/clans/commands/ClansCommand.java | 2 +- .../clans/clans/playtime/PlayingClient.java | 13 ++ .../game/clans/clans/playtime/Playtime.java | 86 +++++++ .../playtime/command/PlayTimeCommand.java | 81 +++++++ .../clans/clans/playtime/command/cemde.java | 30 +++ .../game/clans/clans/pvptimer/PvpTimer.java | 217 ++++++++++++++++++ .../clans/clans/pvptimer/PvpTimerClient.java | 20 ++ .../pvptimer/command/PvPTimerCommand.java | 61 +++++ .../scoreboard/ClansScoreboardManager.java | 39 +++- .../game/clans/gameplay/Gameplay.java | 23 +- .../src/mineplex/game/clans/spawn/Spawn.java | 76 ++++-- .../game/clans/tutorials/Tutorial.java | 12 +- .../game/clans/tutorials/TutorialManager.java | 7 +- .../TutorialGettingStarted.java | 13 +- .../minecraft/game/core/combat/CombatLog.java | 11 + .../game/core/combat/CombatManager.java | 15 +- 21 files changed, 710 insertions(+), 66 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayerStats.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/PlayTimeCommand.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimerClient.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/PlayerStats.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/PlayerStats.java index 9ceb59d83..8bf28aa5b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/PlayerStats.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/PlayerStats.java @@ -21,7 +21,14 @@ public class PlayerStats return _statHash.get(statName); } - + + public long setStat(String statName, long value) + { + _statHash.put(statName, value); + + return _statHash.get(statName); + } + public long getStat(String statName) { return _statHash.containsKey(statName) ? _statHash.get(statName) : 0L; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java index 2b92728ff..d32b5fee3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java @@ -14,6 +14,7 @@ import mineplex.core.database.RepositoryBase; import mineplex.core.database.ResultSetCallable; import mineplex.core.database.column.ColumnVarChar; import mineplex.database.Tables; +import net.md_5.bungee.chat.TranslatableComponentSerializer; import org.jooq.DSLContext; import org.jooq.Insert; @@ -134,8 +135,9 @@ public class StatsRepository extends RepositoryBase .on(Tables.stats.id.eq(Tables.accountStat.statId)) .where(Tables.accountStat.accountId.eq(DSL.select(Tables.accounts.id) .from(Tables.accounts) - .where(Tables.accounts.name.eq(playerName))) - ).fetch(); + .where(Tables.accounts.name.eq(playerName)).limit(1)) + ) + .fetch(); if (result.isNotEmpty()) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index d97ad7c78..d51bb3f24 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -10,7 +10,6 @@ import java.util.TimeZone; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -66,7 +65,6 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansUtility.ClanRelation; -import mineplex.game.clans.clans.claimview.ClaimVisualizer; import mineplex.game.clans.clans.commands.ClanManagementCommand; import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand; @@ -81,7 +79,9 @@ import mineplex.game.clans.clans.gui.ClanShop; import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.map.ItemMapManager; import mineplex.game.clans.clans.observer.ObserverManager; +import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.potato.PotatoManager; +import mineplex.game.clans.clans.pvptimer.PvpTimer; import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler; import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; import mineplex.game.clans.clans.regions.ClansRegions; @@ -155,6 +155,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati private LootManager _lootManager; private DonationManager _donationManager; + private Playtime _playTracker; + private TutorialManager _tutorialManager; private ClassManager _classManager; @@ -228,18 +230,12 @@ public class ClansManager extends MiniClientPluginimplements IRelati TaskManager taskManager = new TaskManager(plugin, _clientManager, webServerAddress); - _tutorialManager = new TutorialManager(plugin, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler); - ClanTips = new ClanTips(plugin, this, preferencesManager); - new StuckManager(this); - - _scoreboard = new ClansScoreboardManager(plugin, _tutorialManager, this, _warManager, _worldEvent, clientManager, donationManager); // new MurderManager(plugin, this); _clanAdmin = new ClansAdmin(this); _clanBlocks = new ClansBlocks(); - _clanDataAccess = new ClansDataAccessLayer(this, _scoreboard); _clanDisplay = new ClansDisplay(plugin, this); _clanGame = new ClansGame(plugin, this); _clanUtility = new ClansUtility(this); @@ -266,11 +262,12 @@ public class ClansManager extends MiniClientPluginimplements IRelati new ObserverManager(plugin, _condition, this); new ClanEnergyTracker(plugin, this); + new StuckManager(this); new ClansAlphaManager(this, taskManager); - + new PotatoManager(plugin, this); - + new Weapon(plugin, energy); new Gameplay(plugin, this, blockRestore, damageManager); _projectileManager = new ProjectileManager(plugin); @@ -298,7 +295,15 @@ public class ClansManager extends MiniClientPluginimplements IRelati ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager); _classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop"); - ClanEnergyManager clanEnergyManager = new ClanEnergyManager(plugin, this, clientManager, donationManager); + new ClanEnergyManager(plugin, this, clientManager, donationManager); + + _playTracker = new Playtime(this, statsManager); + new PvpTimer(this, _playTracker, statsManager); + + _tutorialManager = new TutorialManager(plugin, _playTracker, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler); + + _scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, clientManager, donationManager); + _clanDataAccess = new ClansDataAccessLayer(this, _scoreboard); for (ClanToken token : _clanDataAccess.getRepository().retrieveClans()) { @@ -377,7 +382,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati @Override public void addCommands() { - addCommand(new ClansCommand(this, _tutorialManager)); + addCommand(new ClansCommand(this)); addCommand(new RegionsCommand(this)); addCommand(new ClansChatCommand(this)); addCommand(new ClansAllyChatCommand(this)); @@ -460,7 +465,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati int x = Math.abs(location.getBlockX()); int z = Math.abs(location.getBlockZ()); - return (x <= CLAIMABLE_RADIUS && z <= CLAIMABLE_RADIUS) && !Spawn.getInstance().isInSpawn(location); + return (x <= CLAIMABLE_RADIUS && z <= CLAIMABLE_RADIUS) && !Spawn.getInstance().isSafe(location); } public boolean isFields(Location location) @@ -624,7 +629,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati String rank = _clientManager.Get(event.getPlayer()).GetRank().getTag(true, true) + " "; - if (!_clientManager.Get(event.getPlayer()).GetRank().has(Rank.MEDIA)) + if (!_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH)) rank = ""; if (client.isClanChat() && clan != null) @@ -957,6 +962,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati _blockRestore.onDisable(); _worldEvent.onDisable(); _goldManager.onDisable(); + _playTracker.onDisable(); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayerStats.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayerStats.java new file mode 100644 index 000000000..6b8d45429 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansPlayerStats.java @@ -0,0 +1,18 @@ +package mineplex.game.clans.clans; + +public enum ClansPlayerStats +{ + PLAY_TIME("Clans.TimePlaying"); + + private String _id; + + ClansPlayerStats(String id) + { + _id = id; + } + + public String id() + { + return _id; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index c27bcf57a..6a1356d8c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -24,6 +24,7 @@ import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; import mineplex.game.clans.core.repository.ClanTerritory; +import mineplex.game.clans.spawn.Spawn; public class ClansUtility { @@ -238,7 +239,7 @@ public class ClansUtility public boolean isSafe(Player player) { - if (!UtilTime.elapsed(Clans.getCombatManager().Get(player).GetLastDamaged(), 15000)) return false; + if (!UtilTime.elapsed(Clans.getCombatManager().Get(player).GetLastDamaged(), Spawn.COMBAT_TAG_DURATION)) return false; return isSafe(player.getLocation()); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index f9bab36a5..3fda15789 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -35,7 +35,7 @@ public class ClansCommand extends CommandBase { private ClansManager _manager; - public ClansCommand(ClansManager plugin, TutorialManager tutorialManager) + public ClansCommand(ClansManager plugin) { super(plugin, Rank.ALL, "c", "clan", "clans", "factions"); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java new file mode 100644 index 000000000..fd68d2949 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java @@ -0,0 +1,13 @@ +package mineplex.game.clans.clans.playtime; + +public class PlayingClient +{ + public long StartTime; + public boolean FirstSession; + + public PlayingClient(boolean first) + { + StartTime = System.currentTimeMillis(); + FirstSession = first; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java new file mode 100644 index 000000000..0a433efb7 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java @@ -0,0 +1,86 @@ +package mineplex.game.clans.clans.playtime; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import mineplex.core.MiniClientPlugin; +import mineplex.core.stats.StatsManager; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.ClansPlayerStats; +import mineplex.game.clans.clans.playtime.command.PlayTimeCommand; +import mineplex.game.clans.clans.playtime.command.cemde; + +public class Playtime extends MiniClientPlugin +{ + private StatsManager _statsManager; + + public Playtime(ClansManager clans, StatsManager statsManager) + { + super("Clans Play Time Tracker", clans.getPlugin()); + + _statsManager = statsManager; + + addCommand(new PlayTimeCommand(_statsManager, this)); + } + + @Override + public void disable() + { + for (Player player : Bukkit.getOnlinePlayers()) + { + save(player); + } + } + + // Seconds + public long getPlaytime(Player player) + { + return _statsManager.Get(player).getStat(ClansPlayerStats.PLAY_TIME.id()); + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) + { + Set(event.getPlayer(), AddPlayer(event.getPlayer().getName())); + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) + { + save(event.getPlayer()); + } + + @EventHandler + public void onPlayerKicked(PlayerKickEvent event) + { + save(event.getPlayer()); + } + + private void save(Player player) + { + long timePlaying = getUnsavedPlaytime(player); + + _statsManager.incrementStat(player, ClansPlayerStats.PLAY_TIME.id(), timePlaying); + + // Increment main time in game as well + _statsManager.incrementStat(player, "Global.TimeInGame", timePlaying); + + Get(player).StartTime = System.currentTimeMillis(); + } + + @Override + protected PlayingClient AddPlayer(String player) + { + return new PlayingClient(_statsManager.Get(player).getStat(ClansPlayerStats.PLAY_TIME.id()) == 0); + } + + // Seconds + public long getUnsavedPlaytime(Player player) + { + return (System.currentTimeMillis() - Get(player).StartTime) / 1000; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/PlayTimeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/PlayTimeCommand.java new file mode 100644 index 000000000..30b82b248 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/PlayTimeCommand.java @@ -0,0 +1,81 @@ +package mineplex.game.clans.clans.playtime.command; + +import java.sql.SQLException; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.stats.PlayerStats; +import mineplex.core.stats.StatsManager; +import mineplex.game.clans.clans.ClansPlayerStats; +import mineplex.game.clans.clans.playtime.Playtime; + +public class PlayTimeCommand extends CommandBase +{ + private Playtime _playTracker; + + public PlayTimeCommand(StatsManager plugin, Playtime tracker) + { + super(plugin, Rank.MODERATOR, "clanstime"); + + _playTracker = tracker; + } + + @Override + public void Execute(final Player caller, final String[] args) + { + if (args == null || args.length == 0) + { + UtilPlayer.message(caller, F.main("Clans", "Usage: /clanstime ")); + } + else + { + final Player target = UtilPlayer.searchOnline(caller, args[0], false); + + if (target == null) + { + Plugin.getPlugin().getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() + { + @Override + public void run() + { + try + { + final PlayerStats stats = Plugin.getOfflinePlayerStats(args[0]); + + Plugin.getPlugin().getServer().getScheduler().runTask(Plugin.getPlugin(), new Runnable() + { + @Override + public void run() + { + if (stats == null) + { + UtilPlayer.message(caller, F.main("Clans", "Player " + F.elem(args[0]) + " not found!")); + } + else + { + long time = stats.getStat(ClansPlayerStats.PLAY_TIME.id()); + UtilPlayer.message(caller, F.main("Clans", F.name(args[0]) + " has spent " + F.elem(UtilTime.convertString(time * 1000L, 1, UtilTime.TimeUnit.FIT)) + " playing Clans.")); + } + } + }); + } + catch (SQLException e) + { + UtilPlayer.message(caller, F.main("Clans", F.name(target.getName()) + " does not have any play time in Clans.")); + } + } + }); + } + else + { + long time = Plugin.Get(target).getStat(ClansPlayerStats.PLAY_TIME.id()); + UtilPlayer.message(caller, F.main("Clans", F.name(target.getName()) + " has spent " + F.elem(UtilTime.convertString(time * 1000L, 1, UtilTime.TimeUnit.FIT) + " (+" + UtilTime.MakeStr(_playTracker.getUnsavedPlaytime(target) * 1000) + ")") + " playing Clans.")); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java new file mode 100644 index 000000000..9dc1c22fe --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java @@ -0,0 +1,30 @@ +package mineplex.game.clans.clans.playtime.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.stats.StatsManager; +import mineplex.game.clans.clans.ClansPlayerStats; +import mineplex.game.clans.clans.pvptimer.PvpTimer; + +public class cemde extends CommandBase +{ + PvpTimer _timer; + public cemde(StatsManager plugin, PvpTimer timer) + { + super(plugin, Rank.ALL, "rstime"); + _timer = timer; + } + + @Override + public void Execute(final Player caller, final String[] args) + { + Plugin.Get(caller).setStat(ClansPlayerStats.PLAY_TIME.id(), 0); + _timer.Get(caller).Skipped = false; + _timer.Get(caller).InformedTimes.clear(); + + UtilPlayer.message(caller, "Reset time."); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java new file mode 100644 index 000000000..c2eccc0d4 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java @@ -0,0 +1,217 @@ +package mineplex.game.clans.clans.pvptimer; + +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; + +import mineplex.core.MiniClientPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.stats.StatsManager; +import mineplex.core.task.TaskManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.playtime.Playtime; +import mineplex.game.clans.clans.playtime.command.cemde; +import mineplex.game.clans.clans.pvptimer.command.PvPTimerCommand; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class PvpTimer extends MiniClientPlugin +{ + private Playtime _tracker; + + public static final String SKIPPED_TASK = "PvpTimer.Skipped"; + + private static long TIMER_LENGTH = 30 * 60; + + public PvpTimer(ClansManager clans, Playtime playtime, StatsManager statsManager) + { + super("PvP Timer", clans.getPlugin()); + _tracker = playtime; + + addCommand(new cemde(statsManager, this)); + } + + @Override + public void addCommands() + { + addCommand(new PvPTimerCommand(this)); + } + + public void disableFor(final Player caller) + { + TaskManager.Instance.completedTask(new Callback() { + @Override + public void run(Boolean data) + { + Get(caller).Skipped = true; + caller.playSound(caller.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 0.75f); + } + }, caller, "PvpTimer.Skipped"); + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) + { + final Player player = event.getPlayer(); + + if (hasTimer(player)) + { + Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { + public void run() + { + UtilTextMiddle.display(C.cGold + "PvP Timer", "will end in " + UtilTime.MakeStr(getPvPTimerLeft(player) * 1000), 40, 70, 40, player); + } + }, 10); + + UtilPlayer.message(player, F.main("Clans", "You are currently on your PvP timer. It will end in " + F.elem(UtilTime.MakeStr(getPvPTimerLeft(player) * 1000)))); + UtilPlayer.message(player, F.main("Clans", "Until it ends, you are immune to, and unable to deal PvP damage.")); + UtilPlayer.message(player, F.main("Clans", "If you would like to disable the PvP timer permanently, then type " + F.elem("/pvptimer") + ", and follow the instructions given.")); + } + } + + @EventHandler + public void inform(UpdateEvent event) + { + if (event.getType() == UpdateType.TWOSEC) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + if (hasTimer(player)) + { + long time = getPvPTimerLeft(player); + PvpTimerClient client = Get(player); + + // end + if (time <= 2) + { + UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " has ended!")); + UtilPlayer.message(player, F.main("Clans", "You are now completely open to attacks, and you can also attack others.")); + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 0.75f); + } + // 5 secs + else if (time <= 5 && !client.InformedTimes.contains(5)) + { + UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("5.0 Seconds"))); + UtilTextMiddle.display("Pvp Timer", "ending in 5 Seconds"); + client.InformedTimes.add(5); + } + // 10 secs + else if (time <= 10 && !client.InformedTimes.contains(10)) + { + UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("10.0 Seconds"))); + UtilTextMiddle.display("Pvp Timer", "ending in 10 Seconds"); + client.InformedTimes.add(10); + } + // 30 secs + else if (time <= 30 && !client.InformedTimes.contains(30)) + { + UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("30.0 Seconds"))); + UtilTextMiddle.display("Pvp Timer", "ending in 30 Seconds"); + client.InformedTimes.add(30); + } + // 1 minute + else if (time <= 1 * 60 && !client.InformedTimes.contains(1 * 60)) + { + UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("1.0 Minute"))); + UtilTextMiddle.display("Pvp Timer", "ending in 1 Minute"); + client.InformedTimes.add(5); + } + // 5 minutes + else if (time <= 5 * 60 && !client.InformedTimes.contains(5 * 60)) + { + UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("5.0 Minutes"))); + UtilTextMiddle.display("Pvp Timer", "ending in 5 Minutes"); + client.InformedTimes.add(5 * 60); + } + // 10 minutes + else if (time <= 10 * 60 && !client.InformedTimes.contains(10 * 60)) + { + UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("10.0 Minutes"))); + UtilTextMiddle.display("Pvp Timer", "ending in 10 Minutes"); + client.InformedTimes.add(10 * 60); + } + // 20 minutes + else if (time <= 20 * 60 && !client.InformedTimes.contains(20 * 60)) + { + UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("20.0 Minutes"))); + UtilTextMiddle.display("Pvp Timer", "ending in 20 Minutes"); + client.InformedTimes.add(20 * 60); + } + } + } + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerAttack(CustomDamageEvent event) + { + if (event.GetDamageePlayer() == null || event.GetDamagerEntity(true) == null) + { + return; + } + + Player victim = event.GetDamageePlayer(); + Player damager = event.GetDamagerPlayer(true); + + boolean victimTimer = victim != null && hasTimer(victim); + boolean damagerTimer = damager != null && hasTimer(damager); + boolean bothMsg = false; + + if (victimTimer) + { + if (damagerTimer) + { + UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still on your PvP timer. Type " + F.elem("/pvptimer") + " to disable.")); + bothMsg = true; + } + else if (damager != null) + { + UtilPlayer.message(damager, F.main("Clans", F.name(victim.getName()) + " is still on their Pvp timer.")); + } + + event.SetCancelled("Pvp Timer"); + } + + if (damagerTimer) + { + if (victimTimer) + { + if (!bothMsg) UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still on your PvP timer. Type " + F.elem("/pvptimer") + " to disable.")); + } + else if (damager != null) + { + UtilPlayer.message(damager, F.main("Clans", "You are still on your PvP timer.")); + } + + event.SetCancelled("PvP Timer"); + } + + } + + public long getPvPTimerLeft(Player player) + { + long time = (_tracker.getPlaytime(player) + _tracker.getUnsavedPlaytime(player)); + + return (TIMER_LENGTH <= time ? 0 : TIMER_LENGTH - time); + } + + private boolean hasTimer(Player victim) + { + return victim != null && getPvPTimerLeft(victim) > 0 && !Get(victim).Skipped; + } + + @Override + protected PvpTimerClient AddPlayer(String player) + { + return new PvpTimerClient(Bukkit.getPlayer(player)); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimerClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimerClient.java new file mode 100644 index 000000000..82df2bd55 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimerClient.java @@ -0,0 +1,20 @@ +package mineplex.game.clans.clans.pvptimer; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.entity.Player; + +import mineplex.core.task.TaskManager; + +public class PvpTimerClient +{ + public boolean Skipped; + public List InformedTimes; + + public PvpTimerClient(Player player) + { + Skipped = TaskManager.Instance.hasCompletedTask(player, PvpTimer.SKIPPED_TASK); + InformedTimes = new ArrayList<>(); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java new file mode 100644 index 000000000..b8c04949e --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java @@ -0,0 +1,61 @@ +package mineplex.game.clans.clans.pvptimer.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.pvptimer.PvpTimer; + +public class PvPTimerCommand extends CommandBase +{ + public PvPTimerCommand(PvpTimer plugin) + { + super(plugin, Rank.ALL, "pvptimer", "timer", "pvp"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length == 0) + { + if (Plugin.Get(caller).Skipped) + { + UtilPlayer.message(caller, F.main("Clans", "You have skipped your PvP timer.")); + return; + } + + long pvpTimerLeft = Plugin.getPvPTimerLeft(caller); + + if (pvpTimerLeft == 0) + { + UtilPlayer.message(caller, F.main("Clans", "Your PvP timer has ended.")); + } + else + { + UtilPlayer.message(caller, F.main("Clans", "You have " + F.elem(UtilTime.MakeStr(pvpTimerLeft * 1000)) + " before your PvP timer runs out.")); + new JsonMessage(F.main("Clans", "If you would like to permanently disable Pvp timer, click ")) + .extra("here") + .color("green") + .click(ClickEvent.RUN_COMMAND, "/pvptimer yesiconfirmthatiwouldliketodisablemypvptimerforever") + .extra(".") + .color("gray") + + .sendToPlayer(caller); + } + } + else + { + if (args[0].equalsIgnoreCase("yesiconfirmthatiwouldliketodisablemypvptimerforever")) + { + Plugin.disableFor(caller); + UtilPlayer.message(caller, F.main("Clans", "You have disabled your Pvp timer.")); + } + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java index c337f063f..47457a05b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java @@ -1,10 +1,13 @@ package mineplex.game.clans.clans.scoreboard; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.event.OnlineRankUpdateEvent; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; import mineplex.core.scoreboard.PlayerScoreboard; @@ -29,7 +32,7 @@ public class ClansScoreboardManager extends ScoreboardManager private WarManager _warManager; private WorldEventManager _worldEvent; - public ClansScoreboardManager(JavaPlugin plugin, TutorialManager tutorialManager, ClansManager clansManager, WarManager warManager, WorldEventManager worldEvent, CoreClientManager clientManager, DonationManager donationManager) + public ClansScoreboardManager(JavaPlugin plugin, ClansManager clansManager, WarManager warManager, WorldEventManager worldEvent, CoreClientManager clientManager, DonationManager donationManager) { super(plugin, clientManager, donationManager); @@ -37,10 +40,10 @@ public class ClansScoreboardManager extends ScoreboardManager _warManager = warManager; _worldEvent = worldEvent; - init(tutorialManager); + init(); } - private void init(TutorialManager tutorialManager) + private void init() { setTitle("Clans Alpha " + Clans.VERSION); @@ -53,12 +56,40 @@ public class ClansScoreboardManager extends ScoreboardManager data.writeElement(_warManager); data.writeElement(_worldEvent); - for (Tutorial tutorial : tutorialManager.getTutorials().values()) + for (Tutorial tutorial : TutorialManager.Instance.getTutorials().values()) { data.writeElement(tutorial); } } + @EventHandler + public void onGamemodeChanged(PlayerGameModeChangeEvent event) + { + Bukkit.getScheduler().scheduleSyncDelayedTask(_clansManager.getPlugin(), new Runnable() { + public void run() + { + for (Player player : Bukkit.getOnlinePlayers()) + { + refresh(player); + } + } + }, 20); + } + + @EventHandler + public void onRankUpdate(OnlineRankUpdateEvent event) + { + Bukkit.getScheduler().scheduleSyncDelayedTask(_clansManager.getPlugin(), new Runnable() { + public void run() + { + for (Player player : Bukkit.getOnlinePlayers()) + { + refresh(player); + } + } + }, 20); + } + @EventHandler public void drawUpdate(UpdateEvent event) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index 6cb5196a7..fb578a210 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -39,7 +39,6 @@ import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent.State; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; @@ -47,7 +46,6 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilGear; @@ -94,14 +92,14 @@ public class Gameplay extends MiniPlugin Bukkit.getPluginManager().registerEvents(new CustomCreatures(), plugin); } - @EventHandler(priority = EventPriority.LOWEST) - public void spawnDamage(CustomDamageEvent event) - { - if (_clansManager.getClanUtility().getClaim(event.GetDamageeEntity().getLocation()) != null && _clansManager.getClanUtility().getClaim(event.GetDamageeEntity().getLocation()).isSafe(event.GetDamageeEntity().getLocation())) - { - event.SetCancelled("Safe Zone"); - } - } +// @EventHandler(priority = EventPriority.LOWEST) +// public void spawnDamage(CustomDamageEvent event) +// { +// if (_clansManager.getClanUtility().getClaim(event.GetDamageeEntity().getLocation()) != null && _clansManager.getClanUtility().getClaim(event.GetDamageeEntity().getLocation()).isSafe(event.GetDamageeEntity().getLocation())) +// { +// event.SetCancelled("Safe Zone"); +// } +// } @EventHandler public void onPlayerFishing(PlayerFishEvent event) @@ -436,6 +434,11 @@ public class Gameplay extends MiniPlugin { final Block block = event.getBlock(); + if (_clansManager.getClanUtility().isSafe(block.getLocation())) + { + return; + } + if (!UtilItem.isLog(block.getType())) { return; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java index 36ebdea21..118c483ea 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -16,6 +16,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; 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.BlockBurnEvent; import org.bukkit.event.block.BlockFromToEvent; @@ -28,9 +29,11 @@ import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; +import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; @@ -99,7 +102,7 @@ public class Spawn extends MiniPlugin { Block block = event.getToBlock(); - if (block.isLiquid() && isInSpawn(block.getLocation())) + if (block.isLiquid() && isSafe(block.getLocation())) { event.setCancelled(true); } @@ -112,7 +115,7 @@ public class Spawn extends MiniPlugin @EventHandler public void onWebToss(WebTossEvent event) { - if (isInSpawn(event.getLocation())) + if (isSafe(event.getLocation())) { event.setCancelled(true); } @@ -135,7 +138,7 @@ public class Spawn extends MiniPlugin @EventHandler public void onBlockBurn(BlockBurnEvent event) { - if (isInSpawn(event.getBlock().getLocation())) + if (isSafe(event.getBlock().getLocation())) { event.setCancelled(true); } @@ -150,7 +153,7 @@ public class Spawn extends MiniPlugin { if (event.getEntity() instanceof ItemFrame) { - if (isInSpawn(event.getEntity().getLocation())) + if (isSafe(event.getEntity().getLocation())) { event.setCancelled(true); } @@ -162,7 +165,7 @@ public class Spawn extends MiniPlugin { if (event.GetDamageeEntity() instanceof ItemFrame) { - if (isInSpawn(event.GetDamageeEntity().getLocation())) + if (isSafe(event.GetDamageeEntity().getLocation())) { event.SetCancelled("Item Frame Cancel"); } @@ -174,7 +177,7 @@ public class Spawn extends MiniPlugin { if (event.getEntity() instanceof ItemFrame) { - if (isInSpawn(event.getEntity().getLocation())) + if (isSafe(event.getEntity().getLocation())) { event.setCancelled(true); } @@ -189,9 +192,9 @@ public class Spawn extends MiniPlugin for (Player cur : UtilServer.getPlayers()) { - if (isInSpawn(cur.getLocation())) + if (isSafe(cur.getLocation())) { - long lastDamager = _clansManager.getCombatManager().Get(cur).GetLastCombat(); + long lastDamager = _clansManager.getCombatManager().Get(cur).GetLastCombatEngaged(); long duration = System.currentTimeMillis() - lastDamager; if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION)) @@ -200,7 +203,7 @@ public class Spawn extends MiniPlugin + ChatColor.YELLOW + F.time(UtilTime.convertString(COMBAT_TAG_DURATION - duration, 1, TimeUnit.FIT)); UtilTextMiddle.display(null, message, 0, 20, 0, cur); - _clansManager.getCondition().Factory().Custom(COMBAT_TAG_NAME, cur, cur, ConditionType.CUSTOM, COMBAT_TAG_DURATION / 1000, 0, false, Material.FIRE, (byte)0, true); + _clansManager.getCondition().Factory().Custom(COMBAT_TAG_NAME, cur, cur, ConditionType.CUSTOM, 1.d, 0, false, Material.FIRE, (byte)0, true); playUnsafeParticles(cur); } else if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION + 600)) @@ -211,6 +214,25 @@ public class Spawn extends MiniPlugin } } + @EventHandler + public void ignoreVelocity(PlayerVelocityEvent event) + { + if (_clansManager.getClanUtility().isSafe(event.getPlayer())) + { + event.setCancelled(true); + System.out.println("cancelled"); + } + } + + @EventHandler + public void onSkill(SkillTriggerEvent event) + { + if (!isSafe(event.GetPlayer().getLocation())) + { + _clansManager.getCombatManager().Get(event.GetPlayer()).SetLastCombatEngaged(System.currentTimeMillis()); + } + } + private void playUnsafeParticles(Player player) { UtilParticle.PlayParticle(UtilParticle.ParticleType.CRIT, player.getEyeLocation().add(0, 0.75d, 0), 0, 0, 0, 0.2f, 35, UtilParticle.ViewDist.NORMAL); @@ -280,7 +302,7 @@ public class Spawn extends MiniPlugin @EventHandler public void onEntitySpawn(CreatureSpawnEvent event) { - if (event.getSpawnReason() != CreatureSpawnEvent.SpawnReason.CUSTOM && isInSpawn(event.getLocation())) + if (event.getSpawnReason() != CreatureSpawnEvent.SpawnReason.CUSTOM && isSafe(event.getLocation())) { event.setCancelled(true); } @@ -335,7 +357,7 @@ public class Spawn extends MiniPlugin @EventHandler public void onEntityTarget(EntityTargetEvent event) { - if (event.getTarget() != null && isInSpawn(event.getTarget().getLocation())) + if (event.getTarget() != null && isSafe(event.getTarget().getLocation())) { event.setCancelled(true); } @@ -350,7 +372,7 @@ public class Spawn extends MiniPlugin { if (event.getPlayer().getGameMode() == GameMode.CREATIVE) return; - if (isInSpawn(event.getBlock().getLocation()) || isInSpawn(event.getPlayer())) + if (isSafe(event.getBlock().getLocation()) || isInSpawn(event.getPlayer())) { event.setCancelled(true); } @@ -363,22 +385,37 @@ public class Spawn extends MiniPlugin @EventHandler public void onPlayerAttack(CustomDamageEvent event) { - Player defender = event.GetDamageePlayer(); + Player victim = event.GetDamageePlayer(); Player attacker = event.GetDamagerPlayer(true); // Get (potentially ranged) attacker - if (defender != null && !isCombatTagged(defender)) + // wat + if (victim == null) { - if (isInSpawn(defender)) + return; + } + + if (attacker == null) + { + return; + } + + if (!isCombatTagged(victim)) + { + if (isInSpawn(victim)) { event.SetCancelled("Safe Zone"); attemptNotify(attacker, "You cannot attack players who are in spawn!"); + return; } - else if (isInSpawn(attacker)) + else if (isInSpawn(attacker) && !isCombatTagged(attacker)) { event.SetCancelled("Safe Zone"); attemptNotify(attacker, "You cannot attack untagged players while in spawn!"); - } + return; + } } + + System.out.println(event.GetCancellers()); } public Location getSpawnLocation() @@ -398,7 +435,7 @@ public class Spawn extends MiniPlugin return _shops.elements(); } - public boolean isInSpawn(Location location) + public boolean isSafe(Location location) { return _clansManager.getClanUtility().isSafe(location); // Check to see if location is in a SafeZone chunk } @@ -411,9 +448,10 @@ public class Spawn extends MiniPlugin return xOffset <= radius && zOffset <= radius; } + // this is basically just isSafe(); public boolean isInSpawn(Entity entity) { - return entity != null && isInSpawn(entity.getLocation()); + return entity != null && isSafe(entity.getLocation()); } public static World getSpawnWorld() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java index 4d6ae6cc3..cc785d827 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java @@ -46,6 +46,7 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.event.ClanJoinEvent; import mineplex.game.clans.clans.event.ClanTipEvent; +import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.economy.GoldManager; import net.minecraft.server.v1_8_R3.PacketPlayOutChat; @@ -89,7 +90,9 @@ public abstract class Tutorial implements ScoreboardElement, Listener protected int _gemReward = -1; protected int _coinReward = -1; - public Tutorial(final GoldManager goldManager, final TaskManager taskManager, final ClansManager clansManager, final DonationManager donationManager, final TutorialManager manager, final PacketHandler packetHandler) + protected Playtime _playtime; + + public Tutorial(final GoldManager goldManager, final Playtime playtime, final TaskManager taskManager, final ClansManager clansManager, final DonationManager donationManager, final TutorialManager manager, final PacketHandler packetHandler) { _clansManager = clansManager; _goldManager = goldManager; @@ -99,6 +102,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener _tasks = new ArrayList>(); _inTutorial = new LinkedHashMap<>(); _nameToTask = new LinkedHashMap<>(); + _playtime = playtime; _manager.getPluginManager().registerEvents(this, _manager.getPlugin()); } @@ -499,6 +503,12 @@ public abstract class Tutorial implements ScoreboardElement, Listener { public void run(Boolean data) { + if (_playtime.Get(player).FirstSession) + { + _playtime.Get(player).StartTime = System.currentTimeMillis(); + _playtime.Get(player).FirstSession = false; + } + cancelFor(player); } }, player, String.format(SKIPPED_TASK, _technicalName)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java index 7468ff139..7ecb05986 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java @@ -11,7 +11,6 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; @@ -20,12 +19,12 @@ import mineplex.core.preferences.PreferencesManager; import mineplex.core.task.TaskManager; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.commands.RestartTutCommand; +import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand; import mineplex.game.clans.tutorials.commands.SkipTutorialCommand; import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted; import net.md_5.bungee.api.ChatColor; -import net.minecraft.server.v1_8_R3.IChatBaseComponent; import net.minecraft.server.v1_8_R3.PacketPlayOutChat; public class TutorialManager extends MiniPlugin @@ -37,7 +36,7 @@ public class TutorialManager extends MiniPlugin private final TaskManager _taskManager; - public TutorialManager(final JavaPlugin plugin, final GoldManager goldManager, final TaskManager taskManager, final DonationManager donationManager, final PreferencesManager preferencesManager, final ClansManager clansManager, final PacketHandler packetHandler) + public TutorialManager(final JavaPlugin plugin, final Playtime playtime, final GoldManager goldManager, final TaskManager taskManager, final DonationManager donationManager, final PreferencesManager preferencesManager, final ClansManager clansManager, final PacketHandler packetHandler) { super("Tutorials", plugin); @@ -45,7 +44,7 @@ public class TutorialManager extends MiniPlugin _taskManager = taskManager; - _tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, clansManager, donationManager, goldManager, taskManager, packetHandler)); + _tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, playtime, clansManager, donationManager, goldManager, taskManager, packetHandler)); packetHandler.addPacketHandler(new IPacketHandler() { public void handle(PacketInfo packet) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java index fe2dde3df..c91e87436 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java @@ -12,6 +12,7 @@ import mineplex.core.task.TaskManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.tutorials.Tutorial; @@ -19,9 +20,9 @@ import mineplex.game.clans.tutorials.TutorialManager; public class TutorialGettingStarted extends Tutorial { - public TutorialGettingStarted(final TutorialManager manager, final ClansManager clansManager, final DonationManager donationManager, final GoldManager goldManager, final TaskManager taskManager, final PacketHandler packetHandler) + public TutorialGettingStarted(final TutorialManager manager, final Playtime playtime, final ClansManager clansManager, final DonationManager donationManager, final GoldManager goldManager, final TaskManager taskManager, final PacketHandler packetHandler) { - super(goldManager, taskManager, clansManager, donationManager, manager, packetHandler); + super(goldManager, playtime, taskManager, clansManager, donationManager, manager, packetHandler); // addTask(new TaskWelcome(this, 1)); @@ -52,8 +53,14 @@ public class TutorialGettingStarted extends Tutorial { player.resetPlayerTime(); player.teleport(Spawn.getEastSpawn()); + + if (_playtime.Get(player).FirstSession) + { + _playtime.Get(player).StartTime = System.currentTimeMillis(); + _playtime.Get(player).FirstSession = false; + } } - + @Override protected void onFinishedDelay(Player player) { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java index 752b71fa6..879fc3c30 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java @@ -28,6 +28,7 @@ public class CombatLog protected CombatComponent LastDamager; protected long _lastDamaged; protected long _lastCombat; + protected long _lastCombatEngaged; public CombatLog(Player player, long expireTime) { @@ -185,6 +186,16 @@ public class CombatLog return _lastCombat; } + public long GetLastCombatEngaged() + { + return _lastCombatEngaged; + } + + public void SetLastCombatEngaged(long time) + { + _lastCombatEngaged = time; + } + public void SetLastCombat(long time) { _lastCombat = time; diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java index a255415e5..b42ae087d 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java @@ -3,8 +3,6 @@ package mineplex.minecraft.game.core.combat; import java.util.HashSet; import java.util.Iterator; -import net.minecraft.server.v1_8_R3.ItemStack; - import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.Arrow; import org.bukkit.entity.Fireball; @@ -18,8 +16,6 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -30,9 +26,12 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.event.ClearCombatEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import net.minecraft.server.v1_8_R3.ItemStack; public class CombatManager extends MiniPlugin { @@ -201,7 +200,7 @@ public class CombatManager extends MiniPlugin // Not Player > No Log if (event.GetDamageePlayer() == null) return; - + // Damager is ENTITY if (event.GetDamagerEntity(true) != null) { @@ -256,8 +255,12 @@ public class CombatManager extends MiniPlugin } if (event.GetDamagerEntity(true) instanceof Player) + { Get((Player)event.GetDamagerEntity(true)).SetLastCombat(System.currentTimeMillis()); - + Get((Player)event.GetDamagerEntity(true)).SetLastCombatEngaged(System.currentTimeMillis()); + Get(event.GetDamageePlayer()).SetLastCombatEngaged(System.currentTimeMillis()); + } + Get(event.GetDamageePlayer()).Attacked( UtilEnt.getName(event.GetDamagerEntity(true)), (int) event.GetDamage(), event.GetDamagerEntity(true), From 871c97f7af3443eb69da60660a34299669f97ad7 Mon Sep 17 00:00:00 2001 From: Cheese Date: Tue, 15 Dec 2015 09:25:44 +1100 Subject: [PATCH 17/45] changed chest %'s --- Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java index 83d2c66a5..eb010d496 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java @@ -9,7 +9,7 @@ public enum RewardType OldChest( 0, 0.06, 0.8, 16), AncientChest( 0, 2, 8, 32), - MythicalChest( 0.3, 4, 16, 72), + MythicalChest( 0.1, 4, 16, 72), WinterChest( 0, 6, 20, 32), SpinnerFiller( 0.1, 1, 4, 20), From 47ad563596de633ffbafbf730a5589bce630f9a4 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Tue, 15 Dec 2015 22:46:30 +1300 Subject: [PATCH 18/45] Spawn nametags far far away from players --- Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java index d757499b7..af619626b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java @@ -539,9 +539,10 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook DataWatcher squidWatcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle())); squidWatcher.a(0, (byte) (0 | 1 << 5)); - final PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(); + PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(); spawnPacket.a = squidId; spawnPacket.b = (byte) EntityType.SQUID.getTypeId(); + spawnPacket.c = 1000000; spawnPacket.l = squidWatcher; @@ -555,9 +556,10 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook UtilPlayer.sendPacket(owner, vehiclePacket); } - final PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(); + PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(); spawnPacket.a = newEntityId; spawnPacket.b = (byte) 30; + spawnPacket.c = 1000000; spawnPacket.l = watcher; From 1da04b84b54ec95561a5a0aeb380ef4fe4f53e5d Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Tue, 15 Dec 2015 11:57:33 +0000 Subject: [PATCH 19/45] test push (change version to 0.17d) --- Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index ce3ff1b86..d27dab663 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -49,7 +49,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer; public class Clans extends JavaPlugin { - public static final String VERSION = "0.17b"; + public static final String VERSION = "0.17d"; private String WEB_CONFIG = "webServer"; // Modules From 6a346790f7d101efa324870a7f16371dcd29f45b Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Tue, 15 Dec 2015 12:00:56 +0000 Subject: [PATCH 20/45] disable tutorial --- .../src/mineplex/game/clans/tutorials/TutorialManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java index 7ecb05986..02bcc6899 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java @@ -44,7 +44,7 @@ public class TutorialManager extends MiniPlugin _taskManager = taskManager; - _tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, playtime, clansManager, donationManager, goldManager, taskManager, packetHandler)); +// _tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, playtime, clansManager, donationManager, goldManager, taskManager, packetHandler)); packetHandler.addPacketHandler(new IPacketHandler() { public void handle(PacketInfo packet) From 2216fdc52c7aa559ccf0d5f276ef371e9cf0072e Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 15 Dec 2015 12:07:34 -0500 Subject: [PATCH 21/45] Dont disable new gadgets in games --- .../src/mineplex/core/gadget/GadgetManager.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index ae95d1832..449a4e52f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -45,6 +45,9 @@ import mineplex.core.gadget.set.SetFrostLord; import mineplex.core.gadget.set.SetRaveSuit; import mineplex.core.gadget.set.SetSpaceSuit; import mineplex.core.gadget.set.SetTitan; +import mineplex.core.gadget.types.ArrowEffectGadget; +import mineplex.core.gadget.types.DeathEffectGadget; +import mineplex.core.gadget.types.DoubleJumpEffectGadget; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetSet; import mineplex.core.gadget.types.GadgetType; @@ -328,6 +331,15 @@ public class GadgetManager extends MiniPlugin { if (gadget instanceof ParticleGadget) continue; + + if (gadget instanceof ArrowEffectGadget) + continue; + + if (gadget instanceof DoubleJumpEffectGadget) + continue; + + if (gadget instanceof DeathEffectGadget) + continue; for (Player player : UtilServer.getPlayers()) gadget.Disable(player); From 3edba0fac69ce5dbc069eb9ae365946bdeea5c7b Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 15 Dec 2015 12:28:06 -0500 Subject: [PATCH 22/45] Fix Grinch Hat --- .../src/mineplex/core/gadget/gadgets/hat/HatGrinch.java | 2 +- .../src/mineplex/core/gadget/types/HatGadget.java | 2 +- .../src/mineplex/core/gadget/types/OutfitGadget.java | 4 ++-- .../Mineplex.Core/src/mineplex/core/reward/RewardManager.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatGrinch.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatGrinch.java index 12ca85a39..9ef68b04a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatGrinch.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatGrinch.java @@ -15,7 +15,7 @@ public class HatGrinch extends HatGadget super(manager, "The Grinch", UtilText.splitLineToArray(C.cGray + "Great! Now where’s the Roast Beast?!", LineFormat.LORE), -3, - SkinData.THE_GRINCH.getSkull()); + SkinData.THE_GRINCH.getSkull(), "The Grinch Hat"); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java index 9e2ebc269..b9081c975 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java @@ -17,7 +17,7 @@ public abstract class HatGadget extends OutfitGadget private ItemStack _hat; - public HatGadget(GadgetManager manager, String name, String[] desc, int cost, ItemStack item) + public HatGadget(GadgetManager manager, String name, String[] desc, int cost, ItemStack item, String... altNames) { super(manager, name, desc, cost, ArmorSlot.Helmet, item.getType(), item.getData().getData()); _hat = item; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java index 1d778742a..cc9b7fd39 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java @@ -20,9 +20,9 @@ public abstract class OutfitGadget extends Gadget protected ArmorSlot _slot; - public OutfitGadget(GadgetManager manager, String name, String[] desc, int cost, ArmorSlot slot, Material mat, byte data) + public OutfitGadget(GadgetManager manager, String name, String[] desc, int cost, ArmorSlot slot, Material mat, byte data, String... altNames) { - super(manager, GadgetType.Costume, name, desc, cost, mat, data); + super(manager, GadgetType.Costume, name, desc, cost, mat, data, 1, altNames); _slot = slot; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 42d757d03..78342b4f3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -326,7 +326,7 @@ public class RewardManager // addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, rarity)); } - addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Hat", "The Grinch", "The Grinch Hat", + 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", new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards)); From e3e757da8a5b323fc0e50c9c3f0f69a0009efaab Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 15 Dec 2015 13:06:11 -0500 Subject: [PATCH 23/45] Fix mounts owned count --- .../Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 4f5883c63..76077f8f6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -117,7 +117,7 @@ public class Menu extends ShopPageBase Mount mountActive = getPlugin().getMountManager().getActive(getPlayer()); for (Mount mount : getPlugin().getMountManager().getMounts()) { - if (mount.HasMount(getPlayer())) + if (getDonationManager().Get(getPlayer()).OwnsUnknownPackage(mount.GetName()) || mount.HasMount(getPlayer())) { mountOwned++; } From b9a688c4e77a29ea3edde187af0a92b7300639e4 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 15 Dec 2015 13:07:49 -0500 Subject: [PATCH 24/45] Update monthly bonuses --- .../src/mineplex/core/bonuses/BonusManager.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index 527f4a33f..e5076f9b0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -678,22 +678,19 @@ public class BonusManager extends MiniClientPlugin implements I if (rank.has(Rank.TITAN)) { - data.setAncientChests(6); - data.setMythicalChests(3); + data.setMythicalChests(5); } else if (rank.has(Rank.LEGEND)) { - data.setAncientChests(4); - data.setMythicalChests(1); + data.setMythicalChests(3); } else if (rank.has(Rank.HERO)) { - data.setAncientChests(3); + data.setMythicalChests(2); } else if (rank.has(Rank.ULTRA)) { - data.setOldChests(3); - data.setAncientChests(1); + data.setMythicalChests(1); } return data; From 92b82d786be9505acac643d01051e29e50f4b2b1 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 15 Dec 2015 13:34:47 -0500 Subject: [PATCH 25/45] Don't give Winter Holiday Chests to offline players --- .../nautilus/game/arcade/game/games/christmas/Christmas.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java index 8d129fc69..23b3ec1b1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java @@ -469,6 +469,9 @@ public class Christmas extends SoloGame { if (Manager.IsRewardItems()) { + if (!player.isOnline()) + continue; + if (Manager.GetTaskManager().hasCompletedTask(player, "CC Reward 2015")) { SetCustomWinMessage(player, "You already earned your reward"); From 07f610d4bdd6f37bacf8491e39ab05181f419931 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 15 Dec 2015 14:45:12 -0500 Subject: [PATCH 26/45] More Fixes --- Plugins/.idea/dataSources.xml | 2 +- .../src/mineplex/core/gadget/types/HatGadget.java | 2 +- .../src/mineplex/core/reward/RewardManager.java | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Plugins/.idea/dataSources.xml b/Plugins/.idea/dataSources.xml index dea8a489b..3aa4d521d 100644 --- a/Plugins/.idea/dataSources.xml +++ b/Plugins/.idea/dataSources.xml @@ -1,6 +1,6 @@ - + mysql true diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java index b9081c975..d61339bf8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java @@ -19,7 +19,7 @@ public abstract class HatGadget extends OutfitGadget public HatGadget(GadgetManager manager, String name, String[] desc, int cost, ItemStack item, String... altNames) { - super(manager, name, desc, cost, ArmorSlot.Helmet, item.getType(), item.getData().getData()); + super(manager, name, desc, cost, ArmorSlot.Helmet, item.getType(), item.getData().getData(), altNames); _hat = item; ItemMeta im = _hat.getItemMeta(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 78342b4f3..78dda6d16 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -480,12 +480,17 @@ public class RewardManager } } - possibleRewards.add(treasure); - totalWeight += treasure.getWeight(); + if (!isExcluded) + { + possibleRewards.add(treasure); + totalWeight += treasure.getWeight(); + } } if (possibleRewards.size() == 0) { + totalWeight = 0; + // go again, ignore excluded for (Reward treasure : treasureList) { From 5f14d6675ffd8e28c879cebd79366263dcedee76 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 15 Dec 2015 14:56:19 -0500 Subject: [PATCH 27/45] Fix shard values --- .../src/mineplex/core/reward/RewardManager.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 78dda6d16..b5a69e120 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -45,7 +45,7 @@ public class RewardManager private int _uncommonShards = 100; private int _rareShards = 500; - private int _legendaryShards = 6000; + private int _legendaryShards = 5000; public RewardManager(CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, GiveawayManager giveawayManager, @@ -264,11 +264,11 @@ public class RewardManager addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Death Effect", "Candy Cane Remains", "Candy Cane Remains", new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards)); addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Particles", "Crushed Candy Cane", "Crushed Candy Cane", - new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards)); + new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards)); addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Arrow Effect", "Candy Cane Arrows", "Candy Cane Arrows", - new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards)); + new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards)); addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Jump Effect", "Candy Cane Blast", "Candy Cane Blast", - new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards)); + new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards)); // Mounts addReward(new UnknownPackageReward(donationManager, "Mount", "Mule", "Mount Mule", @@ -341,7 +341,7 @@ public class RewardManager addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Jump Effect", "Gust of the Frost Lord", "Gust of the Frost Lord", new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards)); addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Death Effect", "Fall of the Frost Lord", "Fall of the Frost Lord", - new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards)); + new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards)); // Mounts addReward(new UnknownPackageReward(donationManager, "Mount", "Infernal Horror", "Infernal Horror", From aef704d972e5c61030e7eaedf39a992599d0b1b7 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 15 Dec 2015 14:58:09 -0500 Subject: [PATCH 28/45] Slight winter reward rarity changes --- Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java index 83d2c66a5..0d98851e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java @@ -10,7 +10,7 @@ public enum RewardType OldChest( 0, 0.06, 0.8, 16), AncientChest( 0, 2, 8, 32), MythicalChest( 0.3, 4, 16, 72), - WinterChest( 0, 6, 20, 32), + WinterChest( 0, 5, 18, 32), SpinnerFiller( 0.1, 1, 4, 20), SpinnerReal( 0.000001, 0.05, 0.4, 5); From 4566577c6837520f59c22af6bcfc566563dfe8a4 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Tue, 15 Dec 2015 19:26:09 -0500 Subject: [PATCH 29/45] Die player cache --- Plugins/Mineplex.PlayerCache/.project | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 Plugins/Mineplex.PlayerCache/.project diff --git a/Plugins/Mineplex.PlayerCache/.project b/Plugins/Mineplex.PlayerCache/.project deleted file mode 100644 index 5321c2157..000000000 --- a/Plugins/Mineplex.PlayerCache/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - Mineplex.Cache - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - From baf0f254bbf86de5371fdf3a8282f345113d60f3 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 16 Dec 2015 14:41:57 +0000 Subject: [PATCH 30/45] Custom data, waiting for JLO --- .../core/account/CoreClientManager.java | 14 ++++- .../core/account/CustomPlayerData.java | 27 +++++++++ .../CustomPlayerDataRepository.java | 57 +++++++++++++++++++ 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/CustomPlayerData.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/repository/CustomPlayerDataRepository.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 26859a6b3..d04045521 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -18,6 +18,7 @@ import mineplex.core.account.command.UpdateRank; import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.account.event.ClientWebResponseEvent; import mineplex.core.account.repository.AccountRepository; +import mineplex.core.account.repository.CustomPlayerDataRepository; import mineplex.core.account.repository.token.ClientToken; import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; @@ -35,7 +36,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result; -import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -57,6 +57,8 @@ public class CoreClientManager extends MiniPlugin private static AtomicInteger _clientsConnecting = new AtomicInteger(0); private static AtomicInteger _clientsProcessing = new AtomicInteger(0); + + private CustomPlayerDataRepository _customDataRepository; public CoreClientManager(JavaPlugin plugin, String webServer) { @@ -66,6 +68,8 @@ public class CoreClientManager extends MiniPlugin _repository = new AccountRepository(plugin, webServer); _clientList = new NautHashMap(); _duplicateLoginGlitchPreventionList = new HashSet(); + + _customDataRepository = new CustomPlayerDataRepository(plugin); } public AccountRepository getRepository() @@ -580,4 +584,12 @@ public class CoreClientManager extends MiniPlugin PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); return playerInfo == null ? -1 : playerInfo.getAccountId(); } + + public void addCustomData(Player player, String key, Object data) + { + if (data == null || player == null || key == null) + return; + + _customDataRepository + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CustomPlayerData.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CustomPlayerData.java new file mode 100644 index 000000000..b9fb8c9e3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CustomPlayerData.java @@ -0,0 +1,27 @@ +package mineplex.core.account; + +/** + * Created by William (WilliamTiger). + * 16/12/15 + */ +public class CustomPlayerData +{ + private int _id; + private String _key; + + public CustomPlayerData(int id, String key) + { + _id = id; + _key = key; + } + + public int getId() + { + return _id; + } + + public String getKey() + { + return _key; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/CustomPlayerDataRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/CustomPlayerDataRepository.java new file mode 100644 index 000000000..69af27ddf --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/CustomPlayerDataRepository.java @@ -0,0 +1,57 @@ +package mineplex.core.account.repository; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.account.CustomPlayerData; +import mineplex.core.database.DBPool; +import mineplex.core.database.RepositoryBase; +import mineplex.core.database.ResultSetCallable; +import mineplex.core.database.column.ColumnVarChar; + +/** + * Created by William (WilliamTiger). + * 16/12/15 + */ +public class CustomPlayerDataRepository extends RepositoryBase +{ + private static final String RETRIEVE_KEYS = "SELECT id, key FROM customDataKeys;"; + private static final String INSERT_KEY = "INSERT INTO customDataKeys (key) VALUES (?);"; + + private ArrayList _playerDataTypes; + + public CustomPlayerDataRepository(JavaPlugin plugin) + { + super(plugin, DBPool.ACCOUNT); + } + + @Override + protected void initialize() + { + _playerDataTypes = new ArrayList<>(); + + executeQuery(RETRIEVE_KEYS, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + while (resultSet.next()) + { + _playerDataTypes.add(new CustomPlayerData(resultSet.getInt("id"), resultSet.getString("key"))); + } + } + }); + } + + @Override + protected void update() {} + + public void addKey(String key) + { + //TODO: add the key with auto-increment ID + //executeUpdate(INSERT_KEY, new ColumnVarChar("")) + } +} From 370c59ce754122fbe92bc517dc4826e5d343919f Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 16 Dec 2015 21:52:41 +0000 Subject: [PATCH 31/45] Added custom data --- .../core/account/CoreClientManager.java | 25 +--- .../CustomPlayerDataRepository.java | 57 ------- .../CustomData.java} | 6 +- .../core/customdata/CustomDataManager.java | 64 ++++++++ .../core/customdata/PlayerCustomData.java | 59 ++++++++ .../repository/CustomDataRepository.java | 140 ++++++++++++++++++ 6 files changed, 272 insertions(+), 79 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/repository/CustomPlayerDataRepository.java rename Plugins/Mineplex.Core/src/mineplex/core/{account/CustomPlayerData.java => customdata/CustomData.java} (67%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index d04045521..74f339854 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -18,7 +18,6 @@ import mineplex.core.account.command.UpdateRank; import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.account.event.ClientWebResponseEvent; import mineplex.core.account.repository.AccountRepository; -import mineplex.core.account.repository.CustomPlayerDataRepository; import mineplex.core.account.repository.token.ClientToken; import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; @@ -57,8 +56,6 @@ public class CoreClientManager extends MiniPlugin private static AtomicInteger _clientsConnecting = new AtomicInteger(0); private static AtomicInteger _clientsProcessing = new AtomicInteger(0); - - private CustomPlayerDataRepository _customDataRepository; public CoreClientManager(JavaPlugin plugin, String webServer) { @@ -68,8 +65,6 @@ public class CoreClientManager extends MiniPlugin _repository = new AccountRepository(plugin, webServer); _clientList = new NautHashMap(); _duplicateLoginGlitchPreventionList = new HashSet(); - - _customDataRepository = new CustomPlayerDataRepository(plugin); } public AccountRepository getRepository() @@ -369,7 +364,7 @@ public class CoreClientManager extends MiniPlugin if (client == null || client.GetRank() == null) { - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "There was an error logging you in. Please reconncet."); + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "There was an error logging you in. Please reconnect."); return; } @@ -477,7 +472,7 @@ public class CoreClientManager extends MiniPlugin public void run(List matches) { String tempName = null; - + for (String match : matches) { if (match.equalsIgnoreCase(playerName)) @@ -486,12 +481,12 @@ public class CoreClientManager extends MiniPlugin break; } } - + final String matchedName = tempName; - + if (matchedName != null) { - for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext();) + for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext(); ) { if (!matchIterator.next().equalsIgnoreCase(playerName)) { @@ -499,7 +494,7 @@ public class CoreClientManager extends MiniPlugin } } } - + UtilPlayer.searchOffline(matches, new Callback() { public void run(final String target) @@ -584,12 +579,4 @@ public class CoreClientManager extends MiniPlugin PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); return playerInfo == null ? -1 : playerInfo.getAccountId(); } - - public void addCustomData(Player player, String key, Object data) - { - if (data == null || player == null || key == null) - return; - - _customDataRepository - } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/CustomPlayerDataRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/CustomPlayerDataRepository.java deleted file mode 100644 index 69af27ddf..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/CustomPlayerDataRepository.java +++ /dev/null @@ -1,57 +0,0 @@ -package mineplex.core.account.repository; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; - -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.core.account.CustomPlayerData; -import mineplex.core.database.DBPool; -import mineplex.core.database.RepositoryBase; -import mineplex.core.database.ResultSetCallable; -import mineplex.core.database.column.ColumnVarChar; - -/** - * Created by William (WilliamTiger). - * 16/12/15 - */ -public class CustomPlayerDataRepository extends RepositoryBase -{ - private static final String RETRIEVE_KEYS = "SELECT id, key FROM customDataKeys;"; - private static final String INSERT_KEY = "INSERT INTO customDataKeys (key) VALUES (?);"; - - private ArrayList _playerDataTypes; - - public CustomPlayerDataRepository(JavaPlugin plugin) - { - super(plugin, DBPool.ACCOUNT); - } - - @Override - protected void initialize() - { - _playerDataTypes = new ArrayList<>(); - - executeQuery(RETRIEVE_KEYS, new ResultSetCallable() - { - @Override - public void processResultSet(ResultSet resultSet) throws SQLException - { - while (resultSet.next()) - { - _playerDataTypes.add(new CustomPlayerData(resultSet.getInt("id"), resultSet.getString("key"))); - } - } - }); - } - - @Override - protected void update() {} - - public void addKey(String key) - { - //TODO: add the key with auto-increment ID - //executeUpdate(INSERT_KEY, new ColumnVarChar("")) - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CustomPlayerData.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomData.java similarity index 67% rename from Plugins/Mineplex.Core/src/mineplex/core/account/CustomPlayerData.java rename to Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomData.java index b9fb8c9e3..052965b5c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CustomPlayerData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomData.java @@ -1,15 +1,15 @@ -package mineplex.core.account; +package mineplex.core.customdata; /** * Created by William (WilliamTiger). * 16/12/15 */ -public class CustomPlayerData +public class CustomData { private int _id; private String _key; - public CustomPlayerData(int id, String key) + public CustomData(int id, String key) { _id = id; _key = key; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java new file mode 100644 index 000000000..8e92d3ffb --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java @@ -0,0 +1,64 @@ +package mineplex.core.customdata; + +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.customdata.repository.CustomDataRepository; + +/** + * Created by William (WilliamTiger). + * 16/12/15 + */ +public class CustomDataManager extends MiniDbClientPlugin +{ + private CustomDataRepository _repository; + + public CustomDataManager(JavaPlugin plugin, CoreClientManager clientManager) + { + super("Custom Data Manager", plugin, clientManager); + + _repository = new CustomDataRepository(plugin, clientManager); + } + + @Override + public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException + { + PlayerCustomData data = new PlayerCustomData(_repository); + while (resultSet.next()) + { + data.incrementData(_repository.getKey(resultSet.getInt("customDataId")), resultSet.getInt("data")); + } + Set(playerName, data); + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT accountId, customDataId, data FROM accountCustomData WHERE accountId = " + accountId + ";"; + } + + @Override + protected PlayerCustomData AddPlayer(String player) + { + return new PlayerCustomData(_repository); + } + + @EventHandler + public void onQuit(final PlayerQuitEvent e) + { + getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() + { + @Override + public void run() + { + _repository.saveData(e.getPlayer(), Get(e.getPlayer())); + } + }); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java new file mode 100644 index 000000000..28e509aa9 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java @@ -0,0 +1,59 @@ +package mineplex.core.customdata; + +import java.util.HashMap; + +import mineplex.core.customdata.repository.CustomDataRepository; + +/** + * Created by William (WilliamTiger). + * 16/12/15 + */ +public class PlayerCustomData +{ + private HashMap _data; + private CustomDataRepository _repository; + + public PlayerCustomData(CustomDataRepository repository) + { + _data = new HashMap<>(); + _repository = repository; + } + + public HashMap getData() + { + return _data; + } + + public void incrementData(CustomData cd, int amount) + { + if (!_data.containsKey(cd)) + { + _data.put(cd, amount); + return; + } + + _data.put(cd, _data.get(cd) + amount); + } + + public void incrementData(String key, int amount) + { + if (_repository.doesKeyExist(key)) + { + incrementData(_repository.getKey(key), amount); + return; + } + + _repository.getClientManager().getScheduler().runTaskAsynchronously( + _repository.getClientManager().getPlugin(), + new Runnable() + { + @Override + public void run() + { + _repository.registerKey(key); // Make sure it's in the DB. + + incrementData(_repository.getKey(key), amount); // Input + } + }); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java new file mode 100644 index 000000000..7463cb2c5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java @@ -0,0 +1,140 @@ +package mineplex.core.customdata.repository; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.customdata.CustomData; +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; + +/** + * Created by William (WilliamTiger). + * 16/12/15 + */ +public class CustomDataRepository extends RepositoryBase +{ + private static final String SELECT_KEYS = "SELECT id, name FROM customData;"; + private static final String INSERT_KEY = "INSERT INTO customData (name) VALUES (?);"; + private static final String UPDATE_DATA = "UPDATE accountCustomData SET data = ? WHERE accountId = ? AND customDataId = ?;"; + private static final String INSERT_DATA = "INSERT INTO accountCustomData (accountId, customDataId, data) VALUES (?, ?, ?);"; + + private ArrayList _dataKeys; + + private CoreClientManager _clientManager; + + public CustomDataRepository(JavaPlugin plugin, CoreClientManager clientManager) + { + super(plugin, DBPool.ACCOUNT); + + _clientManager = clientManager; + } + + @Override + protected void initialize() + { + downloadDataKeys(); + } + + @Override + protected void update() {} + + private void downloadDataKeys() + { + _dataKeys = new ArrayList<>(); + + executeQuery(SELECT_KEYS, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + while (resultSet.next()) + { + _dataKeys.add(new CustomData(resultSet.getInt("id"), resultSet.getString("name"))); + } + } + }); + } + + public void saveData(Player player, PlayerCustomData data) + { + for (CustomData cd : data.getData().keySet()) + { + executeQuery(UPDATE_DATA, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + if (!resultSet.next()) + { + // Not already in the DB + executeUpdate( + INSERT_DATA, + new ColumnInt("account", _clientManager.getAccountId(player)), + new ColumnInt("customData", cd.getId()), + new ColumnInt("data", data.getData().get(cd)) + ); + } + } + }, + new ColumnInt("data", data.getData().get(cd)), + new ColumnInt("account", _clientManager.getAccountId(player)), + new ColumnInt("customData", cd.getId()) + ); + } + } + + public void registerKey(String key) + { + if (doesKeyExist(key)) + return; + + executeUpdate(INSERT_KEY, new ColumnVarChar("name", 100, key)); + downloadDataKeys(); + } + + public ArrayList getDataKeys() + { + return _dataKeys; + } + + public boolean doesKeyExist(String key) + { + for (CustomData cur : _dataKeys) + if (cur.getKey().equals(key)) + return true; + + return false; + } + + public CustomData getKey(int id) + { + for (CustomData cur : _dataKeys) + if (cur.getId() == id) + return cur; + + return null; + } + + public CustomData getKey(String key) + { + for (CustomData cur : _dataKeys) + if (cur.getKey().equals(key)) + return cur; + + return null; + } + + public CoreClientManager getClientManager() + { + return _clientManager; + } +} From 4077aa808f6f7adace73893c7ed3a7637fbc9507 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 16 Dec 2015 22:01:51 +0000 Subject: [PATCH 32/45] Add to Arcade and Hub --- Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java | 5 ++++- .../Mineplex.Hub/src/mineplex/hub/HubManager.java | 13 +++++++++++-- .../src/nautilus/game/arcade/Arcade.java | 4 +++- .../src/nautilus/game/arcade/ArcadeManager.java | 9 ++++++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 9940694cc..2b36e28bc 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -14,6 +14,7 @@ import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; import mineplex.core.creature.Creature; +import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; @@ -133,9 +134,11 @@ public class Hub extends JavaPlugin implements IRelation PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager); SkillConditionManager conditionManager = new SkillConditionManager(this); + + 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); + 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); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 52abd753e..738c79422 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -31,6 +31,7 @@ import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguiseSlime; import mineplex.core.donation.DonationManager; @@ -159,6 +160,7 @@ public class HubManager extends MiniClientPlugin private PacketHandler _packetHandler; private PersonalServerManager _personalServerManager; private PlayerCountManager _playerCountManager; + private CustomDataManager _customDataManager; // private HalloweenSpookinessManager _halloweenManager; // private TrickOrTreatManager _trickOrTreatManager; @@ -181,7 +183,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) + 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) { super("Hub Manager", plugin); @@ -250,6 +252,8 @@ public class HubManager extends MiniClientPlugin _playerCountManager = new PlayerCountManager(plugin); + _customDataManager = new CustomDataManager(plugin, clientManager); + _songs = new ArrayList(); try @@ -856,7 +860,12 @@ public class HubManager extends MiniClientPlugin return _visibilityManager; } -// public HalloweenSpookinessManager getHalloweenManager() + public CustomDataManager getCustomDataManager() + { + return _customDataManager; + } + + // public HalloweenSpookinessManager getHalloweenManager() // { // return _halloweenManager; // } 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 aa1468fdf..e2ca772b3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -9,6 +9,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.FoodDupeFix; import mineplex.core.PacketsInteractionFix; import mineplex.core.account.CoreClient; +import mineplex.core.customdata.CustomDataManager; import mineplex.core.giveaway.GiveawayManager; import mineplex.core.globalpacket.GlobalPacketManager; import net.minecraft.server.v1_8_R3.BiomeBase; @@ -149,12 +150,13 @@ public class Arcade extends JavaPlugin 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); //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); + _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); 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 7e9d4a156..eeecc1a54 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -28,6 +28,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; +import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; @@ -191,6 +192,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation private PartyManager _partyManager; private PreferencesManager _preferencesManager; private GiveawayManager _giveawayManager; + private CustomDataManager _customDataManager; private TaskManager _taskManager; private PacketHandler _packetHandler; @@ -219,7 +221,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager, 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) + CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, + NpcManager npcManager, GiveawayManager giveawayManager, CustomDataManager customDataManager) { super("Game Manager", plugin); @@ -279,6 +282,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation _eventManager = new EventModule(this, getPlugin()); _giveawayManager = giveawayManager; + _customDataManager = customDataManager; + // Shop _arcadeShop = new ArcadeShop(this, clientManager, donationManager); @@ -598,6 +603,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _serverStatusManager; } + public CustomDataManager getCustomDataManager() { return _customDataManager; } + public ChatColor GetColor(Player player) { if (_game == null) From ee202bc7f5210b2a066b700fab864fccfc0adc4b Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 16 Dec 2015 22:32:34 +0000 Subject: [PATCH 33/45] Add MineplexPlayer -> ArcadePlayer --- .../core/customdata/MineplexPlayer.java | 41 +++++++++++++++++++ .../core/customdata/PlayerCustomData.java | 11 ++++- .../repository/CustomDataRepository.java | 6 +-- .../nautilus/game/arcade/ArcadeManager.java | 6 +++ .../game/arcade/player/ArcadePlayer.java | 27 +++++++++++- 5 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java new file mode 100644 index 000000000..d9e5a54fa --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java @@ -0,0 +1,41 @@ +package mineplex.core.customdata; + +import org.bukkit.entity.Player; + +/** + * Created by William (WilliamTiger). + * 16/12/15 + */ +public abstract class MineplexPlayer +{ + private Player _player; + private CustomDataManager _customDataManager; + + public MineplexPlayer(Player player, CustomDataManager customDataManager) + { + _player = player; + _customDataManager = customDataManager; + } + + public Player getPlayer() + { + return _player; + } + + public String getKeyPrefix() + { + return ""; + } + + public void put(String key, int data) + { + key = getKeyPrefix() + key; + _customDataManager.Get(getPlayer()).incrementData(key, data); + } + + public int get(String key) + { + key = getKeyPrefix() + key; + return _customDataManager.Get(getPlayer()).getData(key); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java index 28e509aa9..a7150dc81 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java @@ -19,7 +19,7 @@ public class PlayerCustomData _repository = repository; } - public HashMap getData() + public HashMap getDataMap() { return _data; } @@ -56,4 +56,13 @@ public class PlayerCustomData } }); } + + public int getData(String key) + { + if (_data.containsKey(_repository.getKey(key))) + return _data.get(_repository.getKey(key)); + + return -1; + } + } 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 7463cb2c5..271133788 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java @@ -66,7 +66,7 @@ public class CustomDataRepository extends RepositoryBase public void saveData(Player player, PlayerCustomData data) { - for (CustomData cd : data.getData().keySet()) + for (CustomData cd : data.getDataMap().keySet()) { executeQuery(UPDATE_DATA, new ResultSetCallable() { @@ -80,12 +80,12 @@ public class CustomDataRepository extends RepositoryBase INSERT_DATA, new ColumnInt("account", _clientManager.getAccountId(player)), new ColumnInt("customData", cd.getId()), - new ColumnInt("data", data.getData().get(cd)) + new ColumnInt("data", data.getDataMap().get(cd)) ); } } }, - new ColumnInt("data", data.getData().get(cd)), + new ColumnInt("data", data.getDataMap().get(cd)), new ColumnInt("account", _clientManager.getAccountId(player)), new ColumnInt("customData", cd.getId()) ); 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 eeecc1a54..ee5b9e8ea 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -106,6 +106,7 @@ import nautilus.game.arcade.managers.GameWorldManager; import nautilus.game.arcade.managers.HolidayManager; import nautilus.game.arcade.managers.IdleManager; import nautilus.game.arcade.managers.MiscManager; +import nautilus.game.arcade.player.ArcadePlayer; import nautilus.game.arcade.shop.ArcadeShop; import org.bukkit.Bukkit; @@ -428,6 +429,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation } } + public ArcadePlayer getArcadePlayer(Player player) + { + return new ArcadePlayer(player, getCustomDataManager(), this); + } + public GameServerConfig GetServerConfig() { return _serverConfig; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/player/ArcadePlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/player/ArcadePlayer.java index 7b5021ae5..13f27be81 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/player/ArcadePlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/player/ArcadePlayer.java @@ -1,6 +1,29 @@ package nautilus.game.arcade.player; -public class ArcadePlayer -{ +import org.bukkit.entity.Player; +import mineplex.core.customdata.CustomDataManager; +import mineplex.core.customdata.MineplexPlayer; +import nautilus.game.arcade.ArcadeManager; + +/** + * Created by William (WilliamTiger). + * 16/12/15 + */ +public class ArcadePlayer extends MineplexPlayer +{ + private ArcadeManager _arcadeManager; + + public ArcadePlayer(Player player, CustomDataManager customDataManager, ArcadeManager arcadeManager) + { + super(player, customDataManager); + + _arcadeManager = arcadeManager; + } + + @Override + public String getKeyPrefix() + { + return "arcade." + _arcadeManager.GetGame().GetName() + "."; + } } From d28c2be1c338726287a52ed8aeab5f88ede1f7b2 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Wed, 16 Dec 2015 20:26:04 -0500 Subject: [PATCH 34/45] Epic chnage that saved the day omg --- .../nautilus/game/arcade/game/games/paintball/Paintball.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 d345843d0..b432d2361 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 @@ -86,6 +86,7 @@ public class Paintball extends TeamGame new KitShotgun(manager), new KitMachineGun(manager), new KitSniper(manager), + }, new String[] { "Shoot enemies to paint them", @@ -98,6 +99,8 @@ public class Paintball extends TeamGame HungerSet = 20; InventoryClick = false; + + TeamArmorHotbar = true; registerStatTrackers( new KillingSpreeTracker(this), @@ -210,7 +213,7 @@ public class Paintball extends TeamGame } @EventHandler - public void PlayerQuit(PlayerQuitEvent event) + public void onQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); From 7d9b97180db3a99fc0e4f1f74589e6d6bc20b53c Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 17 Dec 2015 01:48:55 +0000 Subject: [PATCH 35/45] Testing ArcadePlayer implementation --- .../src/mineplex/core/MiniClientPlugin.java | 3 + .../core/customdata/CustomDataManager.java | 16 ++---- .../repository/CustomDataRepository.java | 56 ++++++++++++------- .../game/games/gladiators/Gladiators.java | 18 ++++++ .../game/arcade/player/ArcadePlayer.java | 2 +- 5 files changed, 64 insertions(+), 31 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java index b573392b0..4a9de82de 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java @@ -26,6 +26,7 @@ public abstract class MiniClientPlugin extends MiniPlug { synchronized (_clientDataLock) { + saveData(event.GetName()); _clientData.remove(event.GetName()); } } @@ -40,6 +41,8 @@ public abstract class MiniClientPlugin extends MiniPlug return _clientData.get(name); } } + + public void saveData(String name) {} public DataType Get(Player player) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java index 8e92d3ffb..9c0f3ff96 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java @@ -3,6 +3,7 @@ package mineplex.core.customdata; import java.sql.ResultSet; import java.sql.SQLException; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -23,7 +24,7 @@ public class CustomDataManager extends MiniDbClientPlugin { super("Custom Data Manager", plugin, clientManager); - _repository = new CustomDataRepository(plugin, clientManager); + _repository = new CustomDataRepository(plugin, clientManager, this); } @Override @@ -49,16 +50,9 @@ public class CustomDataManager extends MiniDbClientPlugin return new PlayerCustomData(_repository); } - @EventHandler - public void onQuit(final PlayerQuitEvent e) + @Override + public void saveData(String name) { - getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - @Override - public void run() - { - _repository.saveData(e.getPlayer(), Get(e.getPlayer())); - } - }); + _repository.saveData(name); } } 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 271133788..63a8bb0e3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java @@ -9,6 +9,7 @@ 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; @@ -30,12 +31,14 @@ public class CustomDataRepository extends RepositoryBase private ArrayList _dataKeys; private CoreClientManager _clientManager; + private CustomDataManager _customDataManager; - public CustomDataRepository(JavaPlugin plugin, CoreClientManager clientManager) + public CustomDataRepository(JavaPlugin plugin, CoreClientManager clientManager, CustomDataManager customDataManager) { super(plugin, DBPool.ACCOUNT); _clientManager = clientManager; + _customDataManager = customDataManager; } @Override @@ -64,32 +67,47 @@ public class CustomDataRepository extends RepositoryBase }); } - public void saveData(Player player, PlayerCustomData data) + public void saveData(String name) { + PlayerCustomData data = _customDataManager.Get(name); + + System.out.println("saving data for " + name); + System.out.println("size = " + data.getDataMap().keySet().size()); + for (CustomData cd : data.getDataMap().keySet()) { - executeQuery(UPDATE_DATA, new ResultSetCallable() - { - @Override - public void processResultSet(ResultSet resultSet) throws SQLException - { - if (!resultSet.next()) + System.out.println(cd.getKey()); + + executeInsert(UPDATE_DATA, new ResultSetCallable() { - // Not already in the DB - executeUpdate( - INSERT_DATA, - new ColumnInt("account", _clientManager.getAccountId(player)), - new ColumnInt("customData", cd.getId()), - new ColumnInt("data", data.getDataMap().get(cd)) - ); - } - } - }, + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + System.out.println("executed update data"); + + if (!resultSet.isBeforeFirst()) + { + System.out.println("empty result set"); + + // Not already in the DB + executeUpdate( + INSERT_DATA, + new ColumnInt("account", _clientManager.Get(name).getAccountId()), + new ColumnInt("customData", cd.getId()), + new ColumnInt("data", data.getDataMap().get(cd)) + ); + } + else + System.out.println("no second execute"); + } + }, new ColumnInt("data", data.getDataMap().get(cd)), - new ColumnInt("account", _clientManager.getAccountId(player)), + new ColumnInt("account", _clientManager.Get(name).getAccountId()), new ColumnInt("customData", cd.getId()) ); } + + System.out.println("complete"); } public void registerKey(String key) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index ddb562ae1..b90ed49b2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -22,6 +22,7 @@ import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -125,6 +126,23 @@ public class Gladiators extends SoloGame _firstRound = true; } + @EventHandler + public void testPlayer(PlayerCommandPreprocessEvent e) + { + if (!e.getPlayer().getName().equals("WilliamTiger")) + return; + + if (e.getMessage().equalsIgnoreCase("/arcadeplayer")) + { + Manager.getArcadePlayer(e.getPlayer()).put("test", 100); + e.getPlayer().sendMessage(C.cGreen + "Added the test value!"); + } + else if (e.getMessage().equalsIgnoreCase("/getback")) + { + e.getPlayer().sendMessage("value: " + Manager.getArcadePlayer(e.getPlayer()).get("test")); + } + } + @EventHandler public void tutorialStart(GameTutorialStartEvent e) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/player/ArcadePlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/player/ArcadePlayer.java index 13f27be81..73ebfaf00 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/player/ArcadePlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/player/ArcadePlayer.java @@ -24,6 +24,6 @@ public class ArcadePlayer extends MineplexPlayer @Override public String getKeyPrefix() { - return "arcade." + _arcadeManager.GetGame().GetName() + "."; + return "arcade." + _arcadeManager.GetGame().GetName().toLowerCase().replaceAll(" ", ".") + "."; } } From 66372c397bead6bba72959b84766a70999ed03cd Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 18 Dec 2015 10:03:03 +1300 Subject: [PATCH 36/45] First version of ResourcePackManager that handles all resource packs globally --- .../core/resourcepack/ResPackManager.java | 41 --- .../core/resourcepack/ResUnloadCheck.java | 9 - .../resourcepack/ResourcePackManager.java | 238 ++++++++++++++++++ .../Mineplex.Hub/src/mineplex/hub/Hub.java | 11 +- .../nautilus/game/arcade/ArcadeManager.java | 208 +-------------- .../src/nautilus/game/arcade/game/Game.java | 2 +- 6 files changed, 250 insertions(+), 259 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResPackManager.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResUnloadCheck.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResourcePackManager.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResPackManager.java b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResPackManager.java deleted file mode 100644 index f51ee8b96..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResPackManager.java +++ /dev/null @@ -1,41 +0,0 @@ -package mineplex.core.resourcepack; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import mineplex.core.resourcepack.redis.RedisUnloadResPack; -import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; -import mineplex.serverdata.commands.ServerCommandManager; - -public class ResPackManager implements CommandCallback -{ - private ResUnloadCheck _packUnloadCheck; - - public ResPackManager(ResUnloadCheck packUnloadCheck) - { - _packUnloadCheck = packUnloadCheck; - - ServerCommandManager.getInstance().registerCommandType("RedisUnloadResPack", RedisUnloadResPack.class, this); - } - - @Override - public void run(ServerCommand command) - { - if (command instanceof RedisUnloadResPack) - { - RedisUnloadResPack redisCommand = (RedisUnloadResPack) command; - - Player player = Bukkit.getPlayerExact(redisCommand.getPlayer()); - - if (player != null) - { - if (_packUnloadCheck.canSendUnload(player)) - { - player.setResourcePack("http://file.mineplex.com/ResReset.zip"); - } - } - } - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResUnloadCheck.java b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResUnloadCheck.java deleted file mode 100644 index c25175c58..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResUnloadCheck.java +++ /dev/null @@ -1,9 +0,0 @@ -package mineplex.core.resourcepack; - -import org.bukkit.entity.Player; - -public interface ResUnloadCheck -{ - - public boolean canSendUnload(Player player); -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResourcePackManager.java b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResourcePackManager.java new file mode 100644 index 000000000..31b41dd06 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResourcePackManager.java @@ -0,0 +1,238 @@ +package mineplex.core.resourcepack; + +import java.util.Iterator; +import java.util.Map.Entry; + +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerResourcePackStatusEvent; +import org.bukkit.event.player.PlayerResourcePackStatusEvent.Status; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.base.Objects; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.portal.Portal; +import mineplex.core.resourcepack.redis.RedisUnloadResPack; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.serverdata.commands.CommandCallback; +import mineplex.serverdata.commands.ServerCommand; +import mineplex.serverdata.commands.ServerCommandManager; + +public class ResourcePackManager extends MiniPlugin implements CommandCallback +{ + private String _resourcePackUrl; + private boolean _resourcePackRequired; + private NautHashMap _resourcePackUsers = new NautHashMap(); + private NautHashMap _resourcePackNoResponse = new NautHashMap(); + private Portal _portal; + + public ResourcePackManager(JavaPlugin plugin, Portal portal) + { + super("Resource Pack Manager", plugin); + + _portal = portal; + + ServerCommandManager.getInstance().registerCommandType("RedisUnloadResPack", RedisUnloadResPack.class, this); + } + + @EventHandler + public void ResourcePackJoin(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + + if (_resourcePackUrl == null) + { + return; + } + + if (_resourcePackRequired) + { + _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); + } + + _resourcePackUsers.put(player.getName(), false); + player.setResourcePack(_resourcePackUrl); + } + + @EventHandler + public void onSecond(UpdateEvent event) + { + Iterator> itel = _resourcePackNoResponse.entrySet().iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + + if (!UtilTime.elapsed(entry.getValue(), 20000)) + { + continue; + } + + Player player = Bukkit.getPlayerExact(entry.getKey()); + + if (player == null) + { + itel.remove(); + continue; + } + + // Send it again, enforce it! + _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); + player.setResourcePack(_resourcePackUrl); + } + } + + @EventHandler + public void onResourcePackStatus(PlayerResourcePackStatusEvent event) + { + if (_resourcePackUrl == null) + { + return; + } + + Player player = event.getPlayer(); + + if (_resourcePackRequired) + { + if (event.getStatus() == Status.ACCEPTED) + { + _resourcePackNoResponse.remove(player.getName()); + } + else if (event.getStatus() == Status.DECLINED) + { + _resourcePackNoResponse.remove(player.getName()); + + UtilPlayer.message(player, " "); + JsonMessage message = new JsonMessage("").color("gold").bold() + .extra("You need to accept the resource pack!\n" + "Click me for instructions on how to fix this!") + + .click(ClickEvent.OPEN_URL, + + "http://mineplex.com/forums/m/11929946/viewthread/21554536-wizards-resource-pack-help"); + + message.sendToPlayer(player); + UtilPlayer.message(player, " "); + + returnHubNoResPack(player); + } + else if (event.getStatus() == Status.FAILED_DOWNLOAD) + { + _resourcePackNoResponse.remove(player.getName()); + + returnHubNoResPack(player, "Failed to download resource pack!"); + + return; + } + } + + if (event.getStatus() == Status.ACCEPTED || event.getStatus() == Status.SUCCESSFULLY_LOADED) + { + _resourcePackUsers.put(player.getName(), true); + } + else + { + _resourcePackUsers.remove(player.getName()); + } + } + + @EventHandler + public void ResourcePackQuit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + if (!_resourcePackUsers.containsKey(player.getName()) || !_resourcePackUsers.get(player.getName())) + { + return; + } + + new RedisUnloadResPack(player.getName()).publish(); + + _resourcePackUsers.remove(player.getName()); + } + + private void returnHubNoResPack(Player player) + { + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); + _portal.sendPlayerToServer(player, "Lobby"); + } + + private void returnHubNoResPack(Player player, String message) + { + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cGold + C.Bold + message); + UtilPlayer.message(player, " "); + + returnHubNoResPack(player); + } + + public void setResourcePack(String resourcePack, boolean forceResourcePack) + { + if (Objects.equal(resourcePack, _resourcePackUrl) && forceResourcePack == _resourcePackRequired) + { + return; + } + + _resourcePackNoResponse.clear(); + _resourcePackUsers.clear(); + _resourcePackUrl = resourcePack == null || resourcePack.isEmpty() ? null : resourcePack; + _resourcePackRequired = forceResourcePack; + + if (_resourcePackUrl == null || _resourcePackUrl.isEmpty()) + { + _resourcePackRequired = false; + + for (Player player : Bukkit.getOnlinePlayers()) + { + player.setResourcePack("http://file.mineplex.com/ResReset.zip"); + } + } + else + { + for (Player player : Bukkit.getOnlinePlayers()) + { + if (_resourcePackRequired) + { + _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); + } + + _resourcePackUsers.put(player.getName(), false); + player.setResourcePack(_resourcePackUrl); + } + } + } + + @Override + public void run(ServerCommand command) + { + if (command instanceof RedisUnloadResPack) + { + RedisUnloadResPack redisCommand = (RedisUnloadResPack) command; + + Player player = Bukkit.getPlayerExact(redisCommand.getPlayer()); + + if (player == null) + { + return; + } + + if (_resourcePackUsers.containsKey(player.getName())) + { + return; + } + + player.setResourcePack("http://file.mineplex.com/ResReset.zip"); + } + } + +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 9940694cc..e889b76da 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -42,8 +42,7 @@ import mineplex.core.profileCache.ProfileCacheManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; import mineplex.core.recharge.Recharge; -import mineplex.core.resourcepack.ResUnloadCheck; -import mineplex.core.resourcepack.ResPackManager; +import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.serverConfig.ServerConfiguration; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; @@ -146,13 +145,7 @@ public class Hub extends JavaPlugin implements IRelation new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new CustomTagFix(this, packetHandler); new PacketsInteractionFix(this, packetHandler); - new ResPackManager(new ResUnloadCheck() - { - public boolean canSendUnload(Player player) - { - return true; - } - }); + new ResourcePackManager(this, portal); new GlobalPacketManager(this, clientManager, serverStatusManager, inventoryManager, donationManager, petManager, statsManager, giveawayManager); //new Replay(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 7e9d4a156..5eed173fb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -3,9 +3,6 @@ package nautilus.game.arcade; import java.io.File; import java.util.ArrayList; import java.util.HashSet; -import java.util.Iterator; -import java.util.Map.Entry; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -14,18 +11,14 @@ import mineplex.core.blood.Blood; import mineplex.core.bonuses.BonusManager; import mineplex.core.chat.Chat; import mineplex.core.common.Rank; -import mineplex.core.common.jsonchat.ClickEvent; -import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; import mineplex.core.disguise.DisguiseManager; @@ -39,7 +32,6 @@ import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.movement.Movement; -import mineplex.core.notifier.NotificationManager; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; import mineplex.core.party.PartyManager; @@ -48,9 +40,7 @@ import mineplex.core.poll.PollManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; -import mineplex.core.resourcepack.ResPackManager; -import mineplex.core.resourcepack.ResUnloadCheck; -import mineplex.core.resourcepack.redis.RedisUnloadResPack; +import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.reward.RewardData; import mineplex.core.reward.RewardRarity; import mineplex.core.reward.rewards.PetReward; @@ -60,7 +50,6 @@ import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.timing.TimingManager; import mineplex.core.titangiveaway.TitanGiveawayManager; -import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.classcombat.Class.ClassManager; import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -112,7 +101,6 @@ import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.OfflinePlayer; -import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Entity; @@ -132,13 +120,9 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerResourcePackStatusEvent; -import org.bukkit.event.player.PlayerResourcePackStatusEvent.Status; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.util.Vector; - -import com.google.common.base.Objects; public class ArcadeManager extends MiniPlugin implements IRelation { @@ -191,15 +175,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation private PartyManager _partyManager; private PreferencesManager _preferencesManager; private GiveawayManager _giveawayManager; + private ResourcePackManager _resourcePackManager; private TaskManager _taskManager; private PacketHandler _packetHandler; - private String _resourcePackUrl; - private boolean _resourcePackRequired; - private NautHashMap _resourcePackUsers = new NautHashMap(); - private NautHashMap _resourcePackNoResponse = new NautHashMap(); - // Observers private HashSet _specList = new HashSet(); @@ -278,6 +258,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _petManager = petManager; _eventManager = new EventModule(this, getPlugin()); _giveawayManager = giveawayManager; + _resourcePackManager = new ResourcePackManager(plugin, portal); // Shop _arcadeShop = new ArcadeShop(this, clientManager, donationManager); @@ -340,19 +321,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation }, 80L); } - new ResPackManager(new ResUnloadCheck() - { - public boolean canSendUnload(Player player) - { - if (_resourcePackUsers.containsKey(player.getName())) - { - return false; - } - - return true; - } - }); - loadRequiredRank(); } @@ -365,69 +333,17 @@ public class ArcadeManager extends MiniPlugin implements IRelation addCommand(new DisguiseCommand(this)); addCommand(new RequiredRankCommand(this)); } - - @EventHandler - public void onResourcePackStatus(PlayerResourcePackStatusEvent event) - { - if (_resourcePackUrl == null) - { - return; - } - - Player player = event.getPlayer(); - - if (_resourcePackRequired) - { - if (event.getStatus() == Status.ACCEPTED) - { - _resourcePackNoResponse.remove(player.getName()); - } - else if (event.getStatus() == Status.DECLINED) - { - _resourcePackNoResponse.remove(player.getName()); - - UtilPlayer.message(player, " "); - JsonMessage message = new JsonMessage("") - .color("gold") - .bold() - .extra("You need to accept the resource pack!\n" - + "Click me for instructions on how to fix this!") - - .click(ClickEvent.OPEN_URL, - - "http://mineplex.com/forums/m/11929946/viewthread/21554536-wizards-resource-pack-help"); - - message.sendToPlayer(player); - UtilPlayer.message(player, " "); - - returnHubNoResPack(player); - } - else if (event.getStatus() == Status.FAILED_DOWNLOAD) - { - _resourcePackNoResponse.remove(player.getName()); - - returnHubNoResPack(player, "Failed to download resource pack!"); - - return; - } - } - - if (event.getStatus() == Status.ACCEPTED - || event.getStatus() == Status.SUCCESSFULLY_LOADED) - { - _resourcePackUsers.put(player.getName(), true); - } - else - { - _resourcePackUsers.remove(player.getName()); - } - } public GameServerConfig GetServerConfig() { return _serverConfig; } + public ResourcePackManager getResourcePackManager() + { + return _resourcePackManager; + } + public ArrayList GetGameList() { return GetServerConfig().GameList; @@ -1431,116 +1347,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation public boolean isSpectator(Entity player) { if (player instanceof Player) - return UtilPlayer.isSpectator((Player)player); + return UtilPlayer.isSpectator((Player) player); return false; } - @EventHandler - public void onSecond(UpdateEvent event) - { - Iterator> itel = _resourcePackNoResponse.entrySet().iterator(); - - while (itel.hasNext()) - { - Entry entry = itel.next(); - - if (UtilTime.elapsed(entry.getValue(), 20000)) - { - Player player = Bukkit.getPlayerExact(entry.getKey()); - - if (player != null) - { - // Send it again, enforce it! - _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); - player.setResourcePack(_resourcePackUrl); - } - else - { - itel.remove(); - } - } - } - } - - @EventHandler - public void ResourcePackQuit(PlayerQuitEvent event) - { - Player player = event.getPlayer(); - - if (_resourcePackUsers.containsKey(player.getName()) && _resourcePackUsers.get(player.getName())) - { - new RedisUnloadResPack(player.getName()).publish(); - - _resourcePackUsers.remove(player.getName()); - } - } - - private void returnHubNoResPack(Player player) - { - player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); - GetPortal().sendPlayerToServer(player, "Lobby"); - } - - private void returnHubNoResPack(Player player, String message) - { - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cGold + C.Bold + message); - UtilPlayer.message(player, " "); - - returnHubNoResPack(player); - } - - @EventHandler - public void ResourcePackJoin(PlayerJoinEvent event) - { - Player player = event.getPlayer(); - - if (_resourcePackUrl != null) - { - if (_resourcePackRequired) - { - _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); - } - - _resourcePackUsers.put(player.getName(), false); - player.setResourcePack(_resourcePackUrl); - } - } - - public void setResourcePack(String resourcePack, boolean forceResourcePack) - { - if (!Objects.equal(resourcePack, _resourcePackUrl) || forceResourcePack != _resourcePackRequired) - { - _resourcePackNoResponse.clear(); - _resourcePackUsers.clear(); - _resourcePackUrl = resourcePack == null || resourcePack.isEmpty() ? null : resourcePack; - _resourcePackRequired = forceResourcePack; - - if (_resourcePackUrl == null || _resourcePackUrl.isEmpty()) - { - _resourcePackRequired = false; - - for (Player player : Bukkit.getOnlinePlayers()) - { - player.setResourcePack("http://file.mineplex.com/ResReset.zip"); - } - } - else - { - for (Player player : Bukkit.getOnlinePlayers()) - { - if (_resourcePackRequired) - { - _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); - } - - _resourcePackUsers.put(player.getName(), false); - player.setResourcePack(_resourcePackUrl); - } - } - } - } - public void loadRequiredRank() { _requiredRank = null; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 1d6947f06..6eec52eb7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -383,7 +383,7 @@ public abstract class Game implements Listener new ExperienceStatTracker(this), new WinStatTracker(this), new LoseStatTracker(this), new DamageDealtStatTracker( this), new DamageTakenStatTracker(this), new GamesPlayedStatTracker(this)); - Manager.setResourcePack(gameType.getResourcePackUrl(), gameType.isEnforceResourcePack()); + Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrl(), gameType.isEnforceResourcePack()); _useEntityPacketHandler = new IPacketHandler() { From 5c045bfce424190bbf95d41c8747c112d968231b Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 17 Dec 2015 21:27:44 +0000 Subject: [PATCH 37/45] Changes to core client manager, and finishing custom data! --- .../src/mineplex/core/MiniClientPlugin.java | 4 ++-- .../core/account/CoreClientManager.java | 12 ++++++----- .../core/account/event/ClientUnloadEvent.java | 11 ++++++++-- .../mineplex/core/customdata/CorePlayer.java | 21 +++++++++++++++++++ .../core/customdata/CustomDataManager.java | 11 +++++++--- .../core/customdata/PlayerCustomData.java | 8 +------ .../repository/CustomDataRepository.java | 16 +++----------- .../game/games/gladiators/Gladiators.java | 17 --------------- 8 files changed, 51 insertions(+), 49 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/customdata/CorePlayer.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java index 4a9de82de..397e6d0c5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/MiniClientPlugin.java @@ -26,7 +26,7 @@ public abstract class MiniClientPlugin extends MiniPlug { synchronized (_clientDataLock) { - saveData(event.GetName()); + saveData(event.GetName(), event.getAccountId()); _clientData.remove(event.GetName()); } } @@ -42,7 +42,7 @@ public abstract class MiniClientPlugin extends MiniPlug } } - public void saveData(String name) {} + public void saveData(String name, int accountId) {} public DataType Get(Player player) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 74f339854..7228b671e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -103,14 +103,15 @@ public class CoreClientManager extends MiniPlugin return newClient; } - public void Del(String name) + public void Del(String name, int accountId) { synchronized(_clientLock) { _clientList.remove(name); } - _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(name)); + // rawr added account id for custom data - william + _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(name, accountId)); } public CoreClient Get(String name) @@ -406,7 +407,7 @@ public class CoreClientManager extends MiniPlugin if (!_duplicateLoginGlitchPreventionList.contains(event.getPlayer().getName())) { - Del(event.getPlayer().getName()); + Del(event.getPlayer().getName(), _clientList.get(event.getPlayer().getName()).getAccountId()); _duplicateLoginGlitchPreventionList.remove(event.getPlayer().getName()); } } @@ -528,7 +529,8 @@ public class CoreClientManager extends MiniPlugin { for (Iterator> clientIterator = _clientList.entrySet().iterator(); clientIterator.hasNext();) { - Player clientPlayer = clientIterator.next().getValue().GetPlayer(); + CoreClient client = clientIterator.next().getValue(); // rawr, needed this for custom data - william + Player clientPlayer = client.GetPlayer(); if (clientPlayer != null && !clientPlayer.isOnline()) { @@ -536,7 +538,7 @@ public class CoreClientManager extends MiniPlugin if (clientPlayer != null) { - _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(clientPlayer.getName())); + _plugin.getServer().getPluginManager().callEvent(new ClientUnloadEvent(clientPlayer.getName(), client.getAccountId())); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java index 972b1f612..d0d2d467a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientUnloadEvent.java @@ -8,17 +8,24 @@ public class ClientUnloadEvent extends Event private static final HandlerList handlers = new HandlerList(); private String _name; + private int _accountId; - public ClientUnloadEvent(String name) + public ClientUnloadEvent(String name, int accountId) { _name = name; + _accountId = accountId; } public String GetName() { return _name; } - + + public int getAccountId() + { + return _accountId; + } + public HandlerList getHandlers() { return handlers; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CorePlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CorePlayer.java new file mode 100644 index 000000000..14aaec660 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CorePlayer.java @@ -0,0 +1,21 @@ +package mineplex.core.customdata; + +import org.bukkit.entity.Player; + +/** + * Created by William (WilliamTiger). + * 17/12/15 + */ +public class CorePlayer extends MineplexPlayer +{ + public CorePlayer(Player player, CustomDataManager customDataManager) + { + super(player, customDataManager); + } + + @Override + public String getKeyPrefix() + { + return "core."; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java index 9c0f3ff96..11ca1c388 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java @@ -41,7 +41,7 @@ public class CustomDataManager extends MiniDbClientPlugin @Override public String getQuery(int accountId, String uuid, String name) { - return "SELECT accountId, customDataId, data FROM accountCustomData WHERE accountId = " + accountId + ";"; + return "SELECT accountId, customDataId, data FROM accountCustomData INNER JOIN customData ON customData.id = accountCustomData.customDataId WHERE accountId = " + accountId + ";"; } @Override @@ -51,8 +51,13 @@ public class CustomDataManager extends MiniDbClientPlugin } @Override - public void saveData(String name) + public void saveData(String name, int accountId) { - _repository.saveData(name); + _repository.saveData(name, accountId); + } + + public CorePlayer getCorePlayer(Player player) + { + return new CorePlayer(player, this); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java index a7150dc81..9e1d5db78 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java @@ -26,13 +26,7 @@ public class PlayerCustomData public void incrementData(CustomData cd, int amount) { - if (!_data.containsKey(cd)) - { - _data.put(cd, amount); - return; - } - - _data.put(cd, _data.get(cd) + amount); + _data.put(cd, amount); } public void incrementData(String key, int amount) 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 63a8bb0e3..c57e2a03f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java @@ -67,47 +67,37 @@ public class CustomDataRepository extends RepositoryBase }); } - public void saveData(String name) + public void saveData(String name, int accountId) { PlayerCustomData data = _customDataManager.Get(name); - System.out.println("saving data for " + name); - System.out.println("size = " + data.getDataMap().keySet().size()); - for (CustomData cd : data.getDataMap().keySet()) { - System.out.println(cd.getKey()); executeInsert(UPDATE_DATA, new ResultSetCallable() { @Override public void processResultSet(ResultSet resultSet) throws SQLException { - System.out.println("executed update data"); if (!resultSet.isBeforeFirst()) { - System.out.println("empty result set"); // Not already in the DB executeUpdate( INSERT_DATA, - new ColumnInt("account", _clientManager.Get(name).getAccountId()), + new ColumnInt("account", accountId), new ColumnInt("customData", cd.getId()), new ColumnInt("data", data.getDataMap().get(cd)) ); } - else - System.out.println("no second execute"); } }, new ColumnInt("data", data.getDataMap().get(cd)), - new ColumnInt("account", _clientManager.Get(name).getAccountId()), + new ColumnInt("account", accountId), new ColumnInt("customData", cd.getId()) ); } - - System.out.println("complete"); } public void registerKey(String key) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index b90ed49b2..a9fcae09a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -126,23 +126,6 @@ public class Gladiators extends SoloGame _firstRound = true; } - @EventHandler - public void testPlayer(PlayerCommandPreprocessEvent e) - { - if (!e.getPlayer().getName().equals("WilliamTiger")) - return; - - if (e.getMessage().equalsIgnoreCase("/arcadeplayer")) - { - Manager.getArcadePlayer(e.getPlayer()).put("test", 100); - e.getPlayer().sendMessage(C.cGreen + "Added the test value!"); - } - else if (e.getMessage().equalsIgnoreCase("/getback")) - { - e.getPlayer().sendMessage("value: " + Manager.getArcadePlayer(e.getPlayer()).get("test")); - } - } - @EventHandler public void tutorialStart(GameTutorialStartEvent e) { From 3e8c3cb9280cc2dfe3b05c222e16102f2509f2d9 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 17 Dec 2015 22:16:05 +0000 Subject: [PATCH 38/45] Changed to setData in PlayerCustomData --- .../core/customdata/CustomDataManager.java | 4 +--- .../core/customdata/MineplexPlayer.java | 2 +- .../core/customdata/PlayerCustomData.java | 22 +++++++++---------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java index 11ca1c388..cd0543674 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/CustomDataManager.java @@ -4,8 +4,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; @@ -33,7 +31,7 @@ public class CustomDataManager extends MiniDbClientPlugin PlayerCustomData data = new PlayerCustomData(_repository); while (resultSet.next()) { - data.incrementData(_repository.getKey(resultSet.getInt("customDataId")), resultSet.getInt("data")); + data.setData(_repository.getKey(resultSet.getInt("customDataId")), resultSet.getInt("data")); } Set(playerName, data); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java index d9e5a54fa..e49f75211 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/MineplexPlayer.java @@ -30,7 +30,7 @@ public abstract class MineplexPlayer public void put(String key, int data) { key = getKeyPrefix() + key; - _customDataManager.Get(getPlayer()).incrementData(key, data); + _customDataManager.Get(getPlayer()).setData(key, data); } public int get(String key) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java b/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java index 9e1d5db78..961d68023 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/PlayerCustomData.java @@ -24,31 +24,31 @@ public class PlayerCustomData return _data; } - public void incrementData(CustomData cd, int amount) + public void setData(CustomData cd, int amount) { _data.put(cd, amount); } - public void incrementData(String key, int amount) + public void setData(String key, int amount) { if (_repository.doesKeyExist(key)) { - incrementData(_repository.getKey(key), amount); + setData(_repository.getKey(key), amount); return; } _repository.getClientManager().getScheduler().runTaskAsynchronously( _repository.getClientManager().getPlugin(), new Runnable() - { - @Override - public void run() - { - _repository.registerKey(key); // Make sure it's in the DB. + { + @Override + public void run() + { + _repository.registerKey(key); // Make sure it's in the DB. - incrementData(_repository.getKey(key), amount); // Input - } - }); + setData(_repository.getKey(key), amount); // Input + } + }); } public int getData(String key) From e7243d4b9c814266ebe3c03a08730b054fadc56b Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 17 Dec 2015 22:19:45 +0000 Subject: [PATCH 39/45] Re-add getArcadePlayer(Player player) --- .../src/nautilus/game/arcade/ArcadeManager.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 c4026ff48..d0c003551 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -104,6 +104,7 @@ import nautilus.game.arcade.managers.GameWorldManager; import nautilus.game.arcade.managers.HolidayManager; import nautilus.game.arcade.managers.IdleManager; import nautilus.game.arcade.managers.MiscManager; +import nautilus.game.arcade.player.ArcadePlayer; import nautilus.game.arcade.shop.ArcadeShop; import org.bukkit.Bukkit; @@ -1444,4 +1445,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation event.setCancelled(true); } } + + public ArcadePlayer getArcadePlayer(Player player) + { + return new ArcadePlayer(player, getCustomDataManager(), this); + } } From 2953fe395fb3650b3e058b506c74d53af72f56e2 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Thu, 17 Dec 2015 18:33:49 -0500 Subject: [PATCH 40/45] Changed dns api key to new key. Prevent server monitor redis calls to cause restarts. Added winter chests to customer support. --- .../bungee/api/DnsMadeEasyApiCallBase.java | 4 +- Plugins/Mineplex.Core/.classpath | 2 +- .../mineplex/servermonitor/ServerMonitor.java | 52 +++++++++++-------- .../customerSupport/CustomerSupport.java | 13 +++++ 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/DnsMadeEasyApiCallBase.java b/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/DnsMadeEasyApiCallBase.java index f4e7aac72..57dc55496 100644 --- a/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/DnsMadeEasyApiCallBase.java +++ b/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/DnsMadeEasyApiCallBase.java @@ -51,13 +51,13 @@ public abstract class DnsMadeEasyApiCallBase try { String timeStamp = getServerTime(); - SecretKeySpec keySpec = new SecretKeySpec("35bb3b97-3815-4b63-b60b-eb1882c07b40".getBytes(), "HmacSHA1"); + SecretKeySpec keySpec = new SecretKeySpec("9041bc01-5cbc-49cf-ae09-a23b98350c62".getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(keySpec); byte[] hashBytes = mac.doFinal((timeStamp + "").getBytes()); Hex.encodeHexString(hashBytes); - request.addHeader("x-dnsme-apiKey", "a9750980-b7df-4a7e-a047-2ade43628f0d"); + request.addHeader("x-dnsme-apiKey", "2039c697-6ca9-412f-abda-0aef659a382a"); request.addHeader("x-dnsme-requestDate", timeStamp + ""); request.addHeader("x-dnsme-hmac", Hex.encodeHexString(hashBytes)); request.addHeader("Content-Type", "application/json"); diff --git a/Plugins/Mineplex.Core/.classpath b/Plugins/Mineplex.Core/.classpath index ea3a54132..4213d7778 100644 --- a/Plugins/Mineplex.Core/.classpath +++ b/Plugins/Mineplex.Core/.classpath @@ -13,7 +13,7 @@ - + diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index 8056b8d2a..cb57dc313 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -406,30 +406,40 @@ public class ServerMonitor if (deadServer.getUptime() <= 10 || ignoreServer(deadServer.getGroup())) continue; - if (_count == 0 || deadServers.contains(deadServer.getName())) + try { - copyServerLog(deadServer); - killServer(deadServer.getName(), deadServer.getPublicAddress(), deadServer.getPlayerCount(), "[KILLED] [DEAD] " + deadServer.getName() + ":" + deadServer.getPublicAddress(), true); - - handleUserServerGroup(_serverGroupMap.get(deadServer.getGroup())); - } - else if (!_delayedKill.contains(deadServer.getName())) - { - startTimingReport(deadServer); - - _timer.schedule(new TimerTask() + if (_count == 0 || deadServers.contains(deadServer.getName())) { - public void run() + if (_count != 0) + copyServerLog(deadServer); + + killServer(deadServer.getName(), deadServer.getPublicAddress(), deadServer.getPlayerCount(), "[KILLED] [DEAD] " + deadServer.getName() + ":" + deadServer.getPublicAddress(), true); + + handleUserServerGroup(_serverGroupMap.get(deadServer.getGroup())); + } + else if (!_delayedKill.contains(deadServer.getName())) + { + startTimingReport(deadServer); + + _timer.schedule(new TimerTask() { - _deadServers.add(deadServer.getName()); - _delayedKill.remove(deadServer.getName()); - - stopTimingReport(deadServer); - log("[IMPENDING DEATH] : " + deadServer.getName() + ":" + deadServer.getPublicAddress()); - } - }, 20 * 1000); - - _delayedKill.add(deadServer.getName()); + public void run() + { + _deadServers.add(deadServer.getName()); + _delayedKill.remove(deadServer.getName()); + + stopTimingReport(deadServer); + log("[IMPENDING DEATH] : " + deadServer.getName() + ":" + deadServer.getPublicAddress()); + } + }, 20 * 1000); + + _delayedKill.add(deadServer.getName()); + } + } + catch (Exception exception) + { + log("[ERROR] : Trying to delete " + deadServer.getName() + ":" + deadServer.getPublicAddress()); + exception.printStackTrace(); } } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 99fd02eb4..1f12a4982 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -105,6 +105,7 @@ public class CustomerSupport extends MiniPlugin int oldChestsReceived = 0; int ancientChestsReceived = 0; int mythicalChestsReceived = 0; + int winterChestsReceived = 0; for (CoinTransactionToken transaction : donor.getCoinTransactions()) { @@ -150,12 +151,24 @@ public class CustomerSupport extends MiniPlugin } } + if (transaction.SalesPackageName.startsWith("Winter Chest")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 3) + winterChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]); + else if (transaction.SalesPackageName.split(" ").length == 2) + winterChestsReceived += 1; + } + + } } caller.sendMessage(C.cBlue + "Enjin Coin Total Received : " + C.cYellow + enjinCoinsReceived); caller.sendMessage(C.cBlue + "Old Chests Received : " + C.cYellow + oldChestsReceived); 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.cDGreen + C.Strike + "============================================="); _salesPackageManager.displaySalesPackages(caller, playerName); From 53f9a051c585ae4fc5d46c8ce9b1a460d9420ca4 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 17 Dec 2015 21:52:34 -0500 Subject: [PATCH 41/45] Fix spectator page sorting team list --- .../game/arcade/gui/spectatorMenu/page/SpectatorPage.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java index a5e801770..9e4c453b3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java @@ -4,10 +4,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; -import java.util.HashMap; import java.util.List; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -57,7 +55,7 @@ public class SpectatorPage extends _buttons = new IButton[54]; _items = new ItemStack[54]; - List teamList = _arcadeManager.GetGame().GetTeamList(); + List teamList = new ArrayList(_arcadeManager.GetGame().GetTeamList()); int playerCount = _arcadeManager.GetGame().GetPlayers(true).size(); From 2c09fd969ba997b4c585b42b1e6377a67b7508af Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 17 Dec 2015 22:24:44 -0500 Subject: [PATCH 42/45] Attempt at fixing spectator page --- .../game/arcade/gui/spectatorMenu/page/SpectatorPage.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java index 9e4c453b3..1b687bb71 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java @@ -151,9 +151,8 @@ public class SpectatorPage extends int rowsNeeded = (int) Math.ceil(teamPlayers.size() / 8.0); - _buttons = Arrays.copyOf(_buttons, _buttons.length - + (rowsNeeded * 9)); - _items = Arrays.copyOf(_items, _items.length + (rowsNeeded * 9) + rowsNeeded); + _buttons = Arrays.copyOf(_buttons, _buttons.length + (rowsNeeded * 9)); + _items = Arrays.copyOf(_items, _items.length + (rowsNeeded * 9)); for (int row = 0; row < rowsNeeded; row++) { @@ -176,6 +175,9 @@ public class SpectatorPage extends if (rowsNeeded == 1 && teamList.size() < 4 && playerCount <= 26) { currentRow += 2; + + _buttons = Arrays.copyOf(_buttons, _buttons.length + 9); + _items = Arrays.copyOf(_items, _items.length + 9); } else { From 2bf734a15ca073bcb911baf8644ce0d517e71fa2 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Thu, 17 Dec 2015 23:08:07 -0500 Subject: [PATCH 43/45] DONEONDONFA;SDJF;LADSF;OCAJEFOJ;FJAD;FAJSMLDFAH D --- .../core/achievement/AchievementCategory.java | 8 +- .../nautilus/game/arcade/ArcadeManager.java | 69 +++-- .../game/games/paintball/Paintball.java | 131 ++++---- .../games/paintball/PlayerCopyPaintball.java | 2 + .../game/games/paintball/kits/KitSniper.java | 2 +- .../kits/perks/PerkPaintballMachineGun.java | 6 +- .../kits/perks/PerkPaintballRifle.java | 3 + .../kits/perks/PerkPaintballShotgun.java | 3 + .../kits/perks/PerkPaintballSniper.java | 2 +- .../arcade/managers/GameTestingManager.java | 293 ++++++++++++++++++ 10 files changed, 425 insertions(+), 94 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTestingManager.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 16e65af63..7813b1e09 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -2,6 +2,10 @@ package mineplex.core.achievement; import java.util.List; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -10,10 +14,6 @@ import mineplex.core.game.GameDisplay; import mineplex.core.stats.PlayerStats; import mineplex.core.stats.StatsManager; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; - public enum AchievementCategory { GLOBAL("Global", null, 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 7e9d4a156..01ea9b8cf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -6,6 +6,39 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map.Entry; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerResourcePackStatusEvent; +import org.bukkit.event.player.PlayerResourcePackStatusEvent.Status; +import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.util.Vector; + +import com.google.common.base.Objects; + import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -39,7 +72,6 @@ import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.movement.Movement; -import mineplex.core.notifier.NotificationManager; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; import mineplex.core.party.PartyManager; @@ -100,45 +132,13 @@ import nautilus.game.arcade.managers.GameManager; import nautilus.game.arcade.managers.GamePlayerManager; import nautilus.game.arcade.managers.GameSpectatorManager; import nautilus.game.arcade.managers.GameStatManager; +import nautilus.game.arcade.managers.GameTestingManager; import nautilus.game.arcade.managers.GameTournamentManager; import nautilus.game.arcade.managers.GameWorldManager; import nautilus.game.arcade.managers.HolidayManager; import nautilus.game.arcade.managers.IdleManager; import nautilus.game.arcade.managers.MiscManager; import nautilus.game.arcade.shop.ArcadeShop; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockSpreadEvent; -import org.bukkit.event.block.LeavesDecayEvent; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerResourcePackStatusEvent; -import org.bukkit.event.player.PlayerResourcePackStatusEvent.Status; -import org.bukkit.event.server.ServerListPingEvent; -import org.bukkit.potion.PotionEffect; -import org.bukkit.util.Vector; - -import com.google.common.base.Objects; public class ArcadeManager extends MiniPlugin implements IRelation { @@ -302,6 +302,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _idleManager = new IdleManager(this); TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager); new HolidayManager(this, titanGiveaway); + new GameTestingManager(this); // Game Addons new CompassAddon(plugin, this); 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 b432d2361..f509b43dd 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 @@ -18,6 +18,7 @@ import org.bukkit.entity.EnderPearl; import org.bukkit.entity.Player; import org.bukkit.entity.Snowball; import org.bukkit.entity.ThrownPotion; +import org.bukkit.event.Cancellable; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; @@ -26,12 +27,14 @@ import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.scoreboard.NameTagVisibility; import org.bukkit.scoreboard.Team; @@ -49,6 +52,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.hologram.Hologram.HologramTarget; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; @@ -72,6 +76,7 @@ import nautilus.game.arcade.game.games.paintball.trackers.MedicStatTracker; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.stats.WinFastStatTracker; import nautilus.game.arcade.stats.WinWithoutLosingTeammateStatTracker; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; public class Paintball extends TeamGame { @@ -156,59 +161,44 @@ public class Paintball extends TeamGame @EventHandler public void Paint(final ProjectileHitEvent event) { - // Fixed projectile wool painting in waiting lobby. - if (IsLive() || GetState() == GameState.End) { if (event.getEntity() instanceof ThrownPotion) return; final byte color = (byte) (event.getEntity() instanceof EnderPearl || (event.getEntity() instanceof Arrow && event.getEntity().hasMetadata("color") && ChatColor.values()[event.getEntity().getMetadata("color").get(0).asInt()] == ChatColor.RED) ? 14 : 3); - - if (event.getEntity() instanceof Arrow) - { - Manager.runSyncLater(new Runnable() // Stupid thing I have to do to make sure the arrow's location is accounted for. Stupid mojang. - Myst - { - @Override - public void run() + + event.getEntity().setVelocity(event.getEntity().getVelocity().normalize().multiply(1.2)); + + PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(new int[]{event.getEntity().getEntityId()}); + for (Player player : UtilServer.getPlayers()) + UtilPlayer.sendPacket(player, destroy); + + Manager.runSyncLater(new Runnable() // Stupid thing I have to do to make sure the arrow's location is accounted for. Stupid mojang. - Myst { - Location loc = event.getEntity().getLocation(); - loc.add(event.getEntity().getVelocity().clone().normalize().multiply(.5)); - - for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet()) - { - if (block.getType() != Material.WOOL && block.getType() != Material.STAINED_CLAY) - continue; - - block.setData(color); - } - - if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); - else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); - - event.getEntity().remove(); - } - }, 1); - } - else - { - Location loc = event.getEntity().getLocation(); - loc.add(event.getEntity().getVelocity().clone().normalize().multiply(.5)); - - for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet()) + @Override + public void run() { - if (block.getType() != Material.WOOL && block.getType() != Material.STAINED_CLAY) - continue; + Location loc = event.getEntity().getLocation(); + // loc.add(event.getEntity().getVelocity().clone().normalize().multiply(.5)); - block.setData(color); + for (Block block : UtilBlock.getInRadius(loc, 1.5d).keySet()) + { + if (block.getType() != Material.WOOL && block.getType() != Material.STAINED_CLAY && block.getType() != Material.HARD_CLAY) + continue; + + if (block.getType() == Material.HARD_CLAY) + block.setType(Material.STAINED_CLAY); + + block.setData(color); + } + + if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); + else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); + + event.getEntity().remove(); } - - if (color == 3) loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 8); - else loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 10); - - event.getEntity().remove(); - } - + }, 0); } } @@ -238,7 +228,7 @@ public class Paintball extends TeamGame event.SetCancelled("No Projectile"); } - @EventHandler + @EventHandler(priority = EventPriority.LOW) public void PaintballDamage(CustomDamageEvent event) { if (!IsLive()) @@ -359,7 +349,7 @@ public class Paintball extends TeamGame } public void PlayerOut(Player player, Player killer) - { + { //State SetPlayerState(player, PlayerState.OUT); player.setHealth(20); @@ -368,15 +358,15 @@ public class Paintball extends TeamGame Manager.GetCondition().Factory().Blind("Hit", player, player, 1.5, 0, false, false, false); Manager.GetCondition().Factory().Cloak("Hit", player, player, 9999, false, false); + _doubles.put(player, new PlayerCopyPaintball(this, player, killer, GetTeam(player).GetColor())); + //Settings player.setAllowFlight(true); player.setFlying(true); ((CraftPlayer)player).getHandle().spectating = true; ((CraftPlayer)player).getHandle().k = false; - + UtilAction.velocity(player, new Vector(0,1.2,0)); - - _doubles.put(player, new PlayerCopyPaintball(this, player, killer, GetTeam(player).GetColor())); } // @EventHandler @@ -545,20 +535,55 @@ public class Paintball extends TeamGame @EventHandler public void onHeal(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + LaunchPotion(event.getPlayer(), event); + } + + @EventHandler + public void onHeal(PlayerInteractEntityEvent event) + { + LaunchPotion(event.getPlayer(), event); + } + + @EventHandler(ignoreCancelled = false) + public void onHeal(PlayerInteractAtEntityEvent event) + { + LaunchPotion(event.getPlayer(), event); + } + + public void LaunchPotion(Player player, Cancellable event) { if (!IsLive()) return; - if (!UtilEvent.isAction(event, ActionType.R)) + if (!UtilGear.isMat(player.getItemInHand(), Material.POTION)) return; - if (!UtilGear.isMat(event.getItem(), Material.POTION)) + event.setCancelled(true); + + if (!IsAlive(player) || UtilPlayer.isSpectator(player)) + return; + + if (!Recharge.Instance.use(player, "Water Potion", 250, false, false)) return; + + UtilInv.UseItemInHand(player); - if (!IsAlive(event.getPlayer()) || UtilPlayer.isSpectator(event.getPlayer())) - event.setCancelled(true); + ThrownPotion potion = player.launchProjectile(ThrownPotion.class); + potion.getEffects().clear(); + potion.getEffects().add(new PotionEffect(PotionEffectType.WATER_BREATHING, 100, 100)); - UtilInv.Update(event.getPlayer()); + Manager.runAsync(new Runnable() + { + @Override + public void run() + { + UtilInv.Update(player); + } + }); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java index f89e0c66d..a42d2592b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopyPaintball.java @@ -76,12 +76,14 @@ public class PlayerCopyPaintball _holo = new Hologram(host.Manager.getHologramManager(), _ent.getLocation().clone().add(0, 2.2, 0)); _holo.setText(C.cWhite + C.Bold + C.Scramble + "XX" + ChatColor.RESET + " " + nameColor + owner.getName() + " " + C.cWhite + C.Bold + C.Scramble + "XX", C.cWhite + "Painted by " + host.GetTeam(paintedBy).GetColor() + paintedBy.getName()); _holo.setHologramTarget(HologramTarget.WHITELIST); + _holo.setFollowEntity(_ent); _holo.start(); //Save me _saveMe = new Hologram(host.Manager.getHologramManager(), _ent.getLocation().clone().add(0, 2.8, 0)); _saveMe.setText(C.cRedB + "SAVE ME!"); _saveMe.setHologramTarget(HologramTarget.WHITELIST); + _saveMe.setFollowEntity(_ent); _saveMe.start(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java index e7d41949a..ac49ab365 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java @@ -29,7 +29,7 @@ public class KitSniper extends Kit new String[] { "Long range sniper rifle", - C.cGold + "Higher damage every second scoped" + C.cGold + "Higher damage the longer scoped" }, new Perk[] diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballMachineGun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballMachineGun.java index 9cc331b61..081fef3e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballMachineGun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballMachineGun.java @@ -51,6 +51,9 @@ public class PerkPaintballMachineGun extends Perk @EventHandler public void Shoot(PlayerInteractEvent event) { + if (!Manager.GetGame().IsLive()) + return; + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) return; @@ -95,7 +98,8 @@ public class PerkPaintballMachineGun extends Perk //Energy if (player.getExp() >= 0.97) return; - player.setExp((float) (player.getExp() + 0.025)); + + player.setExp((float) Math.min(.999, player.getExp() + 0.025)); //Shoot Vector rand = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballRifle.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballRifle.java index 963da3e0c..944d6ae7a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballRifle.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballRifle.java @@ -39,6 +39,9 @@ public class PerkPaintballRifle extends Perk @EventHandler public void Shoot(PlayerInteractEvent event) { + if (!Manager.GetGame().IsLive()) + return; + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballShotgun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballShotgun.java index 6c14682f9..7e6f6646f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballShotgun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballShotgun.java @@ -42,6 +42,9 @@ public class PerkPaintballShotgun extends Perk @EventHandler public void Shoot(PlayerInteractEvent event) { + if (!Manager.GetGame().IsLive()) + return; + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java index 320a71a1c..f863678e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java @@ -237,7 +237,7 @@ public class PerkPaintballSniper extends Perk implements IPacketHandler if (!_crouching.contains(player)) continue; - player.setExp((float) Math.min(.999F, player.getExp() + .01666)); + player.setExp((float) Math.min(.999F, player.getExp() + .03332)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTestingManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTestingManager.java new file mode 100644 index 000000000..ce554376b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTestingManager.java @@ -0,0 +1,293 @@ +package nautilus.game.arcade.managers; + +import java.util.HashSet; +import java.util.Set; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerLoginEvent.Result; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import nautilus.game.arcade.ArcadeManager; + +public class GameTestingManager implements Listener +{ + /** + * Created by: Mysticate + * Timestamp: November 25, 2015 + */ + + private ArcadeManager _manager; + + private boolean _enabled; + + private boolean _capped = false; + private int _cap = 16; + private String _capMessage = ""; + + private boolean _whitelisted = false; + private Set _whitelistAdded = new HashSet(); + private String _whitelistMessage = ""; + + public GameTestingManager(ArcadeManager manager) + { + _manager = manager; + + _manager.getPluginManager().registerEvents(this, _manager.getPlugin()); + + _enabled = _manager.getPlugin().getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing"); + } + + public ArcadeManager getManager() + { + return _manager; + } + + public void setCapped(boolean cap) + { + _capped = cap; + } + + public boolean isCapped() + { + return _capped; + } + + public void setCap(int cap) + { + _cap = cap; + } + + public int getCap() + { + return _cap; + } + + public boolean isWhitelisted(String name) + { + return _whitelistAdded.contains(new String(name).toLowerCase()); + } + + public void setWhitelisted(String name, boolean whitelist) + { + if (isWhitelisted(name)) + { + _whitelistAdded.remove(name.toLowerCase()); + } + else + { + _whitelistAdded.add(new String(name).toLowerCase()); + } + } + + @EventHandler + public void onLogin(PlayerLoginEvent event) + { + if (!_enabled) + return; + + if (_capped) + { + if (UtilServer.getPlayers().length >= _cap) + { + if (!isWhitelisted(event.getPlayer().getName())) + { + event.disallow(Result.KICK_FULL, C.cGray + "That server has a set cap!\n" + + C.cGray + "Current players " + C.cYellow + UtilServer.getPlayers().length + "/" + _cap + "\n" + + C.cGreen + _capMessage); + } + return; + } + } + + if (_whitelisted) + { + if (!isWhitelisted(event.getPlayer().getName())) + { + event.disallow(Result.KICK_FULL, C.cGray + "That server has a testing whitelist!\n" + + C.cGray + "Current players " + C.cYellow + UtilServer.getPlayers().length + "/" + _cap + "\n" + + C.cGreen + _capMessage); + } + return; + } + } + + @EventHandler + public void onCommandTesting(PlayerCommandPreprocessEvent event) + { + if (!_enabled) + return; + + String[] args = event.getMessage().split(" "); + String cmd = args[0]; + + if (!cmd.equalsIgnoreCase("/testing")) + return; + + event.setCancelled(true); + + if (!_manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.JNR_DEV, true)) + return; + + if (args.length == 1) // Help + { + sendGlobalHelp(event.getPlayer()); + return; + } + else if (args[1].equalsIgnoreCase("cap")) + { + if (args.length == 2) + { + sendCapHelp(event.getPlayer()); + return; + } + + if (args.length == 3) // No cap arguments + { + if (args[2].equalsIgnoreCase("toggle")) + { + _capped = !_capped; + UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing cap enabled " + F.tf(_capped) + ".")); + return; + } + + try + { + _cap = Integer.valueOf(args[2]); + UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing cap set to " + F.elem("" + _cap) + ".")); + } + catch (Exception ex) + { + sendCapHelp(event.getPlayer()); + } + return; + } + + if (args.length >= 4) + { + if (args[2].equalsIgnoreCase("message")) + { + String message = ""; + for (int i = 3 ; i < args.length ; i++) + message += (args[i] + " "); + + _capMessage = message.trim(); + UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing cap message set to " + F.elem(_capMessage) + ".")); + return; + } + + sendCapHelp(event.getPlayer()); + return; + } + + sendCapHelp(event.getPlayer()); + return; + } + else if (args[1].equalsIgnoreCase("whitelist")) + { + if (args.length == 2) + { + sendWhitelistHelp(event.getPlayer()); + return; + } + + if (args.length == 3) // No cap arguments + { + if (args[2].equalsIgnoreCase("toggle")) + { + _whitelisted = !_whitelisted; + UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing whitelist enabled " + F.tf(_whitelisted) + ".")); + return; + } + + sendWhitelistHelp(event.getPlayer()); + return; + } + + if (args.length == 4) + { + if (args[2].equalsIgnoreCase("add")) + { + String playerName = args[3]; + + if (isWhitelisted(playerName)) + { + UtilPlayer.message(event.getPlayer(), F.main("Testing", "That player is already whitelisted!")); + } + else + { + setWhitelisted(playerName, true); + UtilPlayer.message(event.getPlayer(), F.main("Testing", "You have whitelisted " + F.name(playerName) + ".")); + } + return; + } + else if (args[2].equalsIgnoreCase("remove")) + { + String playerName = args[3]; + + if (!isWhitelisted(playerName)) + { + UtilPlayer.message(event.getPlayer(), F.main("Testing", "That player is not whitelisted!")); + } + else + { + setWhitelisted(playerName, false); + UtilPlayer.message(event.getPlayer(), F.main("Testing", "You have removed " + F.name(playerName) + " from the whitelist.")); + } + return; + } + } + + if (args.length >= 4) + { + if (args[2].equalsIgnoreCase("message")) + { + String message = ""; + for (int i = 3 ; i < args.length ; i++) + message += (args[i] + " "); + + _whitelistMessage = message.trim(); + UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing whitelist message set to " + F.elem(_whitelistMessage) + ".")); + return; + } + + sendWhitelistHelp(event.getPlayer()); + return; + } + + sendWhitelistHelp(event.getPlayer()); + return; + } + } + + private void sendGlobalHelp(Player player) + { + UtilPlayer.message(player, ""); + UtilPlayer.message(player, F.main("Testing", "/testing cap")); + UtilPlayer.message(player, F.main("Testing", "/testing whitelist")); + } + + private void sendCapHelp(Player player) + { + UtilPlayer.message(player, ""); + UtilPlayer.message(player, F.main("Testing", "/testing cap toggle")); + UtilPlayer.message(player, F.main("Testing", "/testing cap ")); + UtilPlayer.message(player, F.main("Testing", "/testing cap message ")); + } + + private void sendWhitelistHelp(Player player) + { + UtilPlayer.message(player, ""); + UtilPlayer.message(player, F.main("Testing", "/testing whitelist toggle")); + UtilPlayer.message(player, F.main("Testing", "/testing whitelist add ")); + UtilPlayer.message(player, F.main("Testing", "/testing whitelist remove ")); + UtilPlayer.message(player, F.main("Testing", "/testing whitelist message ")); + } +} \ No newline at end of file From d561915fd32885036b55cc6a05899934a544e131 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Thu, 17 Dec 2015 23:16:57 -0500 Subject: [PATCH 44/45] FORMATTING CHANG EI'M GOING TO CRY UGH --- .../game/arcade/game/games/paintball/kits/KitSniper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java index ac49ab365..3baa4479e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java @@ -53,7 +53,7 @@ public class KitSniper extends Kit @Override public void GiveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_HOE, (byte)0, 1, C.cWhite + "Paintball Sniper Rifle")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_HOE, (byte)0, 1, F.item("Paintball Sniper Rifle"))); ItemStack potion = new ItemStack(Material.POTION, 2, (short)16429); // 16422 PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); From f80648bfbc25db91b295dcbbc917e192b1693f28 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 18 Dec 2015 00:32:07 -0500 Subject: [PATCH 45/45] Update DBPool to load from file --- .../account/repository/AccountRepository.java | 2 +- .../core/antihack/AntiHackRepository.java | 2 +- .../benefit/BenefitManagerRepository.java | 2 +- .../mineplex/core/bonuses/BonusManager.java | 2 +- .../core/bonuses/BonusRepository.java | 4 +- .../botspam/repository/BotSpamRepository.java | 2 +- .../repository/CustomDataRepository.java | 2 +- .../src/mineplex/core/database/DBPool.java | 98 ++++++++++++++++++- .../core/database/RepositoryBase.java | 2 +- .../repository/DonationRepository.java | 2 +- .../src/mineplex/core/elo/EloRepository.java | 2 +- .../core/friend/data/FriendRepository.java | 2 +- .../core/giveaway/GiveawayRepository.java | 2 +- .../core/ignore/data/IgnoreRepository.java | 2 +- .../inventory/data/InventoryRepository.java | 2 +- .../leaderboard/StatEventsRepository.java | 2 +- .../src/mineplex/core/npc/NpcManager.java | 8 +- .../core/pet/repository/PetRepository.java | 2 +- .../mineplex/core/poll/PollRepository.java | 2 +- .../preferences/PreferencesRepository.java | 2 +- .../core/report/ReportRepository.java | 2 +- .../mineplex/core/spawn/SpawnRepository.java | 2 +- .../mineplex/core/stats/StatsRepository.java | 2 +- .../core/task/repository/TaskRepository.java | 2 +- .../TitanGiveawayRepository.java | 2 +- .../clans/core/repository/ClanRepository.java | 2 +- .../fields/repository/FieldRepository.java | 2 +- .../src/mineplex/hub/HubRepository.java | 10 +- .../src/mineplex/hub/mail/MailRepository.java | 2 +- .../mineplex/hub/queue/QueueRepository.java | 10 +- .../mineplex/votifier/VotifierManager.java | 2 +- .../TitanGiveawayRepository.java | 2 +- 32 files changed, 136 insertions(+), 48 deletions(-) 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 d8362e33b..d11b9a081 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -46,7 +46,7 @@ public class AccountRepository extends RepositoryBase public AccountRepository(JavaPlugin plugin, String webAddress) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _webAddress = webAddress; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java index 1b7fb4b65..23a0694b0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHackRepository.java @@ -33,7 +33,7 @@ public class AntiHackRepository { PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.STATS_MINEPLEX.getConnection()) + try (Connection connection = DBPool.getStats().getConnection()) { preparedStatement = connection.prepareStatement(UPDATE_PLAYER_OFFENSES); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManagerRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManagerRepository.java index 39fbfa530..eb5628130 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManagerRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManagerRepository.java @@ -19,7 +19,7 @@ public class BenefitManagerRepository extends RepositoryBase public BenefitManagerRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index e5076f9b0..6c01d3719 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -789,7 +789,7 @@ public class BonusManager extends MiniClientPlugin implements I { try { - final int newTickets = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL).update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(tickets)). + final int newTickets = DSL.using(DBPool.getAccount(), SQLDialect.MYSQL).update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(tickets)). where(Tables.bonus.accountId.eq(accountId)).returning(Tables.bonus.tickets).fetchOne().getTickets(); runSync(new Runnable() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java index 0c4a1c6f5..2ce772e8c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java @@ -36,7 +36,7 @@ public class BonusRepository extends RepositoryBase public BonusRepository(JavaPlugin plugin, BonusManager bonusManager, DonationManager donationManager) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _manager = bonusManager; _donationManager = donationManager; } @@ -145,7 +145,7 @@ public class BonusRepository extends RepositoryBase { try { - DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); + DSLContext create = DSL.using(DBPool.getAccount(), SQLDialect.MYSQL); create.update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(tickets)). where(Tables.bonus.accountId.eq(accountId)).execute(); final int newTickets = create.select(Tables.bonus.tickets).from(Tables.bonus).where(Tables.bonus.accountId.eq(accountId)).fetchOne().value1(); 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 d1460fb4a..3af3d0d4f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/repository/BotSpamRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/repository/BotSpamRepository.java @@ -24,7 +24,7 @@ public class BotSpamRepository extends RepositoryBase public BotSpamRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } public ArrayList getSpamText() 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 c57e2a03f..51866e26f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/customdata/repository/CustomDataRepository.java @@ -35,7 +35,7 @@ public class CustomDataRepository extends RepositoryBase public CustomDataRepository(JavaPlugin plugin, CoreClientManager clientManager, CustomDataManager customDataManager) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _clientManager = clientManager; _customDataManager = customDataManager; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java b/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java index 8400fa954..06495ff54 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java @@ -1,16 +1,26 @@ package mineplex.core.database; import javax.sql.DataSource; + +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 { - public static final DataSource ACCOUNT = openDataSource("jdbc:mysql://db.mineplex.com/Account", "MilitaryPolice", "CUPr6Wuw2Rus$qap"); - public static final DataSource QUEUE = openDataSource("jdbc:mysql://db.mineplex.com/Queue", "MilitaryPolice", "CUPr6Wuw2Rus$qap"); - public static final DataSource MINEPLEX = openDataSource("jdbc:mysql://db.mineplex.com:3306/Mineplex", "MilitaryPolice", "CUPr6Wuw2Rus$qap"); - public static final DataSource STATS_MINEPLEX = openDataSource("jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex", "root", "tAbechAk3wR7tuTh"); + private static DataSource ACCOUNT; + private static DataSource QUEUE; + private static DataSource MINEPLEX; + private static DataSource STATS_MINEPLEX; private static DataSource openDataSource(String url, String username, String password) { @@ -30,8 +40,86 @@ public final class DBPool return source; } - private DBPool() + public static DataSource getAccount() { + if (ACCOUNT == null) + loadDataSources(); + return ACCOUNT; + } + + public static DataSource getQueue() + { + if (QUEUE == null) + loadDataSources(); + + return QUEUE; + } + + public static DataSource getMineplex() + { + if (MINEPLEX == null) + loadDataSources(); + + return MINEPLEX; + } + + public static DataSource getStats() + { + if (STATS_MINEPLEX == null) + loadDataSources(); + + return STATS_MINEPLEX; + } + + private static void loadDataSources() + { + try + { + File configFile = new File("database-config.dat"); + + if (configFile.exists()) + { + List lines = Files.readAllLines(configFile.toPath(), Charset.defaultCharset()); + + for (String line : lines) + { + deserializeConnection(line); + } + } + else + { + System.out.println("database-config.dat not found at " + configFile.toPath().toString()); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + System.out.println("---Unable To Parse DBPOOL Configuration File---"); + } + } + + private static void deserializeConnection(String line) + { + String[] args = line.split(" "); + + if (args.length == 4) + { + String dbSource = args[0]; + String dbHost = args[1]; + String userName = args[2]; + String password = args[3]; + + System.out.println(dbSource + " " + dbHost + " " + userName + " " + password); + + if (dbSource.toUpperCase().equalsIgnoreCase("ACCOUNT")) + ACCOUNT = openDataSource("jdbc:mysql://" + dbHost, userName, password); + else if (dbSource.toUpperCase().equalsIgnoreCase("QUEUE")) + QUEUE = openDataSource("jdbc:mysql://" + dbHost, userName, password); + else if (dbSource.toUpperCase().equalsIgnoreCase("MINEPLEX")) + MINEPLEX = openDataSource("jdbc:mysql://" + dbHost, userName, password); + else if (dbSource.toUpperCase().equalsIgnoreCase("STATS")) + STATS_MINEPLEX = openDataSource("jdbc:mysql://" + dbHost, userName, password); + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java b/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java index f96d1b04d..55acc83ed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java @@ -68,7 +68,7 @@ public abstract class RepositoryBase implements Listener protected DSLContext jooq() { - return DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); + return DSL.using(DBPool.getAccount(), SQLDialect.MYSQL); } /** 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 910f03c63..98999dbf3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java @@ -37,7 +37,7 @@ public class DonationRepository extends RepositoryBase public DonationRepository(JavaPlugin plugin, String webAddress) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _webAddress = webAddress; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java index 54503474f..2304a75c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java @@ -17,7 +17,7 @@ public class EloRepository extends RepositoryBase public EloRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); initialize(); } 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 c7ab1ae90..c09fe1703 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/data/FriendRepository.java @@ -37,7 +37,7 @@ public class FriendRepository extends RepositoryBase public FriendRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _repository = new RedisDataRepository(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), Region.currentRegion(), PlayerStatus.class, "playerStatus"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java index c8cac2179..46844bd07 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java @@ -26,7 +26,7 @@ public class GiveawayRepository extends RepositoryBase public GiveawayRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } public boolean canGiveaway(int accountId, String giveawayName, String cooldownName) 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 aad60e65c..14e1918c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java @@ -17,7 +17,7 @@ public class IgnoreRepository extends RepositoryBase public IgnoreRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override 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 a21d6c9ec..018eb41e9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java @@ -29,7 +29,7 @@ public class InventoryRepository extends RepositoryBase public InventoryRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java index 1679bc36d..5f0659c03 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java @@ -36,7 +36,7 @@ public class StatEventsRepository extends RepositoryBase */ public StatEventsRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index 5e971bf50..1235a6301 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -268,7 +268,7 @@ public class NpcManager extends MiniPlugin public Entity addNpc(Player player, EntityType entityType, double radius, boolean adult, String name, String entityMeta) throws SQLException { - try (Connection connection = DBPool.ACCOUNT.getConnection()) + try (Connection connection = DBPool.getAccount().getConnection()) { String helmet = itemStackToYaml(player.getInventory().getHelmet()); String chestplate = itemStackToYaml(player.getInventory().getChestplate()); @@ -386,7 +386,7 @@ public class NpcManager extends MiniPlugin if (npc != null) { - try (Connection connection = DBPool.ACCOUNT.getConnection()) + try (Connection connection = DBPool.getAccount().getConnection()) { npc.getDatabaseRecord().attach(DSL.using(connection).configuration()); npc.getDatabaseRecord().delete(); @@ -493,7 +493,7 @@ public class NpcManager extends MiniPlugin { String serverType = getServerName(); - try (Connection connection = DBPool.ACCOUNT.getConnection()) + try (Connection connection = DBPool.getAccount().getConnection()) { Result result = DSL.using(connection) .selectFrom(Tables.npcs) @@ -519,7 +519,7 @@ public class NpcManager extends MiniPlugin { String serverType = getServerName(); - try (Connection connection = DBPool.ACCOUNT.getConnection()) + try (Connection connection = DBPool.getAccount().getConnection()) { DSL.using(connection) .delete(Tables.npcs) 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 a79065f4c..40c2d2e1c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java @@ -22,7 +22,7 @@ public class PetRepository extends RepositoryBase public PetRepository(JavaPlugin plugin, String webAddress) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _webAddress = webAddress; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java index 588d3d549..9628a5c93 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java @@ -29,7 +29,7 @@ public class PollRepository extends RepositoryBase public PollRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java index eca4dd35f..3c90a2cce 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java @@ -28,7 +28,7 @@ public class PreferencesRepository extends RepositoryBase public PreferencesRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java index cbae2678c..7b550e058 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java @@ -41,7 +41,7 @@ This will be used to determine if staff are handling public ReportRepository(JavaPlugin plugin, String connectionString) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java index eb85bae9d..c6f4191a5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java @@ -23,7 +23,7 @@ public class SpawnRepository extends RepositoryBase public SpawnRepository(JavaPlugin plugin, String serverName) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _serverName = serverName; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java index d32b5fee3..12deca990 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java @@ -32,7 +32,7 @@ public class StatsRepository extends RepositoryBase public StatsRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override 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 95a427d11..51dfe5726 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/task/repository/TaskRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/task/repository/TaskRepository.java @@ -24,7 +24,7 @@ public class TaskRepository extends RepositoryBase public TaskRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java index 4eb95a46d..b6d29c68b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titangiveaway/TitanGiveawayRepository.java @@ -20,7 +20,7 @@ public class TitanGiveawayRepository extends RepositoryBase public TitanGiveawayRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _titanCount = 0; } 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 037593a54..70f9d082b 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 @@ -86,7 +86,7 @@ public class ClanRepository extends RepositoryBase public ClanRepository(JavaPlugin plugin, String serverName, boolean isClansServer) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _serverName = serverName; _serverId = -1; 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 cd45b22bc..2f36fd067 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 @@ -34,7 +34,7 @@ public class FieldRepository extends RepositoryBase public FieldRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); } public List getFieldBlocks(String server) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java index 5c09e8423..cf07e0012 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java @@ -41,7 +41,7 @@ public class HubRepository PreparedStatement preparedStatement = null; HashMap newsEntries = new HashMap(); - try (Connection connection = DBPool.MINEPLEX.getConnection()) + try (Connection connection = DBPool.getMineplex().getConnection()) { preparedStatement = connection.prepareStatement(RETRIEVE_NEWS_ENTRIES); @@ -91,7 +91,7 @@ public class HubRepository int result = 0; PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.MINEPLEX.getConnection()) + try (Connection connection = DBPool.getMineplex().getConnection()) { preparedStatement = connection.prepareStatement(SET_NEWS_ENTRY); preparedStatement.setString(1, newsEntry); @@ -127,7 +127,7 @@ public class HubRepository ResultSet resultSet = null; PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.MINEPLEX.getConnection()) + try (Connection connection = DBPool.getMineplex().getConnection()) { preparedStatement = connection.prepareStatement(RETRIEVE_MAX_NEWS_POSITION); resultSet = preparedStatement.executeQuery(); @@ -165,7 +165,7 @@ public class HubRepository int maxPos = retrieveMaxNewsPosition(); PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.MINEPLEX.getConnection()) + try (Connection connection = DBPool.getMineplex().getConnection()) { preparedStatement = connection.prepareStatement(ADD_NEWS_ENTRY); preparedStatement.setString(1, newsEntry); @@ -201,7 +201,7 @@ public class HubRepository int maxPos = retrieveMaxNewsPosition(); PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.MINEPLEX.getConnection()) + try (Connection connection = DBPool.getMineplex().getConnection()) { //preparedStatement = connection.prepareStatement(DELETE_RECALC_NEWS_ENTRY); preparedStatement = connection.prepareStatement(DELETE_NEWS_ENTRY); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java index af43ab9f5..ae09e592f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java @@ -21,7 +21,7 @@ public class MailRepository extends RepositoryBase public MailRepository(JavaPlugin plugin, MailManager manager) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _manager = manager; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/queue/QueueRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/queue/QueueRepository.java index 0dfdf8640..d0b0d0a91 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/queue/QueueRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/queue/QueueRepository.java @@ -36,7 +36,7 @@ public class QueueRepository { PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.QUEUE.getConnection()) + try (Connection connection = DBPool.getQueue().getConnection()) { preparedStatement = connection.prepareStatement(DELETE_QUEUE_RECORD); @@ -71,7 +71,7 @@ public class QueueRepository { PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.QUEUE.getConnection()) + try (Connection connection = DBPool.getQueue().getConnection()) { preparedStatement = connection.prepareStatement(SAVE_STATE_VALUE); preparedStatement.setString(1, matchStatus.State); @@ -108,7 +108,7 @@ public class QueueRepository PreparedStatement preparedStatement = null; PlayerMatchStatus matchStatus = new PlayerMatchStatus(); - try (Connection connection = DBPool.QUEUE.getConnection()) + try (Connection connection = DBPool.getQueue().getConnection()) { preparedStatement = connection.prepareStatement(INSERT_ACCOUNT, Statement.RETURN_GENERATED_KEYS); preparedStatement.setString(1, playerList); @@ -165,7 +165,7 @@ public class QueueRepository PreparedStatement preparedStatement = null; PlayerMatchStatus matchStatus = null; - try (Connection connection = DBPool.QUEUE.getConnection()) + try (Connection connection = DBPool.getQueue().getConnection()) { preparedStatement = connection.prepareStatement(RETRIEVE_MATCH_STATUS); preparedStatement.setInt(1, id); @@ -220,7 +220,7 @@ public class QueueRepository ResultSet resultSet = null; PreparedStatement preparedStatement = null; - try (Connection connection = DBPool.QUEUE.getConnection()) + try (Connection connection = DBPool.getQueue().getConnection()) { preparedStatement = connection.prepareStatement(RETRIEVE_OTHER_MATCH_STATUS); preparedStatement.setInt(1, matchStatus.AssignedMatch); diff --git a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java index 19a3c37b3..4817371cb 100644 --- a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java +++ b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java @@ -179,7 +179,7 @@ public class VotifierManager extends MiniPlugin private void awardBonus(final String playerName, final UUID uuid, final Callback onComplete) { - DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); + DSLContext create = DSL.using(DBPool.getAccount(), SQLDialect.MYSQL); Record1 idRecord = create.select(Tables.accounts.id).from(Tables.accounts).where(Tables.accounts.uuid.eq(uuid.toString())).fetchOne(); if (idRecord != null) 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 0ace10a33..3585b3586 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 @@ -15,7 +15,7 @@ public class TitanGiveawayRepository extends RepositoryBase public TitanGiveawayRepository(JavaPlugin plugin) { - super(plugin, DBPool.ACCOUNT); + super(plugin, DBPool.getAccount()); _titanGiveawayCount = 0; }