diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java index 070d4bbe4..bab43e1df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java @@ -22,8 +22,6 @@ import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import mineplex.core.account.permissions.Permission; @@ -41,6 +39,7 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; @@ -80,7 +79,7 @@ public class SnowFight extends TeamGame .build(); private static final int GUN_BULLETS = 5; private static final long COMBAT_TIME = TimeUnit.SECONDS.toMillis(8); - private static final PotionEffect REGENERATION = new PotionEffect(PotionEffectType.REGENERATION, Integer.MAX_VALUE, 1); + private static final String CONDITION_REASON = "Out of Combat"; private boolean _gunMode; private long _gunModeTime = GUN_MODE_TIME; @@ -119,6 +118,8 @@ public class SnowFight extends TeamGame .register(this); new CompassModule() + .setGiveCompassToAlive(true) + .setGiveCompass(false) .register(this); registerDebugCommand("launchers", Perm.DEBUG_COMMANDS, PermissionGroup.ADMIN, (player, args) -> _gunModeTime = 0); @@ -152,7 +153,7 @@ public class SnowFight extends TeamGame { if (event.GetState() == GameState.Prepare) { - UtilTextMiddle.display(C.cGreenB + "Get Ready", "Collect Snowballs!", 0, 60, 10, UtilServer.getPlayers()); + UtilTextMiddle.display(C.cGreenB + "Get Ready", "Collect Snowballs!", 20, 60, 10, UtilServer.getPlayers()); } else if (event.GetState() == GameState.Live) { @@ -254,7 +255,7 @@ public class SnowFight extends TeamGame if (damagee != null) { _lastDamage.put(damagee, System.currentTimeMillis()); - damagee.removePotionEffect(PotionEffectType.REGENERATION); + Manager.GetCondition().EndCondition(damagee, ConditionType.REGENERATION, CONDITION_REASON); } Player shooter = (Player) projectile.getShooter(); @@ -267,7 +268,7 @@ public class SnowFight extends TeamGame if (_blizzard) { - UtilPlayer.hunger(shooter, 2); + UtilPlayer.hunger(shooter, 4); } } @@ -296,10 +297,10 @@ public class SnowFight extends TeamGame } else if (UtilTime.elapsed(GetStateTime(), _blizzardTime)) { + List alive = GetPlayers(true); + if (!_blizzard) { - List alive = GetPlayers(true); - Announce(F.main("Game", F.color("Blizzard", C.cRedB) + " incoming! Attack players to restore hunger.")); UtilTextMiddle.display(C.cRedB + "Blizzard", "Attack players to restore hunger", 0, 40, 10, alive.toArray(new Player[0])); HungerSet = -1; @@ -307,7 +308,7 @@ public class SnowFight extends TeamGame _blizzard = true; } - GetPlayers(true).forEach(player -> + alive.forEach(player -> { if (player.getFoodLevel() == 0) { @@ -317,7 +318,7 @@ public class SnowFight extends TeamGame ); } - player.setSaturation(0); + UtilPlayer.hunger(player, -1); }); } } @@ -371,13 +372,13 @@ public class SnowFight extends TeamGame if (_blizzard) { - player.removePotionEffect(PotionEffectType.REGENERATION); + Manager.GetCondition().EndCondition(player, ConditionType.REGENERATION, CONDITION_REASON); return true; } - if (UtilTime.elapsed(lastDamage, COMBAT_TIME) && !player.hasPotionEffect(PotionEffectType.REGENERATION)) + if (UtilTime.elapsed(lastDamage, COMBAT_TIME)) { - player.addPotionEffect(REGENERATION); + Manager.GetCondition().Factory().Regen(CONDITION_REASON, player, player, 10, 1, false, false, true); } return !IsAlive(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitMedic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitMedic.java index e4f7e2f36..22728ce4b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitMedic.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitMedic.java @@ -1,49 +1,52 @@ package nautilus.game.arcade.game.games.snowfight.kits; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import net.md_5.bungee.api.ChatColor; +import java.util.concurrent.TimeUnit; + import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.Potion; import org.bukkit.potion.PotionType; -public class KitMedic extends ProgressingKit +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitMedic extends KitSnowFight { - private final Potion POTION = new Potion(PotionType.INSTANT_HEAL).splash(); + private static final Potion POTION = new Potion(PotionType.INSTANT_HEAL).splash(); + private static final long COOLDOWN = TimeUnit.SECONDS.toMillis(12); - private static final String[] DESCRIPTION = { - "Throw warmth potions to heal allies!", - ChatColor.RESET + " ", - C.cWhite + "Receive" + C.cGreen + " 1 " + C.cWhite + "Warmth Potion every" + C.cGreen + " 16 seconds. Maximum of 1.", - }; + private static final String[] DESCRIPTION = + { + "Throw warmth potions to heal allies!", + C.blankLine, + C.cWhite + receiveItem("Warmth Potion", 1, 12, 1) + }; private static final Perk[] PERKS = {}; private static final ItemStack IN_HAND = new ItemStack(Material.POTION); - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP, (byte) 0, 1, ChatColor.RESET + "Hearty Winter Stew"), - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP, (byte) 0, 1, ChatColor.RESET + "Hearty Winter Stew"), - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP, (byte) 0, 1, ChatColor.RESET + "Hearty Winter Stew"), - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP, (byte) 0, 1, ChatColor.RESET + "Hearty Winter Stew") - }; + static + { + POTION.setLevel(2); + } public KitMedic(ArcadeManager manager) { - super(manager, "Medic", "snowfightmedic", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.SKELETON, IN_HAND); + super(manager, "Medic", "snowfightmedic", KitAvailability.Free, DESCRIPTION, PERKS, IN_HAND); } @Override @@ -51,53 +54,51 @@ public class KitMedic extends ProgressingKit { player.getInventory().setItem(1, getPotion()); - for (int i = 0; i < PLAYER_ITEMS.length; i++) - { - player.getInventory().setItem(i + 2, PLAYER_ITEMS[i]); - } + super.GiveItems(player); } - @Override - public void SpawnCustom(LivingEntity ent) - { - ent.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); - ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); - ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); - ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); - } - @EventHandler - public void KitItems(UpdateEvent event) + public void kitItems(UpdateEvent event) { - if(!Manager.GetGame().IsLive()) - return; - - if (event.getType() == UpdateType.SLOWER) + if (event.getType() != UpdateType.SEC || !Manager.GetGame().InProgress()) { - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!HasKit(player)) - { - continue; - } + return; + } + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (HasKit(player) && !player.getInventory().contains(Material.POTION) && Recharge.Instance.usable(player, GetName())) + { player.getInventory().setItem(1, getPotion()); } } } + @EventHandler + public void playerInteract(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = player.getItemInHand(); + + if (itemStack == null || itemStack.getType() != Material.POTION || !HasKit(player)) + { + return; + } + + Recharge.Instance.useForce(player, GetName(), COOLDOWN); + } + private ItemStack getPotion() { ItemStack stack = POTION.toItemStack(1); ItemMeta meta = stack.getItemMeta(); - meta.setDisplayName(ChatColor.RESET + "Warmth Potion"); + meta.setDisplayName(C.cYellow + "Warmth Potion"); stack.setItemMeta(meta); return stack; } - - @Override - public boolean usesXp() - { - return false; - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSnowFight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSnowFight.java new file mode 100644 index 000000000..5237db12d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSnowFight.java @@ -0,0 +1,58 @@ +package nautilus.game.arcade.game.games.snowfight.kits; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.itemstack.ItemStackFactory; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; + +class KitSnowFight extends ProgressingKit +{ + + private static final ItemStack[] ARMOUR = + { + new ItemBuilder(Material.LEATHER_BOOTS).setUnbreakable(true).setColor(Color.RED).build(), + new ItemBuilder(Material.LEATHER_LEGGINGS).setUnbreakable(true).setColor(Color.RED).build(), + new ItemBuilder(Material.LEATHER_CHESTPLATE).setUnbreakable(true).setColor(Color.RED).build(), + new ItemBuilder(Material.LEATHER_HELMET).setUnbreakable(true).setColor(Color.RED).build() + }; + private static final ItemStack WINTER_STEW = new ItemBuilder(Material.MUSHROOM_SOUP) + .setTitle(C.cYellow + "Hearty Winter Strew") + .build(); + + KitSnowFight(ArcadeManager manager, String name, String internalName, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, ItemStack itemInHand) + { + super(manager, name, internalName, kitAvailability, kitDesc, kitPerks, EntityType.ZOMBIE, itemInHand); + } + + @Override + public void GiveItems(Player player) + { + for (int i = 2; i < 5; i++) + { + player.getInventory().setItem(i, WINTER_STEW); + } + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + ent.getEquipment().setArmorContents(ARMOUR); + } + + @Override + public boolean usesXp() + { + return false; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSportsman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSportsman.java index feedd5491..3bb235fce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSportsman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSportsman.java @@ -1,67 +1,39 @@ package nautilus.game.arcade.game.games.snowfight.kits; -import mineplex.core.itemstack.ItemStackFactory; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.kit.perks.PerkDoubleJump; import nautilus.game.arcade.kit.perks.PerkFallDamage; import nautilus.game.arcade.kit.perks.PerkSpeed; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -public class KitSportsman extends ProgressingKit +public class KitSportsman extends KitSnowFight { - private static final String[] DESCRIPTION = { - "Trained to be the fastest on snow and ice.", - }; + private static final String[] DESCRIPTION = + { + "Trained to be the fastest on snow and ice.", + C.blankLine, + C.cYellow + "Tap Jump Twice" + C.cWhite + " to " + C.cGreen + "Snow Jump", + }; - private static final Perk[] PERKS = { - new PerkSpeed(0), - new PerkFallDamage(-2), - new PerkDoubleJump("Snow Jump", 1, 0.8, true, 6000, true), - }; + private static final Perk[] PERKS = + { + new PerkSpeed(0), + new PerkFallDamage(-2), + new PerkDoubleJump("Snow Jump", 1, 0.8, true, 6000, true), + }; private static final ItemStack IN_HAND = new ItemStack(Material.SNOW_BALL); - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP, (byte) 0, 1, ChatColor.RESET + "Hearty Winter Stew"), - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP, (byte) 0, 1, ChatColor.RESET + "Hearty Winter Stew"), - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP, (byte) 0, 1, ChatColor.RESET + "Hearty Winter Stew") - }; - public KitSportsman(ArcadeManager manager) { - super(manager, "Sportsman", "snowfightsportsman", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.SKELETON, IN_HAND); + super(manager, "Sportsman", "snowfightsportsman", KitAvailability.Free, DESCRIPTION, PERKS, IN_HAND); } - @Override - public void GiveItems(Player player) - { - for (int i = 0; i < PLAYER_ITEMS.length; i++) - { - player.getInventory().setItem(i + 2, PLAYER_ITEMS[i]); - } - } - - @Override - public void SpawnCustom(LivingEntity ent) - { - ent.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); - ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); - ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); - ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); - } - - @Override - public boolean usesXp() - { - return false; - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitTactician.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitTactician.java index 9acc3059e..17e4da4a6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitTactician.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitTactician.java @@ -1,68 +1,50 @@ package nautilus.game.arcade.game.games.snowfight.kits; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.monsterleague.perks.PerkStoneWall; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -public class KitTactician extends ProgressingKit +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.monsterleague.perks.PerkStoneWall; +import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitTactician extends KitSnowFight { - private static final String[] DESCRIPTION = { - "No Snowfight is complete without a tactical game!", - }; + private static final String[] DESCRIPTION = + { + "No Snowfight is complete without a tactical game!", + C.blankLine, + click(false, "Clay to construct a wall of Ice") + }; - private static final Perk[] PERKS = { - new PerkStoneWall("Ice Wall", Material.ICE, Material.CLAY_BALL), - }; + private static final Perk[] PERKS = + { + new PerkStoneWall("Ice Wall", Material.ICE, Material.CLAY_BALL), + }; private static final ItemStack IN_HAND = new ItemStack(Material.CLAY_BALL); - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.CLAY_BALL, (byte) 0, 1, ChatColor.RESET + "Ice Wall"), - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP, (byte) 0, 1, ChatColor.RESET + "Hearty Winter Stew"), - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP, (byte) 0, 1, ChatColor.RESET + "Hearty Winter Stew"), - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP, (byte) 0, 1, ChatColor.RESET + "Hearty Winter Stew"), - }; + private static final ItemStack PLAYER_ITEM = new ItemBuilder(Material.CLAY_BALL) + .setTitle(C.cYellow + "Ice Wall") + .build(); public KitTactician(ArcadeManager manager) { - super(manager, "Tactician", "snowfighttactician", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.SKELETON, IN_HAND); + super(manager, "Tactician", "snowfighttactician", KitAvailability.Free, DESCRIPTION, PERKS, IN_HAND); } @Override public void GiveItems(Player player) { - player.getInventory().setItem(1, PLAYER_ITEMS[0]); + player.getInventory().setItem(1, PLAYER_ITEM); + player.getInventory().setItem(7, CompassModule.getCompassItem()); - for (int i = 1; i < PLAYER_ITEMS.length - 1; i++) - { - player.getInventory().setItem(i + 2, PLAYER_ITEMS[i]); - } - - player.getInventory().setItem(7, PLAYER_ITEMS[4]); - } - - @Override - public void SpawnCustom(LivingEntity ent) - { - ent.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); - ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); - ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); - ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); - } - - @Override - public boolean usesXp() - { - return false; + super.GiveItems(player); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/compass/CompassModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/compass/CompassModule.java index fda3039b4..23cd74d5f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/compass/CompassModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/compass/CompassModule.java @@ -41,12 +41,18 @@ import nautilus.game.arcade.game.modules.compass.menu.CompassMenu; public class CompassModule extends Module { + private static final ItemStack COMPASS_ITEM = new ItemBuilder(Material.COMPASS) .setAmount(1) - .setTitle(C.cGreen + C.Bold + "Tracking Compass") + .setTitle(C.cGreenB + "Tracking Compass") .build(); + public static ItemStack getCompassItem() + { + return COMPASS_ITEM; + } + private List>> _suppliers = new ArrayList<>(); private CompassMenu _compassMenu;