diff --git a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/EnclosedInteger.java b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/EnclosedInteger.java index 8342fd33e..4e0791615 100644 --- a/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/EnclosedInteger.java +++ b/Plugins/Mineplex.ClansQueue.Common/src/com/mineplex/clansqueue/common/EnclosedInteger.java @@ -1,39 +1,39 @@ -package com.mineplex.clansqueue.common; - -import javax.annotation.concurrent.NotThreadSafe; - -@NotThreadSafe -public class EnclosedInteger -{ - private int _value; - - public EnclosedInteger(int value) - { - _value = value; - } - - public EnclosedInteger() - { - this(0); - } - - public int get() - { - return _value; - } - - public int getAndIncrement() - { - return _value++; - } - - public int incrementAndGet() - { - return ++_value; - } - - public void set(int newValue) - { - _value = newValue; - } +package com.mineplex.clansqueue.common; + +import javax.annotation.concurrent.NotThreadSafe; + +@NotThreadSafe +public class EnclosedInteger +{ + private int _value; + + public EnclosedInteger(int value) + { + _value = value; + } + + public EnclosedInteger() + { + this(0); + } + + public int get() + { + return _value; + } + + public int getAndIncrement() + { + return _value++; + } + + public int incrementAndGet() + { + return ++_value; + } + + public void set(int newValue) + { + _value = newValue; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java index ba36f3406..4dcc784b1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapManager.java @@ -780,7 +780,7 @@ public class ItemMapManager extends MiniPlugin if (_scanList.size() % 20 == 0) { - Collections.sort(_scanList, _comparator); + _scanList.sort(_comparator); } if (_scanList.isEmpty()) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MinestrikeServerTypePage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MinestrikeServerTypePage.java deleted file mode 100644 index ef8df629a..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MinestrikeServerTypePage.java +++ /dev/null @@ -1,58 +0,0 @@ - -package mineplex.hub.server.ui; - -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.donation.DonationManager; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.shop.page.ShopPageBase; -import mineplex.hub.server.ServerManager; -import mineplex.serverdata.data.ServerGroup; - -public class MinestrikeServerTypePage extends ShopPageBase -{ - - private ServerGroup _serverGroup; - - public MinestrikeServerTypePage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, - DonationManager donationManager, Player player, ServerGroup serverGroup) - { - super(plugin, shop, clientManager, donationManager, serverGroup.getServerNpcName(), player, 27); - - _serverGroup = serverGroup; - - buildPage(); - } - - @Override - protected void buildPage() - { - setItem(12, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cYellow + "MineStrike Classic") - .addLore(new String[] - { - C.Reset + "", - C.Reset + C.cGreen + "Click to Play", - }).build()); - - setItem(14, new ItemBuilder(Material.SKULL_ITEM, 2, (byte) 3).setTitle(C.Reset + C.cYellow + "StrikeGames") - .addLore(new String[] - { - C.Reset + "", - C.Reset + C.cGray + "Survival Games with MineStrike weapons", - C.Reset + "", - C.Reset + C.cGreen + "Click to Play" - }).build()); - - getButtonMap().put(12, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "MineStrike Classic", player, "MS"))); - getButtonMap().put(14, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "StrikeGames", player, "MS2"))); - } - - public void Update() - { - getButtonMap().clear(); - buildPage(); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java index ed12076f1..abac54336 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java @@ -29,9 +29,6 @@ public class ServerNpcShop extends ShopBase case "HG": return new ServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup); - case "MS": - return new MinestrikeServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup); - case "UHC": return new UHCServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 3cfbb5831..1aaa215d4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -106,12 +106,8 @@ import nautilus.game.arcade.game.games.spleef.SpleefTeams; import nautilus.game.arcade.game.games.spleef.modes.UltraSpleef; import nautilus.game.arcade.game.games.squidshooter.SquidShooter; import nautilus.game.arcade.game.games.stacker.Stacker; -import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames; -import nautilus.game.arcade.game.games.survivalgames.TeamSurvivalGames; -import nautilus.game.arcade.game.games.survivalgames.modes.ChangingKits; -import nautilus.game.arcade.game.games.survivalgames.modes.OverpoweredSurvival; -import nautilus.game.arcade.game.games.survivalgames.modes.StrikeGames; -import nautilus.game.arcade.game.games.survivalgames.modes.UHCSurvivalgames; +import nautilus.game.arcade.game.games.survivalgames.SurvivalGamesNewSolo; +import nautilus.game.arcade.game.games.survivalgames.SurvivalGamesNewTeams; import nautilus.game.arcade.game.games.tug.Tug; import nautilus.game.arcade.game.games.turfforts.TurfForts; import nautilus.game.arcade.game.games.typewars.TypeWars; @@ -204,8 +200,8 @@ public enum GameType SpleefTeams(SpleefTeams.class, GameDisplay.SpleefTeams), SquidShooter(SquidShooter.class, GameDisplay.SquidShooter), Stacker(Stacker.class, GameDisplay.Stacker), - SurvivalGames(SoloSurvivalGames.class, GameDisplay.SurvivalGames), - SurvivalGamesTeams(TeamSurvivalGames.class, GameDisplay.SurvivalGamesTeams, new GameType[]{GameType.SurvivalGames}, false), + SurvivalGames(SurvivalGamesNewSolo.class, GameDisplay.SurvivalGames), + SurvivalGamesTeams(SurvivalGamesNewTeams.class, GameDisplay.SurvivalGamesTeams, new GameType[]{GameType.SurvivalGames}, false), Tug(Tug.class, GameDisplay.Tug), TurfWars(TurfForts.class, GameDisplay.TurfWars), UHC(UHCTeams.class, GameDisplay.UHC), @@ -228,11 +224,6 @@ public enum GameType Gladiators(Gladiators.class, GameDisplay.Gladiators), Skyfall(SoloSkyfall.class, GameDisplay.Skyfall), SkyfallTeams(TeamSkyfall.class, GameDisplay.SkyfallTeams, new GameType[]{GameType.Skyfall}, false), - StrikeGames(StrikeGames.class, new GameMode[]{}, GameDisplay.StrikeGames, new Pair[] - { - Pair.create(MinecraftVersion.Version1_8, "http://file.mineplex.com/ResStrikeGames18.zip"), - Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResStrikeGames19.zip") - }, true, new GameType[]{GameType.SurvivalGames}, false, false), BouncyBalls(BouncyBalls.class, GameDisplay.BouncyBalls), @@ -280,15 +271,7 @@ public enum GameType new GameMode(DukesOfDecoration.class, GameType.Build, "Dukes Of Decoration"), new GameMode(GodBattles.class, GameType.UHC, "God Battles"), new GameMode(BloodDiamonds.class, GameType.UHC, "Blood Diamonds"), - new GameMode(Assassins.class, GameType.UHC, "Assassins"), - new GameMode(OverpoweredSurvival.class, GameType.SurvivalGames, "OP Survival Games"), - new GameMode(UHCSurvivalgames.class, GameType.SurvivalGames, "UHC Survivalgames"), - new GameMode(ChangingKits.class, GameType.SurvivalGames, "Changing Kits"), - //new GameMode(StrikeGames.class, GameType.SurvivalGames, "Strike Games", new Pair[] - //{ - // Pair.create(MinecraftVersion.Version1_8, "http://file.mineplex.com/ResStrikeGames18.zip"), - // Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResStrikeGames19.zip") - //}, true), + new GameMode(Assassins.class, GameType.UHC, "Assassins"), new GameMode(TinyWinners.class, GameType.Micro, "Tiny Winners"), new GameMode(OverpoweredMicroBattles.class, GameType.Micro, "OP Micro Battles"), new GameMode(CookieFight.class, GameType.Micro, "Cookie Fight"), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/ChestRefillEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/ChestRefillEvent.java index ed2f18fff..b2cd5bbbf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/ChestRefillEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/ChestRefillEvent.java @@ -1,31 +1,24 @@ package nautilus.game.arcade.events; import java.util.ArrayList; +import java.util.List; import org.bukkit.Location; -import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -/** - * ChestRefillEvent - * - * @author xXVevzZXx - */ -public class ChestRefillEvent extends Event implements Cancellable +public class ChestRefillEvent extends Event { private static final HandlerList handlers = new HandlerList(); + + private final List _chests; - private boolean _cancelled = false; - - private ArrayList _chests; - - public ChestRefillEvent(ArrayList chests) + public ChestRefillEvent(List chests) { - _chests = (ArrayList) chests.clone(); + _chests = new ArrayList<>(chests); } - public ArrayList getChests() + public List getChests() { return _chests; } @@ -40,16 +33,4 @@ public class ChestRefillEvent extends Event implements Cancellable return handlers; } - @Override - public boolean isCancelled() - { - return _cancelled; - } - - @Override - public void setCancelled(boolean cancelled) - { - _cancelled = cancelled; - } - } 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 addf3d969..1c2035728 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 @@ -45,6 +45,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.scoreboard.NameTagVisibility; +import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; @@ -68,7 +69,6 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTabTitle; import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.elo.EloPlayer; import mineplex.core.elo.EloTeam; @@ -95,9 +95,6 @@ import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.games.build.Build; -import nautilus.game.arcade.game.games.draw.Draw; -import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; import nautilus.game.arcade.game.modules.AntiExpOrbModule; import nautilus.game.arcade.game.modules.Module; import nautilus.game.arcade.game.modules.gamesummary.GameSummaryModule; @@ -2109,17 +2106,19 @@ public abstract class Game extends ListenerComponent implements Lifetimed } Location loc = player.getLocation(); + String name = "Body #" + ++_deadBodyCount; - String name = "Body #" + _deadBodyCount++; - - Team team = Scoreboard.getScoreboard().getTeam(ChatColor.COLOR_CHAR + "DeadBodies"); - - if (team == null) + if (UseCustomScoreboard) { - team = Scoreboard.getScoreboard().registerNewTeam(ChatColor.COLOR_CHAR + "DeadBodies"); - team.setNameTagVisibility(NameTagVisibility.NEVER); + for (Player other : UtilServer.getPlayersCollection()) + { + setupDeadBodyScoreboard(other.getScoreboard(), name); + } + } + else + { + setupDeadBodyScoreboard(Scoreboard.getScoreboard(), name); } - team.addEntry(name); EntityItem entityItem = new EntityItem( ((CraftWorld) loc.getWorld()).getHandle(), @@ -2152,6 +2151,19 @@ public abstract class Game extends ListenerComponent implements Lifetimed getArcadeManager().GetDisguise().disguise(disguise); } + private void setupDeadBodyScoreboard(Scoreboard scoreboard, String name) + { + Team team = scoreboard.getTeam(ChatColor.COLOR_CHAR + "DeadBodies"); + + if (team == null) + { + team = scoreboard.registerNewTeam(ChatColor.COLOR_CHAR + "DeadBodies"); + team.setNameTagVisibility(NameTagVisibility.NEVER); + } + + team.addEntry(name); + } + @EventHandler(priority = EventPriority.HIGHEST) public void onDeadBodyItemSpawn(ItemSpawnEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitDemolitionist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitDemolitionist.java index 648fd93f0..2f5577241 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitDemolitionist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitDemolitionist.java @@ -31,12 +31,12 @@ public class KitDemolitionist extends KitPlayer }, new Perk[][] { - new Perk[] {new PerkBomberHG(10, 2, true)}, - new Perk[] {new PerkBomberHG(10, 4, true)}, - new Perk[] {new PerkBomberHG(10, 6, true)}, - new Perk[] {new PerkBomberHG(10, 4, true)}, - new Perk[] {new PerkBomberHG(10, 4, true)}, - new Perk[] {new PerkBomberHG(10, 6, true)} + new Perk[] {new PerkBomberHG(10, 2)}, + new Perk[] {new PerkBomberHG(10, 4)}, + new Perk[] {new PerkBomberHG(10, 6)}, + new Perk[] {new PerkBomberHG(10, 4)}, + new Perk[] {new PerkBomberHG(10, 4)}, + new Perk[] {new PerkBomberHG(10, 6)} }, new String[][] { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java index f046879d3..345df00fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java @@ -58,7 +58,6 @@ import mineplex.core.gadget.gadgets.morph.MorphBlock; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.give.Give; -import mineplex.core.gadget.gadgets.mount.Mount; import mineplex.core.punish.PunishClient; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -67,7 +66,6 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.games.bridge.Bridge; import nautilus.game.arcade.game.games.smash.SuperSmash; -import nautilus.game.arcade.game.games.survivalgames.SurvivalGames; import nautilus.game.arcade.kit.Kit; public class EventModule extends MiniPlugin @@ -572,40 +570,6 @@ public class EventModule extends MiniPlugin ((Bridge) Manager.GetGame()).setBridgeTime((int) ((System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + seconds * 1000)); UtilPlayer.message(event.getPlayer(), F.main("Event", "Bridges will drop in " + F.elem(seconds + " Seconds") + "!")); } - else if (args[0].equalsIgnoreCase("dm")) - { - if (!(Manager.GetGame() instanceof SurvivalGames)) - { - UtilPlayer.message(event.getPlayer(), F.main("Event", "You can only start the deathmatch in SG!")); - return; - } - - if (((SurvivalGames) Manager.GetGame()).isDeathMatchTeleported()) - { - UtilPlayer.message(event.getPlayer(), F.main("Event", "The Deathmatch has already began!")); - return; - } - - Manager.GetGame().Announce(C.cGreen + C.Bold + event.getPlayer().getName() - + " has initiated Deathmatch!"); - Manager.GetGame().Announce(C.cGreen + C.Bold + "Deathmatch starting in 60 seconds..."); - - ((SurvivalGames) Manager.GetGame()).setDeathMatchTime(60); - - for (Player player : UtilServer.getPlayers()) - player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, - 1f); - } - else if (args[0].equalsIgnoreCase("supplydrop")) - { - if (!(Manager.GetGame() instanceof SurvivalGames)) - { - UtilPlayer.message(event.getPlayer(), F.main("Event", "You can only start the Supply Srop in SG!")); - return; - } - - Manager.GetGame().WorldData.World.setTime(18000); - } else if (args[0].equalsIgnoreCase("smash")) { if (!(Manager.GetGame() instanceof SuperSmash)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java index 2580bc656..988e8fed1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java @@ -87,11 +87,9 @@ import nautilus.game.arcade.game.games.skyfall.kits.KitStunner; import nautilus.game.arcade.game.games.skyfall.quests.RingQuestTracker; import nautilus.game.arcade.game.games.skyfall.stats.AeronaughtStatTracker; import nautilus.game.arcade.game.games.skyfall.stats.RingStatTracker; -import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent; import nautilus.game.arcade.game.modules.VersionModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker; import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker; import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker; @@ -191,7 +189,6 @@ public abstract class Skyfall extends Game registerStatTrackers(new WinWithoutWearingArmorStatTracker(this), new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"), - new FirstSupplyDropOpenStatTracker(this), new RingStatTracker(this), new AeronaughtStatTracker(this)); @@ -331,9 +328,7 @@ public abstract class Skyfall extends Game _chestsRefilled = System.currentTimeMillis(); _refillAnnounced = false; - ChestRefillEvent refillEvent = UtilServer.CallEvent(new ChestRefillEvent(_lowerIsland.getChests())); - if (refillEvent.isCancelled()) - return; + UtilServer.CallEvent(new ChestRefillEvent(_lowerIsland.getChests())); _lowerIsland.refillChests(); @@ -749,9 +744,9 @@ public abstract class Skyfall extends Game && event.getClickedBlock().getLocation().getBlockY() == _supplyDrop.getBlockY() && event.getClickedBlock().getLocation().getBlockZ() == _supplyDrop.getBlockZ()) { - UtilServer.CallEvent(new SupplyChestOpenEvent(event.getPlayer(), event.getClickedBlock())); if (!_supplyOpened) { + AddStat(event.getPlayer(), "SupplyDropsOpened", 1, false, false); AddGems(event.getPlayer(), 15, "Supply Drop", false, false); _supplyOpened = true; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/BlockChange.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/BlockChange.java deleted file mode 100644 index 6b29d54fd..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/BlockChange.java +++ /dev/null @@ -1,17 +0,0 @@ -package nautilus.game.arcade.game.games.survivalgames; - -import org.bukkit.Location; - -public class BlockChange -{ - public Location Location; - public int Id; - public byte Data; - - public BlockChange(Location loc, int id, byte data) - { - Location = loc; - Id = id; - Data = data; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/ChunkChange.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/ChunkChange.java deleted file mode 100644 index f4d9ea553..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/ChunkChange.java +++ /dev/null @@ -1,52 +0,0 @@ -package nautilus.game.arcade.game.games.survivalgames; - -import java.util.ArrayList; - -import net.minecraft.server.v1_8_R3.PlayerChunkMap; - -import org.bukkit.Chunk; -import org.bukkit.Location; - -public class ChunkChange -{ - public Chunk Chunk; - public long Time; - public ArrayList Changes; - public short[] DirtyBlocks = new short[64]; - public short DirtyCount = 0; - - public ChunkChange(Location loc, int id, byte data) - { - Chunk = loc.getChunk(); - - Changes = new ArrayList(); - - AddChange(loc, id, data); - - Time = System.currentTimeMillis(); - } - - public void AddChange(Location loc, int id, byte data) - { - Changes.add(new BlockChange(loc, id, data)); - - if (DirtyCount < 63) - { - short short1 = (short)((loc.getBlockX() & 0xF) << 12 | (loc.getBlockZ() & 0xF) << 8 | loc.getBlockY()); - - for (int l = 0; l < DirtyCount; l++) - { - if (DirtyBlocks[l] == short1) - { - return; - } - } - - DirtyBlocks[(DirtyCount++)] = short1; - } - else - { - DirtyCount++; - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java deleted file mode 100644 index d6e8b49a5..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java +++ /dev/null @@ -1,222 +0,0 @@ -package nautilus.game.arcade.game.games.survivalgames; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -import mineplex.core.common.util.C; -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.GameStateChangeEvent; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.chat.ChatStatData; -import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker; -import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker; -import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker; -import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker; - -public class SoloSurvivalGames extends SurvivalGames -{ - - private GameTeam _players; - - public SoloSurvivalGames(ArcadeManager manager) - { - this(manager, GameType.SurvivalGames); - - registerStatTrackers(new WinWithoutWearingArmorStatTracker(this), - new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"), - new FirstSupplyDropOpenStatTracker(this), - new SimultaneousSkeletonStatTracker(this, 5)); - - registerChatStats( - Kills, - Assists, - BlankLine, - DamageTaken, - DamageDealt, - BlankLine, - new ChatStatData("SupplyDropsOpened", "Event chests opened", true) - ); - } - - public SoloSurvivalGames(ArcadeManager manager, GameType type) - { - super(manager, type, - new String[] - { - "Search for chests to find loot", - - "Slaughter your opponents", - - "Stay away from the borders!", - - "Last tribute alive wins!" - }); - - this.DamageTeamSelf = true; - } - - public SoloSurvivalGames(ArcadeManager manager, Kit[] kits, GameType type) - { - super(manager, kits, type, - new String[] - { - "Search for chests to find loot", - - "Slaughter your opponents", - - "Stay away from the borders!", - - "Last tribute alive wins!" - }); - - this.DamageTeamSelf = true; - } - - @EventHandler - public void CustomTeamGeneration(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Recruit) - return; - - _players = GetTeamList().get(0); - _players.SetColor(ChatColor.YELLOW); - _players.SetName("Players"); - _players.setDisplayName(C.cYellow + C.Bold + "Players"); - } - - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - if (GetTeamList().isEmpty()) - return; - - Scoreboard.reset(); - - Scoreboard.writeNewLine(); - - GameTeam team = GetTeamList().get(0); - - Scoreboard.write(C.cGreen + C.Bold + "Time"); - Scoreboard.write(UtilTime.convertString(this.getSecondsSinceStart() * 1000, 0, TimeUnit.FIT)); - - Scoreboard.writeNewLine(); - - Scoreboard.write(C.cYellow + C.Bold + "Tributes"); - if (team.GetPlayers(true).size() > 7) - { - Scoreboard.write("" + team.GetPlayers(true).size()); - } - else - { - for (Player player : team.GetPlayers(true)) - { - Scoreboard.write(C.cWhite + player.getName()); - } - } - - Scoreboard.writeNewLine(); - - if (this.getChestRefillTime() > 0 && this.getDeathMatchTime() > 60) - { - Scoreboard.write(C.cGold + C.Bold + "Chest Refill"); - Scoreboard.write(UtilTime.convertString(this.getChestRefillTime() * 1000, 0, TimeUnit.FIT)); - } - else if (this.getDeathMatchTime() > 0) - { - Scoreboard.write(C.cRed + C.Bold + "Deathmatch"); - Scoreboard.write(UtilTime.convertString( - Math.min(this.getDeathMatchTime(), this.isDeathMatchTeleported() ? 10 : this.getDeathMatchTime()) * 1000, 0, TimeUnit.FIT)); - } - else - { - Scoreboard.write(C.cRed + C.Bold + "Game End"); - Scoreboard.write(UtilTime.convertString(Math.max(0, this.getGameEndTime()) * 1000, 0, TimeUnit.FIT)); - } - - Scoreboard.draw(); - } - - @Override - public void EndCheck() - { - if (!IsLive()) - return; - - if (GetPlayers(true).size() <= 1) - { - ArrayList places = GetTeamList().get(0).GetPlacements(true); - - //Announce - AnnounceEnd(places); - - //Gems - if (places.size() >= 1) - AddGems(places.get(0), 20, "1st Place", false, false); - - if (places.size() >= 2) - AddGems(places.get(1), 15, "2nd Place", false, false); - - if (places.size() >= 3) - AddGems(places.get(2), 10, "3rd Place", false, false); - - for (Player player : GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false, false); - - //End - SetState(GameState.End); - } - } - - @Override - public List getWinners() - { - if (GetState().ordinal() >= GameState.End.ordinal()) - { - List places = GetTeamList().get(0).GetPlacements(true); - - if (places.isEmpty() || !places.get(0).isOnline()) - return Arrays.asList(); - else - return Arrays.asList(places.get(0)); - } - else - return null; - } - - @Override - public List getLosers() - { - List winners = getWinners(); - - if (winners == null) - return null; - - List losers = GetTeamList().get(0).GetPlayers(false); - - losers.removeAll(winners); - - return losers; - } - - @Override - public String GetMode() - { - return "Solo Mode"; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SupplyChestOpenEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SupplyChestOpenEvent.java deleted file mode 100644 index 59bb96cd1..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SupplyChestOpenEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -package nautilus.game.arcade.game.games.survivalgames; - -import org.bukkit.block.*; -import org.bukkit.entity.*; -import org.bukkit.event.*; -import org.bukkit.event.player.*; - -public class SupplyChestOpenEvent extends PlayerEvent -{ - private static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() - { - return handlers; - } - - @Override - public HandlerList getHandlers() - { - return getHandlerList(); - } - - private final Block _chest; - - public SupplyChestOpenEvent(Player who, Block chest) - { - super(who); - - _chest = chest; - } - - public Block getChest() - { - return _chest; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java deleted file mode 100644 index 0a323ec8a..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ /dev/null @@ -1,2254 +0,0 @@ -package nautilus.game.arcade.game.games.survivalgames; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Random; -import java.util.Set; - -import net.minecraft.server.v1_8_R3.EntityLargeFireball; -import net.minecraft.server.v1_8_R3.PacketPlayOutScoreboardTeam; -import net.minecraft.server.v1_8_R3.WorldServer; - -import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Effect; -import org.bukkit.FireworkEffect; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.WorldBorder; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.BlockState; -import org.bukkit.block.Chest; -import org.bukkit.block.DoubleChest; -import org.bukkit.block.Furnace; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLargeFireball; -import org.bukkit.craftbukkit.v1_8_R3.scoreboard.CraftScoreboard; -import org.bukkit.craftbukkit.v1_8_R3.util.LongHash; -import org.bukkit.entity.Boat; -import org.bukkit.entity.Egg; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Fireball; -import org.bukkit.entity.Firework; -import org.bukkit.entity.ItemFrame; -import org.bukkit.entity.Player; -import org.bukkit.entity.Snowball; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockSpreadEvent; -import org.bukkit.event.block.LeavesDecayEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.hanging.HangingBreakEvent; -import org.bukkit.event.inventory.CraftItemEvent; -import org.bukkit.event.inventory.InventoryOpenEvent; -import org.bukkit.event.inventory.PrepareItemCraftEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.vehicle.VehicleCreateEvent; -import org.bukkit.inventory.BeaconInventory; -import org.bukkit.inventory.FurnaceInventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.FireworkMeta; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.scoreboard.Scoreboard; -import org.bukkit.scoreboard.Team; -import org.bukkit.util.Vector; - -import mineplex.core.Managers; -import mineplex.core.account.permissions.Permission; -import mineplex.core.account.permissions.PermissionGroup; -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.UtilEvent; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.loot.ChestLoot; -import mineplex.core.loot.RandomItem; -import mineplex.core.recharge.Recharge; -import mineplex.core.titles.tracks.standard.LuckyTrack; -import mineplex.core.titles.tracks.standard.UnluckyTrack; -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.ChestRefillEvent; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.games.survivalgames.kit.KitArcher; -import nautilus.game.arcade.game.games.survivalgames.kit.KitAssassin; -import nautilus.game.arcade.game.games.survivalgames.kit.KitAxeman; -import nautilus.game.arcade.game.games.survivalgames.kit.KitBarbarian; -import nautilus.game.arcade.game.games.survivalgames.kit.KitBeastmaster; -import nautilus.game.arcade.game.games.survivalgames.kit.KitBomber; -import nautilus.game.arcade.game.games.survivalgames.kit.KitBrawler; -import nautilus.game.arcade.game.games.survivalgames.kit.KitHorseman; -import nautilus.game.arcade.game.games.survivalgames.kit.KitKnight; -import nautilus.game.arcade.game.games.survivalgames.kit.KitLooter; -import nautilus.game.arcade.game.games.survivalgames.kit.KitNecromancer; -import nautilus.game.arcade.game.games.survivalgames.kit.KitScavenger; -import nautilus.game.arcade.game.modules.winstreak.WinStreakModule; -import nautilus.game.arcade.game.modules.compass.CompassModule; -import nautilus.game.arcade.kit.Kit; - -public abstract class SurvivalGames extends Game -{ - // Chest loot - private ChestLoot _baseLoot = new ChestLoot(true); - private ChestLoot _spawnLoot = new ChestLoot(true); - private ChestLoot _crateLoot = new ChestLoot(true); - private ChestLoot _deathMatchLoot = new ChestLoot(true); - - // Furnace loot - private ChestLoot _rawFurnace = new ChestLoot(true); - private ChestLoot _cookedFurnace = new ChestLoot(true); - - private HashMap> _hiddenNames = new HashMap>(); - private HashSet _lootedBlocks = new HashSet(); - - // Misc - private HashMap _tntMap = new HashMap(); - private HashSet _placedBlocks = new HashSet(); - private Location _spawn; - - // Supply Drop - private ArrayList _supplyLocations = new ArrayList(); - private Location _supplyCurrent = null; - private Location _supplyEffect = null; - private ArrayList _supplyCrates = new ArrayList(); - private HashSet _landedCrates = new HashSet(); - - // Border - private int _secondsSinceStart; - private HashMap _borderPositions = new HashMap(); - private double _currentBorder; - private double _previousBorder; - private long _borderStartedMoving; - - // Deathmatch - private boolean _deathMatchTeleported = false; - private int _deathMatchTime = 10 * 60; - private boolean _informedDeathmatchCommand; - private int _gameEndTime = 3 * 60; - - private int _chestRefillTime = 60 * 7; - - public enum Perm implements Permission - { - FORCE_DEATHMATCH - } - - public SurvivalGames(ArcadeManager manager, GameType type, String[] description) - { - this(manager, new Kit[] - { - new KitAxeman(manager), - - // new KitLooter(manager), - - new KitKnight(manager), - - new KitArcher(manager), - - new KitBrawler(manager), - - new KitAssassin(manager), - - new KitBeastmaster(manager), - - new KitBomber(manager), - - new KitNecromancer(manager), - - new KitBarbarian(manager), - - new KitHorseman(manager), - - //new KitScavenger(manager) - }, type, description); - } - - public SurvivalGames(ArcadeManager manager, Kit[] kits, GameType type, - String[] description) - { - super(manager, type, kits, description); - - _help = new String[] - { - C.cGreen + "Use a Compass to find and kill enemies!", - - C.cGreen + "You lose Speed 2 at start of game if you attack.", - - C.cAqua + "Avoid enemies who have better gear than you!" - }; - - // Manager.GetAntiStack().SetEnabled(false); - - StrictAntiHack = true; - - AnnounceStay = false; - - HideTeamSheep = true; - - this.ReplaceTeamsWithKits = true; - - GameTimeout = 1500000; - - QuitDropItems = true; - - WorldTimeSet = 0; - WorldBoundaryKill = false; - - DamageSelf = true; - DamageTeamSelf = true; - - DeathDropItems = true; - - ItemDrop = true; - ItemPickup = true; - - InventoryClick = true; - InventoryOpenBlock = true; - InventoryOpenChest = true; - - PlaySoundGameStart = false; - PrepareTime = 15000; - - DeadBodies = true; - - BlockBreakAllow.add(Material.WEB.getId()); // Web - BlockPlaceAllow.add(Material.WEB.getId()); - - BlockBreakAllow.add(Material.LEAVES.getId()); // Leaves - BlockBreakAllow.add(Material.LEAVES_2.getId()); // Leaves - - BlockPlaceAllow.add(Material.CAKE_BLOCK.getId()); - BlockBreakAllow.add(Material.CAKE_BLOCK.getId()); - - BlockBreakAllow.add(Material.LONG_GRASS.getId()); - BlockBreakAllow.add(Material.RED_ROSE.getId()); - BlockBreakAllow.add(Material.YELLOW_FLOWER.getId()); - BlockBreakAllow.add(Material.BROWN_MUSHROOM.getId()); - BlockBreakAllow.add(Material.RED_MUSHROOM.getId()); - BlockBreakAllow.add(Material.DEAD_BUSH.getId()); - BlockBreakAllow.add(Material.CARROT.getId()); - BlockBreakAllow.add(Material.POTATO.getId()); - BlockBreakAllow.add(Material.DOUBLE_PLANT.getId()); - BlockBreakAllow.add(Material.CROPS.getId()); - BlockBreakAllow.add(Material.SAPLING.getId()); - BlockBreakAllow.add(Material.VINE.getId()); - BlockBreakAllow.add(Material.WATER_LILY.getId()); - - // Manager.GetStatsManager().addTable(getName(), "kills", "deaths", - // "chestsOpened"); - - setupLoot(); - - new CompassModule() - .setGiveCompass(true) - .setGiveCompassToSpecs(true) - .setGiveCompassToAlive(false) - .register(this); - - new WinStreakModule() - .register(this); - - if (UtilServer.isTestServer()) - { - PermissionGroup.ADMIN.setPermission(Perm.FORCE_DEATHMATCH, true, true); - PermissionGroup.QA.setPermission(Perm.FORCE_DEATHMATCH, true, true); - } - } - - private double getCurrentBorder() - { - // The distance between the old border and the new - double distanceMovedSince = _currentBorder - _previousBorder; - - // Multiply that distance depending on how long its been since it moved. - long timeSinceMoved = System.currentTimeMillis() - _borderStartedMoving; - double percentageBorderMoved = Math.min(timeSinceMoved, 1000D) / 1000D; - - distanceMovedSince *= percentageBorderMoved; - - return (_previousBorder - 0.3D) + distanceMovedSince; - } - - public boolean isOutsideBorder(Location loc) - { - double border = getCurrentBorder(); - - return (loc.getX() > _spawn.getX() + border - || loc.getX() < _spawn.getX() - border - || loc.getZ() > _spawn.getZ() + border - || loc.getZ() < _spawn.getZ() - border); - } - - @EventHandler - public void BlockBreak(BlockBreakEvent event) - { - Block block = event.getBlock(); - - if (_placedBlocks.remove(block.getLocation())) - { - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, - block.getType()); - block.setType(Material.AIR); - } - } - - @EventHandler - public void BlockBurn(BlockBurnEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void BlockDecay(LeavesDecayEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void BlockFade(BlockFadeEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void BlockSpread(BlockSpreadEvent event) - { - event.setCancelled(true); - } - - protected ItemStack buildCompass(int uses) - { - ItemBuilder item = new ItemBuilder(Material.COMPASS); - item.setTitle(C.cWhite + "Player Tracker" + buildTime()); - - item.addLore(C.cBlue + "Uses remaining: " + C.cWhite + uses); - item.addLore(C.cGray + "Use this to find the location and"); - item.addLore(C.cGray + "distance of the nearest player!"); - - return item.build(); - } - - private String buildTime() - { - String s = ""; - - for (char c : ("" + System.nanoTime()).toCharArray()) - { - s += "ยง" + c; - } - - return s; - } - - @EventHandler - public void CancelItemFrameBreak(HangingBreakEvent event) - { - if (event.getEntity() instanceof ItemFrame) - { - event.setCancelled(true); - } - } - - public void refillSecond() - { - if (_deathMatchTime <= 60) - return; - - if (_chestRefillTime <= 0) - return; - - _chestRefillTime--; - - switch (_chestRefillTime) - { - case 0: - - Announce(C.cGold + C.Bold + "The chests have been refilled!", false); - - for (Player player : Bukkit.getOnlinePlayers()) - { - player.playSound(player.getEyeLocation(), - Sound.IRONGOLEM_DEATH, 1000, 0); - } - - refillChests(); - - _chestRefillTime--; - break; - case 300: - case 180: - case 120: - case 60: - case 30: - case 15: - case 10: - case 5: - case 4: - case 3: - case 2: - case 1: - - String time; - - if (_chestRefillTime >= 60) - { - time = (_chestRefillTime / 60) + " minute" - + (_chestRefillTime > 60 ? "s" : ""); - } - else - { - time = _chestRefillTime + " second" - + (_chestRefillTime != 1 ? "s" : ""); - } - - Announce(C.cGold + C.Bold + "The chests will be refilled in " - + time, false); - - break; - default: - break; - } - } - - @EventHandler - public void CreateRandomChests(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - HashSet ignore = new HashSet(); - - ignore.add(Material.LEAVES); - - int xDiff = WorldData.MaxX - WorldData.MinX; - int zDiff = WorldData.MaxZ - WorldData.MinZ; - - Set illegalCoordinates = new HashSet<>(); - - for (GameTeam team : GetTeamList()) - { - for (Location l : team.GetSpawns()) - { - illegalCoordinates.add(LongHash.toLong(l.getBlockX(), l.getBlockZ())); - } - } - - int done = 0; - - while (done < 40) - { - int tx = WorldData.MinX + UtilMath.r(xDiff); - int tz = WorldData.MinZ + UtilMath.r(zDiff); - - // Don't spawn chest on spawn platform - if (illegalCoordinates.contains(LongHash.toLong(tx, tz))) - continue; - - Block block = UtilBlock.getHighest(WorldData.World, tx, tz, ignore); - - if (!UtilBlock.airFoliage(block) - || !UtilBlock.solid(block.getRelative(BlockFace.DOWN))) - continue; - - block.setTypeIdAndData(Material.CHEST.getId(), - (byte) UtilMath.r(4), true); - done++; - } - } - - @EventHandler - public void DayNightCycle(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.TICK) - return; - - if (_deathMatchTeleported) - return; - - long time = WorldData.World.getTime(); - - if (time > 22000 || time < 14000) - { - WorldTimeSet = (WorldTimeSet + 4) % 24000; - } - else - { - WorldTimeSet = (WorldTimeSet + 16) % 24000; - } - - WorldData.World.setTime(WorldTimeSet); - } - - @EventHandler - public void onVechilePlace(VehicleCreateEvent event) - { - if (event.getVehicle() instanceof Boat) - { - for (int x = -1; x <= 1; x++) - { - for (int y = -1; y <= 1; y++) - { - for (int z = -1; z <= 1; z++) - { - Block b = event.getVehicle().getLocation().add(x, y, z) - .getBlock(); - - if (b.isLiquid()) - { - return; - } - } - } - } - - event.getVehicle().remove(); - } - } - - @EventHandler - public void deathmatchBowShoot(EntityShootBowEvent event) - { - if (!_deathMatchTeleported) - return; - - if (_deathMatchTime <= 0) - return; - - event.getProjectile().remove(); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void DeathmatchDamage(CustomDamageEvent event) - { - if (!_deathMatchTeleported) - return; - - if (_deathMatchTime <= 0) - return; - - event.SetCancelled("Deathmatch"); - } - - @EventHandler - public void DeathmatchMoveCancel(PlayerMoveEvent event) - { - if (_deathMatchTime <= 0) - return; - - if (!_deathMatchTeleported) - return; - - if (UtilMath.offset2d(event.getFrom(), event.getTo()) == 0) - return; - - if (!IsAlive(event.getPlayer())) - return; - - event.setTo(event.getFrom()); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void DeathmatchStart(PlayerCommandPreprocessEvent event) - { - if (!event.getMessage().equalsIgnoreCase("/dm")) - return; - - event.setCancelled(true); - - // If the player cannot force deathmatch, do the normal checks, - // otherwise ignore these - if (!Manager.GetClients().Get(event.getPlayer()).hasPermission(Perm.FORCE_DEATHMATCH)) - { - if (!IsAlive(event.getPlayer())) - { - UtilPlayer.message(event.getPlayer(), - F.main("Game", "You are not in the game.")); - return; - } - - if (!IsLive() || _deathMatchTime <= 60) - { - UtilPlayer.message(event.getPlayer(), - F.main("Game", "Deathmatch cannot be started now.")); - return; - } - - if (_secondsSinceStart < 5 * 60 || GetPlayers(true).size() > 4) - { - UtilPlayer.message(event.getPlayer(), - F.main("Game", "Deathmatch cannot be started now.")); - return; - } - } - - Announce(C.cGreen + C.Bold + event.getPlayer().getName() - + " has initiated Deathmatch!"); - Announce(C.cGreen + C.Bold + "Deathmatch starting in 60 seconds..."); - - _deathMatchTime = 60; - - for (Player player : UtilServer.getPlayers()) - player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, - 1f); - } - - - protected void deathmatchTeleport() - { - for (GameTeam team : GetTeamList()) - team.SpawnTeleport(false); - } - - private void deathmatchSecond() - { - if (_deathMatchTime <= 0) - { - _gameEndTime--; - - if (_gameEndTime <= 0) - { - for (Player player : GetPlayers(true)) - { - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.CUSTOM, 1, false, true, true, - "Game End", "Game End Damage"); - } - } - - return; - } - - _deathMatchTime--; - - if (_deathMatchTime > 0 && _deathMatchTime <= 60) - { - if (_deathMatchTime % 30 == 0 - || _deathMatchTime == 15 - || _deathMatchTime == 10 - || (_deathMatchTeleported ? _deathMatchTime <= 10 - : _deathMatchTime <= 5)) - { - if (_deathMatchTeleported && _deathMatchTime <= 10) - { - Announce(C.cRed + C.Bold + "Deathmatch in " - + _deathMatchTime + "..."); - } - else - { - Announce(C.cGreen + C.Bold + "Deathmatch starting in " - + _deathMatchTime + " seconds..."); - } - } - } - - if (_deathMatchTeleported) - { - if (_deathMatchTime == 5) - { - VisibilityManager vm = Managers.require(VisibilityManager.class); - for (Player player : GetPlayers(true)) - { - Bukkit.getOnlinePlayers().forEach(pl -> vm.refreshVisibility(pl, player)); - } - } - else if (_deathMatchTime == 0) - { - Announce(C.cRed + C.Bold + "Deathmatch has begun!", false); - - _spawn.getWorld() - .playSound(_spawn, Sound.WITHER_DEATH, 1000, 0); - - refillChests(); - } - } - else if (_deathMatchTime == 0) - { - _deathMatchTeleported = true; - - WorldTimeSet = 0; - WorldData.World.setTime(15000); - - deathmatchTeleport(); - - _borderPositions.clear(); - - _currentBorder = 30.5; - _previousBorder = 30.5; - int i = 0; - - for (double border : buildBorders((2 * 30) - 15, 30.5, 7.5)) - { - _borderPositions.put(_secondsSinceStart + 60 + (i++ * 2), - border); - } - - _borderStartedMoving = System.currentTimeMillis(); - - WorldBorder border = WorldData.World.getWorldBorder(); - border.setSize(_currentBorder * 2, 1); - - _deathMatchTime = 11; - } - else - { - if (_deathMatchTime <= 60) - return; - - if (_secondsSinceStart < 5 * 60) - return; - - if (GetPlayers(true).size() > 4) - return; - - if (_informedDeathmatchCommand) - return; - - Announce(C.cGreen + C.Bold + "Type " + ChatColor.RESET + C.Bold - + "/dm" + C.cGreen + C.Bold + " to start Deathmatch!"); - - _informedDeathmatchCommand = true; - } - } - - @EventHandler - public void DisableDamageLevel(CustomDamageEvent event) - { - event.SetDamageToLevel(false); - } - - @EventHandler - public void SnowballEggsDamage(CustomDamageEvent event) - { - if (event.GetProjectile() instanceof Snowball - || event.GetProjectile() instanceof Egg) - { - event.AddMod("Projectile", "Projectile", 0.01, false); - } - } - - @EventHandler - public void DisallowBrewingStand(PlayerInteractEvent event) - { - if (event.getClickedBlock() == null) - return; - - if (event.getClickedBlock().getType() == Material.BREWING_STAND) - { - event.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void ExplosionDamageRemove(EntityExplodeEvent event) - { - event.blockList().clear(); - } - - public void fillChest(Player looter, Block block) - { - _lootedBlocks.add(block.getLocation()); - - Chest chest = (Chest) block.getState(); - - chest.getBlockInventory().clear(); - - int items = 2; - if (Math.random() > 0.50) - items++; - if (Math.random() > 0.65) - items++; - if (Math.random() > 0.80) - items++; - if (Math.random() > 0.95) - items++; - - boolean spawnChest = _chestRefillTime > 0 - && UtilMath.offset(chest.getLocation(), _spawn) < 8; - - if (spawnChest) - items += 3; - - if (GetKit(looter) instanceof KitLooter) - { - items += UtilMath.r(3); - } - - if (_supplyCrates.contains(block)) - { - items = 2; - if (Math.random() > 0.75) - items++; - if (Math.random() > 0.95) - items++; - } - - for (int i = 0; i < items; i++) - { - ItemStack item; - - if (spawnChest) - { - item = _spawnLoot.getLoot(); - } - else if (_deathMatchTeleported) - { - item = _deathMatchLoot.getLoot(); - } - else - { - item = GetChestItem(_supplyCrates.contains(block)); - } - - if (item.getType() == Material.COMPASS) - { - item = buildCompass(5); - } - - handlePickup(item); - - chest.getBlockInventory().setItem(UtilMath.r(27), item); - } - - if (_supplyCrates.contains(block)) - { - Bukkit.getPluginManager().callEvent( - new SupplyChestOpenEvent(looter, block)); - } - - _supplyCrates.remove(block); - - if (getArcadeManager().GetServerConfig().RewardStats) - { - getArcadeManager().getTrackManager().getTrack(LuckyTrack.class).handleLoot(looter, chest.getBlockInventory()); - getArcadeManager().getTrackManager().getTrack(UnluckyTrack.class).handleLoot(looter, chest.getBlockInventory()); - } - } - - protected ItemStack GetChestItem(boolean superChest) - { - if (superChest) - return _crateLoot.getLoot(); - - return _baseLoot.getLoot(); - } - - @Override - public double GetKillsGems(Player killer, Player killed, boolean assist) - { - if (assist) - return 3; - else return 12; - } - - // If an item spawns and no one is there to see it, does it really spawn? - // No. - @EventHandler - public void ItemSpawn(ItemSpawnEvent event) - { - if (event.getEntity().getItemStack().hasItemMeta()) - return; - - Material mat = event.getEntity().getItemStack().getType(); - - switch (mat) - { - case SEEDS: - case SAPLING: - case VINE: - case LEAVES: - case LONG_GRASS: - case RED_ROSE: - case YELLOW_FLOWER: - case DEAD_BUSH: - case WATER_LILY: - event.setCancelled(true); - return; - case CARROT_ITEM: - if (UtilMath.r(10) != 0) - { - event.setCancelled(true); - } - return; - case POTATO_ITEM: - if (UtilMath.r(10) != 0) - { - event.setCancelled(true); - } - return; - case WHEAT: - if (UtilMath.r(6) != 0) - { - event.setCancelled(true); - } - return; - case WOOD: - event.setCancelled(true); - return; - - default: - break; - } - - for (Player player : GetPlayers(true)) - if (UtilMath.offset(player, event.getEntity()) < 6) - return; - - event.setCancelled(true); - } - - @EventHandler - public void onGameEnd(GameStateChangeEvent event) - { - if (event.GetState() != GameState.End) - return; - - new BukkitRunnable() - { - public void run() - { - if (GetState() != GameState.End) - { - cancel(); - return; - } - - for (Location loc : GetTeamList().get(0).GetSpawns()) - { - Firework firework = (Firework) loc.getWorld().spawnEntity( - loc, EntityType.FIREWORK); - - FireworkMeta meta = firework.getFireworkMeta(); - - meta.addEffect(FireworkEffect.builder() - .withColor(Color.AQUA).with(Type.BALL).withTrail() - .build()); - - firework.setFireworkMeta(meta); - } - } - }.runTaskTimer(getArcadeManager().getPlugin(), 0, 60); - } - - @EventHandler - public void onSecond(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - { - return; - } - - if (!IsLive()) - { - return; - } - - _previousBorder = _currentBorder; - - // We half the number so this only activates every 2nd second. - if (_borderPositions.containsKey(_secondsSinceStart)) - { - _currentBorder = _borderPositions.get(_secondsSinceStart); - - _borderStartedMoving = System.currentTimeMillis(); - - WorldBorder border = WorldData.World.getWorldBorder(); - border.setSize(_currentBorder * 2, 1); - } - - _secondsSinceStart++; - - refillSecond(); - deathmatchSecond(); - } - - @EventHandler - public void onUse(PlayerInteractEvent event) - { - if (!IsLive()) - return; - - Player player = event.getPlayer(); - - if (!IsAlive(player)) - return; - - if (!event.getAction().name().contains("RIGHT")) - return; - - ItemStack item = event.getItem(); - - if (item == null || item.getType() != Material.COMPASS) - return; - - if (!Recharge.Instance.use(player, "Use Compass", 2500, true, true)) - { - return; - } - - int uses = Integer.parseInt(ChatColor.stripColor( - item.getItemMeta().getLore().get(0)).replaceAll("\\D+", "")); - - if (uses > 0) - { - uses--; - - Player closestPlayer = null; - double closestDistance = 0; - - for (Player alive : GetPlayers(true)) - { - if (alive != player && getArcadeManager().canHurt(player, alive)) - { - double distance = alive.getLocation().distance( - player.getLocation()); - - if (distance > 10 - && (closestPlayer == null || distance < closestDistance)) - { - closestDistance = distance; - closestPlayer = alive; - } - } - } - - if (closestPlayer != null) - { - player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1, 0); - - player.setCompassTarget(closestPlayer.getLocation()); - player.setItemInHand(buildCompass(uses)); - - player.sendMessage(F.main("Compass", - "Located " + closestPlayer.getName() + " " - + (int) closestDistance + " blocks away")); - - if (uses >= 1) - { - player.sendMessage(F.main("Compass", uses + " use" - + (uses > 1 ? "s" : "") - + " of the compass remaining.")); - } - else - { - player.sendMessage(F.main("Compass", - "No remaining uses! Next use will break it!")); - } - } - else - { - player.sendMessage(F.main("Compass", - "Can't find anyone! Pointing to spawn!")); - player.setCompassTarget(_spawn); - } - } - else - { - player.sendMessage(F.main("Compass", - "The compass breaks! No remaining uses!")); - - player.getWorld().playSound(player.getLocation(), Sound.ITEM_BREAK, - 1, 5); - - player.setItemInHand(new ItemStack(Material.AIR)); - } - } - - @EventHandler - public void pickupItems(PlayerPickupItemEvent event) - { - handlePickup(event.getItem().getItemStack()); - } - - public void handlePickup(ItemStack stack) - { - if (stack.getType() == Material.CARROT - || stack.getType() == Material.POTATO - || stack.getType() == Material.WHEAT - || stack.getType() == Material.CARROT_ITEM - || stack.getType() == Material.POTATO_ITEM) - { - String name = "Carrot"; - if (stack.getType() == Material.POTATO || stack.getType() == Material.POTATO_ITEM) - name = "Potato"; - if (stack.getType() == Material.WHEAT) - name = "Wheat"; - - ItemMeta meta = stack.getItemMeta(); - meta.setDisplayName(name); - stack.setItemMeta(meta); - } - } - - @EventHandler - public void OpenChest(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - Block block = event.getClickedBlock(); - - if (block == null) - return; - - if (!IsLive()) - return; - - if (_lootedBlocks.contains(block.getLocation())) - return; - - BlockState state = block.getState(); - - if (state instanceof DoubleChest) - { - DoubleChest doubleChest = (DoubleChest) state; - - fillChest(event.getPlayer(), - ((Chest) doubleChest.getLeftSide()).getBlock()); - fillChest(event.getPlayer(), - ((Chest) doubleChest.getRightSide()).getBlock()); - } - else if (state instanceof Chest) - { - fillChest(event.getPlayer(), block); - } - else if (state instanceof Furnace) - { - Furnace furnace = (Furnace) state; - - if (furnace.getCookTime() == 0) - { - FurnaceInventory inv = furnace.getInventory(); - - if (UtilMath.r(3) == 0) - { - int random = UtilMath.r(9); - - if (random == 0) - { - inv.setFuel(new ItemStack(Material.STICK, new Random() - .nextInt(2) + 1)); - } - else if (random <= 3) - { - inv.setSmelting(_rawFurnace.getLoot()); - } - else - { - inv.setResult(_cookedFurnace.getLoot()); - } - } - - _lootedBlocks.add(block.getLocation()); - } - } - } - - @EventHandler - public void outsideBorder(UpdateEvent event) - { - if (!IsLive()) - { - return; - } - - if (event.getType() != UpdateType.FAST) - { - return; - } - - double border = getCurrentBorder(); - - // 24 @ 100+ reduced to 0 at 32- - double borderAttackDist = Math.max(8, - (Math.min(100, border) - 28d) / 3d); - double borderCheckDist = borderAttackDist + 6; - - for (Player player : UtilServer.getPlayers()) - { - Location loc = player.getLocation(); - - // Bump Players Back In - if (loc.getX() > _spawn.getX() + border - || loc.getX() < _spawn.getX() - border - || loc.getZ() > _spawn.getZ() + border - || loc.getZ() < _spawn.getZ() - border) - { - if (Recharge.Instance.use(player, "Hit by Border", 1000, false, - false)) - { - Entity bottom = player; - while (bottom.getVehicle() != null) - bottom = bottom.getVehicle(); - - UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(loc, - GetSpectatorLocation()), 1.2, true, 0.4, 0, 10, - true); - - if (Manager.IsAlive(player)) - { - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.CUSTOM, 10, false, false, false, - "Nether Field", "Vaporize"); - - player.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, - 1f); - player.getWorld().playSound(loc, Sound.NOTE_BASS, 2f, - 1f); - } - } - } - - if (border < 32) - continue; - - // Attack Players who are nearby - boolean isX = true; - Location attackSource = null; - if (loc.getX() > _spawn.getX() + (border - borderCheckDist)) - { - attackSource = player.getLocation(); - attackSource.setX(_spawn.getX() + border); - } - else if (loc.getX() < _spawn.getX() - (border - borderCheckDist)) - { - attackSource = player.getLocation(); - attackSource.setX(_spawn.getX() - border); - } - else if (loc.getZ() > _spawn.getZ() + (border - borderCheckDist)) - { - attackSource = player.getLocation(); - attackSource.setZ(_spawn.getZ() + border); - isX = false; - } - else if (loc.getZ() < _spawn.getZ() - (border - borderCheckDist)) - { - attackSource = player.getLocation(); - attackSource.setZ(_spawn.getZ() - border); - isX = false; - } - - if (attackSource != null) - { - double dist = UtilMath.offset(player.getLocation(), - attackSource); - - double scale = 1 - (dist / borderAttackDist); - - player.playSound( - player.getLocation().add( - UtilAlg.getTrajectory(player.getLocation(), - attackSource).multiply(8)), - Sound.PORTAL, - (float) (1 - (dist / borderCheckDist)) * 2, 2f); - - if (!Manager.IsAlive(player)) - continue; - - // Shoot more frequently when they get closer - if (dist < borderAttackDist && Math.random() < scale) - { - // Spawn Fireball - Location spawn = attackSource.clone(); - spawn.add(isX ? 0 : (Math.random() - 0.5) * 12, - 4 + Math.random() * 2 - + (Math.random() * 12 * scale), - isX ? (Math.random() - 0.5) * 12 : 0); - - // Raytrace back - double maxBack = 8; - double back = 0; - while (spawn.getBlock().getType() == Material.AIR - && back < maxBack) - { - spawn.subtract(UtilAlg.getTrajectory(spawn, - player.getLocation()).multiply(0.2)); - back += 0.1; - } - - // Move out of block - spawn.add(UtilAlg - .getTrajectory(spawn, player.getLocation()) - .multiply(Math.min(back, 1))); - - Fireball ball = player.getWorld().spawn(spawn, - Fireball.class); - - // Trajectory - Vector traj = UtilAlg.getTrajectory(spawn, - player.getLocation()); - traj.add(new Vector((Math.random() - 0.5) * 0.2, (Math - .random() - 0.5) * 0.2, (Math.random() - 0.5) * 0.2)); - - EntityLargeFireball eFireball = ((CraftLargeFireball) ball) - .getHandle(); - eFireball.dirX = traj.getX() * 0.1; - eFireball.dirY = traj.getY() * 0.1; - eFireball.dirZ = traj.getZ() * 0.1; - - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, - spawn, 0, 0, 0, 0, 1, ViewDist.MAX, - UtilServer.getPlayers()); - player.getWorld().playSound(attackSource, - Sound.GHAST_FIREBALL, 2f, 2f); - } - } - } - } - - @EventHandler - public void borderBlockDamage(ProjectileHitEvent event) - { - if (!IsLive()) - return; - - if (!(event.getEntity() instanceof Fireball)) - return; - - Collection blocks = UtilBlock.getInRadius( - event.getEntity().getLocation(), 2.4).keySet(); - - Manager.GetExplosion().BlockExplosion(blocks, - event.getEntity().getLocation(), false); - } - - public boolean isStableBlock(Block block) - { - int sides = 0; - if (UtilBlock.solid(block.getRelative(BlockFace.NORTH))) - sides++; - if (UtilBlock.solid(block.getRelative(BlockFace.EAST))) - sides++; - if (UtilBlock.solid(block.getRelative(BlockFace.SOUTH))) - sides++; - if (UtilBlock.solid(block.getRelative(BlockFace.WEST))) - sides++; - - return sides >= 3; - } - - @EventHandler - public void borderSpecInteraction(EntityDamageByEntityEvent event) - { - if (event.getEntity() instanceof Fireball && UtilPlayer.isSpectator(event.getDamager())) - { - event.setCancelled(true); - } - } - - @EventHandler - public void borderDamage(CustomDamageEvent event) - { - if (event.GetProjectile() == null) - return; - - if (!(event.GetProjectile() instanceof Fireball)) - return; - - event.AddMult("Fireball", "Nether Field", 1, true); - - event.AddKnockback("Fireball", 2); - } - - private ArrayList buildBorders(int seconds, double border, - double leaveRemaining) - { - - double totalNumber = Math.pow(seconds, 1.9D) + (seconds * 50); - - ArrayList borders = new ArrayList(); - - for (int i = 0; i <= seconds; i++) - { - borders.add(border - - ((border - leaveRemaining) * (((Math.pow(i, 1.9D) + (i * 50))) / totalNumber))); - } - - return borders; - } - - @Override - public void ParseData() - { - _spawn = UtilWorld.averageLocation(GetTeamList().get(0).GetSpawns()); - - ArrayList borders = new ArrayList(); - - borders.add(WorldData.MaxX - _spawn.getX()); - borders.add(_spawn.getX() - WorldData.MinX); - borders.add(WorldData.MaxZ - _spawn.getZ()); - borders.add(_spawn.getZ() - WorldData.MinZ); - - Collections.sort(borders); - - double largestBorder = borders.get(3); - int i = 0; - - for (double border : buildBorders(10 * 30, largestBorder, 30.5)) - { - _borderPositions.put(i++ * 2, border); - } - - _currentBorder = _borderPositions.get(0); - _previousBorder = _currentBorder; - - for (Location loc : GetTeamList().get(0).GetSpawns()) - loc.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(loc, _spawn))); - - setupChestsEnchantingCrafting(); - - _supplyLocations = WorldData.GetDataLocs("WHITE"); - for (Location loc : _supplyLocations) - loc.getBlock().setType(Material.GLASS); - - WorldBorder border = WorldData.World.getWorldBorder(); - border.setCenter(_spawn); - border.setSize(_currentBorder * 2); - border.setDamageBuffer(-99); - border.setWarningDistance(-99); - border.setWarningTime(-99); - } - - @EventHandler - public void PlayerKill(CombatDeathEvent event) - { - if (!(event.GetEvent().getEntity() instanceof Player)) - return; - - Player player = (Player) event.GetEvent().getEntity(); - - FireworkEffect effect = FireworkEffect.builder().flicker(false) - .withColor(Color.RED).with(Type.BALL_LARGE).trail(false) - .build(); - for (int i = 0; i < 3; i++) - UtilFirework.launchFirework(player.getLocation(), effect, null, 3); - } - - @EventHandler - public void killLevelReward(CombatDeathEvent event) - { - Game game = Manager.GetGame(); - if (game == null) - return; - - if (!(event.GetEvent().getEntity() instanceof Player)) - return; - - Player killed = (Player) event.GetEvent().getEntity(); - - if (event.GetLog().GetKiller() != null) - { - Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller() - .GetName()); - - if (killer != null && !killer.equals(killed)) - { - // Kill - killer.giveExpLevels(2); - - killer.playSound(killer.getLocation(), Sound.LEVEL_UP, 1f, 1f); - } - } - - for (CombatComponent log : event.GetLog().GetAttackers()) - { - if (event.GetLog().GetKiller() != null - && log.equals(event.GetLog().GetKiller())) - continue; - - Player assist = UtilPlayer.searchExact(log.GetName()); - - // Assist - if (assist != null) - { - assist.giveExpLevels(1); - assist.playSound(assist.getLocation(), Sound.ORB_PICKUP, 1f, 1f); - } - - } - } - - @EventHandler - public void preventCrafting(PrepareItemCraftEvent event) - { - ItemStack result = event.getInventory().getResult(); - - if (result != null) - { - Material type = result.getType(); - - if (type == Material.BUCKET || type == Material.GOLDEN_APPLE - || type == Material.FLINT_AND_STEEL || type.isBlock()) - { - event.getInventory().setResult(new ItemStack(Material.AIR)); - } - } - } - - public void refillChests() - { - ArrayList list = new ArrayList(_lootedBlocks); - - ChestRefillEvent event = UtilServer.CallEvent(new ChestRefillEvent(list)); - if (event.isCancelled()) - return; - - _lootedBlocks.clear(); - - WorldServer world = list.isEmpty() ? null : ((CraftWorld) list.get(0) - .getWorld()).getHandle(); - - for (Location loc : list) - { - boolean open = false; - - if (loc.getChunk().isLoaded()) - { - Block block = loc.getBlock(); - - if (block.getState() instanceof InventoryHolder) - { - InventoryHolder holder = (InventoryHolder) block.getState(); - - if (!holder.getInventory().getViewers().isEmpty()) - { - open = true; - - if (_landedCrates.contains(loc)) - continue; - - fillChest((Player) holder.getInventory().getViewers() - .get(0), block); - } - } - } - } - } - - @EventHandler - public void RemoveNametagInfo(PlayerQuitEvent event) - { - if (!IsLive()) - { - return; - } - - if (!_hiddenNames.containsKey(event.getPlayer())) - { - return; - } - - _hiddenNames.remove(event.getPlayer()); - } - - public void setupChestsEnchantingCrafting() - { - ArrayList chests = WorldData.GetCustomLocs("54"); - - System.out.println("Map Chest Locations: " + chests.size()); - - // Enchants - System.out.println("Enchanting Tables: " + Math.min(5, chests.size())); - for (int i = 0; i < 5 && !chests.isEmpty(); i++) - { - Location loc = chests.remove(UtilMath.r(chests.size())); - loc.getBlock().setType(Material.ENCHANTMENT_TABLE); - } - - // Crafting - System.out.println("Crafting Benches: " + Math.min(10, chests.size())); - for (int i = 0; i < 10 && !chests.isEmpty(); i++) - { - Location loc = chests.remove(UtilMath.r(chests.size())); - loc.getBlock().setType(Material.WORKBENCH); - } - - int spawn = 0; - - // Chests - System.out.println("Chests: " + Math.min(250, chests.size())); - for (int i = 0; i < 250 && !chests.isEmpty(); i++) - { - Location loc = chests.remove(UtilMath.r(chests.size())); - - if (UtilMath.offset2d(loc, _spawn) < 8) - spawn++; - } - - for (Location loc : chests) - { - if (spawn < 10 && UtilMath.offset(loc, _spawn) < 8) - { - spawn++; - continue; - } - - loc.getBlock().setType(Material.AIR); - } - } - - public void setupLoot() - { - // Food - _baseLoot.addLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 3)); - _baseLoot.addLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 2)); - _baseLoot.addLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 2)); - _baseLoot.addLoot(new RandomItem(Material.CARROT_ITEM, 30, 1, 3)); - _baseLoot.addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15, 1, 1)); - _baseLoot.addLoot(new RandomItem(Material.WHEAT, 30, 1, 6)); - _baseLoot.addLoot(new RandomItem(Material.APPLE, 30, 1, 4)); - _baseLoot.addLoot(new RandomItem(Material.PORK, 30, 1, 4)); - _baseLoot.addLoot(new RandomItem(Material.ROTTEN_FLESH, 40, 1, 6)); - - // Weapons - _baseLoot.addLoot(new RandomItem(Material.WOOD_AXE, 80)); - _baseLoot.addLoot(new RandomItem(Material.WOOD_SWORD, 70)); - _baseLoot.addLoot(new RandomItem(Material.STONE_AXE, 60)); - _baseLoot.addLoot(new RandomItem(Material.STONE_SWORD, 30)); - - // Leather armor - _baseLoot.addLoot(new RandomItem(Material.LEATHER_BOOTS, 30)); - _baseLoot.addLoot(new RandomItem(Material.LEATHER_CHESTPLATE, 30)); - _baseLoot.addLoot(new RandomItem(Material.LEATHER_HELMET, 30)); - _baseLoot.addLoot(new RandomItem(Material.LEATHER_LEGGINGS, 30)); - - // Gold armor - _baseLoot.addLoot(new RandomItem(Material.GOLD_BOOTS, 25)); - _baseLoot.addLoot(new RandomItem(Material.GOLD_CHESTPLATE, 25)); - _baseLoot.addLoot(new RandomItem(Material.GOLD_HELMET, 25)); - _baseLoot.addLoot(new RandomItem(Material.GOLD_LEGGINGS, 25)); - - // Chain armor - _baseLoot.addLoot(new RandomItem(Material.CHAINMAIL_BOOTS, 20)); - _baseLoot.addLoot(new RandomItem(Material.CHAINMAIL_CHESTPLATE, 20)); - _baseLoot.addLoot(new RandomItem(Material.CHAINMAIL_HELMET, 20)); - _baseLoot.addLoot(new RandomItem(Material.CHAINMAIL_LEGGINGS, 20)); - - // Throwable - _baseLoot.addLoot(new RandomItem(Material.FISHING_ROD, 30)); - _baseLoot.addLoot(new RandomItem(Material.BOW, 20)); - _baseLoot.addLoot(new RandomItem(Material.ARROW, 20, 1, 3)); - _baseLoot.addLoot(new RandomItem(Material.SNOW_BALL, 30, 1, 2)); - _baseLoot.addLoot(new RandomItem(Material.EGG, 30, 1, 2)); - - // Misc - _baseLoot.addLoot(new RandomItem(Material.EXP_BOTTLE, 30, 1, 2)); - _baseLoot.addLoot(new RandomItem(Material.COMPASS, 20)); - _baseLoot.addLoot(new RandomItem(Material.STICK, 30, 1, 2)); - _baseLoot.addLoot(new RandomItem(Material.BOAT, 15)); - _baseLoot.addLoot(new RandomItem(Material.FLINT, 30, 1, 2)); - _baseLoot.addLoot(new RandomItem(Material.FEATHER, 30, 1, 2)); - _baseLoot.addLoot(new RandomItem(Material.GOLD_INGOT, 20)); - _baseLoot.addLoot(new RandomItem(ItemStackFactory.Instance.CreateStack( - Material.TNT, (byte) 0, 1, F.item("Throwing TNT")), 15)); - _spawnLoot.addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15)); - - _spawnLoot.cloneLoot(_baseLoot); - - // Food - _spawnLoot.addLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 5)); - _spawnLoot.addLoot(new RandomItem(Material.CAKE, 30)); - _spawnLoot.addLoot(new RandomItem(Material.MUSHROOM_SOUP, 30, 1, 1)); - _spawnLoot.addLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 3)); - _spawnLoot.addLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 3)); - _spawnLoot.addLoot(new RandomItem(Material.COOKED_FISH, 30, 1, 6)); - _spawnLoot.addLoot(new RandomItem(Material.GRILLED_PORK, 30, 1, 3)); - _spawnLoot.addLoot(new RandomItem(Material.COOKIE, 30)); - _spawnLoot.addLoot(new RandomItem(Material.PUMPKIN_PIE, 30, 1, 3)); - _spawnLoot.addLoot(new RandomItem(Material.APPLE, 30, 2, 6)); - - // Loot for chests in spawn - // Weaponry and ores - _spawnLoot.addLoot(new RandomItem(Material.STONE_SWORD, 30)); - _spawnLoot.addLoot(new RandomItem(Material.IRON_AXE, 30)); - _spawnLoot.addLoot(new RandomItem(Material.IRON_INGOT, 30, 1, 2)); - _spawnLoot.addLoot(new RandomItem(Material.DIAMOND, 30)); - - // Iron gear - _spawnLoot.addLoot(new RandomItem(Material.IRON_BOOTS, 30)); - _spawnLoot.addLoot(new RandomItem(Material.IRON_CHESTPLATE, 30)); - _spawnLoot.addLoot(new RandomItem(Material.IRON_HELMET, 30)); - _spawnLoot.addLoot(new RandomItem(Material.IRON_LEGGINGS, 30)); - - // Supply crate loot - // Diamond gear - _crateLoot.addLoot(new RandomItem(Material.DIAMOND_HELMET, 10)); - _crateLoot.addLoot(new RandomItem(Material.DIAMOND_CHESTPLATE, 6)); - _crateLoot.addLoot(new RandomItem(Material.DIAMOND_LEGGINGS, 8)); - _crateLoot.addLoot(new RandomItem(Material.DIAMOND_BOOTS, 10)); - - // Iron gear - _crateLoot.addLoot(new RandomItem(Material.IRON_HELMET, 30)); - _crateLoot.addLoot(new RandomItem(Material.IRON_CHESTPLATE, 24)); - _crateLoot.addLoot(new RandomItem(Material.IRON_LEGGINGS, 27)); - _crateLoot.addLoot(new RandomItem(Material.IRON_BOOTS, 30)); - - // Weapons - _crateLoot.addLoot(new RandomItem(Material.IRON_SWORD, 24)); - _crateLoot.addLoot(new RandomItem(Material.DIAMOND_SWORD, 8)); - _crateLoot.addLoot(new RandomItem(Material.DIAMOND_AXE, 16)); - - // Cooked furnace - _cookedFurnace.addLoot(new RandomItem(Material.COOKED_BEEF, 3, 1, 2)); - _cookedFurnace - .addLoot(new RandomItem(Material.COOKED_CHICKEN, 3, 1, 2)); - _cookedFurnace.addLoot(new RandomItem(Material.COOKED_FISH, 3, 1, 2)); - _cookedFurnace.addLoot(new RandomItem(Material.GRILLED_PORK, 3, 1, 2)); - _cookedFurnace.addLoot(new RandomItem(Material.BAKED_POTATO, 3, 1, 1)); - _cookedFurnace.addLoot(new RandomItem(Material.PUMPKIN_PIE, 3, 1, 1)); - _cookedFurnace.addLoot(new RandomItem(Material.IRON_INGOT, 1, 1, 1)); - - // Raw furnace - _rawFurnace.addLoot(new RandomItem(Material.RAW_BEEF, 1, 1, 3)); - _rawFurnace.addLoot(new RandomItem(Material.RAW_CHICKEN, 1, 1, 3)); - _rawFurnace.addLoot(new RandomItem(Material.RAW_FISH, 1, 1, 3)); - _rawFurnace.addLoot(new RandomItem(Material.PORK, 1, 1, 3)); - _rawFurnace.addLoot(new RandomItem(Material.POTATO_ITEM, 1, 1, 3)); - - // Deathmatch Loot - _deathMatchLoot.addLoot(new RandomItem(Material.PUMPKIN_PIE, 4)); - _deathMatchLoot.addLoot(new RandomItem(Material.BAKED_POTATO, 4)); - _deathMatchLoot.addLoot(new RandomItem(Material.CAKE, 4)); - _deathMatchLoot.addLoot(new RandomItem(Material.APPLE, 4)); - _deathMatchLoot.addLoot(new RandomItem(Material.CARROT_ITEM, 4)); - _deathMatchLoot.addLoot(new RandomItem(Material.WOOD_SWORD, 3)); - _deathMatchLoot.addLoot(new RandomItem(Material.WOOD_AXE, 3)); - _deathMatchLoot.addLoot(new RandomItem(Material.STONE_AXE, 3)); - _deathMatchLoot.addLoot(new RandomItem(Material.STONE_SWORD, 1)); - } - - @EventHandler - public void SpeedRemove(CustomDamageEvent event) - { - Player damager = event.GetDamagerPlayer(true); - if (damager != null) - Manager.GetCondition().EndCondition(damager, null, "Start Speed"); - } - - @EventHandler - public void StartEffectApply(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - return; - - Scoreboard board = GetScoreboard().getScoreboard(); - - for (Player player : GetPlayers(true)) - { - player.playSound(player.getLocation(), Sound.DONKEY_DEATH, 0.8F, 0); - - Manager.GetCondition() - .Factory() - .Speed("Start Speed", player, player, 30, 1, false, false, - false); - Manager.GetCondition() - .Factory() - .HealthBoost("Start Health", player, player, 30, 1, false, - false, false); - - player.setHealth(player.getMaxHealth()); - - _hiddenNames.put(player, new HashSet()); - } - } - - @EventHandler - public void SupplyDrop(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.FASTEST) - return; - - long time = WorldData.World.getTime(); - - if (time > 14000 && time < 23000) - { - if (_supplyCurrent == null && !_deathMatchTeleported) - { - if (_supplyLocations.isEmpty()) - return; - - _supplyCurrent = _supplyLocations.remove(UtilMath - .r(_supplyLocations.size())); - - // Remove Prior - _supplyCrates.remove(_supplyCurrent.getBlock().getRelative( - BlockFace.UP)); - _supplyCurrent.getBlock().getRelative(BlockFace.UP) - .setType(Material.AIR); - - // Create New - _supplyCurrent.getBlock().setType(Material.BEACON); - for (int x = -1; x <= 1; x++) - for (int z = -1; z <= 1; z++) - _supplyCurrent.getBlock().getRelative(x, -1, z) - .setType(Material.IRON_BLOCK); - - // Announce - Announce(C.cYellow + C.Bold + "Supply Drop Incoming (" - + ChatColor.RESET - + UtilWorld.locToStrClean(_supplyCurrent) + C.cYellow - + C.Bold + ")"); - } - } - else - { - if (_supplyCurrent != null) - { - if (_supplyEffect == null) - { - _supplyEffect = _supplyCurrent.clone(); - _supplyEffect.setY(250); - } - - FireworkEffect effect = FireworkEffect.builder().flicker(false) - .withColor(Color.YELLOW).with(Type.BURST).trail(false) - .build(); - UtilFirework.playFirework(_supplyEffect, effect); - - _supplyEffect.setY(_supplyEffect.getY() - 2); - - if (UtilMath.offset(_supplyEffect, _supplyCurrent) < 2) - { - effect = FireworkEffect.builder().flicker(false) - .withColor(Color.YELLOW).with(Type.BALL_LARGE) - .trail(true).build(); - UtilFirework.playFirework(_supplyEffect, effect); - - // Create Chest - _supplyCurrent.getBlock().setType(Material.GLASS); - - Block block = _supplyCurrent.getBlock().getRelative( - BlockFace.UP); - block.setType(Material.CHEST); - _landedCrates.add(block.getLocation()); - _supplyCrates.add(block); - _lootedBlocks.remove(_supplyCurrent); - - // Reset - _supplyEffect = null; - _supplyCurrent = null; - } - } - } - } - - @EventHandler - public void SupplyGlow(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.TICK) - return; - - if (_supplyCrates.isEmpty()) - return; - - Iterator chestIterator = _supplyCrates.iterator(); - - while (chestIterator.hasNext()) - { - Block block = chestIterator.next(); - - if (block.getType() != Material.CHEST) - { - chestIterator.remove(); - continue; - } - - UtilParticle.PlayParticle(ParticleType.SPELL, block.getLocation() - .add(0.5, 0.5, 0.5), 0.3f, 0.3f, 0.3f, 0, 1, ViewDist.LONG, - UtilServer.getPlayers()); - } - } - - @EventHandler - public void TNTDelay(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - return; - - for (Player player : UtilServer.getPlayers()) - Recharge.Instance.useForce(player, "Throw TNT", 30000); - } - - @EventHandler - public void TNTExplosion(ExplosionPrimeEvent event) - { - if (!_tntMap.containsKey(event.getEntity())) - return; - - Player player = _tntMap.remove(event.getEntity()); - - if (_deathMatchTeleported && _deathMatchTime > 0) - { - event.setCancelled(true); - return; - } - - /* - * CustomExplosion explosion = new - * CustomExplosion(getArcadeManager().GetDamage(), - * event.getEntity().getLocation(), ((TNTPrimed) - * event.getEntity()).getYield(), "Throwing TNT"); - * - * explosion.setPlayer(player, true); - */ - - for (Player other : UtilPlayer.getNearby(event.getEntity() - .getLocation(), 14)) - Manager.GetCondition() - .Factory() - .Explosion("Throwing TNT", other, player, 50, 0.1, false, - false); - } - - @EventHandler - public void TNTThrow(PlayerInteractEvent event) - { - if (!IsLive()) - return; - - if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null) - { - if (UtilBlock.usable(event.getClickedBlock())) - { - return; - } - } - - Player player = event.getPlayer(); - - if (!UtilInv.IsItem(player.getItemInHand(), Material.TNT, (byte) 0)) - return; - - if (!IsAlive(player)) - return; - - event.setCancelled(true); - - if (!Recharge.Instance.use(player, "Throw TNT", 250, true, false)) - { - return; - } - - if (!Manager.GetGame().CanThrowTNT(player.getLocation()) || (_deathMatchTeleported && _deathMatchTime > 0)) - { - // Inform - UtilPlayer.message( - event.getPlayer(), - F.main(GetName(), "You cannot use " + F.item("Throw TNT") - + " here.")); - return; - } - - UtilInv.remove(player, Material.TNT, (byte) 0, 1); - UtilInv.Update(player); - - TNTPrimed tnt = player.getWorld().spawn( - player.getEyeLocation() - .add(player.getLocation().getDirection()), - TNTPrimed.class); - - tnt.setFuseTicks(60); - - UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.5, - false, 0, 0.1, 10, false); - - _tntMap.put(tnt, player); - } - - @EventHandler - public void TourneyKills(CombatDeathEvent event) - { - if (!(event.GetEvent().getEntity() instanceof Player)) - return; - - Player killed = (Player) event.GetEvent().getEntity(); - - if (event.GetLog().GetKiller() != null) - { - Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller() - .GetName()); - - if (killer != null && !killer.equals(killed)) - { - // Manager.GetStatsManager().addStat(killer, getName(), "kills", - // 1); - } - } - - if (event.GetLog().GetPlayer() != null) - { - if (killed != null) - { - // Manager.GetStatsManager().addStat(killed, getName(), - // "deaths", 1); - } - } - } - - @EventHandler - public void craftedItems(CraftItemEvent event) - { - if (UtilItem.isWeapon(event.getCurrentItem()) || UtilItem.isArmor(event.getCurrentItem()) || event.getCurrentItem().getType() == Material.FISHING_ROD) - { - UtilItem.makeUnbreakable(event.getCurrentItem()); - } - } - - @EventHandler - public void UpdateNametagVisibility(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - if (!IsLive()) - return; - - ArrayList alivePlayers = new ArrayList( - _hiddenNames.keySet()); - HashMap> checkedPlayers = new HashMap<>(); - - for (Player target : alivePlayers) - { - Team originalTeam = GetScoreboard().getScoreboard().getTeam(getArcadeManager().GetLobby().getTeamId(GetTeam(target), target)); - - // If it's null this tick, it'll be set next tick. We can wait a tick - if (originalTeam == null) - { - System.out.println("Skipping " + target.getName() + " because of a null originalTeam"); - continue; - } - - Team requestedTeam = GetScoreboard().getScoreboard().getTeam(target.getName()); - - if (requestedTeam == null) - { - requestedTeam = GetScoreboard().getScoreboard().registerNewTeam(target.getName()); - requestedTeam.addEntry(target.getName()); - requestedTeam.setPrefix(originalTeam.getPrefix()); - requestedTeam.setSuffix(originalTeam.getSuffix()); - } - else - { - if (!StringUtils.equals(requestedTeam.getPrefix(), originalTeam.getPrefix())) - { - requestedTeam.setPrefix(originalTeam.getPrefix()); - } - if (!StringUtils.equals(requestedTeam.getSuffix(), originalTeam.getSuffix())) - { - requestedTeam.setSuffix(originalTeam.getSuffix()); - } - } - - PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam(((CraftScoreboard) GetScoreboard().getScoreboard()).getHandle().getTeam(requestedTeam.getName()), 2); - - for (Player player : alivePlayers) - { - if (target != player) - { - boolean hideName = false; - - if (!checkedPlayers.containsKey(target) || !checkedPlayers.get(target).containsKey(player)) - { - if (player.getLocation().distance(target.getLocation()) > (GetKit(target) instanceof KitAssassin ? 8 : 24)) - { - hideName = true; - } - else if (!player.hasLineOfSight(target)) - { - // no los - hideName = true; - } - - Player[] players = new Player[] - { - target, player - }; - - if (!(GetKit(player) instanceof KitAssassin || GetKit(target) instanceof KitAssassin)) - { - for (int i = 0; i <= 1; i++) - { - Player p1 = players[i]; - Player p2 = players[1 - i]; - - if (!checkedPlayers.containsKey(p1)) - { - checkedPlayers.put(p1, - new HashMap()); - } - - checkedPlayers.get(p1).put(p2, hideName); - } - } - } - else - { - hideName = checkedPlayers.get(target).get(player); - } - - // If hiddenNames conta - if (hideName != _hiddenNames.get(player).contains( - target.getName())) - { - if (!hideName) - { - _hiddenNames.get(player).remove(target.getName()); - } - else - { - _hiddenNames.get(player).add(target.getName()); - } - - packet.e = hideName ? "never" : "always"; - - UtilPlayer.sendPacket(player, packet); - } - } - } - } - } - - @EventHandler - public void onInventoryOpen(InventoryOpenEvent event) - { - if (event.getInventory() instanceof BeaconInventory) - { - event.setCancelled(true); - } - } - - public int getSecondsSinceStart() - { - return _secondsSinceStart; - } - - public int getChestRefillTime() - { - return _chestRefillTime; - } - - public int getDeathMatchTime() - { - return _deathMatchTime; - } - - public boolean isDeathMatchTeleported() - { - return _deathMatchTeleported; - } - - public int getGameEndTime() - { - return _gameEndTime; - } - - public ArrayList getSupplyBlocks() - { - return _supplyCrates; - } - - public HashSet getLootedBlocks() - { - return _lootedBlocks; - } - - public ChestLoot getBaseLoot() - { - return _baseLoot; - } - - public ChestLoot getCrateLoot() - { - return _crateLoot; - } - - public ChestLoot getSpawnLoot() - { - return _spawnLoot; - } - - public ChestLoot getDeathMatch() - { - return _deathMatchLoot; - } - - public ChestLoot getRawFurnace() - { - return _rawFurnace; - } - - public ChestLoot getFurnace() - { - return _cookedFurnace; - } - - public Location getSpawn() - { - return _spawn; - } - - public void setDeathMatchTime(int time) - { - _deathMatchTime = time; - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesMapRenderer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesMapRenderer.java new file mode 100644 index 000000000..5b22ef4ae --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesMapRenderer.java @@ -0,0 +1,95 @@ +package nautilus.game.arcade.game.games.survivalgames; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.map.MapCanvas; +import org.bukkit.map.MapCursor.Type; +import org.bukkit.map.MapPalette; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; + +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.modules.worldmap.WorldMapRenderer; + +public class SurvivalGamesMapRenderer extends WorldMapRenderer +{ + + private int _borderSize; + + SurvivalGamesMapRenderer(SurvivalGamesNew game) + { + super(game); + } + + @Override + public void renderTick() + { + _borderSize = (int) _game.WorldData.World.getWorldBorder().getSize() / 2; + } + + @Override + protected void preRender(Player player) + { + + } + + @Override + protected byte renderBlock(Player player, byte color, int mapX, int mapZ, int blockX, int blockZ) + { + int scale = _manager.getScale() * 2, minX = -_borderSize, maxX = _borderSize, minZ = -_borderSize, maxZ = _borderSize; + boolean bigX = blockX > maxX, smallX = blockX < minX, bigZ = blockZ > maxZ, smallZ = blockZ < minZ; + + if (bigX || smallX || bigZ || smallZ) + { + if ( + bigX && blockX - scale < maxX && !smallX && !bigZ && !smallZ || + smallX && blockX + scale > minX && !bigX && !bigZ && !smallZ || + bigZ && blockZ - scale < maxZ && !bigX && !smallX && !smallZ || + smallZ && blockZ + scale > minZ && !bigX && !smallX && !bigZ || + (mapX + (mapZ % 4)) % 4 == 0) + { + color = MapPalette.RED; + } + } + + return color; + } + + @Override + protected void renderCursors(MapCanvas canvas, Player player) + { + GameTeam team = _game.GetTeam(player); + + for (Player other : UtilServer.getPlayersCollection()) + { + if (UtilPlayer.isSpectator(other)) + { + continue; + } + + Location location = other.getLocation(); + + if (player.equals(other)) + { + addCursor(canvas, location, Type.WHITE_POINTER); + } + else if (_game.TeamMode && team.HasPlayer(other)) + { + addCursor(canvas, location, Type.GREEN_POINTER); + } + else if (!Recharge.Instance.usable(player, "Show All Players")) + { + addCursor(canvas, location, Type.RED_POINTER); + } + } + + Location supplyDrop = _game.getSupplyDrop().getCurrentDrop(); + + if (supplyDrop != null) + { + addCursor(canvas, supplyDrop, Type.WHITE_CROSS); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNew.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNew.java new file mode 100644 index 000000000..51017493d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNew.java @@ -0,0 +1,916 @@ +package nautilus.game.arcade.game.games.survivalgames; + +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Boat; +import org.bukkit.entity.Egg; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.hanging.HangingBreakEvent; +import org.bukkit.event.inventory.CraftItemEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.vehicle.VehicleCreateEvent; +import org.bukkit.inventory.BeaconInventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scoreboard.NameTagVisibility; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.survivalgames.kit.KitArcher; +import nautilus.game.arcade.game.games.survivalgames.kit.KitAssassin; +import nautilus.game.arcade.game.games.survivalgames.kit.KitAxeman; +import nautilus.game.arcade.game.games.survivalgames.kit.KitBarbarian; +import nautilus.game.arcade.game.games.survivalgames.kit.KitBeastmaster; +import nautilus.game.arcade.game.games.survivalgames.kit.KitBomber; +import nautilus.game.arcade.game.games.survivalgames.kit.KitBrawler; +import nautilus.game.arcade.game.games.survivalgames.kit.KitHorseman; +import nautilus.game.arcade.game.games.survivalgames.kit.KitKnight; +import nautilus.game.arcade.game.games.survivalgames.kit.KitNecromancer; +import nautilus.game.arcade.game.games.survivalgames.modules.BorderModule; +import nautilus.game.arcade.game.games.survivalgames.modules.FurnaceLootModule; +import nautilus.game.arcade.game.games.survivalgames.modules.SupplyDropModule; +import nautilus.game.arcade.game.games.survivalgames.modules.TrackingCompassModule; +import nautilus.game.arcade.game.modules.CustomScoreboardModule; +import nautilus.game.arcade.game.modules.EXPForKillsModule; +import nautilus.game.arcade.game.modules.ThrowableTNTModule; +import nautilus.game.arcade.game.modules.chest.ChestLootModule; +import nautilus.game.arcade.game.modules.chest.ChestLootPool; +import nautilus.game.arcade.game.modules.combattracker.CombatData; +import nautilus.game.arcade.game.modules.combattracker.CombatTrackerModule; +import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.game.modules.winstreak.WinStreakModule; +import nautilus.game.arcade.game.modules.worldmap.WorldMapModule; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.managers.chat.ChatStatData; +import nautilus.game.arcade.scoreboard.GameScoreboard; +import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker; +import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker; +import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker; + +public abstract class SurvivalGamesNew extends Game +{ + + private static final long PREPARE_TIME = TimeUnit.SECONDS.toMillis(15); + private static final long REFILL_TIME = TimeUnit.MINUTES.toMillis(7); + private static final long REFILL_INFORM_TIME = TimeUnit.MINUTES.toMillis(3); + private static final long KIT_COOLDOWN = TimeUnit.SECONDS.toMillis(30); + private static final int MAX_ITEM_SPAWN_DISTANCE_SQUARED = 36; + private static final String START_EFFECT_REASON = "Start Effect"; + private static final int START_EFFECT_DURATION = 30; + private static final int ENCHANTMENT_TABLES = 5; + private static final int CRAFTING_TABLES = 10; + private static final int DISTANCE_NON_ASSASSIN = 576; + private static final int DISTANCE_ASSASSIN = 64; + + private List _chests; + private SupplyDropModule _supplyDrop; + private final CombatTrackerModule _combatTrackerModule; + private final CustomScoreboardModule _customScoreboardModule; + private boolean _refilled; + + SurvivalGamesNew(ArcadeManager manager, GameType gameType, String[] gameDesc) + { + super(manager, gameType, new Kit[] + { + new KitAxeman(manager), + new KitKnight(manager), + new KitArcher(manager), + new KitBrawler(manager), + new KitAssassin(manager), + new KitBeastmaster(manager), + new KitBomber(manager), + new KitNecromancer(manager), + new KitBarbarian(manager), + new KitHorseman(manager) + }, gameDesc); + + AnnounceStay = false; + StrictAntiHack = true; + + HideTeamSheep = true; + ReplaceTeamsWithKits = true; + + DeathDropItems = true; + QuitDropItems = true; + + DamageSelf = true; + DeadBodies = true; + + ItemDrop = true; + ItemPickup = true; + + InventoryClick = true; + InventoryOpenBlock = true; + InventoryOpenChest = true; + + PrepareTime = PREPARE_TIME; + PlaySoundGameStart = false; + + WorldTimeSet = 0; + WorldBoundaryKill = false; + + BlockBreakAllow.add(Material.WEB.getId()); + BlockPlaceAllow.add(Material.WEB.getId()); + + BlockBreakAllow.add(Material.LEAVES.getId()); + BlockBreakAllow.add(Material.LEAVES_2.getId()); + + BlockPlaceAllow.add(Material.CAKE_BLOCK.getId()); + BlockBreakAllow.add(Material.CAKE_BLOCK.getId()); + + BlockBreakAllow.add(Material.LONG_GRASS.getId()); + BlockBreakAllow.add(Material.RED_ROSE.getId()); + BlockBreakAllow.add(Material.YELLOW_FLOWER.getId()); + BlockBreakAllow.add(Material.BROWN_MUSHROOM.getId()); + BlockBreakAllow.add(Material.RED_MUSHROOM.getId()); + BlockBreakAllow.add(Material.DEAD_BUSH.getId()); + BlockBreakAllow.add(Material.CARROT.getId()); + BlockBreakAllow.add(Material.POTATO.getId()); + BlockBreakAllow.add(Material.DOUBLE_PLANT.getId()); + BlockBreakAllow.add(Material.CROPS.getId()); + BlockBreakAllow.add(Material.SAPLING.getId()); + BlockBreakAllow.add(Material.VINE.getId()); + BlockBreakAllow.add(Material.WATER_LILY.getId()); + + _help = new String[] + { + "Use a Compass to find and kill enemies!", + "You lose Speed 2 at start of game if you attack.", + "Avoid enemies who have better gear than you!", + "Supply drops appear on your item map!" + }; + + manager.GetCreature().SetDisableCustomDrops(true); + + registerStatTrackers + ( + new WinWithoutWearingArmorStatTracker(this), + new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"), + new SimultaneousSkeletonStatTracker(this, 5) + ); + + registerChatStats + ( + Kills, + Assists, + BlankLine, + DamageTaken, + DamageDealt, + BlankLine, + new ChatStatData("SupplyDropsOpened", "Supply Drops Opened", true) + ); + + new CompassModule() + .register(this); + + new WinStreakModule() + .register(this); + + new EXPForKillsModule() + .register(this); + + _supplyDrop = new SupplyDropModule(); + _supplyDrop.register(this); + + _combatTrackerModule = new CombatTrackerModule(); + _combatTrackerModule.register(this); + + _customScoreboardModule = new CustomScoreboardModule() + .setSidebar((player, scoreboard) -> + { + switch (GetState()) + { + case Prepare: + writePrepare(player, scoreboard); + break; + case Live: + writeLive(player, scoreboard); + break; + case End: + case WinRoom: + writeEnd(player, scoreboard); + break; + } + }) + .setPrefix((perspective, subject) -> + { + GameTeam team = GetTeam(subject); + + return team == null || !team.IsAlive(subject) ? C.cGray : team.GetColor().toString(); + }) + .setNameTagVisibility((perspective, subject) -> + { + if (!IsLive() || !IsAlive(perspective) || !IsAlive(subject)) + { + return NameTagVisibility.ALWAYS; + } + + GameTeam perspectiveTeam = GetTeam(perspective); + GameTeam subjectTeam = GetTeam(subject); + Kit kit = GetKit(subject); + + if (perspectiveTeam == null || subjectTeam == null || perspectiveTeam.equals(subjectTeam) && TeamMode) + { + return NameTagVisibility.ALWAYS; + } + else + { + return UtilMath.offsetSquared(perspective, subject) > (kit instanceof KitAssassin ? DISTANCE_ASSASSIN : DISTANCE_NON_ASSASSIN) || !perspective.hasLineOfSight(subject) ? NameTagVisibility.NEVER : NameTagVisibility.ALWAYS; + } + }); + _customScoreboardModule.register(this); + } + + private void writePrepare(Player player, GameScoreboard scoreboard) + { + GameTeam team = GetTeam(player); + + scoreboard.writeNewLine(); + + scoreboard.write((team == null ? "" : team.GetColor()) + C.Bold + "Survival Games"); + scoreboard.write(WorldData.MapName); + + scoreboard.writeNewLine(); + + scoreboard.write(C.cYellowB + "Tributes"); + scoreboard.write(GetPlayers(true).size() + " Players"); + + if (team != null && TeamMode) + { + scoreboard.writeNewLine(); + scoreboard.write(team.GetFormattedName()); + + team.GetPlayers(false).forEach(teammate -> scoreboard.write(teammate.getName())); + } + + scoreboard.writeNewLine(); + } + + private void writeLive(Player player, GameScoreboard scoreboard) + { + GameTeam team = GetTeam(player); + List alive = GetPlayers(true); + Location supplyDrop = _supplyDrop.getCurrentDrop(); + long supplyIn = (SupplyDropModule.TIME - WorldTimeSet) * 50 / 4; + long chestRefillIn = Math.max(0, GetStateTime() + REFILL_TIME - System.currentTimeMillis()); + String event, in; + + if (supplyDrop != null) + { + event = "Supply Drop"; + in = "(" + supplyDrop.getBlockX() + ", " + supplyDrop.getBlockZ() + ")"; + } + else if (!_refilled && chestRefillIn < REFILL_INFORM_TIME) + { + event = "Chest Refill"; + in = UtilTime.MakeStr(chestRefillIn); + } + else + { + event = "Supply Drop"; + in = UtilTime.MakeStr(supplyIn); + } + + scoreboard.writeNewLine(); + + scoreboard.write(C.cYellowB + "Tributes"); + + if (TeamMode) + { + List aliveTeams = GetTeamList().stream() + .filter(GameTeam::IsTeamAlive) + .collect(Collectors.toList()); + + if (alive.size() < 5) + { + for (GameTeam teams : GetTeamList()) + { + for (Player teamMember : teams.GetPlayers(true)) + { + scoreboard.write(teams.GetColor() + teamMember.getName()); + } + } + } + else if (aliveTeams.size() < 5) + { + for (GameTeam teams : aliveTeams) + { + scoreboard.write(teams.GetPlayers(true).size() + " " + teams.GetColor() + teams.GetName()); + } + } + else + { + scoreboard.write(alive.size() + " Alive"); + } + } + else + { + if (alive.size() > 6) + { + scoreboard.write(alive.size() + " Alive"); + } + else + { + alive.forEach(other -> scoreboard.write(other.getName())); + } + } + + writeStats(player, team, scoreboard); + + scoreboard.writeNewLine(); + + scoreboard.write(C.cRedB + event); + scoreboard.write(in); + } + + private void writeEnd(Player player, GameScoreboard scoreboard) + { + List winners = getWinners(); + + writeStats(player, GetTeam(player), scoreboard); + + if (winners == null) + { + return; + } + + scoreboard.writeNewLine(); + scoreboard.write(C.cYellowB + "Winner" + (TeamMode ? "s" : "")); + + for (Player winner : winners) + { + scoreboard.write(winner.getName()); + } + } + + private void writeStats(Player player, GameTeam team, GameScoreboard scoreboard) + { + if (team != null) + { + scoreboard.writeNewLine(); + + scoreboard.write(C.cGoldB + "Stats"); + + CombatData combatData = _combatTrackerModule.getCombatData(player); + + scoreboard.write("Kills: " + C.cGreen + combatData.getKills()); + scoreboard.write("Assists: " + C.cGreen + combatData.getAssits()); + + if (TeamMode) + { + int teamKills = 0, teamAssists = 0; + + for (Player teammate : team.GetPlayers(false)) + { + CombatData teammateCombatData = _combatTrackerModule.getCombatData(teammate); + + teamKills += teammateCombatData.getKills(); + teamAssists += teammateCombatData.getAssits(); + } + + scoreboard.write("Team Kills: " + C.cGreen + teamKills); + scoreboard.write("Team Assists: " + C.cGreen + teamAssists); + } + } + } + + + @Override + public void ScoreboardUpdate(UpdateEvent event) + { + } + + @Override + public void ParseData() + { + new BorderModule() + .register(this); + + setupLoot(); + + new WorldMapModule(WorldData, new SurvivalGamesMapRenderer(this)) + .register(this); + } + + private void setupLoot() + { + ThrowableTNTModule tntModule = new ThrowableTNTModule() + .setThrowStrength(0.3); + tntModule.register(this); + ItemStack tnt = tntModule.getTntItem(); + + TrackingCompassModule compassModule = new TrackingCompassModule(); + compassModule.register(this); + + new FurnaceLootModule() + .register(this); + + Location center = GetSpectatorLocation(); + _chests = WorldData.GetCustomLocs(String.valueOf(Material.CHEST.getId())); + List midChests = _chests.stream() + .filter(location -> UtilMath.offset2dSquared(location, center) < 64) + .collect(Collectors.toList()); + _chests.removeAll(midChests); + + ChestLootModule lootModule = new ChestLootModule(); + + lootModule.registerChestType("Tier 1", _chests, 0.35, + + new ChestLootPool() + .addItem(new ItemStack(Material.WOOD_AXE), 240) + .addItem(new ItemStack(Material.WOOD_SWORD), 210) + .addItem(new ItemStack(Material.STONE_AXE), 180) + .addItem(new ItemStack(Material.STONE_SWORD)) + .setUnbreakable(true) + , + + new ChestLootPool() + .addItem(new ItemStack(Material.LEATHER_HELMET)) + .addItem(new ItemStack(Material.LEATHER_CHESTPLATE)) + .addItem(new ItemStack(Material.LEATHER_LEGGINGS)) + .addItem(new ItemStack(Material.LEATHER_BOOTS)) + .addItem(new ItemStack(Material.GOLD_HELMET), 75) + .addItem(new ItemStack(Material.GOLD_CHESTPLATE), 75) + .addItem(new ItemStack(Material.GOLD_LEGGINGS), 75) + .addItem(new ItemStack(Material.GOLD_BOOTS), 75) + .addItem(new ItemStack(Material.CHAINMAIL_HELMET), 30) + .addItem(new ItemStack(Material.CHAINMAIL_CHESTPLATE), 30) + .addItem(new ItemStack(Material.CHAINMAIL_LEGGINGS), 30) + .addItem(new ItemStack(Material.CHAINMAIL_BOOTS), 30) + .setAmountsPerChest(1, 2) + .setUnbreakable(true) + , + + new ChestLootPool() + .addItem(new ItemStack(Material.FISHING_ROD)) + .addItem(new ItemStack(Material.BOW), 60) + .addItem(new ItemStack(Material.ARROW), 1, 3) + .addItem(new ItemStack(Material.SNOW_BALL), 1, 2) + .addItem(new ItemStack(Material.EGG), 1, 2) + .setUnbreakable(true) + , + + new ChestLootPool() + .addItem(new ItemStack(Material.BAKED_POTATO), 1, 3) + .addItem(new ItemStack(Material.COOKED_BEEF), 1, 2) + .addItem(new ItemStack(Material.COOKED_CHICKEN), 1, 3) + .addItem(new ItemStack(Material.CARROT_ITEM), 1, 3) + .addItem(new ItemStack(Material.WHEAT), 1, 3) + .addItem(new ItemStack(Material.APPLE), 1, 3) + .addItem(new ItemStack(Material.PORK), 1, 3) + .addItem(new ItemStack(Material.MUSHROOM_SOUP), 80) + , + + new ChestLootPool() + .addItem(new ItemStack(Material.EXP_BOTTLE), 1, 2) + .addItem(new ItemStack(Material.STICK), 1, 2) + .addItem(new ItemStack(Material.BOAT), 50) + .addItem(new ItemStack(Material.FLINT), 1, 2) + .addItem(new ItemStack(Material.FEATHER), 1, 2) + .addItem(new ItemStack(Material.GOLD_INGOT), 1, 1, 80) + .addItem(compassModule.getCompass(5)) + .addItem(tnt, 50) + ); + + lootModule.registerChestType("Tier 2", midChests, + + new ChestLootPool() + .addItem(new ItemStack(Material.WOOD_AXE), 240) + .addItem(new ItemStack(Material.WOOD_SWORD), 210) + .addItem(new ItemStack(Material.STONE_AXE), 180) + .addItem(new ItemStack(Material.STONE_SWORD)) + .addItem(new ItemStack(Material.IRON_AXE)) + .setUnbreakable(true) + , + + new ChestLootPool() + .addItem(new ItemStack(Material.LEATHER_HELMET)) + .addItem(new ItemStack(Material.LEATHER_CHESTPLATE)) + .addItem(new ItemStack(Material.LEATHER_LEGGINGS)) + .addItem(new ItemStack(Material.LEATHER_BOOTS)) + .addItem(new ItemStack(Material.GOLD_HELMET), 75) + .addItem(new ItemStack(Material.GOLD_CHESTPLATE), 75) + .addItem(new ItemStack(Material.GOLD_LEGGINGS), 75) + .addItem(new ItemStack(Material.GOLD_BOOTS), 75) + .addItem(new ItemStack(Material.CHAINMAIL_HELMET), 75) + .addItem(new ItemStack(Material.CHAINMAIL_CHESTPLATE), 75) + .addItem(new ItemStack(Material.CHAINMAIL_LEGGINGS), 75) + .addItem(new ItemStack(Material.CHAINMAIL_BOOTS), 75) + .addItem(new ItemStack(Material.IRON_HELMET), 50) + .addItem(new ItemStack(Material.IRON_CHESTPLATE), 50) + .addItem(new ItemStack(Material.IRON_LEGGINGS), 50) + .addItem(new ItemStack(Material.IRON_BOOTS), 50) + .setAmountsPerChest(1, 2) + .setUnbreakable(true) + , + + new ChestLootPool() + .addItem(new ItemStack(Material.FISHING_ROD)) + .addItem(new ItemStack(Material.BOW), 50) + .addItem(new ItemStack(Material.ARROW), 1, 3) + .addItem(new ItemStack(Material.SNOW_BALL), 1, 2) + .addItem(new ItemStack(Material.EGG), 1, 2) + .setUnbreakable(true) + , + + new ChestLootPool() + .addItem(new ItemStack(Material.BAKED_POTATO), 1, 3) + .addItem(new ItemStack(Material.COOKED_BEEF), 1, 2) + .addItem(new ItemStack(Material.COOKED_CHICKEN), 1, 3) + .addItem(new ItemStack(Material.CARROT_ITEM), 1, 3) + .addItem(new ItemStack(Material.WHEAT), 1, 3) + .addItem(new ItemStack(Material.APPLE), 1, 3) + .addItem(new ItemStack(Material.PORK), 1, 3) + .addItem(new ItemStack(Material.MUSHROOM_SOUP), 80) + .addItem(new ItemStack(Material.CAKE), 80) + , + + new ChestLootPool() + .addItem(new ItemStack(Material.EXP_BOTTLE), 1, 2) + .addItem(new ItemStack(Material.STICK), 1, 2) + .addItem(new ItemStack(Material.BOAT), 50) + .addItem(new ItemStack(Material.FLINT), 1, 2) + .addItem(new ItemStack(Material.STRING), 1, 2) + .addItem(new ItemStack(Material.FEATHER), 1, 2) + .addItem(new ItemStack(Material.GOLD_INGOT), 1, 1, 80) + .addItem(compassModule.getCompass(5)) + .addItem(new ItemStack(Material.DIAMOND), 50) + .addItem(tnt, 50) + + ); + + lootModule.register(this); + } + + @EventHandler + public void updateScoreboard(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + _customScoreboardModule.refresh(); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void createTables(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (int i = 0; i < ENCHANTMENT_TABLES; i++) + { + createRandomBlock(Material.ENCHANTMENT_TABLE); + } + + for (int i = 0; i < CRAFTING_TABLES; i++) + { + createRandomBlock(Material.WORKBENCH); + } + } + + private void createRandomBlock(Material type) + { + MapUtil.QuickChangeBlockAt(UtilAlg.Random(_chests), type); + } + + @EventHandler + public void kitCooldowns(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + for (Player player : GetPlayers(true)) + { + Kit kit = GetKit(player); + + for (Perk perk : kit.GetPerks()) + { + Recharge.Instance.useForce(player, perk.GetName(), KIT_COOLDOWN); + } + } + + Manager.runSyncLater(() -> Announce(F.main("Game", "You can now use " + F.skill("Kit Abilities") + ".")), KIT_COOLDOWN / 50); + + Manager.runSyncLater(() -> + { + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (GetKit(player) instanceof KitArcher) + { + player.sendMessage(F.main("Game", "You received your kit " + F.item("Bow") + ".")); + player.getInventory().addItem(KitArcher.BOW); + } + } + }, 90 * 20); + } + + @EventHandler + public void timeUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK || !IsLive()) + { + return; + } + + if (WorldTimeSet > 22000 || WorldTimeSet < 14000) + { + WorldTimeSet += 4; + } + else + { + WorldTimeSet += 16; + } + + WorldTimeSet %= 24000; + } + + @EventHandler + public void startEffect(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + ItemStack mapItem = getModule(WorldMapModule.class).getMapItem() + .setTitle(C.cGreenB + "World Map") + .build(); + + for (Player player : GetPlayers(true)) + { + player.playSound(player.getLocation(), Sound.DONKEY_DEATH, 0.8F, 0); + + Manager.GetCondition().Factory() + .Speed(START_EFFECT_REASON, player, player, START_EFFECT_DURATION, 1, false, false, false); + Manager.GetCondition().Factory() + .HealthBoost(START_EFFECT_REASON, player, player, START_EFFECT_DURATION, 1, false, false, false); + + player.setHealth(player.getMaxHealth()); + player.getInventory().setItem(8, mapItem); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void damage(CustomDamageEvent event) + { + Player damager = event.GetDamagerPlayer(true); + + event.SetDamageToLevel(false); + + boolean egg = event.GetProjectile() instanceof Egg; + boolean snowball = event.GetProjectile() instanceof Snowball; + + if (egg || snowball) + { + event.AddMod(event.GetDamagerPlayer(true).getName(), (egg ? "Egg" : "Snowball"), 0.5, true); + } + + if (damager != null && !event.isCancelled()) + { + Manager.GetCondition().EndCondition(damager, ConditionType.SPEED, START_EFFECT_REASON); + } + } + + @EventHandler + public void boatPlace(VehicleCreateEvent event) + { + if (!(event.getVehicle() instanceof Boat)) + { + return; + } + + for (Block block : UtilBlock.getSurrounding(event.getVehicle().getLocation().getBlock(), true)) + { + if (block.isLiquid()) + { + return; + } + } + + event.getVehicle().remove(); + } + + @EventHandler + public void inventoryOpen(InventoryOpenEvent event) + { + if (event.getInventory().getType() == InventoryType.BREWING || event.getInventory() instanceof BeaconInventory) + { + event.setCancelled(true); + } + } + + @EventHandler + public void preventItemSpawning(ItemSpawnEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getEntity().getItemStack().getType() == Material.MAP) + { + event.setCancelled(true); + return; + } + + for (Player player : GetPlayers(true)) + { + if (UtilMath.offsetSquared(event.getEntity(), player) < MAX_ITEM_SPAWN_DISTANCE_SQUARED) + { + return; + } + } + + event.setCancelled(true); + } + + @EventHandler + public void preventCrafting(PrepareItemCraftEvent event) + { + ItemStack result = event.getInventory().getResult(); + + if (result == null) + { + return; + } + + Material type = result.getType(); + + if (type == Material.BUCKET || type == Material.GOLDEN_APPLE || type == Material.FLINT_AND_STEEL || type.isBlock()) + { + event.getInventory().setResult(null); + } + } + + @EventHandler + public void craftedItems(CraftItemEvent event) + { + ItemStack itemStack = event.getCurrentItem(); + + if (UtilItem.isWeapon(itemStack) || UtilItem.isArmor(itemStack) || itemStack.getType() == Material.FISHING_ROD) + { + UtilItem.makeUnbreakable(itemStack); + } + } + + @EventHandler + public void updateRefill(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || _refilled || !UtilTime.elapsed(GetStateTime(), REFILL_TIME)) + { + return; + } + + _refilled = true; + getModule(ChestLootModule.class) + .refill(); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void explosion(EntityExplodeEvent event) + { + event.blockList().clear(); + } + + @EventHandler + public void blockBurn(BlockBurnEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void blockDecay(LeavesDecayEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void blockFade(BlockFadeEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void blockSpread(BlockSpreadEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void itemFrameBreak(HangingBreakEvent event) + { + if (event.getEntity() instanceof ItemFrame) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void blockBreak(BlockBreakEvent event) + { + if (event.isCancelled()) + { + return; + } + + Block block = event.getBlock(); + + if (UtilBlock.airFoliage(event.getBlock())) + { + event.setCancelled(true); + block.setType(Material.AIR); + } + + if (event.getBlock().getType() == Material.LEAVES && Math.random() < 0.05) + { + Location location = block.getLocation().add(0.5, 0.5, 0.5); + + event.setCancelled(true); + location.getWorld().playEffect(location, Effect.STEP_SOUND, block.getType()); + block.setType(Material.AIR); + location.getWorld().dropItemNaturally(location, new ItemStack(Material.STICK)); + } + } + + @EventHandler + public void explosionDamage(CustomDamageEvent event) + { + Player damagee = event.GetDamageePlayer(); + + if (event.GetCause() != DamageCause.ENTITY_EXPLOSION || damagee == null || !UtilEnt.isInWater(damagee)) + { + return; + } + + event.AddMod("Water Explosion", -event.GetDamage() / 2D); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void entityDeath(EntityDeathEvent event) + { + if (event.getEntity() instanceof Player) + { + return; + } + + event.setDroppedExp(0); + event.getDrops().clear(); + } + + @Override + public double GetKillsGems(Player killer, Player killed, boolean assist) + { + return assist ? 3 : 12; + } + + public SupplyDropModule getSupplyDrop() + { + return _supplyDrop; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNewSolo.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNewSolo.java new file mode 100644 index 000000000..d3c0bd2a5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNewSolo.java @@ -0,0 +1,126 @@ +package nautilus.game.arcade.game.games.survivalgames; + +import java.util.Collections; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.C; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; + +public class SurvivalGamesNewSolo extends SurvivalGamesNew +{ + + private static final String[] DESCRIPTION = + { + "Search for chests to find loot", + "Slaughter your opponents", + "Stay away from the borders!", + "Last tribute alive wins!" + }; + + public SurvivalGamesNewSolo(ArcadeManager manager) + { + super(manager, GameType.SurvivalGames, DESCRIPTION); + + DamageTeamSelf = true; + } + + @EventHandler + public void customTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + { + return; + } + + GameTeam players = GetTeamList().get(0); + players.SetColor(ChatColor.YELLOW); + players.SetName("Tributes"); + players.setDisplayName(C.cYellowB + "Tributes"); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + if (GetPlayers(true).size() <= 1) + { + List places = GetTeamList().get(0).GetPlacements(true); + + if (places.size() > 0) + { + AddGems(places.get(0), 20, "1st Place", false, false); + } + + if (places.size() > 1) + { + AddGems(places.get(1), 15, "2nd Place", false, false); + } + + if (places.size() > 2) + { + AddGems(places.get(2), 10, "3rd Place", false, false); + } + + for (Player player : GetPlayers(false)) + { + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + } + + AnnounceEnd(places); + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (GetState().ordinal() >= GameState.End.ordinal()) + { + List places = GetTeamList().get(0).GetPlacements(true); + + if (places.isEmpty() || !places.get(0).isOnline()) + { + return Collections.emptyList(); + } + else + { + return Collections.singletonList(places.get(0)); + } + } + else + { + return null; + } + } + + @Override + public List getLosers() + { + List winners = getWinners(); + + if (winners == null) + { + return null; + } + + List losers = GetPlayers(false); + losers.removeAll(winners); + + return losers; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNewTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNewTeams.java new file mode 100644 index 000000000..3b7bf5ec4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNewTeams.java @@ -0,0 +1,112 @@ +package nautilus.game.arcade.game.games.survivalgames; + +import java.util.List; +import java.util.stream.Collectors; + +import org.bukkit.entity.Player; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.modules.TeamModule; + +public class SurvivalGamesNewTeams extends SurvivalGamesNew +{ + + private static final String[] DESCRIPTION = + { + "Search for chests to find loot", + "Slaughter your opponents", + "Stay away from the borders!", + "Last tribute alive wins!" + }; + + public SurvivalGamesNewTeams(ArcadeManager manager) + { + super(manager, GameType.SurvivalGamesTeams, DESCRIPTION); + + PlayersPerTeam = 2; + FillTeamsInOrderToCount = 2; + TeamMode = true; + ShowTeammateMessage = true; + + SpawnNearAllies = true; + SpawnNearEnemies = true; + + DamageTeamSelf = false; + + DontAllowOverfill = true; + + new TeamModule() + .register(this); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + List teamsAlive = GetTeamList().stream() + .filter(GameTeam::IsTeamAlive) + .collect(Collectors.toList()); + + if (teamsAlive.size() < 2) + { + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + { + AddGems(player, 10, "Winning Team", false, false); + } + } + + for (Player player : team.GetPlayers(false)) + { + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + } + } + + if (!teamsAlive.isEmpty()) + { + AnnounceEnd(teamsAlive.get(0)); + } + + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + return WinnerTeam == null ? null : WinnerTeam.GetPlayers(false); + } + + @Override + public List getLosers() + { + List winners = getWinners(); + + if (winners == null) + { + return null; + } + + return GetPlayers(false).stream() + .filter(player -> !winners.contains(player)) + .collect(Collectors.toList()); + } + + @Override + public String GetMode() + { + return "Team Mode"; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java deleted file mode 100644 index 0b496e13b..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java +++ /dev/null @@ -1,1649 +0,0 @@ -package nautilus.game.arcade.game.games.survivalgames; - -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map.Entry; - -import mineplex.core.Managers; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.recharge.Recharge; -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.Game; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.survivalgames.kit.KitArcher; -import nautilus.game.arcade.game.games.survivalgames.kit.KitAssassin; -import nautilus.game.arcade.game.games.survivalgames.kit.KitAxeman; -import nautilus.game.arcade.game.games.survivalgames.kit.KitBeastmaster; -import nautilus.game.arcade.game.games.survivalgames.kit.KitBomber; -import nautilus.game.arcade.game.games.survivalgames.kit.KitBrawler; -import nautilus.game.arcade.game.games.survivalgames.kit.KitHorseman; -import nautilus.game.arcade.game.games.survivalgames.kit.KitKnight; -import nautilus.game.arcade.game.games.survivalgames.kit.KitLooter; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.chat.ChatStatData; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Effect; -import org.bukkit.FireworkEffect; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.Chest; -import org.bukkit.entity.Entity; -import org.bukkit.entity.ItemFrame; -import org.bukkit.entity.Player; -import org.bukkit.entity.Snowball; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.block.BlockSpreadEvent; -import org.bukkit.event.block.LeavesDecayEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.hanging.HangingBreakEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.util.Vector; - -public class SurvivalGamesTeams extends TeamGame -{ - private HashSet _openedChest = new HashSet(); - private ArrayList _baseChestLoot = new ArrayList(); - private ArrayList _superChestLoot = new ArrayList(); - - //Misc - private HashMap _tntMap = new HashMap(); - private HashSet _placedBlocks = new HashSet(); - private Location _spawn; - - //Creep - private int _maxSpreadRate = 120; - private ArrayList _redLocations = new ArrayList(); - private int _spreadType = 0; - private String _spreadName = ""; - private boolean _ignoreLiquids = true; - private ArrayList> _spreadTypeBlocks; - private HashMap _redOutTime = new HashMap(); - - private HashMap>> _redMap = new HashMap>>(); - private HashMap> _redChunks = new HashMap>(); - - //Supply Drop - private ArrayList _supplyLocations = new ArrayList(); - private Location _supplyCurrent = null; - private Location _supplyEffect = null; - private ArrayList _supplyChests = new ArrayList(); - - //Deathmatch - private boolean _deathmatchCountdown = false; - private boolean _deathmatchLive = false; - private long _deathmatchTime = 0; - - //Debug - private long totalTime = 0; - - public SurvivalGamesTeams(ArcadeManager manager) - { - super(manager, GameType.SurvivalGames, - - new Kit[] - { - new KitAxeman(manager), - //new KitLooter(manager), - new KitKnight(manager), - - new KitArcher(manager), - new KitBrawler(manager), - - new KitAssassin(manager), - new KitBeastmaster(manager), - new KitBomber(manager), - //new KitNecromancer(manager), - - new KitHorseman(manager) - }, - - new String[] - { - "Search for chests to find loot", - "Slaughter your opponents", - "Stay away from the Deep Freeze!", - "Last team alive wins!" - }); - - _help = new String[] - { - C.cGreen + "Use a Compass to find and kill enemies!", - C.cAqua + "Crouch to become invisible to Compass tracking!", - C.cGreen + "Avoid the Deep Freeze at all costs!", - C.cAqua + "Use TNT & Tripwires to make traps!", - C.cGreen + "You lose Speed 2 at start of game if you attack.", - C.cAqua + "Avoid enemies who have better gear than you!", - C.cGreen + "Compass finds Supply Drops during night time.", - C.cAqua + "Compass finds Players during day time.", - }; - - setItemMerge(true); -// Manager.GetAntiStack().SetEnabled(false); - - this.GameTimeout = 9600000; - - this.WorldTimeSet = 0; - this.WorldBoundaryKill = false; - - SpawnNearAllies = true; - SpawnNearEnemies = true; //This is to ensure theres no 'gaps' of 1 between teams, hence forcing a team to get split. - - this.DamageSelf = true; - this.DamageTeamSelf = false; - - this.DeathDropItems = true; - - this.ItemDrop = true; - this.ItemPickup = true; - - this.InventoryClick = true; - this.InventoryOpenBlock = true; - this.InventoryOpenChest = true; - - //Blocks - this.BlockBreakAllow.add(46); //TNT - this.BlockPlaceAllow.add(46); - - this.BlockBreakAllow.add(30); //Web - this.BlockPlaceAllow.add(30); - - this.BlockBreakAllow.add(132); //Tripwire - this.BlockPlaceAllow.add(132); - - this.BlockBreakAllow.add(131); //Wire Hook - this.BlockPlaceAllow.add(131); - - this.BlockBreakAllow.add(55); //Redstone Dust - this.BlockPlaceAllow.add(55); - - this.BlockBreakAllow.add(72); //Wood Pressure Plate - this.BlockPlaceAllow.add(72); - - this.BlockBreakAllow.add(69); //Lever - this.BlockPlaceAllow.add(69); - - this.BlockBreakAllow.add(18); //Leaves - - //SPREAD - _spreadType = 1;//UtilMath.r(3); - - _spreadTypeBlocks = new ArrayList>(); - - if (_spreadType == 0) - { - _spreadName = "Red"; - _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(159, 14)); - } - else if (_spreadType == 1) - { - _spreadName = "Deep Freeze"; - _ignoreLiquids = false; - _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(78, 0)); - _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(79, 0)); - _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(80, 0)); - _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(49, 0)); - } - else if (_spreadType == 2) - { - _spreadName = "Nether Corruption"; - _ignoreLiquids = false; - _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(49, 0)); - _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(87, 0)); - _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(88, 0)); - _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(89, 0)); - _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(153, 0)); - } - - System.out.println("==================="); - System.out.println("CREEP TYPE: " + _spreadName); - System.out.println("==================="); - //Manager.GetStatsManager().addTable(getName(), "kills", "deaths", "chestsOpened"); - - //Tournament - if (Manager.IsTournamentServer()) - QuitOut = false; - } - - @Override - public double GetKillsGems(Player killer, Player killed, boolean assist) - { - return 4; - } - - @Override - public void ParseData() - { - ArrayList allSpawns = new ArrayList(); - for (GameTeam team : GetTeamList()) - allSpawns.addAll(team.GetSpawns()); - - _spawn = UtilWorld.averageLocation(allSpawns); - - for (Location loc : allSpawns) - loc.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(loc, _spawn))); - - CreateChestCraftEnchant(); - - _supplyLocations = WorldData.GetDataLocs("WHITE"); - for (Location loc : _supplyLocations) - loc.getBlock().setType(Material.GLASS); - - if (!WorldData.GetCustomLocs("VARS").isEmpty()) - { - _maxSpreadRate = WorldData.GetCustomLocs("VARS").get(0).getBlockX(); - System.out.println("Spread Rate: " + _maxSpreadRate); - } - } - - private void CreateChestCraftEnchant() - { - ArrayList chests = WorldData.GetCustomLocs("54"); - - System.out.println("Map Chest Locations: " + chests.size()); - - //Enchants - System.out.println("Enchanting Tables: " + Math.min(5, chests.size())); - for (int i=0 ; i<5 && !chests.isEmpty() ; i++) - { - Location loc = chests.remove(UtilMath.r(chests.size())); - loc.getBlock().setType(Material.ENCHANTMENT_TABLE); - } - - //Crafting - System.out.println("Crafting Benches: " + Math.min(10, chests.size())); - for (int i=0 ; i<10 && !chests.isEmpty() ; i++) - { - Location loc = chests.remove(UtilMath.r(chests.size())); - loc.getBlock().setType(Material.WORKBENCH); - } - - int spawn = 0; - - //Chests - System.out.println("Chests: " + Math.min(250, chests.size())); - for (int i=0 ; i<250 && !chests.isEmpty() ; i++) - { - Location loc = chests.remove(UtilMath.r(chests.size())); - - if (UtilMath.offset2d(loc, _spawn) < 8) - spawn++; - } - - for (Location loc : chests) - { - if (spawn < 10 && UtilMath.offset(loc, _spawn) < 8) - { - spawn++; - continue; - } - - loc.getBlock().setType(Material.AIR); - } - } - - @EventHandler - public void CreateRandomChests(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Recruit) - return; - - HashSet ignore = new HashSet(); - - ignore.add(Material.LEAVES); - - int xDiff = WorldData.MaxX - WorldData.MinX; - int zDiff = WorldData.MaxZ - WorldData.MinZ; - - int done = 0; - - while (done < 40) - { - - Block block = UtilBlock.getHighest(WorldData.World, WorldData.MinX + UtilMath.r(xDiff), WorldData.MinZ + UtilMath.r(zDiff), ignore); - - if (!UtilBlock.airFoliage(block) || !UtilBlock.solid(block.getRelative(BlockFace.DOWN))) - continue; - - block.setTypeIdAndData(54, (byte)UtilMath.r(4), true); - done++; - } - } - - @EventHandler - private void OpenChest(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getClickedBlock() == null) - return; - - if (!(event.getClickedBlock().getState() instanceof Chest)) - return; - - if (GetState() != GameState.Live) - return; - - if (_openedChest.contains(event.getClickedBlock().getLocation())) - return; - - _openedChest.add(event.getClickedBlock().getLocation()); - - Chest chest = (Chest)event.getClickedBlock().getState(); - - chest.getBlockInventory().clear(); - - int count = 2; - if (Math.random() > 0.50) count++; - if (Math.random() > 0.65) count++; - if (Math.random() > 0.80) count++; - if (Math.random() > 0.95) count++; - - if (UtilMath.offset(chest.getLocation(), _spawn) < 8) - count += 3; - - if (GetKit(event.getPlayer()) instanceof KitLooter) - { - count += UtilMath.r(3); - } - - if (_supplyChests.contains(event.getClickedBlock())) - { - count = 2; - if (Math.random() > 0.75) count++; - if (Math.random() > 0.95) count++; - } - - for (int i = 0; i < count; i++) - chest.getBlockInventory().setItem(UtilMath.r(27), GetChestItem(_supplyChests.contains(event.getClickedBlock()))); - - _supplyChests.remove(event.getClickedBlock()); - - Bukkit.getPluginManager().callEvent(new SupplyChestOpenEvent(event.getPlayer(), event.getClickedBlock())); - } - - private ItemStack GetChestItem(boolean superChest) - { - if (_baseChestLoot.isEmpty()) - { - //Armor - for (int i = 0; i < 10; i++) _baseChestLoot.add(new ItemStack(Material.IRON_HELMET)); - for (int i = 0; i < 3; i++) _baseChestLoot.add(new ItemStack(Material.IRON_CHESTPLATE)); - for (int i = 0; i < 5; i++) _baseChestLoot.add(new ItemStack(Material.IRON_LEGGINGS)); - for (int i = 0; i < 10; i++) _baseChestLoot.add(new ItemStack(Material.IRON_BOOTS)); - - for (int i = 0; i < 30; i++) _baseChestLoot.add(new ItemStack(Material.CHAINMAIL_HELMET)); - for (int i = 0; i < 20; i++) _baseChestLoot.add(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); - for (int i = 0; i < 25; i++) _baseChestLoot.add(new ItemStack(Material.CHAINMAIL_LEGGINGS)); - for (int i = 0; i < 30; i++) _baseChestLoot.add(new ItemStack(Material.CHAINMAIL_BOOTS)); - - for (int i = 0; i < 40; i++) _baseChestLoot.add(new ItemStack(Material.GOLD_HELMET)); - for (int i = 0; i < 30; i++) _baseChestLoot.add(new ItemStack(Material.GOLD_CHESTPLATE)); - for (int i = 0; i < 35; i++) _baseChestLoot.add(new ItemStack(Material.GOLD_LEGGINGS)); - for (int i = 0; i < 40; i++) _baseChestLoot.add(new ItemStack(Material.GOLD_BOOTS)); - - for (int i = 0; i < 100; i++) _baseChestLoot.add(new ItemStack(Material.LEATHER_HELMET)); - for (int i = 0; i < 90; i++) _baseChestLoot.add(new ItemStack(Material.LEATHER_CHESTPLATE)); - for (int i = 0; i < 85; i++) _baseChestLoot.add(new ItemStack(Material.LEATHER_LEGGINGS)); - for (int i = 0; i < 100; i++) _baseChestLoot.add(new ItemStack(Material.LEATHER_BOOTS)); - - //Weapons - for (int i = 0; i < 70; i++) _baseChestLoot.add(new ItemStack(Material.WOOD_AXE)); - for (int i = 0; i < 45; i++) _baseChestLoot.add(new ItemStack(Material.GOLD_AXE)); - for (int i = 0; i < 35; i++) _baseChestLoot.add(new ItemStack(Material.STONE_AXE)); - for (int i = 0; i < 15; i++) _baseChestLoot.add(new ItemStack(Material.IRON_AXE)); - - for (int i = 0; i < 60; i++) _baseChestLoot.add(new ItemStack(Material.WOOD_SWORD)); - for (int i = 0; i < 35; i++) _baseChestLoot.add(new ItemStack(Material.GOLD_SWORD)); - for (int i = 0; i < 25; i++) _baseChestLoot.add(new ItemStack(Material.STONE_SWORD)); - for (int i = 0; i < 8; i++) _baseChestLoot.add(new ItemStack(Material.IRON_SWORD)); - - for (int i = 0; i < 45; i++) _baseChestLoot.add(new ItemStack(Material.BOW)); - for (int i = 0; i < 55; i++) _baseChestLoot.add(new ItemStack(Material.ARROW, 4)); - - for (int i = 0; i < 15; i++) _baseChestLoot.add(new ItemStack(Material.TNT, 1)); - for (int i = 0; i < 30; i++) _baseChestLoot.add(new ItemStack(Material.WEB, 2)); - - //Food - for (int i = 0; i < 40; i++) _baseChestLoot.add(new ItemStack(Material.MUSHROOM_SOUP)); - for (int i = 0; i < 50; i++) _baseChestLoot.add(new ItemStack(Material.COOKED_CHICKEN, 5)); - for (int i = 0; i < 80; i++) _baseChestLoot.add(new ItemStack(Material.RAW_BEEF, 6)); - for (int i = 0; i < 50; i++) _baseChestLoot.add(new ItemStack(Material.GRILLED_PORK, 5)); - for (int i = 0; i < 160; i++) _baseChestLoot.add(new ItemStack(Material.BREAD, 5)); - for (int i = 0; i < 40; i++) _baseChestLoot.add(new ItemStack(Material.PUMPKIN_PIE, 4)); - for (int i = 0; i < 80; i++) _baseChestLoot.add(new ItemStack(Material.COOKIE, 7)); - for (int i = 0; i < 90; i++) _baseChestLoot.add(new ItemStack(Material.ROTTEN_FLESH, 4)); - - for (int i = 0; i < 80; i++) _baseChestLoot.add(new ItemStack(Material.WHEAT, 6)); - - //Misc - for (int i = 0; i < 50; i++) _baseChestLoot.add(new ItemStack(Material.COMPASS, 1)); - for (int i = 0; i < 25; i++) _baseChestLoot.add(new ItemStack(Material.EXP_BOTTLE, 1)); - for (int i = 0; i < 50; i++) _baseChestLoot.add(new ItemStack(Material.GOLD_INGOT, 2)); - for (int i = 0; i < 30; i++) _baseChestLoot.add(new ItemStack(Material.IRON_INGOT)); - for (int i = 0; i < 5; i++) _baseChestLoot.add(new ItemStack(Material.DIAMOND)); - for (int i = 0; i < 60; i++) _baseChestLoot.add(new ItemStack(Material.STICK, 4)); - for (int i = 0; i < 80; i++) _baseChestLoot.add(new ItemStack(Material.FLINT, 6)); - for (int i = 0; i < 80; i++) _baseChestLoot.add(new ItemStack(Material.FEATHER, 6)); - for (int i = 0; i < 40; i++) _baseChestLoot.add(new ItemStack(Material.BOAT)); - for (int i = 0; i < 70; i++) _baseChestLoot.add(new ItemStack(Material.FISHING_ROD)); - - //Building Supplies - for (int i = 0; i < 45; i++) _baseChestLoot.add(new ItemStack(Material.PISTON_BASE, 4)); - - /* - String material = _baseChestLoot.get(0).getType().toString(); - double count = 0; - - for (int i = 0; i < _baseChestLoot.size(); i++) - { - if (!_baseChestLoot.get(i).getType().toString().equalsIgnoreCase(material)) - { - System.out.println(material + " - " + count + " - " + (count / _baseChestLoot.size() * 100) + "%"); - material = _baseChestLoot.get(i).getType().toString(); - count = 1; - } - else - { - count++; - } - } - - System.out.println(material + " " + (count / _baseChestLoot.size() * 100) + "%"); - */ - } - - if (_superChestLoot.isEmpty()) - { - for (int i = 0; i < 3; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_HELMET)); - for (int i = 0; i < 1; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_CHESTPLATE)); - for (int i = 0; i < 2; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_LEGGINGS)); - for (int i = 0; i < 3; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_BOOTS)); - - for (int i = 0; i < 30; i++) _superChestLoot.add(new ItemStack(Material.IRON_HELMET)); - for (int i = 0; i < 24; i++) _superChestLoot.add(new ItemStack(Material.IRON_CHESTPLATE)); - for (int i = 0; i < 27; i++) _superChestLoot.add(new ItemStack(Material.IRON_LEGGINGS)); - for (int i = 0; i < 30; i++) _superChestLoot.add(new ItemStack(Material.IRON_BOOTS)); - - for (int i = 0; i < 24; i++) _superChestLoot.add(new ItemStack(Material.IRON_SWORD)); - for (int i = 0; i < 8; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_SWORD)); - for (int i = 0; i < 16; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_AXE)); - } - - - ItemStack stack = _baseChestLoot.get(UtilMath.r(_baseChestLoot.size())); - if (superChest) - stack = _superChestLoot.get(UtilMath.r(_superChestLoot.size())); - - int amount = 1; - - if (stack.getType().getMaxStackSize() > 1) - amount = Math.max(1, UtilMath.r(stack.getAmount())); - - if (stack.getTypeId() == 33) - return ItemStackFactory.Instance.CreateStack(stack.getTypeId(), (byte)0, amount, "Barricade"); - - return ItemStackFactory.Instance.CreateStack(stack.getTypeId(), amount); - } - - @EventHandler - public void StartEffectApply(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - return; - - for (Player player : GetPlayers(true)) - { - Manager.GetCondition().Factory().Speed("Start Speed", player, player, 30, 1, false, false, false); - Manager.GetCondition().Factory().HealthBoost("Start Health", player, player, 30, 1, false, false, false); - - player.setHealth(player.getMaxHealth()); - } - } - - @EventHandler - public void SpeedRemove(CustomDamageEvent event) - { - Player damager = event.GetDamagerPlayer(true); - if (damager != null) - Manager.GetCondition().EndCondition(damager, null, "Start Speed"); - } - - //If an item spawns and no one is there to see it, does it really spawn? No. - @EventHandler - public void ItemSpawn(ItemSpawnEvent event) - { - for (Player player : GetPlayers(true)) - if (UtilMath.offset(player, event.getEntity()) < 6) - return; - - event.setCancelled(true); - } - - @EventHandler - public void RedBorderStart(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - //Start Red - Block block; - - for (int x=WorldData.MinX ; x<=WorldData.MaxX ; x++) - { - block = WorldData.World.getHighestBlockAt(x, WorldData.MinZ); - while (!UtilBlock.solid(block) && !block.isLiquid() && block.getY() > 0) - block = block.getRelative(BlockFace.DOWN); - if (block.getY() > 0) - _redLocations.add(block.getLocation()); - - block = WorldData.World.getHighestBlockAt(x, WorldData.MaxZ); - while (!UtilBlock.solid(block) && !block.isLiquid() && block.getY() > 0) - block = block.getRelative(BlockFace.DOWN); - if (block.getY() > 0) - _redLocations.add(block.getLocation()); - } - - for (int z=WorldData.MinZ ; z<=WorldData.MaxZ ; z++) - { - block = WorldData.World.getHighestBlockAt(WorldData.MinX, z); - while (!UtilBlock.solid(block) && !block.isLiquid() && block.getY() > 0) - block = block.getRelative(BlockFace.DOWN); - if (block.getY() > 0) - _redLocations.add(block.getLocation()); - - block = WorldData.World.getHighestBlockAt(WorldData.MaxX, z); - while (!UtilBlock.solid(block) && !block.isLiquid() && block.getY() > 0) - block = block.getRelative(BlockFace.DOWN); - if (block.getY() > 0) - _redLocations.add(block.getLocation()); - } - } - - public int RedMax() - { - return _maxSpreadRate;// + (24 - GetPlayers(true).size())*2; - } - - @EventHandler - public void RedUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - if (!IsLive()) - return; - - long time = System.currentTimeMillis(); - - if (_redLocations.isEmpty()) - return; - - int max = Math.max(5, Math.min(RedMax(), _redLocations.size()/100)); - - for (int i=0 ; i WorldData.MaxX || block.getZ() < WorldData.MinZ || block.getZ() > WorldData.MaxZ) - return false; - - //Not Visible - if (!UtilBlock.isVisible(block)) - return false; - - //Apply - _redLocations.add(block.getLocation()); - return true; - } - - public void RedChangeBlock(Location loc, int id, byte data) - { - if (!IsLive()) - return; - - MapUtil.ChunkBlockChange(loc, id, data, false); - - //Old Style - /* - if (true) - { - for (Player player : UtilServer.getPlayers()) - { - if (Math.abs(player.getLocation().getChunk().getX() - loc.getChunk().getX()) > UtilServer.getServer().getViewDistance()) - continue; - - if (Math.abs(player.getLocation().getChunk().getZ() - loc.getChunk().getZ()) > UtilServer.getServer().getViewDistance()) - continue; - - player.sendBlockChange(loc, id, data); - } - - return; - } - */ - - //Non-Queue - for (Player player : UtilServer.getPlayers()) - { - if (Math.abs(player.getLocation().getChunk().getX() - loc.getChunk().getX()) > UtilServer.getServer().getViewDistance()) - continue; - - if (Math.abs(player.getLocation().getChunk().getZ() - loc.getChunk().getZ()) > UtilServer.getServer().getViewDistance()) - continue; - - if (!_redChunks.containsKey(player)) - _redChunks.put(player, new ArrayList()); - - boolean added = false; - for (ChunkChange change : _redChunks.get(player)) - { - if (change.Chunk.equals(loc.getChunk()))// && change.DirtyCount < 63) - { - change.AddChange(loc, id, data); - added = true; - break; - } - } - if (!added) - _redChunks.get(player).add(new ChunkChange(loc, id, data)); - } - } - - @EventHandler - public void RedChunkUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - if (!IsLive()) - return; - - for (Player player : _redChunks.keySet()) - { - //Remove Far Away - Iterator chunkIterator = _redChunks.get(player).iterator(); - while (chunkIterator.hasNext()) - { - ChunkChange change = chunkIterator.next(); - - if (Math.abs(player.getLocation().getChunk().getX() - change.Chunk.getX()) > UtilServer.getServer().getViewDistance() || - Math.abs(player.getLocation().getChunk().getZ() - change.Chunk.getZ()) > UtilServer.getServer().getViewDistance()) - { - chunkIterator.remove(); - } - } - - if (_redChunks.get(player).isEmpty()) - continue; - - //Get Fittest Chunk to Update - int bestId = -1; - double bestScore = 0; - - for (int i=0 ; i<_redChunks.get(player).size() ; i++) - { - ChunkChange change = _redChunks.get(player).get(i); - - //Base Score, 1 per block - double score = change.Changes.size(); - - //Time Score, multiply block score by 1 + 0.5 per second - score = score * (1 + (System.currentTimeMillis() - change.Time)/200d); - - //Distance Divisor - double dist = 0.5; - if (!player.getLocation().getChunk().equals(change.Chunk)) - { - int x = Math.abs(player.getLocation().getChunk().getX() - change.Chunk.getX()); - int z = Math.abs(player.getLocation().getChunk().getZ() - change.Chunk.getZ()); - dist = Math.sqrt(x*x + z*z); - } - score = score/(dist*dist); - - if (bestId == -1 || score > bestScore) - { - bestId = i; - bestScore = score; - } - } - - if (bestId == -1) - continue; - - //Send MultiBlock or Chunk Update for Fittest Chunk - ChunkChange change = _redChunks.get(player).remove(bestId); - - if (change.DirtyCount > 63) - MapUtil.SendChunkForPlayer(change.Chunk.getX(), change.Chunk.getZ(), player); - else - MapUtil.SendMultiBlockForPlayer(change.Chunk.getX(), change.Chunk.getZ(), change.DirtyBlocks, change.DirtyCount, change.Chunk.getWorld(), player); - } - } - - public boolean IsRed(Block block) - { - if (!_redMap.containsKey(block.getX())) - return false; - - if (!_redMap.get(block.getX()).containsKey(block.getY())) - return false; - - return _redMap.get(block.getX()).get(block.getY()).contains(block.getZ()); - } - - public void SetRed(Location loc) - { - //Save Red - if (!_redMap.containsKey(loc.getBlockX())) - _redMap.put(loc.getBlockX(), new HashMap>()); - - if (!_redMap.get(loc.getBlockX()).containsKey(loc.getBlockY())) - _redMap.get(loc.getBlockX()).put(loc.getBlockY(), new HashSet()); - - _redMap.get(loc.getBlockX()).get(loc.getBlockY()).add(loc.getBlockZ()); - - //Red - if (_spreadType == 0) - { - RedChangeBlock(loc, 159, (byte)14); - } - //Snow - else if (_spreadType == 1) - { - if (loc.getBlock().getType() == Material.LEAVES) //RedChangeBlock(loc, 79, (byte)0); - { - - } - else if (loc.getBlock().getTypeId() == 8 || loc.getBlock().getTypeId() == 9) RedChangeBlock(loc, 79, (byte)0); - else if (loc.getBlock().getTypeId() == 10 || loc.getBlock().getTypeId() == 11) RedChangeBlock(loc, 49, (byte)0); - else RedChangeBlock(loc, 80, (byte)0); - } - //Nether - else - { - if (loc.getBlock().getType() == Material.LEAVES) RedChangeBlock(loc, 88, (byte)0); - else if (loc.getBlock().getTypeId() == 8 || loc.getBlock().getTypeId() == 9) RedChangeBlock(loc, 49, (byte)0); - else - { - double r = Math.random(); - if (r > 0.1) RedChangeBlock(loc, 87, (byte)0); - else RedChangeBlock(loc, 153, (byte)0); - } - } - } - - @EventHandler - public void RedAttack(UpdateEvent event) - { - if (event.getType() != UpdateType.FASTER) - return; - - for (Player player : GetPlayers(true)) - { - boolean near = false; - - for (Block block : UtilBlock.getInRadius(player.getLocation(), 5d).keySet()) - { - if (!IsRed(block)) - continue; - - near = true; - - //Red - if (_spreadType == 0) - { - if (block.getRelative(BlockFace.UP).getType() == Material.AIR) - { - block.getRelative(BlockFace.UP).setType(Material.FIRE); - break; - } - } - - //Snow - else if (_spreadType == 1) - { - if (Math.random() > 0.95) - player.playEffect(block.getLocation().add(0, 1, 0), Effect.STEP_SOUND, Material.SNOW_BLOCK); - - if (Math.random() > 0.8) - { - Vector traj = UtilAlg.getTrajectory(block.getLocation().add(0.5, 1.5, 0.5), player.getLocation()); - - Snowball ball = player.getWorld().spawn(block.getLocation().add(0.5, 1.5, 0.5).subtract(traj.clone().multiply(8 + UtilMath.r(8))), Snowball.class); - - ball.setVelocity(UtilAlg.getTrajectory(ball.getLocation(), player.getEyeLocation().add(0, 3, 0)).add(new Vector(Math.random()-0.5, Math.random()-0.5, Math.random()-0.5).multiply(0.1))); - } - } - - //Nether - if (_spreadType == 2) - { - if (block.getRelative(BlockFace.UP).getType() == Material.AIR) - { - block.getRelative(BlockFace.UP).setType(Material.FIRE); - break; - } - } - } - - if (!near) - { - if (!UtilEnt.isGrounded(player)) - { - Block block = player.getLocation().getBlock(); - - while (!UtilBlock.solid(block) && block.getY() > 0) - block = block.getRelative(BlockFace.DOWN); - - if (IsRed(block) || block.getY() == 0) - near = true; - } - } - - if (!near) - { - if (_deathmatchLive && UtilMath.offset(player.getLocation(), _spawn) > 48) - near = true; - } - - if (near) - { - player.getWorld().playSound(player.getLocation(), Sound.AMBIENCE_RAIN, 0.5f, 0f); - - if (!_redOutTime.containsKey(player)) - { - _redOutTime.put(player, System.currentTimeMillis()); - } - else - { - if (UtilTime.elapsed(_redOutTime.get(player), 5000)) - { - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.VOID, 1, false, true, false, - "Hunger Games", _spreadName); - } - } - } - else - { - _redOutTime.remove(player); - } - } - } - - @EventHandler - public void RedDamage(CustomDamageEvent event) - { - if (event.GetProjectile() == null) - return; - - if (!(event.GetProjectile() instanceof Snowball)) - return; - - event.AddMod("Snowball", _spreadName, 2, true); - - event.AddKnockback("Snowball", 4); - } - - @EventHandler - public void DayNightCycle(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.TICK) - return; - - long time = WorldData.World.getTime(); - - if (time > 22000 || time < 14000) - { - WorldTimeSet = (WorldTimeSet + 4)%24000; - } - else - { - WorldTimeSet = (WorldTimeSet + 16)%24000; - } - - WorldData.World.setTime(WorldTimeSet); - } - - @EventHandler - public void SupplyDrop(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.FASTEST) - return; - - long time = WorldData.World.getTime(); - - if (time > 14000 && time < 23000) - { - if (_supplyCurrent == null && !_deathmatchCountdown && !_deathmatchLive) - { - if (_supplyLocations.isEmpty()) - return; - - _supplyCurrent = _supplyLocations.remove(UtilMath.r(_supplyLocations.size())); - - //Remove Prior - _supplyChests.remove(_supplyCurrent.getBlock().getRelative(BlockFace.UP)); - _supplyCurrent.getBlock().getRelative(BlockFace.UP).setType(Material.AIR); - - //Create New - _supplyCurrent.getBlock().setType(Material.BEACON); - for (int x=-1 ; x<=1 ; x++) - for (int z=-1 ; z<=1 ; z++) - _supplyCurrent.getBlock().getRelative(x, -1, z).setType(Material.IRON_BLOCK); - - //Announce - this.Announce(C.cYellow + C.Bold + "Supply Drop Incoming (" + ChatColor.RESET + UtilWorld.locToStrClean(_supplyCurrent) + C.cYellow + C.Bold + ")"); - } - } - else - { - if (_supplyCurrent != null) - { - if (_supplyEffect == null) - { - _supplyEffect = _supplyCurrent.clone(); - _supplyEffect.setY(250); - } - - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(Type.BURST).trail(false).build(); - UtilFirework.playFirework(_supplyEffect, effect); - - _supplyEffect.setY(_supplyEffect.getY()-2); - - if (UtilMath.offset(_supplyEffect, _supplyCurrent) < 2) - { - effect = FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(Type.BALL_LARGE).trail(true).build(); - UtilFirework.playFirework(_supplyEffect, effect); - - //Create Chest - _supplyCurrent.getBlock().setType(Material.GLASS); - _supplyCurrent.getBlock().getRelative(BlockFace.UP).setType(Material.CHEST); - _supplyChests.add(_supplyCurrent.getBlock().getRelative(BlockFace.UP)); - _openedChest.remove(_supplyCurrent); - - //Reset - _supplyEffect = null; - _supplyCurrent = null; - } - } - } - } - - @EventHandler - public void SupplyGlow(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.TICK) - return; - - if (_supplyChests.isEmpty()) - return; - - Iterator chestIterator = _supplyChests.iterator(); - - while (chestIterator.hasNext()) - { - Block block = chestIterator.next(); - - if (block.getType() != Material.CHEST) - { - chestIterator.remove(); - continue; - } - - UtilParticle.PlayParticle(ParticleType.SPELL, block.getLocation().add(0.5, 0.5, 0.5), 0.3f, 0.3f, 0.3f, 0, 1, - ViewDist.LONG, UtilServer.getPlayers()); - } - } - - @EventHandler - public void DeathmatchUpdate(UpdateEvent event) - { - if (!IsLive()) - return; - - if (_deathmatchLive) - { - if (event.getType() != UpdateType.SEC) - return; - - if (_deathmatchTime <= 0) - return; - - VisibilityManager vm = Managers.require(VisibilityManager.class); - for (Player player : GetPlayers(true)) - { - Bukkit.getOnlinePlayers().forEach(pl -> vm.refreshVisibility(pl, player)); - } - - Announce(C.cRed + C.Bold + "Deathmatch in " + _deathmatchTime + "..."); - _deathmatchTime--; - } - - else if (_deathmatchCountdown) - { - if (event.getType() != UpdateType.TICK) - return; - - long timeLeft = 60000 - (System.currentTimeMillis() - _deathmatchTime); - - if (timeLeft <= 0) - { - _deathmatchLive = true; - - for (GameTeam team : GetTeamList()) - team.SpawnTeleport(); - - _redLocations.clear(); - - for (Block block : UtilBlock.getInRadius(_spawn, 52d).keySet()) - RedSpread(block); - - _deathmatchTime = 10; - } - } - else - { - if (event.getType() != UpdateType.SEC) - return; - - if (!UtilTime.elapsed(GetStateTime(), 360000)) - return; - - if (GetPlayers(true).size() > 4) - return; - - if (!UtilTime.elapsed(_deathmatchTime, 60000)) - return; - - Announce(C.cGreen + C.Bold + "Type " + ChatColor.RESET + C.Bold + "/dm" + C.cGreen + C.Bold + " to start Deathmatch!"); - - _deathmatchTime = System.currentTimeMillis(); - } - } - - @EventHandler - public void DeathmatchMoveCancel(PlayerMoveEvent event) - { - if (!_deathmatchLive) - return; - - if (_deathmatchTime <= 0) - return; - - if (UtilMath.offset2d(event.getFrom(), event.getTo()) == 0) - return; - - if (!IsAlive(event.getPlayer())) - return; - - event.setTo(event.getFrom()); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void DeathmatchDamage(CustomDamageEvent event) - { - if (!_deathmatchLive) - return; - - if (_deathmatchTime <= 0) - return; - - event.SetCancelled("Deathmatch"); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void DeathmatchStart(PlayerCommandPreprocessEvent event) - { - if (!event.getMessage().equalsIgnoreCase("/dm")) - return; - - event.setCancelled(true); - - if (!IsAlive(event.getPlayer())) - { - UtilPlayer.message(event.getPlayer(), F.main("Game", "You are not in the game.")); - return; - } - - if (!IsLive()) - { - UtilPlayer.message(event.getPlayer(), F.main("Game", "Deathmatch cannot be started now.")); - return; - } - - if (!UtilTime.elapsed(GetStateTime(), 360000)) - { - UtilPlayer.message(event.getPlayer(), F.main("Game", "Deathmatch cannot be started now.")); - return; - } - - if (GetPlayers(true).size() > 4) - { - UtilPlayer.message(event.getPlayer(), F.main("Game", "Deathmatch cannot be started now.")); - return; - } - - if (_deathmatchCountdown) - { - UtilPlayer.message(event.getPlayer(), F.main("Game", "Deathmatch cannot be started now.")); - return; - } - - _deathmatchCountdown = true; - - Announce(C.cGreen + C.Bold + event.getPlayer().getName() + " has initiated Deathmatch!"); - Announce(C.cGreen + C.Bold + "Deathmatch starting in 60 seconds..."); - _deathmatchTime = System.currentTimeMillis(); - - for (Player player : UtilServer.getPlayers()) - player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 1f); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void CropTrample(PlayerInteractEvent event) - { - if (event.getAction() != Action.PHYSICAL) - return; - - if (event.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN).getType() != Material.SOIL) - return; - - event.setCancelled(true); - } - - @EventHandler - public void CompassUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - if (!IsLive()) - return; - - //Night Time > Drop Target - if (WorldData.World.getTime() > 14000 && WorldData.World.getTime() < 23000 && _supplyCurrent != null) - { - for (Player player : GetPlayers(true)) - { - player.setCompassTarget(_supplyCurrent); - - for (int i : player.getInventory().all(Material.COMPASS).keySet()) - { - ItemStack stack = player.getInventory().getItem(i); - - ItemMeta itemMeta = stack.getItemMeta(); - itemMeta.setDisplayName( - C.cWhite + C.Bold + "Supply Drop Location: " + C.cYellow + UtilMath.trim(1, UtilMath.offset(player.getLocation(), _supplyCurrent))); - stack.setItemMeta(itemMeta); - - player.getInventory().setItem(i, stack); - } - } - } - //Player Target - else - { - for (Player player : GetPlayers(true)) - { - Player target = null; - double bestDist = 0; - - for (Player other : Manager.GetGame().GetPlayers(true)) - { - if (other.equals(player)) - continue; - - if (other.isSneaking()) - continue; - - if (GetTeam(player).equals(GetTeam(other))) - continue; - - double dist = UtilMath.offset(player, other); - - if (target == null || dist < bestDist) - { - target = other; - bestDist = dist; - } - } - - if (target != null) - { - player.setCompassTarget(target.getLocation()); - - for (int i : player.getInventory().all(Material.COMPASS).keySet()) - { - ItemStack stack = player.getInventory().getItem(i); - - ItemMeta itemMeta = stack.getItemMeta(); - itemMeta.setDisplayName( - " " + C.cWhite + C.Bold + "Nearest Player: " + GetTeam(target).GetColor() + target.getName() + - " " + C.cWhite + C.Bold + "Distance: " + GetTeam(target).GetColor() + UtilMath.trim(1, bestDist)); - stack.setItemMeta(itemMeta); - - player.getInventory().setItem(i, stack); - } - } - } - } - } - - @EventHandler - public void DisallowBrewFurnace(PlayerInteractEvent event) - { - if (event.getClickedBlock() == null) - return; - - if (event.getClickedBlock().getType() == Material.BREWING_STAND || - event.getClickedBlock().getType() == Material.FURNACE || - event.getClickedBlock().getType() == Material.BURNING_FURNACE) - event.setCancelled(true); - } - - @EventHandler - public void CancelItemFrameBreak(HangingBreakEvent event) - { - if (event.getEntity() instanceof ItemFrame) - { - event.setCancelled(true); - } - } - - @EventHandler - public void TNTDelay(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - return; - - for (Player player : UtilServer.getPlayers()) - Recharge.Instance.useForce(player, "Throw TNT", 30000); - } - - @EventHandler - public void TNTThrow(PlayerInteractEvent event) - { - if (!IsLive()) - return; - - if (!UtilEvent.isAction(event, ActionType.L)) - return; - - Player player = event.getPlayer(); - - if (!UtilInv.IsItem(player.getItemInHand(), Material.TNT, (byte)0)) - return; - - event.setCancelled(true); - - if (!Recharge.Instance.use(player, "Throw TNT", 0, true, false)) - { - UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot use " + F.item("Throw TNT") + " yet.")); - return; - } - - if (!Manager.GetGame().CanThrowTNT(player.getLocation())) - { - //Inform - UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot use " + F.item("Throw TNT") + " here.")); - return; - } - - UtilInv.remove(player, Material.TNT, (byte)0, 1); - UtilInv.Update(player); - - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class); - - UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.5, false, 0, 0.1, 10, false); - - _tntMap.put(tnt, player); - } - - @EventHandler - public void TNTExplosion(ExplosionPrimeEvent event) - { - if (!_tntMap.containsKey(event.getEntity())) - return; - - Player player = _tntMap.remove(event.getEntity()); - - for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), 14)) - Manager.GetCondition().Factory().Explosion("Throwing TNT", other, player, 50, 0.1, false, false); - } - - @EventHandler - public void BlockPlace(BlockPlaceEvent event) - { - if (IsRed(event.getBlockAgainst())) - { - event.setCancelled(true); - return; - } - - if (event.getItemInHand().getType() == Material.PISTON_BASE) - { - _placedBlocks.add(event.getBlock().getLocation()); - event.setCancelled(false); - - final Block block = event.getBlock(); - - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - public void run() - { - block.setType(Material.PISTON_BASE); - block.setData((byte) 6); - } - }, 0); - } - } - - //@EventHandler - public void TourneyKills(CombatDeathEvent event) - { - if (!(event.GetEvent().getEntity() instanceof Player)) - return; - - Player killed = (Player)event.GetEvent().getEntity(); - - if (event.GetLog().GetKiller() != null) - { - Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); - - if (killer != null && !killer.equals(killed)) - { - //Manager.GetStatsManager().addStat(killer, getName(), "kills", 1); - } - } - - if (event.GetLog().GetPlayer() != null) - { - if (killed != null) - { - //Manager.GetStatsManager().addStat(killed, getName(), "deaths", 1); - } - } - } - - @EventHandler - public void BlockBreak(BlockBreakEvent event) - { - if (_placedBlocks.remove(event.getBlock().getLocation())) - { - event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, event.getBlock().getType()); - event.getBlock().setType(Material.AIR); - } - } - - @EventHandler - public void BlockBurn(BlockBurnEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void BlockSpread(BlockSpreadEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void BlockFade(BlockFadeEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void BlockDecay(LeavesDecayEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void PlayerKillAward(CombatDeathEvent event) - { - Game game = Manager.GetGame(); - if (game == null) return; - - if (!(event.GetEvent().getEntity() instanceof Player)) - return; - - FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.RED).with(Type.BALL_LARGE).trail(false).build(); - for (int i=0 ; i<3 ; i++) - UtilFirework.launchFirework(event.GetEvent().getEntity().getLocation(), effect, null, 3); - - if (event.GetLog().GetKiller() == null) - return; - - Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); - if (killer == null) - return; - - if (killer.equals(event.GetEvent().getEntity())) - return; - - killer.giveExpLevels(1); - } - - @EventHandler - public void DisableDamageLevel(CustomDamageEvent event) - { - event.SetDamageToLevel(false); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void ExplosionDamageRemove(EntityExplodeEvent event) - { - event.blockList().clear(); - } - - @EventHandler - public void FixClean(PlayerQuitEvent event) - { - _redChunks.remove(event.getPlayer()); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java deleted file mode 100644 index 4e05e27cc..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java +++ /dev/null @@ -1,229 +0,0 @@ -package nautilus.game.arcade.game.games.survivalgames; - -import java.util.ArrayList; -import java.util.List; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilPlayer; -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.game.GameTeam; -import nautilus.game.arcade.game.modules.TeamModule; -import nautilus.game.arcade.managers.chat.ChatStatData; -import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker; -import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker; -import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker; -import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker; - -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -public class TeamSurvivalGames extends SurvivalGames -{ - - public TeamSurvivalGames(ArcadeManager manager) - { - super(manager, GameType.SurvivalGamesTeams, - new String[] - { - "Search for chests to find loot", - - "Slaughter your opponents", - - "Stay away from the borders!", - - "Last team alive wins!" - }); - - PlayersPerTeam = 2; - FillTeamsInOrderToCount = 2; - - SpawnNearAllies = true; - SpawnNearEnemies = true; - - DamageTeamSelf = false; - - DontAllowOverfill = true; - TeamMode = true; - ShowTeammateMessage = true; - - new TeamModule().register(this); - - registerStatTrackers(new WinWithoutWearingArmorStatTracker(this), - new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"), - new FirstSupplyDropOpenStatTracker(this), - new SimultaneousSkeletonStatTracker(this, 5)); - - registerChatStats( - Kills, - Assists, - BlankLine, - DamageTaken, - DamageDealt, - BlankLine, - new ChatStatData("SupplyDropsOpened", "Event chests opened", true) - ); - } - - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - if (GetTeamList().isEmpty()) - return; - - Scoreboard.reset(); - - Scoreboard.writeNewLine(); - - Scoreboard.write(C.cGreen + C.Bold + "Time"); - Scoreboard.write(UtilTime.convertString(getSecondsSinceStart() * 1000, 0, TimeUnit.FIT)); - - Scoreboard.writeNewLine(); - Scoreboard.write(C.cYellow + C.Bold + "Teams"); - - ArrayList alive = new ArrayList(); - for (GameTeam team : GetTeamList()) - { - if (team.IsTeamAlive()) - alive.add(team); - } - - if (GetPlayers(true).size() <= 7) - { - for (GameTeam team : GetTeamList()) - { - for (Player player : team.GetPlayers(true)) - { - Scoreboard.write(team.GetColor() + player.getName()); - } - } - } - else if (alive.size() <= 7) - { - for (GameTeam team : alive) - { - Scoreboard.write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); - } - } - else - { - Scoreboard.write(C.cWhite + alive.size() + " Alive"); - } - - Scoreboard.writeNewLine(); - - if (getChestRefillTime() > 0 && getDeathMatchTime() > 60) - { - Scoreboard.write(C.cGold + C.Bold + "Chest Refill"); - Scoreboard.write(UtilTime.convertString(getChestRefillTime() * 1000, 0, TimeUnit.FIT)); - } - else if (getDeathMatchTime() > 0) - { - Scoreboard.write(C.cRed + C.Bold + "Deathmatch"); - Scoreboard.write(UtilTime.convertString( - Math.min(getDeathMatchTime(), isDeathMatchTeleported() ? 10 : getDeathMatchTime()) * 1000, 0, TimeUnit.FIT)); - } - else - { - Scoreboard.write(C.cRed + C.Bold + "Game End"); - Scoreboard.write(UtilTime.convertString(Math.max(0, getGameEndTime()) * 1000, 0, TimeUnit.FIT)); - } - - Scoreboard.draw(); - } - - @Override - public void EndCheck() - { - if (!IsLive()) - return; - - ArrayList teamsAlive = new ArrayList(); - - for (GameTeam team : GetTeamList()) - if (team.GetPlayers(true).size() > 0) - teamsAlive.add(team); - - if (teamsAlive.size() <= 1) - { - //Announce - if (teamsAlive.size() > 0) - AnnounceEnd(teamsAlive.get(0)); - - for (GameTeam team : GetTeamList()) - { - if (WinnerTeam != null && team.equals(WinnerTeam)) - { - for (Player player : team.GetPlayers(false)) - AddGems(player, 10, "Winning Team", false, false); - } - - for (Player player : team.GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false, false); - } - - //End - SetState(GameState.End); - } - } - - @Override - public List getWinners() - { - if (WinnerTeam == null) - return null; - - return WinnerTeam.GetPlayers(false); - } - - @Override - public List getLosers() - { - if (WinnerTeam == null) - return null; - - List players = new ArrayList<>(); - - for (GameTeam team : GetTeamList()) - { - if (team != WinnerTeam) - players.addAll(team.GetPlayers(false)); - } - - return players; - } - - @Override - public String GetMode() - { - return "Team Mode"; - } - - @Override - protected void deathmatchTeleport() - { - List spawns = GetTeamList().get(0).GetSpawns(); - - List spectators = GetPlayers(false); - - List living = GetPlayers(true); - - spectators.removeAll(living); - - Location spectatorLocation = GetSpectatorLocation(); - - spectators.forEach(s -> s.teleport(spectatorLocation)); - - UtilPlayer.teleportUniform(living, spawns); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitArcher.java index f520f6e26..9498f380b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitArcher.java @@ -1,14 +1,20 @@ package nautilus.game.arcade.game.games.survivalgames.kit; import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.PerkFletcher; +import nautilus.game.arcade.kit.perks.PerkQuickshot; public class KitArcher extends SurvivalGamesKit { @@ -17,19 +23,35 @@ public class KitArcher extends SurvivalGamesKit "Passively crafts arrows from surrounding terrain.", "", receiveArrowString(1, 20, 3), - "Charge Bow to use " + C.cGreen + "Barrage" + receiveItem("Bow", 1) + " 90 seconds " + C.cWhite + "into the game", + "Charge Bow to use " + C.cGreen + "Barrage", + click(true, "to fire a Quick Shot arrow") }; private static final Perk[] PERKS = { new PerkFletcher(20, 3, true), new PerkBarrage(5, 250, true, false), + new PerkQuickshot("Quick Shot", 2, 30000, true) }; private static final ItemStack IN_HAND = new ItemStack(Material.BOW); + public static final ItemStack BOW = new ItemBuilder(Material.BOW) + .setTitle(C.cYellow + "Archer's Bow") + .build(); public KitArcher(ArcadeManager manager) { super(manager, "Archer", KitAvailability.Gem, DESCRIPTION, PERKS, IN_HAND); } + @EventHandler(priority = EventPriority.LOWEST) + public void playerDeath(PlayerDeathEvent event) + { + if (!HasKit(event.getEntity())) + { + return; + } + + event.getDrops().removeIf(itemStack -> itemStack.isSimilar(BOW)); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitAssassin.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitAssassin.java index dc6cbb43e..d461c2caf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitAssassin.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitAssassin.java @@ -1,12 +1,26 @@ package nautilus.game.arcade.game.games.survivalgames.kit; +import java.util.concurrent.TimeUnit; + +import org.bukkit.Material; +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.inventory.ItemStack; + import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.PerkBackstab; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; public class KitAssassin extends SurvivalGamesKit { @@ -17,6 +31,8 @@ public class KitAssassin extends SurvivalGamesKit "when you're 8 blocks away!", "", "Deal " + C.cGreen + "+2" + C.cWhite + " damage from behind opponents.", + "Fall damage reduced by " + C.cGreen + "50" + C.cWhite + "%.", + click(false, "your map to show the locations of all players.") }; private static final Perk[] PERKS = { @@ -25,8 +41,44 @@ public class KitAssassin extends SurvivalGamesKit private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); + private static final long MAP_COOLDOWN = TimeUnit.SECONDS.toMillis(45); + private static final long MAP_TIME = TimeUnit.SECONDS.toMillis(5); + public KitAssassin(ArcadeManager manager) { super(manager, "Assassin", KitAvailability.Gem, 5000, DESCRIPTION, PERKS, IN_HAND); } + + @EventHandler + public void fallDamage(CustomDamageEvent event) + { + Player damagee = event.GetDamageePlayer(); + + if (event.GetCause() != DamageCause.FALL || damagee == null || !HasKit(damagee)) + { + return; + } + + event.AddMod(GetName() + " Fall Damage", -event.GetDamage() / 2D); + } + + @EventHandler + public void showMapPlayers(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = player.getItemInHand(); + + if (itemStack == null || itemStack.getType() != Material.MAP || !HasKit(player) || !Recharge.Instance.use(player, "Assassin's Eye", MAP_COOLDOWN, true, true)) + { + return; + } + + player.sendMessage(F.main("Game", "You can now see all players on your map for " + F.time(UtilTime.MakeStr(MAP_TIME)) + ".")); + Recharge.Instance.useForce(player, "Show All Players", MAP_TIME); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitBrawler.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitBrawler.java index e2ca0c3b0..5c296e3f0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitBrawler.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitBrawler.java @@ -15,8 +15,8 @@ public class KitBrawler extends SurvivalGamesKit private static final String[] DESCRIPTION = { "Giant and muscular, easily smacks others around.", "", - "Take " + C.cGreen + "75%" + C.cWhite + " knockback", - "Deal " + C.cGreen + "125%" + C.cWhite + " knockback", + "Take " + C.cGreen + "85%" + C.cWhite + " knockback", + "Deal " + C.cGreen + "115%" + C.cWhite + " knockback", C.cYellow + "Right-Click" + C.cWhite + " with Sword/Axe to " + C.cGreen + "Ground Pound" }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitLooter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitLooter.java deleted file mode 100644 index 225710bf0..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitLooter.java +++ /dev/null @@ -1,31 +0,0 @@ -package nautilus.game.arcade.game.games.survivalgames.kit; - -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkLooter; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -public class KitLooter extends SurvivalGamesKit -{ - - private static final String[] DESCRIPTION = { - "Defeat your opponents with your swag loots!", - "", - "You find extra loot in chests.", - - }; - - private static final Perk[] PERKS = { - new PerkLooter(), - }; - - private static final ItemStack IN_HAND = new ItemStack(Material.CHEST); - - public KitLooter(ArcadeManager manager) - { - super(manager, "Looter", KitAvailability.Free, DESCRIPTION, PERKS, IN_HAND); - - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitNecromancer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitNecromancer.java index 95df79bc1..253370dab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitNecromancer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/KitNecromancer.java @@ -7,17 +7,20 @@ import nautilus.game.arcade.kit.perks.PerkSkeletons; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.util.C; + public class KitNecromancer extends SurvivalGamesKit { private static final String[] DESCRIPTION = { - "Harness the power of the dark arts.", - "", - "Killing an opponent summons a skeletal minion." + C.mBody + "Harness the power of the dark arts.", + "", + C.mBody + "Killing an opponent summons a skeletal minion.", + C.cYellow + "Right Click " + C.mBody + "a minion to access its inventory." }; private static final Perk[] PERKS = { - new PerkSkeletons(true) + new PerkSkeletons(true) }; private static final ItemStack IN_HAND = new ItemStack(Material.SKULL_ITEM); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/necroinventory/NecroInventoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/necroinventory/NecroInventoryMenu.java new file mode 100644 index 000000000..a197930cd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/necroinventory/NecroInventoryMenu.java @@ -0,0 +1,163 @@ +package nautilus.game.arcade.game.games.survivalgames.kit.necroinventory; + +import java.util.List; +import java.util.Map; +import java.util.WeakHashMap; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.event.inventory.InventoryInteractEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilItem; +import mineplex.core.lifetimes.ListenerComponent; + +import nautilus.game.arcade.kit.perks.PerkSkeletons; + +public class NecroInventoryMenu extends ListenerComponent +{ + private final Map _pageMap; + private final PerkSkeletons _perk; + + public NecroInventoryMenu(PerkSkeletons perk) + { + _pageMap = new WeakHashMap<>(); + _perk = perk; + } + + public void openInventory(Player player, Skeleton minion) + { + NecroInventoryPage inventoryPage = new NecroInventoryPage(player, minion); + + _pageMap.put(player, inventoryPage); + + inventoryPage.openInventory(); + } + + private boolean shouldCallInteract(InventoryInteractEvent event) + { + if (!(event.getWhoClicked() instanceof Player)) + { + return false; + } + + if (!_pageMap.containsKey(event.getWhoClicked())) + { + return false; + } + + NecroInventoryPage inventoryPage = _pageMap.get(event.getWhoClicked()); + + return inventoryPage.matchesInventory(event.getInventory()); + } + + @EventHandler + public void skeletonClick(PlayerInteractEntityEvent event) + { + if (event.getPlayer() == null || event.getRightClicked() == null) + { + return; + } + + if (!(event.getRightClicked() instanceof Skeleton)) + { + return; + } + + if (!_perk.hasPerk(event.getPlayer())) + { + return; + } + + Skeleton skeleton = (Skeleton) event.getRightClicked(); + + List skeletons = _perk.getSkeletons(event.getPlayer()); + + if (skeletons == null || !skeletons.contains(skeleton)) + { + return; + } + + ItemStack itemInHand = event.getPlayer().getItemInHand(); + + // Don't open the skeleton inventory if it's a weapon/fishing rod + if (UtilItem.isWeapon(itemInHand) + || itemInHand.getType() == Material.FISHING_ROD + || itemInHand.getType() == Material.BOW + || itemInHand.getType() == Material.EGG + || itemInHand.getType() == Material.SNOW_BALL) + { + event.getPlayer().sendMessage(F.main("Game", C.mBody + "You can't open a minion inventory with that item in your hand.")); + return; + } + + event.setCancelled(true); + openInventory(event.getPlayer(), skeleton); + } + + @Override + public void deactivate() + { + super.deactivate(); + _pageMap.values().forEach(NecroInventoryPage::cleanup); + _pageMap.clear(); + } + + @EventHandler + public void inventoryClick(InventoryClickEvent event) + { + if (!shouldCallInteract(event)) + { + return; + } + + NecroInventoryPage inventoryPage = _pageMap.get(event.getWhoClicked()); + + inventoryPage.inventoryClick(event); + } + + @EventHandler + public void inventoryDrag(InventoryDragEvent event) + { + if (!shouldCallInteract(event)) + { + return; + } + + NecroInventoryPage inventoryPage = _pageMap.get(event.getWhoClicked()); + + inventoryPage.inventoryDrag(event); + } + + @EventHandler + public void inventoryClose(InventoryCloseEvent event) + { + if (event.getPlayer() == null || !(event.getPlayer() instanceof Player)) + { + return; + } + + if (!_pageMap.containsKey(event.getPlayer())) + { + return; + } + + NecroInventoryPage inventoryPage = _pageMap.get(event.getPlayer()); + + if (!inventoryPage.matchesInventory(event.getInventory())) + { + return; + } + + _pageMap.remove(event.getPlayer()); + inventoryPage.cleanup(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/necroinventory/NecroInventoryPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/necroinventory/NecroInventoryPage.java new file mode 100644 index 000000000..7e30ef31b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/kit/necroinventory/NecroInventoryPage.java @@ -0,0 +1,374 @@ +package nautilus.game.arcade.game.games.survivalgames.kit.necroinventory; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Bukkit; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilItem; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.itemstack.ItemStackFactory; + +public class NecroInventoryPage +{ + public enum EquipmentType + { + HELMET("Helmet"), + CHESTPLATE("Chestplate"), + LEGGINGS("Leggings"), + BOOTS("Boots"), + WEAPON("Weapon"); + + private String _name; + + EquipmentType(String name) + { + _name = name; + } + + public String getName() + { + return _name; + } + } + + private Map slots; + + private Player _player; + private Skeleton _minion; + + private Inventory _inventory; + + public NecroInventoryPage(Player player, Skeleton minion) + { + slots = new HashMap<>(); + slots.put(0, EquipmentType.HELMET); + slots.put(1, EquipmentType.CHESTPLATE); + slots.put(2, EquipmentType.LEGGINGS); + slots.put(3, EquipmentType.BOOTS); + slots.put(4, EquipmentType.WEAPON); + + _player = player; + _minion = minion; + } + + // Get the player name, from "Skeletal PLAYERNAME" + private String getTitle() + { + return _minion.getCustomName().split(" ")[1] + " - Inventory"; + } + + private ItemStack getButtonEmpty(String inventoryType) + { + return new ItemBuilder(Material.STAINED_GLASS_PANE) + .setData(DyeColor.GRAY.getWoolData()) + .setTitle(C.cRed + "No " + inventoryType + " equipped") + .addLore(C.mBody + "Drag an item onto this slot", "to equip it.") + .build(); + } + + private ItemStack getButton(ItemStack stack, String inventoryType) + { + if (stack != null && stack.getType() != Material.AIR) + { + return stack; + } + + return getButtonEmpty(inventoryType); + } + + public void openInventory() + { + Inventory inventory = Bukkit.createInventory(_player, InventoryType.HOPPER, getTitle()); + + EntityEquipment equipment = _minion.getEquipment(); + + inventory.setItem(0, getButton(equipment.getHelmet(), slots.get(0).getName())); + inventory.setItem(1, getButton(equipment.getChestplate(), slots.get(1).getName())); + inventory.setItem(2, getButton(equipment.getLeggings(), slots.get(2).getName())); + inventory.setItem(3, getButton(equipment.getBoots(), slots.get(3).getName())); + inventory.setItem(4, getButton(equipment.getItemInHand(), slots.get(4).getName())); + + _inventory = inventory; + + _player.openInventory(inventory); + } + + public boolean matchesInventory(Inventory inventory) + { + return inventory != null && _inventory != null && inventory.equals(_inventory); + } + + private boolean isValidItem(ItemStack item, EquipmentType equipmentType) + { + switch (equipmentType) + { + case HELMET: + return UtilItem.isHelmet(item); + case CHESTPLATE: + return UtilItem.isChestplate(item); + case LEGGINGS: + return UtilItem.isLeggings(item); + case BOOTS: + return UtilItem.isBoots(item); + case WEAPON: + return true; + default: + return false; + } + } + + private void setEquipment(ItemStack item, EquipmentType equipmentType) + { + EntityEquipment equipment = _minion.getEquipment(); + + switch (equipmentType) + { + case HELMET: + equipment.setHelmet(item); + break; + case CHESTPLATE: + equipment.setChestplate(item); + break; + case LEGGINGS: + equipment.setLeggings(item); + break; + case BOOTS: + equipment.setBoots(item); + break; + case WEAPON: + equipment.setItemInHand(item); + break; + } + } + + private void equip(ItemStack item, int slot) + { + if (!slots.containsKey(slot)) + { + return; + } + + _inventory.setItem(slot, item); + + EquipmentType equipmentType = slots.get(slot); + + setEquipment(item, equipmentType); + + _player.sendMessage(F.main("Game", C.mBody + "Your minion equipped " + C.cYellow + ItemStackFactory.Instance.GetItemStackName(item) + C.mBody + ".")); + _player.playSound(_player.getLocation(), Sound.HORSE_ARMOR, 1f, 1f); + } + + private void unequip(int slot) + { + if (!slots.containsKey(slot)) + { + return; + } + + ItemStack old = _inventory.getItem(slot); + + EquipmentType equipmentType = slots.get(slot); + + _inventory.setItem(slot, getButtonEmpty(equipmentType.getName())); + + ItemStack air = new ItemStack(Material.AIR); + + setEquipment(air, equipmentType); + + _player.sendMessage(F.main("Game", C.mBody + "Your minion unequipped " + C.cYellow + ItemStackFactory.Instance.GetItemStackName(old) + C.mBody + ".")); + } + + private boolean isPickup(InventoryAction action) + { + return (action == InventoryAction.PICKUP_ALL || action == InventoryAction.PICKUP_HALF || action == InventoryAction.PICKUP_ONE || action == InventoryAction.PICKUP_SOME); + } + + private void playDeny(Player player) + { + player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f); + } + + public void inventoryClick(InventoryClickEvent event) + { + if (_inventory == null || event.getInventory() == null || event.getClickedInventory() == null) + { + return; + } + + if (!event.getInventory().equals(_inventory)) + { + return; + } + + if (event.getWhoClicked() == null || !(event.getWhoClicked() instanceof Player)) + { + return; + } + + Player player = (Player) event.getWhoClicked(); + + if (!event.getClickedInventory().equals(_inventory)) + { + // It's the player's inventory + if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) + { + ItemStack shiftClickedItem = event.getClickedInventory().getItem(event.getSlot()); + + for (int slot : slots.keySet()) + { + EquipmentType equipmentType = slots.get(slot); + + if (isValidItem(shiftClickedItem, equipmentType)) + { + if (_inventory.getItem(slot).getType() != Material.STAINED_GLASS_PANE) + { + player.getInventory().setItem(event.getSlot(), _inventory.getItem(slot)); + } + else + { + player.getInventory().setItem(event.getSlot(), new ItemStack(Material.AIR)); + } + + equip(shiftClickedItem, slot); + event.setCancelled(true); + return; + } + } + + playDeny(player); + event.setCancelled(true); + } + + return; + } + + boolean isPlaceholder = _inventory.getItem(event.getSlot()).getType() == Material.STAINED_GLASS_PANE; + + // If the user is picking up an item + // meaning they are NOT swapping one... + if (isPickup(event.getAction())) + { + // If it's a placeholder pane + // cancel it for obvious reasons + if (isPlaceholder) + { + playDeny(player); + } + // Otherwise it's OK to pick up, + // so unequip that item. + else + { + _player.setItemOnCursor(_inventory.getItem(event.getSlot())); + unequip(event.getSlot()); + } + + event.setCancelled(true); + return; + } + + // If the player has an item in their cursor and is + // trying to swap it with something in the hopper inventory + if (event.getAction() == InventoryAction.SWAP_WITH_CURSOR) + { + // If the item in the player's + // cursor is allowed to go into + // that gear slot, put it in there. + if (isValidItem(event.getCursor(), slots.get(event.getSlot()))) + { + equip(event.getCursor(), event.getSlot()); + + // Don't give them the placeholder item on their cursor... + if (!isPlaceholder) + { + player.setItemOnCursor(_inventory.getItem(event.getSlot())); + } + else + { + player.setItemOnCursor(new ItemStack(Material.AIR)); + } + } + // If the cursor is not empty, + // don't let the player do anything + // with it. + else if (event.getCursor() != null && event.getCursor().getType() != Material.AIR) + { + playDeny(player); + event.setCancelled(true); + return; + } + // Otherwise, let the item in the + // slot be unequipped because the + // cursor is empty. + else if (!isPlaceholder) + { + // Set cursor before unequipping so the item is still there + _player.setItemOnCursor(_inventory.getItem(event.getSlot())); + unequip(event.getSlot()); + } + // It is a placeholder, so play the deny + else + { + playDeny(player); + } + + event.setCancelled(true); + return; + } + + // Shift clicking has odd behavior with ghosting items + // so just disable shift clicking items out of the hopper. + if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) + { + _player.sendMessage(F.main("Game", "You can't use shift-click to unequip items.")); + playDeny(player); + } + + // No clue what they're trying to do in my inventory, + // but I haven't caught it so just cancel the event. + event.setCancelled(true); + } + + public void inventoryDrag(InventoryDragEvent event) + { + if (_inventory == null || event.getInventory() == null) + { + return; + } + + if (!event.getInventory().equals(_inventory)) + { + return; + } + + if (!(event.getWhoClicked() instanceof Player) || event.getWhoClicked().equals(_player)) + { + return; + } + + event.setCancelled(true); + } + + public void cleanup() + { + _inventory = null; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/ChangingKits.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/ChangingKits.java deleted file mode 100644 index 4397ddd32..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/ChangingKits.java +++ /dev/null @@ -1,173 +0,0 @@ -package nautilus.game.arcade.game.games.survivalgames.modes; - -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.entity.EntityDeathEvent; - -import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextBottom; -import mineplex.core.common.util.UtilTime; -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.GameStateChangeEvent; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.games.smash.modes.kits.KitHipster; -import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames; -import nautilus.game.arcade.game.games.survivalgames.kit.KitArcher; -import nautilus.game.arcade.game.games.survivalgames.kit.KitAssassin; -import nautilus.game.arcade.game.games.survivalgames.kit.KitAxeman; -import nautilus.game.arcade.game.games.survivalgames.kit.KitBarbarian; -import nautilus.game.arcade.game.games.survivalgames.kit.KitBeastmaster; -import nautilus.game.arcade.game.games.survivalgames.kit.KitBomber; -import nautilus.game.arcade.game.games.survivalgames.kit.KitBrawler; -import nautilus.game.arcade.game.games.survivalgames.kit.KitHorseman; -import nautilus.game.arcade.game.games.survivalgames.kit.KitKnight; -import nautilus.game.arcade.game.games.survivalgames.kit.KitNecromancer; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.Perk; - -/** - * ChangingKits - * - * @author xXVevzZXx - */ -public class ChangingKits extends SoloSurvivalGames -{ - private Kit[] _kits; - - private long _lastChanged; - private int _changeInterval; - - public ChangingKits(ArcadeManager manager) - { - super(manager, new Kit[] - { - new KitHipster(manager) - }, GameType.Brawl); - - _kits = new Kit[] - { - new KitAxeman(manager), - - // new KitLooter(manager), - - new KitKnight(manager), - - new KitArcher(manager), - - new KitBrawler(manager), - - new KitAssassin(manager), - - new KitBeastmaster(manager), - - new KitBomber(manager), - - new KitNecromancer(manager), - - new KitBarbarian(manager), - }; - - _lastChanged = 0; - _changeInterval = 60; - } - - @EventHandler - public void countdown(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() == UpdateType.SEC) - { - if (System.currentTimeMillis() > _lastChanged + 25000) - { - for (Player player : UtilServer.getPlayers()) - { - player.playSound(player.getLocation(), Sound.NOTE_PLING, 2F, 2F); - } - } - } - - if (event.getType() != UpdateType.TICK) - return; - - double percentage = (double) (System.currentTimeMillis() - _lastChanged) / (_changeInterval*1000); - - for (Player player : UtilServer.getPlayers()) - { - UtilTextBottom.displayProgress("New Kit", percentage, - UtilTime.MakeStr(Math.max(0, (_changeInterval*1000) - (System.currentTimeMillis() - _lastChanged))), player); - } - } - - @EventHandler - public void KitRegister(GameStateChangeEvent event) - { - if (event.GetState() != event.GetGame().KitRegisterState) - return; - - for (Kit kit : _kits) - { - UtilServer.getServer().getPluginManager().registerEvents(kit, Manager.getPlugin()); - - for (Perk perk : kit.GetPerks()) - { - UtilServer.getServer().getPluginManager().registerEvents(perk, Manager.getPlugin()); - perk.registeredEvents(); - } - } - } - - @EventHandler - public void end(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Dead) - return; - - for (Kit kit : _kits) - { - HandlerList.unregisterAll(kit); - - for (Perk perk : kit.GetPerks()) - { - HandlerList.unregisterAll(perk); - perk.unregisteredEvents(); - } - } - } - - @EventHandler - public void kitSwitch(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - if (!IsLive()) - return; - - if (!UtilTime.elapsed(_lastChanged, _changeInterval*1000)) - return; - - _lastChanged = System.currentTimeMillis(); - - for (Player player : GetPlayers(true)) - { - Kit kit = _kits[UtilMath.r(_kits.length)]; - SetKit((Player) player, kit, true, false); - } - } - - @Override - public String GetMode() - { - return "Changing Kits"; - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/OverpoweredSurvival.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/OverpoweredSurvival.java deleted file mode 100644 index b600999c3..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/OverpoweredSurvival.java +++ /dev/null @@ -1,321 +0,0 @@ -package nautilus.game.arcade.game.games.survivalgames.modes; - -import java.util.ArrayList; -import java.util.Arrays; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.Chest; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilMath; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.loot.RandomItem; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.games.AbsorptionFix; -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; - -/** - * OverpoweredSurvival gammeode for Survivalgames - * - * @author xXVevzZXx - */ -public class OverpoweredSurvival extends SoloSurvivalGames -{ - - public OverpoweredSurvival(ArcadeManager manager) - { - super(manager, GameType.Brawl); - - new AbsorptionFix(this); - } - - @Override - public void setupLoot() - { - // Food - getBaseLoot().addLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 3)); - getBaseLoot().addLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 2)); - getBaseLoot().addLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 2)); - getBaseLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15, 1, 1)); - getBaseLoot().addLoot(new RandomItem(Material.APPLE, 30)); - - // Weapons - getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_AXE, 80)); - getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_SWORD, 70)); - getBaseLoot().addLoot(new RandomItem(Material.IRON_AXE, 40)); - getBaseLoot().addLoot(new RandomItem(Material.IRON_SWORD, 35)); - - // armor - getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_BOOTS, 35)); - getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_CHESTPLATE, 35)); - getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_HELMET, 35)); - getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_LEGGINGS, 35)); - - getBaseLoot().addLoot(new RandomItem(Material.IRON_BOOTS, 15)); - getBaseLoot().addLoot(new RandomItem(Material.IRON_CHESTPLATE, 15)); - getBaseLoot().addLoot(new RandomItem(Material.IRON_HELMET, 15)); - getBaseLoot().addLoot(new RandomItem(Material.IRON_LEGGINGS, 15)); - - // Throwable - getBaseLoot().addLoot(new RandomItem(Material.FISHING_ROD, 30)); - getBaseLoot().addLoot(new RandomItem(Material.BOW, 20)); - getBaseLoot().addLoot(new RandomItem(Material.ARROW, 40, 4, 12)); - - // Misc - getBaseLoot().addLoot(new RandomItem(Material.EXP_BOTTLE, 40, 5, 20)); - getBaseLoot().addLoot(new RandomItem(Material.COMPASS, 20)); - getBaseLoot().addLoot(new RandomItem(Material.STICK, 30, 1, 2)); - getBaseLoot().addLoot(new RandomItem(Material.FLINT, 30, 1, 2)); - getBaseLoot().addLoot(new RandomItem(Material.FEATHER, 30, 1, 2)); - getBaseLoot().addLoot(new RandomItem(Material.GOLD_INGOT, 20)); - getBaseLoot().addLoot(new RandomItem(ItemStackFactory.Instance.CreateStack(Material.TNT, - (byte) 0, 1, F.item("Throwing TNT")), 15)); - getSpawnLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15)); - - getSpawnLoot().addLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 3)); - getSpawnLoot().addLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 2)); - getSpawnLoot().addLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 2)); - getSpawnLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15, 1, 1)); - getSpawnLoot().addLoot(new RandomItem(Material.APPLE, 30)); - - getSpawnLoot().addLoot(new RandomItem(Material.IRON_BOOTS, 15)); - getSpawnLoot().addLoot(new RandomItem(Material.IRON_CHESTPLATE, 15)); - getSpawnLoot().addLoot(new RandomItem(Material.IRON_HELMET, 15)); - getSpawnLoot().addLoot(new RandomItem(Material.IRON_LEGGINGS, 15)); - // Loot for chests in spawn - // Weaponry and ores - getSpawnLoot().addLoot(new RandomItem(Material.IRON_SWORD, 30)); - getSpawnLoot().addLoot(new RandomItem(Material.IRON_AXE, 30)); - getSpawnLoot().addLoot(new RandomItem(Material.DIAMOND, 30, 3, 6)); - - // Supply crate loot - int e = 4; - for (int i = 1; i < 4; i++) - { - getCrateLoot().addLoot(new RandomItem( - ItemStackFactory.Instance.CreateStack(Material.DIAMOND_HELMET.getId(), (byte) 0, - 1, (short) 0, null, Arrays.asList(new String[] {}), null, false, i, - Enchantment.PROTECTION_ENVIRONMENTAL), - e * 10)); - getCrateLoot().addLoot(new RandomItem( - ItemStackFactory.Instance.CreateStack(Material.DIAMOND_CHESTPLATE.getId(), - (byte) 0, 1, (short) 0, null, Arrays.asList(new String[] {}), null, - false, i, Enchantment.PROTECTION_ENVIRONMENTAL), - e * 10)); - getCrateLoot().addLoot(new RandomItem( - ItemStackFactory.Instance.CreateStack(Material.DIAMOND_LEGGINGS.getId(), - (byte) 0, 1, (short) 0, null, Arrays.asList(new String[] {}), null, - false, i, Enchantment.PROTECTION_ENVIRONMENTAL), - e * 10)); - getCrateLoot().addLoot(new RandomItem( - ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BOOTS.getId(), (byte) 0, - 1, (short) 0, null, Arrays.asList(new String[] {}), null, false, i, - Enchantment.PROTECTION_ENVIRONMENTAL), - e * 10)); - - getCrateLoot().addLoot(new RandomItem( - ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD.getId(), (byte) 0, - 1, (short) 0, null, Arrays.asList(new String[] {}), null, false, i, - Enchantment.DAMAGE_ALL), - e * 10)); - getCrateLoot().addLoot(new RandomItem( - ItemStackFactory.Instance.CreateStack(Material.DIAMOND_AXE.getId(), (byte) 0, 1, - (short) 0, null, Arrays.asList(new String[] {}), null, false, i, - Enchantment.DAMAGE_ALL), - e * 10)); - - getCrateLoot().addLoot(new RandomItem( - ItemStackFactory.Instance.CreateStack(Material.IRON_HELMET.getId(), (byte) 0, 1, - (short) 0, null, Arrays.asList(new String[] {}), null, false, i, - Enchantment.PROTECTION_ENVIRONMENTAL), - e * 3)); - getCrateLoot().addLoot(new RandomItem( - ItemStackFactory.Instance.CreateStack(Material.IRON_CHESTPLATE.getId(), - (byte) 0, 1, (short) 0, null, Arrays.asList(new String[] {}), null, - false, i, Enchantment.PROTECTION_ENVIRONMENTAL), - e * 3)); - getCrateLoot().addLoot(new RandomItem( - ItemStackFactory.Instance.CreateStack(Material.IRON_LEGGINGS.getId(), (byte) 0, - 1, (short) 0, null, Arrays.asList(new String[] {}), null, false, i, - Enchantment.PROTECTION_ENVIRONMENTAL), - e * 3)); - getCrateLoot().addLoot(new RandomItem( - ItemStackFactory.Instance.CreateStack(Material.IRON_BOOTS.getId(), (byte) 0, 1, - (short) 0, null, Arrays.asList(new String[] {}), null, false, i, - Enchantment.PROTECTION_ENVIRONMENTAL), - e * 3)); - - getCrateLoot().addLoot(new RandomItem( - ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD.getId(), (byte) 0, 1, - (short) 0, null, Arrays.asList(new String[] {}), null, false, i, - Enchantment.DAMAGE_ALL), - e * 3)); - getCrateLoot().addLoot( - new RandomItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE.getId(), - (byte) 0, 1, (short) 0, null, Arrays.asList(new String[] {}), null, - false, i, Enchantment.DAMAGE_ALL), e * 3)); - e--; - } - // Cooked furnace - getFurnace().addLoot(new RandomItem(Material.COOKED_BEEF, 3, 1, 2)); - getFurnace().addLoot(new RandomItem(Material.COOKED_CHICKEN, 3, 1, 2)); - getFurnace().addLoot(new RandomItem(Material.COOKED_FISH, 3, 1, 2)); - getFurnace().addLoot(new RandomItem(Material.GRILLED_PORK, 3, 1, 2)); - getFurnace().addLoot(new RandomItem(Material.BAKED_POTATO, 3, 1, 1)); - getFurnace().addLoot(new RandomItem(Material.PUMPKIN_PIE, 3, 1, 1)); - getFurnace().addLoot(new RandomItem(Material.IRON_INGOT, 1, 1, 1)); - - // Raw furnace - getRawFurnace().addLoot(new RandomItem(Material.RAW_BEEF, 1, 1, 3)); - getRawFurnace().addLoot(new RandomItem(Material.RAW_CHICKEN, 1, 1, 3)); - getRawFurnace().addLoot(new RandomItem(Material.RAW_FISH, 1, 1, 3)); - getRawFurnace().addLoot(new RandomItem(Material.PORK, 1, 1, 3)); - getRawFurnace().addLoot(new RandomItem(Material.POTATO_ITEM, 1, 1, 3)); - - // Deathmatch Loot - getDeathMatch().addLoot(new RandomItem(Material.PUMPKIN_PIE, 4)); - getDeathMatch().addLoot(new RandomItem(Material.BAKED_POTATO, 4)); - getDeathMatch().addLoot(new RandomItem(Material.CAKE, 4)); - getDeathMatch().addLoot(new RandomItem(Material.APPLE, 4)); - getDeathMatch().addLoot(new RandomItem(Material.DIAMOND_AXE, 3)); - getDeathMatch().addLoot(new RandomItem(Material.DIAMOND_SWORD, 3)); - } - - @Override - public void fillChest(Player looter, Block block) - { - getLootedBlocks().add(block.getLocation()); - - Chest chest = (Chest) block.getState(); - - chest.getBlockInventory().clear(); - - int items = 2; - if (Math.random() > 0.50) - items++; - if (Math.random() > 0.65) - items++; - if (Math.random() > 0.80) - items++; - if (Math.random() > 0.95) - items++; - - boolean spawnChest = getChestRefillTime() > 0 - && UtilMath.offset(chest.getLocation(), getSpawn()) < 8; - - if (spawnChest) - items += 3; - - if (GetKit(looter) instanceof KitLooter) - { - items += UtilMath.r(3); - } - - if (getSupplyBlocks().contains(block)) - { - items = 5; - if (Math.random() > 0.50) - items++; - if (Math.random() > 0.60) - items++; - if (Math.random() > 0.70) - items++; - if (Math.random() > 0.80) - items++; - if (Math.random() > 0.90) - items++; - if (Math.random() > 0.95) - items++; - } - - for (int i = 0; i < items; i++) - { - ItemStack item; - - if (spawnChest) - { - item = getSpawnLoot().getLoot(); - } - else if (isDeathMatchTeleported()) - { - item = getDeathMatch().getLoot(); - } - else - { - item = GetChestItem(getSupplyBlocks().contains(block)); - } - - if (item.getType() == Material.COMPASS) - { - item = buildCompass(5); - } - - chest.getBlockInventory().setItem(UtilMath.r(27), item); - } - - if (getSupplyBlocks().contains(block)) - { - Bukkit.getPluginManager().callEvent(new SupplyChestOpenEvent(looter, block)); - } - - getSupplyBlocks().remove(block); - } - - @Override - public void setupChestsEnchantingCrafting() - { - ArrayList chests = WorldData.GetCustomLocs("54"); - - System.out.println("Map Chest Locations: " + chests.size()); - - // Enchants - System.out.println("Enchanting Tables: " + Math.min(5, chests.size())); - for (int i = 0; i < 5 && !chests.isEmpty(); i++) - { - Location loc = chests.remove(UtilMath.r(chests.size())); - loc.getBlock().setType(Material.ENCHANTMENT_TABLE); - } - - // Crafting - System.out.println("Crafting Benches: " + Math.min(10, chests.size())); - for (int i = 0; i < 10 && !chests.isEmpty(); i++) - { - Location loc = chests.remove(UtilMath.r(chests.size())); - loc.getBlock().setType(Material.WORKBENCH); - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void StartEffectApply(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - return; - - for (Player player : GetPlayers(true)) - { - Manager.GetCondition().Factory().HealthBoost("Start Health", player, player, 30, 3, - false, false, false); - - player.setHealth(player.getMaxHealth()); - } - } - - @Override - public String GetMode() - { - return "OP Survival Games"; - } - -} 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 deleted file mode 100644 index cfb326659..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java +++ /dev/null @@ -1,385 +0,0 @@ -package nautilus.game.arcade.game.games.survivalgames.modes; - -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilTime; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.loot.RandomItem; -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.GameStateChangeEvent; -import nautilus.game.arcade.game.games.minestrike.GunModule; -import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats; -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; -import nautilus.game.arcade.game.games.survivalgames.modes.kit.KitPlayer; -import nautilus.game.arcade.game.modules.StrikeGamesModule; -import nautilus.game.arcade.kit.Kit; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.Chest; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -/** - * StrikeGames - * - * @author xXVevzZXx - */ -public class StrikeGames extends SoloSurvivalGames -{ - - private long _peacePhase; - private boolean _peace = false; - - public StrikeGames(ArcadeManager manager) - { - super(manager, new Kit[] - { - new KitPlayer(manager) - }, GameType.StrikeGames); - - Damage = false; - - _peacePhase = 20000; - - HungerSet = 20; - - GunModule gunModule = new GunModule(this); - gunModule.EnableCleaning = false; - gunModule.EnableDrop = false; - gunModule.EnablePickup = false; - gunModule.BlockRegeneration = false; - gunModule.EnableNormalArmor = true; - - new StrikeGamesModule(gunModule) - .register(this); - } - - @EventHandler - public void enableDamage(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - if (!IsLive()) - return; - - if (!UtilTime.elapsed(GetStateTime(), _peacePhase)) - return; - - if (!_peace) - return; - - _peace = false; - - Announce(F.main("Game", "The Peace Phase has ended! You can now fight each other!")); - Damage = 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!")); - } - - @EventHandler - public void disableCrafting(PlayerInteractEvent event) - { - if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) - return; - - if (event.getClickedBlock().getType() == Material.WORKBENCH) - event.setCancelled(true); - } - - public void setupLoot() - { - // Weapons - getBaseLoot().addLoot(new RandomItem(Material.WOOD_SWORD, 70)); - getBaseLoot().addLoot(new RandomItem(Material.STONE_SWORD, 30)); - - // Leather armor - getBaseLoot().addLoot(new RandomItem(Material.LEATHER_BOOTS, 30)); - getBaseLoot().addLoot(new RandomItem(Material.LEATHER_LEGGINGS, 30)); - - // Gold armor - getBaseLoot().addLoot(new RandomItem(Material.GOLD_BOOTS, 25)); - getBaseLoot().addLoot(new RandomItem(Material.GOLD_CHESTPLATE, 25)); - getBaseLoot().addLoot(new RandomItem(Material.GOLD_HELMET, 25)); - getBaseLoot().addLoot(new RandomItem(Material.GOLD_LEGGINGS, 25)); - - // Grenades - getBaseLoot().addLoot(new RandomItem(Material.CARROT_ITEM, 15)); - getBaseLoot().addLoot(new RandomItem(Material.APPLE, 15)); - getBaseLoot().addLoot(new RandomItem(Material.PORK, 15)); - getBaseLoot().addLoot(new RandomItem(Material.GRILLED_PORK, 15)); - getBaseLoot().addLoot(new RandomItem(Material.POTATO_ITEM, 15)); - - // Chain armor - getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_BOOTS, 20)); - getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_CHESTPLATE, 20)); - getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_HELMET, 20)); - getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_LEGGINGS, 20)); - - // Throwable - getBaseLoot().addLoot(new RandomItem(Material.FISHING_ROD, 30)); - getBaseLoot().addLoot(new RandomItem(Material.EGG, 30, 1, 2)); - - // Misc - //getBaseLoot().addLoot(new RandomItem(Material.EXP_BOTTLE, 30, 1, 2)); - getBaseLoot().addLoot(new RandomItem(Material.COMPASS, 20)); - getBaseLoot().addLoot(new RandomItem(Material.STICK, 30, 1, 2)); - getBaseLoot().addLoot(new RandomItem(Material.BOAT, 15)); - getBaseLoot().addLoot(new RandomItem(Material.FLINT, 30, 1, 2)); - getBaseLoot().addLoot(new RandomItem(Material.FEATHER, 30, 1, 2)); - getBaseLoot().addLoot(new RandomItem(Material.GOLD_INGOT, 20)); - getSpawnLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15)); - - getSpawnLoot().cloneLoot(getBaseLoot()); - - // Loot for chests in spawn - // Weaponry and ores - getSpawnLoot().addLoot(new RandomItem(Material.STONE_SWORD, 30)); - getSpawnLoot().addLoot(new RandomItem(Material.IRON_INGOT, 30, 1, 2)); - - // Iron gear - getSpawnLoot().addLoot(new RandomItem(Material.IRON_BOOTS, 30)); - getSpawnLoot().addLoot(new RandomItem(Material.IRON_CHESTPLATE, 30)); - getSpawnLoot().addLoot(new RandomItem(Material.IRON_HELMET, 30)); - getSpawnLoot().addLoot(new RandomItem(Material.IRON_LEGGINGS, 30)); - - // Supply crate loot - // Diamond gear - getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_HELMET, 10)); - getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_CHESTPLATE, 6)); - getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_LEGGINGS, 8)); - getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_BOOTS, 10)); - - // Iron gear - getCrateLoot().addLoot(new RandomItem(Material.IRON_HELMET, 30)); - getCrateLoot().addLoot(new RandomItem(Material.IRON_CHESTPLATE, 24)); - getCrateLoot().addLoot(new RandomItem(Material.IRON_LEGGINGS, 27)); - getCrateLoot().addLoot(new RandomItem(Material.IRON_BOOTS, 30)); - - // Weapons - getCrateLoot().addLoot(new RandomItem(Material.IRON_SWORD, 24)); - getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_SWORD, 8)); - getCrateLoot().addLoot(new RandomItem(Material.GOLD_SPADE, 12)); - - // Deathmatch Loot - getDeathMatch().addLoot(new RandomItem(Material.WOOD_SWORD, 3)); - getDeathMatch().addLoot(new RandomItem(Material.STONE_SWORD, 1)); - } - - @Override - public void fillChest(Player looter, Block block) - { - getLootedBlocks().add(block.getLocation()); - - Chest chest = (Chest) block.getState(); - - chest.getBlockInventory().clear(); - - int items = 2; - if (Math.random() > 0.50) - items++; - if (Math.random() > 0.65) - items++; - if (Math.random() > 0.80) - items++; - if (Math.random() > 0.95) - items++; - - boolean spawnChest = getChestRefillTime() > 0 - && UtilMath.offset(chest.getLocation(), getSpawn()) < 8; - - if (spawnChest) - items += 3; - - if (GetKit(looter) instanceof KitLooter) - { - items += UtilMath.r(3); - } - - if (getSupplyBlocks().contains(block)) - { - items = 5; - if (Math.random() > 0.50) - items++; - if (Math.random() > 0.60) - items++; - if (Math.random() > 0.70) - items++; - if (Math.random() > 0.80) - items++; - if (Math.random() > 0.90) - items++; - if (Math.random() > 0.95) - items++; - } - - for (int i = 0; i < items; i++) - { - ItemStack item; - - if (spawnChest) - { - item = getSpawnLoot().getLoot(); - } - else if (isDeathMatchTeleported()) - { - item = getDeathMatch().getLoot(); - } - else - { - item = GetChestItem(getSupplyBlocks().contains(block)); - } - - if (item.getType() == Material.COMPASS) - { - item = buildCompass(5); - } - if (UtilItem.isWeapon(item)) - { - GunStats gunStat = GunStats.values()[UtilMath.r(GunStats.values().length)]; - - int e = 0; - - while (gunStat == GunStats.AWP && e < 20) - { - gunStat = GunStats.values()[UtilMath.r(GunStats.values().length)]; - e++; - } - - item = ItemStackFactory.Instance.CreateStack(gunStat.getSkin(), (byte) 0, 1, gunStat.getName()); - } - - String name = null; - if (item.getType() == Material.APPLE) - { - name = "High Explosive"; - } - else if (item.getType() == Material.CARROT_ITEM) - { - name = "Flash Bang"; - } - else if (item.getType() == Material.POTATO_ITEM) - { - name = "Smoke"; - } - else if (item.getType() == Material.PORK) - { - name = "Incendiary"; - } - else if (item.getType() == Material.GRILLED_PORK) - { - name = "Molotov"; - } - if (name != null) - { - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName(name); - item.setItemMeta(meta); - } - - chest.getBlockInventory().setItem(UtilMath.r(27), item); - } - - if (getSupplyBlocks().contains(block)) - { - Bukkit.getPluginManager().callEvent(new SupplyChestOpenEvent(looter, block)); - } - - getSupplyBlocks().remove(block); - } - - @EventHandler - @Override - public void ItemSpawn(ItemSpawnEvent event) - { - if (event.getEntity().getItemStack().hasItemMeta()) - return; - - Material mat = event.getEntity().getItemStack().getType(); - - switch (mat) - { - case SEEDS: - case SAPLING: - case VINE: - case LEAVES: - case LONG_GRASS: - case RED_ROSE: - case YELLOW_FLOWER: - case DEAD_BUSH: - case WATER_LILY: - event.setCancelled(true); - return; - case CARROT_ITEM: - event.setCancelled(true); - return; - case POTATO_ITEM: - event.setCancelled(true); - return; - case WHEAT: - event.setCancelled(true); - return; - case WOOD: - event.setCancelled(true); - return; - - default: - break; - } - - for (Player player : GetPlayers(true)) - if (UtilMath.offset(player, event.getEntity()) < 6) - return; - - event.setCancelled(true); - } - - @Override - public String GetMode() - { - return "Strike Games"; - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java deleted file mode 100644 index fa44f00ed..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/UHCSurvivalgames.java +++ /dev/null @@ -1,376 +0,0 @@ -package nautilus.game.arcade.game.games.survivalgames.modes; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.Chest; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -import org.bukkit.event.inventory.PrepareItemCraftEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; - -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilTime; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.loot.RandomItem; -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.GameStateChangeEvent; -import nautilus.game.arcade.game.games.AbsorptionFix; -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; -import nautilus.game.arcade.game.games.survivalgames.modes.kit.KitSurvivalist; -import nautilus.game.arcade.kit.Kit; - -/** - * UHCSurvivalgames gamemode for Survivalgames - * - * @author xXVevzZXx - */ -public class UHCSurvivalgames extends SoloSurvivalGames -{ - - private long _peacePhase; - private boolean _peace; - - public UHCSurvivalgames(ArcadeManager manager) - { - super(manager, new Kit[] - { - new KitSurvivalist(manager) - }, - GameType.Brawl); - - _peacePhase = 45000; // 45 Seconds - SoupEnabled = false; - - DamagePvP = false; - - BlockBreak = true; - BlockPlace = true; - - BlockBreakDeny.add(Material.DIAMOND_BLOCK.getId()); - BlockBreakDeny.add(Material.IRON_BLOCK.getId()); - BlockBreakDeny.add(Material.GOLD_BLOCK.getId()); - BlockBreakDeny.add(Material.REDSTONE_ORE.getId()); - BlockBreakDeny.add(Material.REDSTONE_WIRE.getId()); - BlockBreakDeny.add(Material.REDSTONE.getId()); - BlockBreakDeny.add(Material.TNT.getId()); - BlockBreakDeny.add(Material.CHEST.getId()); - - BlockPlaceDeny.add(Material.REDSTONE.getId()); - BlockPlaceDeny.add(Material.REDSTONE_ORE.getId()); - BlockPlaceDeny.add(Material.REDSTONE_WIRE.getId()); - BlockPlaceDeny.add(Material.CHEST.getId()); - - new AbsorptionFix(this); - } - - @EventHandler - public void enableDamage(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - if (!IsLive()) - return; - - if (!UtilTime.elapsed(GetStateTime(), _peacePhase)) - return; - - if (!_peace) - return; - - _peace = false; - - Announce(F.main("Game", "The Peace Phase has ended! You can now fight each other!")); - DamagePvP = true; - } - - @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!")); - } - - @EventHandler - public void registerObj(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - else if (event.GetState() != GameState.Live) - getCrateLoot().addLoot(new RandomItem(new ItemStack(Material.GOLDEN_APPLE), 100)); - - Objective objective = Scoreboard.getScoreboard().registerNewObjective("Health", "health"); - objective.setDisplaySlot(DisplaySlot.PLAYER_LIST); - } - - @EventHandler - public void regenHealth(EntityRegainHealthEvent event) - { - if (event.getRegainReason() == RegainReason.SATIATED) - event.setCancelled(true); - } - - @EventHandler - public void gappleDrop(EntityDeathEvent event) - { - if (event.getEntity() instanceof Player) - { - event.getDrops().add(new ItemStack(Material.GOLDEN_APPLE, 2)); - } - } - - @EventHandler(priority=EventPriority.LOWEST) - public void spawnBreak(BlockBreakEvent event) - { - if (UtilMath.offset(event.getBlock().getLocation(), getSpawn()) < 40) - event.setCancelled(true); - } - - @EventHandler(priority=EventPriority.LOWEST) - public void spawnPlace(BlockPlaceEvent event) - { - if (UtilMath.offset(event.getBlock().getLocation(), getSpawn()) < 40) - event.setCancelled(true); - } - - public void setupLoot() - { - // Build material - getBaseLoot().addLoot(new RandomItem(Material.WOOD, 40, 7, 15)); - - // Food - getBaseLoot().addLoot(new RandomItem(Material.BAKED_POTATO, 40, 1, 3)); - getBaseLoot().addLoot(new RandomItem(Material.COOKED_BEEF, 40, 1, 2)); - getBaseLoot().addLoot(new RandomItem(Material.COOKED_CHICKEN, 40, 1, 2)); - getBaseLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 10, 1, 1)); - getBaseLoot().addLoot(new RandomItem(Material.PORK, 35, 1, 4)); - - // Weapons - getBaseLoot().addLoot(new RandomItem(Material.IRON_AXE, 80)); - getBaseLoot().addLoot(new RandomItem(Material.IRON_SWORD, 70)); - getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_AXE, 60)); - getBaseLoot().addLoot(new RandomItem(Material.DIAMOND_SWORD, 30)); - - // Gold armor - getBaseLoot().addLoot(new RandomItem(Material.GOLD_BOOTS, 25)); - getBaseLoot().addLoot(new RandomItem(Material.GOLD_CHESTPLATE, 25)); - getBaseLoot().addLoot(new RandomItem(Material.GOLD_HELMET, 25)); - getBaseLoot().addLoot(new RandomItem(Material.GOLD_LEGGINGS, 25)); - - // Chain armor - getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_BOOTS, 20)); - getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_CHESTPLATE, 20)); - getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_HELMET, 20)); - getBaseLoot().addLoot(new RandomItem(Material.CHAINMAIL_LEGGINGS, 20)); - - // Throwable - getBaseLoot().addLoot(new RandomItem(Material.FISHING_ROD, 30)); - getBaseLoot().addLoot(new RandomItem(Material.BOW, 20)); - getBaseLoot().addLoot(new RandomItem(Material.ARROW, 40, 2, 4)); - - // Misc - getBaseLoot().addLoot(new RandomItem(Material.EXP_BOTTLE, 40, 1, 2)); - getBaseLoot().addLoot(new RandomItem(Material.COMPASS, 20)); - getBaseLoot().addLoot(new RandomItem(Material.STICK, 30, 1, 2)); - getBaseLoot().addLoot(new RandomItem(Material.BOAT, 15)); - getBaseLoot().addLoot(new RandomItem(Material.GOLD_INGOT, 20)); - getBaseLoot().addLoot(new RandomItem(Material.GOLDEN_APPLE, 2)); - getBaseLoot().addLoot(new RandomItem(ItemStackFactory.Instance.CreateStack( - Material.TNT, (byte) 0, 1, F.item("Throwing TNT")), 15)); - getSpawnLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15)); - - getSpawnLoot().cloneLoot(getBaseLoot()); - - // Food - getSpawnLoot().addLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 5)); - getSpawnLoot().addLoot(new RandomItem(Material.CAKE, 30)); - getSpawnLoot().addLoot(new RandomItem(Material.MUSHROOM_SOUP, 30, 1, 1)); - getSpawnLoot().addLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 3)); - getSpawnLoot().addLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 3)); - getSpawnLoot().addLoot(new RandomItem(Material.COOKED_FISH, 30, 1, 6)); - getSpawnLoot().addLoot(new RandomItem(Material.GRILLED_PORK, 30, 1, 3)); - getSpawnLoot().addLoot(new RandomItem(Material.COOKIE, 30)); - getSpawnLoot().addLoot(new RandomItem(Material.PUMPKIN_PIE, 30, 1, 3)); - getSpawnLoot().addLoot(new RandomItem(Material.APPLE, 30, 2, 6)); - - // Loot for chests in spawn - // Weaponry and ores - getSpawnLoot().addLoot(new RandomItem(Material.STONE_SWORD, 30)); - getSpawnLoot().addLoot(new RandomItem(Material.IRON_AXE, 30)); - getSpawnLoot().addLoot(new RandomItem(Material.IRON_INGOT, 40, 1, 2)); - getSpawnLoot().addLoot(new RandomItem(Material.DIAMOND, 30)); - - // Iron gear - getSpawnLoot().addLoot(new RandomItem(Material.IRON_BOOTS, 30)); - getSpawnLoot().addLoot(new RandomItem(Material.IRON_CHESTPLATE, 30)); - getSpawnLoot().addLoot(new RandomItem(Material.IRON_HELMET, 30)); - getSpawnLoot().addLoot(new RandomItem(Material.IRON_LEGGINGS, 30)); - - // Supply crate loot - // Diamond gear - getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_HELMET, 10)); - getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_CHESTPLATE, 6)); - getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_LEGGINGS, 8)); - getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_BOOTS, 10)); - - // Iron gear - getCrateLoot().addLoot(new RandomItem(Material.IRON_HELMET, 30)); - getCrateLoot().addLoot(new RandomItem(Material.IRON_CHESTPLATE, 24)); - getCrateLoot().addLoot(new RandomItem(Material.IRON_LEGGINGS, 27)); - getCrateLoot().addLoot(new RandomItem(Material.IRON_BOOTS, 30)); - - // Weapons - getCrateLoot().addLoot(new RandomItem(Material.IRON_SWORD, 24)); - getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_SWORD, 8)); - getCrateLoot().addLoot(new RandomItem(Material.DIAMOND_AXE, 16)); - - // Cooked furnace - getFurnace().addLoot(new RandomItem(Material.COOKED_BEEF, 3, 1, 2)); - getFurnace().addLoot(new RandomItem(Material.COOKED_CHICKEN, 3, 1, 2)); - getFurnace().addLoot(new RandomItem(Material.COOKED_FISH, 3, 1, 2)); - getFurnace().addLoot(new RandomItem(Material.GRILLED_PORK, 3, 1, 2)); - getFurnace().addLoot(new RandomItem(Material.BAKED_POTATO, 3, 1, 1)); - getFurnace().addLoot(new RandomItem(Material.PUMPKIN_PIE, 3, 1, 1)); - getFurnace().addLoot(new RandomItem(Material.IRON_INGOT, 1, 1, 1)); - - // Raw furnace - getRawFurnace().addLoot(new RandomItem(Material.RAW_BEEF, 1, 1, 3)); - getRawFurnace().addLoot(new RandomItem(Material.RAW_CHICKEN, 1, 1, 3)); - getRawFurnace().addLoot(new RandomItem(Material.RAW_FISH, 1, 1, 3)); - getRawFurnace().addLoot(new RandomItem(Material.PORK, 1, 1, 3)); - getRawFurnace().addLoot(new RandomItem(Material.POTATO_ITEM, 1, 1, 3)); - - // Deathmatch Loot - getDeathMatch().addLoot(new RandomItem(Material.PUMPKIN_PIE, 4)); - getDeathMatch().addLoot(new RandomItem(Material.BAKED_POTATO, 4)); - getDeathMatch().addLoot(new RandomItem(Material.CAKE, 4)); - getDeathMatch().addLoot(new RandomItem(Material.APPLE, 4)); - getDeathMatch().addLoot(new RandomItem(Material.WOOD_SWORD, 3)); - getDeathMatch().addLoot(new RandomItem(Material.WOOD_AXE, 3)); - getDeathMatch().addLoot(new RandomItem(Material.STONE_AXE, 3)); - getDeathMatch().addLoot(new RandomItem(Material.STONE_SWORD, 1)); - } - - public void fillChest(Player looter, Block block) - { - getLootedBlocks().add(block.getLocation()); - - Chest chest = (Chest) block.getState(); - - chest.getBlockInventory().clear(); - - int items = 2; - if (Math.random() > 0.50) - items++; - if (Math.random() > 0.65) - items++; - if (Math.random() > 0.80) - items++; - if (Math.random() > 0.95) - items++; - - boolean spawnChest = getChestRefillTime() > 0 - && UtilMath.offset(chest.getLocation(), getSpawn()) < 8; - - if (spawnChest) - items += 3; - - if (GetKit(looter) instanceof KitLooter) - { - items += UtilMath.r(3); - } - - if (getSupplyBlocks().contains(block)) - { - items = 2; - if (Math.random() > 0.75) - items++; - if (Math.random() > 0.95) - items++; - } - - for (int i = 0; i < items; i++) - { - ItemStack item; - - if (spawnChest) - { - item = getSpawnLoot().getLoot(); - } - else if (isDeathMatchTeleported()) - { - item = getDeathMatch().getLoot(); - } - else - { - boolean drop = getSupplyBlocks().contains(block); - item = GetChestItem(drop); - - // Golden apple spawn - if (drop && i == items) - item = new ItemStack(Material.GOLDEN_APPLE); - } - - if (item.getType() == Material.COMPASS) - { - item = buildCompass(5); - } - - handlePickup(item); - - chest.getBlockInventory().setItem(UtilMath.r(27), item); - } - - if (getSupplyBlocks().contains(block)) - { - Bukkit.getPluginManager().callEvent( - new SupplyChestOpenEvent(looter, block)); - } - - getSupplyBlocks().remove(block); - } - - @Override - @EventHandler - public void preventCrafting(PrepareItemCraftEvent event) - { - ItemStack result = event.getInventory().getResult(); - - if (result != null) - { - Material type = result.getType(); - - if (type == Material.BUCKET - || type == Material.FLINT_AND_STEEL) - { - event.getInventory().setResult(new ItemStack(Material.AIR)); - } - } - } - - @Override - public String GetMode() - { - return "UHC Survivalgames"; - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/kit/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/kit/KitPlayer.java deleted file mode 100644 index 9942e1cc3..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/kit/KitPlayer.java +++ /dev/null @@ -1,46 +0,0 @@ -package nautilus.game.arcade.game.games.survivalgames.modes.kit; - -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 nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; - -public class KitPlayer extends Kit -{ - public KitPlayer(ArcadeManager manager) - { - super(manager, "Player", KitAvailability.Free, - new String[] - { - C.cGreen + "Right-Click" + C.cWhite + " - " + C.cYellow + "Fire Gun", - C.cGreen + "Left-Click" + C.cWhite + " - " + C.cYellow + "Reload Gun", - C.cGreen + "Crouch" + C.cWhite + " - " + C.cYellow + "Sniper Scope", - }, - new Perk[] - { - - }, - EntityType.PLAYER, - new ItemStack(Material.AIR)); - - } - - @Override - public void GiveItems(Player player) - { - - } - - @Override - public void SpawnCustom(LivingEntity ent) - { - - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/kit/KitSurvivalist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/kit/KitSurvivalist.java deleted file mode 100644 index d2165eeea..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/kit/KitSurvivalist.java +++ /dev/null @@ -1,48 +0,0 @@ -package nautilus.game.arcade.game.games.survivalgames.modes.kit; - -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 nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; - -/** - * KitSurvivalist - * - * @author xXVevzZXx - */ -public class KitSurvivalist extends Kit -{ - public KitSurvivalist(ArcadeManager manager) - { - super(manager, "Survivalist", KitAvailability.Free, - new String[] - { - "You are a survival expert!", - }, - new Perk[] - { - - }, - EntityType.PLAYER, - new ItemStack(Material.AIR)); - - } - - @Override - public void GiveItems(Player player) - { - - } - - @Override - public void SpawnCustom(LivingEntity ent) - { - - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modules/BorderModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modules/BorderModule.java new file mode 100644 index 000000000..efd0ff2ce --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modules/BorderModule.java @@ -0,0 +1,123 @@ +package nautilus.game.arcade.game.games.survivalgames.modules; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.WorldBorder; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.recharge.Recharge; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerDeathOutEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.modules.Module; + +public class BorderModule extends Module +{ + + private static final int RATE_CONSTANT = 60; + private static final int PLAYER_CONSTANT = 24; + + private double _initialBorder, _initialPlayers, _deathmatchSize = 61; + + @Override + protected void setup() + { + Game game = getGame(); + Location center = game.GetSpectatorLocation(); + List borders = Arrays.asList + ( + game.WorldData.MaxX - center.getX(), + center.getX() - game.WorldData.MinX, + game.WorldData.MaxZ - center.getZ(), + center.getZ() - game.WorldData.MinZ + ); + + borders.sort(Comparator.naturalOrder()); + double largestBorder = borders.get(borders.size() - 1); + WorldBorder border = game.WorldData.World.getWorldBorder(); + + _initialBorder = largestBorder * 2; + border.setCenter(center); + border.setSize(_initialBorder); + border.setDamageAmount(0.1); + border.setDamageBuffer(0); + border.setWarningDistance(10); + + List deathmatchPoint = game.WorldData.GetDataLocs("BROWN"); + + if (!deathmatchPoint.isEmpty()) + { + _deathmatchSize = UtilMath.offset(center, deathmatchPoint.get(0)) * 2; + } + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + int players = getGame().GetPlayers(true).size(); + _initialPlayers = players; + updateBorderSize(players); + } + + @EventHandler + public void end(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + { + return; + } + + getGame().WorldData.World.getWorldBorder().setSize(Integer.MAX_VALUE); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void playerDeathOut(PlayerDeathOutEvent event) + { + if (event.isCancelled()) + { + return; + } + + updateBorderSize(getGame().GetPlayers(true).size() - 1); + } + + private void updateBorderSize(int players) + { + WorldBorder border = getGame().WorldData.World.getWorldBorder(); + + border.setSize(border.getSize()); + border.setSize(_deathmatchSize, (long) ((border.getSize() / _initialBorder) * (players * (PLAYER_CONSTANT / _initialPlayers)) * RATE_CONSTANT)); + } + + @EventHandler + public void borderDamage(CustomDamageEvent event) + { + Player player = event.GetDamageePlayer(); + + if (event.GetCause() != DamageCause.SUFFOCATION || player == null) + { + return; + } + + event.SetCancelled("Border Pre-Event"); + if (Recharge.Instance.use(player, "World Border Damage", 1000, false, false)) + { + getGame().getArcadeManager().GetDamage().NewDamageEvent(event.GetDamageeEntity(), null, null, DamageCause.CUSTOM, 2, false, true, true, getGame().GetName(), "World Border"); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modules/FurnaceLootModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modules/FurnaceLootModule.java new file mode 100644 index 000000000..80ac1362c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modules/FurnaceLootModule.java @@ -0,0 +1,96 @@ +package nautilus.game.arcade.game.games.survivalgames.modules; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Furnace; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.FurnaceInventory; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; + +import nautilus.game.arcade.events.ChestRefillEvent; +import nautilus.game.arcade.game.modules.Module; + +public class FurnaceLootModule extends Module +{ + + private final Set _lootedBlocks; + private final List _rawLoot = Arrays.asList + ( + new ItemStack(Material.RAW_BEEF), + new ItemStack(Material.RAW_CHICKEN), + new ItemStack(Material.RAW_FISH), + new ItemStack(Material.PORK), + new ItemStack(Material.POTATO_ITEM) + ); + private final List _cookedLoot = Arrays.asList + ( + new ItemStack(Material.COOKED_BEEF), + new ItemStack(Material.COOKED_CHICKEN), + new ItemStack(Material.COOKED_FISH), + new ItemStack(Material.GRILLED_PORK), + new ItemStack(Material.BAKED_POTATO), + new ItemStack(Material.BAKED_POTATO), + new ItemStack(Material.IRON_INGOT) + ); + + public FurnaceLootModule() + { + _lootedBlocks = new HashSet<>(); + } + + @EventHandler + public void furnaceInteract(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R_BLOCK) || !getGame().IsLive()) + { + return; + } + + Block block = event.getClickedBlock(); + + if (block.getType() != Material.FURNACE || !_lootedBlocks.add(block)) + { + return; + } + + Furnace furnace = ((Furnace) block.getState()); + + if (furnace.getCookTime() != 0) + { + return; + } + + FurnaceInventory inventory = furnace.getInventory(); + int random = UtilMath.r(9); + + if (random == 0) + { + inventory.setFuel(new ItemStack(Material.STICK, UtilMath.r(2) + 1)); + } + else if (random <= 3) + { + inventory.setSmelting(UtilAlg.Random(_rawLoot)); + } + else + { + inventory.setResult(UtilAlg.Random(_cookedLoot)); + } + } + + @EventHandler + public void chestRefill(ChestRefillEvent event) + { + _lootedBlocks.clear(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modules/SupplyDropModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modules/SupplyDropModule.java new file mode 100644 index 000000000..6f2fb1280 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modules/SupplyDropModule.java @@ -0,0 +1,348 @@ +package nautilus.game.arcade.game.games.survivalgames.modules; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEnderDragon; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.entity.EnderDragon; +import org.bukkit.entity.Entity; +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.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; + +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.Pair; +import mineplex.core.common.util.C; +import mineplex.core.common.util.MapUtil; +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.UtilFirework; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.treasure.util.TreasureUtil; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import nautilus.game.arcade.game.modules.Module; + +public class SupplyDropModule extends Module +{ + + public static final int TIME = 14000; + private static final long DURATION = TimeUnit.SECONDS.toMillis(60); + private static final int HEIGHT = 40; + private static final int RADIUS = 8; + private static final int POINTS = 80; + private static final FireworkEffect FIREWORK_EFFECT = FireworkEffect.builder() + .with(Type.BURST) + .withColor(Color.YELLOW) + .build(); + + private static final int[][] LOOT_CONFIGURATIONS = + { + { + 1, 1, 2 + }, + { + 1, 1, 3 + }, + { + 1, 2, 2 + }, + { + 2, 2 + }, + { + 2, 3 + } + }; + private final ImmutableMap> _lootTable; + private final Inventory _chestInventory; + private SupplyDrop _supplyDrop; + private Block _lastBlock; + private boolean _firstOpening; + + public SupplyDropModule() + { + _lootTable = ImmutableMap.>builder() + .put(1, Lists.newArrayList + ( + new ItemStack(Material.IRON_BOOTS), + new ItemStack(Material.IRON_SWORD), + new ItemStack(Material.DIAMOND_AXE) + )) + .put(2, Lists.newArrayList + ( + new ItemStack(Material.IRON_CHESTPLATE), + new ItemStack(Material.IRON_LEGGINGS), + new ItemStack(Material.DIAMOND_HELMET), + new ItemStack(Material.DIAMOND_BOOTS) + )) + .put(3, Lists.newArrayList + ( + new ItemStack(Material.DIAMOND_CHESTPLATE), + new ItemStack(Material.DIAMOND_LEGGINGS), + new ItemStack(Material.DIAMOND_SWORD) + )) + .build(); + + _chestInventory = Bukkit.createInventory(null, 27, "Supply Drop"); + } + + @Override + public void cleanup() + { + _chestInventory.clear(); + _supplyDrop = null; + _lastBlock = null; + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK || !getGame().IsLive()) + { + return; + } + + if (_supplyDrop == null) + { + if (getGame().WorldTimeSet > TIME && getGame().WorldTimeSet < TIME + 1000) + { + Location location = getRandom(); + + if (location == null) + { + return; + } + + BlockRestore restore = getGame().getArcadeManager().GetBlockRestore(); + long duration = DURATION + TimeUnit.SECONDS.toMillis(10); + for (Pair> pair : UtilBlock.getBeaconBlocks(location, (byte) 4)) + { + restore.add(pair.getLeft().getBlock(), pair.getRight().getLeft().getId(), pair.getRight().getRight(), duration); + } + + getGame().CreatureAllowOverride = true; + + LivingEntity entity = location.getWorld().spawn(location.add(0, HEIGHT, 0), EnderDragon.class); + + entity.setRemoveWhenFarAway(false); + UtilEnt.setTickWhenFarAway(entity, true); + UtilEnt.vegetate(entity, true); + UtilEnt.ghost(entity, true, false); + + getGame().CreatureAllowOverride = false; + + getGame().Announce(C.cRedB + "A Supply Drop has appeared at " + C.cWhite + "(" + location.getBlockX() + ", " + location.getBlockZ() + ")."); + + _supplyDrop = new SupplyDrop(location, entity); + } + } + else if (!_supplyDrop.Dropped) + { + if (UtilTime.elapsed(_supplyDrop.Start, DURATION)) + { + _supplyDrop.Dropped = true; + ((CraftEnderDragon) _supplyDrop.Dragon).getHandle().setTargetBlock(256, 100, 256); + byte data = (byte) (UtilMath.r(4) + 2); + + getGame().getArcadeManager().runSyncTimer(new BukkitRunnable() + { + Block block = _supplyDrop.Drop.getBlock(); + boolean done = false; + + @Override + public void run() + { + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR); + block = block.getRelative(BlockFace.DOWN); + + if (UtilBlock.solid(block)) + { + block = block.getRelative(BlockFace.UP); + done = true; + _supplyDrop.Dragon.remove(); + _supplyDrop = null; + _firstOpening = true; + cancel(); + } + + UtilFirework.playFirework(block.getLocation().add(0.5, 0.5, 0.5), FIREWORK_EFFECT); + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.ENDER_CHEST, data); + + if (done) + { + _lastBlock = block; + populateChest(); + } + } + }, 0, 5); + } + else + { + Location center = _supplyDrop.Drop; + double theta = Math.PI * 2 / POINTS * _supplyDrop.Point; + double x = RADIUS * Math.cos(theta), z = RADIUS * Math.sin(theta); + float yaw = 360 / POINTS * _supplyDrop.Point - 90; + + ((CraftEntity) _supplyDrop.Dragon).getHandle().setPositionRotation(center.getX() + x, center.getY(), center.getZ() + z, yaw, 0); + + _supplyDrop.Point++; + _supplyDrop.Point %= POINTS; + _supplyDrop.Drop.setYaw(yaw); + } + } + } + + @EventHandler + public void openChest(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + { + return; + } + + Player player = event.getPlayer(); + Block block = event.getClickedBlock(); + + if (UtilPlayer.isSpectator(player) || !block.equals(_lastBlock)) + { + return; + } + + event.setCancelled(true); + TreasureUtil.playChestOpen(block.getLocation(), true); + player.openInventory(_chestInventory); + + if (_firstOpening) + { + _firstOpening = false; + getGame().AddStat(player, "SupplyDropsOpened", 1, false, false); + } + } + + private void populateChest() + { + List slots = new ArrayList<>(_chestInventory.getSize()); + + for (int i = 0; i < _chestInventory.getSize(); i++) + { + slots.add(i); + } + + Map> lootTable = new HashMap<>(_lootTable.size()); + + _lootTable.forEach((integer, itemStacks) -> lootTable.put(integer, new ArrayList<>(itemStacks))); + _chestInventory.clear(); + + int[] configuration = UtilMath.randomElement(LOOT_CONFIGURATIONS); + + for (int i : configuration) + { + List itemStacks = lootTable.get(i); + ItemStack itemStack = UtilAlg.Random(itemStacks); + UtilItem.makeUnbreakable(itemStack); + itemStacks.remove(itemStack); + int slot = UtilMath.r(slots.size()); + slots.remove(slot); + + _chestInventory.setItem(slot, itemStack); + } + } + + private Location getRandom() + { + double size = getGame().WorldData.World.getWorldBorder().getSize() / 3; + Location center = getGame().GetSpectatorLocation(); + + int attempts = 0; + + attemptsLoop: + while (attempts++ < 50) + { + Location location = UtilAlg.getRandomLocation(center, size, 0, size); + Block block = location.getBlock(); + + while (block.getLocation().getY() > 0 && !UtilBlock.solid(block)) + { + if (block.isLiquid()) + { + continue attemptsLoop; + } + + block = block.getRelative(BlockFace.DOWN); + } + + for (BlockFace face : UtilBlock.horizontals) + { + if (!UtilBlock.solid(block.getRelative(face))) + { + continue attemptsLoop; + } + } + + block = block.getRelative(BlockFace.UP); + Block bottom = block; + + while (block.getLocation().getY() < getGame().WorldData.MaxY) + { + if (UtilBlock.solid(block)) + { + continue attemptsLoop; + } + + block = block.getRelative(BlockFace.UP); + } + + return bottom.getLocation().add(0.5, 0, 0.5); + } + + return null; + } + + private class SupplyDrop + { + Location Drop; + boolean Dropped; + long Start; + Entity Dragon; + int Point; + + SupplyDrop(Location drop, Entity dragon) + { + Drop = drop; + Start = System.currentTimeMillis(); + Dragon = dragon; + } + } + + public Location getCurrentDrop() + { + return _supplyDrop == null ? null : _supplyDrop.Drop; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modules/TrackingCompassModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modules/TrackingCompassModule.java new file mode 100644 index 000000000..99ac898d5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modules/TrackingCompassModule.java @@ -0,0 +1,122 @@ +package nautilus.game.arcade.game.games.survivalgames.modules; + +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +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.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; + +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.modules.Module; + +public class TrackingCompassModule extends Module +{ + + @EventHandler + public void interactCompass(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = player.getItemInHand(); + + if (UtilPlayer.isSpectator(player) || itemStack == null || itemStack.getType() != Material.COMPASS) + { + return; + } + + int uses = getUses(itemStack); + + if (uses == 0) + { + player.sendMessage(F.main("Game", "The compass breaks! No remaining uses!")); + player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 1); + player.setItemInHand(null); + return; + } + else if (!Recharge.Instance.use(player, "Compass", 500, true, true)) + { + return; + } + + GameTeam team = getGame().GetTeam(player); + + for (Player nearby : UtilPlayer.getNearby(player.getLocation(), 256)) + { + if (player.equals(nearby) || getGame().TeamMode && team.HasPlayer(nearby)) + { + continue; + } + + player.setCompassTarget(nearby.getLocation()); + player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 1); + player.sendMessage(F.main("Game", F.name(nearby.getName()) + " is " + F.count((int) UtilMath.offset(player, nearby)) + " blocks away.")); + player.setItemInHand(getCompass(--uses)); + return; + } + } + + @EventHandler + public void combineCompasses(InventoryClickEvent event) + { + Player player = (Player) event.getWhoClicked(); + ItemStack cursor = event.getCursor(); + ItemStack currentItem = event.getCurrentItem(); + + if (UtilPlayer.isSpectator(player) || cursor == null || currentItem == null || cursor.getType() != Material.COMPASS || currentItem.getType() != Material.COMPASS) + { + return; + } + + int a = getUses(cursor), b = getUses(currentItem); + + event.setCursor(getCompass(a + b)); + event.setCurrentItem(null); + player.sendMessage(F.main("Game", "You combined two compasses.")); + player.playSound(player.getLocation(), Sound.ANVIL_USE, 1, 1); + } + + private int getUses(ItemStack itemStack) + { + if (!itemStack.hasItemMeta()) + { + return 0; + } + + ItemMeta itemMeta = itemStack.getItemMeta(); + List lore = itemMeta.getLore(); + + if (lore.isEmpty()) + { + return 0; + } + + return Integer.parseInt(ChatColor.stripColor(lore.get(0)).replaceAll("\\D+", "")); + } + + public ItemStack getCompass(int uses) + { + return new ItemBuilder(Material.COMPASS) + .setTitle(C.cYellowB + "Tracking Compass") + .addLore("Uses " + C.cYellow + uses, "Use this to find the location and", "distance of the nearest player!", "Click on another compass in your inventory to", "combine them!", "Id: " + C.cRed + UtilMath.r(1000)) + .build(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java index bc1132127..3e1a1a1ea 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java @@ -13,6 +13,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.NameTagVisibility; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Score; import org.bukkit.scoreboard.Scoreboard; @@ -50,6 +51,7 @@ public class CustomScoreboardModule extends Module private BiConsumer _scoreboardConsumer; private BiFunction _prefixFunction; private BiFunction _suffixFunction; + private BiFunction _nameTagVisibilityFunction; private BiFunction _tabListFunction; private String _underNameObjective; private BiFunction _underNameFunction; @@ -225,6 +227,12 @@ public class CustomScoreboardModule extends Module return this; } + public CustomScoreboardModule setNameTagVisibility(BiFunction function) + { + _nameTagVisibilityFunction = function; + return this; + } + /** * Refreshes all player's scoreboards. */ @@ -289,6 +297,7 @@ public class CustomScoreboardModule extends Module String prefix = _prefixFunction == null ? null : _prefixFunction.apply(getOwner(), subject); String suffix = _suffixFunction == null ? null : _suffixFunction.apply(getOwner(), subject); + NameTagVisibility visibility = _nameTagVisibilityFunction == null ? null : _nameTagVisibilityFunction.apply(getOwner(), subject); if (team == null) { @@ -310,6 +319,13 @@ public class CustomScoreboardModule extends Module team.setSuffix(suffix); } } + if (visibility != null) + { + if (!visibility.equals(team.getNameTagVisibility())) + { + team.setNameTagVisibility(visibility); + } + } } private void updateTabList(Player subject) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/ThrowableTNTModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/ThrowableTNTModule.java index 00ed93bbc..6f5649e50 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/ThrowableTNTModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/ThrowableTNTModule.java @@ -3,7 +3,6 @@ package nautilus.game.arcade.game.modules; import java.util.HashMap; import java.util.Map; -import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; @@ -23,6 +22,7 @@ import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; public class ThrowableTNTModule extends Module { @@ -92,7 +92,7 @@ public class ThrowableTNTModule extends Module Player player = event.getPlayer(); ItemStack itemStack = player.getItemInHand(); - if (UtilPlayer.isSpectator(player) || itemStack == null || itemStack.getType() != Material.TNT || UtilBlock.usable(event.getClickedBlock())) + if (UtilPlayer.isSpectator(player) || itemStack == null || itemStack.getType() != Material.TNT || UtilBlock.usable(event.getClickedBlock()) || !Recharge.Instance.use(player, "Throw TNT", 500, false, true)) { return; } @@ -109,7 +109,6 @@ public class ThrowableTNTModule extends Module if (!_throwAndDrop || UtilEvent.isAction(event, ActionType.L)) { UtilAction.velocity(tntPrimed, location.getDirection(), _throwStrength, false, 0, 0.3, 1, false); - player.playEffect(location, Effect.GHAST_SHOOT, 0); } _throwers.put(tntPrimed, player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootModule.java index 0c27961bd..e725ac50c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootModule.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import org.bukkit.Effect; import org.bukkit.Location; @@ -20,6 +21,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.MapUtil; @@ -27,7 +29,7 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.titles.tracks.standard.LuckyTrack; import mineplex.core.titles.tracks.standard.UnluckyTrack; @@ -35,6 +37,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.events.ChestRefillEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.modules.Module; @@ -42,13 +45,6 @@ import nautilus.game.arcade.game.modules.Module; public class ChestLootModule extends Module { - private static final BlockFace[] FACES = { - BlockFace.NORTH, - BlockFace.SOUTH, - BlockFace.WEST, - BlockFace.EAST - }; - private final Map> _chests; private long _destroyAfterOpened; @@ -119,6 +115,11 @@ public class ChestLootModule extends Module public void refill() { _chests.forEach((type, metadataSet) -> metadataSet.forEach(metadata -> metadata.Opened = false)); + + List chests = new ArrayList<>(); + _chests.values().forEach(set -> set.forEach(chestMetadata -> chests.add(chestMetadata.Chest.getLocation()))); + + UtilServer.CallEvent(new ChestRefillEvent(chests)); } public void refill(String typeName) @@ -131,6 +132,9 @@ public class ChestLootModule extends Module } metadataSet.forEach(metadata -> metadata.Opened = false); + UtilServer.CallEvent(new ChestRefillEvent(metadataSet.stream() + .map(chestMetadata -> chestMetadata.Chest.getLocation()) + .collect(Collectors.toList()))); }); } @@ -175,9 +179,9 @@ public class ChestLootModule extends Module if (_autoRotateChests) { - List faces = new ArrayList<>(FACES.length); + List faces = new ArrayList<>(UtilBlock.horizontals.size()); - for (BlockFace face : FACES) + for (BlockFace face : UtilBlock.horizontals) { if (UtilBlock.airFoliage(block.getRelative(face))) { @@ -196,6 +200,10 @@ public class ChestLootModule extends Module metadata.populateChest((Chest) block.getState()); } } + else + { + MapUtil.QuickChangeBlockAt(location, Material.AIR); + } } _chests.put(chestType, metadataSet); @@ -293,13 +301,11 @@ public class ChestLootModule extends Module private ChestMetadata getFromBlock(Block block) { - Location blockLocation = block.getLocation(); - for (Set metadataSet : _chests.values()) { for (ChestMetadata metadata : metadataSet) { - if (UtilMath.offsetSquared(blockLocation, metadata.Chest.getLocation()) < 4) + if (metadata.Chest.getLocation().getBlock().equals(block)) { return metadata; } @@ -371,13 +377,20 @@ public class ChestLootModule extends Module void populateChest(Chest chest) { - chest.getBlockInventory().clear(); + Inventory inventory = chest.getBlockInventory(); + inventory.clear(); + List slots = new ArrayList<>(chest.getBlockInventory().getSize()); + + for (int i = 0; i < inventory.getSize(); i++) + { + slots.add(i); + } for (ChestLootPool pool : Type.Pools) { if (pool.getProbability() == 1 || Math.random() < pool.getProbability()) { - pool.populateChest(chest); + pool.populateChest(chest, slots); } } } @@ -398,6 +411,4 @@ public class ChestLootModule extends Module ChestSpawns = chestLocations; } } - - } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootPool.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootPool.java index cbff2a886..ecb5ce4b3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootPool.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootPool.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.modules.chest; import java.util.AbstractMap.SimpleEntry; +import java.util.List; import java.util.Map.Entry; import org.bukkit.block.Chest; @@ -8,6 +9,7 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.weight.WeightSet; @@ -18,9 +20,9 @@ public class ChestLootPool private final WeightSet _items; private final WeightSet> _enchantments; - private int _minimumPerChest; - private int _maximumPerChest; + private int _minimumPerChest, _maximumPerChest; private double _rarity, _enchantmentRarity; + private boolean _unbreakable; public ChestLootPool() { @@ -82,13 +84,20 @@ public class ChestLootPool return this; } - public void populateChest(Chest chest) + public ChestLootPool setUnbreakable(boolean unbreakable) + { + _unbreakable = unbreakable; + return this; + } + + public void populateChest(Chest chest, List slots) { Inventory inventory = chest.getBlockInventory(); for (int i = 0; i < UtilMath.rRange(_minimumPerChest, _maximumPerChest); i++) { - int slot = UtilMath.r(inventory.getSize()); + int slot = UtilMath.r(slots.size()); + slots.remove(slot); inventory.setItem(slot, getRandomItem()); } @@ -113,6 +122,11 @@ public class ChestLootPool itemStack.addUnsafeEnchantment(enchantment.getKey(), UtilMath.r(enchantment.getValue()) + 1); } + if (_unbreakable && itemStack.getType().getMaxDurability() > 0) + { + UtilItem.makeUnbreakable(itemStack); + } + return itemStack; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combattracker/CombatData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combattracker/CombatData.java new file mode 100644 index 000000000..c2fc669b5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combattracker/CombatData.java @@ -0,0 +1,28 @@ +package nautilus.game.arcade.game.modules.combattracker; + +public class CombatData +{ + + private int _kills, _assits; + + public void incrementKills() + { + _kills++; + } + + public int getKills() + { + return _kills; + } + + public void incrementAssists() + { + _assits++; + } + + + public int getAssits() + { + return _assits; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combattracker/CombatTrackerModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combattracker/CombatTrackerModule.java new file mode 100644 index 000000000..510a0ff02 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/combattracker/CombatTrackerModule.java @@ -0,0 +1,72 @@ +package nautilus.game.arcade.game.modules.combattracker; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.combat.CombatComponent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; + +import nautilus.game.arcade.game.modules.Module; + +public class CombatTrackerModule extends Module +{ + + private final Map _combatData; + + public CombatTrackerModule() + { + _combatData = new HashMap<>(); + } + + public CombatData getCombatData(Player player) + { + return _combatData.computeIfAbsent(player.getUniqueId(), k -> new CombatData()); + } + + @Override + public void cleanup() + { + _combatData.clear(); + } + + @EventHandler + public void combatDeath(CombatDeathEvent event) + { + if (!(event.GetEvent().getEntity() instanceof Player)) + { + return; + } + + Player killed = (Player) event.GetEvent().getEntity(); + + if (event.GetLog().GetKiller() != null) + { + Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + + if (killer != null && !killer.equals(killed)) + { + getCombatData(killer).incrementKills(); + } + } + + for (CombatComponent log : event.GetLog().GetAttackers()) + { + if (event.GetLog().GetKiller() != null && log.equals(event.GetLog().GetKiller())) + { + continue; + } + + Player assist = UtilPlayer.searchExact(log.GetName()); + + if (assist != null) + { + getCombatData(assist).incrementAssists(); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/worldmap/WorldMapModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/worldmap/WorldMapModule.java new file mode 100644 index 000000000..d7365b12f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/worldmap/WorldMapModule.java @@ -0,0 +1,546 @@ +package nautilus.game.arcade.game.modules.worldmap; + +import java.io.File; +import java.util.AbstractMap.SimpleEntry; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import net.minecraft.server.v1_8_R3.Block; +import net.minecraft.server.v1_8_R3.BlockPosition; +import net.minecraft.server.v1_8_R3.IBlockData; +import net.minecraft.server.v1_8_R3.MaterialMapColor; + +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R3.CraftChunk; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.map.MapRenderer; +import org.bukkit.map.MapView; + +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Iterables; +import com.google.common.collect.Multisets; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import nautilus.game.arcade.game.modules.Module; +import nautilus.game.arcade.world.WorldData; + +public class WorldMapModule extends Module +{ + + private static final int BLOCK_SCAN_INTERVAL = 16; + + private int _halfMapSize; + private final int[][] _heightMap; + private boolean _loadWorld = true; + private Map _map = new HashMap<>(); + private short _mapId = (short) UtilMath.r(Short.MAX_VALUE); + private final List> _scanList = new ArrayList<>(); + private World _world; + private int _centerX, _centerZ, _scale; + + private final WorldMapRenderer _renderer; + + public WorldMapModule(WorldData worldData, WorldMapRenderer renderer) + { + this(worldData.World, worldData.MinX, worldData.MinZ, worldData.MaxX, worldData.MaxZ, renderer); + } + + public WorldMapModule(World world, int minX, int minZ, int maxX, int maxZ, WorldMapRenderer renderer) + { + _centerX = minX + ((maxX - minX) / 2); + _centerZ = minZ + ((maxZ - minZ) / 2); + _centerX = (int) (Math.round(_centerX / 16D) * 16); + _centerZ = (int) (Math.round(_centerZ / 16D) * 16); + _renderer = renderer; + renderer.setManager(this); + + _halfMapSize = (int) (Math.ceil(Math.max((maxX - minX) / 2D, (maxZ - minZ) / 2D) / 16D) * 16); + + List> list = new ArrayList<>(); + + for (int scale = 1; scale <= 16; scale++) + { + int s = _halfMapSize; + + if ((s / scale) > 127) + { + continue; + } + + while (s < 10000 && (s % 16 != 0 || s % scale != 0)) + { + s += 16; + } + + if (s < 10000) + { + list.add(new SimpleEntry<>(scale, s)); + } + } + + if (list.isEmpty()) + { + _scale = 16; + _halfMapSize = 127 * 8; + } + else + { + list.sort(Comparator.comparingInt(Entry::getValue)); + + _scale = list.get(0).getKey(); + _halfMapSize = list.get(0).getValue(); + } + + _heightMap = new int[(_halfMapSize * 2) + 16][]; + + for (int x = -_halfMapSize; x < _halfMapSize; x += BLOCK_SCAN_INTERVAL) + { + for (int z = -_halfMapSize - 16; z < _halfMapSize; z += (z < -_halfMapSize ? 16 : BLOCK_SCAN_INTERVAL)) + { + _scanList.add(new SimpleEntry<>(x, z)); + } + } + + for (int s = 1; s <= 2; s++) + { + if (s == 2) + { + s = getScale(); + + if (s == 1) + break; + } + + int size = (_halfMapSize * 2) / s; + Byte[][] bytes = new Byte[size][]; + + for (int i = 0; i < size; i++) + { + bytes[i] = new Byte[size]; + } + + _map.put(s, bytes); + } + + for (int i = 0; i < _heightMap.length; i++) + { + _heightMap[i] = new int[_heightMap.length]; + } + + _world = world; + + try + { + File dataFolder = new File("world/data"); + + if (dataFolder.exists()) + { + for (File file : dataFolder.listFiles()) + { + if (file.getName().startsWith("map_")) + { + file.delete(); + } + } + } + + MapView view = Bukkit.createMap(_world); + _mapId = view.getId(); + setupRenderer(view); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + rebuildScan(); + } + + private void setupRenderer(MapView view) + { + for (MapRenderer renderer : view.getRenderers()) + { + view.removeRenderer(renderer); + } + + view.addRenderer(_renderer); + } + + public int getScale() + { + return _scale; + } + + public int getX() + { + return _centerX; + } + + public int getZ() + { + return _centerZ; + } + + private void colorWorldHeight(int zoom, int startingX, int startingZ) + { + zoom = Math.max(zoom, 1); + + Byte[][] map = _map.get(zoom); + + for (int x = startingX; x < startingX + BLOCK_SCAN_INTERVAL; x += zoom) + { + double d0 = 0; + + // Prevents ugly lines for the first line of Z + for (int addX = 0; addX < zoom; addX++) + { + for (int addZ = 0; addZ < zoom; addZ++) + { + int hX = x + addX + _halfMapSize; + int hZ = (startingZ - zoom) + addZ + _halfMapSize; + + if (hX >= _halfMapSize * 2 || hZ >= _halfMapSize * 2) + { + continue; + } + + d0 += _heightMap[hX + 16][hZ + 16] / (zoom * zoom); + } + } + + for (int z = startingZ; z < startingZ + BLOCK_SCAN_INTERVAL; z += zoom) + { + double d1 = 0; + + for (int addX = 0; addX < zoom; addX++) + { + for (int addZ = 0; addZ < zoom; addZ++) + { + int hX = x + addX + _halfMapSize; + int hZ = z + addZ + _halfMapSize; + + if (hX >= _halfMapSize * 2 || hZ >= _halfMapSize * 2) + { + continue; + } + + d1 += _heightMap[hX + 16][hZ + 16] / (zoom * zoom); + } + } + + double d2 = (d1 - d0) * 4.0D / (zoom + 4) + ((x + z & 0x1) - 0.5D) * 0.4D; + byte b0 = 1; + + d0 = d1; + + if (d2 > 0.6D) + { + b0 = 2; + } + else if (d2 > 1.2D) + { + b0 = 3; + } + else if (d2 < -0.6D) + { + b0 = 0; + } + + int origColor = map[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] - 1; + byte color = (byte) (origColor + b0); + map[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] = color; + } + } + } + + private void drawWorldScale(int zoom, int startingX, int startingZ) + { + Byte[][] first = _map.get(1); + Byte[][] second = _map.get(zoom); + + for (int x = startingX; x < startingX + BLOCK_SCAN_INTERVAL; x += zoom) + { + for (int z = startingZ; z < startingZ + BLOCK_SCAN_INTERVAL; z += zoom) + { + HashMultiset hashmultiset = HashMultiset.create(); + + for (int addX = 0; addX < zoom; addX++) + { + for (int addZ = 0; addZ < zoom; addZ++) + { + int pX = x + addX + _halfMapSize; + int pZ = z + addZ + _halfMapSize; + + if (pX >= first.length || pZ >= first.length) + { + continue; + } + + Byte b = first[pX][pZ]; + + if (b == null) + { + continue; + } + + hashmultiset.add(b); + } + } + + Byte color = Iterables.getFirst(Multisets.copyHighestCountFirst(hashmultiset), (byte) 0); + + second[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] = color; + } + } + } + + private double getDistance(double x1, double z1, double x2, double z2) + { + x1 = (x1 - x2); + z1 = (z1 - z2); + + return (x1 * x1) + (z1 * z1); + } + + private double getDistance(Entry entry, double x1, double z1) + { + return getDistance(x1 + _centerX, z1 + _centerZ, entry.getKey() + (BLOCK_SCAN_INTERVAL / 2), entry.getValue() + (BLOCK_SCAN_INTERVAL / 2)); + } + + Byte[][] getMap(int scale) + { + return _map.get(scale); + } + + private void rebuildScan() + { + for (int x = -_halfMapSize; x < _halfMapSize; x += BLOCK_SCAN_INTERVAL) + { + for (int z = -_halfMapSize - 16; z < _halfMapSize; z += (z < -_halfMapSize ? 16 : BLOCK_SCAN_INTERVAL)) + { + _scanList.add(new SimpleEntry<>(x, z)); + } + } + + if (!_loadWorld) + { + _scanList.removeIf(entry -> + { + for (Player player : UtilServer.getPlayers()) + { + Location location = player.getLocation(); + + if (getDistance(entry, location.getX(), location.getZ()) < 6400) + { + return false; + } + } + + return true; + }); + } + } + + @EventHandler + public void renderMap(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + _renderer.renderTick(); + + if (_scanList.isEmpty()) + { + if (_loadWorld) + { + _loadWorld = false; + System.out.println("Finished rendering the map."); + } + + if (UtilServer.getPlayersCollection().size() == 0) + { + return; + } + + rebuildScan(); + return; + } + + Entry entry = _scanList.remove(0); + + int startingX = entry.getKey(); + int startingZ = entry.getValue(); + + boolean outsideMap = startingZ < -_halfMapSize; + + scanWorldMap(startingX, startingZ, !outsideMap); + + if (outsideMap) + { + return; + } + + for (int s = 1; s <= 2; s++) + { + if (s == 2) + { + s = getScale(); + + if (s == 1) + { + break; + } + } + + if (s == 13 && _loadWorld) + { + continue; + } + + drawWorldScale(s, startingX, startingZ); + colorWorldHeight(s, startingX, startingZ); + } + + colorWorldHeight(0, startingX, startingZ); + } + + public void scanWorldMap(int startingX, int startingZ, boolean setColors) + { + Byte[][] map = _map.get(1); + + for (int beginX = startingX; beginX < startingX + BLOCK_SCAN_INTERVAL; beginX += 16) + { + for (int beginZ = startingZ - (startingZ > -_halfMapSize ? 16 : 0); beginZ < startingZ + (setColors ? BLOCK_SCAN_INTERVAL : 16); beginZ += 16) + { + Chunk chunk = _world.getChunkAt((beginX + _centerX) / 16, (beginZ + _centerZ) / 16); + boolean loaded = false; + + if (!chunk.isLoaded()) + { + if (_loadWorld) + { + loaded = chunk.load(); + } + else + { + continue; + } + } + + net.minecraft.server.v1_8_R3.Chunk nmsChunk = ((CraftChunk) chunk).getHandle(); + + for (int x = beginX; x < beginX + 16; x++) + { + for (int z = beginZ; z < beginZ + 16; z++) + { + int color = 0; + + if (!nmsChunk.isEmpty()) + { + int k3 = x & 0xF; + int l3 = z & 0xF; + + int l4 = nmsChunk.b(k3, l3) + 1; + IBlockData iblockdata; + + if (l4 > 1) + { + do + { + l4--; + iblockdata = nmsChunk.getBlockData(new BlockPosition(k3, l4, l3)); + } + while (iblockdata.getBlock().g(iblockdata) == MaterialMapColor.b && (l4 > 0)); + + if ((l4 > 0) && (iblockdata.getBlock().getMaterial().isLiquid())) + { + int j5 = l4 - 1; + Block block1; + do + { + block1 = nmsChunk.getType(new BlockPosition(k3, j5--, l3)); + } + while ((j5 > 0) && (block1.getMaterial().isLiquid())); + } + } + + _heightMap[x + _halfMapSize + 16][z + _halfMapSize + 16] = l4; + + if (setColors) + { + IBlockData data = nmsChunk.getBlockData(new BlockPosition(k3, l4, l3)); + color = data.getBlock().g(data).M; + + color = (byte) ((color * 4) + 1); + } + } + + if (setColors && beginZ >= startingZ) + { + map[x + _halfMapSize][z + _halfMapSize] = (byte) color; + } + } + + if (loaded) + { + chunk.unload(); + } + } + } + } + } + + @EventHandler + public void dropItem(PlayerDropItemEvent event) + { + ItemStack itemStack = event.getItemDrop().getItemStack(); + + if (itemStack.getType() == Material.MAP) + { + event.setCancelled(true); + event.getPlayer().sendMessage(F.main("Game", "You cannot drop this map.")); + } + } + + @EventHandler + public void inventoryClick(InventoryClickEvent event) + { + if (event.isCancelled()) + { + return; + } + + UtilInv.DisallowMovementOf(event, null, Material.MAP, (byte) _mapId, false); + + if (event.isCancelled()) + { + event.getWhoClicked().sendMessage(F.main("Game", "You cannot move this map from your inventory.")); + } + } + + public ItemBuilder getMapItem() + { + return new ItemBuilder(Material.MAP, 1, _mapId); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/worldmap/WorldMapRenderer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/worldmap/WorldMapRenderer.java new file mode 100644 index 000000000..3e1a98eeb --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/worldmap/WorldMapRenderer.java @@ -0,0 +1,117 @@ +package nautilus.game.arcade.game.modules.worldmap; + +import java.util.concurrent.TimeUnit; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.map.MapCanvas; +import org.bukkit.map.MapCursor; +import org.bukkit.map.MapCursorCollection; +import org.bukkit.map.MapRenderer; +import org.bukkit.map.MapView; + +import mineplex.core.recharge.Recharge; + +import nautilus.game.arcade.game.Game; + +public abstract class WorldMapRenderer extends MapRenderer +{ + + private static final long DRAW_RATE = TimeUnit.SECONDS.toMillis(4); + + protected final T _game; + protected WorldMapModule _manager; + + public WorldMapRenderer(T game) + { + _game = game; + } + + public void setManager(WorldMapModule manager) + { + _manager = manager; + } + + @Override + public void render(MapView mapView, MapCanvas canvas, Player player) + { + preRender(player); + + int zoom = _manager.getScale(); + Byte[][] map = _manager.getMap(zoom); + + int centerX = 0; + int centerZ = 0; + + if (Recharge.Instance.use(player, "Draw Map", DRAW_RATE, false, false)) + { + for (int mapX = 0; mapX < 128; mapX++) + { + for (int mapZ = 0; mapZ < 128; mapZ++) + { + int blockX = centerX + (mapX - 64); + int blockZ = centerZ + (mapZ - 64); + + int pixelX = blockX + (map.length / 2); + int pixelZ = blockZ + (map.length / 2); + + Byte color; + + if (!(pixelX < 0 || pixelZ < 0 || pixelX >= map.length || pixelZ >= map.length) && map[pixelX][pixelZ] != null) + { + color = map[pixelX][pixelZ]; + + blockX *= zoom; + blockZ *= zoom; + + color = renderBlock(player, color, mapX, mapZ, blockX, blockZ); + } + else + { + color = (byte) 0; + } + + canvas.setPixel(mapX, mapZ, color); + } + } + + player.sendMap(mapView); + } + + MapCursorCollection cursors = canvas.getCursors(); + + while (cursors.size() > 0) + { + cursors.removeCursor(cursors.getCursor(0)); + } + + renderCursors(canvas, player); + } + + protected void addCursor(MapCanvas canvas, Location location, MapCursor.Type type) + { + MapCursorCollection cursors = canvas.getCursors(); + int zoom = _manager.getScale(); + double mapX = (location.getX() - _manager.getX()) / zoom; + double mapZ = (location.getZ() - _manager.getZ()) / zoom; + + if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64) + { + byte b0 = (byte) (int) Math.min(127, mapX * 2F + 0.5D); + byte b1 = (byte) (int) Math.max(-127, mapZ * 2F + 0.5D); + byte rotation = (byte) (int) (location.getYaw() * 16D / 360D); + + MapCursor cursor = new MapCursor(b0, b1, (byte) (rotation & 0xF), type.getValue(), true); + + cursors.addCursor(cursor); + } + } + + public abstract void renderTick(); + + protected abstract void preRender(Player player); + + protected abstract byte renderBlock(Player player, byte color, int mapX, int mapZ, int blockX, int blockZ); + + protected abstract void renderCursors(MapCanvas canvas, Player player); +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkAxeThrower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkAxeThrower.java index e9272e6eb..c24f9d4d5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkAxeThrower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkAxeThrower.java @@ -11,53 +11,53 @@ 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.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; + import nautilus.game.arcade.kit.Perk; public class PerkAxeThrower extends Perk implements IThrown { - public PerkAxeThrower() + public PerkAxeThrower() { - super("Axe Thrower", new String[] + super("Axe Thrower", new String[] { - C.cYellow + "Right-Click" + C.cGray + " with Axes to " + C.cGreen + "Throw Axe", + C.cYellow + "Right-Click" + C.cGray + " with Axes to " + C.cGreen + "Throw Axe", }); } - + @EventHandler public void Throw(PlayerInteractEvent event) { if (!UtilEvent.isAction(event, ActionType.R)) return; - - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; - + if (UtilBlock.usable(event.getClickedBlock())) return; - + Player player = event.getPlayer(); - - if (!Kit.HasKit(player)) + + if (!UtilItem.isAxe(player.getItemInHand()) || !Kit.HasKit(player) || !Recharge.Instance.use(player, GetName(), 1000, false, true)) + { return; - + } + event.setCancelled(true); - - org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(player.getItemInHand().getType())); + + Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(player.getItemInHand().getType())); UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 10, false); - Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 0.6f); - + Manager.GetProjectile().AddThrow(ent, player, this, -1, true, false, false, true, 0.7f); + //Remove Axe player.setItemInHand(null); UtilInv.Update(player); @@ -66,19 +66,15 @@ public class PerkAxeThrower extends Perk implements IThrown @Override public void Collide(LivingEntity target, Block block, ProjectileUser data) { - if (target == null) + if (!Manager.GetGame().IsAlive(target)) return; - - if (target instanceof Player) - if (!Manager.GetGame().IsAlive((Player)target)) - return; - - Item item = (Item)data.getThrown(); - + + Item item = (Item) data.getThrown(); + int damage = 4; - if (item.getItemStack().getType() == Material.STONE_AXE) damage = 5; - else if (item.getItemStack().getType() == Material.IRON_AXE) damage = 6; - else if (item.getItemStack().getType() == Material.DIAMOND_AXE) damage = 7; + if (item.getItemStack().getType() == Material.STONE_AXE) damage = 5; + else if (item.getItemStack().getType() == Material.IRON_AXE) damage = 6; + else if (item.getItemStack().getType() == Material.DIAMOND_AXE) damage = 7; //Damage Event Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, @@ -88,25 +84,29 @@ public class PerkAxeThrower extends Perk implements IThrown //Effect data.getThrown().getWorld().playSound(data.getThrown().getLocation(), Sound.ZOMBIE_WOOD, 1f, 1.6f); - //Re-Drop - data.getThrown().getWorld().dropItem(data.getThrown().getLocation(), ItemStackFactory.Instance.CreateStack(item.getItemStack().getType())).setPickupDelay(60); - - //Remove - data.getThrown().remove(); + UtilAction.zeroVelocity(item); + item.setPickupDelay(60); } @Override - public void Idle(ProjectileUser data) + public void Idle(ProjectileUser data) { - + if (Math.random() < 0.15) + { + Player thrower = (Player) data.getThrower(); + + thrower.sendMessage(F.main("Skill", "Your " + F.item("Axe") + " returned to your inventory.")); + thrower.getInventory().addItem(((Item) data.getThrown()).getItemStack()); + data.getThrown().remove(); + } } @Override - public void Expire(ProjectileUser data) + public void Expire(ProjectileUser data) { - + } - + @Override public void ChunkUnload(ProjectileUser data) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkAxeman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkAxeman.java index 6fca7d1e6..514237885 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkAxeman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkAxeman.java @@ -4,6 +4,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import mineplex.core.common.util.UtilItem; +import mineplex.core.recharge.Recharge; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.core.common.util.C; import nautilus.game.arcade.kit.Perk; @@ -27,15 +29,16 @@ public class PerkAxeman extends Perk Player damager = event.GetDamagerPlayer(false); if (damager == null) return; - if (damager.getItemInHand() == null) + if (!UtilItem.isAxe(damager.getItemInHand())) + { return; - - if (!damager.getItemInHand().getType().toString().contains("_AXE")) + } + + if (!Kit.HasKit(damager) || !Recharge.Instance.usable(damager, GetName())) + { return; - - if (!Kit.HasKit(damager)) - return; - + } + event.AddMod(damager.getName(), GetName(), 1, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBackstab.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBackstab.java index 7b282ab83..846fc282f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBackstab.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBackstab.java @@ -9,6 +9,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.util.Vector; import mineplex.core.common.util.C; +import mineplex.core.recharge.Recharge; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.kit.Perk; @@ -37,7 +38,7 @@ public class PerkBackstab extends Perk Player damager = event.GetDamagerPlayer(false); if (damager == null) return; - if (!Kit.HasKit(damager)) + if (!Kit.HasKit(damager) || !Recharge.Instance.usable(damager, GetName())) return; LivingEntity damagee = event.GetDamageeEntity(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomberHG.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomberHG.java index 7edda2765..335738a71 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomberHG.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomberHG.java @@ -27,14 +27,8 @@ public class PerkBomberHG extends Perk { private int _spawnRate; private int _max; - private boolean _onlyRestrictNamed; - public PerkBomberHG(int spawnRate, int max) - { - this(spawnRate, max, false); - } - - public PerkBomberHG(int spawnRate, int max, boolean onlyRestrictNamed) + public PerkBomberHG(int spawnRate, int max) { super("Explosives", new String[] { @@ -43,7 +37,6 @@ public class PerkBomberHG extends Perk _spawnRate = spawnRate; _max = max; - _onlyRestrictNamed = onlyRestrictNamed; } public void Apply(Player player) @@ -71,14 +64,14 @@ public class PerkBomberHG extends Perk if (!Recharge.Instance.use(cur, GetName(), _spawnRate*1000, false, false)) continue; - if (_onlyRestrictNamed ? UtilInv.contains(cur, F.item("Throwing TNT"), Material.TNT, (byte)0, _max) : UtilInv.contains(cur, Material.TNT, (byte)0, _max)) + if (UtilInv.contains(cur, Material.TNT, (byte)0, _max)) continue; if (UtilPlayer.isSpectator(cur)) continue; //Add - cur.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, F.item("Throwing TNT"))); + cur.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, F.item(C.Bold + "Throwable TNT"))); cur.playSound(cur.getLocation(), Sound.ITEM_PICKUP, 2f, 1f); } @@ -90,26 +83,27 @@ public class PerkBomberHG extends Perk if (event.isCancelled()) return; - if (_onlyRestrictNamed ? !UtilInv.IsItem(event.getItemDrop().getItemStack(), F.item("Throwing TNT"), Material.TNT, (byte)0) : !UtilInv.IsItem(event.getItemDrop().getItemStack(), Material.TNT, (byte)0)) - return; - if (!Kit.HasKit(event.getPlayer())) return; if (!hasPerk(event.getPlayer())) return; + if (event.getItemDrop().getItemStack().getType() != Material.TNT) + { + return; + } + //Cancel event.setCancelled(true); //Inform - UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot drop " + F.item("Throwing TNT") + ".")); + UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot drop " + F.item("Throwable TNT") + ".")); } @EventHandler public void TNTInvClick(InventoryClickEvent event) { - //boolean containerOpen = !(event.getView().getTopInventory().getHolder() instanceof Player); boolean clickInContainer = event.getClickedInventory() != null && !(event.getClickedInventory().getHolder() instanceof Player); if (clickInContainer) @@ -126,7 +120,7 @@ public class PerkBomberHG extends Perk if (!hasPerk((Player)event.getWhoClicked())) return; - UtilInv.DisallowMovementOf(event, "Throwing TNT", Material.TNT, (byte) 0, true); + UtilInv.DisallowMovementOf(event, "Throwable TNT", Material.TNT, (byte) 0, true); } @EventHandler @@ -135,7 +129,7 @@ public class PerkBomberHG extends Perk Set remove = new HashSet<>(); for (ItemStack item : event.getDrops()) - if (_onlyRestrictNamed ? UtilInv.IsItem(item, "Throwing TNT", Material.TNT, (byte)0) : UtilInv.IsItem(item, Material.TNT, (byte)0)) + if (UtilInv.IsItem(item, Material.TNT, (byte)0)) remove.add(item); for (ItemStack item : remove) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCleave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCleave.java index f64a380d8..27fcee0c8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCleave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCleave.java @@ -1,55 +1,57 @@ package nautilus.game.arcade.kit.perks; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.Perk; - 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 mineplex.core.common.util.C; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.kit.Perk; + public class PerkCleave extends Perk { private boolean _axeOnly; - - public PerkCleave(double splash, boolean axeOnly) + + public PerkCleave(double splash, boolean axeOnly) { - super("Cleave", new String[] - { - C.cGray + "Attacks deal " + (int)(100*splash) + "% damage to nearby enemies", + super("Cleave", new String[] + { + C.cGray + "Attacks deal " + (int) (100 * splash) + "% damage to nearby enemies", }); - + _axeOnly = axeOnly; } @EventHandler(priority = EventPriority.HIGH) public void Skill(CustomDamageEvent event) { - if (event.IsCancelled()) + if (event.IsCancelled() || event.GetDamageePlayer() == null || event.GetCause() != DamageCause.ENTITY_ATTACK) + { return; + } if (event.GetCause() != DamageCause.ENTITY_ATTACK) return; if (event.GetReason() != null) return; - - //Dont allow usage in early game - if (!UtilTime.elapsed(Manager.GetGame().GetStateTime(), 30000)) - return; //Damager Player damager = event.GetDamagerPlayer(false); - if (damager == null) return; + if (damager == null || !Recharge.Instance.usable(damager, GetName())) + { + return; + } if (_axeOnly && !UtilGear.isAxe(damager.getItemInHand())) return; - + if (!UtilGear.isWeapon(damager.getItemInHand())) return; @@ -58,7 +60,7 @@ public class PerkCleave extends Perk //Damagee LivingEntity damagee = event.GetDamageeEntity(); - if (damagee == null) return; + if (damagee == null) return; //Damage event.AddMod(damager.getName(), GetName(), 0, false); @@ -68,7 +70,7 @@ public class PerkCleave extends Perk { if (other.equals(damagee)) continue; - + if (other.equals(damager)) continue; @@ -76,7 +78,7 @@ public class PerkCleave extends Perk continue; //Damage Event - Manager.GetDamage().NewDamageEvent(other, damager, null, + Manager.GetDamage().NewDamageEvent(other, damager, null, DamageCause.CUSTOM, event.GetDamageInitial(), true, true, false, damager.getName(), GetName()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHiltSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHiltSmash.java index 3202ee820..350f612a8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHiltSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHiltSmash.java @@ -1,7 +1,5 @@ package nautilus.game.arcade.kit.perks; -import java.util.HashSet; - import org.bukkit.Effect; import org.bukkit.Sound; import org.bukkit.entity.Entity; @@ -18,12 +16,12 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import nautilus.game.arcade.kit.Perk; public class PerkHiltSmash extends Perk { - private HashSet _used = new HashSet(); - + public PerkHiltSmash() { super("Hilt Smash", new String[] @@ -32,7 +30,7 @@ public class PerkHiltSmash extends Perk }); } - public boolean CanUse(Player player) + private boolean CanUse(Player player) { if (!Kit.HasKit(player)) return false; @@ -74,12 +72,9 @@ public class PerkHiltSmash extends Perk return; } - //Set Used - _used.add(player); - //Damage Event Manager.GetDamage().NewDamageEvent((LivingEntity)ent, player, null, - DamageCause.ENTITY_ATTACK, 5, false, true, false, + DamageCause.ENTITY_ATTACK, 2, false, true, true, player.getName(), GetName()); } @@ -103,7 +98,6 @@ public class PerkHiltSmash extends Perk //Condition Manager.GetCondition().Factory().Slow(GetName(), damagee, damager, 2, 1, false, false, true, true); - Manager.GetCondition().Factory().Blind(GetName(), damagee, damager, 2, 1, false, false, false); //Effect damagee.getWorld().playSound(damagee.getLocation(), Sound.ZOMBIE_WOOD, 1f, 1.2f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java index 847d43452..74acd5bdb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.kit.perks; import java.util.HashMap; import java.util.Iterator; +import java.util.Map; import org.bukkit.Material; import org.bukkit.Sound; @@ -31,9 +32,8 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilVariant; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.events.GameStateChangeEvent; + import nautilus.game.arcade.events.PlayerStateChangeEvent; -import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.kit.Perk; @@ -41,8 +41,8 @@ public class PerkHorsePet extends Perk { private static final ItemStack SADDLE_ITEM = new ItemBuilder(Material.SADDLE).setTitle(C.cGreenB + "Saddle").build(); - private HashMap _horseMap = new HashMap(); - private HashMap _deathTime = new HashMap(); + private final Map _horseMap = new HashMap<>(); + private final Map _deathTime = new HashMap<>(); public PerkHorsePet() { @@ -55,9 +55,18 @@ public class PerkHorsePet extends Perk @Override public void Apply(Player player) { - spawnHorse(player, false); + Manager.runSyncLater(() -> spawnHorse(player, false), 45 * 20); } - + + @Override + public void unregisteredEvents() + { + for (Player player : Manager.GetGame().GetPlayers(true)) + { + despawnHorse(player); + } + } + public void spawnHorse(Player player, boolean baby) { if (!Manager.GetGame().IsAlive(player)) @@ -85,20 +94,6 @@ public class PerkHorsePet extends Perk Manager.GetGame().CreatureAllowOverride = false; } - @EventHandler - public void onGameEnd(GameStateChangeEvent event) - { - if (event.GetState() == Game.GameState.End) - { - // Players alive at the end of the game don't die, so their horse sticks around. - // We need to iterate through them just in case they have a horse to kill. - for (Player player : event.GetGame().GetPlayers(true)) - { - despawnHorse(player); - } - } - } - @EventHandler public void horseUpdate(UpdateEvent event) { @@ -263,7 +258,6 @@ public class PerkHorsePet extends Perk { UtilPlayer.message(player, F.main("Mount", "This is not your Horse!")); event.setCancelled(true); - return; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkQuickshot.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkQuickshot.java index 9ec202098..1f9bbfe46 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkQuickshot.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkQuickshot.java @@ -10,26 +10,35 @@ import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; + import nautilus.game.arcade.kit.Perk; public class PerkQuickshot extends Perk { - private String _name; - private double _power; - private long _recharge; - - public PerkQuickshot(String name, double power, long recharge) + private final String _name; + private final double _power; + private final long _recharge; + private final boolean _useArrow; + + public PerkQuickshot(String name, double power, long recharge) { - super("Quickshot", new String[] + this(name, power, recharge, false); + } + + public PerkQuickshot(String name, double power, long recharge, boolean useArrow) + { + super("Quickshot", new String[] { - C.cYellow + "Left-Click" + C.cGray + " with Bow to " + C.cGreen + name + C.cYellow + "Left-Click" + C.cGray + " with Bow to " + C.cGreen + name }); - + _name = name; _power = power; _recharge = recharge; + _useArrow = useArrow; } @EventHandler @@ -37,30 +46,38 @@ public class PerkQuickshot extends Perk { if (event.isCancelled()) return; - + if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK) return; - + if (UtilBlock.usable(event.getClickedBlock())) return; - + if (event.getPlayer().getItemInHand() == null) return; - + if (event.getPlayer().getItemInHand().getType() != Material.BOW) return; - + Player player = event.getPlayer(); - + if (!Kit.HasKit(player)) return; - + + if (_useArrow && !player.getInventory().contains(Material.ARROW, 1)) + { + player.sendMessage(F.main("Game", "You need an " + F.name("Arrow") + " to use " + F.name(GetName()) + ".")); + return; + } + if (!Recharge.Instance.use(player, _name, _recharge, true, true)) return; - + + UtilInv.remove(player, Material.ARROW, (byte) 0, 1); + Arrow arrow = player.launchProjectile(Arrow.class); arrow.setVelocity(player.getLocation().getDirection().multiply(_power)); - + UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(_name) + ".")); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlamHG.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlamHG.java index a0b41be6b..7f978945a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlamHG.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlamHG.java @@ -19,6 +19,7 @@ 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.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import nautilus.game.arcade.kit.Perk; @@ -45,19 +46,17 @@ public class PerkSeismicSlamHG extends Perk if (UtilBlock.usable(event.getClickedBlock())) return; - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_SWORD") && !event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; - Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!UtilItem.isAxe(player.getItemInHand()) && !UtilItem.isSword(player.getItemInHand())) + { return; + } - if (!Recharge.Instance.use(player, GetName(), 10000, true, true)) + if (!Kit.HasKit(player) || !Recharge.Instance.use(player, GetName(), 14000, true, true)) + { return; + } //Action double range = 6; @@ -73,14 +72,13 @@ public class PerkSeismicSlamHG extends Perk //Velocity UtilAction.velocity(cur, UtilAlg.getTrajectory2d(player.getLocation().toVector(), cur.getLocation().toVector()), - 2.2 * targets.get(cur), true, 0, 0.3 + 0.9 * targets.get(cur), 1.2, true); + 1.8 * targets.get(cur), true, 0, 0.3 + 0.9 * targets.get(cur), 1.2, 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()) + ".")); + UtilPlayer.message(cur, F.main("Game", F.name(player.getName()) +" hit you with " + F.skill(GetName()) + ".")); } //Effect diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java index 306b84cd4..3b8358aa7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java @@ -9,12 +9,10 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSkeleton; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -25,6 +23,7 @@ import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerEvent; +import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; @@ -32,16 +31,16 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; 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.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.games.survivalgames.SurvivalGames; +import nautilus.game.arcade.game.games.survivalgames.kit.necroinventory.NecroInventoryMenu; import nautilus.game.arcade.kit.Perk; -import net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.NavigationAbstract; public class PerkSkeletons extends Perk { @@ -56,7 +55,7 @@ public class PerkSkeletons extends Perk private final PerkSkeletons _perkSkeletons; - public MinionSpawnEvent(Player who, PerkSkeletons perkSkeletons) + MinionSpawnEvent(Player who, PerkSkeletons perkSkeletons) { super(who); @@ -75,7 +74,8 @@ public class PerkSkeletons extends Perk } } - private Map> _minions = new HashMap<>(); + private final Map> _minions = new HashMap<>(); + private final NecroInventoryMenu _menu; private boolean _name; private int _maxDist = 8; @@ -88,6 +88,19 @@ public class PerkSkeletons extends Perk C.cGray + "Killing an opponent summons a skeletal minion." }); _name = name; + _menu = new NecroInventoryMenu(this); + } + + @Override + public void registeredEvents() + { + _menu.activate(); + } + + @Override + public void unregisteredEvents() + { + _menu.deactivate(); } /** @@ -97,21 +110,13 @@ public class PerkSkeletons extends Perk * A location is valid if it meets the following * criteria: * - The block at and 1 y-value above are both air - * - It is within the border on X, Y, and Z * @param location - The location at which you want to spawn a skeleton. * @return Whether the location is valid or not */ private boolean isValidSpawn(Location location) { return location.getBlock().getType() == Material.AIR - && location.clone().add(0, 1, 0).getBlock().getType() == Material.AIR - && !((SurvivalGames) Manager.GetGame()).isOutsideBorder(location); - - } - - private double vectorDistance(Location a, Location b) - { - return a.toVector().distance(b.toVector()); + && location.clone().add(0, 1, 0).getBlock().getType() == Material.AIR; } private Location getMinionLocation(Location deathLocation) @@ -132,7 +137,7 @@ public class PerkSkeletons extends Perk List nearbyBlocks = UtilBlock.getBlocksInRadius(deathLocation, MAX_SPAWN_RADIUS, deathLocation.getBlockY()) .stream() .filter(b -> isValidSpawn(b.getLocation())) - .sorted(Comparator.comparingDouble(a -> vectorDistance(a.getLocation(), deathLocation))) + .sorted(Comparator.comparingDouble(a -> UtilMath.offsetSquared(a.getLocation(), deathLocation))) .collect(Collectors.toCollection(LinkedList::new)); if (nearbyBlocks.size() > 0) @@ -181,7 +186,14 @@ public class PerkSkeletons extends Perk skel.setMaxHealth(30); skel.setHealth(skel.getMaxHealth()); - skel.getEquipment().setItemInHand(killed.getItemInHand()); + ItemStack inHand = killed.getItemInHand(); + + if (inHand != null && inHand.getType() == Material.MAP) + { + inHand = null; + } + + skel.getEquipment().setItemInHand(inHand); skel.getEquipment().setHelmet(killed.getInventory().getHelmet()); skel.getEquipment().setChestplate(killed.getInventory().getChestplate()); skel.getEquipment().setLeggings(killed.getInventory().getLeggings()); @@ -205,14 +217,11 @@ public class PerkSkeletons extends Perk skel.setCustomNameVisible(true); } - if (!_minions.containsKey(killer)) - _minions.put(killer, new ArrayList<>()); - - _minions.get(killer).add(skel); + _minions.computeIfAbsent(killer, k -> new ArrayList<>()).add(skel); killer.playSound(killer.getLocation(), Sound.SKELETON_HURT, 1f, 1f); - Bukkit.getPluginManager().callEvent(new MinionSpawnEvent(killer, this)); + UtilServer.CallEvent(new MinionSpawnEvent(killer, this)); } @EventHandler @@ -287,12 +296,8 @@ public class PerkSkeletons extends Perk //Move Location target = skel.getLocation().add(UtilAlg.getTrajectory(skel, player).multiply(3)); - EntityCreature ec = ((CraftCreature) skel).getHandle(); - NavigationAbstract nav = ec.getNavigation(); - nav.a(target.getX(), target.getY(), target.getZ(), speed); - skel.setTarget(null); - ((CraftSkeleton) skel).getHandle().setGoalTarget(null); + UtilEnt.CreatureMove(skel, target, speed); } // If it's VERY far from the player diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkTNTArrow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkTNTArrow.java index fb5e90528..fbf08d40e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkTNTArrow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkTNTArrow.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.kit.perks; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import org.bukkit.Location; import org.bukkit.Material; @@ -11,13 +12,12 @@ import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; -import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import mineplex.core.common.util.C; @@ -26,19 +26,21 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import nautilus.game.arcade.kit.Perk; public class PerkTNTArrow extends Perk { - private HashSet _active = new HashSet(); - private HashSet _arrows = new HashSet(); + private final Set _active = new HashSet<>(); + private final Set _arrows = new HashSet<>(); public PerkTNTArrow() { @@ -65,7 +67,7 @@ public class PerkTNTArrow extends Perk Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!Kit.HasKit(player) || !Recharge.Instance.usable(player, GetName(), true)) return; event.setCancelled(true); @@ -104,8 +106,10 @@ public class PerkTNTArrow extends Perk Player player = (Player)event.getEntity(); - if (!_active.remove(player)) + if (!_active.remove(player) || !Recharge.Instance.use(player, GetName(), 8000, true, true)) + { return; + } //Inform UtilPlayer.message(player, F.main("Game", "You fired " + F.skill(GetName()) + ".")); @@ -152,20 +156,17 @@ public class PerkTNTArrow extends Perk final Arrow arrow = (Arrow)proj; - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + Manager.runSyncLater(() -> { - public void run() + try { - try - { - //If it hasnt already triggered (via damage) - if (_arrows.remove(arrow)) - trigger(arrow, arrow.getLocation()); - } - catch (Exception e) - { - e.printStackTrace(); - } + //If it hasnt already triggered (via damage) + if (_arrows.remove(arrow)) + trigger(arrow, arrow.getLocation()); + } + catch (Exception e) + { + e.printStackTrace(); } }, 0); @@ -223,8 +224,7 @@ public class PerkTNTArrow extends Perk 0.4 + 0.8 * range, false, 0, 0.2 + 0.5 * range, 1.2, true); //Inform - if (cur instanceof Player) - UtilPlayer.message((Player)cur, F.main("Game", F.name(player.getName()) +" hit you with " + F.skill(GetName()) + ".")); + UtilPlayer.message(cur, F.main("Game", F.name(player.getName()) +" hit you with " + F.skill(GetName()) + ".")); } UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, loc, 0, 0, 0, 0, 1, @@ -239,7 +239,6 @@ public class PerkTNTArrow extends Perk return; for (Entity ent : _arrows) - UtilParticle.PlayParticle(ParticleType.LAVA, ent.getLocation(), 0, 0, 0, 0, 1, - ViewDist.MAX, UtilServer.getPlayers()); + UtilParticle.PlayParticleToAll(ParticleType.LAVA, ent.getLocation(), 0, 0, 0, 0, 1, ViewDist.LONG); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java index 417f8c0b7..fc333c1b8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java @@ -8,7 +8,6 @@ import org.bukkit.DyeColor; import org.bukkit.EntityEffect; import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWolf; import org.bukkit.entity.Entity; @@ -16,7 +15,9 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Wolf; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -28,6 +29,7 @@ import mineplex.core.common.util.SpigotUtil; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -36,12 +38,11 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.kit.Perk; -import net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.NavigationAbstract; public class PerkWolfPet extends Perk { @@ -191,23 +192,24 @@ public class PerkWolfPet extends Perk //Return to Owner double range = 0.5; if (wolf.getTarget() != null) - range = 12; + range = 9; Location target = player.getLocation().add(player.getLocation().getDirection().multiply(3)); target.setY(player.getLocation().getY()); if (UtilMath.offset(wolf.getLocation(), target) > range) { - float speed = 1f; + float speed = 1.2f; if (player.isSprinting()) - speed = 1.4f; - - //Move - EntityCreature ec = ((CraftCreature) wolf).getHandle(); - NavigationAbstract nav = ec.getNavigation(); - nav.a(target.getX(), target.getY(), target.getZ(), speed); + speed = 1.6f; wolf.setTarget(null); + wolf.setAngry(false); + UtilEnt.CreatureMove(wolf, target, speed); + } + else + { + wolf.setAngry(true); } } } @@ -225,14 +227,13 @@ public class PerkWolfPet extends Perk if (UtilBlock.usable(event.getClickedBlock())) return; - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE") && !event.getPlayer().getItemInHand().getType().toString().contains("_SWORD")) - return; - Player player = event.getPlayer(); + if (!UtilItem.isAxe(player.getItemInHand()) && !UtilItem.isSword(player.getItemInHand())) + { + return; + } + if (!Kit.HasKit(player)) return; @@ -242,7 +243,7 @@ public class PerkWolfPet extends Perk return; } - if (!Recharge.Instance.use(player, "Cub Strike", 4000, true, true)) + if (!Recharge.Instance.use(player, "Cub Strike", 10000, true, true)) return; Wolf wolf = _petMap.get(player).get(UtilMath.r(_petMap.get(player).size())); @@ -380,18 +381,28 @@ public class PerkWolfPet extends Perk return false; } - @EventHandler + @EventHandler(priority = EventPriority.HIGH) public void damage(CustomDamageEvent event) { - if (event.GetDamagerEntity(true) == null) + if (event.IsCancelled()) + { return; + } - if (!isMinion(event.GetDamagerEntity(true))) - return; + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(true); - double damage = 3; + if (isMinion(damagee) && event.GetCause() == DamageCause.FALL) + { + event.SetCancelled("Wolf Fall Damage"); + } + else if (damager != null && isMinion(damager)) + { + double damage = 3; - event.AddMod("Wolf Minion", "Negate", -event.GetDamageInitial(), false); - event.AddMod("Wolf Minion", "Damage", damage, false); + event.GetDamageeEntity().getWorld().playSound(event.GetDamageeEntity().getLocation(), Sound.SUCCESSFUL_HIT, 1, 1); + event.AddMod("Wolf Minion", "Negate", -event.GetDamageInitial(), false); + event.AddMod("Wolf Minion", "Damage", damage, false); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java index a67d3b93e..53946ac75 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java @@ -42,13 +42,10 @@ public class CollectQuestTracker extends QuestTracker super(game, TriggerType.COLLECT); } - @EventHandler(priority=EventPriority.LOWEST) + @EventHandler(priority=EventPriority.MONITOR) public void chestRefill(ChestRefillEvent event) { - if (event.isCancelled()) - return; - - _usedChests.clear(); + _usedChests.removeAll(event.getChests()); } @EventHandler(priority=EventPriority.HIGHEST) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java deleted file mode 100644 index d13edc1f9..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java +++ /dev/null @@ -1,35 +0,0 @@ -package nautilus.game.arcade.stats; - -import java.util.HashSet; -import java.util.Set; - -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent; - -import org.bukkit.block.Block; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -public class FirstSupplyDropOpenStatTracker extends StatTracker -{ - private Set _opened = new HashSet(); - - public FirstSupplyDropOpenStatTracker(Game game) - { - super(game); - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onSupplyChestOpen(SupplyChestOpenEvent event) - { - if (getGame().GetState() != Game.GameState.Live) - return; - System.out.println("DEBUG 1"); - if (_opened.contains(event.getChest())) - return; - - _opened.add(event.getChest()); - System.out.println("DEBUG 2"); - addStat(event.getPlayer(), "SupplyDropsOpened", 1, false, false); - } -}