diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFiveYear.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFiveYear.java index 0e678c256..d40d78d26 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFiveYear.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFiveYear.java @@ -17,6 +17,7 @@ import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.gadget.util.CostConstants; +import mineplex.core.particleeffects.BabyFireworkEffect; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -29,7 +30,8 @@ public class ParticleFiveYear extends ParticleGadget { super(manager, "Five Years of Mineplex", new String[] { - C.cGray + "", + C.cGray + "Celebrate Mineplex's 5th", + C.cGray + "Anniversary with this aura!", C.blankLine, C.cBlue + "Earned by joining the server during", C.cBlue + "the Mineplex 5 Year Anniversary." @@ -47,24 +49,33 @@ public class ParticleFiveYear extends ParticleGadget } Location location = player.getLocation().add(0, 1, 0); - location.setPitch(0); - Vector direction = location.getDirection(); - location.add(UtilAlg.getRight(direction).multiply(0.3)); - location.subtract(direction.multiply(0.5)); - int color, height = _bufferedImage.getHeight() / 2, width = _bufferedImage.getWidth() / 2; - double yaw = Math.toRadians(location.getYaw()); - - for (int y = 1; y < _bufferedImage.getHeight(); y++) + if (Manager.isMoving(player)) { - for (int x = 0; x < _bufferedImage.getWidth() - 1; x++) - { - color = _bufferedImage.getRGB(x, y); + new BabyFireworkEffect(location, Color.ORANGE, 1) + .start(); + } + else + { + location.setPitch(0); + Vector direction = location.getDirection(); + location.add(UtilAlg.getRight(direction).multiply(0.3)); + location.subtract(direction.multiply(0.5)); - Vector vector = new Vector(width - x, height - y, 0).multiply(0.2); - UtilAlg.rotateAroundYAxis(vector, yaw); - UtilParticle.PlayParticleToAll(Color.black.getRGB() == color ? ParticleType.FLAME : ParticleType.SMOKE, location.add(vector), null, 0, 1, ViewDist.NORMAL); - location.subtract(vector); + int color, height = _bufferedImage.getHeight() / 2, width = _bufferedImage.getWidth() / 2; + double yaw = Math.toRadians(location.getYaw()); + + for (int y = 1; y < _bufferedImage.getHeight(); y++) + { + for (int x = 0; x < _bufferedImage.getWidth() - 1; x++) + { + color = _bufferedImage.getRGB(x, y); + + Vector vector = new Vector(width - x, height - y, 0).multiply(0.2); + UtilAlg.rotateAroundYAxis(vector, yaw); + UtilParticle.PlayParticleToAll(Color.black.getRGB() == color ? ParticleType.FLAME : ParticleType.SMOKE, location.add(vector), null, 0, 1, ViewDist.NORMAL); + location.subtract(vector); + } } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/kit/GameKit.java b/Plugins/Mineplex.Core/src/mineplex/core/game/kit/GameKit.java index 770d4d0a1..24bd69723 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/kit/GameKit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/kit/GameKit.java @@ -1838,24 +1838,6 @@ public enum GameKit ) ), - MILK_THE_COW_FARM_HAND - ( - 1, - GameDisplay.MilkCow, - "Sturdy Farmhand", - "milksturdyfarmhand", - new String[] - { - "Been working on the ranch so long, even a charging bull can't faze him!" - }, - new KitEntityData<> - ( - Zombie.class, - new ItemStack(Material.IRON_SPADE) - ), - 2000 - ), - MILK_THE_COW_COW ( 2, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/CowScore.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/CowScore.java deleted file mode 100644 index 8a5f0dda4..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/CowScore.java +++ /dev/null @@ -1,15 +0,0 @@ -package nautilus.game.arcade.game.games.milkcow; - -import org.bukkit.entity.Player; - -public class CowScore -{ - public org.bukkit.entity.Player Player; - public double Score; - - public CowScore(Player player, double i) - { - Player = player; - Score = i; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java index a4c90bf8b..9ec8c6961 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkCow.java @@ -1,53 +1,26 @@ package nautilus.game.arcade.game.games.milkcow; -import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; - -import mineplex.core.Managers; -import mineplex.core.common.Pair; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.visibility.VisibilityManager; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent.RemoveType; -import nautilus.game.arcade.game.games.milkcow.kits.KitCow; -import nautilus.game.arcade.game.games.milkcow.kits.KitFarmerJump; -import nautilus.game.arcade.game.games.milkcow.kits.KitSturdyFarmhand; -import nautilus.game.arcade.game.modules.compass.CompassModule; -import nautilus.game.arcade.game.team.selectors.RatioSelector; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.NullKit; -import net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.NavigationAbstract; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; -import org.bukkit.entity.Chicken; +import org.bukkit.entity.Ageable; import org.bukkit.entity.Cow; import org.bukkit.entity.Creature; -import org.bukkit.entity.Pig; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import org.bukkit.entity.Villager; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerBucketFillEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; @@ -56,64 +29,89 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; +import mineplex.core.Managers; +import mineplex.core.common.Pair; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.visibility.VisibilityManager; +import mineplex.minecraft.game.core.combat.CombatComponent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.milkcow.kits.KitCow; +import nautilus.game.arcade.game.games.milkcow.kits.KitFarmerJump; +import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.game.team.selectors.RatioSelector; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.NullKit; + public class MilkCow extends SoloGame { + + private static final int SCORE_TO_WIN = 15; + private static final int SCORE_DEATH = 5; + private static final String[] DESCRIPTION = + { + C.cGreen + "Farmers" + C.Reset + " get " + C.cYellow + "1" + C.Reset + " point for drinking milk.", + C.cRed + "Cows" + C.Reset + " defend your herd from the farmers.", + "", + C.cYellow + "Everyone" + C.Reset + " loses " + C.cYellow + SCORE_DEATH + C.Reset + " points for dying.", + "First player to " + C.cYellow + "15" + C.Reset + " points wins!" + }; + private GameTeam _farmers; private GameTeam _cows; - private ArrayList _chickens; - private ArrayList _pigs; - private ArrayList _villager; - - private ArrayList _ranks = new ArrayList(); - private ArrayList _lastScoreboard = new ArrayList(); - - private HashSet _herd = new HashSet(); - - private Objective _scoreObj; + private final Map> _animals; + private final Map _scores; + private final Set _herd; + private final Objective _objective; public MilkCow(ArcadeManager manager) { - super(manager, GameType.MilkCow, - - new Kit[] - { + super(manager, GameType.MilkCow, new Kit[] + { new KitFarmerJump(manager), - new KitSturdyFarmhand(manager), new NullKit(manager), new KitCow(manager), - }, + }, DESCRIPTION); - new String[] - { - "Farmers get 1 point for drinking milk.", - "You lose 5 points for dying!", - "", - "Cows get 1 point for killing farmers.", - "Defend your herd to stop farmers!", - "", - "First player to 15 points wins!" - }); + _animals = new HashMap<>(3); + _scores = new HashMap<>(); + _herd = new HashSet<>(); + + DeathOut = false; new CompassModule() .setGiveCompassToAlive(true) .register(this); - this.DeathOut = false; - _scoreObj = Scoreboard.getScoreboard().registerNewObjective("Milk", "dummy"); - _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); + _objective = Scoreboard.getScoreboard().registerNewObjective("Milk", "dummy"); + _objective.setDisplaySlot(DisplaySlot.BELOW_NAME); registerChatStats( - Kills + Kills, + Deaths ); } @Override - public void ParseData() + public void ParseData() { - _chickens = WorldData.GetDataLocs("WHITE"); - _pigs = WorldData.GetDataLocs("PINK"); - _villager = WorldData.GetDataLocs("PURPLE"); + _animals.put(EntityType.CHICKEN, WorldData.GetDataLocs("WHITE")); + _animals.put(EntityType.PIG, WorldData.GetDataLocs("PINK")); + _animals.put(EntityType.VILLAGER, WorldData.GetDataLocs("PURPLE")); } @Override @@ -126,12 +124,16 @@ public class MilkCow extends SoloGame if (team.GetColor() == ChatColor.RED) { if (kit.GetName().contains("Farm")) + { team.GetRestrictedKits().add(kit); + } } else { if (kit.GetName().contains("Cow")) + { team.GetRestrictedKits().add(kit); + } } } } @@ -139,17 +141,18 @@ public class MilkCow extends SoloGame @Override @EventHandler - public void CustomTeamGeneration(GameStateChangeEvent event) + public void CustomTeamGeneration(GameStateChangeEvent event) { if (event.GetState() != GameState.Recruit) + { return; + } - _farmers = this.GetTeamList().get(0); + _farmers = GetTeamList().get(0); _farmers.SetName("Farmers"); - //Undead Team - _cows = new GameTeam(this, "Cow", ChatColor.RED, _farmers.GetSpawns()); - GetTeamList().add(_cows); + _cows = new GameTeam(this, "Cow", ChatColor.RED, _farmers.GetSpawns()); + AddTeam(_cows); _teamSelector = new RatioSelector(_cows, 0.25); @@ -157,117 +160,90 @@ public class MilkCow extends SoloGame } @EventHandler - public void SpawnAnimals(GameStateChangeEvent event) + public void spawnAnimals(GameStateChangeEvent event) { if (event.GetState() != GameState.Live) + { return; - - for (Location loc : _chickens) - { - this.CreatureAllowOverride = true; - Chicken ent = loc.getWorld().spawn(loc, Chicken.class); - if (Math.random() > 0.75) - { - ent.setBaby(); - ent.setAgeLock(true); - } - - this.CreatureAllowOverride = false; } - for (Location loc : _pigs) + CreatureAllowOverride = true; + + _animals.forEach((entityType, locations) -> { - this.CreatureAllowOverride = true; - Pig ent = loc.getWorld().spawn(loc, Pig.class); - if (Math.random() > 0.75) + locations.forEach(location -> { - ent.setBaby(); - ent.setAgeLock(true); - } + Entity entity = location.getWorld().spawnEntity(location, entityType); - this.CreatureAllowOverride = false; - } + if (entity instanceof Ageable) + { + Ageable ageable = (Ageable) entity; + ageable.setBaby(); + ageable.setAgeLock(true); + } + else + { + entity.setCustomName("Bob"); + entity.setCustomNameVisible(true); + } + }); + }); - for (Location loc : _villager) - { - this.CreatureAllowOverride = true; - Villager ent = loc.getWorld().spawn(loc, Villager.class); - if (Math.random() > 0.75) - { - ent.setCustomName("Bob"); - ent.setCustomNameVisible(true); - } - - this.CreatureAllowOverride = false; - } + CreatureAllowOverride = false; } @EventHandler - public void HerdUpdate(UpdateEvent event) + public void updateHerd(UpdateEvent event) { - if (event.getType() != UpdateType.SEC) - return; - - if (!IsLive()) - return; - - if (_cows.GetPlayers(true).size() <= 0) - return; - - Player host = _cows.GetPlayers(true).get(0); - - Iterator herdIterator = _herd.iterator(); - - while (herdIterator.hasNext()) + if (event.getType() != UpdateType.SEC || !IsLive()) { - Cow cow = herdIterator.next(); + return; + } + List aliveCows = _cows.GetPlayers(true); + + if (aliveCows.isEmpty()) + { + return; + } + + Location target = aliveCows.get(0).getLocation(); + + _herd.removeIf(cow -> + { if (!cow.isValid()) { - cow.remove(); - herdIterator.remove(); - continue; + return true; } - //Move - EntityCreature ec = ((CraftCreature)cow).getHandle(); - NavigationAbstract nav = ec.getNavigation(); - - if (UtilMath.offset(cow, host) > 6) - { - if (UtilMath.offset(cow, host) > 16) - { - Location target = cow.getLocation(); - - target.add(UtilAlg.getTrajectory(cow, host).multiply(16)); - - nav.a(target.getX(), target.getY(), target.getZ(), 1.8f); - } - else - nav.a(host.getLocation().getX(), host.getLocation().getY(),host.getLocation().getZ(), 1.4f); - } - } + UtilEnt.CreatureMove(cow, target, 1.4F); + return false; + }); while (_herd.size() < 5) { - this.CreatureAllowOverride = true; - Cow cow = host.getWorld().spawn(host.getLocation(), Cow.class); + CreatureAllowOverride = true; + + Cow cow = target.getWorld().spawn(target, Cow.class); + if (Math.random() > 0.5) { cow.setBaby(); - cow.setAgeLock(true); } _herd.add(cow); - this.CreatureAllowOverride = false; - } + + CreatureAllowOverride = false; + } } @EventHandler - public void HerdDamage(CustomDamageEvent event) + public void cowDamage(CustomDamageEvent event) { - if (event.GetDamageeEntity() instanceof Creature) + if (event.GetDamageeEntity() instanceof Creature || _cows.HasPlayer(event.GetDamageePlayer())) + { event.SetCancelled("Cow Immunity"); + } } @EventHandler @@ -281,189 +257,193 @@ public class MilkCow extends SoloGame if (_cows.GetPlayers(true).isEmpty() && !_farmers.GetPlayers(true).isEmpty()) { Player player = UtilAlg.Random(_farmers.GetPlayers(true)); - SetCow(player, true); + setCow(player); } } - public void SetCow(Player player, boolean forced) + private void setCow(Player player) { SetPlayerTeam(player, _cows, true); //Refresh VisibilityManager vm = Managers.require(VisibilityManager.class); Bukkit.getOnlinePlayers().forEach(pl -> vm.refreshVisibility(pl, player)); - + //Turn off flight player.setAllowFlight(false); player.setFlying(false); - if (forced) - { - AddGems(player, 10, "Forced Cow", false, false); + AddGems(player, 10, "Forced Cow", false, false); - Announce(F.main("Game", F.elem(_farmers.GetColor() + player.getName()) + " has become " + - F.elem(_cows.GetColor() + GetKit(player).GetName()) + ".")); + Announce(F.main("Game", F.elem(_farmers.GetColor() + player.getName()) + " has become " + F.elem(_cows.GetColor() + GetKit(player).GetName()) + ".")); - player.getWorld().strikeLightningEffect(player.getLocation()); - } + player.getWorld().strikeLightningEffect(player.getLocation()); } @EventHandler - public void GetMilk(PlayerInteractEntityEvent event) + public void getMilk(PlayerInteractEntityEvent event) { - if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.BUCKET)) - return; + Player player = event.getPlayer(); + ItemStack itemStack = player.getItemInHand(); - if (!(event.getRightClicked() instanceof Player)) + if (itemStack == null || itemStack.getType() != Material.BUCKET || !(event.getRightClicked() instanceof Player)) + { return; + } - Player cow = (Player)event.getRightClicked(); + Player cow = (Player) event.getRightClicked(); if (!_cows.HasPlayer(cow)) + { return; + } event.setCancelled(true); + itemStack.setType(Material.MILK_BUCKET); + player.updateInventory(); + } - event.getPlayer().setItemInHand(new ItemStack(Material.MILK_BUCKET)); + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void bucketFill(PlayerBucketFillEvent event) + { + if (!InProgress()) + { + return; + } + + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void drinkMilk(PlayerItemConsumeEvent event) + { + if (!IsLive() || event.getItem().getType() != Material.MILK_BUCKET) + { + return; + } + + Player player = event.getPlayer(); + + incrementScore(player, 1); + UtilPlayer.health(player, 2); + + player.getWorld().playSound(player.getLocation(), Sound.BURP, 2, 1); + + AddGems(player, 0.5, "Milk Drunk", true, true); } @EventHandler - public void DrinkMilk(PlayerItemConsumeEvent event) + public void loseMilk(PlayerDeathEvent event) { - if (!IsLive()) - return; - - if (event.getItem().getType() != Material.MILK_BUCKET) - return; - - SetScore(event.getPlayer(), GetScore(event.getPlayer())+1); - event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.BURP, 2f, 1f); - UtilPlayer.health(event.getPlayer(), 2); - - this.AddGems(event.getPlayer(), 0.5, "Milk Drunk", true, true); + UtilServer.CallEvent(new MilkRemoveEvent(event.getEntity(), SCORE_DEATH)); } @EventHandler - public void LoseMilk(PlayerDeathEvent event) + public void killFarmer(CombatDeathEvent event) { - MilkRemoveEvent e = new MilkRemoveEvent(event.getEntity(), 5, RemoveType.DEATH); - Bukkit.getPluginManager().callEvent(e); - SetScore(event.getEntity(), Math.max(0, GetScore(event.getEntity()) - e.GetMilk())); - } + CombatComponent killer = event.GetLog().GetKiller(); - @EventHandler - public void KillFarmer(CombatDeathEvent event) - { - if (event.GetLog().GetKiller() == null) + if (killer == null) + { return; + } - if (!event.GetLog().GetKiller().IsPlayer()) + Player player = UtilPlayer.searchExact(killer.getUniqueIdOfEntity()); + + if (player == null) + { return; - - Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); - if (player == null) return; - - //Score - SetScore(player, GetScore(player)+1); - } - - public void SetScore(Player player, double level) - { - _scoreObj.getScore(player.getName()).setScore((int)level); - - //Rank - for (CowScore score : _ranks) - { - if (score.Player.equals(player)) - { - score.Score = level; - - if (level == 15) - End(); - - return; - } } - _ranks.add(new CowScore(player, level)); + incrementScore(player, 1); } - public double GetScore(Player player) + @EventHandler(priority = EventPriority.MONITOR) + public void handleLostMilk(MilkRemoveEvent event) { - if (!IsAlive(player)) - return 0; - - //Rank - for (CowScore score : _ranks) - { - if (score.Player.equals(player)) - { - return score.Score; - } - } - - return 0; + incrementScore(event.getPlayer(), -event.getMilkToRemove()); } - private void SortScores() + private void incrementScore(Player player, int score) { - for (int i=0 ; i<_ranks.size() ; i++) + int newScore = getScore(player) + score; + + if (newScore < 0) { - for (int j=_ranks.size()-1 ; j>0 ; j--) - { - if (_ranks.get(j).Score > _ranks.get(j-1).Score) - { - CowScore temp = _ranks.get(j); - _ranks.set(j, _ranks.get(j-1)); - _ranks.set(j-1, temp); - } - } + newScore = 0; } + + _objective.getScore(player.getName()).setScore(newScore); + _scores.put(player, newScore); + + if (newScore >= SCORE_TO_WIN) + { + End(); + } + } + + private int getScore(Player player) + { + return _scores.getOrDefault(player, 0); + } + + private List getPlacements() + { + return _scores.entrySet().stream() + // Reserved natural ordering + .sorted((o1, o2) -> o2.getValue().compareTo(o1.getValue())) + .map(Entry::getKey) + .collect(Collectors.toList()); } private void End() { - SortScores(); - - //Set Places - ArrayList places = new ArrayList(); - for (int i=0 ; i<_ranks.size() ; i++) - places.add(i, _ranks.get(i).Player); + List places = getPlacements(); //Award Gems - if (_ranks.size() >= 1) - AddGems(_ranks.get(0).Player, 20, "1st Place", false, false); + if (!places.isEmpty()) + { + AddGems(places.get(0), 20, "1st Place", false, false); + } - if (_ranks.size() >= 2) - AddGems(_ranks.get(1).Player, 15, "2nd Place", false, false); + if (places.size() > 1) + { + AddGems(places.get(1), 15, "2nd Place", false, false); + } - if (_ranks.size() >= 3) - AddGems(_ranks.get(2).Player, 10, "3rd Place", false, false); + if (places.size() > 2) + { + AddGems(places.get(2), 10, "3rd Place", false, false); + } //Participation - for (Player player : GetPlayers(false)) + for (Player player : places) + { if (player.isOnline()) + { AddGems(player, 10, "Participation", false, false); + } + } - SetState(GameState.End); AnnounceEnd(places); + SetState(GameState.End); } @Override public void EndCheck() { if (!IsLive()) - return; - - if (!UtilTime.elapsed(GetStateTime(), 5000)) - return; - - if (_cows.GetPlayers(true).size() <= 0) - End(); - - if (_farmers.GetPlayers(true).size() <= 0) { - SetScore(_cows.GetPlayers(true).get(0), 20); + return; + } + + if (_cows.GetPlayers(true).isEmpty()) + { + End(); + } + else if (_farmers.GetPlayers(true).isEmpty()) + { + _cows.GetPlayers(true).forEach(player -> incrementScore(player, SCORE_TO_WIN)); End(); } } @@ -473,45 +453,24 @@ public class MilkCow extends SoloGame public void ScoreboardUpdate(UpdateEvent event) { if (event.getType() != UpdateType.FAST) + { return; + } - //Wipe Last - Scoreboard.reset(); - Scoreboard.writeNewLine(); Scoreboard.writeGroup(GetPlayers(true), player -> { - int score = (int)GetScore(player); - GameTeam team = GetTeam(player); - if (team == null) return null; - return Pair.create(team.GetColor() + player.getName(), score); + if (team == null) + { + return null; + } + + return Pair.create(team.GetColor() + player.getName(), getScore(player)); }, true); Scoreboard.draw(); } - - @EventHandler - public void BucketFill(PlayerBucketFillEvent event) - { - if (!IsLive()) - { - event.setCancelled(true); - UtilInv.Update(event.getPlayer()); - } - - if (event.getBlockClicked() == null) - return; - - if (event.getBlockClicked().getTypeId() != 8 && event.getBlockClicked().getTypeId() != 9) - return; - - event.setCancelled(true); - UtilInv.Update(event.getPlayer()); - - if (event.getBlockClicked() != null) - event.getPlayer().sendBlockChange(event.getBlockClicked().getLocation(), 8, (byte)0); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkRemoveEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkRemoveEvent.java index 5ac777588..8ab53cd57 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkRemoveEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/MilkRemoveEvent.java @@ -1,56 +1,40 @@ package nautilus.game.arcade.game.games.milkcow; import org.bukkit.entity.Player; -import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; -public class MilkRemoveEvent extends Event +public class MilkRemoveEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); - private Player _player; - private int _milk; - private RemoveType _cause; - - public MilkRemoveEvent(Player player, int milk, RemoveType cause) + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + public static HandlerList getHandlerList() { - _player = player; - _milk = milk; - _cause = cause; + return HANDLER_LIST; } - - public HandlerList getHandlers() + + private int _milkToRemove; + + public MilkRemoveEvent(Player who, int milkToRemove) + { + super(who); + + _milkToRemove = milkToRemove; + } + + public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() - { - return handlers; - } - - public Player GetPlayer() - { - return _player; - } - - public int GetMilk() - { - return _milk; - } - - public RemoveType GetCause() - { - return _cause; - } - - public void SetMilk(int milk) - { - _milk = milk; - } - - public static enum RemoveType - { - FLING, DEATH; + return HANDLER_LIST; } + public void setMilkToRemove(int milkToRemove) + { + _milkToRemove = milkToRemove; + } + + public int getMilkToRemove() + { + return _milkToRemove; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitCow.java index 72b3b2677..697970ff4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitCow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitCow.java @@ -3,23 +3,21 @@ package nautilus.game.arcade.game.games.milkcow.kits; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; import mineplex.core.disguise.disguises.DisguiseCow; import mineplex.core.game.kit.GameKit; import mineplex.core.itemstack.ItemStackFactory; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.milkcow.kits.perk.PerkCharge; +import nautilus.game.arcade.game.games.milkcow.kits.perk.PerkCowBomb; +import nautilus.game.arcade.game.games.milkcow.kits.perk.PerkSeismicCow; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkCharge; -import nautilus.game.arcade.kit.perks.PerkCowBomb; import nautilus.game.arcade.kit.perks.PerkDamageSet; import nautilus.game.arcade.kit.perks.PerkKnockbackMultiplier; -import nautilus.game.arcade.kit.perks.PerkSeismicCow; public class KitCow extends Kit { @@ -30,7 +28,7 @@ public class KitCow extends Kit new PerkKnockbackMultiplier(4), new PerkCharge(), new PerkCowBomb(), - new PerkSeismicCow("Body Slam") + new PerkSeismicCow() }; private static final ItemStack[] PLAYER_ITEMS = @@ -72,18 +70,8 @@ public class KitCow extends Kit //Disguise DisguiseCow disguise = new DisguiseCow(player); - disguise.setName(C.cRed + player.getName());//+ " the Furious Cow"); + disguise.setName(C.cRed + player.getName()); disguise.setCustomNameVisible(true); Manager.GetDisguise().disguise(disguise); } - - @EventHandler - public void NoDamage(CustomDamageEvent event) - { - Player player = event.GetDamageePlayer(); - if (player == null) return; - - if (HasKit(player)) - event.SetCancelled("Cow Immunity"); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitSturdyFarmhand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitSturdyFarmhand.java deleted file mode 100644 index 0f3c397fb..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/KitSturdyFarmhand.java +++ /dev/null @@ -1,40 +0,0 @@ -package nautilus.game.arcade.game.games.milkcow.kits; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.game.kit.GameKit; -import mineplex.core.itemstack.ItemStackFactory; - -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkIronSkin; -import nautilus.game.arcade.kit.perks.PerkNoSpillMilk; - -public class KitSturdyFarmhand extends Kit -{ - - private static final Perk[] PERKS = - { - new PerkNoSpillMilk(), - new PerkIronSkin(2) - }; - - private static final ItemStack[] PLAYER_ITEMS = - { - ItemStackFactory.Instance.CreateStack(Material.BUCKET) - }; - - public KitSturdyFarmhand(ArcadeManager manager) - { - super(manager, GameKit.MILK_THE_COW_FARM_HAND, PERKS); - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(PLAYER_ITEMS); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/perk/PerkCharge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/perk/PerkCharge.java new file mode 100644 index 000000000..85581a0a2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/perk/PerkCharge.java @@ -0,0 +1,134 @@ +package nautilus.game.arcade.game.games.milkcow.kits.perk; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Cow; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkCharge extends Perk +{ + + public PerkCharge() + { + super("Cow Charge", new String[] + { + C.cYellow + "Sprint" + C.cGray + " to use " + C.cGreen + "Cow Charge" + }); + } + + @EventHandler + public void collide(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!player.isSprinting() || !hasPerk(player)) + { + continue; + } + + Location location = player.getLocation(); + location.setYaw(0); + + player.getWorld().playSound(location, Sound.COW_WALK, 0.8f, 1f); + + Manager.GetCondition().Factory().Speed(GetName(), player, player, 0.9, 2, false, false, false); + + UtilEnt.getInRadius(location.clone().add(location.getDirection()), 2).forEach((entity, scale) -> + { + if (entity.equals(player) || entity instanceof Cow) + { + return; + } + + if (entity instanceof Player) + { + Player hit = (Player) entity; + + if (!Recharge.Instance.use(hit, "Hit By " + GetName(), 500, false, false)) + { + return; + } + + UtilServer.CallEvent(new MilkRemoveEvent(hit, 1)); + + for (ItemStack itemStack : hit.getInventory().getContents()) + { + if (itemStack == null || itemStack.getType() != Material.MILK_BUCKET) + { + continue; + } + + itemStack.setType(Material.BUCKET); + } + } + + Location entityLocation = entity.getLocation(); + + Vector dir = UtilAlg.getTrajectory2d(location, entityLocation); + dir.add(location.getDirection()); + dir.setY(0); + + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 3, false, false, false, player.getName(), GetName()); + Manager.GetCondition().Factory().Falling(GetName(), entity, player, 10, false, true); + + UtilAction.velocity(entity, dir, 1 + 0.8 * scale, true, 0, 0.8 + 0.4 * scale, 1.6, true); + + player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_WOOD, 0.75f, 1f); + }); + } + } + + @EventHandler + public void charge(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + { + return; + } + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!hasPerk(player)) + { + continue; + } + + if (player.isSprinting()) + { + UtilPlayer.hunger(player, -1); + + if (player.getFoodLevel() <= 0) + { + player.setSprinting(false); + } + } + else + { + UtilPlayer.hunger(player, 1); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/perk/PerkCowBomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/perk/PerkCowBomb.java new file mode 100644 index 000000000..20c84c3b5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/perk/PerkCowBomb.java @@ -0,0 +1,138 @@ +package nautilus.game.arcade.game.games.milkcow.kits.perk; + +import java.util.concurrent.TimeUnit; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Cow; +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.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.kit.Perk; + +public class PerkCowBomb extends Perk implements IThrown +{ + + private static final long COOLDOWN = TimeUnit.SECONDS.toMillis(3); + + public PerkCowBomb() + { + super("Cow Bomb", new String[] + { + C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Cow Bomb" + }); + } + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void Shoot(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + Block block = event.getClickedBlock(); + + if (UtilBlock.usable(block)) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = player.getItemInHand(); + + if (!UtilItem.isAxe(itemStack) || !hasPerk(player) || !Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } + + event.setCancelled(true); + + Manager.GetGame().CreatureAllowOverride = true; + + Location location = player.getEyeLocation(); + Cow cow = location.getWorld().spawn(location.add(location.getDirection()), Cow.class); + cow.setBaby(); + cow.setAgeLock(true); + + Manager.GetGame().CreatureAllowOverride = false; + + UtilAction.velocity(cow, player.getLocation().getDirection(), 1.4, false, 0, 0.3, 10, false); + + Manager.GetProjectile().AddThrow(cow, player, this, -1, true, true, true, true, 0.5f); + + player.sendMessage(F.main(Manager.getName(), "You used " + F.skill(GetName()) + ".")); + + player.getWorld().playSound(player.getLocation(), Sound.COW_IDLE, 2f, 1.5f); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Explode(data); + + if (target == null) + { + return; + } + + Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.PROJECTILE, 4, true, true, false, data.getThrower().getName(), GetName()); + } + + @Override + public void Idle(ProjectileUser data) + { + Explode(data); + } + + @Override + public void Expire(ProjectileUser data) + { + Explode(data); + } + + public void Explode(ProjectileUser data) + { + Location location = data.getThrown().getLocation(); + + location.getWorld().playSound(location, Sound.COW_HURT, 2f, 1.2f); + location.getWorld().createExplosion(location, 0.5f); + + data.getThrown().remove(); + } + + @Override + public void ChunkUnload(ProjectileUser data) + { + data.getThrown().remove(); + } + + @EventHandler + public void Knockback(CustomDamageEvent event) + { + if (event.GetReason() == null || !event.GetReason().contains(GetName())) + { + return; + } + + event.AddKnockback(GetName(), 5); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/perk/PerkSeismicCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/perk/PerkSeismicCow.java new file mode 100644 index 000000000..8cf699137 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/milkcow/kits/perk/PerkSeismicCow.java @@ -0,0 +1,160 @@ +package nautilus.game.arcade.game.games.milkcow.kits.perk; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Cow; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import nautilus.game.arcade.kit.Perk; + +public class PerkSeismicCow extends Perk +{ + + private static final long COOLDOWN = TimeUnit.SECONDS.toMillis(6); + private static final long LEAP_TIME = TimeUnit.SECONDS.toMillis(1); + private static final int DAMAGE = 4; + private static final int RANGE = 6; + + private final Map _live = new HashMap<>(); + + public PerkSeismicCow() + { + super("Body Slam", new String[] + { + C.cYellow + "Right-Click" + C.cGray + " with Shovel to " + C.cGreen + "Body Slam" + }); + } + + @Override + public void unregisteredEvents() + { + _live.clear(); + } + + @EventHandler + public void playerInteract(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + Block block = event.getClickedBlock(); + + if (UtilBlock.usable(block)) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = player.getItemInHand(); + + if (!UtilItem.isSpade(itemStack) || !hasPerk(player) || !Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } + + Vector direction = player.getLocation().getDirection(); + + if (direction.getY() < 0) + { + direction.setY(direction.getY() * -1); + } + + UtilAction.velocity(player, direction); + + _live.put(player, System.currentTimeMillis()); + + player.sendMessage(F.main(Manager.getName(), "You used " + F.skill(GetName()) + ".")); + } + + @EventHandler + public void updateSlam(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!UtilEnt.isGrounded(player)) + { + continue; + } + + Long last = _live.get(player); + + if (last == null || !UtilTime.elapsed(last, LEAP_TIME)) + { + return; + } + + _live.remove(player); + + Location location = player.getLocation(); + + UtilEnt.getInRadius(location, RANGE).forEach((entity, scale) -> + { + if (entity.equals(player) || entity instanceof Cow) + { + return; + } + + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, DAMAGE * scale + 0.5, false, true, false, player.getName(), GetName()); + + UtilAction.velocity(entity, UtilAlg.getTrajectory2d(location, entity.getLocation()), 1.8 * scale, true, 0, 0.4 + 1.0 * scale, 1.6, true); + + Manager.GetCondition().Factory().Falling(GetName(), entity, player, 10, false, true); + + if (entity instanceof Player) + { + player.sendMessage(F.main(Manager.getName(), F.name(player.getName()) + " hit you with " + F.skill(GetName()) + ".")); + } + }); + + location.getWorld().playSound(location, Sound.ZOMBIE_WOOD, 2f, 0.2f); + + UtilBlock.getBlocksInRadius(player.getLocation(), 4).forEach(block -> + { + if (UtilBlock.airFoliage(block.getRelative(BlockFace.UP)) && !UtilBlock.airFoliage(block)) + { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); + } + }); + } + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _live.remove(event.getPlayer()); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCharge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCharge.java deleted file mode 100644 index 3e4fbdfc3..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCharge.java +++ /dev/null @@ -1,126 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.HashMap; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent; -import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent.RemoveType; -import nautilus.game.arcade.kit.Perk; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Cow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -public class PerkCharge extends Perk -{ - public PerkCharge() - { - super("Cow Charge", new String[] - { - C.cYellow + "Sprint" + C.cGray + " to use " + C.cGreen + "Cow Charge" - }); - } - - @EventHandler - public void Damage(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!player.isSprinting()) - continue; - - if (!Kit.HasKit(player)) - continue; - - player.getWorld().playSound(player.getLocation(), Sound.COW_WALK, 0.8f, 1f); - - Manager.GetCondition().Factory().Speed(GetName(), player, player, 0.9, 2, false, false, false); - - HashMap targets = UtilEnt.getInRadius(player.getLocation().add(player.getLocation().getDirection().setY(0).normalize()), 2); - for (LivingEntity cur : targets.keySet()) - { - if (cur.equals(player)) - continue; - - if (cur instanceof Cow) - continue; - - Vector dir = UtilAlg.getTrajectory2d(player.getLocation().toVector(), cur.getLocation().toVector()); - dir.add(player.getLocation().getDirection().setY(0).normalize()); - dir.setY(0); - dir.normalize(); - - //Damage Event - Manager.GetDamage().NewDamageEvent(cur, player, null, - DamageCause.CUSTOM, 3, false, false, false, - player.getName(), GetName()); - - //Velocity - UtilAction.velocity(cur, dir, 1 + 0.8 * targets.get(cur), true, 0, 0.8 + 0.4 * targets.get(cur), 1.6, true); - - //Condition - Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true); - - //Sound - player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_WOOD, 0.75f, 1f); - - if (cur instanceof Player) - { - MilkRemoveEvent e = new MilkRemoveEvent((Player)cur, 1, RemoveType.FLING); - Bukkit.getPluginManager().callEvent(e); - ItemStack bucket = e.GetPlayer().getInventory().getItem(0); - if ((bucket.getType() == Material.MILK_BUCKET) && e.GetMilk() >= 0) - { - bucket.setType(Material.BUCKET); - e.GetPlayer().getInventory().setItem(0, bucket); - } - UtilInv.Update(e.GetPlayer()); - } - } - } - } - - @EventHandler - public void Charge(UpdateEvent event) - { - if (event.getType() != UpdateType.FASTER) - return; - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!Kit.HasKit(player)) - continue; - - if (player.isSprinting()) - { - UtilPlayer.hunger(player, -1); - - if (player.getFoodLevel() <= 0) - { - player.setSprinting(false); - } - } - else - { - UtilPlayer.hunger(player, 1); - } - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCowBomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCowBomb.java deleted file mode 100644 index a8c1fda22..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCowBomb.java +++ /dev/null @@ -1,140 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.Cow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; - -import mineplex.core.common.util.C; -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.UtilInv; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.Perk; - -public class PerkCowBomb extends Perk implements IThrown -{ - public PerkCowBomb() - { - super("Cow Bomb", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Cow Bomb" - }); - } - - - @EventHandler - public void Shoot(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (UtilBlock.usable(event.getClickedBlock())) - return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; - - Player player = event.getPlayer(); - - if (!Kit.HasKit(player)) - return; - - if (!Recharge.Instance.use(player, GetName(), 3000, true, true)) - return; - - event.setCancelled(true); - - UtilInv.Update(player); - - Manager.GetGame().CreatureAllowOverride = true; - Cow ent = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), Cow.class); - Manager.GetGame().CreatureAllowOverride = false; - ent.setBaby(); - ent.setAgeLock(true); - ent.setMaxHealth(100); - ent.setHealth(100); - - UtilAction.velocity(ent, player.getLocation().getDirection(), 1.4, false, 0, 0.3, 10, false); - - Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, true, - null, 1f, 1f, - null, 1, UpdateType.SLOW, - 0.5f); - - //Inform - UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); - - //Effect - player.getWorld().playSound(player.getLocation(), Sound.COW_IDLE, 2f, 1.5f); - } - - @Override - public void Collide(LivingEntity target, Block block, ProjectileUser data) - { - Explode(data); - - if (target == null) - return; - - //Damage Event - Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, - DamageCause.PROJECTILE, 4, true, true, false, - UtilEnt.getName(data.getThrower()), GetName()); - } - - @Override - public void Idle(ProjectileUser data) - { - Explode(data); - } - - @Override - public void Expire(ProjectileUser data) - { - Explode(data); - } - - public void Explode(ProjectileUser data) - { - //Effect - data.getThrown().getWorld().playSound(data.getThrown().getLocation(), Sound.COW_HURT, 2f, 1.2f); - data.getThrown().getWorld().playSound(data.getThrown().getLocation(), Sound.COW_HURT, 2f, 1.2f); - - data.getThrown().getWorld().createExplosion(data.getThrown().getLocation(), 0.5f); - data.getThrown().remove(); - } - - @Override - public void ChunkUnload(ProjectileUser data) - { - data.getThrown().remove(); - } - - @EventHandler - public void Knockback(CustomDamageEvent event) - { - if (event.GetReason() == null || !event.GetReason().contains(GetName())) - return; - - event.AddKnockback(GetName(), 5); - } -} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNoSpillMilk.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNoSpillMilk.java deleted file mode 100644 index fd4400d73..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkNoSpillMilk.java +++ /dev/null @@ -1,43 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import mineplex.core.common.util.C; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent; -import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent.RemoveType; -import nautilus.game.arcade.kit.Perk; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -public class PerkNoSpillMilk extends Perk -{ - - public PerkNoSpillMilk() - { - super("Steady Hands", new String[] - { - C.cGray + "Lose less milk when you die", - C.cGray + "Don't lose your bucket of milk when cows run into you", - }); - } - - @EventHandler - public void onLoseMilk(MilkRemoveEvent event) - { - Player player = event.GetPlayer(); - - if (!Kit.HasKit(player)) - return; - - if (event.GetCause() == RemoveType.DEATH) - { - if (event.GetMilk() > 3) - event.SetMilk(3); - } - - if (event.GetCause() == RemoveType.FLING) - { - event.SetMilk(-1); - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicCow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicCow.java deleted file mode 100644 index f259ca0a2..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicCow.java +++ /dev/null @@ -1,148 +0,0 @@ -package nautilus.game.arcade.kit.perks; - -import java.util.HashMap; - -import org.bukkit.Effect; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Cow; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.kit.Perk; - -public class PerkSeismicCow extends Perk -{ - private HashMap _live = new HashMap(); - - public PerkSeismicCow(String displayName) - { - super(displayName, new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Shovel to " + C.cGreen + "Seismic Slam" - }); - } - - public PerkSeismicCow() - { - super("Seismic Slam", new String[] - { - C.cYellow + "Right-Click" + C.cGray + " with Shovel to " + C.cGreen + "Seismic Slam" - }); - } - - @EventHandler - public void Leap(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (UtilBlock.usable(event.getClickedBlock())) - return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SPADE")) - return; - - Player player = event.getPlayer(); - - if (!Kit.HasKit(player)) - return; - - if (!Recharge.Instance.use(player, GetName(), 6000, true, true)) - return; - - //Action - Vector vec = player.getLocation().getDirection(); - if (vec.getY() < 0) - vec.setY(vec.getY() * -1); - - UtilAction.velocity(player, vec, 1, true, 1, 0, 1, true); - - //Record - _live.put(player, System.currentTimeMillis()); - - //Inform - UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); - } - - @EventHandler - public void Slam(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!UtilEnt.isGrounded(player)) - continue; - - if (!_live.containsKey(player)) - continue; - - if (!UtilTime.elapsed(_live.get(player), 1000)) - continue; - - _live.remove(player); - - //Action - int damage = 4; - double range = 6; - - HashMap targets = UtilEnt.getInRadius(player.getLocation(), range); - for (LivingEntity cur : targets.keySet()) - { - if (cur.equals(player)) - continue; - - if (cur instanceof Cow) - continue; - - //Damage Event - Manager.GetDamage().NewDamageEvent(cur, player, null, - DamageCause.CUSTOM, damage * targets.get(cur) + 0.5, false, true, false, - player.getName(), GetName()); - - //Velocity - UtilAction.velocity(cur, - UtilAlg.getTrajectory2d(player.getLocation().toVector(), cur.getLocation().toVector()), - 1.8 * targets.get(cur), true, 0, 0.4 + 1.0 * targets.get(cur), 1.6, true); - - //Condition - Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true); - - //Inform - if (cur instanceof Player) - UtilPlayer.message((Player)cur, F.main("Game", F.name(player.getName()) +" hit you with " + F.skill(GetName()) + ".")); - } - - //Effect - player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_WOOD, 2f, 0.2f); - for (Block cur : UtilBlock.getInRadius(player.getLocation(), 4d).keySet()) - if (UtilBlock.airFoliage(cur.getRelative(BlockFace.UP)) && !UtilBlock.airFoliage(cur)) - cur.getWorld().playEffect(cur.getLocation(), Effect.STEP_SOUND, cur.getTypeId()); - } - } -}