diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index a3df8747f..a710ccb1b 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -1617,35 +1617,4 @@ public class UtilBlock } } - - public static boolean water(Material type) - { - return type == Material.WATER || type == Material.STATIONARY_WATER; - } - - public static boolean lava(Material type) - { - return type == Material.LAVA || type == Material.STATIONARY_LAVA; - } - - public static boolean liquid(Material type) - { - return water(type) || lava(type); - } - - public static boolean water(Block block) - { - return water(block.getType()); - } - - public static boolean lava(Block block) - { - return lava(block.getType()); - } - - public static boolean liquid(Block block) - { - return liquid(block.getType()); - } - } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParser.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParser.java new file mode 100644 index 000000000..453904e1e --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParser.java @@ -0,0 +1,59 @@ +package mineplex.core.common.util; + +import org.bukkit.event.entity.EntityDamageEvent; + +public class UtilParser +{ + public static String parseDamageCause(EntityDamageEvent.DamageCause cause) + { + switch (cause) + { + case CONTACT: + return "Cactus"; + case ENTITY_ATTACK: + return "Attack"; + case PROJECTILE: + return "Ranged Weapon"; + case SUFFOCATION: + return "Suffocation"; + case FALL: + return "Fall"; + case FIRE: + return "Fire"; + case FIRE_TICK: + return "Burning"; + case MELTING: + return "Melting"; + case LAVA: + return "Lava"; + case DROWNING: + return "Drowning"; + case BLOCK_EXPLOSION: + return "Explosion"; + case ENTITY_EXPLOSION: + return "Explosion"; + case VOID: + return "Void"; + case LIGHTNING: + return "Lightning"; + case SUICIDE: + return "Suicide"; + case STARVATION: + return "Hunger"; + case POISON: + return "Poison"; + case MAGIC: + return "Thrown Potion"; + case WITHER: + return "Wither Effect"; + case FALLING_BLOCK: + return "Falling Block"; + case THORNS: + return "Thorns Enchantment"; + case CUSTOM: + return "Custom"; + default: + return "The Mighty defek7"; + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 52090385e..058c0e255 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -769,11 +769,11 @@ public enum Achievement new int[] {3}, AchievementCategory.BAWK_BAWK_BATTLES), -// BAWK_BAWK_BATTLES_BOUNCING_SHADOW("Bouncing Shadow", 500, -// new String[]{"Bawk Bawk Battles.BouncingShadow"}, -// new String[]{C.cGray + "Bouncing Block Challenge", "Win 3 entire rounds", "without stepping on red wool"}, -// new int[] {3}, -// AchievementCategory.BAWK_BAWK_BATTLES), + BAWK_BAWK_BATTLES_BOUNCING_SHADOW("Bouncing Shadow", 500, + new String[]{"Bawk Bawk Battles.BouncingShadow"}, + new String[]{C.cGray + "Bouncing Block Challenge", "Win 3 entire rounds", "without stepping on red wool"}, + new int[] {3}, + AchievementCategory.BAWK_BAWK_BATTLES), //Bomb Lobbers BOMB_LOBBERS_WINS("Master Bomber", 1200, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index e8d600949..c60d7594e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -592,7 +592,7 @@ public class GadgetManager extends MiniPlugin if (armor.getSlot() == slot) { - armor.removeArmor(player); + armor.removeArmor(player, true); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BabyCowBalloon.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BabyCowBalloon.java index 883957f59..4b1e7e23f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BabyCowBalloon.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BabyCowBalloon.java @@ -41,7 +41,7 @@ public class BabyCowBalloon extends BalloonGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { _entityStand.remove(); _balloonEntity.remove(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java index a9add458a..f0c658846 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java @@ -47,9 +47,9 @@ public class ItemBatGun extends ItemGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { - super.disableCustom(player); + super.disableCustom(player, message); Clear(player); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemEtherealPearl.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemEtherealPearl.java index 973d2f55d..96fa54ed6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemEtherealPearl.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemEtherealPearl.java @@ -42,9 +42,9 @@ public class ItemEtherealPearl extends ItemGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { - super.disableCustom(player); + super.disableCustom(player, message); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemPaintbrush.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemPaintbrush.java index 0c75b1a81..98171d0c3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemPaintbrush.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemPaintbrush.java @@ -89,13 +89,13 @@ public class ItemPaintbrush extends ItemGadget @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { _brushColor.remove(player.getName()); _brushPrevious.remove(player.getName()); _playerLocation.remove(player.getName()); - RemoveItem(player); + RemoveItem(player, message); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java index d8ca2a8eb..5a3e85f68 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBat.java @@ -65,7 +65,7 @@ public class MorphBat extends MorphGadget implements IThrown } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); Manager.getDisguiseManager().undisguise(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java index 57bb92473..0708fe148 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java @@ -48,7 +48,7 @@ public class MorphBlaze extends MorphGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); Manager.getDisguiseManager().undisguise(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlock.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlock.java index c04d0eba3..e1c9a15aa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlock.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlock.java @@ -54,7 +54,7 @@ public class MorphBlock extends MorphGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java index 60bd653e9..762dc9a7c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java @@ -79,7 +79,7 @@ public class MorphBunny extends MorphGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { _jumpCharge.remove(player); this.RemoveArmor(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java index 34a3cd6b9..20c997d91 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChicken.java @@ -54,7 +54,7 @@ public class MorphChicken extends MorphGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); Manager.getDisguiseManager().undisguise(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java index 4cbe53990..652c35330 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCow.java @@ -42,7 +42,7 @@ public class MorphCow extends MorphGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); Manager.getDisguiseManager().undisguise(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java index fe68c21f0..149c59a82 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java @@ -56,7 +56,7 @@ public class MorphCreeper extends MorphGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); Manager.getDisguiseManager().undisguise(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java index e167ec7c8..59e7d9e2f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphEnderman.java @@ -53,7 +53,7 @@ public class MorphEnderman extends MorphGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); Manager.getDisguiseManager().undisguise(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java index b8a94970b..5a0e4f4c2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java @@ -55,7 +55,7 @@ public class MorphPig extends MorphGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); Manager.getDisguiseManager().undisguise(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java index 7bed212fc..ae4aa8913 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java @@ -1,6 +1,5 @@ package mineplex.core.gadget.gadgets.morph; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton.SkeletonType; @@ -47,7 +46,7 @@ public class MorphPumpkinKing extends MorphGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); Manager.getDisguiseManager().undisguise(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java index a184823ac..7ea51f3f0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java @@ -65,7 +65,7 @@ public class MorphSlime extends MorphGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); Manager.getDisguiseManager().undisguise(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java index e8b1786ef..3996d5626 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java @@ -66,7 +66,7 @@ public class MorphSnowman extends MorphGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); Manager.getDisguiseManager().undisguise(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java index 9881ffa93..c2bcd1cc7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java @@ -70,7 +70,7 @@ public class MorphTitan extends MorphGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); Manager.getDisguiseManager().undisguise(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java index 5c525b591..44cad0b25 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphUncleSam.java @@ -46,7 +46,7 @@ public class MorphUncleSam extends MorphGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java index 9290bd13b..3480504e3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java @@ -64,7 +64,7 @@ public class MorphVillager extends MorphGadget implements IThrown } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); Manager.getDisguiseManager().undisguise(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java index aa1f7a03f..505551d3b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java @@ -73,7 +73,7 @@ public class MorphWither extends MorphGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { this.RemoveArmor(player); Manager.getDisguiseManager().undisguise(player); @@ -200,7 +200,7 @@ public class MorphWither extends MorphGadget if (disguise == null || !(disguise instanceof DisguiseWither)) { - disableCustom(player); + disableCustom(player, true); activeIterator.remove(); continue; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/OutfitTeam.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/OutfitTeam.java index 8aa3d98ad..087893c88 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/OutfitTeam.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/OutfitTeam.java @@ -77,7 +77,7 @@ public class OutfitTeam extends OutfitGadget } @Override - public void removeArmor(Player player) + public void removeArmor(Player player, boolean message) { if (!_active.remove(player)) return; @@ -96,9 +96,9 @@ public class OutfitTeam extends OutfitGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { - removeArmor(player); + removeArmor(player, message); } @EventHandler(priority=EventPriority.LOWEST) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/ravesuit/OutfitRaveSuit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/ravesuit/OutfitRaveSuit.java index 4140410f4..adfef82bc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/ravesuit/OutfitRaveSuit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/ravesuit/OutfitRaveSuit.java @@ -43,9 +43,9 @@ public class OutfitRaveSuit extends OutfitGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { - removeArmor(player); + removeArmor(player, message); _colorPhase.remove(player.getName()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/spacesuit/OutfitSpaceSuit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/spacesuit/OutfitSpaceSuit.java index d27a3f56c..bac66d1ae 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/spacesuit/OutfitSpaceSuit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/spacesuit/OutfitSpaceSuit.java @@ -32,9 +32,9 @@ public class OutfitSpaceSuit extends OutfitGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { - removeArmor(player); + removeArmor(player, message); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuit.java index c67e5a9c2..974ff360a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuit.java @@ -41,9 +41,9 @@ public class OutfitWindUpSuit extends OutfitGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { - removeArmor(player); + removeArmor(player, message); _colorPhase.remove(player); _percentage.remove(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFairy.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFairy.java index a72364d41..2116e7604 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFairy.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFairy.java @@ -36,7 +36,7 @@ public class ParticleFairy extends ParticleGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { if (_active.remove(player)) UtilPlayer.message(player, F.main("Gadget", "You unsummoned " + F.elem(getName()) + ".")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java index da57bfcb6..1b3751877 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java @@ -61,7 +61,7 @@ public class ParticleKronos extends ParticleGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { if (_active.remove(player)) UtilPlayer.message(player, F.main("Gadget", "You unsummoned " + F.elem(getName()) + ".")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java index b10b946f5..db4464335 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java @@ -46,7 +46,7 @@ public class ParticleHeart extends ParticleGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { if (_active.remove(player)) UtilPlayer.message(player, F.main("Gadget", "You unsummoned " + F.elem(getName()) + ".")); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java index 90645d5bb..20742f4f3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java @@ -146,17 +146,12 @@ public abstract class Gadget extends SalesPackageBase implements Listener UtilPlayer.message(player, F.main("Gadget", "You enabled " + F.elem(getName()) + ".")); } - public void disableCustom(Player player) - { - disableCustom(player, true); - } - public void disableCustom(Player player, boolean message) { if (_active.remove(player) && message) UtilPlayer.message(player, F.main("Gadget", "You disabled " + F.elem(getName()) + ".")); } - + @Override public void sold(Player player, CurrencyType currencyType) { 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 55c249907..6c647876c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java @@ -59,12 +59,13 @@ public abstract class HatGadget extends OutfitGadget player.getInventory().setHelmet(getHelmetItem()); } - public void removeArmor(Player player) + public void removeArmor(Player player, boolean message) { if (!_active.remove(player)) return; - - UtilPlayer.message(player, F.main("Gadget", "You took off " + F.elem(getName()) + ".")); + + if (message) + UtilPlayer.message(player, F.main("Gadget", "You took off " + F.elem(getName()) + ".")); player.getInventory().setHelmet(null); } @@ -96,9 +97,9 @@ public abstract class HatGadget extends OutfitGadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { - removeArmor(player); + removeArmor(player, message); } public HatType getHatType() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java index e6125a64f..657ad67ac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java @@ -56,9 +56,9 @@ public abstract class ItemGadget extends Gadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { - RemoveItem(player); + RemoveItem(player, message); } public HashSet getActive() @@ -113,13 +113,14 @@ public abstract class ItemGadget extends Gadget } } - public void RemoveItem(Player player) + public void RemoveItem(Player player, boolean message) { if (_active.remove(player)) { player.getInventory().setItem(Manager.getActiveItemSlot(), null); - - UtilPlayer.message(player, F.main("Gadget", "You unequipped " + F.elem(getName()) + ".")); + + if (message) + UtilPlayer.message(player, F.main("Gadget", "You unequipped " + F.elem(getName()) + ".")); } } 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 1b0d32d54..72edc0486 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java @@ -68,12 +68,13 @@ public abstract class OutfitGadget extends Gadget ItemStackFactory.Instance.CreateStack(getDisplayMaterial().getId(), getDisplayData(), 1, getName())); } - public void removeArmor(Player player) + public void removeArmor(Player player, boolean message) { if (!_active.remove(player)) return; - - UtilPlayer.message(player, F.main("Gadget", "You took off " + F.elem(getName()) + ".")); + + if (message) + UtilPlayer.message(player, F.main("Gadget", "You took off " + F.elem(getName()) + ".")); if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(null); else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(null); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ParticleGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ParticleGadget.java index aaaeb60d0..06af3908b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ParticleGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ParticleGadget.java @@ -41,7 +41,7 @@ public abstract class ParticleGadget extends Gadget } @Override - public void disableCustom(Player player) + public void disableCustom(Player player, boolean message) { if (_active.remove(player)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index c51a2fea3..5bc78f8a3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -32,7 +32,7 @@ public enum GameDisplay Micro("Micro Battle", Material.LAVA_BUCKET, (byte)0, GameCategory.ARCADE, 24), MilkCow("Milk the Cow", Material.MILK_BUCKET, (byte)0, GameCategory.ARCADE, 27), MineStrike("MineStrike", Material.TNT, (byte)0, GameCategory.CHAMPIONS, 25),// Temp set to CHAMPIONS to fix UI bug - BawkBawkBattles("Bawk Bawk Battles", Material.EGG, (byte)0, GameCategory.EXTRA, 26), + BawkBawkBattles("Bawk Bawk Battles", Material.EGG, (byte)0, GameCategory.CLASSICS, 26), OldMineWare("Old MineWare", Material.PAPER, (byte)0, GameCategory.EXTRA, 26), Paintball("Super Paintball", Material.ENDER_PEARL, (byte)0, GameCategory.ARCADE, 28), Quiver("One in the Quiver", Material.ARROW, (byte)0, GameCategory.ARCADE, 29), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index 43a1d22e8..d3a3c4107 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -227,7 +227,8 @@ public class InventoryManager extends MiniDbClientPlugin event.getInventory().setItem(1, new ItemStack(Material.INK_SACK, level, (byte) 4)); } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + // fixme broken cast +// @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { if (event.getBlock().getType() != Material.ENCHANTMENT_TABLE) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java index 870c756ea..10648f4ed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java @@ -159,7 +159,7 @@ public class PersonalServerManager extends MiniPlugin } } - final ServerGroup serverGroup = new ServerGroup(serverName, serverName, host.getName(), ram, cpu, 1, 0, UtilMath.random.nextInt(250) + 19999, null, true, "arcade.zip", "Arcade.jar", "plugins/Arcade/", minPlayers, maxPlayers, + final ServerGroup serverGroup = new ServerGroup(serverName, serverName, host.getName(), ram, cpu, 1, 0, UtilMath.random.nextInt(250) + 19999, "", true, "arcade.zip", "Arcade.jar", "plugins/Arcade/", minPlayers, maxPlayers, true, false, false, games, "", "", "Player", true, event, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU, "", "", "", ""); getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java index 07b4e54e9..12dbee6b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileManager.java @@ -88,15 +88,6 @@ public class ProjectileManager extends MiniPlugin sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult)); } - public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, - long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, - Sound sound, float soundVolume, float soundPitch, ParticleType particle, UpdateType effectRate, float hitboxMult, double charge) - { - _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, - expireTime, hitPlayer, hitNonPlayerEntity, hitBlock, idle, false, - sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult, charge)); - } - public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, Sound sound, float soundVolume, float soundPitch, ParticleType particle, float pX, float pY, float pZ, float pS, int pC, UpdateType effectRate, float hitboxMult) @@ -142,14 +133,14 @@ public class ProjectileManager extends MiniPlugin } public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, - long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, - Sound sound, float soundVolume, float soundPitch, ParticleType particle, UpdateType effectRate, float hitboxMult, List canHit) + long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, + Sound sound, float soundVolume, float soundPitch, ParticleType particle, UpdateType effectRate, float hitboxMult, List canHit) { _thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback, - expireTime, hitPlayer, hitNonPlayerEntity, hitBlock, idle, false, - sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult, canHit)); + expireTime, hitPlayer, hitNonPlayerEntity, hitBlock, idle, false, + sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult, canHit)); } - + public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback, long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, Sound sound, float soundVolume, float soundPitch, ParticleType particle, float pX, float pY, float pZ, float pS, int pC, UpdateType effectRate, float hitboxMult, List canHit) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java index 16213685f..31aee43b1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java @@ -62,8 +62,6 @@ public class ProjectileUser private UpdateType _effectRate = UpdateType.TICK; private double _hitboxGrow; - - private double _charge; private List _canHit; @@ -106,47 +104,6 @@ public class ProjectileUser _canHit = null; } - public ProjectileUser(ProjectileManager throwInput, Entity thrown, LivingEntity thrower, IThrown callback, - long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, boolean pickup, - Sound sound, float soundVolume, float soundPitch, - Effect effect, int effectData, UpdateType effectRate, - ParticleType particle, float particleX, float particleY, - float particleZ, float particleS, int particleC, double hitboxMult, double charge) - { - Throw = throwInput; - - _thrown = thrown; - _thrower = thrower; - _callback = callback; - - _expireTime = expireTime; - _startTime = System.currentTimeMillis(); - - _hitPlayer = hitPlayer; - _hitNonPlayerEntity = hitNonPlayerEntity; - _hitBlock = hitBlock; - _idle = idle; - _pickup = pickup; - - _sound = sound; - _soundVolume = soundVolume; - _soundPitch = soundPitch; - _particle = particle; - _particleX = particleX; - _particleY = particleY; - _particleZ = particleZ; - _particleS = particleS; - _particleC = particleC; - _effect = effect; - _effectData = effectData; - _effectRate = effectRate; - - _hitboxGrow = hitboxMult; - _canHit = null; - - _charge = charge; - } - public ProjectileUser(ProjectileManager throwInput, Entity thrown, LivingEntity thrower, IThrown callback, long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, boolean pickup, Sound sound, float soundVolume, float soundPitch, @@ -185,7 +142,6 @@ public class ProjectileUser _hitboxGrow = hitboxMult; _canHit = canHit; } - public void effect(UpdateEvent event) { @@ -355,11 +311,6 @@ public class ProjectileUser return false; } - - public double getCharge() - { - return _charge; - } public IThrown getIThrown() { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index a92a99b2e..3e0ac74e7 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -924,6 +924,11 @@ public class ServerManager extends MiniDbClientPlugin implement return _serverNpcShopMap.get("Weekend Brawl"); } + public ShopBase getBawkShop() + { + return _serverNpcShopMap.get("Bawk Bawk Battles"); + } + @Override public String getQuery(int accountId, String uuid, String name) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 2a9b3243a..a176467a8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -41,25 +41,32 @@ public class ServerGameMenu extends ShopPageBase @Override protected void buildPage() { - add(2, Material.QUARTZ_BLOCK, C.cYellowB + "Speed Builders " + C.cGray + "Competitive Building", new String[] + add(1, Material.EGG, C.cYellowB + "Bawk Bawk Battles " + C.cGray + "Challenges", new String[] { (_extraValue ? C.cAquaB : C.cWhiteB) + "NEW GAME", + C.Reset + "", + C.Reset + "Follow Bawk Bawk's instructions", + C.Reset + "Complete different tasks", + C.Reset + "If you lose, chickens will devour you!" + }, "BBB", "Bawk_Bawk_Battles", new SelectBawkButton(this)); + + add(3, Material.QUARTZ_BLOCK, C.cYellowB + "Speed Builders " + C.cGray + "Competitive Building", new String[] + { C.Reset + "", C.Reset + "Memorize Gwen the Guardian's builds", C.Reset + "Then recreate them in a short amount of time.", C.Reset + "The least correct builder is eliminated.", }, "SB", "Speed_Builders", new SelectSBButton(this)); - add(4, Material.BOOK_AND_QUILL, C.cYellowB + "Draw My Thing " + C.cGray + "Pictionary", new String[] + add(5, Material.BOOK_AND_QUILL, C.cYellowB + "Draw My Thing " + C.cGray + "Pictionary", new String[] { - (_extraValue ? C.cAquaB : C.cWhiteB) + "NEW UPDATE", C.Reset + "", C.Reset + "Players take turns at drawing a random", C.Reset + "word. Whoever guesses it within the time", C.Reset + "limit gets some points!", }, "DMT", "Draw_My_Thing", new SelectDMTButton(this)); - add(6, Material.TNT, C.cYellowB + "Dragon Escape " + C.cGray + "Fast Paced Parkour", new String[] + add(7, Material.TNT, C.cYellowB + "Dragon Escape " + C.cGray + "Fast Paced Parkour", new String[] { (_extraValue ? C.cAquaB : C.cWhiteB) + "FEATURED ARCADE GAME", C.Reset + "", @@ -192,7 +199,6 @@ public class ServerGameMenu extends ShopPageBase add(41, Material.BREWING_STAND_ITEM, C.cYellowB + "Monster Maze " + C.cGray + "Snow Sprint", new String[] { - (_extraValue ? C.cAquaB : C.cWhiteB) + "BETA GAME", C.Reset + "", C.Reset + "Run along a maze avoiding", C.Reset + "evil monsters. Get to the", @@ -570,6 +576,11 @@ public class ServerGameMenu extends ShopPageBase { getPlugin().getValentinesShop().attemptShopOpen(player); } + + public void openBawk(Player player) + { + getPlugin().getBawkShop().attemptShopOpen(player); + } /* ADDITIONAL LORES; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBawkButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBawkButton.java new file mode 100644 index 000000000..8e9edf8c0 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBawkButton.java @@ -0,0 +1,23 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectBawkButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectBawkButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.openBawk(player); + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java index 2a87b1c30..7aecaade1 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java @@ -33,7 +33,7 @@ public class Blink extends SkillActive { private HashMap _loc = new HashMap(); private HashMap _blinkTime = new HashMap(); - + public Blink(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels, int energy, int energyMod, @@ -206,9 +206,6 @@ public class Blink extends SkillActive done = true; } - target.setYaw(player.getLocation().getYaw()); - target.setPitch(player.getLocation().getPitch()); - player.teleport(target); player.setFallDistance(0); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java index 128ee2a11..c00d10c69 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java @@ -29,7 +29,6 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.recharge.Recharge; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -214,11 +213,10 @@ public class Evade extends SkillActive { Player player = activeIter.next(); - if (!player.isOnline() || !player.isBlocking() || UtilTime.elapsed(_active.get(player), 1000)) + if (!player.isOnline() || !player.isBlocking() || UtilTime.elapsed(_active.get(player), 750)) { activeIter.remove(); UtilPlayer.message(player, F.main(GetClassType().name(), "You failed to " + F.skill(GetName()) + ".")); - Recharge.Instance.useForce(player, GetName(), 10000l, true); } } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java index 16b032c06..1918c5cf4 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java @@ -14,7 +14,6 @@ import org.bukkit.event.player.PlayerDropItemEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; @@ -29,6 +28,7 @@ import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import net.minecraft.server.v1_8_R3.Material; public class Recall extends Skill { @@ -69,12 +69,6 @@ public class Recall extends Skill event.setCancelled(true); - if (UtilBlock.water(player.getLocation().getBlock())) - { - UtilPlayer.message(player, F.main("Skill", "You cannot use " + F.skill(GetName()) + " in water.")); - return; - } - //Check Allowed SkillTriggerEvent trigger = new SkillTriggerEvent(player, GetName(), GetClassType()); Bukkit.getServer().getPluginManager().callEvent(trigger); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/ViperStrikes.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/ViperStrikes.java index 6aaaba4a2..7cac7e593 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/ViperStrikes.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/ViperStrikes.java @@ -6,14 +6,12 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; import mineplex.core.common.util.UtilGear; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class ViperStrikes extends Skill { @@ -23,8 +21,8 @@ public class ViperStrikes extends Skill SetDesc(new String[] { - "Your attacks give", - "enemies Poison 1", + "Your attacks give enemies", + "Shock, Slow 1 and Poison 1", "for #0#1 seconds." }); } @@ -49,9 +47,10 @@ public class ViperStrikes extends Skill LivingEntity damagee = event.GetDamageeEntity(); if (damagee == null) return; - - Factory.Damage().NewDamageEvent(damagee, damager, null, DamageCause.POISON, 0, false, true, true, damager.getName(), GetName()); - damagee.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 20 * (2 + level), 0)); + + //Confuse + Factory.Condition().Factory().PoisonShock(GetName(), damagee, damager, level, false); + Factory.Condition().Factory().Slow(GetName(), damagee, damager, level, 0, false, false, true, false); //Sound damager.getWorld().playSound(damager.getLocation(), Sound.SPIDER_IDLE, 1f, 2f); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java index 3422b690b..800547f8b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java @@ -9,34 +9,32 @@ import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.entity.Entity; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; 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.UtilEvent; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; +import mineplex.core.updater.UpdateType; +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.UtilServer; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.classcombat.Skill.SkillCharge; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.BlockTossExpireEvent; @@ -92,7 +90,7 @@ public class BlockToss extends SkillCharge implements IThrown @Override public String GetRechargeString() { - return "Recharge: " + "#5.5#-0.5 Seconds"; + return "Recharge: " + "#4#-0.5 Seconds"; } @EventHandler @@ -195,22 +193,7 @@ public class BlockToss extends SkillCharge implements IThrown //Effect player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, block.getMaterial().getId()); } - - @EventHandler - public void Damage(EntityDamageByEntityEvent event) - { - Entity vehicle = event.getEntity().getVehicle(); - - if (_holding.containsKey(vehicle)) - { - Player attacker = (Player) event.getDamager(); - - //Forward Damage - Factory.Damage().NewDamageEvent((Player) vehicle, attacker, Factory.Damage().GetProjectile(event), - event.getCause(), event.getDamage(), true, false, false, null, null, event.isCancelled()); - } - } - + @EventHandler public void Throw(UpdateEvent event) { @@ -241,7 +224,7 @@ public class BlockToss extends SkillCharge implements IThrown } //Throw - if (!cur.isBlocking() || (_charge.containsKey(cur) && _charge.get(cur) >= 1)) + if (!cur.isBlocking()) throwSet.add(cur); //Charged Tick @@ -258,7 +241,7 @@ public class BlockToss extends SkillCharge implements IThrown for (Player cur : throwSet) { Recharge.Instance.recharge(cur, GetName()); - Recharge.Instance.use(cur, GetName(), 5500 - (500 * getLevel(cur)), false, true); + Recharge.Instance.use(cur, GetName(), 4000 - (500 * getLevel(cur)), false, true); FallingBlock block = _holding.remove(cur); float charge = _charge.remove(cur); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/CripplingBlow.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/CripplingBlow.java index 1ae7b8f6e..3e384a64c 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/CripplingBlow.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/CripplingBlow.java @@ -24,7 +24,7 @@ public class CripplingBlow extends Skill { "Your powerful axe attacks give", "targets Slow 2 for 1.5 second,", - "as well as 25% less knockback." + "as well as 50% less knockback." }); } @@ -57,7 +57,7 @@ public class CripplingBlow extends Skill //Damage event.AddMod(damager.getName(), GetName(), 0, true); - event.AddKnockback(GetName(), 0.75); + event.AddKnockback(GetName(), 0.5); //Event UtilServer.getServer().getPluginManager().callEvent(new SkillEvent(damager, GetName(), ClassType.Brute, damagee)); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/DwarfToss.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/DwarfToss.java index 1ce818b5f..915c78b7a 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/DwarfToss.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/DwarfToss.java @@ -73,7 +73,7 @@ public class DwarfToss extends SkillActive { if (_used.contains(player)) return false; - + return true; } @@ -96,13 +96,7 @@ public class DwarfToss extends SkillActive { int level = getLevel(player); if (level == 0) return false; - - if (player.getLocation().getBlock().getTypeId() == 8 || player.getLocation().getBlock().getTypeId() == 9) - { - UtilPlayer.message(player, F.main("Skill", "You cannot use " + F.skill(GetName()) + " in water.")); - return false; - } - + //Check Material if (player.getItemInHand() != null) if (!_itemSet.contains(player.getItemInHand().getType())) @@ -343,9 +337,6 @@ public class DwarfToss extends SkillActive target.leaveVehicle(); final double mult = (1.8) * timeScale; - //Protection - Factory.Condition().Factory().Invulnerable(GetName(), target, target, 1.25, false, false); - //Delay Bukkit.getScheduler().scheduleSyncDelayedTask(Factory.getPlugin(), new Runnable() { diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/FleshHook.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/FleshHook.java index 588571fdc..373caea1f 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/FleshHook.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/FleshHook.java @@ -101,16 +101,16 @@ public class FleshHook extends SkillActiveCharge implements IThrown //Release Charge else if (_charge.containsKey(cur)) { - double charge = _charge.remove(cur); + float charge = _charge.remove(cur); //Action Item item = cur.getWorld().dropItem(cur.getEyeLocation().add(cur.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(131)); UtilAction.velocity(item, cur.getLocation().getDirection(), - 1 + charge, false, 0, 0.2, 20, false); + 1 + charge , false, 0, 0.2, 20, false); Factory.Projectile().AddThrow(item, cur, this, -1, true, true, true, true, - Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, UpdateType.TICK, 0.6f, charge); - + Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, UpdateType.TICK, 0.6f); + //Inform UtilPlayer.message(cur, F.main(GetClassType().name(), "You used " + F.skill(GetName(level)) + ".")); @@ -148,14 +148,14 @@ public class FleshHook extends SkillActiveCharge implements IThrown //Pull UtilAction.velocity(target, UtilAlg.getTrajectory(target.getLocation(), player.getLocation()), - velocity, false, 0, 0.7, 1.2, true); + 1.2 + (0.3 * level), false, 0, 0.7, 1.2, true); //Condition Factory.Condition().Factory().Falling(GetName(), target, player, 10, false, true); //Damage Event Factory.Damage().NewDamageEvent(target, player, null, - DamageCause.CUSTOM, (5 + level) * data.getCharge(), false, true, false, + DamageCause.CUSTOM, 5 + level, false, true, false, player.getName(), GetName()); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Intimidation.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Intimidation.java index 1f5d560b9..cab4d77fa 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Intimidation.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Intimidation.java @@ -21,7 +21,7 @@ public class Intimidation extends Skill SetDesc(new String[] { "You intimidate nearby enemies;", - "Enemies within #4#2 blocks receive Slow 1.", + "Enemies within #3#3 blocks receive Slow 1.", }); } @@ -36,7 +36,7 @@ public class Intimidation extends Skill int level = getLevel(cur); if (level == 0) continue; - HashMap targets = UtilPlayer.getInRadius(cur.getLocation(), 3 + (level * 2)); + HashMap targets = UtilPlayer.getInRadius(cur.getLocation(), 3 + (level * 3)); for (Player other : targets.keySet()) if (!other.equals(cur)) if (Factory.Relation().canHurt(cur, other)) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/AxeThrow.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/AxeThrow.java index 14ae0fcf1..bf2d6aa75 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/AxeThrow.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/AxeThrow.java @@ -52,7 +52,7 @@ public class AxeThrow extends SkillActive implements IThrown SetDesc(new String[] { "Throw your axe with #0.7#0.1 velocity, ", - "dealing #4.5#0.5 damage.", + "dealing #5.5#0.5 damage.", "", "You pull your axe back to you when it", "collides with anything.", @@ -107,7 +107,7 @@ public class AxeThrow extends SkillActive implements IThrown if (level <= 0) return; - double damage = 4.5 + 0.5 * level; + double damage = 5.5 + 0.5 * level; //Damage Event Factory.Damage().NewDamageEvent(target, data.getThrower(), null, diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HiltSmash.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HiltSmash.java index cf9845e03..9e743cea2 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HiltSmash.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HiltSmash.java @@ -46,7 +46,7 @@ public class HiltSmash extends SkillActive SetDesc(new String[] { "Smash the hilt of your sword into", - "your opponent, dealing #1#1 damage", + "your opponent, dealing #2#1 damage", "and Slow 3 for #0.5#0.5 seconds." }); } @@ -153,7 +153,7 @@ public class HiltSmash extends SkillActive //Damage Event Factory.Damage().NewDamageEvent((LivingEntity)ent, player, null, - DamageCause.CUSTOM, 1 + level, false, true, false, + DamageCause.CUSTOM, 2 + level, false, true, false, player.getName(), GetName()); //Sound diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Swordsmanship.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Swordsmanship.java index 5d62eac5f..1e29be118 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Swordsmanship.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Swordsmanship.java @@ -30,7 +30,7 @@ public class Swordsmanship extends Skill { "Prepare a powerful sword attack;", "You gain 1 Charge every #5#-1 seconds.", - "You can store a maximum of #1#1 Charges.", + "You can store a maximum of #0#1 Charges.", "", "When you next attack, your damage is", "increased by the number of your Charges,", @@ -79,7 +79,7 @@ public class Swordsmanship extends Skill if (!Recharge.Instance.use(cur, GetName(), 5000 - (1000 * level), false, false)) continue; - int max = 1 + level; + int max = level; int charge = 1; if (_charges.containsKey(cur)) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java index e27680712..57bf77854 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java @@ -67,7 +67,7 @@ public class Blizzard extends SkillActive @Override public String GetEnergyString() { - return "Energy: #42#-2 per Second"; + return "Energy: #34#-2 per Second"; } @Override @@ -114,7 +114,7 @@ public class Blizzard extends SkillActive } //Energy - if (!Factory.Energy().Use(cur, GetName(), 2.1 - (0.1 * level), true, true)) + if (!Factory.Energy().Use(cur, GetName(), 1.7 - (0.1 * level), true, true)) { _active.remove(cur); continue; diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java index a04b31ebc..2c2c0f118 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java @@ -48,7 +48,7 @@ public class IcePrison extends SkillActive implements IThrown { "Launch an icy orb. When it collides,", "it creates a hollow sphere of ice", - "thats lasts for #3#1 seconds.", + "thats lasts for #3#1.5 seconds.", }); } @@ -171,7 +171,7 @@ public class IcePrison extends SkillActive implements IThrown if (!UtilBlock.airFoliage(freeze)) return; - long time = 3500 + (1000 * level); + long time = 3500 + (1500 * level); int yDiff = freeze.getY() - mid.getY(); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Immolate.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Immolate.java index d0f884988..043333409 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Immolate.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Immolate.java @@ -152,12 +152,6 @@ public class Immolate extends Skill Remove(cur); continue; } - - if (cur.getLocation().getBlock().getType() == Material.WATER || cur.getLocation().getBlock().getType() == Material.STATIONARY_WATER) - { - Remove(cur); - continue; - } //Energy if (!Factory.Energy().Use(cur, GetName(), 0.65 - (level * 0.05), true, true)) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java index 2c07078cb..9ef227c18 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java @@ -53,7 +53,7 @@ public class Inferno extends SkillActive @Override public String GetEnergyString() { - return "Energy: #42#-2 per Second"; + return "Energy: #34#-2 per Second"; } @Override @@ -100,7 +100,7 @@ public class Inferno extends SkillActive } //Energy - if (!Factory.Energy().Use(cur, GetName(), 2.1 - (0.1 * level), true, false)) + if (!Factory.Energy().Use(cur, GetName(), 1.7 - (0.1 * level), true, false)) { _active.remove(cur); continue; @@ -113,7 +113,7 @@ public class Inferno extends SkillActive itemStack.setItemMeta(meta); Item fire = cur.getWorld().dropItem(cur.getEyeLocation().add(cur.getLocation().getDirection()), itemStack); - Factory.Fire().Add(fire, cur, 0.7, 0, 0.3 + (0.1 * level), .25, GetName(), false); + Factory.Fire().Add(fire, cur, 0.7, 0, 0.3 + (0.1 * level), 1, GetName(), false); fire.teleport(cur.getEyeLocation()); double x = 0.07 - (UtilMath.r(14)/100d); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java index 4ad73365d..837fb8ada 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java @@ -42,8 +42,8 @@ public class LifeBonds extends Skill { "Drop Axe/Sword to Toggle.", "", - "Transfers life from yourself to", - "nearby allies with less health.", + "Transfers life from healthy allies", + "to nearby allies with less health.", "", "Transfers #0.5#0.5 health every second.", "Maximum range of #3#3 Blocks from user." @@ -188,6 +188,9 @@ public class LifeBonds extends Skill int level = getLevel(cur); //Bonds + Player highest = null; + double highestHp = 0; + Player lowest = null; double lowestHp = 20; @@ -196,6 +199,12 @@ public class LifeBonds extends Skill if (Factory.Relation().canHurt(cur, other) && !other.equals(cur)) continue; + if (highest == null || other.getHealth() > highestHp) + { + highest = other; + highestHp = other.getHealth(); + } + if (lowest == null || other.getHealth() < lowestHp) { lowest = other; @@ -204,18 +213,18 @@ public class LifeBonds extends Skill } //Nothing to Transfer - if (cur.equals(lowest) || cur.getHealth() - lowestHp < 2) + if (highest == null || lowest == null || highest.equals(lowest) || highestHp - lowestHp < 2) continue; double amount = 0.5 + (0.5 * level); - amount = Math.min((double)(cur.getHealth() - lowestHp) / 2d, amount); + amount = Math.min((double)(highestHp - lowestHp) / 2d, amount); //Steal - UtilPlayer.health(cur, -amount); + UtilPlayer.health(highest, -amount); //Hearts - _hearts.add(new LifeBondsData(cur.getLocation().add(0, 0.8, 0), lowest, amount)); + _hearts.add(new LifeBondsData(highest.getLocation().add(0, 0.8, 0), lowest, amount)); //Effect //highest.getWorld().playEffect(highest.getLocation(), Effect.STEP_SOUND, 18); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/MagmaBlade.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/MagmaBlade.java index e107aca50..4ad21a66b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/MagmaBlade.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/MagmaBlade.java @@ -22,7 +22,7 @@ public class MagmaBlade extends Skill SetDesc(new String[] { "Your sword deals an additional,", - "#0.25#0.25 damage to burning opponents,", + "#0.5#0.5 damage to burning opponents,", "but also extinguishes them.", }); } @@ -54,7 +54,7 @@ public class MagmaBlade extends Skill if (level == 0) return; //Damage - event.AddMod(damager.getName(), GetName(), 0.25 + 0.25 * level, true); + event.AddMod(damager.getName(), GetName(), 0.5 + 0.5 * level, true); //Effect damager.getWorld().playSound(damager.getLocation(), Sound.FIZZ, 0.8f, 0f); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Sharpshooter.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Sharpshooter.java index 4a0f2ede7..77218628b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Sharpshooter.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Sharpshooter.java @@ -18,24 +18,18 @@ import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import org.bukkit.Sound; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.util.BlockIterator; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; public class Sharpshooter extends Skill { - private WeakHashMap _missedCount = new WeakHashMap(); private WeakHashMap _hitCount = new WeakHashMap(); - private HashMap _arrows = new HashMap(); + private HashMap _arrows = new HashMap(); public Sharpshooter(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) { @@ -59,15 +53,9 @@ public class Sharpshooter extends Skill int level = getLevel((Player)event.getEntity()); if (level == 0) return; - - if (!(event.getProjectile() instanceof Arrow)) - { - System.out.println(GetName() + " : " + event.getEntity().getName() + " shot bow but resulting projectile was now Arrow?!?!?!?"); - return; - } - + //Store - _arrows.put((Arrow) event.getProjectile(), (Player)event.getEntity()); + _arrows.put(event.getProjectile(), (Player)event.getEntity()); } @EventHandler(priority = EventPriority.HIGH) @@ -110,46 +98,9 @@ public class Sharpshooter extends Skill projectile.remove(); - _missedCount.remove(player); - Recharge.Instance.useForce(player, GetName() + " Timer", 5000); } - @EventHandler - public void missReset(ProjectileHitEvent event) - { - final Projectile projectile = event.getEntity(); - Factory.runSyncLater(() -> { - if (!projectile.isDead() && _arrows.containsKey(projectile)) - { - Player shooter = (Player) projectile.getShooter(); - - if (!_hitCount.containsKey(shooter)) - { - return; - } - - if (!_missedCount.containsKey(shooter)) - { - _missedCount.put(shooter, Integer.valueOf(1)); - } - else - { - _missedCount.put(shooter, Integer.valueOf(_missedCount.get(shooter).intValue() + 1)); - - // Reset - if (_missedCount.get(shooter).intValue() >= 2) - { - _hitCount.remove(shooter); - _missedCount.remove(shooter); - UtilPlayer.message(shooter, F.main(GetClassType().name(), GetName() + " : " + F.elem("Damage Bonus Reset"))); - shooter.playSound(shooter.getLocation(), Sound.NOTE_PLING, 1f, 0.75f); - } - } - } - }, 3l); - } - @EventHandler public void resetViaTime(UpdateEvent event) { @@ -197,6 +148,5 @@ public class Sharpshooter extends Skill public void Reset(Player player) { _hitCount.remove(player); - _missedCount.remove(player); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java index 310146f5a..db7e4e34c 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java @@ -1,26 +1,28 @@ package mineplex.minecraft.game.classcombat.Skill.Ranger; import java.util.HashMap; -import java.util.Iterator; -import java.util.Map.Entry; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; +import org.bukkit.event.player.PlayerMoveEvent; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilTime; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class VitalitySpores extends Skill { - private HashMap _lastDamage = new HashMap<>(); + private HashMap _lastMove = new HashMap(); public VitalitySpores(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) { @@ -28,52 +30,47 @@ public class VitalitySpores extends Skill SetDesc(new String[] { - "After getting hit, if no damage is taken", - "for 10 Seconds then you will receive", - "Regeneration #2#0 for #5#1 Seconds", + "While standing still, forest spores", + "heal you for #0#0.5 health per 2 seconds." }); } @EventHandler - public void damage(CustomDamageEvent event) + public void playerMove(PlayerMoveEvent event) { - if (doesUserHaveSkill(event.GetDamageePlayer())) - { - if (event.GetDamageePlayer().hasPotionEffect(PotionEffectType.REGENERATION)) - { - event.GetDamageePlayer().removePotionEffect(PotionEffectType.REGENERATION); - } - else - { - _lastDamage.put(event.GetDamageePlayer(), Long.valueOf(System.currentTimeMillis())); - } - } + if (doesUserHaveSkill(event.getPlayer()) && UtilMath.offset(event.getFrom(), event.getTo()) > 0) + _lastMove.put(event.getPlayer(), System.currentTimeMillis()); } @EventHandler public void update(UpdateEvent event) { if (event.getType() != UpdateType.TICK) - { return; - } - - Iterator> iterator = _lastDamage.entrySet().iterator(); - while (iterator.hasNext()) - { - Entry entry = iterator.next(); - - if (UtilTime.elapsed(entry.getValue().longValue(), 10000)) + + for (Player cur : GetUsers()) + { + int level = getLevel(cur); + if (level == 0) continue; + + if (!_lastMove.containsKey(cur)) + continue; + + if (UtilTime.elapsed(_lastMove.get(cur), 2000)) { - iterator.remove(); - entry.getKey().addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, (20 * (5 + getLevel(entry.getKey()))), 1)); - } + UtilPlayer.health(cur, 0.5 * level); + + UtilParticle.PlayParticle(ParticleType.HEART, cur.getEyeLocation().add(UtilAlg.getBehind(cur.getLocation().getDirection().multiply(0.5))), 0, 0.2f, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); + + _lastMove.put(cur, System.currentTimeMillis()); + } } } @Override public void Reset(Player player) { - _lastDamage.remove(player); + _lastMove.remove(player); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java index 195ff7a27..51e412beb 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsPounce.java @@ -45,7 +45,7 @@ public class WolfsPounce extends SkillChargeSword "Taking damage cancels charge.", "", "Colliding with another player", - "mid-air deals up to #2#1 damage", + "mid-air deals up to #4#1 damage", "and Slow 2 for 3 seconds." }); @@ -128,7 +128,7 @@ public class WolfsPounce extends SkillChargeSword if (_chargeStore.containsKey(damager)) charge = _chargeStore.remove(damager); - int damage = (int)((2 + getLevel(damager)) * charge); + int damage = (int)((4 + getLevel(damager)) * charge); //Damage Event Factory.Damage().NewDamageEvent(damagee, damager, null, diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java index 8bc9f565b..7fd52db63 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/SkillFactory.java @@ -221,6 +221,10 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory AddSkill(new Fitness(this, "Mana Pool", ClassType.Mage, SkillType.GlobalPassive, 1, 3)); AddSkill(new Recharge(this, "Mana Regeneration", ClassType.Mage, SkillType.GlobalPassive, 1, 3)); + AddSkill(new Fitness(this, "Fitness", ClassType.Assassin, SkillType.GlobalPassive, 1, 3)); + AddSkill(new Recharge(this, "Rest", ClassType.Assassin, SkillType.GlobalPassive, 1, 3)); + + //AddSkill(new Stamina(this, "Stamina", ClassType.Global, SkillType.GlobalPassive, 1, 1)); //AddSkill(new Swim(this, "Swim", ClassType.Global, SkillType.GlobalPassive, 1, 1)); } @@ -231,9 +235,9 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory //Sword AddSkill(new Evade(this, "Evade", ClassType.Assassin, SkillType.Sword, - 2, 1, + 1, 4, 0, 0, - 2500, -500, true, + 6500, -500, true, new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD}, new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK})); @@ -333,7 +337,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory AddSkill(new Takedown(this, "Takedown", ClassType.Brute, SkillType.Axe, 1, 5, 0, 0, - 17000, -1000, true, + 21000, -1000, true, new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE}, new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK})); @@ -370,7 +374,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory AddSkill(new Riposte(this, "Riposte", ClassType.Knight, SkillType.Sword, 1, 5, 0, 0, - 15000, -1000, false, + 11000, -1000, false, new Material[] {Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD}, new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK})); @@ -407,7 +411,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory AddSkill(new AxeThrow(this, "Roped Axe Throw", ClassType.Knight, SkillType.Axe, 1, 5, 0, 0, - 4300, -300, true, + 3300, -300, true, new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE}, new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK})); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/Condition.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/Condition.java index 8109e3ef2..b84ac5cd0 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/Condition.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/Condition.java @@ -72,9 +72,7 @@ public class Condition protected boolean _add = false; protected boolean _live = false; - - protected boolean _cancelPotion; - + protected boolean _showIndicator = true; public Condition(ConditionManager manager, String reason, LivingEntity ent, LivingEntity source, @@ -103,35 +101,6 @@ public class Condition //Live if NOT Additive _live = !add; } - - public Condition(ConditionManager manager, String reason, LivingEntity ent, LivingEntity source, - ConditionType type, int mult, int ticks, boolean add, Material visualType, byte visualData, boolean showIndicator, boolean ambient, boolean cancelPotion) - { - Manager = manager; - _time = System.currentTimeMillis(); - - _reason = reason; - - _ent = ent; - _source = source; - - _type = type; - _mult = mult; - _ticks = ticks; - _ticksTotal = ticks; - _ambient = ambient; - - _indicatorType = visualType; - _indicatorData = visualData; - _showIndicator = showIndicator; - - _cancelPotion = cancelPotion; - - _add = add; - - //Live if NOT Additive - _live = !add; - } public boolean Tick() { @@ -155,11 +124,6 @@ public class Condition public void Add() { - if (_cancelPotion) - { - return; - } - try { PotionEffectType type = PotionEffectType.getByName(_type.toString()); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionFactory.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionFactory.java index fcfa571e1..e6fac9836 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionFactory.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/condition/ConditionFactory.java @@ -239,16 +239,10 @@ public class ConditionFactory public Condition Poison(String reason, LivingEntity ent, LivingEntity source, double duration, int mult, boolean extend, boolean showIndicator, boolean ambient) - { - return Poison(reason, ent, source, duration, mult, extend, showIndicator, ambient, false); - } - - public Condition Poison(String reason, LivingEntity ent, LivingEntity source, - double duration, int mult, boolean extend, boolean showIndicator, boolean ambient, boolean cancelPotion) { return Manager.AddCondition(new Condition(Manager, reason, ent, source, ConditionType.POISON, mult, (int)(20 * duration), extend, - Material.SLIME_BALL, (byte)14, showIndicator, ambient, cancelPotion)); + Material.SLIME_BALL, (byte)14, showIndicator, ambient)); } public Condition PoisonShock(String reason, LivingEntity ent, LivingEntity source, diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java index da2a1d74e..ba3295037 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java @@ -24,7 +24,7 @@ public class ServerGroup private int _requiredTotalServers; private int _requiredJoinableServers; - private String _uptimes; + private String _uptimes = ""; private boolean _arcadeGroup; private String _worldZip; @@ -80,7 +80,7 @@ public class ServerGroup _requiredTotalServers = Integer.valueOf(data.get("totalServers")); _requiredJoinableServers = Integer.valueOf(data.get("joinableServers")); _portSection = Integer.valueOf(data.get("portSection")); - _uptimes = data.get("uptimes"); + _uptimes = data.containsKey("uptimes") ? data.get("uptimes") : ""; _arcadeGroup = Boolean.valueOf(data.get("arcadeGroup")); _worldZip = data.get("worldZip"); _plugin = data.get("plugin"); 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 c47833359..7bffad2da 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -73,7 +73,6 @@ import nautilus.game.arcade.command.GameCommand; import nautilus.game.arcade.command.KitUnlockCommand; import nautilus.game.arcade.command.RequiredRankCommand; import nautilus.game.arcade.command.WriteCommand; -import nautilus.game.arcade.command.*; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; @@ -91,7 +90,6 @@ import org.bukkit.*; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.OfflinePlayer; -import org.bukkit.block.Chest; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Entity; @@ -147,7 +145,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation // Managers private GameCreationManager _gameCreationManager; - private GameGemManager _gameGemManager; + private GameRewardManager _gameRewardManager; private GameManager _gameManager; private GameLobbyManager _gameLobbyManager; private GamePlayerManager _gamePlayerManager; @@ -279,7 +277,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation // Managers _gameChatManager = new GameChatManager(this); _gameCreationManager = new GameCreationManager(this); - _gameGemManager = new GameGemManager(this); + _gameRewardManager = new GameRewardManager(this); _gameManager = new GameManager(this); _gameLobbyManager = new GameLobbyManager(this, packetHandler); _gameHostManager = new GameHostManager(this); @@ -510,9 +508,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _gameManager; } - public GameGemManager GetGameGemManager() + public GameRewardManager GetGameGemManager() { - return _gameGemManager; + return _gameRewardManager; } public GamePlayerManager GetGamePlayerManager() 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 e4f76a2f7..76a31e27e 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 @@ -2,12 +2,10 @@ package nautilus.game.arcade.game; import com.google.common.collect.Lists; import com.mojang.authlib.GameProfile; - import mineplex.core.common.util.*; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.elo.EloPlayer; import mineplex.core.elo.EloTeam; -import mineplex.core.gadget.types.GadgetType; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketInfo; @@ -35,7 +33,6 @@ import nautilus.game.arcade.world.WorldData; import net.minecraft.server.v1_8_R3.EntityItem; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import net.minecraft.server.v1_8_R3.WorldServer; - import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -204,6 +201,7 @@ public abstract class Game implements Listener public boolean WorldLeavesDecay = false; public boolean WorldSoilTrample = false; public boolean WorldBoneMeal = false; + public boolean WorldChunkUnload = false; public int HungerSet = -1; public int HealthSet = -1; @@ -423,13 +421,14 @@ public abstract class Game implements Listener System.out.println("Loading " + GetName() + "..."); } - public void registerModule(Module module) + public T registerModule(T module) { if (!_modules.containsKey(module.getClass())) { - module.initialize(this); _modules.put(module.getClass(), module); UtilServer.RegisterEvents(module); + module.initialize(this); + return module; } else { @@ -437,6 +436,16 @@ public abstract class Game implements Listener } } + public void unregisterModule(Module module) + { + if (_modules.containsKey(module.getClass()) && _modules.get(module.getClass()) == module) + { + _modules.remove(module.getClass()); + module.cleanup(); + HandlerList.unregisterAll(module); + } + } + public void setKits(Kit[] kits) { _kits = kits; @@ -1640,18 +1649,6 @@ public abstract class Game implements Listener // End SetState(GameState.End); } - - @EventHandler - public void disableParticles(GameStateChangeEvent event) - { - if (event.GetState() == GameState.Prepare && Manager.getCosmeticManager().getGadgetManager().hideParticles()) - { - for (Player player : GetPlayers(false)) - { - getArcadeManager().getCosmeticManager().getGadgetManager().removeGadgetType(player, GadgetType.PARTICLE); - } - } - } @EventHandler public void onGameStart(GameStateChangeEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java index 48ae4e9de..1f55a9039 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java @@ -1,33 +1,38 @@ package nautilus.game.arcade.game; -import mineplex.core.common.util.*; -import mineplex.core.common.util.UtilTime.*; -import mineplex.core.updater.*; -import mineplex.core.updater.event.*; -import nautilus.game.arcade.*; -import nautilus.game.arcade.events.*; -import nautilus.game.arcade.game.GameTeam.*; -import nautilus.game.arcade.kit.*; -import nautilus.game.arcade.stats.TeamDeathsStatTracker; -import nautilus.game.arcade.stats.TeamKillsStatTracker; +import mineplex.core.common.util.C; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.PlayerStateChangeEvent; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.kit.Kit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +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.Bukkit; -import org.bukkit.entity.*; -import org.bukkit.event.*; -import org.bukkit.event.player.*; - -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; public abstract class TeamGame extends Game { + public long RejoinTime = 120000; + protected ArrayList _places = new ArrayList(); - private NautHashMap _rejoinTime = new NautHashMap(); - protected NautHashMap RejoinTeam = new NautHashMap(); - protected NautHashMap RejoinKit = new NautHashMap(); - protected NautHashMap RejoinHealth = new NautHashMap(); - - protected long RejoinTime = 120000; + public NautHashMap RejoinTimes = new NautHashMap(); + public NautHashMap RejoinTeam = new NautHashMap(); + public NautHashMap RejoinKit = new NautHashMap(); + public NautHashMap RejoinHealth = new NautHashMap(); public TeamGame(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc) { @@ -54,7 +59,7 @@ public abstract class TeamGame extends Game return _places; } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOW) public void PlayerQuit(PlayerQuitEvent event) { if (!InProgress()) @@ -79,7 +84,7 @@ public abstract class TeamGame extends Game if (!QuitOut) { //Store - _rejoinTime.put(player.getName(), System.currentTimeMillis()); + RejoinTimes.put(player.getName(), System.currentTimeMillis()); RejoinTeam.put(player.getName(), team); if (GetKit(player) != null) @@ -102,7 +107,7 @@ public abstract class TeamGame extends Game //Rejoined GameTeam team = RejoinTeam.remove(event.getPlayer().getName()); - if (team != null && _rejoinTime.remove(event.getPlayer().getName()) != null) + if (team != null && RejoinTimes.remove(event.getPlayer().getName()) != null) { team.AddPlayer(event.getPlayer(), true); Announce(team.GetColor() + C.Bold + event.getPlayer().getName() + " has reconnected!", false); @@ -126,8 +131,6 @@ public abstract class TeamGame extends Game // } // } // }, 20); - - return; } } @@ -143,7 +146,21 @@ public abstract class TeamGame extends Game if (RejoinHealth.containsKey(player.getName())) { double health = RejoinHealth.remove(player.getName()); - player.setHealth(health); + if (health > 0) + { + getArcadeManager().runSyncLater(() -> + { + player.setHealth(health); + }, 1L); + } + } + + if (GetLocationStore().containsKey(player.getName())) + { + getArcadeManager().runSyncLater(() -> + { + player.teleport(GetLocationStore().remove(player.getName())); + }, 1L); } } @@ -153,13 +170,13 @@ public abstract class TeamGame extends Game if (event.getType() != UpdateType.SEC || QuitOut) return; - Iterator rejoinIterator = _rejoinTime.keySet().iterator(); + Iterator rejoinIterator = RejoinTimes.keySet().iterator(); while (rejoinIterator.hasNext()) { String name = rejoinIterator.next(); - if (!UtilTime.elapsed(_rejoinTime.get(name), RejoinTime)) + if (!UtilTime.elapsed(RejoinTimes.get(name), RejoinTime)) continue; rejoinIterator.remove(); @@ -187,7 +204,7 @@ public abstract class TeamGame extends Game } else { - _rejoinTime.put(toks[1], System.currentTimeMillis()); + RejoinTimes.put(toks[1], System.currentTimeMillis()); event.getPlayer().sendMessage("Allowed " + toks[1] + " to rejoin!"); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java index 32855df7d..fbe9a5428 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java @@ -1,7 +1,9 @@ package nautilus.game.arcade.game.games.champions; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; @@ -26,6 +28,7 @@ import nautilus.game.arcade.stats.SpecialWinStatTracker; import nautilus.game.arcade.stats.TheLongestShotStatTracker; import org.bukkit.Location; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java index 52763c8a3..f8583deec 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java @@ -16,6 +16,7 @@ import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.common.Domination; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.ElectrocutionStatTracker; import nautilus.game.arcade.stats.KillReasonStatTracker; import nautilus.game.arcade.stats.SeismicSlamStatTracker; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java index 8baa4a01c..3f6441659 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java @@ -16,6 +16,7 @@ import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.common.TeamDeathmatch; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.ElectrocutionStatTracker; import nautilus.game.arcade.stats.KillAllOpposingStatTracker; import nautilus.game.arcade.stats.KillReasonStatTracker; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java index c21d4e824..55535e846 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java @@ -4,15 +4,6 @@ import mineplex.core.common.util.*; 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.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketInfo; @@ -320,14 +311,13 @@ public class HideSeek extends TeamGame { if (event.GetState() == GameState.Prepare) { - System.out.println("prep"); this.getArcadeManager().getPacketHandler().addPacketHandler(_blockDisguise, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutEntityDestroy.class); this.getArcadeManager().getPacketHandler().addPacketHandler(_useEntity, true, PacketPlayInUseEntity.class); } else if (event.GetState() == GameState.Dead) { - this.getArcadeManager().getPacketHandler().removePacketHandler(_blockDisguise); - this.getArcadeManager().getPacketHandler().removePacketHandler(_useEntity); + this.getArcadeManager().getPacketHandler().removePacketHandler(_blockDisguise); + this.getArcadeManager().getPacketHandler().removePacketHandler(_useEntity); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/GunModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/GunModule.java index 3e391c0d3..e4dbe64ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/GunModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/GunModule.java @@ -136,6 +136,8 @@ public class GunModule implements Listener public boolean CustomHitbox = true; public boolean BulletAlternate = false; + public boolean EnableNormalArmor = false; + public boolean BlockRegeneration = true; public boolean EnablePickup = true; public boolean EnableDrop = true; public boolean EnableCleaning = true; @@ -1021,6 +1023,29 @@ public class GunModule implements Listener { UtilAction.zeroVelocity(event.GetDamageeEntity()); } + + if (EnableNormalArmor) + { + + double armomrDamage = 0; + + for (ItemStack item : event.GetDamageePlayer().getInventory().getArmorContents()) + { + if (item == null) + continue; + + if (item.getType().toString().contains("DIAMOND")) armomrDamage -= 1; + if (item.getType().toString().contains("GOLD")) armomrDamage -= 0.5; + if (item.getType().toString().contains("IRON")) armomrDamage -= 0.75; + if (item.getType().toString().contains("LEATHER")) armomrDamage -= 0.25; + if (item.getType().toString().contains("CHAIN")) armomrDamage -= 0.5; + } + + if (event.GetDamage() - armomrDamage <= 0) + armomrDamage = -(event.GetDamage() - 1); + + event.AddMod(event.GetDamageePlayer().getName(), "Armor", armomrDamage, false); + } event.SetKnockback(false); event.SetIgnoreRate(true); @@ -1293,6 +1318,9 @@ public class GunModule implements Listener @EventHandler public void healthCancel(EntityRegainHealthEvent event) { + if (!BlockRegeneration) + return; + if (event.getRegainReason() == RegainReason.SATIATED) event.setCancelled(true); } @@ -1379,12 +1407,19 @@ public class GunModule implements Listener if (event.getType() != UpdateType.TICK) return; - for (Player player : _host.GetPlayers(true)) + for (Player player : UtilServer.getPlayers()) { - if (UtilGear.isMat(player.getItemInHand(), Material.IRON_AXE) || UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD)) - Manager.GetCondition().Factory().Speed("Knife", player, player, 1.9, 0, false, false, false); + if (_host.IsAlive(player)) + { + if (UtilGear.isMat(player.getItemInHand(), Material.IRON_AXE) || UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD)) + player.setWalkSpeed(0.2F); + else + player.setWalkSpeed(0.1F); + } else - Manager.GetCondition().EndCondition(player, ConditionType.SPEED, null); + { + player.setWalkSpeed(0.1F); + } } } @@ -1661,6 +1696,10 @@ public class GunModule implements Listener @EventHandler public void debug(PlayerCommandPreprocessEvent event) { + if (!event.getPlayer().isOp()) + { + return; + } if (event.getMessage().contains("recoil")) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java index fb42cbfdb..862ead445 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/Minestrike.java @@ -1344,4 +1344,4 @@ public class Minestrike extends TeamGame { return _gunModule; } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java index e8df7a9f0..87f40aa8d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java @@ -78,11 +78,12 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeSettings; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeAnvilDance; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeArrowRampage; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeBlockLobbers; +import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeBouncingBlock; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeBuildRace; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeChickenShooting; +import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeColorChange; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeDeadlyTnt; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeDiamondHunt; -import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeDogsVersusCats; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeEggSmash; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeFallingBlocks; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeFastFood; @@ -100,7 +101,6 @@ import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeReverseT import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeRushPush; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeSmashOff; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeTreasureDigger; -import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeVolleyPig; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeWaterHorror; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeWaveCrush; import nautilus.game.arcade.game.games.mineware.effect.ChickenAttack; @@ -108,6 +108,7 @@ import nautilus.game.arcade.game.games.mineware.effect.DeathEffect; import nautilus.game.arcade.game.games.mineware.effect.DeathEffectData; import nautilus.game.arcade.game.games.mineware.events.ChallengeEndEvent; import nautilus.game.arcade.game.games.mineware.kit.KitBawksFood; +import nautilus.game.arcade.game.games.mineware.tracker.BouncingShadowTracker; import nautilus.game.arcade.game.games.mineware.tracker.DragonKingTracker; import nautilus.game.arcade.game.games.mineware.tracker.EliteArcherTracker; import nautilus.game.arcade.game.games.mineware.tracker.MilkManTracker; @@ -182,7 +183,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown private static final float SPECTATOR_KNOCKBACK_SOUND_VOLUME = 2.0F; private static final float SPECTATOR_KNOCKBACK_SOUND_PITCH = 0.5F; - private static final int MIN_PLAYERS_BLOCK_ATTEMPT = 1; private static final int GENERIC_SCOREBOARD_PLAYER_COUNT = 15; private static final int LOST_ONE_LIFE = MAX_LIVES - 1; @@ -254,6 +254,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown populateChallenges(); registerStatTrackers( + new BouncingShadowTracker(this), new DragonKingTracker(this), new EliteArcherTracker(this), new MilkManTracker(this), @@ -271,11 +272,12 @@ public class BawkBawkBattles extends TeamGame implements IThrown new ChallengeAnvilDance(this), new ChallengeArrowRampage(this), new ChallengeBlockLobbers(this), + new ChallengeBouncingBlock(this), new ChallengeBuildRace(this), + new ChallengeColorChange(this), new ChallengeChickenShooting(this), new ChallengeDeadlyTnt(this), new ChallengeDiamondHunt(this), - new ChallengeDogsVersusCats(this), new ChallengeEggSmash(this), new ChallengeFallingBlocks(this), new ChallengeFastFood(this), @@ -294,8 +296,18 @@ public class BawkBawkBattles extends TeamGame implements IThrown new ChallengeRushPush(this), new ChallengeSmashOff(this), new ChallengeTreasureDigger(this), - new ChallengeVolleyPig(this), new ChallengeWaveCrush(this)); + + /* + * Removed: + * + * Cloud Fall + * Dogs Vs Cats + * Fishing Day + * Navigation Maze + * Volley Pig + * Zombie Infection + */ } @Override @@ -386,7 +398,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown } } - System.out.println("Found matching challenge: " + instance.getName()); return instance; } @@ -688,7 +699,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown private void showDescriptionText() { List messages = Lists.newArrayList(_challenge.getDescription()); - messages.add(0, C.cGray + "Bawk Bawk says..."); + messages.add(0, C.cGray + "Bawk Bawk commands..."); new BukkitRunnable() { @@ -1195,21 +1206,21 @@ public class BawkBawkBattles extends TeamGame implements IThrown _winners.remove(player); } - @EventHandler - public void blockStartAttempt(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - // If there is only 1 player and the game starts, do not teleport him to the map. - - if (GetState() == GameState.Recruit && GetCountdown() >= 0 && GetPlayers(false).size() <= MIN_PLAYERS_BLOCK_ATTEMPT) - { - UtilServer.broadcast(F.main("Game", C.cRed + "This game requires at least 2 players to start.")); - SetCountdown(-1); - Manager.GetLobby().DisplayWaiting(); - } - } + // @EventHandler + // public void blockStartAttempt(UpdateEvent event) + // { + // if (event.getType() != UpdateType.TICK) + // return; + // + // // If there is only 1 player and the game starts, do not teleport him to the map. + // + // if (GetState() == GameState.Recruit && GetCountdown() >= 0 && GetPlayers(false).size() <= MIN_PLAYERS_BLOCK_ATTEMPT) + // { + // UtilServer.broadcast(F.main("Game", C.cRed + "This game requires at least 2 players to start.")); + // SetCountdown(-1); + // Manager.GetLobby().DisplayWaiting(); + // } + // } /* * Miscellaneous @@ -1475,6 +1486,74 @@ public class BawkBawkBattles extends TeamGame implements IThrown return ""; } + // @EventHandler + // public void debugCommands(PlayerCommandPreprocessEvent event) + // { + // Player player = event.getPlayer(); + // String message = event.getMessage(); + // + // if (Manager.GetClients().hasRank(player, Rank.SNR_MODERATOR)) + // { + // if (message.startsWith("/restrict")) + // { + // String[] pieces = message.split(" "); + // + // if (pieces.length > 1) + // { + // String challenge = F.combine(pieces, 1, null, false).trim(); + // + // if (_list.restrict(challenge)) + // { + // UtilPlayer.message(player, F.main("Game", "Restricted to " + F.elem(challenge) + " challenge.")); + // } + // else + // { + // UtilPlayer.message(player, F.main("Game", "Could not find any challenge by that name.")); + // } + // } + // else + // { + // UtilPlayer.message(player, F.main("Game", "All challenge restrictions were cleared.")); + // _list.unrestrict(); + // } + // + // event.setCancelled(true); + // } + // else if (message.startsWith("/skip")) + // { + // if (IsLive()) + // { + // endCurrentChallenge(); + // + // Announce(C.cAqua + C.Bold + player.getName() + " skipped this challenge."); + // } + // else + // { + // UtilPlayer.message(player, F.main("Game", "You cannot skip a challenge if the game is not started.")); + // } + // + // event.setCancelled(true); + // } + // else if (message.startsWith("/lose")) + // { + // if (IsLive() && _challenge != null && IsAlive(player)) + // { + // setLives(player, 0); + // _challenge.getData().addLostPlayer(player); + // _deathEffect.playDeath(player, player.getLocation()); + // GetScoreboard().ResetScore(player.getName()); + // _chickenAttack.start(player); + // } + // else + // { + // UtilPlayer.message(player, F.main("Game", "You cannot lose at this time.")); + // } + // + // event.setCancelled(true); + // } + // } + // } + /* * Helper methods */ diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/ChallengeList.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/ChallengeList.java index 352d5fc33..4a394b405 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/ChallengeList.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/ChallengeList.java @@ -57,7 +57,6 @@ public class ChallengeList { if (challenge.getName().contains(name)) { - System.out.println("Restricted: " + challenge.getName()); _restricted = challenge; return true; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/ChallengeSettings.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/ChallengeSettings.java index 419e2e6e7..52a4b4eb4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/ChallengeSettings.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/ChallengeSettings.java @@ -8,7 +8,7 @@ import org.bukkit.Location; public class ChallengeSettings { private Challenge _challenge; - private int _minPlayers = 2; + private int _minPlayers = 1; private int _maxPlayers = 250; private int _maxCompletedCount; private long _startTime; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/other/ChallengeSeperateRooms.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/other/ChallengeSeperateRooms.java deleted file mode 100644 index f7f12a675..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/other/ChallengeSeperateRooms.java +++ /dev/null @@ -1,158 +0,0 @@ -package nautilus.game.arcade.game.games.mineware.challenge.other; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map.Entry; - -import org.bukkit.Location; -import org.bukkit.entity.Player; - -import mineplex.core.common.util.UtilPlayer; -import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; -import nautilus.game.arcade.game.games.mineware.challenge.Challenge; -import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType; - -/** - * Not used. - * @deprecated - */ -public abstract class ChallengeSeperateRooms extends Challenge -{ - private HashMap _borders = new HashMap(); - private HashMap> _spawns = new HashMap>(); - private HashMap _rooms = new HashMap(); - private double _borderX, _borderZ; - - public ChallengeSeperateRooms(BawkBawkBattles host, ChallengeType challengeType, String challengeName) - { - super(host, challengeType, challengeName); - } - - public Location getRoom(Player player) - { - System.out.print("2. " + player.getName()); - return _rooms.get(player.getName()).clone(); - } - - public void assignRooms() - { - for (Player player : getPlayersAlive()) - { - for (Entry> entry : _spawns.entrySet()) - { - if (entry.getKey().distance(player.getLocation()) < 1) - { - System.out.print("1. " + player.getName()); - _rooms.put(player.getName(), entry.getValue().getValue()); - _borders.put(player.getName(), entry.getValue().getKey()); - break; - } - } - } - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public final void generateRoom() - { - int size = getPlayersAlive().size(); - - int x = 1; - int z = 1; - - while (size > x * z) - { - if (x > z) - { - z++; - } - else - { - x++; - } - } - - _borderX = (x * getBorderX()) + (x * getDividersX()); - _borderZ = (z * getBorderZ()) + (z * getDividersZ()); - _borderX /= 2; - _borderZ /= 2; - _borderX = Math.ceil(_borderX); - _borderZ = Math.ceil(_borderZ); - - int players = 0; - - for (int x1 = 0; x1 < x; x1++) - { - for (int z1 = 0; z1 < z; z1++) - { - if (++players > size) - continue; - - double lX = (x1 * getBorderX()) + (x1 * getDividersX()); - double lZ = (z1 * getBorderZ()) + (z1 * getDividersZ()); - lX -= _borderX; - lZ -= _borderZ; - - Location loc = getCenter().clone().add(lX, 0, lZ); - - generateRoom(loc.clone()); - - _spawns.put(getSpawn(loc.clone()), new HashMap.SimpleEntry(new Integer[] - { - loc.getBlockX(), loc.getBlockX() + getBorderX(), - - loc.getBlockY(), loc.getBlockY() + getBorderY(), - - loc.getBlockZ(), loc.getBlockZ() + getBorderZ() - }, loc.clone())); - } - } - } - - @Override - public void start() - { - super.start(); - - setBorder((int) -Math.ceil(_borderX), (int) Math.ceil(_borderX), 0, 256, (int) -Math.ceil(_borderZ), - (int) Math.ceil(_borderZ)); - } - - public abstract void generateRoom(Location loc); - - public abstract int getBorderX(); - - public abstract int getBorderY(); - - public abstract int getBorderZ(); - - public abstract int getDividersX(); - - public abstract int getDividersZ(); - - public Location getSpawn(Location roomLocation) - { - return roomLocation.clone().add((getBorderX() + 1) / 2D, 1.1, (getBorderZ() + 1) / 2D); - } - - @Override - public ArrayList createSpawns() - { - return new ArrayList(_spawns.keySet()); - } - - public boolean isInsideMap(Player player) - { - Location loc = player.getLocation(); - - if (!_borders.containsKey(player.getName()) || UtilPlayer.isSpectator(player)) - { - return super.isInsideMap(player); - } - - Integer[] borders = _borders.get(player.getName()); - - return !(loc.getX() >= borders[1] + 1 || loc.getX() <= borders[0] || loc.getZ() >= borders[5] + 1 - || loc.getZ() <= borders[4] || loc.getY() >= borders[3] + 1 || loc.getY() <= borders[2]); - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeBouncingBlock.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeBouncingBlock.java index e126d141b..dbe302bbc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeBouncingBlock.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeBouncingBlock.java @@ -55,7 +55,7 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker private static final float SCORE_SOUND_PITCH = 0.2F; private static final int SCORE_BLOCK_HEIGHT = 6; private static final int SCORE_BLOCK_HEIGHT_ADD = 5; - private static final int SCORE_BLOCK_HEIGHT_MAX = SCORE_BLOCK_HEIGHT + SCORE_BLOCK_HEIGHT_ADD; + private static final int SCORE_BLOCK_DATA_RANGE = 16; private static final int SCORE_BLOCK_SPAWN_SHIFT = 2; private static final int SCORE_BLOCK_BOUND_MULTIPLY = 2; private static final double SCORE_FIREWORK_LOCATION_ADD = 0.5; @@ -177,7 +177,7 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker if (event.getType() != UpdateType.TICK) return; - for (Player player : getPlayersIn(true)) + for (Player player : getPlayersIn(false)) { UtilTextBottom.display(C.Bold + "Score: " + C.Reset + C.cYellow + C.Bold + _score.get(player), player); } @@ -230,7 +230,7 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker increment(player, 1); player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, SCORE_SOUND_VOLUME, SCORE_SOUND_PITCH); resetBlock(block); - spawnRandomWool(); + spawnRandomWool(true); } private void checkCompleted(Player player) @@ -238,7 +238,6 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker if (_score.get(player) >= SCORE_GOAL) { setCompleted(player); - UtilTextBottom.display(C.cGreen + C.Bold + "Completed!", player); } } @@ -279,40 +278,15 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker } } - private static final double SCORE_BLOCK_SPAWN_CHANCE = 0.1; - private static final int SCORE_BLOCK_DATA_RANGE = 16; - private void spawnStartingWool() { - whileLoop: while (_blocks.size() <= Settings.getMaxCompletedCount() + 1) + for (int i = 0; i < Host.getPlayersWithRemainingLives() + 1; i++) { - for (int x = -getArenaSize(); x <= getArenaSize(); x++) - { - for (int z = -getArenaSize(); z <= getArenaSize(); z++) - { - for (int y = SCORE_BLOCK_HEIGHT; y <= SCORE_BLOCK_HEIGHT_MAX; y++) - { - Block block = getCenter().getBlock().getRelative(x, y, z); - - if (block.isEmpty() || block.getType() == null) - { - if (Math.random() < SCORE_BLOCK_SPAWN_CHANCE) - { - spawnRandomWoolAt(x, y, z); - - if (_blocks.size() >= Settings.getMaxCompletedCount() + 1) - { - break whileLoop; - } - } - } - } - } - } + spawnRandomWool(false); } } - private void spawnRandomWool() + private void spawnRandomWool(boolean firework) { int size = getArenaSize(MAP_MIN_SIZE) - SCORE_BLOCK_SPAWN_SHIFT; @@ -320,11 +294,18 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker int y = SCORE_BLOCK_HEIGHT + UtilMath.r(SCORE_BLOCK_HEIGHT_ADD); int z = UtilMath.r(size * SCORE_BLOCK_BOUND_MULTIPLY) - size; - spawnRandomWoolAt(x, y, z); + while (!Host.WorldData.World.getBlockAt(x, y, z).isEmpty()) + { + x = UtilMath.r(size * SCORE_BLOCK_BOUND_MULTIPLY) - size; + y = SCORE_BLOCK_HEIGHT + UtilMath.r(SCORE_BLOCK_HEIGHT_ADD); + z = UtilMath.r(size * SCORE_BLOCK_BOUND_MULTIPLY) - size; + } + + spawnRandomWoolAt(x, y, z, firework); } @SuppressWarnings("deprecation") - private void spawnRandomWoolAt(int x, int y, int z) + private void spawnRandomWoolAt(int x, int y, int z, boolean firework) { Block b = getCenter().getBlock().getRelative(x, y, z); Byte color = (byte) UtilMath.r(SCORE_BLOCK_DATA_RANGE); @@ -335,7 +316,11 @@ public class ChallengeBouncingBlock extends Challenge implements LogicTracker } setBlock(b, Material.WOOL, color); - UtilFirework.playFirework(b.getLocation().add(SCORE_FIREWORK_LOCATION_ADD, SCORE_FIREWORK_LOCATION_ADD, SCORE_FIREWORK_LOCATION_ADD), Type.BALL, DyeColor.getByWoolData(b.getData()).getColor(), false, false); + + if (firework) + { + UtilFirework.playFirework(b.getLocation().add(SCORE_FIREWORK_LOCATION_ADD, SCORE_FIREWORK_LOCATION_ADD, SCORE_FIREWORK_LOCATION_ADD), Type.BALL, DyeColor.getByWoolData(b.getData()).getColor(), false, false); + } _blocks.add(b); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeBuildRace.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeBuildRace.java index 77d93c836..b2829b1b3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeBuildRace.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeBuildRace.java @@ -144,7 +144,6 @@ public class ChallengeBuildRace extends Challenge implements LogicTracker if (!Data.isModifiedBlock(block.getRelative(BlockFace.DOWN))) { - System.out.println("Cancel"); event.setCancelled(true); return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeChickenShooting.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeChickenShooting.java index 4354a2ef5..abdec69e5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeChickenShooting.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeChickenShooting.java @@ -357,7 +357,7 @@ public class ChallengeChickenShooting extends Challenge implements NumberTracker chicken.setMaxHealth(CHICKEN_HEATH); chicken.setHealth(CHICKEN_HEATH); - + if (Math.random() < CHICKEN_BABY_SPAWN_CHANCE) { chicken.setBaby(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeCloudFall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeCloudFall.java index 5384545b8..96661c9a9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeCloudFall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeCloudFall.java @@ -19,6 +19,8 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType; /** * A challenge based on dropping from a platform in the correct block. + * + * @deprecated */ public class ChallengeCloudFall extends Challenge { @@ -84,7 +86,6 @@ public class ChallengeCloudFall extends Challenge Host.DamageFall = false; } - @EventHandler public void onCustomDamage(CustomDamageEvent event) { @@ -142,7 +143,6 @@ public class ChallengeCloudFall extends Challenge } } - @SuppressWarnings("deprecation") private boolean isLandingBlock(Block block) { return block.getType() == LANDING_PLATFORM_BLOCK_TYPE && block.getData() == LANDING_PLATFORM_BLOCK_DATA; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeColorChange.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeColorChange.java index 345cfecb2..67f62bdcf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeColorChange.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeColorChange.java @@ -31,7 +31,7 @@ public class ChallengeColorChange extends Challenge private static final int SPAWN_COORDINATES_MULTIPLE = 2; private static final int MAP_HEIGHT = 1; - private static final long TIME_DELAY = 3000; + private static final long TIME_DELAY = 5000; private static final int TIME_DELAY_DECREMENT_RATE = 100; private static final int RESET_DELAY = 4000; @@ -104,6 +104,7 @@ public class ChallengeColorChange extends Challenge { _isFalling = false; _lastSound = 0; + _lastGeneratedPlatforms.clear(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeDogsVersusCats.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeDogsVersusCats.java index f0a3c0474..86abbfedf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeDogsVersusCats.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeDogsVersusCats.java @@ -34,6 +34,8 @@ import nautilus.game.arcade.game.games.mineware.challenge.TeamChallenge; /** * A team based challenge with players disguised as dogs and cats. + * + * @deprecated */ public class ChallengeDogsVersusCats extends TeamChallenge { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeEmpty.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeEmpty.java new file mode 100644 index 000000000..79ab58f6e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeEmpty.java @@ -0,0 +1,42 @@ +package nautilus.game.arcade.game.games.mineware.challenge.type; + +import java.util.ArrayList; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; + +import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; +import nautilus.game.arcade.game.games.mineware.challenge.Challenge; +import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType; + +/** + * This challenge is used to prevent the game from crashing if it's forced to start with only one player. + * + * @deprecated + */ +public class ChallengeEmpty extends Challenge +{ + public ChallengeEmpty(BawkBawkBattles host) + { + super(host, ChallengeType.FirstComplete, "Empty", "Not enough players"); + + Settings.setUseMapHeight(); + } + + @Override + public ArrayList createSpawns() + { + ArrayList spawns = new ArrayList<>(); + spawns.add(getCenter().add(0, 1, 0)); + return spawns; + } + + @Override + public void createMap() + { + Block center = getCenter().getBlock(); + center.setType(Material.BARRIER); + addBlock(center); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeFallingBlocks.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeFallingBlocks.java index 297439697..8024d10e7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeFallingBlocks.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeFallingBlocks.java @@ -55,7 +55,7 @@ public class ChallengeFallingBlocks extends Challenge implements NumberTracker private static final int PLAYER_CAMP_MAX_HEIGHT = 3; private static final byte ADDITIONAL_BLOCK_DATA = 2; - private static final float BLOCK_HITBOX_GROW = 0.7F; + private static final float BLOCK_HITBOX_GROW = 0.6F; private static final Material[] MATERIALS = { Material.GRASS, @@ -234,12 +234,7 @@ public class ChallengeFallingBlocks extends Challenge implements NumberTracker if (!isChallengeValid()) return; - Player player = event.getPlayer(); - - if (_waveTracker.containsKey(player)) - { - _waveTracker.remove(player); - } + _waveTracker.remove(event.getPlayer()); } private void initializeWaveTracker() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeFishingDay.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeFishingDay.java index 6baa30a9d..d288ca70b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeFishingDay.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeFishingDay.java @@ -43,8 +43,9 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType; /** * A challenge based on fishing. + * + * @deprecated */ -@SuppressWarnings("deprecation") public class ChallengeFishingDay extends Challenge { private int _startingLureLevel = 8; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java index b6fdcce87..311983f81 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java @@ -149,7 +149,6 @@ public class ChallengeLavaRun extends Challenge _modifiedDelay += _modifiedDelayMin; } - System.out.println("Delay: " + _modifiedDelay); _disappearingBlocks++; _shouldMoveObsidian = false; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeNavigationMaze.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeNavigationMaze.java index 804633ce6..cbcc9648b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeNavigationMaze.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeNavigationMaze.java @@ -20,6 +20,8 @@ import nautilus.game.arcade.game.games.mineware.challenge.NumberTracker; /** * A challenge based on mazes. + * + * @deprecated */ public class ChallengeNavigationMaze extends Challenge implements NumberTracker { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeReverseTag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeReverseTag.java index a88e4e3ee..2883ab39a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeReverseTag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeReverseTag.java @@ -199,7 +199,11 @@ public class ChallengeReverseTag extends TeamChallenge implements LogicTracker return; Player player = event.getEntity(); - getFirstTeam().remove(player); + + if (!isPlayerValid(player)) + return; + + _tagTracker.put(player, false); } @EventHandler @@ -267,14 +271,7 @@ public class ChallengeReverseTag extends TeamChallenge implements LogicTracker private void trackTag(Player player) { - if (_tagTracker.containsKey(player)) - { - if (_tagTracker.get(player)) - { - _tagTracker.put(player, true); - } - } - else + if (!_tagTracker.containsKey(player)) { _tagTracker.put(player, true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeRushPush.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeRushPush.java index 879ca6006..e87e88be6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeRushPush.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeRushPush.java @@ -45,7 +45,7 @@ public class ChallengeRushPush extends TeamChallenge (byte) 11, (byte) 14, "Rush Push", - "Attack to the enemy team.", + "Attack the enemy team.", "Push them off the platform."); Settings.setUseMapHeight(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeVolleyPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeVolleyPig.java index 3b1b4c12d..9c9f7c5d7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeVolleyPig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeVolleyPig.java @@ -34,6 +34,8 @@ import nautilus.game.arcade.game.games.mineware.challenge.TeamChallenge; /** * A challenge based on volley. + * + * @deprecated */ public class ChallengeVolleyPig extends TeamChallenge { @@ -164,7 +166,6 @@ public class ChallengeVolleyPig extends TeamChallenge _redSide = 0; } - @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.LOW) public void onPlayerMove(PlayerMoveEvent event) { @@ -308,7 +309,6 @@ public class ChallengeVolleyPig extends TeamChallenge } } - @SuppressWarnings("deprecation") private void increaseTeamScore() { if (_pig.isValid()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeWaveCrush.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeWaveCrush.java index 82422cfc0..ace1cd80c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeWaveCrush.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeWaveCrush.java @@ -62,7 +62,7 @@ public class ChallengeWaveCrush extends Challenge implements NumberTracker ChallengeType.LastStanding, "Wave Crush", "Waves of blocks are coming towards you!", - "Avoid getting him by them."); + "Avoid getting hit by them."); Settings.setUseMapHeight(); } @@ -119,11 +119,7 @@ public class ChallengeWaveCrush extends Challenge implements NumberTracker { _modifiedNextWaveDelay = NEXT_WAVE_DELAY; - for (Player player : getPlayersAlive()) - { - _survivedWaves.put(player, 0); - } - + initializeWaveTracker(); startWavesTask(); } @@ -143,12 +139,7 @@ public class ChallengeWaveCrush extends Challenge implements NumberTracker if (!isChallengeValid()) return; - Player player = event.getPlayer(); - - if (_survivedWaves.containsKey(player)) - { - _survivedWaves.remove(player); - } + _survivedWaves.remove(event.getPlayer()); } @Override @@ -161,6 +152,7 @@ public class ChallengeWaveCrush extends Challenge implements NumberTracker if (isPlayerValid(player)) { Host.Manager.GetDamage().NewDamageEvent(target, null, null, DamageCause.PROJECTILE, player.getHealth(), false, false, false, "Falling Block", "Wave Crush"); + subtractWaveCount(player); } } } @@ -179,6 +171,22 @@ public class ChallengeWaveCrush extends Challenge implements NumberTracker return COLORS[_colorIndex]; } + private void initializeWaveTracker() + { + for (Player player : getPlayersAlive()) + { + _survivedWaves.put(player, 0); + } + } + + private void subtractWaveCount(Player player) + { + if (Data.isLost(player) && _survivedWaves.get(player) > 0) + { + _survivedWaves.put(player, _survivedWaves.get(player) - 1); + } + } + private void startWavesTask() { new BukkitRunnable() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeZombieInfection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeZombieInfection.java index dba0d979c..2d7dd04fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeZombieInfection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeZombieInfection.java @@ -35,6 +35,8 @@ import nautilus.game.arcade.game.games.mineware.challenge.other.ZombieWrapper; /** * A challenge based on zombie survival. + * + * @deprecated */ public class ChallengeZombieInfection extends Challenge { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java index 950608a2f..02f34c55d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java @@ -81,7 +81,7 @@ public class ChickenAttack player.teleport(_center); UtilTextMiddle.display(C.cRed + "Chicken Attack!", "You ran out of lives.", INFORM_TITLTE_FADE_IN_TICKS, INFORM_TITLTE_STAY_TICKS, INFORM_TITLTE_FADE_OUT_TICKS, player); - UtilPlayer.message(player, F.main("Game", "You failed to follow bawk bawk's instructions and you ran out of lives. His minions are now attacking you.")); + UtilPlayer.message(player, F.main("Game", "You failed to follow Bawk Bawk's commands. Now his chickens will devour you!")); player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1.0F, 1.0F); player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 1)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/BouncingShadowTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/BouncingShadowTracker.java index 5cc154fa7..fa18c7066 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/BouncingShadowTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/BouncingShadowTracker.java @@ -30,9 +30,8 @@ public class BouncingShadowTracker extends ChallengeStatTracker for (Player player : getGame().GetPlayers(true)) { - if (bouncingBlock.hasData(player) && bouncingBlock.getData().isDone(player)) + if (bouncingBlock.hasData(player) && bouncingBlock.getData().isCompleted(player)) { - System.out.println("Bouncing Shadow: " + player.getName()); addStat(player, "BouncingShadow", 1, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/DragonKingTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/DragonKingTracker.java index 50944864f..717363810 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/DragonKingTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/DragonKingTracker.java @@ -36,7 +36,6 @@ public class DragonKingTracker extends ChallengeStatTracker if (score > 0) { - System.out.println("Dragon King: " + player.getName()); addStat(player, "DragonKing", score, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/EliteArcherTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/EliteArcherTracker.java index 7f634de5e..ae654b4f3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/EliteArcherTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/EliteArcherTracker.java @@ -36,7 +36,6 @@ public class EliteArcherTracker extends ChallengeStatTracker if (score > 0) { - System.out.println("Elite Archer: " + player.getName()); addStat(player, "EliteArcher", score, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/MilkManTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/MilkManTracker.java index 0aadc34c6..11c11a92e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/MilkManTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/MilkManTracker.java @@ -36,7 +36,6 @@ public class MilkManTracker extends ChallengeStatTracker if (score > 0) { - System.out.println("Milk Man: " + player.getName()); addStat(player, "MilkMan", score, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/PinataMasterTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/PinataMasterTracker.java index 5c47f2b3c..c45c23d71 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/PinataMasterTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/PinataMasterTracker.java @@ -36,7 +36,6 @@ public class PinataMasterTracker extends ChallengeStatTracker if (score > 0) { - System.out.println("Pinata Master: " + player.getName()); addStat(player, "PinataMaster", score, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/PixelNinjaTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/PixelNinjaTracker.java index 9d94686f3..05401270e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/PixelNinjaTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/PixelNinjaTracker.java @@ -36,7 +36,6 @@ public class PixelNinjaTracker extends ChallengeStatTracker if (score > 0) { - System.out.println("Pixel Ninja: " + player.getName()); addStat(player, "PixelNinja", score, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/SpeedyBuildersTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/SpeedyBuildersTracker.java index be408cef1..205995bf2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/SpeedyBuildersTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/SpeedyBuildersTracker.java @@ -34,7 +34,6 @@ public class SpeedyBuildersTracker extends ChallengeStatTracker { if (buildRace.hasData(player) && buildRace.getData().isDone(player)) { - System.out.println("Speedy Builders: " + player.getName()); addStat(player, "SpeedyBuilders", 1, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/SurfUpTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/SurfUpTracker.java index 54eb2fdc3..b976ca2d8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/SurfUpTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/SurfUpTracker.java @@ -36,7 +36,6 @@ public class SurfUpTracker extends ChallengeStatTracker if (score > 0) { - System.out.println("Surf Up: " + player.getName()); addStat(player, "SurfUp", score, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/TagMasterTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/TagMasterTracker.java index f5729a679..fd672eebc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/TagMasterTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/TagMasterTracker.java @@ -28,11 +28,10 @@ public class TagMasterTracker extends ChallengeStatTracker { ChallengeReverseTag reverseTag = (ChallengeReverseTag) challenge; - for (Player player : reverseTag.getFirstTeam().getPlayers()) + for (Player player : getGame().GetPlayers(true)) { if (reverseTag.hasData(player)) { - System.out.println("Tag Master: " + player.getName()); addStat(player, "TagMaster", 1, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/VeteranTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/VeteranTracker.java index 80c2bac97..debcf47ae 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/VeteranTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/tracker/VeteranTracker.java @@ -31,7 +31,6 @@ public class VeteranTracker extends StatTracker if (winner != null) { - System.out.println("Veteran: " + winner.getName()); addStat(winner, "Veteran", 1, true, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java index 2373b9537..c5deefa69 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java @@ -11,11 +11,14 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.enchantment.EnchantItemEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerItemDamageEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerToggleSneakEvent; @@ -33,12 +36,14 @@ import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.loot.RandomItem; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minestrike.GunModule; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; import nautilus.game.arcade.game.games.minestrike.items.grenades.FlashBang; import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade; import nautilus.game.arcade.game.games.minestrike.items.grenades.HighExplosive; @@ -47,6 +52,8 @@ import nautilus.game.arcade.game.games.minestrike.items.grenades.Molotov; import nautilus.game.arcade.game.games.minestrike.items.grenades.Smoke; import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunType; +import nautilus.game.arcade.game.games.minestrike.items.guns.Shotgun; import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames; import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent; import nautilus.game.arcade.game.games.survivalgames.kit.KitLooter; @@ -64,6 +71,7 @@ public class StrikeGames extends SoloSurvivalGames private GunModule _gunModule; private long _peacePhase; + private boolean _peace = false; private HashMap _helmets; @@ -84,6 +92,8 @@ public class StrikeGames extends SoloSurvivalGames _gunModule.EnableCleaning = false; _gunModule.EnableDrop = false; _gunModule.EnablePickup = false; + _gunModule.BlockRegeneration = false; + _gunModule.EnableNormalArmor = true; } @EventHandler @@ -98,19 +108,56 @@ public class StrikeGames extends SoloSurvivalGames if (!UtilTime.elapsed(GetStateTime(), _peacePhase)) return; - if (Damage) + if (!_peace) return; + _peace = false; + Announce(F.main("Game", "The Peace Phase has ended! You can now fight each other!")); Damage = true; } + @EventHandler + public void eatingGrenades(PlayerItemConsumeEvent event) + { + if (event.getItem().getType() == Material.POTATO_ITEM + || event.getItem().getType() == Material.CARROT_ITEM + || event.getItem().getType() == Material.APPLE + || event.getItem().getType() == Material.PORK + || event.getItem().getType() == Material.GRILLED_PORK) + { + event.setCancelled(true); + } + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void DeathmatchDamage(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (!isDeathMatchTeleported()) + return; + + if (getDeathMatchTime() <= 0) + { + Damage = true; + } + else + { + Damage = false; + } + } + @EventHandler public void informPeace(GameStateChangeEvent event) { if (event.GetState() != GameState.Live) return; + _peace = true; + Announce(F.main("Game", "A Peace Phase of " + F.time((_peacePhase/1000) + "") + " seconds has started!")); } @@ -417,7 +464,15 @@ public class StrikeGames extends SoloSurvivalGames { if (stat.getSkin() == stack.getType()) { - Gun gun = new Gun(stat, _gunModule); + Gun gun = null; + if (stat.getGunType() == GunType.SHOTGUN) + { + gun = new Shotgun(stat, _gunModule); + } + else + { + gun = new Gun(stat, _gunModule); + } gun.setStack(stack); gun.updateWeaponName(player, null, false); gun.addID(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index e4af92f98..5f563ab9e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -16,11 +16,12 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParser; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilWorld; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.timing.TimingManager; @@ -38,14 +39,17 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.uhc.helpers.ChunkLoadingThread; import nautilus.game.arcade.game.games.uhc.helpers.WorldGenThread; +import nautilus.game.arcade.game.modules.OreVeinEditorModule; import nautilus.game.arcade.game.modules.TeamModule; +import nautilus.game.arcade.game.modules.antixray.AntiXrayModule; +import nautilus.game.arcade.game.modules.combatlog.CombatLogModule; +import nautilus.game.arcade.game.modules.combatlog.CombatLogNPC; import nautilus.game.arcade.kit.Kit; -import net.minecraft.server.v1_8_R3.Chunk; -import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.WorldServer; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Chunk; import org.bukkit.Difficulty; import org.bukkit.Location; import org.bukkit.Material; @@ -54,9 +58,8 @@ import org.bukkit.World.Environment; import org.bukkit.WorldBorder; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.craftbukkit.v1_8_R3.CraftChunk; +import org.bukkit.block.BlockState; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -68,7 +71,9 @@ 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.BlockBreakEvent; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockGrowEvent; +import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; @@ -81,6 +86,7 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerPickupItemEvent; @@ -88,6 +94,7 @@ import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.world.ChunkUnloadEvent; +import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ShapedRecipe; @@ -96,16 +103,17 @@ import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.material.MaterialData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; -import org.spigotmc.ActivationRange; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; @@ -120,12 +128,27 @@ public class UHC extends TeamGame implements NCPHook // The number of minutes after which PVP should be enabled public static final int SAFE_TIME_IN_MINUTES = 11; + // The number of chunks to unload per tick + public static final int CHUNKS_UNLOAD_PER_TICK = 1; + + // This is the region in which nothing can be done (block placing, flowing, etc) + public static final int SAFE_REGION = 36; + + // The amount of damage to give from hitting the world border + public static final int WORLD_BORDER_DAMAGE = 5; + // The thread responsible for generating the world private final WorldGenThread _worldGenThread = new WorldGenThread(this); // The thread responsible for loading and decorating the world private final ChunkLoadingThread _chunkLoadingThread = new ChunkLoadingThread(this); + // The chunks which we have prevented unloading + private final Set _loadedChunks = new HashSet<>(); + + // The task which will unload chunks periodically + private BukkitRunnable _chunkUnloadTask; + // The number of minutes passed in this game private int _minutesSinceStart = 0; @@ -139,8 +162,6 @@ public class UHC extends TeamGame implements NCPHook // Whether players are teleporting currently private volatile boolean _isTeleporting = false; - private boolean xrayDebug; - // Border private int _secondsSinceStart; private HashMap _borderPositions = new HashMap(); @@ -159,6 +180,11 @@ public class UHC extends TeamGame implements NCPHook DamageTaken, DamageDealt ); + + registerModule( + new OreVeinEditorModule() + .removeNonAirVeins() + ); } public UHC(ArcadeManager manager, GameType type) @@ -176,12 +202,12 @@ public class UHC extends TeamGame implements NCPHook "Borders shrink over time", "Last player/team alive wins!" }); + _gamesRun++; + this.HideTeamSheep = true; this.StrictAntiHack = true; - AnnounceStay = false; - this.GameTimeout = 10800000; this.DamagePvP = false; @@ -229,6 +255,10 @@ public class UHC extends TeamGame implements NCPHook WorldTimeSet = -1; this.WorldLeavesDecay = true; + this.WorldBlockGrow = true; + this.WorldSoilTrample = true; + this.WorldBoneMeal = true; + this.WorldChunkUnload = true; CraftRecipes(); @@ -247,6 +277,31 @@ public class UHC extends TeamGame implements NCPHook NCPHookManager.addHook(CheckType.ALL, this); registerModule(new TeamModule()); + registerModule(new AntiXrayModule()) + .setEnabled(true) + .setUpdateOnDamage(true) + .setAntiTexturePacksAndFreecam(false) + .setUseProximityHider(false) + .setEngineMode(2) + .setInitialRadius(1) + .setUpdateRadius(2) + .setObfuscateBlocks( + Material.GOLD_ORE, + Material.IRON_ORE, + Material.LAPIS_ORE, + Material.DIAMOND_ORE, + Material.REDSTONE_ORE, + Material.GLOWING_REDSTONE_ORE, + Material.EMERALD_ORE + ) + .setRandomBlocks( + Material.GOLD_ORE, + Material.IRON_ORE, + Material.LAPIS_ORE, + Material.DIAMOND_ORE, + Material.REDSTONE_ORE, + Material.EMERALD_ORE + ); } @Override @@ -345,7 +400,7 @@ public class UHC extends TeamGame implements NCPHook if (Manager.IsAlive(player)) { - Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 10, false, false, false, + Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, WORLD_BORDER_DAMAGE, false, false, false, "Nether Field", "Vaporize"); player.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, 1f); @@ -358,6 +413,36 @@ public class UHC extends TeamGame implements NCPHook } } } + + if (getModule(CombatLogModule.class) != null) + { + for (CombatLogNPC npc : getModule(CombatLogModule.class).getAllNPCs()) + { + LivingEntity ent = npc.getNPC(); + Location loc = ent.getLocation(); + + // Bump Players Back In + if (loc.getX() > border || loc.getX() < -border || loc.getZ() > border || loc.getZ() < -border) + { + // Can't use recharge on entities; blame bad design (mapping by name instead of uuid) +// if (Recharge.Instance.use(ent, "Hit by Border", 1000, false, false)) + { + Entity bottom = ent; + while (bottom.getVehicle() != null) + bottom = bottom.getVehicle(); + + UtilAction + .velocity(bottom, UtilAlg.getTrajectory2d(loc, GetSpectatorLocation()), 1.2, true, 0.4, 0, 10, true); + + Manager.GetDamage().NewDamageEvent(ent, null, null, DamageCause.CUSTOM, WORLD_BORDER_DAMAGE, false, false, false, + "Nether Field", "Vaporize"); + + ent.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, 1f); + ent.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, 1f); + } + } + } + } } private ArrayList buildBorders(int seconds, double border, double leaveRemaining) @@ -517,7 +602,70 @@ public class UHC extends TeamGame implements NCPHook this.DamagePvP = true; this.CompassGiveItem = true; - this.QuitOut = true; + this.RejoinTime = 300000; // 5 minutes + registerModule( + new CombatLogModule() + .setSpawnForCreative(false) + .setCombatLogTime(300000) + .setOnDeathAction(npc -> + { + if (npc.getLastDamager() instanceof Player) + { + Player killer = (Player) npc.getLastDamager(); + Announce(npc.getPlayerInfo().getTeamColor() + C.Bold + npc.getPlayerInfo().getName() + + C.cGray + C.Bold + " was killed by " + getArcadeManager().GetColor(killer) + + C.Bold + npc.getLastDamager().getName() + C.cGray + C.Bold + " while logged out."); + } + else + { + String cause = UtilParser.parseDamageCause(npc.getLastDamageCause()); + if (npc.getLastDamager() != null) + { + cause = npc.getLastDamager().getName(); + } + Announce(npc.getPlayerInfo().getTeamColor() + C.Bold + npc.getPlayerInfo().getName() + + C.cGray + C.Bold + " was killed by " + cause + " while logged out."); + } + + ItemStack stack = new ItemBuilder(Material.SKULL_ITEM) + .setData((byte) 3) + .setTitle(npc.getPlayerInfo().getTeamColor() + npc.getPlayerInfo().getName() + "'s Head") + .build(); + + SkullMeta meta = (SkullMeta) stack.getItemMeta(); + meta.setOwner(npc.getPlayerInfo().getName()); + stack.setItemMeta(meta); + + npc.getNPC().getWorld().dropItemNaturally(npc.getNPC().getLocation(), stack); + + Location location = npc.getNPC().getLocation(); + + for (ItemStack item : npc.getPlayerInfo().getItems()) + { + location.getWorld().dropItemNaturally(location, item); + } + }) + .setOnExpireAction(npc -> + { + ItemStack stack = new ItemBuilder(Material.SKULL_ITEM) + .setData((byte) 3) + .setTitle(npc.getPlayerInfo().getTeamColor() + npc.getPlayerInfo().getName() + "'s Head") + .build(); + + SkullMeta meta = (SkullMeta) stack.getItemMeta(); + meta.setOwner(npc.getPlayerInfo().getName()); + stack.setItemMeta(meta); + + npc.getNPC().getWorld().dropItemNaturally(npc.getNPC().getLocation(), stack); + + Location location = npc.getNPC().getLocation(); + + for (ItemStack item : npc.getPlayerInfo().getItems()) + { + location.getWorld().dropItemNaturally(location, item); + } + }) + ); } } @@ -581,6 +729,27 @@ public class UHC extends TeamGame implements NCPHook } HandlerList.unregisterAll(_chunkLoadingThread); NCPHookManager.removeHook(this); + + if (_chunkUnloadTask != null) + { + try + { + _chunkUnloadTask.cancel(); + } + catch (IllegalStateException ex) + { + // bukkit + } + } + + Iterator iterator = _loadedChunks.iterator(); + while (iterator.hasNext()) + { + Chunk chunk = iterator.next(); + WorldData.World.unloadChunk(chunk.getX(), chunk.getZ()); + iterator.remove(); + } + return; } @@ -592,16 +761,13 @@ public class UHC extends TeamGame implements NCPHook _worldGenThread.start(); } - @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = false) + @EventHandler(priority = EventPriority.MONITOR) public void on(ChunkUnloadEvent event) { - if (IsLive()) - { - event.setCancelled(false); - } - else + if (!IsLive()) { event.setCancelled(true); + _loadedChunks.add(event.getChunk()); } } @@ -641,11 +807,11 @@ public class UHC extends TeamGame implements NCPHook Location zero = WorldData.World.getSpawnLocation(); + // fixme if you leave while teleporting you'll rejoin at 0,0 + for (Player player : players) { player.teleport(zero); - player.hidePlayer(player); - // Heal player.setHealth(player.getMaxHealth()); // Resistance and regen @@ -711,14 +877,31 @@ public class UHC extends TeamGame implements NCPHook WorldData.World.setAutoSave(true); - int x = 0; - for (org.bukkit.Chunk chunk : WorldData.World.getLoadedChunks()) + _chunkUnloadTask = new BukkitRunnable() { - if (WorldData.World.unloadChunkRequest(chunk.getX(), chunk.getZ())) + @Override + public void run() { - System.out.println("Requesting unload of chunk #" + (++x) + " " + chunk.getX() + " " + chunk.getZ()); + Iterator iterator = _loadedChunks.iterator(); + int amount = 0; + + while (amount < CHUNKS_UNLOAD_PER_TICK && iterator.hasNext()) + { + Chunk next = iterator.next(); + if (WorldData.World.unloadChunkRequest(next.getX(), next.getZ())) + { + System.out.println("Requesting unload of chunk " + next.getX() + " " + next.getZ()); + } + iterator.remove(); + amount++; + } + + if (_loadedChunks.size() == 0) + { + cancel(); + } } - } + }; }, 10 * 20L); } }, 5 * 20L); @@ -821,17 +1004,90 @@ public class UHC extends TeamGame implements NCPHook return SpectatorSpawn; } + // fixme flowing water and stuff + @EventHandler - public void WorldBoundaryYLimit(BlockPlaceEvent event) + public void preventBlockPlacement(BlockPlaceEvent event) { - if (event.getBlock().getX() >= -36 && event.getBlock().getX() <= 36 && event.getBlock().getZ() >= -36 - && event.getBlock().getZ() <= 36) + if (isInSafeZone(event.getBlock().getLocation())) { UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot build this high near center of map.")); event.setCancelled(true); } } + @EventHandler + public void preventStructureGrow(StructureGrowEvent event) + { + Iterator blocks = event.getBlocks().iterator(); + while (blocks.hasNext()) + { + BlockState next = blocks.next(); + if (isInSafeZone(next.getLocation())) + { + blocks.remove(); + } + } + } + + @EventHandler + public void preventBlockGrow(BlockGrowEvent event) + { + if (isInSafeZone(event.getBlock().getLocation())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void preventBoneMeal(PlayerInteractEvent event) + { + if (event.getAction() == Action.RIGHT_CLICK_BLOCK) + { + boolean isIllegal = false; + if (!isIllegal) + { + isIllegal = event.getPlayer().getItemInHand().getType() == Material.INK_SACK && + event.getPlayer().getItemInHand().getData().getData() == (byte) 15; + } + if (!isIllegal) + { + isIllegal = event.getPlayer().getItemInHand().getType() == Material.WATER_BUCKET + || event.getPlayer().getItemInHand().getType() == Material.LAVA_BUCKET; + } + + if (isIllegal && isInSafeZone(event.getClickedBlock().getLocation())) + { + event.setCancelled(true); + } + } + } + + @EventHandler + public void preventPistons(BlockPistonExtendEvent event) + { + boolean willBeUnsafe = false; + for (Block block : event.getBlocks()) + { + if (isInSafeZone(block.getRelative(event.getDirection()).getLocation())) + { + willBeUnsafe = true; + break; + } + } + if (willBeUnsafe) + { + event.setCancelled(true); + } + } + + private boolean isInSafeZone(Location location) + { + return location.getX() <= SAFE_REGION && location.getX() >= -SAFE_REGION + && location.getZ() < SAFE_REGION && location.getZ() >= -SAFE_REGION; + } + + // fixme world decoration means random spawns which were clear before might not be after public Location GetRandomSpawn(Location around) { // Sometimes getting a random spawn at 0,0 hangs forever @@ -1019,7 +1275,7 @@ public class UHC extends TeamGame implements NCPHook if (event.getType() != UpdateType.SLOW) return; - HashMap> ents = new HashMap>(); + Map> ents = new HashMap<>(); for (Entity ent : WorldData.World.getEntities()) { @@ -1573,82 +1829,12 @@ public class UHC extends TeamGame implements NCPHook return true; } + private static int _gamesRun = 0; + @EventHandler public void on(PlayerCommandPreprocessEvent event) { - if (event.getMessage().equals("/uhcentities")) - { - CoreClient client = getArcadeManager().GetClients().Get(event.getPlayer()); - if (client.GetRank().has(Rank.DEVELOPER)) - { - for (Entity entity : event.getPlayer().getNearbyEntities(5.0, 5.0, 5.0)) - { - net.minecraft.server.v1_8_R3.Entity nms = ((CraftEntity) entity).getHandle(); - String debug = "Entity: " + entity.getType() + " id:" + nms.getId() + " inac:" + ActivationRange.checkIfActive(nms); - debug += " at:" + nms.activatedTick + " dac:" + nms.defaultActivationState; - - int x = MathHelper.floor(nms.locX); - int z = MathHelper.floor(nms.locZ); - - net.minecraft.server.v1_8_R3.Chunk chunk = nms.world.getChunkIfLoaded(x >> 4, z >> 4); - debug += " c:" + chunk + " il:" + (chunk != null ? chunk.areNeighborsLoaded(1) : "null"); - event.getPlayer().sendMessage(debug); - } - event.setCancelled(true); - } - } - else if (event.getMessage().equals("/uhcchunk")) - { - CoreClient client = getArcadeManager().GetClients().Get(event.getPlayer()); - if (client.GetRank().has(Rank.DEVELOPER)) - { - net.minecraft.server.v1_8_R3.Chunk chunk = ((CraftChunk) event.getPlayer().getLocation().getChunk()).getHandle(); - try - { - Field neighbors = chunk.getClass().getDeclaredField("neighbors"); - neighbors.setAccessible(true); - int n = neighbors.getInt(chunk); - - for (int x = -1; x < 2; x++) - { - for (int z = -1; z < 2; z++) - { - if (x == 0 && z == 0) - { - continue; - } - - int mask = 0x1 << (x * 5 + z + 12); - - boolean should = chunk.world.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z) != null; - boolean is = (n & mask) == mask; - if (is && should) - { - event.getPlayer().sendMessage(ChatColor.GREEN + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is a neighbor"); - } - else if (is && !should) - { - event.getPlayer().sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is a neighbor but should not be"); - } - else if (!is && should) - { - event.getPlayer().sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is not a neighbor but should be"); - } - else if (!is && !should) - { - event.getPlayer().sendMessage(ChatColor.GREEN + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is not a neighbor"); - } - } - } - } - catch (Throwable t) - { - t.printStackTrace(); - } - event.setCancelled(true); - } - } - else if (event.getMessage().equals("/uhcgc")) + if (event.getMessage().equals("/uhcgc")) { CoreClient client = getArcadeManager().GetClients().Get(event.getPlayer()); if (client.GetRank().has(Rank.DEVELOPER)) @@ -1658,53 +1844,6 @@ public class UHC extends TeamGame implements NCPHook event.setCancelled(true); } } - else if (event.getMessage().equals("/uhcallchunks")) - { - CoreClient client = getArcadeManager().GetClients().Get(event.getPlayer()); - if (client.GetRank().has(Rank.DEVELOPER)) - { - for (Chunk chunk : ((CraftWorld) event.getPlayer().getWorld()).getHandle().chunkProviderServer.chunks.values()) - { - try - { - Field neighbors = chunk.getClass().getDeclaredField("neighbors"); - neighbors.setAccessible(true); - int n = neighbors.getInt(chunk); - - for (int x = -1; x < 2; x++) - { - for (int z = -1; z < 2; z++) - { - if (x == 0 && z == 0) - { - continue; - } - - int mask = 0x1 << (x * 5 + z + 12); - - boolean should = chunk.world.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z) != null; - boolean is = (n & mask) == mask; - if (is && !should) - { - event.getPlayer().sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") relative to " + (chunk.locX) + "," + chunk.locZ + " is a neighbor but should not be"); - } - else if (!is && should) - { - event.getPlayer().sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") relative to " + (chunk.locX) + "," + chunk.locZ + " is not a neighbor but should be"); - } - } - } - } - catch (Throwable t) - { - t.printStackTrace(); - } - } - - event.getPlayer().sendMessage("Done"); - event.setCancelled(true); - } - } else if (event.getMessage().equals("/uhcworlds")) { CoreClient client = getArcadeManager().GetClients().Get(event.getPlayer()); @@ -1734,183 +1873,14 @@ public class UHC extends TeamGame implements NCPHook event.setCancelled(true); } } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void xrayBlockBreak(BlockBreakEvent event) - { - if (event.isCancelled()) - return; - - if (xrayDebug) - TimingManager.start("Block Break"); - - int range = 3; - - // Find Nearby Ores - ArrayList ores = findOres(event.getBlock(), range); - - // Anti-Xray - removeNonAirVeins(generateVeins(ores)); - - if (xrayDebug) - TimingManager.stop("Block Break"); - } - - private ArrayList findOres(Block source, int range) - { - ArrayList ores = new ArrayList(); - - for (int x = -range; x <= range; x++) - for (int z = -range; z <= range; z++) - for (int y = -range; y <= range; y++) - { - Block block = source.getRelative(x, y, z); - - findOreFromBlock(ores, block); - } - - if (xrayDebug) - for (Block debug : ores) - System.out.println("Found " + debug.getType() + " at " + UtilWorld.locToStrClean(debug.getLocation())); - - return ores; - } - - public void findOreFromBlock(ArrayList ores, Block block) - { - if (ores.contains(block)) - return; - - if (isOre(block)) + else if (event.getMessage().equals("/uhcgames")) { - ores.add(block); - - for (Block neighbour : UtilBlock.getSurrounding(block, true)) + CoreClient client = getArcadeManager().GetClients().Get(event.getPlayer()); + if (client.GetRank().has(Rank.DEVELOPER)) { - findOreFromBlock(ores, neighbour); + event.getPlayer().sendMessage("Games run: " + _gamesRun); + event.setCancelled(true); } } } - - public boolean isOre(Block block) - { - return (block.getType() == Material.IRON_ORE || block.getType() == Material.GOLD_ORE || block.getType() == Material.DIAMOND_ORE); - } - - private ArrayList> generateVeins(ArrayList ores) - { - ArrayList> veins = new ArrayList>(); - - while (!ores.isEmpty()) - { - Block block = ores.remove(0); - - if (xrayDebug) - System.out.println("NEW VEIN - " + block.getType()); - - // Start New Vein - ArrayList vein = new ArrayList(); - veins.add(vein); - vein.add(block); - - // Find Vein Ores - boolean addedToVein = true; - while (addedToVein) - { - addedToVein = false; - - Iterator oreIterator = ores.iterator(); - - while (oreIterator.hasNext()) - { - Block ore = oreIterator.next(); - - boolean inVein = false; - - // Check if in Vein - for (Block veinOre : vein) - { - // if (veinOre.getType() != ore.getType()) - // continue; - - if (UtilMath.offset(ore.getLocation(), veinOre.getLocation()) <= 2) - { - inVein = true; - break; - } - } - - // Add to Vein - if (inVein) - { - vein.add(ore); - oreIterator.remove(); - addedToVein = true; - } - } - } - - if (xrayDebug) - for (Block veinOre : vein) - System.out.println(UtilWorld.locToStrClean(veinOre.getLocation())); - } - - return veins; - } - - private void removeNonAirVeins(ArrayList> oreVeins) - { - // Remove Non-Aired Veins - for (ArrayList vein : oreVeins) - { - boolean visible = false; - - // Check if Air is near Vein - for (Block ore : vein) - { - for (Block visibleCheckBlock : UtilBlock.getSurrounding(ore, true)) - { - if (visibleCheckBlock.getType() == Material.AIR || UtilBlock.isVisible(visibleCheckBlock)) - { - visible = true; - } - - if (visible) - break; - } - - if (visible) - break; - } - - if (visible) - setOreType(vein); - - // Remove Vein - if (!visible) - { - if (xrayDebug) - System.out.println("DELETING VEIN;"); - - for (Block ore : vein) - { - if (xrayDebug) - System.out.println(ore.getType() + " " + UtilWorld.locToStrClean(ore.getLocation())); - - ore.setType(Material.STONE); - } - } - else - { - if (xrayDebug) - System.out.println("VALID VEIN!"); - } - } - } - - public void setOreType(ArrayList blocks) - { - - } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/modes/CutClean.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/modes/CutClean.java index fba15e38a..9cce1ec01 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/modes/CutClean.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/modes/CutClean.java @@ -1,112 +1,63 @@ package nautilus.game.arcade.game.games.uhc.modes; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.games.uhc.UHC; +import nautilus.game.arcade.game.modules.CutCleanModule; +import nautilus.game.arcade.game.modules.ItemGiverModule; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; -/** - * CutClean gamemode for UHC +/* + * The CutClean variant of UHC * - * @author xXVevzZXx + * This is identical to UHC however iron and gold ore will immediately smelt + * and mob drops will be immediately cooked */ public class CutClean extends UHC { - - private int _steakAmount; - - private HashMap _oreDrops; - private HashMap _drops; + // The amount of steak to give at the start of the game + private static final int STEAK_AMOUNT = 15; public CutClean(ArcadeManager manager) { super(manager, GameType.Brawl); - _steakAmount = 15; + registerModule(new CutCleanModule() + .associateBlockDrop( + Material.GOLD_ORE, + new ItemBuilder(Material.GOLD_INGOT).build() + ) + .associateBlockDrop( + Material.IRON_ORE, + new ItemBuilder(Material.IRON_INGOT).build() + ) + .associateMobDrop( + Material.RAW_BEEF, + new ItemBuilder(Material.COOKED_BEEF).build() + ) + .associateMobDrop( + Material.RAW_CHICKEN, + new ItemBuilder(Material.COOKED_CHICKEN).build() + ) + .associateMobDrop( + Material.RAW_FISH, + new ItemBuilder(Material.COOKED_FISH).build() + ) + .associateMobDrop( + Material.PORK, + new ItemBuilder(Material.GRILLED_PORK).build() + ) + .associateMobDrop( + Material.RABBIT, + new ItemBuilder(Material.COOKED_RABBIT).build() + ) + ); - _oreDrops = new HashMap<>(); - _oreDrops.put(Material.GOLD_ORE, Material.GOLD_INGOT); - _oreDrops.put(Material.IRON_ORE, Material.IRON_INGOT); - - _drops = new HashMap<>(); - _drops.put(Material.RAW_BEEF, Material.COOKED_BEEF); - _drops.put(Material.RAW_CHICKEN, Material.COOKED_CHICKEN); - _drops.put(Material.RAW_FISH, Material.COOKED_FISH); - _drops.put(Material.PORK, Material.GRILLED_PORK); - _drops.put(Material.RABBIT, Material.COOKED_RABBIT); - } - - @EventHandler - public void giveSteak(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - return; - - for (Player player : GetPlayers(true)) - { - UtilInv.insert(player, - ItemStackFactory.Instance.CreateStack(Material.COOKED_BEEF, _steakAmount)); - } - } - - @EventHandler - public void smeltOres(BlockBreakEvent event) - { - for (Material mat : _oreDrops.keySet()) - { - if (event.getBlock().getType() == mat) - { - event.setCancelled(true); - event.getBlock().setType(Material.AIR); - - Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() - { - @Override - public void run() - { - event.getBlock().getWorld().dropItem( - event.getBlock().getLocation().add(0.5, 0.2, 0.5), - new ItemStack(_oreDrops.get(mat))); - - } - }, 1); - } - } - } - - @EventHandler - public void smeltFood(EntityDeathEvent event) - { - List drops = event.getDrops(); - for (Material mat : _drops.keySet()) - { - Iterator itemIterator = drops.iterator(); - while (itemIterator.hasNext()) - { - ItemStack item = itemIterator.next(); - if (item.getType() == mat) - { - itemIterator.remove(); - drops.add(ItemStackFactory.Instance.CreateStack(_drops.get(mat), - 1 + UtilMath.r(3))); - } - } - } + registerModule(new ItemGiverModule() + .withItem(new ItemStack(Material.COOKED_BEEF, STEAK_AMOUNT)) + ); } @Override @@ -114,5 +65,4 @@ public class CutClean extends UHC { return "Cut Clean"; } - } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/modes/GodBattles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/modes/GodBattles.java index ebf7d5d43..12b6906a9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/modes/GodBattles.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/modes/GodBattles.java @@ -1,103 +1,74 @@ package nautilus.game.arcade.game.games.uhc.modes; -import java.util.ArrayList; -import java.util.HashMap; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.inventory.ItemStack; - +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; +import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.games.uhc.UHC; +import nautilus.game.arcade.game.modules.CutCleanModule; +import nautilus.game.arcade.game.modules.ItemGiverModule; +import nautilus.game.arcade.game.modules.OreVeinEditorModule; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.inventory.ItemStack; + +import java.util.List; +import java.util.Set; /** * GodBattles gamemode for UHC - * - * @author xXVevzZXx */ public class GodBattles extends UHC { + // The set of materials which will be considered as an ore + private static final Set ORE_MATERIALS = Sets.newHashSet( + Material.COAL_ORE, + Material.REDSTONE_ORE, + Material.IRON_ORE, + Material.GOLD_ORE, + Material.DIAMOND_ORE + ); - private ArrayList _ores; - private HashMap _oreDrops; + // The set of materials which will act as replacements + private static final List ORE_REPLACEMENTS = Lists.newArrayList( + Material.GOLD_ORE, + Material.DIAMOND_ORE + ); public GodBattles(ArcadeManager manager) { super(manager, GameType.Brawl); - _ores = new ArrayList<>(); + registerModule(new CutCleanModule() + .associateBlockDrop( + Material.GOLD_ORE, + new ItemBuilder(Material.GOLD_BLOCK).build() + ) + ); - _ores.add(Material.GOLD_ORE); - _ores.add(Material.DIAMOND_ORE); + registerModule(new ItemGiverModule() + .withItem(UtilItem.makeUnbreakable(new ItemStack(Material.DIAMOND_PICKAXE))) + ); - _oreDrops = new HashMap<>(); - _oreDrops.put(Material.GOLD_ORE, Material.GOLD_BLOCK); - } - - @EventHandler - public void blockOres(BlockBreakEvent event) - { - for (Material mat : _oreDrops.keySet()) - { - if (event.getBlock().getType() == mat) - { - event.setCancelled(true); - event.getBlock().setType(Material.AIR); - - Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() + registerModule(new OreVeinEditorModule() + .useFilter(block -> ORE_MATERIALS.contains(block.getType())) + .useEditor(vein -> { - @Override - public void run() + Material ore = ORE_REPLACEMENTS.get(UtilMath.r(ORE_REPLACEMENTS.size())); + for (Block block : vein) { - event.getBlock().getWorld().dropItem( - event.getBlock().getLocation().add(0.5, 0.2, 0.5), - new ItemStack(_oreDrops.get(mat))); - + if(!ORE_REPLACEMENTS.contains(block.getType())) + { + if(!UtilBlock.isVisible(block)) + block.setType(ore); + } } - }, 1); - } - } - } - - @EventHandler - public void givePickaxe(GameStateChangeEvent event) - { - if(event.GetState() != GameState.Live) - return; - - for (Player player : GetPlayers(true)) - { - player.getInventory().addItem(UtilItem.makeUnbreakable(new ItemStack(Material.DIAMOND_PICKAXE))); - } - } - - @Override - public void setOreType(ArrayList blocks) - { - Material ore = _ores.get(UtilMath.r(_ores.size())); - for (Block block : blocks) - { - if(block.getType() != Material.DIAMOND_ORE && block.getType() != Material.GOLD_ORE) - { - if(!UtilBlock.isVisible(block)) - block.setType(ore); - } - } - } - - @Override - public boolean isOre(Block block) - { - return (block.getType() == Material.COAL_ORE || block.getType() == Material.REDSTONE_ORE || block.getType() == Material.IRON_ORE || block.getType() == Material.GOLD_ORE || block.getType() == Material.DIAMOND_ORE); + }) + ); } @Override @@ -105,5 +76,4 @@ public class GodBattles extends UHC { return "God Battles"; } - } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java index 18a6494aa..6ab2f5018 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.wizards; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -50,11 +51,11 @@ import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickBlock; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickEntity; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.chat.ChatStatData; import net.minecraft.server.v1_8_R3.EntityFireball; import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; +import nautilus.game.arcade.managers.chat.ChatStatData; import org.apache.commons.lang.IllegalClassException; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -735,7 +736,7 @@ public class Wizards extends SoloGame done++; } } - + private void displayProgress(String progressColor, String prefix, double amount, String suffix, Player... players) { // Generate Bar @@ -862,7 +863,7 @@ public class Wizards extends SoloGame return items; } - + private void dropSpells(Player player) { HashSet spells = new HashSet(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CutCleanModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CutCleanModule.java new file mode 100644 index 000000000..84e4f3a50 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CutCleanModule.java @@ -0,0 +1,107 @@ +package nautilus.game.arcade.game.modules; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.EnumMap; +import java.util.Iterator; +import java.util.List; + +/* + * This module will implement CutClean-esque features within the game. + * + * In particular, the CutCleanModule#associateBlockDrop and CutCleanModule#associateMobDrop methods will + * allow you to drop different items for each block and mob killed + */ +public class CutCleanModule extends Module +{ + private final EnumMap> _blockDrops = new EnumMap<>(Material.class); + private final EnumMap> _mobDrops = new EnumMap<>(Material.class); + + /* + * Associates a material with a list of drops. + * + * Every time a block of that material is broken, the drops given will be dropped instead + * + * fixme does not support data ids + */ + public CutCleanModule associateBlockDrop(Material block, ItemStack... drops) + { + if (_blockDrops.containsKey(block)) + { + throw new IllegalStateException(block + " is already registered to " + _blockDrops.get(block)); + } + _blockDrops.put(block, new ArrayList<>(Arrays.asList(drops))); + return this; + } + + /* + * Associates a mob drop with a list of different drops + * + * Every time an item of the given type is dropped by a mob death, the alternative drops will be dropped instead + */ + public CutCleanModule associateMobDrop(Material drop, ItemStack... drops) + { + if (_mobDrops.containsKey(drop)) + { + throw new IllegalStateException(drop + " is already registered to " + _mobDrops.get(drop)); + } + _mobDrops.put(drop, new ArrayList<>(Arrays.asList(drops))); + return this; + } + + @EventHandler + public void on(BlockBreakEvent event) + { + List drops = _blockDrops.get(event.getBlock().getType()); + if (drops == null) + { + return; + } + + event.getBlock().setType(Material.AIR); + + getGame().getArcadeManager().getScheduler().runTaskLater(getGame().getArcadeManager().getPlugin(), () -> + { + Location dropLocation = event.getBlock().getLocation().add(0.5, 0.2, 0.5); + for (ItemStack drop : drops) + { + event.getBlock().getWorld().dropItem(dropLocation, drop.clone()); + } + }, 1L); + } + + @EventHandler + public void on(EntityDeathEvent event) + { + List drops = event.getDrops(); + List newDrops = new ArrayList<>(); + + Iterator itemIterator = drops.iterator(); + while (itemIterator.hasNext()) + { + ItemStack item = itemIterator.next(); + + List replacements = _mobDrops.get(item.getType()); + if (replacements == null) + { + continue; + } + + itemIterator.remove(); + + for (ItemStack replace : replacements) + { + newDrops.add(replace.clone()); + } + } + + drops.addAll(newDrops); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/ItemGiverModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/ItemGiverModule.java new file mode 100644 index 000000000..08130e94c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/ItemGiverModule.java @@ -0,0 +1,55 @@ +package nautilus.game.arcade.game.modules; + +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +/* + * This module will give all players specific items at the start of the game + */ +public class ItemGiverModule extends Module +{ + private final List _itemsToGive = new ArrayList<>(); + + public ItemGiverModule withItem(ItemStack item) + { + _itemsToGive.add(item.clone()); + return this; + } + + public ItemGiverModule withItems(ItemStack... items) + { + List clones = new ArrayList<>(); + for (ItemStack item : items) + { + clones.add(item.clone()); + } + + _itemsToGive.addAll(clones); + return this; + } + + + @EventHandler + public void on(GameStateChangeEvent event) + { + if(event.GetState() != Game.GameState.Live) + return; + + for (Player player : getGame().GetPlayers(true)) + { + for (ItemStack toGive : _itemsToGive) + { + UtilInv.insert(player, toGive.clone()); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/Module.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/Module.java index 0279e0da6..bff9ae688 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/Module.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/Module.java @@ -1,13 +1,34 @@ package nautilus.game.arcade.game.modules; +import com.google.gson.JsonElement; import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.TeamGame; import org.bukkit.event.Listener; +/* + * This is a Module + * + * A Module represents something which will enhance or change the way games can be played. + * Modules should function independent of which specific gamemode is being played. + * If you need game-specific features, put it into that Game implementation or refactor it into a separate class (not a module). + * + * Modules should never directly access other Modules via the Game instance. + * Instead, the game which requires cross-contamination should do so itself. + * + * Modules should be associated per-game. Do not make them static + * + * If your module is able to accept custom configuration, override the configure(JsonElement) method + * You can define the format of the json you wish to use. + * This custom configuration will be used to dynamically adjust gamemodes via Redis if needed + */ public abstract class Module implements Listener { // The game this module belongs to private Game _game; + /* + * Initializes this module with the specific game instance. You should never do this as {@link Game} does it for you + */ public void initialize(Game game) { if (_game != null) @@ -15,13 +36,47 @@ public abstract class Module implements Listener throw new IllegalArgumentException("Attempting to initialize module which has already been initialized for " + _game); } this._game = game; + this.setup(); } + /* + * This method is called once initialization is complete. Do whatever you need to do with the {@link Game} here + */ + protected void setup() + { + + } + + /* + * If this module can be configured via a JsonObject/JsonPrimitive, then override this method + * to implement that feature + * + * You can define how the JsonElement should be formatted. + * + * It is recommended to have a "force" boolean which will reset this module to a clean state + * (to allow extensive customization using json) + */ + public void configure(JsonElement element) + { + + } + + /* + * This method is called once this module is no longer needed. + * This could be because the game is over + * Or because this module was unregistered + * + * The {@link Game} will unregister this module as a listener for you. + * All you need to do is clean up after yourself + */ public void cleanup() { } + /* + * Gets the game this module is associated with + */ public Game getGame() { return this._game; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/OreVeinEditorModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/OreVeinEditorModule.java new file mode 100644 index 000000000..a7582e28f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/OreVeinEditorModule.java @@ -0,0 +1,219 @@ +package nautilus.game.arcade.game.modules; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.timing.TimingManager; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Predicate; + +/* + * This module will allow you to edit veins of ore live as players break them + */ +public class OreVeinEditorModule extends Module +{ + // Initial range to look for veins + // For example, if I break a block at 0,0,0 and RANGE is 3 + // Then this module will look for ores in the region of -3,-3,-3 to 3,3,3 + private static final int RANGE = 3; + + private boolean _debug = false; + private boolean _removeNonAirVeins = false; + + private Predicate _predicateIsOre = block -> + (block.getType() == Material.IRON_ORE || block.getType() == Material.GOLD_ORE || block.getType() == Material.DIAMOND_ORE); + + private Consumer> _consumerOreEditor = list -> + { + + }; + + public OreVeinEditorModule debug() + { + this._debug = true; + return this; + } + + public OreVeinEditorModule removeNonAirVeins() + { + this._removeNonAirVeins = true; + return this; + } + + public OreVeinEditorModule useFilter(Predicate filter) + { + this._predicateIsOre = filter; + return this; + } + + public OreVeinEditorModule useEditor(Consumer> editor) + { + this._consumerOreEditor = editor; + return this; + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void on(BlockBreakEvent event) + { + if (_debug) + TimingManager.start("Block Break"); + + // Find Nearby Ores + List ores = findOres(event.getBlock(), RANGE); + + // Anti-Xray + removeNonAirVeins(generateVeins(ores)); + + if (_debug) + TimingManager.stop("Block Break"); + } + + // Searches in a range x range x range cube for ores + private List findOres(Block source, int range) + { + List ores = new ArrayList<>(); + + for (int x = -range; x <= range; x++) + for (int z = -range; z <= range; z++) + for (int y = -range; y <= range; y++) + findOreFromBlock(ores, source.getRelative(x, y, z)); + + if (_debug) + for (Block debug : ores) + System.out.println("Found " + debug.getType() + " at " + UtilWorld.locToStrClean(debug.getLocation())); + + return ores; + } + + // Checks if the current block is ore + // If so, then search all blocks around it to see if they are ores + private void findOreFromBlock(List ores, Block block) + { + if (ores.contains(block)) + return; + + if (_predicateIsOre.test(block)) + { + ores.add(block); + + for (Block neighbour : UtilBlock.getSurrounding(block, true)) + { + findOreFromBlock(ores, neighbour); + } + } + } + + private List> generateVeins(List ores) + { + List> veins = new ArrayList<>(); + + while (!ores.isEmpty()) + { + Block block = ores.remove(0); + + if (_debug) + System.out.println("NEW VEIN - " + block.getType()); + + // Start New Vein + List vein = new ArrayList<>(); + veins.add(vein); + + vein.add(block); + + // Find Vein Ores + boolean addedToVein = true; + while (addedToVein) + { + addedToVein = false; + + Iterator oreIterator = ores.iterator(); + + while (oreIterator.hasNext()) + { + Block ore = oreIterator.next(); + + boolean inVein = false; + + // Check if in Vein + // fixme is this a good algorithm? + for (Block veinOre : vein) + { + if (UtilMath.offset(ore.getLocation(), veinOre.getLocation()) <= 2) + { + inVein = true; + break; + } + } + + // Add to Vein + if (inVein) + { + vein.add(ore); + oreIterator.remove(); + addedToVein = true; + } + } + } + + if (_debug) + for (Block veinOre : vein) + System.out.println(UtilWorld.locToStrClean(veinOre.getLocation())); + } + + return veins; + } + + private void removeNonAirVeins(List> oreVeins) + { + // Remove Non-Aired Veins + for (List vein : oreVeins) + { + boolean visible = false; + + // Check if Air is near Vein + outer: for (Block ore : vein) + { + for (Block visibleCheckBlock : UtilBlock.getSurrounding(ore, true)) + { + if (visibleCheckBlock.getType() == Material.AIR || UtilBlock.isVisible(visibleCheckBlock)) + { + visible = true; + break outer; + } + } + } + + if (visible) + _consumerOreEditor.accept(vein); + + // Remove Vein + if (!visible && _removeNonAirVeins) + { + if (_debug) + System.out.println("DELETING VEIN;"); + + for (Block ore : vein) + { + if (_debug) + System.out.println(ore.getType() + " " + UtilWorld.locToStrClean(ore.getLocation())); + + ore.setType(Material.STONE); + } + } + else + { + if (_debug) + System.out.println("VALID VEIN!"); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamModule.java index 60fb19d7d..38e54b55e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamModule.java @@ -1,7 +1,5 @@ package nautilus.game.arcade.game.modules; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; @@ -14,11 +12,14 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerQuitEvent; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; import java.util.UUID; public class TeamModule extends Module { - private BiMap _teamReqs = HashBiMap.create(); + private Map _teamReqs = new HashMap<>(); @EventHandler(priority = EventPriority.HIGH) public void teamSelectInteract(PlayerInteractEntityEvent event) @@ -147,8 +148,15 @@ public class TeamModule extends Module if (getGame().GetTeam(player) != null) getGame().GetTeam(player).DisbandTeam(); - _teamReqs.remove(player.getUniqueId()); - _teamReqs.inverse().remove(player.getUniqueId()); + Iterator> iterator = _teamReqs.entrySet().iterator(); + while (iterator.hasNext()) + { + Map.Entry entry = iterator.next(); + if (entry.getKey().equals(player.getUniqueId()) || entry.getValue().equals(player.getUniqueId())) + { + iterator.remove(); + } + } } private GameTeam getEmptyTeam() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayModule.java new file mode 100644 index 000000000..216cf8355 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayModule.java @@ -0,0 +1,111 @@ +package nautilus.game.arcade.game.modules.antixray; + +import mineplex.core.common.util.UtilServer; +import nautilus.game.arcade.game.modules.Module; +import org.bukkit.Material; +import org.bukkit.plugin.RegisteredServiceProvider; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +/* + * This module will enable antixray for this specific game + * + * NOTE: The game server must also have the Mineplex Orebfuscator plugin installed + */ +public class AntiXrayModule extends Module +{ + private AntiXrayService _service; + + @Override + protected void setup() + { + RegisteredServiceProvider rsp = UtilServer.getServer().getServicesManager().getRegistration(AntiXrayService.class); + if (rsp == null) + { + getGame().unregisterModule(this); + System.out.println("!!!ERROR!!! AntiXray module was registered but the Mineplex Orebfuscator Service was not registered"); + return; + } + AntiXrayService service = rsp.getProvider(); + if (service == null) + { + getGame().unregisterModule(this); + System.out.println("!!!ERROR!!! AntiXray module was registered but the Mineplex Orebfuscator Service was null"); + return; + } + _service = service; + } + + @Override + public void cleanup() + { + _service.setEnabled(false); + } + + public AntiXrayModule setEnabled(boolean enabled) + { + _service.setEnabled(enabled); + return this; + } + + public AntiXrayModule setUpdateOnDamage(boolean updateOnDamage) + { + _service.setUpdateOnDamage(updateOnDamage); + return this; + } + + public AntiXrayModule setEngineMode(int engineMode) + { + _service.setEngineMode(engineMode); + return this; + } + + public AntiXrayModule setInitialRadius(int initialRadius) + { + _service.setInitialRadius(initialRadius); + return this; + } + + public AntiXrayModule setUpdateRadius(int updateRadius) + { + _service.setUpdateRadius(updateRadius); + return this; + } + + public AntiXrayModule setUseProximityHider(boolean useProximityHider) + { + _service.setUseProximityHider(useProximityHider); + return this; + } + + public AntiXrayModule setAntiTexturePacksAndFreecam(boolean antiTexturePacksAndFreecam) + { + _service.setAntiTexturePacksAndFreecam(antiTexturePacksAndFreecam); + return this; + } + + public AntiXrayModule setObfuscateBlocks(Material... materials) + { + return setObfuscateBlocks(Arrays.asList(materials)); + } + + public AntiXrayModule setObfuscateBlocks(List materials) + { + _service.setObfuscateBlocks(materials); + return this; + } + + public AntiXrayModule setRandomBlocks(Material... materials) + { + return setRandomBlocks(Arrays.asList(materials)); + } + + public AntiXrayModule setRandomBlocks(List materials) + { + _service.setRandomBlocks(materials); + return this; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayService.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayService.java new file mode 100644 index 000000000..9c1619bbf --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/antixray/AntiXrayService.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.modules.antixray; + +import org.bukkit.Material; + +import java.util.Arrays; +import java.util.List; + +public interface AntiXrayService +{ + void setEnabled(boolean enabled); + + void setUpdateOnDamage(boolean updateOnDamage); + + void setEngineMode(int engineMode); + + void setInitialRadius(int initialRadius); + + void setUpdateRadius(int updateRadius); + + void setUseProximityHider(boolean useProximityHider); + + void setAntiTexturePacksAndFreecam(boolean antiTexturePacksAndFreecam); + + void setObfuscateBlocks(List materials); + + void setRandomBlocks(List materials); +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java new file mode 100644 index 000000000..25b2d3b73 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogModule.java @@ -0,0 +1,339 @@ +package nautilus.game.arcade.game.modules.combatlog; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilParser; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.modules.Module; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.world.ChunkUnloadEvent; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.UUID; +import java.util.function.Consumer; + +/* + * This module will spawn combat log NPCs for players who disconnect + */ +public class CombatLogModule extends Module +{ + // The map of player UUIDs to their combat log NPCs + private Map _logoutNpcs = new HashMap<>(); + + // The map of player UUIDs and who killed their combat logged NPC + private Map _killedBy = new HashMap<>(); + + // The time that combat log npcs will stay spawned for, in milliseconds + private int _spawnTime = 60000; + // Whether to notify the combat logged player on join if they have been killed + private boolean _notifyPlayer = true; + // Whether to spawn a combat log NPC for creative players + private boolean _spawnForCreative = true; + // The action to take once a combat logged NPC has died + private Consumer _onKill = npc -> + { + + }; + // The action to take once a combat logged NPC has expired + private Consumer _onExpire = npc -> + { + + }; + + private int _locationTaskId = -1; + + protected void setup() + { + _locationTaskId = Bukkit.getScheduler().runTaskTimer(getGame().getArcadeManager().getPlugin(), () -> + { + for (CombatLogNPC npc : _logoutNpcs.values()) + { + getGame().GetLocationStore().put(npc.getPlayerInfo().getName(), npc.getNPC().getLocation()); + } + }, 0L, 1L).getTaskId(); + } + + public CombatLogModule setNotifyPlayer(boolean notifyPlayer) + { + this._notifyPlayer = notifyPlayer; + return this; + } + + public CombatLogModule setSpawnForCreative(boolean spawnForCreative) + { + this._spawnForCreative = spawnForCreative; + return this; + } + + public CombatLogModule setOnDeathAction(Consumer action) + { + this._onKill = action; + return this; + } + + public CombatLogModule setOnExpireAction(Consumer action) + { + this._onExpire = action; + return this; + } + + public CombatLogModule setCombatLogTime(int time) + { + this._spawnTime = time; + return this; + } + + /* + * Spawns a combat log NPC for the given player if that player does not already have one + */ + public void spawnLogoutNpc(Player player) + { + if (hasLogoutNpc(player)) + return; + if (player.getGameMode() == GameMode.CREATIVE && !_spawnForCreative) + return; + + CombatLogNPC npc = new CombatLogNPC(this, player, getGame().getArcadeManager()); + npc.spawn(); + _logoutNpcs.put(player.getUniqueId(), npc); + System.out.println(String.format("Spawned combat log NPC for %s!", player.getName())); + } + + public boolean hasLogoutNpc(Player player) + { + return _logoutNpcs.containsKey(player.getUniqueId()); + } + + public CombatLogNPC getLogoutNpc(Player player) + { + return _logoutNpcs.get(player.getUniqueId()); + } + + public void despawnLogoutNpc(Player player) + { + CombatLogNPC npc = getLogoutNpc(player); + + if (npc != null) + { + npc.despawn(); + _logoutNpcs.remove(player.getUniqueId()); + System.out.println(String.format("Despawned combat log NPC for %s!", player.getName())); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void on(PlayerQuitEvent event) + { + if (getGame().InProgress() && getGame().IsAlive(event.getPlayer())) + { + spawnLogoutNpc(event.getPlayer()); + } + } + + @EventHandler + public void on(PlayerJoinEvent event) + { + if (hasLogoutNpc(event.getPlayer())) + { + despawnLogoutNpc(event.getPlayer()); + } + + if (_killedBy.containsKey(event.getPlayer().getUniqueId())) + { + String name = _killedBy.remove(event.getPlayer().getUniqueId()); + if (_notifyPlayer && name != null) + { + UtilPlayer.message(event.getPlayer(), F.main("Combat Log", "While you were gone, you were killed by " + ChatColor.GREEN + name + C.mBody + ".")); + } + } + } + + @Override + public void cleanup() + { + System.out.println("Killing combat log NPCs"); + + for (CombatLogNPC npc : _logoutNpcs.values()) + { + npc.despawn(); + } + + _logoutNpcs.clear(); + _killedBy.clear(); + } + + @EventHandler + public void onChunkUnload(ChunkUnloadEvent event) + { + for (CombatLogNPC npc : _logoutNpcs.values()) + { + if (npc.getNPC().getLocation().getChunk().equals(event.getChunk())) + { + event.setCancelled(true); + return; + } + } + } + + @EventHandler(ignoreCancelled = true) + public void onEntityDeath(EntityDeathEvent event) + { + CombatLogNPC logoutNpc = getLogoutNpc(event.getEntity()); + + if (logoutNpc == null) + return; + + _onKill.accept(logoutNpc); + logoutNpc.onDeath(); + event.getDrops().clear(); // Clear the entity's item drops. If drops are wanted they can be added + + if (logoutNpc.getLastDamager() != null) + { + _killedBy.put(logoutNpc.getPlayerInfo().getUniqueId(), logoutNpc.getLastDamager().getName()); + } + else + { + _killedBy.put(logoutNpc.getPlayerInfo().getUniqueId(), UtilParser.parseDamageCause(logoutNpc.getLastDamageCause())); + } + + + if (getGame() instanceof TeamGame) + { + TeamGame teamGame = (TeamGame) getGame(); + teamGame.RejoinTimes.remove(logoutNpc.getPlayerInfo().getName()); + teamGame.RejoinKit.remove(logoutNpc.getPlayerInfo().getName()); + teamGame.RejoinTeam.remove(logoutNpc.getPlayerInfo().getName()); + teamGame.RejoinHealth.remove(logoutNpc.getPlayerInfo().getName()); + } + } + + @EventHandler(ignoreCancelled = true) + public void onEntityDamaged(EntityDamageEvent event) + { + CombatLogNPC logoutNpc = getLogoutNpc(event.getEntity()); + + if (logoutNpc != null) + { + LivingEntity damager = UtilEvent.GetDamagerEntity(event, true); + + Player damagerPlayer = null; + if (damager instanceof Player) + { + damagerPlayer = (Player) damager; + } + + if (getGame() instanceof TeamGame && damagerPlayer != null) + { + GameTeam damagerTeam = getGame().GetTeam(damagerPlayer); + if (damagerTeam == logoutNpc.getPlayerInfo().getTeam()) + { + event.setCancelled(true); + return; + } + } + + logoutNpc.getNPC().getWorld().playSound(logoutNpc.getNPC().getLocation(), Sound.HURT_FLESH, 1, 1); + + if (getGame() instanceof TeamGame) + { + getGame().getArcadeManager().runSync(() -> + { + ((TeamGame) getGame()).RejoinHealth.put(logoutNpc.getPlayerInfo().getName(), logoutNpc.getNPC().getHealth()); + }); + } + + logoutNpc.handleDamageEvent(event); + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.FASTER) + { + for (CombatLogNPC npc : _logoutNpcs.values()) + { + npc.update(); + } + } + + if (event.getType() == UpdateType.SEC) + { + Iterator iterator = _logoutNpcs.values().iterator(); + + while (iterator.hasNext()) + { + CombatLogNPC npc = iterator.next(); + + if (Bukkit.getPlayerExact(npc.getPlayerInfo().getName()) != null) + { + System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 1"); + npc.despawn(); + iterator.remove(); + } + else if (!npc.isAlive()) + { + System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 2"); + npc.remove(); + iterator.remove(); + } + else if (npc.getAliveDuation() > this._spawnTime) + { + System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 3"); + _onExpire.accept(npc); + npc.despawn(); + iterator.remove(); + } + } + } + } + + private CombatLogNPC getLogoutNpc(Entity entity) + { + return getLogoutNpc(entity.getEntityId()); + } + + private CombatLogNPC getLogoutNpc(int entityId) + { + for (CombatLogNPC npc : _logoutNpcs.values()) + { + if (npc.getNPC().getEntityId() == entityId) + { + return npc; + } + } + + return null; + } + + public int getSpawnTime() + { + return _spawnTime; + } + + public Collection getAllNPCs() + { + return _logoutNpcs.values(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogNPC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogNPC.java new file mode 100644 index 000000000..66c7eac4c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/CombatLogNPC.java @@ -0,0 +1,183 @@ +package nautilus.game.arcade.game.modules.combatlog; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.hologram.Hologram; +import nautilus.game.arcade.ArcadeManager; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; + +public class CombatLogNPC +{ + private CombatLogModule _module; + + private PlayerInfo _playerInfo; + + private Hologram _hologram; + + private DisguiseManager _disguiseManager; + private long _spawnDate; + private final long _endingTime; + private double _spawnHealth; + private double _maxHealth; + + private LivingEntity _npc; + + private EntityDamageEvent.DamageCause _lastDamageCause; + private Entity _lastDamager; + + public CombatLogNPC(CombatLogModule module, Player player, ArcadeManager arcadeManager) + { + this._module = module; + + _playerInfo = new PlayerInfo(player, arcadeManager); + + _endingTime = System.currentTimeMillis() + this._module.getSpawnTime(); + + _disguiseManager = arcadeManager.GetDisguise(); + _hologram = new Hologram(arcadeManager.getHologramManager(), player.getEyeLocation().add(0, 1, 0), "Quitting in " + UtilTime.MakeStr(Math.max(_endingTime - System.currentTimeMillis(), 0))); + _spawnDate = 0; + _spawnHealth = player.getHealth(); + _maxHealth = player.getMaxHealth(); + _hologram.start(); + } + + /** + * Called when the {@code _npc} associated with this CombatLogNPC is killed + * and thus drops all the owner's items. + */ + public void onDeath() + { + _disguiseManager.undisguise(_npc); + } + + public void update() + { + _hologram.setText("Quitting in " + UtilTime.MakeStr(Math.max(_endingTime - System.currentTimeMillis(), 0))); + if (_npc != null) + { + _hologram.setLocation(_npc.getEyeLocation().add(0, 1, 0)); + } + } + + /** + * @return true, if the {@code _npc} associated with this CombatLogNPC is + * alive, false otherwise. + */ + public boolean isAlive() + { + return _npc != null && !_npc.isDead(); + } + + /** + * @return the amount of time (in milliseconds) that this npc has been alive + * an spawned in. + */ + public long getAliveDuation() + { + return System.currentTimeMillis() - _spawnDate; + } + + public void spawn() + { + if (_npc != null) despawn(); + + _npc = spawnNpc(getPlayer()); + _spawnDate = System.currentTimeMillis(); + } + + public void despawn() + { + if (_npc != null) + { + _npc.remove(); + _npc = null; + _hologram.stop(); + _hologram = null; + } + } + + public void remove() + { + _hologram.stop(); + _hologram = null; + } + + public PlayerInfo getPlayerInfo() + { + return _playerInfo; + } + + public Player getPlayer() + { + return _playerInfo.getPlayer(); + } + + private LivingEntity spawnNpc(Player player) + { + Location spawnLoc = player.getLocation(); + LivingEntity skel = player.getWorld().spawn(spawnLoc, Creeper.class); + skel.setRemoveWhenFarAway(false); + skel.setMetadata("CombatLogNPC", new FixedMetadataValue(_disguiseManager.getPlugin(), player.getUniqueId().toString())); + skel.teleport(spawnLoc); + skel.setMaxHealth(_maxHealth); + skel.setHealth(_spawnHealth); + skel.setFallDistance(player.getFallDistance()); + // fixme potion effects, mobs don't target, entity collision (setting to ghost disables arrows and fishing rods), logging while sleeping + // best solution to spawn EntityPlayer? + UtilEnt.Vegetate(skel); + UtilEnt.silence(skel, true); + + skel.getEquipment().setHelmet(player.getInventory().getHelmet()); + skel.getEquipment().setChestplate(player.getInventory().getChestplate()); + skel.getEquipment().setLeggings(player.getInventory().getLeggings()); + skel.getEquipment().setBoots(player.getInventory().getBoots()); + skel.getEquipment().setItemInHand(player.getItemInHand()); + + // Disguise + DisguisePlayer disguise = new DisguisePlayer(skel, ((CraftPlayer) player).getHandle().getProfile()); + _disguiseManager.disguise(disguise); + + return skel; + } + + public Entity getLastDamager() + { + return _lastDamager; + } + + public LivingEntity getNPC() + { + return this._npc; + } + + public void handleDamageEvent(EntityDamageEvent event) + { + this._lastDamageCause = event.getCause(); + if (event instanceof EntityDamageByEntityEvent) + { + EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) event; + this._lastDamager = entityDamageByEntityEvent.getDamager(); + } + else + { + this._lastDamager = null; + } + } + + public EntityDamageEvent.DamageCause getLastDamageCause() + { + return _lastDamageCause; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/PlayerInfo.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/PlayerInfo.java new file mode 100644 index 000000000..1a1405145 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combatlog/PlayerInfo.java @@ -0,0 +1,69 @@ +package nautilus.game.arcade.game.modules.combatlog; + +import mineplex.core.common.util.UtilInv; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +public class PlayerInfo +{ + private String _playerName; + private UUID _playerUuid; + private List _items; + private ChatColor _teamColor = ChatColor.GRAY; + private GameTeam _team; + + public PlayerInfo(Player player, ArcadeManager arcadeManager) + { + _playerName = player.getName(); + _playerUuid = player.getUniqueId(); + _items = UtilInv.getItems(player); + _team = arcadeManager.GetGame().GetTeam(player); + if (_team != null) + { + _teamColor = _team.GetColor(); + } + } + + public String getName() + { + return _playerName; + } + + public UUID getUniqueId() + { + return _playerUuid; + } + + public Player getPlayer() + { + return Bukkit.getPlayerExact(_playerName); + } + + public ChatColor getTeamColor() + { + return _teamColor; + } + + public GameTeam getTeam() + { + return _team; + } + + public List getItems() + { + return this._items; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index c4ef3eaf9..c00b8f81d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -720,7 +720,7 @@ public class GameFlagManager implements Listener player.removePotionEffect(potion.getType()); //Visual -// Manager.GetCondition().Factory().Blind("Ghost", player, player, 2.5, 0, false, false, false); + Manager.GetCondition().Factory().Blind("Ghost", player, player, 2.5, 0, false, false, false); player.setFireTicks(0); player.setFallDistance(0); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java similarity index 88% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java index 23ede3d63..c39b46247 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.managers; import java.lang.reflect.Field; import java.util.HashMap; +import org.bukkit.Bukkit; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; @@ -37,14 +38,17 @@ import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.GemData; import net.minecraft.server.v1_8_R3.EntityHuman; -public class GameGemManager implements Listener +/** + * This class is used to reward gems and shards at the end of a game, or when players leave the server. + */ +public class GameRewardManager implements Listener { ArcadeManager Manager; boolean DoubleGem = false; boolean TimeReward = true; - public GameGemManager(ArcadeManager manager) + public GameRewardManager(ArcadeManager manager) { Manager = manager; @@ -159,18 +163,23 @@ public class GameGemManager implements Listener if (gems == null) return; - int earned = 0; + final int baseGemsEarned; + int gemsToReward; - for (GemData data : gems.values()) - earned += (int)data.Gems; + // Calculate the base gems earned in this game + { + int gemsEarned = 0; - if (earned <= 0) - earned = 1; + for (GemData data : gems.values()) + gemsEarned += (int) data.Gems; - earned = (int) (earned * gameMult); + if (gemsEarned <= 0) + gemsEarned = 1; + + baseGemsEarned = (int) (gemsEarned * gameMult); + gemsToReward = baseGemsEarned; + } - int total = earned; - String oldName = player.getName(); if(Manager.GetClients().Get(player).getDisguisedAs() != null) @@ -179,27 +188,28 @@ public class GameGemManager implements Listener System.out.println("Gems for " + Manager.GetClients().Get(player).GetPlayerName()); } - final int baseShards = total; - int shards = baseShards; + // Award players shards equal to base gems, plus booster bonuses. + final int baseShardsEarned = baseGemsEarned; + int shardsToReward = baseShardsEarned; - //Gem Boooster + // Gem Boooster Booster booster = Manager.getBoosterManager().getActiveBooster(); if (game.GemBoosterEnabled && booster != null) { - shards += baseShards * booster.getMultiplier(); + shardsToReward *= booster.getMultiplier(); } - //Gem Finder + // Gem Finder if (game.GemHunterEnabled) { int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel(); if (gemFinder > 0) { - total += (int)(earned * (gemFinder * 0.25)); + gemsToReward += (int)(baseGemsEarned * (gemFinder * 0.25)); } } - //Time Reward + // Time Reward if (TimeReward) { long timeOnline = Utility.currentTimeMillis() - Manager.GetClients().Get(player).getNetworkSessionLoginTime(); @@ -211,34 +221,34 @@ public class GameGemManager implements Listener if (hoursOnline > 5) hoursOnline = 5; - total += (int)(earned * (hoursOnline * 0.2)); + gemsToReward += (int)(baseGemsEarned * (hoursOnline * 0.2)); } } if (DoubleGem && game.GemDoubleEnabled) - total += earned; + gemsToReward += baseGemsEarned; Rank rank = Manager.GetClients().Get(player).GetRank(); int accountId = Manager.GetClients().getAccountId(player); if (rank == rank.ULTRA) - shards += baseShards * 0.5; + shardsToReward += baseShardsEarned * 0.5; else if (rank == rank.HERO) - shards += baseShards * 1; + shardsToReward += baseShardsEarned * 1; else if (rank == rank.LEGEND) - shards += baseShards * 1.5; + shardsToReward += baseShardsEarned * 1.5; else if (rank.has(Rank.TITAN)) - shards += baseShards * 2; + shardsToReward += baseShardsEarned * 2; - Manager.GetDonation().RewardGems(null, "Earned " + game.GetName(), player.getName(), player.getUniqueId(), total); + Manager.GetDonation().RewardGems(null, "Earned " + game.GetName(), player.getName(), player.getUniqueId(), gemsToReward); if (accountId != -1) { - Manager.GetDonation().rewardCoinsUntilSuccess(null, "Earned", player.getName(), accountId, shards); + Manager.GetDonation().rewardCoinsUntilSuccess(null, "Earned", player.getName(), accountId, shardsToReward); } //Stats - Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", total); - Manager.GetStatsManager().incrementStat(player, game.GetName()+".GemsEarned", total); + Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", gemsToReward); + Manager.GetStatsManager().incrementStat(player, game.GetName()+".GemsEarned", gemsToReward); if(Manager.GetClients().Get(player).getDisguisedAs() != null) { @@ -359,7 +369,7 @@ public class GameGemManager implements Listener totalGems += earnedGems; } - final int baseShards = totalGems; + final int baseShards = earnedGems; int shards = baseShards; double extraMult = 0; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java index defc9f325..8e6088764 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameSpectatorManager.java @@ -1,20 +1,27 @@ package nautilus.game.arcade.managers; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; - +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketInfo; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game.GameState; import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.EntityTracker; +import net.minecraft.server.v1_8_R3.EntityTrackerEntry; import net.minecraft.server.v1_8_R3.NetworkManager; import net.minecraft.server.v1_8_R3.PacketPlayOutCamera; import net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange; import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; import net.minecraft.server.v1_8_R3.WorldSettings; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Entity; @@ -30,41 +37,37 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.event.vehicle.VehicleDamageEvent; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextBottom; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.Game.GameState; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; public class GameSpectatorManager implements Listener, IPacketHandler { - private Set _pendingSpectate = Collections.synchronizedSet(new HashSet<>()); + // A map of a player UUID to the UUID of the entity they want to spectate + private Map _pendingSpectate = Collections.synchronizedMap(new HashMap<>()); - ArcadeManager Manager; + private ArcadeManager _manager; public GameSpectatorManager(ArcadeManager manager) { - Manager = manager; + _manager = manager; - Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); + _manager.getPluginManager().registerEvents(this, _manager.getPlugin()); - Manager.getPacketHandler().addPacketHandler(this, PacketHandler.ListenerPriority.HIGH, PacketPlayOutNamedEntitySpawn.class); + _manager.getPacketHandler().addPacketHandler(this, PacketHandler.ListenerPriority.HIGH, PacketPlayOutNamedEntitySpawn.class); } - @EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void interactCancel(PlayerInteractEvent event) { - if (Manager.GetGame() == null) + if (_manager.GetGame() == null) return; Player player = event.getPlayer(); - if (!Manager.GetGame().IsAlive(player)) + if (!_manager.GetGame().IsAlive(player)) event.setCancelled(true); processClick(player, event.getAction()); @@ -72,45 +75,45 @@ public class GameSpectatorManager implements Listener, IPacketHandler public void processClick(Player player, Action action) { - if (Manager.GetGame() == null) + if (_manager.GetGame() == null) return; - if(!Manager.GetGame().AllowEntitySpectate) + if (!_manager.GetGame().AllowEntitySpectate) return; - if(!Manager.GetGame().IsLive()) + if (!_manager.GetGame().IsLive()) return; - if(player.getGameMode() != GameMode.SPECTATOR) + if (player.getGameMode() != GameMode.SPECTATOR) return; - if(player.getSpectatorTarget() == null) + if (player.getSpectatorTarget() == null) return; - if(!(player.getSpectatorTarget() instanceof Player)) + if (!(player.getSpectatorTarget() instanceof Player)) return; - List players = Manager.GetGame().GetPlayers(true); + List players = _manager.GetGame().GetPlayers(true); int currentPlayer = 0; - for(Player otherPlayer : players) + for (Player otherPlayer : players) { currentPlayer++; - if(((Player) player.getSpectatorTarget()) == otherPlayer) + if (player.getSpectatorTarget() == otherPlayer) break; } - if(action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) + if (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) currentPlayer = currentPlayer - 2; else return; - if(currentPlayer < 0) + if (currentPlayer < 0) currentPlayer = players.size() - 1; - if(currentPlayer >= players.size()) + if (currentPlayer >= players.size()) currentPlayer = 0; - if(players.get(currentPlayer) == null) + if (players.get(currentPlayer) == null) return; Player specPlayer = players.get(currentPlayer); @@ -121,25 +124,25 @@ public class GameSpectatorManager implements Listener, IPacketHandler @EventHandler(priority = EventPriority.LOW) public void interactEntityCancel(PlayerInteractEntityEvent event) { - if (Manager.GetGame() == null) + if (_manager.GetGame() == null) return; Player player = event.getPlayer(); - if (Manager.GetGame().GetState() == GameState.Recruit) + if (_manager.GetGame().GetState() == GameState.Recruit) { - if (Manager.getCosmeticManager().getMountManager().isMount(event.getRightClicked())) + if (_manager.getCosmeticManager().getMountManager().isMount(event.getRightClicked())) { return; } } - if (!Manager.GetGame().IsAlive(player)) + if (!_manager.GetGame().IsAlive(player)) { event.setCancelled(true); - if(Manager.GetGame().IsLive()) + if (_manager.GetGame().IsLive()) { - if(Manager.GetGame().AllowEntitySpectate) + if (_manager.GetGame().AllowEntitySpectate) { setSpectating(player, event.getRightClicked()); } @@ -150,26 +153,25 @@ public class GameSpectatorManager implements Listener, IPacketHandler @EventHandler public void updateSpecEntitys(UpdateEvent event) { - if(event.getType() != UpdateType.FASTER) + if (event.getType() != UpdateType.FASTER) return; - if(Manager.GetGame() == null) + if (_manager.GetGame() == null) return; - if(Manager.GetGame().IsLive() || Manager.GetGame().GetState() == GameState.End) + if (_manager.GetGame().IsLive() || _manager.GetGame().GetState() == GameState.End) { - if(Manager.GetGame().AllowEntitySpectate) + if (_manager.GetGame().AllowEntitySpectate) { - for(Player player : UtilServer.getPlayers()) + for (Player player : UtilServer.getPlayers()) { - if (!Manager.GetGame().IsAlive(player)) + if (!_manager.GetGame().IsAlive(player)) { - if(player.getGameMode() == GameMode.SPECTATOR) + if (player.getGameMode() == GameMode.SPECTATOR) { - if(player.getSpectatorTarget() == null) + if (player.getSpectatorTarget() == null) { - player.setGameMode(GameMode.SURVIVAL); - player.setAllowFlight(true); + despectate(player); } } } @@ -181,28 +183,27 @@ public class GameSpectatorManager implements Listener, IPacketHandler @EventHandler(priority = EventPriority.LOW) public void spectatedEntityDeath(PlayerDeathEvent event) { - if(Manager.GetGame() == null) + if (_manager.GetGame() == null) return; - if(Manager.GetGame().IsLive() || Manager.GetGame().GetState() == GameState.End) + if (_manager.GetGame().IsLive() || _manager.GetGame().GetState() == GameState.End) { - if(Manager.GetGame().AllowEntitySpectate) + if (_manager.GetGame().AllowEntitySpectate) { - for(Player player : UtilServer.getPlayers()) + for (Player player : UtilServer.getPlayers()) { - if (!Manager.GetGame().IsAlive(player)) + if (!_manager.GetGame().IsAlive(player)) { - if(player.getGameMode() == GameMode.SPECTATOR) + if (player.getGameMode() == GameMode.SPECTATOR) { - if(player.getSpectatorTarget() == event.getEntity()) + if (player.getSpectatorTarget() == event.getEntity()) { - if(Manager.GetGame().GetPlayers(true).size() >= 1) + if (_manager.GetGame().GetPlayers(true).size() >= 1) { - setSpectating(player, Manager.GetGame().GetPlayers(true).get(UtilMath.r(Manager.GetGame().GetPlayers(true).size()))); + setSpectating(player, _manager.GetGame().GetPlayers(true).get(UtilMath.r(_manager.GetGame().GetPlayers(true).size()))); return; } - player.setGameMode(GameMode.SURVIVAL); - player.setAllowFlight(true); + despectate(player); } } } @@ -214,28 +215,53 @@ public class GameSpectatorManager implements Listener, IPacketHandler @EventHandler(priority = EventPriority.LOW) public void dismountEntity(PlayerToggleSneakEvent event) { - if(Manager.GetGame() == null) + if (_manager.GetGame() == null) return; - if(Manager.GetGame().IsLive() || Manager.GetGame().GetState() == GameState.End) + if (_manager.GetGame().IsLive() || _manager.GetGame().GetState() == GameState.End) { - if(Manager.GetGame().AllowEntitySpectate) + if (_manager.GetGame().AllowEntitySpectate) { - if(!Manager.GetGame().IsAlive(event.getPlayer())) + if (!_manager.GetGame().IsAlive(event.getPlayer())) { - if(event.getPlayer().getGameMode() == GameMode.SPECTATOR) + if (event.getPlayer().getGameMode() == GameMode.SPECTATOR) { - event.getPlayer().setGameMode(GameMode.SURVIVAL); - event.getPlayer().setAllowFlight(true); + despectate(event.getPlayer()); } } } } } + /* + * There's a reason this code is so complicated. + * + * Basically, when we want to set someone to spectate another entity, we send a PacketPlayOutCamera + * However, on the client side if the entity with the id as specified in PacketPlayOutCamera doesn't exist, + * the client simply ignores it + * This is alright if we're talking about small games like SSM or whatever, but in bigger games like SG and UHC + * the client does not get to keep the entire map loaded in memory + * Therefore, there is a chance that when we call Player#setSpectatorTarget, it has no effect because the client + * has not yet loaded the target + * + * To remedy this, we take a two pronged approach. + * + * First, we use Minecraft's internal EntityTracker to determine whether the client should have the entity loaded + * or not (if that's out of sync we're screwed anyways so oh well) + * + * If the client does have it loaded, then we simply use the Bukkit API to set the spectator target + * + * If the client doesn't have it loaded, we add it to a map of pending spectates and let the packet handler do the rest + * + * If at any point the client wants to stop spectating, we immediately replace the value in the map which notifies + * the packet handler to stop doing whatever it's doing. + * + * This is because the despectation code will work no matter what step of the spectating process is currently + * being executed + */ public void setSpectating(Player player, Entity target) { - if (Manager.GetGame().IsAlive(player)) + if (_manager.GetGame().IsAlive(player)) { return; } @@ -245,66 +271,78 @@ public class GameSpectatorManager implements Listener, IPacketHandler if (target instanceof Player) { playerTarget = (Player) target; - if (!Manager.GetGame().IsAlive(playerTarget)) + if (!_manager.GetGame().IsAlive(playerTarget)) { return; } } - _pendingSpectate.add(target.getUniqueId()); + // Not finished last spectate + if (_pendingSpectate.containsKey(player.getUniqueId())) + return; + _pendingSpectate.put(player.getUniqueId(), target.getUniqueId()); + + EntityPlayer ep = ((CraftPlayer) player).getHandle(); + EntityTracker tracker = ep.u().getTracker(); + EntityTrackerEntry entry = tracker.trackedEntities.get(target.getEntityId()); + + // If the server is tracking this entity (eg the player should have it loaded) we can spectate right away + if (entry.trackedPlayers.contains(ep)) + { + player.teleport(target.getLocation().add(0, 1, 0)); + + // If the player already has the entity loaded, we have to set it now + player.setGameMode(GameMode.SPECTATOR); + player.setSpectatorTarget(target); + if (playerTarget != null) + UtilTextBottom.display(C.cGray + "You are spectating " + F.elem(_manager.GetGame().GetTeam(playerTarget).GetColor() + playerTarget.getName()) + ".", player); + + UtilPlayer.message(player, F.main("Game", "Sneak to stop spectating.")); + _pendingSpectate.remove(player.getUniqueId()); + } + + // We still set spectating here even though it's pointless because of updateSpecEntites() above player.teleport(target.getLocation().add(0, 1, 0)); - - // If the player already has the entity loaded, we have to set it now - - // todo - // In the future, we could do some really cool stuff where we listen to all incoming and outgoing - // spawn/destroy packets and track whether the client has loaded the entity in memory - // However, that approach has the risk of desynchronization at which point we're screwed player.setGameMode(GameMode.SPECTATOR); player.setSpectatorTarget(target); - - if (playerTarget != null) - UtilTextBottom.display(C.cGray + "You are spectating " + F.elem(Manager.GetGame().GetTeam(playerTarget).GetColor() + playerTarget.getName()) + ".", player); - - UtilPlayer.message(player, F.main("Game", "Sneak to stop spectating.")); - - // And if the player did have the entity loaded, we also need to clean up after ourselves - // 20 ticks should be more than enough time considering we're just waiting for the server to attempt to - // send the packet - // and even if the server was lagging, the scheduler should be lagging too - Manager.runSyncLater(() -> - { - _pendingSpectate.remove(target.getUniqueId()); - }, 20L); } @EventHandler(priority = EventPriority.LOW) public void vehicleDamage(VehicleDamageEvent event) { - if (Manager.GetGame() == null) + if (_manager.GetGame() == null) return; if (!(event.getAttacker() instanceof Player)) return; - Player player = (Player)event.getAttacker(); + Player player = (Player) event.getAttacker(); - if (!Manager.GetGame().IsAlive(player)) + if (!_manager.GetGame().IsAlive(player)) event.setCancelled(true); } + // Yes, there are a lot of checks for _pendingSpectate + // This is needed because if at any point (keeping in mind this code is not executed sequentially, but with delays) + // spectation needs to be aborted (signaled by replacing the value in _pendingSpectate) + // Then we need to stop spectating right away + // Otherwise the client will be out of sync @Override public void handle(PacketInfo packetInfo) { if (packetInfo.getPacket() instanceof PacketPlayOutNamedEntitySpawn) { PacketPlayOutNamedEntitySpawn packet = (PacketPlayOutNamedEntitySpawn) packetInfo.getPacket(); - if (_pendingSpectate.remove(packet.b)) + if (_pendingSpectate.get(packetInfo.getPlayer().getUniqueId()) == packet.b) { // Handle Minestrike spam race condition - if (Manager.GetGame().IsAlive(packetInfo.getPlayer())) + if (_manager.GetGame().IsAlive(packetInfo.getPlayer())) { + _manager.runSync(() -> + { + _pendingSpectate.remove(packetInfo.getPlayer().getUniqueId()); + }); return; } @@ -313,31 +351,100 @@ public class GameSpectatorManager implements Listener, IPacketHandler EntityPlayer ep = ((CraftPlayer) packetInfo.getPlayer()).getHandle(); NetworkManager manager = ep.playerConnection.networkManager; + if (_pendingSpectate.get(packetInfo.getPlayer().getUniqueId()) != packet.b) + return; + manager.a(packet, future -> { - Manager.runSync(() -> + if (_pendingSpectate.get(packetInfo.getPlayer().getUniqueId()) != packet.b) + return; + + _manager.runSync(() -> { PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(packetInfo.getPlayer(), GameMode.SPECTATOR); UtilServer.CallEvent(event); - if(event.isCancelled()) { + if (event.isCancelled()) + { + _manager.runSync(() -> + { + _pendingSpectate.remove(packetInfo.getPlayer().getUniqueId()); + }); return; } ep.playerInteractManager.setGameMode(WorldSettings.EnumGamemode.getById(GameMode.SPECTATOR.getValue())); ep.fallDistance = 0.0F; + + if (_pendingSpectate.get(packetInfo.getPlayer().getUniqueId()) != packet.b) + return; + manager.a(new PacketPlayOutCamera(ep), future1 -> { - manager.a(new PacketPlayOutGameStateChange(3, (float)GameMode.SPECTATOR.getValue()), future2 -> - { - PacketPlayOutCamera p1 = new PacketPlayOutCamera(); - p1.a = packet.a; - manager.handle(p1); - }); + if (_pendingSpectate.get(packetInfo.getPlayer().getUniqueId()) != packet.b) + return; + manager.a(new PacketPlayOutGameStateChange(3, (float) GameMode.SPECTATOR.getValue()), future2 -> + { + if (_pendingSpectate.get(packetInfo.getPlayer().getUniqueId()) != packet.b) + return; + + _manager.runSync(() -> + { + PacketPlayOutCamera p1 = new PacketPlayOutCamera(); + p1.a = packet.a; + + if (_pendingSpectate.get(packetInfo.getPlayer().getUniqueId()) != packet.b) + return; + + manager.a(p1, future3 -> + { + _manager.runSync(() -> + { + Player playerTarget = Bukkit.getPlayer(packet.b); + + if (playerTarget != null) + UtilTextBottom.display(C.cGray + "You are spectating " + F.elem(_manager.GetGame().GetTeam(playerTarget).GetColor() + playerTarget.getName()) + ".", packetInfo.getPlayer()); + + UtilPlayer.message(packetInfo.getPlayer(), F.main("Game", "Sneak to stop spectating.")); + _pendingSpectate.remove(packetInfo.getPlayer().getUniqueId()); + }); + }); + }); + }); }); }); }); } } } + + public void despectate(Player player) + { + // We want to override and tell any pending spectates that we are despectating now + _pendingSpectate.put(player.getUniqueId(), player.getUniqueId()); + + PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(player, GameMode.SURVIVAL); + UtilServer.CallEvent(event); + if (event.isCancelled()) + { + _pendingSpectate.remove(player.getUniqueId()); + return; + } + + EntityPlayer ep = ((CraftPlayer) player).getHandle(); + ep.playerInteractManager.setGameMode(WorldSettings.EnumGamemode.getById(GameMode.SURVIVAL.getValue())); + ep.fallDistance = 0.0F; + NetworkManager manager = ep.playerConnection.networkManager; + manager.a(new PacketPlayOutCamera(ep), future1 -> + { + manager.a(new PacketPlayOutGameStateChange(3, (float) GameMode.SURVIVAL.getValue()), future2 -> + { + _manager.runSync(() -> + { + player.setAllowFlight(true); + _pendingSpectate.remove(player.getUniqueId()); + }); + }); + }); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameWorldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameWorldManager.java index df3147fd4..fdaf4c271 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameWorldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameWorldManager.java @@ -75,8 +75,23 @@ public class GameWorldManager implements Listener } if (Manager.GetGame() != null) + { if (Manager.GetGame().WorldData != null) - Manager.GetGame().WorldData.ChunkUnload(event); + { + + if (Manager.GetGame().WorldChunkUnload) + { + return; + } + if (Manager.GetGame().WorldData.World == null) + return; + + if (!event.getWorld().equals(Manager.GetGame().WorldData.World)) + return; + + event.setCancelled(true); + } + } } public void RegisterWorld(WorldData worldData) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ServerUptimeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ServerUptimeManager.java index c00df712e..963449a38 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ServerUptimeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ServerUptimeManager.java @@ -169,7 +169,7 @@ public class ServerUptimeManager implements Listener public void updateDates(String uptimes) { System.out.println(uptimes); - if (Manager.GetServerConfig().Uptimes == null) + if (Manager.GetServerConfig().Uptimes.isEmpty()) { _enabled = false; return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java index 63b45effa..fdd9af536 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java @@ -450,17 +450,6 @@ public class WorldData World = null; } - - public void ChunkUnload(ChunkUnloadEvent event) - { - if (World == null) - return; - - if (!event.getWorld().equals(World)) - return; - - event.setCancelled(true); - } public void ChunkLoad(ChunkPreLoadEvent event) {