From 84cb803c6686493438ff41d526cb2100e4255d63 Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 2 Jun 2017 13:22:12 +0200 Subject: [PATCH 001/183] Async db calls... --- .../quests/repository/QuestRepository.java | 95 ++++++++++++++----- 1 file changed, 69 insertions(+), 26 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java index 8a5cd8a08..4592781c1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java @@ -9,6 +9,7 @@ import org.apache.commons.lang3.tuple.Triple; import mineplex.core.account.CoreClient; import mineplex.core.common.Pair; import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UtilServer; import mineplex.core.quests.Quest; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; @@ -42,56 +43,98 @@ public class QuestRepository extends RepositoryBase public void createTable() { - executeUpdate(CREATE_TABLE); + UtilServer.runAsync(new Runnable() + { + @Override + public void run() + { + executeUpdate(CREATE_TABLE); + } + }); } public void getQuests(CoreClient client, Callback>>> callback) { - executeQuery(FETCH_QUESTS, new ResultSetCallable() - { + UtilServer.runAsync(new Runnable() + { @Override - public void processResultSet(ResultSet resultSet) throws SQLException + public void run() { - ArrayList>> list = new ArrayList<>(); - while (resultSet.next()) - { - list.add(Pair.create(resultSet.getInt(1), Triple.of(resultSet.getInt(2), resultSet.getLong(4), resultSet.getInt(3)))); - } - callback.run(list); + executeQuery(FETCH_QUESTS, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + ArrayList>> list = new ArrayList<>(); + while (resultSet.next()) + { + list.add(Pair.create(resultSet.getInt(1), Triple.of(resultSet.getInt(2), resultSet.getLong(4), resultSet.getInt(3)))); + } + callback.run(list); + } + } ,new ColumnInt("accountId", client.getAccountId())); } - } ,new ColumnInt("accountId", client.getAccountId())); + }); } public void resetQuest(CoreClient client, Quest quest, boolean completed) { - if (completed) + UtilServer.runAsync(new Runnable() { - executeUpdate(COMPLETE_QUEST, new ColumnLong("lastCompleted", System.currentTimeMillis()), new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); - } - else - { - executeUpdate(RESET_QUEST, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); - } + @Override + public void run() + { + if (completed) + { + executeUpdate(COMPLETE_QUEST, new ColumnLong("lastCompleted", System.currentTimeMillis()), new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); + } + else + { + executeUpdate(RESET_QUEST, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); + } + } + }); } public void addQuest(CoreClient client, Quest quest) { - executeUpdate(START_QUEST, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); + UtilServer.runAsync(new Runnable() + { + @Override + public void run() + { + executeUpdate(START_QUEST, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); + } + }); } public void addNew(CoreClient client, Quest quest) { - executeInsert(INSTERT_NEW_QUEST, null, - new ColumnInt("accountId", client.getAccountId()), - new ColumnInt("questId", quest.getID()), - new ColumnInt("progress", 0), - new ColumnInt("questCompletion", 0), - new ColumnLong("lastCompleted", (long) 0)); + UtilServer.runAsync(new Runnable() + { + @Override + public void run() + { + executeInsert(INSTERT_NEW_QUEST, null, + new ColumnInt("accountId", client.getAccountId()), + new ColumnInt("questId", quest.getID()), + new ColumnInt("progress", 0), + new ColumnInt("questCompletion", 0), + new ColumnLong("lastCompleted", (long) 0)); + } + }); } public void incrementQuest(CoreClient client, Quest quest, int value) { - executeUpdate(INCREMENT_QUEST, new ColumnInt("progress", value), new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); + UtilServer.runAsync(new Runnable() + { + @Override + public void run() + { + executeUpdate(INCREMENT_QUEST, new ColumnInt("progress", value), new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); + } + }); } } From b064542c4e64a88667aa596cfb56e596fb252a0e Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 22 Jun 2017 21:39:37 +0100 Subject: [PATCH 002/183] Staff and Clans Title --- .../core/titles/tracks/TrackManager.java | 12 ++++++ .../titles/tracks/award/ClansRaidTrack.java | 28 ++++++++++++++ .../titles/tracks/staff/BuilderTrack.java | 36 ++++++++++++++++++ .../titles/tracks/staff/ModeratorTrack.java | 36 ++++++++++++++++++ .../tracks/staff/SeniorModeratorTrack.java | 37 +++++++++++++++++++ .../titles/tracks/staff/TraineeTrack.java | 35 ++++++++++++++++++ 6 files changed, 184 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/ClansRaidTrack.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/BuilderTrack.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/ModeratorTrack.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/TraineeTrack.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java index 05c6833d0..fc5c8b3d6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java @@ -9,6 +9,11 @@ import java.util.function.Consumer; import mineplex.core.titles.tracks.award.AlienInvasionTrack; import mineplex.core.titles.tracks.award.AprilFools2017Track; +import mineplex.core.titles.tracks.award.ClansRaidTrack; +import mineplex.core.titles.tracks.staff.BuilderTrack; +import mineplex.core.titles.tracks.staff.ModeratorTrack; +import mineplex.core.titles.tracks.staff.SeniorModeratorTrack; +import mineplex.core.titles.tracks.staff.TraineeTrack; import mineplex.core.titles.tracks.standard.GemHuntersTrack; import net.md_5.bungee.api.ChatColor; @@ -86,6 +91,13 @@ public class TrackManager extends MiniPlugin registerTrack(new Bridges2017Track()); registerTrack(new AprilFools2017Track()); registerTrack(new AlienInvasionTrack()); + registerTrack(new ClansRaidTrack()); + + // Staff tracks + registerTrack(new BuilderTrack()); + registerTrack(new TraineeTrack()); + registerTrack(new ModeratorTrack()); + registerTrack(new SeniorModeratorTrack()); // Custom tracks // registerTrack(track("lenny", "Lenny", "( ͡° ͜ʖ ͡°)")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/ClansRaidTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/ClansRaidTrack.java new file mode 100644 index 000000000..9daaaeccd --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/ClansRaidTrack.java @@ -0,0 +1,28 @@ +package mineplex.core.titles.tracks.award; + +import mineplex.core.titles.tracks.ItemizedTrack; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; +import net.md_5.bungee.api.ChatColor; + +public class ClansRaidTrack extends ItemizedTrack +{ + public ClansRaidTrack() + { + super( + "clans-raid", + ChatColor.GOLD, + "Fallen Lord", + "The Fallen Lord", + "Among the first players to defeat the Charles Witherton raid!", + true); + + getRequirements() + .addTier(new TrackTier( + "The Fallen Lord", + null, + this::owns, + new TrackFormat(ChatColor.GOLD, ChatColor.GOLD) + )); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/BuilderTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/BuilderTrack.java new file mode 100644 index 000000000..e4254358c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/BuilderTrack.java @@ -0,0 +1,36 @@ +package mineplex.core.titles.tracks.staff; + +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.titles.tracks.ItemizedTrack; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.entity.Player; + +public class BuilderTrack extends ItemizedTrack +{ + + private final CoreClientManager _clientManager = Managers.get(CoreClientManager.class); + + public BuilderTrack() + { + super("staff-builder", ChatColor.BLUE, "Builder", "What's a Happer?", "What's a leader?", true); + getRequirements() + .addTier(new TrackTier( + "What's a Happer?", + null, + this::owns, + new TrackFormat(ChatColor.BLUE, ChatColor.BLUE) + )); + } + + @Override + public boolean owns(Player player) + { + Rank rank = _clientManager.Get(player).GetRank(true); + return rank == Rank.MAPDEV || rank == Rank.MAPLEAD || rank == Rank.MAPPER || rank.has(Rank.ADMIN); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/ModeratorTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/ModeratorTrack.java new file mode 100644 index 000000000..042d54e11 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/ModeratorTrack.java @@ -0,0 +1,36 @@ +package mineplex.core.titles.tracks.staff; + +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.titles.tracks.ItemizedTrack; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.entity.Player; + +public class ModeratorTrack extends ItemizedTrack +{ + + private final CoreClientManager _clientManager = Managers.get(CoreClientManager.class); + + public ModeratorTrack() + { + super("staff-moderator", ChatColor.GOLD, "Moderator", "My name isn't mod", "I have a name y'know!", true); + getRequirements() + .addTier(new TrackTier( + "My name isn't mod", + null, + this::owns, + new TrackFormat(ChatColor.GOLD, ChatColor.GOLD) + )); + } + + @Override + public boolean owns(Player player) + { + Rank rank = _clientManager.Get(player).GetRank(true); + return rank == Rank.MODERATOR || rank == Rank.CMA || rank.has(Rank.ADMIN); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java new file mode 100644 index 000000000..de60dd764 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java @@ -0,0 +1,37 @@ +package mineplex.core.titles.tracks.staff; + +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.titles.tracks.ItemizedTrack; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.entity.Player; + +public class SeniorModeratorTrack extends ItemizedTrack +{ + + private final CoreClientManager _clientManager = Managers.get(CoreClientManager.class); + + public SeniorModeratorTrack() + { + super("staff-srmod", ChatColor.GOLD, "Sr.Mod", "I think my team is the best team", "Team loyalty at its finest", true); + getRequirements() + .addTier(new TrackTier( + "I think my team is the best team", + null, + this::owns, + new TrackFormat(ChatColor.GOLD, ChatColor.GOLD) + )); + } + + @Override + public boolean owns(Player player) + { + Rank rank = _clientManager.Get(player).GetRank(true); + return rank == Rank.SNR_MODERATOR || rank == Rank.CMOD || rank.has(Rank.ADMIN); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/TraineeTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/TraineeTrack.java new file mode 100644 index 000000000..3aa827567 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/TraineeTrack.java @@ -0,0 +1,35 @@ +package mineplex.core.titles.tracks.staff; + +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.titles.tracks.ItemizedTrack; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.entity.Player; + +public class TraineeTrack extends ItemizedTrack +{ + + private final CoreClientManager _clientManager = Managers.get(CoreClientManager.class); + + public TraineeTrack() + { + super("staff-trainee", ChatColor.GOLD, "Trainee", "Choo Choo", "Choo Choo I'm a train-ee", true); + getRequirements() + .addTier(new TrackTier( + "Choo Choo", + null, + this::owns, + new TrackFormat(ChatColor.GOLD, ChatColor.GOLD) + )); + } + + @Override + public boolean owns(Player player) + { + Rank rank = _clientManager.Get(player).GetRank(true); + return rank == Rank.HELPER || rank.has(Rank.ADMIN); + } +} From 8fb2c81c7f8e37c8b40ade42430dc33d4b5f4ff6 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 22 Jun 2017 21:45:09 +0100 Subject: [PATCH 003/183] Shorten SR.MOD title --- .../mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java index de60dd764..5001c38c3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java @@ -18,7 +18,7 @@ public class SeniorModeratorTrack extends ItemizedTrack public SeniorModeratorTrack() { - super("staff-srmod", ChatColor.GOLD, "Sr.Mod", "I think my team is the best team", "Team loyalty at its finest", true); + super("staff-srmod", ChatColor.GOLD, "Sr.Mod", "I my team is the best team", "Team loyalty at its finest", true); getRequirements() .addTier(new TrackTier( "I think my team is the best team", From c6a3001bae9b993dbc21d7649f367190e09678e0 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 23 Jun 2017 22:31:08 +0100 Subject: [PATCH 004/183] Basic battle royale game --- .../src/mineplex/core/game/GameDisplay.java | 2 + .../src/nautilus/game/arcade/GameType.java | 3 + .../game/games/battleroyale/BattleRoyale.java | 347 ++++++++++++++++++ .../battleroyale/BattleRoyalePlayer.java | 132 +++++++ .../games/battleroyale/BattleRoyaleSolo.java | 151 ++++++++ .../game/modules/chest/ChestLootItem.java | 37 ++ .../game/modules/chest/ChestLootModule.java | 262 +++++++++++++ .../game/modules/chest/ChestLootPool.java | 94 +++++ 8 files changed, 1028 insertions(+) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootItem.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootModule.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootPool.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 413dbbc8f..ac7c74b16 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -107,6 +107,8 @@ public enum GameDisplay MOBA("Heroes of GWEN", Material.PRISMARINE, (byte)0, GameCategory.CLASSICS, 70, true), MOBATraining("Heroes of GWEN Training", Material.PRISMARINE, (byte)0, GameCategory.CLASSICS, 70, false), + BattleRoyale("Battle Royale", Material.DIAMOND_SWORD, (byte)0, GameCategory.EVENT, 72, false), + GemHunters("Gem Hunters", Material.EMERALD, (byte) 0, GameCategory.SURVIVAL, 71, false), Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999, false), 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 503422b10..c60f4c16c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -9,6 +9,7 @@ import nautilus.game.arcade.game.games.alieninvasion.AlienInvasion; import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl; import nautilus.game.arcade.game.games.barbarians.Barbarians; import nautilus.game.arcade.game.games.basketball.Basketball; +import nautilus.game.arcade.game.games.battleroyale.BattleRoyaleSolo; import nautilus.game.arcade.game.games.bossbattles.BossBattles; import nautilus.game.arcade.game.games.bouncyballs.BouncyBalls; import nautilus.game.arcade.game.games.bridge.Bridge; @@ -237,6 +238,8 @@ public enum GameType MOBA(MobaClassic.class, GameDisplay.MOBA), MOBATraining(MobaTraining.class, GameDisplay.MOBATraining), + BattleRoyale(BattleRoyaleSolo.class, GameDisplay.BattleRoyale), + Event(EventGame.class, GameDisplay.Event, new GameType[]{ GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, GameType.Cards, GameType.CastleSiege, GameType.ChampionsDominate, GameType.ChampionsTDM, GameType.Christmas, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java new file mode 100644 index 000000000..e1cbaab7c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java @@ -0,0 +1,347 @@ +package nautilus.game.arcade.game.games.battleroyale; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +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.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.modules.chest.ChestLootModule; +import nautilus.game.arcade.game.modules.chest.ChestLootPool; +import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.kit.Kit; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.WorldBorder; +import org.bukkit.entity.Chicken; +import org.bukkit.entity.EnderDragon; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +public abstract class BattleRoyale extends Game +{ + + private static final long PREPARE_TIME = TimeUnit.SECONDS.toMillis(20); + private static final int MAX_CORD = 1000; + private static final int SPAWN_Y = 130; + private static final int WORLD_SIZE_BUFFER = 300; + private static final int MIN_DISTANCE_APART_FOR_SPAWNS_SQUARED = 100; + private static final long MAX_DRAGON_TIME = TimeUnit.SECONDS.toMillis(60); + private static final long BORDER_TIME = TimeUnit.MINUTES.toSeconds(20); + + private final Map _playerData = new HashMap<>(70); + + protected WorldBorder _border; + + public BattleRoyale(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc) + { + super(manager, gameType, kits, gameDesc); + + PrepareTime = PREPARE_TIME; + PrepareFreeze = false; + Damage = false; + DamageTeamSelf = true; + DeathDropItems = true; + QuitDropItems = true; + HungerSet = 20; + DeathTeleport = false; + WorldChunkUnload = true; + + ItemDrop = true; + ItemPickup = true; + + StrictAntiHack = true; + InventoryClick = true; + InventoryOpenBlock = true; + InventoryOpenChest = true; + + new CompassModule() + .register(this); + + new ChestLootModule() + .registerChestType("Standard", + + // Swords + new ChestLootPool() + .addItem(new ItemStack(Material.WOOD_SWORD)) + .addItem(new ItemStack(Material.STONE_SWORD)) + , + // Armour + 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)) + ) + .register(this); + } + + @Override + public void ParseData() + { + ChestLootModule chestModule = getModule(ChestLootModule.class); + + chestModule.setSpawnsForType("Standard", WorldData.GetDataLocs("ORANGE")); + + WorldData.MinX = -MAX_CORD; + WorldData.MinZ = -MAX_CORD; + WorldData.MaxX = MAX_CORD; + WorldData.MaxZ = MAX_CORD; + + _border = WorldData.World.getWorldBorder(); + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + _border.setCenter(getRandomCenter()); + _border.setSize(MAX_CORD * 2); + + List toTeleport = GetPlayers(true); + AtomicInteger index = new AtomicInteger(); + + Manager.runSyncTimer(new BukkitRunnable() + { + @Override + public void run() + { + if (index.get() >= toTeleport.size()) + { + cancel(); + return; + } + + Player player = toTeleport.get(index.get()); + + if (player == null || !player.isOnline() || UtilPlayer.isSpectator(player)) + { + return; + } + + Location spawn = null; + int attempts = 0; + int initialXZ = 0; + + while (spawn == null && attempts++ < 20) + { + if (attempts > 10) + { + initialXZ += 20; + } + + spawn = getPlayerSpawn(initialXZ); + } + + // Couldn't create a spawn, this should never happen and is pretty much impossible + if (spawn == null) + { + cancel(); + SetState(GameState.Dead); + return; + } + + Location goal = spawn.clone(); + + goal.setX(-spawn.getX()); + goal.setZ(-spawn.getZ()); + + Bukkit.broadcastMessage(player.getName() + " -> " + UtilWorld.locToStrClean(spawn) + " after " + attempts + " attempts"); + BattleRoyalePlayer royalePlayer = new BattleRoyalePlayer(Manager, player, spawn, goal); + _playerData.put(player, royalePlayer); + + index.getAndIncrement(); + } + }, 100, 2); + } + + private Location getPlayerSpawn(int initialXZ) + { + // Calculate where a player should spawn + int max = MAX_CORD - WORLD_SIZE_BUFFER; + int x = initialXZ; + int z = initialXZ; + boolean varyX = UtilMath.random.nextBoolean(); + boolean sign = UtilMath.random.nextBoolean(); + + if (varyX) + { + x += UtilMath.rRange(-max, max); + z += sign ? max : -max; + } + else + { + x += sign ? max : -max; + z += UtilMath.rRange(-max, max); + } + + Location location = new Location(WorldData.World, x, SPAWN_Y, z); + + // Check to make sure no players are nearby + for (BattleRoyalePlayer other : _playerData.values()) + { + if (UtilMath.offsetSquared(location, other.getLocation()) < MIN_DISTANCE_APART_FOR_SPAWNS_SQUARED) + { + return null; + } + } + + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, GetSpectatorLocation()))); + return location; + } + + private Location getRandomCenter() + { + int attempts = 0; + + while (attempts++ < 20) + { + Location location = UtilAlg.getRandomLocation(GetSpectatorLocation(), 200, 0, 200); + + if (UtilBlock.airFoliage(UtilBlock.getHighest(location.getWorld(), location.getBlock()))) + { + return location; + } + } + + return SpectatorSpawn; + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + CreatureAllowOverride = true; + + _playerData.forEach((player, battleRoyalePlayer) -> + { + battleRoyalePlayer.removeCage(); + battleRoyalePlayer.spawnDragon(); + }); + + CreatureAllowOverride = false; + } + + @EventHandler + public void updateDragons(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !IsLive()) + { + return; + } + + Iterator iterator = _playerData.keySet().iterator(); + + while (iterator.hasNext()) + { + Player player = iterator.next(); + BattleRoyalePlayer royalePlayer = _playerData.get(player); + + if (royalePlayer == null || !player.isOnline()) + { + iterator.remove(); + continue; + } + + EnderDragon dragon = royalePlayer.getDragon(); + Chicken chicken = royalePlayer.getChicken(); + + if (dragon == null || chicken == null) + { + continue; + } + + UtilTextBottom.display((player.getTicksLived() % 5 == 0 ? C.cGreenB : C.cWhiteB) + "PRESS YOUR SNEAK KEY TO DISMOUNT YOUR DRAGON", player); + if (dragon.getPassenger() == null || chicken.getPassenger() == null) + { + Recharge.Instance.useForce(player, "Fall Damage", TimeUnit.SECONDS.toMillis(10)); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, player.getLocation(), 5, 5, 5, 0.01F, 100, ViewDist.NORMAL); + player.playSound(player.getLocation(), Sound.BLAZE_DEATH, 1, 0.6F); + dragon.remove(); + chicken.remove(); + iterator.remove(); + } + } + + if (!Damage && UtilTime.elapsed(GetStateTime(), MAX_DRAGON_TIME)) + { + _playerData.forEach((player, battleRoyalePlayer) -> + { + Recharge.Instance.useForce(player, "Fall Damage", TimeUnit.SECONDS.toMillis(10)); + player.sendMessage(F.main("Game", "You were too slow!")); + battleRoyalePlayer.getDragon().remove(); + battleRoyalePlayer.getChicken().remove(); + }); + _playerData.clear(); + + Announce(C.cRedB + "Grace Period Over!", false); + + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1); + } + + Damage = true; + HungerSet = -1; + _border.setSize(100, BORDER_TIME); + } + } + + @EventHandler + public void fallDamage(CustomDamageEvent event) + { + Player player = event.GetDamageePlayer(); + + if (player == null || event.GetCause() != DamageCause.FALL || Recharge.Instance.usable(player, "Fall Damage")) + { + return; + } + + event.SetCancelled("Dragon Fall"); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void preventDragonExplosion(EntityExplodeEvent event) + { + if (event.getEntity() instanceof EnderDragon) + { + event.blockList().clear(); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java new file mode 100644 index 000000000..6ceff59dd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java @@ -0,0 +1,132 @@ +package nautilus.game.arcade.game.games.battleroyale; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilEnt; +import nautilus.game.arcade.ArcadeManager; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEnderDragon; +import org.bukkit.entity.Chicken; +import org.bukkit.entity.EnderDragon; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import java.util.HashSet; +import java.util.Set; + +class BattleRoyalePlayer +{ + + private final Player _player; + private final Location _location; + private final Location _goal; + private final Set _cageBlocks; + private EnderDragon _dragon; + private Chicken _chicken; + + public BattleRoyalePlayer(ArcadeManager manager, Player player, Location location, Location goal) + { + _player = player; + _location = location; + _goal = goal; + _cageBlocks = new HashSet<>(); + + // Colour the cage based on the player's rank + Rank rank = manager.GetClients().Get(player).GetRank(); + byte data = UtilColor.chatColorToWoolData(rank.getColor()); + + // Build the cage + buildCage(data); + // Teleport the player to the cage + player.teleport(_location.add(0, 1, 0)); + } + + private void buildCage(byte colourData) + { + // Floor + for (int x = -2; x <= 2; x++) + { + for (int z = -2; z <= 2; z++) + { + _location.add(x, -1, z); + MapUtil.QuickChangeBlockAt(_location, Material.STAINED_GLASS, colourData); + _cageBlocks.add(_location); + _location.subtract(x, -1, z); + } + } + + // Roof + for (int x = -2; x <= 2; x++) + { + for (int z = -2; z <= 2; z++) + { + _location.add(x, 4, z); + MapUtil.QuickChangeBlockAt(_location, Material.STAINED_GLASS, colourData); + _cageBlocks.add(_location); + _location.subtract(x, 4, z); + } + } + + // Walls + for (int y = 0; y < 4; y++) + { + for (int x = -2; x <= 2; x++) + { + for (int z = -2; z <= 2; z++) + { + if (x != -2 && x != 2 && z != -2 && z != 2) + { + continue; + } + + _location.add(x, y, z); + MapUtil.QuickChangeBlockAt(_location, Material.STAINED_GLASS, colourData); + _cageBlocks.add(_location); + _location.subtract(x, y, z); + } + } + } + } + + public void removeCage() + { + for (Location location : _cageBlocks) + { + MapUtil.QuickChangeBlockAt(location, Material.AIR); + } + } + + public void spawnDragon() + { + _dragon = _location.getWorld().spawn(_location, EnderDragon.class); + UtilEnt.vegetate(_dragon); + UtilEnt.ghost(_dragon, true, false); + + _chicken = _location.getWorld().spawn(_location, Chicken.class); + _chicken.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0)); + + _dragon.setPassenger(_chicken); + _chicken.setPassenger(_player); + + ((CraftEnderDragon) _dragon).getHandle().setTargetBlock(_goal.getBlockX(), _goal.getBlockY(), _goal.getBlockZ()); + } + + public Location getLocation() + { + return _location; + } + + public EnderDragon getDragon() + { + return _dragon; + } + + public Chicken getChicken() + { + return _chicken; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java new file mode 100644 index 000000000..0e1fca782 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java @@ -0,0 +1,151 @@ +package nautilus.game.arcade.game.games.battleroyale; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilWorld; +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.game.games.moba.kit.KitPlayer; +import nautilus.game.arcade.kit.Kit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class BattleRoyaleSolo extends BattleRoyale +{ + + private static final String[] DESCRIPTION = { + "Battle Royale!" + }; + + private GameTeam _players; + + public BattleRoyaleSolo(ArcadeManager manager) + { + super(manager, GameType.BattleRoyale, new Kit[] {new KitPlayer(manager)}, DESCRIPTION); + } + + @EventHandler + public void customTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + _players = GetTeamList().get(0); + _players.SetColor(ChatColor.YELLOW); + _players.SetName("Players"); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !InProgress()) + { + return; + } + + Scoreboard.writeNewLine(); + + Scoreboard.write(C.cYellow + C.Bold + "Players"); + if (_players.GetPlayers(true).size() > 10) + { + Scoreboard.write(String.valueOf( _players.GetPlayers(true).size())); + } + else + { + for (Player player : _players.GetPlayers(true)) + { + Scoreboard.write(player.getName()); + } + } + + Scoreboard.writeNewLine(); + + int size = (int) _border.getSize(); + Scoreboard.write(C.cRedB + "World Border"); + Scoreboard.write(UtilWorld.locToStrClean(_border.getCenter())); + Scoreboard.write(size + " Blocks Wide"); + + Scoreboard.draw(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + if (GetPlayers(true).size() <= 1) + { + List places = _players.GetPlacements(true); + + AnnounceEnd(places); + + 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); + } + } + + _border.setSize(10000); + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (GetState().ordinal() >= GameState.End.ordinal()) + { + List places = _players.GetPlacements(true); + + if (places.isEmpty() || !places.get(0).isOnline()) + return new ArrayList<>(0); + else + return Collections.singletonList(places.get(0)); + } + else + return null; + } + + @Override + public List getLosers() + { + List winners = getWinners(); + + if (winners == null) + { + return null; + } + + List losers = _players.GetPlayers(false); + losers.removeAll(winners); + + return losers; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootItem.java new file mode 100644 index 000000000..a86370368 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootItem.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.modules.chest; + +import mineplex.core.common.util.UtilMath; +import org.bukkit.inventory.ItemStack; + +public class ChestLootItem +{ + + private ItemStack _item; + private int _lowestAmount, _highestAmount; + private double _rarity; + + public ChestLootItem(ItemStack item, int lowestAmount, int highestAmount, double rarity) + { + _item = item; + _lowestAmount = lowestAmount; + _highestAmount = highestAmount; + _rarity = rarity; + } + + public ItemStack getItem() + { + ItemStack itemStack = _item.clone(); + + if (_lowestAmount != _highestAmount) + { + itemStack.setAmount(UtilMath.rRange(_lowestAmount, _highestAmount)); + } + + return itemStack; + } + + public double getProbability() + { + return _rarity; + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..b57c21cad --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootModule.java @@ -0,0 +1,262 @@ +package nautilus.game.arcade.game.modules.chest; + +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.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.modules.Module; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Chest; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerInteractEvent; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +public class ChestLootModule extends Module +{ + + private static final BlockFace[] FACES = { + BlockFace.NORTH, + BlockFace.SOUTH, + BlockFace.WEST, + BlockFace.EAST + }; + + private final List _chestTypes; + private final Map> _chests; + + private long _destroyAfterOpened; + private boolean _autoRotateChests = true; + + public ChestLootModule() + { + _chestTypes = new ArrayList<>(); + _chests = new HashMap<>(); + } + + public ChestLootModule registerChestType(String name, ChestLootPool... pools) + { + return registerChestType(name, 1, pools); + } + + public ChestLootModule registerChestType(String name, double spawnChance, ChestLootPool... pools) + { + _chestTypes.add(new ChestType(name, spawnChance, pools)); + return this; + } + + public ChestLootModule setSpawnsForType(String typeName, List locations) + { + for (ChestType type : _chestTypes) + { + if (type.Name.equals(typeName)) + { + type.ChestSpawns = locations; + } + } + + return this; + } + + public ChestLootModule destoryAfterOpened(int seconds) + { + _destroyAfterOpened = TimeUnit.SECONDS.toMillis(seconds); + return this; + } + + public ChestLootModule autoRotateChests(boolean autoRotate) + { + _autoRotateChests = autoRotate; + return this; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void populateChests(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (ChestType chestType : _chestTypes) + { + if (chestType.ChestSpawns == null) + { + continue; + } + + Set metadataSet = new HashSet<>(); + + for (Location location : chestType.ChestSpawns) + { + if (chestType.SpawnChance == 1 || Math.random() < chestType.SpawnChance) + { + Block block = location.getBlock(); + block.setType(Material.CHEST); + + if (_autoRotateChests) + { + for (BlockFace face : FACES) + { + if (UtilBlock.airFoliage(block.getRelative(face))) + { + block.setData(getData(face)); + break; + } + } + } + + ChestMetadata metadata = new ChestMetadata(block, chestType); + metadataSet.add(metadata); + } + } + + _chests.put(chestType, metadataSet); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void openChest(PlayerInteractEvent event) + { + Block block = event.getClickedBlock(); + + if (event.isCancelled() || !UtilEvent.isAction(event, ActionType.R_BLOCK) || block == null || !(block.getState() instanceof Chest)) + { + return; + } + + ChestMetadata metadata = getFromBlock(block); + + if (metadata == null) + { + return; + } + + if (metadata.Opened) + { + return; + } + + metadata.Opened = true; + metadata.OpenedAt = System.currentTimeMillis(); + metadata.populateChest((Chest) block.getState()); + } + + @EventHandler + public void destroyOpenedChests(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || _destroyAfterOpened == 0) + { + return; + } + + for (Set metadataSet : _chests.values()) + { + metadataSet.removeIf(metadata -> + { + if (metadata.Opened && UtilTime.elapsed(metadata.OpenedAt, _destroyAfterOpened)) + { + Block block = metadata.Chest; + Location location = block.getLocation(); + location.getWorld().playEffect(location.add(0.5, 0.5, 0.5), Effect.STEP_SOUND, block.getType(), block.getData()); + block.setType(Material.AIR); + return true; + } + + return false; + }); + } + } + + 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) + { + return metadata; + } + } + } + + return null; + } + + private byte getData(BlockFace face) + { + switch (face) + { + case NORTH: + return 0; + case SOUTH: + return 3; + case WEST: + return 4; + case EAST: + return 5; + } + + return 0; + } + + private class ChestMetadata + { + + Block Chest; + ChestType Type; + long OpenedAt; + boolean Opened; + + ChestMetadata(Block chest, ChestType type) + { + Chest = chest; + Type = type; + } + + void populateChest(Chest chest) + { + for (ChestLootPool pool : Type.Pool) + { + pool.populateChest(chest); + } + } + } + + public class ChestType + { + String Name; + double SpawnChance; + List Pool; + List ChestSpawns; + + public ChestType(String name, double spawnChance, ChestLootPool... pools) + { + Name = name; + SpawnChance = spawnChance; + Pool = Arrays.asList(pools); + } + } + + +} 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 new file mode 100644 index 000000000..973597748 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/chest/ChestLootPool.java @@ -0,0 +1,94 @@ +package nautilus.game.arcade.game.modules.chest; + +import mineplex.core.common.util.UtilMath; +import org.bukkit.block.Chest; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +public class ChestLootPool +{ + + private List _items; + private int _minimumPerChest; + private int _maximumPerChest; + + public ChestLootPool() + { + _items = new ArrayList<>(); + _minimumPerChest = 1; + _maximumPerChest = 1; + } + + public ChestLootPool addItem(ItemStack itemStack) + { + return addItem(itemStack, itemStack.getAmount(), itemStack.getAmount(), 1); + } + + public ChestLootPool addItem(ItemStack itemStack, double rarity) + { + return addItem(itemStack, itemStack.getAmount(), itemStack.getAmount(), rarity); + } + + public ChestLootPool addItem(ItemStack itemStack, int lowestAmount, int highestAmount) + { + return addItem(itemStack, lowestAmount, highestAmount, 1); + } + + public ChestLootPool addItem(ItemStack itemStack, int lowestAmount, int highestAmount, double rarity) + { + _items.add(new ChestLootItem(itemStack, lowestAmount, highestAmount, rarity)); + return this; + } + + public ChestLootPool setAmountsPerChest(int minimumPerChest, int maximumPerChest) + { + _minimumPerChest = minimumPerChest; + _maximumPerChest = maximumPerChest; + return this; + } + + public void populateChest(Chest chest) + { + Inventory inventory = chest.getBlockInventory(); + + for (int i = 0; i < UtilMath.rRange(_minimumPerChest, _maximumPerChest); i++) + { + int slot = UtilMath.r(inventory.getSize()); + ChestLootItem item = getRandomItem(); + + if (item == null) + { + continue; + } + + inventory.setItem(slot, item.getItem()); + } + + chest.update(); + } + + private ChestLootItem getRandomItem() + { + double totalWeight = 0; + + for (ChestLootItem item : _items) + { + totalWeight += item.getProbability(); + } + + double select = Math.random() * totalWeight; + + for (ChestLootItem item : _items) + { + if ((select -= item.getProbability()) <= 0) + { + return item; + } + } + + return null; + } +} \ No newline at end of file From 31533f29b7fad5e747c81cec37afc2b153285e92 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 24 Jun 2017 18:19:56 +0100 Subject: [PATCH 005/183] Add Guns into Battle Royale --- .../src/nautilus/game/arcade/GameType.java | 6 +- .../game/games/battleroyale/BattleRoyale.java | 157 ++++++++--- .../games/battleroyale/BattleRoyaleSolo.java | 5 +- .../survivalgames/modes/StrikeGames.java | 253 ++---------------- .../game/modules/StrikeGamesModule.java | 220 +++++++++++++++ .../game/modules/chest/ChestLootModule.java | 97 +++++-- .../game/modules/chest/ChestLootPool.java | 13 + .../game/arcade/managers/GameFlagManager.java | 9 +- 8 files changed, 464 insertions(+), 296 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/StrikeGamesModule.java 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 c60f4c16c..7cefa2340 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -238,7 +238,11 @@ public enum GameType MOBA(MobaClassic.class, GameDisplay.MOBA), MOBATraining(MobaTraining.class, GameDisplay.MOBATraining), - BattleRoyale(BattleRoyaleSolo.class, GameDisplay.BattleRoyale), + BattleRoyale(BattleRoyaleSolo.class, GameDisplay.BattleRoyale, new Pair[] + { + Pair.create(MinecraftVersion.Version1_8, "http://file.mineplex.com/ResStrikeGames18.zip"), + Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResStrikeGames19.zip") + }, false), Event(EventGame.class, GameDisplay.Event, new GameType[]{ GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java index e1cbaab7c..c4695a3b7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java @@ -12,6 +12,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -20,6 +21,9 @@ 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.games.minestrike.GunModule; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats; +import nautilus.game.arcade.game.modules.StrikeGamesModule; import nautilus.game.arcade.game.modules.chest.ChestLootModule; import nautilus.game.arcade.game.modules.chest.ChestLootPool; import nautilus.game.arcade.game.modules.compass.CompassModule; @@ -29,6 +33,8 @@ 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.entity.Chicken; import org.bukkit.entity.EnderDragon; import org.bukkit.entity.Player; @@ -59,12 +65,18 @@ public abstract class BattleRoyale extends Game private final Map _playerData = new HashMap<>(70); + protected GunModule _gunModule; + protected WorldBorder _border; + private boolean _colouredMessage; public BattleRoyale(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc) { super(manager, gameType, kits, gameDesc); + // TODO REMOVE THIS + TeleportsDisqualify = false; + PrepareTime = PREPARE_TIME; PrepareFreeze = false; Damage = false; @@ -74,6 +86,7 @@ public abstract class BattleRoyale extends Game HungerSet = 20; DeathTeleport = false; WorldChunkUnload = true; + GameTimeout = TimeUnit.MINUTES.toMillis(40); ItemDrop = true; ItemPickup = true; @@ -83,33 +96,81 @@ public abstract class BattleRoyale extends Game InventoryOpenBlock = true; InventoryOpenChest = true; - new CompassModule() + BlockBreakAllow.add(Material.GLASS.getId()); + BlockBreakAllow.add(Material.STAINED_GLASS.getId()); + BlockBreakAllow.add(Material.THIN_GLASS.getId()); + BlockBreakAllow.add(Material.STAINED_GLASS_PANE.getId()); + BlockBreakAllow.add(Material.LEAVES.getId()); + + _gunModule = new GunModule(this); + _gunModule.EnableCleaning = false; + _gunModule.EnableDrop = false; + _gunModule.EnablePickup = false; + _gunModule.BlockRegeneration = false; + _gunModule.EnableNormalArmor = true; + + new StrikeGamesModule(_gunModule) .register(this); - new ChestLootModule() - .registerChestType("Standard", - - // Swords - new ChestLootPool() - .addItem(new ItemStack(Material.WOOD_SWORD)) - .addItem(new ItemStack(Material.STONE_SWORD)) - , - // Armour - 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)) - ) + new CompassModule() .register(this); } @Override public void ParseData() { - ChestLootModule chestModule = getModule(ChestLootModule.class); + new ChestLootModule() + .spawnNearbyDataPoints() + .registerChestType("Standard", WorldData.GetDataLocs("ORANGE"), - chestModule.setSpawnsForType("Standard", WorldData.GetDataLocs("ORANGE")); + // Guns + new ChestLootPool() + .addItem(buildFromGun(GunStats.GLOCK_18)) + .addItem(buildFromGun(GunStats.CZ75)) + .addItem(buildFromGun(GunStats.DEAGLE)) + .addItem(buildFromGun(GunStats.P250)) + .addItem(buildFromGun(GunStats.P2000)) + .addItem(buildFromGun(GunStats.AK47), 0.2) + .addItem(buildFromGun(GunStats.M4A4), 0.2) + .setProbability(0.4) + , + + // Weapons + new ChestLootPool() + .addItem(new ItemStack(Material.WOOD_SWORD)) + .addItem(new ItemStack(Material.STONE_SWORD), 0.3) + .setProbability(0.5) + , + + // Armour + 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)) + , + + // Food + new ChestLootPool() + .addItem(new ItemStack(Material.RAW_FISH), 1, 3) + .addItem(new ItemStack(Material.RAW_BEEF), 1, 3) + .addItem(new ItemStack(Material.RAW_CHICKEN), 1, 3) + .addItem(new ItemStack(Material.MUTTON), 1, 3) + .addItem(new ItemStack(Material.MELON), 1, 3) + .addItem(new ItemStack(Material.BREAD), 1, 2, 0.4) + .addItem(new ItemStack(Material.COOKED_FISH), 0.2) + .addItem(new ItemStack(Material.COOKED_BEEF), 0.2) + .addItem(new ItemStack(Material.COOKED_CHICKEN), 0.2) + .addItem(new ItemStack(Material.COOKED_MUTTON), 0.2) + .addItem(new ItemStack(Material.COOKIE), 0.2) + , + + // Misc + new ChestLootPool() + .addItem(new ItemStack(Material.STICK), 1, 2) + .setProbability(0.2) + ) + .register(this); WorldData.MinX = -MAX_CORD; WorldData.MinZ = -MAX_CORD; @@ -119,6 +180,13 @@ public abstract class BattleRoyale extends Game _border = WorldData.World.getWorldBorder(); } + private ItemStack buildFromGun(GunStats gunStats) + { + return new ItemBuilder(gunStats.getSkin()) + .setTitle(C.cWhiteB + gunStats.getName()) + .build(); + } + @EventHandler public void prepare(GameStateChangeEvent event) { @@ -229,6 +297,17 @@ public abstract class BattleRoyale extends Game while (attempts++ < 20) { Location location = UtilAlg.getRandomLocation(GetSpectatorLocation(), 200, 0, 200); + Block block = location.getBlock(); + + while (!UtilBlock.solid(block)) + { + block = block.getRelative(BlockFace.DOWN); + } + + if (block.isLiquid()) + { + continue; + } if (UtilBlock.airFoliage(UtilBlock.getHighest(location.getWorld(), location.getBlock()))) { @@ -266,6 +345,8 @@ public abstract class BattleRoyale extends Game return; } + _colouredMessage = !_colouredMessage; + Iterator iterator = _playerData.keySet().iterator(); while (iterator.hasNext()) @@ -287,27 +368,25 @@ public abstract class BattleRoyale extends Game continue; } - UtilTextBottom.display((player.getTicksLived() % 5 == 0 ? C.cGreenB : C.cWhiteB) + "PRESS YOUR SNEAK KEY TO DISMOUNT YOUR DRAGON", player); + UtilTextBottom.display((_colouredMessage ? C.cGreenB : C.cWhiteB) + "PRESS YOUR SNEAK KEY TO DISMOUNT YOUR DRAGON", player); if (dragon.getPassenger() == null || chicken.getPassenger() == null) { - Recharge.Instance.useForce(player, "Fall Damage", TimeUnit.SECONDS.toMillis(10)); - UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, player.getLocation(), 5, 5, 5, 0.01F, 100, ViewDist.NORMAL); - player.playSound(player.getLocation(), Sound.BLAZE_DEATH, 1, 0.6F); - dragon.remove(); - chicken.remove(); + if (!UtilTime.elapsed(GetStateTime(), 4000)) + { + player.sendMessage(F.main("Game", "Did you accidentally press sneak? Don't worry I'll put you back on your dragon.")); + dragon.setPassenger(chicken); + chicken.setPassenger(player); + continue; + } + + dismountDragon(player, royalePlayer); iterator.remove(); } } if (!Damage && UtilTime.elapsed(GetStateTime(), MAX_DRAGON_TIME)) { - _playerData.forEach((player, battleRoyalePlayer) -> - { - Recharge.Instance.useForce(player, "Fall Damage", TimeUnit.SECONDS.toMillis(10)); - player.sendMessage(F.main("Game", "You were too slow!")); - battleRoyalePlayer.getDragon().remove(); - battleRoyalePlayer.getChicken().remove(); - }); + _playerData.forEach(this::dismountDragon); _playerData.clear(); Announce(C.cRedB + "Grace Period Over!", false); @@ -323,6 +402,16 @@ public abstract class BattleRoyale extends Game } } + private void dismountDragon(Player player, BattleRoyalePlayer royalePlayer) + { + // Recharge this so that players won't take fall damage for the next 10 seconds + Recharge.Instance.useForce(player, "Fall Damage", TimeUnit.SECONDS.toMillis(10)); + player.playSound(player.getLocation(), Sound.BLAZE_DEATH, 1, 0.6F); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, player.getLocation(), 5, 5, 5, 0.01F, 100, ViewDist.NORMAL); + royalePlayer.getDragon().remove(); + royalePlayer.getChicken().remove(); + } + @EventHandler public void fallDamage(CustomDamageEvent event) { @@ -344,4 +433,10 @@ public abstract class BattleRoyale extends Game event.blockList().clear(); } } + + @EventHandler + public void damageToLevel(CustomDamageEvent event) + { + event.SetDamageToLevel(false); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java index 0e1fca782..b41d01379 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java @@ -1,7 +1,6 @@ package nautilus.game.arcade.game.games.battleroyale; import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilWorld; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; @@ -11,6 +10,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.KitPlayer; import nautilus.game.arcade.kit.Kit; import org.bukkit.ChatColor; +import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -70,8 +70,9 @@ public class BattleRoyaleSolo extends BattleRoyale Scoreboard.writeNewLine(); int size = (int) _border.getSize(); + Location center = _border.getCenter(); Scoreboard.write(C.cRedB + "World Border"); - Scoreboard.write(UtilWorld.locToStrClean(_border.getCenter())); + Scoreboard.write("(" + center.getBlockX() + ", " + center.getBlockZ() + ")"); Scoreboard.write(size + " Blocks Wide"); Scoreboard.draw(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java index 304140edd..cfb326659 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java @@ -1,31 +1,5 @@ package nautilus.game.arcade.game.games.survivalgames.modes; -import java.util.HashMap; -import java.util.Iterator; - -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.enchantment.EnchantItemEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerItemConsumeEvent; -import org.bukkit.event.player.PlayerItemDamageEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.inventory.meta.ItemMeta; - import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; @@ -36,29 +10,28 @@ import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.loot.RandomItem; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerKitGiveEvent; -import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minestrike.GunModule; -import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; -import nautilus.game.arcade.game.games.minestrike.items.grenades.FlashBang; -import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade; -import nautilus.game.arcade.game.games.minestrike.items.grenades.HighExplosive; -import nautilus.game.arcade.game.games.minestrike.items.grenades.Incendiary; -import nautilus.game.arcade.game.games.minestrike.items.grenades.Molotov; -import nautilus.game.arcade.game.games.minestrike.items.grenades.Smoke; -import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats; -import nautilus.game.arcade.game.games.minestrike.items.guns.GunType; -import nautilus.game.arcade.game.games.minestrike.items.guns.Shotgun; import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames; import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent; import nautilus.game.arcade.game.games.survivalgames.kit.KitLooter; 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 @@ -68,12 +41,8 @@ import nautilus.game.arcade.kit.Kit; public class StrikeGames extends SoloSurvivalGames { - private GunModule _gunModule; - private long _peacePhase; private boolean _peace = false; - - private HashMap _helmets; public StrikeGames(ArcadeManager manager) { @@ -83,19 +52,20 @@ public class StrikeGames extends SoloSurvivalGames }, GameType.StrikeGames); Damage = false; - - _helmets = new HashMap<>(); - + _peacePhase = 20000; HungerSet = 20; - _gunModule = new GunModule(this); - _gunModule.EnableCleaning = false; - _gunModule.EnableDrop = false; - _gunModule.EnablePickup = false; - _gunModule.BlockRegeneration = false; - _gunModule.EnableNormalArmor = true; + 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 @@ -119,20 +89,6 @@ public class StrikeGames extends SoloSurvivalGames Damage = true; } - @EventHandler - public void eatingGrenades(PlayerItemConsumeEvent event) - { - if (event.getItem().getType() == Material.POTATO_ITEM - || event.getItem().getType() == Material.CARROT_ITEM - || event.getItem().getType() == Material.APPLE - || event.getItem().getType() == Material.PORK - || event.getItem().getType() == Material.GRILLED_PORK) - { - event.setCancelled(true); - } - - } - @EventHandler(priority = EventPriority.LOWEST) public void DeathmatchDamage(UpdateEvent event) { @@ -163,39 +119,6 @@ public class StrikeGames extends SoloSurvivalGames Announce(F.main("Game", "A Peace Phase of " + F.time((_peacePhase/1000) + "") + " seconds has started!")); } - @EventHandler(priority=EventPriority.HIGHEST) - public void addHelmet(PlayerToggleSneakEvent event) - { - if (!IsLive()) - return; - - if (!IsAlive(event.getPlayer())) - return; - - if (_gunModule.getScoped().containsKey(event.getPlayer())) - return; - - if (event.getPlayer().getInventory().getHelmet() != null) - _helmets.put(event.getPlayer(), event.getPlayer().getInventory().getHelmet()); - } - - @EventHandler(priority=EventPriority.HIGHEST) - public void pumpkinDrop(PlayerDeathEvent event) - { - Iterator itemIterator = event.getDrops().iterator(); - while (itemIterator.hasNext()) - { - ItemStack item = itemIterator.next(); - if (item.getType() == Material.PUMPKIN - || item.getType() == Material.PUMPKIN_STEM) - { - itemIterator.remove(); - } - } - if (_helmets.containsKey(event.getEntity())) - event.getDrops().add(_helmets.get(event.getEntity())); - } - @EventHandler public void disableCrafting(PlayerInteractEvent event) { @@ -205,13 +128,6 @@ public class StrikeGames extends SoloSurvivalGames if (event.getClickedBlock().getType() == Material.WORKBENCH) event.setCancelled(true); } - - @EventHandler - public void weaponEnchantment(EnchantItemEvent event) - { - if (!UtilItem.isArmor(event.getItem())) - event.setCancelled(true); - } public void setupLoot() { @@ -414,131 +330,6 @@ public class StrikeGames extends SoloSurvivalGames getSupplyBlocks().remove(block); } - @EventHandler - public void addEquipment(InventoryClickEvent event) - { - if (event.getCurrentItem() == null) - return; - - if (!(event.getWhoClicked() instanceof Player)) - return; - - Player player = (Player) event.getWhoClicked(); - - if (!(event.getClickedInventory() instanceof PlayerInventory)) - { - ItemStack stack = event.getCurrentItem(); - for (GunStats stat : GunStats.values()) - { - if (stat.getSkin() == stack.getType()) - { - Gun gun = null; - if (stat.getGunType() == GunType.SHOTGUN) - { - gun = new Shotgun(stat, _gunModule); - } - else - { - gun = new Gun(stat, _gunModule); - } - gun.setStack(stack); - gun.updateWeaponName(player, null, false); - gun.addID(); - _gunModule.registerGun(gun, player); - return; - } - } - - Grenade grenade = null; - - if (stack.getType() == Material.APPLE) - { - grenade = new HighExplosive(); - } - else if (stack.getType() == Material.CARROT_ITEM) - { - grenade = new FlashBang(); - } - else if (stack.getType() == Material.POTATO_ITEM) - { - grenade = new Smoke(); - } - else if (stack.getType() == Material.PORK) - { - grenade = new Incendiary(); - } - else if (stack.getType() == Material.GRILLED_PORK) - { - grenade = new Molotov(); - } - - if (grenade != null) - { - ItemMeta meta = stack.getItemMeta(); - meta.setDisplayName(grenade.getName()); - stack.setItemMeta(meta); - grenade.setStack(stack); - _gunModule.registerGrenade(grenade, player); - } - } - } - - @EventHandler - public void triggerPickup(PlayerPickupItemEvent event) - { - - if (!InProgress()) - return; - - if (!IsAlive(event.getPlayer())) - return; - - //Guns - Gun gun = _gunModule.getDroppedGuns().get(event.getItem()); - if (gun != null) - { - _gunModule.deregisterDroppedGun(gun); - _gunModule.registerGun(gun, event.getPlayer()); - gun.setStack(event.getItem().getItemStack()); - } - - //Grenades - Grenade grenade = _gunModule.getDroppedGrenades().get(event.getItem()); - if (grenade != null) - { - _gunModule.deregisterDroppedGrenade(grenade); - _gunModule.registerGrenade(grenade, event.getPlayer()); - grenade.setStack(event.getItem().getItemStack()); - } - } - - @EventHandler - public void triggerDrop(PlayerDropItemEvent event) - { - if (!InProgress()) - return; - - //Guns - Gun gun = _gunModule.getGunInHand(event.getPlayer(), event.getItemDrop().getItemStack()); - if (gun != null) - { - gun.drop(_gunModule, event.getPlayer(), false, false); - event.getItemDrop().remove(); - event.getPlayer().setItemInHand(null); - return; - } - - //Grenades - Grenade grenade = _gunModule.getGrenadeInHand(event.getPlayer(), event.getItemDrop().getItemStack()); - if (grenade != null) - { - grenade.drop(_gunModule, event.getPlayer(), false, false); - event.getItemDrop().remove(); - event.getPlayer().setItemInHand(null); - return; - } - } - @EventHandler @Override public void ItemSpawn(ItemSpawnEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/StrikeGamesModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/StrikeGamesModule.java new file mode 100644 index 000000000..a398eba40 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/StrikeGamesModule.java @@ -0,0 +1,220 @@ +package nautilus.game.arcade.game.modules; + +import mineplex.core.common.util.UtilItem; +import nautilus.game.arcade.game.games.minestrike.GunModule; +import nautilus.game.arcade.game.games.minestrike.items.grenades.FlashBang; +import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade; +import nautilus.game.arcade.game.games.minestrike.items.grenades.HighExplosive; +import nautilus.game.arcade.game.games.minestrike.items.grenades.Incendiary; +import nautilus.game.arcade.game.games.minestrike.items.grenades.Molotov; +import nautilus.game.arcade.game.games.minestrike.items.grenades.Smoke; +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunType; +import nautilus.game.arcade.game.games.minestrike.items.guns.Shotgun; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.enchantment.EnchantItemEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.HashMap; +import java.util.Map; + +public class StrikeGamesModule extends Module +{ + + private final Map _helmets; + private final GunModule _gunModule; + + public StrikeGamesModule(GunModule gunModule) + { + _gunModule = gunModule; + _helmets = new HashMap<>(); + } + + @EventHandler + public void eatingGrenades(PlayerItemConsumeEvent event) + { + Material material = event.getItem().getType(); + + switch (material) + { + case POTATO_ITEM: + case CARROT_ITEM: + case APPLE: + case PORK: + case GRILLED_PORK: + event.setCancelled(true); + break; + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void addHelmet(PlayerToggleSneakEvent event) + { + Player player = event.getPlayer(); + ItemStack helmet = player.getInventory().getHelmet(); + + if (!getGame().IsLive() || !getGame().IsAlive(player) || _gunModule.getScoped().containsKey(player) || helmet == null) + { + return; + } + + _helmets.put(event.getPlayer(), helmet); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void pumpkinDrop(PlayerDeathEvent event) + { + Player player = event.getEntity(); + + event.getDrops().removeIf(item -> item.getType() == Material.PUMPKIN || item.getType() == Material.PUMPKIN_STEM); + + if (_helmets.containsKey(player)) + { + event.getDrops().add(_helmets.get(player)); + } + } + + @EventHandler + public void weaponEnchantment(EnchantItemEvent event) + { + if (!UtilItem.isArmor(event.getItem())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void addEquipment(InventoryClickEvent event) + { + if (event.getCurrentItem() == null || !(event.getWhoClicked() instanceof Player) || event.getClickedInventory() instanceof PlayerInventory) + { + return; + } + + Player player = (Player) event.getWhoClicked(); + ItemStack stack = event.getCurrentItem(); + for (GunStats stat : GunStats.values()) + { + if (stat.getSkin() == stack.getType()) + { + Gun gun; + if (stat.getGunType() == GunType.SHOTGUN) + { + gun = new Shotgun(stat, _gunModule); + } + else + { + gun = new Gun(stat, _gunModule); + } + gun.setStack(stack); + gun.updateWeaponName(player, null, false); + gun.addID(); + _gunModule.registerGun(gun, player); + return; + } + } + + Grenade grenade = null; + + switch (stack.getType()) + { + case APPLE: + grenade = new HighExplosive(); + break; + case CARROT_ITEM: + grenade = new FlashBang(); + break; + case POTATO_ITEM: + grenade = new Smoke(); + break; + case PORK: + grenade = new Incendiary(); + break; + case GRILLED_PORK: + grenade = new Molotov(); + break; + } + + if (grenade == null) + { + return; + } + + ItemMeta meta = stack.getItemMeta(); + meta.setDisplayName(grenade.getName()); + stack.setItemMeta(meta); + grenade.setStack(stack); + _gunModule.registerGrenade(grenade, player); + } + + @EventHandler + public void triggerPickup(PlayerPickupItemEvent event) + { + if (!getGame().InProgress() || !getGame().IsAlive(event.getPlayer())) + { + return; + } + + //Guns + Gun gun = _gunModule.getDroppedGuns().get(event.getItem()); + if (gun != null) + { + _gunModule.deregisterDroppedGun(gun); + _gunModule.registerGun(gun, event.getPlayer()); + gun.setStack(event.getItem().getItemStack()); + } + + //Grenades + Grenade grenade = _gunModule.getDroppedGrenades().get(event.getItem()); + if (grenade != null) + { + _gunModule.deregisterDroppedGrenade(grenade); + _gunModule.registerGrenade(grenade, event.getPlayer()); + grenade.setStack(event.getItem().getItemStack()); + } + } + + @EventHandler + public void triggerDrop(PlayerDropItemEvent event) + { + if (!getGame().InProgress()) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = event.getItemDrop().getItemStack(); + + //Guns + Gun gun = _gunModule.getGunInHand(player, itemStack); + + if (gun != null) + { + gun.drop(_gunModule, player, false, false); + event.getItemDrop().remove(); + player.setItemInHand(null); + return; + } + + //Grenades + Grenade grenade = _gunModule.getGrenadeInHand(player, itemStack); + if (grenade != null) + { + grenade.drop(_gunModule, player, false, false); + event.getItemDrop().remove(); + player.setItemInHand(null); + } + } +} 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 b57c21cad..4ebeecc89 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 @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.modules.chest; +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; @@ -44,6 +45,8 @@ public class ChestLootModule extends Module private long _destroyAfterOpened; private boolean _autoRotateChests = true; + private boolean _spawnNearby; + private int _spawnNearbyRadius = 8; public ChestLootModule() { @@ -51,27 +54,14 @@ public class ChestLootModule extends Module _chests = new HashMap<>(); } - public ChestLootModule registerChestType(String name, ChestLootPool... pools) + public ChestLootModule registerChestType(String name, List chestLocations, ChestLootPool... pools) { - return registerChestType(name, 1, pools); + return registerChestType(name, chestLocations, 1, pools); } - public ChestLootModule registerChestType(String name, double spawnChance, ChestLootPool... pools) + public ChestLootModule registerChestType(String name, List chestLocations, double spawnChance, ChestLootPool... pools) { - _chestTypes.add(new ChestType(name, spawnChance, pools)); - return this; - } - - public ChestLootModule setSpawnsForType(String typeName, List locations) - { - for (ChestType type : _chestTypes) - { - if (type.Name.equals(typeName)) - { - type.ChestSpawns = locations; - } - } - + _chestTypes.add(new ChestType(name, chestLocations, spawnChance, pools)); return this; } @@ -87,6 +77,19 @@ public class ChestLootModule extends Module return this; } + public ChestLootModule spawnNearbyDataPoints() + { + _spawnNearby = true; + return this; + } + + public ChestLootModule spawnNearbyDataPoints(int radius) + { + _spawnNearby = true; + _spawnNearbyRadius = radius; + return this; + } + @EventHandler(priority = EventPriority.HIGHEST) public void populateChests(GameStateChangeEvent event) { @@ -109,6 +112,19 @@ public class ChestLootModule extends Module if (chestType.SpawnChance == 1 || Math.random() < chestType.SpawnChance) { Block block = location.getBlock(); + + if (_spawnNearby) + { + Location nearby = getNearbyLocation(location); + + if (nearby == null) + { + continue; + } + + block = nearby.getBlock(); + } + block.setType(Material.CHEST); if (_autoRotateChests) @@ -144,12 +160,7 @@ public class ChestLootModule extends Module ChestMetadata metadata = getFromBlock(block); - if (metadata == null) - { - return; - } - - if (metadata.Opened) + if (metadata == null || metadata.Opened) { return; } @@ -220,6 +231,30 @@ public class ChestLootModule extends Module return 0; } + private Location getNearbyLocation(Location center) + { + int attempts = 0; + while (attempts++ < 20) + { + Location newLocation = UtilAlg.getRandomLocation(center, _spawnNearbyRadius, 1, _spawnNearbyRadius); + + if (isSuitable(newLocation.getBlock())) + { + return newLocation; + } + } + + return null; + } + + private boolean isSuitable(Block block) + { + Block up = block.getRelative(BlockFace.UP); + Block down = block.getRelative(BlockFace.DOWN); + + return block.getType() == Material.AIR && up.getType() == Material.AIR && down.getType() != Material.AIR && !UtilBlock.liquid(down) && !UtilBlock.liquid(up) && !UtilBlock.liquid(block); + } + private class ChestMetadata { @@ -236,25 +271,29 @@ public class ChestLootModule extends Module void populateChest(Chest chest) { - for (ChestLootPool pool : Type.Pool) + for (ChestLootPool pool : Type.Pools) { - pool.populateChest(chest); + if (pool.getProbability() == 1 || Math.random() < pool.getProbability()) + { + pool.populateChest(chest); + } } } } - public class ChestType + private class ChestType { String Name; double SpawnChance; - List Pool; + List Pools; List ChestSpawns; - public ChestType(String name, double spawnChance, ChestLootPool... pools) + ChestType(String name, List chestLocations, double spawnChance, ChestLootPool... pools) { Name = name; SpawnChance = spawnChance; - Pool = Arrays.asList(pools); + Pools = Arrays.asList(pools); + 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 973597748..8683a66c0 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 @@ -14,12 +14,14 @@ public class ChestLootPool private List _items; private int _minimumPerChest; private int _maximumPerChest; + private double _rarity; public ChestLootPool() { _items = new ArrayList<>(); _minimumPerChest = 1; _maximumPerChest = 1; + _rarity = 1; } public ChestLootPool addItem(ItemStack itemStack) @@ -50,6 +52,12 @@ public class ChestLootPool return this; } + public ChestLootPool setProbability(double probability) + { + _rarity = probability; + return this; + } + public void populateChest(Chest chest) { Inventory inventory = chest.getBlockInventory(); @@ -91,4 +99,9 @@ public class ChestLootPool return null; } + + public double getProbability() + { + return _rarity; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index a2819e252..ce46fb56a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -1096,9 +1096,14 @@ public class GameFlagManager implements Listener return; } - if (game.WorldWaterDamage <= 0 && !game.WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty()) + if (game.WorldWaterDamage <= 0) { - game.WorldWaterDamage = 4; + if (!game.WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty()) + { + game.WorldWaterDamage = 4; + } + + return; } for (Player player : game.GetPlayers(true)) From 8541b984c6888cdbf67e72c44849ca260ff9c744 Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 27 Jun 2017 23:15:25 +0200 Subject: [PATCH 006/183] Implement new Quests and fix older Quests --- .../src/mineplex/core/quests/TriggerType.java | 2 +- .../src/nautilus/game/arcade/game/Game.java | 6 +- .../game/games/paintball/Paintball.java | 3 + .../paintball/quests/ReviveQuestTracker.java | 32 +++++++++ .../game/games/turfforts/TurfForts.java | 2 + .../quests/BlockBreakQuestTracker.java | 33 +++++++++ .../arcade/quest/CollectQuestTracker.java | 71 +++++++++++++++++++ .../arcade/quest/FirstBloodQuestTracker.java | 31 ++++++++ .../game/arcade/quest/HitQuestTracker.java | 63 ++++++++++++++++ .../game/arcade/quest/QuestTracker.java | 3 + 10 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/quests/ReviveQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/quests/BlockBreakQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/FirstBloodQuestTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java index 861999fae..bf8a64b55 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/TriggerType.java @@ -8,7 +8,7 @@ package mineplex.core.quests; public enum TriggerType { - KILL("Kill"), DIE("Die"), WIN("Win"), LOSE("Lose"), COLLECT("Collect"), PLAY("Play"), COMPLETE("Complete"); + KILL("Kill"), DIE("Die"), WIN("Win"), LOSE("Lose"), COLLECT("Collect"), PLAY("Play"), COMPLETE("Complete"), HIT("Hit"), FIRST_BLOOD("First Blood"); private String _name; 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 be505ed11..3bf2f1a57 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 @@ -43,6 +43,8 @@ import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.managers.lobby.LobbyManager; import nautilus.game.arcade.quest.ChestOpenQuestTracker; import nautilus.game.arcade.quest.CollectQuestTracker; +import nautilus.game.arcade.quest.FirstBloodQuestTracker; +import nautilus.game.arcade.quest.HitQuestTracker; import nautilus.game.arcade.quest.KillEntityQuestTracker; import nautilus.game.arcade.quest.KillQuestTracker; import nautilus.game.arcade.quest.ParticipateQuestTracker; @@ -433,7 +435,9 @@ public abstract class Game extends ListenerComponent implements Lifetimed new ChestOpenQuestTracker(this), new KillEntityQuestTracker(this), new PlayGameQuestTracker(this), - new ParticipateQuestTracker(this)); + new ParticipateQuestTracker(this), + new HitQuestTracker(this), + new FirstBloodQuestTracker(this)); Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(this), gameType.isEnforceResourcePack(this)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java index e7f509b4e..063a76d36 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java @@ -71,6 +71,7 @@ import nautilus.game.arcade.game.games.paintball.kits.KitMachineGun; import nautilus.game.arcade.game.games.paintball.kits.KitRifle; import nautilus.game.arcade.game.games.paintball.kits.KitShotgun; import nautilus.game.arcade.game.games.paintball.kits.KitSniper; +import nautilus.game.arcade.game.games.paintball.quests.ReviveQuestTracker; import nautilus.game.arcade.game.games.paintball.trackers.KillingSpreeTracker; import nautilus.game.arcade.game.games.paintball.trackers.LastStandStatTracker; import nautilus.game.arcade.game.games.paintball.trackers.MedicStatTracker; @@ -125,6 +126,8 @@ public class Paintball extends TeamGame DamageTaken, DamageDealt ); + + registerQuestTrackers(new ReviveQuestTracker(this)); new CompassModule() .setGiveCompass(true) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/quests/ReviveQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/quests/ReviveQuestTracker.java new file mode 100644 index 000000000..400515b3a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/quests/ReviveQuestTracker.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.paintball.quests; + +import org.bukkit.event.EventHandler; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.paintball.events.ReviveEvent; +import nautilus.game.arcade.quest.QuestTracker; + +/** + * ReviveQuestTracker + * + * @author xXVevzZXx + */ +public class ReviveQuestTracker extends QuestTracker +{ + + public ReviveQuestTracker(Game game) + { + super(game, TriggerType.COLLECT); + } + + @EventHandler + public void onHit(ReviveEvent event) + { + if (!getGame().IsLive()) + return; + + incrementQuests(event.getPlayer(), 1, "Revive", getGame().GetKit(event.getPlayer()).GetName() + "Kit"); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index 93c2fb37c..8e85f9e16 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -58,6 +58,7 @@ import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.turfforts.kits.KitInfiltrator; import nautilus.game.arcade.game.games.turfforts.kits.KitMarksman; import nautilus.game.arcade.game.games.turfforts.kits.KitShredder; +import nautilus.game.arcade.game.games.turfforts.quests.BlockBreakQuestTracker; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -171,6 +172,7 @@ public class TurfForts extends TeamGame new ChatStatData("BlocksBroken", "Blocks Broken", true) ); + registerQuestTrackers(new BlockBreakQuestTracker(this)); new CompassModule() .setGiveCompass(true) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/quests/BlockBreakQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/quests/BlockBreakQuestTracker.java new file mode 100644 index 000000000..f15b21e37 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/quests/BlockBreakQuestTracker.java @@ -0,0 +1,33 @@ +package nautilus.game.arcade.game.games.turfforts.quests; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.turfforts.TurfForts; +import nautilus.game.arcade.quest.QuestTracker; + +/** + * BlockBreakQuestTracker + * + * @author xXVevzZXx + */ +public class BlockBreakQuestTracker extends QuestTracker +{ + + public BlockBreakQuestTracker(Game game) + { + super(game, TriggerType.COLLECT); + } + + @EventHandler + public void onHit(TurfForts.ShredBlockEvent event) + { + if (!getGame().IsLive()) + return; + + incrementQuests((Player) event.getArrow().getShooter(), 1, "Block Break", getGame().GetKit((Player) event.getArrow().getShooter()).GetName() + "Kit"); + } +} \ No newline at end of file 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 d8ad07885..83367508e 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 @@ -5,14 +5,18 @@ import java.util.ArrayList; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.block.Chest; import org.bukkit.block.DoubleChest; import org.bukkit.entity.Player; 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.BlockPlaceEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -30,6 +34,7 @@ public class CollectQuestTracker extends QuestTracker { private ArrayList _itemsAvailable = new ArrayList<>(); private ArrayList _usedChests = new ArrayList<>(); + private ArrayList _usedBlocks = new ArrayList<>(); public CollectQuestTracker(Game game) { @@ -45,6 +50,72 @@ public class CollectQuestTracker extends QuestTracker _usedChests.clear(); } + @EventHandler(priority=EventPriority.HIGHEST) + public void blockRegister(BlockPlaceEvent event) + { + if (!getGame().IsLive()) + return; + + if (event.isCancelled()) + return; + + if (event.getBlockPlaced().getType() == Material.IRON_ORE + || event.getBlockPlaced().getType() == Material.GOLD_ORE) + { + _usedBlocks.add(event.getBlock().getLocation()); + } + + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void itemRegister(BlockBreakEvent event) + { + if (!getGame().IsLive()) + return; + + if (event.isCancelled()) + return; + + if (_usedBlocks.contains(event.getBlock().getLocation())) + return; + + for (ItemStack item : event.getBlock().getDrops()) + { + _itemsAvailable.add(item); + } + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void itemPickup(PlayerPickupItemEvent event) + { + if (!getGame().IsLive()) + return; + + if (event.isCancelled()) + return; + + ItemStack item = event.getItem().getItemStack(); + ItemStack fromList = null; + + for (ItemStack available : _itemsAvailable) + { + if (available.getType() == item.getType()) + fromList = available; + } + + if (fromList == null) + return; + + _itemsAvailable.remove(fromList); + + String itemName = item.getType().toString(); + + if (item.hasItemMeta()) + itemName = item.getItemMeta().getDisplayName(); + + incrementQuests(event.getPlayer(), item.getAmount(), ChatColor.stripColor(itemName)); + } + @EventHandler(priority=EventPriority.HIGHEST) public void chestRegister(PlayerInteractEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/FirstBloodQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/FirstBloodQuestTracker.java new file mode 100644 index 000000000..22b7f79c4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/FirstBloodQuestTracker.java @@ -0,0 +1,31 @@ +package nautilus.game.arcade.quest; + +import org.bukkit.event.EventHandler; + +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.events.FirstBloodEvent; +import nautilus.game.arcade.game.Game; + +/** + * FirstBloodQuestTracker + * + * @author xXVevzZXx + */ +public class FirstBloodQuestTracker extends QuestTracker +{ + + public FirstBloodQuestTracker(Game game) + { + super(game, TriggerType.FIRST_BLOOD); + } + + @EventHandler + public void onHit(FirstBloodEvent event) + { + if (!getGame().IsLive()) + return; + + incrementQuests(event.getPlayer(), 1, getGame().GetKit(event.getPlayer()).GetName() + "Kit"); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java new file mode 100644 index 000000000..107048e14 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java @@ -0,0 +1,63 @@ +package nautilus.game.arcade.quest; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.ProjectileHitEvent; + +import mineplex.core.common.util.UtilItem; +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.game.Game; + +/** + * HitQuestTracker + * + * @author xXVevzZXx + */ +public class HitQuestTracker extends QuestTracker +{ + + public HitQuestTracker(Game game) + { + super(game, TriggerType.HIT); + } + + @EventHandler + public void onHit(EntityDamageByEntityEvent event) + { + if (!getGame().IsLive()) + return; + + if (!(event.getEntity() instanceof Player)) + return; + + incrementQuests((Player) event.getDamager(), 1, "Player", getGame().GetKit((Player) event.getDamager()).GetName() + "Kit"); + } + + @EventHandler + public void onProjectileHit(ProjectileHitEvent event) + { + if (!getGame().IsLive()) + return; + + if (!(event.getEntity().getShooter() instanceof Player)) + return; + + Item itemEntity = (Item) event.getEntity(); + String item = itemEntity.getItemStack().getType().toString(); + + if (UtilItem.isAxe(itemEntity.getItemStack().getType())) + { + item = "Axe"; + } + + Entity ent = event.getEntity().getLastDamageCause().getEntity(); + if (ent instanceof Player) + { + incrementQuests((Player) event.getEntity().getShooter(), 1, "Player", item, getGame().GetKit((Player) event.getEntity().getShooter()).GetName() + "Kit"); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java index c34a50efc..d615bcd9d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/QuestTracker.java @@ -42,6 +42,9 @@ public class QuestTracker implements Listener public void incrementQuests(Player player, int value, String... items) { + if (getGame().getArcadeManager().GetGameHostManager().isPrivateServer()) + return; + if (canProgressQuests()) { for (Quest quest : getGame().getArcadeManager().getQuestManager().getAvailableQuests()) From e9fea233826d6f3360a53bb7ce1cc6364166a960 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:28:39 -0400 Subject: [PATCH 007/183] Add gaussian methods to UtilMath --- .../mineplex/core/common/util/UtilMath.java | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java index 5e37e0ac5..1b3b40835 100644 --- a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; import org.bukkit.Location; import org.bukkit.entity.Entity; @@ -13,6 +14,8 @@ import org.bukkit.util.Vector; public class UtilMath { + public static final double TAU = Math.PI * 2D; + public static double trim(int degree, double d) { String format = "#.#"; @@ -332,4 +335,119 @@ public class UtilMath return min; } + + /** + * Creates an array of points, arranged in a circle normal to a vector. + * + * @param center The center of the circle. + * @param normal A vector normal to the circle. + * @param radius The radius of the circle. + * @param points How many points to make up the circle. + * + * @return An array of points of the form double[point #][x=0, y=1, z=3]. + */ + public static double[][] normalCircle(Location center, Vector normal, double radius, int points) + { + return normalCircle(center.toVector(), normal, radius, points); + } + + /** + * Creates an array of points, arranged in a circle normal to a vector. + * + * @param center The center of the circle. + * @param normal A vector normal to the circle. + * @param radius The radius of the circle. + * @param points How many points to make up the circle. + * + * @return An array of points of the form double[point #][x=0, y=1, z=3]. + */ + public static double[][] normalCircle(Vector center, Vector normal, double radius, int points) + { + Vector n = normal.clone().normalize(); + Vector a = n.clone().add(new Vector(1, 1, 1)).crossProduct(n).normalize(); + Vector b = n.getCrossProduct(a).normalize(); + + double[][] data = new double[points][3]; + + double interval = TAU / points; + double theta = 0; + + for (int i = 0; i < points; i++) + { + data[i][0] = center.getX() + (radius * ((Math.cos(theta) * a.getX()) + (Math.sin(theta) * b.getX()))); + data[i][1] = center.getY() + (radius * ((Math.cos(theta) * a.getY()) + (Math.sin(theta) * b.getY()))); + data[i][2] = center.getZ() + (radius * ((Math.cos(theta) * a.getZ()) + (Math.sin(theta) * b.getZ()))); + theta += interval; + } + + return data; + } + + /** + * Slightly randomize a location with a standard deviation of one. + * + * @param location The location to randomize. + * + * @return The original location, now gaussian-randomized. + */ + public static Location gauss(Location location) + { + return gauss(location, 1, 1, 1); + } + + /** + * Slightly randomize a vector with a standard deviation of one. + * + * @param vector The location to randomize. + * + * @return The randomized vector, now gaussian-randomized. + */ + public static Vector gauss(Vector vector) + { + return gauss(vector, 1, 1, 1); + } + + /** + * Slightly randomize a location with a standard deviation of one.
+ * + * This method only accepts positive values for all of its arguments.
+ * + * A good parameter set for small offsets is (loc, 10, 10, 10). + * + * @param location The location to randomize. + * @param x A granularity control for the x-axis, higher numbers = less randomness + * @param y A granularity control for the y-axis, higher numbers = less randomness + * @param z A granularity control for the z-axis, higher numbers = less randomness + * + * @return The original location, now gaussian-randomized + */ + public static Location gauss(Location location, double x, double y, double z) + { + return location.clone().add( + x <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / x), + y <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / y), + z <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / z)); + } + + /** + * Slightly randomize a vector with a standard deviation of one.
+ * + * This method only accepts positive values for all of its arguments.
+ * + * A good parameter set for small offsets is (loc, 10, 10, 10). + * + * @param vector The location to randomize. + * @param x A granularity control for the x-axis, higher numbers = less randomness + * @param y A granularity control for the y-axis, higher numbers = less randomness + * @param z A granularity control for the z-axis, higher numbers = less randomness + * + * @return The randomized vector, now gaussian-randomized + */ + public static Vector gauss(Vector vector, double x, double y, double z) + { + return vector.clone().add(new Vector( + x <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / x), + y <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / y), + z <= 0 ? 0 : (ThreadLocalRandom.current().nextGaussian() / z))); + } } From 845e96109b2be51bfe7254582812f23e0e7c3e59 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:29:02 -0400 Subject: [PATCH 008/183] Add Hat skin data --- .../src/mineplex/core/common/skin/SkinData.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index f803154ce..6b7b7a675 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -78,6 +78,8 @@ public class SkinData public static final SkinData LARISSA = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjE0MTUxMzQsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jYThjNDRhOWVmZTY3NzExMDYzMjM5ODEwNDRmOTdjYmM1OWJmZmRlOGI1ODdlMGQzMWE4N2ViMDhhMmExZiJ9fX0=", "Lyac51CrnMK/CI2dWgGQLowAm/ZnQMpf0Ict/gqVrUgJVlGWDIVG77Rd1JyMQDEeESvTmoyivH+usiO0ePW95qjisqT3R43YEmLi85CqctGYqLKeSYpGYwYRz8Euw57LwJAALKOMLhVc2s4h2Or9nTecunG8KSmkCuZc4H1qh3frU+ltuV4HLqgdFUULbIHTggyvqiINov2tBqkkXeEjT7sOcTJCJNgNYU2O7//qg5kJmhso2CKHlRLpmy9LsaUK/Z+BzUmoRbwQgSwr3mz7dFAdlVWWKvKNcgX3nt1et0DIig3JKYmrnQX2Fprg+kWcr3nuizzLgjVwAlADC48P3DN0s/VBty2AYoWie16VNPIM+CV4BF2JRQ34GxZ8XceXbCKURrOjoCBgLGHvIhRW35eicoh26xp3/mwLvk5anPi5StJ/qEuzWJALeWcNbLsnt21m2MZp9h/MxaY6ftWOTzjTr5CYVd/teJyscMnGK4+lcV1dlt12lhbDMv6I+iz8iG9NIzuW5OvGkax90dA/Gq+Cd9FXVThPY4ufxWttHcTqgPB64GfMn6rywRm1B0eO1pJpYc/KlJZlW/PuaO8L1assyJs5KkOypBSy3zc6TO6pzgeOZv+VpQfA/UWpogv6ofmTpgdtwpjLFGSzIKTDXvF6FftALKVlYypG0fYbssA="); public static final SkinData ROWENA = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0Njk1MTcxOTgsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jNDY1OGExODY4YzNhNjhhZWVhZmZkOTUxZDQyYmZkN2QxYTRjNGZjNDJjZDI2YTlmYzhkNTNmOTkxMTM1ZCJ9fX0=", "OqXMyH9SMmQ/Pwmb21In29YnCxbsN6yqUxfudN6KNgDwRUK6y072XhW6TIoTh9JQLAUKftpeVB53tk0LxHIxnsuBMrIHvETPDQFysIc/6xq3ABogs+zqFzcp5jk6S73HiD78JxLq5pzfUzhgDPMPuZP5Q/u2q1rYbe6B9lVEJ5sUcxBLUTossgucoR4qXYAlWVQdHRhq85Ol8a+OU7ruw3HackNGto6wt6u2MigCtiHVTt9XhJ/AJE4ScodQ3XwW4L6urpl/lV2OMCsr3mCjjjEz2EMhDbCWxrAorQ9aPpMbDkHBS+4TC1tbMGUlKhj5n+EZBYVaeLr4NGPACPSdT35p/2Zra49+DXn9Xn+681yNEB0ghTdsnsgwXg76+HVPHPqRHQMuTBQGQyGZaaTX/zE0tFjH+osMElLdb8dmz3dC7kQA4A13B2phj3YbMSF1FoU4GvnPKIQn6JIuEd6hd+pRLUW7Y+mgYIHHX1FT0ihrXAyVO6lQQ6rs92gSQr7sxC7tnhPSMFcmh7OcJYcbRpn97GMubthPLanOhVy7CKqjmwIkEVtYgP28idigKwNJ+sJuUONrOu7nMKl1UTD5EEapOacc/np6UhdSw8yW+LnWD/x9ueYz9ksnyRrJgcOa41izo/WCbjPK/j3JVezr9Q3x1yveWuFmdl7CGYdXngw="); public static final SkinData BIFF = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjEzMDQzNjYsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9mOWMyMTE3ZDY0ZWE0ZmUxMWZiY2NhZmE2YzU5YzhlZjY3NDVkZjVkMTZjM2QwMmI4NmI2OTlmZWJjNTA0OGI1In19fQ==", "mJMpEvQ4A02z0S/chgLm5bKrrrd+zmp7A0012AB7b3KlyIHoLKEDDz+ZJgJtvN6skOqed3P+yNVqkxitugXaZZP8Af9J+/TseHn+vOy6CTK5tykRSY3Zb8Zmw1kn36v/SARAVtDIHD53yuPgJayYSAbVB7aknj1Q8XBQGUmZRMRxWWxeD7rQTOwgRYI4YJeKFf4UL9i6zxvOJuHsOAouJ7scu7VohG8vgR77Js/Z8rSu8/aSG+O9AQdzP6h9ixYNFkkQOHm7DseK/5tsWKHM4FYBgjIDKt3ApQokSbhThzGB55BA1qjXZkfCoOb13y1nOMC8WoIL6Ees1qzxG3VloGx2WAZLh+Q+/irwrFDMxk1zeU5fIRuj1c/UIM2HKdxxWgoRdrZ8ww/Jrll6maiOBx7geMn/0aOUbJ2U7gkTif6RG6YNS5YN9ZQDLh72l/akJMxF3SlmuAPmLs2kBghQ6eD2YQKuxWR/Hf1yS1YXtogFVNsGnzC1nda7F48EGL3zI+kCajbDlAGQ32aRt0btbEQ+Gj575kir3Aa53qiZ0YOIYQlhgZdOsTN2NE2s8uuy/15Rgc6K3ydgEmSZfdqyMyW0Dy7pE5TfVL8DumKRVRXdOceT5WfnW7MyqSmdorP5ab1fw2wLOnAVzhJmW8oXXNSs77WJ1/PURclxOWB4IF8="); + public static final SkinData CANADA_HAT = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg2MDE5MDYwNzYsInByb2ZpbGVJZCI6IjdkYTJhYjNhOTNjYTQ4ZWU4MzA0OGFmYzNiODBlNjhlIiwicHJvZmlsZU5hbWUiOiJHb2xkYXBmZWwiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2M2MTExNTNmODdmMjZjMzRmOTdkODIxM2ZmOTk1ZGJlNjcyZWJkNGM0NjRkNGFkNzM5MWFlNDNjMWU3YTllIn19fQ", "QMw6e1FXl/Xrt+BbfPKsz3OHyOxL9CEPffS9grxRLD6gbLbMD84OT3+bge5V9lBFn9PPnTyID+WTF24qHj4ADTTgK94ykNedCEO6R1wS0FZKPI1UjwOxMhIG5ZeVr7+HxITgGU4Xz94IigBkvW//f2ZGelMvS0GLCrm4iCovEBMUzyYJ2dZ4xgzFSH6v+9efK4/SBAJaj8mHjXpDxU58/vskTGI3T9t5sWlZLXgId9vHcMj0GH3Un6yvUXiMkh38V/rAEM8/R8q08xUVyW0e2R38qWQV2+eKvsG8GmJmgkU/78wA9cKGZdrEz0pnr80eGNCbvXqQvC/czYhEhDapgxfndcHLX8q/Zk3I8msNr340E4ZrQL61Yl7KcVC1qEUQVu3cosq5A6ckXLGvv//HSwXVO8M9ThUbuEC8QjiS/fMFufnVa18lHrVulnfb/2KQ4yPsoCHK/zvGtRkWtD1sLOIfehN+sxCLiaz80ILBiwN0oHITfNHpJzoa4kF/OrxxCualp4Sv5o5TXBv7aWsO18v9ixb9o9CmJKKE8MUl5xmRVz4HQD4dyOfcwtPuxmfcYjJrxqBijdQMrcgLzqqMs+DUqcZZlxM7M5GaNUoEvL9tJNGpZaB2OrBw0DTk5wx15XfANCH4egx8X4+Iy2RUoFthHX3BsVazG7fjSiDnUtI="); + public static final SkinData AMERICA_HAT = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg2MDI3MjMyODgsInByb2ZpbGVJZCI6IjNlMjZiMDk3MWFjZDRjNmQ5MzVjNmFkYjE1YjYyMDNhIiwicHJvZmlsZU5hbWUiOiJOYWhlbGUiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzYzMjI0MDhkYzBiZjMxNjU4N2RiNDJiN2Q5ZmViZTUwYWQ4MGY0OGU4Njc5YzI0NTFkOTk3MTdjZmVjNTdkYWQifX19","oRo6DIuhOTaXDkFsgwJ488LWqx5d1QpwtglwG1SdEvkbX1aCMGdZyDm9YIopQRjfBg0uYKQFetOZ1ZkdMmc/aKC5/dm0+Ema7g8AUzjwf4OaSLH1r4C1UJ4ruaNG5diBxNTkYnMa7yT8zvyEr22CA7lUOIgTh8ymBfSGK35RPhsn8jM0hDjdhjemBAlxKpiioByfmAQbwokNBOrXfh/PnKq+iJYg4WpMSZ1zo5Rr0CzLXwu+/T3dvrb6mg7qry7J3Lj5/qn6iIdBcjJBeyvy1sCo45jQ3Rzc6oL/84Vu5Dpn395EqUK8Sa7mdpVpATTcj56TCjkNNtDapXNqyO/IIQuzU4wnBKNQmZefaxRl6LV0DhZ8n8YQaPj6hH/mr2oDsd23+jejjqu6Y95ReTyukp06mIGqgekmrdZV2etML2oMAOTv9ieVvqtfo5gEomYs+NFAL7rMmzjAlhd17VOgqNRMpmJazAHWOYKl8KdOH99wGDe5XcyKHysh+qyHKMvhPJztIeAEaosynF/aGHghH2PM354KCuUVNmdR5G7UZUoG9ZA5ZU3EzZ854jeqxcqw3jzb6qL7A83QNuFqOsb87ugL/jO3QEDdQ9drdf3WAQauQGkU3nYBrls5wxoMrQ+Ceth+FtZw9a1v7dc+DEWOeJKCtOAIskb29pv6OcRe0Wk="); // Comments this out for now, so it doesn't load the player profile // A better way to do this would check for the properties when getting the skull or the skin From b7a094f4729de79483c40b0cb46c81b00c98ed82 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:30:29 -0400 Subject: [PATCH 009/183] Create flag gadget type --- .../core/common/util/banner/CountryFlag.java | 57 +++++++++-- .../cosmetic/ui/button/open/OpenFlags.java | 25 +++++ .../core/cosmetic/ui/page/FlagPage.java | 62 ++++++++++++ .../core/cosmetic/ui/page/GadgetPage.java | 15 ++- .../mineplex/core/cosmetic/ui/page/Menu.java | 84 +++++++++++----- .../core/gadget/types/FlagGadget.java | 95 +++++++++++++++++++ .../core/gadget/types/GadgetType.java | 3 +- 7 files changed, 302 insertions(+), 39 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java index d4e48144f..54626d736 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java @@ -1,17 +1,30 @@ package mineplex.core.common.util.banner; import org.bukkit.DyeColor; +import org.bukkit.Material; import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.PatternType; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; + +import static org.bukkit.DyeColor.*; +import static org.bukkit.block.banner.PatternType.*; public enum CountryFlag { + // Vetted + MINEPLEX("Mineplex", "Mineplexian", BLACK, new Pattern(ORANGE, TRIANGLE_TOP), new Pattern(BLACK, TRIANGLES_TOP), + new Pattern(ORANGE, STRIPE_LEFT), new Pattern(ORANGE, STRIPE_RIGHT), new Pattern(BLACK, BORDER), + new Pattern(BLACK, STRIPE_BOTTOM)), + USA("The United States of America", "American", RED, new Pattern(WHITE, STRIPE_SMALL), new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(BLUE, SQUARE_TOP_RIGHT), new Pattern(BLUE, SQUARE_TOP_RIGHT)), + + CANADA("Canada", "Canadian", WHITE, new Pattern(RED, CROSS), new Pattern(WHITE, STRIPE_LEFT), new Pattern(RED, STRIPE_MIDDLE), + new Pattern(WHITE, BORDER), new Pattern(RED, STRIPE_TOP), new Pattern(RED, STRIPE_BOTTOM)), + + // Not Vetted BRAZIL(DyeColor.GREEN, new Pattern(DyeColor.YELLOW, PatternType.RHOMBUS_MIDDLE), new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)), - USA(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_SMALL), new Pattern(DyeColor.BLUE, PatternType.SQUARE_TOP_RIGHT)), - CANADA(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM), - new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)), UK(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNLEFT), new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNRIGHT), new Pattern(DyeColor.RED, PatternType.STRAIGHT_CROSS), new Pattern(DyeColor.RED, PatternType.CROSS)), IRELAND(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.STRIPE_TOP), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_BOTTOM)), @@ -54,17 +67,47 @@ public enum CountryFlag new Pattern(DyeColor.GREEN, PatternType.STRIPE_CENTER), new Pattern(DyeColor.BLACK, PatternType.TRIANGLE_BOTTOM)), POLAND(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.HALF_VERTICAL_MIRROR)); - private DyeColor _baseColor; - private Pattern[] _patterns; + private final String _country; + private final String _adjective; + private final DyeColor _baseColor; + private final Pattern[] _patterns; - CountryFlag(DyeColor baseColor, Pattern... patterns){ + CountryFlag(String country, String adjective, DyeColor baseColor, Pattern... patterns) + { + _country = country; + _adjective = adjective; _baseColor = baseColor; _patterns = patterns; } + CountryFlag(DyeColor baseColor, Pattern... patterns) + { + this("", "", baseColor, patterns); + } + public ItemStack getBanner() { - return UtilBanner.createBanner(_baseColor, _patterns); + ItemStack banner = new ItemStack(Material.BANNER); + BannerMeta bannerMeta = (BannerMeta) banner.getItemMeta(); + bannerMeta.setBaseColor(_baseColor); + + for (Pattern pattern : _patterns) + { + bannerMeta.addPattern(pattern); + } + + banner.setItemMeta(bannerMeta); + return banner; + } + + public String getCountryName() + { + return _country; + } + + public String getCountryAdjective() + { + return _adjective; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java new file mode 100644 index 000000000..987d549ac --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java @@ -0,0 +1,25 @@ +package mineplex.core.cosmetic.ui.button.open; + +import mineplex.core.cosmetic.ui.page.FlagPage; +import mineplex.core.cosmetic.ui.page.HatPage; +import mineplex.core.cosmetic.ui.page.Menu; +import mineplex.core.gadget.types.Gadget; +import org.bukkit.entity.Player; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class OpenFlags extends OpenPageButton +{ + public OpenFlags(Menu menu, Gadget active) + { + super(menu, active); + } + + @Override + protected void leftClick(Player player) + { + getMenu().getShop().openPageForPlayer(player, new FlagPage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(), "Flags", player)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java new file mode 100644 index 000000000..1a2b98635 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java @@ -0,0 +1,62 @@ +package mineplex.core.cosmetic.ui.page; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import java.util.List; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class FlagPage extends GadgetPage +{ + public FlagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, + Player player) + { + super(plugin, shop, clientManager, donationManager, name, player); + } + + @Override + protected void buildPage() + { + int slot = 10; + + List list = getPlugin().getGadgetManager().getGadgets(GadgetType.FLAG); + if(list != null) + for (Gadget gadget : list) + { + addGadget(gadget, slot); + + if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.FLAG) == gadget) + { + addGlow(slot); + } + + slot++; + + if (slot % 9 == 8) + { + slot += 2; + } + } + + addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + { + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index 657d98b30..12523a911 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -8,6 +8,7 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; +import mineplex.core.gadget.types.FlagGadget; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -60,12 +61,16 @@ public class GadgetPage extends ShopPageBase addGadget(gadget, slot); if (getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.getDisplayName()) > 0) + { addGlow(slot); + } slot++; - if (slot == 17 || slot == 26) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() @@ -366,7 +371,7 @@ public class GadgetPage extends ShopPageBase meta.setLore(itemLore); gadgetItemStack.setItemMeta(meta); - if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH + /*if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) { if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) @@ -377,7 +382,7 @@ public class GadgetPage extends ShopPageBase bannerMeta.setLore(meta.getLore()); gadgetItemStack.setItemMeta(bannerMeta); } - } + }*/ addButton(slot, new ShopItem(gadgetItemStack, false, false).hideInfo(), new DeactivateGadgetButton(gadget, this)); } @@ -389,7 +394,7 @@ public class GadgetPage extends ShopPageBase meta.setLore(itemLore); gadgetItemStack.setItemMeta(meta); - if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH + /*if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) { if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) @@ -400,7 +405,7 @@ public class GadgetPage extends ShopPageBase bannerMeta.setLore(meta.getLore()); gadgetItemStack.setItemMeta(bannerMeta); } - } + }*/ /*if (gadget instanceof MorphStray) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 8a27df36e..084025a09 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -1,11 +1,17 @@ package mineplex.core.cosmetic.ui.page; import java.util.ArrayList; +import java.util.Arrays; import java.util.EnumMap; import java.util.List; import java.util.Map; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.cosmetic.ui.button.open.OpenFlags; +import mineplex.core.itemstack.ItemBuilder; +import org.bukkit.DyeColor; import org.bukkit.Material; +import org.bukkit.block.Banner; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -40,6 +46,10 @@ import mineplex.core.mount.Mount; import mineplex.core.pet.PetType; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; +import org.bukkit.inventory.meta.ItemMeta; public class Menu extends ShopPageBase { @@ -64,35 +74,46 @@ public class Menu extends ShopPageBase List shardLore = new ArrayList(); shardLore.add(" "); - shardLore.add(C.cGray + "This seems like it might come in"); - shardLore.add(C.cGray + "handy. Maybe I can collect more!"); + shardLore.add(C.cGray + "These seem like they might come in"); + shardLore.add(C.cGray + "handy. Maybe I should collect more!"); ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false); - // Cosmetic Items - int[] slots = UtilUI.getIndicesFor(15, 0, 5, 1); - /*int particleSlot = 9;//slots[0]; - int arrowSlot = 11;//slots[1]; - int jumpSlot = 13;//slots[2]; - int deathSlot = 15;//slots[3]; - int gadgetSlot = 27;//slots[4]; - int morphSlot = 29;//slots[5]; - int mountSlot = 31;//slots[6]; - int petSlot = 33;//slots[7]; - int hatSlot = 35;//slots[8]; - int costumeSlot = 45;//slots[9]; - int musicSlot = 47;//slots[10]; - int tauntSlot = 49;//slots[11]; - int winEffectSlot = 51; - int gameModifierSlot = 53;*/ - int particleSlot = slots[0], arrowSlot = slots[1], jumpSlot = slots[2], - deathSlot = slots[3], gadgetSlot = slots[4], morphSlot = slots[5], - mountSlot = slots[6], petSlot = slots[7], hatSlot = slots[8], - costumeSlot = slots[9], musicSlot = slots[10], tauntSlot = slots[11], - winEffectSlot = slots[12], gameModifierSlot = slots[13], balloonsSlot = slots[14], - kitSelectorSlot = balloonsSlot + 4; + int deathSlot = 1; + int jumpSlot = 28; + int particleSlot = 10; + int winEffectSlot = 13; + int shardSlot = 22; + int arrowSlot = 19; + int tauntSlot = 31; + int gameModifierSlot = 21; + int kitSelectorSlot = 23; + int musicSlot = 48; + int mountSlot = 50; + int balloonsSlot = 47; + int petSlot = 51; + int gadgetSlot = 49; + int hatSlot = 7; + int flagSlot = 34; + int morphSlot = 25; + int costumeSlot = 16; + + addItem(shardSlot, shards); + + ItemStack pane = new ItemBuilder(Material.STAINED_GLASS_PANE).setData((byte)15).setTitle("").build(); + for (int i = 0; i <= 45; i += 9) addItem(i, pane.clone()); + for (int i = 8; i <= 53; i += 9) addItem(i, pane.clone()); + for (int i = 37; i <= 43; ++i) addItem(i, pane.clone()); + for (int i = 2; i <= 6; ++i) addItem(i, pane.clone()); + for (int i = 11; i <= 29; i += 9) addItem(i, pane.clone()); + for (int i = 15; i <= 33; i += 9) addItem(i, pane.clone()); + addItem(12, pane.clone()); + addItem(14, pane.clone()); + addItem(30, pane.clone()); + addItem(32, pane.clone()); + addItem(46, pane.clone()); + addItem(52, pane.clone()); - addItem(kitSelectorSlot + 2, shards); EnumMap ownedCount = new EnumMap<>(GadgetType.class); EnumMap maxCount = new EnumMap<>(GadgetType.class); @@ -187,7 +208,7 @@ public class Menu extends ShopPageBase if (petActive != null) addGlow(petSlot); type = GadgetType.HAT; - lore = getLore(ownedCount.get(type), maxCount.get(type), "Hats are in this year. Wear them on your head to impress the ladies.", VISIBILITY_HUB, enabled.get(type)); + lore = getLore(ownedCount.get(type), maxCount.get(type), "Hats are in this year. Wear them on your head to impress the others.", VISIBILITY_HUB, enabled.get(type)); addButton(hatSlot, new ShopItem(Material.GOLD_HELMET, "Hats", lore, 1, false), new OpenHats(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(hatSlot); @@ -227,6 +248,17 @@ public class Menu extends ShopPageBase lore = getLore(ownedCount.get(type), maxCount.get(type), "Click here to select different particles to indicate which kit you have selected!", VISIBILITY_GAME_HUB, enabled.get(type)); addButton(kitSelectorSlot, new ShopItem(Material.LEVER, "Kit Selector Particles", lore, 1, false), new OpenKitSelector(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(kitSelectorSlot); + + type = GadgetType.FLAG; + lore = getLore(ownedCount.get(type), maxCount.get(type), "Show off your country's flag!", VISIBILITY_HUB, enabled.get(type)); + addButton(flagSlot, new ShopItem(Material.BANNER, "Flags", lore, 1, false), new OpenFlags(this, enabled.get(type))); + if (enabled.containsKey(type)) addGlow(flagSlot); + BannerMeta banner = (BannerMeta) CountryFlag.MINEPLEX.getBanner().getItemMeta(); + BannerMeta meta = ((BannerMeta) getItem(flagSlot).getItemMeta()); + meta.setBaseColor(banner.getBaseColor()); + meta.setPatterns(banner.getPatterns()); + meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); + getItem(flagSlot).setItemMeta(meta); } private String[] getLore(int ownedCount, int maxCount, String info, String visibility, Gadget enabled) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java new file mode 100644 index 000000000..d28b45a17 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java @@ -0,0 +1,95 @@ +package mineplex.core.gadget.types; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.disguise.disguises.DisguiseSkeleton; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.flag.FlagType; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.itemstack.ItemBuilder; +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.LeatherArmorMeta; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class FlagGadget extends Gadget +{ + private final FlagType _flag; + + public FlagGadget(GadgetManager manager, FlagType flag) + { + super(manager, GadgetType.FLAG, flag.getFlag().getCountryAdjective() + " Flag", + UtilText.splitLineToArray(C.cGray + "The flag of " + C.cWhite + flag.getFlag().getCountryName(), LineFormat.LORE), + flag.getCost(), Material.WOOL, (byte) 0); + + setDisplayItem(flag.getFlag().getBanner()); + _flag = flag; + } + + public void applyArmor(Player player, boolean message) + { + Manager.removeGadgetType(player, GadgetType.MORPH, this); + Manager.removeGadgetType(player, GadgetType.FLAG, this); + Manager.removeOutfit(player, OutfitGadget.ArmorSlot.HELMET); + + _active.add(player); + + if (message) + { + UtilPlayer.message(player, F.main("Gadget", "You unfurled your " + F.elem(getName()) + ".")); + } + } + + public void removeArmor(Player player) + { + if (_active.remove(player)) + { + UtilPlayer.message(player, F.main("Gadget", "You put away your " + F.elem(getName()) + ".")); + } + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + ItemStack flag = _flag.getFlag().getBanner(); + ItemMeta meta = flag.getItemMeta(); + meta.setDisplayName(getDisplayName()); + flag.setItemMeta(meta); + player.getInventory().setHelmet(flag); + player.updateInventory(); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + player.getInventory().setHelmet(new ItemStack(Material.AIR)); + player.updateInventory(); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void playerDeath(PlayerDeathEvent event) + { + disable(event.getEntity()); + } + + public FlagType getFlagType() + { + return _flag; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java index edc823e6d..386f764a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java @@ -18,7 +18,8 @@ public enum GadgetType WIN_EFFECT("Win Effects", "activeWinEffect"), GAME_MODIFIER("Game Modifiers", ""), BALLOON("Balloons", ""), - KIT_SELECTOR("Kit Selectors", "activeKitSelector"); + KIT_SELECTOR("Kit Selectors", "activeKitSelector"), + FLAG("Flags", "activeFlag"); private String _name; private String _databaseKey; From c1765aaf20f765db16faa6dd2def752bd16b20da Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:30:56 -0400 Subject: [PATCH 010/183] Allow UtilParticle to accept java awt colors --- .../core/common/util/UtilParticle.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java index a87bb2565..cc58f5d0d 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java @@ -418,4 +418,22 @@ public class UtilParticle PlayParticleToAll(particleType, location, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1f, count, dist); } + public static void playColoredParticle(java.awt.Color color, ParticleType particleType, Location location, int count, ViewDist dist, Player... players) + { + if (particleType != ParticleType.RED_DUST + && particleType != ParticleType.MOB_SPELL_AMBIENT) + return; + PlayParticle(particleType, location, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1f, count, dist, players); + } + + public static void playColoredParticleToAll(java.awt.Color color, ParticleType particleType, Location location, int count, ViewDist dist) + { + if (particleType != ParticleType.RED_DUST && particleType != ParticleType.MOB_SPELL_AMBIENT) + { + return; + } + + PlayParticleToAll(particleType, location, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1f, count, dist); + } + } \ No newline at end of file From 78445551a1f22717db0ab85c2ec8e1cd4cbf6321 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:31:54 -0400 Subject: [PATCH 011/183] Reduce lag on Molten Snake --- .../src/mineplex/core/mount/types/MountTitanData.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java index 137ae9bbe..ff998efee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java @@ -39,7 +39,7 @@ public class MountTitanData extends MountData //Nodes _nodes = new ArrayList(); - for (int i=0 ; i<30 ; i++) + for (int i=0 ; i<20 ; i++) { ArmorStand node = loc.getWorld().spawn(loc, ArmorStand.class); @@ -81,7 +81,7 @@ public class MountTitanData extends MountData Location infront = _head.getLocation().add(0, -1.5, 0); //Move - for (int i=0 ; i<30 ; i++) + for (int i=0 ; i<20 ; i++) { ArmorStand node = _nodes.get(i); From 1b39a540434c0e3474653f3f06a1ef98cdfe546c Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:33:03 -0400 Subject: [PATCH 012/183] Fix gadget pages --- .../core/cosmetic/ui/page/ArrowTrailPage.java | 10 +++++++--- .../core/cosmetic/ui/page/BalloonsPage.java | 6 +++++- .../core/cosmetic/ui/page/DeathEffectPage.java | 10 +++++++--- .../core/cosmetic/ui/page/DoubleJumpPage.java | 12 ++++++++---- .../src/mineplex/core/cosmetic/ui/page/HatPage.java | 12 ++++++++---- .../core/cosmetic/ui/page/KitSelectorPage.java | 6 +++++- .../mineplex/core/cosmetic/ui/page/MorphPage.java | 12 +++++++++--- .../mineplex/core/cosmetic/ui/page/MountPage.java | 4 +++- .../mineplex/core/cosmetic/ui/page/MusicPage.java | 4 +++- .../core/cosmetic/ui/page/ParticlePage.java | 12 ++++++++---- .../src/mineplex/core/cosmetic/ui/page/PetPage.java | 13 ++++++++++--- .../mineplex/core/cosmetic/ui/page/TauntPage.java | 12 ++++++++---- .../core/cosmetic/ui/page/WinEffectPage.java | 12 ++++++++---- .../ui/page/custompet/name/CustomPetTagPage.java | 6 ++++++ 14 files changed, 95 insertions(+), 36 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java index 80db4bcd6..e4d1333f9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ArrowTrailPage.java @@ -33,12 +33,16 @@ public class ArrowTrailPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.ARROW_TRAIL) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - if (slot == 17) - slot += 2; + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java index fd0b3cf08..3208e5a05 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/BalloonsPage.java @@ -32,12 +32,16 @@ public class BalloonsPage extends GadgetPage addGadget(gadget, slot); if (gadget.isActive(getPlayer())) + { addGlow(slot); + } slot++; - if (slot == 17 || slot == 26) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java index 07dbee136..a54b7f840 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DeathEffectPage.java @@ -33,12 +33,16 @@ public class DeathEffectPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.DEATH) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - if (slot == 17) - slot += 2; + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java index f9748cb06..8ecddc541 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/DoubleJumpPage.java @@ -33,12 +33,16 @@ public class DoubleJumpPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.DOUBLE_JUMP) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 17) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java index 37f472616..a21f31cea 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/HatPage.java @@ -38,12 +38,16 @@ public class HatPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.HAT) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 17) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java index 26b399783..6ce7f5ebd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java @@ -31,12 +31,16 @@ public class KitSelectorPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.KIT_SELECTOR) == gadget) + { addGlow(slot); + } slot++; - if (slot == 17 || slot == 26 || slot == 35) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java index 682140891..0689b3f07 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MorphPage.java @@ -32,13 +32,19 @@ public class MorphPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.MORPH) == gadget) - if (!(gadget instanceof MorphBlock)) - addGlow(slot); + { + if (!(gadget instanceof MorphBlock)) + { + addGlow(slot); + } + } slot++; - if (slot == 17 || slot == 26 || slot == 35) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java index 6e670effc..0c2b2cd60 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java @@ -46,8 +46,10 @@ public class MountPage extends ShopPageBase addMount(mount, slot); slot++; - if (slot == 17 || slot == 26) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java index 54ff244d7..97f32d027 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java @@ -34,8 +34,10 @@ public class MusicPage extends GadgetPage slot++; - if (slot == 17) + if (slot % 9 == 8) + { slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java index a488c922c..168741d0a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ParticlePage.java @@ -31,12 +31,16 @@ public class ParticlePage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.PARTICLE) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 17 || slot == 26 || slot == 35) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java index e7bf684cb..264f73dbe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java @@ -231,16 +231,23 @@ public class PetPage extends ShopPageBase slot++; - if (slot == 17 || slot == 26) + if (slot % 9 == 8) + { slot += 2; + } } slot = 49; for (PetExtra petExtra : PetExtra.values()) { List itemLore = new ArrayList(); - - if (!getPlugin().getPetManager().hasActivePet(getPlayer().getName())) + + if (getPlugin().getPunishManager().GetClient(_player.getName()).IsMuted()) + { + itemLore.add(C.cRed + "You may not rename pets while muted!"); + getInventory().setItem(slot, new ShopItem(petExtra.getMaterial(), (byte)0, C.cRed + petExtra.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); + } + else if (!getPlugin().getPetManager().hasActivePet(getPlayer().getName())) { itemLore.add(C.cWhite + "You must have an active pet to use this!"); getInventory().setItem(slot, new ShopItem(petExtra.getMaterial(), (byte)0, C.cRed + petExtra.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java index 687516e0f..63ef90b24 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/TauntPage.java @@ -38,12 +38,16 @@ public class TauntPage extends GadgetPage addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.TAUNT) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 26) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java index cc116cbac..e66674be4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java @@ -49,12 +49,16 @@ public class WinEffectPage extends GadgetPage } if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.WIN_EFFECT) == gadget) - addGlow(slot); + { + addGlow(slot); + } slot++; - - if (slot == 17 || slot == 26) - slot += 2; + + if (slot % 9 == 8) + { + slot += 2; + } } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java index 774ecf2d0..2350f8eba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java @@ -1,9 +1,14 @@ package mineplex.core.cosmetic.ui.page.custompet.name; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilItem; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.punish.PunishClient; import net.minecraft.server.v1_8_R3.ItemStack; import net.minecraft.server.v1_8_R3.Items; import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; @@ -34,6 +39,7 @@ public class CustomPetTagPage extends ShopPageBase Date: Wed, 28 Jun 2017 01:34:51 -0400 Subject: [PATCH 013/183] Reorganize packages --- .../core/gadget/commands/LockInfusedCommand.java | 12 ++++++------ .../arrowtrail/{vampire => }/ArrowTrailBlood.java | 2 +- .../{candycane => }/ArrowTrailCandyCane.java | 2 +- .../arrowtrail/{party => }/ArrowTrailConfetti.java | 2 +- .../arrowtrail/{cupidslove => }/ArrowTrailCupid.java | 2 +- .../arrowtrail/{emerald => }/ArrowTrailEmerald.java | 2 +- .../arrowtrail/{wisdom => }/ArrowTrailEnchant.java | 2 +- .../arrowtrail/{freedom => }/ArrowTrailFreedom.java | 2 +- .../{frostlord => }/ArrowTrailFrostLord.java | 2 +- .../{halloween => }/ArrowTrailHalloween.java | 2 +- .../arrowtrail/{music => }/ArrowTrailMusic.java | 2 +- .../arrowtrail/{shadow => }/ArrowTrailShadow.java | 2 +- .../arrowtrail/{spring => }/ArrowTrailSpring.java | 2 +- .../{howlingwinds => }/ArrowTrailStorm.java | 2 +- .../arrowtrail/{titan => }/ArrowTrailTitan.java | 2 +- .../gadgets/death/{vampire => }/DeathBlood.java | 2 +- .../death/{candycane => }/DeathCandyCane.java | 2 +- .../{cupidslove => }/DeathCupidsBrokenHeart.java | 2 +- .../gadgets/death/{emerald => }/DeathEmerald.java | 2 +- .../gadgets/death/{wisdom => }/DeathEnchant.java | 2 +- .../gadgets/death/{freedom => }/DeathFreedom.java | 2 +- .../death/{frostlord => }/DeathFrostLord.java | 2 +- .../gadget/gadgets/death/{music => }/DeathMusic.java | 2 +- .../gadgets/death/{party => }/DeathPinataBurst.java | 2 +- .../death/{christmas => }/DeathPresentDanger.java | 2 +- .../gadgets/death/{shadow => }/DeathShadow.java | 2 +- .../gadgets/death/{spring => }/DeathSpring.java | 2 +- .../gadgets/death/{howlingwinds => }/DeathStorm.java | 2 +- .../gadget/gadgets/death/{titan => }/DeathTitan.java | 2 +- .../doublejump/{vampire => }/DoubleJumpBlood.java | 2 +- .../{candycane => }/DoubleJumpCandyCane.java | 2 +- .../{cupidslove => }/DoubleJumpCupidsWings.java | 2 +- .../doublejump/{emerald => }/DoubleJumpEmerald.java | 2 +- .../doublejump/{wisdom => }/DoubleJumpEnchant.java | 2 +- .../{party => }/DoubleJumpFirecracker.java | 2 +- .../doublejump/{freedom => }/DoubleJumpFreedom.java | 4 ++-- .../{frostlord => }/DoubleJumpFrostLord.java | 2 +- .../{halloween => }/DoubleJumpHalloween.java | 2 +- .../doublejump/{music => }/DoubleJumpMusic.java | 2 +- .../doublejump/{shadow => }/DoubleJumpShadow.java | 2 +- .../doublejump/{spring => }/DoubleJumpSpring.java | 2 +- .../{howlingwinds => }/DoubleJumpStorm.java | 2 +- .../doublejump/{titan => }/DoubleJumpTitan.java | 2 +- .../src/mineplex/core/gadget/set/SetCandyCane.java | 6 +++--- .../src/mineplex/core/gadget/set/SetCupidsLove.java | 6 +++--- .../src/mineplex/core/gadget/set/SetEmerald.java | 6 +++--- .../src/mineplex/core/gadget/set/SetFreedom.java | 9 +++++---- .../src/mineplex/core/gadget/set/SetFrostLord.java | 6 +++--- .../mineplex/core/gadget/set/SetHowlingWinds.java | 6 +++--- .../src/mineplex/core/gadget/set/SetMusic.java | 6 +++--- .../src/mineplex/core/gadget/set/SetParty.java | 6 +++--- .../src/mineplex/core/gadget/set/SetShadow.java | 6 +++--- .../src/mineplex/core/gadget/set/SetSpring.java | 6 +++--- .../src/mineplex/core/gadget/set/SetTitan.java | 6 +++--- .../src/mineplex/core/gadget/set/SetVampire.java | 6 +++--- .../src/mineplex/core/gadget/set/SetWisdom.java | 6 +++--- 56 files changed, 90 insertions(+), 89 deletions(-) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{vampire => }/ArrowTrailBlood.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{candycane => }/ArrowTrailCandyCane.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{party => }/ArrowTrailConfetti.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{cupidslove => }/ArrowTrailCupid.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{emerald => }/ArrowTrailEmerald.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{wisdom => }/ArrowTrailEnchant.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{freedom => }/ArrowTrailFreedom.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{frostlord => }/ArrowTrailFrostLord.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{halloween => }/ArrowTrailHalloween.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{music => }/ArrowTrailMusic.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{shadow => }/ArrowTrailShadow.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{spring => }/ArrowTrailSpring.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{howlingwinds => }/ArrowTrailStorm.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/{titan => }/ArrowTrailTitan.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{vampire => }/DeathBlood.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{candycane => }/DeathCandyCane.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{cupidslove => }/DeathCupidsBrokenHeart.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{emerald => }/DeathEmerald.java (93%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{wisdom => }/DeathEnchant.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{freedom => }/DeathFreedom.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{frostlord => }/DeathFrostLord.java (93%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{music => }/DeathMusic.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{party => }/DeathPinataBurst.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{christmas => }/DeathPresentDanger.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{shadow => }/DeathShadow.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{spring => }/DeathSpring.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{howlingwinds => }/DeathStorm.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/{titan => }/DeathTitan.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{vampire => }/DoubleJumpBlood.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{candycane => }/DoubleJumpCandyCane.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{cupidslove => }/DoubleJumpCupidsWings.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{emerald => }/DoubleJumpEmerald.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{wisdom => }/DoubleJumpEnchant.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{party => }/DoubleJumpFirecracker.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{freedom => }/DoubleJumpFreedom.java (92%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{frostlord => }/DoubleJumpFrostLord.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{halloween => }/DoubleJumpHalloween.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{music => }/DoubleJumpMusic.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{shadow => }/DoubleJumpShadow.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{spring => }/DoubleJumpSpring.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{howlingwinds => }/DoubleJumpStorm.java (94%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/{titan => }/DoubleJumpTitan.java (96%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java index fef74b9fd..a91dcdb3e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java @@ -9,12 +9,12 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; -import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; -import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; -import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.death.DeathCandyCane; +import mineplex.core.gadget.gadgets.death.DeathFrostLord; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; import mineplex.core.gadget.gadgets.hat.HatType; import mineplex.core.gadget.gadgets.item.ItemCoal; import mineplex.core.gadget.gadgets.item.ItemFreezeCannon; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/vampire/ArrowTrailBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBlood.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/vampire/ArrowTrailBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBlood.java index f54c9ae92..180e336de 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/vampire/ArrowTrailBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.vampire; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java index d45b1b023..58cbee4d9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.candycane; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/party/ArrowTrailConfetti.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailConfetti.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/party/ArrowTrailConfetti.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailConfetti.java index d8f06ce45..be2cd9b90 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/party/ArrowTrailConfetti.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailConfetti.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.party; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCupid.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCupid.java index c10562f6d..4249c19c3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailCupid.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.cupidslove; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Color; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/emerald/ArrowTrailEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEmerald.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/emerald/ArrowTrailEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEmerald.java index 8592bc16b..b7b8a6df2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/emerald/ArrowTrailEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.emerald; +package mineplex.core.gadget.gadgets.arrowtrail; import mineplex.core.common.util.*; import org.bukkit.Location; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/wisdom/ArrowTrailEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEnchant.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/wisdom/ArrowTrailEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEnchant.java index 00e47e049..b33723020 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/wisdom/ArrowTrailEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.wisdom; +package mineplex.core.gadget.gadgets.arrowtrail; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFreedom.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFreedom.java index 8921b26cc..fa5f7ade2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/freedom/ArrowTrailFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFreedom.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.freedom; +package mineplex.core.gadget.gadgets.arrowtrail; import java.awt.Color; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/frostlord/ArrowTrailFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/frostlord/ArrowTrailFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java index 6ae8d9b43..3a7c910b5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/frostlord/ArrowTrailFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.frostlord; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java index 112f272ad..bd5b62563 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.halloween; +package mineplex.core.gadget.gadgets.arrowtrail; import java.awt.Color; import java.util.HashMap; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/music/ArrowTrailMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailMusic.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/music/ArrowTrailMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailMusic.java index d535035af..6c6a3006e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/music/ArrowTrailMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.music; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/shadow/ArrowTrailShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailShadow.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/shadow/ArrowTrailShadow.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailShadow.java index aec688901..8db14cbdb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/shadow/ArrowTrailShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailShadow.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.shadow; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailSpring.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailSpring.java index c335ce062..59cb064c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailSpring.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.spring; +package mineplex.core.gadget.gadgets.arrowtrail; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/howlingwinds/ArrowTrailStorm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailStorm.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/howlingwinds/ArrowTrailStorm.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailStorm.java index a3cc14165..084611017 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/howlingwinds/ArrowTrailStorm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailStorm.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.howlingwinds; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java index 956055929..29c39b7d0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/titan/ArrowTrailTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail.titan; +package mineplex.core.gadget.gadgets.arrowtrail; import org.bukkit.Material; import org.bukkit.entity.Arrow; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/vampire/DeathBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBlood.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/vampire/DeathBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBlood.java index 5365e3e14..7101aba36 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/vampire/DeathBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.vampire; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/candycane/DeathCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/candycane/DeathCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java index 45a7028d0..2d100b3fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/candycane/DeathCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.candycane; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/cupidslove/DeathCupidsBrokenHeart.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCupidsBrokenHeart.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/cupidslove/DeathCupidsBrokenHeart.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCupidsBrokenHeart.java index 1c92abc02..d0053f9df 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/cupidslove/DeathCupidsBrokenHeart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathCupidsBrokenHeart.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.cupidslove; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/emerald/DeathEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEmerald.java similarity index 93% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/emerald/DeathEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEmerald.java index 79ea0b404..85fb2db18 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/emerald/DeathEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.emerald; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/wisdom/DeathEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEnchant.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/wisdom/DeathEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEnchant.java index 7229b155d..35532906d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/wisdom/DeathEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.wisdom; +package mineplex.core.gadget.gadgets.death; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/freedom/DeathFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFreedom.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/freedom/DeathFreedom.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFreedom.java index 24d43eb0b..137b68207 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/freedom/DeathFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFreedom.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.freedom; +package mineplex.core.gadget.gadgets.death; import org.bukkit.ChatColor; import org.bukkit.Location; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/frostlord/DeathFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFrostLord.java similarity index 93% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/frostlord/DeathFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFrostLord.java index 0ce7b546f..72cd2c3cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/frostlord/DeathFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.frostlord; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/music/DeathMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMusic.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/music/DeathMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMusic.java index 2bf566254..d6c4176ad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/music/DeathMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.music; +package mineplex.core.gadget.gadgets.death; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/party/DeathPinataBurst.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPinataBurst.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/party/DeathPinataBurst.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPinataBurst.java index 09ccfe10a..0adc3dfb8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/party/DeathPinataBurst.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPinataBurst.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.party; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/christmas/DeathPresentDanger.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPresentDanger.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/christmas/DeathPresentDanger.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPresentDanger.java index e8db5ed6a..c1b07ce33 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/christmas/DeathPresentDanger.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathPresentDanger.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.christmas; +package mineplex.core.gadget.gadgets.death; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/shadow/DeathShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathShadow.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/shadow/DeathShadow.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathShadow.java index 3adb240f2..f80b4ad9b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/shadow/DeathShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathShadow.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.shadow; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathSpring.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathSpring.java index eb15f5986..bae34473b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathSpring.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.spring; +package mineplex.core.gadget.gadgets.death; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/howlingwinds/DeathStorm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathStorm.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/howlingwinds/DeathStorm.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathStorm.java index 00cf6d607..c3cf2f0da 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/howlingwinds/DeathStorm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathStorm.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.howlingwinds; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java index 00b64eace..0e56f8308 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/titan/DeathTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.death.titan; +package mineplex.core.gadget.gadgets.death; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/vampire/DoubleJumpBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBlood.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/vampire/DoubleJumpBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBlood.java index 882133687..2f910416c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/vampire/DoubleJumpBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.vampire; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/candycane/DoubleJumpCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/candycane/DoubleJumpCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java index d6a7620c7..62f3ad6c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/candycane/DoubleJumpCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.candycane; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/cupidslove/DoubleJumpCupidsWings.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCupidsWings.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/cupidslove/DoubleJumpCupidsWings.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCupidsWings.java index 71a7b66b5..81884a52b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/cupidslove/DoubleJumpCupidsWings.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCupidsWings.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.cupidslove; +package mineplex.core.gadget.gadgets.doublejump; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/emerald/DoubleJumpEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEmerald.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/emerald/DoubleJumpEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEmerald.java index 0453e0b57..f74859c2c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/emerald/DoubleJumpEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.emerald; +package mineplex.core.gadget.gadgets.doublejump; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/wisdom/DoubleJumpEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEnchant.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/wisdom/DoubleJumpEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEnchant.java index ec1120f3b..d9d4db576 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/wisdom/DoubleJumpEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.wisdom; +package mineplex.core.gadget.gadgets.doublejump; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/party/DoubleJumpFirecracker.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFirecracker.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/party/DoubleJumpFirecracker.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFirecracker.java index 06ee124f7..65ce9bd80 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/party/DoubleJumpFirecracker.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFirecracker.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.party; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/freedom/DoubleJumpFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java similarity index 92% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/freedom/DoubleJumpFreedom.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java index 7f887e345..820ccd155 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/freedom/DoubleJumpFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFreedom.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.freedom; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -18,7 +18,7 @@ public class DoubleJumpFreedom extends DoubleJumpEffectGadget { super(manager, "Leap of Freedom", UtilText.splitLineToArray(UtilText.colorWords("FREEEEEEEEEEEDOM!", ChatColor.RED, ChatColor.WHITE, ChatColor.BLUE), LineFormat.LORE), -8, Material.WOOL, - (byte) 14); + (byte) 0); setDisplayItem(CountryFlag.USA.getBanner()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/frostlord/DoubleJumpFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFrostLord.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/frostlord/DoubleJumpFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFrostLord.java index 62325731c..64cc9f962 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/frostlord/DoubleJumpFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.frostlord; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java index 10155afbd..0f2cc13e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.halloween; +package mineplex.core.gadget.gadgets.doublejump; import java.awt.Color; import java.util.HashMap; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/music/DoubleJumpMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMusic.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/music/DoubleJumpMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMusic.java index 5b7459f0d..2a4d5c1ba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/music/DoubleJumpMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.music; +package mineplex.core.gadget.gadgets.doublejump; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/shadow/DoubleJumpShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpShadow.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/shadow/DoubleJumpShadow.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpShadow.java index 005c3403c..c64052bca 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/shadow/DoubleJumpShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpShadow.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.shadow; +package mineplex.core.gadget.gadgets.doublejump; import mineplex.core.common.util.C; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java index 63dabdaf9..c4d06c230 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.spring; +package mineplex.core.gadget.gadgets.doublejump; import java.util.ArrayList; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/howlingwinds/DoubleJumpStorm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpStorm.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/howlingwinds/DoubleJumpStorm.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpStorm.java index 6b04d1f00..9cd07ef15 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/howlingwinds/DoubleJumpStorm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpStorm.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.howlingwinds; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java index 336aaa5bc..9c81a3309 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/titan/DoubleJumpTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump.titan; +package mineplex.core.gadget.gadgets.doublejump; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java index e6f6f5707..9a2d9ce75 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; -import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.death.DeathCandyCane; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java index ccbaf0863..47f1552f7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; -import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart; -import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; +import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java index b34a8f88e..740174dba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; -import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald; -import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; +import mineplex.core.gadget.gadgets.death.DeathEmerald; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java index 6196a145b..e8c300adf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java @@ -1,9 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; -import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.death.DeathFreedom; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; import mineplex.core.gadget.types.GadgetSet; @@ -16,7 +17,7 @@ public class SetFreedom extends GadgetSet manager.getGadget(ArrowTrailFreedom.class), manager.getGadget(DeathFreedom.class), manager.getGadget(DoubleJumpFreedom.class), - manager.getGadget(ParticleFreedom.class)); + manager.getGadget(ParticleStarSpangled.class)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java index 6112655a0..6050a0b00 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; -import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.death.DeathFrostLord; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java index 120a35c95..672f49bdc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; -import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; -import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; +import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java index 9e606f0e2..fdd47eacd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.death.music.DeathMusic; -import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; +import mineplex.core.gadget.gadgets.death.DeathMusic; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java index f9debaef0..0b99f9f2e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; -import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst; -import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.death.DeathPinataBurst; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java index befc2e27c..1d5fad5dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; -import mineplex.core.gadget.gadgets.death.shadow.DeathShadow; -import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; +import mineplex.core.gadget.gadgets.death.DeathShadow; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java index 77727b480..fb21b5f9e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.spring.ArrowTrailSpring; -import mineplex.core.gadget.gadgets.death.spring.DeathSpring; -import mineplex.core.gadget.gadgets.doublejump.spring.DoubleJumpSpring; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; +import mineplex.core.gadget.gadgets.death.DeathSpring; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java index 7c66a8f6c..0d333818d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.titan.ArrowTrailTitan; -import mineplex.core.gadget.gadgets.death.titan.DeathTitan; -import mineplex.core.gadget.gadgets.doublejump.titan.DoubleJumpTitan; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailTitan; +import mineplex.core.gadget.gadgets.death.DeathTitan; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan; import mineplex.core.gadget.gadgets.particle.titan.ParticleTitan; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java index b070122de..7ec9b7f7a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; -import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; -import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; +import mineplex.core.gadget.gadgets.death.DeathBlood; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; import mineplex.core.gadget.types.GadgetSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java index 2d2ff0693..870b70d3f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java @@ -1,9 +1,9 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; -import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; +import mineplex.core.gadget.gadgets.death.DeathEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; import mineplex.core.gadget.types.GadgetSet; From 3c929a4b00250de2aa6122e4f61437f9b3949b22 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:35:22 -0400 Subject: [PATCH 014/183] Update hat and flag type enums --- .../core/gadget/gadgets/flag/FlagType.java | 34 +++++++++++++++++++ .../core/gadget/gadgets/hat/HatType.java | 6 +++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java new file mode 100644 index 000000000..7e2c48e28 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java @@ -0,0 +1,34 @@ +package mineplex.core.gadget.gadgets.flag; + +import mineplex.core.common.util.banner.CountryFlag; + +/** + * @author J Teissler + * @date 6/27/17 + */ +public enum FlagType +{ + UNITED_STATES(CountryFlag.USA, -8), + CANADA(CountryFlag.CANADA, -8), + + ; + + private final CountryFlag _flag; + private final int _cost; + + FlagType(CountryFlag flag, int cost) + { + _flag = flag; + _cost = cost; + } + + public CountryFlag getFlag() + { + return _flag; + } + + public int getCost() + { + return _cost; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java index c6f623e20..cabad2568 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatType.java @@ -22,7 +22,11 @@ public enum HatType SNOWMAN("Snowman Head", UtilText.splitLineToArray(C.cGray + "Do you want to be a snowman?", LineFormat.LORE), -2, SkinData.SNOWMAN), TEDDY_BEAR("Teddy Bear", UtilText.splitLineToArray(C.cGray + "Aww, it's a cute teddy bear! What shall I name him?", LineFormat.LORE), -6, SkinData.TEDDY_BEAR), UNCLE_SAM("Uncle Sam Hat", UtilText.splitLineToArray(UtilText.colorWords("Uncle Sam has a big hat but now you can too.", ChatColor.RED, ChatColor.WHITE, ChatColor.BLUE), LineFormat.LORE), -8, SkinData.UNCLE_SAM), - PUMPKIN("Pumpkin Hat", UtilText.splitLineToArray(C.cGray + "Pumpkin on the head, don't end up dead!", LineFormat.LORE), -9, Material.PUMPKIN); + PUMPKIN("Pumpkin Hat", UtilText.splitLineToArray(C.cGray + "Pumpkin on the head, don't end up dead!", LineFormat.LORE), -9, Material.PUMPKIN), + CANADA("Warm Canadian Hat", UtilText.splitLineToArray(C.cGray + "Keep your ears nice and warm while up north.", LineFormat.LORE), -8, SkinData.CANADA_HAT), + AMERICA("Patriotic American Hat", UtilText.splitLineToArray(C.cGray + "Careful not to get a big head.", LineFormat.LORE), -8, SkinData.AMERICA_HAT), + + ; private final String _name; private final String[] _lore; From 3d430dedf6c91c50719dc00139286d339d874ce4 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:35:57 -0400 Subject: [PATCH 015/183] Add new cosmetic items --- .../core/common/shape/ShapeWings.java | 35 +++- .../arrowtrail/ArrowTrailRedWhite.java | 78 ++++++++ .../gadget/gadgets/death/DeathMapleLeaf.java | 44 +++++ .../gadgets/doublejump/DoubleJumpMaple.java | 114 ++++++++++++ .../particle/ParticleAuraNiceness.java | 176 ++++++++++++++++++ .../gadgets/particle/ParticleCanadian.java | 68 +++++++ .../particle/ParticleFreedomFireworks.java | 57 ++++++ .../particle/ParticleStarSpangled.java | 80 ++++++++ .../mineplex/core/gadget/set/SetCanadian.java | 26 +++ 9 files changed, 677 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleAuraNiceness.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCanadian.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFreedomFireworks.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleStarSpangled.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java index 3c9a78a56..4026dad3f 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java @@ -166,7 +166,40 @@ public class ShapeWings extends ShapeGrid implements CosmeticShape "0$#######$0", "$#########$" }; - + + public static final String[] MAPLE_LEAF = new String[] + { + "000000000000000000000000000$000000000000000000000000000", + "00000000000000000000000000$$$00000000000000000000000000", + "0000000000000000000000000$$#$$0000000000000000000000000", + "000000000000000000000000$$###$$000000000000000000000000", + "00000000000000000000000$$#####$$00000000000000000000000", + "0000000000000000$$$000$$#######$$000$$$0000000000000000", + "0000000000000000$#$$$$$#########$$$$$#$0000000000000000", + "0000000000000000$$###################$$0000000000000000", + "00000000000000000$###################$00000000000000000", + "00000000000$$0000$$#################$$0000$$00000000000", + "0$$$000000$$$$$000$#################$000$$$$$000000$$$0", + "00$$$$$$$$$###$$$0$$###############$$0$$$###$$$$$$$$$00", + "00$$############$$$$###############$$$$############$$00", + "000$$#############$$###############$$#############$$000", + "0000$$###########################################$$0000", + "00$$$#############################################$$$00", + "$$$#################################################$$$", + "00$$$$###########################################$$$$00", + "00000$$$#######################################$$$00000", + "00000000$$$$###############################$$$$00000000", + "00000000000$$$###########################$$$00000000000", + "0000000000000$$#########################$$0000000000000", + "0000000000000$$#########################$$0000000000000", + "0000000000000$##$$$$$$$$$$$#$$$$$$$$$$$##$0000000000000", + "000000000000$$$$$000000000$#$000000000$$$$$000000000000", + "00000000000000000000000000$#$00000000000000000000000000", + "00000000000000000000000000$#$00000000000000000000000000", + "00000000000000000000000000$#$00000000000000000000000000", + "00000000000000000000000000$#$00000000000000000000000000", + "00000000000000000000000000$$$00000000000000000000000000" + }; /** * Default rotation to give the wings a little tilt when displayed on players for instance diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java new file mode 100644 index 000000000..e9a3c19e1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java @@ -0,0 +1,78 @@ +package mineplex.core.gadget.gadgets.arrowtrail; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ArrowEffectGadget; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.banner.Pattern; +import org.bukkit.entity.Arrow; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; +import org.bukkit.util.Vector; + +import java.awt.*; + +public class ArrowTrailRedWhite extends ArrowEffectGadget +{ + public ArrowTrailRedWhite(GadgetManager manager) + { + super(manager, "Red & White Arrows", + UtilText.splitLineToArray(C.cRed + "Killing you nicely.", LineFormat.LORE), + -8, Material.WOOL, (byte)0); + + setDisplayItem(CountryFlag.CANADA.getBanner()); + } + + @Override + public void doTrail(Arrow arrow) + { + Vector v = arrow.getVelocity(); + Vector up = UtilAlg.getUp(v); + Vector left = UtilAlg.getLeft(v); + + Location loc = arrow.getLocation(); + + double amount = 2; + double ticks = 15; + + for(int i = 0; i < amount; i++) + { + double rad = Math.PI*2.0; + rad += i/amount * rad; + rad += Math.PI*2*(arrow.getTicksLived()%ticks)/ticks; + double l = -Math.sin(rad); + double u = Math.cos(rad); + + Vector vel = v.clone().add(up.clone().multiply(u)).add(left.clone().multiply(l)); + vel.multiply(0.4); + + if (i == 0) + { + for(int j = 0; j < 3; ++j) + { + UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, loc.clone().add(vel), 0, UtilParticle.ViewDist.NORMAL); + } + } + else + { + for(int j = 0; j < 3; ++j) + { + UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, loc.clone().add(vel), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + } + + @Override + public void doHitEffect(Arrow arrow) + { + //UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, arrow.getLocation(), 0.35f, 0.35f, 0.35f, 1f, 15, UtilParticle.ViewDist.LONGER); + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, arrow.getLocation(), 0, 0, 0, 0, 3, UtilParticle.ViewDist.LONGER); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java new file mode 100644 index 000000000..b1a0e9955 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java @@ -0,0 +1,44 @@ +package mineplex.core.gadget.gadgets.death; + +import mineplex.core.blood.BloodEvent; +import mineplex.core.common.shape.ShapeWings; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.DeathEffectGadget; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class DeathMapleLeaf extends DeathEffectGadget +{ + private final ShapeWings _leafOuter = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1.0, 0, 0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); + private final ShapeWings _leafInner = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0.7, 0, 0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); + + public DeathMapleLeaf(GadgetManager manager) + { + super(manager, "Fallen Maple Leaf", + UtilText.splitLineToArray(C.cGray + "When you die in " + C.cRed + "Canada" + C.cGray + " you die in real life.", LineFormat.LORE), + -8, Material.WOOL, (byte) 0); + + setDisplayItem(CountryFlag.CANADA.getBanner()); + } + + @Override + public void onBlood(Player player, BloodEvent event) + { + event.setCancelled(true); + Location loc = player.getLocation().add(0, 3, 0); + _leafOuter.display(loc); + _leafInner.display(loc); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java new file mode 100644 index 000000000..1b1396463 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java @@ -0,0 +1,114 @@ +package mineplex.core.gadget.gadgets.doublejump; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.DoubleJumpEffectGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class DoubleJumpMaple extends DoubleJumpEffectGadget +{ + /** + * Amount of particles played per tick as a player flies through the air. + */ + private static final int PARTICLES = 50; + + /** + * Vertical offset of the animation's center from the player's location. + */ + private static final float Y_OFFSET = 0.95f; + + /** + * Divisor of the gaussian distribution of particles as the player flies through the air. + */ + private static final int DISTRIBUTION = 2; + + /** + * Particle ring count when a player launches from the ground. + */ + private static final int LAUNCH_RINGS = 6; + + /** + * The distance between launch rings. + */ + private static final float RING_SPACING = 0.4f; + + /** + * Particles played per 1 unit radius. + */ + private static final int RING_DENSITY = 8; + + private HashMap _playerMap = new HashMap<>(); + + public DoubleJumpMaple(GadgetManager manager) + { + super(manager, "Maple Leap", + UtilText.splitLineToArray(C.cGray + "Jump higher than the maple trees!", LineFormat.LORE), + -8, Material.WOOL, (byte)0); + setDisplayItem(CountryFlag.CANADA.getBanner()); + } + + @Override + public void doEffect(Player player) + { + _playerMap.put(player, System.currentTimeMillis() + 1000); + + float limit = (LAUNCH_RINGS * RING_SPACING) + RING_SPACING; + + for (float r = RING_SPACING; r < limit; r++) + { + double[][] points = UtilMath.normalCircle(player.getLocation(), player.getVelocity(), r, Math.round(RING_DENSITY * r)); + + for (int i = 0; i < points.length; i++) + { + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, new Location(player.getWorld(), points[i][0], points[i][1], points[i][2]), + null, 0, 1, UtilParticle.ViewDist.NORMAL); + } + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if(event.getType() != UpdateType.FASTEST) + { + return; + } + + for(Iterator> it = _playerMap.entrySet().iterator(); it.hasNext();) + { + Map.Entry e = it.next(); + + if(e.getValue() <= System.currentTimeMillis()) + { + it.remove(); + continue; + } + + Location loc = e.getKey().getLocation().add(0, Y_OFFSET, 0); + + for (int i = 0; i < PARTICLES; ++i) + { + UtilParticle.playColoredParticleToAll(java.awt.Color.RED, UtilParticle.ParticleType.RED_DUST, + UtilMath.gauss(loc, DISTRIBUTION, DISTRIBUTION, DISTRIBUTION), 0, UtilParticle.ViewDist.NORMAL); + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleAuraNiceness.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleAuraNiceness.java new file mode 100644 index 000000000..39b20d946 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleAuraNiceness.java @@ -0,0 +1,176 @@ +package mineplex.core.gadget.gadgets.particle; + +import mineplex.core.arcadeevents.CoreGameStartEvent; +import mineplex.core.arcadeevents.CoreGameStopEvent; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilSound; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.treasure.event.TreasureFinishEvent; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + +import java.awt.Color; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; +import java.util.stream.Collectors; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class ParticleAuraNiceness extends ParticleGadget +{ + /** Radius within which flowers not allowed near treasure chests */ + private static final int TREASURE_RADIUS = 4; + + private static final double H_FIELD = 0.5; + private static final double V_FIELD = 0.35; + private static final int ROSE_PROBABILITY = 30; + private static final double ROSE_RADIUS = 2.5; + + private final Set _blocks = new HashSet<>(); + + /** Locations at which treasure is currently being opened */ + private final Map _openingTreasure = new HashMap<>(); + + private boolean _enabled = true; + + public ParticleAuraNiceness(GadgetManager manager) + { + super(manager, "Aura of Niceness", + UtilText.splitLineToArray(C.cGray + "Canadians are always nice online.", LineFormat.LORE), -8, Material.WOOL, + (byte) 0); + + setDisplayItem(CountryFlag.CANADA.getBanner()); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + { + return; + } + + for (Location location : _openingTreasure.values()) + { + if (location.toVector().isInSphere(player.getLocation().toVector(), TREASURE_RADIUS)) + { + return; + } + } + + UtilShapes.getCircle(player.getLocation().subtract(0, 0.5, 0), false, ROSE_RADIUS).stream().map(Location::getBlock) + .collect(Collectors.toSet()).forEach(block -> + { + if (ThreadLocalRandom.current().nextInt(ROSE_PROBABILITY) == 0) + { + Block b = block.getRelative(BlockFace.UP); + + if (b.isEmpty() && UtilBlock.fullSolid(block) && !UtilBlock.bottomSlab(block)) + { + Location loc = b.getLocation().add(H_FIELD, V_FIELD, H_FIELD); + + if (_enabled) + { + _blocks.add(b); + Manager.getBlockRestore().add(b, Material.RED_ROSE.getId(), (byte) 3, 5000); + } + + for (int i = 0; i < 20; ++i) + { + UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 4, 4, 4), 0, UtilParticle.ViewDist.NORMAL); + UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 4, 4, 4), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + }); + + for(Iterator it = _blocks.iterator(); it.hasNext();) + { + Block b = it.next(); + + if (b.getType() != Material.RED_ROSE) + { + it.remove(); + Location loc = b.getLocation().add(H_FIELD, V_FIELD, H_FIELD); + for (int i = 0; i < 10; ++i) + { + UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 6, 6, 6), 0, UtilParticle.ViewDist.NORMAL); + UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 6, 6, 6), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + } + + @EventHandler + public void onBlockFade(BlockPhysicsEvent event) + { + if (_blocks.contains(event.getBlock())) + { + event.setCancelled(true); + } + } + + /** + * Disable flowers in the area around treasure being opened. + */ + @EventHandler(priority = EventPriority.LOW) + public void disableOnTreasureStart(TreasureStartEvent event) + { + _openingTreasure.put(event.getPlayer().getUniqueId(), event.getPlayer().getLocation()); + Manager.getBlockRestore().restoreBlockAround(Material.CARPET, event.getPlayer().getLocation(), TREASURE_RADIUS); + } + + /** + * Enable flowers in the area around treasure no longer being opened. + */ + @EventHandler(priority = EventPriority.HIGH) + public void enableOnTreasureFinish(TreasureFinishEvent event) + { + if (_openingTreasure.containsKey(event.getPlayer().getUniqueId())) + { + _openingTreasure.remove(event.getPlayer().getUniqueId()); + } + } + + @EventHandler + public void onGameStart(CoreGameStartEvent event) + { + _enabled = false; + } + + @EventHandler + public void onGameEnd(CoreGameStopEvent event) + { + _enabled = true; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCanadian.java new file mode 100644 index 000000000..10f87fe29 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCanadian.java @@ -0,0 +1,68 @@ +package mineplex.core.gadget.gadgets.particle; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; + +import java.awt.Color; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class ParticleCanadian extends ParticleGadget +{ + private static final int STRAND_COUNT = 9; + private static final double STRAND_SPACING = 0.124; + private static final double DISTANCE_FROM_FLOOR = 0.43; + + public ParticleCanadian(GadgetManager manager) + { + super(manager, "Canadian Trail", + UtilText.splitLineToArray(C.cGray + "Lead the way to freedom!", LineFormat.LORE), + -8, Material.WOOL, (byte) 0); + + ItemStack stack = CountryFlag.CANADA.getBanner(); + System.out.println(((BannerMeta)stack.getItemMeta()).getBaseColor().getColor().toString()); + setDisplayItem(stack); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Location center = player.getLocation().add(0, DISTANCE_FROM_FLOOR, 0); + + if (Manager.isMoving(player)) + { + for (int i = 0; i < STRAND_COUNT; i++) + { + if (i < 3 || i > 5) + { + UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, + center.add(0, STRAND_SPACING, 0), 0, UtilParticle.ViewDist.NORMAL); + } + else + { + UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, + center.add(0, STRAND_SPACING, 0), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFreedomFireworks.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFreedomFireworks.java new file mode 100644 index 000000000..92721b705 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFreedomFireworks.java @@ -0,0 +1,57 @@ +package mineplex.core.gadget.gadgets.particle; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import java.util.concurrent.ThreadLocalRandom; + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class ParticleFreedomFireworks extends ParticleGadget +{ + private static final Material[] BLOCKTYPES = { + Material.REDSTONE_BLOCK, + Material.LAPIS_BLOCK, + Material.QUARTZ_BLOCK + }; + + public ParticleFreedomFireworks(GadgetManager manager) + { + super(manager, "Freedom Fireworks", + UtilText.splitLineToArray(C.cGray + "Keep your patriotism close.", LineFormat.LORE), + -8, Material.WOOL, (byte) 0); + + setDisplayItem(CountryFlag.USA.getBanner()); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + String particle = UtilParticle.ParticleType.BLOCK_CRACK.getParticle(BLOCKTYPES[ThreadLocalRandom.current().nextInt(0, BLOCKTYPES.length)], 0); + Location location = UtilMath.gauss(player.getEyeLocation(), 1, 1, 1); + + for (int i = 0; i < 20; ++i) + { + UtilParticle.PlayParticleToAll(particle, location, null, 3.0f, 1, UtilParticle.ViewDist.NORMAL); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleStarSpangled.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleStarSpangled.java new file mode 100644 index 000000000..ead0bc411 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleStarSpangled.java @@ -0,0 +1,80 @@ +package mineplex.core.gadget.gadgets.particle; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import java.awt.*; + + +/** + * @author J Teissler + * @date 6/26/17 + */ +public class ParticleStarSpangled extends ParticleGadget +{ + private static final int STRAND_COUNT = 9; + private static final double STRAND_SPACING = 0.124; + private static final double DISTANCE_FROM_FLOOR = 0.43; + + private static final Color BLUE = new Color(29, 26, 120); + + public ParticleStarSpangled(GadgetManager manager) + { + super(manager, "Star Spangled Stripe", + UtilText.splitLineToArray(C.cGray + "Blaze a trail of freedom!", LineFormat.LORE), + -8, Material.WOOL, (byte) 0); + setDisplayItem(CountryFlag.USA.getBanner()); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Location center = player.getLocation().add(0, DISTANCE_FROM_FLOOR, 0); + + if (Manager.isMoving(player)) + { + for (int i = 0; i < STRAND_COUNT; i++) + { + if (i == 3 || i == 7) + { + if (player.getTicksLived() % 3 == 0) + { + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.FIREWORKS_SPARK, + center.add(0, STRAND_SPACING, 0), 0f, 0f, 0f, 0f, 0, UtilParticle.ViewDist.NORMAL); + continue; + } + } + else if (i == 5) + { + if (player.getTicksLived() + 1 % 3 == 0) + { + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.FIREWORKS_SPARK, + center.add(0, STRAND_SPACING, 0), 0f, 0f, 0f, 0f, 0, UtilParticle.ViewDist.NORMAL); + continue; + } + } + + UtilParticle.playColoredParticleToAll(BLUE, UtilParticle.ParticleType.RED_DUST, + center.add(0, STRAND_SPACING, 0), 0, UtilParticle.ViewDist.NORMAL); + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java new file mode 100644 index 000000000..a295bb9da --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java @@ -0,0 +1,26 @@ +package mineplex.core.gadget.set; + +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; +import mineplex.core.gadget.gadgets.death.DeathFreedom; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; +import mineplex.core.gadget.gadgets.particle.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; +import mineplex.core.gadget.types.GadgetSet; + +public class SetCanadian extends GadgetSet +{ + + public SetCanadian(GadgetManager manager) + { + super(manager, "Canadian", "2x Holiday Points while active (Titles)", + manager.getGadget(ArrowTrailRedWhite.class), + manager.getGadget(DeathMapleLeaf.class), + manager.getGadget(DoubleJumpMaple.class), + manager.getGadget(ParticleCanadian.class)); + } + +} From e599f1653c63bc606ffa1ed8b35431fcc4294ba6 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:36:21 -0400 Subject: [PATCH 016/183] Allow Flags to interact with costumes and hats correctly --- .../src/mineplex/core/gadget/types/HatGadget.java | 2 +- .../src/mineplex/core/gadget/types/MorphGadget.java | 3 ++- .../src/mineplex/core/gadget/types/OutfitGadget.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java index b6becadc1..38df4c367 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/HatGadget.java @@ -47,7 +47,7 @@ public abstract class HatGadget extends OutfitGadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); - + Manager.removeGadgetType(player, GadgetType.FLAG, this); Manager.removeOutfit(player, _slot); _active.add(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java index 4fb2b5ed9..7240ed1d5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java @@ -26,7 +26,8 @@ public abstract class MorphGadget extends Gadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); - Manager.removeGadgetType(player, GadgetType.COSTUME); + Manager.removeGadgetType(player, GadgetType.COSTUME, this); + Manager.removeGadgetType(player, GadgetType.FLAG, this); _active.add(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java index 6ce4d70b7..e5ab85cb3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java @@ -60,7 +60,7 @@ public abstract class OutfitGadget extends Gadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); - + Manager.removeGadgetType(player, GadgetType.FLAG, this); Manager.removeOutfit(player, _slot); _active.add(player); From 3d4fc5fa9c5968fde0096d8c795ee7668fa8e6b9 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:36:49 -0400 Subject: [PATCH 017/183] Add cosmetics to chests --- .../core/cosmetic/CosmeticManager.java | 26 ++- .../mineplex/core/gadget/GadgetManager.java | 163 +++++++++++------- .../mineplex/core/reward/RewardManager.java | 112 +++++++----- .../core/treasure/gui/TreasurePage.java | 66 +++++-- 4 files changed, 249 insertions(+), 118 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java index d1ae7b491..9f0552d86 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java @@ -1,5 +1,7 @@ package mineplex.core.cosmetic; +import mineplex.core.chat.Chat; +import mineplex.core.punish.Punish; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -41,19 +43,23 @@ import mineplex.core.twofactor.TwoFactorAuth; public class CosmeticManager extends MiniPlugin { private final TwoFactorAuth _twofactor = Managers.require(TwoFactorAuth.class); - private InventoryManager _inventoryManager; - private GadgetManager _gadgetManager; - private MountManager _mountManager; - private PetManager _petManager; - private TreasureManager _treasureManager; - private BoosterManager _boosterManager; + private final InventoryManager _inventoryManager; + private final GadgetManager _gadgetManager; + private final MountManager _mountManager; + private final PetManager _petManager; + private final TreasureManager _treasureManager; + private final BoosterManager _boosterManager; + private final Punish _punish; private CosmeticShop _shop; private boolean _showInterface = true; private int _interfaceSlot = 4; - public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, PetManager petManager, TreasureManager treasureManager, BoosterManager boosterManager) + public CosmeticManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, + InventoryManager inventoryManager, GadgetManager gadgetManager, MountManager mountManager, + PetManager petManager, TreasureManager treasureManager, BoosterManager boosterManager, + Punish punish) { super("Cosmetic Manager", plugin); @@ -63,6 +69,7 @@ public class CosmeticManager extends MiniPlugin _petManager = petManager; _treasureManager = treasureManager; _boosterManager = boosterManager; + _punish = punish; _shop = new CosmeticShop(this, clientManager, donationManager, _moduleName); } @@ -242,6 +249,11 @@ public class CosmeticManager extends MiniPlugin { return _boosterManager; } + + public Punish getPunishManager() + { + return _punish; + } public void displayUI(Player player) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index e0d211e34..18afeb5f7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -10,7 +10,18 @@ import java.util.Set; import java.util.UUID; import java.util.function.Predicate; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; +import mineplex.core.gadget.gadgets.flag.FlagType; import mineplex.core.gadget.gadgets.morph.MorphBobRoss; +import mineplex.core.gadget.gadgets.particle.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; +import mineplex.core.gadget.set.SetCanadian; +import mineplex.core.gadget.types.FlagGadget; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -47,50 +58,50 @@ import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.event.PlayerToggleSwimEvent; import mineplex.core.gadget.event.TauntCommandEvent; -import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; -import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; -import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.arrowtrail.halloween.ArrowTrailHalloween; -import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; -import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; -import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; -import mineplex.core.gadget.gadgets.arrowtrail.spring.ArrowTrailSpring; -import mineplex.core.gadget.gadgets.arrowtrail.titan.ArrowTrailTitan; -import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; -import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailTitan; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.balloons.BalloonItem; import mineplex.core.gadget.gadgets.balloons.BalloonType; -import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; -import mineplex.core.gadget.gadgets.death.christmas.DeathPresentDanger; -import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart; -import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald; -import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; -import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; -import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; -import mineplex.core.gadget.gadgets.death.music.DeathMusic; -import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst; -import mineplex.core.gadget.gadgets.death.shadow.DeathShadow; -import mineplex.core.gadget.gadgets.death.spring.DeathSpring; -import mineplex.core.gadget.gadgets.death.titan.DeathTitan; -import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; -import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; -import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; -import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; -import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; -import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; -import mineplex.core.gadget.gadgets.doublejump.halloween.DoubleJumpHalloween; -import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; -import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; -import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; -import mineplex.core.gadget.gadgets.doublejump.spring.DoubleJumpSpring; -import mineplex.core.gadget.gadgets.doublejump.titan.DoubleJumpTitan; -import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; -import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.death.DeathCandyCane; +import mineplex.core.gadget.gadgets.death.DeathPresentDanger; +import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; +import mineplex.core.gadget.gadgets.death.DeathEmerald; +import mineplex.core.gadget.gadgets.death.DeathFreedom; +import mineplex.core.gadget.gadgets.death.DeathFrostLord; +import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.death.DeathMusic; +import mineplex.core.gadget.gadgets.death.DeathPinataBurst; +import mineplex.core.gadget.gadgets.death.DeathShadow; +import mineplex.core.gadget.gadgets.death.DeathSpring; +import mineplex.core.gadget.gadgets.death.DeathTitan; +import mineplex.core.gadget.gadgets.death.DeathBlood; +import mineplex.core.gadget.gadgets.death.DeathEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.GameModifierMount; import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.MountType; @@ -366,6 +377,7 @@ public class GadgetManager extends MiniPlugin addSet(new SetMusic(this)); addSet(new SetFreedom(this)); addSet(new SetSpring(this)); + addSet(new SetCanadian(this)); } private void createGadgets() @@ -459,31 +471,40 @@ public class GadgetManager extends MiniPlugin // Particles addGadget(new ParticleFoot(this)); - addGadget(new ParticleFireRings(this)); - addGadget(new ParticleFairy(this)); - addGadget(new ParticleLegend(this)); - addGadget(new ParticleFrostLord(this)); - addGadget(new ParticleTitan(this)); - addGadget(new ParticleCandyCane(this)); - addGadget(new ParticleCoalFumes(this)); - addGadget(new ParticlePartyTime(this)); - addGadget(new ParticleHeart(this)); addGadget(new ParticleEmerald(this)); - addGadget(new ParticleWingsDemons(this)); - addGadget(new ParticleEnchant(this)); addGadget(new ParticleRain(this)); addGadget(new ParticleBlood(this)); + addGadget(new ParticleEnchant(this)); addGadget(new ParticleMusic(this)); - addGadget(new ParticleWingsAngel(this)); - addGadget(new ParticleWingsInfernal(this)); - addGadget(new ParticleWingsPixie(this)); + addGadget(new ParticlePartyTime(this)); + + addGadget(new ParticleHeart(this)); + addGadget(new ParticleCandyCane(this)); + addGadget(new ParticleFrostLord(this)); + addGadget(new ParticleLegend(this)); + addGadget(new ParticleTitan(this)); addGadget(new ParticleYinYang(this)); - addGadget(new ParticleFreedom(this)); - addGadget(new ParticleChristmasTree(this)); + addGadget(new ParticleKing(this, _castleManager)); + + addGadget(new ParticleWingsPixie(this)); + addGadget(new ParticleWingsDemons(this)); + addGadget(new ParticleWingsInfernal(this)); + addGadget(new ParticleWingsAngel(this)); addGadget(new ParticleWingsLove(this)); + addGadget(new ParticleFireRings(this)); + addGadget(new ParticleFairy(this)); + + addGadget(new ParticleChristmasTree(this)); + addGadget(new ParticleCoalFumes(this)); addGadget(new ParticleSpringHalo(this)); addGadget(new ParticleWingsBee(this)); - addGadget(new ParticleKing(this, _castleManager)); + + addGadget(new ParticleFreedom(this)); + addGadget(new ParticleFreedomFireworks(this)); + addGadget(new ParticleStarSpangled(this)); + addGadget(new ParticleAuraNiceness(this)); + addGadget(new ParticleCanadian(this)); + // Arrow Trails addGadget(new ArrowTrailFrostLord(this)); @@ -500,6 +521,7 @@ public class GadgetManager extends MiniPlugin addGadget(new ArrowTrailFreedom(this)); addGadget(new ArrowTrailHalloween(this)); addGadget(new ArrowTrailSpring(this)); + addGadget(new ArrowTrailRedWhite(this)); // Death Effect addGadget(new DeathFrostLord(this)); @@ -516,6 +538,7 @@ public class GadgetManager extends MiniPlugin addGadget(new DeathFreedom(this)); addGadget(new DeathPresentDanger(this)); addGadget(new DeathSpring(this)); + addGadget(new DeathMapleLeaf(this)); // Double Jump addGadget(new DoubleJumpFrostLord(this)); @@ -532,6 +555,7 @@ public class GadgetManager extends MiniPlugin addGadget(new DoubleJumpFreedom(this)); addGadget(new DoubleJumpHalloween(this)); addGadget(new DoubleJumpSpring(this)); + addGadget(new DoubleJumpMaple(this)); // Hat for (HatType hatType : HatType.values()) @@ -625,6 +649,10 @@ public class GadgetManager extends MiniPlugin addGadget(new BlowAKissTaunt(this)); addGadget(new RainbowTaunt(this)); + // Flags + addGadget(new FlagGadget(this, FlagType.UNITED_STATES)); + addGadget(new FlagGadget(this, FlagType.CANADA)); + // Kit Selectors addGadget(new WaterWingsKitSelector(this)); addGadget(new HaloKitSelector(this)); @@ -830,6 +858,23 @@ public class GadgetManager extends MiniPlugin return null; } + public FlagGadget getFlagGadget(FlagType type) + { + for (Gadget gadget : getGadgets(GadgetType.FLAG)) + { + if(gadget instanceof FlagGadget) + { + FlagGadget flagGadget = (FlagGadget) gadget; + + if (type.equals(flagGadget.getFlagType())) + { + return flagGadget; + } + } + } + return null; + } + public BalloonGadget getBalloonGadget(BalloonType balloonType) { for (Gadget gadget : getGadgets(GadgetType.BALLOON)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 5f4e5fb16..eabf8e7e4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -5,6 +5,14 @@ import java.util.EnumMap; import java.util.List; import java.util.Random; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; +import mineplex.core.gadget.gadgets.flag.FlagType; +import mineplex.core.gadget.gadgets.particle.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -15,46 +23,46 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.halloween.ArrowTrailHalloween; -import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; -import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; -import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; -import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; -import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; -import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; -import mineplex.core.gadget.gadgets.arrowtrail.spring.ArrowTrailSpring; -import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; -import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.balloons.BalloonType; -import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane; -import mineplex.core.gadget.gadgets.death.christmas.DeathPresentDanger; -import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart; -import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald; -import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; -import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord; -import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; -import mineplex.core.gadget.gadgets.death.music.DeathMusic; -import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst; -import mineplex.core.gadget.gadgets.death.shadow.DeathShadow; -import mineplex.core.gadget.gadgets.death.spring.DeathSpring; -import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; -import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.halloween.DoubleJumpHalloween; -import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; -import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; -import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; -import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; -import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; -import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; -import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; -import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; -import mineplex.core.gadget.gadgets.doublejump.spring.DoubleJumpSpring; -import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; -import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.death.DeathCandyCane; +import mineplex.core.gadget.gadgets.death.DeathPresentDanger; +import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; +import mineplex.core.gadget.gadgets.death.DeathEmerald; +import mineplex.core.gadget.gadgets.death.DeathFreedom; +import mineplex.core.gadget.gadgets.death.DeathFrostLord; +import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.death.DeathMusic; +import mineplex.core.gadget.gadgets.death.DeathPinataBurst; +import mineplex.core.gadget.gadgets.death.DeathShadow; +import mineplex.core.gadget.gadgets.death.DeathSpring; +import mineplex.core.gadget.gadgets.death.DeathBlood; +import mineplex.core.gadget.gadgets.death.DeathEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin; import mineplex.core.gadget.gadgets.hat.HatType; import mineplex.core.gadget.gadgets.item.ItemBatGun; @@ -318,6 +326,10 @@ public class RewardManager addHat(Type.WINTER_HOLIDAY, HatType.PRESENT, rarity, 5); addHat(Type.WINTER_HOLIDAY, HatType.SNOWMAN, rarity, 5); + // FREEDOM + addGadget(Type.FREEDOM, getGadget(ArrowTrailRedWhite.class), rarity, 150); + addGadget(Type.FREEDOM, getGadget(ArrowTrailFreedom.class), rarity, 150); + // Omega items addMusicReward(Type.OMEGA, "Blocks Disc", rarity, 25); addMusicReward(Type.OMEGA, "Cat Disc", rarity, 25); @@ -484,9 +496,12 @@ public class RewardManager // FREEDOM addHat(Type.FREEDOM, HatType.UNCLE_SAM, rarity, 100); + addHat(Type.FREEDOM, HatType.AMERICA, rarity, 120); + addHat(Type.FREEDOM, HatType.CANADA, rarity, 120); addGadget(Type.FREEDOM, getGadget(DoubleJumpFreedom.class), rarity, 50); - addGadget(Type.FREEDOM, getGadget(ArrowTrailFreedom.class), rarity, 10); + addGadget(Type.FREEDOM, getGadget(DoubleJumpMaple.class), rarity, 50); addGadget(Type.FREEDOM, getGadget(DeathFreedom.class), rarity, 75); + addGadget(Type.FREEDOM, getGadget(DeathMapleLeaf.class), rarity, 75); // Omega Chest addGadget(Type.OMEGA, getGadget(DoubleJumpFreedom.class), rarity, 5); @@ -758,6 +773,12 @@ public class RewardManager addMount(Type.FREEDOM, getMount(MountFreedomHorse.class), rarity, 1); addGadget(Type.FREEDOM, getGadget(MorphUncleSam.class), rarity, 5); addGadget(Type.FREEDOM, getGadget(ParticleFreedom.class), rarity, 50); + addGadget(Type.FREEDOM, getGadget(ParticleFreedomFireworks.class), rarity, 95); + addGadget(Type.FREEDOM, getGadget(ParticleAuraNiceness.class), rarity, 40); + addGadget(Type.FREEDOM, getGadget(ParticleCanadian.class), rarity, 10); + addGadget(Type.FREEDOM, getGadget(ParticleStarSpangled.class), rarity, 10); + addFlag(Type.FREEDOM, FlagType.CANADA, rarity, 35); + addFlag(Type.FREEDOM, FlagType.UNITED_STATES, rarity, 35); // Omega items addPetReward(Type.OMEGA, PetType.VILLAGER, rarity, 1); @@ -1013,6 +1034,17 @@ public class RewardManager return addGadget(type, gadget, gadget.getDisplayName(), rarity, weight, shards); } + public UnknownPackageReward addFlag(Type type, FlagType flagType, RewardRarity rarity, int weight) + { + return addFlag(type, flagType, rarity, weight, getShards(rarity)); + } + + public UnknownPackageReward addFlag(Type type, FlagType flagType, RewardRarity rarity, int weight, int shards) + { + Gadget gadget = _gadgetManager.getFlagGadget(flagType); + return addGadget(type, gadget, gadget.getDisplayName(), rarity, weight, shards); + } + public UnknownPackageReward addBalloon(Type type, BalloonType balloonType, RewardRarity rarity, int weight) { return addBalloon(type, balloonType, rarity, weight, getShards(rarity)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index 030e3dc1d..de56e4730 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -4,6 +4,15 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; +import mineplex.core.gadget.gadgets.flag.FlagType; +import mineplex.core.gadget.gadgets.hat.HatType; +import mineplex.core.gadget.gadgets.particle.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -20,9 +29,9 @@ import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; -import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; -import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; +import mineplex.core.gadget.gadgets.death.DeathFreedom; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; import mineplex.core.gadget.gadgets.morph.MorphUncleSam; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; import mineplex.core.gadget.types.Gadget; @@ -141,7 +150,7 @@ public class TreasurePage extends ShopPageBase int springCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.SPRING.getItemName()); boolean availableChristmas = false; - boolean availableFreedom = false; + boolean availableFreedom = true; boolean availableHaunted = false; boolean availableTrick = false; boolean availableThank = false; @@ -152,8 +161,8 @@ public class TreasurePage extends ShopPageBase List shardLore = new ArrayList<>(); shardLore.add(" "); - shardLore.add(C.cGray + "This seems like it might come in"); - shardLore.add(C.cGray + "handy. Maybe I can collect more!"); + shardLore.add(C.cGray + "These seem like they might come in"); + shardLore.add(C.cGray + "handy. Maybe I should collect more!"); List basicLore = new ArrayList<>(); basicLore.add(" "); @@ -254,14 +263,36 @@ public class TreasurePage extends ShopPageBase freedomLore.add(C.cGray + "carved this chest himself from the wood"); freedomLore.add(C.cGray + "of the apple tree he cut down..."); freedomLore.add(" "); - if (freedomCount > 0 && !hasAllFreedomItems(getPlayer())) - freedomLore.add(C.cGreen + "Click to Open!"); + + if (freedomCount > 0) + { + if (hasAllFreedomItems(getPlayer())) + { + freedomLore.add(C.cWhite + "You own all treasures from this chest."); + } + else + { + freedomLore.add(C.cGreen + "Click to Open!"); + } + } else { - freedomLore.add(C.cRed + "This item is no longer available!"); + if (!availableFreedom) + { + freedomLore.add(C.cRed + "This item is no longer available!"); + } + else if (hasAllFreedomItems(getPlayer())) + { + freedomLore.add(C.cWhite + "You own all treasures from this chest."); + } + else + { + freedomLore.add(ChatColor.RESET + "Purchase at: " + C.cYellow + "www.mineplex.com/shop"); + } } + freedomLore.add(" "); - freedomLore.add(ChatColor.RESET + C.cGreen + getFreedomUnlockedAmount(getPlayer()) + "/7 Unlocked"); + freedomLore.add(ChatColor.RESET + C.cGreen + getFreedomUnlockedAmount(getPlayer()) + "/18 Unlocked"); List omegaLore = new ArrayList<>(); omegaLore.add(" "); @@ -699,7 +730,7 @@ public class TreasurePage extends ShopPageBase public int getFreedomUnlockedAmount(Player player) { if (hasAllFreedomItems(player)) - return 7; + return 18; int amount = 0; Gadget[] gadgets = new Gadget[] { @@ -708,7 +739,18 @@ public class TreasurePage extends ShopPageBase _gadgetManager.getGadget(ArrowTrailFreedom.class), _gadgetManager.getGadget(DoubleJumpFreedom.class), _gadgetManager.getGadget(DeathFreedom.class), - _gadgetManager.getGadget(MorphUncleSam.class) + _gadgetManager.getGadget(MorphUncleSam.class), + _gadgetManager.getGadget(ArrowTrailRedWhite.class), + _gadgetManager.getGadget(DeathMapleLeaf.class), + _gadgetManager.getGadget(DoubleJumpMaple.class), + _gadgetManager.getGadget(ParticleAuraNiceness.class), + _gadgetManager.getGadget(ParticleCanadian.class), + _gadgetManager.getGadget(ParticleFreedomFireworks.class), + _gadgetManager.getGadget(ParticleStarSpangled.class), + _gadgetManager.getHatGadget(HatType.AMERICA), + _gadgetManager.getHatGadget(HatType.CANADA), + _gadgetManager.getFlagGadget(FlagType.CANADA), + _gadgetManager.getFlagGadget(FlagType.UNITED_STATES), }; Mount freedomMount = _gadgetManager.getMountManager().getMount("Freedom Mount"); if (freedomMount != null) From bfca6603c17c3c5b30d031f92f3b5dcd715224c8 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:37:06 -0400 Subject: [PATCH 018/183] Disallow eternal taunt disguising an already disguised player --- .../gadget/gadgets/taunts/EternalTaunt.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java index 103efacd2..1e0c943b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import mineplex.core.disguise.disguises.DisguiseBase; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -41,7 +42,8 @@ public class EternalTaunt extends TauntGadget private static final int COOLDOWN = 30000; private static final int PVP_COOLDOWN = 10000; - private Map> _clocks = new HashMap<>(); + private final Map> _clocks = new HashMap<>(); + private final Map _disguises = new HashMap<>(); public EternalTaunt(GadgetManager manager) { @@ -68,8 +70,12 @@ public class EternalTaunt extends TauntGadget Bukkit.broadcastMessage(F.main("Taunt", F.name(player.getName()) + " waited so long they turned to bones.")); - DisguiseSkeleton disguiseSkeleton = new DisguiseSkeleton(player); - UtilMorph.disguise(player, disguiseSkeleton, Manager); + if (!Manager.getDisguiseManager().isDisguised(player)) + { + DisguiseSkeleton disguiseSkeleton = new DisguiseSkeleton(player); + UtilMorph.disguise(player, disguiseSkeleton, Manager); + _disguises.put(player.getUniqueId(), disguiseSkeleton); + } } @Override @@ -114,7 +120,11 @@ public class EternalTaunt extends TauntGadget @Override public void onFinish(Player player) { - UtilMorph.undisguise(player, Manager.getDisguiseManager()); + if (_disguises.containsKey(player.getUniqueId())) + { + Manager.getDisguiseManager().undisguise(_disguises.remove(player.getUniqueId())); + } + if (_clocks.containsKey(player.getUniqueId())) { _clocks.get(player.getUniqueId()).forEach(c -> c.remove()); From 082a197e8b0a0086a35857eab032854c3c8d7bfd Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:37:20 -0400 Subject: [PATCH 019/183] Overhaul legend particle --- .../gadgets/particle/ParticleLegend.java | 182 +++++++++++++++++- 1 file changed, 180 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java index f99338a75..51911de42 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java @@ -1,6 +1,9 @@ package mineplex.core.gadget.gadgets.particle; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; import org.bukkit.Effect; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -16,13 +19,46 @@ import mineplex.core.inventory.ClientItem; import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.util.Vector; + +import java.awt.Color; +import java.util.Random; public class ParticleLegend extends ParticleGadget { + private static final double PI = Math.PI; + private static final int BASE_PILLARS = 9; + private static final int PILLAR_VARIANCE = 7; + private static final int COLOR_VARIANCE = 5; + private static final int MOVING_PARTICLES = 8; + private static final double VERTICAL_SPEED = 0.1; + private static final double HEIGHT_VARIANCE = 0.8; + private static final double ROTATIONAL_SPEED = .03; + private static final double RADIAL_VARIANCE = 0.09; + private static final double DARK_PARTICLE_CHANCE = 0.5; + private static final double BASE_RADIUS = 1.30; + private static final double HEIGHT_MODIFIER_BASE = 0.1; + private static final double HEIGHT_MODIFIER_MAX = 1.3; + private static final double HEIGHT_MODIFIER_INTERVAL = 0.2; + private static final Color[] SELECTABLE_COLORS = { + new Color(170, 100, 170), + new Color(50, 10, 60), + new Color(120, 10, 170), + new Color(65, 20, 80) + }; + + private final int _pillars = pillars(); + private final Color[] _colors = colors(); + private final double[] _heights = heights(); + private final double[] _verticals = verticals(); + private final double[] _variance = variances(); + private final double[] _thetas = thetas(); + private final double[] _radii = radii(); + public ParticleLegend(GadgetManager manager) { super(manager, "Legendary Aura", - UtilText.splitLineToArray(C.cGray + "This particle will be updated soon! Yay!", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "Let the energy of the End protect you.", LineFormat.LORE), -1, Material.ENDER_PORTAL_FRAME, (byte)0); } @@ -31,9 +67,151 @@ public class ParticleLegend extends ParticleGadget public void playParticle(Player player, UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } - player.getWorld().playEffect(player.getLocation().add(0, 1, 0), Effect.ENDER_SIGNAL, 0); + if (Manager.isMoving(player)) + { + Location loc = player.getLocation().add(0, 1.5, 0); + + for (int i = 0; i < MOVING_PARTICLES; i++) + { + UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, + UtilMath.gauss(loc, 8, 4, 8), 0, UtilParticle.ViewDist.NORMAL); + } + } + else + { + if (event.getTick() % (ROTATIONAL_SPEED * 100) == 0) + { + for (int i = 0; i < _pillars; i++) + { + _thetas[i] = rollover(_thetas[i], ROTATIONAL_SPEED); + _heights[i] = rollover(_heights[i], _verticals[i]); + + double x = (_radii[i] * Math.cos(_thetas[i])) + player.getLocation().getX(); + double z = (_radii[i] * Math.sin(_thetas[i])) + player.getLocation().getZ(); + double y = (Math.sin(_heights[i]) * _variance[i]) + player.getLocation().getY(); + + for (double h = HEIGHT_MODIFIER_BASE; h <= HEIGHT_MODIFIER_MAX; h+= HEIGHT_MODIFIER_INTERVAL) + { + UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, + new Location(player.getWorld(), x, y + h, z), 0, UtilParticle.ViewDist.NORMAL); + + if (Math.random() < DARK_PARTICLE_CHANCE) + { + UtilParticle.playColoredParticleToAll(Color.BLACK, UtilParticle.ParticleType.RED_DUST, + new Location(player.getWorld(), x, y + h, z), 0, UtilParticle.ViewDist.NORMAL); + } + } + } + } + } + } + + private double[] heights() + { + double[] array = new double[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + array[i] = 6.28 * Math.random(); + } + + return array; + } + + private double[] variances() + { + double[] array = new double[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + array[i] = Math.random() * HEIGHT_VARIANCE; + } + + return array; + } + + private double[] verticals() + { + double[] array = new double[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + array[i] = Math.random() * VERTICAL_SPEED; + } + + return array; + } + + private double[] thetas() + { + double[] array = new double[_pillars]; + double theta = 0; + double interval = (2 * PI) / _pillars; + + for (int i = 0; i < _pillars; i++) + { + array[i] = theta; + theta += interval; + } + + return array; + } + + private double[] radii() + { + double[] array = new double[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + array[i] = BASE_RADIUS + (Math.random() * RADIAL_VARIANCE); + } + + return array; + } + + private Color[] colors() + { + Random random = new Random(); + + Color[] array = new Color[_pillars]; + + for (int i = 0; i < _pillars; i++) + { + Color color = SELECTABLE_COLORS[i % SELECTABLE_COLORS.length]; + + int r = color.getRed() + (int) (random.nextGaussian() * COLOR_VARIANCE); + int g = color.getGreen() + (int) (random.nextGaussian() * COLOR_VARIANCE); + int b = color.getBlue() + (int) (random.nextGaussian() * COLOR_VARIANCE); + + r = Math.min(255, Math.max(0, r)); + g = Math.min(255, Math.max(0, g)); + b = Math.min(255, Math.max(0, b)); + + array[i] = new Color(r, g, b); + } + + return array; + } + + private int pillars() + { + return BASE_PILLARS + (int) ((Math.random() * PILLAR_VARIANCE) - (PILLAR_VARIANCE / 2)); + } + + private double rollover(double value, double additive) + { + value += additive; + + if (value >= 2 * PI) + { + value = value - (2 * PI); + } + + return value; } @EventHandler From 9d1c3930b394f55523f68461d86928f51eebfcfd Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:37:33 -0400 Subject: [PATCH 020/183] Update hubs with new CosmeticManager constructor --- .../Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java | 2 +- Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java | 2 +- .../Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java | 2 +- .../mavericks-review-hub/src/mineplex/mavericks/review/Hub.java | 2 +- .../src/mineplex/gemhunters/GemHunters.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index 29e6ab472..b02d21718 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -233,7 +233,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter _treasureManager.addTreasureLocation(loc); } - new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); + new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager, punish); new MenuManager(_plugin); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 070cd582a..a1281af14 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -236,7 +236,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess _bonusManager = new BonusManager(plugin, null, playWireManager, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager, "Carl"); _treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager()); - CosmeticManager cosmeticManager = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager); + CosmeticManager cosmeticManager = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager, punish); _mavericksManager = new MavericksManager(plugin, cosmeticManager, hologramManager, this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 197d76ff0..87c4ec8ab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -203,7 +203,7 @@ public class Arcade extends JavaPlugin GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito, castleManager); ThankManager thankManager = new ThankManager(this, _clientManager, _donationManager); BoosterManager boosterManager = new BoosterManager(this, _serverConfiguration.getServerGroup().getBoosterGroup(), _clientManager, _donationManager, inventoryManager, thankManager); - CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager); + CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager, punish); cosmeticManager.setInterfaceSlot(6); gadgetManager.setActiveItemSlot(3); cosmeticManager.disableTeamArmor(); diff --git a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java index ebc01ac9c..4fbb830fa 100644 --- a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java +++ b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java @@ -138,7 +138,7 @@ public class Hub extends JavaPlugin RewardManager rewardManager = new RewardManager(_clientManager, _donationManager, inventoryManager, petManager, gadgetManager, statsManager); TreasureManager treasureManager = new TreasureManager(this, _clientManager, serverStatusManager, _donationManager, inventoryManager, petManager, gadgetManager, blockRestore, hologramManager, statsManager, rewardManager); CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, - mountManager, petManager, treasureManager, boosterManager); + mountManager, petManager, treasureManager, boosterManager, punish); cosmeticManager.setInterfaceSlot(7); cosmeticManager.disableTeamArmor(); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index 9b8256d80..db3fefddd 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -260,7 +260,7 @@ public class GemHunters extends JavaPlugin GadgetManager gadgetManager = new GadgetManager(this, clientManager, donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito, castleManager); ThankManager thankManager = new ThankManager(this, clientManager, donationManager); BoosterManager boosterManager = new BoosterManager(this, null, clientManager, donationManager, inventoryManager, thankManager); - CosmeticManager cosmeticManager = new CosmeticManager(this, clientManager, donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager); + CosmeticManager cosmeticManager = new CosmeticManager(this, clientManager, donationManager, inventoryManager, gadgetManager, mountManager, petManager, null, boosterManager, punish); cosmeticManager.setActive(false); cosmeticManager.setHideParticles(true); From fbd347ff41dd5b6509991c4f33d6208a676db892 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 01:40:46 -0400 Subject: [PATCH 021/183] Remove unnecessary packages --- .../mineplex/core/gadget/GadgetManager.java | 31 +++++++++---------- .../gadget/commands/LockInfusedCommand.java | 2 +- .../particle/{vampire => }/ParticleBlood.java | 2 +- .../{candycane => }/ParticleCandyCane.java | 2 +- .../{emerald => }/ParticleEmerald.java | 2 +- .../{wisdom => }/ParticleEnchant.java | 2 +- .../particle/{shadow => }/ParticleFoot.java | 2 +- .../{frostlord => }/ParticleFrostLord.java | 2 +- .../{cupidslove => }/ParticleHeart.java | 2 +- .../particle/{music => }/ParticleMusic.java | 2 +- .../{party => }/ParticlePartyTime.java | 2 +- .../{howlingwinds => }/ParticleRain.java | 2 +- .../particle/{titan => }/ParticleTitan.java | 2 +- .../{ => freedom}/ParticleAuraNiceness.java | 2 +- .../{ => freedom}/ParticleCanadian.java | 2 +- .../ParticleFreedomFireworks.java | 2 +- .../{ => freedom}/ParticleStarSpangled.java | 2 +- .../mineplex/core/gadget/set/SetCanadian.java | 6 +--- .../core/gadget/set/SetCandyCane.java | 2 +- .../core/gadget/set/SetCupidsLove.java | 2 +- .../mineplex/core/gadget/set/SetEmerald.java | 2 +- .../mineplex/core/gadget/set/SetFreedom.java | 3 +- .../core/gadget/set/SetFrostLord.java | 2 +- .../core/gadget/set/SetHowlingWinds.java | 2 +- .../mineplex/core/gadget/set/SetMusic.java | 2 +- .../mineplex/core/gadget/set/SetParty.java | 2 +- .../mineplex/core/gadget/set/SetShadow.java | 2 +- .../mineplex/core/gadget/set/SetTitan.java | 2 +- .../mineplex/core/gadget/set/SetVampire.java | 2 +- .../mineplex/core/gadget/set/SetWisdom.java | 2 +- .../mineplex/core/reward/RewardManager.java | 28 ++++++++--------- .../core/treasure/gui/TreasurePage.java | 8 ++--- 32 files changed, 62 insertions(+), 68 deletions(-) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{vampire => }/ParticleBlood.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{candycane => }/ParticleCandyCane.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{emerald => }/ParticleEmerald.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{wisdom => }/ParticleEnchant.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{shadow => }/ParticleFoot.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{frostlord => }/ParticleFrostLord.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{cupidslove => }/ParticleHeart.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{music => }/ParticleMusic.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{party => }/ParticlePartyTime.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{howlingwinds => }/ParticleRain.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{titan => }/ParticleTitan.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => freedom}/ParticleAuraNiceness.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => freedom}/ParticleCanadian.java (97%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => freedom}/ParticleFreedomFireworks.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/{ => freedom}/ParticleStarSpangled.java (97%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 18afeb5f7..69e331174 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -10,16 +10,15 @@ import java.util.Set; import java.util.UUID; import java.util.function.Predicate; -import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; import mineplex.core.gadget.gadgets.flag.FlagType; import mineplex.core.gadget.gadgets.morph.MorphBobRoss; -import mineplex.core.gadget.gadgets.particle.ParticleAuraNiceness; -import mineplex.core.gadget.gadgets.particle.ParticleCanadian; -import mineplex.core.gadget.gadgets.particle.ParticleFreedomFireworks; -import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import mineplex.core.gadget.set.SetCanadian; import mineplex.core.gadget.types.FlagGadget; import org.bukkit.Bukkit; @@ -196,19 +195,19 @@ import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; import mineplex.core.gadget.gadgets.particle.ParticleWingsLove; import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie; import mineplex.core.gadget.gadgets.particle.ParticleYinYang; -import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; -import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart; -import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; +import mineplex.core.gadget.gadgets.particle.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.ParticleEmerald; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; -import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; -import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; -import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; -import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; -import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleRain; +import mineplex.core.gadget.gadgets.particle.ParticleMusic; +import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; +import mineplex.core.gadget.gadgets.particle.ParticleFoot; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; -import mineplex.core.gadget.gadgets.particle.titan.ParticleTitan; -import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; -import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; +import mineplex.core.gadget.gadgets.particle.ParticleTitan; +import mineplex.core.gadget.gadgets.particle.ParticleBlood; +import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; import mineplex.core.gadget.gadgets.taunts.EternalTaunt; import mineplex.core.gadget.gadgets.taunts.RainbowTaunt; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java index a91dcdb3e..d57b89228 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java @@ -21,7 +21,7 @@ import mineplex.core.gadget.gadgets.item.ItemFreezeCannon; import mineplex.core.gadget.gadgets.item.ItemPartyPopper; import mineplex.core.gadget.gadgets.item.ItemSnowball; import mineplex.core.gadget.gadgets.morph.MorphSnowman; -import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; import mineplex.core.gadget.types.Gadget; import mineplex.core.mount.Mount; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/vampire/ParticleBlood.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleBlood.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/vampire/ParticleBlood.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleBlood.java index a33078067..0c3c3546a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/vampire/ParticleBlood.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleBlood.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.vampire; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/candycane/ParticleCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/candycane/ParticleCandyCane.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java index 4d8b223fc..5f31b13fb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/candycane/ParticleCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.candycane; +package mineplex.core.gadget.gadgets.particle; import java.util.HashMap; import java.util.UUID; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/emerald/ParticleEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEmerald.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/emerald/ParticleEmerald.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEmerald.java index 417587dbb..f81361c66 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/emerald/ParticleEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEmerald.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.emerald; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/wisdom/ParticleEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/wisdom/ParticleEnchant.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java index f8d734e74..706c32fbd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/wisdom/ParticleEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnchant.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.wisdom; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoot.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoot.java index 9c3b8be54..fd315fc04 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/shadow/ParticleFoot.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoot.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.shadow; +package mineplex.core.gadget.gadgets.particle; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/frostlord/ParticleFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/frostlord/ParticleFrostLord.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java index 62c1388b3..32f947e47 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/frostlord/ParticleFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFrostLord.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.frostlord; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Material; import org.bukkit.Sound; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java index dea6a85aa..ca008bc75 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/cupidslove/ParticleHeart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.cupidslove; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/music/ParticleMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMusic.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/music/ParticleMusic.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMusic.java index 04874fffc..e0bbb3537 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/music/ParticleMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMusic.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.music; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/party/ParticlePartyTime.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/party/ParticlePartyTime.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java index 3aab6f928..a3944317c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/party/ParticlePartyTime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.party; +package mineplex.core.gadget.gadgets.particle; import java.util.Arrays; import java.util.Collections; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/howlingwinds/ParticleRain.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/howlingwinds/ParticleRain.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java index f2c45007c..4311666c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/howlingwinds/ParticleRain.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.howlingwinds; +package mineplex.core.gadget.gadgets.particle; import java.util.ArrayList; import java.util.List; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java index b5f02de23..7d062f713 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/titan/ParticleTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle.titan; +package mineplex.core.gadget.gadgets.particle; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleAuraNiceness.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleAuraNiceness.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java index 39b20d946..8b72b935c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleAuraNiceness.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.freedom; import mineplex.core.arcadeevents.CoreGameStartEvent; import mineplex.core.arcadeevents.CoreGameStopEvent; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCanadian.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java index 10f87fe29..7984af254 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCanadian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.freedom; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFreedomFireworks.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFreedomFireworks.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java index 92721b705..4234a257b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFreedomFireworks.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.freedom; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleStarSpangled.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleStarSpangled.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java index ead0bc411..cf65cb0dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleStarSpangled.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.particle; +package mineplex.core.gadget.gadgets.particle.freedom; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java index a295bb9da..0b18eca18 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCanadian.java @@ -1,14 +1,10 @@ package mineplex.core.gadget.set; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; -import mineplex.core.gadget.gadgets.death.DeathFreedom; import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; -import mineplex.core.gadget.gadgets.particle.ParticleCanadian; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; import mineplex.core.gadget.types.GadgetSet; public class SetCanadian extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java index 9a2d9ce75..c9b059480 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCandyCane.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; import mineplex.core.gadget.gadgets.death.DeathCandyCane; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; -import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; +import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; import mineplex.core.gadget.types.GadgetSet; public class SetCandyCane extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java index 47f1552f7..dca2f191c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; -import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.ParticleHeart; import mineplex.core.gadget.types.GadgetSet; public class SetCupidsLove extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java index 740174dba..26df2fd6f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; import mineplex.core.gadget.gadgets.death.DeathEmerald; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; -import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.ParticleEmerald; import mineplex.core.gadget.types.GadgetSet; public class SetEmerald extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java index e8c300adf..a64e2caf3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFreedom.java @@ -4,8 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; import mineplex.core.gadget.gadgets.death.DeathFreedom; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; -import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import mineplex.core.gadget.types.GadgetSet; public class SetFreedom extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java index 6050a0b00..311600e5e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; import mineplex.core.gadget.gadgets.death.DeathFrostLord; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; -import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; import mineplex.core.gadget.types.GadgetSet; public class SetFrostLord extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java index 672f49bdc..668503111 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; import mineplex.core.gadget.gadgets.death.DeathStorm; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; -import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; +import mineplex.core.gadget.gadgets.particle.ParticleRain; import mineplex.core.gadget.types.GadgetSet; public class SetHowlingWinds extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java index fdd47eacd..50eef82a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; import mineplex.core.gadget.gadgets.death.DeathMusic; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; +import mineplex.core.gadget.gadgets.particle.ParticleMusic; import mineplex.core.gadget.types.GadgetSet; public class SetMusic extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java index 0b99f9f2e..f22ce959e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; import mineplex.core.gadget.gadgets.death.DeathPinataBurst; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; -import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; +import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; import mineplex.core.gadget.types.GadgetSet; public class SetParty extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java index 1d5fad5dd..80b751d7d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; import mineplex.core.gadget.gadgets.death.DeathShadow; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; -import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.ParticleFoot; import mineplex.core.gadget.types.GadgetSet; public class SetShadow extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java index 0d333818d..360d86270 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailTitan; import mineplex.core.gadget.gadgets.death.DeathTitan; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan; -import mineplex.core.gadget.gadgets.particle.titan.ParticleTitan; +import mineplex.core.gadget.gadgets.particle.ParticleTitan; import mineplex.core.gadget.types.GadgetSet; public class SetTitan extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java index 7ec9b7f7a..1a5541085 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; import mineplex.core.gadget.gadgets.death.DeathBlood; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; -import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; +import mineplex.core.gadget.gadgets.particle.ParticleBlood; import mineplex.core.gadget.types.GadgetSet; public class SetVampire extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java index 870b70d3f..5bbae55da 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java @@ -4,7 +4,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.death.DeathEnchant; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; -import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; +import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.types.GadgetSet; public class SetWisdom extends GadgetSet diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index eabf8e7e4..783e16317 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -9,10 +9,10 @@ import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; import mineplex.core.gadget.gadgets.flag.FlagType; -import mineplex.core.gadget.gadgets.particle.ParticleAuraNiceness; -import mineplex.core.gadget.gadgets.particle.ParticleCanadian; -import mineplex.core.gadget.gadgets.particle.ParticleFreedomFireworks; -import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -124,18 +124,18 @@ import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; import mineplex.core.gadget.gadgets.particle.ParticleWingsLove; import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie; import mineplex.core.gadget.gadgets.particle.ParticleYinYang; -import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane; -import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart; -import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; +import mineplex.core.gadget.gadgets.particle.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.ParticleEmerald; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; -import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord; -import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; -import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; -import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; -import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleRain; +import mineplex.core.gadget.gadgets.particle.ParticleMusic; +import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; +import mineplex.core.gadget.gadgets.particle.ParticleFoot; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; -import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; -import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; +import mineplex.core.gadget.gadgets.particle.ParticleBlood; +import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; import mineplex.core.gadget.gadgets.taunts.RainbowTaunt; import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index de56e4730..6c79d08c8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -9,10 +9,10 @@ import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; import mineplex.core.gadget.gadgets.flag.FlagType; import mineplex.core.gadget.gadgets.hat.HatType; -import mineplex.core.gadget.gadgets.particle.ParticleAuraNiceness; -import mineplex.core.gadget.gadgets.particle.ParticleCanadian; -import mineplex.core.gadget.gadgets.particle.ParticleFreedomFireworks; -import mineplex.core.gadget.gadgets.particle.ParticleStarSpangled; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; From c7e4f4bd4ddefcefbdcf55ba96ba5b86f6e1c025 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 02:02:57 -0400 Subject: [PATCH 022/183] Clean up and add comments --- .../core/cosmetic/CosmeticManager.java | 1 - .../core/cosmetic/ui/page/CostumePage.java | 3 -- .../core/cosmetic/ui/page/FlagPage.java | 4 -- .../core/cosmetic/ui/page/GadgetPage.java | 29 ------------- .../mineplex/core/cosmetic/ui/page/Menu.java | 7 +--- .../core/cosmetic/ui/page/MusicPage.java | 3 -- .../arrowtrail/ArrowTrailRedWhite.java | 11 +++-- .../gadget/gadgets/death/DeathMapleLeaf.java | 9 ++-- .../gadgets/doublejump/DoubleJumpMaple.java | 4 -- .../core/gadget/gadgets/flag/FlagType.java | 3 +- .../freedom/ParticleAuraNiceness.java | 42 +++++++++++++------ .../particle/freedom/ParticleCanadian.java | 12 +++--- .../freedom/ParticleFreedomFireworks.java | 10 +++-- .../core/gadget/types/FlagGadget.java | 13 ++---- .../src/mineplex/core/reward/Reward.java | 3 -- .../src/mineplex/core/reward/RewardData.java | 3 -- .../mineplex/core/reward/RewardRarity.java | 3 -- .../treasure/event/TreasureFinishEvent.java | 2 +- .../treasure/event/TreasurePreStartEvent.java | 2 +- .../treasure/event/TreasureStartEvent.java | 3 ++ 20 files changed, 64 insertions(+), 103 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java index 9f0552d86..7cb686de7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java @@ -1,6 +1,5 @@ package mineplex.core.cosmetic; -import mineplex.core.chat.Chat; import mineplex.core.punish.Punish; import org.bukkit.Bukkit; import org.bukkit.ChatColor; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java index 73af59a89..c1a606358 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java @@ -22,9 +22,6 @@ import mineplex.core.gadget.types.OutfitGadget; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -/** - * Created by shaun on 14-09-15. - */ public class CostumePage extends GadgetPage { public CostumePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java index 1a2b98635..8de6f4cdf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java @@ -15,10 +15,6 @@ import org.bukkit.event.inventory.ClickType; import java.util.List; -/** - * @author J Teissler - * @date 6/26/17 - */ public class FlagPage extends GadgetPage { public FlagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index 12523a911..03efda5ce 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -8,12 +8,10 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; -import mineplex.core.gadget.types.FlagGadget; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.account.CoreClientManager; @@ -22,7 +20,6 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.GadgetButton; @@ -371,19 +368,6 @@ public class GadgetPage extends ShopPageBase meta.setLore(itemLore); gadgetItemStack.setItemMeta(meta); - /*if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH - || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) - { - if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) - { - gadgetItemStack = CountryFlag.USA.getBanner(); - BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta(); - bannerMeta.setDisplayName(C.cGreen + C.Bold + gadget.getName()); - bannerMeta.setLore(meta.getLore()); - gadgetItemStack.setItemMeta(bannerMeta); - } - }*/ - addButton(slot, new ShopItem(gadgetItemStack, false, false).hideInfo(), new DeactivateGadgetButton(gadget, this)); } else @@ -394,19 +378,6 @@ public class GadgetPage extends ShopPageBase meta.setLore(itemLore); gadgetItemStack.setItemMeta(meta); - /*if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH - || gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP) - { - if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8) - { - gadgetItemStack = CountryFlag.USA.getBanner(); - BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta(); - bannerMeta.setDisplayName(C.cGreen + C.Bold + gadget.getName()); - bannerMeta.setLore(meta.getLore()); - gadgetItemStack.setItemMeta(bannerMeta); - } - }*/ - /*if (gadget instanceof MorphStray) { gadgetItemStack = UtilItem.getVersionSpecificItem(_player, UtilPlayer.PlayerVersion._1_9, gadgetItemStack); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 084025a09..a3275ea39 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -1,7 +1,6 @@ package mineplex.core.cosmetic.ui.page; import java.util.ArrayList; -import java.util.Arrays; import java.util.EnumMap; import java.util.List; import java.util.Map; @@ -9,9 +8,7 @@ import java.util.Map; import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.cosmetic.ui.button.open.OpenFlags; import mineplex.core.itemstack.ItemBuilder; -import org.bukkit.DyeColor; import org.bukkit.Material; -import org.bukkit.block.Banner; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -20,7 +17,6 @@ import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilUI; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.open.OpenArrowTrails; @@ -49,7 +45,6 @@ import mineplex.core.shop.page.ShopPageBase; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BannerMeta; -import org.bukkit.inventory.meta.ItemMeta; public class Menu extends ShopPageBase { @@ -253,6 +248,8 @@ public class Menu extends ShopPageBase lore = getLore(ownedCount.get(type), maxCount.get(type), "Show off your country's flag!", VISIBILITY_HUB, enabled.get(type)); addButton(flagSlot, new ShopItem(Material.BANNER, "Flags", lore, 1, false), new OpenFlags(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(flagSlot); + + // Copy over banner design BannerMeta banner = (BannerMeta) CountryFlag.MINEPLEX.getBanner().getItemMeta(); BannerMeta meta = ((BannerMeta) getItem(flagSlot).getItemMeta()); meta.setBaseColor(banner.getBaseColor()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java index 97f32d027..49fa65cf7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MusicPage.java @@ -14,9 +14,6 @@ import mineplex.core.gadget.types.GadgetType; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.item.IButton; -/** - * Created by shaun on 14-09-15. - */ public class MusicPage extends GadgetPage { public MusicPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java index e9a3c19e1..37934c81f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailRedWhite.java @@ -10,14 +10,14 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.ArrowEffectGadget; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.block.banner.Pattern; import org.bukkit.entity.Arrow; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.util.Vector; -import java.awt.*; +import java.awt.Color; +/** + * Trails a red and white double helix behind the arrow. + */ public class ArrowTrailRedWhite extends ArrowEffectGadget { public ArrowTrailRedWhite(GadgetManager manager) @@ -72,7 +72,6 @@ public class ArrowTrailRedWhite extends ArrowEffectGadget @Override public void doHitEffect(Arrow arrow) { - //UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, arrow.getLocation(), 0.35f, 0.35f, 0.35f, 1f, 15, UtilParticle.ViewDist.LONGER); - UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, arrow.getLocation(), 0, 0, 0, 0, 3, UtilParticle.ViewDist.LONGER); + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.EXPLODE, arrow.getLocation(), 0, 0, 0, 0, 3, UtilParticle.ViewDist.NORMAL); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java index b1a0e9955..194a2b6d4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java @@ -5,7 +5,6 @@ import mineplex.core.common.shape.ShapeWings; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.gadget.GadgetManager; @@ -16,11 +15,13 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; /** - * @author J Teissler - * @date 6/26/17 + * Displays a giant maple leaf at the point of death. */ public class DeathMapleLeaf extends DeathEffectGadget { + /** height off the ground of the leaf */ + private static final double HEIGHT = 3; + private final ShapeWings _leafOuter = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1.0, 0, 0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); private final ShapeWings _leafInner = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0.7, 0, 0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); @@ -37,7 +38,7 @@ public class DeathMapleLeaf extends DeathEffectGadget public void onBlood(Player player, BloodEvent event) { event.setCancelled(true); - Location loc = player.getLocation().add(0, 3, 0); + Location loc = player.getLocation().add(0, HEIGHT, 0); _leafOuter.display(loc); _leafInner.display(loc); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java index 1b1396463..4b9d08338 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpMaple.java @@ -2,8 +2,6 @@ package mineplex.core.gadget.gadgets.doublejump; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilColor; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilText; @@ -12,12 +10,10 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.DoubleJumpEffectGadget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.util.Vector; import java.util.HashMap; import java.util.Iterator; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java index 7e2c48e28..aec958dd9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java @@ -3,8 +3,7 @@ package mineplex.core.gadget.gadgets.flag; import mineplex.core.common.util.banner.CountryFlag; /** - * @author J Teissler - * @date 6/27/17 + * Cosmetic flags representing countries. */ public enum FlagType { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java index 8b72b935c..99a22fff4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java @@ -2,14 +2,12 @@ package mineplex.core.gadget.gadgets.particle.freedom; import mineplex.core.arcadeevents.CoreGameStartEvent; import mineplex.core.arcadeevents.CoreGameStopEvent; -import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilShapes; -import mineplex.core.common.util.UtilSound; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.gadget.GadgetManager; @@ -18,19 +16,14 @@ import mineplex.core.treasure.event.TreasureFinishEvent; import mineplex.core.treasure.event.TreasureStartEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockFadeEvent; import org.bukkit.event.block.BlockPhysicsEvent; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.util.Vector; import java.awt.Color; import java.util.HashMap; @@ -43,24 +36,38 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Collectors; /** - * @author J Teissler - * @date 6/26/17 + * Places flowers around the player with poofs of red and white */ public class ParticleAuraNiceness extends ParticleGadget { /** Radius within which flowers not allowed near treasure chests */ private static final int TREASURE_RADIUS = 4; + /** Horizontal offset for particle spawns */ private static final double H_FIELD = 0.5; + + /** Vertical offset for particle spawns */ private static final double V_FIELD = 0.35; - private static final int ROSE_PROBABILITY = 30; + + /** How likely a flower is to be spawned (1/n) */ + private static final int ROSE_PROBABILITY = 40; + + /** Radius in which flowers are spawned */ private static final double ROSE_RADIUS = 2.5; + /** How many particles accompany each flower spawn */ + private static final int PARTICLE_COUNT = 20; + + /** List of blocks that have flowers in them */ private final Set _blocks = new HashSet<>(); + /** Milliseconds for which flowers persist */ + private final long DURATION = 5000; + /** Locations at which treasure is currently being opened */ private final Map _openingTreasure = new HashMap<>(); + /** Whether flowers can be spawned in addition to particles */ private boolean _enabled = true; public ParticleAuraNiceness(GadgetManager manager) @@ -102,10 +109,10 @@ public class ParticleAuraNiceness extends ParticleGadget if (_enabled) { _blocks.add(b); - Manager.getBlockRestore().add(b, Material.RED_ROSE.getId(), (byte) 3, 5000); + Manager.getBlockRestore().add(b, Material.RED_ROSE.getId(), (byte) 3, DURATION); } - for (int i = 0; i < 20; ++i) + for (int i = 0; i < PARTICLE_COUNT; ++i) { UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 4, 4, 4), 0, UtilParticle.ViewDist.NORMAL); UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 4, 4, 4), 0, UtilParticle.ViewDist.NORMAL); @@ -122,7 +129,7 @@ public class ParticleAuraNiceness extends ParticleGadget { it.remove(); Location loc = b.getLocation().add(H_FIELD, V_FIELD, H_FIELD); - for (int i = 0; i < 10; ++i) + for (int i = 0; i < PARTICLE_COUNT / 2; ++i) { UtilParticle.playColoredParticleToAll(Color.RED, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 6, 6, 6), 0, UtilParticle.ViewDist.NORMAL); UtilParticle.playColoredParticleToAll(Color.WHITE, UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(loc, 6, 6, 6), 0, UtilParticle.ViewDist.NORMAL); @@ -131,6 +138,9 @@ public class ParticleAuraNiceness extends ParticleGadget } } + /** + * Stop flowers from popping off of blocks + */ @EventHandler public void onBlockFade(BlockPhysicsEvent event) { @@ -162,12 +172,18 @@ public class ParticleAuraNiceness extends ParticleGadget } } + /** + * Disable flowers on game start + */ @EventHandler public void onGameStart(CoreGameStartEvent event) { _enabled = false; } + /** + * Enable flowers on game end + */ @EventHandler public void onGameEnd(CoreGameStopEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java index 7984af254..c9efa6b5c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java @@ -18,13 +18,17 @@ import org.bukkit.inventory.meta.BannerMeta; import java.awt.Color; /** - * @author J Teissler - * @date 6/26/17 + * Leaves a trail behind the player with the colors of the Canadian flag. */ public class ParticleCanadian extends ParticleGadget { + /** # of lines of particles */ private static final int STRAND_COUNT = 9; + + /** How far apart each line of particles is */ private static final double STRAND_SPACING = 0.124; + + /** How far off the floor the particles begin */ private static final double DISTANCE_FROM_FLOOR = 0.43; public ParticleCanadian(GadgetManager manager) @@ -33,9 +37,7 @@ public class ParticleCanadian extends ParticleGadget UtilText.splitLineToArray(C.cGray + "Lead the way to freedom!", LineFormat.LORE), -8, Material.WOOL, (byte) 0); - ItemStack stack = CountryFlag.CANADA.getBanner(); - System.out.println(((BannerMeta)stack.getItemMeta()).getBaseColor().getColor().toString()); - setDisplayItem(stack); + setDisplayItem(CountryFlag.CANADA.getBanner()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java index 4234a257b..a7a18702e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleFreedomFireworks.java @@ -13,22 +13,24 @@ import mineplex.core.updater.event.UpdateEvent; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; -import org.bukkit.util.Vector; import java.util.concurrent.ThreadLocalRandom; /** - * @author J Teissler - * @date 6/26/17 + * Small fireworks which explode around the player */ public class ParticleFreedomFireworks extends ParticleGadget { + /** Block types to source for particles */ private static final Material[] BLOCKTYPES = { Material.REDSTONE_BLOCK, Material.LAPIS_BLOCK, Material.QUARTZ_BLOCK }; + /** Amount of particles for each firework */ + private static final int PARTICLE_COUNT = 20; + public ParticleFreedomFireworks(GadgetManager manager) { super(manager, "Freedom Fireworks", @@ -49,7 +51,7 @@ public class ParticleFreedomFireworks extends ParticleGadget String particle = UtilParticle.ParticleType.BLOCK_CRACK.getParticle(BLOCKTYPES[ThreadLocalRandom.current().nextInt(0, BLOCKTYPES.length)], 0); Location location = UtilMath.gauss(player.getEyeLocation(), 1, 1, 1); - for (int i = 0; i < 20; ++i) + for (int i = 0; i < PARTICLE_COUNT; ++i) { UtilParticle.PlayParticleToAll(particle, location, null, 3.0f, 1, UtilParticle.ViewDist.NORMAL); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java index d28b45a17..7b7d71883 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java @@ -5,26 +5,18 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.banner.CountryFlag; -import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.flag.FlagType; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; -import mineplex.core.itemstack.ItemBuilder; -import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.LeatherArmorMeta; /** - * @author J Teissler - * @date 6/26/17 + * Flags which sit upon players head. */ public class FlagGadget extends Gadget { @@ -88,6 +80,9 @@ public class FlagGadget extends Gadget disable(event.getEntity()); } + /** + * @return The specific gadget which this represents. + */ public FlagType getFlagType() { return _flag; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java index ef209276e..281374325 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java @@ -6,9 +6,6 @@ import org.bukkit.entity.Player; import mineplex.core.common.util.Callback; -/** - * Created by Shaun on 9/2/2014. - */ public abstract class Reward { protected static final Random RANDOM = new Random(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java index 8179dbb98..6f3acd00b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardData.java @@ -2,9 +2,6 @@ package mineplex.core.reward; import org.bukkit.inventory.ItemStack; -/** - * Created by shaun on 14-09-18. - */ public class RewardData { private final String _header; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java index 759769234..eff019430 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardRarity.java @@ -7,9 +7,6 @@ import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.common.util.C; import static mineplex.core.common.util.C.*; -/** - * Created by Shaun on 9/2/2014. - */ public enum RewardRarity { /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java index ca001e6a5..15a85c4dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureFinishEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.HandlerList; import mineplex.core.treasure.Treasure; /** - * Created by shaun on 14-09-12. + * Called once a player has finished with the treasure opening process. */ public class TreasureFinishEvent extends Event { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java index d384c61db..29355cfd1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasurePreStartEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; /** - * Created by shaun on 14-09-12. + * Called when a player selects a chest to open. */ public class TreasurePreStartEvent extends Event implements Cancellable { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java index 70c891f52..37d59dc74 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java @@ -10,6 +10,9 @@ import org.bukkit.event.HandlerList; import mineplex.core.reward.Reward; import mineplex.core.treasure.Treasure; +/** + * Called when a player is able to begin opening chests. + */ public class TreasureStartEvent extends Event { private static final HandlerList handlers = new HandlerList(); From 968fec5d77be5fd46a9bec7050a327be8d2e63ee Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 28 Jun 2017 16:41:46 +0100 Subject: [PATCH 023/183] Fix the cages not being removed correctly --- .../game/games/battleroyale/BattleRoyalePlayer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java index 6ceff59dd..fad6dedf9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java @@ -54,7 +54,7 @@ class BattleRoyalePlayer { _location.add(x, -1, z); MapUtil.QuickChangeBlockAt(_location, Material.STAINED_GLASS, colourData); - _cageBlocks.add(_location); + _cageBlocks.add(_location.clone()); _location.subtract(x, -1, z); } } @@ -66,7 +66,7 @@ class BattleRoyalePlayer { _location.add(x, 4, z); MapUtil.QuickChangeBlockAt(_location, Material.STAINED_GLASS, colourData); - _cageBlocks.add(_location); + _cageBlocks.add(_location.clone()); _location.subtract(x, 4, z); } } @@ -85,7 +85,7 @@ class BattleRoyalePlayer _location.add(x, y, z); MapUtil.QuickChangeBlockAt(_location, Material.STAINED_GLASS, colourData); - _cageBlocks.add(_location); + _cageBlocks.add(_location.clone()); _location.subtract(x, y, z); } } @@ -107,7 +107,7 @@ class BattleRoyalePlayer UtilEnt.ghost(_dragon, true, false); _chicken = _location.getWorld().spawn(_location, Chicken.class); - _chicken.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0)); + _chicken.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false)); _dragon.setPassenger(_chicken); _chicken.setPassenger(_player); From 60f4511a79a93a45625a0c32a8b70e8e73ef574b Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:31:39 -0400 Subject: [PATCH 024/183] Swap cosmetic menu positions of items --- .../src/mineplex/core/cosmetic/ui/page/Menu.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index a3275ea39..9814c081b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -74,12 +74,12 @@ public class Menu extends ShopPageBase ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false); - int deathSlot = 1; + int deathSlot = 19; int jumpSlot = 28; - int particleSlot = 10; + int particleSlot = 1; int winEffectSlot = 13; int shardSlot = 22; - int arrowSlot = 19; + int arrowSlot = 10; int tauntSlot = 31; int gameModifierSlot = 21; int kitSelectorSlot = 23; @@ -95,7 +95,7 @@ public class Menu extends ShopPageBase addItem(shardSlot, shards); - ItemStack pane = new ItemBuilder(Material.STAINED_GLASS_PANE).setData((byte)15).setTitle("").build(); + ItemStack pane = new ItemBuilder(Material.STAINED_GLASS_PANE).setData((byte)15).setTitle(C.cBlack).build(); for (int i = 0; i <= 45; i += 9) addItem(i, pane.clone()); for (int i = 8; i <= 53; i += 9) addItem(i, pane.clone()); for (int i = 37; i <= 43; ++i) addItem(i, pane.clone()); From 7f729ca5866c6cbfbc4ad0e9164e721edd7648f0 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:31:48 -0400 Subject: [PATCH 025/183] Add cosmetics unlock command for all players --- .../commands/UnlockCosmeticsCommand.java | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java index 43e1a4756..69e6f863d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java @@ -41,13 +41,30 @@ public class UnlockCosmeticsCommand extends CommandBase { addCosmetics(null, caller); } - else if (args.length == 1) + else if (args.length >= 1) { - Player player = Bukkit.getPlayer(args[0]); - if (player != null) + if (args[0].equalsIgnoreCase("all")) { - addCosmetics(null, player); - UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added all the cosmetics to " + F.name(player.getName()) + "!")); + for (Player player : UtilServer.getPlayers()) + { + if (player != null) + { + addCosmetics(null, player); + UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added all the cosmetics to " + F.name(player.getName()) + "!")); + } + } + } + else + { + for (int i = 0; i < args.length; ++i) + { + Player player = Bukkit.getPlayer(args[i]); + if (player != null) + { + addCosmetics(null, player); + UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added all the cosmetics to " + F.name(player.getName()) + "!")); + } + } } } } From ea7475b95018c90cfb4b20a96fa8f3f01ac1fcb0 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:32:00 -0400 Subject: [PATCH 026/183] Add white to maple leaf death effect --- .../src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java index 194a2b6d4..3cfeeb034 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathMapleLeaf.java @@ -22,7 +22,7 @@ public class DeathMapleLeaf extends DeathEffectGadget /** height off the ground of the leaf */ private static final double HEIGHT = 3; - private final ShapeWings _leafOuter = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1.0, 0, 0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); + private final ShapeWings _leafOuter = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1.0, 1.0, 1.0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); private final ShapeWings _leafInner = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0.7, 0, 0), 1, 0, false, 0, ShapeWings.MAPLE_LEAF); public DeathMapleLeaf(GadgetManager manager) From 37996e6901424eeb64b89c0ec879ae43feddf4fd Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:32:12 -0400 Subject: [PATCH 027/183] Remove green from candy cane cosmetics --- .../core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java | 2 +- .../core/gadget/gadgets/particle/ParticleCandyCane.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java index 62f3ad6c4..209da4b7c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpCandyCane.java @@ -30,7 +30,7 @@ public class DoubleJumpCandyCane extends DoubleJumpEffectGadget Location loc = player.getLocation(); UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 1), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); - UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 2), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, 0, 0, 0, 0.15f, 100, ViewDist.NORMAL); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java index 5f31b13fb..e9e572f19 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCandyCane.java @@ -63,7 +63,7 @@ public class ParticleCandyCane extends ParticleGadget UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 1), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); - UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 2), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); + UtilParticle.playParticleFor(player, UtilParticle.ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, 15), loc, w, y, w, 0, a, UtilParticle.ViewDist.NORMAL); } @EventHandler From 1899272a10aefc61b075f54bedcbd4d423f12b40 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:32:19 -0400 Subject: [PATCH 028/183] Reduce coal fume particles --- .../core/gadget/gadgets/particle/ParticleCoalFumes.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java index 236bc1e8a..651993fb9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java @@ -1,5 +1,6 @@ package mineplex.core.gadget.gadgets.particle; +import mineplex.core.common.util.UtilMath; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -27,7 +28,7 @@ public class ParticleCoalFumes extends ParticleGadget @Override public void playParticle(Player player, UpdateEvent event) { - if(event.getType() != UpdateType.TICK) return; + if(event.getType() != UpdateType.FASTER) return; float xz = 1; int amount = 5; @@ -39,6 +40,6 @@ public class ParticleCoalFumes extends ParticleGadget amount = 2; } - UtilParticle.playParticleFor(player, type, player.getLocation(), xz, 0, xz, 0, amount, ViewDist.NORMAL); + UtilParticle.playParticleFor(player, type, UtilMath.gauss(player.getLocation(), 2, 6, 2), xz, 0, xz, 0, amount, ViewDist.NORMAL); } } From 901d62c8e09061be23c29e9efb4ea0da204a9764 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:32:39 -0400 Subject: [PATCH 029/183] Distribute heart particles using a gaussian curve --- .../mineplex/core/gadget/gadgets/particle/ParticleHeart.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java index ca008bc75..c48b0ddb4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleHeart.java @@ -1,5 +1,6 @@ package mineplex.core.gadget.gadgets.particle; +import mineplex.core.common.util.UtilMath; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -37,11 +38,11 @@ public class ParticleHeart extends ParticleGadget { if(getSet() == null || !getSet().isActive(player)) return; - UtilParticle.playParticleFor(player, ParticleType.HEART, player.getLocation().add(0, 1, 0), null, 0, 1, ViewDist.NORMAL); + UtilParticle.playParticleFor(player, ParticleType.HEART, player.getLocation().add(0, 1.2, 0), null, 0, 1, ViewDist.NORMAL); } else { - UtilParticle.playParticleFor(player, ParticleType.HEART, player.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, ViewDist.NORMAL); + UtilParticle.playParticleFor(player, ParticleType.HEART, UtilMath.gauss(player.getLocation(), 1, 3, 1).add(0, 1.2, 0), null, 0, 1, ViewDist.NORMAL); } } From cfc223f52ac51bf9e4b8ecee5aca9f9de6a39d9d Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:32:52 -0400 Subject: [PATCH 030/183] Correctly handle taunt cooldowns --- .../gadget/gadgets/taunts/BlowAKissTaunt.java | 8 ++++++-- .../gadget/gadgets/taunts/EternalTaunt.java | 20 +++++++++++++------ .../gadget/gadgets/taunts/RainbowTaunt.java | 8 ++++++-- .../core/gadget/types/TauntGadget.java | 8 +++++--- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java index fdc5da288..c246b2975 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java @@ -35,10 +35,12 @@ public class BlowAKissTaunt extends TauntGadget } @Override - public void onStart(Player player) + public boolean onStart(Player player) { if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) - return; + { + return false; + } HashSet ignore = new HashSet<>(); ignore.add(Material.AIR); @@ -46,6 +48,8 @@ public class BlowAKissTaunt extends TauntGadget BlowAKissEffect blowAKissEffect = new BlowAKissEffect(player, loc, this); blowAKissEffect.start(); + + return true; } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java index 1e0c943b7..59d3c5484 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java @@ -29,9 +29,7 @@ import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.events.EnableArcadeSpawnEvent; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.TauntGadget; -import mineplex.core.game.GameDisplay; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -52,18 +50,21 @@ public class EternalTaunt extends TauntGadget C.cWhite + "Use /taunt in game to show how long you've been waiting.", C.cRed + "Cannot be used while in PvP!"}, LineFormat.LORE), -15, Material.WATCH, (byte) 0); + setCanPlayWithPvp(false); setPvpCooldown(PVP_COOLDOWN); setShouldPlay(true); setEventType(UpdateType.FAST); - addDisabledGames(GameDisplay.Smash, GameDisplay.SmashTeams, GameDisplay.SmashDomination); } @Override - public void onStart(Player player) + public boolean onStart(Player player) { if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) - return; + { + return false; + } + UtilFirework.playFirework(player.getLocation(), FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.fromRGB(255, 175, 175)).withFade(Color.RED).build()); _clocks.put(player.getUniqueId(), new ArrayList<>()); @@ -73,16 +74,23 @@ public class EternalTaunt extends TauntGadget if (!Manager.getDisguiseManager().isDisguised(player)) { DisguiseSkeleton disguiseSkeleton = new DisguiseSkeleton(player); - UtilMorph.disguise(player, disguiseSkeleton, Manager); + disguiseSkeleton.setName(player.getName()); + disguiseSkeleton.setCustomNameVisible(true); + disguiseSkeleton.showArmor(); + Manager.getDisguiseManager().disguise(disguiseSkeleton); _disguises.put(player.getUniqueId(), disguiseSkeleton); } + + return true; } @Override public void onPlay(Player player) { if (!_clocks.containsKey(player.getUniqueId())) + { return; + } int i = getPlayerTicks(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java index de81b6a1b..6a49fe8c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java @@ -36,10 +36,12 @@ public class RainbowTaunt extends TauntGadget } @Override - public void onStart(Player player) + public boolean onStart(Player player) { if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) - return; + { + return false; + } Vector dir = player.getLocation().getDirection(); Vector sideA = dir.clone().setX(-dir.getZ()).setZ(dir.getX()); @@ -51,6 +53,8 @@ public class RainbowTaunt extends TauntGadget RainbowTauntEffect rainbowTauntEffect = new RainbowTauntEffect(start, Manager.getPlugin()); rainbowTauntEffect.setTargetLocation(new EffectLocation(end)); rainbowTauntEffect.start(); + + return true; } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java index 991a7425b..c0b11870d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java @@ -76,11 +76,13 @@ public abstract class TauntGadget extends Gadget public void start(Player player) { - onStart(player); - _ticksPerPlayer.put(player.getUniqueId(), 0); + if (onStart(player)) + { + _ticksPerPlayer.put(player.getUniqueId(), 0); + } } - public abstract void onStart(Player player); + public abstract boolean onStart(Player player); public void play(Player player) { From ca8041e5b72647eaa5567cb69dad3d1321a482fa Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:33:00 -0400 Subject: [PATCH 031/183] Change Legend Aura to green --- .../gadgets/particle/ParticleLegend.java | 59 ++++++++----------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java index 51911de42..8337efae4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java @@ -2,7 +2,6 @@ package mineplex.core.gadget.gadgets.particle; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -19,32 +18,27 @@ import mineplex.core.inventory.ClientItem; import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.util.Vector; import java.awt.Color; -import java.util.Random; public class ParticleLegend extends ParticleGadget { private static final double PI = Math.PI; private static final int BASE_PILLARS = 9; - private static final int PILLAR_VARIANCE = 7; - private static final int COLOR_VARIANCE = 5; + private static final int PILLAR_VARIANCE = 8; private static final int MOVING_PARTICLES = 8; private static final double VERTICAL_SPEED = 0.1; private static final double HEIGHT_VARIANCE = 0.8; private static final double ROTATIONAL_SPEED = .03; private static final double RADIAL_VARIANCE = 0.09; - private static final double DARK_PARTICLE_CHANCE = 0.5; private static final double BASE_RADIUS = 1.30; private static final double HEIGHT_MODIFIER_BASE = 0.1; private static final double HEIGHT_MODIFIER_MAX = 1.3; - private static final double HEIGHT_MODIFIER_INTERVAL = 0.2; + private static final double HEIGHT_MODIFIER_INTERVAL = 0.15; private static final Color[] SELECTABLE_COLORS = { - new Color(170, 100, 170), - new Color(50, 10, 60), - new Color(120, 10, 170), - new Color(65, 20, 80) + new Color(60, 170, 25), + new Color(33, 92, 13), + new Color(0, 0, 0) }; private final int _pillars = pillars(); @@ -58,7 +52,7 @@ public class ParticleLegend extends ParticleGadget public ParticleLegend(GadgetManager manager) { super(manager, "Legendary Aura", - UtilText.splitLineToArray(C.cGray + "Let the energy of the End protect you.", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "Legendary energy protects you.", LineFormat.LORE), -1, Material.ENDER_PORTAL_FRAME, (byte)0); } @@ -73,12 +67,19 @@ public class ParticleLegend extends ParticleGadget if (Manager.isMoving(player)) { - Location loc = player.getLocation().add(0, 1.5, 0); for (int i = 0; i < MOVING_PARTICLES; i++) { - UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, - UtilMath.gauss(loc, 8, 4, 8), 0, UtilParticle.ViewDist.NORMAL); + if (_colors[i].getGreen() == 0) + { + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.SMOKE, + UtilMath.gauss(player.getLocation(), 8, 4, 8), null, 0, 1, UtilParticle.ViewDist.NORMAL); + } + else + { + UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, + UtilMath.gauss(player.getLocation(), 8, 4, 8), 0, UtilParticle.ViewDist.NORMAL); + } } } else @@ -96,12 +97,14 @@ public class ParticleLegend extends ParticleGadget for (double h = HEIGHT_MODIFIER_BASE; h <= HEIGHT_MODIFIER_MAX; h+= HEIGHT_MODIFIER_INTERVAL) { - UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, - new Location(player.getWorld(), x, y + h, z), 0, UtilParticle.ViewDist.NORMAL); - - if (Math.random() < DARK_PARTICLE_CHANCE) + if (_colors[i].getGreen() == 0) { - UtilParticle.playColoredParticleToAll(Color.BLACK, UtilParticle.ParticleType.RED_DUST, + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.SMOKE, + new Location(player.getWorld(), x, y + h, z), null, 0, 1, UtilParticle.ViewDist.NORMAL); + } + else + { + UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, new Location(player.getWorld(), x, y + h, z), 0, UtilParticle.ViewDist.NORMAL); } } @@ -175,23 +178,11 @@ public class ParticleLegend extends ParticleGadget private Color[] colors() { - Random random = new Random(); - Color[] array = new Color[_pillars]; for (int i = 0; i < _pillars; i++) { - Color color = SELECTABLE_COLORS[i % SELECTABLE_COLORS.length]; - - int r = color.getRed() + (int) (random.nextGaussian() * COLOR_VARIANCE); - int g = color.getGreen() + (int) (random.nextGaussian() * COLOR_VARIANCE); - int b = color.getBlue() + (int) (random.nextGaussian() * COLOR_VARIANCE); - - r = Math.min(255, Math.max(0, r)); - g = Math.min(255, Math.max(0, g)); - b = Math.min(255, Math.max(0, b)); - - array[i] = new Color(r, g, b); + array[i] = SELECTABLE_COLORS[i % SELECTABLE_COLORS.length]; } return array; @@ -213,7 +204,7 @@ public class ParticleLegend extends ParticleGadget return value; } - + @EventHandler public void legendOwner(PlayerJoinEvent event) { From 61b8ed971d23bddd64312d551b3d4ca5f9aa603a Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:33:18 -0400 Subject: [PATCH 032/183] Spawn trail particles behind player model --- .../core/gadget/gadgets/particle/freedom/ParticleCanadian.java | 3 ++- .../gadget/gadgets/particle/freedom/ParticleStarSpangled.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java index c9efa6b5c..4770908b9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleCanadian.java @@ -48,7 +48,8 @@ public class ParticleCanadian extends ParticleGadget return; } - Location center = player.getLocation().add(0, DISTANCE_FROM_FLOOR, 0); + Location center = player.getLocation().subtract(player.getLocation().getDirection().multiply(0.4)) + .subtract(0, 0.1, 0).add(0, DISTANCE_FROM_FLOOR, 0); if (Manager.isMoving(player)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java index cf65cb0dd..7ad601f9a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleStarSpangled.java @@ -47,7 +47,8 @@ public class ParticleStarSpangled extends ParticleGadget return; } - Location center = player.getLocation().add(0, DISTANCE_FROM_FLOOR, 0); + Location center = player.getLocation().subtract(player.getLocation().getDirection().multiply(0.4)) + .subtract(0, 0.1, 0).add(0, DISTANCE_FROM_FLOOR, 0); if (Manager.isMoving(player)) { From 6abeadf0ea8707c89a45f037fdabe51416c47271 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:33:28 -0400 Subject: [PATCH 033/183] Align flowers correctly in spring leap --- .../core/gadget/gadgets/doublejump/DoubleJumpSpring.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java index c4d06c230..527b44b0f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpSpring.java @@ -38,7 +38,7 @@ public class DoubleJumpSpring extends DoubleJumpEffectGadget { for (int i = 50; i < 60; i++) { - Item sunflower = player.getWorld().dropItem(player.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); + Item sunflower = player.getWorld().dropItem(player.getLocation().add(0.0, 0.2, 0.0), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); _items.add(sunflower); Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d)); From 2e23aae024af070e3a75d9c136ebac037c3a70b5 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:33:49 -0400 Subject: [PATCH 034/183] Change niceness aura to use red and white tulips --- .../gadget/gadgets/particle/freedom/ParticleAuraNiceness.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java index 99a22fff4..2e68270e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/freedom/ParticleAuraNiceness.java @@ -108,8 +108,10 @@ public class ParticleAuraNiceness extends ParticleGadget if (_enabled) { + byte data = ThreadLocalRandom.current().nextInt(2) == 0 ? (byte) 4 : 6; + _blocks.add(b); - Manager.getBlockRestore().add(b, Material.RED_ROSE.getId(), (byte) 3, DURATION); + Manager.getBlockRestore().add(b, Material.RED_ROSE.getId(), data, DURATION); } for (int i = 0; i < PARTICLE_COUNT; ++i) From 2ef463c8595b35c4421c002d7af6f04f7ec6e5c0 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:36:59 -0400 Subject: [PATCH 035/183] Update disabled games for eternal taunt --- .../src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java index 59d3c5484..6e0a7e133 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java @@ -7,6 +7,7 @@ import java.util.Map; import java.util.UUID; import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.game.GameDisplay; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -55,6 +56,7 @@ public class EternalTaunt extends TauntGadget setPvpCooldown(PVP_COOLDOWN); setShouldPlay(true); setEventType(UpdateType.FAST); + addDisabledGames(GameDisplay.Smash, GameDisplay.SmashTeams, GameDisplay.SmashDomination, GameDisplay.SmashTraining); } @Override From f291d378962ecfef447977aeed43e043fa65b9ef Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 28 Jun 2017 18:40:24 -0400 Subject: [PATCH 036/183] Stop outfits from taking off flags --- .../src/mineplex/core/gadget/types/OutfitGadget.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java index e5ab85cb3..78471a943 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java @@ -60,7 +60,12 @@ public abstract class OutfitGadget extends Gadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); - Manager.removeGadgetType(player, GadgetType.FLAG, this); + + if (_slot == ArmorSlot.HELMET) + { + Manager.removeGadgetType(player, GadgetType.FLAG, this); + } + Manager.removeOutfit(player, _slot); _active.add(player); From a8e17996172e4562381c3e2f91d3c43c90a2a22e Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 30 Jun 2017 00:27:12 +0100 Subject: [PATCH 037/183] Fix Deathbomber achievement tracker --- .../arcade/stats/DeathBomberStatTracker.java | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java index 61d4b8923..ddaf85fe4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java @@ -1,12 +1,15 @@ package nautilus.game.arcade.stats; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.Game; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.inventory.ItemStack; import java.util.HashMap; import java.util.Map; @@ -51,11 +54,6 @@ public class DeathBomberStatTracker extends StatTracker if(killer.equals(killed)) return; - if (killer.getItemInHand().getType() != Material.TNT) - { - return; - } - if (event.GetLog().GetKiller() != null && event.GetLog().GetKiller().GetReason().contains("Throwing TNT")) { Integer count = _killCount.get(killer.getUniqueId()); @@ -70,4 +68,32 @@ public class DeathBomberStatTracker extends StatTracker addStat(killer, "DeathBomber", 1, true, false); } } + + @EventHandler + public void removeFakeThrowingTNT(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (Player player : getGame().GetPlayers(true)) + { + ItemStack[] contents = player.getInventory().getContents(); + int i = 0; + + for (ItemStack itemStack : contents) + { + if (itemStack == null || itemStack.getItemMeta() == null || itemStack.getItemMeta().getDisplayName() == null) + { + continue; + } + + if (itemStack.getItemMeta().getDisplayName().contains("Throwing TNT") && itemStack.getType() != Material.TNT) + { + player.getInventory().setItem(i, null); + } + } + } + } } From 67d792e9d733ffe4ba1c226a2de4f4dd9744b50c Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 30 Jun 2017 12:57:20 +0100 Subject: [PATCH 038/183] More progress --- .../src/nautilus/game/arcade/GameType.java | 2 +- .../game/games/battleroyale/BattleRoyale.java | 453 +++++++++++++++++- .../battleroyale/BattleRoyalePlayer.java | 25 +- .../games/battleroyale/BattleRoyaleSolo.java | 166 +++++-- .../battleroyale/BattleRoyaleSupplyDrop.java | 185 +++++++ .../game/arcade/game/games/bridge/Bridge.java | 8 - .../game/modules/CustomScoreboardModule.java | 1 + .../game/modules/WorldBorderModule.java | 116 ----- .../game/modules/chest/ChestLootModule.java | 60 ++- 9 files changed, 829 insertions(+), 187 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSupplyDrop.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/WorldBorderModule.java 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 7cefa2340..80a5490f1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -242,7 +242,7 @@ public enum GameType { Pair.create(MinecraftVersion.Version1_8, "http://file.mineplex.com/ResStrikeGames18.zip"), Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResStrikeGames19.zip") - }, false), + }, true), Event(EventGame.class, GameDisplay.Event, new GameType[]{ GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java index c4695a3b7..be32bb923 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java @@ -16,6 +16,8 @@ import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +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; @@ -29,6 +31,7 @@ import nautilus.game.arcade.game.modules.chest.ChestLootPool; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import org.bukkit.Bukkit; +import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -42,9 +45,22 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.AnvilInventory; +import org.bukkit.inventory.EnchantingInventory; +import org.bukkit.inventory.FurnaceInventory; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitRunnable; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -55,27 +71,55 @@ import java.util.concurrent.atomic.AtomicInteger; public abstract class BattleRoyale extends Game { - private static final long PREPARE_TIME = TimeUnit.SECONDS.toMillis(20); + private static final long PREPARE_TIME = TimeUnit.SECONDS.toMillis(30); + private static final int MIN_CORD = 100; private static final int MAX_CORD = 1000; private static final int SPAWN_Y = 130; private static final int WORLD_SIZE_BUFFER = 300; private static final int MIN_DISTANCE_APART_FOR_SPAWNS_SQUARED = 100; + private static final long MIN_DRAGON_TIME = TimeUnit.SECONDS.toMillis(5); private static final long MAX_DRAGON_TIME = TimeUnit.SECONDS.toMillis(60); private static final long BORDER_TIME = TimeUnit.MINUTES.toSeconds(20); + protected static final long SUPPLY_DROP_TIME = TimeUnit.MINUTES.toMillis(5); + private static final int MAX_DROPS_PER_GAME = 3; - private final Map _playerData = new HashMap<>(70); + private static final ItemStack SMALL_BACKPACK = new ItemBuilder(Material.CHEST) + .setTitle(C.cGreen + "Small Backpack") + .addLore("Clicking this will unlock a new row in your inventory!") + .build(); + private static final ItemStack LARGE_BACKPACK = new ItemBuilder(Material.ENDER_CHEST) + .setTitle(C.cGreen + "Large Backpack") + .addLore("Clicking this will unlock two new rows in your inventory!") + .build(); + + private static final ItemStack SMALL_HEALTH_POT = new ItemBuilder(Material.POTION) + .setTitle(C.cGreen + "Small Health Pot") + .addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0)) + .build(); + + private static final ItemStack LARGE_HEALTH_POT = new ItemBuilder(Material.POTION) + .setTitle(C.cGreen + "Large Health Pot") + .addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1)) + .build(); + + protected final Map _playerData = new HashMap<>(70); protected GunModule _gunModule; protected WorldBorder _border; private boolean _colouredMessage; + protected BattleRoyaleSupplyDrop _supplyDrop; + protected long _lastSupplyDrop; + private int _totalDrops; + public BattleRoyale(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc) { super(manager, gameType, kits, gameDesc); // TODO REMOVE THIS TeleportsDisqualify = false; + TickPerTeleport = 20; PrepareTime = PREPARE_TIME; PrepareFreeze = false; @@ -114,14 +158,23 @@ public abstract class BattleRoyale extends Game new CompassModule() .register(this); + + manager.GetCreature().SetDisableCustomDrops(true); } @Override public void ParseData() { + List chestSpawns = new ArrayList<>(500); + chestSpawns.addAll(WorldData.GetDataLocs("ORANGE")); + chestSpawns.addAll(WorldData.GetDataLocs("GREEN")); + chestSpawns.addAll(WorldData.GetDataLocs("YELLOW")); + chestSpawns.addAll(WorldData.GetDataLocs("BLUE")); + new ChestLootModule() + .destoryAfterOpened(20) .spawnNearbyDataPoints() - .registerChestType("Standard", WorldData.GetDataLocs("ORANGE"), + .registerChestType("Standard", chestSpawns, // Guns new ChestLootPool() @@ -130,22 +183,76 @@ public abstract class BattleRoyale extends Game .addItem(buildFromGun(GunStats.DEAGLE)) .addItem(buildFromGun(GunStats.P250)) .addItem(buildFromGun(GunStats.P2000)) + .addItem(buildFromGun(GunStats.P90), 0.5) + .addItem(buildFromGun(GunStats.PPBIZON), 0.5) + .addItem(buildFromGun(GunStats.GALIL), 0.2) + .addItem(buildFromGun(GunStats.FAMAS), 0.2) .addItem(buildFromGun(GunStats.AK47), 0.2) .addItem(buildFromGun(GunStats.M4A4), 0.2) + .addItem(buildFromGun(GunStats.SG553), 0.2) + .addItem(buildFromGun(GunStats.AUG), 0.2) + .addItem(buildFromGun(GunStats.SSG08), 0.2) + .addItem(buildFromGun(GunStats.NOVA), 0.2) + .addItem(buildFromGun(GunStats.XM1014), 0.2) .setProbability(0.4) , + // Grenades + new ChestLootPool() + .addItem(buildGrenade(Material.CARROT_ITEM, "Flash Bang")) + .addItem(buildGrenade(Material.APPLE, "High Explosive")) + .addItem(buildGrenade(Material.POTATO_ITEM, "Smoke")) + .addItem(buildGrenade(Material.PORK, "Incendiary"), 0.5) + .addItem(buildGrenade(Material.GRILLED_PORK, "Molotov"), 0.5) + .setProbability(0.2) + , + // Weapons new ChestLootPool() - .addItem(new ItemStack(Material.WOOD_SWORD)) - .addItem(new ItemStack(Material.STONE_SWORD), 0.3) - .setProbability(0.5) + .addItem(new ItemStack(Material.BOW)) + .setProbability(0.05) + , + + // Ammo + new ChestLootPool() + .addItem(new ItemStack(Material.ARROW), 1, 8) + .setProbability(0.2) + .setAmountsPerChest(1, 3) + , + + // Medical + new ChestLootPool() + .addItem(SMALL_HEALTH_POT) + .addItem(LARGE_HEALTH_POT) + .setProbability(0.2) + .setAmountsPerChest(1, 2) , // Armour new ChestLootPool() - .addItem(new ItemStack(Material.LEATHER_HELMET)) - .addItem(new ItemStack(Material.LEATHER_CHESTPLATE)) + .addItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cRed + "Red Baseball Cap") + .setColor(Color.RED) + .build()) + .addItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cAqua + "Blue Baseball Cap") + .setColor(Color.BLUE) + .build()) + .addItem(new ItemBuilder(Material.CHAINMAIL_HELMET) + .setTitle(C.cDGreen + "Tactical Helmet") + .build()) + .addItem(new ItemBuilder(Material.IRON_HELMET) + .setTitle(C.cDGreen + "Motorcycle Helmet") + .build()) + .addItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cDGreen + "Wooden Body Armour") + .build()) + .addItem(new ItemBuilder(Material.CHAINMAIL_CHESTPLATE) + .setTitle(C.cDGreen + "Plated Body Armour") + .build()) + .addItem(new ItemBuilder(Material.IRON_CHESTPLATE) + .setTitle(C.cDGreen + "Laminated Tactical Body Armour") + .build()) .addItem(new ItemStack(Material.LEATHER_LEGGINGS)) .addItem(new ItemStack(Material.LEATHER_BOOTS)) , @@ -167,9 +274,59 @@ public abstract class BattleRoyale extends Game // Misc new ChestLootPool() + .addItem(new ItemStack(Material.STRING), 1, 2, 0.5) .addItem(new ItemStack(Material.STICK), 1, 2) + .addItem(new ItemStack(Material.FLINT), 1, 2) + .addItem(new ItemStack(Material.FEATHER), 1, 2) + .addItem(SMALL_BACKPACK, 0.5) + .addItem(LARGE_BACKPACK, 0.2) .setProbability(0.2) + .setAmountsPerChest(1, 2) ) + .registerChestType("Supply Drop", new ArrayList<>(0), + + // Guns + new ChestLootPool() + .addItem(buildFromGun(GunStats.AUG)) + .addItem(buildFromGun(GunStats.AK47)) + .addItem(buildFromGun(GunStats.M4A4)) + .addItem(buildFromGun(GunStats.XM1014)) + .addItem(buildFromGun(GunStats.AWP)) + .setAmountsPerChest(1, 2) + , + // Backpack + new ChestLootPool() + .addItem(SMALL_BACKPACK) + .addItem(LARGE_BACKPACK) + , + + // Armour + new ChestLootPool() + .addItem(new ItemBuilder(Material.IRON_HELMET) + .setTitle(C.cDGreen + "Motorcycle Helmet") + .build()) + .addItem(new ItemBuilder(Material.IRON_CHESTPLATE) + .setTitle(C.cDGreen + "Laminated Tactical Body Armour") + .build()) + , + + // Grenades + new ChestLootPool() + .addItem(buildGrenade(Material.CARROT_ITEM, "Flash Bang")) + .addItem(buildGrenade(Material.APPLE, "High Explosive")) + .addItem(buildGrenade(Material.POTATO_ITEM, "Smoke")) + .addItem(buildGrenade(Material.PORK, "Incendiary"), 0.5) + .addItem(buildGrenade(Material.GRILLED_PORK, "Molotov"), 0.5) + .setAmountsPerChest(1, 2) + , + + // Medical + new ChestLootPool() + .addItem(SMALL_HEALTH_POT) + .addItem(LARGE_HEALTH_POT) + .setAmountsPerChest(1, 2) + + ) .register(this); WorldData.MinX = -MAX_CORD; @@ -187,6 +344,19 @@ public abstract class BattleRoyale extends Game .build(); } + private ItemStack buildGrenade(Material material, String name) + { + return new ItemBuilder(material) + .setTitle(C.cDGreenB + name) + .build(); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + } + @EventHandler public void prepare(GameStateChangeEvent event) { @@ -252,7 +422,7 @@ public abstract class BattleRoyale extends Game index.getAndIncrement(); } - }, 100, 2); + }, 200, 2); } private Location getPlayerSpawn(int initialXZ) @@ -296,7 +466,7 @@ public abstract class BattleRoyale extends Game while (attempts++ < 20) { - Location location = UtilAlg.getRandomLocation(GetSpectatorLocation(), 200, 0, 200); + Location location = UtilAlg.getRandomLocation(GetSpectatorLocation(), WORLD_SIZE_BUFFER, 0, WORLD_SIZE_BUFFER); Block block = location.getBlock(); while (!UtilBlock.solid(block)) @@ -309,10 +479,7 @@ public abstract class BattleRoyale extends Game continue; } - if (UtilBlock.airFoliage(UtilBlock.getHighest(location.getWorld(), location.getBlock()))) - { - return location; - } + return location; } return SpectatorSpawn; @@ -326,12 +493,23 @@ public abstract class BattleRoyale extends Game return; } + _lastSupplyDrop = System.currentTimeMillis(); + CreatureAllowOverride = true; + ItemStack locked = new ItemBuilder(Material.STAINED_GLASS_PANE, (byte) 15) + .setTitle(C.cGray + "Locked") + .build(); + _playerData.forEach((player, battleRoyalePlayer) -> { battleRoyalePlayer.removeCage(); battleRoyalePlayer.spawnDragon(); + + for (int i = 18; i < player.getInventory().getSize(); i++) + { + player.getInventory().setItem(i, locked); + } }); CreatureAllowOverride = false; @@ -363,7 +541,7 @@ public abstract class BattleRoyale extends Game EnderDragon dragon = royalePlayer.getDragon(); Chicken chicken = royalePlayer.getChicken(); - if (dragon == null || chicken == null) + if (dragon == null || !dragon.isValid() || chicken == null || !chicken.isValid()) { continue; } @@ -371,23 +549,21 @@ public abstract class BattleRoyale extends Game UtilTextBottom.display((_colouredMessage ? C.cGreenB : C.cWhiteB) + "PRESS YOUR SNEAK KEY TO DISMOUNT YOUR DRAGON", player); if (dragon.getPassenger() == null || chicken.getPassenger() == null) { - if (!UtilTime.elapsed(GetStateTime(), 4000)) + if (!UtilTime.elapsed(GetStateTime(), MIN_DRAGON_TIME)) { - player.sendMessage(F.main("Game", "Did you accidentally press sneak? Don't worry I'll put you back on your dragon.")); + player.sendMessage(F.main("Game", "Did you accidentally press sneak? It's too soon to jump! Don't worry I'll put you back on your dragon.")); dragon.setPassenger(chicken); chicken.setPassenger(player); continue; } dismountDragon(player, royalePlayer); - iterator.remove(); } } if (!Damage && UtilTime.elapsed(GetStateTime(), MAX_DRAGON_TIME)) { _playerData.forEach(this::dismountDragon); - _playerData.clear(); Announce(C.cRedB + "Grace Period Over!", false); @@ -398,12 +574,17 @@ public abstract class BattleRoyale extends Game Damage = true; HungerSet = -1; - _border.setSize(100, BORDER_TIME); + _border.setSize(MIN_CORD, BORDER_TIME); } } private void dismountDragon(Player player, BattleRoyalePlayer royalePlayer) { + if (!royalePlayer.getDragon().isValid()) + { + return; + } + // Recharge this so that players won't take fall damage for the next 10 seconds Recharge.Instance.useForce(player, "Fall Damage", TimeUnit.SECONDS.toMillis(10)); player.playSound(player.getLocation(), Sound.BLAZE_DEATH, 1, 0.6F); @@ -434,9 +615,241 @@ public abstract class BattleRoyale extends Game } } + @Override + public void disable() + { + super.disable(); + + if (_supplyDrop != null) + { + _supplyDrop.cleanup(); + } + } + + @EventHandler + public void updateSupplyDrop(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !IsLive()) + { + return; + } + + if (_totalDrops < MAX_DROPS_PER_GAME && UtilTime.elapsed(_lastSupplyDrop, SUPPLY_DROP_TIME)) + { + _lastSupplyDrop = System.currentTimeMillis(); + + List locations = WorldData.GetDataLocs("RED"); + Location location = null; + int attempts = 0; + + while (location == null || attempts++ < 20) + { + location = UtilAlg.Random(locations); + + if (UtilWorld.inWorldBorder(location)) + { + break; + } + } + + _supplyDrop = new BattleRoyaleSupplyDrop(this, location); + _totalDrops++; + Announce(C.cGoldB + "A New Supply Drop Will Spawn At " + C.cYellow + UtilWorld.locToStrClean(_supplyDrop.getDropLocation()) + C.cGold + "!"); + } + else if (_supplyDrop != null && _supplyDrop.isOpened()) + { + _supplyDrop = null; + } + } + + @EventHandler + public void playerDeath(CombatDeathEvent event) + { + Player player = (Player) event.GetEvent().getEntity(); + CombatComponent killer = event.GetLog().GetKiller(); + + if (killer.IsPlayer()) + { + Player killerPlayer = UtilPlayer.searchExact(killer.getUniqueIdOfEntity()); + + if (killerPlayer != null) + { + BattleRoyalePlayer royalePlayer = _playerData.get(killerPlayer); + + if (royalePlayer != null) + { + royalePlayer.incrementKills(); + UtilTextBottom.display(C.cRedB + royalePlayer.getKills() + " Kill" + (royalePlayer.getKills() == 1 ? "" : "s")); + } + } + } + + List attackers = event.GetLog().GetAttackers(); + + for (CombatComponent attacker : attackers) + { + if (!attacker.IsPlayer() || killer.equals(attacker)) + { + continue; + } + + Player attackerPlayer = UtilPlayer.searchExact(attacker.getUniqueIdOfEntity()); + + if (attackerPlayer == null) + { + continue; + } + + BattleRoyalePlayer royalePlayer = _playerData.get(attackerPlayer); + + if (royalePlayer != null) + { + attackerPlayer.sendMessage(F.main("Game", "You assisted in killing " + F.name(player.getName()) + ".")); + royalePlayer.incrementAssists(); + } + } + } + + @EventHandler + public void preventLockedInventoryClick(InventoryClickEvent event) + { + Player player = (Player) event.getWhoClicked(); + ItemStack itemStack = event.getCurrentItem(); + + if (event.getClickedInventory() == null || itemStack == null) + { + return; + } + + if (itemStack.getType() == Material.STAINED_GLASS_PANE) + { + event.setCancelled(true); + player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0.6F); + } + } + + @EventHandler + public void clickBackpack(InventoryClickEvent event) + { + Player player = (Player) event.getWhoClicked(); + ItemStack itemStack = event.getCurrentItem(); + + if (event.getClickedInventory() == null || itemStack == null) + { + return; + } + + int slots = 0; + + if (itemStack.isSimilar(SMALL_BACKPACK)) + { + slots = 9; + } + else if (itemStack.isSimilar(LARGE_BACKPACK)) + { + slots = 18; + } + + if (slots == 0) + { + return; + } + + ItemStack[] items = player.getInventory().getContents(); + int removed = 0; + + for (int i = 0; i < items.length && removed < slots; i++) + { + ItemStack inventoryItem = items[i]; + + if (inventoryItem != null && inventoryItem.getType() == Material.STAINED_GLASS_PANE) + { + player.getInventory().setItem(i, null); + removed++; + } + } + + event.setCurrentItem(null); + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1); + player.sendMessage(F.main("Game", "You unlocked an additional " + F.elem(removed) + " slots in your inventory.")); + } + + @EventHandler + public void noHungerRegeneration(EntityRegainHealthEvent event) + { + if (event.getRegainReason() == RegainReason.SATIATED) + { + event.setCancelled(true); + } + } + + @EventHandler + public void inventoryOpen(InventoryOpenEvent event) + { + Inventory inventory = event.getInventory(); + + if (inventory instanceof EnchantingInventory || inventory instanceof AnvilInventory || inventory instanceof FurnaceInventory) + { + event.setCancelled(true); + } + } + @EventHandler public void damageToLevel(CustomDamageEvent event) { event.SetDamageToLevel(false); } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _playerData.remove(event.getPlayer()); + } + + @EventHandler + public void removeEmptyPotions(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (Player player : GetPlayers(true)) + { + player.getInventory().remove(Material.GLASS_BOTTLE); + } + } + + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + if (!IsLive()) + { + return; + } + + event.getDrops().removeIf(itemStack -> itemStack.getType() == Material.STAINED_GLASS_PANE); + + Player player = event.getEntity(); + awardTimeGems(player); + } + + protected void awardTimeGems(Player player) + { + long timeAlive = Math.min(System.currentTimeMillis() - GetStateTime(), TimeUnit.MINUTES.toMillis(30)); + + // i.e 1 gem per 10 seconds alive + AddGems(player, timeAlive / TimeUnit.SECONDS.toMillis(10), "Surviving " + UtilTime.MakeStr(timeAlive), false, false); + } + + @Override + public double GetKillsGems(Player killer, Player killed, boolean assist) + { + if (assist) + { + return 50; + } + + return _border.getSize() == MIN_CORD ? 200 : 100; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java index fad6dedf9..c01c52658 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java @@ -5,7 +5,6 @@ import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilColor; import mineplex.core.common.util.UtilEnt; import nautilus.game.arcade.ArcadeManager; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEnderDragon; @@ -27,8 +26,10 @@ class BattleRoyalePlayer private final Set _cageBlocks; private EnderDragon _dragon; private Chicken _chicken; + private int _kills; + private int _assists; - public BattleRoyalePlayer(ArcadeManager manager, Player player, Location location, Location goal) + BattleRoyalePlayer(ArcadeManager manager, Player player, Location location, Location goal) { _player = player; _location = location; @@ -129,4 +130,24 @@ class BattleRoyalePlayer { return _chicken; } + + public void incrementKills() + { + _kills++; + } + + public int getKills() + { + return _kills; + } + + public void incrementAssists() + { + _assists++; + } + + public int getAssists() + { + return _assists; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java index b41d01379..678cae858 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java @@ -1,6 +1,9 @@ package nautilus.game.arcade.game.games.battleroyale; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; @@ -8,11 +11,14 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.KitPlayer; +import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import java.util.ArrayList; import java.util.Collections; @@ -27,55 +33,157 @@ public class BattleRoyaleSolo extends BattleRoyale private GameTeam _players; + // Scoreboard data + private final String _playersAliveTitle = C.cYellowB + "Players"; + private String _playersAlive; + private final String _statsTitle = C.cYellowB + "Stats"; + private String _supplyDropTitle = C.cGoldB + "Supply Drop"; + private String _supplyDropLocation; + private String _supplyDropState; + private final String _borderTitle = C.cRedB + "World Border"; + private String _borderCenter; + private String _borderSize; + private boolean _showBorderCenter; + public BattleRoyaleSolo(ArcadeManager manager) { - super(manager, GameType.BattleRoyale, new Kit[] {new KitPlayer(manager)}, DESCRIPTION); + super(manager, GameType.BattleRoyale, new Kit[]{new KitPlayer(manager)}, DESCRIPTION); + + new CustomScoreboardModule() + .setSidebar((player, scoreboard) -> + { + switch (GetState()) + { + case Prepare: + writePrepare(player, scoreboard); + break; + case Live: + writeLive(player, scoreboard); + break; + } + }) + .setPrefix((perspective, subject) -> + { + if (!IsAlive(subject)) + { + return C.cGray; + } + + return perspective.equals(subject) ? C.cGreen : C.cRed; + }) + .register(this); } @EventHandler public void customTeamGeneration(GameStateChangeEvent event) { if (event.GetState() != GameState.Recruit) + { return; + } _players = GetTeamList().get(0); _players.SetColor(ChatColor.YELLOW); _players.SetName("Players"); } - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) + // LOW so that this is run before the scoreboards are updated + @EventHandler(priority = EventPriority.LOW) + public void scoreboardDataUpdate(UpdateEvent event) { - if (event.getType() != UpdateType.FAST || !InProgress()) + if (event.getType() != UpdateType.FAST || _border == null) { return; } - Scoreboard.writeNewLine(); + // Due to many players being in this game and the fact that the scoreboard module scales O(n^2) + // we can optimise this by storing global variables that all players would see on their scoreboard + // regardless of their state. + _playersAlive = GetPlayers(true).size() + " Alive"; - Scoreboard.write(C.cYellow + C.Bold + "Players"); - if (_players.GetPlayers(true).size() > 10) + if (_supplyDrop != null) { - Scoreboard.write(String.valueOf( _players.GetPlayers(true).size())); + _supplyDropLocation = UtilWorld.locToStrClean(_supplyDrop.getDropLocation()); + _supplyDropState = _supplyDrop.getScoreboardString(); } else { - for (Player player : _players.GetPlayers(true)) - { - Scoreboard.write(player.getName()); - } + _supplyDropLocation = ""; + _supplyDropState = UtilTime.MakeStr(_lastSupplyDrop + BattleRoyale.SUPPLY_DROP_TIME - System.currentTimeMillis()); } - Scoreboard.writeNewLine(); - int size = (int) _border.getSize(); Location center = _border.getCenter(); - Scoreboard.write(C.cRedB + "World Border"); - Scoreboard.write("(" + center.getBlockX() + ", " + center.getBlockZ() + ")"); - Scoreboard.write(size + " Blocks Wide"); - Scoreboard.draw(); + if (size < 1000 && !_showBorderCenter) + { + _showBorderCenter = true; + Announce(C.cRedB + "The Center Of The Border Is Now Visible!"); + } + + if (_showBorderCenter) + { + _borderCenter = "(" + center.getBlockX() + ", " + center.getBlockZ() + ")"; + } + else + { + _borderCenter = "Center Unknown"; + } + + _borderSize = size + " Blocks Wide"; + } + + public void writePrepare(Player player, GameScoreboard scoreboard) + { + scoreboard.writeNewLine(); + + scoreboard.write(_playersAliveTitle); + scoreboard.write(_playersAlive); + + scoreboard.writeNewLine(); + } + + public void writeLive(Player player, GameScoreboard scoreboard) + { + BattleRoyalePlayer royalePlayer = _playerData.get(player); + + scoreboard.writeNewLine(); + + scoreboard.write(_playersAliveTitle); + scoreboard.write(_playersAlive); + + scoreboard.writeNewLine(); + + if (royalePlayer != null) + { + scoreboard.write(_statsTitle); + scoreboard.write("Kills: " + C.cGreen + royalePlayer.getKills()); + scoreboard.write("Assists: " + C.cGreen + royalePlayer.getAssists()); + + scoreboard.writeNewLine(); + } + + scoreboard.write(_supplyDropTitle); + if (_supplyDrop != null) + { + scoreboard.write(_supplyDropLocation); + } + if (_supplyDropState != null) + { + scoreboard.write(_supplyDropState); + } + else if (_supplyDrop != null && IsAlive(player)) + { + int dist = (int) UtilMath.offset2d(_supplyDrop.getDropLocation(), player.getLocation()); + + scoreboard.write(dist + " Blocks Away"); + } + + scoreboard.writeNewLine(); + + scoreboard.write(_borderTitle); + scoreboard.write(_borderCenter); + scoreboard.write(_borderSize); } @Override @@ -86,8 +194,12 @@ public class BattleRoyaleSolo extends BattleRoyale return; } - if (GetPlayers(true).size() <= 1) + List alive = GetPlayers(true); + + if (alive.size() <= 1) { + alive.forEach(this::awardTimeGems); + List places = _players.GetPlacements(true); AnnounceEnd(places); @@ -105,14 +217,6 @@ public class BattleRoyaleSolo extends BattleRoyale AddGems(places.get(2), 10, "3rd Place", false, false); } - for (Player player : GetPlayers(false)) - { - if (player.isOnline()) - { - AddGems(player, 10, "Participation", false, false); - } - } - _border.setSize(10000); SetState(GameState.End); } @@ -126,12 +230,18 @@ public class BattleRoyaleSolo extends BattleRoyale List places = _players.GetPlacements(true); if (places.isEmpty() || !places.get(0).isOnline()) + { return new ArrayList<>(0); + } else + { return Collections.singletonList(places.get(0)); + } } else + { return null; + } } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSupplyDrop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSupplyDrop.java new file mode 100644 index 000000000..966ea593c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSupplyDrop.java @@ -0,0 +1,185 @@ +package nautilus.game.arcade.game.games.battleroyale; + +import mineplex.core.common.Pair; +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.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.modules.chest.ChestLootModule; +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.entity.ArmorStand; +import org.bukkit.entity.Chicken; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +class BattleRoyaleSupplyDrop implements Listener +{ + + private static final int DRAGON_Y = 120; + private static long DROP_WAIT = TimeUnit.MINUTES.toMillis(2); + private static final ItemStack CHEST = new ItemStack(Material.CHEST); + private static final FireworkEffect FIREWORK_EFFECT = FireworkEffect.builder() + .with(Type.BALL_LARGE) + .withColor(Color.YELLOW) + .withFlicker() + .build(); + + private final BattleRoyale _host; + private final long _start; + private final Set _beaconBlocks; + + private Location _dropLocation; + + private ArmorStand _chest; + private Chicken _seat; + private final List _chute; + + private boolean _dropped; + private boolean _opened; + private boolean _landed; + private long _openedAt; + + BattleRoyaleSupplyDrop(BattleRoyale host, Location dropLocation) + { + _host = host; + _dropLocation = dropLocation; + _start = System.currentTimeMillis(); + _beaconBlocks = new HashSet<>(); + _chute = new ArrayList<>(); + + // Construct a beacon + for (Pair> pair : UtilBlock.getBeaconBlocks(_dropLocation, (byte) 0)) + { + // Look it's like a maze + _beaconBlocks.add(pair.getLeft().getBlock()); + host.getArcadeManager().GetBlockRestore().add(pair.getLeft().getBlock(), pair.getRight().getLeft().getId(), pair.getRight().getRight(), Long.MAX_VALUE); + } + + _dropLocation.setY(DRAGON_Y); + + UtilServer.RegisterEvents(this); + } + + @EventHandler + public void updateDrop(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + if (UtilTime.elapsed(_start, DROP_WAIT) && !_dropped) + { + _dropped = true; + _host.CreatureAllowOverride = true; + + UtilFirework.playFirework(_dropLocation, FIREWORK_EFFECT); + _chest = _dropLocation.getWorld().spawn(_dropLocation, ArmorStand.class); + _chest.setGravity(false); + _chest.setVisible(false); + _chest.setHelmet(CHEST); + + _seat = _dropLocation.getWorld().spawn(_dropLocation, Chicken.class); + UtilEnt.vegetate(_seat); + UtilEnt.ghost(_seat, true, true); + UtilEnt.silence(_seat, true); + _seat.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false)); + _seat.setPassenger(_chest); + + for (int i = 0; i < 6; i++) + { + Chicken chicken = _dropLocation.getWorld().spawn(UtilAlg.getRandomLocation(_dropLocation, 2, 0.5, 2).add(0, 5, 0), Chicken.class); + UtilEnt.vegetate(chicken); + UtilEnt.ghost(chicken, true, false); + chicken.setLeashHolder(_seat); + _chute.add(chicken); + } + + _host.CreatureAllowOverride = false; + } + else if (_dropped && !_landed && UtilEnt.isGrounded(_seat)) + { + _landed = true; + + Location chest = _seat.getLocation(); + UtilFirework.playFirework(chest, FIREWORK_EFFECT); + MapUtil.QuickChangeBlockAt(chest, Material.CHEST); + _dropLocation = chest; + + ChestLootModule lootModule = _host.getModule(ChestLootModule.class); + lootModule.addChestLocation("Supply Drop", chest); + + _beaconBlocks.forEach(block -> _host.getArcadeManager().GetBlockRestore().restore(block)); + + _chest.remove(); + _seat.remove(); + _chute.forEach(Chicken::remove); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void playerInteract(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + Block block = event.getClickedBlock(); + + if (block == null || block.getType() != Material.CHEST) + { + return; + } + + if (UtilMath.offsetSquared(block.getLocation(), _dropLocation) < 4) + { + _opened = true; + _openedAt = System.currentTimeMillis(); + cleanup(); + } + } + + public void cleanup() + { + _chute.clear(); + UtilServer.Unregister(this); + } + + public Location getDropLocation() + { + return _dropLocation; + } + + public boolean isOpened() + { + return _opened; + } + + public String getScoreboardString() + { + return _dropped ? null : UtilTime.MakeStr(_start + DROP_WAIT - System.currentTimeMillis()); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index dfc12db46..99b9e3b6e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -832,14 +832,6 @@ public class Bridge extends TeamGame implements OreObsfucation if (!_bridgesDown) { _bridgesDown = true; - -// WorldBorderModule borderModule = getModule(WorldBorderModule.class); -// -// for (Player player : GetPlayers(true)) -// { -// borderModule.setSize(player, 10000); -// } - Manager.GetExplosion().SetLiquidDamage(true); Announce(C.cRedB + "ALERT: " + C.Reset + C.Bold + "THE BRIDGES ARE SPAWNING!"); UtilTextMiddle.display(C.cRedB + "ALERT", "The BRIDGES ARE SPAWNING!"); 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 efb25437b..a4ba2f3dc 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 @@ -82,6 +82,7 @@ public class CustomScoreboardModule extends Module } setupScoreboard(player); + refreshAsSubject(player); } /** diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/WorldBorderModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/WorldBorderModule.java deleted file mode 100644 index 6a1f13bae..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/WorldBorderModule.java +++ /dev/null @@ -1,116 +0,0 @@ -package nautilus.game.arcade.game.modules; - -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -import mineplex.core.common.Pair; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.packethandler.IPacketHandler; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.packethandler.PacketInfo; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game.GameState; -import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder; -import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder.EnumWorldBorderAction; -import net.minecraft.server.v1_8_R3.WorldBorder; - -public class WorldBorderModule extends Module implements IPacketHandler -{ - - private PacketHandler _packetHandler; - private Map _sizeToSet; - private Map> _centerToSet; - - @Override - protected void setup() - { - _packetHandler = getGame().getArcadeManager().getPacketHandler(); - _sizeToSet = new HashMap<>(); - _centerToSet = new HashMap<>(); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void live(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - { - return; - } - - _packetHandler.addPacketHandler(this, PacketPlayOutWorldBorder.class); - } - - @Override - public void handle(PacketInfo packetInfo) - { - UUID player = packetInfo.getPlayer().getUniqueId(); - PacketPlayOutWorldBorder packet = (PacketPlayOutWorldBorder) packetInfo.getPacket(); - - try - { - Field actionField = packet.getClass().getDeclaredField("a"); - actionField.setAccessible(true); - EnumWorldBorderAction action = (EnumWorldBorderAction) actionField.get(packet); - - if (action == EnumWorldBorderAction.SET_SIZE) - { - Field sizeField = packet.getClass().getDeclaredField("e"); - sizeField.setAccessible(true); - double newSize = _sizeToSet.get(player); - - sizeField.set(packet, newSize); - } - else if (action == EnumWorldBorderAction.SET_CENTER) - { - Field xField = packet.getClass().getDeclaredField("c"); - Field zField = packet.getClass().getDeclaredField("d"); - - xField.setAccessible(true); - zField.setAccessible(true); - - Pair pair = _centerToSet.get(player); - - xField.set(packet, pair.getLeft()); - zField.set(packet, pair.getRight()); - } - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - @Override - public void cleanup() - { - _packetHandler.removePacketHandler(this); - } - - public void setSize(Player player, double size) - { - _sizeToSet.put(player.getUniqueId(), size); - - sendPacket(player, EnumWorldBorderAction.SET_SIZE); - } - - public void setCenter(Player player, Location location) - { - _centerToSet.put(player.getUniqueId(), Pair.create(location.getX(), location.getZ())); - - sendPacket(player, EnumWorldBorderAction.SET_CENTER); - } - - private void sendPacket(Player player, EnumWorldBorderAction action) - { - WorldBorder border = ((CraftWorld) player.getWorld()).getHandle().getWorldBorder(); - UtilPlayer.sendPacket(player, new PacketPlayOutWorldBorder(border, action)); - } -} 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 4ebeecc89..030a2fcbc 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 @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.modules.chest; +import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; @@ -21,12 +22,12 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEvent; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -40,7 +41,6 @@ public class ChestLootModule extends Module BlockFace.EAST }; - private final List _chestTypes; private final Map> _chests; private long _destroyAfterOpened; @@ -50,7 +50,6 @@ public class ChestLootModule extends Module public ChestLootModule() { - _chestTypes = new ArrayList<>(); _chests = new HashMap<>(); } @@ -61,7 +60,7 @@ public class ChestLootModule extends Module public ChestLootModule registerChestType(String name, List chestLocations, double spawnChance, ChestLootPool... pools) { - _chestTypes.add(new ChestType(name, chestLocations, spawnChance, pools)); + _chests.put(new ChestType(name, chestLocations, spawnChance, pools), new HashSet<>()); return this; } @@ -90,6 +89,38 @@ public class ChestLootModule extends Module return this; } + public void addChestLocation(String typeName, Location location) + { + for (Entry> entry : _chests.entrySet()) + { + if (!entry.getKey().Name.equals(typeName)) + { + continue; + } + + entry.getValue().add(new ChestMetadata(location.getBlock(), entry.getKey())); + return; + } + } + + public void refill() + { + _chests.forEach((type, metadataSet) -> metadataSet.forEach(metadata -> metadata.Opened = false)); + } + + public void refill(String typeName) + { + _chests.forEach((type, metadataSet) -> + { + if (!type.Name.equals(typeName)) + { + return; + } + + metadataSet.forEach(metadata -> metadata.Opened = false); + }); + } + @EventHandler(priority = EventPriority.HIGHEST) public void populateChests(GameStateChangeEvent event) { @@ -98,14 +129,16 @@ public class ChestLootModule extends Module return; } - for (ChestType chestType : _chestTypes) + for (Entry> entry : _chests.entrySet()) { + ChestType chestType = entry.getKey(); + if (chestType.ChestSpawns == null) { continue; } - Set metadataSet = new HashSet<>(); + Set metadataSet = entry.getValue(); for (Location location : chestType.ChestSpawns) { @@ -186,8 +219,9 @@ public class ChestLootModule extends Module { Block block = metadata.Chest; Location location = block.getLocation(); - location.getWorld().playEffect(location.add(0.5, 0.5, 0.5), Effect.STEP_SOUND, block.getType(), block.getData()); - block.setType(Material.AIR); + location.getWorld().playEffect(location.add(0.5, 0.5, 0.5), Effect.STEP_SOUND, block.getType()); + ((Chest) block.getState()).getBlockInventory().clear(); + MapUtil.QuickChangeBlockAt(location, Material.AIR); return true; } @@ -258,10 +292,10 @@ public class ChestLootModule extends Module private class ChestMetadata { - Block Chest; - ChestType Type; - long OpenedAt; - boolean Opened; + Block Chest; + ChestType Type; + long OpenedAt; + boolean Opened; ChestMetadata(Block chest, ChestType type) { @@ -271,6 +305,8 @@ public class ChestLootModule extends Module void populateChest(Chest chest) { + chest.getBlockInventory().clear(); + for (ChestLootPool pool : Type.Pools) { if (pool.getProbability() == 1 || Math.random() < pool.getProbability()) From 811463e5868f80c51ba37cfc435339bb27caa178 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 30 Jun 2017 13:56:20 +0100 Subject: [PATCH 039/183] Attempt to somewhat fix the lag whenever the game starts --- .../game/arcade/game/games/battleroyale/BattleRoyale.java | 6 +++--- .../arcade/game/games/battleroyale/BattleRoyaleSolo.java | 3 ++- .../game/games/battleroyale/BattleRoyaleSupplyDrop.java | 4 +--- .../game/arcade/game/modules/chest/ChestLootModule.java | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java index be32bb923..d66e49e34 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java @@ -119,10 +119,10 @@ public abstract class BattleRoyale extends Game // TODO REMOVE THIS TeleportsDisqualify = false; - TickPerTeleport = 20; PrepareTime = PREPARE_TIME; PrepareFreeze = false; + SpawnTeleport = false; Damage = false; DamageTeamSelf = true; DeathDropItems = true; @@ -172,7 +172,7 @@ public abstract class BattleRoyale extends Game chestSpawns.addAll(WorldData.GetDataLocs("BLUE")); new ChestLootModule() - .destoryAfterOpened(20) + .destroyAfterOpened(20) .spawnNearbyDataPoints() .registerChestType("Standard", chestSpawns, @@ -422,7 +422,7 @@ public abstract class BattleRoyale extends Game index.getAndIncrement(); } - }, 200, 2); + }, 40, 2); } private Location getPlayerSpawn(int initialXZ) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java index 678cae858..945a3a98b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java @@ -103,7 +103,8 @@ public class BattleRoyaleSolo extends BattleRoyale if (_supplyDrop != null) { - _supplyDropLocation = UtilWorld.locToStrClean(_supplyDrop.getDropLocation()); + Location location = _supplyDrop.getDropLocation(); + _supplyDropLocation = "(" + location.getBlockX() + ", " + location.getBlockZ() + ")"; _supplyDropState = _supplyDrop.getScoreboardString(); } else diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSupplyDrop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSupplyDrop.java index 966ea593c..edd9f332c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSupplyDrop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSupplyDrop.java @@ -59,12 +59,11 @@ class BattleRoyaleSupplyDrop implements Listener private boolean _dropped; private boolean _opened; private boolean _landed; - private long _openedAt; BattleRoyaleSupplyDrop(BattleRoyale host, Location dropLocation) { _host = host; - _dropLocation = dropLocation; + _dropLocation = dropLocation.clone(); _start = System.currentTimeMillis(); _beaconBlocks = new HashSet<>(); _chute = new ArrayList<>(); @@ -157,7 +156,6 @@ class BattleRoyaleSupplyDrop implements Listener if (UtilMath.offsetSquared(block.getLocation(), _dropLocation) < 4) { _opened = true; - _openedAt = System.currentTimeMillis(); cleanup(); } } 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 030a2fcbc..05c309d65 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 @@ -64,7 +64,7 @@ public class ChestLootModule extends Module return this; } - public ChestLootModule destoryAfterOpened(int seconds) + public ChestLootModule destroyAfterOpened(int seconds) { _destroyAfterOpened = TimeUnit.SECONDS.toMillis(seconds); return this; From f719e0db8d6043aeb0ab016847cd3c2d7968ab48 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 30 Jun 2017 14:22:43 +0100 Subject: [PATCH 040/183] Clean up player data --- .../game/arcade/game/games/battleroyale/BattleRoyale.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java index d66e49e34..54d25748c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java @@ -620,6 +620,7 @@ public abstract class BattleRoyale extends Game { super.disable(); + _playerData.clear(); if (_supplyDrop != null) { _supplyDrop.cleanup(); From 81ae3e004935da2dab9862dbda3dcbd40ea3281d Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 30 Jun 2017 19:32:08 +0100 Subject: [PATCH 041/183] Give players rewards and remove debug messages --- .../game/games/battleroyale/BattleRoyale.java | 26 ++++++-------- .../games/battleroyale/BattleRoyaleSolo.java | 36 +++++++++++++++++++ 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java index 54d25748c..73842accd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java @@ -117,9 +117,6 @@ public abstract class BattleRoyale extends Game { super(manager, gameType, kits, gameDesc); - // TODO REMOVE THIS - TeleportsDisqualify = false; - PrepareTime = PREPARE_TIME; PrepareFreeze = false; SpawnTeleport = false; @@ -209,8 +206,10 @@ public abstract class BattleRoyale extends Game // Weapons new ChestLootPool() + .addItem(new ItemStack(Material.IRON_SWORD)) + .addItem(new ItemStack(Material.IRON_AXE)) .addItem(new ItemStack(Material.BOW)) - .setProbability(0.05) + .setProbability(0.1) , // Ammo @@ -224,7 +223,7 @@ public abstract class BattleRoyale extends Game new ChestLootPool() .addItem(SMALL_HEALTH_POT) .addItem(LARGE_HEALTH_POT) - .setProbability(0.2) + .setProbability(0.1) .setAmountsPerChest(1, 2) , @@ -259,17 +258,13 @@ public abstract class BattleRoyale extends Game // Food new ChestLootPool() - .addItem(new ItemStack(Material.RAW_FISH), 1, 3) - .addItem(new ItemStack(Material.RAW_BEEF), 1, 3) - .addItem(new ItemStack(Material.RAW_CHICKEN), 1, 3) - .addItem(new ItemStack(Material.MUTTON), 1, 3) .addItem(new ItemStack(Material.MELON), 1, 3) - .addItem(new ItemStack(Material.BREAD), 1, 2, 0.4) - .addItem(new ItemStack(Material.COOKED_FISH), 0.2) - .addItem(new ItemStack(Material.COOKED_BEEF), 0.2) - .addItem(new ItemStack(Material.COOKED_CHICKEN), 0.2) - .addItem(new ItemStack(Material.COOKED_MUTTON), 0.2) - .addItem(new ItemStack(Material.COOKIE), 0.2) + .addItem(new ItemStack(Material.BREAD), 1, 2, 0.6) + .addItem(new ItemStack(Material.COOKED_FISH), 0.5) + .addItem(new ItemStack(Material.COOKED_BEEF), 0.5) + .addItem(new ItemStack(Material.COOKED_CHICKEN), 0.5) + .addItem(new ItemStack(Material.COOKED_MUTTON), 0.5) + .addItem(new ItemStack(Material.COOKIE), 0.5) , // Misc @@ -416,7 +411,6 @@ public abstract class BattleRoyale extends Game goal.setX(-spawn.getX()); goal.setZ(-spawn.getZ()); - Bukkit.broadcastMessage(player.getName() + " -> " + UtilWorld.locToStrClean(spawn) + " after " + attempts + " attempts"); BattleRoyalePlayer royalePlayer = new BattleRoyalePlayer(Manager, player, spawn, goal); _playerData.put(player, royalePlayer); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java index 945a3a98b..03a984706 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java @@ -1,9 +1,11 @@ package nautilus.game.arcade.game.games.battleroyale; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; +import mineplex.core.treasure.TreasureType; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; @@ -207,6 +209,40 @@ public class BattleRoyaleSolo extends BattleRoyale if (places.size() >= 1) { + Player player = places.get(0); + long wins = Manager.GetStatsManager().Get(player).getStat("Battle Royale.Wins"); + + if (wins > 1) + { + Manager.getInventoryManager().addItemToInventory(success -> + { + if (success) + { + player.sendMessage(F.main("Game", "Unlocked 1 " + C.cAqua + "Mythical Chest" + C.mBody + ".")); + } + else + { + player.sendMessage(F.main("Game", "Failed to give you your Mythical Chest, you should inform a staff member!")); + } + + }, player, TreasureType.MYTHICAL.getItemName(), 1); + } + else + { + Manager.getInventoryManager().addItemToInventory(success -> + { + if (success) + { + player.sendMessage(F.main("Game", "Unlocked 1 " + C.cRed + "Freedom Chest" + C.mBody + ".")); + } + else + { + player.sendMessage(F.main("Game", "Failed to give you your Freedom Chest, you should inform a staff member!")); + } + + }, player, TreasureType.FREEDOM.getItemName(), 1); + } + AddGems(places.get(0), 20, "1st Place", false, false); } if (places.size() >= 2) From b01cb0c2e909c42bea82f062b196314178a5c3ef Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 1 Jul 2017 01:05:05 -0400 Subject: [PATCH 042/183] Add Revolutionary SkinData --- .../src/mineplex/core/common/skin/SkinData.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index 6b7b7a675..fc34a0649 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -80,6 +80,7 @@ public class SkinData public static final SkinData BIFF = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjEzMDQzNjYsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9mOWMyMTE3ZDY0ZWE0ZmUxMWZiY2NhZmE2YzU5YzhlZjY3NDVkZjVkMTZjM2QwMmI4NmI2OTlmZWJjNTA0OGI1In19fQ==", "mJMpEvQ4A02z0S/chgLm5bKrrrd+zmp7A0012AB7b3KlyIHoLKEDDz+ZJgJtvN6skOqed3P+yNVqkxitugXaZZP8Af9J+/TseHn+vOy6CTK5tykRSY3Zb8Zmw1kn36v/SARAVtDIHD53yuPgJayYSAbVB7aknj1Q8XBQGUmZRMRxWWxeD7rQTOwgRYI4YJeKFf4UL9i6zxvOJuHsOAouJ7scu7VohG8vgR77Js/Z8rSu8/aSG+O9AQdzP6h9ixYNFkkQOHm7DseK/5tsWKHM4FYBgjIDKt3ApQokSbhThzGB55BA1qjXZkfCoOb13y1nOMC8WoIL6Ees1qzxG3VloGx2WAZLh+Q+/irwrFDMxk1zeU5fIRuj1c/UIM2HKdxxWgoRdrZ8ww/Jrll6maiOBx7geMn/0aOUbJ2U7gkTif6RG6YNS5YN9ZQDLh72l/akJMxF3SlmuAPmLs2kBghQ6eD2YQKuxWR/Hf1yS1YXtogFVNsGnzC1nda7F48EGL3zI+kCajbDlAGQ32aRt0btbEQ+Gj575kir3Aa53qiZ0YOIYQlhgZdOsTN2NE2s8uuy/15Rgc6K3ydgEmSZfdqyMyW0Dy7pE5TfVL8DumKRVRXdOceT5WfnW7MyqSmdorP5ab1fw2wLOnAVzhJmW8oXXNSs77WJ1/PURclxOWB4IF8="); public static final SkinData CANADA_HAT = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg2MDE5MDYwNzYsInByb2ZpbGVJZCI6IjdkYTJhYjNhOTNjYTQ4ZWU4MzA0OGFmYzNiODBlNjhlIiwicHJvZmlsZU5hbWUiOiJHb2xkYXBmZWwiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2M2MTExNTNmODdmMjZjMzRmOTdkODIxM2ZmOTk1ZGJlNjcyZWJkNGM0NjRkNGFkNzM5MWFlNDNjMWU3YTllIn19fQ", "QMw6e1FXl/Xrt+BbfPKsz3OHyOxL9CEPffS9grxRLD6gbLbMD84OT3+bge5V9lBFn9PPnTyID+WTF24qHj4ADTTgK94ykNedCEO6R1wS0FZKPI1UjwOxMhIG5ZeVr7+HxITgGU4Xz94IigBkvW//f2ZGelMvS0GLCrm4iCovEBMUzyYJ2dZ4xgzFSH6v+9efK4/SBAJaj8mHjXpDxU58/vskTGI3T9t5sWlZLXgId9vHcMj0GH3Un6yvUXiMkh38V/rAEM8/R8q08xUVyW0e2R38qWQV2+eKvsG8GmJmgkU/78wA9cKGZdrEz0pnr80eGNCbvXqQvC/czYhEhDapgxfndcHLX8q/Zk3I8msNr340E4ZrQL61Yl7KcVC1qEUQVu3cosq5A6ckXLGvv//HSwXVO8M9ThUbuEC8QjiS/fMFufnVa18lHrVulnfb/2KQ4yPsoCHK/zvGtRkWtD1sLOIfehN+sxCLiaz80ILBiwN0oHITfNHpJzoa4kF/OrxxCualp4Sv5o5TXBv7aWsO18v9ixb9o9CmJKKE8MUl5xmRVz4HQD4dyOfcwtPuxmfcYjJrxqBijdQMrcgLzqqMs+DUqcZZlxM7M5GaNUoEvL9tJNGpZaB2OrBw0DTk5wx15XfANCH4egx8X4+Iy2RUoFthHX3BsVazG7fjSiDnUtI="); public static final SkinData AMERICA_HAT = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg2MDI3MjMyODgsInByb2ZpbGVJZCI6IjNlMjZiMDk3MWFjZDRjNmQ5MzVjNmFkYjE1YjYyMDNhIiwicHJvZmlsZU5hbWUiOiJOYWhlbGUiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzYzMjI0MDhkYzBiZjMxNjU4N2RiNDJiN2Q5ZmViZTUwYWQ4MGY0OGU4Njc5YzI0NTFkOTk3MTdjZmVjNTdkYWQifX19","oRo6DIuhOTaXDkFsgwJ488LWqx5d1QpwtglwG1SdEvkbX1aCMGdZyDm9YIopQRjfBg0uYKQFetOZ1ZkdMmc/aKC5/dm0+Ema7g8AUzjwf4OaSLH1r4C1UJ4ruaNG5diBxNTkYnMa7yT8zvyEr22CA7lUOIgTh8ymBfSGK35RPhsn8jM0hDjdhjemBAlxKpiioByfmAQbwokNBOrXfh/PnKq+iJYg4WpMSZ1zo5Rr0CzLXwu+/T3dvrb6mg7qry7J3Lj5/qn6iIdBcjJBeyvy1sCo45jQ3Rzc6oL/84Vu5Dpn395EqUK8Sa7mdpVpATTcj56TCjkNNtDapXNqyO/IIQuzU4wnBKNQmZefaxRl6LV0DhZ8n8YQaPj6hH/mr2oDsd23+jejjqu6Y95ReTyukp06mIGqgekmrdZV2etML2oMAOTv9ieVvqtfo5gEomYs+NFAL7rMmzjAlhd17VOgqNRMpmJazAHWOYKl8KdOH99wGDe5XcyKHysh+qyHKMvhPJztIeAEaosynF/aGHghH2PM354KCuUVNmdR5G7UZUoG9ZA5ZU3EzZ854jeqxcqw3jzb6qL7A83QNuFqOsb87ugL/jO3QEDdQ9drdf3WAQauQGkU3nYBrls5wxoMrQ+Ceth+FtZw9a1v7dc+DEWOeJKCtOAIskb29pv6OcRe0Wk="); + public static final SkinData REVOLUTIONARY = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg3ODQ5Mzk3NjAsInByb2ZpbGVJZCI6ImIwZDRiMjhiYzFkNzQ4ODlhZjBlODY2MWNlZTk2YWFiIiwicHJvZmlsZU5hbWUiOiJZZWxlaGEiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2I4NTBkZDNkYWQ0MjkxYzFhYmU4NGU2OTM2ZmQ3MDM0ZWVlZTk1OTk2MWI3YjE5NDZhODIxYWRlMTFiODI2YjIifX19","U2xBG+ryUacvZq3WreWF2J4QnQERuvp1okqdlkAYECqvVHz0cars78usPuZYD4s3HyOM0eGASzS4zkQERF6Hk8crnG+ZtqvML5kL+TkxK8gEbn2j5qB+YDG0qTx635mYGC77sGaqE/CsZAlhRYU6lyXILW2616Af8B8orOlpyCMRytijp/OfJREK0bC4I1QnB7AJ2QmBYuZJ9l8473858fJOlCVHjbsC/WRcUvepPSYYxvl8Z5NwayyIVnnz3tGVN6hnM7tzil/gQmsmDwGhlSyify/MEGssvd0sHLTlccA7XX98tyUFHXU84L5MJuNKg/uXTYz+9cRPIgJaptJNfqCoEa/ape+YHlOlK2lm5qRvubvp931X+VwFbcrEuaIFgbqr9cof5JW6DYfpVKvcngi9+K9IzgtPG59Jro5kxb70IfQhZcDkcHGo1pz5Tj7cdJdD7crBeIBaE/EoKU6iaSOrUFoILEdpcWQfaToRnk4L/JMet7zPXBNE/D/vEgQLGLNX7byofdCXSD9njtjLWmHg4rCzwuUqaiWnTCYIkkdg/mFuRQ3oTRRTzdlLXsK90Pz0XU9N6gBhWA9pxhzDJR7YK+mdXODALuMXE6zcCsbVuWhqbnN+EByGdjT9X1QPSN+/5iV9d5JyweiJrF7arf2PmxgEIb9OSjePNKRmHoo="); // Comments this out for now, so it doesn't load the player profile // A better way to do this would check for the properties when getting the skull or the skin From 55a1afbb7154d9a5bef1e15dea83f21775985d03 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 1 Jul 2017 01:05:44 -0400 Subject: [PATCH 043/183] Expose banner data in CountryFlag --- .../core/common/util/banner/CountryFlag.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java index 54626d736..f49d5040c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java @@ -7,6 +7,9 @@ import org.bukkit.block.banner.PatternType; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BannerMeta; +import java.util.Arrays; +import java.util.List; + import static org.bukkit.DyeColor.*; import static org.bukkit.block.banner.PatternType.*; @@ -110,4 +113,14 @@ public enum CountryFlag return _adjective; } + public DyeColor getBaseColor() + { + return _baseColor; + } + + public List getPatterns() + { + return Arrays.asList(_patterns); + } + } From 5a86141e8f998614f4b8422ae95d019d0686a9d8 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 1 Jul 2017 01:05:58 -0400 Subject: [PATCH 044/183] Fix costume count displaying incorrectly --- .../Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 9814c081b..ab57f6835 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -209,7 +209,7 @@ public class Menu extends ShopPageBase type = GadgetType.COSTUME; // -4 Fixes more than the real costumes being counted (Happens because of the hub games costumes - lore = getLore(ownedCount.get(type) - 4, maxCount.get(type) - 4, "Sometimes going out calls for special clothes! Gain bonus effects for matching outfit.", VISIBILITY_HUB, enabled.get(type)); + lore = getLore(ownedCount.get(type), maxCount.get(type) - 4, "Sometimes going out calls for special clothes! Gain bonus effects for matching outfit.", VISIBILITY_HUB, enabled.get(type)); addButton(costumeSlot, new ShopItem(Material.DIAMOND_CHESTPLATE, "Costumes", lore, 1, false), new OpenCostumes(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(costumeSlot); From 5957b96a4f6b3c523f287526b1b65356919b3e4f Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 1 Jul 2017 01:07:32 -0400 Subject: [PATCH 045/183] Add freedom fighter morph --- .../mineplex/core/gadget/GadgetManager.java | 2 + .../gadgets/morph/MorphFreedomFighter.java | 263 ++++++++++++++++++ .../powerplayclub/PowerPlayClubRewards.java | 1 + 3 files changed, 266 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 69e331174..18632e6f6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -15,6 +15,7 @@ import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; import mineplex.core.gadget.gadgets.flag.FlagType; import mineplex.core.gadget.gadgets.morph.MorphBobRoss; +import mineplex.core.gadget.gadgets.morph.MorphFreedomFighter; import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; @@ -467,6 +468,7 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphGoldPot(this)); addGadget(new MorphAwkwardRabbit(this)); addGadget(new MorphBobRoss(this, _hologramManager)); + addGadget(new MorphFreedomFighter(this)); // Particles addGadget(new ParticleFoot(this)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java new file mode 100644 index 000000000..d3b117b29 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java @@ -0,0 +1,263 @@ +package mineplex.core.gadget.gadgets.morph; + +import com.mojang.authlib.GameProfile; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.block.Banner; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import java.time.Month; +import java.time.YearMonth; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; + +/** + * Freedom fighter morph, capable of planting flags by crouching. + */ +public class MorphFreedomFighter extends MorphGadget +{ + /** How long it takes to plant a flag */ + private static final long FLAG_DELAY = 3500; + + /** How long between flag plantings */ + private static final long FLAG_COOLDOWN = 25000; + + /** Recharge key for planting flags */ + private static final String RECHARGE_KEY = "Plant Flag"; + + /** Design for beacon base */ + private static final int[][] BEACON_BASE = { + { 0, -2, 0}, {1, -2, 0}, {0, -2, 1}, {1, -2, 1}, + {-1, -2, 0}, {0, -2, -1}, {-1,-2,-1}, {0, -2, 1}, + {-1, -2, 1}, {1, -2, -1} + }; + + /** Active timers for players planting flags */ + private final Map _flagTimers = new HashMap<>(); + + /** Active timers for players that have planted flags */ + private final Map _flagCooldowns = new HashMap<>(); + + public MorphFreedomFighter(GadgetManager manager) + { + super(manager, "Freedom Fighter", UtilText.splitLinesToArray(new String[] { + C.cGray + "Fight for your freedom from tyranny and oppressors!", + "", + C.cGreen + "Hold sneak" + C.cWhite + " to plant a flag of freedom!", + }, LineFormat.LORE), -14, Material.CHAINMAIL_CHESTPLATE, (byte) 0, YearMonth.of(2017, Month.JULY)); + } + + /** + * Sets the player's skin. + */ + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + GameProfile profile = UtilGameProfile.getGameProfile(player); + profile.getProperties().clear(); + profile.getProperties().put("textures", SkinData.REVOLUTIONARY.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile); + disguisePlayer.showInTabList(true, 0); + UtilMorph.disguise(player, disguisePlayer, Manager); + + } + + /** + * Restores the player's skin + */ + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + // Clear cooldown timers + if (event.getType() == UpdateType.SEC) + { + Iterator> itr = _flagCooldowns.entrySet().iterator(); + + while (itr.hasNext()) + { + Map.Entry entry = itr.next(); + + if (entry.getValue() + FLAG_COOLDOWN < System.currentTimeMillis()) + { + itr.remove(); + } + } + } + + // For all active cosmetics + for (Player player : getActive()) + { + UUID uuid = player.getUniqueId(); + + // If the player is attempting to place a flag + if (_flagTimers.containsKey(uuid) && !_flagCooldowns.containsKey(uuid)) + { + // Mark them as no longer attempting to place if not sneaking + if (!player.isSneaking()) + { + _flagTimers.remove(uuid); + continue; + } + + // If the players has waiting long enough to place the flag + if (_flagTimers.get(uuid) + FLAG_DELAY < System.currentTimeMillis()) + { + boolean flag = false; + Location location = player.getLocation().subtract(0, 0.5, 0); + + // Make sure the ground is flat enough to place the flag + for (int i = 0; i < BEACON_BASE.length; ++i) + { + Block b = location.clone().add(BEACON_BASE[i][0], 0, BEACON_BASE[i][2]).getBlock(); + + if (b.isEmpty()) + { + flag = true; + break; + } + } + + if (flag) + { + _flagTimers.remove(uuid); + player.sendMessage(F.main("Morphs", C.cRed + "You must plant your flag on flatter ground.")); + } + else + { + // handle placing the flag + if (Recharge.Instance.use(player, RECHARGE_KEY, FLAG_COOLDOWN, true, false)) + { + _flagTimers.remove(uuid); + _flagCooldowns.put(uuid, System.currentTimeMillis()); + buildStructure(player); + } + } + } + else + { + // Play particles leading up to placing the flag + int particleCount = (int) ((System.currentTimeMillis() - _flagTimers.get(uuid)) / 40); + UtilParticle.playParticleFor(player, UtilParticle.ParticleType.FIREWORKS_SPARK, + UtilMath.gauss(player.getLocation().add(0, 1, 0), 2, 6, 2), null, 0, particleCount, UtilParticle.ViewDist.NORMAL); + } + } + else // if the player is not attempting to or has already placed a flag + { + if (player.isSneaking()) + { + if (_flagCooldowns.containsKey(uuid)) + { + Recharge.Instance.usable(player, RECHARGE_KEY, true); + } + else + { + _flagTimers.put(uuid, System.currentTimeMillis()); + _flagCooldowns.remove(uuid); + } + } + } + } + } + + /** + * Builds the structure and beacon by the player. + */ + private void buildStructure(Player player) + { + World world = player.getWorld(); + BlockRestore restore = Manager.getBlockRestore(); + int r = ThreadLocalRandom.current().nextInt(3); + byte data = r == 0 ? (byte) 14 : r == 1 ? (byte) 0 : 11; + Location point = player.getLocation().subtract(0, 0.5, 0); + + while (point.getY() > 1 && !(UtilBlock.fullSolid(point.getBlock()) || UtilBlock.airFoliage(point.getBlock()))) + { + point.setY(point.getY() - 1); + } + + Block glass = point.getBlock().getRelative(BlockFace.UP); + restore.add(glass, Material.STAINED_GLASS.getId(), data, FLAG_COOLDOWN); + glass = glass.getRelative(BlockFace.UP); + restore.add(glass, Material.STAINED_GLASS.getId(), data, FLAG_COOLDOWN); + + BlockFace[] faces = { BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST, BlockFace.EAST }; + Block[] blocks = { glass.getRelative(BlockFace.NORTH), glass.getRelative(BlockFace.SOUTH), + glass.getRelative(BlockFace.WEST), glass.getRelative(BlockFace.EAST) }; + + restore.add(glass.getRelative(BlockFace.UP), Material.CARPET.getId(), data, FLAG_COOLDOWN - 50); + + for (int i = 0; i < 4; ++i) + { + restore.add(blocks[i], Material.WALL_BANNER.getId(), (byte) i, blocks[i].getTypeId(), blocks[i].getData(), FLAG_COOLDOWN - 100); + } + + for (int i = 0; i < 4; ++i) + { + Banner state = ((Banner) blocks[i].getState()); + org.bukkit.material.Banner stateData = (org.bukkit.material.Banner) state.getData(); + stateData.setFacingDirection(faces[i]); + CountryFlag flag = i < 2 ? CountryFlag.USA : CountryFlag.CANADA; + state.setBaseColor(flag.getBaseColor()); + state.setPatterns(flag.getPatterns()); + state.update(); + } + + restore.add(point.getBlock(), Material.PISTON_BASE.getId(), (byte) 0, FLAG_COOLDOWN); + + point.subtract(0, 1, 0); + restore.add(point.getBlock(), Material.PISTON_BASE.getId(), (byte) 0, FLAG_COOLDOWN); + + restore.add(point.getBlock().getRelative(BlockFace.DOWN), Material.BEACON.getId(), (byte) 0, FLAG_COOLDOWN); + + for (int i = 0; i < BEACON_BASE.length; ++i) + { + restore.add(world.getBlockAt(point.clone().add(BEACON_BASE[i][0], BEACON_BASE[i][1], BEACON_BASE[i][2])), + Material.IRON_BLOCK.getId(), (byte) 0, FLAG_COOLDOWN); + } + + UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.HUGE_EXPLOSION, player.getLocation(), null, 0, 1, UtilParticle.ViewDist.NORMAL); + player.playSound(player.getLocation(), Sound.EXPLODE, 1.0f, 1.0f); + player.teleport(player.getLocation().add(0, 2.5, 0)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index 83fc019ad..8dc08a791 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -39,6 +39,7 @@ public class PowerPlayClubRewards .put(YearMonth.of(2017, Month.APRIL), new UnknownSalesPackageItem("Bumblebee's Wings")) .put(YearMonth.of(2017, Month.MAY), new UnknownSalesPackageItem("King")) .put(YearMonth.of(2017, Month.JUNE), new UnknownSalesPackageItem("Bob Ross Morph")) + .put(YearMonth.of(2017, Month.JULY), new UnknownSalesPackageItem("Freedom Fighter")) .build(); public interface PowerPlayClubItem From acaf3b2dd97630608a58371294dc2e390cbb67c3 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 1 Jul 2017 01:09:05 -0400 Subject: [PATCH 046/183] Change freedom treasure from 35k to 30k shards --- .../src/mineplex/core/treasure/TreasureType.java | 2 +- .../src/mineplex/core/treasure/gui/TreasurePage.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java index a9d3bf5c1..784018ca9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java @@ -18,7 +18,7 @@ public enum TreasureType ILLUMINATED(C.cAqua + "Illuminated Treasure", "Illuminated Chest", "Illuminated", RewardType.ILLUMINATED_CHEST, Material.CHEST, TreasureStyle.ILLUMINATED, RewardPool.Type.ILLUMINATED, true, 20000), - FREEDOM(C.cRed + "Freedom " + C.cBlue + "Treasure", "Freedom Treasure", "Freedom", RewardType.FREEDOM_CHEST, Material.CHEST, TreasureStyle.FREEDOM, RewardPool.Type.FREEDOM, true, 35000), + FREEDOM(C.cRed + "Freedom " + C.cBlue + "Treasure", "Freedom Treasure", "Freedom", RewardType.FREEDOM_CHEST, Material.CHEST, TreasureStyle.FREEDOM, RewardPool.Type.FREEDOM, true, 20000), OMEGA(C.cAqua + "Omega Chest", "Omega Chest", "Omega", RewardType.OMEGA_CHEST, Material.ENDER_CHEST, TreasureStyle.OMEGA, RewardPool.Type.OMEGA, false, 50000), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index 6c79d08c8..154c0f4e7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -261,7 +261,7 @@ public class TreasurePage extends ShopPageBase freedomLore.add(" "); freedomLore.add(C.cGray + "It is said that George Washington"); freedomLore.add(C.cGray + "carved this chest himself from the wood"); - freedomLore.add(C.cGray + "of the apple tree he cut down..."); + freedomLore.add(C.cGray + "of the cherry tree he cut down..."); freedomLore.add(" "); if (freedomCount > 0) @@ -287,7 +287,9 @@ public class TreasurePage extends ShopPageBase } else { - freedomLore.add(ChatColor.RESET + "Purchase at: " + C.cYellow + "www.mineplex.com/shop"); + freedomLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "20000 Treasure Shards"); + freedomLore.add(" "); + freedomLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop"); } } From 43b1a118d3e51e9daeed776386158e8f87f55158 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 1 Jul 2017 01:11:17 -0400 Subject: [PATCH 047/183] Final tweaks and bugfixes for Sigils --- .../game/games/battleroyale/BattleRoyale.java | 125 +++++++++++------- 1 file changed, 75 insertions(+), 50 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java index 73842accd..bcc43c75c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java @@ -1,9 +1,51 @@ package nautilus.game.arcade.game.games.battleroyale; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import org.bukkit.Bukkit; +import org.bukkit.Color; +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.entity.Chicken; +import org.bukkit.entity.EnderDragon; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.AnvilInventory; +import org.bukkit.inventory.EnchantingInventory; +import org.bukkit.inventory.FurnaceInventory; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitRunnable; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; 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.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -30,43 +72,6 @@ import nautilus.game.arcade.game.modules.chest.ChestLootModule; import nautilus.game.arcade.game.modules.chest.ChestLootPool; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; -import org.bukkit.Bukkit; -import org.bukkit.Color; -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.entity.Chicken; -import org.bukkit.entity.EnderDragon; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryOpenEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.AnvilInventory; -import org.bukkit.inventory.EnchantingInventory; -import org.bukkit.inventory.FurnaceInventory; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; public abstract class BattleRoyale extends Game { @@ -191,7 +196,7 @@ public abstract class BattleRoyale extends Game .addItem(buildFromGun(GunStats.SSG08), 0.2) .addItem(buildFromGun(GunStats.NOVA), 0.2) .addItem(buildFromGun(GunStats.XM1014), 0.2) - .setProbability(0.4) + .setProbability(0.5) , // Grenades @@ -269,14 +274,9 @@ public abstract class BattleRoyale extends Game // Misc new ChestLootPool() - .addItem(new ItemStack(Material.STRING), 1, 2, 0.5) - .addItem(new ItemStack(Material.STICK), 1, 2) - .addItem(new ItemStack(Material.FLINT), 1, 2) - .addItem(new ItemStack(Material.FEATHER), 1, 2) .addItem(SMALL_BACKPACK, 0.5) .addItem(LARGE_BACKPACK, 0.2) .setProbability(0.2) - .setAmountsPerChest(1, 2) ) .registerChestType("Supply Drop", new ArrayList<>(0), @@ -724,12 +724,16 @@ public abstract class BattleRoyale extends Game } @EventHandler - public void clickBackpack(InventoryClickEvent event) + public void clickBackpack(PlayerInteractEvent event) { - Player player = (Player) event.getWhoClicked(); - ItemStack itemStack = event.getCurrentItem(); + Player player = event.getPlayer(); + ItemStack itemStack = event.getItem(); - if (event.getClickedInventory() == null || itemStack == null) + if (itemStack == null) + { + return; + } + if (!UtilEvent.isAction(event, ActionType.R)) { return; } @@ -763,8 +767,16 @@ public abstract class BattleRoyale extends Game removed++; } } - - event.setCurrentItem(null); + + if (itemStack.getAmount() > 1) + { + itemStack.setAmount(itemStack.getAmount() - 1); + } + else + { + player.getInventory().setItemInHand(null); + } + player.updateInventory(); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1); player.sendMessage(F.main("Game", "You unlocked an additional " + F.elem(removed) + " slots in your inventory.")); } @@ -828,6 +840,19 @@ public abstract class BattleRoyale extends Game Player player = event.getEntity(); awardTimeGems(player); } + + @EventHandler + public void onIceMelt(BlockFadeEvent event) + { + if (!event.getBlock().getWorld().equals(WorldData.World)) + { + return; + } + if (event.getBlock().getType() == Material.ICE) + { + event.setCancelled(true); + } + } protected void awardTimeGems(Player player) { @@ -847,4 +872,4 @@ public abstract class BattleRoyale extends Game return _border.getSize() == MIN_CORD ? 200 : 100; } -} +} \ No newline at end of file From b36c5da721545b2f69fa7598e8de97535ca17652 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 1 Jul 2017 05:56:53 -0400 Subject: [PATCH 048/183] Fix bug which stopped more than 1 use of ability --- .../core/gadget/gadgets/morph/MorphFreedomFighter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java index d3b117b29..f2af2f184 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java @@ -188,7 +188,10 @@ public class MorphFreedomFighter extends MorphGadget { if (_flagCooldowns.containsKey(uuid)) { - Recharge.Instance.usable(player, RECHARGE_KEY, true); + if (Recharge.Instance.usable(player, RECHARGE_KEY, true)) + { + _flagCooldowns.remove(uuid); + } } else { From cd110ddef999a23a8590d6ae2669ce593d7b48f4 Mon Sep 17 00:00:00 2001 From: cnr Date: Sat, 1 Jul 2017 03:48:49 -0700 Subject: [PATCH 049/183] Add purchase condition for freedom chests --- .../src/mineplex/core/treasure/gui/BuyChestButton.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java index c119b1ae2..e314d0915 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -111,16 +111,16 @@ public class BuyChestButton implements IButton } if (_chestType == TreasureType.FREEDOM || _chestType == TreasureType.HAUNTED) { + if (!new File("../../update/files/EnableFreedomChest.dat").exists()) + { + player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); + return; + } if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) { player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); return; } - else - { - player.sendMessage(F.main("Treasure", "This chest is no longer available for purchases!")); - return; - } } if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player) && (_chestType == TreasureType.ILLUMINATED || _chestType == TreasureType.OMEGA From 5a4fab5fc05ef2c628e03c40350cb36cb14e447e Mon Sep 17 00:00:00 2001 From: cnr Date: Sat, 1 Jul 2017 04:11:03 -0700 Subject: [PATCH 050/183] Separate out Haunted Chest purchase condition --- .../core/treasure/gui/BuyChestButton.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java index e314d0915..e01e16b44 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -109,7 +109,20 @@ public class BuyChestButton implements IButton return; } } - if (_chestType == TreasureType.FREEDOM || _chestType == TreasureType.HAUNTED) + if (_chestType == TreasureType.HAUNTED) + { + if (!new File("../../update/files/EnableHauntedChest.dat").exists()) + { + player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); + return; + } + if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) + { + player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); + return; + } + } + if (_chestType == TreasureType.FREEDOM) { if (!new File("../../update/files/EnableFreedomChest.dat").exists()) { From dca43b6c57d43166c291a39fde153ecf4120dc2d Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 3 Jul 2017 00:36:54 +0100 Subject: [PATCH 051/183] Separate Gem Hunters inventories by region --- .../gemhunters/persistence/PersistenceData.java | 10 +++++++++- .../persistence/PersistenceModule.java | 5 ++++- .../persistence/PersistenceRepository.java | 16 +++++++++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceData.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceData.java index fed987d21..3ab3ed48f 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceData.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceData.java @@ -1,12 +1,14 @@ package mineplex.gemhunters.persistence; import mineplex.gemhunters.quest.QuestPlayerData; +import mineplex.serverdata.Region; import org.bukkit.Location; import org.bukkit.inventory.ItemStack; public class PersistenceData { + private final Region _region; private final int _gems; private final Location _location; private final QuestPlayerData _questData; @@ -19,8 +21,9 @@ public class PersistenceData private final long _saveTime; private final int _cashOutTime; - public PersistenceData(int gems, Location location, QuestPlayerData questData, int health, int maxHealth, int hunger, int slots, ItemStack[] items, ItemStack[] armour, long saveTime, int cashOutTime) + public PersistenceData(Region region, int gems, Location location, QuestPlayerData questData, int health, int maxHealth, int hunger, int slots, ItemStack[] items, ItemStack[] armour, long saveTime, int cashOutTime) { + _region = region; _gems = gems; _location = location; _questData = questData; @@ -34,6 +37,11 @@ public class PersistenceData _cashOutTime = cashOutTime; } + public Region getRegion() + { + return _region; + } + public int getGems() { return _gems; diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceModule.java index 322f25d54..aeaf4da47 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceModule.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import mineplex.core.common.util.UtilServer; +import mineplex.serverdata.Region; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -84,6 +86,7 @@ public class PersistenceModule extends MiniPlugin return; } + Region region = UtilServer.getRegion(); int gems = _economy.Get(player); Location location = player.getLocation(); QuestPlayerData quest = _quest.Get(player); @@ -106,7 +109,7 @@ public class PersistenceModule extends MiniPlugin cashOutTime = (int) rechargeData.GetRemaining(); } - PersistenceData data = new PersistenceData(gems, location, quest, health, maxHealth, hunger, slots, items, armour, saveTime, cashOutTime); + PersistenceData data = new PersistenceData(region, gems, location, quest, health, maxHealth, hunger, slots, items, armour, saveTime, cashOutTime); runAsync(() -> { diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java index cab1e644a..3f6bcf360 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java @@ -2,7 +2,9 @@ package mineplex.gemhunters.persistence; import com.google.gson.Gson; import mineplex.core.account.CoreClient; +import mineplex.core.common.util.UtilServer; import mineplex.gemhunters.quest.QuestPlayerData; +import mineplex.serverdata.Region; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnInt; @@ -25,9 +27,9 @@ import java.util.function.Consumer; public class PersistenceRepository extends RepositoryBase { - private static final String GET_DATA = "SELECT * FROM gemHunters WHERE accountId=?;"; - private static final String INSERT_DATA = "INSERT INTO gemHunters VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"; - private static final String UPDATE_DATA = "UPDATE gemHunters SET gems=?,health=?,maxHealth=?,hunger=?,x=?,y=?,z=?,yaw=?,pitch=?,quests=?,slots=?,items=?,armour=?,saveTime=?,cashOutTime=? WHERE accountId=?;"; + private static final String GET_DATA = "SELECT * FROM gemHunters WHERE accountId=? AND region=?;"; + private static final String INSERT_DATA = "INSERT INTO gemHunters VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"; + private static final String UPDATE_DATA = "UPDATE gemHunters SET region=?,gems=?,health=?,maxHealth=?,hunger=?,x=?,y=?,z=?,yaw=?,pitch=?,quests=?,slots=?,items=?,armour=?,saveTime=?,cashOutTime=? WHERE accountId=?;"; private static final String DELETE_DATA = "DELETE FROM gemHunters WHERE accountId=?;"; private static final Gson GSON; private static final ItemStack AIR = new ItemStack(Material.AIR); @@ -49,6 +51,7 @@ public class PersistenceRepository extends RepositoryBase public void getPersistenceData(Consumer response, CoreClient client) { int accountId = client.getAccountId(); + Region region = UtilServer.getRegion(); executeQuery(GET_DATA, resultSet -> { @@ -111,16 +114,17 @@ public class PersistenceRepository extends RepositoryBase _exists.add(accountId); Location location = new Location(Bukkit.getWorlds().get(0), x, y, z, yaw, pitch); - PersistenceData data = new PersistenceData(gems, location, questData, health, maxHealth, hunger, slots, itemsList.toArray(new ItemStack[0]), armourList.toArray(new ItemStack[0]), saveTime.getTime(), cashOutTime); + PersistenceData data = new PersistenceData(region, gems, location, questData, health, maxHealth, hunger, slots, itemsList.toArray(new ItemStack[0]), armourList.toArray(new ItemStack[0]), saveTime.getTime(), cashOutTime); response.accept(data); } - }, new ColumnInt("accountId", accountId)); + }, new ColumnInt("accountId", accountId), new ColumnVarChar("region", 2, region.toString())); } public void savePersistence(CoreClient client, PersistenceData data) { int accountId = client.getAccountId(); + Region region = data.getRegion(); int gems = data.getGems(); int health = data.getHealth(); int maxHealth = data.getMaxHealth(); @@ -161,6 +165,7 @@ public class PersistenceRepository extends RepositoryBase if (exists(client)) { executeUpdate(UPDATE_DATA, + new ColumnVarChar("region", 2, region.toString()), new ColumnInt("gems", gems), new ColumnInt("health", health), new ColumnInt("maxHealth", maxHealth), @@ -183,6 +188,7 @@ public class PersistenceRepository extends RepositoryBase { executeInsert(INSERT_DATA, null, new ColumnInt("accountId", accountId), + new ColumnVarChar("region", 2, region.toString()), new ColumnInt("gems", gems), new ColumnInt("health", health), new ColumnInt("maxHealth", maxHealth), From 1d046ff11918cfebf01548858610867014c8e5cb Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 5 Jul 2017 23:38:24 +0200 Subject: [PATCH 052/183] Add "all" to the GetMineplexMission Command, dont let specs get chest quest progress --- .../core/quests/command/GetQuestCommand.java | 38 +++++++++++++++---- .../game/games/dragonescape/DragonEscape.java | 3 +- .../arcade/quest/ChestOpenQuestTracker.java | 3 ++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java index 1b7fe9cc8..867779ee7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java @@ -1,5 +1,7 @@ package mineplex.core.quests.command; +import java.util.ArrayList; + import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -7,6 +9,7 @@ import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.quests.Quest; import mineplex.core.quests.QuestManager; @@ -37,19 +40,40 @@ public class GetQuestCommand extends CommandBase return; } - Player player = caller; + ArrayList players = new ArrayList<>(); if (args.length == 2) { if (UtilPlayer.searchExact(args[1]) != null) - player = UtilPlayer.searchExact(args[1]); + { + players.add(UtilPlayer.searchExact(args[1])); + } + else + { + if (args[1].equalsIgnoreCase("all")) + { + players.addAll(UtilServer.getPlayersCollection()); + } + } } Quest quest = Plugin.getQuestByID(Integer.parseInt(args[0])); - Plugin.addNewQuest(player, quest); - UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Added " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName())); - - if (caller != player) - UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + player.getName())); + for (Player player : players) + { + Plugin.addNewQuest(player, quest); + UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Added " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName())); + + + if (args[1].equalsIgnoreCase("all")) + { + UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + "everyone")); + } + else + { + if (caller != players.get(0)) + UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + player.getName())); + + } + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index 9646a217c..38abce9fb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -8,7 +8,6 @@ import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; -import mineplex.core.common.Pair; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -34,6 +33,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; +import mineplex.core.common.Pair; import mineplex.core.common.block.BlockData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -52,6 +52,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java index 30cbb77d2..c7a935560 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/ChestOpenQuestTracker.java @@ -38,6 +38,9 @@ public class ChestOpenQuestTracker extends QuestTracker if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; + if (!getGame().IsAlive(event.getPlayer())) + return; + if (event.getClickedBlock().getType() != Material.CHEST) return; From c5818b1bb589c603b708002afae7e8a40aec82b8 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 6 Jul 2017 00:35:05 +0100 Subject: [PATCH 053/183] Update time! --- .../achievement/ui/page/AchievementPage.java | 2 +- .../playerdisguise/PlayerDisguiseManager.java | 32 +++++--- .../hub/server/ui/ServerGameMenu.java | 2 +- .../game/arcade/game/games/moba/Moba.java | 5 +- .../games/moba/general/MobaDamageManager.java | 28 +++++++ .../moba/kit/larissa/SkillAquaCannon.java | 4 +- .../arcade/game/games/moba/shop/MobaShop.java | 10 ++- .../moba/shop/warrior/MobaWarriorShop.java | 80 +++++++++---------- .../games/moba/structure/tower/Tower.java | 18 +++++ .../moba/structure/tower/TowerManager.java | 7 ++ .../games/moba/training/MobaTraining.java | 3 +- 11 files changed, 131 insertions(+), 60 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java index 3915059e8..d68117cf7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java @@ -31,7 +31,7 @@ import mineplex.core.stats.StatsManager; public class AchievementPage extends ShopPageBase { - private static int ACHIEVEMENT_MIDDLE_INDEX = 31; + private static final int ACHIEVEMENT_MIDDLE_INDEX = 31; private AchievementCategory _category; private StatsManager _statsManager; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java index a650df7ec..06829a12d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java @@ -423,10 +423,26 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler DisguisePlayer disguise = _disguises.remove(caller.getUniqueId()); + undisguise(caller, disguise); + + _mapping.remove(disguise.getName().toLowerCase()); + + UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!")); + getPluginManager().callEvent(new PlayerUndisguisedEvent(caller)); + removeDisguiseData(caller); + } + + public void undisguise(Player caller, DisguisePlayer disguise) + { GameProfile originalProfile = disguise.getOriginalProfile(); GameProfile currentProfile = ((CraftPlayer) caller).getProfile(); + boolean sameName = caller.getName().equals(currentProfile.getName()); + + if (!sameName) + { + require(ScoreboardManager.class).handlePlayerQuit(disguise.getName()); + } - require(ScoreboardManager.class).handlePlayerQuit(disguise.getName()); try { UtilGameProfile.changeName(currentProfile, originalProfile.getName()); @@ -447,7 +463,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler return; } - getDisguiseManager().undisguise(caller); + getDisguiseManager().undisguise(disguise); GameProfile disguisedProfile = disguise.getProfile(); @@ -458,14 +474,10 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler require(FriendManager.class).updatePlayerStatus(originalProfile.getId(), new PlayerStatus(originalProfile.getId(), originalProfile.getName(), _serverName)); getPreferencesManager().handlePlayerJoin(caller, true); - require(ScoreboardManager.class).handlePlayerJoin(disguise.getOriginalProfile().getName()); - - - _mapping.remove(disguise.getName().toLowerCase()); - - UtilPlayer.message(caller, F.main("Disguise", "You are no longer disguised!")); - getPluginManager().callEvent(new PlayerUndisguisedEvent(caller)); - removeDisguiseData(caller); + if (!sameName) + { + require(ScoreboardManager.class).handlePlayerJoin(disguise.getOriginalProfile().getName()); + } } public void disguise(Player caller, GameProfile requestedProfile) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 07e52532f..ea290f3c1 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -126,7 +126,7 @@ public class ServerGameMenu extends ShopPageBase add(13, Material.FEATHER, (byte) 0, C.cYellowB + "Skywars " + C.cGray + "Solo/Team Survival", new String[] { C.Reset + "", - C.Reset + "16 contenders fight to rule the skies!", + C.Reset + "12 contenders fight to rule the skies!", C.Reset + "Spawn on a sky island and build your path!", C.Reset + "Find weapons to take your enemies down!", C.Reset + "Up in the skies, death looming if you fall..", diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index f1db74bae..fad12392b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -9,6 +9,7 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager; import mineplex.core.leaderboard.Leaderboard; import mineplex.core.leaderboard.LeaderboardManager; import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; @@ -283,6 +284,8 @@ public class Moba extends TeamGame _listeners.clear(); _betaWhitelist.deregisterSelf(); + PlayerDisguiseManager playerDisguiseManager = Managers.require(PlayerDisguiseManager.class); + // Undisguise all players for (Player player : Bukkit.getOnlinePlayers()) { @@ -290,7 +293,7 @@ public class Moba extends TeamGame if (disguise != null && disguise instanceof DisguisePlayer) { - Manager.GetDisguise().undisguise(disguise); + playerDisguiseManager.undisguise(player, (DisguisePlayer) disguise); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java index 7fa54255c..6a0cfccfc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java @@ -13,6 +13,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.potion.PotionEffectType; public class MobaDamageManager implements Listener { @@ -97,4 +99,30 @@ public class MobaDamageManager implements Listener event.setKilledWord(word); } } + + @EventHandler + public void mageStrength(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.CUSTOM) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + + if (damager == null) + { + return; + } + + damager.getActivePotionEffects().forEach(effect -> + { + + if (effect.getType() == PotionEffectType.INCREASE_DAMAGE) + { + event.AddMod("Strength", effect.getAmplifier() * 2 + 1); + } + + }); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java index e2f7b1c9f..c49d9fef5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java @@ -29,7 +29,7 @@ public class SkillAquaCannon extends HeroSkill "Fires a beam of water that deals damage", "to the first enemy it comes in contact with." }; - private static final int DAMAGE = 6; + private static final int DAMAGE = 4; private static final ItemStack SKILL_ITEM = new ItemStack(Material.DIAMOND_HOE); public SkillAquaCannon(int slot) @@ -66,7 +66,7 @@ public class SkillAquaCannon extends HeroSkill continue; } - Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, DAMAGE, true, false, false, player.getName(), MobaConstants.BASIC_ATTACK); + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, DAMAGE, false, false, false, player.getName(), MobaConstants.BASIC_ATTACK); break; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 55c40f2af..f0c15a324 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -4,7 +4,6 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -42,8 +41,6 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerItemConsumeEvent; -import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.HashMap; @@ -95,6 +92,7 @@ public class MobaShop implements Listener villager.setCustomNameVisible(true); UtilEnt.vegetate(villager); UtilEnt.silence(villager, true); + UtilEnt.ghost(villager, true, false); UtilEnt.CreatureForceLook(villager, 0, UtilAlg.GetYaw(UtilAlg.getTrajectory(villager.getLocation(), _host.GetSpectatorLocation()))); ((CraftLivingEntity) villager).getHandle().k = false; @@ -226,6 +224,12 @@ public class MobaShop implements Listener } _host.GetKit(player).GiveItems(player); + + // If we aren't tracking purchases then after we give the item remove it. + if (!category.isTrackingPurchases()) + { + owned.remove(item); + } } public boolean ownsItem(Player player, MobaItem item) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java index 2d0ca6f60..8c9118358 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java @@ -44,21 +44,21 @@ public class MobaWarriorShop extends MobaShopMenu new MobaItem(new ItemBuilder(Material.IRON_HELMET) .setTitle(C.cGreenB + "Archer's Bane") .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) - .build(), 400) + .build(), 100) .addEffects( new MobaHPRegenEffect(0.03) ), -// new MobaItem(new ItemBuilder(Material.IRON_HELMET) -// .setTitle(C.cYellowB + "Superior Archer's Bane") -// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) -// .build(), 750) -// .addEffects( -// new MobaHPRegenEffect(0.05) -// ), + new MobaItem(new ItemBuilder(Material.IRON_HELMET) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 300) + .addEffects( + new MobaHPRegenEffect(0.05) + ), new MobaItem(new ItemBuilder(Material.IRON_HELMET) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) - .build(), 400) + .build(), 300) .addEffects( new MobaHPRegenEffect(0.03) ), @@ -71,7 +71,7 @@ public class MobaWarriorShop extends MobaShopMenu // ), new MobaItem(new ItemBuilder(Material.DIAMOND_HELMET) .setTitle(C.cDRedB + "Prince's Plate") - .build(), 2000) + .build(), 1200) .addEffects( new MobaHPRegenEffect(0.15) ) @@ -81,21 +81,21 @@ public class MobaWarriorShop extends MobaShopMenu new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) .setTitle(C.cGreenB + "Archer's Bane") .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) - .build(), 600) + .build(), 150) .addEffects( new MobaTotalHealthEffect(2) ), -// new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) -// .setTitle(C.cYellowB + "Superior Archer's Bane") -// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) -// .build(), 1000) -// .addEffects( -// new MobaTotalHealthEffect(4) -// ), + new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 400) + .addEffects( + new MobaTotalHealthEffect(4) + ), new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) - .build(), 600) + .build(), 400) .addEffects( new MobaTotalHealthEffect(2) ), @@ -108,7 +108,7 @@ public class MobaWarriorShop extends MobaShopMenu // ), new MobaItem(new ItemBuilder(Material.DIAMOND_CHESTPLATE) .setTitle(C.cDRedB + "Prince's Plate") - .build(), 2500) + .build(), 1500) .addEffects( new MobaTotalHealthEffect(4) ) @@ -118,21 +118,21 @@ public class MobaWarriorShop extends MobaShopMenu new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) .setTitle(C.cGreenB + "Archer's Bane") .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) - .build(), 600) + .build(), 150) .addEffects( new MobaCDREffect(0.05) ), -// new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) -// .setTitle(C.cYellowB + "Superior Archer's Bane") -// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) -// .build(), 1000) -// .addEffects( -// new MobaCDREffect(0.07) -// ), + new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 400) + .addEffects( + new MobaCDREffect(0.07) + ), new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) - .build(), 600) + .build(), 400) .addEffects( new MobaCDREffect(0.05) ), @@ -145,7 +145,7 @@ public class MobaWarriorShop extends MobaShopMenu // ), new MobaItem(new ItemBuilder(Material.DIAMOND_LEGGINGS) .setTitle(C.cDRedB + "Prince's Plate") - .build(), 2500) + .build(), 1500) .addEffects( new MobaCDREffect(0.1) ) @@ -155,21 +155,21 @@ public class MobaWarriorShop extends MobaShopMenu new MobaItem(new ItemBuilder(Material.IRON_BOOTS) .setTitle(C.cGreenB + "Archer's Bane") .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) - .build(), 400) + .build(), 100) .addEffects( new MobaSpeedEffect(0.04) ), -// new MobaItem(new ItemBuilder(Material.IRON_BOOTS) -// .setTitle(C.cYellowB + "Superior Archer's Bane") -// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) -// .build(), 750) -// .addEffects( -// new MobaSpeedEffect(0.06) -// ), + new MobaItem(new ItemBuilder(Material.IRON_BOOTS) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 300) + .addEffects( + new MobaSpeedEffect(0.06) + ), new MobaItem(new ItemBuilder(Material.IRON_BOOTS) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) - .build(), 400) + .build(), 300) .addEffects( new MobaSpeedEffect(0.04) ), @@ -182,7 +182,7 @@ public class MobaWarriorShop extends MobaShopMenu // ), new MobaItem(new ItemBuilder(Material.DIAMOND_BOOTS) .setTitle(C.cDRedB + "Prince's Plate") - .build(), 2000) + .build(), 1200) .addEffects( new MobaSpeedEffect(0.1) ) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index efb13fcb6..9d94785d4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -135,6 +135,24 @@ public class Tower _host.getArcadeManager().GetDamage().NewDamageEvent(_target, null, null, DamageCause.CUSTOM, _damage++, false, true, false, "Tower", "Tower"); } + public void updateHealing() + { + if (_dead) + { + return; + } + + for (Player player : _team.GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player) || UtilMath.offsetSquared(player, _crystal) > TARGET_RANGE_SQUARED) + { + continue; + } + + MobaUtil.heal(player, null, 2); + } + } + private void setLaserTarget(LivingEntity target) { if (target == null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index eaa2f4626..b252f1477 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -144,6 +144,13 @@ public class TowerManager implements Listener tower.updateDamage(); } } + else if (event.getType() != UpdateType.SLOW) + { + for (Tower tower : _towers) + { + tower.updateHealing(); + } + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index 439390385..aa21262a6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -364,6 +364,7 @@ public class MobaTraining extends Moba UtilEnt.vegetate(entity); UtilEnt.setFakeHead(entity, true); UtilEnt.silence(entity, true); + UtilEnt.ghost(entity, true, false); } CreatureAllowOverride = false; @@ -452,8 +453,6 @@ public class MobaTraining extends Moba // Reducing the wither's health to 10% gives a shield like effect. stand.setGravity(false); - UtilEnt.setBoundingBox(stand, 3, 5); - DisguiseWither disguise = new DisguiseWither(stand); disguise.setName(C.cAqua + "Blue's Wither"); disguise.setCustomNameVisible(true); From ed3455db6863042d405f7ce155e4d09a930d948c Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 6 Jul 2017 00:59:43 +0100 Subject: [PATCH 054/183] No need to update primary key --- .../mineplex/gemhunters/persistence/PersistenceRepository.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java index 3f6bcf360..6ce1437d3 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java @@ -29,7 +29,7 @@ public class PersistenceRepository extends RepositoryBase private static final String GET_DATA = "SELECT * FROM gemHunters WHERE accountId=? AND region=?;"; private static final String INSERT_DATA = "INSERT INTO gemHunters VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"; - private static final String UPDATE_DATA = "UPDATE gemHunters SET region=?,gems=?,health=?,maxHealth=?,hunger=?,x=?,y=?,z=?,yaw=?,pitch=?,quests=?,slots=?,items=?,armour=?,saveTime=?,cashOutTime=? WHERE accountId=?;"; + private static final String UPDATE_DATA = "UPDATE gemHunters SET gems=?,health=?,maxHealth=?,hunger=?,x=?,y=?,z=?,yaw=?,pitch=?,quests=?,slots=?,items=?,armour=?,saveTime=?,cashOutTime=? WHERE accountId=?;"; private static final String DELETE_DATA = "DELETE FROM gemHunters WHERE accountId=?;"; private static final Gson GSON; private static final ItemStack AIR = new ItemStack(Material.AIR); @@ -165,7 +165,6 @@ public class PersistenceRepository extends RepositoryBase if (exists(client)) { executeUpdate(UPDATE_DATA, - new ColumnVarChar("region", 2, region.toString()), new ColumnInt("gems", gems), new ColumnInt("health", health), new ColumnInt("maxHealth", maxHealth), From c341671ffc3420b4cf742b22bb6a7a4f5d7a8ccb Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 5 Jul 2017 21:33:55 -0700 Subject: [PATCH 055/183] Move GH quit NPCs to redis; use region when saving GH data --- .../death/quitnpc/QuitNPCModule.java | 2 +- .../death/quitnpc/QuitNPCRepository.java | 56 ++++--------------- .../persistence/PersistenceRepository.java | 35 ++++++------ 3 files changed, 30 insertions(+), 63 deletions(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCModule.java index 109e1039f..2bc115159 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCModule.java @@ -101,7 +101,7 @@ public class QuitNPCModule extends MiniPlugin { try { - String npcServer = _repo.loadNpcServer(event.getUniqueId()).get(); + String npcServer = _repo.loadNpcServer(event.getUniqueId()).join(); if (npcServer == null || npcServer.isEmpty()) { return; diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java index 6db02ac7f..c01b2d91e 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java @@ -1,69 +1,33 @@ package mineplex.gemhunters.death.quitnpc; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.util.UUID; import java.util.concurrent.CompletableFuture; import mineplex.core.common.util.UtilServer; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnVarChar; +import mineplex.serverdata.Region; +import mineplex.serverdata.redis.RedisRepository; -public class QuitNPCRepository extends RepositoryBase +public class QuitNPCRepository extends RedisRepository { - private static final String GET_DATA = "SELECT serverName FROM gemHuntersQuitNpcs WHERE uuid=?;"; - private static final String INSERT_DATA = "INSERT INTO gemHuntersQuitNpcs (uuid, serverName) VALUES (?, ?);"; - private static final String DELETE_DATA = "DELETE FROM gemHuntersQuitNpcs WHERE uuid=?;"; + private static final String REDIS_KEY_PREFIX = "GemHuntersNPC."; public QuitNPCRepository() { - super(DBPool.getAccount()); + super(Region.ALL); } - + public CompletableFuture loadNpcServer(UUID uuid) { - return CompletableFuture.supplyAsync(() -> - { - try (Connection conn = getConnection()) - { - PreparedStatement stmt = conn.prepareStatement(GET_DATA); - stmt.setString(1, uuid.toString()); - - String serverName = null; - - ResultSet resultSet = stmt.executeQuery(); - if (resultSet.next()) - { - serverName = resultSet.getString("serverName"); - } - - return serverName; - } - catch (Exception e) - { - e.printStackTrace(); - return null; - } - }); + return CompletableFuture.supplyAsync(() -> getResource(false).get(getKey(REDIS_KEY_PREFIX + uuid.toString()))); } public void deleteNpc(UUID uuid) { - final String uuidStr = uuid.toString(); - UtilServer.runAsync(() -> - { - executeUpdate(DELETE_DATA, new ColumnVarChar("uuid", uuidStr.length(), uuidStr)); - }); + UtilServer.runAsync(() -> getResource(true).del(getKey(REDIS_KEY_PREFIX + uuid.toString()))); } - + public void insertNpc(UUID uuid, String serverName) { - final String uuidStr = uuid.toString(); - UtilServer.runAsync(() -> - { - executeInsert(INSERT_DATA, null, new ColumnVarChar("uuid", uuidStr.length(), uuidStr), new ColumnVarChar("serverName", serverName.length(), serverName)); - }); + UtilServer.runAsync(() -> getResource(true).setex(REDIS_KEY_PREFIX + uuid.toString(), 60, serverName)); } } \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java index 6ce1437d3..3e9d86782 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceRepository.java @@ -1,6 +1,21 @@ package mineplex.gemhunters.persistence; +import java.lang.reflect.Constructor; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + import com.google.gson.Gson; + import mineplex.core.account.CoreClient; import mineplex.core.common.util.UtilServer; import mineplex.gemhunters.quest.QuestPlayerData; @@ -10,26 +25,13 @@ import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnTimestamp; import mineplex.serverdata.database.column.ColumnVarChar; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.lang.reflect.Constructor; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; public class PersistenceRepository extends RepositoryBase { private static final String GET_DATA = "SELECT * FROM gemHunters WHERE accountId=? AND region=?;"; - private static final String INSERT_DATA = "INSERT INTO gemHunters VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"; - private static final String UPDATE_DATA = "UPDATE gemHunters SET gems=?,health=?,maxHealth=?,hunger=?,x=?,y=?,z=?,yaw=?,pitch=?,quests=?,slots=?,items=?,armour=?,saveTime=?,cashOutTime=? WHERE accountId=?;"; + private static final String INSERT_DATA = "INSERT INTO gemHunters (accountId, region, gems, health, maxHealth, hunger, x, y, z, yaw, pitch, quests, slots, items, armour, saveTime, cashOutTime) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"; + private static final String UPDATE_DATA = "UPDATE gemHunters SET gems=?,health=?,maxHealth=?,hunger=?,x=?,y=?,z=?,yaw=?,pitch=?,quests=?,slots=?,items=?,armour=?,saveTime=?,cashOutTime=? WHERE accountId=? AND region=?;"; private static final String DELETE_DATA = "DELETE FROM gemHunters WHERE accountId=?;"; private static final Gson GSON; private static final ItemStack AIR = new ItemStack(Material.AIR); @@ -180,7 +182,8 @@ public class PersistenceRepository extends RepositoryBase new ColumnVarChar("armour", 1000, GSON.toJson(armourMap)), new ColumnTimestamp("saveTime", saveTime), new ColumnInt("cashOutTime", cashOutTime), - new ColumnInt("accountId", accountId) + new ColumnInt("accountId", accountId), + new ColumnVarChar("region", 2, region.toString()) ); } else From fd660f95a0892440c663c072d31c6c1dbad701d3 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 1 Jul 2017 15:28:56 +0100 Subject: [PATCH 056/183] Fix players getting stuck in pregame lobbies --- .../game/arcade/game/games/battleroyale/BattleRoyale.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java index bcc43c75c..683793c0c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyale.java @@ -352,7 +352,7 @@ public abstract class BattleRoyale extends Game { } - @EventHandler + @EventHandler(priority = EventPriority.HIGH) public void prepare(GameStateChangeEvent event) { if (event.GetState() != GameState.Prepare) @@ -377,9 +377,9 @@ public abstract class BattleRoyale extends Game return; } - Player player = toTeleport.get(index.get()); + Player player = toTeleport.get(index.getAndIncrement()); - if (player == null || !player.isOnline() || UtilPlayer.isSpectator(player)) + if (player == null || !player.isOnline()) { return; } @@ -413,8 +413,6 @@ public abstract class BattleRoyale extends Game BattleRoyalePlayer royalePlayer = new BattleRoyalePlayer(Manager, player, spawn, goal); _playerData.put(player, royalePlayer); - - index.getAndIncrement(); } }, 40, 2); } From d61e067b86e191a88e2b116acae1b705db437103 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 1 Jul 2017 14:38:03 -0400 Subject: [PATCH 057/183] Allow customer support to track freedom chests and improve error information to prevent forging/confusion --- .../customerSupport/CustomerSupport.java | 1 + .../games/battleroyale/BattleRoyaleSolo.java | 68 +++++++++++++------ 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 0da0df265..f7ba42c91 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -424,6 +424,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Love Chests Received: " + C.cYellow + loveChestsReceived); caller.sendMessage(C.cBlue + "St Patrick's Chests Received: " + C.cYellow + stPatricksChestReceived); caller.sendMessage(C.cBlue + "Spring Chests Received: " + C.cYellow + springChestsReceived); + caller.sendMessage(C.cBlue + "Freedom Chests Received: " + C.cYellow + freedomChestsReceived); caller.sendMessage(C.cBlue + "Game Amplifiers Received: " + C.cYellow + boostersReceived); caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min/60 min) Received: " + C.cYellow + runeAmplifier20 + "/" + runeAmplifier60); caller.sendMessage(C.cBlue + "Clans Dye Boxes Received: " + C.cYellow + clansDyeBoxesReceived + " " + C.cBlue + "Clans Builder Boxes Received: " + C.cYellow + clansBuilderBoxesReceived); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java index 03a984706..e1d418b26 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyaleSolo.java @@ -1,10 +1,21 @@ package nautilus.game.arcade.game.games.battleroyale; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilWorld; +import mineplex.core.server.util.TransactionResponse; import mineplex.core.treasure.TreasureType; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -16,15 +27,6 @@ import nautilus.game.arcade.game.games.moba.kit.KitPlayer; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.scoreboard.GameScoreboard; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; public class BattleRoyaleSolo extends BattleRoyale { @@ -214,33 +216,55 @@ public class BattleRoyaleSolo extends BattleRoyale if (wins > 1) { - Manager.getInventoryManager().addItemToInventory(success -> + Manager.GetDonation().purchaseUnknownSalesPackage(player, TreasureType.MYTHICAL.getItemName(), GlobalCurrency.GEM, 0, false, data -> { - if (success) + if (data == TransactionResponse.Success) { - player.sendMessage(F.main("Game", "Unlocked 1 " + C.cAqua + "Mythical Chest" + C.mBody + ".")); + Manager.getInventoryManager().addItemToInventory(success -> + { + if (success) + { + player.sendMessage(F.main("Game", "Unlocked 1 " + C.cAqua + "Mythical Chest" + C.mBody + ".")); + } + else + { + player.sendMessage(F.main("Game", "Failed to give you your Mythical Chest, you should take a screenshot of this and make a support ticket!")); + player.sendMessage(C.cGray + "Error Verification Code: " + C.cGreen + new StringBuilder(player.getUniqueId().toString().split("-")[1]).reverse().toString()); + } + }, player, TreasureType.MYTHICAL.getItemName(), 1); } else { - player.sendMessage(F.main("Game", "Failed to give you your Mythical Chest, you should inform a staff member!")); + player.sendMessage(F.main("Game", "Failed to give you your Mythical Chest, you should take a screenshot of this and make a support ticket!")); + player.sendMessage(C.cGray + "Error Verification Code: " + C.cGreen + new StringBuilder(player.getUniqueId().toString().split("-")[1]).reverse().toString()); } - - }, player, TreasureType.MYTHICAL.getItemName(), 1); + }); } else { - Manager.getInventoryManager().addItemToInventory(success -> + Manager.GetDonation().purchaseUnknownSalesPackage(player, TreasureType.FREEDOM.getItemName(), GlobalCurrency.GEM, 0, false, data -> { - if (success) + if (data == TransactionResponse.Success) { - player.sendMessage(F.main("Game", "Unlocked 1 " + C.cRed + "Freedom Chest" + C.mBody + ".")); + Manager.getInventoryManager().addItemToInventory(success -> + { + if (success) + { + player.sendMessage(F.main("Game", "Unlocked 1 " + C.cRed + "Freedom Chest" + C.mBody + ".")); + } + else + { + player.sendMessage(F.main("Game", "Failed to give you your Freedom Chest, you should take a screenshot of this and make a support ticket!")); + player.sendMessage(C.cGray + "Error Verification Code: " + C.cGreen + new StringBuilder(player.getUniqueId().toString().split("-")[1]).reverse().toString()); + } + }, player, TreasureType.FREEDOM.getItemName(), 1); } else { - player.sendMessage(F.main("Game", "Failed to give you your Freedom Chest, you should inform a staff member!")); + player.sendMessage(F.main("Game", "Failed to give you your Freedom Chest, you should take a screenshot of this and make a support ticket!")); + player.sendMessage(C.cGray + "Error Verification Code: " + C.cGreen + new StringBuilder(player.getUniqueId().toString().split("-")[1]).reverse().toString()); } - - }, player, TreasureType.FREEDOM.getItemName(), 1); + }); } AddGems(places.get(0), 20, "1st Place", false, false); From 79644e706cd111e016fc46b6c834c8a104a6e069 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 1 Jul 2017 15:37:56 -0400 Subject: [PATCH 058/183] Update CUST-1 menu for support staff request --- .../customerSupport/CustomerSupport.java | 87 +++++++++++-------- .../customerSupport/checkBonusCommand.java | 47 ++++++++++ .../customerSupport/checkCommand.java | 2 +- 3 files changed, 98 insertions(+), 38 deletions(-) create mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index f7ba42c91..2f7e0cd5c 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -72,6 +72,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable _allowWeatherChange = false; addCommand(new checkCommand(this)); + addCommand(new checkBonusCommand(this)); addCommand(new checkOwnsPackageCommand(this)); addCommand(new ListPPCCommand(this, _powerPlayRepo)); } @@ -108,7 +109,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(F.main(getName(), "Usage : /check defek7")); } - public void showPlayerInfo(Player caller, CoreClient client) + public void showPlayerInfo(Player caller, CoreClient client, boolean bonuses) { String playerName = client.getName(); Donor donor = _donationManager.Get(client.getUniqueId()); @@ -130,8 +131,11 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable StringBuilder basic = new StringBuilder(C.cBlue + "Name: " + C.cYellow + playerName); basic.append(" "); basic.append(C.cBlue + "Rank: " + C.cYellow + (client.GetRank() == null ? C.cRed + "Error rank null!" : (client.GetRank().Name.isEmpty() ? "Regular" : client.GetRank().Name))); - basic.append(" "); - basic.append(C.cBlue + "Gems: " + C.cYellow + donor.getBalance(GlobalCurrency.GEM)); + if (!bonuses) + { + basic.append(" "); + basic.append(C.cBlue + "Gems: " + C.cYellow + donor.getBalance(GlobalCurrency.GEM)); + } caller.sendMessage(basic.toString()); int enjinCoinsReceived = 0; @@ -410,45 +414,54 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable } } - StringBuilder shards = new StringBuilder(C.cBlue + "Enjin Shard Total Received: " + C.cYellow + enjinCoinsReceived); - shards.append(" "); - shards.append(C.cBlue + "Shards: " + C.cYellow + donor.getBalance(GlobalCurrency.TREASURE_SHARD)); - caller.sendMessage(shards.toString()); - // Strutt20 asked me to remove some stuff from the menu - caller.sendMessage(C.cBlue + "Old Chests Received: " + C.cYellow + oldChestsReceived + " " + C.cBlue + "Ancient Chests Received: " + C.cYellow + ancientChestsReceived); - caller.sendMessage(C.cBlue + "Mythical Chests Received: " + C.cYellow + mythicalChestsReceived + " " + C.cBlue + "Illuminated Chests Received: " + C.cYellow + illuminatedChestsReceived); - caller.sendMessage(C.cBlue + "Omega Chests Received: " + C.cYellow + omegaChestsReceived); - caller.sendMessage(C.cBlue + "Haunted Chests Received: " + C.cYellow + hauntedChestsReceived + " " + C.cBlue + "Haunted Chests Opened: " + C.cYellow + hauntedChestsOpened); - caller.sendMessage(C.cBlue + "Trick or Treat Chests Received: " + C.cYellow + trickOrTreatChestsReceived + " " + C.cBlue + "Thankful Chests Received: " + C.cYellow + thankfulChestsReceived); - caller.sendMessage(C.cBlue + "Gingerbread Chests Received: " + C.cYellow + gingerbreadChestsReceived + " " + C.cBlue + "Minestrike Chests Received: " + C.cYellow + minestrikeChestsReceived); - caller.sendMessage(C.cBlue + "Love Chests Received: " + C.cYellow + loveChestsReceived); - caller.sendMessage(C.cBlue + "St Patrick's Chests Received: " + C.cYellow + stPatricksChestReceived); - caller.sendMessage(C.cBlue + "Spring Chests Received: " + C.cYellow + springChestsReceived); - caller.sendMessage(C.cBlue + "Freedom Chests Received: " + C.cYellow + freedomChestsReceived); - caller.sendMessage(C.cBlue + "Game Amplifiers Received: " + C.cYellow + boostersReceived); - caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min/60 min) Received: " + C.cYellow + runeAmplifier20 + "/" + runeAmplifier60); - caller.sendMessage(C.cBlue + "Clans Dye Boxes Received: " + C.cYellow + clansDyeBoxesReceived + " " + C.cBlue + "Clans Builder Boxes Received: " + C.cYellow + clansBuilderBoxesReceived); - caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Usage") + " " + C.cBlue + "Clan Banner Editor: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Editor")); - YearMonth yearMonth = YearMonth.now(); - caller.sendMessage(C.cBlue + "Power Play Subscription (" + yearMonth.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + ") " + (powerPlayData.isSubscribed() ? C.cGreen + "Active" : C.cRed + "Inactive")); - if (powerPlayData.isSubscribed()) + if (!bonuses) { - caller.sendMessage(C.cBlue + "Power Play Chest/Amplifiers (" + yearMonth.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + ") " + (powerPlayData.getUnclaimedMonths().contains(YearMonth.now()) ? C.cGreen + "Unclaimed" : C.cRed + "Claimed")); - LocalDate nextClaimDate = powerPlayData.getNextClaimDate().get(); // Guaranteed by isSubscribed() - caller.sendMessage(C.cBlue + "Power Play Next Claim Date " + C.cYellow + nextClaimDate.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + " " + nextClaimDate.getDayOfMonth()); - } - caller.sendMessage(C.cBlue + "Monthly Bonus Log (Last 6 entries):"); - - if (_accountBonusLog.containsKey(client.getAccountId())) - { - for (String logEntry : _accountBonusLog.get(client.getAccountId())) + StringBuilder shards = new StringBuilder(C.cBlue + "Enjin Shard Total Received: " + C.cYellow + enjinCoinsReceived); + shards.append(" "); + shards.append(C.cBlue + "Shards: " + C.cYellow + donor.getBalance(GlobalCurrency.TREASURE_SHARD)); + caller.sendMessage(shards.toString()); + // Strutt20 asked me to remove some stuff from the menu + caller.sendMessage(C.cBlue + "Old Chests Received: " + C.cYellow + oldChestsReceived + " " + C.cBlue + "Ancient Chests Received: " + C.cYellow + ancientChestsReceived); + caller.sendMessage(C.cBlue + "Mythical Chests Received: " + C.cYellow + mythicalChestsReceived + " " + C.cBlue + "Illuminated Chests Received: " + C.cYellow + illuminatedChestsReceived); + caller.sendMessage(C.cBlue + "Omega Chests Received: " + C.cYellow + omegaChestsReceived); + caller.sendMessage(C.cBlue + "Haunted Chests Received: " + C.cYellow + hauntedChestsReceived + " " + C.cBlue + "Haunted Chests Opened: " + C.cYellow + hauntedChestsOpened); + caller.sendMessage(C.cBlue + "Trick or Treat Chests Received: " + C.cYellow + trickOrTreatChestsReceived + " " + C.cBlue + "Thankful Chests Received: " + C.cYellow + thankfulChestsReceived); + caller.sendMessage(C.cBlue + "Gingerbread Chests Received: " + C.cYellow + gingerbreadChestsReceived + " " + C.cBlue + "Minestrike Chests Received: " + C.cYellow + minestrikeChestsReceived); + caller.sendMessage(C.cBlue + "Love Chests Received: " + C.cYellow + loveChestsReceived); + caller.sendMessage(C.cBlue + "St Patrick's Chests Received: " + C.cYellow + stPatricksChestReceived); + caller.sendMessage(C.cBlue + "Spring Chests Received: " + C.cYellow + springChestsReceived); + caller.sendMessage(C.cBlue + "Freedom Chests Received: " + C.cYellow + freedomChestsReceived); + caller.sendMessage(C.cBlue + "Game Amplifiers Received: " + C.cYellow + boostersReceived); + caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min/60 min) Received: " + C.cYellow + runeAmplifier20 + "/" + runeAmplifier60); + caller.sendMessage(C.cBlue + "Clans Dye Boxes Received: " + C.cYellow + clansDyeBoxesReceived + " " + C.cBlue + "Clans Builder Boxes Received: " + C.cYellow + clansBuilderBoxesReceived); + caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Usage") + " " + C.cBlue + "Clan Banner Editor: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Editor")); + YearMonth yearMonth = YearMonth.now(); + caller.sendMessage(C.cBlue + "Power Play Subscription (" + yearMonth.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + ") " + (powerPlayData.isSubscribed() ? C.cGreen + "Active" : C.cRed + "Inactive")); + if (powerPlayData.isSubscribed()) { - caller.sendMessage(C.cYellow + logEntry); - } + caller.sendMessage(C.cBlue + "Power Play Chest/Amplifiers (" + yearMonth.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + ") " + (powerPlayData.getUnclaimedMonths().contains(YearMonth.now()) ? C.cGreen + "Unclaimed" : C.cRed + "Claimed")); + LocalDate nextClaimDate = powerPlayData.getNextClaimDate().get(); // Guaranteed by isSubscribed() + caller.sendMessage(C.cBlue + "Power Play Next Claim Date " + C.cYellow + nextClaimDate.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + " " + nextClaimDate.getDayOfMonth()); + } + } + else + { + caller.sendMessage(C.cBlue + "Monthly Bonus Log (Last 6 entries):"); + + if (_accountBonusLog.containsKey(client.getAccountId())) + { + for (String logEntry : _accountBonusLog.get(client.getAccountId())) + { + caller.sendMessage(C.cYellow + logEntry); + } + } } caller.sendMessage(C.cDGreen + C.Strike + "============================================="); - _salesPackageManager.displaySalesPackages(caller, playerName); + if (!bonuses) + { + _salesPackageManager.displaySalesPackages(caller, playerName); + } _accountBonusLog.remove(client.getAccountId()); } }); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java new file mode 100644 index 000000000..2c679185f --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java @@ -0,0 +1,47 @@ +package mineplex.staffServer.customerSupport; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +public class checkBonusCommand extends CommandBase +{ + public checkBonusCommand(CustomerSupport plugin) + { + super(plugin, Rank.MODERATOR, "checkbonus"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args == null || args.length != 1) + { + caller.sendMessage(F.main(Plugin.getName(), "Usage : /checkbonus defek7")); + } + else + { + String playerName = args[0]; + + _commandCenter.GetClientManager().checkPlayerName(caller, playerName, name -> + { + if (name != null) + { + _commandCenter.GetClientManager().loadClientByName(name, client -> + { + if (client != null) + { + Plugin.showPlayerInfo(caller, client, true); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not load data for " + name)); + } + }); + } + }); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java index d4d2542e6..373a7a998 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java @@ -33,7 +33,7 @@ public class checkCommand extends CommandBase { if (client != null) { - Plugin.showPlayerInfo(caller, client); + Plugin.showPlayerInfo(caller, client, false); } else { From 4ccf9e39ad9f6cc4b533772d4d25bf10be951f3e Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 3 Jul 2017 16:58:45 +1000 Subject: [PATCH 059/183] Remove pling sound from /msg for version compat --- .../src/mineplex/mapparser/command/PMCommand.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java index f18483199..1f1509fe2 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java @@ -3,7 +3,6 @@ package mineplex.mapparser.command; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.mapparser.MapParser; -import org.bukkit.Sound; import org.bukkit.entity.Player; /** @@ -44,7 +43,6 @@ public class PMCommand extends BaseCommand continue; } ops.sendMessage(F.main("Message", builder.toString().trim())); - ops.playSound(ops.getLocation(), Sound.BLOCK_NOTE_PLING, 1.0f, 1.0f); } return true; From a8c41f8904f6e8bd0b2a31cd0cd9e32d8ab70da0 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 5 Jul 2017 17:32:34 -0400 Subject: [PATCH 060/183] Lowercase messages with >30 capital letters --- .../src/mineplex/core/chat/Chat.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index 63087f2f9..3949ff3fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -377,7 +377,25 @@ public class Chat extends MiniPlugin } if (!event.isCancelled()) + { + String oldMessage = event.getMessage(); + if (!_clientManager.Get(sender).GetRank().has(Rank.ADMIN)) + { + int capsCount = 0; + for (char c : oldMessage.toCharArray()) + { + if (Character.isUpperCase(c)) + { + capsCount++; + } + } + if (capsCount > 30) + { + event.setMessage(oldMessage.toLowerCase()); + } + } _playerLastMessage.put(sender.getUniqueId(), new MessageData(event.getMessage())); + } for (Function filter : _lowPriorityFilters) { From f92eae067f8e05bdcaba4092b83657448bee7bf0 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 5 Jul 2017 17:32:47 -0400 Subject: [PATCH 061/183] Add player ping and server tps to ban metadata --- .../core/antihack/logging/builtin/PlayerInfoMetadata.java | 3 +++ .../core/antihack/logging/builtin/ServerInfoMetadata.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java index 479db70d2..1af27c8c7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java @@ -3,6 +3,7 @@ package mineplex.core.antihack.logging.builtin; import java.util.UUID; import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import com.google.gson.JsonElement; @@ -18,6 +19,7 @@ public class PlayerInfoMetadata extends AnticheatMetadata private static final String KEY_UUID = "uuid"; private static final String KEY_ACCOUNT_ID = "accountid"; private static final String KEY_NAME = "name"; + private static final String KEY_PING = "ping"; private final CoreClientManager _clientManager = require(CoreClientManager.class); @@ -38,6 +40,7 @@ public class PlayerInfoMetadata extends AnticheatMetadata { object.addProperty(KEY_NAME, bPlayer.getName()); object.addProperty(KEY_ACCOUNT_ID, _clientManager.getAccountId(bPlayer)); + object.addProperty(KEY_PING, Math.min(((CraftPlayer) bPlayer).getHandle().ping, 1000)); } return object; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java index 7376a6d3e..18c64a3c2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java @@ -7,12 +7,14 @@ import com.google.gson.JsonObject; import mineplex.core.antihack.logging.AnticheatMetadata; import mineplex.core.common.util.UtilServer; +import net.minecraft.server.v1_8_R3.MinecraftServer; public class ServerInfoMetadata extends AnticheatMetadata { private static final String KEY_SERVER_NAME = "server-name"; private static final String KEY_SERVER_REGION = "server-region"; private static final String KEY_SERVER_GROUP = "server-group"; + private static final String KEY_SERVER_TPS = ""; @Override public String getId() @@ -27,6 +29,7 @@ public class ServerInfoMetadata extends AnticheatMetadata info.addProperty(KEY_SERVER_NAME, UtilServer.getServerName()); info.addProperty(KEY_SERVER_REGION, UtilServer.getRegion().name()); info.addProperty(KEY_SERVER_GROUP, UtilServer.getGroup()); + info.addProperty(KEY_SERVER_TPS, MinecraftServer.getServer().recentTps[0]); return info; } @@ -35,4 +38,4 @@ public class ServerInfoMetadata extends AnticheatMetadata { } -} +} \ No newline at end of file From b314744b6d07a074e1cbbec64bcb7aa64aa8e7be Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 5 Jul 2017 18:15:05 -0400 Subject: [PATCH 062/183] Fix incorrect event argument in UpdateRank --- .../src/mineplex/core/account/CoreClient.java | 32 +++++++++---------- .../core/account/command/UpdateRank.java | 2 +- .../mineplex/core/command/CommandBase.java | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java index 379dc217d..71c935918 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java @@ -45,7 +45,7 @@ public class CoreClient public UUID getUniqueId() { - return this._uuid; + return _uuid; } public String getName() @@ -134,20 +134,20 @@ public class CoreClient public void undisguise() { - this._disguisedName = null; - this._disguisedSkin = null; - this._disguisedRank = null; - this._disguisedUUID = null; + _disguisedName = null; + _disguisedSkin = null; + _disguisedRank = null; + _disguisedUUID = null; } public String getDisguisedAs() { - return this._disguisedName; + return _disguisedName; } public String getDisguisedSkin() { - return this._disguisedSkin; + return _disguisedSkin; } public Rank getDisguisedRank() @@ -157,32 +157,32 @@ public class CoreClient public UUID getDisguisedAsUUID() { - return this._disguisedUUID; + return _disguisedUUID; } public boolean isDisguised() { - if (this._disguisedName == null) + if (_disguisedName == null) { return false; } - return !this._name.equalsIgnoreCase(this._disguisedName); + return !_name.equalsIgnoreCase(_disguisedName); } public void disguise(String name, UUID uuid, Rank rank) { - this._disguisedName = name; - this._disguisedUUID = uuid; - this._disguisedRank = rank; + _disguisedName = name; + _disguisedUUID = uuid; + _disguisedRank = rank; } public Rank getRealOrDisguisedRank() { - if (this._disguisedRank != null) + if (_disguisedRank != null) { - return this._disguisedRank; + return _disguisedRank; } - return this.GetRank(); + return GetRank(); } public void setNetworkSessionLoginTime(long loginTime) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java index ba8c69ffa..da9f6343f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java @@ -92,7 +92,7 @@ public class UpdateRank extends CommandBase if (Plugin.Get(p).GetRank() != Plugin.Get(p).GetRank(true)) Plugin.Get(p).resetTemp(); - OnlineRankUpdateEvent event = new OnlineRankUpdateEvent(caller, Plugin.Get(caller).GetRank(), rank, true); + OnlineRankUpdateEvent event = new OnlineRankUpdateEvent(caller, Plugin.Get(caller).GetRank(), rank, false); Plugin.Get(p).SetRank(rank, false); Bukkit.getPluginManager().callEvent(event); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java index 02709a26f..264fe539f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java @@ -63,7 +63,7 @@ public abstract class CommandBase implements ICom public void setRequiredRank(Rank rank) { - this._requiredRank = rank; + _requiredRank = rank; } public Rank[] GetSpecificRanks() From 8e0bb180764c378890299d2e05558fdb15f6c1fc Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 6 Jul 2017 22:55:34 +0200 Subject: [PATCH 063/183] Fixes of current and new missions --- .../core/quests/command/GetQuestCommand.java | 16 ++++++---- .../src/nautilus/game/arcade/game/Game.java | 13 +++++++- .../game/games/dragonescape/DragonEscape.java | 6 ++++ .../quests/DragonEscapeWinQuestTracker.java | 30 +++++++++++++++++++ .../arcade/quest/CollectQuestTracker.java | 26 ++++++++-------- .../game/arcade/quest/HitQuestTracker.java | 26 ++++++++-------- 6 files changed, 84 insertions(+), 33 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/quests/DragonEscapeWinQuestTracker.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java index 867779ee7..414ac6b48 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java @@ -55,6 +55,10 @@ public class GetQuestCommand extends CommandBase } } } + else + { + players.add(caller); + } Quest quest = Plugin.getQuestByID(Integer.parseInt(args[0])); @@ -64,16 +68,16 @@ public class GetQuestCommand extends CommandBase UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Added " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName())); - if (args[1].equalsIgnoreCase("all")) - { - UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + "everyone")); - } - else + if (!args[1].equalsIgnoreCase("all")) { if (caller != players.get(0)) UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + player.getName())); - } } + + if (args[1].equalsIgnoreCase("all")) + { + UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + "everyone")); + } } } 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 39596d508..7f980d389 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 @@ -3,6 +3,7 @@ package nautilus.game.arcade.game; import com.google.common.collect.Lists; import com.mojang.authlib.GameProfile; import mineplex.core.Managers; +import mineplex.core.MiniPlugin; import mineplex.core.antihack.AntiHack; import mineplex.core.arcadeevents.CoreGameStartEvent; import mineplex.core.arcadeevents.CoreGameStopEvent; @@ -1778,6 +1779,16 @@ public abstract class Game extends ListenerComponent implements Lifetimed { return _questTrackers; } + + public > T getQuestTracker(Class clazz) + { + for (QuestTracker tracker : _questTrackers) + { + if (tracker.getClass().equals(clazz)) + return clazz.cast(tracker); + } + return null; + } @EventHandler public void onHangingBreak(HangingBreakEvent event) @@ -2057,7 +2068,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public void onQuestBuy(QuestInteractEvent event) { if (GetState() == GameState.Live || GetState() == GameState.Prepare || GetState() == GameState.End) - event.setCancelled("You cant interact with " + QuestManager.QUEST_NAME + "s while you are ingame!"); + event.setCancelled("You can't interact with " + QuestManager.QUEST_NAME + "s while you are ingame!"); } public NautHashMap getDeadBodies() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index 38abce9fb..8a9272463 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -62,6 +62,7 @@ import nautilus.game.arcade.game.games.dragonescape.kits.KitDigger; import nautilus.game.arcade.game.games.dragonescape.kits.KitDisruptor; import nautilus.game.arcade.game.games.dragonescape.kits.KitLeaper; import nautilus.game.arcade.game.games.dragonescape.kits.KitWarper; +import nautilus.game.arcade.game.games.dragonescape.quests.DragonEscapeWinQuestTracker; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -144,6 +145,8 @@ public class DragonEscape extends SoloGame BlankLine, new ChatStatData("kit", "Kit", true) ); + + registerQuestTrackers(new DragonEscapeWinQuestTracker(this)); new CompassModule() .setGiveCompass(true) @@ -487,7 +490,10 @@ public class DragonEscape extends SoloGame AddGems(_winner, 10, "Course Complete", false, false); if (places.size() >= 1) + { AddGems(places.get(0), 20, "1st Place", false, false); + getQuestTracker(DragonEscapeWinQuestTracker.class).increment(places.get(0)); + } if (places.size() >= 2) AddGems(places.get(1), 15, "2nd Place", false, false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/quests/DragonEscapeWinQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/quests/DragonEscapeWinQuestTracker.java new file mode 100644 index 000000000..b47de5575 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/quests/DragonEscapeWinQuestTracker.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.dragonescape.quests; + +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.Arcade; +import nautilus.game.arcade.game.games.dragonescape.DragonEscape; +import nautilus.game.arcade.quest.QuestTracker; + +/** + * DragonEscapeWinQuestTracker + * + * @author xXVevzZXx + */ +public class DragonEscapeWinQuestTracker extends QuestTracker +{ + + public DragonEscapeWinQuestTracker(DragonEscape game) + { + super(game, TriggerType.COMPLETE); + } + + public void increment(Player player) + { + incrementQuests(player, 1, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), getGame().GetKit(player).GetName() + "Kit", "Parkour"); + } + +} 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 83367508e..9bcc6165e 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 @@ -1,5 +1,6 @@ package nautilus.game.arcade.quest; +import java.awt.dnd.DragSourceDropEvent; import java.util.ArrayList; import org.bukkit.ChatColor; @@ -15,6 +16,7 @@ import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; @@ -33,6 +35,7 @@ import nautilus.game.arcade.game.Game; public class CollectQuestTracker extends QuestTracker { private ArrayList _itemsAvailable = new ArrayList<>(); + private ArrayList _badItems = new ArrayList<>(); private ArrayList _usedChests = new ArrayList<>(); private ArrayList _usedBlocks = new ArrayList<>(); @@ -67,6 +70,12 @@ public class CollectQuestTracker extends QuestTracker } + @EventHandler(priority=EventPriority.HIGHEST) + public void itemRegister(PlayerDropItemEvent event) + { + _badItems.add(event.getItemDrop().getItemStack()); + } + @EventHandler(priority=EventPriority.HIGHEST) public void itemRegister(BlockBreakEvent event) { @@ -76,12 +85,12 @@ public class CollectQuestTracker extends QuestTracker if (event.isCancelled()) return; - if (_usedBlocks.contains(event.getBlock().getLocation())) + if (!_usedBlocks.contains(event.getBlock().getLocation())) return; for (ItemStack item : event.getBlock().getDrops()) { - _itemsAvailable.add(item); + _badItems.add(item); } } @@ -95,19 +104,12 @@ public class CollectQuestTracker extends QuestTracker return; ItemStack item = event.getItem().getItemStack(); - ItemStack fromList = null; - for (ItemStack available : _itemsAvailable) + if (_badItems.contains(item)) { - if (available.getType() == item.getType()) - fromList = available; - } - - if (fromList == null) + _badItems.remove(item); return; - - _itemsAvailable.remove(fromList); - + } String itemName = item.getType().toString(); if (item.hasItemMeta()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java index 107048e14..71070aaf1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java @@ -9,6 +9,7 @@ import org.bukkit.event.entity.ProjectileHitEvent; import mineplex.core.common.util.UtilItem; import mineplex.core.quests.TriggerType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.Game; @@ -34,30 +35,27 @@ public class HitQuestTracker extends QuestTracker if (!(event.getEntity() instanceof Player)) return; - incrementQuests((Player) event.getDamager(), 1, "Player", getGame().GetKit((Player) event.getDamager()).GetName() + "Kit"); + + Item itemEntity = (Item) event.getEntity(); + String item = itemEntity.getItemStack().getType().toString(); + + incrementQuests((Player) event.getDamager(), 1, "Player", item, getGame().GetKit((Player) event.getDamager()).GetName() + "Kit"); } @EventHandler - public void onProjectileHit(ProjectileHitEvent event) + public void onProjectileHit(CustomDamageEvent event) { if (!getGame().IsLive()) return; - if (!(event.getEntity().getShooter() instanceof Player)) + if (event.GetReason() == null) return; - Item itemEntity = (Item) event.getEntity(); - String item = itemEntity.getItemStack().getType().toString(); + if (!event.GetReason().contains("Axe Thrower")) + return; - if (UtilItem.isAxe(itemEntity.getItemStack().getType())) - { - item = "Axe"; - } + System.out.println("Test2"); - Entity ent = event.getEntity().getLastDamageCause().getEntity(); - if (ent instanceof Player) - { - incrementQuests((Player) event.getEntity().getShooter(), 1, "Player", item, getGame().GetKit((Player) event.getEntity().getShooter()).GetName() + "Kit"); - } + incrementQuests(event.GetDamagerPlayer(true), 1, "Player", "Axe", getGame().GetKit(event.GetDamagerPlayer(true)).GetName() + "Kit"); } } From 994517b3a456dcecb58c56699071935a1581c230 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 7 Jul 2017 02:22:05 +0100 Subject: [PATCH 064/183] Finish up training mode --- .../core/packethandler/CustomFrames.java | 149 ++++++++++++++++++ .../src/nautilus/game/arcade/Arcade.java | 3 + .../game/games/moba/boss/BossManager.java | 10 +- .../games/moba/kit/bardolf/HeroBardolf.java | 2 +- .../game/games/moba/minion/MinionManager.java | 2 +- .../games/moba/training/MobaTraining.java | 65 +++++--- .../game/arcade/managers/GameHostManager.java | 1 + 7 files changed, 209 insertions(+), 23 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/packethandler/CustomFrames.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/CustomFrames.java b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/CustomFrames.java new file mode 100644 index 000000000..e99755e90 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/CustomFrames.java @@ -0,0 +1,149 @@ +package mineplex.core.packethandler; + +import com.google.common.base.Optional; +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.common.util.UtilServer; +import net.minecraft.server.v1_8_R3.DataWatcher; +import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; +import net.minecraft.server.v1_8_R3.EntityItemFrame; +import net.minecraft.server.v1_8_R3.ItemStack; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItemFrame; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.hanging.HangingPlaceEvent; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.UUID; + +@ReflectivelyCreateMiniPlugin +public class CustomFrames extends MiniPlugin implements IPacketHandler +{ + private final List ourPackets = new ArrayList<>(); + private final Map> frameData = new HashMap<>(); + + private CustomFrames() + { + super("CustomFrames"); + } + + @Override + public void enable() + { + require(PacketHandler.class).addPacketHandler(this, PacketPlayOutEntityMetadata.class); + } + + @Override + public void disable() + { + require(PacketHandler.class).removePacketHandler(this); + } + + //@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onEntitySpawn(HangingPlaceEvent event) + { + Bukkit.broadcastMessage(event.getEventName()); + + if (event.getEntity() instanceof ItemFrame) + { + Bukkit.broadcastMessage("ItemFrame"); + final ItemFrame frame = (ItemFrame) event.getEntity(); + final Random rand = new Random(); + + new BukkitRunnable() + { + @Override + public void run() + { + Bukkit.broadcastMessage("Setting"); + + for (Player player : UtilServer.getPlayersCollection()) + { + Material mat = Material.values()[rand.nextInt(Material.values().length)]; + setItem(player, frame, new org.bukkit.inventory.ItemStack(mat, 1)); + } + } + }.runTaskTimer(getPlugin(), 100, 100); + } + } + + @Override + public void handle(PacketInfo packetInfo) + { + if (packetInfo.getPacket() instanceof PacketPlayOutEntityMetadata) + { + if (ourPackets.contains(packetInfo.getPacket())) + { + ourPackets.remove(packetInfo.getPacket()); + return; + } + + PacketPlayOutEntityMetadata packet = (PacketPlayOutEntityMetadata) packetInfo.getPacket(); + Map map = frameData.get(packet.a); + if (map != null) + { + UUID uuid = packetInfo.getPlayer().getUniqueId(); + ItemStack item = map.get(uuid); + if (item != null) + { + for (WatchableObject meta : packet.b) + { + if (meta.getIndex().a() == 8) + { + meta.a(item, Optional.fromNullable(item)); + break; + } + } + } + } + } + } + + public void setItem(Player player, ItemFrame frame, org.bukkit.inventory.ItemStack item) + { + Bukkit.broadcastMessage(item.getType().toString()); + ItemStack nmsItem = CraftItemStack.asNMSCopy(item.clone()); + EntityItemFrame nmsEntity = ((CraftItemFrame) frame).getHandle(); + + DataWatcher watcher = new DataWatcher(nmsEntity); + + watcher.add(8, 5, EntityItemFrame.META_ITEM, Optional.fromNullable(nmsItem)); + + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(frame.getEntityId(), watcher, true); + ourPackets.add(packet); + + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + + frameData.computeIfAbsent(frame.getEntityId(), HashMap::new).put(player.getUniqueId(), nmsItem); + } + + public void removeItems(ItemFrame frame) + { + frameData.remove(frame.getEntityId()); + + ItemStack nmsItem = null; + EntityItemFrame nmsEntity = ((CraftItemFrame) frame).getHandle(); + + DataWatcher watcher = new DataWatcher(nmsEntity); + watcher.add(8, 5, EntityItemFrame.META_ITEM, Optional.fromNullable(nmsItem)); + + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(frame.getEntityId(), watcher, true); + + MinecraftServer.getServer().getPlayerList().players.forEach(player -> player.playerConnection.sendPacket(packet)); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 5f75dde80..5306f213b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -3,6 +3,7 @@ package nautilus.game.arcade; import java.io.File; import java.util.HashMap; +import mineplex.core.packethandler.CustomFrames; import net.minecraft.server.v1_8_R3.MinecraftServer; import org.bukkit.Bukkit; @@ -229,6 +230,8 @@ public class Arcade extends JavaPlugin AprilFoolsManager.getInstance(); + require(CustomFrames.class); + //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java index 7b45daa6b..11f37cceb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -102,8 +102,14 @@ public class BossManager implements Listener { List bosses = new ArrayList<>(); - bosses.addAll(_teamBosses.values()); - bosses.add(_pumpkinBoss); + if (_teamBosses != null) + { + bosses.addAll(_teamBosses.values()); + } + if (_pumpkinBoss != null) + { + bosses.add(_pumpkinBoss); + } return bosses; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java index 7ac660d7f..8deda46ad 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java @@ -151,7 +151,7 @@ public class HeroBardolf extends HeroKit } GameTeam team = Manager.GetGame().GetTeam((Player) damager); - if (team != null && MobaUtil.isTeamEntity(damagee, team)) + if (team != null && !Manager.GetGame().DamageTeamSelf && MobaUtil.isTeamEntity(damagee, team)) { event.SetCancelled("Team Wolf"); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index efdb7356b..e5fe816f0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -66,7 +66,7 @@ public class MinionManager implements Listener @EventHandler public void spawnMinions(UpdateEvent event) { - if (event.getType() != UpdateType.SEC || !_enabled || !_host.IsLive() || !UtilTime.elapsed(_lastWave, MINION_SPAWN_TIME)) + if (event.getType() != UpdateType.SEC || !_enabled || !_host.IsLive() || !UtilTime.elapsed(_lastWave, MINION_SPAWN_TIME) || _waves.size() > 6) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index aa21262a6..d7a406b92 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -27,12 +27,14 @@ import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.entity.Villager; import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; @@ -108,8 +110,7 @@ public class MobaTraining extends Moba private Location _borderA; private Location _borderB; - private Location _selectKit; - private LivingEntity _selectKitEntity; + private List _selectKit; private final Map _entities = new HashMap<>(); @@ -129,8 +130,6 @@ public class MobaTraining extends Moba // Prevent the wither from being damaged as well as to not spawn the pumpkin king _boss.setDummyBosses(true); _overtimeManager.disableOvertime(); - - // Disable minions _minion.disableMinions(); Function safeFunction = player -> UtilAlg.inBoundingBox(player.getLocation(), _borderA, _borderB); @@ -243,13 +242,13 @@ public class MobaTraining extends Moba { super.ParseData(); - List locations = WorldData.GetDataLocs("BROWN"); + List locations = WorldData.GetCustomLocs("PVP_AREA"); _borderA = locations.get(0); _borderB = locations.get(1); - _selectKit = WorldData.GetCustomLocs("SELECT_KIT").get(0); - SpectatorSpawn = _selectKit; + _selectKit = WorldData.GetCustomLocs("SELECT_KIT"); + SpectatorSpawn = _selectKit.get(0); } @EventHandler @@ -262,12 +261,12 @@ public class MobaTraining extends Moba for (Location location : GetTeam(ChatColor.YELLOW).GetSpawns()) { - location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _selectKit))); + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, SpectatorSpawn))); } for (Location location : GetTeam(ChatColor.GRAY).GetSpawns()) { - location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _selectKit))); + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, SpectatorSpawn))); } Location center = WorldData.GetCustomLocs("CENTER").get(0); @@ -318,6 +317,15 @@ public class MobaTraining extends Moba } } + @Override + public void SetKit(Player player, Kit kit, boolean announce) + { + super.SetKit(player, kit, announce); + + player.setFlying(false); + player.setAllowFlight(false); + } + @EventHandler public void giveGold(UpdateEvent event) { @@ -336,7 +344,7 @@ public class MobaTraining extends Moba } @EventHandler - public void plaeyrJoin(PlayerJoinEvent event) + public void playerJoin(PlayerJoinEvent event) { if (InProgress()) { @@ -361,6 +369,7 @@ public class MobaTraining extends Moba for (LivingEntity entity : _entities.keySet()) { entity.setCustomNameVisible(true); + entity.setRemoveWhenFarAway(false); UtilEnt.vegetate(entity); UtilEnt.setFakeHead(entity, true); UtilEnt.silence(entity, true); @@ -380,16 +389,29 @@ public class MobaTraining extends Moba event.SetCancelled("NPC"); - if (_selectKitEntity != null && _selectKitEntity.equals(event.GetDamageeEntity())) + String name = event.GetDamageeEntity().getCustomName(); + + if (name != null && name.contains("")) { openMenu(event.GetDamagerPlayer(false)); } } + @EventHandler + public void entityCombust(EntityCombustEvent event) + { + if (!_entities.containsKey(event.getEntity())) + { + return; + } + + event.setCancelled(true); + } + @EventHandler public void entityInteract(PlayerInteractAtEntityEvent event) { - if (_selectKitEntity != null && event.getRightClicked().equals(_selectKitEntity)) + if (isKitSelectionEntity(event.getRightClicked())) { openMenu(event.getPlayer()); } @@ -422,6 +444,11 @@ public class MobaTraining extends Moba new SelectKitMenu(Manager).open(player); } + private boolean isKitSelectionEntity(Entity entity) + { + return entity.getCustomName() != null && entity.getCustomName().contains("Select A Hero"); + } + private void spawnHelpText() { Map locationMap = getLocationStartsWith("HELP"); @@ -442,7 +469,6 @@ public class MobaTraining extends Moba { Skeleton skeleton = UtilVariant.spawnWitherSkeleton(WorldData.GetCustomLocs("PUMPKIN_KING").get(0)); skeleton.setCustomName(C.cDRedB + "Pumpkin King"); - UtilEnt.CreatureLook(skeleton, 90); _entities.put(skeleton, skeleton.getLocation()); } @@ -450,7 +476,6 @@ public class MobaTraining extends Moba Location location = WorldData.GetCustomLocs("DUMMY_WITHER").get(0); ArmorStand stand = location.getWorld().spawn(location, ArmorStand.class); - // Reducing the wither's health to 10% gives a shield like effect. stand.setGravity(false); DisguiseWither disguise = new DisguiseWither(stand); @@ -472,12 +497,14 @@ public class MobaTraining extends Moba private void spawnNPCs() { - Villager villager = WorldData.World.spawn(_selectKit, Villager.class); - villager.setCustomName(C.cYellowB + "Select A Hero"); - UtilEnt.CreatureLook(villager, GetTeam(ChatColor.YELLOW).GetSpawns().get(0)); + for (Location location : _selectKit) + { + Villager villager = WorldData.World.spawn(location, Villager.class); + villager.setCustomName(C.cYellowB + "Select A Hero"); + UtilEnt.CreatureLook(villager, GetTeam(ChatColor.YELLOW).GetSpawns().get(0)); - _entities.put(villager, villager.getLocation()); - _selectKitEntity = villager; + _entities.put(villager, villager.getLocation()); + } } public void teleportIntoArena(Player player, HeroKit kit) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index f046626b4..d22502170 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -123,6 +123,7 @@ public class GameHostManager implements Listener legendGames.add(GameType.Skywars); legendGames.add(GameType.SpeedBuilders); legendGames.add(GameType.TypeWars); + legendGames.add(GameType.MOBA); // Team variants - Currently being remade. /* legendGames.add(GameType.DragonEscapeTeams); From ce6ee670ed40a116256a103740ce453ae1591339 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 7 Jul 2017 06:44:19 -0400 Subject: [PATCH 065/183] Use a try-with-resources for gem hunters redis calls --- .../death/quitnpc/QuitNPCRepository.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java index c01b2d91e..379093f82 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java @@ -6,6 +6,7 @@ import java.util.concurrent.CompletableFuture; import mineplex.core.common.util.UtilServer; import mineplex.serverdata.Region; import mineplex.serverdata.redis.RedisRepository; +import redis.clients.jedis.Jedis; public class QuitNPCRepository extends RedisRepository { @@ -18,16 +19,34 @@ public class QuitNPCRepository extends RedisRepository public CompletableFuture loadNpcServer(UUID uuid) { - return CompletableFuture.supplyAsync(() -> getResource(false).get(getKey(REDIS_KEY_PREFIX + uuid.toString()))); + return CompletableFuture.supplyAsync(() -> + { + try (Jedis jedis = getResource(false)) + { + return getResource(false).get(getKey(REDIS_KEY_PREFIX + uuid.toString())); + } + }); } public void deleteNpc(UUID uuid) { - UtilServer.runAsync(() -> getResource(true).del(getKey(REDIS_KEY_PREFIX + uuid.toString()))); + UtilServer.runAsync(() -> + { + try (Jedis jedis = getResource(true)) + { + jedis.del(getKey(REDIS_KEY_PREFIX + uuid.toString())); + } + }); } public void insertNpc(UUID uuid, String serverName) { - UtilServer.runAsync(() -> getResource(true).setex(REDIS_KEY_PREFIX + uuid.toString(), 60, serverName)); + UtilServer.runAsync(() -> + { + try (Jedis jedis = getResource(true)) + { + jedis.setex(REDIS_KEY_PREFIX + uuid.toString(), 60, serverName); + } + }); } } \ No newline at end of file From f73c78809ab7864034c47889bdebb24c4ad5a1d8 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 7 Jul 2017 06:47:15 -0400 Subject: [PATCH 066/183] Whoops, forgot to change a line --- .../mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java index 379093f82..ce0dc8a9d 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java @@ -23,7 +23,7 @@ public class QuitNPCRepository extends RedisRepository { try (Jedis jedis = getResource(false)) { - return getResource(false).get(getKey(REDIS_KEY_PREFIX + uuid.toString())); + return jedis.get(getKey(REDIS_KEY_PREFIX + uuid.toString())); } }); } From dd128244023ebe428817657c4295413100266009 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 7 Jul 2017 07:13:31 -0400 Subject: [PATCH 067/183] Fix NPE in LootModule --- .../src/mineplex/gemhunters/loot/LootModule.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java index 9aa42e3ac..07e0afb7c 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java @@ -672,6 +672,10 @@ public class LootModule extends MiniPlugin { for (LootItemReward reward : _itemRewards) { + if (reward.getPlayer() == null) + { + continue; + } if (reward.getPlayer().equals(event.getEntity())) { reward.death(event); From 84752f0b17f4dac676044dfacd86d1e24fb372fd Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 8 Jul 2017 01:34:19 +0100 Subject: [PATCH 068/183] Item maps --- .../CustomItemFrames.java} | 74 ++---- .../core/imagemap/ImageMapManager.java | 155 +++++++++++ .../core/imagemap/ImageMapRenderer.java | 41 +++ .../src/mineplex/core/imagemap/MapImage.java | 55 ++++ .../core/imagemap/PlayerMapBoard.java | 14 + .../core/imagemap/PlayerMapImage.java | 59 +++++ .../mineplex/core/map/ImageMapRenderer.java | 4 +- .../core/sponsorbranding/BrandingManager.java | 133 ---------- .../core/sponsorbranding/BrandingPost.java | 242 ------------------ .../core/sponsorbranding/LogoMapRenderer.java | 51 ---- .../src/nautilus/game/arcade/Arcade.java | 4 +- .../src/mineplex/gemhunters/GemHunters.java | 16 +- .../mineplex/gemhunters/bounties/Bounty.java | 36 --- .../gemhunters/bounties/BountyModule.java | 46 ---- 14 files changed, 355 insertions(+), 575 deletions(-) rename Plugins/Mineplex.Core/src/mineplex/core/{packethandler/CustomFrames.java => imagemap/CustomItemFrames.java} (58%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapRenderer.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/imagemap/MapImage.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapBoard.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapImage.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/BrandingManager.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/BrandingPost.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/LogoMapRenderer.java delete mode 100644 Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/bounties/Bounty.java delete mode 100644 Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/bounties/BountyModule.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/CustomFrames.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java similarity index 58% rename from Plugins/Mineplex.Core/src/mineplex/core/packethandler/CustomFrames.java rename to Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java index e99755e90..440bb1e15 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/CustomFrames.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java @@ -1,9 +1,12 @@ -package mineplex.core.packethandler; +package mineplex.core.imagemap; import com.google.common.base.Optional; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; -import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.packethandler.PacketInfo; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; import net.minecraft.server.v1_8_R3.EntityItemFrame; @@ -11,35 +14,30 @@ import net.minecraft.server.v1_8_R3.ItemStack; import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; -import org.bukkit.Bukkit; -import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItemFrame; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntitySpawnEvent; -import org.bukkit.event.hanging.HangingPlaceEvent; -import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Random; import java.util.UUID; @ReflectivelyCreateMiniPlugin -public class CustomFrames extends MiniPlugin implements IPacketHandler +public class CustomItemFrames extends MiniPlugin implements IPacketHandler { - private final List ourPackets = new ArrayList<>(); - private final Map> frameData = new HashMap<>(); - private CustomFrames() + private final List _ourPackets; + private final Map> _frameData; + + private CustomItemFrames() { - super("CustomFrames"); + super("CustomItemFrames"); + + _ourPackets = new ArrayList<>(); + _frameData = new HashMap<>(); } @Override @@ -54,47 +52,19 @@ public class CustomFrames extends MiniPlugin implements IPacketHandler require(PacketHandler.class).removePacketHandler(this); } - //@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onEntitySpawn(HangingPlaceEvent event) - { - Bukkit.broadcastMessage(event.getEventName()); - - if (event.getEntity() instanceof ItemFrame) - { - Bukkit.broadcastMessage("ItemFrame"); - final ItemFrame frame = (ItemFrame) event.getEntity(); - final Random rand = new Random(); - - new BukkitRunnable() - { - @Override - public void run() - { - Bukkit.broadcastMessage("Setting"); - - for (Player player : UtilServer.getPlayersCollection()) - { - Material mat = Material.values()[rand.nextInt(Material.values().length)]; - setItem(player, frame, new org.bukkit.inventory.ItemStack(mat, 1)); - } - } - }.runTaskTimer(getPlugin(), 100, 100); - } - } - @Override public void handle(PacketInfo packetInfo) { if (packetInfo.getPacket() instanceof PacketPlayOutEntityMetadata) { - if (ourPackets.contains(packetInfo.getPacket())) + if (_ourPackets.contains(packetInfo.getPacket())) { - ourPackets.remove(packetInfo.getPacket()); + _ourPackets.remove(packetInfo.getPacket()); return; } PacketPlayOutEntityMetadata packet = (PacketPlayOutEntityMetadata) packetInfo.getPacket(); - Map map = frameData.get(packet.a); + Map map = _frameData.get(packet.a); if (map != null) { UUID uuid = packetInfo.getPlayer().getUniqueId(); @@ -116,25 +86,23 @@ public class CustomFrames extends MiniPlugin implements IPacketHandler public void setItem(Player player, ItemFrame frame, org.bukkit.inventory.ItemStack item) { - Bukkit.broadcastMessage(item.getType().toString()); ItemStack nmsItem = CraftItemStack.asNMSCopy(item.clone()); EntityItemFrame nmsEntity = ((CraftItemFrame) frame).getHandle(); DataWatcher watcher = new DataWatcher(nmsEntity); - watcher.add(8, 5, EntityItemFrame.META_ITEM, Optional.fromNullable(nmsItem)); PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(frame.getEntityId(), watcher, true); - ourPackets.add(packet); + _ourPackets.add(packet); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + UtilPlayer.sendPacket(player, packet); - frameData.computeIfAbsent(frame.getEntityId(), HashMap::new).put(player.getUniqueId(), nmsItem); + _frameData.computeIfAbsent(frame.getEntityId(), HashMap::new).put(player.getUniqueId(), nmsItem); } public void removeItems(ItemFrame frame) { - frameData.remove(frame.getEntityId()); + _frameData.remove(frame.getEntityId()); ItemStack nmsItem = null; EntityItemFrame nmsEntity = ((CraftItemFrame) frame).getHandle(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java new file mode 100644 index 000000000..06197b412 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java @@ -0,0 +1,155 @@ +package mineplex.core.imagemap; + +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.common.util.UtilBlock; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.ItemFrame; +import org.bukkit.inventory.ItemStack; +import org.bukkit.map.MapView; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@ReflectivelyCreateMiniPlugin +public class ImageMapManager extends MiniPlugin +{ + + private static final String IMAGE_FILE = ".." + File.separator + ".." + File.separator + "update" + File.separator + "files"; + private static final int PIXELS_PER_MAP = 128; + + public static int getPixelsPerMap() + { + return PIXELS_PER_MAP; + } + + private final CustomItemFrames _itemFrames; + + private final Map _imageCache; + + private ImageMapManager() + { + super("Image Map"); + + _itemFrames = require(CustomItemFrames.class); + + _imageCache = new HashMap<>(); + } + + public void createPlayerBoard(Location topLeft, BlockFace direction, int width, int height) + { + List itemFrames = createItemFrames(topLeft, BlockFace.EAST, 7, 4); + + PlayerMapImage image1 = new PlayerMapImage(_itemFrames, getImage(new File("Bardolf.png")), itemFrames, 7, 4); + PlayerMapImage image2 = new PlayerMapImage(_itemFrames, getImage(new File("Biff.png")), itemFrames, 7, 4); + + runSyncTimer(() -> + { + + image. + + }, 100, 100); + } + + private List createItemFrames(Location topLeft, BlockFace direction, int width, int height) + { + List itemFrames = new ArrayList<>(); + + for (int x = 0; x < width; x++) + { + for (int y = 0; y < height; y++) + { + Location location = modLocation(topLeft, direction, x, y); + + Block opposite = location.getBlock().getRelative(direction.getOppositeFace()); + + if (!UtilBlock.solid(opposite)) + { + opposite.setType(Material.SMOOTH_BRICK); + } + + ItemFrame itemFrame = location.getWorld().spawn(location, ItemFrame.class); + itemFrame.setFacingDirection(direction, true); + itemFrames.add(itemFrame); + } + } + + return itemFrames; + } + + private Location modLocation(Location location, BlockFace direction, int x, int y) + { + int modX = 0; + int modZ = 0; + + switch (direction) + { + case NORTH: + modX = -x; + break; + case SOUTH: + modX = x; + break; + case WEST: + modZ = x; + break; + case EAST: + modZ = -x; + break; + } + + return new Location(location.getWorld(), location.getBlockX() + modX, location.getBlockY() - y, location.getBlockZ() + modZ); + } + + private BufferedImage getImage(File file) + { + if (_imageCache.containsKey(file.getName())) + { + return _imageCache.get(file.getName()); + } + + try + { + BufferedImage image = ImageIO.read(file); + _imageCache.put(file.getName(), image); + return image; + } + catch (IOException e) + { + e.printStackTrace(); + return null; + } + } + + private BufferedImage getImage(URL url) + { + if (_imageCache.containsKey(url.toString())) + { + return _imageCache.get(url.toString()); + } + + try + { + BufferedImage image = ImageIO.read(url); + _imageCache.put(url.toString(), image); + return image; + } + catch (IOException e) + { + e.printStackTrace(); + return null; + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapRenderer.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapRenderer.java new file mode 100644 index 000000000..15566f92a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapRenderer.java @@ -0,0 +1,41 @@ +package mineplex.core.imagemap; + +import org.bukkit.entity.Player; +import org.bukkit.map.MapCanvas; +import org.bukkit.map.MapRenderer; +import org.bukkit.map.MapView; + +import java.awt.*; +import java.awt.image.BufferedImage; + +public class ImageMapRenderer extends MapRenderer +{ + + private Image _image; + private boolean _rendered; + + public ImageMapRenderer(BufferedImage image, int x1, int y1) + { + int startX = Math.min(x1 * ImageMapManager.getPixelsPerMap(), image.getWidth()); + startX = Math.max(image.getMinX(), startX); + int startY = Math.min(y1 * ImageMapManager.getPixelsPerMap(), image.getHeight()); + startY = Math.max(image.getMinY(), startY); + + if (startX + ImageMapManager.getPixelsPerMap() > image.getWidth() || startY + ImageMapManager.getPixelsPerMap() > image.getHeight()) + { + return; + } + + _image = image.getSubimage(startX, startY, ImageMapManager.getPixelsPerMap(), ImageMapManager.getPixelsPerMap()); + } + + @Override + public void render(MapView view, MapCanvas canvas, Player player) + { + if (_image != null && !_rendered) + { + canvas.drawImage(0, 0, _image); + _rendered = true; + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/MapImage.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/MapImage.java new file mode 100644 index 000000000..097953cfd --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/MapImage.java @@ -0,0 +1,55 @@ +package mineplex.core.imagemap; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.entity.ItemFrame; +import org.bukkit.inventory.ItemStack; +import org.bukkit.map.MapView; + +import java.awt.image.BufferedImage; +import java.util.List; + +public class MapImage +{ + + protected final BufferedImage _image; + protected final List _itemFrames; + protected final int _width, _height; + + public MapImage(BufferedImage image, List itemFrames, int width, int height) + { + _image = image; + _itemFrames = itemFrames; + _width = width; + _height = height; + } + + public void create() + { + int i = 0; + + for (int x = 0; x < _width; x++) + { + for (int y = 0; y < _height; y++) + { + ItemFrame frame = _itemFrames.get(i++); + + frame.setItem(getMapItem(frame.getWorld(), x, y)); + } + } + } + + protected ItemStack getMapItem(World world, int x, int y) + { + ItemStack item = new ItemStack(Material.MAP); + + MapView map = Bukkit.getServer().createMap(world); + map.getRenderers().forEach(map::removeRenderer); + + map.addRenderer(new ImageMapRenderer(_image, x, y)); + item.setDurability(map.getId()); + + return item; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapBoard.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapBoard.java new file mode 100644 index 000000000..94d42c227 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapBoard.java @@ -0,0 +1,14 @@ +package mineplex.core.imagemap; + +import org.bukkit.Location; + +public class PlayerMapBoard +{ + + private final Location _location; + + public PlayerMapBoard(Location location) + { + _location = location; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapImage.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapImage.java new file mode 100644 index 000000000..1bfa3aad2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapImage.java @@ -0,0 +1,59 @@ +package mineplex.core.imagemap; + +import org.bukkit.World; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.List; + +public class PlayerMapImage extends MapImage +{ + + private final CustomItemFrames _itemFramesManager; + private final List _itemMaps; + private final List _viewers; + + public PlayerMapImage(CustomItemFrames itemFramesManager, BufferedImage image, List itemFrames, int width, int height) + { + super(image, itemFrames, width, height); + + _itemFramesManager = itemFramesManager; + _itemMaps = new ArrayList<>(); + _viewers = new ArrayList<>(); + } + + @Override + public void create() + { + World world = _itemFrames.get(0).getWorld(); + + for (int x = 0; x < _width; x++) + { + for (int y = 0; y < _height; y++) + { + _itemMaps.add(getMapItem(world, x, y)); + } + } + } + + public void addViewer(Player player) + { + _viewers.add(player); + + for (int i = 0; i < _itemMaps.size(); i++) + { + ItemFrame itemFrame = _itemFrames.get(i); + ItemStack itemStack = _itemMaps.get(i); + + _itemFramesManager.setItem(player, itemFrame, itemStack); + } + } + + public void removeViewer(Player player) + { + _viewers.remove(player); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java b/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java index 80b57ae69..6fab6c914 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/ImageMapRenderer.java @@ -7,12 +7,12 @@ import org.bukkit.map.MapCanvas; import org.bukkit.map.MapRenderer; import org.bukkit.map.MapView; -public class ImageMapRenderer extends MapRenderer +class ImageMapRenderer extends MapRenderer { private BufferedImage _image; private boolean _first = true; - public ImageMapRenderer(BufferedImage image) + ImageMapRenderer(BufferedImage image) { _image = image; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/BrandingManager.java b/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/BrandingManager.java deleted file mode 100644 index 883975960..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/BrandingManager.java +++ /dev/null @@ -1,133 +0,0 @@ -package mineplex.core.sponsorbranding; - -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.concurrent.ConcurrentHashMap; - -import javax.imageio.ImageIO; - -import org.bukkit.Location; -import org.bukkit.block.BlockFace; -import mineplex.core.MiniPlugin; -import mineplex.core.ReflectivelyCreateMiniPlugin; - -/** - * - * Manager for creating billboards with branding logos - */ -@ReflectivelyCreateMiniPlugin -public class BrandingManager extends MiniPlugin -{ - private ConcurrentHashMap _posts = new ConcurrentHashMap(); - private ConcurrentHashMap _imgCache = new ConcurrentHashMap(); - - private BrandingManager() - { - super("Branding Manager"); - } - - private BufferedImage getImage(String fileName) - { - if (_imgCache.containsKey(fileName)) - { - return _imgCache.get(fileName); - } - - File folder = new File("../../update"); - File f = new File(folder, "logos" + File.separatorChar + fileName); - BufferedImage image = null; - - if (!f.exists()) - { - return null; - } - - try - { - image = ImageIO.read(f); - _imgCache.put(fileName, image); - } - catch (IOException e) - { - e.printStackTrace(); - } - - return image; - } - - private BufferedImage getImage(URL url) - { - if (_imgCache.containsKey(url.toString())) - { - return _imgCache.get(url.toString()); - } - - BufferedImage image = null; - - try - { - image = ImageIO.read(url); - _imgCache.put(url.toString(), image); - } - catch (IOException e) - { - e.printStackTrace(); - } - - return image; - } - - /** - * Generates a billboard with a stored logo - * @param location The center of the billboard - * @param facing The BlockFace the logo will appear on - * @param imageFileName The file name of the logo's base image - */ - public void createPost(Location location, BlockFace facing, String imageFileName) - { - BufferedImage img = getImage(imageFileName); - if (img == null) - { - System.out.println("ERROR! Invalid image file name!"); - return; - } - BrandingPost bp = new BrandingPost(location, facing, img); - bp.spawn(); - _posts.put(_posts.size(), bp); - } - - public void createPost(Location location, BlockFace facing, URL url) - { - BufferedImage image = getImage(url); - - if (image == null) - { - System.out.println("ERROR! Invalid image url!"); - return; - } - - BrandingPost brandingPost = new BrandingPost(location, facing, image); - brandingPost.spawn(); - // Umm why not use a List? - _posts.put(_posts.size(), brandingPost); - } - - /** - * Clears away all existing billboards - */ - public void reset() - { - disable(); - } - - @Override - public void disable() - { - for (Integer key : _posts.keySet()) - { - _posts.remove(key).despawn(); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/BrandingPost.java b/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/BrandingPost.java deleted file mode 100644 index 54f469646..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/BrandingPost.java +++ /dev/null @@ -1,242 +0,0 @@ -package mineplex.core.sponsorbranding; - -import java.awt.image.BufferedImage; -import java.util.List; - -import mineplex.core.common.util.UtilMath; - -import org.bukkit.Bukkit; -import org.bukkit.DyeColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.ItemFrame; -import org.bukkit.inventory.ItemStack; -import org.bukkit.map.MapRenderer; -import org.bukkit.map.MapView; - -import com.google.common.collect.Lists; - -/** - * An instance of a billboard with all its required data - */ -public class BrandingPost -{ - private Location _center; - private BlockFace _facing; - private BufferedImage _img; - - private Location[] _corners; - private List _ents = Lists.newArrayList(); - - public BrandingPost(Location center, BlockFace facing, BufferedImage image) - { - _center = center; - _facing = facing; - _img = image; - } - - @SuppressWarnings("deprecation") - private ItemStack getMapItem(int x, int y, BufferedImage image) - { - ItemStack item = new ItemStack(Material.MAP); - - MapView map = Bukkit.getServer().createMap(Bukkit.getServer().getWorlds().get(0)); - for (MapRenderer r : map.getRenderers()) - { - map.removeRenderer(r); - } - - map.addRenderer(new LogoMapRenderer(image, x, y)); - item.setDurability(map.getId()); - - return item; - } - - /** - * Generates a billboard using parameters from instance constructor - */ - @SuppressWarnings("deprecation") - public void spawn() - { - Location corner1 = _center.clone(); - Location corner2 = _center.clone(); - Location corner3 = _center.clone(); - Location corner4 = _center.clone(); - - int width = (int) Math.ceil(_img.getWidth() / 128); - int height = (int) Math.ceil(_img.getHeight() / 128); - - Bukkit.broadcastMessage("width=" + width + " height=" + height); - - switch (_facing) - { - case EAST: - corner1.add(0, 1, -2); - corner2.add(0, -1, 2); - corner3.add(0, 2, -3); - corner4.add(0, -2, 3); - break; - case WEST: - corner1.add(0, 1, -2); - corner2.add(0, -1, 2); - corner3.add(0, 2, -3); - corner4.add(0, -2, 3); - break; - case SOUTH: - corner1.add(-2, 1, 0); - corner2.add(2, -1, 0); - corner3.add(-3, 2, 0); - corner4.add(3, -2, 0); - break; - case NORTH: - corner1.add(-2, 1, 0); - corner2.add(2, -1, 0); - corner3.add(-3, 2, 0); - corner4.add(3, -2, 0); - break; - default: - System.out.println("ERROR! Invalid BlockFace given while loading BrandingPost!"); - return; - } - - _corners = new Location[] {corner1, corner2, corner3, corner4}; - - for (int x = Math.max(corner1.getBlockX(), corner2.getBlockX()); x >= Math.min(corner1.getBlockX(), corner2.getBlockX()); x--) - { - for (int y = Math.max(corner1.getBlockY(), corner2.getBlockY()); y >= Math.min(corner1.getBlockY(), corner2.getBlockY()); y--) - { - for (int z = Math.max(corner1.getBlockZ(), corner2.getBlockZ()); z >= Math.min(corner1.getBlockZ(), corner2.getBlockZ()); z--) - { - Location set = new Location(_center.getWorld(), x, y, z); - set.getBlock().setType(Material.STAINED_CLAY); - set.getBlock().setData(DyeColor.LIGHT_BLUE.getWoolData()); - } - } - } - - int xMod = 0; - int zMod = 0; - - switch (_facing) - { - case EAST: - zMod = -1; - break; - case WEST: - zMod = 1; - break; - case SOUTH: - xMod = 1; - break; - case NORTH: - xMod = -1; - break; - default: - break; - } - - BufferedImage image = _img; - - if (image == null) - { - System.out.println("ERROR! Invalid image given while loading BrandingPost!"); - return; - } - - Block base = corner1.getBlock().getRelative(_facing); - - try - { - for (int x = 0; x < width; x++) - { - for (int y = 0; y < height; y++) - { - ItemFrame i = null; - Block block = base.getRelative(x * xMod, -y, x * zMod); - i = block.getWorld().spawn(block.getLocation(), ItemFrame.class); - - i.setFacingDirection(_facing, false); - - ItemStack item = getMapItem(x, y, _img); - i.setItem(item); - - Bukkit.broadcastMessage(x + " <- X Y -> " + y); - _ents.add(i); - } - } - } - catch (NullPointerException e) - { - System.out.println("ERROR! ItemFrame space already occupied!"); - return; - } - - for (int x = Math.max(corner3.getBlockX(), corner4.getBlockX()); x >= Math.min(corner3.getBlockX(), corner4.getBlockX()); x--) - { - for (int y = Math.max(corner3.getBlockY(), corner4.getBlockY()); y >= Math.min(corner3.getBlockY(), corner4.getBlockY()); y--) - { - for (int z = Math.max(corner3.getBlockZ(), corner4.getBlockZ()); z >= Math.min(corner3.getBlockZ(), corner4.getBlockZ()); z--) - { - Location set = new Location(_center.getWorld(), x, y, z); - if (set.getBlock().getType() == Material.STAINED_CLAY) - continue; - - if (UtilMath.offset2d(corner3.getBlock().getLocation(), set.getBlock().getLocation()) == 0 || UtilMath.offset2d(corner4.getBlock().getLocation(), set.getBlock().getLocation()) == 0) - { - if (corner3.getBlockY() != set.getBlockY() && corner4.getBlockY() != set.getBlockY()) - { - Material type = Material.COBBLE_WALL; - if (_center.getBlockY() == set.getBlockY()) - { - type = Material.FENCE; - } - - set.getBlock().setType(type); - continue; - } - } - - Material type = Material.STEP; - byte data = (byte)5; - if (set.getBlockY() == corner4.getBlockY()) - { - type = Material.SMOOTH_BRICK; - data = (byte)0; - } - - set.getBlock().setType(type); - set.getBlock().setData(data); - } - } - } - } - - /** - * Clears away all blocks and ItemFrames generated by this billboard - */ - public void despawn() - { - if (_corners != null) - { - for (int x = Math.max(_corners[2].getBlockX(), _corners[3].getBlockX()); x >= Math.min(_corners[2].getBlockX(), _corners[3].getBlockX()); x--) - { - for (int y = Math.max(_corners[2].getBlockY(), _corners[3].getBlockY()); y >= Math.min(_corners[2].getBlockY(), _corners[3].getBlockY()); y--) - { - for (int z = Math.max(_corners[2].getBlockZ(), _corners[3].getBlockZ()); z >= Math.min(_corners[2].getBlockZ(), _corners[3].getBlockZ()); z--) - { - Location set = new Location(_center.getWorld(), x, y, z); - set.getBlock().setType(Material.AIR); - } - } - } - } - for (ItemFrame it : _ents) - { - it.setItem(new ItemStack(Material.AIR)); - it.remove(); - } - _ents.clear(); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/LogoMapRenderer.java b/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/LogoMapRenderer.java deleted file mode 100644 index 5dfb5822e..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/sponsorbranding/LogoMapRenderer.java +++ /dev/null @@ -1,51 +0,0 @@ -package mineplex.core.sponsorbranding; - -import java.awt.Image; -import java.awt.image.BufferedImage; - -import org.bukkit.entity.Player; -import org.bukkit.map.MapCanvas; -import org.bukkit.map.MapRenderer; -import org.bukkit.map.MapView; - -/** - * Renderer for each map panel of the full billboard logo - */ -public class LogoMapRenderer extends MapRenderer -{ - private Image _img; - private boolean _first = true; - - public LogoMapRenderer(BufferedImage image, int x1, int y1) - { - recalculateInput(image, x1, y1); - } - - private void recalculateInput(BufferedImage input, int x1, int y1) - { - if (x1 > input.getWidth() || y1 > input.getHeight()) - { - return; - } - - int startX = Math.min(x1 * 128, input.getWidth()); - startX = Math.max(input.getMinX(), startX); - int startY = Math.min(y1 * 128, input.getHeight()); - startY = Math.max(input.getMinY(), startY); - - _img = input.getSubimage(startX, startY, 128, 128); - - _first = true; - } - - @Override - public void render(MapView view, MapCanvas canvas, Player player) - { - if (_img != null && _first) - { - canvas.drawImage(0, 0, _img); - _first = false; - } - } - -} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 5306f213b..ae10ed3a9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -3,7 +3,7 @@ package nautilus.game.arcade; import java.io.File; import java.util.HashMap; -import mineplex.core.packethandler.CustomFrames; +import mineplex.core.imagemap.CustomItemFrames; import net.minecraft.server.v1_8_R3.MinecraftServer; import org.bukkit.Bukkit; @@ -230,7 +230,7 @@ public class Arcade extends JavaPlugin AprilFoolsManager.getInstance(); - require(CustomFrames.class); + require(CustomItemFrames.class); //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index b0df81d54..a010a5ac6 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -1,13 +1,5 @@ package mineplex.gemhunters; -import net.minecraft.server.v1_8_R3.MinecraftServer; - -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.plugin.java.JavaPlugin; -import org.spigotmc.SpigotConfig; - import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; import mineplex.core.account.CoreClientManager; @@ -70,7 +62,6 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.visibility.VisibilityManager; import mineplex.gemhunters.beta.BetaModule; -import mineplex.gemhunters.bounties.BountyModule; import mineplex.gemhunters.chat.ChatModule; import mineplex.gemhunters.death.DeathModule; import mineplex.gemhunters.death.quitnpc.QuitNPCModule; @@ -100,6 +91,12 @@ import mineplex.gemhunters.worldevent.WorldEventModule; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.plugin.java.JavaPlugin; +import org.spigotmc.SpigotConfig; import static mineplex.core.Managers.require; @@ -275,7 +272,6 @@ public class GemHunters extends JavaPlugin // Though if any other module needs one of these it will be generated in // order, however they are all here just for good measure. require(BetaModule.class); - require(BountyModule.class); require(CashOutModule.class); require(ChatModule.class); require(DeathModule.class); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/bounties/Bounty.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/bounties/Bounty.java deleted file mode 100644 index 6e9069d16..000000000 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/bounties/Bounty.java +++ /dev/null @@ -1,36 +0,0 @@ -package mineplex.gemhunters.bounties; - -import java.util.UUID; - -import org.bukkit.entity.Player; - -public class Bounty -{ - - private UUID _target; - private UUID _setter; - private int _amount; - - public Bounty(Player target, Player setter, int amount) - { - _target = target.getUniqueId(); - _setter = setter.getUniqueId(); - _amount = amount; - } - - public UUID getTarget() - { - return _target; - } - - public UUID getSetter() - { - return _setter; - } - - public int getAmount() - { - return _amount; - } - -} diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/bounties/BountyModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/bounties/BountyModule.java deleted file mode 100644 index 771d58997..000000000 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/bounties/BountyModule.java +++ /dev/null @@ -1,46 +0,0 @@ -package mineplex.gemhunters.bounties; - -import java.net.MalformedURLException; -import java.net.URL; - -import org.bukkit.block.BlockFace; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; - -import mineplex.core.MiniPlugin; -import mineplex.core.ReflectivelyCreateMiniPlugin; -import mineplex.core.sponsorbranding.BrandingManager; - -@ReflectivelyCreateMiniPlugin -public class BountyModule extends MiniPlugin -{ - - private final BrandingManager _brandingManager; - - private BountyModule() - { - super("Bounty"); - - _brandingManager = require(BrandingManager.class); - } - - //@EventHandler - public void test(PlayerCommandPreprocessEvent event) - { - if (!event.getMessage().startsWith("/want")) - { - return; - } - - try - { - event.setCancelled(true); - _brandingManager.createPost(event.getPlayer().getLocation(), BlockFace.SOUTH, new URL("http://minotar.net/helm/Moppletop.png")); - } - catch (MalformedURLException e) - { - e.printStackTrace(); - } - } - -} From c0cc3789b14dec71afe48f08e7c0ac01be277a16 Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 7 Jul 2017 16:45:04 -0700 Subject: [PATCH 069/183] Fix server tps metadata key --- .../core/antihack/logging/builtin/ServerInfoMetadata.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java index 18c64a3c2..cd937ec64 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java @@ -14,7 +14,7 @@ public class ServerInfoMetadata extends AnticheatMetadata private static final String KEY_SERVER_NAME = "server-name"; private static final String KEY_SERVER_REGION = "server-region"; private static final String KEY_SERVER_GROUP = "server-group"; - private static final String KEY_SERVER_TPS = ""; + private static final String KEY_SERVER_TPS = "server-tps"; @Override public String getId() From b7c629c4c8e3aa320a35e107dab504a7c360ed62 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 11 Jul 2017 02:10:43 +0100 Subject: [PATCH 070/183] Make item map billboards not really work --- .../core/imagemap/CustomItemFrames.java | 1 + .../core/imagemap/ImageMapManager.java | 76 ++++++++++++++++--- .../core/imagemap/ImageMapRenderer.java | 8 +- .../core/imagemap/PlayerMapBoard.java | 49 +++++++++++- .../core/imagemap/PlayerMapImage.java | 23 ++++++ .../Mineplex.Hub/src/mineplex/hub/Hub.java | 17 ++--- .../hub/modules/BillboardManager.java | 66 ---------------- .../nautilus/game/arcade/ArcadeManager.java | 75 ++++++++---------- .../game/arcade/game/games/moba/Moba.java | 31 ++++++++ .../games/moba/general/MobaDamageManager.java | 7 +- .../game/games/moba/kit/dana/SkillRally.java | 5 ++ .../moba/structure/tower/TowerManager.java | 2 +- .../games/moba/training/MobaTraining.java | 5 +- .../games/speedbuilders/SpeedBuilders.java | 21 ++--- 14 files changed, 229 insertions(+), 157 deletions(-) delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/BillboardManager.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java index 440bb1e15..41b873995 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java @@ -13,6 +13,7 @@ import net.minecraft.server.v1_8_R3.EntityItemFrame; import net.minecraft.server.v1_8_R3.ItemStack; import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItemFrame; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java index 06197b412..67332cf4b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java @@ -6,12 +6,12 @@ import mineplex.core.common.util.UtilBlock; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.ItemFrame; -import org.bukkit.inventory.ItemStack; -import org.bukkit.map.MapView; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; @@ -27,10 +27,10 @@ import java.util.Map; public class ImageMapManager extends MiniPlugin { - private static final String IMAGE_FILE = ".." + File.separator + ".." + File.separator + "update" + File.separator + "files"; + private static final String IMAGE_DIR = ".." + File.separator + ".." + File.separator + "update" + File.separator + "files"; private static final int PIXELS_PER_MAP = 128; - public static int getPixelsPerMap() + public static int getMapDimension() { return PIXELS_PER_MAP; } @@ -38,6 +38,7 @@ public class ImageMapManager extends MiniPlugin private final CustomItemFrames _itemFrames; private final Map _imageCache; + private List _boards; private ImageMapManager() { @@ -46,21 +47,72 @@ public class ImageMapManager extends MiniPlugin _itemFrames = require(CustomItemFrames.class); _imageCache = new HashMap<>(); + _boards = new ArrayList<>(); } - public void createPlayerBoard(Location topLeft, BlockFace direction, int width, int height) + @EventHandler + public void playerJoin(PlayerJoinEvent event) { - List itemFrames = createItemFrames(topLeft, BlockFace.EAST, 7, 4); + Player player = event.getPlayer(); - PlayerMapImage image1 = new PlayerMapImage(_itemFrames, getImage(new File("Bardolf.png")), itemFrames, 7, 4); - PlayerMapImage image2 = new PlayerMapImage(_itemFrames, getImage(new File("Biff.png")), itemFrames, 7, 4); + runSyncLater(() -> _boards.forEach(board -> board.onPlayerJoin(player)), 100); + } - runSyncTimer(() -> + public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, String... images) + { + BufferedImage[] bufferedImages = new BufferedImage[images.length]; + + for (int i = 0; i < images.length; i++) { + bufferedImages[i] = getImage(new File(IMAGE_DIR + File.separator + images[i])); + } - image. + return createPlayerBoard(topLeft, direction, width, height, bufferedImages); + } - }, 100, 100); + public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, File... images) + { + BufferedImage[] bufferedImages = new BufferedImage[images.length]; + + for (int i = 0; i < images.length; i++) + { + bufferedImages[i] = getImage(images[i]); + } + + return createPlayerBoard(topLeft, direction, width, height, bufferedImages); + } + + public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, URL... images) + { + BufferedImage[] bufferedImages = new BufferedImage[images.length]; + + for (int i = 0; i < images.length; i++) + { + bufferedImages[i] = getImage(images[i]); + } + + return createPlayerBoard(topLeft, direction, width, height, bufferedImages); + } + + public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, BufferedImage... images) + { + List itemFrames = createItemFrames(topLeft, direction, width, height); + List mapImageList = new ArrayList<>(); + + for (BufferedImage image : images) + { + PlayerMapImage mapImage = new PlayerMapImage(_itemFrames, image, itemFrames, width, height); + mapImage.create(); + + mapImageList.add(mapImage); + } + + PlayerMapBoard board = new PlayerMapBoard(topLeft, mapImageList); + + Bukkit.getOnlinePlayers().forEach(board::onPlayerJoin); + + _boards.add(board); + return board; } private List createItemFrames(Location topLeft, BlockFace direction, int width, int height) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapRenderer.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapRenderer.java index 15566f92a..7d83fe199 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapRenderer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapRenderer.java @@ -16,17 +16,17 @@ public class ImageMapRenderer extends MapRenderer public ImageMapRenderer(BufferedImage image, int x1, int y1) { - int startX = Math.min(x1 * ImageMapManager.getPixelsPerMap(), image.getWidth()); + int startX = Math.min(x1 * ImageMapManager.getMapDimension(), image.getWidth()); startX = Math.max(image.getMinX(), startX); - int startY = Math.min(y1 * ImageMapManager.getPixelsPerMap(), image.getHeight()); + int startY = Math.min(y1 * ImageMapManager.getMapDimension(), image.getHeight()); startY = Math.max(image.getMinY(), startY); - if (startX + ImageMapManager.getPixelsPerMap() > image.getWidth() || startY + ImageMapManager.getPixelsPerMap() > image.getHeight()) + if (startX + ImageMapManager.getMapDimension() > image.getWidth() || startY + ImageMapManager.getMapDimension() > image.getHeight()) { return; } - _image = image.getSubimage(startX, startY, ImageMapManager.getPixelsPerMap(), ImageMapManager.getPixelsPerMap()); + _image = image.getSubimage(startX, startY, ImageMapManager.getMapDimension(), ImageMapManager.getMapDimension()); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapBoard.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapBoard.java index 94d42c227..3dc4fb850 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapBoard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapBoard.java @@ -1,14 +1,61 @@ package mineplex.core.imagemap; import org.bukkit.Location; +import org.bukkit.entity.Player; + +import java.util.List; public class PlayerMapBoard { private final Location _location; + private final List _images; - public PlayerMapBoard(Location location) + public PlayerMapBoard(Location location, List images) { _location = location; + _images = images; } + + public void goTo(Player player, boolean next) + { + int i = 0; + + for (PlayerMapImage image : _images) + { + if (image.getViewers().contains(player)) + { + if (next && _images.size() - 1 == i) + { + i = -1; + } + else if (!next && i == 0) + { + i = _images.size(); + } + + image.removeViewer(player); + _images.get(next ? i + 1 : i - 1).addViewer(player); + return; + } + + i++; + } + } + + public void onPlayerJoin(Player player) + { + _images.get(0).addViewer(player); + } + + public Location getLocation() + { + return _location; + } + + public List getImages() + { + return _images; + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapImage.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapImage.java index 1bfa3aad2..825921187 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapImage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapImage.java @@ -1,5 +1,6 @@ package mineplex.core.imagemap; +import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; @@ -15,6 +16,7 @@ public class PlayerMapImage extends MapImage private final CustomItemFrames _itemFramesManager; private final List _itemMaps; private final List _viewers; + private boolean _sentPacket; public PlayerMapImage(CustomItemFrames itemFramesManager, BufferedImage image, List itemFrames, int width, int height) { @@ -41,8 +43,21 @@ public class PlayerMapImage extends MapImage public void addViewer(Player player) { + if (_viewers.contains(player)) + { + return; + } + _viewers.add(player); + if (!_sentPacket) + { + player.getInventory().clear(); + player.getInventory().addItem(_itemMaps.toArray(new ItemStack[0])); + player.getInventory().clear(); + _sentPacket = true; + } + for (int i = 0; i < _itemMaps.size(); i++) { ItemFrame itemFrame = _itemFrames.get(i); @@ -50,10 +65,18 @@ public class PlayerMapImage extends MapImage _itemFramesManager.setItem(player, itemFrame, itemStack); } + + Bukkit.broadcastMessage("Hello " + player.getName()); } public void removeViewer(Player player) { _viewers.remove(player); + Bukkit.broadcastMessage("Bye " + player.getName()); + } + + public List getViewers() + { + return _viewers; } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 6c22d7cbb..6f3a344b2 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -1,10 +1,5 @@ package mineplex.hub; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.CustomTagFix; import mineplex.core.PacketsInteractionFix; import mineplex.core.TwitchIntegrationFix; @@ -16,7 +11,6 @@ import mineplex.core.antihack.guardians.GuardianManager; import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.boosters.BoosterManager; -import mineplex.hub.brawl.fountain.FountainManager; import mineplex.core.chat.Chat; import mineplex.core.chatsnap.SnapshotManager; import mineplex.core.chatsnap.SnapshotPlugin; @@ -62,7 +56,6 @@ import mineplex.core.report.ReportManager; import mineplex.core.report.ReportPlugin; import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.serverConfig.ServerConfiguration; -import mineplex.core.sponsorbranding.BrandingManager; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; @@ -77,8 +70,8 @@ import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; import mineplex.core.website.WebsiteLinkManager; +import mineplex.hub.brawl.fountain.FountainManager; import mineplex.hub.modules.AprilFoolsTreasureHunt; -import mineplex.hub.modules.BillboardManager; import mineplex.hub.queue.QueueManager; import mineplex.hub.server.ServerManager; import mineplex.minecraft.game.classcombat.Class.ClassManager; @@ -91,6 +84,10 @@ import mineplex.minecraft.game.core.IRelation; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; import static mineplex.core.Managers.require; @@ -209,7 +206,6 @@ public class Hub extends JavaPlugin implements IRelation CombatManager combatManager = new CombatManager(this); - DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, conditionManager); conditionManager.setDamageManager(damage); @@ -233,9 +229,6 @@ public class Hub extends JavaPlugin implements IRelation //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); - BrandingManager brandingManager = require(BrandingManager.class); - new BillboardManager(this, brandingManager); - require(TrackManager.class); require(Titles.class); require(TwoFactorAuth.class); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/BillboardManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/BillboardManager.java deleted file mode 100644 index d1dd5df72..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/BillboardManager.java +++ /dev/null @@ -1,66 +0,0 @@ -package mineplex.hub.modules; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.events.ServerShutdownEvent; -import mineplex.core.sponsorbranding.BrandingManager; - -import org.bukkit.entity.ItemFrame; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.hanging.HangingBreakEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.plugin.java.JavaPlugin; - -/** - * Manager to handle generation and protection of billboards in the hub - */ -public class BillboardManager extends MiniPlugin -{ - private BrandingManager _branding; - - public BillboardManager(JavaPlugin plugin, BrandingManager branding) - { - super("Billboard", plugin); - _branding = branding; - - generateBoards(); - } - - private void generateBoards() - { - - } - - @EventHandler - public void stopBreaking(HangingBreakEvent event) - { - if (event.getEntity() instanceof ItemFrame) - { - event.setCancelled(true); - } - } - - @EventHandler - public void stopBreaking(EntityDamageEvent event) - { - if (event.getEntity() instanceof ItemFrame) - { - event.setCancelled(true); - } - } - - @EventHandler - public void stopInteract(PlayerInteractEntityEvent event) - { - if (event.getRightClicked() != null && event.getRightClicked() instanceof ItemFrame) - { - event.setCancelled(true); - } - } - - @EventHandler - public void handleShutdown(ServerShutdownEvent event) - { - _branding.reset(); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index bdca5e21c..2bfab0d6b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -1,44 +1,10 @@ package nautilus.game.arcade; -import java.io.File; -import java.util.ArrayList; -import java.util.HashSet; - -import mineplex.core.google.GoogleSheetsManager; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockSpreadEvent; -import org.bukkit.event.block.LeavesDecayEvent; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.server.ServerListPingEvent; -import org.bukkit.potion.PotionEffect; -import org.bukkit.scoreboard.Team; -import org.bukkit.util.Vector; - import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; -import mineplex.core.antihack.compedaccount.PriorityCause; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.bonuses.BonusManager; @@ -74,6 +40,7 @@ import mineplex.core.facebook.FacebookManager; import mineplex.core.gadget.event.ToggleMobsEvent; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; +import mineplex.core.google.GoogleSheetsManager; import mineplex.core.hologram.HologramManager; import mineplex.core.incognito.IncognitoManager; import mineplex.core.incognito.events.IncognitoStatusChangeEvent; @@ -100,7 +67,6 @@ import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager; import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.scoreboard.MineplexScoreboard; import mineplex.core.scoreboard.ScoreboardManager; -import mineplex.core.sponsorbranding.BrandingManager; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; @@ -169,6 +135,37 @@ import nautilus.game.arcade.managers.lobby.legacy.LegacyGameLobbyManager; import nautilus.game.arcade.player.ArcadePlayer; import nautilus.game.arcade.shop.ArcadeShop; import net.minecraft.server.v1_8_R3.EntityLiving; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.scoreboard.Team; +import org.bukkit.util.Vector; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashSet; public class ArcadeManager extends MiniPlugin implements IRelation { @@ -224,7 +221,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation private ResourcePackManager _resourcePackManager; private CustomDataManager _customDataManager; private Punish _punishmentManager; - private BrandingManager _brandingManager; private BonusManager _bonusManager; private KitProgressionManager _kitProgressionManager; private ProgressingKitManager _progressionKitManager; @@ -289,8 +285,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation _conditionManager = new SkillConditionManager(plugin); - _brandingManager = require(BrandingManager.class); - _boosterManager = boosterManager; _clientManager = clientManager; @@ -723,11 +717,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _punishmentManager; } - public BrandingManager getBrandingManager() - { - return _brandingManager; - } - public Portal GetPortal() { return _portal; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index fad12392b..6eff23022 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -6,10 +6,15 @@ import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager; +import mineplex.core.imagemap.CustomItemFrames; +import mineplex.core.imagemap.ImageMapManager; +import mineplex.core.imagemap.PlayerMapBoard; +import mineplex.core.imagemap.PlayerMapImage; import mineplex.core.leaderboard.Leaderboard; import mineplex.core.leaderboard.LeaderboardManager; import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; @@ -54,6 +59,8 @@ import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -61,6 +68,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.Arrays; @@ -233,6 +241,29 @@ public class Moba extends TeamGame Location location = lobbyCustomLocs.get("TOP_GOLD").get(0); leaderboard.registerLeaderboard("TOP_HOG_GOLD", new Leaderboard("Top Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.ALL, location, 10)); } + + String[] files = { + "Anath_the_Burnt.png", + "Bardolf.png", + "Biff.png", + "Dana.png", + "Devon.png", + "Hattori.png", + "Larissa.png", + "Rowena.png" + }; + + PlayerMapBoard board = Managers.require(ImageMapManager.class).createPlayerBoard(lobbyCustomLocs.get("HERO_VIEWER").get(0).clone().add(0, 1, 0), BlockFace.EAST, 7, 4, files); + + Manager.runSyncTimer(() -> + { + + for (Player player : Bukkit.getOnlinePlayers()) + { + board.goTo(player, true); + } + + }, 100, 100); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java index 6a0cfccfc..4ab136f7b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java @@ -9,6 +9,8 @@ import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -103,11 +105,13 @@ public class MobaDamageManager implements Listener @EventHandler public void mageStrength(CustomDamageEvent event) { - if (event.GetCause() != DamageCause.CUSTOM) + if (event.GetReason() == null || !event.GetReason().contains(MobaConstants.BASIC_ATTACK)) { return; } + Bukkit.broadcastMessage("Mage Basic Attack"); + Player damager = event.GetDamagerPlayer(true); if (damager == null) @@ -120,6 +124,7 @@ public class MobaDamageManager implements Listener if (effect.getType() == PotionEffectType.INCREASE_DAMAGE) { + Bukkit.broadcastMessage("Power Potion"); event.AddMod("Strength", effect.getAmplifier() * 2 + 1); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index 19922f0e1..1479cfbe3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -151,6 +151,11 @@ public class SkillRally extends HeroSkill for (LivingEntity nearby : UtilEnt.getInRadius(player.getLocation(), 3).keySet()) { + if (!isTeamDamage(nearby, player)) + { + continue; + } + Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, 7, true, true, false, UtilEnt.getName(player), GetName()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index b252f1477..28da828f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -144,7 +144,7 @@ public class TowerManager implements Listener tower.updateDamage(); } } - else if (event.getType() != UpdateType.SLOW) + else if (event.getType() == UpdateType.SLOW) { for (Tower tower : _towers) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index d7a406b92..9be3809a1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -25,6 +25,7 @@ import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; @@ -37,6 +38,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.ItemStack; import java.util.HashMap; import java.util.List; @@ -391,7 +393,7 @@ public class MobaTraining extends Moba String name = event.GetDamageeEntity().getCustomName(); - if (name != null && name.contains("")) + if (name != null && name.contains("Select A Hero")) { openMenu(event.GetDamagerPlayer(false)); } @@ -469,6 +471,7 @@ public class MobaTraining extends Moba { Skeleton skeleton = UtilVariant.spawnWitherSkeleton(WorldData.GetCustomLocs("PUMPKIN_KING").get(0)); skeleton.setCustomName(C.cDRedB + "Pumpkin King"); + skeleton.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); _entities.put(skeleton, skeleton.getLocation()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java index 186b91746..a69086bd0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java @@ -1,10 +1,5 @@ package nautilus.game.arcade.game.games.speedbuilders; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map.Entry; - import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -32,7 +27,6 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.games.skyfall.quests.RingQuestTracker; import nautilus.game.arcade.game.games.speedbuilders.data.BuildData; import nautilus.game.arcade.game.games.speedbuilders.data.DemolitionData; import nautilus.game.arcade.game.games.speedbuilders.data.MobData; @@ -49,7 +43,6 @@ import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.BlockPlaceStatTracker; import net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Effect; @@ -97,6 +90,11 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map.Entry; + public class SpeedBuilders extends SoloGame { private static final String GUARDIAN_NAME = "Gwen the Guardian"; @@ -206,15 +204,6 @@ public class SpeedBuilders extends SoloGame .setGiveCompassToAlive(false) .register(this); } - - @EventHandler - public void onEnd(GameStateChangeEvent event) - { - if (event.GetState() == GameState.End || event.GetState() == GameState.Dead) - { - Manager.getBrandingManager().reset(); - } - } @Override public void ParseData() From 06a8c191ac5bd96b726c4745aa18927497d865dd Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 12 Jul 2017 00:38:54 +0100 Subject: [PATCH 071/183] Complete the implementation for map boards --- .../core/imagemap/ImageMapManager.java | 26 +++- .../imagemap/objects/MapBoardSelector.java | 144 ++++++++++++++++++ .../core/imagemap/{ => objects}/MapImage.java | 3 +- .../{ => objects}/PlayerMapBoard.java | 2 +- .../{ => objects}/PlayerMapImage.java | 23 ++- .../game/arcade/game/games/moba/Moba.java | 29 ++-- .../game/games/moba/general/BetaManager.java | 21 ++- .../games/moba/general/MobaDamageManager.java | 9 +- 8 files changed, 213 insertions(+), 44 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapBoardSelector.java rename Plugins/Mineplex.Core/src/mineplex/core/imagemap/{ => objects}/MapImage.java (92%) rename Plugins/Mineplex.Core/src/mineplex/core/imagemap/{ => objects}/PlayerMapBoard.java (95%) rename Plugins/Mineplex.Core/src/mineplex/core/imagemap/{ => objects}/PlayerMapImage.java (78%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java index 67332cf4b..34680c21b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java @@ -3,15 +3,19 @@ package mineplex.core.imagemap; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.common.util.UtilBlock; +import mineplex.core.imagemap.objects.PlayerMapBoard; +import mineplex.core.imagemap.objects.PlayerMapImage; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; @@ -55,7 +59,15 @@ public class ImageMapManager extends MiniPlugin { Player player = event.getPlayer(); - runSyncLater(() -> _boards.forEach(board -> board.onPlayerJoin(player)), 100); + runSyncLater(() -> _boards.forEach(board -> board.onPlayerJoin(player)), 50); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + _boards.forEach(board -> board.getImages().forEach(image -> image.removeViewer(player))); } public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, String... images) @@ -204,4 +216,16 @@ public class ImageMapManager extends MiniPlugin return null; } } + + public void cleanupBoard(PlayerMapBoard board) + { + _boards.remove(board); + + board.getImages().forEach(image -> + { + image.getViewers().clear(); + image.getItemFrames().forEach(Entity::remove); + image.getItemFrames().clear(); + }); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapBoardSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapBoardSelector.java new file mode 100644 index 000000000..2d2cc009c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapBoardSelector.java @@ -0,0 +1,144 @@ +package mineplex.core.imagemap.objects; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +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.UtilServer; +import mineplex.core.recharge.Recharge; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class MapBoardSelector implements Listener +{ + + private final PlayerMapBoard _board; + private ArmorStand _goNext; + private Slime _goNextBox; + private ArmorStand _goBack; + private Slime _goBackBox; + + public MapBoardSelector(PlayerMapBoard board) + { + _board = board; + + UtilServer.RegisterEvents(this); + } + + public void createHolograms(Location goNext, Location goBack) + { + _goNext = createArmourStand(goNext); + _goNext.setCustomName(C.cGreen + "Next Page"); + + _goNextBox = createSlimeBox(goNext); + + _goBack = createArmourStand(goBack); + _goBack.setCustomName(C.cGreen + "Previous Page"); + + _goBackBox = createSlimeBox(goBack); + } + + private ArmorStand createArmourStand(Location location) + { + ArmorStand stand = location.getWorld().spawn(location.clone().subtract(0, 0.5, 0), ArmorStand.class); + + UtilEnt.vegetate(stand); + UtilEnt.ghost(stand, true, false); + + stand.setCustomNameVisible(true); + stand.setVisible(false); + stand.setGravity(false); + + return stand; + } + + private Slime createSlimeBox(Location location) + { + Slime slime = location.getWorld().spawn(location.clone().add(0, 1, 0), Slime.class); + + UtilEnt.vegetate(slime); + UtilEnt.ghost(slime, true, false); + UtilEnt.setFakeHead(slime, true); + UtilEnt.silence(slime, true); + + slime.setSize(5); + slime.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false)); + + return slime; + } + + public void cleanup() + { + _goNext.remove(); + _goNextBox.remove(); + _goBack.remove(); + _goBackBox.remove(); + UtilServer.Unregister(this); + } + + @EventHandler + public void onClick(PlayerInteractAtEntityEvent event) + { + if (onClick(event.getPlayer(), event.getRightClicked())) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onClick(EntityDamageByEntityEvent event) + { + if (onClick(event.getDamager(), event.getEntity())) + { + event.setCancelled(true); + } + } + + private boolean onClick(Entity clicker, Entity clicked) + { + if (!(clicker instanceof Player)) + { + return false; + } + + Player player = (Player) clicker; + boolean action = false; + + if (!Recharge.Instance.use(player, "Change Page", 500, false, false)) + { + return true; + } + + if (_goNextBox != null && _goNextBox.equals(clicked)) + { + _board.goTo(player, true); + action = true; + } + else if (_goBackBox != null && _goBackBox.equals(clicked)) + { + _board.goTo(player, false); + action = true; + } + + if (action) + { + UtilParticle.PlayParticle(ParticleType.CRIT, clicked.getLocation().add(0, 1.5, 0), 0.25F, 0.25F, 0.25F, 0.2F, 15, ViewDist.SHORT, player); + player.playSound(clicked.getLocation(), Sound.WOOD_CLICK, 1, 1); + } + + return action; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/MapImage.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapImage.java similarity index 92% rename from Plugins/Mineplex.Core/src/mineplex/core/imagemap/MapImage.java rename to Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapImage.java index 097953cfd..37c6d315f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/MapImage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapImage.java @@ -1,5 +1,6 @@ -package mineplex.core.imagemap; +package mineplex.core.imagemap.objects; +import mineplex.core.imagemap.ImageMapRenderer; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.World; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapBoard.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapBoard.java similarity index 95% rename from Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapBoard.java rename to Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapBoard.java index 3dc4fb850..72a6f3a73 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapBoard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapBoard.java @@ -1,4 +1,4 @@ -package mineplex.core.imagemap; +package mineplex.core.imagemap.objects; import org.bukkit.Location; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapImage.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapImage.java similarity index 78% rename from Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapImage.java rename to Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapImage.java index 825921187..6ee11f5cd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/PlayerMapImage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapImage.java @@ -1,6 +1,7 @@ -package mineplex.core.imagemap; +package mineplex.core.imagemap.objects; -import org.bukkit.Bukkit; +import mineplex.core.imagemap.CustomItemFrames; +import mineplex.core.imagemap.objects.MapImage; import org.bukkit.World; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; @@ -16,7 +17,6 @@ public class PlayerMapImage extends MapImage private final CustomItemFrames _itemFramesManager; private final List _itemMaps; private final List _viewers; - private boolean _sentPacket; public PlayerMapImage(CustomItemFrames itemFramesManager, BufferedImage image, List itemFrames, int width, int height) { @@ -41,6 +41,11 @@ public class PlayerMapImage extends MapImage } } + public List getItemFrames() + { + return _itemFrames; + } + public void addViewer(Player player) { if (_viewers.contains(player)) @@ -50,13 +55,8 @@ public class PlayerMapImage extends MapImage _viewers.add(player); - if (!_sentPacket) - { - player.getInventory().clear(); - player.getInventory().addItem(_itemMaps.toArray(new ItemStack[0])); - player.getInventory().clear(); - _sentPacket = true; - } + player.getInventory().clear(); + player.getInventory().addItem(_itemMaps.toArray(new ItemStack[0])); for (int i = 0; i < _itemMaps.size(); i++) { @@ -65,14 +65,11 @@ public class PlayerMapImage extends MapImage _itemFramesManager.setItem(player, itemFrame, itemStack); } - - Bukkit.broadcastMessage("Hello " + player.getName()); } public void removeViewer(Player player) { _viewers.remove(player); - Bukkit.broadcastMessage("Bye " + player.getName()); } public List getViewers() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 6eff23022..add6d1f87 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -5,16 +5,15 @@ import mineplex.core.beta.BetaWhitelist; import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.util.F; +import mineplex.core.common.util.PlayerMap; import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager; -import mineplex.core.imagemap.CustomItemFrames; import mineplex.core.imagemap.ImageMapManager; -import mineplex.core.imagemap.PlayerMapBoard; -import mineplex.core.imagemap.PlayerMapImage; +import mineplex.core.imagemap.objects.MapBoardSelector; +import mineplex.core.imagemap.objects.PlayerMapBoard; import mineplex.core.leaderboard.Leaderboard; import mineplex.core.leaderboard.LeaderboardManager; import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; @@ -59,7 +58,6 @@ import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; @@ -68,7 +66,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.Arrays; @@ -95,7 +92,10 @@ public class Moba extends TeamGame protected final TowerManager _tower; protected final CapturePointManager _capturePoint; protected final MinionManager _minion; + private final ImageMapManager _mapManager = Managers.require(ImageMapManager.class); private BetaWhitelist _betaWhitelist; + private PlayerMapBoard _board; + private MapBoardSelector _selector; private int _inPlayers; @@ -253,17 +253,9 @@ public class Moba extends TeamGame "Rowena.png" }; - PlayerMapBoard board = Managers.require(ImageMapManager.class).createPlayerBoard(lobbyCustomLocs.get("HERO_VIEWER").get(0).clone().add(0, 1, 0), BlockFace.EAST, 7, 4, files); - - Manager.runSyncTimer(() -> - { - - for (Player player : Bukkit.getOnlinePlayers()) - { - board.goTo(player, true); - } - - }, 100, 100); + _board = _mapManager.createPlayerBoard(lobbyCustomLocs.get("HERO_VIEWER").get(0).clone().add(0, 1, 0), BlockFace.EAST, 7, 4, files); + _selector = new MapBoardSelector(_board); + _selector.createHolograms(lobbyCustomLocs.get("HERO_VIEWER NEXT").get(0), lobbyCustomLocs.get("HERO_VIEWER BACK").get(0)); } } } @@ -315,6 +307,9 @@ public class Moba extends TeamGame _listeners.clear(); _betaWhitelist.deregisterSelf(); + _mapManager.cleanupBoard(_board); + _selector.cleanup(); + PlayerDisguiseManager playerDisguiseManager = Managers.require(PlayerDisguiseManager.class); // Undisguise all players diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java index f8f08448a..f4c1a10d6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java @@ -1,11 +1,15 @@ package nautilus.game.arcade.game.games.moba.general; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.moba.Moba; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ClickEvent.Action; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -13,7 +17,16 @@ import org.bukkit.event.Listener; public class BetaManager implements Listener { - private static final String MESSAGE = F.main("Game", "You can suggest improvements for the game on our Trello here ") + C.cYellow + "https://trello.com/b/MrxWVhlI/mineplex-heroes-of-gwen-feedback-update"; + private static final TextComponent MESSAGE; + + static + { + MESSAGE = new TextComponent("You can suggest improvements for the game on our Trello by clicking here!"); + MESSAGE.setColor(ChatColor.AQUA); + MESSAGE.setClickEvent(new ClickEvent(Action.OPEN_URL, "https://trello.com/b/MrxWVhlI/mineplex-heroes-of-gwen-feedback-update")); + MESSAGE.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click here to open the Trello board").color(ChatColor.YELLOW).create())); + } + private final Moba _host; public BetaManager(Moba host) @@ -29,6 +42,6 @@ public class BetaManager implements Listener return; } - Bukkit.broadcastMessage(MESSAGE); + Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(MESSAGE)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java index 4ab136f7b..bf75923c3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java @@ -10,12 +10,10 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.util.MobaConstants; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.potion.PotionEffectType; public class MobaDamageManager implements Listener @@ -110,8 +108,6 @@ public class MobaDamageManager implements Listener return; } - Bukkit.broadcastMessage("Mage Basic Attack"); - Player damager = event.GetDamagerPlayer(true); if (damager == null) @@ -122,10 +118,9 @@ public class MobaDamageManager implements Listener damager.getActivePotionEffects().forEach(effect -> { - if (effect.getType() == PotionEffectType.INCREASE_DAMAGE) + if (effect.getType().toString().equals(PotionEffectType.INCREASE_DAMAGE.toString())) { - Bukkit.broadcastMessage("Power Potion"); - event.AddMod("Strength", effect.getAmplifier() * 2 + 1); + event.AddMod("Strength", (effect.getAmplifier() + 1) * 2 + 1); } }); From cecc3614b8ccdd6d3efca05772acbf5b03676ab4 Mon Sep 17 00:00:00 2001 From: cnr Date: Tue, 11 Jul 2017 23:17:58 -0700 Subject: [PATCH 072/183] Set the correct key in QuitNPCRepository --- .../mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java index ce0dc8a9d..160e5352c 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPCRepository.java @@ -45,7 +45,7 @@ public class QuitNPCRepository extends RedisRepository { try (Jedis jedis = getResource(true)) { - jedis.setex(REDIS_KEY_PREFIX + uuid.toString(), 60, serverName); + jedis.setex(getKey(REDIS_KEY_PREFIX + uuid.toString()), 60, serverName); } }); } From f437ada4b9b9ae45c536f21da0f5da35ffdbe481 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 12 Jul 2017 16:49:50 +0100 Subject: [PATCH 073/183] Progress on game statistics --- .../core/imagemap/CustomItemFrames.java | 16 ++++-- .../core/imagemap/ImageMapManager.java | 17 ++++++- .../imagemap/objects/MapBoardSelector.java | 2 + .../core/imagemap/objects/PlayerMapBoard.java | 20 ++++++++ .../stats/game/GameStatisticsManager.java | 27 ++++++++++ .../stats/game/GameStatisticsRepository.java | 41 +++++++++++++++ .../mineplex/core/stats/game/GameStats.java | 51 +++++++++++++++++++ 7 files changed, 170 insertions(+), 4 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java index 41b873995..d712d3bb0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java @@ -44,7 +44,7 @@ public class CustomItemFrames extends MiniPlugin implements IPacketHandler @Override public void enable() { - require(PacketHandler.class).addPacketHandler(this, PacketPlayOutEntityMetadata.class); + require(PacketHandler.class).addPacketHandler(this, PacketPlayOutEntityMetadata.class, PacketPlayInUseEntity.class); } @Override @@ -58,18 +58,19 @@ public class CustomItemFrames extends MiniPlugin implements IPacketHandler { if (packetInfo.getPacket() instanceof PacketPlayOutEntityMetadata) { - if (_ourPackets.contains(packetInfo.getPacket())) + if (_ourPackets.remove(packetInfo.getPacket())) { - _ourPackets.remove(packetInfo.getPacket()); return; } PacketPlayOutEntityMetadata packet = (PacketPlayOutEntityMetadata) packetInfo.getPacket(); Map map = _frameData.get(packet.a); + if (map != null) { UUID uuid = packetInfo.getPlayer().getUniqueId(); ItemStack item = map.get(uuid); + if (item != null) { for (WatchableObject meta : packet.b) @@ -83,6 +84,15 @@ public class CustomItemFrames extends MiniPlugin implements IPacketHandler } } } + else if (packetInfo.getPacket() instanceof PacketPlayInUseEntity) + { + PacketPlayInUseEntity packet = (PacketPlayInUseEntity) packetInfo.getPacket(); + + if (_frameData.containsKey(packet.a)) + { + packetInfo.setCancelled(true); + } + } } public void setItem(Player player, ItemFrame frame, org.bukkit.inventory.ItemStack item) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java index 34680c21b..9999c3053 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java @@ -3,8 +3,12 @@ package mineplex.core.imagemap; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilServer; import mineplex.core.imagemap.objects.PlayerMapBoard; import mineplex.core.imagemap.objects.PlayerMapImage; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilScheduler; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -70,6 +74,17 @@ public class ImageMapManager extends MiniPlugin _boards.forEach(board -> board.getImages().forEach(image -> image.removeViewer(player))); } + @EventHandler + public void refreshBoards(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOWER) + { + return; + } + + _boards.forEach(PlayerMapBoard::onRefresh); + } + public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, String... images) { BufferedImage[] bufferedImages = new BufferedImage[images.length]; @@ -121,7 +136,7 @@ public class ImageMapManager extends MiniPlugin PlayerMapBoard board = new PlayerMapBoard(topLeft, mapImageList); - Bukkit.getOnlinePlayers().forEach(board::onPlayerJoin); + runSyncLater(() -> Bukkit.getOnlinePlayers().forEach(board::onPlayerJoin), 50); _boards.add(board); return board; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapBoardSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapBoardSelector.java index 2d2cc009c..c0a57e7c2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapBoardSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/MapBoardSelector.java @@ -60,6 +60,7 @@ public class MapBoardSelector implements Listener stand.setCustomNameVisible(true); stand.setVisible(false); stand.setGravity(false); + stand.setRemoveWhenFarAway(false); return stand; } @@ -75,6 +76,7 @@ public class MapBoardSelector implements Listener slime.setSize(5); slime.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false)); + slime.setRemoveWhenFarAway(false); return slime; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapBoard.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapBoard.java index 72a6f3a73..6316b8baa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapBoard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapBoard.java @@ -1,20 +1,28 @@ package mineplex.core.imagemap.objects; +import mineplex.core.common.util.UtilMath; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class PlayerMapBoard { + private static final int VIEW_DIST_SQUARED = 28 * 28; + private final Location _location; private final List _images; + private final Set _viewers; public PlayerMapBoard(Location location, List images) { _location = location; _images = images; + _viewers = new HashSet<>(); } public void goTo(Player player, boolean next) @@ -48,6 +56,18 @@ public class PlayerMapBoard _images.get(0).addViewer(player); } + public void onRefresh() + { + Bukkit.getOnlinePlayers().forEach(player -> + { + + if (UtilMath.offset2dSquared(player.getLocation(), _location) < VIEW_DIST_SQUARED) + { + _viewers.add(player); + } + }); + } + public Location getLocation() { return _location; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java new file mode 100644 index 000000000..5ec293f60 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java @@ -0,0 +1,27 @@ +package mineplex.core.stats.game; + +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.stats.StatsManager; + +import java.util.function.Consumer; + +@ReflectivelyCreateMiniPlugin +public class GameStatisticsManager extends MiniPlugin +{ + + private final StatsManager _statsManager; + + private GameStatisticsManager() + { + super("Game Statistics"); + + _statsManager = require(StatsManager.class); + } + + public void saveGameStats(Consumer callback, GameStats gameStats) + { + + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java new file mode 100644 index 000000000..5e8f6c14e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java @@ -0,0 +1,41 @@ +package mineplex.core.stats.game; + +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnLong; +import mineplex.serverdata.database.column.ColumnVarChar; + +public class GameStatisticsRepository extends RepositoryBase +{ + + private static final String SAVE_GAME = "INESRT INTO gameStatistics VALUES (gameType, map, startTime, endTime) (?,?,?,?)"; + private static final String SAVE_PLAYER_STAT = "INESRT INTO gamePlayerStatistics VALUES (?,?,?,?)"; + + public GameStatisticsRepository() + { + super(DBPool.getAccount()); + } + + public void saveGameStats(GameStats gameStats) + { + executeInsert(SAVE_GAME, resultSet -> + { + int gameId = resultSet.getInt(0); + + saveGamePlayerStatistics(gameId, gameStats); + }, + + new ColumnInt("gameType", gameStats.getGameType().getGameId()), + new ColumnVarChar("map", 16, gameStats.getMap()), + new ColumnLong("startTime", gameStats.getStartTime()), + new ColumnLong("endTime", gameStats.getEndTime()) + + ); + } + + private void saveGamePlayerStatistics(int gameId, GameStats gameStats) + { + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java new file mode 100644 index 000000000..8869742c8 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java @@ -0,0 +1,51 @@ +package mineplex.core.stats.game; + +import mineplex.core.game.GameDisplay; + +import java.util.HashMap; +import java.util.Map; + +public class GameStats +{ + + private final int _gameId; + private final GameDisplay _gameType; + + private String _map; + private long _startTime; + private long _endTime; + + private final Map _globalStats; + + public GameStats(int gameId, GameDisplay display) + { + _gameId = gameId; + _gameType = display; + _globalStats = new HashMap<>(); + } + + public int getGameId() + { + return _gameId; + } + + public GameDisplay getGameType() + { + return _gameType; + } + + public String getMap() + { + return _map; + } + + public long getStartTime() + { + return _startTime; + } + + public long getEndTime() + { + return _endTime; + } +} From 25d3c09329aea9eefaefd276802eff682640d72a Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 12 Jul 2017 23:33:45 +0100 Subject: [PATCH 074/183] Complete implementation of game stats --- .../stats/game/GameStatisticsManager.java | 37 ++++- .../stats/game/GameStatisticsRepository.java | 149 ++++++++++++++++-- .../mineplex/core/stats/game/GameStats.java | 40 ++++- .../arcade/game/games/moba/MobaClassic.java | 4 + .../game/modules/GameStatisticsModule.java | 67 ++++++++ 5 files changed, 278 insertions(+), 19 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/GameStatisticsModule.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java index 5ec293f60..fa0619e6d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java @@ -2,8 +2,13 @@ package mineplex.core.stats.game; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.common.timing.TimingManager; +import mineplex.core.game.GameDisplay; import mineplex.core.stats.StatsManager; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import java.util.function.Consumer; @ReflectivelyCreateMiniPlugin @@ -12,16 +17,46 @@ public class GameStatisticsManager extends MiniPlugin private final StatsManager _statsManager; + private final GameStatisticsRepository _repository; + + private final Map _gameMaps; + private GameStatisticsManager() { super("Game Statistics"); _statsManager = require(StatsManager.class); + _repository = new GameStatisticsRepository(_statsManager); + _gameMaps = Collections.synchronizedMap(new HashMap<>()); } - public void saveGameStats(Consumer callback, GameStats gameStats) + public void getMapId(Consumer callback, GameDisplay gameType, String mapName) { + if (_gameMaps.containsKey(mapName)) + { + if (callback != null) + { + callback.accept(_gameMaps.get(mapName)); + } + } + else + { + _repository.getMapId(mapId -> + { + _gameMaps.put(mapName, mapId); + callback.accept(mapId); + }, gameType.getGameId(), mapName); + } + } + public void saveGameStats(GameStats gameStats) + { + runAsync(() -> + { + TimingManager.start("Save Game Stats"); + _repository.saveGame(gameStats); + TimingManager.stop("Save Game Stats"); + }); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java index 5e8f6c14e..ee0a3e532 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java @@ -1,41 +1,166 @@ package mineplex.core.stats.game; +import mineplex.core.common.util.UtilTime; +import mineplex.core.game.GameDisplay; +import mineplex.core.stats.StatsManager; +import mineplex.serverdata.Region; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnInt; -import mineplex.serverdata.database.column.ColumnLong; +import mineplex.serverdata.database.column.ColumnTimestamp; import mineplex.serverdata.database.column.ColumnVarChar; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Consumer; + public class GameStatisticsRepository extends RepositoryBase { - private static final String SAVE_GAME = "INESRT INTO gameStatistics VALUES (gameType, map, startTime, endTime) (?,?,?,?)"; - private static final String SAVE_PLAYER_STAT = "INESRT INTO gamePlayerStatistics VALUES (?,?,?,?)"; + private static final String INSERT_MAP = "INSERT INTO gameMaps (gameType,mapName) VALUES (?,?)"; + private static final String GET_MAP_BY_ID = "SELECT * FROM gameMaps WHERE mapName=?"; + private static final String SAVE_GAME = "INSERT INTO gameStatistics (region,gameId,map,startTime,endTime) VALUES (?,?,?,?,?)"; + private static final String SAVE_STAT = "INSERT INTO gamePlayerStatistics VALUES (?,?,?,?);"; + private static final String GET_BY_ID = "SELECT * FROM gameStatistics WHERE gameId=?"; + private static final String SQL_REGEX = "\\?"; + private static final long MAX_RESPONSE_TIME = TimeUnit.SECONDS.toMillis(5); - public GameStatisticsRepository() + private final StatsManager _statsManager; + + public GameStatisticsRepository(StatsManager statsManager) { super(DBPool.getAccount()); + + _statsManager = statsManager; } - public void saveGameStats(GameStats gameStats) + public void getMapId(Consumer callback, int gameId, String mapName) + { + executeQuery(GET_MAP_BY_ID, resultSet -> + { + if (resultSet.next()) + { + callback.accept(resultSet.getInt(0)); + } + else + { + executeInsert(INSERT_MAP, resultSetInsert -> + { + if (resultSetInsert.next()) + { + callback.accept(resultSetInsert.getInt(1)); + } + }, + new ColumnInt("gameType", gameId), + new ColumnVarChar("mapName", 32, mapName) + ); + } + }, new ColumnVarChar("mapName", 32, mapName)); + } + + public void saveGame(GameStats gameStats) { executeInsert(SAVE_GAME, resultSet -> { - int gameId = resultSet.getInt(0); + if (resultSet.next()) + { + int gameId = resultSet.getInt(1); - saveGamePlayerStatistics(gameId, gameStats); + saveGameStats(gameId, gameStats); + } }, + new ColumnVarChar("region", 2, gameStats.getRegion().name()), new ColumnInt("gameType", gameStats.getGameType().getGameId()), - new ColumnVarChar("map", 16, gameStats.getMap()), - new ColumnLong("startTime", gameStats.getStartTime()), - new ColumnLong("endTime", gameStats.getEndTime()) + new ColumnInt("map", gameStats.getMapId()), + new ColumnTimestamp("startTime", new Timestamp(gameStats.getStartTime())), + new ColumnTimestamp("endTime", new Timestamp(gameStats.getEndTime())) - ); + ); } - private void saveGamePlayerStatistics(int gameId, GameStats gameStats) + private void saveGameStats(int gameId, GameStats gameStats) { + String gameIdString = String.valueOf(gameId); + Map> stats = gameStats.getStats(); + StringBuilder builder = new StringBuilder(1000); + long start = System.currentTimeMillis(); + AtomicInteger sqlAppends = new AtomicInteger(); + AtomicInteger expectedSqlAppends = new AtomicInteger(); + + stats.forEach((playerId, statsMap) -> expectedSqlAppends.getAndAdd(statsMap.size())); + + stats.forEach((playerId, statsMap) -> + { + String playerIdString = String.valueOf(playerId); + + statsMap.forEach((name, value) -> + { + _statsManager.loadStatId(name, statId -> + { + String statIdString = String.valueOf(statId); + String statValueString = String.valueOf(value); + + String sql = SAVE_STAT + .replaceFirst(SQL_REGEX, gameIdString) + .replaceFirst(SQL_REGEX, playerIdString) + .replaceFirst(SQL_REGEX, statIdString) + .replaceFirst(SQL_REGEX, statValueString); + + builder.append(sql); + sqlAppends.getAndIncrement(); + }); + }); + }); + + while (sqlAppends.get() < expectedSqlAppends.get()) + { + if (UtilTime.elapsed(start, MAX_RESPONSE_TIME)) + { + return; + } + + try + { + Thread.sleep(500); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + try ( + Connection connection = getConnection() + ) + { + PreparedStatement preparedStatement = connection.prepareStatement(builder.toString()); + + preparedStatement.executeUpdate(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + + public void getGameStats(Consumer callback, int gameId) + { + executeQuery(GET_BY_ID, resultSet -> + { + + if (resultSet.next()) + { + GameStats stats = new GameStats(gameId, Region.valueOf(resultSet.getString("region")), GameDisplay.getById(gameId)); + callback.accept(stats); + } + + }, new ColumnInt("gameId", gameId)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java index 8869742c8..5fe6bbfc4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java @@ -1,6 +1,7 @@ package mineplex.core.stats.game; import mineplex.core.game.GameDisplay; +import mineplex.serverdata.Region; import java.util.HashMap; import java.util.Map; @@ -9,19 +10,21 @@ public class GameStats { private final int _gameId; + private final Region _region; private final GameDisplay _gameType; - private String _map; + private int _mapId; private long _startTime; private long _endTime; - private final Map _globalStats; + private final Map> _stats; - public GameStats(int gameId, GameDisplay display) + public GameStats(int gameId, Region region, GameDisplay display) { _gameId = gameId; + _region = region; _gameType = display; - _globalStats = new HashMap<>(); + _stats = new HashMap<>(); } public int getGameId() @@ -29,14 +32,29 @@ public class GameStats return _gameId; } + public Region getRegion() + { + return _region; + } + public GameDisplay getGameType() { return _gameType; } - public String getMap() + public void setMapId(int mapId) { - return _map; + _mapId = mapId; + } + + public int getMapId() + { + return _mapId; + } + + public void setStartTime(long startTime) + { + _startTime = startTime; } public long getStartTime() @@ -44,8 +62,18 @@ public class GameStats return _startTime; } + public void setEndTime(long endTime) + { + _endTime = endTime; + } + public long getEndTime() { return _endTime; } + + public Map> getStats() + { + return _stats; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java index 8fa8ee3cb..3d1f9bb52 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java @@ -9,6 +9,7 @@ import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; import nautilus.game.arcade.game.modules.CustomScoreboardModule; +import nautilus.game.arcade.game.modules.GameStatisticsModule; import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.ChatColor; import org.bukkit.entity.LivingEntity; @@ -46,6 +47,9 @@ public class MobaClassic extends Moba registerManager(new PrepareManager(this)); registerManager(new PrepareSelection(this)); + new GameStatisticsModule() + .register(this); + new CustomScoreboardModule() .setSidebar((player, scoreboard) -> { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/GameStatisticsModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/GameStatisticsModule.java new file mode 100644 index 000000000..a024f3cfc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/GameStatisticsModule.java @@ -0,0 +1,67 @@ +package nautilus.game.arcade.game.modules; + +import mineplex.core.Managers; +import mineplex.core.common.util.UtilServer; +import mineplex.core.stats.game.GameStatisticsManager; +import mineplex.core.stats.game.GameStats; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import org.bukkit.event.EventHandler; + +import java.util.HashMap; +import java.util.Map; + +public class GameStatisticsModule extends Module +{ + + private static final GameStatisticsManager STATS_MANAGER; + + static + { + STATS_MANAGER = Managers.require(GameStatisticsManager.class); + } + + private GameStats _currentGame; + + @Override + protected void setup() + { + _currentGame = new GameStats(-1, UtilServer.getRegion(), getGame().GetType().getDisplay()); + Map dummy = new HashMap<>(); + dummy.put(getGame().GetName() + ".Kills", 1); + dummy.put(getGame().GetName() + ".Wins", 2); + _currentGame.getStats().put(1, dummy); + } + + @Override + public void cleanup() + { + if (getGame().getArcadeManager().IsRewardStats()) + { + STATS_MANAGER.saveGameStats(_currentGame); + } + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + STATS_MANAGER.getMapId(mapId -> _currentGame.setMapId(mapId), getGame().GetType().getDisplay(), getGame().WorldData.MapName); + _currentGame.setStartTime(System.currentTimeMillis()); + } + + @EventHandler + public void end(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + { + return; + } + + _currentGame.setEndTime(System.currentTimeMillis()); + } +} From c4508b653a1c879d0b4d0934b57516a4d43c6067 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 13 Jul 2017 00:16:40 +0100 Subject: [PATCH 075/183] Remove rank requirement for HOG --- .../game/arcade/game/games/moba/Moba.java | 47 +++++++------------ 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index add6d1f87..b51e5050c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,11 +1,9 @@ package nautilus.game.arcade.game.games.moba; import mineplex.core.Managers; -import mineplex.core.beta.BetaWhitelist; import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.util.F; -import mineplex.core.common.util.PlayerMap; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguiseBase; @@ -78,6 +76,17 @@ import java.util.Set; public class Moba extends TeamGame { + private static final String[] ITEM_IMAGES = { + "Anath_the_Burnt.png", + "Bardolf.png", + "Biff.png", + "Dana.png", + "Devon.png", + "Hattori.png", + "Larissa.png", + "Rowena.png" + }; + private final HeroKit[] _kits; protected final Set _playerData = new HashSet<>(); @@ -93,7 +102,6 @@ public class Moba extends TeamGame protected final CapturePointManager _capturePoint; protected final MinionManager _minion; private final ImageMapManager _mapManager = Managers.require(ImageMapManager.class); - private BetaWhitelist _betaWhitelist; private PlayerMapBoard _board; private MapBoardSelector _selector; @@ -141,17 +149,6 @@ public class Moba extends TeamGame // Beta Message registerManager(new BetaManager(this)); - // Beta Whitelist - _betaWhitelist = Managers.get(BetaWhitelist.class); - if (_betaWhitelist == null) - { - _betaWhitelist = new BetaWhitelist(manager.GetClients(), manager.getBonusManager().getPowerPlayClubRepository()); - } - else - { - _betaWhitelist.registerSelf(); - } - new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -242,18 +239,7 @@ public class Moba extends TeamGame leaderboard.registerLeaderboard("TOP_HOG_GOLD", new Leaderboard("Top Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.ALL, location, 10)); } - String[] files = { - "Anath_the_Burnt.png", - "Bardolf.png", - "Biff.png", - "Dana.png", - "Devon.png", - "Hattori.png", - "Larissa.png", - "Rowena.png" - }; - - _board = _mapManager.createPlayerBoard(lobbyCustomLocs.get("HERO_VIEWER").get(0).clone().add(0, 1, 0), BlockFace.EAST, 7, 4, files); + _board = _mapManager.createPlayerBoard(lobbyCustomLocs.get("HERO_VIEWER").get(0).clone().add(0, 1, 0), BlockFace.EAST, 7, 4, ITEM_IMAGES); _selector = new MapBoardSelector(_board); _selector.createHolograms(lobbyCustomLocs.get("HERO_VIEWER NEXT").get(0), lobbyCustomLocs.get("HERO_VIEWER BACK").get(0)); } @@ -277,6 +263,11 @@ public class Moba extends TeamGame _playerData.add(new MobaPlayer(player)); MobaUtil.setTeamEntity(player, GetTeam(player)); } + + // Cleanup tutorial boards + _mapManager.cleanupBoard(_board); + _selector.cleanup(); + } @EventHandler @@ -305,10 +296,6 @@ public class Moba extends TeamGame super.disable(); _listeners.forEach(UtilServer::Unregister); _listeners.clear(); - _betaWhitelist.deregisterSelf(); - - _mapManager.cleanupBoard(_board); - _selector.cleanup(); PlayerDisguiseManager playerDisguiseManager = Managers.require(PlayerDisguiseManager.class); From bfba119f3f6ad9b200d03431b6a24873bf9a5801 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 13 Jul 2017 00:16:50 +0100 Subject: [PATCH 076/183] Really hackily fix item maps --- .../core/imagemap/objects/PlayerMapImage.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapImage.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapImage.java index 6ee11f5cd..9d33e135e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapImage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapImage.java @@ -1,7 +1,7 @@ package mineplex.core.imagemap.objects; +import mineplex.core.common.util.UtilServer; import mineplex.core.imagemap.CustomItemFrames; -import mineplex.core.imagemap.objects.MapImage; import org.bukkit.World; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; @@ -48,15 +48,19 @@ public class PlayerMapImage extends MapImage public void addViewer(Player player) { - if (_viewers.contains(player)) + if (!_viewers.add(player)) { return; } - _viewers.add(player); + //FIXME + int slot = 8; + for (ItemStack itemStack : _itemMaps) + { + player.getInventory().setItem(slot++, itemStack); + } - player.getInventory().clear(); - player.getInventory().addItem(_itemMaps.toArray(new ItemStack[0])); + UtilServer.runSyncLater(() -> player.getInventory().removeItem(_itemMaps.toArray(new ItemStack[0])), 5); for (int i = 0; i < _itemMaps.size(); i++) { From 59af31c6f898d1b225ed8798ccfb33a3de95ed36 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 13 Jul 2017 00:18:45 +0100 Subject: [PATCH 077/183] Fix spectators being able to interact with hero selection --- .../arcade/game/games/moba/prepare/PrepareSelection.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index 4480e761f..c55dfba5f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.itemstack.ItemBuilder; @@ -193,6 +194,11 @@ public class PrepareSelection implements Listener, IPacketHandler Player player = packetInfo.getPlayer(); int entityId = packet.a; + if (UtilPlayer.isSpectator(player)) + { + return; + } + ClientArmorStand goBackStand = _goBackStands.get(player); if (goBackStand != null && goBackStand.getEntityId() == entityId) From c695bb570eb54f47c9e6a856874baf4dbb663e25 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 10 Jul 2017 03:53:51 -0400 Subject: [PATCH 078/183] Fix several thread-related issues in the leaderboard system --- .../core/leaderboard/Leaderboard.java | 28 +++-- .../core/leaderboard/LeaderboardManager.java | 2 +- .../leaderboard/LeaderboardRepository.java | 108 +++++++++--------- 3 files changed, 78 insertions(+), 60 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java index c90639b66..fd72e005b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java @@ -15,13 +15,13 @@ import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; public class Leaderboard { - private String _display; - private Pair _statDisplay; - private String[] _statNames; - private int[] _statIds; - private int _size, _start; - private LeaderboardSQLType _type; - private Location _loc; + private final String _display; + private final Pair _statDisplay; + private final String[] _statNames; + private final int[] _statIds; + private final int _size, _start; + private final LeaderboardSQLType _type; + private final Location _loc; private Hologram _holo; public Leaderboard(String display, Pair statDisplayNames, String[] statNames, LeaderboardSQLType type, Location displayLoc, int size) @@ -37,6 +37,7 @@ public class Leaderboard _statIds = new int[_statNames.length]; _type = type; _size = size; + _start = start; _loc = displayLoc; update(new LinkedHashMap<>()); @@ -52,12 +53,15 @@ public class Leaderboard return _start; } + /** + * The returned array is not safe for mutation + */ public String[] getStatNames() { return _statNames; } - public int[] getStatIds() + public synchronized int[] getStatIds() { return _statIds; } @@ -89,6 +93,14 @@ public class Leaderboard _holo = new Hologram(Managers.get(LeaderboardManager.class).getHologramManager(), _loc, display.toArray(new String[display.size()])).start(); } + public synchronized void setStatId(int index, int id) + { + if (_statIds.length > index && index >= 0) + { + _statIds[index] = id; + } + } + public void deconstruct() { if (_holo != null) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java index 88a84c29d..e2849a5d0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java @@ -120,7 +120,7 @@ public class LeaderboardManager extends MiniPlugin final int index = i; Managers.get(StatsManager.class).loadStatId(board.getStatNames()[index], id -> { - board.getStatIds()[index] = id.intValue(); + board.setStatId(index, id.intValue()); }); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index f9b286039..4ef0e86cf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -90,73 +90,79 @@ public class LeaderboardRepository extends RepositoryBase public void insertStats(int accountId, Map stats) { - try ( - Connection c = getConnection(); - PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT); - PreparedStatement insertStat = c.prepareStatement(INSERT_STAT); - ) + UtilServer.runAsync(() -> { - for (Integer statId : stats.keySet()) + try ( + Connection c = getConnection(); + PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT); + PreparedStatement insertStat = c.prepareStatement(INSERT_STAT); + ) { - updateStat.setLong(1, stats.get(statId)); - updateStat.setInt(2, accountId); - updateStat.setInt(3, statId); - updateStat.addBatch(); - } - int[] rowsAffected = updateStat.executeBatch(); - int i = 0; - for (Integer statId : stats.keySet()) - { - if (rowsAffected[i] < 1) + for (Integer statId : stats.keySet()) { - insertStat.setInt(1, accountId); - insertStat.setInt(2, statId); - insertStat.setLong(3, stats.get(statId)); - insertStat.addBatch(); + updateStat.setLong(1, stats.get(statId)); + updateStat.setInt(2, accountId); + updateStat.setInt(3, statId); + updateStat.addBatch(); } - i++; + int[] rowsAffected = updateStat.executeBatch(); + int i = 0; + for (Integer statId : stats.keySet()) + { + if (rowsAffected[i] < 1) + { + insertStat.setInt(1, accountId); + insertStat.setInt(2, statId); + insertStat.setLong(3, stats.get(statId)); + insertStat.addBatch(); + } + i++; + } + insertStat.executeBatch(); } - insertStat.executeBatch(); - } - catch (SQLException e) - { - e.printStackTrace(); - } + catch (SQLException e) + { + e.printStackTrace(); + } + }); } public void loadLeaderboard(Leaderboard board, Consumer> leaderboard) { - Map names = new LinkedHashMap<>(); - try ( - Connection c = getConnection(); - Statement s = c.createStatement(); - ) + UtilServer.runAsync(() -> { - s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize())); - for (int i = 0; i < board.getStatIds().length; i++) + Map names = new LinkedHashMap<>(); + try ( + Connection c = getConnection(); + Statement s = c.createStatement(); + ) { - try (ResultSet rs = s.getResultSet()) + s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize())); + for (int i = 0; i < board.getStatIds().length; i++) { - while (rs.next()) + try (ResultSet rs = s.getResultSet()) { - names.merge(rs.getString("name"), rs.getInt("value"), Integer::sum); - } - - if (!s.getMoreResults()) - { - break; + while (rs.next()) + { + names.merge(rs.getString("name"), rs.getInt("value"), Integer::sum); + } + + if (!s.getMoreResults()) + { + break; + } } } } - } - catch (SQLException ex) - { - ex.printStackTrace(); - } - finally - { - UtilServer.runSync(() -> leaderboard.accept(names)); - } + catch (SQLException ex) + { + ex.printStackTrace(); + } + finally + { + UtilServer.runSync(() -> leaderboard.accept(names)); + } + }); } @SuppressWarnings("unchecked") From 8a18be0c5c96688122340bc6d9f3da74cbe0ea02 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 12 Jul 2017 00:41:47 +0100 Subject: [PATCH 079/183] Shorten and fix a typo in the senior moderator title --- .../core/titles/tracks/staff/SeniorModeratorTrack.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java index 5001c38c3..3521e362d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java @@ -18,10 +18,10 @@ public class SeniorModeratorTrack extends ItemizedTrack public SeniorModeratorTrack() { - super("staff-srmod", ChatColor.GOLD, "Sr.Mod", "I my team is the best team", "Team loyalty at its finest", true); + super("staff-srmod", ChatColor.GOLD, "Sr.Mod", "My Team's the Best Team", "Team loyalty at its finest", true); getRequirements() .addTier(new TrackTier( - "I think my team is the best team", + "My Team's the Best Team", null, this::owns, new TrackFormat(ChatColor.GOLD, ChatColor.GOLD) From d15063a0659b51d9a08f0619395f8f7f59097b91 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 12 Jul 2017 01:20:13 +0100 Subject: [PATCH 080/183] Fix "serverName" is restarting --- Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 68a0c10c1..062a529d3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -132,7 +132,7 @@ public class Portal extends MiniPlugin { if (server.getGroup().equalsIgnoreCase("Clans") && server.getMotd().equalsIgnoreCase("Restarting soon")) { - UtilPlayer.message(player, F.main(getName(), C.cGold + "serverName" + C.cRed + " is restarting!")); + UtilPlayer.message(player, F.main(getName(), C.cGold + serverName + C.cRed + " is restarting!")); return; } if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.has(Rank.ULTRA)) From 035c5e9011977ee42694d6e61953ef17423e2041 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 12 Jul 2017 17:00:20 +0100 Subject: [PATCH 081/183] Fix a typo --- .../src/mineplex/core/achievement/AchievementCategory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 885bf7939..ae6a80c2d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -43,7 +43,7 @@ public enum AchievementCategory StatDisplay.fromGame("Wins", GameDisplay.SkywarsTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SkywarsTeams, "Wins", "Losses"), StatDisplay.fromGame("Kills", GameDisplay.SkywarsTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SkywarsTeams, "Deaths"), StatDisplay.fromGame("Gems Earned", GameDisplay.SkywarsTeams, "GemsEarned") }, - Material.FEATHER, 0, GameCategory.SURVIVAL, "Destructor Kit", false, GameDisplay.Skywars.getGameId(), GameDisplay.SkywarsTeams.getGameId()), + Material.FEATHER, 0, GameCategory.SURVIVAL, "Earth Kit", false, GameDisplay.Skywars.getGameId(), GameDisplay.SkywarsTeams.getGameId()), UHC("Ultra Hardcore", null, new StatDisplay[] { From 5cac083941f2cee396fc6243da214083e5d5b642 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Wed, 12 Jul 2017 23:06:13 -0400 Subject: [PATCH 082/183] Add command to get versions, spawn wither skeletons with /mob --- .../core/creature/command/MobCommand.java | 13 ++++ .../src/mineplex/core/monitor/LagMeter.java | 6 ++ .../core/monitor/VersionsCommand.java | 74 +++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java index 33e0ed950..6b9e16de1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java @@ -250,6 +250,19 @@ public class MobCommand extends MultiCommandBase } argHandle.add(arg); } + + else if (arg.equalsIgnoreCase("wither")) + { + for (Entity ent : entSet) + { + if (ent instanceof Skeleton) + { + ((Skeleton) ent).setSkeletonType(SkeletonType.WITHER); + } + } + + argHandle.add(arg); + } } for (String arg : argHandle) argSet.remove(arg); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java index e34150584..4a89c9d7d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java @@ -42,6 +42,12 @@ public class LagMeter extends MiniPlugin _start = System.currentTimeMillis(); } + @Override + public void addCommands() + { + addCommand(new VersionsCommand(this)); + } + @EventHandler public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java new file mode 100644 index 000000000..ef2bdab58 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java @@ -0,0 +1,74 @@ +package mineplex.core.monitor; + +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.print.attribute.IntegerSyntax; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; + +/** + * Statistics on versions + * @author Dan + */ +public class VersionsCommand extends CommandBase +{ + public VersionsCommand(LagMeter plugin) + { + super(plugin, Rank.DEVELOPER, "versions", "getver"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length == 0) + { + Map versions = new HashMap<>(); + for (Player player : Bukkit.getOnlinePlayers()) + { + int version = ((CraftPlayer) player).getHandle().getProtocol(); + int players = versions.getOrDefault(version, 0); + versions.put(version, players + 1); + } + + UtilPlayer.message(caller, F.main("Version", "Distribution on " + C.cGold + + UtilServer.getServerName())); + + List> sorted = versions + .entrySet().stream() + .sorted(Comparator.comparing(Map.Entry::getValue, (i1, i2) -> -i1.compareTo(i2))) + .collect(Collectors.toList()); + for (Map.Entry entry : sorted) + { + UtilPlayer.message(caller, + F.main("Version", C.cYellow + entry.getKey() + C.cGray + ": " + C.cGreen + + entry.getValue() + C.cGray + " players")); + } + } else if (args.length == 1) + { + List players = UtilPlayer.matchOnline(caller, args[0], true); + if (!players.isEmpty()) + { + Player player = players.get(0); + UtilPlayer.message(caller, + F.main("Version", C.cYellow + player.getName() + C.cGray + " is on protocol " + + C.cGreen + ((CraftPlayer) player).getHandle().getProtocol())); + } + } else + { + UtilPlayer.message(caller, F.main("Version", "Invalid argument list.")); + } + } +} From e7772938664326fda2337edd7e456d65fcc54959 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 13 Jul 2017 15:38:56 +0100 Subject: [PATCH 083/183] Add achievements --- .../core/achievement/Achievement.java | 57 +++- .../core/achievement/AchievementCategory.java | 2 +- .../stats/game/GameStatisticsManager.java | 15 +- .../stats/game/GameStatisticsRepository.java | 6 +- .../game/arcade/game/games/moba/Moba.java | 10 +- .../arcade/game/games/moba/MobaClassic.java | 4 + .../game/arcade/game/games/moba/MobaRole.java | 18 +- .../games/moba/prepare/PrepareSelection.java | 14 +- .../moba/progression/MobaProgression.java | 251 ++++++++++++++++++ .../moba/progression/ui/MobaRolePage.java | 42 +++ .../moba/progression/ui/MobaRoleShop.java | 28 ++ .../arcade/game/games/moba/util/MobaUtil.java | 38 ++- 12 files changed, 457 insertions(+), 28 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRoleShop.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 90872f27c..13e038ce0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -1225,7 +1225,62 @@ public enum Achievement new String[]{"Gem Hunters.ChestsOpened"}, new String[]{"+1 for each chest opened"}, new int[]{50,100,200,400,1000}, - AchievementCategory.GEM_HUNTERS); + AchievementCategory.GEM_HUNTERS), + + MOBA_GOLD_EARNED("Gold Farmer", 0, + new String[]{"Heroes of GWEN.GoldEarned"}, + new String[]{"Earn Gold"}, + new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}}, + new int[]{10000,50000,100000,250000,500000}, + "I", + new String[] {"II","III","IV","V","X"}, + AchievementCategory.MOBA), + + MOBA_KILLS("Champion Slayer", 0, + new String[]{"Heroes of GWEN.Kills"}, + new String[]{"Kill players"}, + new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}}, + new int[]{100,250,500,1000,5000}, + "I", + new String[] {"II","III","IV","V","X"}, + AchievementCategory.MOBA), + + MOBA_WINS_ASSASSIN("Assassin Victor", 0, + new String[]{"Heroes of GWEN.Assassin.Wins"}, + new String[]{"Win Games as an Assassin"}, + new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}}, + new int[]{10,50,100,250,500}, + "I", + new String[] {"II","III","IV","V","X"}, + AchievementCategory.MOBA), + + MOBA_WINS_HUNTER("Hunter Victor", 0, + new String[]{"Heroes of GWEN.Hunter.Wins"}, + new String[]{"Win Games as a Hunter"}, + new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}}, + new int[]{10,50,100,250,500}, + "I", + new String[] {"II","III","IV","V","X"}, + AchievementCategory.MOBA), + + MOBA_WINS_MAGE("Mage Victor", 0, + new String[]{"Heroes of GWEN.Mage.Wins"}, + new String[]{"Win Games as a Mage"}, + new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}}, + new int[]{10,50,100,250,500}, + "I", + new String[] {"II","III","IV","V","X"}, + AchievementCategory.MOBA), + + MOBA_WINS_WARRIOR("Warrior Victor", 0, + new String[]{"Heroes of GWEN.Warrior.Wins"}, + new String[]{"Win Games as a Warrior"}, + new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}}, + new int[]{10,50,100,250,500}, + "I", + new String[] {"II","III","IV","V","X"}, + AchievementCategory.MOBA), + ; private String _name; private String[] _desc; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 885bf7939..b448cd365 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -220,7 +220,7 @@ public enum AchievementCategory Material.EMERALD, 0, GameCategory.SURVIVAL, null, false, GameDisplay.GemHunters.getGameId()), MOBA("Heroes of GWEN", null, - new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, StatDisplay.fromGame("Gold Earned", GameDisplay.MOBA, "GoldEarned")}, + new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED, null, StatDisplay.fromGame("Gold Earned", GameDisplay.MOBA, "GoldEarned")}, Material.PRISMARINE_SHARD, 0, GameCategory.CLASSICS, null, false, GameDisplay.MOBA.getGameId()); private String _name; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java index fa0619e6d..d3ae17479 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsManager.java @@ -41,11 +41,16 @@ public class GameStatisticsManager extends MiniPlugin } else { - _repository.getMapId(mapId -> - { - _gameMaps.put(mapName, mapId); - callback.accept(mapId); - }, gameType.getGameId(), mapName); + runAsync(() -> + _repository.getMapId(mapId -> + { + _gameMaps.put(mapName, mapId); + + if (callback != null) + { + runSync(() -> callback.accept(mapId)); + } + }, gameType.getGameId(), mapName)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java index ee0a3e532..0d504478d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java @@ -23,8 +23,8 @@ public class GameStatisticsRepository extends RepositoryBase { private static final String INSERT_MAP = "INSERT INTO gameMaps (gameType,mapName) VALUES (?,?)"; - private static final String GET_MAP_BY_ID = "SELECT * FROM gameMaps WHERE mapName=?"; - private static final String SAVE_GAME = "INSERT INTO gameStatistics (region,gameId,map,startTime,endTime) VALUES (?,?,?,?,?)"; + private static final String GET_MAP_BY_ID = "SELECT mapId FROM gameMaps WHERE mapName=?"; + private static final String SAVE_GAME = "INSERT INTO gameStatistics (region,gameType,map,startTime,endTime) VALUES (?,?,?,?,?)"; private static final String SAVE_STAT = "INSERT INTO gamePlayerStatistics VALUES (?,?,?,?);"; private static final String GET_BY_ID = "SELECT * FROM gameStatistics WHERE gameId=?"; private static final String SQL_REGEX = "\\?"; @@ -45,7 +45,7 @@ public class GameStatisticsRepository extends RepositoryBase { if (resultSet.next()) { - callback.accept(resultSet.getInt(0)); + callback.accept(resultSet.getInt(1)); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index b51e5050c..21aa9a064 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -15,6 +15,7 @@ import mineplex.core.imagemap.objects.PlayerMapBoard; import mineplex.core.leaderboard.Leaderboard; import mineplex.core.leaderboard.LeaderboardManager; import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; +import mineplex.core.stats.event.StatChangeEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; @@ -45,6 +46,7 @@ import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa; import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena; import nautilus.game.arcade.game.games.moba.minion.MinionManager; import nautilus.game.arcade.game.games.moba.overtime.OvertimeManager; +import nautilus.game.arcade.game.games.moba.progression.MobaProgression; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; @@ -101,6 +103,7 @@ public class Moba extends TeamGame protected final TowerManager _tower; protected final CapturePointManager _capturePoint; protected final MinionManager _minion; + private final MobaProgression _progression; private final ImageMapManager _mapManager = Managers.require(ImageMapManager.class); private PlayerMapBoard _board; private MapBoardSelector _selector; @@ -137,6 +140,7 @@ public class Moba extends TeamGame _buffs = registerManager(new BuffManager()); _arrowKb = registerManager(new ArrowKBManager(this)); _minion = registerManager(new MinionManager(this)); + _progression = registerManager(new MobaProgression(this)); registerManager(new HPManager(this)); registerManager(new MobaDamageManager(this)); registerManager(new MobaFountain(this)); @@ -239,7 +243,9 @@ public class Moba extends TeamGame leaderboard.registerLeaderboard("TOP_HOG_GOLD", new Leaderboard("Top Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.ALL, location, 10)); } - _board = _mapManager.createPlayerBoard(lobbyCustomLocs.get("HERO_VIEWER").get(0).clone().add(0, 1, 0), BlockFace.EAST, 7, 4, ITEM_IMAGES); + _progression.spawnRoleViewers(lobbyCustomLocs); + + _board = _mapManager.createPlayerBoard(lobbyCustomLocs.get("HERO_VIEWER").get(0), BlockFace.EAST, 7, 4, ITEM_IMAGES); _selector = new MapBoardSelector(_board); _selector.createHolograms(lobbyCustomLocs.get("HERO_VIEWER NEXT").get(0), lobbyCustomLocs.get("HERO_VIEWER BACK").get(0)); } @@ -267,7 +273,7 @@ public class Moba extends TeamGame // Cleanup tutorial boards _mapManager.cleanupBoard(_board); _selector.cleanup(); - + _progression.removeRoleViewers(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java index 3d1f9bb52..ab2750c01 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java @@ -254,11 +254,15 @@ public class MobaClassic extends Moba for (Player player : otherTeam.GetPlayers(true)) { + MobaPlayer mobaPlayer = getMobaData(player); + + AddStat(player, mobaPlayer.getRole().getName() + ".Wins", 1, true, false); AddGems(player, 20, "Winning", false, false); } AnnounceEnd(otherTeam); SetState(GameState.End); + return; } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index dd09209b9..fd4b64d91 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,26 +1,29 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.common.skin.SkinData; import org.bukkit.ChatColor; import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", Color.GRAY, ChatColor.GRAY), - HUNTER("Hunter", Color.LIME, ChatColor.GREEN), - MAGE("Mage", Color.PURPLE, ChatColor.DARK_PURPLE), - WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD), + ASSASSIN("Assassin", Color.GRAY, ChatColor.GRAY, SkinData.HATTORI), + HUNTER("Hunter", Color.LIME, ChatColor.GREEN, SkinData.DEVON), + MAGE("Mage", Color.PURPLE, ChatColor.DARK_PURPLE, SkinData.ANATH), + WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD, SkinData.DANA), ; private final String _name; private final Color _color; private final ChatColor _chatColor; + private final SkinData _skinData; - MobaRole(String name, Color color, ChatColor chatColor) + MobaRole(String name, Color color, ChatColor chatColor, SkinData skinData) { _name = name; _color = color; _chatColor = chatColor; + _skinData = skinData; } public String getName() @@ -37,4 +40,9 @@ public enum MobaRole { return _chatColor; } + + public SkinData getSkin() + { + return _skinData; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index c55dfba5f..938d03258 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -43,6 +43,11 @@ import java.util.concurrent.atomic.AtomicInteger; public class PrepareSelection implements Listener, IPacketHandler { + public static ItemStack buildColouredStack(Material material, MobaRole role) + { + return new ItemBuilder(material).setColor(role.getColor()).build(); + } + private final Moba _host; private final Map _roleStands = new HashMap<>(); private final Map _kitStands = new HashMap<>(); @@ -76,8 +81,6 @@ public class PrepareSelection implements Listener, IPacketHandler Location average = UtilAlg.getAverageLocation(team.GetSpawns()); Player[] players = team.GetPlayers(true).toArray(new Player[0]); - ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 3).build(); - UtilServer.runSyncLater(() -> { for (Player player : team.GetPlayers(true)) @@ -99,7 +102,7 @@ public class PrepareSelection implements Listener, IPacketHandler stand.setCustomNameVisible(true); stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + C.cGreenB + "AVAILABLE"); stand.setArms(true); - stand.setHelmet(head); + stand.setHelmet(role.getSkin().getSkull()); stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); @@ -176,11 +179,6 @@ public class PrepareSelection implements Listener, IPacketHandler return location.clone().add(0, 1, 0); } - private ItemStack buildColouredStack(Material material, MobaRole role) - { - return new ItemBuilder(material).setColor(role.getColor()).build(); - } - private void removePodiums() { _host.getLocationStartsWith("KIT").forEach((key, location) -> location.getBlock().setType(Material.AIR)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java new file mode 100644 index 000000000..86dde7520 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java @@ -0,0 +1,251 @@ +package nautilus.game.arcade.game.games.moba.progression; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilServer; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeFormat; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.DebugCommand; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GemData; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaPlayer; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; +import nautilus.game.arcade.game.games.moba.progression.ui.MobaRoleShop; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; + +import java.text.DecimalFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +public class MobaProgression implements Listener +{ + + private static final int[] EXP_LEVELS; + private static final DecimalFormat FORMAT = new DecimalFormat("0.0"); + + static + { + EXP_LEVELS = new int[100]; + int expRequired = 0; + + for (int level = 0; level < 10; level++) + { + EXP_LEVELS[level] = expRequired += 2000; + } + + for (int level = 10; level < 20; level++) + { + EXP_LEVELS[level] = expRequired += 4000; + } + + for (int level = 20; level < 40; level++) + { + EXP_LEVELS[level] = expRequired += 8000; + } + + for (int level = 40; level < 60; level++) + { + EXP_LEVELS[level] = expRequired += 16000; + } + + for (int level = 60; level < 80; level++) + { + EXP_LEVELS[level] = expRequired += 32000; + } + + for (int level = 80; level < 100; level++) + { + EXP_LEVELS[level] = expRequired += 64000; + } + } + + private final Moba _host; + private final Map _roleViewers; + private final MobaRoleShop _roleShop; + + public MobaProgression(Moba host) + { + _host = host; + _roleViewers = new HashMap<>(); + _roleShop = new MobaRoleShop(host.getArcadeManager()); + + host.registerDebugCommand(new DebugCommand("fakeexp", Rank.DEVELOPER) + { + @Override + public void Execute(Player caller, String[] args) + { + int exp = Integer.parseInt(args[0]); + _host.GetGems(caller).put("Fake Exp", new GemData(exp, false)); + caller.sendMessage(F.main("Debug", "Gave you " + F.elem(exp) + " fake exp.")); + } + }); + } + + public void spawnRoleViewers(Map> lobbyLocations) + { + Location center = lobbyLocations.get("SPAWN").get(0); + + for (MobaRole role : MobaRole.values()) + { + List locations = lobbyLocations.get(role.name()); + + if (locations == null || locations.isEmpty()) + { + continue; + } + + Location location = locations.get(0).clone(); + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, center))); + + ArmorStand stand = location.getWorld().spawn(location, ArmorStand.class); + + UtilEnt.vegetate(stand); + UtilEnt.ghost(stand, true, false); + + stand.setCustomName(C.cGreenB + role.getName()); + stand.setCustomNameVisible(true); + stand.setArms(true); + stand.setBasePlate(false); + stand.setHelmet(role.getSkin().getSkull()); + stand.setChestplate(PrepareSelection.buildColouredStack(Material.LEATHER_CHESTPLATE, role)); + stand.setLeggings(PrepareSelection.buildColouredStack(Material.LEATHER_LEGGINGS, role)); + stand.setBoots(PrepareSelection.buildColouredStack(Material.LEATHER_BOOTS, role)); + + _roleViewers.put(stand, role); + } + } + + public void removeRoleViewers() + { + for (ArmorStand stand : _roleViewers.keySet()) + { + stand.remove(); + } + + _roleViewers.clear(); + } + + @EventHandler + public void onClick(CustomDamageEvent event) + { + onClick(event.GetDamagerEntity(true), event.GetDamageeEntity()); + } + + @EventHandler + public void onClick(PlayerInteractAtEntityEvent event) + { + onClick(event.getPlayer(), event.getRightClicked()); + } + + private void onClick(Entity clicker, Entity clicked) + { + if (clicker == null || !(clicker instanceof Player) || !_roleViewers.containsKey(clicked)) + { + return; + } + + Player player = (Player) clicker; + MobaRole role = _roleViewers.get(clicked); + + if (role == null) + { + return; + } + + _roleShop.openShop(player, role); + } + + @EventHandler + public void end(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End || !_host.getArcadeManager().IsRewardStats()) + { + return; + } + + _host.GetPlayers(true).forEach(this::rewardPlayer); + } + + private int getLevel(long exp) + { + int i = 0; + + for (int expRequired : EXP_LEVELS) + { + i++; + if (expRequired > exp) + { + return i; + } + } + + return 1; + } + + private void rewardPlayer(Player player) + { + MobaPlayer mobaPlayer = _host.getMobaData(player); + MobaRole role = mobaPlayer.getRole(); + String stat = _host.GetName() + "." + role.getName() + "." + "ExpEarned"; + long currentExp = _host.getArcadeManager().GetStatsManager().Get(player).getStat(stat); + AtomicInteger earnedExp = new AtomicInteger(); + + for (GemData data : _host.GetGems(player).values()) + { + earnedExp.getAndAdd((int) data.Gems); + } + + int level = getLevel(currentExp); + int newLevel = getLevel(currentExp + earnedExp.get()); + int expForThisLevel = EXP_LEVELS[level - 1]; + AtomicBoolean levelUp = new AtomicBoolean(); + + if (newLevel > level) + { + levelUp.set(true); + } + + _host.getArcadeManager().GetStatsManager().incrementStat(player, stat, earnedExp.get()); + + UtilServer.runSyncLater(() -> + { + player.sendMessage(ArcadeFormat.Line); + player.sendMessage(""); + + player.sendMessage(" " + role.getChatColor() + C.Bold + role.getName() + " Progression" + (levelUp.get() ? C.cGreenB + " LEVEL UP" : "")); + player.sendMessage(""); + player.sendMessage(MobaUtil.getProgressBar(currentExp, currentExp + earnedExp.get(), expForThisLevel, 100) + " " + C.cGray + "+" + C.cGreen + earnedExp + C.cGray + "/" + C.cAqua + expForThisLevel); + player.sendMessage(C.cGreen + FORMAT.format((currentExp + earnedExp.get()) / (double) expForThisLevel * 100D) + C.cWhite + "% complete for Level " + level); + + player.sendMessage(""); + player.sendMessage(ArcadeFormat.Line); + + if (levelUp.get()) + { + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1); + } + else + { + player.playSound(player.getLocation(), Sound.CLICK, 1, 1); + } + }, 60); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java new file mode 100644 index 000000000..c383b126e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java @@ -0,0 +1,42 @@ +package nautilus.game.arcade.game.games.moba.progression.ui; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.UtilUI; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import org.bukkit.entity.Player; + +public class MobaRolePage extends ShopPageBase +{ + + private static final int SIZE = 45; + private static final int[] MAPPINGS = UtilUI.getIndicesFor(4, 3); + + private final MobaRole _role; + + public MobaRolePage(ArcadeManager plugin, MobaRoleShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, MobaRole role) + { + super(plugin, shop, clientManager, donationManager, role.getName(), player, SIZE); + + _role = role; + + buildPage(); + } + + @Override + protected void buildPage() + { + addButtonNoAction(13, new ItemBuilder(_role.getSkin().getSkull()) + .setTitle(_role.getChatColor() + _role.getName()) + .addLore("", "Every 10 levels you unlock a new", "hero within the " + _role.getName() + " category.") + .build()); + +// for (int slot : MAPPINGS) +// { +// addButton(slot, ); +// } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRoleShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRoleShop.java new file mode 100644 index 000000000..f7a76b1d1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRoleShop.java @@ -0,0 +1,28 @@ +package nautilus.game.arcade.game.games.moba.progression.ui; + +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import org.bukkit.entity.Player; + +public class MobaRoleShop extends ShopBase +{ + + + public MobaRoleShop(ArcadeManager plugin) + { + super(plugin, plugin.GetClients(), plugin.GetDonation(), "Moba Heroes"); + } + + public void openShop(Player player, MobaRole role) + { + openPageForPlayer(player, new MobaRolePage(getPlugin(), this, getClientManager(), getDonationManager(), player, role)); + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return null; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 76721ad08..8483e03b7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -137,16 +137,21 @@ public class MobaUtil } public static String getHealthBar(LivingEntity entity, double newHealth, int bars) + { + return getProgressBar(newHealth, entity.getMaxHealth(), bars); + } + + public static String getProgressBar(double value, double max, int bars) { StringBuilder out = new StringBuilder(); - double health = newHealth / entity.getMaxHealth(); - String colour = getColour(health); + double progress = value / max; + String colour = getColour(progress); for (int i = 0; i < bars; i++) { double cur = i * (1D / (double) bars); - if (cur < health) + if (cur < progress) { out.append(colour).append("|"); } @@ -159,6 +164,33 @@ public class MobaUtil return out.toString(); } + public static String getProgressBar(double valueA, double valueB, double max, int bars) + { + StringBuilder out = new StringBuilder(); + double progressA = valueA / max; + double progressB = valueB / max; + + for (int i = 0; i < bars; i++) + { + double cur = i * (1D / (double) bars); + + if (cur < progressA) + { + out.append(C.cAqua).append("|"); + } + else if (cur < progressB) + { + out.append(C.cGreen).append("|"); + } + else + { + out.append(C.cGrayB).append("|"); + } + } + + return out.toString(); + } + public static String getColour(double percentage) { if (percentage < 0.25) From da08868206677a3e198725fc62aed4936b50cc20 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 13 Jul 2017 18:02:39 -0700 Subject: [PATCH 084/183] Fix ClassCastException in HitQuestTracker --- .../src/nautilus/game/arcade/quest/HitQuestTracker.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java index 71070aaf1..665657a3d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java @@ -1,13 +1,10 @@ package nautilus.game.arcade.quest; -import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import mineplex.core.common.util.UtilItem; import mineplex.core.quests.TriggerType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -31,14 +28,14 @@ public class HitQuestTracker extends QuestTracker { if (!getGame().IsLive()) return; - - if (!(event.getEntity() instanceof Player)) + + if (!(event.getDamager() instanceof Player) || !(event.getEntity() instanceof Item)) return; Item itemEntity = (Item) event.getEntity(); String item = itemEntity.getItemStack().getType().toString(); - + incrementQuests((Player) event.getDamager(), 1, "Player", item, getGame().GetKit((Player) event.getDamager()).GetName() + "Kit"); } From aa69b75be0310fdd8b598555adc55b46ad651651 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 14 Jul 2017 02:04:29 +0100 Subject: [PATCH 085/183] Final push --- .../core/achievement/Achievement.java | 2 +- .../core/imagemap/ImageMapManager.java | 20 ++ .../core/monitor/VersionsCommand.java | 74 +++---- .../stats/game/GameStatisticsRepository.java | 2 +- .../mineplex/core/stats/game/GameStats.java | 9 +- .../game/arcade/game/games/moba/Moba.java | 30 ++- .../arcade/game/games/moba/MobaClassic.java | 4 +- .../arcade/game/games/moba/kit/HeroKit.java | 26 ++- .../games/moba/kit/bardolf/HeroBardolf.java | 2 +- .../game/games/moba/kit/biff/HeroBiff.java | 2 +- .../game/games/moba/kit/dana/SkillRally.java | 2 +- .../games/moba/kit/larissa/HeroLarissa.java | 2 +- .../games/moba/kit/rowena/HeroRowena.java | 2 +- .../games/moba/prepare/PrepareSelection.java | 9 +- .../moba/progression/MobaProgression.java | 112 ++++++++--- .../moba/progression/MobaUnlockAnimation.java | 188 ++++++++++++++++++ .../moba/progression/ui/MobaRolePage.java | 130 +++++++++++- .../moba/progression/ui/MobaRoleShop.java | 4 +- .../games/moba/structure/tower/Tower.java | 4 +- .../game/modules/GameStatisticsModule.java | 45 ++++- 20 files changed, 564 insertions(+), 105 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaUnlockAnimation.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 13e038ce0..33bb61aff 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -1231,7 +1231,7 @@ public enum Achievement new String[]{"Heroes of GWEN.GoldEarned"}, new String[]{"Earn Gold"}, new int[][] {new int[] {0,0,1000}, new int[] {0,0,5000}, new int[]{0,0,10000}, new int[]{0,0,25000}, new int[]{0,0,50000}}, - new int[]{10000,50000,100000,250000,500000}, + new int[]{100000,500000,1000000,2500000,5000000}, "I", new String[] {"II","III","IV","V","X"}, AchievementCategory.MOBA), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java index 9999c3053..a85a0898a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java @@ -2,6 +2,7 @@ package mineplex.core.imagemap; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.common.util.FileUtil; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilServer; import mineplex.core.imagemap.objects.PlayerMapBoard; @@ -12,6 +13,7 @@ import mineplex.core.utils.UtilScheduler; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; @@ -236,6 +238,24 @@ public class ImageMapManager extends MiniPlugin { _boards.remove(board); + //TODO Fix when multiple boards are needed at one time + File dataDir = new File(board.getLocation().getWorld().getName() + File.separator + "data"); + if (dataDir.isDirectory()) + { + File[] files = dataDir.listFiles(); + + if (files != null) + { + for (File file : files) + { + if (file.getName().startsWith("map")) + { + file.delete(); + } + } + } + } + board.getImages().forEach(image -> { image.getViewers().clear(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java index ef2bdab58..232bbfaca 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java @@ -33,42 +33,42 @@ public class VersionsCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args.length == 0) - { - Map versions = new HashMap<>(); - for (Player player : Bukkit.getOnlinePlayers()) - { - int version = ((CraftPlayer) player).getHandle().getProtocol(); - int players = versions.getOrDefault(version, 0); - versions.put(version, players + 1); - } - - UtilPlayer.message(caller, F.main("Version", "Distribution on " + C.cGold - + UtilServer.getServerName())); - - List> sorted = versions - .entrySet().stream() - .sorted(Comparator.comparing(Map.Entry::getValue, (i1, i2) -> -i1.compareTo(i2))) - .collect(Collectors.toList()); - for (Map.Entry entry : sorted) - { - UtilPlayer.message(caller, - F.main("Version", C.cYellow + entry.getKey() + C.cGray + ": " + C.cGreen - + entry.getValue() + C.cGray + " players")); - } - } else if (args.length == 1) - { - List players = UtilPlayer.matchOnline(caller, args[0], true); - if (!players.isEmpty()) - { - Player player = players.get(0); - UtilPlayer.message(caller, - F.main("Version", C.cYellow + player.getName() + C.cGray + " is on protocol " - + C.cGreen + ((CraftPlayer) player).getHandle().getProtocol())); - } - } else - { - UtilPlayer.message(caller, F.main("Version", "Invalid argument list.")); - } +// if (args.length == 0) +// { +// Map versions = new HashMap<>(); +// for (Player player : Bukkit.getOnlinePlayers()) +// { +// int version = ((CraftPlayer) player).getHandle().getProtocol(); +// int players = versions.getOrDefault(version, 0); +// versions.put(version, players + 1); +// } +// +// UtilPlayer.message(caller, F.main("Version", "Distribution on " + C.cGold +// + UtilServer.getServerName())); +// +// List> sorted = versions +// .entrySet().stream() +// .sorted(Comparator.comparing(Map.Entry::getValue, (i1, i2) -> -i1.compareTo(i2))) +// .collect(Collectors.toList()); +// for (Map.Entry entry : sorted) +// { +// UtilPlayer.message(caller, +// F.main("Version", C.cYellow + entry.getKey() + C.cGray + ": " + C.cGreen +// + entry.getValue() + C.cGray + " players")); +// } +// } else if (args.length == 1) +// { +// List players = UtilPlayer.matchOnline(caller, args[0], true); +// if (!players.isEmpty()) +// { +// Player player = players.get(0); +// UtilPlayer.message(caller, +// F.main("Version", C.cYellow + player.getName() + C.cGray + " is on protocol " +// + C.cGreen + ((CraftPlayer) player).getHandle().getProtocol())); +// } +// } else +// { +// UtilPlayer.message(caller, F.main("Version", "Invalid argument list.")); +// } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java index 0d504478d..162717f55 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStatisticsRepository.java @@ -87,7 +87,7 @@ public class GameStatisticsRepository extends RepositoryBase private void saveGameStats(int gameId, GameStats gameStats) { String gameIdString = String.valueOf(gameId); - Map> stats = gameStats.getStats(); + Map> stats = gameStats.getStats(); StringBuilder builder = new StringBuilder(1000); long start = System.currentTimeMillis(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java index 5fe6bbfc4..d7abd582d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/game/GameStats.java @@ -17,7 +17,7 @@ public class GameStats private long _startTime; private long _endTime; - private final Map> _stats; + private final Map> _stats; public GameStats(int gameId, Region region, GameDisplay display) { @@ -72,8 +72,13 @@ public class GameStats return _endTime; } - public Map> getStats() + public Map> getStats() { return _stats; } + + public boolean isValid() + { + return _region != null && _gameType != null && _mapId != 0 && _startTime != 0 && _endTime != 0; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 21aa9a064..0bdc5f21c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -303,18 +303,21 @@ public class Moba extends TeamGame _listeners.forEach(UtilServer::Unregister); _listeners.clear(); - PlayerDisguiseManager playerDisguiseManager = Managers.require(PlayerDisguiseManager.class); - - // Undisguise all players - for (Player player : Bukkit.getOnlinePlayers()) + Manager.runSyncLater(() -> { - DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + PlayerDisguiseManager playerDisguiseManager = Managers.require(PlayerDisguiseManager.class); - if (disguise != null && disguise instanceof DisguisePlayer) + // Undisguise all players + for (Player player : Bukkit.getOnlinePlayers()) { - playerDisguiseManager.undisguise(player, (DisguisePlayer) disguise); + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + + if (disguise != null && disguise instanceof DisguisePlayer) + { + playerDisguiseManager.undisguise(player, (DisguisePlayer) disguise); + } } - } + }, 50); } @Override @@ -334,6 +337,12 @@ public class Moba extends TeamGame return DeathMessageType.Detailed; } + @Override + public double GetKillsGems(Player killer, Player killed, boolean assist) + { + return assist ? 1 : 2; + } + // Clear up memory @EventHandler public void playerQuit(PlayerQuitEvent event) @@ -553,4 +562,9 @@ public class Moba extends TeamGame { return _minion; } + + public MobaProgression getProgression() + { + return _progression; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java index ab2750c01..e3a0817a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java @@ -47,8 +47,8 @@ public class MobaClassic extends Moba registerManager(new PrepareManager(this)); registerManager(new PrepareSelection(this)); - new GameStatisticsModule() - .register(this); +// new GameStatisticsModule() +// .register(this); new CustomScoreboardModule() .setSidebar((player, scoreboard) -> diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 4758aefcd..e364ede7e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -16,6 +16,7 @@ import mineplex.core.utils.UtilGameProfile; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.progression.MobaProgression; import nautilus.game.arcade.game.games.moba.shop.MobaItem; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.kit.Kit; @@ -32,13 +33,15 @@ import java.util.List; public class HeroKit extends Kit { - private final MobaRole _role; - private static final int AMMO_SLOT = 7; + + private final MobaRole _role; + private final SkinData _skin; + private final int _unlockLevel; + private ItemStack _ammo; private long _giveTime; private int _maxAmmo; - private SkinData _skin; private static final int SHOP_SLOT = 8; private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT) @@ -49,12 +52,18 @@ public class HeroKit extends Kit private boolean _visible = true; public HeroKit(ArcadeManager manager, String name, Perk[] kitPerks, MobaRole role, SkinData skin) + { + this(manager, name, kitPerks, role, skin, 0); + } + + public HeroKit(ArcadeManager manager, String name, Perk[] kitPerks, MobaRole role, SkinData skin, int unlockLevel) { super(manager, name, KitAvailability.Free, new String[0], kitPerks, null, null); _role = role; _maxAmmo = 64; _skin = skin; + _unlockLevel = unlockLevel; } public MobaRole getRole() @@ -62,11 +71,22 @@ public class HeroKit extends Kit return _role; } + public int getUnlockLevel() + { + return _unlockLevel; + } + public ItemStack getAmmo() { return _ammo; } + public boolean ownsKit(Player player) + { + MobaProgression progression = ((Moba) Manager.GetGame()).getProgression(); + return _unlockLevel == 0 || Manager.GetDonation().Get(player).ownsUnknownSalesPackage(progression.getPackageName(this)); + } + public void setAmmo(ItemStack ammo, long giveTime) { _ammo = ammo; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java index 8deda46ad..a62692c09 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java @@ -49,7 +49,7 @@ public class HeroBardolf extends HeroKit public HeroBardolf(ArcadeManager manager) { - super(manager, "Bardolf", PERKS, MobaRole.ASSASSIN, SkinData.BARDOLF); + super(manager, "Bardolf", PERKS, MobaRole.ASSASSIN, SkinData.BARDOLF, 10); _data = new ArrayList<>(2); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java index 3ea9175bc..f068bb772 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java @@ -19,6 +19,6 @@ public class HeroBiff extends HeroKit public HeroBiff(ArcadeManager manager) { - super(manager, "Biff", PERKS, MobaRole.WARRIOR, SkinData.BIFF); + super(manager, "Biff", PERKS, MobaRole.WARRIOR, SkinData.BIFF, 10); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index 1479cfbe3..94d26369a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -151,7 +151,7 @@ public class SkillRally extends HeroSkill for (LivingEntity nearby : UtilEnt.getInRadius(player.getLocation(), 3).keySet()) { - if (!isTeamDamage(nearby, player)) + if (isTeamDamage(nearby, player)) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java index a1f2cb08b..fa70c8926 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java @@ -27,7 +27,7 @@ public class HeroLarissa extends HeroKit public HeroLarissa(ArcadeManager manager) { - super(manager, "Larissa", PERKS, MobaRole.MAGE, SkinData.LARISSA); + super(manager, "Larissa", PERKS, MobaRole.MAGE, SkinData.LARISSA, 10); setAmmo(AMMO, 3000); setMaxAmmo(5); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java index d15ab3174..5c7bcb9e0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java @@ -28,7 +28,7 @@ public class HeroRowena extends HeroKit public HeroRowena(ArcadeManager manager) { - super(manager, "Rowena", PERKS, MobaRole.HUNTER, SkinData.ROWENA); + super(manager, "Rowena", PERKS, MobaRole.HUNTER, SkinData.ROWENA, 10); setAmmo(AMMO, 2000); setMaxAmmo(2); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index 938d03258..03086b5b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -150,7 +150,7 @@ public class PrepareSelection implements Listener, IPacketHandler ClientArmorStand stand = ClientArmorStand.spawn(location.clone().add(0, 1, 0), player); stand.setCustomNameVisible(true); - stand.setCustomName(C.cGreenB + kit.GetName()); + stand.setCustomName((kit.ownsKit(player) ? C.cGreenB : C.cRedB) + kit.GetName()); stand.setArms(true); stand.setHelmet(kit.getSkinData().getSkull()); stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, kit.getRole())); @@ -262,6 +262,13 @@ public class PrepareSelection implements Listener, IPacketHandler HeroKit kit = _kitStands.get(stand); + if (!kit.ownsKit(player)) + { + player.sendMessage(F.main("Game", "You have not unlocked this kit. Try picking one with a " + C.cGreen + "Green" + C.cGray + " name.")); + player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 0.2F); + return; + } + if (goBackStand != null) { _goBackStands.remove(player).remove(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java index 86dde7520..51717e88e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java @@ -6,6 +6,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -15,6 +16,7 @@ import nautilus.game.arcade.game.GemData; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; import nautilus.game.arcade.game.games.moba.progression.ui.MobaRoleShop; import nautilus.game.arcade.game.games.moba.util.MobaUtil; @@ -39,48 +41,25 @@ public class MobaProgression implements Listener { private static final int[] EXP_LEVELS; - private static final DecimalFormat FORMAT = new DecimalFormat("0.0"); + public static final DecimalFormat FORMAT = new DecimalFormat("0.0"); static { EXP_LEVELS = new int[100]; - int expRequired = 0; + int expRequired = 2000; - for (int level = 0; level < 10; level++) + for (int level = 0; level < 100; level++) { EXP_LEVELS[level] = expRequired += 2000; } - - for (int level = 10; level < 20; level++) - { - EXP_LEVELS[level] = expRequired += 4000; - } - - for (int level = 20; level < 40; level++) - { - EXP_LEVELS[level] = expRequired += 8000; - } - - for (int level = 40; level < 60; level++) - { - EXP_LEVELS[level] = expRequired += 16000; - } - - for (int level = 60; level < 80; level++) - { - EXP_LEVELS[level] = expRequired += 32000; - } - - for (int level = 80; level < 100; level++) - { - EXP_LEVELS[level] = expRequired += 64000; - } } private final Moba _host; private final Map _roleViewers; private final MobaRoleShop _roleShop; + private MobaUnlockAnimation _currentAnimation; + public MobaProgression(Moba host) { _host = host; @@ -97,6 +76,17 @@ public class MobaProgression implements Listener caller.sendMessage(F.main("Debug", "Gave you " + F.elem(exp) + " fake exp.")); } }); + host.registerDebugCommand(new DebugCommand("setmobalevel", Rank.DEVELOPER) + { + @Override + public void Execute(Player caller, String[] args) + { + MobaRole role = MobaRole.valueOf(args[0].toUpperCase()); + int exp = getExperience(Integer.parseInt(args[1])) - 1; + _host.getArcadeManager().GetStatsManager().setStat(caller, _host.GetName() + "." + role.getName() + ".ExpEarned", exp); + caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp)) + ".")); + } + }); } public void spawnRoleViewers(Map> lobbyLocations) @@ -184,6 +174,41 @@ public class MobaProgression implements Listener _host.GetPlayers(true).forEach(this::rewardPlayer); } + public int getExperience(int level) + { + if (level > EXP_LEVELS.length) + { + return Integer.MAX_VALUE; + } + else if (level < 1) + { + return 0; + } + + return EXP_LEVELS[level - 1]; + } + + public long getExperience(Player player, MobaRole role) + { + String stat = _host.GetName() + "." + role.getName() + ".ExpEarned"; + return _host.getArcadeManager().GetStatsManager().Get(player).getStat(stat); + } + + public long getExperienceCurrentLevel(Player player, MobaRole role) + { + int level = getLevel(player, role); + return getExperience(level) - getExperience(level - 1); + } + public int getLevel(Player player, HeroKit kit) + { + return getLevel(player, kit.getRole()); + } + + public int getLevel(Player player, MobaRole role) + { + return getLevel(getExperience(player, role)); + } + private int getLevel(long exp) { int i = 0; @@ -204,7 +229,7 @@ public class MobaProgression implements Listener { MobaPlayer mobaPlayer = _host.getMobaData(player); MobaRole role = mobaPlayer.getRole(); - String stat = _host.GetName() + "." + role.getName() + "." + "ExpEarned"; + String stat = _host.GetName() + "." + role.getName() + ".ExpEarned"; long currentExp = _host.getArcadeManager().GetStatsManager().Get(player).getStat(stat); AtomicInteger earnedExp = new AtomicInteger(); @@ -215,7 +240,7 @@ public class MobaProgression implements Listener int level = getLevel(currentExp); int newLevel = getLevel(currentExp + earnedExp.get()); - int expForThisLevel = EXP_LEVELS[level - 1]; + long expForThisLevel = getExperienceCurrentLevel(player, role); AtomicBoolean levelUp = new AtomicBoolean(); if (newLevel > level) @@ -240,6 +265,18 @@ public class MobaProgression implements Listener if (levelUp.get()) { + for (HeroKit kit : _host.getKits()) + { + if (!kit.getRole().equals(role) || kit.getUnlockLevel() != newLevel) + { + continue; + } + + player.playSound(player.getLocation(), Sound.ENDERDRAGON_DEATH, 1, 1); + UtilTextMiddle.display(role.getColor() + kit.GetName(), "You unlocked a new Hero!", 10, 40, 10, player); + return; + } + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1); } else @@ -248,4 +285,19 @@ public class MobaProgression implements Listener } }, 60); } + + public String getPackageName(HeroKit kit) + { + return "MOBA_KIT_" + kit.GetName().toUpperCase(); + } + + public void setCurrentAnimation(MobaUnlockAnimation animation) + { + _currentAnimation = animation; + } + + public MobaUnlockAnimation getCurrentAnimation() + { + return _currentAnimation; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaUnlockAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaUnlockAnimation.java new file mode 100644 index 000000000..30a3db379 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaUnlockAnimation.java @@ -0,0 +1,188 @@ +package nautilus.game.arcade.game.games.moba.progression; + +import com.mojang.authlib.GameProfile; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilFirework; +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.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.hologram.Hologram; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.util.Vector; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public class MobaUnlockAnimation implements Listener +{ + + private static final FireworkEffect FIREWORK_EFFECT = FireworkEffect.builder() + .withColor(Color.ORANGE) + .withFlicker() + .with(Type.BURST) + .build(); + + private final Moba _host; + private final Player _player; + private final HeroKit _kit; + private final Location _spawn; + private final Location _toTeleport; + private final Location _npc; + private final Location _info; + private final long _start; + + private ArmorStand _npcEntity; + private int _animationStage; + private Hologram _skillInfo; + + public MobaUnlockAnimation(Moba host, Player player, HeroKit kit) + { + _host = host; + _player = player; + _kit = kit; + + Map> lobbyLocations = ((NewGameLobbyManager) host.getArcadeManager().GetLobby()).getCustomLocs(); + _spawn = lobbyLocations.get("SPAWN").get(0); + _toTeleport = lobbyLocations.get("HERO_UNLOCK PLAYER").get(0); + _npc = lobbyLocations.get("HERO_UNLOCK NPC").get(0); + _info = lobbyLocations.get("HERO_UNLOCK INFO_1").get(0); + + Vector dir = UtilAlg.getTrajectory(_toTeleport, _npc); + _toTeleport.setYaw(UtilAlg.GetYaw(dir)); + _npc.setYaw(UtilAlg.GetYaw(dir.clone().multiply(-1))); + + _start = System.currentTimeMillis(); + + UtilServer.RegisterEvents(this); + _host.getProgression().setCurrentAnimation(this); + start(); + } + + public void start() + { + _player.sendMessage(F.main("Game", "Unlocking " + _kit.getRole().getChatColor() + _kit.GetName() + ".")); + _player.teleport(_toTeleport); + + _npcEntity = _npc.getWorld().spawn(_npc, ArmorStand.class); + GameProfile profile = new GameProfile(UUID.randomUUID(), _kit.GetName()); + profile.getProperties().clear(); + profile.getProperties().put("textures", _kit.getSkinData().getProperty()); + DisguisePlayer disguise = new DisguisePlayer(_npcEntity, profile); + disguise.setSendSkinDataToSelf(false); + _host.getArcadeManager().GetDisguise().disguise(disguise); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + switch (_animationStage) + { + case 0: + if (!UtilTime.elapsed(_start, 2000)) + { + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, _npcEntity.getLocation().add(0, 1.5, 0), 1, 1, 1, 0.0001F, 50, ViewDist.NORMAL); + } + else + { + _animationStage++; + } + break; + case 1: + _npcEntity.getWorld().strikeLightningEffect(_npcEntity.getLocation()); + + String[] text = new String[_kit.GetPerks().length + 1]; + int i = 0; + text[i++] = C.cAqua + "Skills"; + + for (Perk perk : _kit.GetPerks()) + { + text[i++] = C.cYellow + perk.GetName(); + } + + _skillInfo = new Hologram(_host.getArcadeManager().getHologramManager(), _info, text); + _skillInfo.start(); + + for (int j = 0; j < 10; j++) + { + UtilFirework.playFirework(UtilAlg.getRandomLocation(_npcEntity.getLocation(), 4, 0, 4), FIREWORK_EFFECT); + } + + _animationStage++; + break; + case 2: + if (UtilTime.elapsed(_start, 12000)) + { + _player.sendMessage(F.main("Game", "Unlocked" + _kit.getRole().getChatColor() + _kit.GetName() + ". You can now select them at the start of the game!")); + _player.teleport(_spawn); + _player.playSound(_player.getLocation(), Sound.LEVEL_UP, 1, 1.2F); + cleanup(); + _animationStage++; + } + + break; + } + } + + @EventHandler + public void playerMove(PlayerMoveEvent event) + { + if (!event.getPlayer().equals(_player)) + { + return; + } + + Location from = event.getFrom(); + Location to = event.getTo(); + + if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ()) + { + return; + } + + event.setTo(event.getFrom()); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + if (event.getPlayer().equals(_player)) + { + cleanup(); + } + } + + private void cleanup() + { + UtilServer.Unregister(this); + _npcEntity.remove(); + _skillInfo.stop(); + _host.getProgression().setCurrentAnimation(null); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java index c383b126e..04e19a0ad 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java @@ -1,26 +1,46 @@ package nautilus.game.arcade.game.games.moba.progression.ui; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilUI; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.server.util.TransactionResponse; import mineplex.core.shop.page.ShopPageBase; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.progression.MobaProgression; +import nautilus.game.arcade.game.games.moba.progression.MobaUnlockAnimation; +import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; +import java.util.List; public class MobaRolePage extends ShopPageBase { private static final int SIZE = 45; private static final int[] MAPPINGS = UtilUI.getIndicesFor(4, 3); + private static final ItemStack COMING_SOON = new ItemBuilder(Material.STAINED_CLAY, (byte) 15) + .setTitle(C.cRed + "Coming Soon") + .build(); + private static final int ANIMATION_TIME = 20; + private final Moba _host; private final MobaRole _role; - public MobaRolePage(ArcadeManager plugin, MobaRoleShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, MobaRole role) + public MobaRolePage(ArcadeManager plugin, MobaRoleShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, Moba host, MobaRole role) { super(plugin, shop, clientManager, donationManager, role.getName(), player, SIZE); + _host = host; _role = role; buildPage(); @@ -29,14 +49,112 @@ public class MobaRolePage extends ShopPageBase @Override protected void buildPage() { + int level = _host.getProgression().getLevel(_player, _role); + long currentExp = _host.getProgression().getExperience(_player, _role); + long thisLevel = _host.getProgression().getExperienceCurrentLevel(_player, _role); + long toNextLevel = _host.getProgression().getExperience(level) - currentExp; + long levelExp = _host.getProgression().getExperience(level); + addButtonNoAction(13, new ItemBuilder(_role.getSkin().getSkull()) .setTitle(_role.getChatColor() + _role.getName()) - .addLore("", "Every 10 levels you unlock a new", "hero within the " + _role.getName() + " category.") + .addLore( + "", + "Every " + F.elem(10) + " levels you unlock a new", + "hero within the " + F.name(_role.getName()) + " category.", + "", + "Your Level: " + C.cGreen + level, + "Next Level: " + C.cGreen + toNextLevel + C.cGray + "/" + C.cGreen + thisLevel + C.cGray + " (" + C.cAqua + MobaProgression.FORMAT.format(100 - ((double) currentExp / (double) levelExp) * 100D) + C.cGray + "%)" + ) .build()); -// for (int slot : MAPPINGS) -// { -// addButton(slot, ); -// } + List kits = new ArrayList<>(); + + for (HeroKit kit : _host.getKits()) + { + if (!kit.getRole().equals(_role) || !kit.isVisible() || kit.getUnlockLevel() == 0) + { + continue; + } + + kits.add(kit); + } + + int i = 0; + for (int slot : MAPPINGS) + { + if (i >= kits.size()) + { + addButtonNoAction(slot, COMING_SOON); + continue; + } + + HeroKit kit = kits.get(i++); + String packageName = _host.getProgression().getPackageName(kit); + boolean hasUnlocked = _plugin.GetDonation().Get(_player).ownsUnknownSalesPackage(packageName); + boolean canUnlock = _host.getProgression().getLevel(_player, kit) >= kit.getUnlockLevel(); + ItemBuilder builder = new ItemBuilder(Material.STAINED_CLAY); + + builder.setTitle(C.cGreen + kit.GetName()); + builder.addLore("", "Unlocks at " + _role.getName() + " Level " + C.cGreen + (i * 10)); + + if (hasUnlocked) + { + builder.setData((byte) 5); + builder.addLore(C.cRed + "You have already unlocked this hero!"); + } + else + { + builder.setData((byte) 14); + builder.setGlow(canUnlock); + + if (canUnlock) + { + builder.addLore(C.cGreen + "Click to unlock!"); + } + else + { + builder.addLore(C.cRed + "You cannot unlock this hero!"); + } + } + + addButton(slot, builder.build(), (player, clickType) -> + { + if (!Recharge.Instance.use(player, "Hero Unlock", 1000, false, false)) + { + playDenySound(player); + return; + } + + boolean allowAnimation = (_host.GetCountdown() > ANIMATION_TIME || _host.GetCountdown() < 0) && _host.getProgression().getCurrentAnimation() == null; + + if (!hasUnlocked && canUnlock) + { + if (allowAnimation) + { + _host.getArcadeManager().GetDonation().purchaseUnknownSalesPackage(player, packageName, GlobalCurrency.GEM, 0, true, data -> + { + if (data != TransactionResponse.Success) + { + player.sendMessage(F.main("Game", "Failed to unlock " + kit.GetName() + " please try again in a few seconds.")); + return; + } + + new MobaUnlockAnimation(_host, player, kit); + playAcceptSound(player); + player.closeInventory(); + }); + } + else + { + player.sendMessage(F.main("Game", "You cannot unlock a Hero right now.")); + playDenySound(player); + } + } + else + { + playDenySound(player); + } + }); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRoleShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRoleShop.java index f7a76b1d1..faff3d138 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRoleShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRoleShop.java @@ -3,13 +3,13 @@ package nautilus.game.arcade.game.games.moba.progression.ui; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaRole; import org.bukkit.entity.Player; public class MobaRoleShop extends ShopBase { - public MobaRoleShop(ArcadeManager plugin) { super(plugin, plugin.GetClients(), plugin.GetDonation(), "Moba Heroes"); @@ -17,7 +17,7 @@ public class MobaRoleShop extends ShopBase public void openShop(Player player, MobaRole role) { - openPageForPlayer(player, new MobaRolePage(getPlugin(), this, getClientManager(), getDonationManager(), player, role)); + openPageForPlayer(player, new MobaRolePage(getPlugin(), this, getClientManager(), getDonationManager(), player, (Moba) getPlugin().GetGame(), role)); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 9d94785d4..c8823b984 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -33,6 +33,7 @@ public class Tower { private static final int DAMAGE = 3; + private static final double HEALING = 2.6; private static final int TARGET_RANGE = 10; public static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30); @@ -149,7 +150,7 @@ public class Tower continue; } - MobaUtil.heal(player, null, 2); + MobaUtil.heal(player, null, HEALING); } } @@ -217,7 +218,6 @@ public class Tower { player.playSound(player.getLocation(), Sound.ANVIL_LAND, 1, 0.5F); player.sendMessage(F.main("Game", "Your Tower is under attack!")); - //UtilTextMiddle.display("", _team.GetColor() + "Your Tower is under attack!", 0, 30, 10, player); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/GameStatisticsModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/GameStatisticsModule.java index a024f3cfc..8f593f2c0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/GameStatisticsModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/GameStatisticsModule.java @@ -2,14 +2,19 @@ package nautilus.game.arcade.game.modules; import mineplex.core.Managers; import mineplex.core.common.util.UtilServer; +import mineplex.core.stats.event.StatChangeEvent; import mineplex.core.stats.game.GameStatisticsManager; import mineplex.core.stats.game.GameStats; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.UUID; public class GameStatisticsModule extends Module { @@ -22,21 +27,30 @@ public class GameStatisticsModule extends Module } private GameStats _currentGame; + private final List _statsToListen; + private final Map _playerId; + + public GameStatisticsModule() + { + _statsToListen = new ArrayList<>(); + _playerId = new HashMap<>(); + } + + public void addStatListener(String stat) + { + _statsToListen.add(stat); + } @Override protected void setup() { _currentGame = new GameStats(-1, UtilServer.getRegion(), getGame().GetType().getDisplay()); - Map dummy = new HashMap<>(); - dummy.put(getGame().GetName() + ".Kills", 1); - dummy.put(getGame().GetName() + ".Wins", 2); - _currentGame.getStats().put(1, dummy); } @Override public void cleanup() { - if (getGame().getArcadeManager().IsRewardStats()) + if (getGame().getArcadeManager().IsRewardStats() && _currentGame.isValid()) { STATS_MANAGER.saveGameStats(_currentGame); } @@ -50,6 +64,12 @@ public class GameStatisticsModule extends Module return; } + int id = 0; + for (Player player : getGame().GetPlayers(true)) + { + _playerId.put(player.getUniqueId(), ++id); + } + STATS_MANAGER.getMapId(mapId -> _currentGame.setMapId(mapId), getGame().GetType().getDisplay(), getGame().WorldData.MapName); _currentGame.setStartTime(System.currentTimeMillis()); } @@ -64,4 +84,19 @@ public class GameStatisticsModule extends Module _currentGame.setEndTime(System.currentTimeMillis()); } + + @EventHandler + public void statChange(StatChangeEvent event) + { + Player player = event.getPlayer(); + String stat = event.getStatName(); + long change = event.getValueAfter() - event.getValueBefore(); + + if (_statsToListen.contains(getGame().GetName() + "." + stat) && _playerId.containsKey(player.getUniqueId())) + { + int playerId = _playerId.get(player.getUniqueId()); + _currentGame.getStats().putIfAbsent(playerId, new HashMap<>()); + _currentGame.getStats().get(playerId).put(stat, change); + } + } } From 7535200c35c8e729ab146e2de1ae6cf6dd7bf063 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 13 Jul 2017 18:17:30 -0700 Subject: [PATCH 086/183] Fix out of bounds exception in legendary particle --- .../core/gadget/gadgets/particle/ParticleLegend.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java index 8337efae4..9f1a9afa4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java @@ -1,7 +1,7 @@ package mineplex.core.gadget.gadgets.particle; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; +import java.awt.*; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -11,6 +11,8 @@ import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.ParticleGadget; @@ -19,8 +21,6 @@ import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import java.awt.Color; - public class ParticleLegend extends ParticleGadget { private static final double PI = Math.PI; @@ -70,14 +70,14 @@ public class ParticleLegend extends ParticleGadget for (int i = 0; i < MOVING_PARTICLES; i++) { - if (_colors[i].getGreen() == 0) + if (_colors[i % _colors.length].getGreen() == 0) { UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.SMOKE, UtilMath.gauss(player.getLocation(), 8, 4, 8), null, 0, 1, UtilParticle.ViewDist.NORMAL); } else { - UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, + UtilParticle.playColoredParticleToAll(_colors[i % _colors.length], UtilParticle.ParticleType.RED_DUST, UtilMath.gauss(player.getLocation(), 8, 4, 8), 0, UtilParticle.ViewDist.NORMAL); } } From 690854d06744095583093f410ff65d52edcea45f Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 13 Jul 2017 21:17:26 -0700 Subject: [PATCH 087/183] Add tps and ping to each GWEN metadata frame --- .../core/antihack/logging/builtin/PlayerInfoMetadata.java | 3 --- .../core/antihack/logging/builtin/ServerInfoMetadata.java | 3 --- .../core/antihack/logging/builtin/ViolationInfoMetadata.java | 5 +++++ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java index 1af27c8c7..479db70d2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java @@ -3,7 +3,6 @@ package mineplex.core.antihack.logging.builtin; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import com.google.gson.JsonElement; @@ -19,7 +18,6 @@ public class PlayerInfoMetadata extends AnticheatMetadata private static final String KEY_UUID = "uuid"; private static final String KEY_ACCOUNT_ID = "accountid"; private static final String KEY_NAME = "name"; - private static final String KEY_PING = "ping"; private final CoreClientManager _clientManager = require(CoreClientManager.class); @@ -40,7 +38,6 @@ public class PlayerInfoMetadata extends AnticheatMetadata { object.addProperty(KEY_NAME, bPlayer.getName()); object.addProperty(KEY_ACCOUNT_ID, _clientManager.getAccountId(bPlayer)); - object.addProperty(KEY_PING, Math.min(((CraftPlayer) bPlayer).getHandle().ping, 1000)); } return object; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java index cd937ec64..2b838a9cc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ServerInfoMetadata.java @@ -7,14 +7,12 @@ import com.google.gson.JsonObject; import mineplex.core.antihack.logging.AnticheatMetadata; import mineplex.core.common.util.UtilServer; -import net.minecraft.server.v1_8_R3.MinecraftServer; public class ServerInfoMetadata extends AnticheatMetadata { private static final String KEY_SERVER_NAME = "server-name"; private static final String KEY_SERVER_REGION = "server-region"; private static final String KEY_SERVER_GROUP = "server-group"; - private static final String KEY_SERVER_TPS = "server-tps"; @Override public String getId() @@ -29,7 +27,6 @@ public class ServerInfoMetadata extends AnticheatMetadata info.addProperty(KEY_SERVER_NAME, UtilServer.getServerName()); info.addProperty(KEY_SERVER_REGION, UtilServer.getRegion().name()); info.addProperty(KEY_SERVER_GROUP, UtilServer.getGroup()); - info.addProperty(KEY_SERVER_TPS, MinecraftServer.getServer().recentTps[0]); return info; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ViolationInfoMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ViolationInfoMetadata.java index da2ee4278..556cea86b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ViolationInfoMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ViolationInfoMetadata.java @@ -9,6 +9,7 @@ import java.util.UUID; import net.minecraft.server.v1_8_R3.MinecraftServer; import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; @@ -49,6 +50,8 @@ public class ViolationInfoMetadata extends AnticheatMetadata private static final String KEY_Z = "z"; private static final String KEY_YAW = "yaw"; private static final String KEY_PITCH = "pitch"; + private static final String KEY_PING = "ping"; + private static final String KEY_SERVER_TPS = "server-tps"; private static final JsonObject VAL_CHECK_DISABLED; @@ -143,11 +146,13 @@ public class ViolationInfoMetadata extends AnticheatMetadata location.addProperty(KEY_PITCH, MUTABLE_LOCATION.getPitch()); playerInfo.add(KEY_LOCATION, location); + playerInfo.addProperty(KEY_PING, Math.min(((CraftPlayer) event.getPlayer()).getHandle().ping, 1000)); JsonObject data = new JsonObject(); data.add(KEY_CURRENT_TIME, currentTime); data.add(KEY_VIOLATION_INFO, violationInfo); data.add(KEY_PLAYER_INFO, playerInfo); + data.addProperty(KEY_SERVER_TPS, MinecraftServer.getServer().recentTps[0]); violations.add(data); } From 22676ab9e338a5e1c53f8ccff0a5529fda3ace08 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 13 Jul 2017 22:31:22 -0700 Subject: [PATCH 088/183] Add selection page for Heroes of GWEN training / normal game --- .../hub/server/ui/MOBAServerTypePage.java | 52 +++++++++++++++++++ .../mineplex/hub/server/ui/ServerNpcShop.java | 3 ++ 2 files changed, 55 insertions(+) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java new file mode 100644 index 000000000..b51f3b49e --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java @@ -0,0 +1,52 @@ +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 MOBAServerTypePage extends ShopPageBase +{ + private final ServerGroup _serverGroup; + + public MOBAServerTypePage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, ServerGroup serverGroup) + { + super(plugin, shop, clientManager, donationManager, "Super Smash Mobs ", player, 27); + _serverGroup = serverGroup; + + buildPage(); + } + + @Override + protected void buildPage() + { + setItem(12, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 4).setTitle(C.Reset + C.cGold + "Play " + C.cYellow + "Heroes of GWEN") + .addLore(new String[] + { + C.Reset + "", + C.Reset + C.cGreen + "Click to Play", + }).build()); + + setItem(14, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cYellow + "Heroes of GWEN " + C.cGold + "Training") + .addLore(new String[] + { + C.Reset + "", + C.Reset + C.cGreen + "Click to Play", + }).build()); + + getButtonMap().put(12, (player, __) -> getShop().openPageForPlayer(player, new ServerTypePage(getPlugin(), getShop(), getClientManager(), getDonationManager(), player, _serverGroup))); + getButtonMap().put(14, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Heroes of GWEN Training", player, "MOBAT"))); + } + + 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 4bda13c2c..46eb48b44 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java @@ -41,6 +41,9 @@ public class ServerNpcShop extends ShopBase case "SSM": return new SuperSmashMobsServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup); + case "MOBA": + return new MOBAServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup); + default: return new ServerNpcPage(getPlugin(), this, getClientManager(), getDonationManager(), _serverGroup.getServerNpcName(), player, _serverGroup.getPrefix()); } From bdaea49d56e54dd07c143f05193f9687ad6a0e5a Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 13 Jul 2017 23:44:16 -0700 Subject: [PATCH 089/183] Fix Heroes of GWEN select menu --- .../src/mineplex/hub/server/ui/MOBAServerTypePage.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java index b51f3b49e..fa6b999e8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java @@ -17,7 +17,7 @@ public class MOBAServerTypePage extends ShopPageBase getShop().openPageForPlayer(player, new ServerTypePage(getPlugin(), getShop(), getClientManager(), getDonationManager(), player, _serverGroup))); + getButtonMap().put(12, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Heroes of GWEN", player, "MOBA"))); getButtonMap().put(14, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Heroes of GWEN Training", player, "MOBAT"))); } From 6418a6006fd4440472b9384a2a2b4c1a7e3f2370 Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 14 Jul 2017 03:00:59 -0700 Subject: [PATCH 090/183] Manually construct WatchableObjects for custom item frames --- .../core/imagemap/CustomItemFrames.java | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java index d712d3bb0..9bd70c7db 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/CustomItemFrames.java @@ -1,30 +1,33 @@ package mineplex.core.imagemap; -import com.google.common.base.Optional; -import mineplex.core.MiniPlugin; -import mineplex.core.ReflectivelyCreateMiniPlugin; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.packethandler.IPacketHandler; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.packethandler.PacketInfo; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + import net.minecraft.server.v1_8_R3.DataWatcher; -import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; import net.minecraft.server.v1_8_R3.EntityItemFrame; import net.minecraft.server.v1_8_R3.ItemStack; import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; + import org.bukkit.craftbukkit.v1_8_R3.entity.CraftItemFrame; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import com.google.common.base.Optional; + +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.packethandler.PacketInfo; @ReflectivelyCreateMiniPlugin public class CustomItemFrames extends MiniPlugin implements IPacketHandler @@ -73,7 +76,7 @@ public class CustomItemFrames extends MiniPlugin implements IPacketHandler if (item != null) { - for (WatchableObject meta : packet.b) + for (DataWatcher.WatchableObject meta : packet.b) { if (meta.getIndex().a() == 8) { @@ -98,12 +101,13 @@ public class CustomItemFrames extends MiniPlugin implements IPacketHandler public void setItem(Player player, ItemFrame frame, org.bukkit.inventory.ItemStack item) { ItemStack nmsItem = CraftItemStack.asNMSCopy(item.clone()); - EntityItemFrame nmsEntity = ((CraftItemFrame) frame).getHandle(); - DataWatcher watcher = new DataWatcher(nmsEntity); - watcher.add(8, 5, EntityItemFrame.META_ITEM, Optional.fromNullable(nmsItem)); + DataWatcher.WatchableObject> frameMetaItem = new DataWatcher.WatchableObject<>(5, 8, nmsItem, EntityItemFrame.META_ITEM, Optional.fromNullable(nmsItem)); + + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(); + packet.a = frame.getEntityId(); + packet.b = Collections.singletonList(frameMetaItem); - PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(frame.getEntityId(), watcher, true); _ourPackets.add(packet); UtilPlayer.sendPacket(player, packet); From 2fd3c9cc2f19da96451ee47c04462251734c2af7 Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 14 Jul 2017 03:39:41 -0700 Subject: [PATCH 091/183] Send players into the training arena only if the game has started --- .../game/arcade/game/modules/TrainingGameModule.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java index 15f877ec2..0dd6008c7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java @@ -166,6 +166,11 @@ public class TrainingGameModule extends Module @EventHandler(priority = EventPriority.MONITOR) public void playerJoin(PlayerJoinEvent event) { + if (!getGame().InProgress()) + { + return; + } + Player player = event.getPlayer(); if (UtilPlayer.isSpectator(player)) From 4a5913bb3af160910b09b26f7c5a51224111ab1a Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 14 Jul 2017 17:40:22 +0100 Subject: [PATCH 092/183] Don't have the second towers be Elder Guardians --- .../game/arcade/game/games/moba/structure/tower/Tower.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index c8823b984..6aaf95375 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -80,10 +80,7 @@ public class Tower _guardian = new DisguiseGuardian(_stand); _host.getArcadeManager().GetDisguise().disguise(_guardian); - if (!_firstTower) - { - _guardian.setElder(true); - } + //_guardian.setElder(!_firstTower); _guardian.setCustomNameVisible(true); From 968bcc022392713f34292c962cd04c71aa94a81a Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 14 Jul 2017 18:03:09 +0100 Subject: [PATCH 093/183] Add MOBA to the game menu --- .../mineplex/hub/server/ServerManager.java | 5 +++++ .../hub/server/ui/MOBAServerTypePage.java | 4 ++-- .../hub/server/ui/ServerGameMenu.java | 18 ++++++++++----- .../server/ui/button/SelectMOBAButton.java | 22 +++++++++++++++++++ 4 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectMOBAButton.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index f833f0200..38839f738 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -865,6 +865,11 @@ public class ServerManager extends MiniPlugin return _serverNpcShopMap.get("Bawk Bawk Battles"); } + public ServerNpcShop getMobaShop() + { + return _serverNpcShopMap.get("Heroes of GWEN"); + } + public BoosterManager getBoosterManager() { return _boosterManager; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java index fa6b999e8..3fbb186f3 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/MOBAServerTypePage.java @@ -26,14 +26,14 @@ public class MOBAServerTypePage extends ShopPageBase C.Reset + "at all costs!", }, "CA", "Castle_Assault", new SelectCAButton(this)); - add(4, Material.DIAMOND_CHESTPLATE, C.cYellowB + "Castle Assault TDM " + C.cGray + "Team PvP", new String[] + add(4, Material.PRISMARINE_SHARD, C.cYellowB + "Heroes of GWEN " + C.cGray + "Team Game", new String[] { - (_extraValue ? C.cAquaB : C.cWhiteB) + "NEW GAME", + (_extraValue ? C.cAquaB : C.cWhiteB) + "FULL RELEASE", C.Reset + "", - C.Reset + "Combatants must battle to", - C.Reset + "win glory for their team", - C.Reset + "by slaying the enemy!", - }, "CATDM", "Castle_Assault_TDM", new SelectCATDMButton(this)); + C.Reset + "Face off in a crazy 4v4", + C.Reset + "battle with many different", + C.Reset + "Heroes and Abilities!", + }, "MOBA", "Heroes_of_GWEN", new SelectMOBAButton(this)); add(6, Material.QUARTZ_BLOCK, C.cYellowB + "Speed Builders " + C.cGray + "Competitive Building", new String[] { @@ -761,6 +762,11 @@ public class ServerGameMenu extends ShopPageBase getPlugin().getBawkShop().attemptShopOpen(player); } + public void openMoba(Player player) + { + getPlugin().getMobaShop().attemptShopOpen(player); + } + /* ADDITIONAL LORES; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectMOBAButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectMOBAButton.java new file mode 100644 index 000000000..c65848b38 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectMOBAButton.java @@ -0,0 +1,22 @@ +package mineplex.hub.server.ui.button; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +public class SelectMOBAButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectMOBAButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.openMoba(player); + } +} From f202085eeb34bd3499847191bfc4ac66a95534c1 Mon Sep 17 00:00:00 2001 From: cnr Date: Sat, 15 Jul 2017 13:21:29 -0700 Subject: [PATCH 094/183] Remove Heroes of GWEN from MPS --- .../src/nautilus/game/arcade/managers/GameHostManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index d22502170..f046626b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -123,7 +123,6 @@ public class GameHostManager implements Listener legendGames.add(GameType.Skywars); legendGames.add(GameType.SpeedBuilders); legendGames.add(GameType.TypeWars); - legendGames.add(GameType.MOBA); // Team variants - Currently being remade. /* legendGames.add(GameType.DragonEscapeTeams); From 9255c5a6ab349d3c14a713a306b3e7e0054a6cb4 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Mon, 17 Jul 2017 13:28:50 -0400 Subject: [PATCH 095/183] Perform disguise validation before doing any of the disguise work If a disguise is invalid, we won't notify redis or prevent players from joining --- .../playerdisguise/DisguiseCommand.java | 10 +- .../disguise/playerdisguise/ExpiringSet.java | 96 ++++++ .../playerdisguise/PlayerDisguiseManager.java | 281 ++++++++++-------- 3 files changed, 250 insertions(+), 137 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/ExpiringSet.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java index e0c544659..4b53402cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java @@ -37,11 +37,9 @@ public class DisguiseCommand extends CommandBase implemen return; } - Plugin.runAsync(() -> - { - new PlayerDisguiseNotification(realName, currentUUID, args[0], args.length > 1 ? args[1] : args[0]).publish(); - }); - - Plugin.disguise(caller, args[0], args.length > 1 ? args[1] : args[0]); + String skin = args.length > 1 ? args[1] : args[0]; + Plugin.tryDisguise(caller, args[0], skin, () -> // onComplete + Plugin.runAsync(() -> // task + new PlayerDisguiseNotification(realName, currentUUID, args[0], skin).publish())); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/ExpiringSet.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/ExpiringSet.java new file mode 100644 index 000000000..12aa1d0ca --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/ExpiringSet.java @@ -0,0 +1,96 @@ +package mineplex.core.disguise.playerdisguise; + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; +import java.util.function.Predicate; +import java.util.stream.Stream; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; + +/** + * Set with contents that expire after X amount of time units. Essentially HashSet reimplemented with a Cache instead of HashMap. + * @author Dan + */ +public class ExpiringSet extends AbstractSet implements Set +{ + private transient Cache cache; + + private static final Object DUMMY = new Object(); + + public ExpiringSet(long duration, TimeUnit unit) + { + this.cache = CacheBuilder.newBuilder().expireAfterWrite(duration, unit).build(); + } + + @Override + public Iterator iterator() + { + return cache.asMap().keySet().iterator(); + } + + @Override + public void forEach(Consumer action) + { + cache.asMap().keySet().forEach(action); + } + + @Override + public boolean removeIf(Predicate filter) + { + return cache.asMap().keySet().removeIf(filter); + } + + @Override + public Spliterator spliterator() + { + return cache.asMap().keySet().spliterator(); + } + + @Override + public Stream stream() + { + return cache.asMap().keySet().stream(); + } + + @Override + public Stream parallelStream() + { + return cache.asMap().keySet().parallelStream(); + } + + @Override + public int size() + { + return (int) cache.size(); + } + + @Override + public boolean contains(Object o) + { + return cache.getIfPresent(o) != null; + } + + @Override + public boolean add(E e) + { + boolean contained = contains(e); + cache.put(e, DUMMY); + return contained; + } + + @Override + public boolean remove(Object o) + { + boolean contained = contains(o); + cache.invalidate(o); + return contained; + } + + @Override + public void clear() + { + cache.invalidateAll(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java index 06829a12d..30de25c49 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java @@ -1,14 +1,8 @@ package mineplex.core.disguise.playerdisguise; import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import net.minecraft.server.v1_8_R3.MinecraftServer; @@ -86,7 +80,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler ILLEGAL_USERNAMES = ImmutableSet.copyOf(Arrays.asList("hypixel", "chiss", "dctr", "blondebug", "dooskee", "tomcallister", "jessiemarcia", "spu_", "sp614x", "deadmau5", "gwen", "mineplex", "samczsun", "sethbling", - "xisuma", "cubehamster", "natet_bird", "qwertyuiopthepie" + "xisuma", "cubehamster", "natet_bird", "qwertyuiopthepie", "hitler", "adolfhitler" )); VERY_SPECIAL_PEOPLE = ImmutableSet.copyOf(Arrays.asList( @@ -121,14 +115,15 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler private CoreClientManager _clients = require(CoreClientManager.class); private DisguiseManager _disguise = require(DisguiseManager.class); private Punish _punish = require(Punish.class); - private CosmeticManager _cosmetics = require(CosmeticManager.class); + // private CosmeticManager _cosmetics = require(CosmeticManager.class); private PreferencesManager _prefs = require(PreferencesManager.class); private RedisDataRepository _redis; // The list of usernames which cannot join because someone else is joining - private Set _cannotJoin = Collections.synchronizedSet(new HashSet<>()); - private Set _loggingIn = Collections.synchronizedSet(new HashSet<>()); + // Values expire in 30 seconds if they haven't been properly cleaned up + private Set _cannotJoin = Collections.synchronizedSet(new ExpiringSet<>(1, TimeUnit.MINUTES)); + private Set _loggingIn = Collections.synchronizedSet(new ExpiringSet<>(1, TimeUnit.MINUTES)); private Set _pendingDisguise1 = new HashSet<>(); @@ -164,7 +159,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler if (disguisePlayer.getProfile().getName().equalsIgnoreCase(event.getPlayer().getName())) { event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - event.setKickMessage("Failed to login: The authentication servers are currently down for maintainence"); + event.setKickMessage("Failed to login: The authentication servers are currently down for maintenance"); return; } } @@ -172,7 +167,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler if (_cannotJoin.contains(event.getPlayer().getName().toLowerCase())) { event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - event.setKickMessage("Failed to login: The authentication servers are currently down for maintainence"); + event.setKickMessage("Failed to login: The authentication servers are currently down for maintenance"); return; } @@ -231,7 +226,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler runSyncLater(() -> { UtilPlayer.message(event.getPlayer(), F.main(getName(), "Attempting to disguise you as " + bean.getGameProfile().getName())); - disguise(event.getPlayer(), bean.getGameProfile()); + tryDisguise(event.getPlayer(), bean.getGameProfile(), () -> { }); }, 1); } } @@ -480,15 +475,15 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler } } - public void disguise(Player caller, GameProfile requestedProfile) + public void tryDisguise(Player caller, GameProfile requestedProfile, Runnable onComplete) { if (getDisguiseManager().isDisguised(caller)) { if (isDisguised(caller)) { - UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); - } - else + UtilPlayer.message(caller, + F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); + } else { UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Perhaps you are morphed?")); } @@ -497,134 +492,75 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler if (isDisguised(caller)) { - UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); - return; - } - - String requestedUsername = requestedProfile.getName(); - - if (!requestedUsername.equalsIgnoreCase(caller.getName())) - { - _cannotJoin.add(requestedUsername.toLowerCase()); - for (Player other : UtilServer.getPlayersCollection()) - { - if (other.getName().equalsIgnoreCase(requestedUsername)) - { - UtilPlayer.message(caller, C.cRed + F.main("Disguise", "This name is already in use!")); - _cannotJoin.remove(requestedUsername.toLowerCase()); - return; - } - } - } - - if (!_pendingDisguise.add(requestedUsername.toLowerCase())) - { - UtilPlayer.message(caller, F.main("Disguise", "Someone is already disguising as that user")); - return; - } - - PlayerPreDisguiseEvent playerPreDisguiseEvent = new PlayerPreDisguiseEvent(caller, requestedUsername); - UtilServer.CallEvent(playerPreDisguiseEvent); - if (playerPreDisguiseEvent.isCancelled()) - { - UtilPlayer.message(caller, F.main(getName(), "Your disguise was cancelled by something")); - _pendingDisguise.remove(requestedUsername.toLowerCase()); + UtilPlayer.message(caller, + F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); return; } CoreClient callerClient = getClientManager().Get(caller); - if (!requestedUsername.equalsIgnoreCase(caller.getName())) + String requestedUsername = requestedProfile.getName(); + if (requestedUsername.equalsIgnoreCase(caller.getName())) { - getClientManager().getOrLoadClient(requestedUsername, other -> + if (doDisguise(caller, requestedProfile, callerClient, callerClient)) { - Rank otherRank = other != null ? other.GetRank() : Rank.ALL; + onComplete.run(); + } + return; + } + for (Player other : UtilServer.getPlayersCollection()) + { + if (other.getName().equalsIgnoreCase(requestedUsername)) + { + UtilPlayer.message(caller, C.cRed + F.main("Disguise", "This name is already in use!")); + return; + } + } + + if (_pendingDisguise.contains(requestedUsername.toLowerCase())) + { + UtilPlayer.message(caller, F.main("Disguise", "Someone is already disguising as that user")); + return; + } + + getClientManager().getOrLoadClient(requestedUsername, other -> + { + if (other != null) + { + Rank otherRank = other.GetRank(); if (otherRank.has(Rank.TWITCH)) { - UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, YouTubers or Twitchers!")); + UtilPlayer.message(caller, + F.main("Disguise", "You can't disguise as staff, YouTubers or Twitchers!")); return; } - if (other != null) + PunishClient pclient = getPunishManager().GetClient(requestedUsername); + if (pclient != null && (pclient.IsBanned() || pclient.IsMuted())) { - PunishClient pclient = getPunishManager().GetClient(requestedUsername); - if (pclient != null && (pclient.IsBanned() || pclient.IsMuted())) - { - UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as players who are banned/muted!")); - return; - } + UtilPlayer.message(caller, + F.main("Disguise", "You can't disguise as players who are banned/muted!")); + return; } + } - callerClient.disguise(requestedUsername, requestedProfile.getId(), otherRank); + if (doDisguise(caller, requestedProfile, callerClient, other)) + { + onComplete.run(); + } + }); + } - _mapping.put(callerClient.getDisguisedAs().toLowerCase(), callerClient.getName()); + public boolean doDisguise(Player caller, GameProfile requestedProfile, CoreClient callerClient, CoreClient otherClient) + { + String requestedUsername = requestedProfile.getName(); + _pendingDisguise.add(requestedUsername.toLowerCase()); - System.out.println("================="); - System.out.println("Disguising " + caller.getName() + " as:"); - System.out.println(requestedProfile.getName() + " id " + requestedProfile.getId()); - System.out.println("Properties:"); - for (Map.Entry p : requestedProfile.getProperties().entries()) - { - System.out.println("\t" + p.getKey() + " " + p.getValue().getName()); - System.out.println("\t" + p.getValue().getValue()); - System.out.println("\t" + p.getValue().getSignature()); - } - System.out.println("================="); - - DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); - disguisePlayer.showInTabList(true, 0); - allow(caller); - getDisguiseManager().disguise(disguisePlayer, () -> - { - GameProfile callerProfile = ((CraftPlayer) caller).getProfile(); - - require(ScoreboardManager.class).handlePlayerQuit(disguisePlayer.getOriginalProfile().getName()); - - try - { - UtilGameProfile.changeName(callerProfile, disguisePlayer.getProfile().getName()); - UtilGameProfile.changeId(callerProfile, disguisePlayer.getProfile().getId()); - - Field playersByName = PlayerList.class.getDeclaredField("playersByName"); - playersByName.setAccessible(true); - Map map = (Map) playersByName.get(MinecraftServer.getServer().getPlayerList()); - map.remove(disguisePlayer.getOriginalProfile().getName()); - map.put(disguisePlayer.getProfile().getName(), disguisePlayer.getEntity()); - } - catch (Throwable t) - { - t.printStackTrace(); - } - - require(ScoreboardManager.class).handlePlayerJoin(disguisePlayer.getName()); - - callerProfile.getProperties().clear(); - callerProfile.getProperties().putAll(disguisePlayer.getProfile().getProperties()); - - callerProfile.getProperties().removeAll(ORIGINAL_UUID_KEY); - callerProfile.getProperties().put(ORIGINAL_UUID_KEY, new Property(ORIGINAL_UUID_KEY, caller.getUniqueId().toString())); - - require(FriendManager.class).updatePlayerStatus(disguisePlayer.getOriginalProfile().getId(), null); - require(FriendManager.class).updatePlayerStatus(disguisePlayer.getProfile().getId(), new PlayerStatus(disguisePlayer.getProfile().getId(), requestedUsername, _serverName)); - - getPreferencesManager().handlePlayerJoin(caller, true); - - _disguises.put(caller.getUniqueId(), disguisePlayer); - - UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + requestedUsername)); - - UtilServer.CallEvent(new PlayerDisguisedEvent(caller)); - - storeDisguiseData(caller, requestedUsername, requestedProfile); - - _pendingDisguise.remove(requestedUsername.toLowerCase()); - - _cannotJoin.remove(requestedUsername.toLowerCase()); - }); - }); - } - else + if (!requestedUsername.equalsIgnoreCase(caller.getName())) + { + _cannotJoin.add(requestedUsername.toLowerCase()); + } else { DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); disguisePlayer.showInTabList(true, 0); @@ -641,10 +577,93 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler _pendingDisguise.remove(requestedUsername.toLowerCase()); }); + + return true; } + + PlayerPreDisguiseEvent playerPreDisguiseEvent = new PlayerPreDisguiseEvent(caller, requestedUsername); + UtilServer.CallEvent(playerPreDisguiseEvent); + if (playerPreDisguiseEvent.isCancelled()) + { + UtilPlayer.message(caller, F.main(getName(), "Your disguise was cancelled by something")); + _pendingDisguise.remove(requestedUsername.toLowerCase()); + _cannotJoin.remove(requestedUsername.toLowerCase()); + return false; + } + + Rank otherRank = otherClient != null ? otherClient.GetRank() : Rank.ALL; + callerClient.disguise(requestedUsername, requestedProfile.getId(), otherRank); + + _mapping.put(callerClient.getDisguisedAs().toLowerCase(), callerClient.getName()); + + System.out.println("================="); + System.out.println("Disguising " + caller.getName() + " as:"); + System.out.println(requestedProfile.getName() + " id " + requestedProfile.getId()); + System.out.println("Properties:"); + for (Map.Entry p : requestedProfile.getProperties().entries()) + { + System.out.println("\t" + p.getKey() + " " + p.getValue().getName()); + System.out.println("\t" + p.getValue().getValue()); + System.out.println("\t" + p.getValue().getSignature()); + } + System.out.println("================="); + + DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); + disguisePlayer.showInTabList(true, 0); + allow(caller); + getDisguiseManager().disguise(disguisePlayer, () -> + { + GameProfile callerProfile = ((CraftPlayer) caller).getProfile(); + + require(ScoreboardManager.class).handlePlayerQuit(disguisePlayer.getOriginalProfile().getName()); + + try + { + UtilGameProfile.changeName(callerProfile, disguisePlayer.getProfile().getName()); + UtilGameProfile.changeId(callerProfile, disguisePlayer.getProfile().getId()); + + Field playersByName = PlayerList.class.getDeclaredField("playersByName"); + playersByName.setAccessible(true); + Map map = (Map) playersByName.get(MinecraftServer.getServer().getPlayerList()); + map.remove(disguisePlayer.getOriginalProfile().getName()); + map.put(disguisePlayer.getProfile().getName(), disguisePlayer.getEntity()); + } catch (Throwable t) + { + t.printStackTrace(); + } + + require(ScoreboardManager.class).handlePlayerJoin(disguisePlayer.getName()); + + callerProfile.getProperties().clear(); + callerProfile.getProperties().putAll(disguisePlayer.getProfile().getProperties()); + + callerProfile.getProperties().removeAll(ORIGINAL_UUID_KEY); + callerProfile.getProperties() + .put(ORIGINAL_UUID_KEY, new Property(ORIGINAL_UUID_KEY, caller.getUniqueId().toString())); + + require(FriendManager.class).updatePlayerStatus(disguisePlayer.getOriginalProfile().getId(), null); + require(FriendManager.class).updatePlayerStatus(disguisePlayer.getProfile().getId(), + new PlayerStatus(disguisePlayer.getProfile().getId(), requestedUsername, _serverName)); + + getPreferencesManager().handlePlayerJoin(caller, true); + + _disguises.put(caller.getUniqueId(), disguisePlayer); + + UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + requestedUsername)); + + UtilServer.CallEvent(new PlayerDisguisedEvent(caller)); + + storeDisguiseData(caller, requestedUsername, requestedProfile); + + _pendingDisguise.remove(requestedUsername.toLowerCase()); + + _cannotJoin.remove(requestedUsername.toLowerCase()); + }); + + return true; } - public void disguise(Player caller, String requestedUsername, String requestedSkin) + public void tryDisguise(Player caller, String requestedUsername, String requestedSkin, Runnable onComplete) { if (!validateUsername(caller, requestedUsername, true)) return; if (!validateUsername(caller, requestedSkin, false)) return; @@ -667,7 +686,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler requestedProfile.getProperties().clear(); requestedProfile.getProperties().put("textures", skinData.getProperty()); - disguise(caller, requestedProfile); + tryDisguise(caller, requestedProfile, onComplete); }; if (!requestedUsername.equalsIgnoreCase(requestedSkin)) From 953ad66aca8df7a3b4dd8f693d8388293cbfe719 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 11 Jul 2017 05:42:21 -0400 Subject: [PATCH 096/183] Update SalesAnnouncement system to allow clans-only announcements and make cross-server updating work properly --- .../src/mineplex/clanshub/ClansHub.java | 2 +- .../src/mineplex/clanshub/HubManager.java | 3 +- .../SalesAnnouncementData.java | 6 +-- .../SalesAnnouncementDeleteCommand.java | 12 ++++-- .../SalesAnnouncementDeleteHandler.java | 11 +++-- .../SalesAnnouncementManager.java | 43 ++++++++++--------- .../SalesAnnouncementPage.java | 5 ++- .../SalesAnnouncementRepository.java | 33 +++++++------- .../SalesAnnouncementUpdateCommand.java | 13 ++++-- .../SalesAnnouncementUpdateHandler.java | 11 +++-- .../SalesAnnouncementData.java | 6 +-- .../SalesAnnouncementDeleteCommand.java | 12 ++++-- .../SalesAnnouncementDeleteHandler.java | 11 +++-- .../SalesAnnouncementManager.java | 43 ++++++++++--------- .../SalesAnnouncementPage.java | 5 ++- .../SalesAnnouncementRepository.java | 33 +++++++------- .../SalesAnnouncementUpdateCommand.java | 13 ++++-- .../SalesAnnouncementUpdateHandler.java | 11 +++-- .../serverdata/commands/CommandCallback.java | 4 +- .../serverdata/commands/CommandType.java | 10 ++--- .../commands/ServerCommandManager.java | 9 ++-- 21 files changed, 163 insertions(+), 133 deletions(-) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java index 42a6f3a74..df7dd09c4 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java @@ -154,7 +154,7 @@ public class ClansHub extends JavaPlugin ConditionManager condition = new ConditionManager(this); ThankManager thankManager = new ThankManager(this, clientManager, donationManager); BoosterManager boosterManager = new BoosterManager(this, "", clientManager, donationManager, inventoryManager, thankManager); - HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, condition, disguiseManager, new TaskManager(this, clientManager), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, condition, disguiseManager, new TaskManager(this, clientManager), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, hologramManager, npcManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager, castleManager); ClansTransferManager serverManager = new ClansTransferManager(this, clientManager, donationManager, partyManager, portal, hubManager); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index b02d21718..19d55cb24 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -172,7 +172,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter private HashMap> _creativeAdmin = new HashMap>(); - public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager) + public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager, CastleManager castleManager) { super("Hub Manager", plugin); @@ -195,7 +195,6 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter _inventoryManager = inventoryManager; new BenefitManager(plugin, clientManager, _inventoryManager); - CastleManager castleManager = new CastleManager(_plugin, _clientManager, hologramManager, false); _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager, packetHandler, hologramManager, incognito, castleManager); FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementData.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementData.java index f12564495..23c2f5e7a 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementData.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementData.java @@ -12,12 +12,12 @@ import mineplex.core.itemstack.ItemBuilder; public class SalesAnnouncementData { - private final int _id; + private final Integer _id; private final Rank[] _displayTo; private final String _message; private boolean _enabled; - public SalesAnnouncementData(int id, Rank[] displayTo, String message, boolean enabled) + public SalesAnnouncementData(Integer id, Rank[] displayTo, String message, boolean enabled) { _id = id; _displayTo = displayTo; @@ -25,7 +25,7 @@ public class SalesAnnouncementData _enabled = enabled; } - public int getId() + public Integer getId() { return _id; } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteCommand.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteCommand.java index 90c08ad87..705c41f59 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteCommand.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteCommand.java @@ -4,16 +4,17 @@ import mineplex.serverdata.commands.ServerCommand; public class SalesAnnouncementDeleteCommand extends ServerCommand { - private String _id; + private Integer _id; private String _from; + private boolean _clans; - public SalesAnnouncementDeleteCommand(String id, String from) + public SalesAnnouncementDeleteCommand(Integer id, String from, boolean clans) { _id = id; _from = from; } - public String getId() + public Integer getId() { return _id; } @@ -22,4 +23,9 @@ public class SalesAnnouncementDeleteCommand extends ServerCommand { return _from; } + + public boolean isClans() + { + return _clans; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteHandler.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteHandler.java index 215789987..b8ab47fdd 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteHandler.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteHandler.java @@ -1,9 +1,8 @@ package mineplex.clanshub.salesannouncements; import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; -public class SalesAnnouncementDeleteHandler implements CommandCallback +public class SalesAnnouncementDeleteHandler implements CommandCallback { private final SalesAnnouncementManager _manager; @@ -13,16 +12,16 @@ public class SalesAnnouncementDeleteHandler implements CommandCallback } @Override - public void run(ServerCommand command) + public void run(SalesAnnouncementDeleteCommand command) { - if (!(command instanceof SalesAnnouncementDeleteCommand)) + if (_manager.getServer().equalsIgnoreCase(command.getFrom())) { return; } - if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementDeleteCommand) command).getFrom())) + if (_manager.CLANS != command.isClans()) { return; } - _manager.handleRemoteDeletion(Integer.parseInt(((SalesAnnouncementDeleteCommand)command).getId())); + _manager.handleRemoteDeletion(command.getId()); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java index 82398a078..bc5610cf3 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java @@ -1,14 +1,13 @@ package mineplex.clanshub.salesannouncements; -import java.util.List; +import java.util.HashMap; +import java.util.Map; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; -import com.google.common.collect.Lists; - import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; @@ -22,22 +21,23 @@ import mineplex.serverdata.commands.ServerCommandManager; public class SalesAnnouncementManager extends MiniPlugin { private static final String LINE = C.cDGreenB + C.Strike + "============================================="; - private final List _data = Lists.newArrayList(); + private final Map _data = new HashMap<>(); private final SalesAnnouncementRepository _repo; + public final boolean CLANS = true; public SalesAnnouncementManager(JavaPlugin plugin) { super("Sales", plugin); - _repo = new SalesAnnouncementRepository(plugin); + _repo = new SalesAnnouncementRepository(plugin, CLANS); _repo.loadAnnouncements(_data); addCommand(new SalesAnnouncementCommand(this)); - ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementUpdate", SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this)); - ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementDelete", SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this)); + ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this)); + ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this)); } - public List getLoadedAnnouncements() + public Map getLoadedAnnouncements() { return _data; } @@ -57,8 +57,8 @@ public class SalesAnnouncementManager extends MiniPlugin _repo.createAnnouncement(displayTo, message, data -> { UtilPlayer.message(creator, F.main(getName(), "Announcement successfully created!")); - _data.add(data); - new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish(); + _data.put(data.getId(), data); + new SalesAnnouncementUpdateCommand(data.getId(), getServer(), CLANS).publish(); }); } @@ -73,9 +73,9 @@ public class SalesAnnouncementManager extends MiniPlugin UtilPlayer.message(deletor, F.main(getName(), "Successfully deleted announcement!")); if (!forceRemoveFromList) { - _data.remove(data); + _data.remove(data.getId()); } - new SalesAnnouncementDeleteCommand(data.getId() + "", getServer()).publish(); + new SalesAnnouncementDeleteCommand(data.getId(), getServer(), CLANS).publish(); }); } @@ -85,23 +85,26 @@ public class SalesAnnouncementManager extends MiniPlugin _repo.updateAnnouncementStatus(data, () -> { UtilPlayer.message(toggler, F.main(getName(), "Successfully toggled announcement!")); - new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish(); + new SalesAnnouncementUpdateCommand(data.getId(), getServer(), CLANS).publish(); }); } public void handleRemoteDeletion(int id) { - _data.removeIf(data -> data.getId() == id); - UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + runSync(() -> + { + _data.remove(Integer.valueOf(id)); + UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + }); } public void handleRemoteUpdate(int id) { - if (_data.stream().filter(data -> data.getId() == id).toArray().length > 0) + if (_data.containsKey(Integer.valueOf(id))) { _repo.loadAnnouncement(id, data -> { - _data.stream().filter(existing -> existing.getId() == data.getId()).forEach(existing -> existing.setEnabled(data.isEnabled())); + _data.get(data.getId()).setEnabled(data.isEnabled()); UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); }); } @@ -109,7 +112,7 @@ public class SalesAnnouncementManager extends MiniPlugin { _repo.loadAnnouncement(id, data -> { - _data.add(data); + _data.put(data.getId(), data); UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); }); } @@ -118,7 +121,7 @@ public class SalesAnnouncementManager extends MiniPlugin @EventHandler public void onJoin(PlayerJoinEvent event) { - if (_data.isEmpty() || _data.stream().filter(data -> data.isEnabled()).toArray().length == 0) + if (_data.isEmpty() || !_data.values().stream().filter(data -> data.isEnabled()).findAny().isPresent()) { return; } @@ -127,7 +130,7 @@ public class SalesAnnouncementManager extends MiniPlugin runSyncLater(() -> { - _data.stream().filter(data -> data.isEnabled() && data.shouldDisplayTo(rank)).forEach(data -> + _data.values().stream().filter(data -> data.isEnabled() && data.shouldDisplayTo(rank)).forEach(data -> { player.sendMessage(" "); player.sendMessage(LINE); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementPage.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementPage.java index c81eb6b76..966409666 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementPage.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementPage.java @@ -36,10 +36,11 @@ public class SalesAnnouncementPage implements Listener private void setup() { _buttons.clear(); - for (int i = 0; i < _manager.getLoadedAnnouncements().size(); i++) + int i = 0; + for (SalesAnnouncementData data : _manager.getLoadedAnnouncements().values()) { - SalesAnnouncementData data = _manager.getLoadedAnnouncements().get(i); _buttons.put(i, new SalesAnnouncementButton(data, this)); + i++; } updateButtons(false); } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java index 6876ba6f2..78762f61c 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java @@ -1,6 +1,8 @@ package mineplex.clanshub.salesannouncements; +import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; @@ -9,7 +11,6 @@ import com.google.common.collect.Lists; import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; -import mineplex.core.database.MinecraftRepository; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnBoolean; @@ -18,20 +19,22 @@ import mineplex.serverdata.database.column.ColumnVarChar; public class SalesAnnouncementRepository extends RepositoryBase { - private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS salesAnnouncements (id INT NOT NULL AUTO_INCREMENT, ranks VARCHAR(250), message VARCHAR(256), enabled BOOL, PRIMARY KEY (id));"; + private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS salesAnnouncements (id INT NOT NULL AUTO_INCREMENT, ranks VARCHAR(250), message VARCHAR(256), enabled BOOL, clans BOOL, PRIMARY KEY (id), INDEX typeIndex (clans));"; - private static final String GET_ANNOUNCEMENTS = "SELECT * FROM salesAnnouncements;"; + private static final String GET_ANNOUNCEMENTS = "SELECT * FROM salesAnnouncements WHERE clans=?;"; private static final String GET_ANNOUNCEMENT = "SELECT * FROM salesAnnouncements WHERE id=?;"; private static final String UPDATE_ANNOUNCEMENT_STATUS = "UPDATE salesAnnouncements SET enabled=? WHERE id=?;"; - private static final String INSERT_ANNOUNCEMENT = "INSERT INTO salesAnnouncements (ranks, message, enabled) VALUES(?, ?, ?);"; + private static final String INSERT_ANNOUNCEMENT = "INSERT INTO salesAnnouncements (ranks, message, enabled, clans) VALUES(?, ?, ?, ?);"; private static final String DELETE_ANNOUNCEMENT = "DELETE FROM salesAnnouncements WHERE id=?;"; private final JavaPlugin _plugin; + private final boolean _clans; - public SalesAnnouncementRepository(JavaPlugin plugin) + public SalesAnnouncementRepository(JavaPlugin plugin, boolean clans) { super(DBPool.getAccount()); _plugin = plugin; + _clans = clans; } private void runAsync(Runnable runnable) @@ -44,13 +47,13 @@ public class SalesAnnouncementRepository extends RepositoryBase Bukkit.getScheduler().runTask(_plugin, runnable); } - public void loadAnnouncements(final List announcementList) + public void loadAnnouncements(final Map map) { runAsync(() -> { executeQuery(GET_ANNOUNCEMENTS, resultSet -> { - final List data = Lists.newArrayList(); + final List data = new ArrayList<>(); while (resultSet.next()) { int id = resultSet.getInt("id"); @@ -71,15 +74,15 @@ public class SalesAnnouncementRepository extends RepositoryBase String message = resultSet.getString("message"); boolean enabled = resultSet.getBoolean("enabled"); - data.add(new SalesAnnouncementData(id, displayTo, message, enabled)); + data.add(new SalesAnnouncementData(Integer.valueOf(id), displayTo, message, enabled)); } runSync(() -> { - announcementList.clear(); - data.forEach(sData -> announcementList.add(sData)); + map.clear(); + data.forEach(sData -> map.put(sData.getId(), sData)); }); - }); + }, new ColumnBoolean("clans", _clans)); }); } @@ -109,7 +112,7 @@ public class SalesAnnouncementRepository extends RepositoryBase String message = resultSet.getString("message"); boolean enabled = resultSet.getBoolean("enabled"); - final SalesAnnouncementData data = new SalesAnnouncementData(aId, displayTo, message, enabled); + final SalesAnnouncementData data = new SalesAnnouncementData(Integer.valueOf(aId), displayTo, message, enabled); runSync(() -> { callback.run(data); @@ -139,7 +142,7 @@ public class SalesAnnouncementRepository extends RepositoryBase runSync(() -> callback.run(data)); } } - }, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true)); + }, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true), new ColumnBoolean("clans", _clans)); }); } @@ -147,7 +150,7 @@ public class SalesAnnouncementRepository extends RepositoryBase { runAsync(() -> { - executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId())); + executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId().intValue())); if (after != null) { runSync(after); @@ -159,7 +162,7 @@ public class SalesAnnouncementRepository extends RepositoryBase { runAsync(() -> { - executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId())); + executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId().intValue())); if (after != null) { runSync(after); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateCommand.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateCommand.java index 8c1c52054..16edeabc9 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateCommand.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateCommand.java @@ -4,16 +4,18 @@ import mineplex.serverdata.commands.ServerCommand; public class SalesAnnouncementUpdateCommand extends ServerCommand { - private String _id; + private Integer _id; private String _from; + private boolean _clans; - public SalesAnnouncementUpdateCommand(String id, String from) + public SalesAnnouncementUpdateCommand(Integer id, String from, boolean clans) { _id = id; _from = from; + _clans = clans; } - public String getId() + public Integer getId() { return _id; } @@ -22,4 +24,9 @@ public class SalesAnnouncementUpdateCommand extends ServerCommand { return _from; } + + public boolean isClans() + { + return _clans; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateHandler.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateHandler.java index 1c56c5ca6..d2771b953 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateHandler.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementUpdateHandler.java @@ -1,9 +1,8 @@ package mineplex.clanshub.salesannouncements; import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; -public class SalesAnnouncementUpdateHandler implements CommandCallback +public class SalesAnnouncementUpdateHandler implements CommandCallback { private final SalesAnnouncementManager _manager; @@ -13,16 +12,16 @@ public class SalesAnnouncementUpdateHandler implements CommandCallback } @Override - public void run(ServerCommand command) + public void run(SalesAnnouncementUpdateCommand command) { - if (!(command instanceof SalesAnnouncementUpdateCommand)) + if (_manager.getServer().equalsIgnoreCase(command.getFrom())) { return; } - if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementUpdateCommand) command).getFrom())) + if (_manager.CLANS != command.isClans()) { return; } - _manager.handleRemoteUpdate(Integer.parseInt(((SalesAnnouncementUpdateCommand)command).getId())); + _manager.handleRemoteUpdate(command.getId()); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementData.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementData.java index a7663e430..964962bf7 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementData.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementData.java @@ -12,12 +12,12 @@ import mineplex.core.itemstack.ItemBuilder; public class SalesAnnouncementData { - private final int _id; + private final Integer _id; private final Rank[] _displayTo; private final String _message; private boolean _enabled; - public SalesAnnouncementData(int id, Rank[] displayTo, String message, boolean enabled) + public SalesAnnouncementData(Integer id, Rank[] displayTo, String message, boolean enabled) { _id = id; _displayTo = displayTo; @@ -25,7 +25,7 @@ public class SalesAnnouncementData _enabled = enabled; } - public int getId() + public Integer getId() { return _id; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteCommand.java index f8244ec41..e7e1f0c7e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteCommand.java @@ -4,16 +4,17 @@ import mineplex.serverdata.commands.ServerCommand; public class SalesAnnouncementDeleteCommand extends ServerCommand { - private String _id; + private Integer _id; private String _from; + private boolean _clans; - public SalesAnnouncementDeleteCommand(String id, String from) + public SalesAnnouncementDeleteCommand(Integer id, String from, boolean clans) { _id = id; _from = from; } - public String getId() + public Integer getId() { return _id; } @@ -22,4 +23,9 @@ public class SalesAnnouncementDeleteCommand extends ServerCommand { return _from; } + + public boolean isClans() + { + return _clans; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteHandler.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteHandler.java index ec8a8934d..88071df75 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteHandler.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteHandler.java @@ -1,9 +1,8 @@ package mineplex.hub.modules.salesannouncements; import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; -public class SalesAnnouncementDeleteHandler implements CommandCallback +public class SalesAnnouncementDeleteHandler implements CommandCallback { private final SalesAnnouncementManager _manager; @@ -13,16 +12,16 @@ public class SalesAnnouncementDeleteHandler implements CommandCallback } @Override - public void run(ServerCommand command) + public void run(SalesAnnouncementDeleteCommand command) { - if (!(command instanceof SalesAnnouncementDeleteCommand)) + if (_manager.getServer().equalsIgnoreCase(command.getFrom())) { return; } - if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementDeleteCommand) command).getFrom())) + if (_manager.CLANS != command.isClans()) { return; } - _manager.handleRemoteDeletion(Integer.parseInt(((SalesAnnouncementDeleteCommand)command).getId())); + _manager.handleRemoteDeletion(command.getId()); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java index f91f399f8..b45cf8401 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java @@ -1,14 +1,13 @@ package mineplex.hub.modules.salesannouncements; -import java.util.List; +import java.util.HashMap; +import java.util.Map; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; -import com.google.common.collect.Lists; - import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; @@ -22,22 +21,23 @@ import mineplex.serverdata.commands.ServerCommandManager; public class SalesAnnouncementManager extends MiniPlugin { private static final String LINE = C.cDGreenB + C.Strike + "============================================="; - private final List _data = Lists.newArrayList(); + private final Map _data = new HashMap<>(); private final SalesAnnouncementRepository _repo; + public final boolean CLANS = false; public SalesAnnouncementManager(JavaPlugin plugin) { super("Sales", plugin); - _repo = new SalesAnnouncementRepository(plugin); + _repo = new SalesAnnouncementRepository(plugin, CLANS); _repo.loadAnnouncements(_data); addCommand(new SalesAnnouncementCommand(this)); - ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementUpdate", SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this)); - ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementDelete", SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this)); + ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this)); + ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this)); } - public List getLoadedAnnouncements() + public Map getLoadedAnnouncements() { return _data; } @@ -57,8 +57,8 @@ public class SalesAnnouncementManager extends MiniPlugin _repo.createAnnouncement(displayTo, message, data -> { UtilPlayer.message(creator, F.main(getName(), "Announcement successfully created!")); - _data.add(data); - new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish(); + _data.put(data.getId(), data); + new SalesAnnouncementUpdateCommand(data.getId(), getServer(), CLANS).publish(); }); } @@ -73,9 +73,9 @@ public class SalesAnnouncementManager extends MiniPlugin UtilPlayer.message(deletor, F.main(getName(), "Successfully deleted announcement!")); if (!forceRemoveFromList) { - _data.remove(data); + _data.remove(data.getId()); } - new SalesAnnouncementDeleteCommand(data.getId() + "", getServer()).publish(); + new SalesAnnouncementDeleteCommand(data.getId(), getServer(), CLANS).publish(); }); } @@ -85,23 +85,26 @@ public class SalesAnnouncementManager extends MiniPlugin _repo.updateAnnouncementStatus(data, () -> { UtilPlayer.message(toggler, F.main(getName(), "Successfully toggled announcement!")); - new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish(); + new SalesAnnouncementUpdateCommand(data.getId(), getServer(), CLANS).publish(); }); } public void handleRemoteDeletion(int id) { - _data.removeIf(data -> data.getId() == id); - UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + runSync(() -> + { + _data.remove(Integer.valueOf(id)); + UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + }); } public void handleRemoteUpdate(int id) { - if (_data.stream().filter(data -> data.getId() == id).toArray().length > 0) + if (_data.containsKey(Integer.valueOf(id))) { _repo.loadAnnouncement(id, data -> { - _data.stream().filter(existing -> existing.getId() == data.getId()).forEach(existing -> existing.setEnabled(data.isEnabled())); + _data.get(data.getId()).setEnabled(data.isEnabled()); UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); }); } @@ -109,7 +112,7 @@ public class SalesAnnouncementManager extends MiniPlugin { _repo.loadAnnouncement(id, data -> { - _data.add(data); + _data.put(data.getId(), data); UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); }); } @@ -118,7 +121,7 @@ public class SalesAnnouncementManager extends MiniPlugin @EventHandler public void onJoin(PlayerJoinEvent event) { - if (_data.isEmpty() || _data.stream().filter(data -> data.isEnabled()).toArray().length == 0) + if (_data.isEmpty() || !_data.values().stream().filter(data -> data.isEnabled()).findAny().isPresent()) { return; } @@ -127,7 +130,7 @@ public class SalesAnnouncementManager extends MiniPlugin runSyncLater(() -> { - _data.stream().filter(data -> data.isEnabled() && data.shouldDisplayTo(rank)).forEach(data -> + _data.values().stream().filter(data -> data.isEnabled() && data.shouldDisplayTo(rank)).forEach(data -> { player.sendMessage(" "); player.sendMessage(LINE); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementPage.java index c2be6a7b8..53990c319 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementPage.java @@ -36,10 +36,11 @@ public class SalesAnnouncementPage implements Listener private void setup() { _buttons.clear(); - for (int i = 0; i < _manager.getLoadedAnnouncements().size(); i++) + int i = 0; + for (SalesAnnouncementData data : _manager.getLoadedAnnouncements().values()) { - SalesAnnouncementData data = _manager.getLoadedAnnouncements().get(i); _buttons.put(i, new SalesAnnouncementButton(data, this)); + i++; } updateButtons(false); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java index 844a3b5ee..43584cd7e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java @@ -1,6 +1,8 @@ package mineplex.hub.modules.salesannouncements; +import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; @@ -9,7 +11,6 @@ import com.google.common.collect.Lists; import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; -import mineplex.core.database.MinecraftRepository; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnBoolean; @@ -18,20 +19,22 @@ import mineplex.serverdata.database.column.ColumnVarChar; public class SalesAnnouncementRepository extends RepositoryBase { - private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS salesAnnouncements (id INT NOT NULL AUTO_INCREMENT, ranks VARCHAR(250), message VARCHAR(256), enabled BOOL, PRIMARY KEY (id));"; + private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS salesAnnouncements (id INT NOT NULL AUTO_INCREMENT, ranks VARCHAR(250), message VARCHAR(256), enabled BOOL, clans BOOL, PRIMARY KEY (id), INDEX typeIndex (clans));"; - private static final String GET_ANNOUNCEMENTS = "SELECT * FROM salesAnnouncements;"; + private static final String GET_ANNOUNCEMENTS = "SELECT * FROM salesAnnouncements WHERE clans=?;"; private static final String GET_ANNOUNCEMENT = "SELECT * FROM salesAnnouncements WHERE id=?;"; private static final String UPDATE_ANNOUNCEMENT_STATUS = "UPDATE salesAnnouncements SET enabled=? WHERE id=?;"; - private static final String INSERT_ANNOUNCEMENT = "INSERT INTO salesAnnouncements (ranks, message, enabled) VALUES(?, ?, ?);"; + private static final String INSERT_ANNOUNCEMENT = "INSERT INTO salesAnnouncements (ranks, message, enabled, clans) VALUES(?, ?, ?, ?);"; private static final String DELETE_ANNOUNCEMENT = "DELETE FROM salesAnnouncements WHERE id=?;"; private final JavaPlugin _plugin; + private final boolean _clans; - public SalesAnnouncementRepository(JavaPlugin plugin) + public SalesAnnouncementRepository(JavaPlugin plugin, boolean clans) { super(DBPool.getAccount()); _plugin = plugin; + _clans = clans; } private void runAsync(Runnable runnable) @@ -44,13 +47,13 @@ public class SalesAnnouncementRepository extends RepositoryBase Bukkit.getScheduler().runTask(_plugin, runnable); } - public void loadAnnouncements(final List announcementList) + public void loadAnnouncements(final Map map) { runAsync(() -> { executeQuery(GET_ANNOUNCEMENTS, resultSet -> { - final List data = Lists.newArrayList(); + final List data = new ArrayList<>(); while (resultSet.next()) { int id = resultSet.getInt("id"); @@ -71,15 +74,15 @@ public class SalesAnnouncementRepository extends RepositoryBase String message = resultSet.getString("message"); boolean enabled = resultSet.getBoolean("enabled"); - data.add(new SalesAnnouncementData(id, displayTo, message, enabled)); + data.add(new SalesAnnouncementData(Integer.valueOf(id), displayTo, message, enabled)); } runSync(() -> { - announcementList.clear(); - data.forEach(sData -> announcementList.add(sData)); + map.clear(); + data.forEach(sData -> map.put(sData.getId(), sData)); }); - }); + }, new ColumnBoolean("clans", _clans)); }); } @@ -109,7 +112,7 @@ public class SalesAnnouncementRepository extends RepositoryBase String message = resultSet.getString("message"); boolean enabled = resultSet.getBoolean("enabled"); - final SalesAnnouncementData data = new SalesAnnouncementData(aId, displayTo, message, enabled); + final SalesAnnouncementData data = new SalesAnnouncementData(Integer.valueOf(aId), displayTo, message, enabled); runSync(() -> { callback.run(data); @@ -139,7 +142,7 @@ public class SalesAnnouncementRepository extends RepositoryBase runSync(() -> callback.run(data)); } } - }, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true)); + }, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true), new ColumnBoolean("clans", _clans)); }); } @@ -147,7 +150,7 @@ public class SalesAnnouncementRepository extends RepositoryBase { runAsync(() -> { - executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId())); + executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId().intValue())); if (after != null) { runSync(after); @@ -159,7 +162,7 @@ public class SalesAnnouncementRepository extends RepositoryBase { runAsync(() -> { - executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId())); + executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId().intValue())); if (after != null) { runSync(after); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateCommand.java index 698154e7c..c1735a5ba 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateCommand.java @@ -4,16 +4,18 @@ import mineplex.serverdata.commands.ServerCommand; public class SalesAnnouncementUpdateCommand extends ServerCommand { - private String _id; + private Integer _id; private String _from; + private boolean _clans; - public SalesAnnouncementUpdateCommand(String id, String from) + public SalesAnnouncementUpdateCommand(Integer id, String from, boolean clans) { _id = id; _from = from; + _clans = clans; } - public String getId() + public Integer getId() { return _id; } @@ -22,4 +24,9 @@ public class SalesAnnouncementUpdateCommand extends ServerCommand { return _from; } + + public boolean isClans() + { + return _clans; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateHandler.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateHandler.java index a9143764f..1939a18d4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateHandler.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementUpdateHandler.java @@ -1,9 +1,8 @@ package mineplex.hub.modules.salesannouncements; import mineplex.serverdata.commands.CommandCallback; -import mineplex.serverdata.commands.ServerCommand; -public class SalesAnnouncementUpdateHandler implements CommandCallback +public class SalesAnnouncementUpdateHandler implements CommandCallback { private final SalesAnnouncementManager _manager; @@ -13,16 +12,16 @@ public class SalesAnnouncementUpdateHandler implements CommandCallback } @Override - public void run(ServerCommand command) + public void run(SalesAnnouncementUpdateCommand command) { - if (!(command instanceof SalesAnnouncementUpdateCommand)) + if (_manager.getServer().equalsIgnoreCase(command.getFrom())) { return; } - if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementUpdateCommand) command).getFrom())) + if (_manager.CLANS != command.isClans()) { return; } - _manager.handleRemoteUpdate(Integer.parseInt(((SalesAnnouncementUpdateCommand)command).getId())); + _manager.handleRemoteUpdate(command.getId()); } } \ No newline at end of file diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java index 2153d4758..fcf12abca 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandCallback.java @@ -1,8 +1,6 @@ package mineplex.serverdata.commands; - public interface CommandCallback { - void run(T command); -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandType.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandType.java index 9f541b8b8..4fe680f44 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandType.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/CommandType.java @@ -1,18 +1,16 @@ package mineplex.serverdata.commands; - public class CommandType { - private Class _commandClazz; public Class getCommandType() { return _commandClazz; } - private CommandCallback _commandCallback; - public CommandCallback getCallback() { return _commandCallback; } + private CommandCallback _commandCallback; + public CommandCallback getCallback() { return _commandCallback; } - public CommandType(Class commandClazz, CommandCallback commandCallback) + public CommandType(Class commandClazz, CommandCallback commandCallback) { _commandClazz = commandClazz; _commandCallback = commandCallback; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java index 259a5ef5f..72f86461a 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/ServerCommandManager.java @@ -9,8 +9,6 @@ import mineplex.serverdata.Utility; import mineplex.serverdata.servers.ServerManager; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; -import redis.clients.jedis.JedisPoolConfig; -import redis.clients.jedis.exceptions.JedisConnectionException; public class ServerCommandManager { @@ -35,7 +33,7 @@ public class ServerCommandManager public boolean isServerInitialized() { return _localServerName != null; } public String getServerName() { - return this._localServerName; + return _localServerName; } /** @@ -46,7 +44,7 @@ public class ServerCommandManager _writePool = Utility.generatePool(ServerManager.getMasterConnection()); // Publish to master instance _readPool = Utility.generatePool(ServerManager.getSlaveConnection()); // Read from slave instance - _commandTypes = new HashMap(); + _commandTypes = new HashMap<>(); initialize(); } @@ -98,6 +96,7 @@ public class ServerCommandManager * @param commandType - the type of command being received * @param serializedCommand - the serialized {@link ServerCommand} data. */ + @SuppressWarnings({ "unchecked", "rawtypes" }) public void handleCommand(final String commandType, String serializedCommand) { if (!isServerInitialized()) @@ -163,4 +162,4 @@ public class ServerCommandManager return _instance; } -} +} \ No newline at end of file From 460cc29c0409a5c047dab7c5d35089c9e893d14e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 14 Jul 2017 06:31:03 -0400 Subject: [PATCH 097/183] Fix clan-mates and allies being able to force despawn mounts --- .../game/clans/clans/mounts/MountManager.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java index 2460ffea9..d262f4270 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java @@ -396,7 +396,7 @@ public class MountManager extends MiniDbClientPlugin } @EventHandler(priority = EventPriority.LOWEST) - public void handleHorseHits(CustomDamageEvent event) + public void redirectHorseDamage(CustomDamageEvent event) { if (event.GetDamageeEntity() == null || !(event.GetDamageeEntity() instanceof Horse)) { @@ -413,14 +413,16 @@ public class MountManager extends MiniDbClientPlugin mount.despawn(false); return; } - event.setDamagee(mount.getOwner()); - if (event.GetCause() != DamageCause.FALL) + if (mount.getEntity().getPassenger() == null) { - mount.handleHit(); + event.SetCancelled("Killing riderless mount"); + mount.despawn(true); + return; } + event.setDamagee(mount.getOwner()); } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void handleRiderHits(CustomDamageEvent event) { if (event.GetDamageePlayer() == null || event.GetDamageePlayer().getVehicle() == null || !(event.GetDamageePlayer().getVehicle() instanceof Horse)) From 82679aae8a3a3d5e3ad71caa5eb526c9ddac2bd2 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 14 Jul 2017 06:31:45 -0400 Subject: [PATCH 098/183] Kill players who log out during raids and force respawn players who die in raids --- .../clans/clans/worldevent/raid/RaidWorldEvent.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java index f3331ad5c..6903d35ab 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java @@ -251,7 +251,8 @@ public abstract class RaidWorldEvent extends WorldEvent } if (_players.remove(event.getPlayer())) { - event.getPlayer().teleport(Spawn.getNorthSpawn()); + event.getPlayer().setHealth(0); + event.getPlayer().spigot().respawn(); } } @@ -264,13 +265,7 @@ public abstract class RaidWorldEvent extends WorldEvent } if (_players.remove(event.getEntity())) { - event.getEntity().setHealth(event.getEntity().getMaxHealth()); - getCondition().Clean(event.getEntity()); - event.getEntity().getActivePotionEffects().forEach(pe -> event.getEntity().removePotionEffect(pe.getType())); - event.getEntity().setExp(0); - event.getEntity().setLevel(0); - event.getEntity().setFireTicks(-1); - event.getEntity().teleport(Spawn.getNorthSpawn()); + Manager.runSyncLater(() -> event.getEntity().spigot().respawn(), 10); } } From 7054706b0f5f8aef534aa856c69737532c15fb2a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 14 Jul 2017 06:32:05 -0400 Subject: [PATCH 099/183] Begin work on clans capture point event --- .../capturepoint/CapturePointEvent.java | 37 +++++++++++++++++++ .../capturepoint/CapturePointLocation.java | 30 +++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java new file mode 100644 index 000000000..663bd3850 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java @@ -0,0 +1,37 @@ +package mineplex.game.clans.clans.worldevent.capturepoint; + +import mineplex.core.common.util.UtilWorld; +import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; + +public class CapturePointEvent extends WorldEvent +{ + public CapturePointEvent(WorldEventManager manager) + { + super("Capture Point", CapturePointLocation.getRandomLocation().toLocation(UtilWorld.getWorld("world")), 5, true, manager.getDisguiseManager(), manager.getClans().getProjectile(), manager.getDamage(), manager.getBlockRestore(), manager.getClans().getCondition()); + } + + @Override + protected void customStart() + { + + } + + @Override + protected void customTick() + { + + } + + @Override + public void customCleanup(boolean onDisable) + { + + } + + @Override + protected void customStop() + { + + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java new file mode 100644 index 000000000..cd205cb7f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointLocation.java @@ -0,0 +1,30 @@ +package mineplex.game.clans.clans.worldevent.capturepoint; + +import java.util.concurrent.ThreadLocalRandom; + +import org.bukkit.Location; +import org.bukkit.World; + +public enum CapturePointLocation +{ + ; + + private final double _x, _y, _z; + + private CapturePointLocation(double x, double y, double z) + { + _x = x; + _y = y; + _z = z; + } + + public Location toLocation(World world) + { + return new Location(world, _x, _y, _z); + } + + public static CapturePointLocation getRandomLocation() + { + return CapturePointLocation.values()[ThreadLocalRandom.current().nextInt(CapturePointLocation.values().length)]; + } +} \ No newline at end of file From fdaa267f3e0e14118d978eada36156b8156fb3e5 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 14 Jul 2017 06:33:10 -0400 Subject: [PATCH 100/183] Remove the bow from clans custom item durabilities --- .../src/mineplex/game/clans/gameplay/DurabilityManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java index 995598c15..da8fc5cca 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DurabilityManager.java @@ -61,7 +61,6 @@ public class DurabilityManager implements Listener _itemDurabilities.put(Material.LEATHER_CHESTPLATE, 900); _itemDurabilities.put(Material.LEATHER_LEGGINGS, 900); _itemDurabilities.put(Material.LEATHER_BOOTS, 900); - _itemDurabilities.put(Material.BOW, 900); } private boolean canRepair(ItemStack item) From 5e540ea995006ba2356373298e6939e9577a00cf Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 14 Jul 2017 06:34:11 -0400 Subject: [PATCH 101/183] Increase legendary drop rate from raids and world bosses --- .../src/mineplex/game/clans/items/GearManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index dfb7547ea..0b439df86 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -102,9 +102,9 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable // Weightings for randomly selecting item type (legendary/weapon/armor/bow) private static final WeightSet TYPE_WEIGHTS = new WeightSet( - new Weight<>(6, ItemType.LEGENDARY), + new Weight<>(9, ItemType.LEGENDARY), new Weight<>(9, ItemType.RARE), - new Weight<>(46 - 9, ItemType.ARMOR), + new Weight<>(34, ItemType.ARMOR), new Weight<>(25, ItemType.WEAPON), new Weight<>(23, ItemType.BOW) ); From 0b902e3f6f7043ae6da825cda84fcf6ffcc3c7bf Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 14 Jul 2017 06:34:44 -0400 Subject: [PATCH 102/183] Fix the Scythe of the Fallen Lord healing the user when hitting allies and clan-mates --- .../game/clans/items/legendaries/DemonicScythe.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java index b054624ad..a35cd627e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java @@ -10,7 +10,8 @@ public class DemonicScythe extends LegendaryItem { public DemonicScythe() { - super("Scythe of the Fallen Lord", new String[]{ + super("Scythe of the Fallen Lord", new String[] + { C.cWhite + "An old blade fashioned of nothing more", C.cWhite + "than bones and cloth which served no", C.cWhite + "purpose. Brave adventurers however have", @@ -24,7 +25,10 @@ public class DemonicScythe extends LegendaryItem @Override public void onAttack(CustomDamageEvent event, Player wielder) { - event.AddMod("Scythe of the Fallen Lord", 8); - wielder.setHealth(Math.min(wielder.getMaxHealth(), wielder.getHealth() + 2)); + if (!event.isCancelled()) + { + event.AddMod("Scythe of the Fallen Lord", 8); + wielder.setHealth(Math.min(wielder.getMaxHealth(), wielder.getHealth() + 2)); + } } } \ No newline at end of file From c2a46c14edf179c5a4a1fcc09a3dc22ed66bc9ae Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 14 Jul 2017 06:35:05 -0400 Subject: [PATCH 103/183] Allow weapon runes to be added to the Scythe of the Fallen Lord --- .../src/mineplex/game/clans/items/runes/RuneManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java index eb3ba28fd..20fa3c7d9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java @@ -353,7 +353,7 @@ public class RuneManager implements Listener { return true; } - if (type == Material.RECORD_4 || type == Material.GOLD_RECORD || type == Material.RECORD_3 || type == Material.RECORD_5 || type == Material.GREEN_RECORD) + if (type == Material.RECORD_4 || type == Material.GOLD_RECORD || type == Material.RECORD_3 || type == Material.RECORD_5 || type == Material.GREEN_RECORD || type == Material.RECORD_8) { return true; } From 7354c4dc1c5ce73de0ced346ed071a67bcbb968f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 14 Jul 2017 06:36:28 -0400 Subject: [PATCH 104/183] Allow access to clans blacklisting from core, make GWEN issue 90-day clans blacklists for instabans and banwaves --- .../src/mineplex/core/antihack/AntiHack.java | 50 ++++-- .../core/antihack/banwave/BanWaveInfo.java | 2 +- .../core/antihack/banwave/BanWaveManager.java | 4 +- .../src/mineplex/core/punish/Punish.java | 17 +- .../mineplex/core/punish/clans}/ClansBan.java | 6 +- .../core/punish/clans}/ClansBanClient.java | 5 +- .../core/punish/clans/ClansBanManager.java | 161 ++++++++++++++++++ .../punish/clans}/ClansBanRepository.java | 44 +++-- .../clans/command}/ClansBanCommand.java | 33 ++-- .../clans/redis/ClansBanNotification.java | 27 +++ .../core/punish/clans}/ui/ClansBanPage.java | 75 ++++---- .../core/punish/clans}/ui/ClansBanShop.java | 13 +- .../src/mineplex/game/clans/Clans.java | 10 +- .../game/clans/clans/ClansManager.java | 11 +- .../game/clans/clans/ban/ClansBanCache.java | 26 --- .../clans/clans/commands/KillCommand.java | 28 +-- .../ClansFreezeManager.java} | 79 +-------- .../commands/FreezeCommand.java | 8 +- .../commands/UnfreezeCommand.java | 8 +- .../game/clans/gameplay/Gameplay.java | 2 +- .../game/clans/gameplay/safelog/SafeLog.java | 4 +- .../minecraft/game/core/combat/CombatLog.java | 6 +- 22 files changed, 381 insertions(+), 238 deletions(-) rename Plugins/{Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban => Mineplex.Core/src/mineplex/core/punish/clans}/ClansBan.java (94%) rename Plugins/{Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban => Mineplex.Core/src/mineplex/core/punish/clans}/ClansBanClient.java (90%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java rename Plugins/{Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban => Mineplex.Core/src/mineplex/core/punish/clans}/ClansBanRepository.java (90%) rename Plugins/{Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands => Mineplex.Core/src/mineplex/core/punish/clans/command}/ClansBanCommand.java (65%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/punish/clans/redis/ClansBanNotification.java rename Plugins/{Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban => Mineplex.Core/src/mineplex/core/punish/clans}/ui/ClansBanPage.java (71%) rename Plugins/{Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban => Mineplex.Core/src/mineplex/core/punish/clans}/ui/ClansBanShop.java (68%) delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanCache.java rename Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/{ban/ClansBanManager.java => freeze/ClansFreezeManager.java} (80%) rename Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/{ban => freeze}/commands/FreezeCommand.java (81%) rename Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/{ban => freeze}/commands/UnfreezeCommand.java (81%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 97cdfe07c..8dabca492 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -158,7 +158,7 @@ public class AntiHack extends MiniPlugin require(GuardianManager.class); _banWaveManager = require(BanWaveManager.class); - Bukkit.getServicesManager().register(MineplexLink.class, new MineplexLinkImpl(), this._plugin, ServicePriority.Normal); + Bukkit.getServicesManager().register(MineplexLink.class, new MineplexLinkImpl(), _plugin, ServicePriority.Normal); ServerCommandManager.getInstance().registerCommandType(MajorViolationCommand.class, violation -> { @@ -167,9 +167,13 @@ public class AntiHack extends MiniPlugin for (Player player : Bukkit.getOnlinePlayers()) { if (_detailedMessages.contains(player.getName())) + { player.spigot().sendMessage(detailed); + } else if (_clientManager.Get(player).GetRank().has(Rank.HELPER) && (violation.getOriginatingServer().equals(_thisServer) || _preferences.get(player).isActive(Preference.GLOBAL_GWEN_REPORTS))) + { player.spigot().sendMessage(minimal); + } } }); @@ -222,12 +226,19 @@ public class AntiHack extends MiniPlugin { Consumer> doPunish = after -> { - runAsync(() -> - { - new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id, gep).publish(); - }); + runAsync(() -> + { + new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id, gep).publish(); + }); - _punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, hoursBanned, true, after); + _punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, hoursBanned, true, after); + if (UtilServer.getGroup().equals("Clans")) + { + _punish.getClansPunish().loadClient(coreClient.getUniqueId(), client -> + { + _punish.getClansPunish().ban(client, null, AntiHack.NAME, 90 * 24 * 60 * 60 * 1000, finalMessage, null, ban -> {}); + }); + } }; if (coreClient.GetRank().has(Rank.TWITCH)) @@ -266,14 +277,21 @@ public class AntiHack extends MiniPlugin Consumer> doPunish = after -> { - _punish.AddPunishment(coreClient.getName(), Category.Hacking, info.getMessage(), AntiHack.NAME, 3, true, getHoursBanned(player), true, after); + final int hoursBanned = getHoursBanned(player); + _punish.AddPunishment(coreClient.getName(), Category.Hacking, info.getMessage(), AntiHack.NAME, 3, true, hoursBanned, true, after); + String[] serverSplit = info.getServer().split("-"); + if (serverSplit.length > 0 && serverSplit[0].equals("Clans")) + { + _punish.getClansPunish().loadClient(coreClient.getUniqueId(), client -> + { + _punish.getClansPunish().ban(client, null, AntiHack.NAME, 90 * 24 * 60 * 60 * 1000, info.getMessage(), null, ban -> {}); + }); + } }; if (coreClient.GetRank().has(Rank.TWITCH)) { - doPunish.accept(response -> - { - }); + doPunish.accept(response -> {}); } else { @@ -332,14 +350,18 @@ public class AntiHack extends MiniPlugin public void on(EntityDamageEvent event) { if (_pendingBan.contains(event.getEntity())) + { event.setCancelled(true); + } } @EventHandler(priority = EventPriority.LOWEST) public void on(EntityDamageByEntityEvent event) { if (_pendingBan.contains(event.getDamager())) + { event.setCancelled(true); + } } public int getPunishments(Player player) @@ -414,7 +436,9 @@ public class AntiHack extends MiniPlugin } if (_ignoredChecks.contains(event.getCheckClass())) + { return; + } ACTIONS.getOrDefault(event.getCheckClass(), NOOP_ACTION).handle(event); @@ -434,7 +458,7 @@ public class AntiHack extends MiniPlugin MajorViolationCommand command = new MajorViolationCommand(_thisServer, event.getPlayer().getName(), CheckManager.getCheckSimpleName(event.getCheckClass()), event.getViolations(), event.getMessage()); ServerCommandManager.getInstance().publishCommand(command); - this._cooldown.put(key, event.getViolations()); + _cooldown.put(key, event.getViolations()); } } @@ -525,6 +549,6 @@ public class AntiHack extends MiniPlugin public void setStrict(boolean strict) { - this._strict = strict; + _strict = strict; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java index 2c471cd07..d9ff6e428 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveInfo.java @@ -116,4 +116,4 @@ public class BanWaveInfo { return Objects.hash(_accountId, _timeToBan, _hackType, _message, _vl, _server); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java index 7123a383c..9c56787e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java @@ -62,7 +62,7 @@ public class BanWaveManager extends MiniPlugin CoreClient client = _clientManager.Get(player); - if (this._repository.insertBanWaveInfo(client.getAccountId(), timeToBan, CheckManager.getCheckSimpleName(checkClass), newMessage, vl, server)) + if (_repository.insertBanWaveInfo(client.getAccountId(), timeToBan, CheckManager.getCheckSimpleName(checkClass), newMessage, vl, server)) { runAsync(() -> { @@ -81,4 +81,4 @@ public class BanWaveManager extends MiniPlugin { _repository.flagDone(client.getAccountId()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java index 1a26d65c4..d905ec7bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java @@ -4,7 +4,6 @@ import java.util.HashMap; import java.util.function.Consumer; import java.util.logging.Level; -import mineplex.core.account.CoreClient; import org.bukkit.Bukkit; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -21,6 +20,7 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.ClientWebResponseEvent; import mineplex.core.common.Constants; @@ -36,6 +36,7 @@ import mineplex.core.punish.Command.PunishCommand; import mineplex.core.punish.Command.RulesCommand; import mineplex.core.punish.Tokens.PunishClientToken; import mineplex.core.punish.Tokens.PunishmentToken; +import mineplex.core.punish.clans.ClansBanManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.commands.AddPunishCommand; @@ -47,18 +48,30 @@ public class Punish extends MiniPlugin private HashMap _punishClients; private PunishRepository _repository; private CoreClientManager _clientManager; + private ClansBanManager _clansPunish; public Punish(JavaPlugin plugin, CoreClientManager clientManager) + { + this(plugin, clientManager, false); + } + + public Punish(JavaPlugin plugin, CoreClientManager clientManager, boolean clansServer) { super("Punish", plugin); - + _punishClients = new HashMap(); _clientManager = clientManager; _repository = new PunishRepository(); + _clansPunish = new ClansBanManager(plugin, clientManager, clansServer); ServerCommandManager.getInstance().registerCommandType("PunishCommand", mineplex.serverdata.commands.PunishCommand.class, new PunishmentHandler(this)); } + public ClansBanManager getClansPunish() + { + return _clansPunish; + } + public PunishRepository GetRepository() { return _repository; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBan.java similarity index 94% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java rename to Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBan.java index 60ae2b90f..1b1c092e4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBan.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.clans.ban; +package mineplex.core.punish.clans; import java.sql.Timestamp; import java.util.UUID; @@ -7,7 +7,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTime; /** - * Stores the information about a ban in Clans. + * Stores the information about a blacklist in Clans. */ public class ClansBan { @@ -98,4 +98,4 @@ public class ClansBan { _removed = true; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanClient.java similarity index 90% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java rename to Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanClient.java index 10ad60f2b..6710f4dd0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanClient.java @@ -1,14 +1,13 @@ -package mineplex.game.clans.clans.ban; +package mineplex.core.punish.clans; import java.util.List; -import java.util.Set; import java.util.UUID; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTime; /** - * Signifies a player on clans, and a Set of their current clan bans. + * A client representing a player and a List of their Clans blacklists */ public class ClansBanClient { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java new file mode 100644 index 000000000..48d273a61 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java @@ -0,0 +1,161 @@ +package mineplex.core.punish.clans; + +import java.util.Optional; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.function.Consumer; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.AsyncPlayerPreLoginEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.punish.clans.command.ClansBanCommand; +import mineplex.core.punish.clans.redis.ClansBanNotification; +import mineplex.serverdata.commands.ServerCommandManager; + +public class ClansBanManager extends MiniPlugin +{ + private final CoreClientManager _clientManager; + private final ClansBanRepository _repository; + private final boolean _fullOperation; + + public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, boolean fullOperation) + { + super("Clans Blacklist", plugin); + + _clientManager = clientManager; + + _repository = new ClansBanRepository(plugin); + + _fullOperation = fullOperation; + + if (_fullOperation) + { + ServerCommandManager.getInstance().registerCommandType(ClansBanNotification.class, notification -> + { + runSync(() -> + { + if (Bukkit.getPlayer(notification.getTarget()) != null) + { + Bukkit.getPlayer(notification.getTarget()).kickPlayer(C.cRedB + "You have been banned from Clans " + notification.getBanTimeFormatted() + "."); + } + }); + }); + } + } + + @Override + public void addCommands() + { + addCommand(new ClansBanCommand(this)); + } + + public CoreClientManager getClientManager() + { + return _clientManager; + } + + public ClansBanRepository getRepository() + { + return _repository; + } + + public void loadClient(String name, Consumer> callback) + { + _repository.loadClient(name).thenAccept(client -> runSync(() -> callback.accept(client))); + } + + public void loadClient(UUID uuid, Consumer callback) + { + _repository.loadClient(uuid).thenAccept(client -> runSync(() -> callback.accept(client))); + } + + public void ban(ClansBanClient target, String targetName, String admin, long duration, String reason, Player caller, Consumer> callback) + { + _repository.ban(target._uuid, admin, duration, reason).thenAccept(ban -> runSync(() -> + { + if (ban.isPresent()) + { + target._bans.add(ban.get()); + String banTimeFormatted = target.getBanTimeFormatted(); + + if (targetName != null) + { + for (Player notify : Bukkit.getOnlinePlayers()) + { + if (_clientManager.Get(notify).GetRank().has(notify, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false)) + { + UtilPlayer.message(notify, F.main(getName(), F.elem(targetName) + " is now banned " + banTimeFormatted + ".")); + } + } + } + if (_fullOperation && Bukkit.getPlayer(target._uuid) != null) + { + Bukkit.getPlayer(target._uuid).kickPlayer(C.cRedB + "You have been banned from Clans " + banTimeFormatted + "."); + } + new ClansBanNotification(target._uuid, banTimeFormatted).publish(); + } + else + { + if (caller != null && targetName != null) + { + UtilPlayer.message(caller, F.main(getName(), C.cRed + "An issue occurred when trying to ban " + F.elem(targetName))); + } + } + callback.accept(ban); + })); + } + + public void unban(ClansBanClient target, ClansBan ban, Runnable callback) + { + if (!target._uuid.equals(ban.getUUID())) + { + return; + } + + ban.remove(); + _repository.removeBan(ban); + + callback.run(); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onLogin(AsyncPlayerPreLoginEvent event) + { + if (!_fullOperation) + { + return; + } + try + { + ClansBanClient client = _repository.loadClient(event.getUniqueId()).get(); + + if (client.isBanned()) + { + String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT); + + if (client.getLongestBan().isPermanent()) + { + time = "Permanent"; + } + + String reason = C.cRedB + "You are banned from Clans for " + time + + "\n" + C.cWhite + client.getLongestBan().getReason(); + + event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, reason); + } + } + catch (Exception ignored) {} + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanRepository.java similarity index 90% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java rename to Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanRepository.java index 3d5c798cc..3444e3eb0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanRepository.java @@ -1,20 +1,24 @@ -package mineplex.game.clans.clans.ban; +package mineplex.core.punish.clans; -import mineplex.core.Managers; -import mineplex.core.account.CoreClientManager; -import mineplex.core.database.MinecraftRepository; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnInt; -import org.bukkit.plugin.java.JavaPlugin; - -import java.sql.*; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.UUID; import java.util.concurrent.CompletableFuture; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; + public class ClansBanRepository extends RepositoryBase { private static final String BAN_PLAYER = "INSERT INTO clanBans (uuid, admin, reason, banTime, unbanTime, permanent, removed) VALUES (?, ?, ?, ?, ?, ?, ?);"; @@ -50,18 +54,22 @@ public class ClansBanRepository extends RepositoryBase { int id = resultSet.getInt(1); return Optional.of(new ClansBan(id, uuid, admin, reason, banTime, unbanTime, time == -1, false)); - } else + } + else { return Optional.empty(); } - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); return Optional.empty(); } }); } - public CompletableFuture loadClient(UUID uuid) { + public CompletableFuture loadClient(UUID uuid) + { return CompletableFuture.supplyAsync(() -> { try (Connection conn = DBPool.getAccount().getConnection()) @@ -87,7 +95,9 @@ public class ClansBanRepository extends RepositoryBase } return new ClansBanClient(uuid, bans); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); return new ClansBanClient(uuid, new ArrayList<>()); } @@ -106,7 +116,9 @@ public class ClansBanRepository extends RepositoryBase CompletableFuture> future = new CompletableFuture<>(); future.complete(Optional.empty()); return future; - } else { + } + else + { return loadClient(uuid).thenApply(Optional::of); } }); @@ -116,4 +128,4 @@ public class ClansBanRepository extends RepositoryBase { executeUpdate(REMOVE_BAN, new ColumnInt("id", ban.getId())); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/command/ClansBanCommand.java similarity index 65% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/punish/clans/command/ClansBanCommand.java index 3275072c5..7daa6e7d7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/ClansBanCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/command/ClansBanCommand.java @@ -1,13 +1,13 @@ -package mineplex.game.clans.clans.ban.commands; +package mineplex.core.punish.clans.command; -import mineplex.game.clans.clans.ban.ui.ClansBanShop; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; -import mineplex.game.clans.clans.ban.ClansBanManager; +import mineplex.core.punish.clans.ClansBanManager; +import mineplex.core.punish.clans.ui.ClansBanShop; public class ClansBanCommand extends CommandBase { @@ -35,23 +35,22 @@ public class ClansBanCommand extends CommandBase } final String finalReason = reason; - - Plugin.getRepository().loadClient(playerName) - .thenAccept(maybeClient -> - Plugin.runSync(() -> - { - if (!maybeClient.isPresent()) - { - UtilPlayer.message(caller, C.cRed + "Could not find player with name " + C.cYellow + playerName); - } else - { - new ClansBanShop(Plugin, playerName, maybeClient.get(), finalReason).attemptShopOpen(caller); - } - })); + + Plugin.loadClient(playerName, client -> + { + if (client.isPresent()) + { + new ClansBanShop(Plugin, playerName, client.get(), finalReason).attemptShopOpen(caller); + } + else + { + UtilPlayer.message(caller, C.cRed + "Could not find player with name " + C.cYellow + playerName); + } + }); } else { UtilPlayer.message(caller, C.cBlue + "/cb " + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view their past bans."); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/redis/ClansBanNotification.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/redis/ClansBanNotification.java new file mode 100644 index 000000000..cf7829069 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/redis/ClansBanNotification.java @@ -0,0 +1,27 @@ +package mineplex.core.punish.clans.redis; + +import java.util.UUID; + +import mineplex.serverdata.commands.ServerCommand; + +public class ClansBanNotification extends ServerCommand +{ + private final UUID _target; + private final String _banTimeFormatted; + + public ClansBanNotification(UUID target, String banTimeFormatted) + { + _target = target; + _banTimeFormatted = banTimeFormatted; + } + + public UUID getTarget() + { + return _target; + } + + public String getBanTimeFormatted() + { + return _banTimeFormatted; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanPage.java similarity index 71% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java rename to Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanPage.java index b15f69518..bbe04bf90 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanPage.java @@ -1,21 +1,21 @@ -package mineplex.game.clans.clans.ban.ui; +package mineplex.core.punish.clans.ui; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.shop.page.ShopPageBase; -import mineplex.game.clans.clans.ban.ClansBan; -import mineplex.game.clans.clans.ban.ClansBanClient; -import mineplex.game.clans.clans.ban.ClansBanManager; -import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; +import mineplex.core.Managers; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTime; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.punish.clans.ClansBan; +import mineplex.core.punish.clans.ClansBanClient; +import mineplex.core.punish.clans.ClansBanManager; +import mineplex.core.shop.page.ShopPageBase; + public class ClansBanPage extends ShopPageBase { private long _time; @@ -28,7 +28,7 @@ public class ClansBanPage extends ShopPageBase public ClansBanPage(final ClansBanManager banManager, final ClansBanShop shop, final String name, final Player player, String victimName, ClansBanClient client, String reason) { - super(banManager, shop, banManager.getClientManager(), banManager.getDonationManager(), name, player); + super(banManager, shop, banManager.getClientManager(), Managers.get(DonationManager.class), name, player); _reason = reason; @@ -71,7 +71,8 @@ public class ClansBanPage extends ShopPageBase C.cRed + C.Italics + "Left-Click to BAN PLAYER", C.cGray + C.Italics + "Right-Click to toggle permanent ban setting" ).build(), - (player, click) -> { + (player, click) -> + { if (click == ClickType.RIGHT) { _permanent = !_permanent; @@ -99,13 +100,16 @@ public class ClansBanPage extends ShopPageBase .setGlow(ban.isActive()) .build(); - addButton(slot++, item, (player, click) -> { + addButton(slot++, item, (player, click) -> + { if (ban.isActive()) { - getPlugin().runAsync(() -> { - getPlugin().unban(_victimClient, ban, client -> { + getPlugin().runAsync(() -> + { + getPlugin().unban(_victimClient, ban, () -> + { refresh(); - player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f); + playAcceptSound(player); }); }); } @@ -115,32 +119,27 @@ public class ClansBanPage extends ShopPageBase private void performBan() { - getPlugin().getRepository().ban(_victimClient._uuid, getPlayer().getName(), _permanent ? -1 : _time, _reason) - .thenAccept(maybeBan -> getPlugin().runSync(() -> - { - if (maybeBan.isPresent()) - { - _victimClient._bans.add(maybeBan.get()); - - String banTimeFormatted = _victimClient.getBanTimeFormatted(); - UtilPlayer.message(getPlayer(), F.main("Clans", F.elem(_victimName) + " is now banned " + banTimeFormatted + ".")); - - Player target = Bukkit.getPlayer(_victimClient._uuid); - target.kickPlayer(C.cRedB + "You have been banned from Clans " + banTimeFormatted + "."); - refresh(); - } else - { - F.main("Clans", C.cRed + "An issue occurred when trying to ban " + F.elem(_victimName)); - } - })); + getPlugin().ban(_victimClient, _victimName, getPlayer().getName(), _permanent ? -1 : _time, _reason, getPlayer(), ban -> + { + if (ban.isPresent()) + { + playAcceptSound(getPlayer()); + refresh(); + } + else + { + playDenySound(getPlayer()); + } + }); } private void addTimeAdjuster(int index, long time) { addButton(index, new ItemBuilder(Material.PAPER).setTitle(C.cRed + (time < 0 ? "-" : "") + UtilTime.MakeStr(Math.abs(time))).build(), - (player, click) -> { + (player, click) -> + { _time += time; refresh(); }); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanShop.java similarity index 68% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java rename to Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanShop.java index 375e52b43..e1c404ebc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ui/ClansBanShop.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanShop.java @@ -1,11 +1,13 @@ -package mineplex.game.clans.clans.ban.ui; +package mineplex.core.punish.clans.ui; -import mineplex.game.clans.clans.ban.ClansBanClient; import org.bukkit.entity.Player; +import mineplex.core.Managers; +import mineplex.core.donation.DonationManager; +import mineplex.core.punish.clans.ClansBanClient; +import mineplex.core.punish.clans.ClansBanManager; import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; -import mineplex.game.clans.clans.ban.ClansBanManager; public class ClansBanShop extends ShopBase { @@ -15,7 +17,7 @@ public class ClansBanShop extends ShopBase public ClansBanShop(final ClansBanManager plugin, String victimName, ClansBanClient client, String reason) { - super(plugin, plugin.getClientManager(), plugin.getDonationManager(), "Clans Punish"); + super(plugin, plugin.getClientManager(), Managers.get(DonationManager.class), "Clans Punish"); _clientName = victimName; _client = client; _reason = reason; @@ -25,6 +27,5 @@ public class ClansBanShop extends ShopBase protected ShopPageBase> buildPagesFor(final Player player) { return new ClansBanPage(getPlugin(), this, "Clans Punish", player, _clientName, _client, _reason); - } - + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index ed924a65f..487ea34ce 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -66,7 +66,7 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.visibility.VisibilityManager; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.ban.ClansBanManager; +import mineplex.game.clans.clans.freeze.ClansFreezeManager; import mineplex.game.clans.items.GearManager; import mineplex.game.clans.shop.building.BuildingShop; import mineplex.game.clans.shop.farming.FarmingShop; @@ -143,9 +143,9 @@ public class Clans extends JavaPlugin Portal portal = new Portal(); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion(), GenericServer.CLANS_HUB); - ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager); + ClansFreezeManager clansFreeze = new ClansFreezeManager(this, _clientManager); - Punish punish = new Punish(this, _clientManager); + Punish punish = new Punish(this, _clientManager, true); DisguiseManager disguiseManager = require(DisguiseManager.class); Creature creature = new Creature(this); @@ -187,7 +187,7 @@ public class Clans extends JavaPlugin GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager); HologramManager hologram = new HologramManager(this, packetHandler); - _clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, inventory); + _clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, inventory); new Recipes(this); new Farming(this); new BuildingShop(_clansManager, _clientManager, _donationManager); @@ -243,4 +243,4 @@ public class Clans extends JavaPlugin { return MAP; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 8d872a932..941756e20 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -90,7 +90,6 @@ import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.amplifiers.AmplifierManager; -import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.banners.BannerManager; import mineplex.game.clans.clans.boxes.BoxManager; import mineplex.game.clans.clans.commands.ClanManagementCommand; @@ -98,7 +97,6 @@ import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand; import mineplex.game.clans.clans.commands.ClansCommand; import mineplex.game.clans.clans.commands.KillCommand; -import mineplex.game.clans.clans.commands.MapCommand; import mineplex.game.clans.clans.commands.RegionsCommand; import mineplex.game.clans.clans.commands.SpeedCommand; import mineplex.game.clans.clans.data.PlayerClan; @@ -106,7 +104,6 @@ import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; import mineplex.game.clans.clans.gui.ClanShop; import mineplex.game.clans.clans.invsee.InvseeManager; import mineplex.game.clans.clans.loot.LootManager; -import mineplex.game.clans.clans.map.ItemMapManager; import mineplex.game.clans.clans.mounts.MountManager; import mineplex.game.clans.clans.nameblacklist.ClansBlacklist; import mineplex.game.clans.clans.nether.NetherManager; @@ -115,7 +112,6 @@ import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.potato.PotatoManager; import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler; import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; -import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.siege.SiegeManager; @@ -124,6 +120,7 @@ import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager; import mineplex.game.clans.clans.war.WarManager; import mineplex.game.clans.clans.warpoints.WarPointEvasion; import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.ClanDeleteCommand; import mineplex.game.clans.core.ClanLoadCommand; import mineplex.game.clans.core.repository.ClanTerritory; @@ -257,7 +254,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati // Spawn area - public ClansManager(JavaPlugin plugin, ClansBanManager clansBans, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, InventoryManager inventoryManager) + public ClansManager(JavaPlugin plugin, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, InventoryManager inventoryManager) { super("Clans Manager", plugin); @@ -288,7 +285,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati _npcManager = new NpcManager(plugin, Managers.get(Creature.class)); _condition = new SkillConditionManager(plugin); _damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition); - _damageManager.addCommand(new KillCommand(_damageManager)); _condition.setDamageManager(_damageManager); _worldEvent = new WorldEventManager(plugin, this, _damageManager, _lootManager, blockRestore, _clanRegions, null); @@ -494,6 +490,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati addCommand(new ClanManagementCommand(this)); // addCommand(new MapCommand(this)); addCommand(new SpeedCommand(this)); + addCommand(new KillCommand(this)); } public void loadClan(ClanToken clanToken, boolean loadBanner) @@ -515,7 +512,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati } if (loadBanner) + { _bannerManager.loadBanner(clan); + } } public void loadClan(ClanToken clanToken) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanCache.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanCache.java deleted file mode 100644 index 73178787c..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanCache.java +++ /dev/null @@ -1,26 +0,0 @@ -package mineplex.game.clans.clans.ban; - -/** - * Stores the data provided through the /cban (Clans ban) command for use further in the plugin. - */ -public class ClansBanCache -{ - private String _victim; - private String _reason; - - public ClansBanCache(String victim, String reason) - { - _victim = victim; - _reason = reason; - } - - public String getVictim() - { - return _victim; - } - - public String getReason() - { - return _reason; - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java index 7f9b6f85a..c95ab485a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java @@ -1,17 +1,19 @@ package mineplex.game.clans.clans.commands; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClansManager; -import mineplex.minecraft.game.core.damage.DamageManager; +import mineplex.game.clans.spawn.Spawn; -import org.bukkit.entity.Player; - -public class KillCommand extends CommandBase +public class KillCommand extends CommandBase { - public KillCommand(DamageManager plugin) + public KillCommand(ClansManager plugin) { super(plugin, Rank.ALL, "suicide", "kill"); } @@ -19,26 +21,26 @@ public class KillCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if ((System.currentTimeMillis() - Plugin.GetCombatManager().Get(caller).GetLastCombat()) <= 20000) + if (!UtilTime.elapsed(Plugin.getCombatManager().Get(caller).GetLastDamaged(), Spawn.COMBAT_TAG_DURATION)) { UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in combat.")); return; } - if(ClansManager.getInstance().getTutorial().inTutorial(caller)) + if (Plugin.getTutorial().inTutorial(caller)) { UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in the tutorial.")); return; } - if (mineplex.core.recharge.Recharge.Instance.use(caller, "Suicide", 5000, false, false)) - { - UtilPlayer.message(caller, F.main("Clans", "Please wait a bit before suiciding")); - return; - } - if (ClansManager.getInstance().getClanUtility().isSafe(caller.getLocation()) || (ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()) != null && ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equalsIgnoreCase("Spawn"))) + if (Plugin.getClanUtility().isSafe(caller.getLocation()) || (Plugin.getClanUtility().getClaim(caller.getLocation()) != null && Plugin.getClanUtility().getClaim(caller.getLocation()).Owner.equalsIgnoreCase("Spawn"))) { UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in a safezone!")); return; } + if (Recharge.Instance.use(caller, "Suicide", 5000, false, false)) + { + UtilPlayer.message(caller, F.main("Clans", "Run the command again to confirm.")); + return; + } UtilPlayer.message(caller, F.main("Clans", "You have imploded.")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java similarity index 80% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java index ab8e38228..0b6ca5355 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/ClansBanManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.clans.ban; +package mineplex.game.clans.clans.freeze; import java.util.HashMap; import java.util.Map; @@ -12,7 +12,6 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityTargetLivingEntityEvent; -import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -23,89 +22,38 @@ import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.donation.DonationManager; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ban.commands.ClansBanCommand; -import mineplex.game.clans.clans.ban.commands.FreezeCommand; -import mineplex.game.clans.clans.ban.commands.UnfreezeCommand; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.clans.freeze.commands.FreezeCommand; +import mineplex.game.clans.clans.freeze.commands.UnfreezeCommand; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -public class ClansBanManager extends MiniPlugin +public class ClansFreezeManager extends MiniPlugin { private static final long FREEZE_MESSAGE_INTERVAL = 10000; private final CoreClientManager _clientManager; - private final DonationManager _donationManager; - private final ClansBanRepository _repository; private final Map _frozen = new HashMap<>(); - public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) + public ClansFreezeManager(JavaPlugin plugin, CoreClientManager clientManager) { - super("Blacklist", plugin); + super("Freeze", plugin); _clientManager = clientManager; - - _repository = new ClansBanRepository(plugin); - - _donationManager = donationManager; } @Override public void addCommands() { - addCommand(new ClansBanCommand(this)); addCommand(new FreezeCommand(this)); addCommand(new UnfreezeCommand(this)); } - - public CoreClientManager getClientManager() - { - return _clientManager; - } - - public DonationManager getDonationManager() - { - return _donationManager; - } - - public ClansBanRepository getRepository() - { - return _repository; - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onLogin(AsyncPlayerPreLoginEvent event) - { - try - { - ClansBanClient client = _repository.loadClient(event.getUniqueId()).get(); - - if (client.isBanned()) - { - String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT); - - if (client.getLongestBan().isPermanent()) - { - time = "Permanent"; - } - - String reason = C.cRedB + "You are banned from Clans for " + time + - "\n" + C.cWhite + client.getLongestBan().getReason(); - - event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, reason); - } - } catch (Exception ignored) {} - } @EventHandler(priority = EventPriority.LOW) public void onQuit(PlayerQuitEvent event) @@ -299,17 +247,4 @@ public class ClansBanManager extends MiniPlugin } } } - - public void unban(ClansBanClient target, ClansBan ban, Callback callback) - { - if (!target._uuid.equals(ban.getUUID())) - { - return; - } - - ban.remove(); - _repository.removeBan(ban); - - callback.run(target); - } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/FreezeCommand.java similarity index 81% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/FreezeCommand.java index 1a75c70d7..a5c55a670 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/FreezeCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/FreezeCommand.java @@ -1,20 +1,20 @@ -package mineplex.game.clans.clans.ban.commands; +package mineplex.game.clans.clans.freeze.commands; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.game.clans.clans.ban.ClansBanManager; +import mineplex.game.clans.clans.freeze.ClansFreezeManager; import org.bukkit.entity.Player; /** * Command to freeze players */ -public class FreezeCommand extends CommandBase +public class FreezeCommand extends CommandBase { - public FreezeCommand(ClansBanManager plugin) + public FreezeCommand(ClansFreezeManager plugin) { super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "freeze"); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/UnfreezeCommand.java similarity index 81% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/UnfreezeCommand.java index 13e4aa098..7f9f7bd92 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ban/commands/UnfreezeCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/UnfreezeCommand.java @@ -1,20 +1,20 @@ -package mineplex.game.clans.clans.ban.commands; +package mineplex.game.clans.clans.freeze.commands; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.game.clans.clans.ban.ClansBanManager; +import mineplex.game.clans.clans.freeze.ClansFreezeManager; import org.bukkit.entity.Player; /** * Command to unfreeze players */ -public class UnfreezeCommand extends CommandBase +public class UnfreezeCommand extends CommandBase { - public UnfreezeCommand(ClansBanManager plugin) + public UnfreezeCommand(ClansFreezeManager plugin) { super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "unfreeze"); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index d54d83ebb..a437335cc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -756,4 +756,4 @@ public class Gameplay extends MiniPlugin { UtilPlayer.message(player, F.main("Clans", message)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java index d964df566..350e6228c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java @@ -23,8 +23,8 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.ClanTips.TipType; +import mineplex.game.clans.clans.freeze.ClansFreezeManager; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.ban.ClansBanManager; import mineplex.game.clans.clans.worldevent.raid.RaidManager; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; import mineplex.game.clans.restart.RestartManager; @@ -66,7 +66,7 @@ public class SafeLog extends MiniPlugin return; } - if (Managers.get(ClansBanManager.class).isFrozen(player)) + if (Managers.get(ClansFreezeManager.class).isFrozen(player)) { isSafeLog = true; } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java index 89a04fe90..b6f0de986 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java @@ -236,7 +236,5 @@ public class CombatLog public void SetKillerColor(String color) { _killerColor = color; - } - - -} + } +} \ No newline at end of file From f00d9fbb5437985ecc6d0b0baabd909c19ebbc22 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 14 Jul 2017 06:39:59 -0400 Subject: [PATCH 105/183] Fix sales announcement remote updates being handled async --- .../SalesAnnouncementManager.java | 29 ++++++++++--------- .../SalesAnnouncementManager.java | 29 ++++++++++--------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java index bc5610cf3..fa6546121 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java @@ -100,22 +100,25 @@ public class SalesAnnouncementManager extends MiniPlugin public void handleRemoteUpdate(int id) { - if (_data.containsKey(Integer.valueOf(id))) + runSync(() -> { - _repo.loadAnnouncement(id, data -> + if (_data.containsKey(Integer.valueOf(id))) { - _data.get(data.getId()).setEnabled(data.isEnabled()); - UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); - }); - } - else - { - _repo.loadAnnouncement(id, data -> + _repo.loadAnnouncement(id, data -> + { + _data.get(data.getId()).setEnabled(data.isEnabled()); + UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + }); + } + else { - _data.put(data.getId(), data); - UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); - }); - } + _repo.loadAnnouncement(id, data -> + { + _data.put(data.getId(), data); + UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + }); + } + }); } @EventHandler diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java index b45cf8401..a4e219fb6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java @@ -100,22 +100,25 @@ public class SalesAnnouncementManager extends MiniPlugin public void handleRemoteUpdate(int id) { - if (_data.containsKey(Integer.valueOf(id))) + runSync(() -> { - _repo.loadAnnouncement(id, data -> + if (_data.containsKey(Integer.valueOf(id))) { - _data.get(data.getId()).setEnabled(data.isEnabled()); - UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); - }); - } - else - { - _repo.loadAnnouncement(id, data -> + _repo.loadAnnouncement(id, data -> + { + _data.get(data.getId()).setEnabled(data.isEnabled()); + UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + }); + } + else { - _data.put(data.getId(), data); - UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); - }); - } + _repo.loadAnnouncement(id, data -> + { + _data.put(data.getId(), data); + UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent()); + }); + } + }); } @EventHandler From 99c2522e922d91b41db7add62dab948f19af7ace Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 14 Jul 2017 06:49:47 -0400 Subject: [PATCH 106/183] Clean up the Clans blacklist GUI --- .../core/punish/clans/ClansBanManager.java | 1 - .../core/punish/clans/ui/ClansBanPage.java | 45 +++++++++++++------ 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java index 48d273a61..f8940291b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java @@ -2,7 +2,6 @@ package mineplex.core.punish.clans; import java.util.Optional; import java.util.UUID; -import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import org.bukkit.Bukkit; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanPage.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanPage.java index bbe04bf90..f26c4a0b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ui/ClansBanPage.java @@ -86,19 +86,38 @@ public class ClansBanPage extends ShopPageBase for (ClansBan ban : _victimClient._bans) { - ItemStack item = new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK) - .setTitle(ban.isActive() ? C.cGreenB + "Active" : C.cRedB + "Inactive") - .addLore(" ") - .addLore(C.cGray + "Date banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime())) - .addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin()) - .addLore(C.cGray + "Time left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None")) - .addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No")) - .addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16) - .addLore(C.cGray + "Is Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No")) - .addLore(ban.isActive() ? " " : null) - .addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null) - .setGlow(ban.isActive()) - .build(); + ItemStack item; + if (ban.isPermanent()) + { + item = new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK) + .setTitle(ban.isActive() ? C.cGreenB + "Active" : C.cRedB + "Inactive") + .addLore(" ") + .addLore(C.cGray + "Date Banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime())) + .addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin()) + .addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No")) + .addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16) + .addLore(C.cGray + "Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No")) + .addLore(ban.isActive() ? " " : null) + .addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null) + .setGlow(ban.isActive()) + .build(); + } + else + { + item = new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK) + .setTitle(ban.isActive() ? C.cGreenB + "Active" : C.cRedB + "Inactive") + .addLore(" ") + .addLore(C.cGray + "Date Banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime())) + .addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin()) + .addLore(C.cGray + "Time Left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None")) + .addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No")) + .addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16) + .addLore(C.cGray + "Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No")) + .addLore(ban.isActive() ? " " : null) + .addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null) + .setGlow(ban.isActive()) + .build(); + } addButton(slot++, item, (player, click) -> { From 46768c60ec5ad87a0f0c9f1f7372d3b824a7e3a3 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 14 Jul 2017 07:06:42 -0400 Subject: [PATCH 107/183] Disable all other magmus abilities while heat room is active, and make the heat room safezone despawn after damage stops occurring --- .../raid/wither/creature/magma/HeatingUp.java | 11 ++++------- .../worldevent/raid/wither/creature/magma/Magmus.java | 1 + .../raid/wither/creature/magma/MagmusCataclysm.java | 4 ++++ .../raid/wither/creature/magma/MagmusEat.java | 6 +++++- .../raid/wither/creature/magma/MagmusMeteor.java | 6 ++---- .../raid/wither/creature/magma/MagmusSmash.java | 4 ++++ 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java index c421b4b82..845142fd1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java @@ -29,7 +29,7 @@ public class HeatingUp extends Cataclysm @Override protected void onStart() { - ((MagmusMeteor)Magmus.Abilities.get(2)).Disabled = true; + Magmus.HeatingRoom = true; _center = Challenge.getRaid().getWorldData().getCustomLocs("C_SIX_C1S").get(0); for (int x = -1; x <= 1; x++) { @@ -50,17 +50,14 @@ public class HeatingUp extends Cataclysm _center.getBlock().getRelative(x, -1, z).setType(Material.STONE); } } - if (Magmus.Abilities.size() > 1 && Magmus.Abilities.get(2) instanceof MagmusMeteor) - { - ((MagmusMeteor)Magmus.Abilities.get(2)).Disabled = false; - } + Magmus.HeatingRoom = true; } @Override protected void tick() { _ticks++; - if (_ticks > (20 * 10)) + if (_ticks > (20 * 10) && _ticks <= (20 * 30)) { for (Player player : Challenge.getRaid().getPlayers()) { @@ -71,7 +68,7 @@ public class HeatingUp extends Cataclysm } } } - if (_ticks > (20 * 30)) + if (_ticks > (20 * 33)) { end(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java index 490adbfb0..daae379f7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java @@ -26,6 +26,7 @@ public class Magmus extends RaidCreature protected List> Abilities = new ArrayList<>(); protected boolean TeleportBackASAP = true; + protected boolean HeatingRoom = false; public Magmus(ChallengeSix challenge, Location location) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java index 1bec42e4c..da2120316 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusCataclysm.java @@ -40,6 +40,10 @@ public class MagmusCataclysm extends BossPassive @Override public void tick() { + if (getBoss().HeatingRoom) + { + return; + } if (UtilTime.elapsed(_lastUse, getCooldown() * 1000)) { _lastUse = System.currentTimeMillis(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java index f174ced35..4100a889b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusEat.java @@ -39,7 +39,7 @@ public class MagmusEat extends BossPassive private void eat() { - if (_ticks < 20 * 10) + if (_ticks < 20 * 10 && !getBoss().HeatingRoom) { _eating.setFireTicks(40); _eating.teleport(getEntity()); @@ -73,6 +73,10 @@ public class MagmusEat extends BossPassive @Override public void tick() { + if (getBoss().HeatingRoom) + { + return; + } if (_eating != null) { eat(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java index c0da5fa5b..f358e511f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusMeteor.java @@ -28,8 +28,6 @@ public class MagmusMeteor extends BossPassive private long _lastUse; private List _shot = new ArrayList<>(); - protected boolean Disabled = false; - public MagmusMeteor(Magmus creature) { super(creature); @@ -38,7 +36,7 @@ public class MagmusMeteor extends BossPassive private void newBall() { - if (Disabled) + if (getBoss().HeatingRoom) { return; } @@ -72,7 +70,7 @@ public class MagmusMeteor extends BossPassive @Override public void tick() { - if (Disabled) + if (getBoss().HeatingRoom) { return; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java index 50eab5b2b..7fd1de661 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusSmash.java @@ -62,6 +62,10 @@ public class MagmusSmash extends BossPassive @Override public void tick() { + if (getBoss().HeatingRoom) + { + return; + } if (UtilTime.elapsed(_lastUse, getCooldown() * 1000)) { _lastUse = System.currentTimeMillis(); From 8379c6235b8c7da59aabca45ea654d0d6352a7b7 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 17 Jul 2017 13:03:33 -0400 Subject: [PATCH 108/183] Lower freeze walk buffer --- .../mineplex/game/clans/clans/freeze/ClansFreezeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java index 0b6ca5355..6442c239e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java @@ -79,7 +79,7 @@ public class ClansFreezeManager extends MiniPlugin if (isFrozen(event.getPlayer()) && UtilMath.offset2d(event.getFrom().getBlock().getLocation(), event.getTo().getBlock().getLocation()) >= 1) { event.setCancelled(true); - event.getPlayer().teleport(event.getFrom().getBlock().getLocation().add(0, 1, 0)); + event.getPlayer().teleport(event.getFrom().getBlock().getLocation().add(0, 0.5, 0)); } } From 5e70ff8471a89fd7fdc73e6877ebb82c6308e508 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 17 Jul 2017 13:17:28 -0400 Subject: [PATCH 109/183] Block sleeping in beds --- .../src/mineplex/game/clans/clans/ClansGame.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index 15b9df83f..a02020ecc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -759,6 +759,13 @@ public class ClansGame extends MiniPlugin ClanInfo clan = _clans.getClan(event.getPlayer()); Block block = event.getClickedBlock(); + + if (UtilEvent.isAction(event, ActionType.R_BLOCK) && block.getType() == Material.BED_BLOCK) + { + event.setCancelled(true); + return; + } + Player player = event.getPlayer(); if (clan == null) From d5355ab757d7bbc91253426e22e88172d6d137cd Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 17 Jul 2017 13:32:27 -0400 Subject: [PATCH 110/183] Despawn mounts on chunk unload and clean up some formatting --- .../mineplex/core/common/util/UtilWorld.java | 6 +++- .../game/clans/clans/ClansManager.java | 28 ++++++++++++++----- .../game/clans/clans/mounts/MountManager.java | 14 ++++++++++ 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java index b0d4bd9bc..696cf72d3 100644 --- a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java @@ -11,7 +11,6 @@ import org.bukkit.World.Environment; import org.bukkit.WorldBorder; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.entity.Entity; import org.bukkit.util.Vector; import com.google.common.collect.Lists; @@ -22,6 +21,11 @@ public class UtilWorld { return Bukkit.getServer().getWorld(world); } + + public static boolean isInChunk(Location location, Chunk chunk) + { + return location.getChunk().getX() == chunk.getX() && location.getChunk().getZ() == chunk.getZ() && chunk.getWorld().equals(location.getChunk().getWorld()); + } public static boolean areChunksEqual(Location first, Location second) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 941756e20..2fed14075 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -792,10 +792,12 @@ public class ClansManager extends MiniClientPluginimplements IRelati { player.setOp(true); } - if(player.getInventory().getHelmet() != null) { //Reset helmet to fix 1 damage bug + if (player.getInventory().getHelmet() != null) //Reset helmet to fix 1 damage bug + { ItemStack helmet = player.getInventory().getHelmet().clone(); player.getInventory().setHelmet(null); - runSyncLater(() -> { + runSyncLater(() -> + { player.getInventory().setHelmet(helmet); }, 20L); } @@ -806,7 +808,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati { // happens 20 ticks later because player channels don't // seem to work immediately after joining. - runSyncLater(() -> { + runSyncLater(() -> + { ByteArrayDataOutput bado = ByteStreams.newDataOutput(); bado.writeUTF("no_xray"); @@ -844,7 +847,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati for (String message : messages) { - if (!event.getMessage().equalsIgnoreCase("/" + message) && !event.getMessage().startsWith("/" + message + " ")) + if (!event.getMessage().equalsIgnoreCase("/" + message) && !event.getMessage().toLowerCase().startsWith("/" + message + " ")) { continue; } @@ -903,7 +906,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati for (Player other : event.getRecipients()) { if (_tutorial.inTutorial(other)) + { continue; + } UtilPlayer.message(other, String.format(rank + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), event.getMessage())); } @@ -917,7 +922,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati for (Player other : event.getRecipients()) { if (_tutorial.inTutorial(other)) + { continue; + } ClanInfo otherClan = _clanUtility.getClanByPlayer(other); @@ -940,7 +947,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void disableObsidian(BlockBreakEvent event) { - if(event.getBlock().getType().equals(Material.OBSIDIAN)) + if (event.getBlock().getType().equals(Material.OBSIDIAN)) { event.setCancelled(true); event.getBlock().setType(Material.AIR); @@ -976,7 +983,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati String rank = _clientManager.Get(event.getPlayer()).GetRank().getTag(true, true) + " "; if (!_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH)) + { rank = ""; + } if (client.isClanChat() && clan != null) { @@ -1028,7 +1037,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " "; if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH)) + { rank = ""; + } handleClanChat(caller, message, clan, rank); } @@ -1038,7 +1049,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " "; if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH)) + { rank = ""; + } handleAllyChat(caller, message, clan, rank); } @@ -1316,7 +1329,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati public void updateBedStatus(UpdateEvent event) { if (event.getType() != UpdateType.TWOSEC) + { return; + } for (String name : getClanNameSet()) { @@ -1391,7 +1406,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati { _clanMemberLeftMap.remove(uuid); _warPointEvasion.resetCooldown(uuid); - } @EventHandler(priority = EventPriority.LOWEST) @@ -1405,7 +1419,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati { if (event.getEntered() instanceof Player && event.getVehicle() instanceof Horse) { - if(!Recharge.Instance.use((Player) event.getEntered(), "Ride Horse", 2 * 20L, true, false)) + if (!Recharge.Instance.use((Player) event.getEntered(), "Ride Horse", 2 * 20L, true, false)) { event.setCancelled(true); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java index d262f4270..c0d55196d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java @@ -20,6 +20,7 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.inventory.HorseInventory; import org.bukkit.plugin.java.JavaPlugin; @@ -34,6 +35,7 @@ import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; import mineplex.core.donation.DonationManager; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -481,6 +483,18 @@ public class MountManager extends MiniDbClientPlugin UtilPlayer.message(event.getPlayer(), F.main(getName(), "This is not your Mount!")); event.setCancelled(true); } + + @EventHandler + public void onChunkUnload(ChunkUnloadEvent event) + { + _spawnedMounts.entrySet().forEach(entry -> + { + if (UtilWorld.isInChunk(entry.getKey().getLocation(), event.getChunk())) + { + entry.getValue().despawn(false); + } + }); + } @Override public String getQuery(int accountId, String uuid, String name) From 9daa46bb4add66b1a7dd0dd42c1027759bd0ec00 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 17 Jul 2017 13:55:31 -0400 Subject: [PATCH 111/183] Unify combat tag checking --- .../game/clans/clans/ClansUtility.java | 2 +- .../game/clans/clans/commands/KillCommand.java | 2 +- .../game/clans/clans/nether/NetherManager.java | 1 - .../mineplex/game/clans/gameplay/Gameplay.java | 18 ++++++++++-------- .../src/mineplex/game/clans/spawn/Spawn.java | 16 +++++++--------- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index 4f63bf168..f019fa1d5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -282,7 +282,7 @@ public class ClansUtility public boolean isSafe(Player player) { - if (!UtilTime.elapsed(_clansManager.getCombatManager().Get(player).GetLastDamaged(), Spawn.COMBAT_TAG_DURATION)) return false; + if (!UtilTime.elapsed(_clansManager.getCombatManager().Get(player).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION)) return false; return isSafe(player.getLocation()); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java index c95ab485a..2f16ab4b0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java @@ -21,7 +21,7 @@ public class KillCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (!UtilTime.elapsed(Plugin.getCombatManager().Get(caller).GetLastDamaged(), Spawn.COMBAT_TAG_DURATION)) + if (!UtilTime.elapsed(Plugin.getCombatManager().Get(caller).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION)) { UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in combat.")); return; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index fdbe13146..77d53a997 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -40,7 +40,6 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index a437335cc..83b1d6a5a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -610,15 +610,13 @@ public class Gameplay extends MiniPlugin final byte data = block.getData(); - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { - public void run() + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> + { + Material mat = block.getRelative(BlockFace.DOWN).getType(); + if (mat == Material.DIRT || mat == Material.GRASS) { - Material mat = block.getRelative(BlockFace.DOWN).getType(); - if (mat == Material.DIRT || mat == Material.GRASS) - { - block.setType(Material.SAPLING); - block.setData(data); - } + block.setType(Material.SAPLING); + block.setData(data); } }, 20 * 10); } @@ -637,7 +635,9 @@ public class Gameplay extends MiniPlugin event.setCancelled(true); for (int x = -1; x <= 1; x++) + { for (int y = -1; y <= 1; y++) + { for (int z = -1; z <= 1; z++) { // Self @@ -659,6 +659,8 @@ public class Gameplay extends MiniPlugin if (block.getTypeId() == 0) block.setType(Material.FIRE); } + } + } } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java index 07750faf6..73ea914ca 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -51,7 +51,6 @@ public class Spawn extends MiniPlugin { public static final int SPAWN_RADIUS = 32; public static final int SHOP_RADIUS = 48; - public static final String COMBAT_TAG_NAME = "Unsafe"; public static final long COMBAT_TAG_DURATION = 15000; public static final Location ORIGIN = new Location(getSpawnWorld(), 0, 0, 0); @@ -201,7 +200,6 @@ public class Spawn extends MiniPlugin + ChatColor.YELLOW + F.time(UtilTime.convertString(COMBAT_TAG_DURATION - duration, 1, TimeUnit.FIT)); UtilTextMiddle.display(null, message, 0, 20, 0, cur); - _clansManager.getCondition().Factory().Custom(COMBAT_TAG_NAME, cur, cur, ConditionType.CUSTOM, 1.d, 0, false, Material.FIRE, (byte)0, true); playUnsafeParticles(cur); } else if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION + 600)) @@ -490,16 +488,14 @@ public class Spawn extends MiniPlugin public boolean isCombatTagged(Player player) { - return _clansManager.getCondition().HasCondition(player, ConditionType.CUSTOM, COMBAT_TAG_NAME); + return !UtilTime.elapsed(_clansManager.getCombatManager().Get(player).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION); } public void teleport(final Player player, final Location location, int delay) { - Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { - @Override - public void run() { - player.teleport(location); - } + Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> + { + player.teleport(location); }, delay); } @@ -521,7 +517,9 @@ public class Spawn extends MiniPlugin public void playDatMusicALLDAYLONG(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } if (UtilTime.elapsed(_songEastLast, _songEastLength)) { @@ -542,4 +540,4 @@ public class Spawn extends MiniPlugin { return _clansManager; } -} +} \ No newline at end of file From 4f04d879ab566dac50b6cdc91a10d4cca13c2a22 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 17 Jul 2017 18:36:59 -0400 Subject: [PATCH 112/183] I'm a dumbo, and remove the ability to add runes to the Scythe of the Fallen Lord --- .../clans/worldevent/raid/wither/creature/magma/HeatingUp.java | 2 +- .../src/mineplex/game/clans/items/runes/RuneManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java index 845142fd1..8fb52f8c6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java @@ -50,7 +50,7 @@ public class HeatingUp extends Cataclysm _center.getBlock().getRelative(x, -1, z).setType(Material.STONE); } } - Magmus.HeatingRoom = true; + Magmus.HeatingRoom = false; } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java index 20fa3c7d9..eb3ba28fd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/runes/RuneManager.java @@ -353,7 +353,7 @@ public class RuneManager implements Listener { return true; } - if (type == Material.RECORD_4 || type == Material.GOLD_RECORD || type == Material.RECORD_3 || type == Material.RECORD_5 || type == Material.GREEN_RECORD || type == Material.RECORD_8) + if (type == Material.RECORD_4 || type == Material.GOLD_RECORD || type == Material.RECORD_3 || type == Material.RECORD_5 || type == Material.GREEN_RECORD) { return true; } From 5d39f7145d877a27838d85dd70545126ae94daf9 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Mon, 17 Jul 2017 18:54:58 -0400 Subject: [PATCH 113/183] Fix guardian disguises This commit fixes guardian disguises (esp. elder guardians) and also provides for disguises to modify packets before they're sent if necessary --- .../core/disguise/DisguiseManager.java | 19 +-- .../core/disguise/disguises/DisguiseBase.java | 65 ++++++---- .../disguise/disguises/DisguiseGuardian.java | 113 +++++++++++++++++- 3 files changed, 163 insertions(+), 34 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index 89c28093f..44dc988fc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -360,6 +360,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler final Packet packet = packetInfo.getPacket(); final Player owner = packetInfo.getPlayer(); final PacketVerifier packetVerifier = packetInfo.getVerifier(); + final int protocol = ((CraftPlayer) owner).getHandle().getProtocol(); if (packet instanceof PacketPlayOutPlayerInfo) { @@ -406,7 +407,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler { packetInfo.setCancelled(true); - handleSpawnPackets(packetInfo.getVerifier(), latestDisguise); + handleSpawnPackets(packetInfo.getVerifier(), latestDisguise, protocol); } else if (latestDisguise.isHideIfNotDisguised()) { @@ -436,7 +437,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler if (latestDisguise != null && containsSpawnDisguise(owner, latestDisguise) && owner.getEntityId() != entityId) { packetInfo.setCancelled(true); - handlePacket(latestDisguise.getMetadataPacket(), packetVerifier); + handlePacket(latestDisguise.modifyMetaPacket(protocol, latestDisguise.getMetadataPacket()), packetVerifier); } } else if (packet instanceof PacketPlayOutEntityEquipment) @@ -475,7 +476,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler _handlingPacket = false; } - private void handleSpawnPackets(PacketVerifier packetVerifier, DisguiseBase disguise) + private void handleSpawnPackets(PacketVerifier packetVerifier, DisguiseBase disguise, int protocol) { if (disguise instanceof DisguisePlayer) { @@ -493,14 +494,14 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler handlePacket(infoPacket, packetVerifier); } - handlePacket(pDisguise.getSpawnPacket(), packetVerifier); + handlePacket(pDisguise.modifySpawnPacket(protocol, pDisguise.getSpawnPacket()), packetVerifier); for (Packet packet : pDisguise.getEquipmentPackets()) { handlePacket(packet, packetVerifier); } - handlePacket(pDisguise.getMetadataPacket(), packetVerifier); + handlePacket(pDisguise.modifyMetaPacket(protocol, pDisguise.getMetadataPacket()), packetVerifier); if (pDisguise.getSleepingDirection() != null) { @@ -556,7 +557,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler } else { - handlePacket(disguise.getSpawnPacket(), packetVerifier); + handlePacket(disguise.modifySpawnPacket(protocol, disguise.getSpawnPacket()), packetVerifier); if (disguise instanceof DisguiseLiving) { @@ -644,10 +645,12 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler { if (tester.test(player)) { - if (disguise.getEntity() == ((CraftPlayer) player).getHandle()) + EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle(); + if (disguise.getEntity() == nmsPlayer) continue; - UtilPlayer.sendPacket(player, disguise.getMetadataPacket()); + int protocol = nmsPlayer.getProtocol(); + UtilPlayer.sendPacket(player, disguise.modifyMetaPacket(protocol, disguise.getMetadataPacket())); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java index 2d0334abc..b9e6cdd9c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java @@ -2,16 +2,9 @@ package mineplex.core.disguise.disguises; import mineplex.core.common.DummyEntity; import mineplex.core.common.util.UtilPlayer; -import net.minecraft.server.v1_8_R3.DataWatcher; -import net.minecraft.server.v1_8_R3.Entity; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.EntityTrackerEntry; -import net.minecraft.server.v1_8_R3.IntHashMap; -import net.minecraft.server.v1_8_R3.MinecraftServer; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; -import net.minecraft.server.v1_8_R3.WorldServer; + +import net.minecraft.server.v1_8_R3.*; + import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -21,6 +14,8 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.function.Consumer; +import java.util.function.Supplier; public abstract class DisguiseBase { @@ -72,15 +67,7 @@ public abstract class DisguiseBase DataWatcher.watch(1, getEntity().getDataWatcher().getShort(1), net.minecraft.server.v1_8_R3.Entity.META_AIR, (int) getEntity().getDataWatcher().getShort(1)); } - public abstract Packet getSpawnPacket(); - - public Packet getMetadataPacket() - { - UpdateDataWatcher(); - return new PacketPlayOutEntityMetadata(getEntity().getId(), DataWatcher, true); - } - - public void resendMetadata() + public void sendToWatchers(Supplier supplier) { if (getEntity() == null || !getEntity().getBukkitEntity().isValid() || !(getEntity().world instanceof WorldServer)) return; @@ -90,14 +77,48 @@ public abstract class DisguiseBase if (tracker.get(getEntity().getId()) == null) return; - Packet packet = getMetadataPacket(); + Packet packet = supplier.get(); + if (packet == null) + return; for (EntityPlayer player : tracker.get(getEntity().getId()).trackedPlayers) { - UtilPlayer.sendPacket(player.getBukkitEntity(), packet); + if (packet instanceof PacketPlayOutEntityMetadata) + { + player.playerConnection.sendPacket(modifyMetaPacket(player.getProtocol(), packet)); + } else if (packet instanceof PacketPlayOutSpawnEntityLiving) + { + player.playerConnection.sendPacket(modifySpawnPacket(player.getProtocol(), packet)); + } else + { + player.playerConnection.sendPacket(packet); + } } } + public abstract Packet getSpawnPacket(); + + public Packet modifySpawnPacket(int protocol, Packet packet) + { + return packet; + } + + public Packet getMetadataPacket() + { + UpdateDataWatcher(); + return new PacketPlayOutEntityMetadata(getEntity().getId(), DataWatcher, true); + } + + public void resendMetadata() + { + sendToWatchers(this::getMetadataPacket); + } + + public Packet modifyMetaPacket(int protocol, Packet packet) + { + return packet; + } + public void setSoundDisguise(DisguiseBase soundDisguise) { _soundDisguise = soundDisguise; @@ -197,7 +218,7 @@ public abstract class DisguiseBase return this._disguiseType; } - public void setEntity(net.minecraft.server.v1_8_R3.Entity entity) + public void setEntity(Entity entity) { _entity.clear(); _entity = new WeakReference<>(entity); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java index af05e67bb..eaa367258 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java @@ -1,11 +1,23 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.*; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; -import net.minecraft.server.v1_8_R3.EntityGuardian; +import com.mineplex.MetaWrapper; +import com.mineplex.ProtocolVersion; + +import net.minecraft.server.v1_8_R3.*; +import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; + +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.EntityType; public class DisguiseGuardian extends DisguiseCreature { + private int target = 0; + private boolean elder = false; + public DisguiseGuardian(org.bukkit.entity.Entity entity) { super(EntityType.GUARDIAN, entity); @@ -15,17 +27,33 @@ public class DisguiseGuardian extends DisguiseCreature public void setTarget(int target) { + this.target = target; + DataWatcher.watch(17, target, EntityGuardian.META_TARGET, target); } public void setElder(boolean elder) { - DataWatcher.watch(16, Integer.valueOf(DataWatcher.getInt(16) | 4), EntityGuardian.META_ELDER, (byte) (DataWatcher.getInt(16) | 4)); + this.elder = elder; + + int oldValue = DataWatcher.getInt(16); + int newValue = elder ? oldValue | 4 : oldValue & ~4; + + DataWatcher.watch(16, Integer.valueOf(newValue), EntityGuardian.META_ELDER, (byte) newValue); + + sendToWatchers(() -> new PacketPlayOutEntityDestroy(new int[]{getEntityId()})); + sendToWatchers(this::getSpawnPacket); + sendToWatchers(this::getMetadataPacket); } public boolean isElder() { - return (this.DataWatcher.getInt(16) & 4) != 0; + return elder; + } + + public int getTarget() + { + return target; } protected String getHurtSound() @@ -37,4 +65,81 @@ public class DisguiseGuardian extends DisguiseCreature return "mob.guardian.hit"; } + + // ---- Packet modification for 1.11 and up + + @Override + public Packet modifySpawnPacket(int protocol, Packet packet) + { + if (protocol >= ProtocolVersion.v1_11) + { + PacketPlayOutSpawnEntityLiving newSpawn = (PacketPlayOutSpawnEntityLiving) getSpawnPacket(); + if (isElder()) newSpawn.b = 4; + newSpawn.m = processSpawnMeta(DataWatcher.c()); + return newSpawn; + } + + return packet; + } + + @Override + public Packet modifyMetaPacket(int protocol, Packet packet) + { + if (protocol >= ProtocolVersion.v1_11) + { + PacketPlayOutEntityMetadata newPacket = (PacketPlayOutEntityMetadata) getMetadataPacket(); + newPacket.b = processMeta(newPacket.b); + return newPacket; + } + + return packet; + } + + private List processMeta(List list) + { + List newMeta = new ArrayList<>(); + for (WatchableObject meta : list) + { + MetaWrapper wrapper = new MetaWrapper(meta); + if (wrapper.getIndex() == 11) + { + byte value = (byte) wrapper.getValue(); + newMeta.add(new MetaWrapper(11, DataType.BOOLEAN, (value & 0x02) != 0)); + } else + { + newMeta.add(wrapper); + } + } + + return newMeta.stream().map(MetaWrapper::toWatchableObject).collect(Collectors.toList()); + } + + private List processSpawnMeta(List list) + { + List newMeta = new ArrayList<>(); + for (WatchableObject meta : list) + { + MetaWrapper wrapper = new MetaWrapper(meta); + if (wrapper.getIndex() >= 5) // 1.10 + { + wrapper.setIndex(wrapper.getIndex() + 1); + } + + if (getEntity() instanceof EntityArmorStand && (wrapper.getIndex() == 12 || wrapper.getIndex() == 13)) + { + continue; + } + + if (wrapper.getIndex() < 12) // Skip higher ones in 1.11 + { + newMeta.add(wrapper); + } else if (wrapper.getIndex() == 12) + { + byte value = (byte) wrapper.getValue(); + newMeta.add(new MetaWrapper(12, DataType.BOOLEAN, (value & 0x02) != 0)); + } + } + + return newMeta.stream().map(MetaWrapper::toWatchableObject).collect(Collectors.toList()); + } } From ac2df004f063a07cc2648e527fc0377c0607334c Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 17 Jul 2017 19:00:03 -0400 Subject: [PATCH 114/183] Fix players being combat tagged after respawn --- .../src/mineplex/game/clans/spawn/Spawn.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java index 73ea914ca..1a1524f42 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -16,7 +16,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.classcombat.item.event.WebTossEvent; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Bukkit; @@ -24,7 +23,6 @@ import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Entity; @@ -275,6 +273,7 @@ public class Spawn extends MiniPlugin public void onRespawn(PlayerRespawnEvent event) { event.setRespawnLocation(getSpawnLocation()); + _clansManager.getCombatManager().Get(event.getPlayer()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION); } /* From 212858743ff485b1ff45052edf5457665aae166f Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Tue, 18 Jul 2017 12:33:07 -0400 Subject: [PATCH 115/183] Rewrite spawn meta for all living entities on 1.10 and up --- .../disguise/disguises/DisguiseCreature.java | 57 +++++++++++++++++-- .../disguise/disguises/DisguiseGuardian.java | 39 ++----------- 2 files changed, 57 insertions(+), 39 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java index d477ab3bc..55e62c217 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java @@ -1,9 +1,16 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.MathHelper; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; -import org.bukkit.entity.*; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import com.mineplex.MetaWrapper; +import com.mineplex.ProtocolVersion; + +import net.minecraft.server.v1_8_R3.*; +import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; + +import org.bukkit.entity.EntityType; public abstract class DisguiseCreature extends DisguiseInsentient { @@ -70,4 +77,46 @@ public abstract class DisguiseCreature extends DisguiseInsentient return packet; } + + @Override + public Packet modifySpawnPacket(int protocol, Packet packet) + { + if (protocol >= ProtocolVersion.v1_10_PRE) + { + PacketPlayOutSpawnEntityLiving newSpawn = (PacketPlayOutSpawnEntityLiving) getSpawnPacket(); + newSpawn.m = processSpawnMeta(protocol, DataWatcher.c()); + return newSpawn; + } + + return packet; + } + + private List processSpawnMeta(int protocol, List list) + { + List newMeta = new ArrayList<>(); + for (WatchableObject meta : list) + { + MetaWrapper wrapper = new MetaWrapper(meta); + if (wrapper.getIndex() >= 5) // 1.10 + { + wrapper.setIndex(wrapper.getIndex() + 1); + } + + if (protocol < ProtocolVersion.v1_11) + { + newMeta.add(wrapper); + continue; + } + + if (getEntity() instanceof EntityArmorStand && wrapper.getIndex() >= 12) + { + // Armor stand meta conflicts with a lot of entities on 1.11+ + continue; + } + + newMeta.add(wrapper); + } + + return newMeta.stream().map(MetaWrapper::toWatchableObject).collect(Collectors.toList()); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java index eaa367258..31222e6da 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java @@ -71,15 +71,13 @@ public class DisguiseGuardian extends DisguiseCreature @Override public Packet modifySpawnPacket(int protocol, Packet packet) { - if (protocol >= ProtocolVersion.v1_11) + PacketPlayOutSpawnEntityLiving newSpawn = (PacketPlayOutSpawnEntityLiving) super.modifySpawnPacket(protocol, packet); + if (protocol >= ProtocolVersion.v1_11 && isElder()) { - PacketPlayOutSpawnEntityLiving newSpawn = (PacketPlayOutSpawnEntityLiving) getSpawnPacket(); - if (isElder()) newSpawn.b = 4; - newSpawn.m = processSpawnMeta(DataWatcher.c()); - return newSpawn; + newSpawn.b = 4; } - return packet; + return newSpawn; } @Override @@ -113,33 +111,4 @@ public class DisguiseGuardian extends DisguiseCreature return newMeta.stream().map(MetaWrapper::toWatchableObject).collect(Collectors.toList()); } - - private List processSpawnMeta(List list) - { - List newMeta = new ArrayList<>(); - for (WatchableObject meta : list) - { - MetaWrapper wrapper = new MetaWrapper(meta); - if (wrapper.getIndex() >= 5) // 1.10 - { - wrapper.setIndex(wrapper.getIndex() + 1); - } - - if (getEntity() instanceof EntityArmorStand && (wrapper.getIndex() == 12 || wrapper.getIndex() == 13)) - { - continue; - } - - if (wrapper.getIndex() < 12) // Skip higher ones in 1.11 - { - newMeta.add(wrapper); - } else if (wrapper.getIndex() == 12) - { - byte value = (byte) wrapper.getValue(); - newMeta.add(new MetaWrapper(12, DataType.BOOLEAN, (value & 0x02) != 0)); - } - } - - return newMeta.stream().map(MetaWrapper::toWatchableObject).collect(Collectors.toList()); - } } From 8b39fa4e249a9dd461b38117ee64163a4e284c86 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Mon, 17 Jul 2017 13:28:50 -0400 Subject: [PATCH 116/183] Perform disguise validation before doing any of the disguise work If a disguise is invalid, we won't notify redis or prevent players from joining --- .../playerdisguise/DisguiseCommand.java | 10 +- .../disguise/playerdisguise/ExpiringSet.java | 96 ++++++ .../playerdisguise/PlayerDisguiseManager.java | 281 ++++++++++-------- 3 files changed, 250 insertions(+), 137 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/ExpiringSet.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java index e0c544659..4b53402cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java @@ -37,11 +37,9 @@ public class DisguiseCommand extends CommandBase implemen return; } - Plugin.runAsync(() -> - { - new PlayerDisguiseNotification(realName, currentUUID, args[0], args.length > 1 ? args[1] : args[0]).publish(); - }); - - Plugin.disguise(caller, args[0], args.length > 1 ? args[1] : args[0]); + String skin = args.length > 1 ? args[1] : args[0]; + Plugin.tryDisguise(caller, args[0], skin, () -> // onComplete + Plugin.runAsync(() -> // task + new PlayerDisguiseNotification(realName, currentUUID, args[0], skin).publish())); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/ExpiringSet.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/ExpiringSet.java new file mode 100644 index 000000000..12aa1d0ca --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/ExpiringSet.java @@ -0,0 +1,96 @@ +package mineplex.core.disguise.playerdisguise; + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; +import java.util.function.Predicate; +import java.util.stream.Stream; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; + +/** + * Set with contents that expire after X amount of time units. Essentially HashSet reimplemented with a Cache instead of HashMap. + * @author Dan + */ +public class ExpiringSet extends AbstractSet implements Set +{ + private transient Cache cache; + + private static final Object DUMMY = new Object(); + + public ExpiringSet(long duration, TimeUnit unit) + { + this.cache = CacheBuilder.newBuilder().expireAfterWrite(duration, unit).build(); + } + + @Override + public Iterator iterator() + { + return cache.asMap().keySet().iterator(); + } + + @Override + public void forEach(Consumer action) + { + cache.asMap().keySet().forEach(action); + } + + @Override + public boolean removeIf(Predicate filter) + { + return cache.asMap().keySet().removeIf(filter); + } + + @Override + public Spliterator spliterator() + { + return cache.asMap().keySet().spliterator(); + } + + @Override + public Stream stream() + { + return cache.asMap().keySet().stream(); + } + + @Override + public Stream parallelStream() + { + return cache.asMap().keySet().parallelStream(); + } + + @Override + public int size() + { + return (int) cache.size(); + } + + @Override + public boolean contains(Object o) + { + return cache.getIfPresent(o) != null; + } + + @Override + public boolean add(E e) + { + boolean contained = contains(e); + cache.put(e, DUMMY); + return contained; + } + + @Override + public boolean remove(Object o) + { + boolean contained = contains(o); + cache.invalidate(o); + return contained; + } + + @Override + public void clear() + { + cache.invalidateAll(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java index 06829a12d..30de25c49 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java @@ -1,14 +1,8 @@ package mineplex.core.disguise.playerdisguise; import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import net.minecraft.server.v1_8_R3.MinecraftServer; @@ -86,7 +80,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler ILLEGAL_USERNAMES = ImmutableSet.copyOf(Arrays.asList("hypixel", "chiss", "dctr", "blondebug", "dooskee", "tomcallister", "jessiemarcia", "spu_", "sp614x", "deadmau5", "gwen", "mineplex", "samczsun", "sethbling", - "xisuma", "cubehamster", "natet_bird", "qwertyuiopthepie" + "xisuma", "cubehamster", "natet_bird", "qwertyuiopthepie", "hitler", "adolfhitler" )); VERY_SPECIAL_PEOPLE = ImmutableSet.copyOf(Arrays.asList( @@ -121,14 +115,15 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler private CoreClientManager _clients = require(CoreClientManager.class); private DisguiseManager _disguise = require(DisguiseManager.class); private Punish _punish = require(Punish.class); - private CosmeticManager _cosmetics = require(CosmeticManager.class); + // private CosmeticManager _cosmetics = require(CosmeticManager.class); private PreferencesManager _prefs = require(PreferencesManager.class); private RedisDataRepository _redis; // The list of usernames which cannot join because someone else is joining - private Set _cannotJoin = Collections.synchronizedSet(new HashSet<>()); - private Set _loggingIn = Collections.synchronizedSet(new HashSet<>()); + // Values expire in 30 seconds if they haven't been properly cleaned up + private Set _cannotJoin = Collections.synchronizedSet(new ExpiringSet<>(1, TimeUnit.MINUTES)); + private Set _loggingIn = Collections.synchronizedSet(new ExpiringSet<>(1, TimeUnit.MINUTES)); private Set _pendingDisguise1 = new HashSet<>(); @@ -164,7 +159,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler if (disguisePlayer.getProfile().getName().equalsIgnoreCase(event.getPlayer().getName())) { event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - event.setKickMessage("Failed to login: The authentication servers are currently down for maintainence"); + event.setKickMessage("Failed to login: The authentication servers are currently down for maintenance"); return; } } @@ -172,7 +167,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler if (_cannotJoin.contains(event.getPlayer().getName().toLowerCase())) { event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - event.setKickMessage("Failed to login: The authentication servers are currently down for maintainence"); + event.setKickMessage("Failed to login: The authentication servers are currently down for maintenance"); return; } @@ -231,7 +226,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler runSyncLater(() -> { UtilPlayer.message(event.getPlayer(), F.main(getName(), "Attempting to disguise you as " + bean.getGameProfile().getName())); - disguise(event.getPlayer(), bean.getGameProfile()); + tryDisguise(event.getPlayer(), bean.getGameProfile(), () -> { }); }, 1); } } @@ -480,15 +475,15 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler } } - public void disguise(Player caller, GameProfile requestedProfile) + public void tryDisguise(Player caller, GameProfile requestedProfile, Runnable onComplete) { if (getDisguiseManager().isDisguised(caller)) { if (isDisguised(caller)) { - UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); - } - else + UtilPlayer.message(caller, + F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); + } else { UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Perhaps you are morphed?")); } @@ -497,134 +492,75 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler if (isDisguised(caller)) { - UtilPlayer.message(caller, F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); - return; - } - - String requestedUsername = requestedProfile.getName(); - - if (!requestedUsername.equalsIgnoreCase(caller.getName())) - { - _cannotJoin.add(requestedUsername.toLowerCase()); - for (Player other : UtilServer.getPlayersCollection()) - { - if (other.getName().equalsIgnoreCase(requestedUsername)) - { - UtilPlayer.message(caller, C.cRed + F.main("Disguise", "This name is already in use!")); - _cannotJoin.remove(requestedUsername.toLowerCase()); - return; - } - } - } - - if (!_pendingDisguise.add(requestedUsername.toLowerCase())) - { - UtilPlayer.message(caller, F.main("Disguise", "Someone is already disguising as that user")); - return; - } - - PlayerPreDisguiseEvent playerPreDisguiseEvent = new PlayerPreDisguiseEvent(caller, requestedUsername); - UtilServer.CallEvent(playerPreDisguiseEvent); - if (playerPreDisguiseEvent.isCancelled()) - { - UtilPlayer.message(caller, F.main(getName(), "Your disguise was cancelled by something")); - _pendingDisguise.remove(requestedUsername.toLowerCase()); + UtilPlayer.message(caller, + F.main("Disguise", "You are already disguised. Please undisguise by using /disguise")); return; } CoreClient callerClient = getClientManager().Get(caller); - if (!requestedUsername.equalsIgnoreCase(caller.getName())) + String requestedUsername = requestedProfile.getName(); + if (requestedUsername.equalsIgnoreCase(caller.getName())) { - getClientManager().getOrLoadClient(requestedUsername, other -> + if (doDisguise(caller, requestedProfile, callerClient, callerClient)) { - Rank otherRank = other != null ? other.GetRank() : Rank.ALL; + onComplete.run(); + } + return; + } + for (Player other : UtilServer.getPlayersCollection()) + { + if (other.getName().equalsIgnoreCase(requestedUsername)) + { + UtilPlayer.message(caller, C.cRed + F.main("Disguise", "This name is already in use!")); + return; + } + } + + if (_pendingDisguise.contains(requestedUsername.toLowerCase())) + { + UtilPlayer.message(caller, F.main("Disguise", "Someone is already disguising as that user")); + return; + } + + getClientManager().getOrLoadClient(requestedUsername, other -> + { + if (other != null) + { + Rank otherRank = other.GetRank(); if (otherRank.has(Rank.TWITCH)) { - UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, YouTubers or Twitchers!")); + UtilPlayer.message(caller, + F.main("Disguise", "You can't disguise as staff, YouTubers or Twitchers!")); return; } - if (other != null) + PunishClient pclient = getPunishManager().GetClient(requestedUsername); + if (pclient != null && (pclient.IsBanned() || pclient.IsMuted())) { - PunishClient pclient = getPunishManager().GetClient(requestedUsername); - if (pclient != null && (pclient.IsBanned() || pclient.IsMuted())) - { - UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as players who are banned/muted!")); - return; - } + UtilPlayer.message(caller, + F.main("Disguise", "You can't disguise as players who are banned/muted!")); + return; } + } - callerClient.disguise(requestedUsername, requestedProfile.getId(), otherRank); + if (doDisguise(caller, requestedProfile, callerClient, other)) + { + onComplete.run(); + } + }); + } - _mapping.put(callerClient.getDisguisedAs().toLowerCase(), callerClient.getName()); + public boolean doDisguise(Player caller, GameProfile requestedProfile, CoreClient callerClient, CoreClient otherClient) + { + String requestedUsername = requestedProfile.getName(); + _pendingDisguise.add(requestedUsername.toLowerCase()); - System.out.println("================="); - System.out.println("Disguising " + caller.getName() + " as:"); - System.out.println(requestedProfile.getName() + " id " + requestedProfile.getId()); - System.out.println("Properties:"); - for (Map.Entry p : requestedProfile.getProperties().entries()) - { - System.out.println("\t" + p.getKey() + " " + p.getValue().getName()); - System.out.println("\t" + p.getValue().getValue()); - System.out.println("\t" + p.getValue().getSignature()); - } - System.out.println("================="); - - DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); - disguisePlayer.showInTabList(true, 0); - allow(caller); - getDisguiseManager().disguise(disguisePlayer, () -> - { - GameProfile callerProfile = ((CraftPlayer) caller).getProfile(); - - require(ScoreboardManager.class).handlePlayerQuit(disguisePlayer.getOriginalProfile().getName()); - - try - { - UtilGameProfile.changeName(callerProfile, disguisePlayer.getProfile().getName()); - UtilGameProfile.changeId(callerProfile, disguisePlayer.getProfile().getId()); - - Field playersByName = PlayerList.class.getDeclaredField("playersByName"); - playersByName.setAccessible(true); - Map map = (Map) playersByName.get(MinecraftServer.getServer().getPlayerList()); - map.remove(disguisePlayer.getOriginalProfile().getName()); - map.put(disguisePlayer.getProfile().getName(), disguisePlayer.getEntity()); - } - catch (Throwable t) - { - t.printStackTrace(); - } - - require(ScoreboardManager.class).handlePlayerJoin(disguisePlayer.getName()); - - callerProfile.getProperties().clear(); - callerProfile.getProperties().putAll(disguisePlayer.getProfile().getProperties()); - - callerProfile.getProperties().removeAll(ORIGINAL_UUID_KEY); - callerProfile.getProperties().put(ORIGINAL_UUID_KEY, new Property(ORIGINAL_UUID_KEY, caller.getUniqueId().toString())); - - require(FriendManager.class).updatePlayerStatus(disguisePlayer.getOriginalProfile().getId(), null); - require(FriendManager.class).updatePlayerStatus(disguisePlayer.getProfile().getId(), new PlayerStatus(disguisePlayer.getProfile().getId(), requestedUsername, _serverName)); - - getPreferencesManager().handlePlayerJoin(caller, true); - - _disguises.put(caller.getUniqueId(), disguisePlayer); - - UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + requestedUsername)); - - UtilServer.CallEvent(new PlayerDisguisedEvent(caller)); - - storeDisguiseData(caller, requestedUsername, requestedProfile); - - _pendingDisguise.remove(requestedUsername.toLowerCase()); - - _cannotJoin.remove(requestedUsername.toLowerCase()); - }); - }); - } - else + if (!requestedUsername.equalsIgnoreCase(caller.getName())) + { + _cannotJoin.add(requestedUsername.toLowerCase()); + } else { DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); disguisePlayer.showInTabList(true, 0); @@ -641,10 +577,93 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler _pendingDisguise.remove(requestedUsername.toLowerCase()); }); + + return true; } + + PlayerPreDisguiseEvent playerPreDisguiseEvent = new PlayerPreDisguiseEvent(caller, requestedUsername); + UtilServer.CallEvent(playerPreDisguiseEvent); + if (playerPreDisguiseEvent.isCancelled()) + { + UtilPlayer.message(caller, F.main(getName(), "Your disguise was cancelled by something")); + _pendingDisguise.remove(requestedUsername.toLowerCase()); + _cannotJoin.remove(requestedUsername.toLowerCase()); + return false; + } + + Rank otherRank = otherClient != null ? otherClient.GetRank() : Rank.ALL; + callerClient.disguise(requestedUsername, requestedProfile.getId(), otherRank); + + _mapping.put(callerClient.getDisguisedAs().toLowerCase(), callerClient.getName()); + + System.out.println("================="); + System.out.println("Disguising " + caller.getName() + " as:"); + System.out.println(requestedProfile.getName() + " id " + requestedProfile.getId()); + System.out.println("Properties:"); + for (Map.Entry p : requestedProfile.getProperties().entries()) + { + System.out.println("\t" + p.getKey() + " " + p.getValue().getName()); + System.out.println("\t" + p.getValue().getValue()); + System.out.println("\t" + p.getValue().getSignature()); + } + System.out.println("================="); + + DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); + disguisePlayer.showInTabList(true, 0); + allow(caller); + getDisguiseManager().disguise(disguisePlayer, () -> + { + GameProfile callerProfile = ((CraftPlayer) caller).getProfile(); + + require(ScoreboardManager.class).handlePlayerQuit(disguisePlayer.getOriginalProfile().getName()); + + try + { + UtilGameProfile.changeName(callerProfile, disguisePlayer.getProfile().getName()); + UtilGameProfile.changeId(callerProfile, disguisePlayer.getProfile().getId()); + + Field playersByName = PlayerList.class.getDeclaredField("playersByName"); + playersByName.setAccessible(true); + Map map = (Map) playersByName.get(MinecraftServer.getServer().getPlayerList()); + map.remove(disguisePlayer.getOriginalProfile().getName()); + map.put(disguisePlayer.getProfile().getName(), disguisePlayer.getEntity()); + } catch (Throwable t) + { + t.printStackTrace(); + } + + require(ScoreboardManager.class).handlePlayerJoin(disguisePlayer.getName()); + + callerProfile.getProperties().clear(); + callerProfile.getProperties().putAll(disguisePlayer.getProfile().getProperties()); + + callerProfile.getProperties().removeAll(ORIGINAL_UUID_KEY); + callerProfile.getProperties() + .put(ORIGINAL_UUID_KEY, new Property(ORIGINAL_UUID_KEY, caller.getUniqueId().toString())); + + require(FriendManager.class).updatePlayerStatus(disguisePlayer.getOriginalProfile().getId(), null); + require(FriendManager.class).updatePlayerStatus(disguisePlayer.getProfile().getId(), + new PlayerStatus(disguisePlayer.getProfile().getId(), requestedUsername, _serverName)); + + getPreferencesManager().handlePlayerJoin(caller, true); + + _disguises.put(caller.getUniqueId(), disguisePlayer); + + UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + requestedUsername)); + + UtilServer.CallEvent(new PlayerDisguisedEvent(caller)); + + storeDisguiseData(caller, requestedUsername, requestedProfile); + + _pendingDisguise.remove(requestedUsername.toLowerCase()); + + _cannotJoin.remove(requestedUsername.toLowerCase()); + }); + + return true; } - public void disguise(Player caller, String requestedUsername, String requestedSkin) + public void tryDisguise(Player caller, String requestedUsername, String requestedSkin, Runnable onComplete) { if (!validateUsername(caller, requestedUsername, true)) return; if (!validateUsername(caller, requestedSkin, false)) return; @@ -667,7 +686,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler requestedProfile.getProperties().clear(); requestedProfile.getProperties().put("textures", skinData.getProperty()); - disguise(caller, requestedProfile); + tryDisguise(caller, requestedProfile, onComplete); }; if (!requestedUsername.equalsIgnoreCase(requestedSkin)) From 7836e0aaaa5ffaa255a1f2c99e4b206fa48c10ec Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Mon, 17 Jul 2017 18:54:58 -0400 Subject: [PATCH 117/183] Fix guardian disguises This commit fixes guardian disguises (esp. elder guardians) and also provides for disguises to modify packets before they're sent if necessary --- .../core/disguise/DisguiseManager.java | 19 +-- .../core/disguise/disguises/DisguiseBase.java | 65 ++++++---- .../disguise/disguises/DisguiseGuardian.java | 113 +++++++++++++++++- 3 files changed, 163 insertions(+), 34 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index 89c28093f..44dc988fc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -360,6 +360,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler final Packet packet = packetInfo.getPacket(); final Player owner = packetInfo.getPlayer(); final PacketVerifier packetVerifier = packetInfo.getVerifier(); + final int protocol = ((CraftPlayer) owner).getHandle().getProtocol(); if (packet instanceof PacketPlayOutPlayerInfo) { @@ -406,7 +407,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler { packetInfo.setCancelled(true); - handleSpawnPackets(packetInfo.getVerifier(), latestDisguise); + handleSpawnPackets(packetInfo.getVerifier(), latestDisguise, protocol); } else if (latestDisguise.isHideIfNotDisguised()) { @@ -436,7 +437,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler if (latestDisguise != null && containsSpawnDisguise(owner, latestDisguise) && owner.getEntityId() != entityId) { packetInfo.setCancelled(true); - handlePacket(latestDisguise.getMetadataPacket(), packetVerifier); + handlePacket(latestDisguise.modifyMetaPacket(protocol, latestDisguise.getMetadataPacket()), packetVerifier); } } else if (packet instanceof PacketPlayOutEntityEquipment) @@ -475,7 +476,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler _handlingPacket = false; } - private void handleSpawnPackets(PacketVerifier packetVerifier, DisguiseBase disguise) + private void handleSpawnPackets(PacketVerifier packetVerifier, DisguiseBase disguise, int protocol) { if (disguise instanceof DisguisePlayer) { @@ -493,14 +494,14 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler handlePacket(infoPacket, packetVerifier); } - handlePacket(pDisguise.getSpawnPacket(), packetVerifier); + handlePacket(pDisguise.modifySpawnPacket(protocol, pDisguise.getSpawnPacket()), packetVerifier); for (Packet packet : pDisguise.getEquipmentPackets()) { handlePacket(packet, packetVerifier); } - handlePacket(pDisguise.getMetadataPacket(), packetVerifier); + handlePacket(pDisguise.modifyMetaPacket(protocol, pDisguise.getMetadataPacket()), packetVerifier); if (pDisguise.getSleepingDirection() != null) { @@ -556,7 +557,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler } else { - handlePacket(disguise.getSpawnPacket(), packetVerifier); + handlePacket(disguise.modifySpawnPacket(protocol, disguise.getSpawnPacket()), packetVerifier); if (disguise instanceof DisguiseLiving) { @@ -644,10 +645,12 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler { if (tester.test(player)) { - if (disguise.getEntity() == ((CraftPlayer) player).getHandle()) + EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle(); + if (disguise.getEntity() == nmsPlayer) continue; - UtilPlayer.sendPacket(player, disguise.getMetadataPacket()); + int protocol = nmsPlayer.getProtocol(); + UtilPlayer.sendPacket(player, disguise.modifyMetaPacket(protocol, disguise.getMetadataPacket())); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java index 2d0334abc..b9e6cdd9c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java @@ -2,16 +2,9 @@ package mineplex.core.disguise.disguises; import mineplex.core.common.DummyEntity; import mineplex.core.common.util.UtilPlayer; -import net.minecraft.server.v1_8_R3.DataWatcher; -import net.minecraft.server.v1_8_R3.Entity; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.EntityTrackerEntry; -import net.minecraft.server.v1_8_R3.IntHashMap; -import net.minecraft.server.v1_8_R3.MinecraftServer; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; -import net.minecraft.server.v1_8_R3.WorldServer; + +import net.minecraft.server.v1_8_R3.*; + import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -21,6 +14,8 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.function.Consumer; +import java.util.function.Supplier; public abstract class DisguiseBase { @@ -72,15 +67,7 @@ public abstract class DisguiseBase DataWatcher.watch(1, getEntity().getDataWatcher().getShort(1), net.minecraft.server.v1_8_R3.Entity.META_AIR, (int) getEntity().getDataWatcher().getShort(1)); } - public abstract Packet getSpawnPacket(); - - public Packet getMetadataPacket() - { - UpdateDataWatcher(); - return new PacketPlayOutEntityMetadata(getEntity().getId(), DataWatcher, true); - } - - public void resendMetadata() + public void sendToWatchers(Supplier supplier) { if (getEntity() == null || !getEntity().getBukkitEntity().isValid() || !(getEntity().world instanceof WorldServer)) return; @@ -90,14 +77,48 @@ public abstract class DisguiseBase if (tracker.get(getEntity().getId()) == null) return; - Packet packet = getMetadataPacket(); + Packet packet = supplier.get(); + if (packet == null) + return; for (EntityPlayer player : tracker.get(getEntity().getId()).trackedPlayers) { - UtilPlayer.sendPacket(player.getBukkitEntity(), packet); + if (packet instanceof PacketPlayOutEntityMetadata) + { + player.playerConnection.sendPacket(modifyMetaPacket(player.getProtocol(), packet)); + } else if (packet instanceof PacketPlayOutSpawnEntityLiving) + { + player.playerConnection.sendPacket(modifySpawnPacket(player.getProtocol(), packet)); + } else + { + player.playerConnection.sendPacket(packet); + } } } + public abstract Packet getSpawnPacket(); + + public Packet modifySpawnPacket(int protocol, Packet packet) + { + return packet; + } + + public Packet getMetadataPacket() + { + UpdateDataWatcher(); + return new PacketPlayOutEntityMetadata(getEntity().getId(), DataWatcher, true); + } + + public void resendMetadata() + { + sendToWatchers(this::getMetadataPacket); + } + + public Packet modifyMetaPacket(int protocol, Packet packet) + { + return packet; + } + public void setSoundDisguise(DisguiseBase soundDisguise) { _soundDisguise = soundDisguise; @@ -197,7 +218,7 @@ public abstract class DisguiseBase return this._disguiseType; } - public void setEntity(net.minecraft.server.v1_8_R3.Entity entity) + public void setEntity(Entity entity) { _entity.clear(); _entity = new WeakReference<>(entity); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java index af05e67bb..eaa367258 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java @@ -1,11 +1,23 @@ package mineplex.core.disguise.disguises; -import org.bukkit.entity.*; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; -import net.minecraft.server.v1_8_R3.EntityGuardian; +import com.mineplex.MetaWrapper; +import com.mineplex.ProtocolVersion; + +import net.minecraft.server.v1_8_R3.*; +import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; + +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.EntityType; public class DisguiseGuardian extends DisguiseCreature { + private int target = 0; + private boolean elder = false; + public DisguiseGuardian(org.bukkit.entity.Entity entity) { super(EntityType.GUARDIAN, entity); @@ -15,17 +27,33 @@ public class DisguiseGuardian extends DisguiseCreature public void setTarget(int target) { + this.target = target; + DataWatcher.watch(17, target, EntityGuardian.META_TARGET, target); } public void setElder(boolean elder) { - DataWatcher.watch(16, Integer.valueOf(DataWatcher.getInt(16) | 4), EntityGuardian.META_ELDER, (byte) (DataWatcher.getInt(16) | 4)); + this.elder = elder; + + int oldValue = DataWatcher.getInt(16); + int newValue = elder ? oldValue | 4 : oldValue & ~4; + + DataWatcher.watch(16, Integer.valueOf(newValue), EntityGuardian.META_ELDER, (byte) newValue); + + sendToWatchers(() -> new PacketPlayOutEntityDestroy(new int[]{getEntityId()})); + sendToWatchers(this::getSpawnPacket); + sendToWatchers(this::getMetadataPacket); } public boolean isElder() { - return (this.DataWatcher.getInt(16) & 4) != 0; + return elder; + } + + public int getTarget() + { + return target; } protected String getHurtSound() @@ -37,4 +65,81 @@ public class DisguiseGuardian extends DisguiseCreature return "mob.guardian.hit"; } + + // ---- Packet modification for 1.11 and up + + @Override + public Packet modifySpawnPacket(int protocol, Packet packet) + { + if (protocol >= ProtocolVersion.v1_11) + { + PacketPlayOutSpawnEntityLiving newSpawn = (PacketPlayOutSpawnEntityLiving) getSpawnPacket(); + if (isElder()) newSpawn.b = 4; + newSpawn.m = processSpawnMeta(DataWatcher.c()); + return newSpawn; + } + + return packet; + } + + @Override + public Packet modifyMetaPacket(int protocol, Packet packet) + { + if (protocol >= ProtocolVersion.v1_11) + { + PacketPlayOutEntityMetadata newPacket = (PacketPlayOutEntityMetadata) getMetadataPacket(); + newPacket.b = processMeta(newPacket.b); + return newPacket; + } + + return packet; + } + + private List processMeta(List list) + { + List newMeta = new ArrayList<>(); + for (WatchableObject meta : list) + { + MetaWrapper wrapper = new MetaWrapper(meta); + if (wrapper.getIndex() == 11) + { + byte value = (byte) wrapper.getValue(); + newMeta.add(new MetaWrapper(11, DataType.BOOLEAN, (value & 0x02) != 0)); + } else + { + newMeta.add(wrapper); + } + } + + return newMeta.stream().map(MetaWrapper::toWatchableObject).collect(Collectors.toList()); + } + + private List processSpawnMeta(List list) + { + List newMeta = new ArrayList<>(); + for (WatchableObject meta : list) + { + MetaWrapper wrapper = new MetaWrapper(meta); + if (wrapper.getIndex() >= 5) // 1.10 + { + wrapper.setIndex(wrapper.getIndex() + 1); + } + + if (getEntity() instanceof EntityArmorStand && (wrapper.getIndex() == 12 || wrapper.getIndex() == 13)) + { + continue; + } + + if (wrapper.getIndex() < 12) // Skip higher ones in 1.11 + { + newMeta.add(wrapper); + } else if (wrapper.getIndex() == 12) + { + byte value = (byte) wrapper.getValue(); + newMeta.add(new MetaWrapper(12, DataType.BOOLEAN, (value & 0x02) != 0)); + } + } + + return newMeta.stream().map(MetaWrapper::toWatchableObject).collect(Collectors.toList()); + } } From 2c997935c9ab8530b3ce5a42d5cd87ffc1801278 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Tue, 18 Jul 2017 12:33:07 -0400 Subject: [PATCH 118/183] Rewrite spawn meta for all living entities on 1.10 and up --- .../disguise/disguises/DisguiseCreature.java | 57 +++++++++++++++++-- .../disguise/disguises/DisguiseGuardian.java | 39 ++----------- 2 files changed, 57 insertions(+), 39 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java index d477ab3bc..55e62c217 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java @@ -1,9 +1,16 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.MathHelper; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; -import org.bukkit.entity.*; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import com.mineplex.MetaWrapper; +import com.mineplex.ProtocolVersion; + +import net.minecraft.server.v1_8_R3.*; +import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; + +import org.bukkit.entity.EntityType; public abstract class DisguiseCreature extends DisguiseInsentient { @@ -70,4 +77,46 @@ public abstract class DisguiseCreature extends DisguiseInsentient return packet; } + + @Override + public Packet modifySpawnPacket(int protocol, Packet packet) + { + if (protocol >= ProtocolVersion.v1_10_PRE) + { + PacketPlayOutSpawnEntityLiving newSpawn = (PacketPlayOutSpawnEntityLiving) getSpawnPacket(); + newSpawn.m = processSpawnMeta(protocol, DataWatcher.c()); + return newSpawn; + } + + return packet; + } + + private List processSpawnMeta(int protocol, List list) + { + List newMeta = new ArrayList<>(); + for (WatchableObject meta : list) + { + MetaWrapper wrapper = new MetaWrapper(meta); + if (wrapper.getIndex() >= 5) // 1.10 + { + wrapper.setIndex(wrapper.getIndex() + 1); + } + + if (protocol < ProtocolVersion.v1_11) + { + newMeta.add(wrapper); + continue; + } + + if (getEntity() instanceof EntityArmorStand && wrapper.getIndex() >= 12) + { + // Armor stand meta conflicts with a lot of entities on 1.11+ + continue; + } + + newMeta.add(wrapper); + } + + return newMeta.stream().map(MetaWrapper::toWatchableObject).collect(Collectors.toList()); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java index eaa367258..31222e6da 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java @@ -71,15 +71,13 @@ public class DisguiseGuardian extends DisguiseCreature @Override public Packet modifySpawnPacket(int protocol, Packet packet) { - if (protocol >= ProtocolVersion.v1_11) + PacketPlayOutSpawnEntityLiving newSpawn = (PacketPlayOutSpawnEntityLiving) super.modifySpawnPacket(protocol, packet); + if (protocol >= ProtocolVersion.v1_11 && isElder()) { - PacketPlayOutSpawnEntityLiving newSpawn = (PacketPlayOutSpawnEntityLiving) getSpawnPacket(); - if (isElder()) newSpawn.b = 4; - newSpawn.m = processSpawnMeta(DataWatcher.c()); - return newSpawn; + newSpawn.b = 4; } - return packet; + return newSpawn; } @Override @@ -113,33 +111,4 @@ public class DisguiseGuardian extends DisguiseCreature return newMeta.stream().map(MetaWrapper::toWatchableObject).collect(Collectors.toList()); } - - private List processSpawnMeta(List list) - { - List newMeta = new ArrayList<>(); - for (WatchableObject meta : list) - { - MetaWrapper wrapper = new MetaWrapper(meta); - if (wrapper.getIndex() >= 5) // 1.10 - { - wrapper.setIndex(wrapper.getIndex() + 1); - } - - if (getEntity() instanceof EntityArmorStand && (wrapper.getIndex() == 12 || wrapper.getIndex() == 13)) - { - continue; - } - - if (wrapper.getIndex() < 12) // Skip higher ones in 1.11 - { - newMeta.add(wrapper); - } else if (wrapper.getIndex() == 12) - { - byte value = (byte) wrapper.getValue(); - newMeta.add(new MetaWrapper(12, DataType.BOOLEAN, (value & 0x02) != 0)); - } - } - - return newMeta.stream().map(MetaWrapper::toWatchableObject).collect(Collectors.toList()); - } } From fb28a953e6ff6f875747077e12fa69cb6a4d4e1b Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Mon, 17 Jul 2017 15:55:59 -0400 Subject: [PATCH 119/183] Hide players from staff if the staff are also at the spawn point --- .../hub/modules/HubVisibilityManager.java | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java index b2c29d783..e93b00540 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java @@ -34,14 +34,12 @@ public class HubVisibilityManager extends MiniPlugin public HubVisibilityManager(HubManager manager) { super("Visibility Manager", manager.getPlugin()); - Manager = manager; } public void addHiddenPlayer(Player player) { _hiddenPlayers.add(player); - } public void removeHiddenPlayer(Player player) @@ -64,30 +62,30 @@ public class HubVisibilityManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { Rank rank = Manager.GetClients().Get(player).GetRank(); - boolean hideMe = UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 || - (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) || - _hiddenPlayers.contains(player); + boolean hideMe = UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 + || (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && + (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) + || _hiddenPlayers.contains(player); for (Player other : UtilServer.getPlayers()) { boolean localHideMe = hideMe; if (player.equals(other)) continue; - - if(Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR)) - localHideMe = false; - + + if (Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR)) + localHideMe = UtilMath.offset2d(other.getLocation(), Manager.GetSpawn()) == 0; + if (localHideMe || !Manager.getPreferences().get(other).isActive(Preference.SHOW_PLAYERS)) { VisibilityManager.Instance.setVisibility(player, false, other); - } - else + } else { VisibilityManager.Instance.setVisibility(player, true, other); } } } - } + } @EventHandler public void ParticleSwap(PlayerInteractEvent event) @@ -128,10 +126,9 @@ public class HubVisibilityManager extends MiniPlugin for (Player player : _particle.keySet()) { - - UtilParticle.PlayParticle(ParticleType.values()[_particle.get(player)], player.getLocation().add(1, 1, 0), 0f, 0f, 0f, 0, 1, + UtilParticle.PlayParticle(ParticleType.values()[_particle.get(player)], + player.getLocation().add(1, 1, 0), 0f, 0f, 0f, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); - } } } From 8516a9808758f613f583f1e14cf08a24e3c76f6d Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 18 Jul 2017 20:12:38 +0100 Subject: [PATCH 120/183] Lots of bug fixes --- .../core/imagemap/ImageMapManager.java | 18 +---- .../core/imagemap/objects/PlayerMapBoard.java | 75 +++++++++++-------- .../core/imagemap/objects/PlayerMapImage.java | 32 +++----- .../game/arcade/game/games/moba/Moba.java | 1 - .../arcade/game/games/moba/kit/HeroKit.java | 56 ++++++++------ .../arcade/game/games/moba/kit/HeroSkill.java | 15 +++- .../moba/progression/MobaProgression.java | 9 ++- .../arcade/game/games/moba/shop/MobaShop.java | 16 +++- .../games/moba/training/MobaTraining.java | 12 +++ .../arcade/managers/chat/GameChatManager.java | 2 +- 10 files changed, 135 insertions(+), 101 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java index a85a0898a..4cfc9486b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/ImageMapManager.java @@ -2,21 +2,16 @@ package mineplex.core.imagemap; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; -import mineplex.core.common.util.FileUtil; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilServer; import mineplex.core.imagemap.objects.PlayerMapBoard; import mineplex.core.imagemap.objects.PlayerMapImage; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.utils.UtilScheduler; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.entity.Entity; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -65,7 +60,7 @@ public class ImageMapManager extends MiniPlugin { Player player = event.getPlayer(); - runSyncLater(() -> _boards.forEach(board -> board.onPlayerJoin(player)), 50); + runSyncLater(() -> _boards.forEach(board -> board.onPlayerJoin(player)), 40); } @EventHandler @@ -73,13 +68,13 @@ public class ImageMapManager extends MiniPlugin { Player player = event.getPlayer(); - _boards.forEach(board -> board.getImages().forEach(image -> image.removeViewer(player))); + _boards.forEach(board -> board.onPlayerQuit(player)); } @EventHandler public void refreshBoards(UpdateEvent event) { - if (event.getType() != UpdateType.SLOWER) + if (event.getType() != UpdateType.TWOSEC) { return; } @@ -256,11 +251,6 @@ public class ImageMapManager extends MiniPlugin } } - board.getImages().forEach(image -> - { - image.getViewers().clear(); - image.getItemFrames().forEach(Entity::remove); - image.getItemFrames().clear(); - }); + board.cleanup(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapBoard.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapBoard.java index 6316b8baa..fb58bd7ac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapBoard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapBoard.java @@ -3,11 +3,12 @@ package mineplex.core.imagemap.objects; import mineplex.core.common.util.UtilMath; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import java.util.HashSet; +import java.util.HashMap; import java.util.List; -import java.util.Set; +import java.util.Map; public class PlayerMapBoard { @@ -16,66 +17,74 @@ public class PlayerMapBoard private final Location _location; private final List _images; - private final Set _viewers; + private final Map _viewers; public PlayerMapBoard(Location location, List images) { _location = location; _images = images; - _viewers = new HashSet<>(); + _viewers = new HashMap<>(); } public void goTo(Player player, boolean next) { - int i = 0; - - for (PlayerMapImage image : _images) + if (!_viewers.containsKey(player)) { - if (image.getViewers().contains(player)) - { - if (next && _images.size() - 1 == i) - { - i = -1; - } - else if (!next && i == 0) - { - i = _images.size(); - } - - image.removeViewer(player); - _images.get(next ? i + 1 : i - 1).addViewer(player); - return; - } - - i++; + return; } + + int index = _viewers.get(player); + + if (next && _images.size() - 1 == index) + { + index = -1; + } + else if (!next && index == 0) + { + index = _images.size(); + } + + int newIndex = next ? index + 1 : index - 1; + _viewers.put(player, newIndex); + _images.get(newIndex).addViewer(player, true); } public void onPlayerJoin(Player player) { - _images.get(0).addViewer(player); + _viewers.put(player, 0); + _images.get(0).addViewer(player, true); + } + + public void onPlayerQuit(Player player) + { + _viewers.remove(player); } public void onRefresh() { Bukkit.getOnlinePlayers().forEach(player -> { - - if (UtilMath.offset2dSquared(player.getLocation(), _location) < VIEW_DIST_SQUARED) + if (player.getWorld().equals(_location.getWorld()) && UtilMath.offset2dSquared(player.getLocation(), _location) < VIEW_DIST_SQUARED && _viewers.containsKey(player)) { - _viewers.add(player); + int index = _viewers.get(player); + _images.get(index).addViewer(player, false); } }); } + public void cleanup() + { + _viewers.clear(); + _images.forEach(image -> + { + image.getItemFrames().forEach(Entity::remove); + image.getItemFrames().clear(); + }); + } + public Location getLocation() { return _location; } - public List getImages() - { - return _images; - } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapImage.java b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapImage.java index 9d33e135e..2f21cd59b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapImage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/imagemap/objects/PlayerMapImage.java @@ -16,7 +16,6 @@ public class PlayerMapImage extends MapImage private final CustomItemFrames _itemFramesManager; private final List _itemMaps; - private final List _viewers; public PlayerMapImage(CustomItemFrames itemFramesManager, BufferedImage image, List itemFrames, int width, int height) { @@ -24,7 +23,6 @@ public class PlayerMapImage extends MapImage _itemFramesManager = itemFramesManager; _itemMaps = new ArrayList<>(); - _viewers = new ArrayList<>(); } @Override @@ -46,22 +44,20 @@ public class PlayerMapImage extends MapImage return _itemFrames; } - public void addViewer(Player player) + public void addViewer(Player player, boolean sendMap) { - if (!_viewers.add(player)) + if (sendMap) { - return; - } + //FIXME + int slot = 8; + for (ItemStack itemStack : _itemMaps) + { + player.getInventory().setItem(slot++, itemStack); + } - //FIXME - int slot = 8; - for (ItemStack itemStack : _itemMaps) - { - player.getInventory().setItem(slot++, itemStack); + UtilServer.runSyncLater(() -> player.getInventory().removeItem(_itemMaps.toArray(new ItemStack[0])), 5); } - UtilServer.runSyncLater(() -> player.getInventory().removeItem(_itemMaps.toArray(new ItemStack[0])), 5); - for (int i = 0; i < _itemMaps.size(); i++) { ItemFrame itemFrame = _itemFrames.get(i); @@ -70,14 +66,4 @@ public class PlayerMapImage extends MapImage _itemFramesManager.setItem(player, itemFrame, itemStack); } } - - public void removeViewer(Player player) - { - _viewers.remove(player); - } - - public List getViewers() - { - return _viewers; - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 0bdc5f21c..736dcf189 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -15,7 +15,6 @@ import mineplex.core.imagemap.objects.PlayerMapBoard; import mineplex.core.leaderboard.Leaderboard; import mineplex.core.leaderboard.LeaderboardManager; import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; -import mineplex.core.stats.event.StatChangeEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index e364ede7e..f3b3cd47f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -25,6 +25,7 @@ import nautilus.game.arcade.kit.Perk; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -217,27 +218,6 @@ public class HeroKit extends Kit { inventory.setBoots(itemstack); } - - // Give consumable items - else if (!UtilItem.isSword(itemstack) && !UtilGear.isBow(itemstack)) - { - // Keep moving left from the ammo slot until a free slot is available - for (int i = AMMO_SLOT - 1; i >= GetPerks().length - 1; i--) - { - ItemStack consumable = inventory.getItem(i); - - if (consumable == null) - { - inventory.setItem(i, itemstack); - break; - } - else if (consumable.isSimilar(itemstack)) - { - consumable.setAmount(consumable.getAmount() + 1); - break; - } - } - } } // Give all skill related items @@ -267,6 +247,40 @@ public class HeroKit extends Kit super.GiveItemsCall(player); disguise(player); + giveConsumables(player); + } + + public void giveConsumables(Player player) + { + Inventory inventory = player.getInventory(); + Moba game = (Moba) Manager.GetGame(); + List items = game.getShop().getOwnedItems(player); + + for (MobaItem item : items) + { + ItemStack itemStack = item.getItem(); + + // Give consumable items + if (itemStack.getType() == Material.POTION || itemStack.getType() == Material.ENDER_PEARL) + { + // Keep moving left from the ammo slot until a free slot is available + for (int i = AMMO_SLOT - 1; i >= GetPerks().length - 1; i--) + { + ItemStack consumable = inventory.getItem(i); + + if (consumable == null) + { + inventory.setItem(i, itemStack); + break; + } + else if (consumable.isSimilar(itemStack)) + { + consumable.setAmount(consumable.getAmount() + 1); + break; + } + } + } + } } public void disguise(Player player) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 2a19d34cd..965129a52 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -9,6 +9,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; @@ -185,8 +186,17 @@ public class HeroSkill extends Perk return false; } - return itemStack.isSimilar(_item); + if (itemStack.isSimilar(_item)) + { + if (_dropItemActivate && !Recharge.Instance.use(player, "Ultimate", _cooldown, false, false)) + { + return false; + } + return true; + } + + return false; } protected boolean isSkillSneak(PlayerToggleSneakEvent event) @@ -248,7 +258,7 @@ public class HeroSkill extends Perk } game.Announce(team.GetColor() + C.Bold + player.getName() + " " + kit.getRole().getChatColor() + kit.GetName() + C.cWhiteB + " activated their " + team.GetColor() + C.Bold + GetName() + C.cWhiteB + ".", false); - player.getWorld().playSound(player.getLocation(), Sound.NOTE_PLING, 10, 0.5F); + player.getWorld().playSound(player.getLocation(), Sound.NOTE_PLING, 1, 0.5F); } @EventHandler @@ -386,7 +396,6 @@ public class HeroSkill extends Perk GameTeam team = Manager.GetGame().GetTeam((Player) damager); return team != null && MobaUtil.isTeamEntity(damagee, team); - } public int getSlot() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java index 51717e88e..98fb784aa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java @@ -41,16 +41,18 @@ public class MobaProgression implements Listener { private static final int[] EXP_LEVELS; + private static final int EXP_PER_LEVEL = 1000; + private static final int EXP_FACTOR = 3; public static final DecimalFormat FORMAT = new DecimalFormat("0.0"); static { EXP_LEVELS = new int[100]; - int expRequired = 2000; + int expRequired = EXP_PER_LEVEL; for (int level = 0; level < 100; level++) { - EXP_LEVELS[level] = expRequired += 2000; + EXP_LEVELS[level] = expRequired += EXP_PER_LEVEL; } } @@ -199,6 +201,7 @@ public class MobaProgression implements Listener int level = getLevel(player, role); return getExperience(level) - getExperience(level - 1); } + public int getLevel(Player player, HeroKit kit) { return getLevel(player, kit.getRole()); @@ -238,6 +241,8 @@ public class MobaProgression implements Listener earnedExp.getAndAdd((int) data.Gems); } + earnedExp.getAndAdd(earnedExp.get() * EXP_FACTOR); + int level = getLevel(currentExp); int newLevel = getLevel(currentExp + earnedExp.get()); long expForThisLevel = getExperienceCurrentLevel(player, role); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index f0c15a324..6b8b00e34 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -19,12 +19,14 @@ import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop; import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop; import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop; import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop; import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import nautilus.game.arcade.kit.Kit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; @@ -210,10 +212,11 @@ public class MobaShop implements Listener // The respawn event needs to be called here so that effects like "Total Health Increase" will work straight away, instead of after the next respawn, // Prevents infinite speed + double currentHealth = player.getHealth(); player.setWalkSpeed(0.2F); player.setMaxHealth(20); - PlayerGameRespawnEvent fakeEvent = new PlayerGameRespawnEvent(null, player); + PlayerGameRespawnEvent fakeEvent = new PlayerGameRespawnEvent(_host, player); for (MobaItem ownedItem : owned) { @@ -223,13 +226,20 @@ public class MobaShop implements Listener } } - _host.GetKit(player).GiveItems(player); + HeroKit kit = (HeroKit) _host.GetKit(player); // If we aren't tracking purchases then after we give the item remove it. - if (!category.isTrackingPurchases()) + if (category.isTrackingPurchases()) { + kit.GiveItems(player); + } + else + { + kit.giveConsumables(player); owned.remove(item); } + + player.setHealth(Math.min(currentHealth, player.getMaxHealth())); } public boolean ownsItem(Player player, MobaItem item) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index 9be3809a1..59b4c33c2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.training; import mineplex.core.common.Rank; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilTime; @@ -522,4 +523,15 @@ public class MobaTraining extends Moba SetPlayerTeam(player, GetTeam(ChatColor.YELLOW), true); SetKit(player, kit, true); } + + @EventHandler + public void informLobbyPlayers(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC_20 || InProgress()) + { + return; + } + + Announce(F.main("Game", "Waiting for more players before starting the training area."), false); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java index 69e9958d2..17a1cb5d8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java @@ -171,7 +171,7 @@ public class GameChatManager implements Listener event.setFormat(dead + levelStr + rankStr + _manager.GetColor(sender) + senderName + " " + C.cWhite + "%2$s"); //Public/Private (Not If Player Dead) - if (_manager.GetGame() != null && _manager.GetGame().GetState() == GameState.Live) + if (_manager.GetGame() != null && _manager.GetGame().InProgress()) { boolean globalMessage = false; From 8b6f79a5eed8e3fabb6970ff3de2919c6571b317 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 19 Jul 2017 11:25:55 +0100 Subject: [PATCH 121/183] Delay persistence data get --- .../gemhunters/death/quitnpc/QuitNPC.java | 28 +++++++++---------- .../mineplex/gemhunters/join/JoinModule.java | 16 +++++------ 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPC.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPC.java index 0c79be7ef..e3cc6d88e 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPC.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/death/quitnpc/QuitNPC.java @@ -1,19 +1,5 @@ package mineplex.gemhunters.death.quitnpc; -import java.util.UUID; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; - import mineplex.core.Managers; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; @@ -26,6 +12,19 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilGameProfile; import mineplex.gemhunters.death.event.QuitNPCDespawnEvent; import mineplex.gemhunters.economy.EconomyModule; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +import java.util.UUID; public class QuitNPC implements Listener { @@ -94,7 +93,6 @@ public class QuitNPC implements Listener return; } - _disguise.undisguise(_disguise.getActiveDisguise(_entity)); _entity.remove(); _hologram.remove(); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/join/JoinModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/join/JoinModule.java index e7bd8f00a..435278517 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/join/JoinModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/join/JoinModule.java @@ -1,12 +1,5 @@ package mineplex.gemhunters.join; -import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; - import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClient; @@ -23,8 +16,14 @@ import mineplex.gemhunters.persistence.PersistenceModule; import mineplex.gemhunters.persistence.PersistenceRepository; import mineplex.gemhunters.quest.QuestModule; import mineplex.gemhunters.spawn.SpawnModule; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; + @ReflectivelyCreateMiniPlugin public class JoinModule extends MiniPlugin { @@ -88,6 +87,7 @@ public class JoinModule extends MiniPlugin } _inventory.resetSlots(player); + _spawn.teleportToSpawn(player); runAsync(() -> { @@ -97,7 +97,7 @@ public class JoinModule extends MiniPlugin { runSync(() -> _spawn.teleportToSpawn(player)); } - }); + }, 40); } private void loseDurability(ItemStack[] items, long time) From 2c0d4603570a10be7e856949086efe74a0c381dd Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 20 Jul 2017 00:55:14 -0400 Subject: [PATCH 122/183] Add Timer check (no bans enabled) --- Plugins/Mineplex.Core/pom.xml | 2 +- Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/pom.xml b/Plugins/Mineplex.Core/pom.xml index 50bfe79f3..b89d67002 100644 --- a/Plugins/Mineplex.Core/pom.xml +++ b/Plugins/Mineplex.Core/pom.xml @@ -48,7 +48,7 @@ com.mineplex anticheat - 1.5 + 1.6 org.tukaani diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 8dabca492..69e00b2dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -48,6 +48,7 @@ import com.mineplex.anticheat.checks.combat.KillauraTypeF; import com.mineplex.anticheat.checks.move.Glide; import com.mineplex.anticheat.checks.move.HeadRoll; import com.mineplex.anticheat.checks.move.Speed; +import com.mineplex.anticheat.checks.move.Timer; import com.mineplex.anticheat.checks.move.Toggle; import com.mineplex.anticheat.checks.player.BadPackets; @@ -100,6 +101,7 @@ public class AntiHack extends MiniPlugin .put(Speed.class, new CheckThresholds("Speed", 1000, 2000, 3500)) .put(HeadRoll.class, new CheckThresholds("Illegal Movement", 0, 0, 1000)) .put(Toggle.class, new CheckThresholds("AutoSneak", 100, 200, 300)) + .put(Timer.class, new CheckThresholds("Timer", 1000, 2000, 3000)) .build(); private static final CheckThresholds NOOP_THRESHOLD = new CheckThresholds("Unknown", Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); From d5d21a3fab49aaae9946941eab7ed16a92b2e375 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 20 Jul 2017 01:00:37 -0400 Subject: [PATCH 123/183] Disable anticheat checks in event servers --- .../src/mineplex/core/antihack/AntiHack.java | 4 ++-- .../game/arcade/managers/GameHostManager.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 69e00b2dd..159290bf3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -89,7 +89,7 @@ import mineplex.serverdata.commands.ServerCommandManager; @ReflectivelyCreateMiniPlugin public class AntiHack extends MiniPlugin { - private static final Map, CheckThresholds> CHECKS = ImmutableMap., CheckThresholds>builder() + public static final Map, CheckThresholds> CHECKS = ImmutableMap., CheckThresholds>builder() .put(KillauraTypeA.class, new CheckThresholds("Kill Aura", 25, 45, 60)) .put(KillauraTypeB.class, new CheckThresholds("High CPS", 0, 0, Integer.MAX_VALUE)) .put(KillauraTypeC.class, new CheckThresholds("Reach", 25, Integer.MAX_VALUE, Integer.MAX_VALUE)) @@ -106,7 +106,7 @@ public class AntiHack extends MiniPlugin private static final CheckThresholds NOOP_THRESHOLD = new CheckThresholds("Unknown", Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); - private static final Map, AntiHackAction> ACTIONS = ImmutableMap., AntiHackAction>builder() + public static final Map, AntiHackAction> ACTIONS = ImmutableMap., AntiHackAction>builder() .put(KillauraTypeA.class, new ImmediateBanAction(200)) .put(KillauraTypeD.class, new BanwaveAction(1500)) .put(KillauraTypeF.class, new BanwaveAction(600)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index f046626b4..0867fb6cc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.managers; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.stream.Stream; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -22,6 +23,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.Plugin; import mineplex.core.Managers; +import mineplex.core.antihack.AntiHack; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -40,14 +42,17 @@ import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; 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.gui.privateServer.PrivateServerShop; import nautilus.game.arcade.gui.privateServer.page.GameVotingPage; public class GameHostManager implements Listener { + private final AntiHack _antiHack; private ArrayList ultraGames = new ArrayList(); private ArrayList heroGames = new ArrayList(); private ArrayList legendGames = new ArrayList(); @@ -79,6 +84,7 @@ public class GameHostManager implements Listener public GameHostManager(ArcadeManager manager) { + _antiHack = Managers.require(AntiHack.class); Manager = manager; _shop = new PrivateServerShop(manager, manager.GetClients(), manager.GetDonation()); Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); @@ -160,6 +166,18 @@ public class GameHostManager implements Listener return games; } + @EventHandler + public void onStateChange(GameStateChangeEvent event) + { + if (!isEventServer()) + { + return; + } + + // Disable all checks in event servers + Stream.concat(AntiHack.ACTIONS.keySet().stream(), AntiHack.CHECKS.keySet().stream()).distinct().forEach(_antiHack::addIgnoredCheck); + } + @EventHandler public void updateHost(UpdateEvent event) { From e5e0fd8eda7cee1c4ad9fe131b421bfde59f9f9c Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 20 Jul 2017 01:03:03 -0400 Subject: [PATCH 124/183] Halve exp requirements for leveling in MOBA --- .../arcade/game/games/moba/progression/MobaProgression.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java index 98fb784aa..9402ac11c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java @@ -41,7 +41,7 @@ public class MobaProgression implements Listener { private static final int[] EXP_LEVELS; - private static final int EXP_PER_LEVEL = 1000; + private static final int EXP_PER_LEVEL = 500; private static final int EXP_FACTOR = 3; public static final DecimalFormat FORMAT = new DecimalFormat("0.0"); From a29cff2db1ab0df01ca50d8d09a157630a8e76d9 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 20 Jul 2017 16:52:49 -0400 Subject: [PATCH 125/183] Properly block Scythe healing when hitting teammates --- .../items/legendaries/DemonicScythe.java | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java index a35cd627e..06d840826 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/DemonicScythe.java @@ -1,9 +1,13 @@ package mineplex.game.clans.items.legendaries; +import org.bukkit.GameMode; import org.bukkit.Material; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import mineplex.core.common.util.C; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.ClansUtility; import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class DemonicScythe extends LegendaryItem @@ -21,14 +25,48 @@ public class DemonicScythe extends LegendaryItem C.cYellow + "Attack" + C.cWhite + " to use" + C.cGreen + " Leach Health", }, Material.RECORD_8); } + + private boolean isTeammate(Entity attacker, Entity defender) + { + if (attacker == null || defender == null) return false; + // Don't count attacks towards teammates + if (attacker instanceof Player && defender instanceof Player) + { + ClansUtility.ClanRelation relation = ClansManager.getInstance().getRelation((Player) attacker, (Player) defender); + if (relation == ClansUtility.ClanRelation.ALLY + || relation == ClansUtility.ClanRelation.SAFE + || relation == ClansUtility.ClanRelation.SELF) + { + return true; + } + } + return false; + } @Override public void onAttack(CustomDamageEvent event, Player wielder) { - if (!event.isCancelled()) + if (event.isCancelled()) { - event.AddMod("Scythe of the Fallen Lord", 8); - wielder.setHealth(Math.min(wielder.getMaxHealth(), wielder.getHealth() + 2)); + return; } + if (ClansManager.getInstance().isSafe(wielder)) + { + return; + } + if (event.GetDamageeEntity() instanceof Player && ClansManager.getInstance().isSafe(event.GetDamageePlayer())) + { + return; + } + if (wielder.getGameMode().equals(GameMode.CREATIVE)) + { + return; + } + if (isTeammate(wielder, event.GetDamageeEntity())) + { + return; + } + event.AddMod("Scythe of the Fallen Lord", 8); + wielder.setHealth(Math.min(wielder.getMaxHealth(), wielder.getHealth() + 2)); } } \ No newline at end of file From d8d1ee78323b3f4a0886250cc48564bcff0740bc Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 21 Jul 2017 22:31:23 -0400 Subject: [PATCH 126/183] Fix anticheat banning in clans --- .../src/mineplex/core/antihack/AntiHack.java | 38 ++++++++++--------- .../antihack/logging/AnticheatDatabase.java | 3 +- .../antihack/logging/AnticheatMetadata.java | 2 +- .../logging/builtin/PartyInfoMetadata.java | 9 ++++- .../logging/builtin/PlayerInfoMetadata.java | 2 +- .../builtin/ViolationInfoMetadata.java | 2 +- .../core/punish/clans/ClansBanRepository.java | 27 +++++++------ 7 files changed, 44 insertions(+), 39 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 159290bf3..c991e8c75 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -1,6 +1,5 @@ package mineplex.core.antihack; -import javax.xml.bind.DatatypeConverter; import java.util.Collections; import java.util.HashSet; import java.util.Map; @@ -10,11 +9,7 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; +import javax.xml.bind.DatatypeConverter; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -77,6 +72,7 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.punish.Category; @@ -85,6 +81,11 @@ import mineplex.core.punish.PunishClient; import mineplex.core.punish.Punishment; import mineplex.core.punish.PunishmentResponse; import mineplex.serverdata.commands.ServerCommandManager; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; @ReflectivelyCreateMiniPlugin public class AntiHack extends MiniPlugin @@ -238,7 +239,7 @@ public class AntiHack extends MiniPlugin { _punish.getClansPunish().loadClient(coreClient.getUniqueId(), client -> { - _punish.getClansPunish().ban(client, null, AntiHack.NAME, 90 * 24 * 60 * 60 * 1000, finalMessage, null, ban -> {}); + _punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, mineplex.core.common.util.UtilTime.TimeUnit.DAYS, mineplex.core.common.util.UtilTime.TimeUnit.MILLISECONDS), finalMessage, null, ban -> {}); }); } }; @@ -254,17 +255,18 @@ public class AntiHack extends MiniPlugin else { runBanAnimation(player, () -> - doPunish.accept(result -> + { + doPunish.accept(result -> + { + if (result == PunishmentResponse.Punished) { - if (result == PunishmentResponse.Punished) - { - announceBan(player); - _banned.add(player.getUniqueId()); - _banWaveManager.flagDone(coreClient); - } - _pendingBan.remove(player); - }) - ); + announceBan(player); + _banned.add(player.getUniqueId()); + _banWaveManager.flagDone(coreClient); + } + _pendingBan.remove(player); + }); + }); } }, custom); } @@ -286,7 +288,7 @@ public class AntiHack extends MiniPlugin { _punish.getClansPunish().loadClient(coreClient.getUniqueId(), client -> { - _punish.getClansPunish().ban(client, null, AntiHack.NAME, 90 * 24 * 60 * 60 * 1000, info.getMessage(), null, ban -> {}); + _punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, mineplex.core.common.util.UtilTime.TimeUnit.DAYS, mineplex.core.common.util.UtilTime.TimeUnit.MILLISECONDS), info.getMessage(), null, ban -> {}); }); } }; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatDatabase.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatDatabase.java index 087b68d3c..721abb330 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatDatabase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatDatabase.java @@ -5,7 +5,6 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import mineplex.core.common.util.UtilTasks; -import mineplex.core.database.MinecraftRepository; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; @@ -45,4 +44,4 @@ public class AnticheatDatabase extends RepositoryBase } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatMetadata.java index dc015a66a..9ae46926e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AnticheatMetadata.java @@ -20,4 +20,4 @@ public abstract class AnticheatMetadata implements Listener public abstract JsonElement build(UUID player); public abstract void remove(UUID player); -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PartyInfoMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PartyInfoMetadata.java index 5b56687d8..6d0be3f48 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PartyInfoMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PartyInfoMetadata.java @@ -28,7 +28,12 @@ public class PartyInfoMetadata extends AnticheatMetadata @Override public JsonElement build(UUID player) { - Party party = require(PartyManager.class).getPartyByPlayer(player); + PartyManager pm = require(PartyManager.class); + if (pm == null) + { + return JsonNull.INSTANCE; + } + Party party = pm.getPartyByPlayer(player); if (party != null) { JsonObject partyData = new JsonObject(); @@ -52,4 +57,4 @@ public class PartyInfoMetadata extends AnticheatMetadata { } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java index 479db70d2..509561a76 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/PlayerInfoMetadata.java @@ -48,4 +48,4 @@ public class PlayerInfoMetadata extends AnticheatMetadata { } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ViolationInfoMetadata.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ViolationInfoMetadata.java index 556cea86b..69685a46c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ViolationInfoMetadata.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/builtin/ViolationInfoMetadata.java @@ -156,4 +156,4 @@ public class ViolationInfoMetadata extends AnticheatMetadata violations.add(data); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanRepository.java index 3444e3eb0..702968d98 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanRepository.java @@ -108,20 +108,19 @@ public class ClansBanRepository extends RepositoryBase { // Yes, this is garbage. // Yes, it would be better implemented in a functional language. - return CompletableFuture.supplyAsync(() -> Managers.get(CoreClientManager.class).loadUUIDFromDB(name)) - .thenCompose(uuid -> - { - if (uuid == null) - { - CompletableFuture> future = new CompletableFuture<>(); - future.complete(Optional.empty()); - return future; - } - else - { - return loadClient(uuid).thenApply(Optional::of); - } - }); + return CompletableFuture.supplyAsync(() -> Managers.get(CoreClientManager.class).loadUUIDFromDB(name)).thenCompose(uuid -> + { + if (uuid == null) + { + CompletableFuture> future = new CompletableFuture<>(); + future.complete(Optional.empty()); + return future; + } + else + { + return loadClient(uuid).thenApply(Optional::of); + } + }); } public void removeBan(ClansBan ban) From 5ccc599ef19355e706b9dda8925159c50fbae4a1 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 21 Jul 2017 22:34:35 -0400 Subject: [PATCH 127/183] Clean up anticheat clans blacklist reason --- .../Mineplex.Core/src/mineplex/core/antihack/AntiHack.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index c991e8c75..6a75bea99 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -239,7 +239,7 @@ public class AntiHack extends MiniPlugin { _punish.getClansPunish().loadClient(coreClient.getUniqueId(), client -> { - _punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, mineplex.core.common.util.UtilTime.TimeUnit.DAYS, mineplex.core.common.util.UtilTime.TimeUnit.MILLISECONDS), finalMessage, null, ban -> {}); + _punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, mineplex.core.common.util.UtilTime.TimeUnit.DAYS, mineplex.core.common.util.UtilTime.TimeUnit.MILLISECONDS), ChatColor.stripColor(finalMessage).replace("\n", ""), null, ban -> {}); }); } }; @@ -288,7 +288,7 @@ public class AntiHack extends MiniPlugin { _punish.getClansPunish().loadClient(coreClient.getUniqueId(), client -> { - _punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, mineplex.core.common.util.UtilTime.TimeUnit.DAYS, mineplex.core.common.util.UtilTime.TimeUnit.MILLISECONDS), info.getMessage(), null, ban -> {}); + _punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, mineplex.core.common.util.UtilTime.TimeUnit.DAYS, mineplex.core.common.util.UtilTime.TimeUnit.MILLISECONDS), ChatColor.stripColor(info.getMessage()).replace("\n", ""), null, ban -> {}); }); } }; From 66fdd9be9f2f4af925eeace056b7662328be6840 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 22 Jul 2017 14:24:29 +0100 Subject: [PATCH 128/183] Skeleton mode --- .../game/arcade/game/games/moba/Moba.java | 98 ++++++---- .../game/games/moba/boss/BossManager.java | 45 ++--- .../arcade/game/games/moba/boss/MobaBoss.java | 5 + .../games/moba/boss/pumpkin/PumpkinBoss.java | 14 +- .../moba/buff/buffs/BuffPumpkinKing.java | 20 +- .../game/games/moba/minion/MinionWave.java | 16 +- .../games/moba/modes/MobaHeroesValleyMap.java | 17 ++ .../arcade/game/games/moba/modes/MobaMap.java | 15 ++ .../game/games/moba/modes/MobaMapType.java | 40 ++++ .../games/moba/modes/MobaMonochromeMap.java | 185 ++++++++++++++++++ .../games/moba/overtime/OvertimeManager.java | 7 +- 11 files changed, 363 insertions(+), 99 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaHeroesValleyMap.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMap.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMapType.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMonochromeMap.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 0bdc5f21c..da645327e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -45,6 +45,8 @@ import nautilus.game.arcade.game.games.moba.kit.hp.HPManager; import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa; import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena; import nautilus.game.arcade.game.games.moba.minion.MinionManager; +import nautilus.game.arcade.game.games.moba.modes.MobaMap; +import nautilus.game.arcade.game.games.moba.modes.MobaMapType; import nautilus.game.arcade.game.games.moba.overtime.OvertimeManager; import nautilus.game.arcade.game.games.moba.progression.MobaProgression; import nautilus.game.arcade.game.games.moba.shop.MobaShop; @@ -108,6 +110,8 @@ public class Moba extends TeamGame private PlayerMapBoard _board; private MapBoardSelector _selector; + private MobaMap _map; + private int _inPlayers; public Moba(ArcadeManager manager, GameType gameType, String[] description) @@ -207,48 +211,64 @@ public class Moba extends TeamGame SpectatorSpawn = WorldData.GetCustomLocs("CENTER").get(0); - // Leaderboards - if (Manager.IsRewardStats()) + MobaMapType mapType = null; + + for (String key : WorldData.GetAllCustomLocs().keySet()) { - if (Manager.GetLobby() instanceof NewGameLobbyManager) + try { - Map> lobbyCustomLocs = ((NewGameLobbyManager) Manager.GetLobby()).getCustomLocs(); - LeaderboardManager leaderboard = Managers.get(LeaderboardManager.class); - Pair winPair = Pair.create("Win", "Wins"); - Pair killPair = Pair.create("Kill", "Kills"); - Pair goldPair = Pair.create("Gold", "Gold"); - - { - Location location = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); - leaderboard.registerLeaderboard("TOP_HOG_DAILY_WINS", new Leaderboard("Top Daily Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.DAILY, location, 10)); - } - { - Location location = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); - leaderboard.registerLeaderboard("TOP_HOG_DAILY_KILLS", new Leaderboard("Top Daily Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.DAILY, location, 10)); - } - { - Location location = lobbyCustomLocs.get("TOP_DAILY_GOLD").get(0); - leaderboard.registerLeaderboard("TOP_HOG_DAILY_GOLD", new Leaderboard("Top Daily Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.DAILY, location, 10)); - } - { - Location location = lobbyCustomLocs.get("TOP_WINS").get(0); - leaderboard.registerLeaderboard("TOP_HOG_WINS", new Leaderboard("Top Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.ALL, location, 10)); - } - { - Location location = lobbyCustomLocs.get("TOP_KILLS").get(0); - leaderboard.registerLeaderboard("TOP_HOG_KILLS", new Leaderboard("Top Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.ALL, location, 10)); - } - { - Location location = lobbyCustomLocs.get("TOP_GOLD").get(0); - leaderboard.registerLeaderboard("TOP_HOG_GOLD", new Leaderboard("Top Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.ALL, location, 10)); - } - - _progression.spawnRoleViewers(lobbyCustomLocs); - - _board = _mapManager.createPlayerBoard(lobbyCustomLocs.get("HERO_VIEWER").get(0), BlockFace.EAST, 7, 4, ITEM_IMAGES); - _selector = new MapBoardSelector(_board); - _selector.createHolograms(lobbyCustomLocs.get("HERO_VIEWER NEXT").get(0), lobbyCustomLocs.get("HERO_VIEWER BACK").get(0)); + mapType = MobaMapType.valueOf(key); } + catch (IllegalArgumentException e) + { + } + } + + if (mapType == null) + { + mapType = MobaMapType.HEROES_VALLEY; + } + + _map = registerManager(mapType.createInstance(this)); + + if (Manager.IsRewardStats() && Manager.GetLobby() instanceof NewGameLobbyManager) + { + Map> lobbyCustomLocs = ((NewGameLobbyManager) Manager.GetLobby()).getCustomLocs(); + LeaderboardManager leaderboard = Managers.get(LeaderboardManager.class); + Pair winPair = Pair.create("Win", "Wins"); + Pair killPair = Pair.create("Kill", "Kills"); + Pair goldPair = Pair.create("Gold", "Gold"); + + { + Location location = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_DAILY_WINS", new Leaderboard("Top Daily Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.DAILY, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_DAILY_KILLS", new Leaderboard("Top Daily Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.DAILY, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_DAILY_GOLD").get(0); + leaderboard.registerLeaderboard("TOP_HOG_DAILY_GOLD", new Leaderboard("Top Daily Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.DAILY, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_WINS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_WINS", new Leaderboard("Top Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.ALL, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_KILLS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_KILLS", new Leaderboard("Top Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.ALL, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_GOLD").get(0); + leaderboard.registerLeaderboard("TOP_HOG_GOLD", new Leaderboard("Top Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.ALL, location, 10)); + } + + _progression.spawnRoleViewers(lobbyCustomLocs); + + _board = _mapManager.createPlayerBoard(lobbyCustomLocs.get("HERO_VIEWER").get(0), BlockFace.EAST, 7, 4, ITEM_IMAGES); + _selector = new MapBoardSelector(_board); + _selector.createHolograms(lobbyCustomLocs.get("HERO_VIEWER NEXT").get(0), lobbyCustomLocs.get("HERO_VIEWER BACK").get(0)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java index 11f37cceb..7bddb9ed3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -4,35 +4,36 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.boss.pumpkin.PumpkinBoss; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.world.WorldData; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; public class BossManager implements Listener { private final Moba _host; - private Map _teamBosses; - private PumpkinBoss _pumpkinBoss; + private final Set _bosses; + private final Map _teamBosses; private boolean _dummyBosses; public BossManager(Moba host) { _host = host; + _bosses = new HashSet<>(); _teamBosses = new HashMap<>(2); } - private void spawnBosses() + private void spawnTeamWithers() { if (_dummyBosses) { @@ -52,10 +53,6 @@ public class BossManager implements Listener _teamBosses.put(team, boss); } - // Pumpkin King - _pumpkinBoss = new PumpkinBoss(_host, worldData.GetDataLocs("BLACK").get(0)); - _pumpkinBoss.setup(); - _host.CreatureAllowOverride = false; } @@ -67,7 +64,7 @@ public class BossManager implements Listener return; } - spawnBosses(); + spawnTeamWithers(); } @EventHandler @@ -79,17 +76,18 @@ public class BossManager implements Listener } _teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup()); + _bosses.forEach(MobaBoss::cleanup); + _bosses.clear(); + } - if (_pumpkinBoss != null) - { - _pumpkinBoss.cleanup(); - } + public void registerBoss(MobaBoss boss) + { + _bosses.add(boss); } public String getWitherDisplayString(GameTeam team) { WitherBoss boss = getWitherBoss(team); - return MobaUtil.getColour(boss.getHealthPercentage()) + "♚"; } @@ -98,20 +96,9 @@ public class BossManager implements Listener return _teamBosses.get(team); } - public List getBosses() + public Collection getWitherBosses() { - List bosses = new ArrayList<>(); - - if (_teamBosses != null) - { - bosses.addAll(_teamBosses.values()); - } - if (_pumpkinBoss != null) - { - bosses.add(_pumpkinBoss); - } - - return bosses; + return _teamBosses.values(); } public void setDummyBosses(boolean dummyBosses) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index e46cdffd7..7fc4bce66 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -113,6 +113,11 @@ public abstract class MobaBoss implements Listener getAi().setEntity(_entity); } + public void registerBoss() + { + _host.getBossManager().registerBoss(this); + } + public abstract LivingEntity spawnEntity(); public abstract MobaAI getAi(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index 133a8277e..c53a08e79 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -113,7 +113,7 @@ public class PumpkinBoss extends MobaBoss getAi().setEntity(skeleton); UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10); - _host.Announce(F.main("Game", C.cRedB + "The Pumpkin King Has Awoken!"), false); + _host.Announce(F.main("Game", "The " + F.elem("Pumpkin King") + " has spawned! Killing him will give your team a buff!"), false); for (Player player : Bukkit.getOnlinePlayers()) { @@ -125,7 +125,8 @@ public class PumpkinBoss extends MobaBoss Block block = entry.getKey(); double setChance = entry.getValue(); - if (!UtilBlock.solid(block)|| block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > setChance) + if (!UtilBlock.solid(block) || block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > + setChance) { continue; } @@ -230,12 +231,7 @@ public class PumpkinBoss extends MobaBoss BuffManager buffManager = _host.getBuffManager(); for (Player teamMember : team.GetPlayers(true)) { - if (UtilPlayer.isSpectator(teamMember)) - { - continue; - } - - buffManager.apply(new BuffPumpkinKing(_host, teamMember)); + buffManager.apply(new BuffPumpkinKing(_host, teamMember, true)); } } @@ -283,7 +279,7 @@ public class PumpkinBoss extends MobaBoss } else { - _entity.setHealth(Math.min(_entity.getHealth() + HEALTH_OUT_OF_COMBAT, _entity.getMaxHealth())); + MobaUtil.heal(_entity, null, HEALTH_OUT_OF_COMBAT); updateDisplay(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java index 13868ec67..bb334e128 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java @@ -12,6 +12,7 @@ import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.buff.Buff; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; import org.bukkit.Bukkit; +import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; @@ -29,13 +30,17 @@ public class BuffPumpkinKing extends Buff { private static final long DURATION = TimeUnit.MINUTES.toMillis(1); - private static final String DAMAGE_REASON = "Pumpkin King Buff"; + private static final String DAMAGE_REASON = "Boss Buff"; private static final double DAMAGE_FACTOR = 1.5; private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN); - public BuffPumpkinKing(Moba host, Player entity) + private boolean _giveHelmet; + + public BuffPumpkinKing(Moba host, Player entity, boolean giveHelmet) { super(host, entity, DURATION); + + _giveHelmet = giveHelmet; } @Override @@ -44,19 +49,22 @@ public class BuffPumpkinKing extends Buff _entity.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60 * 20, 1)); UtilParticle.PlayParticleToAll(ParticleType.LAVA, _entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG); _entity.playSound(_entity.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F); - _entity.sendMessage(F.main("Game", "You feel the power of the Pumpkin King flow through you. Your damage and regeneration are increased!")); + _entity.sendMessage(F.main("Game", "You feel a " + F.elem("Great Power") + "flow through you. Your " + F.elem("Damage") + " and " + F.elem("Regeneration") + " are increased!")); } @Override public void onExpire() { - sendFakeHelmet(_entity, _entity.getInventory().getHelmet()); + if (_giveHelmet) + { + sendFakeHelmet(_entity, _entity.getInventory().getHelmet()); + } } @EventHandler public void updateFakeHelmet(UpdateEvent event) { - if (event.getType() != UpdateType.SLOW) + if (event.getType() != UpdateType.SLOW || !_giveHelmet) { return; } @@ -80,7 +88,7 @@ public class BuffPumpkinKing extends Buff return; } - UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, damagee.getLocation().add(0, 0.5, 0), 0.25F, 0.25F, 0.25F, 0.1F, 10, ViewDist.NORMAL); + damagee.getWorld().playEffect(damagee.getLocation().add(0, 0.5, 0), Effect.STEP_SOUND, Material.REDSTONE_BLOCK); event.AddMod(DAMAGE_REASON, DAMAGE_FACTOR); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 2ec589c7e..0fb7e7f17 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -28,6 +28,7 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -243,16 +244,9 @@ public class MinionWave implements Listener private Location targetWither(Minion minion) { - for (MobaBoss boss : _host.getBossManager().getBosses()) + for (WitherBoss boss : _host.getBossManager().getWitherBosses()) { - if (boss.isDead() || !(boss instanceof WitherBoss)) - { - continue; - } - - WitherBoss witherBoss = (WitherBoss) boss; - - if (witherBoss.getTeam().equals(_owner)) + if (boss.isDead() || boss.getTeam().equals(_owner)) { continue; } @@ -352,11 +346,11 @@ public class MinionWave implements Listener return; } - List bosses = _host.getBossManager().getBosses(); + Collection bosses = _host.getBossManager().getWitherBosses(); for (Minion minion : _minions) { - for (MobaBoss boss : bosses) + for (WitherBoss boss : bosses) { // Dead, not close enough if (boss.isDead() || MobaUtil.isTeamEntity(boss.getEntity(), _owner) || UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()) > DAMAGE_RANGE_SQUARED) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaHeroesValleyMap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaHeroesValleyMap.java new file mode 100644 index 000000000..ef539679a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaHeroesValleyMap.java @@ -0,0 +1,17 @@ +package nautilus.game.arcade.game.games.moba.modes; + +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.boss.pumpkin.PumpkinBoss; + +public class MobaHeroesValleyMap extends MobaMap +{ + + public MobaHeroesValleyMap(Moba host) + { + super(host); + + new PumpkinBoss(host, host.WorldData.GetDataLocs("BLACK").get(0)) + .registerBoss(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMap.java new file mode 100644 index 000000000..44cd32d00 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMap.java @@ -0,0 +1,15 @@ +package nautilus.game.arcade.game.games.moba.modes; + +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.event.Listener; + +public class MobaMap implements Listener +{ + + protected final Moba _host; + + public MobaMap(Moba host) + { + _host = host; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMapType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMapType.java new file mode 100644 index 000000000..b1ad4f9c3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMapType.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.moba.modes; + +import nautilus.game.arcade.game.games.moba.Moba; + +import java.lang.reflect.InvocationTargetException; + +public enum MobaMapType +{ + + HEROES_VALLEY("Heroes Valley", MobaHeroesValleyMap.class), + MONOCHROME("Monochrome", MobaMonochromeMap.class) + + ; + + private final String _name; + private final Class _clazz; + + MobaMapType(String name, Class clazz) + { + _name = name; + _clazz = clazz; + } + + public String getName() + { + return _name; + } + + public MobaMap createInstance(Moba host) + { + try + { + return _clazz.getConstructor(Moba.class).newInstance(host); + } + catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) + { + return null; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMonochromeMap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMonochromeMap.java new file mode 100644 index 000000000..498a6f4a8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMonochromeMap.java @@ -0,0 +1,185 @@ +package nautilus.game.arcade.game.games.moba.modes; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.buff.BuffManager; +import nautilus.game.arcade.game.games.moba.buff.buffs.BuffPumpkinKing; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +public class MobaMonochromeMap extends MobaMap +{ + + private static final long START_TIME = TimeUnit.MINUTES.toMillis(1); + private static final long ACTIVE_TIME = TimeUnit.SECONDS.toMillis(30); + private static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD); + + private final Set _skeletons; + private final Map _killedSkeletons; + + private boolean _active; + private long _lastStart; + + public MobaMonochromeMap(Moba host) + { + super(host); + + _skeletons = new HashSet<>(); + _killedSkeletons = new HashMap<>(); + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + _lastStart = System.currentTimeMillis(); + } + + @EventHandler + public void updateStart(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !_host.IsLive() || _active || !UtilTime.elapsed(_lastStart, START_TIME)) + { + return; + } + + _lastStart = System.currentTimeMillis(); + _active = true; + + UtilTextMiddle.display(C.cRedB + "Wither Skeletons", "Have Spawned!", 10, 40, 10); + _host.Announce(F.main("Game", F.elem("Wither Skeletons") + " have spawned! The team that kills the most within " + F.time("30 seconds") + " receives a buff!"), false); + + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, 0.4F); + } + + for (Location location : _host.WorldData.GetDataLocs("BLACK")) + { + Skeleton skeleton = UtilVariant.spawnWitherSkeleton(location); + skeleton.getEquipment().setItemInHand(IN_HAND); + + _skeletons.add(skeleton); + } + + for (GameTeam team : _host.GetTeamList()) + { + _killedSkeletons.put(team, 0); + } + } + + @EventHandler + public void updateEnd(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !_host.IsLive() || !_active || !UtilTime.elapsed(_lastStart, ACTIVE_TIME)) + { + return; + } + + GameTeam mostKillsTeam = null; + int mostKills = 0; + + for (Entry entry : _killedSkeletons.entrySet()) + { + GameTeam team = entry.getKey(); + int kills = entry.getValue(); + + if (mostKillsTeam == null || kills > mostKills) + { + mostKillsTeam = team; + mostKills = kills; + } + // Draw + else if (kills == mostKills && mostKills != 0) + { + + return; + } + } + + if (mostKillsTeam == null) + { + return; + } + + _host.Announce(F.main("Game", F.name(mostKillsTeam.GetFormattedName()) + " killed the most " + F.elem("Wither Skeletons")), false); + UtilTextMiddle.display("", mostKillsTeam.GetFormattedName() + C.cWhite + " killed the most " + F.elem("Wither Skeletons"), 10, 40, 10); + + // Give the team members the buff + BuffManager buffManager = _host.getBuffManager(); + for (Player teamMember : mostKillsTeam.GetPlayers(true)) + { + buffManager.apply(new BuffPumpkinKing(_host, teamMember, false)); + } + + _skeletons.forEach(Entity::remove); + _skeletons.clear(); + _killedSkeletons.clear(); + } + + @EventHandler + public void entityDeath(EntityDeathEvent event) + { + LivingEntity entity = event.getEntity(); + + if (_skeletons.remove(entity)) + { + Player player = entity.getKiller(); + + if (player == null) + { + return; + } + + GameTeam team = _host.GetTeam(player); + + if (team == null) + { + return; + } + + _killedSkeletons.put(team, _killedSkeletons.get(team) + 1); + player.sendMessage(F.main("Game", "+1")); + } + } + + @EventHandler + public void entityCombust(EntityCombustEvent event) + { + if (_skeletons.contains(event.getEntity())) + { + event.setCancelled(true); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java index f22986f4c..3270cc7de 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java @@ -49,12 +49,9 @@ public class OvertimeManager implements Listener UtilTextMiddle.display(C.cRedB + "OVERTIME", "Victory or Death, Withers are moving to the center!"); _host.Announce(F.main("Game", "Victory or Death, Withers are moving to the center!"), false); - for (MobaBoss boss : _host.getBossManager().getBosses()) + for (WitherBoss boss : _host.getBossManager().getWitherBosses()) { - if (boss instanceof WitherBoss) - { - ((WitherBoss) boss).setDamageable(true); - } + boss.setDamageable(true); } for (Player player : Bukkit.getOnlinePlayers()) From 8054296d0af54c4dd864a9c251fa9d8fae8366a4 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 22 Jul 2017 20:31:51 -0400 Subject: [PATCH 129/183] Fix incorrect local removal of sales announcements --- .../Mineplex.Core/src/mineplex/core/antihack/AntiHack.java | 4 ++-- .../clanshub/salesannouncements/SalesAnnouncementManager.java | 2 +- .../modules/salesannouncements/SalesAnnouncementManager.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 6a75bea99..4f6f2b982 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -239,7 +239,7 @@ public class AntiHack extends MiniPlugin { _punish.getClansPunish().loadClient(coreClient.getUniqueId(), client -> { - _punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, mineplex.core.common.util.UtilTime.TimeUnit.DAYS, mineplex.core.common.util.UtilTime.TimeUnit.MILLISECONDS), ChatColor.stripColor(finalMessage).replace("\n", ""), null, ban -> {}); + _punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, UtilTime.TimeUnit.DAYS, UtilTime.TimeUnit.MILLISECONDS), ChatColor.stripColor(finalMessage).replace("\n", ""), null, ban -> {}); }); } }; @@ -288,7 +288,7 @@ public class AntiHack extends MiniPlugin { _punish.getClansPunish().loadClient(coreClient.getUniqueId(), client -> { - _punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, mineplex.core.common.util.UtilTime.TimeUnit.DAYS, mineplex.core.common.util.UtilTime.TimeUnit.MILLISECONDS), ChatColor.stripColor(info.getMessage()).replace("\n", ""), null, ban -> {}); + _punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, UtilTime.TimeUnit.DAYS, UtilTime.TimeUnit.MILLISECONDS), ChatColor.stripColor(info.getMessage()).replace("\n", ""), null, ban -> {}); }); } }; diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java index fa6546121..bc76e23fa 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java @@ -66,7 +66,7 @@ public class SalesAnnouncementManager extends MiniPlugin { if (forceRemoveFromList) { - _data.remove(data); + _data.remove(data.getId()); } _repo.deleteAnnouncement(data, () -> { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java index a4e219fb6..266f340d9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java @@ -66,7 +66,7 @@ public class SalesAnnouncementManager extends MiniPlugin { if (forceRemoveFromList) { - _data.remove(data); + _data.remove(data.getId()); } _repo.deleteAnnouncement(data, () -> { From 06a90abc6a74343eda72c99c1699a90496e7435d Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 22 Jul 2017 22:21:12 -0400 Subject: [PATCH 130/183] Properly store clans tag for sales announcement deletion --- .../salesannouncements/SalesAnnouncementDeleteCommand.java | 1 + .../salesannouncements/SalesAnnouncementDeleteCommand.java | 1 + 2 files changed, 2 insertions(+) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteCommand.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteCommand.java index 705c41f59..115d5985c 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteCommand.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementDeleteCommand.java @@ -12,6 +12,7 @@ public class SalesAnnouncementDeleteCommand extends ServerCommand { _id = id; _from = from; + _clans = clans; } public Integer getId() diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteCommand.java index e7e1f0c7e..9623add3f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementDeleteCommand.java @@ -12,6 +12,7 @@ public class SalesAnnouncementDeleteCommand extends ServerCommand { _id = id; _from = from; + _clans = clans; } public Integer getId() From 99ca371204d4a9125bd57771fdf926fc11a21d23 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Sun, 23 Jul 2017 16:14:29 -0400 Subject: [PATCH 131/183] Treat magma cubes as slimes and slimes as creatures for disguises Fixes crashes in 1.12 --- .../disguise/disguises/DisguiseCreature.java | 6 +- .../disguise/disguises/DisguiseMagmaCube.java | 94 ++----------------- .../disguise/disguises/DisguiseSlime.java | 75 +++------------ 3 files changed, 25 insertions(+), 150 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java index 55e62c217..5e8eaaf8c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java @@ -25,9 +25,9 @@ public abstract class DisguiseCreature extends DisguiseInsentient PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); packet.a = getEntity().getId(); packet.b = (byte) getDisguiseType().getTypeId(); - packet.c = (int) MathHelper.floor(getEntity().locX*32D); - packet.d = (int) MathHelper.floor(getEntity().locY * 32.0D); - packet.e = (int) MathHelper.floor(getEntity().locZ*32D); + packet.c = MathHelper.floor(getEntity().locX * 32.0D); + packet.d = MathHelper.floor(getEntity().locY * 32.0D); + packet.e = MathHelper.floor(getEntity().locZ * 32.0D); packet.i = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); packet.j = (byte) ((int) (getEntity().pitch * 256.0F / 360.0F)); packet.k = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java index 904835bba..e06a56b17 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMagmaCube.java @@ -1,95 +1,15 @@ package mineplex.core.disguise.disguises; -import net.minecraft.server.v1_8_R3.EntitySlime; -import net.minecraft.server.v1_8_R3.MathHelper; -import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; -public class DisguiseMagmaCube extends DisguiseInsentient +/** + * Magma cubes are essentially identical to slimes for disguise purposes + */ +public class DisguiseMagmaCube extends DisguiseSlime { - public DisguiseMagmaCube(org.bukkit.entity.Entity entity) + public DisguiseMagmaCube(Entity entity) { super(EntityType.MAGMA_CUBE, entity); - - DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1); } - - public void SetSize(int i) - { - DataWatcher.watch(16, new Byte((byte) i), EntitySlime.META_SIZE, i); - } - - public int GetSize() - { - return DataWatcher.getByte(16); - } - - public Packet getSpawnPacket() - { - PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); - packet.a = getEntity().getId(); - packet.b = (byte) 62; - packet.c = (int) MathHelper.floor(getEntity().locX * 32D); - packet.d = (int) MathHelper.floor(getEntity().locY * 32.0D); - packet.e = (int) MathHelper.floor(getEntity().locZ * 32D); - packet.i = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); - packet.j = (byte) ((int) (getEntity().pitch * 256.0F / 360.0F)); - packet.k = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); - packet.uuid = getEntity().getUniqueID(); - - double var2 = 3.9D; - double var4 = 0; - double var6 = 0; - double var8 = 0; - - if (var4 < -var2) - { - var4 = -var2; - } - - if (var6 < -var2) - { - var6 = -var2; - } - - if (var8 < -var2) - { - var8 = -var2; - } - - if (var4 > var2) - { - var4 = var2; - } - - if (var6 > var2) - { - var6 = var2; - } - - if (var8 > var2) - { - var8 = var2; - } - - packet.f = (int) (var4 * 8000.0D); - packet.g = (int) (var6 * 8000.0D); - packet.h = (int) (var8 * 8000.0D); - - packet.l = DataWatcher; - packet.m = DataWatcher.b(); - - return packet; - } - - protected String getHurtSound() - { - return "mob.slime." + (GetSize() > 1 ? "big" : "small"); - } - - protected float getVolume() - { - return 0.4F * (float) GetSize(); - } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java index 96bb78cd9..6a0cb2a34 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSlime.java @@ -4,14 +4,26 @@ import net.minecraft.server.v1_8_R3.EntitySlime; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; + +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; -public class DisguiseSlime extends DisguiseInsentient +/** + * Slimes have an odd type hierarchy, but they're essentially creatures as far as disguises are concerned. + */ +public class DisguiseSlime extends DisguiseCreature { - public DisguiseSlime(org.bukkit.entity.Entity entity) + public DisguiseSlime(Entity entity) { - super(EntityType.SLIME, entity); + this(EntityType.SLIME, entity); + } + /** + * For magma cubes + */ + protected DisguiseSlime(EntityType type, Entity entity) + { + super(type, entity); DataWatcher.a(16, new Byte((byte) 1), EntitySlime.META_SIZE, 1); } @@ -25,63 +37,6 @@ public class DisguiseSlime extends DisguiseInsentient return DataWatcher.getByte(16); } - public Packet getSpawnPacket() - { - PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); - packet.a = getEntity().getId(); - packet.b = (byte) 55; - packet.c = (int) MathHelper.floor(getEntity().locX * 32D); - packet.d = (int) MathHelper.floor(getEntity().locY * 32.0D); - packet.e = (int) MathHelper.floor(getEntity().locZ * 32D); - packet.i = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); - packet.j = (byte) ((int) (getEntity().pitch * 256.0F / 360.0F)); - packet.k = (byte) ((int) (getEntity().yaw * 256.0F / 360.0F)); - packet.uuid = getEntity().getUniqueID(); - - double var2 = 3.9D; - double var4 = 0; - double var6 = 0; - double var8 = 0; - - if (var4 < -var2) - { - var4 = -var2; - } - - if (var6 < -var2) - { - var6 = -var2; - } - - if (var8 < -var2) - { - var8 = -var2; - } - - if (var4 > var2) - { - var4 = var2; - } - - if (var6 > var2) - { - var6 = var2; - } - - if (var8 > var2) - { - var8 = var2; - } - - packet.f = (int) (var4 * 8000.0D); - packet.g = (int) (var6 * 8000.0D); - packet.h = (int) (var8 * 8000.0D); - packet.l = DataWatcher; - packet.m = DataWatcher.b(); - - return packet; - } - protected String getHurtSound() { return "mob.slime." + (GetSize() > 1 ? "big" : "small"); From 49c50b027bb3dae9baf2aa6acf351b82a9fc9369 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Sun, 23 Jul 2017 16:26:46 -0400 Subject: [PATCH 132/183] Attempt to get version strings with /versions Makes it easier for those who don't know the protocol ;) --- .../core/monitor/VersionsCommand.java | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java index ef2bdab58..43454f57c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java @@ -1,5 +1,6 @@ package mineplex.core.monitor; +import java.lang.reflect.Field; import java.util.Comparator; import java.util.HashMap; import java.util.List; @@ -8,6 +9,8 @@ import java.util.stream.Collectors; import javax.print.attribute.IntegerSyntax; +import com.mineplex.ProtocolVersion; + import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -25,14 +28,37 @@ import mineplex.core.common.util.UtilServer; */ public class VersionsCommand extends CommandBase { + private static Map PRETTY_VERSIONS; + public VersionsCommand(LagMeter plugin) { super(plugin, Rank.DEVELOPER, "versions", "getver"); } + private void ensureVersions() + { + if (PRETTY_VERSIONS == null) + { + PRETTY_VERSIONS = new HashMap<>(); + for (Field field : ProtocolVersion.class.getFields()) + { + try + { + int protocol = field.getInt(null); + String version = field.getName().replace("v", "").replace("_", "."); + version += " (" + protocol + ")"; + + PRETTY_VERSIONS.put(protocol, version); + } catch (ReflectiveOperationException ex) { } + } + } + } + @Override public void Execute(Player caller, String[] args) { + ensureVersions(); + if (args.length == 0) { Map versions = new HashMap<>(); @@ -52,8 +78,11 @@ public class VersionsCommand extends CommandBase .collect(Collectors.toList()); for (Map.Entry entry : sorted) { + int protocol = entry.getKey(); + String pretty = PRETTY_VERSIONS.computeIfAbsent(protocol, x -> Integer.toString(protocol)); + UtilPlayer.message(caller, - F.main("Version", C.cYellow + entry.getKey() + C.cGray + ": " + C.cGreen + F.main("Version", C.cYellow + pretty + C.cGray + ": " + C.cGreen + entry.getValue() + C.cGray + " players")); } } else if (args.length == 1) @@ -62,9 +91,12 @@ public class VersionsCommand extends CommandBase if (!players.isEmpty()) { Player player = players.get(0); + int protocol = ((CraftPlayer) player).getHandle().getProtocol(); + String pretty = PRETTY_VERSIONS.computeIfAbsent(protocol, x -> Integer.toString(protocol)); + UtilPlayer.message(caller, - F.main("Version", C.cYellow + player.getName() + C.cGray + " is on protocol " - + C.cGreen + ((CraftPlayer) player).getHandle().getProtocol())); + F.main("Version", C.cYellow + player.getName() + C.cGray + " is on version " + + C.cGreen + pretty)); } } else { From 789658b2d9a16bef0b42c9a44ba58f8eb825a3a5 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 25 Jul 2017 17:57:25 +0100 Subject: [PATCH 133/183] Second MOBA map --- .../src/nautilus/game/arcade/game/Game.java | 8 +- .../game/arcade/game/games/moba/Moba.java | 25 +++-- .../game/games/moba/boss/BossManager.java | 1 + .../games/moba/boss/pumpkin/PumpkinBoss.java | 2 +- .../moba/buff/buffs/BuffPumpkinKing.java | 18 ++-- .../games/moba/modes/MobaHeroesValleyMap.java | 1 + .../game/games/moba/modes/MobaMapType.java | 2 + .../games/moba/modes/MobaMonochromeMap.java | 100 ++++++++++++------ 8 files changed, 101 insertions(+), 56 deletions(-) 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 7f980d389..46c6dd349 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 @@ -1215,13 +1215,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed UtilServer.getServer().getPluginManager().callEvent(event); // Re-Give Kit - Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - public void run() - { - GetKit(player).ApplyKit(player); - } - }, 0); + Manager.runSyncLater(() -> GetKit(player).ApplyKit(player), 0); } public void RespawnPlayerTeleport(Player player) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 48701441c..474f03a22 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -199,9 +199,6 @@ public class Moba extends TeamGame @Override public void ParseData() { - // Register all "Managers" - _listeners.forEach(UtilServer::RegisterEvents); - // Make all spawns face the center of the map for (List locations : WorldData.SpawnLocs.values()) { @@ -217,6 +214,7 @@ public class Moba extends TeamGame try { mapType = MobaMapType.valueOf(key); + break; } catch (IllegalArgumentException e) { @@ -269,6 +267,9 @@ public class Moba extends TeamGame _selector = new MapBoardSelector(_board); _selector.createHolograms(lobbyCustomLocs.get("HERO_VIEWER NEXT").get(0), lobbyCustomLocs.get("HERO_VIEWER BACK").get(0)); } + + // Register all "Managers" + _listeners.forEach(UtilServer::RegisterEvents); } @EventHandler(priority = EventPriority.LOWEST) @@ -289,10 +290,7 @@ public class Moba extends TeamGame MobaUtil.setTeamEntity(player, GetTeam(player)); } - // Cleanup tutorial boards - _mapManager.cleanupBoard(_board); - _selector.cleanup(); - _progression.removeRoleViewers(); + cleanupLobby(); } @EventHandler @@ -315,6 +313,17 @@ public class Moba extends TeamGame player.setGameMode(GameMode.ADVENTURE); } + private void cleanupLobby() + { + if (_mapManager != null) + { + _mapManager.cleanupBoard(_board); + _selector.cleanup(); + } + + _progression.removeRoleViewers(); + } + @Override public void disable() { @@ -322,6 +331,8 @@ public class Moba extends TeamGame _listeners.forEach(UtilServer::Unregister); _listeners.clear(); + cleanupLobby(); + Manager.runSyncLater(() -> { PlayerDisguiseManager playerDisguiseManager = Managers.require(PlayerDisguiseManager.class); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java index 7bddb9ed3..52f8c774e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -83,6 +83,7 @@ public class BossManager implements Listener public void registerBoss(MobaBoss boss) { _bosses.add(boss); + boss.setup(); } public String getWitherDisplayString(GameTeam team) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index c53a08e79..6cd5e0a22 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -231,7 +231,7 @@ public class PumpkinBoss extends MobaBoss BuffManager buffManager = _host.getBuffManager(); for (Player teamMember : team.GetPlayers(true)) { - buffManager.apply(new BuffPumpkinKing(_host, teamMember, true)); + buffManager.apply(new BuffPumpkinKing(_host, teamMember, HELMET)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java index bb334e128..ef68cd0c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java @@ -32,15 +32,14 @@ public class BuffPumpkinKing extends Buff private static final long DURATION = TimeUnit.MINUTES.toMillis(1); private static final String DAMAGE_REASON = "Boss Buff"; private static final double DAMAGE_FACTOR = 1.5; - private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN); - private boolean _giveHelmet; + private final ItemStack _helmet; - public BuffPumpkinKing(Moba host, Player entity, boolean giveHelmet) + public BuffPumpkinKing(Moba host, Player entity, ItemStack helmet) { super(host, entity, DURATION); - _giveHelmet = giveHelmet; + _helmet = helmet; } @Override @@ -49,27 +48,24 @@ public class BuffPumpkinKing extends Buff _entity.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60 * 20, 1)); UtilParticle.PlayParticleToAll(ParticleType.LAVA, _entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG); _entity.playSound(_entity.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F); - _entity.sendMessage(F.main("Game", "You feel a " + F.elem("Great Power") + "flow through you. Your " + F.elem("Damage") + " and " + F.elem("Regeneration") + " are increased!")); + _entity.sendMessage(F.main("Game", "You feel a " + F.elem("Great Power") + " flow through you. Your " + F.elem("Damage") + " and " + F.elem("Regeneration") + " are increased!")); } @Override public void onExpire() { - if (_giveHelmet) - { - sendFakeHelmet(_entity, _entity.getInventory().getHelmet()); - } + sendFakeHelmet(_entity, _entity.getInventory().getHelmet()); } @EventHandler public void updateFakeHelmet(UpdateEvent event) { - if (event.getType() != UpdateType.SLOW || !_giveHelmet) + if (event.getType() != UpdateType.SLOW) { return; } - sendFakeHelmet(_entity, HELMET); + sendFakeHelmet(_entity, _helmet); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaHeroesValleyMap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaHeroesValleyMap.java index ef539679a..1db64f3e8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaHeroesValleyMap.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaHeroesValleyMap.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.modes; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.boss.pumpkin.PumpkinBoss; +import org.bukkit.Bukkit; public class MobaHeroesValleyMap extends MobaMap { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMapType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMapType.java index b1ad4f9c3..cc5d177df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMapType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMapType.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.modes; import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import java.lang.reflect.InvocationTargetException; @@ -34,6 +35,7 @@ public enum MobaMapType } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) { + e.printStackTrace(); return null; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMonochromeMap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMonochromeMap.java index 498a6f4a8..bdd4c3d0d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMonochromeMap.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/modes/MobaMonochromeMap.java @@ -2,9 +2,12 @@ package nautilus.game.arcade.game.games.moba.modes; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; +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.UtilTextMiddle; import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilVariant; @@ -15,10 +18,10 @@ import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.buff.BuffManager; import nautilus.game.arcade.game.games.moba.buff.buffs.BuffPumpkinKing; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; @@ -27,19 +30,22 @@ import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; +import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.TimeUnit; public class MobaMonochromeMap extends MobaMap { - private static final long START_TIME = TimeUnit.MINUTES.toMillis(1); + private static final long START_TIME = TimeUnit.MINUTES.toMillis(5); private static final long ACTIVE_TIME = TimeUnit.SECONDS.toMillis(30); private static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD); + private static final ItemStack BUFF_HELMET = new ItemBuilder(Material.SKULL_ITEM, (byte) 1).build(); private final Set _skeletons; private final Map _killedSkeletons; @@ -85,14 +91,20 @@ public class MobaMonochromeMap extends MobaMap player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, 0.4F); } + _host.CreatureAllowOverride = true; + for (Location location : _host.WorldData.GetDataLocs("BLACK")) { Skeleton skeleton = UtilVariant.spawnWitherSkeleton(location); skeleton.getEquipment().setItemInHand(IN_HAND); + skeleton.setCustomName(C.Bold + "Wither Skeleton"); + skeleton.setCustomNameVisible(true); _skeletons.add(skeleton); } + _host.CreatureAllowOverride = false; + for (GameTeam team : _host.GetTeamList()) { _killedSkeletons.put(team, 0); @@ -107,45 +119,71 @@ public class MobaMonochromeMap extends MobaMap return; } - GameTeam mostKillsTeam = null; - int mostKills = 0; + GameTeam red = _host.GetTeam(ChatColor.RED); + int redKills = _killedSkeletons.get(red); + GameTeam blue = _host.GetTeam(ChatColor.AQUA); + int blueKills = _killedSkeletons.get(blue); + List winners; - for (Entry entry : _killedSkeletons.entrySet()) + // Draw + if (redKills == blueKills) { - GameTeam team = entry.getKey(); - int kills = entry.getValue(); - - if (mostKillsTeam == null || kills > mostKills) - { - mostKillsTeam = team; - mostKills = kills; - } - // Draw - else if (kills == mostKills && mostKills != 0) - { - - return; - } + winners = Arrays.asList(red, blue); + } + // Red win + else if (redKills > blueKills) + { + winners = Collections.singletonList(red); + } + // Blue win + else + { + winners = Collections.singletonList(blue); } - if (mostKillsTeam == null) + if (winners.size() == 1) { + GameTeam winner = winners.get(0); + + _host.Announce(F.main("Game", F.name(winner.GetFormattedName()) + " killed the most " + F.elem("Wither Skeletons") + ". They have been given the buff!"), false); + UtilTextMiddle.display("", winner.GetFormattedName() + C.cWhite + " killed the most " + F.elem("Wither Skeletons"), 10, 40, 10); + } + else + { + _host.Announce(F.main("Game", F.elem(C.Bold + "Draw") + "! No one was given the buff!"), false); + UtilTextMiddle.display("", C.cYellowB + "Draw" + C.cWhite + "! No one was given the buff!", 10, 40, 10); + cleanup(); return; } - _host.Announce(F.main("Game", F.name(mostKillsTeam.GetFormattedName()) + " killed the most " + F.elem("Wither Skeletons")), false); - UtilTextMiddle.display("", mostKillsTeam.GetFormattedName() + C.cWhite + " killed the most " + F.elem("Wither Skeletons"), 10, 40, 10); - // Give the team members the buff BuffManager buffManager = _host.getBuffManager(); - for (Player teamMember : mostKillsTeam.GetPlayers(true)) + winners.forEach(team -> { - buffManager.apply(new BuffPumpkinKing(_host, teamMember, false)); - } + for (Player teamMember : team.GetPlayers(true)) + { + buffManager.apply(new BuffPumpkinKing(_host, teamMember, BUFF_HELMET)); + } + }); - _skeletons.forEach(Entity::remove); + cleanup(); + } + + private void cleanup() + { + _skeletons.forEach(entity -> + { + if (!entity.isDead()) + { + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, entity.getLocation().add(0, 1.5, 0), 0.5F, 1, 0.5F, 0.001F, 15, ViewDist.LONG); + } + + entity.remove(); + }); _skeletons.clear(); _killedSkeletons.clear(); + + _active = false; } @EventHandler @@ -169,8 +207,10 @@ public class MobaMonochromeMap extends MobaMap return; } + event.getDrops().clear(); + event.setDroppedExp(0); _killedSkeletons.put(team, _killedSkeletons.get(team) + 1); - player.sendMessage(F.main("Game", "+1")); + player.sendMessage(F.main("Game", "You killed a " + F.name("Wither Skeleton") + "!")); } } From 4f221cabba35356e39ad33cdb6f9469fe90eb2a9 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 25 Jul 2017 19:22:11 +0100 Subject: [PATCH 134/183] Fix the NPE that caused MPS crashes --- .../src/nautilus/game/arcade/game/games/moba/Moba.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 474f03a22..62c399321 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -44,7 +44,6 @@ import nautilus.game.arcade.game.games.moba.kit.hp.HPManager; import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa; import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena; import nautilus.game.arcade.game.games.moba.minion.MinionManager; -import nautilus.game.arcade.game.games.moba.modes.MobaMap; import nautilus.game.arcade.game.games.moba.modes.MobaMapType; import nautilus.game.arcade.game.games.moba.overtime.OvertimeManager; import nautilus.game.arcade.game.games.moba.progression.MobaProgression; @@ -109,8 +108,6 @@ public class Moba extends TeamGame private PlayerMapBoard _board; private MapBoardSelector _selector; - private MobaMap _map; - private int _inPlayers; public Moba(ArcadeManager manager, GameType gameType, String[] description) @@ -226,7 +223,7 @@ public class Moba extends TeamGame mapType = MobaMapType.HEROES_VALLEY; } - _map = registerManager(mapType.createInstance(this)); + registerManager(mapType.createInstance(this)); if (Manager.IsRewardStats() && Manager.GetLobby() instanceof NewGameLobbyManager) { @@ -315,7 +312,7 @@ public class Moba extends TeamGame private void cleanupLobby() { - if (_mapManager != null) + if (_mapManager != null && _board != null) { _mapManager.cleanupBoard(_board); _selector.cleanup(); From ddf0666ba69cd6e70b3fa6faee56beffc76ffe16 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 25 Jul 2017 20:13:50 +0100 Subject: [PATCH 135/183] Fix level displays --- .../games/moba/progression/MobaLevelData.java | 48 ++++++++++ .../moba/progression/MobaProgression.java | 91 +++++++------------ .../moba/progression/ui/MobaRolePage.java | 11 +-- 3 files changed, 85 insertions(+), 65 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java new file mode 100644 index 000000000..175d11907 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java @@ -0,0 +1,48 @@ +package nautilus.game.arcade.game.games.moba.progression; + +public class MobaLevelData +{ + + private final int _exp; + private final int _level; + private final int _thisLevel; + private final int _nextLevel; + + public MobaLevelData(long exp) + { + _exp = (int) exp; + _level = MobaProgression.getLevel(exp); + _thisLevel = MobaProgression.getExpFor(_level); + _nextLevel = MobaProgression.getExpFor(_level + 1); + } + + public int getExp() + { + return _exp; + } + + public int getLevel() + { + return _level; + } + + public int getExpThisLevel() + { + return _thisLevel; + } + + public int getExpJustThisLevel() + { + return _nextLevel - _thisLevel; + } + + public int getExpReminder() + { + return _nextLevel - _exp; + } + + public double getPercentageComplete() + { + return (double) (_exp - _thisLevel) / (double) (getExpJustThisLevel()); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java index 9402ac11c..f0f0f6182 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java @@ -40,20 +40,18 @@ import java.util.concurrent.atomic.AtomicInteger; public class MobaProgression implements Listener { - private static final int[] EXP_LEVELS; - private static final int EXP_PER_LEVEL = 500; + private static final int EXP_PER_LEVEL = 1000; private static final int EXP_FACTOR = 3; public static final DecimalFormat FORMAT = new DecimalFormat("0.0"); - static + public static int getExpFor(int level) { - EXP_LEVELS = new int[100]; - int expRequired = EXP_PER_LEVEL; + return EXP_PER_LEVEL * (level - 1); + } - for (int level = 0; level < 100; level++) - { - EXP_LEVELS[level] = expRequired += EXP_PER_LEVEL; - } + public static int getLevel(long exp) + { + return (int) Math.floor(exp / EXP_PER_LEVEL); } private final Moba _host; @@ -84,7 +82,7 @@ public class MobaProgression implements Listener public void Execute(Player caller, String[] args) { MobaRole role = MobaRole.valueOf(args[0].toUpperCase()); - int exp = getExperience(Integer.parseInt(args[1])) - 1; + int exp = getExpFor(Integer.parseInt(args[1])) - 1; _host.getArcadeManager().GetStatsManager().setStat(caller, _host.GetName() + "." + role.getName() + ".ExpEarned", exp); caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp)) + ".")); } @@ -176,32 +174,12 @@ public class MobaProgression implements Listener _host.GetPlayers(true).forEach(this::rewardPlayer); } - public int getExperience(int level) - { - if (level > EXP_LEVELS.length) - { - return Integer.MAX_VALUE; - } - else if (level < 1) - { - return 0; - } - - return EXP_LEVELS[level - 1]; - } - public long getExperience(Player player, MobaRole role) { String stat = _host.GetName() + "." + role.getName() + ".ExpEarned"; return _host.getArcadeManager().GetStatsManager().Get(player).getStat(stat); } - public long getExperienceCurrentLevel(Player player, MobaRole role) - { - int level = getLevel(player, role); - return getExperience(level) - getExperience(level - 1); - } - public int getLevel(Player player, HeroKit kit) { return getLevel(player, kit.getRole()); @@ -212,28 +190,25 @@ public class MobaProgression implements Listener return getLevel(getExperience(player, role)); } - private int getLevel(long exp) - { - int i = 0; - - for (int expRequired : EXP_LEVELS) - { - i++; - if (expRequired > exp) - { - return i; - } - } - - return 1; - } - private void rewardPlayer(Player player) { MobaPlayer mobaPlayer = _host.getMobaData(player); + + if (mobaPlayer == null) + { + return; + } + MobaRole role = mobaPlayer.getRole(); String stat = _host.GetName() + "." + role.getName() + ".ExpEarned"; - long currentExp = _host.getArcadeManager().GetStatsManager().Get(player).getStat(stat); + // EXP before earning + long currentExp = getExperience(player, role); + // Level before earning + int currentLevel = getLevel(currentExp); + + player.sendMessage("currentExp = " + currentExp); + player.sendMessage("currentLevel = " + currentLevel); + AtomicInteger earnedExp = new AtomicInteger(); for (GemData data : _host.GetGems(player).values()) @@ -242,16 +217,16 @@ public class MobaProgression implements Listener } earnedExp.getAndAdd(earnedExp.get() * EXP_FACTOR); + MobaLevelData levelData = new MobaLevelData(currentExp + earnedExp.get()); - int level = getLevel(currentExp); - int newLevel = getLevel(currentExp + earnedExp.get()); - long expForThisLevel = getExperienceCurrentLevel(player, role); - AtomicBoolean levelUp = new AtomicBoolean(); + player.sendMessage("exp = " + levelData.getExp()); + player.sendMessage("level = " + levelData.getLevel()); + player.sendMessage("thisLevel = " + levelData.getExpThisLevel()); + player.sendMessage("justThisLevel = " + levelData.getExpJustThisLevel()); + player.sendMessage("reminder = " + levelData.getExpReminder()); + player.sendMessage("percentage = " + levelData.getPercentageComplete()); - if (newLevel > level) - { - levelUp.set(true); - } + AtomicBoolean levelUp = new AtomicBoolean(levelData.getLevel() > currentLevel); _host.getArcadeManager().GetStatsManager().incrementStat(player, stat, earnedExp.get()); @@ -262,8 +237,8 @@ public class MobaProgression implements Listener player.sendMessage(" " + role.getChatColor() + C.Bold + role.getName() + " Progression" + (levelUp.get() ? C.cGreenB + " LEVEL UP" : "")); player.sendMessage(""); - player.sendMessage(MobaUtil.getProgressBar(currentExp, currentExp + earnedExp.get(), expForThisLevel, 100) + " " + C.cGray + "+" + C.cGreen + earnedExp + C.cGray + "/" + C.cAqua + expForThisLevel); - player.sendMessage(C.cGreen + FORMAT.format((currentExp + earnedExp.get()) / (double) expForThisLevel * 100D) + C.cWhite + "% complete for Level " + level); + player.sendMessage(MobaUtil.getProgressBar(currentExp, levelData.getExp(), levelData.getExpThisLevel(), 100) + " " + C.cGray + "+" + C.cGreen + earnedExp + C.cGray + "/" + C.cAqua + levelData.getExpJustThisLevel()); + player.sendMessage(C.cGreen + FORMAT.format((levelData.getPercentageComplete() * 100D) + C.cWhite + "% complete for Level " + currentLevel)); player.sendMessage(""); player.sendMessage(ArcadeFormat.Line); @@ -272,7 +247,7 @@ public class MobaProgression implements Listener { for (HeroKit kit : _host.getKits()) { - if (!kit.getRole().equals(role) || kit.getUnlockLevel() != newLevel) + if (!kit.getRole().equals(role) || kit.getUnlockLevel() != levelData.getLevel()) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java index 04e19a0ad..4396a2c99 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java @@ -14,6 +14,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.progression.MobaLevelData; import nautilus.game.arcade.game.games.moba.progression.MobaProgression; import nautilus.game.arcade.game.games.moba.progression.MobaUnlockAnimation; import org.bukkit.Material; @@ -49,11 +50,7 @@ public class MobaRolePage extends ShopPageBase @Override protected void buildPage() { - int level = _host.getProgression().getLevel(_player, _role); - long currentExp = _host.getProgression().getExperience(_player, _role); - long thisLevel = _host.getProgression().getExperienceCurrentLevel(_player, _role); - long toNextLevel = _host.getProgression().getExperience(level) - currentExp; - long levelExp = _host.getProgression().getExperience(level); + MobaLevelData levelData = new MobaLevelData(_host.getProgression().getExperience(_player, _role)); addButtonNoAction(13, new ItemBuilder(_role.getSkin().getSkull()) .setTitle(_role.getChatColor() + _role.getName()) @@ -62,8 +59,8 @@ public class MobaRolePage extends ShopPageBase "Every " + F.elem(10) + " levels you unlock a new", "hero within the " + F.name(_role.getName()) + " category.", "", - "Your Level: " + C.cGreen + level, - "Next Level: " + C.cGreen + toNextLevel + C.cGray + "/" + C.cGreen + thisLevel + C.cGray + " (" + C.cAqua + MobaProgression.FORMAT.format(100 - ((double) currentExp / (double) levelExp) * 100D) + C.cGray + "%)" + "Your Level: " + C.cGreen + levelData.getLevel(), + "Next Level: " + C.cGreen + levelData.getExpReminder() + C.cGray + "/" + C.cGreen + levelData.getExpJustThisLevel() + C.cGray + " (" + C.cAqua + MobaProgression.FORMAT.format(levelData.getPercentageComplete() * 100D) + C.cGray + "%)" ) .build()); From f86664c510a5cefa0b6e32dfde60e5d72d443a94 Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 21 Jul 2017 05:10:51 -0400 Subject: [PATCH 136/183] Revert MOBA exp per level to 1000 --- .../arcade/game/games/moba/progression/MobaProgression.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java index 9402ac11c..98fb784aa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java @@ -41,7 +41,7 @@ public class MobaProgression implements Listener { private static final int[] EXP_LEVELS; - private static final int EXP_PER_LEVEL = 500; + private static final int EXP_PER_LEVEL = 1000; private static final int EXP_FACTOR = 3; public static final DecimalFormat FORMAT = new DecimalFormat("0.0"); From 1fb69edc134a88f7e5027c4d7c4c74fcff8f691d Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 26 Jul 2017 12:40:38 -0400 Subject: [PATCH 137/183] Add Timer ban action @ 15000 VL --- Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 4f6f2b982..e3a6df469 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -115,6 +115,7 @@ public class AntiHack extends MiniPlugin .put(Speed.class, new ImmediateBanAction(10000)) .put(HeadRoll.class, new ImmediateBanAction(2000)) .put(Toggle.class, new ImmediateBanAction(500)) + .put(Timer.class, new ImmediateBanAction(15000)) .put(BadPackets.class, new GEPBanAction(300)) .put(KillauraTypeB.class, new GEPBanAction(100)) .build(); From a70be6ffd8f955d1f1bfbb9ede2673c61647118a Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 26 Jul 2017 23:03:48 +0100 Subject: [PATCH 138/183] Fix level display for real this time --- .../game/arcade/game/games/moba/Moba.java | 3 +- .../arcade/game/games/moba/MobaClassic.java | 4 + .../games/moba/general/HotJoiningManager.java | 88 +++++++++++++++++++ .../games/moba/prepare/PrepareManager.java | 9 +- .../MobaExperienceCalculateEvent.java | 39 ++++++++ .../games/moba/progression/MobaLevelData.java | 12 ++- .../moba/progression/MobaProgression.java | 26 +++--- .../moba/progression/ui/MobaRolePage.java | 4 +- .../arcade/game/games/moba/util/MobaUtil.java | 2 +- 9 files changed, 162 insertions(+), 25 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaExperienceCalculateEvent.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 62c399321..d8052c50b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -29,6 +29,7 @@ import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.general.ArrowKBManager; import nautilus.game.arcade.game.games.moba.general.BetaManager; import nautilus.game.arcade.game.games.moba.general.EnderPearlManager; +import nautilus.game.arcade.game.games.moba.general.HotJoiningManager; import nautilus.game.arcade.game.games.moba.general.MobaDamageManager; import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.HeroKit; @@ -312,7 +313,7 @@ public class Moba extends TeamGame private void cleanupLobby() { - if (_mapManager != null && _board != null) + if (_board != null) { _mapManager.cleanupBoard(_board); _selector.cleanup(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java index e3a0817a5..1d0cf535b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java @@ -6,6 +6,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; +import nautilus.game.arcade.game.games.moba.general.HotJoiningManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; import nautilus.game.arcade.game.modules.CustomScoreboardModule; @@ -47,6 +48,9 @@ public class MobaClassic extends Moba registerManager(new PrepareManager(this)); registerManager(new PrepareSelection(this)); + // Hot joining + registerManager(new HotJoiningManager(this)); + // new GameStatisticsModule() // .register(this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java new file mode 100644 index 000000000..ad0c64270 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java @@ -0,0 +1,88 @@ +package nautilus.game.arcade.game.games.moba.general; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.progression.MobaExperienceCalculateEvent; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.kit.Kit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.ArrayList; +import java.util.List; + +public class HotJoiningManager implements Listener +{ + + private static final int HOT_JOIN_EXP_REWARD = 100; + + private final Moba _host; + private final List _hotJoined; + + public HotJoiningManager(Moba host) + { + _host = host; + _hotJoined = new ArrayList<>(); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void playerJoin(PlayerJoinEvent event) + { + if (!_host.IsLive()) + { + return; + } + + Player player = event.getPlayer(); + GameTeam team = _host.ChooseTeam(player); + + if (team == null || _host.getArcadeManager().isVanished(player)) + { + return; + } + + for (Tower tower : _host.getTowerManager().getTowers()) + { + // If the team's second tower is dead + if (tower.getOwner().equals(team) && !tower.isFirstTower() && tower.isDead()) + { + player.sendMessage(F.main("Game", "Sorry but you can only join a game in progress if they have at least " + F.elem(1) + " tower alive.")); + return; + } + } + + team.AddPlayer(player, true); + team.SpawnTeleport(player); + _hotJoined.add(player); + + _host.getArcadeManager().runSyncLater(() -> + { + Kit kit = _host.getFirstKit(player); + + player.sendMessage(F.main("Game", "Thanks for choosing to join a game in progress! If you stay until the end of the game ")); + _host.SetKit(player, kit, true); + }, 1); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + _hotJoined.remove(player); + } + + @EventHandler + public void expCalculate(MobaExperienceCalculateEvent event) + { + if (_hotJoined.contains(event.getPlayer())) + { + event.getExpEarned().getAndAdd(HOT_JOIN_EXP_REWARD); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java index eacc7cdd0..d968f8239 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java @@ -1,7 +1,11 @@ package nautilus.game.arcade.game.games.moba.prepare; import mineplex.core.common.entity.ClientArmorStand; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GamePrepareCountdownCommence; @@ -80,9 +84,6 @@ public class PrepareManager implements Listener } HeroKit heroKit = _host.getFirstKit(player); - MobaPlayer mobaPlayer = _host.getMobaData(player); - - mobaPlayer.setRole(heroKit.getRole()); _host.SetKit(player, heroKit, true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaExperienceCalculateEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaExperienceCalculateEvent.java new file mode 100644 index 000000000..f39ff1b84 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaExperienceCalculateEvent.java @@ -0,0 +1,39 @@ +package nautilus.game.arcade.game.games.moba.progression; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +import java.util.concurrent.atomic.AtomicInteger; + +public class MobaExperienceCalculateEvent extends PlayerEvent +{ + + private static final HandlerList _handlers = new HandlerList(); + + private AtomicInteger _expEarned; + + public MobaExperienceCalculateEvent(Player player, AtomicInteger expEarned) + { + super(player); + + _expEarned = expEarned; + } + + public AtomicInteger getExpEarned() + { + return _expEarned; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java index 175d11907..e63b280c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java @@ -26,6 +26,11 @@ public class MobaLevelData return _level; } + public int getDisplayLevel() + { + return _level + 1; + } + public int getExpThisLevel() { return _thisLevel; @@ -36,6 +41,11 @@ public class MobaLevelData return _nextLevel - _thisLevel; } + public int getExpLevelProgress() + { + return _exp - _thisLevel; + } + public int getExpReminder() { return _nextLevel - _exp; @@ -43,6 +53,6 @@ public class MobaLevelData public double getPercentageComplete() { - return (double) (_exp - _thisLevel) / (double) (getExpJustThisLevel()); + return (double) (getExpLevelProgress()) / (double) (getExpJustThisLevel()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java index f0f0f6182..6ccdc62af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java @@ -46,7 +46,7 @@ public class MobaProgression implements Listener public static int getExpFor(int level) { - return EXP_PER_LEVEL * (level - 1); + return EXP_PER_LEVEL * level; } public static int getLevel(long exp) @@ -82,9 +82,9 @@ public class MobaProgression implements Listener public void Execute(Player caller, String[] args) { MobaRole role = MobaRole.valueOf(args[0].toUpperCase()); - int exp = getExpFor(Integer.parseInt(args[1])) - 1; + int exp = getExpFor(Integer.parseInt(args[1]) - 1); _host.getArcadeManager().GetStatsManager().setStat(caller, _host.GetName() + "." + role.getName() + ".ExpEarned", exp); - caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp)) + ".")); + caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp) + 1) + ".")); } }); } @@ -206,9 +206,6 @@ public class MobaProgression implements Listener // Level before earning int currentLevel = getLevel(currentExp); - player.sendMessage("currentExp = " + currentExp); - player.sendMessage("currentLevel = " + currentLevel); - AtomicInteger earnedExp = new AtomicInteger(); for (GemData data : _host.GetGems(player).values()) @@ -217,14 +214,11 @@ public class MobaProgression implements Listener } earnedExp.getAndAdd(earnedExp.get() * EXP_FACTOR); - MobaLevelData levelData = new MobaLevelData(currentExp + earnedExp.get()); - player.sendMessage("exp = " + levelData.getExp()); - player.sendMessage("level = " + levelData.getLevel()); - player.sendMessage("thisLevel = " + levelData.getExpThisLevel()); - player.sendMessage("justThisLevel = " + levelData.getExpJustThisLevel()); - player.sendMessage("reminder = " + levelData.getExpReminder()); - player.sendMessage("percentage = " + levelData.getPercentageComplete()); + MobaExperienceCalculateEvent event = new MobaExperienceCalculateEvent(player, earnedExp); + UtilServer.CallEvent(event); + + MobaLevelData levelData = new MobaLevelData(currentExp + earnedExp.get()); AtomicBoolean levelUp = new AtomicBoolean(levelData.getLevel() > currentLevel); @@ -237,8 +231,8 @@ public class MobaProgression implements Listener player.sendMessage(" " + role.getChatColor() + C.Bold + role.getName() + " Progression" + (levelUp.get() ? C.cGreenB + " LEVEL UP" : "")); player.sendMessage(""); - player.sendMessage(MobaUtil.getProgressBar(currentExp, levelData.getExp(), levelData.getExpThisLevel(), 100) + " " + C.cGray + "+" + C.cGreen + earnedExp + C.cGray + "/" + C.cAqua + levelData.getExpJustThisLevel()); - player.sendMessage(C.cGreen + FORMAT.format((levelData.getPercentageComplete() * 100D) + C.cWhite + "% complete for Level " + currentLevel)); + player.sendMessage(MobaUtil.getProgressBar(levelData.getExpLevelProgress() - earnedExp.get(), levelData.getExpLevelProgress(), levelData.getExpJustThisLevel(), 100) + " " + C.cGray + "+" + C.cGreen + earnedExp + C.cGray + "/" + C.cAqua + levelData.getExpJustThisLevel()); + player.sendMessage(C.cGreen + FORMAT.format((levelData.getPercentageComplete() * 100D)) + C.cWhite + "% complete for Level " + levelData.getDisplayLevel()); player.sendMessage(""); player.sendMessage(ArcadeFormat.Line); @@ -247,7 +241,7 @@ public class MobaProgression implements Listener { for (HeroKit kit : _host.getKits()) { - if (!kit.getRole().equals(role) || kit.getUnlockLevel() != levelData.getLevel()) + if (!kit.getRole().equals(role) || kit.getUnlockLevel() != levelData.getDisplayLevel()) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java index 4396a2c99..de2fb9774 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java @@ -59,8 +59,8 @@ public class MobaRolePage extends ShopPageBase "Every " + F.elem(10) + " levels you unlock a new", "hero within the " + F.name(_role.getName()) + " category.", "", - "Your Level: " + C.cGreen + levelData.getLevel(), - "Next Level: " + C.cGreen + levelData.getExpReminder() + C.cGray + "/" + C.cGreen + levelData.getExpJustThisLevel() + C.cGray + " (" + C.cAqua + MobaProgression.FORMAT.format(levelData.getPercentageComplete() * 100D) + C.cGray + "%)" + "Your Level: " + C.cGreen + levelData.getDisplayLevel(), + "Next Level: " + C.cGreen + levelData.getExpLevelProgress() + C.cGray + "/" + C.cGreen + levelData.getExpJustThisLevel() + C.cGray + " (" + C.cAqua + MobaProgression.FORMAT.format(levelData.getPercentageComplete() * 100D) + C.cGray + "%)" ) .build()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 8483e03b7..0a56168fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -184,7 +184,7 @@ public class MobaUtil } else { - out.append(C.cGrayB).append("|"); + out.append(C.cGray).append("|"); } } From d951089239734bdf8c739cc8f0c8b8e5b79ce78f Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 22 Jul 2017 15:05:53 +0100 Subject: [PATCH 139/183] Fix the Egg Blaster, Explode disguise bug --- .../games/smash/perks/chicken/PerkEggGun.java | 53 ++++++++----------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkEggGun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkEggGun.java index 6162c7276..4d9cf7bd3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkEggGun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/chicken/PerkEggGun.java @@ -1,26 +1,12 @@ package nautilus.game.arcade.game.games.smash.perks.chicken; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.bukkit.Sound; -import org.bukkit.entity.Egg; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -29,6 +15,16 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.smash.perks.SmashPerk; +import org.bukkit.Sound; +import org.bukkit.entity.Egg; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; public class PerkEggGun extends SmashPerk { @@ -148,28 +144,21 @@ public class PerkEggGun extends SmashPerk @EventHandler public void EggHit(CustomDamageEvent event) { - if (event.GetProjectile() == null) + if (event.GetProjectile() == null || !(event.GetProjectile() instanceof Egg)) { return; } - - if (!(event.GetProjectile() instanceof Egg)) - { - return; - } - - if (event.GetDamage() >= _damage) - { - return; - } - - event.SetCancelled("Egg Blaster"); - Egg egg = (Egg) event.GetProjectile(); + Player damager = event.GetDamagerPlayer(true); - // Damage Event - Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), (LivingEntity) egg.getShooter(), egg, DamageCause.PROJECTILE, _damage, true, true, false, UtilEnt.getName((LivingEntity) egg - .getShooter()), GetName()); + if (damager == null || !hasPerk(damager)) + { + return; + } + + event.AddMod("Negate", -event.GetDamage()); + event.AddMod(damager.getName(), "Egg Blaster", _damage, true); + event.SetIgnoreRate(true); UtilAction.zeroVelocity(event.GetDamageeEntity()); } From 86c733259f27267f55313c79dac0f048e022edd5 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 25 Jul 2017 13:05:20 +0100 Subject: [PATCH 140/183] Allow double jumping when having hub velocity disabled --- .../src/mineplex/hub/HubManager.java | 4 +- .../src/mineplex/hub/modules/JumpManager.java | 38 ++++++++++--------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index eb7242bde..05a1c7222 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -915,7 +915,9 @@ public class HubManager extends MiniClientPlugin implements IChatMess @EventHandler public void ignoreVelocity(PlayerVelocityEvent event) { - if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY)) + Player player = event.getPlayer(); + + if (_clientManager.Get(player).GetRank().has(Rank.TWITCH) && _preferences.get(player).isActive(Preference.IGNORE_VELOCITY) && !getJumpManager().isDoubleJumping(player)) { event.setCancelled(true); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java index 9e6730cb8..b5bef12d6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java @@ -1,16 +1,5 @@ package mineplex.hub.modules; -import java.util.HashSet; - -import org.bukkit.Effect; -import org.bukkit.GameMode; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerToggleFlightEvent; -import org.bukkit.util.Vector; - import mineplex.core.MiniPlugin; import mineplex.core.common.Rank; import mineplex.core.common.util.UtilAction; @@ -27,9 +16,20 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleFlightEvent; +import org.bukkit.util.Vector; + +import java.util.HashSet; public class JumpManager extends MiniPlugin { + public HubManager Manager; private HashSet _preparedDoubleJump = new HashSet<>(); @@ -45,11 +45,10 @@ public class JumpManager extends MiniPlugin { Player player = event.getPlayer(); - if (player.getGameMode() == GameMode.CREATIVE) - return; - - if (player.isFlying()) + if (player.getGameMode() == GameMode.CREATIVE || player.isFlying()) + { return; + } Rank rank = Manager.GetClients().Get(player).GetRank(); if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) @@ -75,11 +74,11 @@ public class JumpManager extends MiniPlugin //Velocity _preparedDoubleJump.add(player.getName()); UtilAction.velocity(player, vec, 1.4, false, 0, 0.2, 1, true); - + //Sound player.playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0); - Recharge.Instance.useForce(player, "Double Jump", 500); + Recharge.Instance.useForce(player, "Double Jump", 250); } @EventHandler @@ -129,4 +128,9 @@ public class JumpManager extends MiniPlugin { return _preparedDoubleJump.contains(player.getName()); } + + public boolean isDoubleJumping(Player player) + { + return !Recharge.Instance.usable(player, "Double Jump"); + } } From 099d2cb1322fb7d89fbd069492a2f46eb2a6088c Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 25 Jul 2017 13:06:05 +0100 Subject: [PATCH 141/183] Cleanup HubVisibilityManager while slowing down the rate at which players are shown other players --- .../mineplex/core/common/util/UtilServer.java | 10 +- .../hub/modules/HubVisibilityManager.java | 166 +++++++++++------- 2 files changed, 101 insertions(+), 75 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java index 63b55feab..5fa174eea 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java @@ -9,6 +9,7 @@ import mineplex.serverdata.Region; import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.Sound; +import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -43,14 +44,7 @@ public class UtilServer public static List getSortedPlayers() { - return getSortedPlayers(new Comparator() - { - @Override - public int compare(Player o1, Player o2) - { - return o1.getName().compareTo(o2.getName()); - } - }); + return getSortedPlayers(Comparator.comparing(HumanEntity::getName)); } public static List getSortedPlayers(Comparator comparator) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java index e93b00540..e9158f679 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java @@ -2,34 +2,37 @@ package mineplex.hub.modules; import mineplex.core.MiniPlugin; import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilEnt; 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.UtilServer; import mineplex.core.preferences.Preference; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.visibility.VisibilityManager; import mineplex.hub.HubManager; -import org.bukkit.Material; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; public class HubVisibilityManager extends MiniPlugin { + + private static final String JUST_SPAWNED_FLAG = "JustSpawned"; + private static final int HIDE_SPAWN_RADIUS_SQUARED = 4; + public HubManager Manager; - private HashMap _particle = new HashMap(); - private HashSet _hiddenPlayers = new HashSet(); + private final Set _hiddenPlayers = new HashSet<>(); + private final Map _nextShownPlayer = new HashMap<>(); public HubVisibilityManager(HubManager manager) { @@ -48,87 +51,116 @@ public class HubVisibilityManager extends MiniPlugin } @EventHandler - public void removeHiddenPlayerOnQuit(PlayerQuitEvent event) + public void playerQuit(PlayerQuitEvent event) { - _hiddenPlayers.remove(event.getPlayer()); + Player player = event.getPlayer(); + + _hiddenPlayers.remove(player); + _nextShownPlayer.remove(player); } @EventHandler - public void updateVisibility(UpdateEvent event) + public void playerJoin(PlayerJoinEvent event) + { + UtilEnt.addFlag(event.getPlayer(), JUST_SPAWNED_FLAG); + } + + @EventHandler + public void updateVisibility0(UpdateEvent event) { if (event.getType() != UpdateType.SEC) - return; - - for (Player player : UtilServer.getPlayers()) { - Rank rank = Manager.GetClients().Get(player).GetRank(); - boolean hideMe = UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 - || (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && - (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) - || _hiddenPlayers.contains(player); + return; + } - for (Player other : UtilServer.getPlayers()) + Collection online = UtilServer.getPlayersCollection(); + + for (Player subject : online) + { + boolean hideMe = shouldHide(subject); + + for (Player perspective : online) { - boolean localHideMe = hideMe; - if (player.equals(other)) + boolean closeToSpawn = closeToSpawn(perspective); + boolean justSpawned = UtilEnt.hasFlag(perspective, JUST_SPAWNED_FLAG); + + // Don't hide themselves OR they are currently being sent player data one by one + if (perspective.equals(subject) || _nextShownPlayer.containsKey(perspective)) + { continue; - - if (Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR)) - localHideMe = UtilMath.offset2d(other.getLocation(), Manager.GetSpawn()) == 0; - - if (localHideMe || !Manager.getPreferences().get(other).isActive(Preference.SHOW_PLAYERS)) - { - VisibilityManager.Instance.setVisibility(player, false, other); - } else - { - VisibilityManager.Instance.setVisibility(player, true, other); } + + // Player has just spawned flag however they are no longer near the spawn + if (justSpawned && !closeToSpawn) + { + UtilEnt.removeFlag(perspective, JUST_SPAWNED_FLAG); + _nextShownPlayer.put(perspective, 0); + } + + // Has preference AND is not close to the spawn AND has not just spawned + boolean showOthers = Manager.getPreferences().get(perspective).isActive(Preference.SHOW_PLAYERS) && (!closeToSpawn || !justSpawned); + + VisibilityManager.Instance.setVisibility(subject, !hideMe && showOthers, perspective); } } } @EventHandler - public void ParticleSwap(PlayerInteractEvent event) + public void updateVisibility1(UpdateEvent event) { - Player player = event.getPlayer(); - - if (!player.isOp()) - return; - - if (!UtilGear.isMat(player.getItemInHand(), Material.GOLD_NUGGET)) - return; - - int past = 0; - if (_particle.containsKey(player)) - past = _particle.get(player); - - if (UtilEvent.isAction(event, ActionType.R)) + if (event.getType() != UpdateType.FASTEST) { - past = (past+1)%ParticleType.values().length; - } - else if (UtilEvent.isAction(event, ActionType.L)) - { - past = past - 1; - if (past < 0) - past = ParticleType.values().length - 1; + return; } - _particle.put(player, past); + Player[] online = UtilServer.getPlayers(); + Iterator iterator = _nextShownPlayer.keySet().iterator(); - player.sendMessage("Particle: " + ParticleType.values()[past]); + while (iterator.hasNext()) + { + Player perspective = iterator.next(); + int index = _nextShownPlayer.get(perspective); + + if (perspective == null || !perspective.isOnline() || online.length <= index) + { + Bukkit.broadcastMessage("Done"); + iterator.remove(); + continue; + } + + Player subject = online[index]; + + if (!perspective.equals(subject) && !shouldHide(subject)) + { + Bukkit.broadcastMessage("Making visible " + subject.getName() + " for " + perspective.getName()); + VisibilityManager.Instance.setVisibility(subject, true, perspective); + } + else + { + Bukkit.broadcastMessage("Ignoring " + subject.getName() + " for " + perspective.getName()); + } + + _nextShownPlayer.put(perspective, ++index); + } } - @EventHandler - public void Particles(UpdateEvent event) + private boolean shouldHide(Player subject) { - if (event.getType() != UpdateType.FAST) - return; + Rank subjectRank = Manager.GetClients().Get(subject).GetRank(); - for (Player player : _particle.keySet()) - { - UtilParticle.PlayParticle(ParticleType.values()[_particle.get(player)], - player.getLocation().add(1, 1, 0), 0f, 0f, 0f, 0, 1, - ViewDist.NORMAL, UtilServer.getPlayers()); - } + return + // Close to spawn + closeToSpawn(subject) || + // Enabled Invisibility + Manager.getPreferences().get(subject).isActive(Preference.INVISIBILITY) && + // AND Is Moderator+ OR Youtube OR Twitch + (subjectRank.has(Rank.MODERATOR) || subjectRank == Rank.YOUTUBE || subjectRank == Rank.TWITCH) || + // OR Player has been explicitly hidden + _hiddenPlayers.contains(subject); + } + + private boolean closeToSpawn(Player player) + { + return UtilMath.offset2dSquared(player.getLocation(), Manager.GetSpawn()) < HIDE_SPAWN_RADIUS_SQUARED; } } From cd3a90da08d914d8c8634d5d4b90e68c8a043d9a Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 26 Jul 2017 23:03:48 +0100 Subject: [PATCH 142/183] Fix level display for real this time --- .../game/arcade/game/games/moba/Moba.java | 3 +- .../arcade/game/games/moba/MobaClassic.java | 4 + .../games/moba/general/HotJoiningManager.java | 88 +++++++++++++++++++ .../games/moba/prepare/PrepareManager.java | 9 +- .../MobaExperienceCalculateEvent.java | 39 ++++++++ .../games/moba/progression/MobaLevelData.java | 12 ++- .../moba/progression/MobaProgression.java | 26 +++--- .../moba/progression/ui/MobaRolePage.java | 4 +- .../arcade/game/games/moba/util/MobaUtil.java | 2 +- 9 files changed, 162 insertions(+), 25 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaExperienceCalculateEvent.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 62c399321..d8052c50b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -29,6 +29,7 @@ import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.general.ArrowKBManager; import nautilus.game.arcade.game.games.moba.general.BetaManager; import nautilus.game.arcade.game.games.moba.general.EnderPearlManager; +import nautilus.game.arcade.game.games.moba.general.HotJoiningManager; import nautilus.game.arcade.game.games.moba.general.MobaDamageManager; import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.HeroKit; @@ -312,7 +313,7 @@ public class Moba extends TeamGame private void cleanupLobby() { - if (_mapManager != null && _board != null) + if (_board != null) { _mapManager.cleanupBoard(_board); _selector.cleanup(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java index e3a0817a5..1d0cf535b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java @@ -6,6 +6,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; +import nautilus.game.arcade.game.games.moba.general.HotJoiningManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; import nautilus.game.arcade.game.modules.CustomScoreboardModule; @@ -47,6 +48,9 @@ public class MobaClassic extends Moba registerManager(new PrepareManager(this)); registerManager(new PrepareSelection(this)); + // Hot joining + registerManager(new HotJoiningManager(this)); + // new GameStatisticsModule() // .register(this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java new file mode 100644 index 000000000..ad0c64270 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java @@ -0,0 +1,88 @@ +package nautilus.game.arcade.game.games.moba.general; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.progression.MobaExperienceCalculateEvent; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.kit.Kit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.ArrayList; +import java.util.List; + +public class HotJoiningManager implements Listener +{ + + private static final int HOT_JOIN_EXP_REWARD = 100; + + private final Moba _host; + private final List _hotJoined; + + public HotJoiningManager(Moba host) + { + _host = host; + _hotJoined = new ArrayList<>(); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void playerJoin(PlayerJoinEvent event) + { + if (!_host.IsLive()) + { + return; + } + + Player player = event.getPlayer(); + GameTeam team = _host.ChooseTeam(player); + + if (team == null || _host.getArcadeManager().isVanished(player)) + { + return; + } + + for (Tower tower : _host.getTowerManager().getTowers()) + { + // If the team's second tower is dead + if (tower.getOwner().equals(team) && !tower.isFirstTower() && tower.isDead()) + { + player.sendMessage(F.main("Game", "Sorry but you can only join a game in progress if they have at least " + F.elem(1) + " tower alive.")); + return; + } + } + + team.AddPlayer(player, true); + team.SpawnTeleport(player); + _hotJoined.add(player); + + _host.getArcadeManager().runSyncLater(() -> + { + Kit kit = _host.getFirstKit(player); + + player.sendMessage(F.main("Game", "Thanks for choosing to join a game in progress! If you stay until the end of the game ")); + _host.SetKit(player, kit, true); + }, 1); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + _hotJoined.remove(player); + } + + @EventHandler + public void expCalculate(MobaExperienceCalculateEvent event) + { + if (_hotJoined.contains(event.getPlayer())) + { + event.getExpEarned().getAndAdd(HOT_JOIN_EXP_REWARD); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java index eacc7cdd0..d968f8239 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java @@ -1,7 +1,11 @@ package nautilus.game.arcade.game.games.moba.prepare; import mineplex.core.common.entity.ClientArmorStand; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GamePrepareCountdownCommence; @@ -80,9 +84,6 @@ public class PrepareManager implements Listener } HeroKit heroKit = _host.getFirstKit(player); - MobaPlayer mobaPlayer = _host.getMobaData(player); - - mobaPlayer.setRole(heroKit.getRole()); _host.SetKit(player, heroKit, true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaExperienceCalculateEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaExperienceCalculateEvent.java new file mode 100644 index 000000000..f39ff1b84 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaExperienceCalculateEvent.java @@ -0,0 +1,39 @@ +package nautilus.game.arcade.game.games.moba.progression; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +import java.util.concurrent.atomic.AtomicInteger; + +public class MobaExperienceCalculateEvent extends PlayerEvent +{ + + private static final HandlerList _handlers = new HandlerList(); + + private AtomicInteger _expEarned; + + public MobaExperienceCalculateEvent(Player player, AtomicInteger expEarned) + { + super(player); + + _expEarned = expEarned; + } + + public AtomicInteger getExpEarned() + { + return _expEarned; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java index 175d11907..e63b280c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaLevelData.java @@ -26,6 +26,11 @@ public class MobaLevelData return _level; } + public int getDisplayLevel() + { + return _level + 1; + } + public int getExpThisLevel() { return _thisLevel; @@ -36,6 +41,11 @@ public class MobaLevelData return _nextLevel - _thisLevel; } + public int getExpLevelProgress() + { + return _exp - _thisLevel; + } + public int getExpReminder() { return _nextLevel - _exp; @@ -43,6 +53,6 @@ public class MobaLevelData public double getPercentageComplete() { - return (double) (_exp - _thisLevel) / (double) (getExpJustThisLevel()); + return (double) (getExpLevelProgress()) / (double) (getExpJustThisLevel()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java index f0f0f6182..6ccdc62af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java @@ -46,7 +46,7 @@ public class MobaProgression implements Listener public static int getExpFor(int level) { - return EXP_PER_LEVEL * (level - 1); + return EXP_PER_LEVEL * level; } public static int getLevel(long exp) @@ -82,9 +82,9 @@ public class MobaProgression implements Listener public void Execute(Player caller, String[] args) { MobaRole role = MobaRole.valueOf(args[0].toUpperCase()); - int exp = getExpFor(Integer.parseInt(args[1])) - 1; + int exp = getExpFor(Integer.parseInt(args[1]) - 1); _host.getArcadeManager().GetStatsManager().setStat(caller, _host.GetName() + "." + role.getName() + ".ExpEarned", exp); - caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp)) + ".")); + caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp) + 1) + ".")); } }); } @@ -206,9 +206,6 @@ public class MobaProgression implements Listener // Level before earning int currentLevel = getLevel(currentExp); - player.sendMessage("currentExp = " + currentExp); - player.sendMessage("currentLevel = " + currentLevel); - AtomicInteger earnedExp = new AtomicInteger(); for (GemData data : _host.GetGems(player).values()) @@ -217,14 +214,11 @@ public class MobaProgression implements Listener } earnedExp.getAndAdd(earnedExp.get() * EXP_FACTOR); - MobaLevelData levelData = new MobaLevelData(currentExp + earnedExp.get()); - player.sendMessage("exp = " + levelData.getExp()); - player.sendMessage("level = " + levelData.getLevel()); - player.sendMessage("thisLevel = " + levelData.getExpThisLevel()); - player.sendMessage("justThisLevel = " + levelData.getExpJustThisLevel()); - player.sendMessage("reminder = " + levelData.getExpReminder()); - player.sendMessage("percentage = " + levelData.getPercentageComplete()); + MobaExperienceCalculateEvent event = new MobaExperienceCalculateEvent(player, earnedExp); + UtilServer.CallEvent(event); + + MobaLevelData levelData = new MobaLevelData(currentExp + earnedExp.get()); AtomicBoolean levelUp = new AtomicBoolean(levelData.getLevel() > currentLevel); @@ -237,8 +231,8 @@ public class MobaProgression implements Listener player.sendMessage(" " + role.getChatColor() + C.Bold + role.getName() + " Progression" + (levelUp.get() ? C.cGreenB + " LEVEL UP" : "")); player.sendMessage(""); - player.sendMessage(MobaUtil.getProgressBar(currentExp, levelData.getExp(), levelData.getExpThisLevel(), 100) + " " + C.cGray + "+" + C.cGreen + earnedExp + C.cGray + "/" + C.cAqua + levelData.getExpJustThisLevel()); - player.sendMessage(C.cGreen + FORMAT.format((levelData.getPercentageComplete() * 100D) + C.cWhite + "% complete for Level " + currentLevel)); + player.sendMessage(MobaUtil.getProgressBar(levelData.getExpLevelProgress() - earnedExp.get(), levelData.getExpLevelProgress(), levelData.getExpJustThisLevel(), 100) + " " + C.cGray + "+" + C.cGreen + earnedExp + C.cGray + "/" + C.cAqua + levelData.getExpJustThisLevel()); + player.sendMessage(C.cGreen + FORMAT.format((levelData.getPercentageComplete() * 100D)) + C.cWhite + "% complete for Level " + levelData.getDisplayLevel()); player.sendMessage(""); player.sendMessage(ArcadeFormat.Line); @@ -247,7 +241,7 @@ public class MobaProgression implements Listener { for (HeroKit kit : _host.getKits()) { - if (!kit.getRole().equals(role) || kit.getUnlockLevel() != levelData.getLevel()) + if (!kit.getRole().equals(role) || kit.getUnlockLevel() != levelData.getDisplayLevel()) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java index 4396a2c99..de2fb9774 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/ui/MobaRolePage.java @@ -59,8 +59,8 @@ public class MobaRolePage extends ShopPageBase "Every " + F.elem(10) + " levels you unlock a new", "hero within the " + F.name(_role.getName()) + " category.", "", - "Your Level: " + C.cGreen + levelData.getLevel(), - "Next Level: " + C.cGreen + levelData.getExpReminder() + C.cGray + "/" + C.cGreen + levelData.getExpJustThisLevel() + C.cGray + " (" + C.cAqua + MobaProgression.FORMAT.format(levelData.getPercentageComplete() * 100D) + C.cGray + "%)" + "Your Level: " + C.cGreen + levelData.getDisplayLevel(), + "Next Level: " + C.cGreen + levelData.getExpLevelProgress() + C.cGray + "/" + C.cGreen + levelData.getExpJustThisLevel() + C.cGray + " (" + C.cAqua + MobaProgression.FORMAT.format(levelData.getPercentageComplete() * 100D) + C.cGray + "%)" ) .build()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 8483e03b7..0a56168fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -184,7 +184,7 @@ public class MobaUtil } else { - out.append(C.cGrayB).append("|"); + out.append(C.cGray).append("|"); } } From e599f28d3433024d885de54b1c58f1302410e97d Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 26 Jul 2017 21:22:16 -0400 Subject: [PATCH 143/183] Modify HotJoiningManager join message --- .../game/arcade/game/games/moba/general/HotJoiningManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java index ad0c64270..cd02401a9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java @@ -65,7 +65,7 @@ public class HotJoiningManager implements Listener { Kit kit = _host.getFirstKit(player); - player.sendMessage(F.main("Game", "Thanks for choosing to join a game in progress! If you stay until the end of the game ")); + player.sendMessage(F.main("Game", "Thanks for choosing to join a game in progress! If you stay until the end of the game you will earn an additional " + HOT_JOIN_EXP_REWARD + " experience points")); _host.SetKit(player, kit, true); }, 1); } From 2180be20552bcbfdef773f4318472c87b6cfd684 Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Wed, 26 Jul 2017 21:17:31 -0400 Subject: [PATCH 144/183] Remove Specific creators from BonusManager --- .../mineplex/core/bonuses/BonusManager.java | 41 +------------------ 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index 2bdd967f5..ef84b512f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -149,7 +149,6 @@ public class BonusManager extends MiniClientPlugin implements I private int _visualTick; private ArrayList _voteList; - private List> _youtubers; private String _creeperName; @@ -182,18 +181,8 @@ public class BonusManager extends MiniClientPlugin implements I { _voteList.add("http://vote1.mineplex.com"); _voteList.add("http://vote2.mineplex.com"); - _voteList.add("http://vote3.mineplex.com"); } - _youtubers = new ArrayList<>(); - if (!ClansBonus) - { - _youtubers.add(Pair.create("Sigils", "https://www.youtube.com/user/SigilsPlaysGames?sub_confirmation=1")); - _youtubers.add(Pair.create("SallyGreenGamer", "https://www.youtube.com/channel/UCt8eypdLUND5CBvgXzEZrxw?sub_confirmation=1")); - _youtubers.add(Pair.create("RustyDawgT", "https://www.youtube.com/user/RustyDawgT?sub_confirmation=1")); - } - _youtubers.add(Pair.create("SamitoD", "https://www.youtube.com/user/SamitoD?sub_confirmation=1")); - _creeperName = "Carl"; updateOffSet(); @@ -240,18 +229,8 @@ public class BonusManager extends MiniClientPlugin implements I { _voteList.add("http://vote1.mineplex.com"); _voteList.add("http://vote2.mineplex.com"); - _voteList.add("http://vote3.mineplex.com"); } _canVote = true; - - _youtubers = new ArrayList<>(); - if (!ClansBonus) - { - _youtubers.add(Pair.create("Sigils", "https://www.youtube.com/user/SigilsPlaysGames?sub_confirmation=1")); - _youtubers.add(Pair.create("SallyGreenGamer", "https://www.youtube.com/channel/UCt8eypdLUND5CBvgXzEZrxw?sub_confirmation=1")); - _youtubers.add(Pair.create("RustyDawgT", "https://www.youtube.com/user/RustyDawgT?sub_confirmation=1")); - } - _youtubers.add(Pair.create("SamitoD", "https://www.youtube.com/user/SamitoD?sub_confirmation=1")); if (npcManager != null) { @@ -1005,7 +984,6 @@ public class BonusManager extends MiniClientPlugin implements I if (canVote(player)) availableRewards++; if (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) availableRewards++; if (_youtubeManager.canYoutube(player)) availableRewards++; - if (_youtubeManager.canSpecificYoutube(player)) availableRewards++; if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++; if (canDaily(player)) availableRewards++; if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++; @@ -1165,7 +1143,7 @@ public class BonusManager extends MiniClientPlugin implements I { if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false)) { - if (_pollManager.hasPoll(player) || canVote(player) || _youtubeManager.canSpecificYoutube(player) || _youtubeManager.canYoutube(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) + if (_pollManager.hasPoll(player) || canVote(player) || _youtubeManager.canYoutube(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) { if (_showCarl.containsKey(player.getName())) { @@ -1186,23 +1164,6 @@ public class BonusManager extends MiniClientPlugin implements I int index = date % _voteList.size(); return _voteList.get(index); } - - public Pair getSpecificCreator() - { - long sqlTime = getSqlTime(); - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(sqlTime); - int date = calendar.get(Calendar.DAY_OF_YEAR); - if (_youtubers.size() >= 1) - { - int index = date % _youtubers.size(); - return _youtubers.get(index); - } - else - { - return Pair.create("MineplexGames", "http://youtube.com/mineplexgamesofficial?sub_confirmation=1"); - } - } /** * Used for disabling rank rewards during first month of release From 04491493c2cf3f3d02166a85cce43eb48aa6ea96 Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Wed, 26 Jul 2017 21:23:02 -0400 Subject: [PATCH 145/183] Update SpecificChannelButton.java --- .../core/bonuses/gui/buttons/SpecificChannelButton.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/SpecificChannelButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/SpecificChannelButton.java index 1edafc35d..f04a6f2b3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/SpecificChannelButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/SpecificChannelButton.java @@ -34,7 +34,7 @@ public class SpecificChannelButton implements GuiItem @Override public void setup() { - _channel = Managers.get(BonusManager.class).getSpecificCreator(); + _channel = Pair.create("", ""); if (_youtubeManager.canSpecificYoutube(_player)) { _item = new ItemBuilder(Material.APPLE) @@ -111,4 +111,4 @@ public class SpecificChannelButton implements GuiItem { return _item; } -} \ No newline at end of file +} From 52341c15505e0b77a6d4d65488ca5d703a970356 Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Wed, 26 Jul 2017 21:26:17 -0400 Subject: [PATCH 146/183] Update BonusGui.java --- .../src/mineplex/core/bonuses/gui/BonusGui.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java index ea4c1a099..413816698 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java @@ -12,7 +12,6 @@ import mineplex.core.bonuses.gui.buttons.PlayWireButton; import mineplex.core.bonuses.gui.buttons.PollButton; import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton; import mineplex.core.bonuses.gui.buttons.RankBonusButton; -import mineplex.core.bonuses.gui.buttons.SpecificChannelButton; import mineplex.core.bonuses.gui.buttons.TwitterButton; import mineplex.core.bonuses.gui.buttons.VoteButton; import mineplex.core.bonuses.gui.buttons.YoutubeButton; @@ -33,10 +32,9 @@ public class BonusGui extends SimpleGui private final int CLAIM_TIPS_SLOT = 30; private final int POWER_PLAY_SLOT = 16; private final int CARL_SPINNER_SLOT = 14; - private final int YOUTUBE_SLOT = 22; + private final int YOUTUBE_SLOT = 24; private final int TWITTER_SLOT = 34; private final int PLAY_WIRE_SLOT = 32; - private final int SPECIFIC_YOUTUBE_SLOT = 24; private static final int INV_SIZE = 54; @@ -65,8 +63,6 @@ public class BonusGui extends SimpleGui setItem(CARL_SPINNER_SLOT, new CarlSpinButton(getPlugin(), player, manager, rewardManager)); setItem(PLAY_WIRE_SLOT, new PlayWireButton(playWireManager, player)); - - setItem(SPECIFIC_YOUTUBE_SLOT, new SpecificChannelButton(player, youtubeManager)); } @Override @@ -74,4 +70,4 @@ public class BonusGui extends SimpleGui { super.finalize(); } -} \ No newline at end of file +} From 16744de29607d65fbd58c5d12e06df797f5a2daf Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 27 Jul 2017 02:35:19 +0100 Subject: [PATCH 147/183] Fix some bugs --- .../game/arcade/game/games/moba/Moba.java | 13 +-- .../arcade/game/games/moba/MobaClassic.java | 3 +- .../game/games/moba/buff/BuffManager.java | 33 ++++---- .../games/moba/general/HotJoiningManager.java | 80 +++++++++++++++++-- .../games/moba/kit/devon/SkillInfinity.java | 4 +- .../arcade/game/games/moba/shop/MobaShop.java | 16 +--- 6 files changed, 97 insertions(+), 52 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index d8052c50b..2ac418c9b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -282,15 +282,18 @@ public class Moba extends TeamGame setKits(_kits); // Store player data - for (Player player : GetPlayers(true)) - { - _playerData.add(new MobaPlayer(player)); - MobaUtil.setTeamEntity(player, GetTeam(player)); - } + GetPlayers(true).forEach(this::setupPlayerData); + // Make sure to cleanup cleanupLobby(); } + public void setupPlayerData(Player player) + { + _playerData.add(new MobaPlayer(player)); + MobaUtil.setTeamEntity(player, GetTeam(player)); + } + @EventHandler public void preventOverfill(PlayerPrepareTeleportEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java index 1d0cf535b..853488d6d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java @@ -10,7 +10,6 @@ import nautilus.game.arcade.game.games.moba.general.HotJoiningManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; import nautilus.game.arcade.game.modules.CustomScoreboardModule; -import nautilus.game.arcade.game.modules.GameStatisticsModule; import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.ChatColor; import org.bukkit.entity.LivingEntity; @@ -98,7 +97,7 @@ public class MobaClassic extends Moba { suffix = C.cYellow + " Unknown"; } - else if (mobaPlayer.getKit() == null) + else if (mobaPlayer == null || mobaPlayer.getKit() == null) { suffix = C.cYellow + " Selecting"; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java index 66ce3aba8..c89e1fe11 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java @@ -4,6 +4,8 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -36,25 +38,7 @@ public class BuffManager implements Listener _buffs.get(buff.getEntity()).add(buff); buff.apply(); } - - public boolean hasBuff(LivingEntity entity, Class> clazz) - { - if (!_buffs.containsKey(entity)) - { - return false; - } - - for (Buff buff : _buffs.get(entity)) - { - if (buff.getClass().equals(clazz)) - { - return true; - } - } - - return false; - } - + @EventHandler public void update(UpdateEvent event) { @@ -91,4 +75,15 @@ public class BuffManager implements Listener } } } + + @EventHandler + public void end(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + { + return; + } + + _buffs.forEach((livingEntity, buffs) -> buffs.forEach(Buff::expire)); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java index ad0c64270..f413cd84b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/HotJoiningManager.java @@ -1,21 +1,26 @@ package nautilus.game.arcade.game.games.moba.general; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.progression.MobaExperienceCalculateEvent; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.Perk; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; import java.util.ArrayList; import java.util.List; +import java.util.UUID; public class HotJoiningManager implements Listener { @@ -23,18 +28,22 @@ public class HotJoiningManager implements Listener private static final int HOT_JOIN_EXP_REWARD = 100; private final Moba _host; + private final List _pending; private final List _hotJoined; + private final List _played; public HotJoiningManager(Moba host) { _host = host; + _pending = new ArrayList<>(); _hotJoined = new ArrayList<>(); + _played = new ArrayList<>(8); } - @EventHandler(priority = EventPriority.MONITOR) - public void playerJoin(PlayerJoinEvent event) + @EventHandler(priority = EventPriority.LOWEST) + public void playerLogin(PlayerLoginEvent event) { - if (!_host.IsLive()) + if (!_host.IsLive() || !_host.getArcadeManager().IsRewardStats()) { return; } @@ -42,11 +51,36 @@ public class HotJoiningManager implements Listener Player player = event.getPlayer(); GameTeam team = _host.ChooseTeam(player); - if (team == null || _host.getArcadeManager().isVanished(player)) + if (team == null || team.GetSize() >= 4) { return; } + _pending.add(player); + team.AddPlayer(player, true); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void playerJoin(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + + if (!_pending.remove(player)) + { + return; + } + + GameTeam team = _host.GetTeam(player); + + if (_host.getArcadeManager().isVanished(player)) + { + if (team != null) + { + team.RemovePlayer(player); + } + return; + } + for (Tower tower : _host.getTowerManager().getTowers()) { // If the team's second tower is dead @@ -57,16 +91,34 @@ public class HotJoiningManager implements Listener } } - team.AddPlayer(player, true); + boolean played = _played.contains(player.getUniqueId()); + team.SpawnTeleport(player); - _hotJoined.add(player); + + if (!played) + { + _hotJoined.add(player); + } + + _host.setupPlayerData(player); _host.getArcadeManager().runSyncLater(() -> { Kit kit = _host.getFirstKit(player); - player.sendMessage(F.main("Game", "Thanks for choosing to join a game in progress! If you stay until the end of the game ")); + if (!played) + { + player.sendMessage(F.main("Game", "Thanks for choosing to join a game in progress! If you stay until the end of the game you will were an additional " + F.elem(HOT_JOIN_EXP_REWARD) + " " + F.greenElem("Heroes of GWEN Role") + " experience.")); + } _host.SetKit(player, kit, true); + + Perk perk = kit.GetPerks()[kit.GetPerks().length - 1]; + + // Put Ultimates on cooldown + if (perk instanceof HeroSkill) + { + ((HeroSkill) perk).useSkill(player); + } }, 1); } @@ -74,9 +126,21 @@ public class HotJoiningManager implements Listener public void playerQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); + _pending.remove(player); _hotJoined.remove(player); } + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + _host.GetPlayers(true).forEach(player -> _played.add(player.getUniqueId())); + } + @EventHandler public void expCalculate(MobaExperienceCalculateEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 6097e9a28..753b4d324 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -50,7 +50,7 @@ public class SkillInfinity extends HeroSkill @EventHandler public void interact(PlayerInteractEvent event) { - if (!isSkillItem(event) || _active.contains(event.getPlayer())) + if (!isSkillItem(event)) { return; } @@ -66,13 +66,11 @@ public class SkillInfinity extends HeroSkill // Give 1 arrow just incase the player didn't have one _kit.giveAmmo(player, 1); bow.addEnchantment(Enchantment.ARROW_INFINITE, 1); - _active.add(player); broadcast(player); useActiveSkill(() -> { bow.removeEnchantment(Enchantment.ARROW_INFINITE); - _active.remove(player); }, player, 7000); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 6b8b00e34..224ee61bc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -26,7 +26,6 @@ import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop; import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop; import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop; import nautilus.game.arcade.game.games.moba.util.MobaConstants; -import nautilus.game.arcade.kit.Kit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; @@ -249,6 +248,7 @@ public class MobaShop implements Listener public List getOwnedItems(Player player) { + _upgrades.putIfAbsent(player, new ArrayList<>()); return _upgrades.get(player); } @@ -329,20 +329,6 @@ public class MobaShop implements Listener Handle MobaItem events */ - @EventHandler - public void prepare(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - { - return; - } - - for (Player player : _host.GetPlayers(true)) - { - _upgrades.put(player, new ArrayList<>()); - } - } - @EventHandler public void ammoGive(AmmoGiveEvent event) { From eb566d3363d21429536596791c014d1c16da1e2a Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 26 Jul 2017 23:29:07 -0400 Subject: [PATCH 148/183] Remove debug broadcasts --- .../src/mineplex/hub/modules/HubVisibilityManager.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java index e9158f679..f2d58351f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java @@ -123,7 +123,6 @@ public class HubVisibilityManager extends MiniPlugin if (perspective == null || !perspective.isOnline() || online.length <= index) { - Bukkit.broadcastMessage("Done"); iterator.remove(); continue; } @@ -132,13 +131,8 @@ public class HubVisibilityManager extends MiniPlugin if (!perspective.equals(subject) && !shouldHide(subject)) { - Bukkit.broadcastMessage("Making visible " + subject.getName() + " for " + perspective.getName()); VisibilityManager.Instance.setVisibility(subject, true, perspective); } - else - { - Bukkit.broadcastMessage("Ignoring " + subject.getName() + " for " + perspective.getName()); - } _nextShownPlayer.put(perspective, ++index); } From 66e5339eab485272fb76f93f73250426501cc4f1 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Jul 2017 15:45:24 -0400 Subject: [PATCH 149/183] Make UtilEnt#GetMetadata infer needed type --- .../src/mineplex/core/common/util/UtilEnt.java | 5 +++-- .../src/mineplex/game/clans/clans/mounts/MountManager.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 7af6ab2dd..07a2058c5 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -1025,14 +1025,15 @@ public class UtilEnt } // Nicer than doing entity.getMetadata(key).get(0); - public static Object GetMetadata(Entity entity, String key) + @SuppressWarnings("unchecked") + public static T GetMetadata(Entity entity, String key) { if (!entity.hasMetadata(key)) { return null; } - return entity.getMetadata(key).get(0).value(); + return (T) entity.getMetadata(key).get(0).value(); } public static void removeMetadata(Entity entity, String key) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java index c0d55196d..0100cb175 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java @@ -268,7 +268,7 @@ public class MountManager extends MiniDbClientPlugin { if (UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME") != null) { - Long dismount = (Long) UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME"); + Long dismount = UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME"); if (UtilTime.elapsed(dismount.longValue(), MAX_TIME_DISMOUNTED)) { mountIterator.remove(); From 9f45d3672dd3d0e6fe3fe793dc89604362b07164 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Jul 2017 15:45:40 -0400 Subject: [PATCH 150/183] Add Castle Assault to Build Server --- Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java index b8c09946c..d0bb8bc54 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java @@ -16,6 +16,8 @@ public enum GameType Build("Master Builders"), BuildMavericks("Mavericks Master Builders"), CastleSiege("Castle Siege"), + CastleAssault("Castle Assault"), + CastleAssaultTDM("Castle Assault TDM"), ChampionsTDM("Champions TDM", "Champions"), ChampionsDominate("Champions Domination", "Champions"), ChampionsCTF("Champions CTF", "Champions"), From 3952fa2e1d3ae97bec97c92ae743e8361c43a0bb Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Jul 2017 15:48:33 -0400 Subject: [PATCH 151/183] Increase amplifier and duration of Castle Assault spawn regeneration and add spawn resistance --- .../game/arcade/game/games/castleassault/kits/KitPlayer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java index ac445dd49..d278f174a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java @@ -39,7 +39,8 @@ public abstract class KitPlayer extends ProgressingKit protected void giveRegeneration(Player player) { - player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 5, 3)); + player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 8, 4)); + player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * 8, 3)); } @Override From 3ffd2966b6dd654cb3edc5e77fde2e5a4528170c Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Jul 2017 15:49:53 -0400 Subject: [PATCH 152/183] Nerf Tank kit --- .../games/castleassault/kits/KitTank.java | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java index c6b01406f..1c1873306 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java @@ -25,7 +25,7 @@ public class KitTank extends KitPlayer C.cGrayB + "Starting Kit:", C.cGray + "Diamond Sword", C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", - C.cGray + "Protection I on Iron Armor" + C.cGray + "Protection I on Iron Chestplace" }, new Perk[][] { @@ -39,21 +39,19 @@ public class KitTank extends KitPlayer new String[][] { { - C.cGray + "Obtain a Protection II Enchantment on your Iron Armor" + C.cGray + "Obtain a Protection I Enchantment on your Iron Leggings" + }, + { + C.cGray + "Obtain a Protection II Enchantment on your Iron Chestplate" + }, + { + C.cGray + "Obtain a Protection II Enchantment on your Iron Leggings" }, { C.cGray + "Obtain a Protection I Enchantment on your Diamond Helmet" }, { C.cGray + "Obtain a Protection I Enchantment on your Diamond Boots" - }, - { - C.cGray + "Obtain a Protection II Enchantment on your Diamond Helmet", - C.cGray + "Obtain a Protection II Enchantment on your Diamond Boots" - }, - { - C.cGray + "Obtain a Protection III Enchantment on your Iron Chestplate", - C.cGray + "Obtain a Protection III Enchantment on your Iron Leggings" } }, Material.DIAMOND_CHESTPLATE); @@ -71,44 +69,44 @@ public class KitTank extends KitPlayer { player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); } else if (level == 1) + { + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } + else if (level == 2) + { + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } + else if (level == 3) { player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); } - else if (level == 2) + else if (level == 4) { player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); } - else if (level == 3) + else if (level == 5) { player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); } - else if (level == 4) - { - player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - } - else if (level == 5) - { - player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - } } @Override From e9c3aebf90db7542a5f768171776e8004eb16d19 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Jul 2017 15:50:11 -0400 Subject: [PATCH 153/183] Complete Alchemist kit --- .../castleassault/kits/KitAlchemist.java | 132 ++++++++++++++++-- 1 file changed, 123 insertions(+), 9 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java index d42c40ae0..91656877f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java @@ -2,7 +2,12 @@ package nautilus.game.arcade.game.games.castleassault.kits; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.KitAvailability; @@ -12,21 +17,130 @@ public class KitAlchemist extends KitPlayer { public KitAlchemist(ArcadeManager manager) { - super(manager, "Alchemist", KitAvailability.Free, new String[] {}, new Perk[] {}, Material.POTION); + super(manager, "Alchemist", KitAvailability.Free, + new String[] + { + C.cGrayB + "Starting Kit:", + C.cGray + "Diamond Sword", + C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", + C.cGray + "Speed I Potion", + C.cGreenB + "Passive Ability:", + C.cGreen + "Netherborne: Permanent Fire Resistance" + }, + new Perk[][] + { + new Perk[] {}, + new Perk[] {}, + new Perk[] {}, + new Perk[] {}, + new Perk[] {}, + new Perk[] {} + }, + new String[][] + { + { + C.cGray + "Receive a Regeneration II Potion" + }, + { + C.cGray + "Obtain a time extension on your Speed I Potion" + }, + { + C.cGray + "Obtain a time extension on your Regeneration II Potion" + }, + { + C.cGray + "Receive a Resistance I Potion" + }, + { + C.cGray + "Obtain a time extension on your Resistance I Potion" + } + }, + Material.POTION); } @Override public void GiveItems(Player player) { - player.getInventory().setItem(0, new ItemBuilder(Material.IRON_SWORD).setUnbreakable(true).build()); - player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8194).build()); - player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setData((short)8193).build()); - player.getInventory().setHelmet(new ItemBuilder(Material.IRON_HELMET).setUnbreakable(true).build()); - player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setUnbreakable(true).build()); - player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setUnbreakable(true).build()); - player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).setUnbreakable(true).build()); + giveRegeneration(player); + player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 100000, 0)); + + player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + + int level = getUpgradeLevel(player.getUniqueId()); + if (level == 0) + { + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8194).build()); + } + else if (level == 1) + { + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8194).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setData((short)8225).build()); + } + else if (level == 2) + { + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8258).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setData((short)8225).build()); + } + else if (level == 3) + { + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8258).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setData((short)8289).build()); + } + else if (level == 4) + { + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8258).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setData((short)8289).build()); + ItemStack item = new ItemBuilder(Material.POTION).setData((short)8205).build(); + PotionMeta pm = (PotionMeta) item.getItemMeta(); + pm.clearCustomEffects(); + pm.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * 60, 0), true); + item.setItemMeta(pm); + player.getInventory().addItem(item); + } + else if (level == 5) + { + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8258).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setData((short)8289).build()); + ItemStack item = new ItemBuilder(Material.POTION).setData((short)8205).build(); + PotionMeta pm = (PotionMeta) item.getItemMeta(); + pm.clearCustomEffects(); + pm.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * 130, 0), true); + item.setItemMeta(pm); + player.getInventory().addItem(item); + } + + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); } @Override - public void awardKillStreak(Player player, int streak) {} + public void awardKillStreak(Player player, int streak) + { + if (streak == 2) + { + player.sendMessage(C.cRedB + "You have received a Slowness I Splash Potion as a Kill Streak Reward!"); + player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)16394).build()); + } + else if (streak == 4) + { + player.sendMessage(C.cRedB + "You have received a Weakness I Splash Potion as a Kill Streak Reward!"); + player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)16392).build()); + } + else if (streak == 6) + { + player.sendMessage(C.cRedB + "You have received 4 Instant Damage II Splash Potions as a Kill Streak Reward!"); + player.getInventory().addItem(new ItemBuilder(Material.POTION, 4).setData((short)16428).build()); + } + else if (streak == 8) + { + player.sendMessage(C.cRedB + "You have received a Regeneration III Potion as a Kill Streak Reward!"); + ItemStack item = new ItemBuilder(Material.POTION).setData((short)8193).build(); + PotionMeta pm = (PotionMeta) item.getItemMeta(); + pm.clearCustomEffects(); + pm.addCustomEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 10, 2), true); + item.setItemMeta(pm); + player.getInventory().addItem(item); + } + } } \ No newline at end of file From bf86c08126544d9fd7d48e306e27ac6ff3c26d3a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Jul 2017 15:50:28 -0400 Subject: [PATCH 154/183] Buff Archer kit --- .../games/castleassault/kits/KitArcher.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java index 94efc77d0..80c2cf28f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java @@ -25,16 +25,16 @@ public class KitArcher extends KitPlayer C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", C.cGray + "10 Fletched Arrows", C.cGreenB + "Starting Ability:", - C.cGreen + "Fletcher: Obtain 1 Fletched Arrow every 7 seconds (Max of 10)" + C.cGreen + "Fletcher: Obtain 1 Fletched Arrow every 6 seconds (Max of 10)" }, new Perk[][] { - new Perk[] {new PerkFletcher(7, 10, true, false)}, - new Perk[] {new PerkFletcher(7, 16, true, false)}, - new Perk[] {new PerkFletcher(7, 24, true, false)}, - new Perk[] {new PerkFletcher(7, 32, true, false)}, - new Perk[] {new PerkFletcher(7, 32, true, false)}, - new Perk[] {new PerkFletcher(7, 32, true, false)} + new Perk[] {new PerkFletcher(6, 10, true, false)}, + new Perk[] {new PerkFletcher(6, 16, true, false)}, + new Perk[] {new PerkFletcher(6, 24, true, false)}, + new Perk[] {new PerkFletcher(6, 32, true, false)}, + new Perk[] {new PerkFletcher(6, 32, true, false)}, + new Perk[] {new PerkFletcher(6, 32, true, false)} }, new String[][] { @@ -43,7 +43,8 @@ public class KitArcher extends KitPlayer }, { C.cGray + "Increase maximum and starting amount of Fletched Arrows to 24", - C.cGray + "Obtain a Power I Enchantment on your Bow" + C.cGray + "Obtain a Power I Enchantment on your Bow", + C.cGray + "Receive a Feather Falling II Enchantment on your Diamond Boots" }, { C.cGray + "Increase maximum and starting amount of Fletched Arrows to 32", @@ -100,10 +101,14 @@ public class KitArcher extends KitPlayer player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); - if (level < 5) + if (level < 2) { player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); } + else if (level < 5) + { + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_FALL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } else { player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_FALL, 4).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); @@ -130,8 +135,9 @@ public class KitArcher extends KitPlayer } else if (streak == 8) { - player.sendMessage(C.cRedB + "You have received 32 Arrows as a Kill Streak Reward!"); + player.sendMessage(C.cRedB + "You have received 32 Arrows and a Flame I book as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.ARROW).setAmount(32).setTitle(F.item("Fletched Arrow")).build()); + player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_FIRE, 1).build()); } } } \ No newline at end of file From 05de0246065227a542a8c5b93420a63c4f3f301e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Jul 2017 15:50:45 -0400 Subject: [PATCH 155/183] Buff Demolitionist kit --- .../arcade/game/games/castleassault/kits/KitDemolitionist.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 5af012192..f8527eab6 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 @@ -145,8 +145,9 @@ public class KitDemolitionist extends KitPlayer } else if (streak == 8) { - player.sendMessage(C.cRedB + "You have received 5 Throwing TNT as a Kill Streak Reward!"); + player.sendMessage(C.cRedB + "You have received 5 Throwing TNT and a 30-Use Flint and Steel as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(5).build()); + player.getInventory().addItem(new ItemBuilder(Material.FLINT_AND_STEEL).setData((short) (Material.FLINT_AND_STEEL.getMaxDurability() - 30)).build()); } } } \ No newline at end of file From b672988d3151bdae0164af9fd52aa4bafb40d5d7 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Jul 2017 15:51:06 -0400 Subject: [PATCH 156/183] Nerf Fighter kit --- .../game/games/castleassault/kits/KitFighter.java | 12 ++++++------ .../game/games/castleassault/kits/PerkBloodlust.java | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java index 986bfb915..df96abc2b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java @@ -22,7 +22,7 @@ public class KitFighter extends KitPlayer C.cGray + "Diamond Sword", C.cGray + "1 Golden Applegate", C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", - C.cGreenB + "Passive Ability:", + C.cGreenB + "Starting Ability:", C.cGreen + "Bloodlust: Deal half a heart more damage for 3 seconds after killing an enemy" }, new Perk[][] @@ -32,7 +32,7 @@ public class KitFighter extends KitPlayer new Perk[] {new PerkBloodlust(1, 3)}, new Perk[] {new PerkBloodlust(1, 3)}, new Perk[] {new PerkBloodlust(1, 3)}, - new Perk[] {new PerkBloodlust(1, 3)} + new Perk[] {new PerkBloodlust(1, 5)} }, new String[][] { @@ -50,7 +50,7 @@ public class KitFighter extends KitPlayer C.cGray + "Increase starting amount of Golden Applegates to 3" }, { - C.cGray + "Obtain a Sharpness II Enchantment on your Diamond Sword" + C.cGray + "Increase duration of Bloodlust to 5 seconds" } }, Material.DIAMOND_SWORD); @@ -92,7 +92,7 @@ public class KitFighter extends KitPlayer } else if (level == 5) { - player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setItem(1, new ItemBuilder(Material.FISHING_ROD).addEnchantment(Enchantment.KNOCKBACK, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); player.getInventory().setItem(2, new ItemBuilder(Material.GOLDEN_APPLE).setAmount(3).setTitle(C.cPurple + "Golden Applegate").build()); } @@ -113,13 +113,13 @@ public class KitFighter extends KitPlayer } else if (streak == 4) { - player.sendMessage(C.cRedB + "You have received a Splash Healing II Potion as a Kill Streak Reward!"); + player.sendMessage(C.cRedB + "You have received a Healing II Splash Potion as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)16421).build()); } else if (streak == 6) { player.sendMessage(C.cRedB + "You have received a Speed II Potion as a Kill Streak Reward!"); - player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)8290).build()); + player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)8226).build()); } else if (streak == 8) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java index 9dc21c017..2fc724eef 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java @@ -27,7 +27,7 @@ public class PerkBloodlust extends Perk public PerkBloodlust(double damageBoost, int duration) { super("Bloodlust", - new String[] + new String[] { C.cGray + "Deal an extra " + (damageBoost / 2) + " hearts of damage for " + duration + " seconds after a kill.", } @@ -92,7 +92,7 @@ public class PerkBloodlust extends Perk Bukkit.getScheduler().cancelTask(id.intValue()); } - player.sendMessage(C.cRed + "You are now channeling bloodlust for 3 seconds!"); + player.sendMessage(C.cRed + "You are now channeling bloodlust for " + _duration + " seconds!"); _lusting.put(player, Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () -> _lusting.remove(player), _duration * 20).getTaskId()); } From f8f87a23bc9f8f9578ef1c7446594a098d056cb1 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 15 Jul 2017 15:52:13 -0400 Subject: [PATCH 157/183] Fix bug causing tnt to not function, increase tnt damage, remove fire resistance from loot pool, and implement Alchemist kit --- .../arcade/game/games/castleassault/CastleAssault.java | 10 +++++----- .../game/games/castleassault/CastleAssaultTDM.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 9d651ad84..f0bc1402d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -56,7 +56,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.material.Dispenser; import org.bukkit.material.MaterialData; import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.metadata.MetadataValue; import org.bukkit.util.Vector; import mineplex.core.Managers; @@ -97,6 +96,7 @@ import nautilus.game.arcade.game.games.castleassault.data.KillStreakData; import nautilus.game.arcade.game.games.castleassault.data.ObjectiveTNTSpawner; import nautilus.game.arcade.game.games.castleassault.data.TeamCrystal; import nautilus.game.arcade.game.games.castleassault.data.TeamKing; +import nautilus.game.arcade.game.games.castleassault.kits.KitAlchemist; import nautilus.game.arcade.game.games.castleassault.kits.KitArcher; import nautilus.game.arcade.game.games.castleassault.kits.KitDemolitionist; import nautilus.game.arcade.game.games.castleassault.kits.KitFighter; @@ -143,7 +143,7 @@ public class CastleAssault extends TeamGame super(manager, GameType.CastleAssault, new Kit[] { - //new KitAlchemist(manager), + new KitAlchemist(manager), new KitArcher(manager), new KitDemolitionist(manager), //new KitEnchanter(manager), @@ -246,7 +246,6 @@ public class CastleAssault extends TeamGame } { _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8193).build(), 2); - _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8195).build(), 2); } { _miscGear.addLoot(new ItemStack(Material.ENDER_PEARL), 2); @@ -956,7 +955,8 @@ public class CastleAssault extends TeamGame float radius = event.getRadius(); event.setRadius(0f); - Player player = UtilPlayer.searchExact(((MetadataValue)UtilEnt.GetMetadata(event.getEntity(), "THROWER")).asString()); + String thrower = UtilEnt.GetMetadata(event.getEntity(), "THROWER"); + Player player = UtilPlayer.searchExact(thrower); if (player == null) { return; @@ -1003,7 +1003,7 @@ public class CastleAssault extends TeamGame } blastProtEPF = Math.min(blastProtEPF, 20); - double damage = 8 * mult; + double damage = 10 * mult; damage = damage * (1 - (blastProtEPF / 25)); double knockbackReduction = 1 - (highestBlastProt * 0.15); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java index 959288efe..e1401ca49 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java @@ -46,7 +46,6 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.material.Dispenser; import org.bukkit.material.MaterialData; -import org.bukkit.metadata.MetadataValue; import mineplex.core.Managers; import mineplex.core.common.Pair; @@ -807,7 +806,8 @@ public class CastleAssaultTDM extends TeamGame float radius = event.getRadius(); event.setRadius(0f); - Player player = UtilPlayer.searchExact(((MetadataValue)UtilEnt.GetMetadata(event.getEntity(), "THROWER")).asString()); + String thrower = UtilEnt.GetMetadata(event.getEntity(), "THROWER"); + Player player = UtilPlayer.searchExact(thrower); if (player == null) { return; From d5f56cdb3283357d6cbd91a8715fe9419f756618 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 24 Jul 2017 15:40:02 -0400 Subject: [PATCH 158/183] Remove Bow from game chests and document bow presence in Archer kit --- .../game/arcade/game/games/castleassault/CastleAssault.java | 2 +- .../game/arcade/game/games/castleassault/kits/KitArcher.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index f0bc1402d..487210603 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -233,7 +233,7 @@ public class CastleAssault extends TeamGame private void generateLoot() { { - _rangedGear.addLoot(new ItemStack(Material.BOW), 3); + _rangedGear.addLoot(new ItemStack(Material.EGG), 3); _rangedGear.addLoot(Material.ARROW, 3, 8, 16); } { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java index 80c2cf28f..b449ab7f2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java @@ -22,6 +22,7 @@ public class KitArcher extends KitPlayer { C.cGrayB + "Starting Kit:", C.cGray + "Diamond Sword", + C.cGray + "Bow", C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", C.cGray + "10 Fletched Arrows", C.cGreenB + "Starting Ability:", From d737b412817e6672cb3ebb02de61977af5eea7f4 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 24 Jul 2017 15:43:55 -0400 Subject: [PATCH 159/183] Make the starting Alchemist potions marked Kit Items --- .../castleassault/kits/KitAlchemist.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java index 91656877f..a9cd5379b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java @@ -68,28 +68,28 @@ public class KitAlchemist extends KitPlayer int level = getUpgradeLevel(player.getUniqueId()); if (level == 0) { - player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8194).build()); + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8194).build()); } else if (level == 1) { - player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8194).build()); - player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setData((short)8225).build()); + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8194).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8225).build()); } else if (level == 2) { - player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8258).build()); - player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setData((short)8225).build()); + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8258).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8225).build()); } else if (level == 3) { - player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8258).build()); - player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setData((short)8289).build()); + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8258).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8289).build()); } else if (level == 4) { - player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8258).build()); - player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setData((short)8289).build()); - ItemStack item = new ItemBuilder(Material.POTION).setData((short)8205).build(); + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8258).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8289).build()); + ItemStack item = new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8205).build(); PotionMeta pm = (PotionMeta) item.getItemMeta(); pm.clearCustomEffects(); pm.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * 60, 0), true); @@ -98,9 +98,9 @@ public class KitAlchemist extends KitPlayer } else if (level == 5) { - player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8258).build()); - player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setData((short)8289).build()); - ItemStack item = new ItemBuilder(Material.POTION).setData((short)8205).build(); + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8258).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8289).build()); + ItemStack item = new ItemBuilder(Material.POTION).setLore(C.cGold + "Kit Item").setData((short)8205).build(); PotionMeta pm = (PotionMeta) item.getItemMeta(); pm.clearCustomEffects(); pm.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * 130, 0), true); From 58730758368ff0dc9e36e8655aa52df70b258e85 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 24 Jul 2017 15:48:31 -0400 Subject: [PATCH 160/183] Clear potion effects on kit equip --- .../game/arcade/game/games/castleassault/kits/KitPlayer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java index d278f174a..ad992cb7c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java @@ -39,6 +39,7 @@ public abstract class KitPlayer extends ProgressingKit protected void giveRegeneration(Player player) { + player.getActivePotionEffects().forEach(p -> player.removePotionEffect(p.getType())); player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 8, 4)); player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * 8, 3)); } From 4f8a71cefcd10cbb8644540b17732fcd93f01f85 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 24 Jul 2017 15:53:14 -0400 Subject: [PATCH 161/183] Remove bolded text from kill streak reward information --- .../game/games/castleassault/kits/KitAlchemist.java | 8 ++++---- .../arcade/game/games/castleassault/kits/KitArcher.java | 8 ++++---- .../game/games/castleassault/kits/KitDemolitionist.java | 8 ++++---- .../arcade/game/games/castleassault/kits/KitFighter.java | 8 ++++---- .../arcade/game/games/castleassault/kits/KitTank.java | 8 ++++---- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java index a9cd5379b..c4b9dcde3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java @@ -119,22 +119,22 @@ public class KitAlchemist extends KitPlayer { if (streak == 2) { - player.sendMessage(C.cRedB + "You have received a Slowness I Splash Potion as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Slowness I Splash Potion as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)16394).build()); } else if (streak == 4) { - player.sendMessage(C.cRedB + "You have received a Weakness I Splash Potion as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Weakness I Splash Potion as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)16392).build()); } else if (streak == 6) { - player.sendMessage(C.cRedB + "You have received 4 Instant Damage II Splash Potions as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 4 Instant Damage II Splash Potions as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.POTION, 4).setData((short)16428).build()); } else if (streak == 8) { - player.sendMessage(C.cRedB + "You have received a Regeneration III Potion as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Regeneration III Potion as a Kill Streak Reward!"); ItemStack item = new ItemBuilder(Material.POTION).setData((short)8193).build(); PotionMeta pm = (PotionMeta) item.getItemMeta(); pm.clearCustomEffects(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java index b449ab7f2..5ad41af5a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java @@ -121,22 +121,22 @@ public class KitArcher extends KitPlayer { if (streak == 2) { - player.sendMessage(C.cRedB + "You have received 8 Arrows as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 8 Arrows as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.ARROW).setAmount(8).setTitle(F.item("Fletched Arrow")).build()); } else if (streak == 4) { - player.sendMessage(C.cRedB + "You have received 12 Arrows as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 12 Arrows as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.ARROW).setAmount(12).setTitle(F.item("Fletched Arrow")).build()); } else if (streak == 6) { - player.sendMessage(C.cRedB + "You have received a Punch I book as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Punch I book as a Kill Streak Reward!"); player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_KNOCKBACK, 1).build()); } else if (streak == 8) { - player.sendMessage(C.cRedB + "You have received 32 Arrows and a Flame I book as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 32 Arrows and a Flame I book as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.ARROW).setAmount(32).setTitle(F.item("Fletched Arrow")).build()); player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_FIRE, 1).build()); } 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 f8527eab6..4f57ebad3 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 @@ -130,22 +130,22 @@ public class KitDemolitionist extends KitPlayer { if (streak == 2) { - player.sendMessage(C.cRedB + "You have received 2 Throwing TNT as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 2 Throwing TNT as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(2).build()); } else if (streak == 4) { - player.sendMessage(C.cRedB + "You have received 3 Throwing TNT as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 3 Throwing TNT as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(3).build()); } else if (streak == 6) { - player.sendMessage(C.cRedB + "You have received 4 Throwing TNT as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 4 Throwing TNT as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(4).build()); } else if (streak == 8) { - player.sendMessage(C.cRedB + "You have received 5 Throwing TNT and a 30-Use Flint and Steel as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received 5 Throwing TNT and a 30-Use Flint and Steel as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(5).build()); player.getInventory().addItem(new ItemBuilder(Material.FLINT_AND_STEEL).setData((short) (Material.FLINT_AND_STEEL.getMaxDurability() - 30)).build()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java index df96abc2b..34cd1ea0d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java @@ -108,22 +108,22 @@ public class KitFighter extends KitPlayer { if (streak == 2) { - player.sendMessage(C.cRedB + "You have received a Golden Applegate as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Golden Applegate as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setAmount(1).setTitle(C.cPurple + "Golden Applegate").build()); } else if (streak == 4) { - player.sendMessage(C.cRedB + "You have received a Healing II Splash Potion as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Healing II Splash Potion as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)16421).build()); } else if (streak == 6) { - player.sendMessage(C.cRedB + "You have received a Speed II Potion as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Speed II Potion as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)8226).build()); } else if (streak == 8) { - player.sendMessage(C.cRedB + "You have received a Fire Aspect I book as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Fire Aspect I book as a Kill Streak Reward!"); player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.FIRE_ASPECT, 1).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java index 1c1873306..5184cb3a3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java @@ -114,17 +114,17 @@ public class KitTank extends KitPlayer { if (streak == 2) { - player.sendMessage(C.cRedB + "You have received a Golden Applegate as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Golden Applegate as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setAmount(1).setTitle(C.cPurple + "Golden Applegate").build()); } else if (streak == 4) { - player.sendMessage(C.cRedB + "You have received a Regeneration II Potion as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Regeneration II Potion as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)8289).build()); } else if (streak == 6) { - player.sendMessage(C.cRedB + "You have received a Resistance I Potion as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Resistance I Potion as a Kill Streak Reward!"); ItemStack item = new ItemBuilder(Material.POTION).setData((short)8205).build(); PotionMeta pm = (PotionMeta) item.getItemMeta(); pm.clearCustomEffects(); @@ -134,7 +134,7 @@ public class KitTank extends KitPlayer } else if (streak == 8) { - player.sendMessage(C.cRedB + "You have received a Thorns II book as a Kill Streak Reward!"); + player.sendMessage(C.cRed + "You have received a Thorns II book as a Kill Streak Reward!"); player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.THORNS, 2).build()); } } From f2e5dfffd9be9059fb8eec8a55e0ea37605871da Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 24 Jul 2017 16:00:05 -0400 Subject: [PATCH 162/183] Change kit description color because joe has OCD --- .../game/arcade/game/games/castleassault/kits/KitAlchemist.java | 2 +- .../game/arcade/game/games/castleassault/kits/KitArcher.java | 2 +- .../arcade/game/games/castleassault/kits/KitDemolitionist.java | 2 +- .../game/arcade/game/games/castleassault/kits/KitFighter.java | 2 +- .../game/arcade/game/games/castleassault/kits/KitTank.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java index c4b9dcde3..c0478f3ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java @@ -20,7 +20,7 @@ public class KitAlchemist extends KitPlayer super(manager, "Alchemist", KitAvailability.Free, new String[] { - C.cGrayB + "Starting Kit:", + C.cWhiteB + "Starting Kit:", C.cGray + "Diamond Sword", C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", C.cGray + "Speed I Potion", diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java index 5ad41af5a..7aa25d439 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java @@ -20,7 +20,7 @@ public class KitArcher extends KitPlayer super(manager, "Archer", KitAvailability.Free, new String[] { - C.cGrayB + "Starting Kit:", + C.cWhiteB + "Starting Kit:", C.cGray + "Diamond Sword", C.cGray + "Bow", C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", 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 4f57ebad3..648fd93f0 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 @@ -19,7 +19,7 @@ public class KitDemolitionist extends KitPlayer super(manager, "Demolitionist", KitAvailability.Free, new String[] { - C.cGrayB + "Starting Kit:", + C.cWhiteB + "Starting Kit:", C.cGray + "Diamond Sword, Flint and Steel", C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", C.cGray + "Blast Protection IV on all Armor", diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java index 34cd1ea0d..119380430 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java @@ -18,7 +18,7 @@ public class KitFighter extends KitPlayer super(manager, "Fighter", KitAvailability.Free, new String[] { - C.cGrayB + "Starting Kit:", + C.cWhiteB + "Starting Kit:", C.cGray + "Diamond Sword", C.cGray + "1 Golden Applegate", C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java index 5184cb3a3..a98498e57 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java @@ -22,7 +22,7 @@ public class KitTank extends KitPlayer super(manager, "Tank", KitAvailability.Free, new String[] { - C.cGrayB + "Starting Kit:", + C.cWhiteB + "Starting Kit:", C.cGray + "Diamond Sword", C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", C.cGray + "Protection I on Iron Chestplace" From 8dcea688ed3e0b06a650ea0225e0def186282f46 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 24 Jul 2017 16:05:59 -0400 Subject: [PATCH 163/183] Add alchemist kit kills achievement --- .../src/mineplex/core/achievement/Achievement.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 33bb61aff..0439fa106 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -461,6 +461,15 @@ public enum Achievement new String[]{"Novice I", "Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, AchievementCategory.CASTLE_ASSAULT), + CASTLE_ASSAULT_ALCHEMIST_KIT("Alchemist", 0, + new String[]{"Castle Assault.AlchemistKitKills", "Castle Assault TDM.AlchemistKitKills"}, + new String[]{"Kill opponents while wearing the Alchemist Kit"}, + new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, + new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, + "Initiate", + new String[]{"Novice I", "Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, + AchievementCategory.CASTLE_ASSAULT), + CASTLE_ASSAULT_WINNER("Assault", 0, new String[]{"Castle Assault.Wins", "Castle Assault TDM.Wins"}, new String[]{"Win games of Castle Assault"}, From 53f28ac26b84021062ffc360622602c0b56668a3 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 24 Jul 2017 16:20:08 -0400 Subject: [PATCH 164/183] Add a sound when your king is being damaged --- .../game/arcade/game/games/castleassault/CastleAssault.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 487210603..b8d2ea776 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -14,6 +14,7 @@ import org.bukkit.ChatColor; 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; @@ -233,7 +234,7 @@ public class CastleAssault extends TeamGame private void generateLoot() { { - _rangedGear.addLoot(new ItemStack(Material.EGG), 3); + _rangedGear.addLoot(new ItemStack(Material.EGG), 3, 5, 9); _rangedGear.addLoot(Material.ARROW, 3, 8, 16); } { @@ -1194,6 +1195,7 @@ public class CastleAssault extends TeamGame { if (Recharge.Instance.use(alert, "KingDamageAlert", 5000, false, false)) { + alert.playSound(alert.getLocation(), Sound.ANVIL_LAND, 10, 3); alert.sendMessage(king.getName(true) + " is under attack!"); } } From 5edfcfa40e6741b42a154da4fdca5d4a26b4696f Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 27 Jul 2017 10:47:14 +0100 Subject: [PATCH 165/183] Stop training mode from using map specific code --- .../game/arcade/game/games/moba/Moba.java | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index d8052c50b..a4910c2bd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -29,7 +29,6 @@ import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.general.ArrowKBManager; import nautilus.game.arcade.game.games.moba.general.BetaManager; import nautilus.game.arcade.game.games.moba.general.EnderPearlManager; -import nautilus.game.arcade.game.games.moba.general.HotJoiningManager; import nautilus.game.arcade.game.games.moba.general.MobaDamageManager; import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.HeroKit; @@ -51,6 +50,7 @@ import nautilus.game.arcade.game.games.moba.progression.MobaProgression; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; +import nautilus.game.arcade.game.games.moba.training.MobaTraining; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; @@ -205,26 +205,29 @@ public class Moba extends TeamGame SpectatorSpawn = WorldData.GetCustomLocs("CENTER").get(0); - MobaMapType mapType = null; - - for (String key : WorldData.GetAllCustomLocs().keySet()) + if (!(this instanceof MobaTraining)) { - try - { - mapType = MobaMapType.valueOf(key); - break; - } - catch (IllegalArgumentException e) - { - } - } + MobaMapType mapType = null; - if (mapType == null) - { - mapType = MobaMapType.HEROES_VALLEY; - } + for (String key : WorldData.GetAllCustomLocs().keySet()) + { + try + { + mapType = MobaMapType.valueOf(key); + break; + } + catch (IllegalArgumentException e) + { + } + } - registerManager(mapType.createInstance(this)); + if (mapType == null) + { + mapType = MobaMapType.HEROES_VALLEY; + } + + registerManager(mapType.createInstance(this)); + } if (Manager.IsRewardStats() && Manager.GetLobby() instanceof NewGameLobbyManager) { From c69f67b3e84fde102804c3c868627f871b688852 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Fri, 28 Jul 2017 17:20:04 -0400 Subject: [PATCH 166/183] Fix skeleton disguises appearing invisible --- .../core/disguise/DisguiseManager.java | 3 + .../core/disguise/disguises/DisguiseBase.java | 38 +++++-- .../disguise/disguises/DisguiseCreature.java | 101 +++++++++++++++--- .../disguise/disguises/DisguiseGuardian.java | 64 ++--------- .../disguise/disguises/DisguiseHorse.java | 53 ++++++++- .../disguise/disguises/DisguiseMutable.java | 40 +++++++ .../disguise/disguises/DisguiseSkeleton.java | 22 +++- 7 files changed, 228 insertions(+), 93 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMutable.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index 44dc988fc..59783273d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -228,6 +228,9 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler if (!spawnedIn) { refreshTrackers(disguise.getEntity().getBukkitEntity()); + } else + { + disguise.markSpawnedIn(); } disguise.onDisguise(true); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java index b9e6cdd9c..e6e02767b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java @@ -1,7 +1,11 @@ package mineplex.core.disguise.disguises; -import mineplex.core.common.DummyEntity; -import mineplex.core.common.util.UtilPlayer; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.function.Predicate; +import java.util.function.Supplier; import net.minecraft.server.v1_8_R3.*; @@ -10,12 +14,8 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.entity.CreatureSpawnEvent; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.function.Consumer; -import java.util.function.Supplier; +import mineplex.core.common.DummyEntity; +import mineplex.core.common.util.UtilPlayer; public abstract class DisguiseBase { @@ -32,6 +32,8 @@ public abstract class DisguiseBase */ private boolean _hideIfNotDisguised = false; + protected boolean _spawnedIn = false; + public DisguiseBase(EntityType entityType, org.bukkit.entity.Entity entity) { if (entity == null) @@ -67,7 +69,7 @@ public abstract class DisguiseBase DataWatcher.watch(1, getEntity().getDataWatcher().getShort(1), net.minecraft.server.v1_8_R3.Entity.META_AIR, (int) getEntity().getDataWatcher().getShort(1)); } - public void sendToWatchers(Supplier supplier) + protected void sendToWatchers(Predicate protocolPredicate, Supplier supplier) { if (getEntity() == null || !getEntity().getBukkitEntity().isValid() || !(getEntity().world instanceof WorldServer)) return; @@ -83,12 +85,16 @@ public abstract class DisguiseBase for (EntityPlayer player : tracker.get(getEntity().getId()).trackedPlayers) { + int protocol = player.getProtocol(); + if (!protocolPredicate.test(protocol)) + continue; + if (packet instanceof PacketPlayOutEntityMetadata) { - player.playerConnection.sendPacket(modifyMetaPacket(player.getProtocol(), packet)); + player.playerConnection.sendPacket(modifyMetaPacket(protocol, packet)); } else if (packet instanceof PacketPlayOutSpawnEntityLiving) { - player.playerConnection.sendPacket(modifySpawnPacket(player.getProtocol(), packet)); + player.playerConnection.sendPacket(modifySpawnPacket(protocol, packet)); } else { player.playerConnection.sendPacket(packet); @@ -96,6 +102,11 @@ public abstract class DisguiseBase } } + protected void sendToWatchers(Supplier supplier) + { + sendToWatchers(x -> true, supplier); + } + public abstract Packet getSpawnPacket(); public Packet modifySpawnPacket(int protocol, Packet packet) @@ -203,6 +214,11 @@ public abstract class DisguiseBase } + public void markSpawnedIn() + { + _spawnedIn = true; + } + public void setHideIfNotDisguised(boolean hideIfNotDisguised) { this._hideIfNotDisguised = hideIfNotDisguised; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java index 5e8eaaf8c..65b1f1174 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java @@ -1,10 +1,10 @@ package mineplex.core.disguise.disguises; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; -import java.util.stream.Collectors; -import com.mineplex.MetaWrapper; +import com.mineplex.MetadataRewriter; import com.mineplex.ProtocolVersion; import net.minecraft.server.v1_8_R3.*; @@ -78,45 +78,112 @@ public abstract class DisguiseCreature extends DisguiseInsentient return packet; } + // ---- Metadata processing + + // This WON'T be post-processed by the Spigot metadata processor + @Override public Packet modifySpawnPacket(int protocol, Packet packet) { if (protocol >= ProtocolVersion.v1_10_PRE) { PacketPlayOutSpawnEntityLiving newSpawn = (PacketPlayOutSpawnEntityLiving) getSpawnPacket(); - newSpawn.m = processSpawnMeta(protocol, DataWatcher.c()); + + // Allow the entity type to be changed (needed on 1.11+) + newSpawn.b = getTypeId(protocol >= ProtocolVersion.v1_11); + + boolean hasArms = false; + List meta = DataWatcher.b(); + + if (meta != null) + { + // Run the meta through our Spigot rewriter + meta = MetadataRewriter.rewrite(getTypeId(false), protocol, meta).objects; + + // Remove indexes >= 12 on 1.11+ + if (protocol >= ProtocolVersion.v1_11) + { + Iterator iter = meta.iterator(); + while (iter.hasNext()) + { + WatchableObject next = iter.next(); + if (next.getIndex().a() == 6) + { + hasArms = true; + } else if (next.getIndex().a() >= 12) + { + iter.remove(); + } + } + } + } else + { + meta = new ArrayList<>(); + } + + if (!hasArms) + { + WatchableObject arms = new WatchableObject<>(0, 0, null, + new DataIndex<>(6, DataType.BYTE), (byte) 0); + meta.add(arms); + } + + newSpawn.m = meta; return newSpawn; } return packet; } - private List processSpawnMeta(int protocol, List list) + protected int getTypeId(boolean separate) { - List newMeta = new ArrayList<>(); - for (WatchableObject meta : list) + return getDisguiseType().getTypeId(); + } + + // This WILL be post-processed by Spigot's metadata processor + + @Override + public Packet modifyMetaPacket(int protocol, Packet packet) + { + if (protocol >= ProtocolVersion.v1_10_PRE) { - MetaWrapper wrapper = new MetaWrapper(meta); - if (wrapper.getIndex() >= 5) // 1.10 + PacketPlayOutEntityMetadata newMeta = new PacketPlayOutEntityMetadata(); + newMeta.a = getEntityId(); + + boolean hasArms = false; + List meta = DataWatcher.b(); + List adjusted = new ArrayList<>(); + + if (meta != null) { - wrapper.setIndex(wrapper.getIndex() + 1); + // Process the meta while we know the entity id + adjusted = MetadataRewriter.rewrite(getTypeId(false), protocol, meta).objects; + hasArms = meta.stream().anyMatch(obj -> obj.getIndex().a() == 6); } - if (protocol < ProtocolVersion.v1_11) + for (int i = 0; i < adjusted.size(); i++) { - newMeta.add(wrapper); - continue; + WatchableObject object = adjusted.get(i); + int index = object.getIndex().a(); + if (index >= 6) + { + index--; + adjusted.set(i, new WatchableObject(0, 0, null, + new DataIndex(index, object.getIndex().b()), object.getValue())); + } } - if (getEntity() instanceof EntityArmorStand && wrapper.getIndex() >= 12) + if (!hasArms) { - // Armor stand meta conflicts with a lot of entities on 1.11+ - continue; + WatchableObject arms = new WatchableObject<>(0, 0, null, + new DataIndex<>(5, DataType.BYTE), (byte) 0); + adjusted.add(arms); } - newMeta.add(wrapper); + newMeta.b = adjusted; + return newMeta; } - return newMeta.stream().map(MetaWrapper::toWatchableObject).collect(Collectors.toList()); + return packet; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java index 31222e6da..1f40da543 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseGuardian.java @@ -1,20 +1,14 @@ package mineplex.core.disguise.disguises; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; +import net.minecraft.server.v1_8_R3.EntityGuardian; -import com.mineplex.MetaWrapper; -import com.mineplex.ProtocolVersion; - -import net.minecraft.server.v1_8_R3.*; -import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; - -import org.bukkit.entity.ArmorStand; import org.bukkit.entity.EntityType; -public class DisguiseGuardian extends DisguiseCreature +public class DisguiseGuardian extends DisguiseMutable { + private static final int GUARDIAN_ID = 68; + private static final int ELDER_GUARDIAN_ID = 4; + private int target = 0; private boolean elder = false; @@ -41,9 +35,7 @@ public class DisguiseGuardian extends DisguiseCreature DataWatcher.watch(16, Integer.valueOf(newValue), EntityGuardian.META_ELDER, (byte) newValue); - sendToWatchers(() -> new PacketPlayOutEntityDestroy(new int[]{getEntityId()})); - sendToWatchers(this::getSpawnPacket); - sendToWatchers(this::getMetadataPacket); + mutate(); } public boolean isElder() @@ -66,49 +58,9 @@ public class DisguiseGuardian extends DisguiseCreature return "mob.guardian.hit"; } - // ---- Packet modification for 1.11 and up - @Override - public Packet modifySpawnPacket(int protocol, Packet packet) + protected int getTypeId(boolean separate) { - PacketPlayOutSpawnEntityLiving newSpawn = (PacketPlayOutSpawnEntityLiving) super.modifySpawnPacket(protocol, packet); - if (protocol >= ProtocolVersion.v1_11 && isElder()) - { - newSpawn.b = 4; - } - - return newSpawn; - } - - @Override - public Packet modifyMetaPacket(int protocol, Packet packet) - { - if (protocol >= ProtocolVersion.v1_11) - { - PacketPlayOutEntityMetadata newPacket = (PacketPlayOutEntityMetadata) getMetadataPacket(); - newPacket.b = processMeta(newPacket.b); - return newPacket; - } - - return packet; - } - - private List processMeta(List list) - { - List newMeta = new ArrayList<>(); - for (WatchableObject meta : list) - { - MetaWrapper wrapper = new MetaWrapper(meta); - if (wrapper.getIndex() == 11) - { - byte value = (byte) wrapper.getValue(); - newMeta.add(new MetaWrapper(11, DataType.BOOLEAN, (value & 0x02) != 0)); - } else - { - newMeta.add(wrapper); - } - } - - return newMeta.stream().map(MetaWrapper::toWatchableObject).collect(Collectors.toList()); + return separate && isElder() ? ELDER_GUARDIAN_ID : GUARDIAN_ID; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java index cbd7ee097..b306a76b6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java @@ -2,14 +2,24 @@ package mineplex.core.disguise.disguises; import java.util.UUID; -import net.minecraft.server.v1_8_R3.EntityHorse; - -import org.bukkit.entity.*; - import com.google.common.base.Optional; -public class DisguiseHorse extends DisguiseAnimal +import net.minecraft.server.v1_8_R3.EntityAgeable; +import net.minecraft.server.v1_8_R3.EntityHorse; + +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Horse; + +public class DisguiseHorse extends DisguiseMutable { + private static final int HORSE_ID = 100; + private static final int DONKEY_ID = 31; + private static final int MULE_ID = 32; + private static final int ZOMBIE_HORSE_ID = 29; + private static final int SKELETON_HORSE_ID = 28; + + private Horse.Variant variant = Horse.Variant.HORSE; + public DisguiseHorse(org.bukkit.entity.Entity entity) { super(EntityType.HORSE, entity); @@ -19,11 +29,25 @@ public class DisguiseHorse extends DisguiseAnimal DataWatcher.a(20, Integer.valueOf(0), EntityHorse.META_VARIANT, 0); DataWatcher.a(21, String.valueOf(""), EntityHorse.META_OWNER, Optional. absent()); DataWatcher.a(22, Integer.valueOf(0), EntityHorse.META_ARMOR, 0); + + DataWatcher.a(12, new Byte((byte)0), EntityAgeable.META_BABY, false); + } + + public boolean isBaby() + { + return DataWatcher.getByte(12) < 0; + } + + public void setBaby() + { + DataWatcher.watch(12, new Byte((byte) ( -1 )), EntityAgeable.META_BABY, true); } public void setType(Horse.Variant horseType) { DataWatcher.watch(19, Byte.valueOf((byte) horseType.ordinal()), EntityHorse.META_TYPE, horseType.ordinal()); + this.variant = horseType; + mutate(); } public Horse.Variant getType() @@ -72,4 +96,23 @@ public class DisguiseHorse extends DisguiseAnimal { DataWatcher.watch(22, Integer.valueOf(i), EntityHorse.META_ARMOR, i); } + + // 1.11 and up require separate entity ids + @Override + protected int getTypeId(boolean separate) + { + if (separate && variant != Horse.Variant.HORSE) + { + switch (variant) + { + case DONKEY: return DONKEY_ID; + case MULE: return MULE_ID; + case UNDEAD_HORSE: return ZOMBIE_HORSE_ID; + case SKELETON_HORSE: return SKELETON_HORSE_ID; + default: return HORSE_ID; + } + } + + return HORSE_ID; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMutable.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMutable.java new file mode 100644 index 000000000..d3ff2216c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseMutable.java @@ -0,0 +1,40 @@ +package mineplex.core.disguise.disguises; + +import java.util.function.Predicate; + +import com.mineplex.ProtocolVersion; + +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; + +/** + * Represents a disguise that can "mutate" from one entity type to another. + */ +public abstract class DisguiseMutable extends DisguiseCreature +{ + public DisguiseMutable(EntityType disguiseType, Entity entity) + { + super(disguiseType, entity); + } + + protected void mutate() + { +// if (!_spawnedIn) +// return; + + Predicate pred = v -> v >= ProtocolVersion.v1_11; + sendToWatchers(pred, this::getDestroyPacket); + sendToWatchers(pred, this::getSpawnPacket); + sendToWatchers(pred, this::getMetadataPacket); + } + + private Packet getDestroyPacket() + { + return new PacketPlayOutEntityDestroy(new int[] { getEntityId() }); + } + + protected abstract int getTypeId(boolean separate); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java index 122490073..34dd47cc0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSkeleton.java @@ -2,11 +2,16 @@ package mineplex.core.disguise.disguises; import net.minecraft.server.v1_8_R3.EntitySkeleton; -import org.bukkit.entity.*; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Skeleton.SkeletonType; -public class DisguiseSkeleton extends DisguiseMonster +public class DisguiseSkeleton extends DisguiseMutable { + private static final int SKELETON_ID = 51; + private static final int WITHER_SKELETON_ID = 5; + + private SkeletonType type = SkeletonType.NORMAL; + public DisguiseSkeleton(org.bukkit.entity.Entity entity) { super(EntityType.SKELETON, entity); @@ -17,15 +22,24 @@ public class DisguiseSkeleton extends DisguiseMonster public void SetSkeletonType(SkeletonType skeletonType) { DataWatcher.watch(13, Byte.valueOf((byte) skeletonType.getId()), EntitySkeleton.META_TYPE, skeletonType.getId()); + this.type = skeletonType; + mutate(); } - public int GetSkeletonType() + public SkeletonType getSkeletonType() { - return DataWatcher.getByte(13); + return type; } protected String getHurtSound() { return "mob.skeleton.hurt"; } + + // 1.11 and up require separate entity ids + @Override + protected int getTypeId(boolean separate) + { + return separate && type == SkeletonType.WITHER ? WITHER_SKELETON_ID : SKELETON_ID; + } } From bfee68007cfb6108ab6ced9e47c4c2e8a928bb24 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Fri, 28 Jul 2017 21:57:07 -0400 Subject: [PATCH 167/183] Fix disguise nametags on 1.10+ --- .../disguise/disguises/DisguiseCreature.java | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java index 65b1f1174..290d321f1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseCreature.java @@ -150,37 +150,21 @@ public abstract class DisguiseCreature extends DisguiseInsentient PacketPlayOutEntityMetadata newMeta = new PacketPlayOutEntityMetadata(); newMeta.a = getEntityId(); - boolean hasArms = false; - List meta = DataWatcher.b(); - List adjusted = new ArrayList<>(); + List meta = MetadataRewriter.rewrite(getTypeId(false), protocol, DataWatcher.c()).objects; - if (meta != null) + for (int i = 0; i < meta.size(); i++) { - // Process the meta while we know the entity id - adjusted = MetadataRewriter.rewrite(getTypeId(false), protocol, meta).objects; - hasArms = meta.stream().anyMatch(obj -> obj.getIndex().a() == 6); - } - - for (int i = 0; i < adjusted.size(); i++) - { - WatchableObject object = adjusted.get(i); + WatchableObject object = meta.get(i); int index = object.getIndex().a(); if (index >= 6) { index--; - adjusted.set(i, new WatchableObject(0, 0, null, + meta.set(i, new WatchableObject(0, 0, null, new DataIndex(index, object.getIndex().b()), object.getValue())); } } - if (!hasArms) - { - WatchableObject arms = new WatchableObject<>(0, 0, null, - new DataIndex<>(5, DataType.BYTE), (byte) 0); - adjusted.add(arms); - } - - newMeta.b = adjusted; + newMeta.b = meta; return newMeta; } From dadbd87f45f85a89e902faeb4549cfc018b3d987 Mon Sep 17 00:00:00 2001 From: Graphica Date: Thu, 27 Jul 2017 18:30:38 -0400 Subject: [PATCH 168/183] Correctly enable/disable chests --- .../core/treasure/gui/BuyChestButton.java | 26 ++++++++++++++++--- .../core/treasure/gui/TreasurePage.java | 14 +++++----- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java index e01e16b44..c10c4d15d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -51,24 +51,42 @@ public class BuyChestButton implements IButton if (_chestType == TreasureType.TRICK_OR_TREAT) { - if (!new File("../../update/files/EnableTrickOrTreat.dat").exists()) + if (!new File("../../update/files/EnableTrickOrTreatChest.dat").exists()) { player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); return; } + if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) + { + player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); + return; + } } if (_chestType == TreasureType.THANKFUL) { - if (!new File("../../update/files/EnableThankful.dat").exists()) + if (!new File("../../update/files/EnableThankfulChest.dat").exists()) { player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); return; } + if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) + { + player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); + return; + } } if (_chestType == TreasureType.GINGERBREAD) { - player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); - return; + if (!new File("../../update/files/EnableGingerbreadChest.dat").exists()) + { + player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); + return; + } + if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) + { + player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); + return; + } } if (_chestType == TreasureType.LOVE_CHEST) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index 154c0f4e7..9abd2b5e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -149,13 +149,13 @@ public class TreasurePage extends ShopPageBase int stpatricksCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.ST_PATRICKS.getItemName()); int springCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.SPRING.getItemName()); - boolean availableChristmas = false; - boolean availableFreedom = true; - boolean availableHaunted = false; - boolean availableTrick = false; - boolean availableThank = false; - boolean availableGingerbread = false; - boolean availableLove = false; + boolean availableChristmas = new File("../../update/files/EnableChristmasChest.dat").exists(); + boolean availableFreedom = new File("../../update/files/EnableFreedomChest.dat").exists(); + boolean availableHaunted = new File("../../update/files/EnableHauntedChest.dat").exists(); + boolean availableTrick = new File("../../update/files/EnableTrickOrTreatChest.dat").exists(); + boolean availableThank = new File("../../update/files/EnableThankfulChest.dat").exists(); + boolean availableGingerbread = new File("../../update/files/EnableGingerbreadChest.dat").exists(); + boolean availableLove = new File("../../update/files/EnableLoveChest.dat").exists(); boolean availableStPatricks = new File("../../update/files/EnableStPatricksChest.dat").exists(); boolean availableSpring = new File("../../update/files/EnableSpringChest.dat").exists(); From 200578df88e939c2cbfcdcda5860a4ffb71c3afd Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 29 Jul 2017 07:38:35 -0400 Subject: [PATCH 169/183] Add new flags to CountryFlag enum --- .../core/common/util/banner/CountryFlag.java | 1056 ++++++++++++++++- 1 file changed, 1006 insertions(+), 50 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java index f49d5040c..b24ef02c3 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java @@ -13,62 +13,1018 @@ import java.util.List; import static org.bukkit.DyeColor.*; import static org.bukkit.block.banner.PatternType.*; +/** + * Banner patterns for country (and related) flags. + */ public enum CountryFlag { - // Vetted - MINEPLEX("Mineplex", "Mineplexian", BLACK, new Pattern(ORANGE, TRIANGLE_TOP), new Pattern(BLACK, TRIANGLES_TOP), - new Pattern(ORANGE, STRIPE_LEFT), new Pattern(ORANGE, STRIPE_RIGHT), new Pattern(BLACK, BORDER), + MINEPLEX("Mineplex", "Mineplex", BLACK, + new Pattern(ORANGE, TRIANGLE_TOP), + new Pattern(BLACK, TRIANGLES_TOP), + new Pattern(ORANGE, STRIPE_LEFT), + new Pattern(ORANGE, STRIPE_RIGHT), + new Pattern(BLACK, BORDER), new Pattern(BLACK, STRIPE_BOTTOM)), - USA("The United States of America", "American", RED, new Pattern(WHITE, STRIPE_SMALL), new Pattern(BLUE, SQUARE_TOP_RIGHT), - new Pattern(BLUE, SQUARE_TOP_RIGHT), new Pattern(BLUE, SQUARE_TOP_RIGHT)), + USA("The United States of America", "American", RED, + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(BLUE, SQUARE_TOP_RIGHT)), - CANADA("Canada", "Canadian", WHITE, new Pattern(RED, CROSS), new Pattern(WHITE, STRIPE_LEFT), new Pattern(RED, STRIPE_MIDDLE), - new Pattern(WHITE, BORDER), new Pattern(RED, STRIPE_TOP), new Pattern(RED, STRIPE_BOTTOM)), + CANADA("Canada", "Canadian", WHITE, + new Pattern(RED, CROSS), + new Pattern(WHITE, STRIPE_LEFT), + new Pattern(RED, STRIPE_MIDDLE), + new Pattern(WHITE, BORDER), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), - // Not Vetted - BRAZIL(DyeColor.GREEN, new Pattern(DyeColor.YELLOW, PatternType.RHOMBUS_MIDDLE), new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)), - UK(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNLEFT), new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNRIGHT), - new Pattern(DyeColor.RED, PatternType.STRAIGHT_CROSS), new Pattern(DyeColor.RED, PatternType.CROSS)), - IRELAND(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.STRIPE_TOP), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_BOTTOM)), - SPAIN(DyeColor.YELLOW, new Pattern(DyeColor.RED, PatternType.STRIPE_LEFT), new Pattern(DyeColor.RED, PatternType.STRIPE_RIGHT)), - JAPAN(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)), - SOUTH_SUDAN(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_LEFT), new Pattern(DyeColor.BLACK, PatternType.STRIPE_RIGHT), - new Pattern(DyeColor.GREEN, PatternType.TRIANGLE_BOTTOM)), - JAMAICA(DyeColor.GREEN, new Pattern(DyeColor.BLACK, PatternType.TRIANGLE_TOP), new Pattern(DyeColor.BLACK, PatternType.TRIANGLES_BOTTOM), - new Pattern(DyeColor.YELLOW, PatternType.CROSS)), - ITALY(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.GREEN, PatternType.STRIPE_BOTTOM)), - SENEGAL(DyeColor.YELLOW, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.GREEN, PatternType.STRIPE_BOTTOM), - new Pattern(DyeColor.GREEN, PatternType.CIRCLE_MIDDLE)), - FRANCE(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM)), - INDIA(DyeColor.WHITE, new Pattern(DyeColor.ORANGE, PatternType.STRIPE_LEFT), new Pattern(DyeColor.GREEN, PatternType.STRIPE_RIGHT), - new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)), - BELGIUM(DyeColor.YELLOW, new Pattern(DyeColor.BLACK, PatternType.STRIPE_BOTTOM), new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)), - ENGLAND(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRAIGHT_CROSS)), - AUSTRIA(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER)), - ARMENIA(DyeColor.RED, new Pattern(DyeColor.BLUE, PatternType.STRIPE_CENTER), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_RIGHT)), - ARGENTINA(DyeColor.LIGHT_BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER), new Pattern(DyeColor.YELLOW, PatternType.CIRCLE_MIDDLE)), - GREECE(DyeColor.LIGHT_BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_SMALL), new Pattern(DyeColor.LIGHT_BLUE, PatternType.SQUARE_BOTTOM_LEFT)), - CZECH_REPUBLIC(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.HALF_VERTICAL_MIRROR), new Pattern(DyeColor.BLUE, PatternType.TRIANGLE_BOTTOM)), - ROMANIA(DyeColor.YELLOW, new Pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM), new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)), - HONDURAS(DyeColor.WHITE, new Pattern(DyeColor.BLUE, PatternType.STRIPE_LEFT), new Pattern(DyeColor.BLUE, PatternType.STRIPE_RIGHT)), - ALGERIA(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.HALF_HORIZONTAL_MIRROR), new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)), - PORTUGAL(DyeColor.RED, new Pattern(DyeColor.GREEN, PatternType.STRIPE_TOP), new Pattern(DyeColor.YELLOW, PatternType.CIRCLE_MIDDLE)), - BAHRAIN(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.TRIANGLES_BOTTOM)), - GERMANY(DyeColor.RED, new Pattern(DyeColor.BLACK, PatternType.STRIPE_LEFT), new Pattern(DyeColor.YELLOW, PatternType.STRIPE_RIGHT)), - GABON(DyeColor.YELLOW, new Pattern(DyeColor.BLUE, PatternType.STRIPE_RIGHT), new Pattern(DyeColor.LIME, PatternType.STRIPE_LEFT)), - SCOTLAND(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.CROSS)), - PERU(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM)), - TANZANIA(DyeColor.LIME, new Pattern(DyeColor.LIGHT_BLUE, PatternType.DIAGONAL_RIGHT), new Pattern(DyeColor.BLACK, PatternType.STRIPE_DOWNLEFT)), - MOROCCO(DyeColor.RED, new Pattern(DyeColor.GREEN, PatternType.CIRCLE_MIDDLE)), - SOLOMON_ISLANDS(DyeColor.GREEN, new Pattern(DyeColor.BLUE, PatternType.DIAGONAL_LEFT_MIRROR), new Pattern(DyeColor.YELLOW, PatternType.STRIPE_DOWNRIGHT)), - SWITZERLAND(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRAIGHT_CROSS), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM), - new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)), - FINLAND(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.SQUARE_BOTTOM_LEFT), new Pattern(DyeColor.WHITE, PatternType.SQUARE_BOTTOM_RIGHT), - new Pattern(DyeColor.WHITE, PatternType.HALF_HORIZONTAL), new Pattern(DyeColor.BLUE, PatternType.STRIPE_CENTER)), - SOUTH_AFRICA(DyeColor.WHITE, new Pattern(DyeColor.BLUE, PatternType.HALF_VERTICAL_MIRROR), new Pattern(DyeColor.RED, PatternType.HALF_VERTICAL), - new Pattern(DyeColor.GREEN, PatternType.STRIPE_CENTER), new Pattern(DyeColor.BLACK, PatternType.TRIANGLE_BOTTOM)), - POLAND(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.HALF_VERTICAL_MIRROR)); + UK("The United Kingdom", "British", BLUE, + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(WHITE, STRIPE_DOWNRIGHT), + new Pattern(WHITE, STRIPE_DOWNRIGHT), + new Pattern(RED, CROSS), + new Pattern(RED, CROSS), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS)), + + GERMANY("Germany", "German", BLACK, + new Pattern(YELLOW, HALF_VERTICAL), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER)), + + BRAZIL("Brazil", "Brazilian", DyeColor.LIME, + new Pattern(YELLOW, RHOMBUS_MIDDLE), + new Pattern(YELLOW, RHOMBUS_MIDDLE), + new Pattern(YELLOW, RHOMBUS_MIDDLE), + new Pattern(BLUE, CIRCLE_MIDDLE), + new Pattern(BLUE, CIRCLE_MIDDLE)), + + FRANCE("France", "French", WHITE, + new Pattern(BLUE, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + + MEXICO("Mexico", "Mexican", WHITE, + new Pattern(GREEN, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(BROWN, CIRCLE_MIDDLE), + new Pattern(BROWN, CIRCLE_MIDDLE), + new Pattern(YELLOW, CIRCLE_MIDDLE)), + + JAPAN("Japan", "Japanese", WHITE, + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + AUSTRALIA("Australia", "Australian", WHITE, + new Pattern(BLUE, CROSS), + new Pattern(BLUE, STRAIGHT_CROSS), + new Pattern(BLUE, CURLY_BORDER), + new Pattern(RED, SQUARE_TOP_RIGHT)), + + NETHERLANDS("The Netherlands", "Dutch", WHITE, + new Pattern(RED, PatternType.STRIPE_RIGHT), + new Pattern(RED, PatternType.STRIPE_RIGHT), + new Pattern(BLUE, PatternType.STRIPE_LEFT), + new Pattern(BLUE, PatternType.STRIPE_LEFT)), + + CHINA("China", "Chinese", RED, + new Pattern(YELLOW, SQUARE_TOP_RIGHT), + new Pattern(RED, PatternType.STRIPE_SMALL), + new Pattern(RED, BORDER), + new Pattern(RED, BRICKS)), + + INDIA("India", "Indian", WHITE, + new Pattern(ORANGE, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_RIGHT), + new Pattern(BLUE, CIRCLE_MIDDLE)), + + INDONESIA("Indonesia", "Indonesian", WHITE, + new Pattern(RED, HALF_VERTICAL_MIRROR)), + + RUSSIA("Germany", "German", WHITE, + new Pattern(RED, HALF_VERTICAL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), + + NIGERIA("Nigeria", "Nigerian", WHITE, + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_BOTTOM)), + + VIETNAM("Vietnam", "Vietnamese", RED, + new Pattern(YELLOW, CROSS), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + SOUTH_KOREA("South Korea", "South Korean", RED, + new Pattern(BLUE, DIAGONAL_LEFT_MIRROR), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, CURLY_BORDER), + new Pattern(WHITE, STRIPE_BOTTOM), + new Pattern(BLACK, TRIANGLES_TOP), + new Pattern(BLACK, TRIANGLES_TOP), + new Pattern(BLACK, TRIANGLES_TOP), + new Pattern(BLACK, TRIANGLES_BOTTOM), + new Pattern(BLACK, TRIANGLES_BOTTOM), + new Pattern(BLACK, TRIANGLES_BOTTOM), + new Pattern(WHITE, TRIANGLES_BOTTOM), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, BORDER)), + + TURKEY("Turkey", "Turkish", RED, + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, FLOWER), + new Pattern(RED, TRIANGLE_BOTTOM)), + + PHILIPPINES("The Philippines", "Philippine", BLUE, + new Pattern(RED, HALF_VERTICAL), + new Pattern(WHITE, TRIANGLE_TOP)), + + ITALY("Italy", "Italian", WHITE, + new Pattern(GREEN, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + SPAIN("Spain", "Spanish", YELLOW, + new Pattern(BROWN, FLOWER), + new Pattern(YELLOW, HALF_HORIZONTAL_MIRROR)), + + HUNGARY("Hungary", "Hungarian", RED, + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER)), + + DENMARK("Denmark", "Danish", WHITE, + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_CENTER)), + + NORWAY("Norway", "Norwegian", BLUE, + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), + + FINLAND("Finland", "Finnish", BLUE, + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, STRIPE_CENTER)), + + ICELAND("Iceland", "Icelandic", RED, + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER)), + + SWEDEN("Sweden", "Swedish", YELLOW, + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(YELLOW, STRIPE_CENTER)), + + SCOTLAND("Scotland", "Scottish", BLUE, + new Pattern(WHITE, CROSS), + new Pattern(WHITE, CROSS)), + + IRELAND("Ireland", "Irish", WHITE, + new Pattern(GREEN, STRIPE_TOP), + new Pattern(ORANGE, STRIPE_BOTTOM)), + + ENGLAND("England", "English", WHITE, + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS)), + + POLAND("Poland", "Polish", WHITE, + new Pattern(RED, HALF_VERTICAL)), + + PORTUGAL("Portugal", "Portuguese", RED, + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(YELLOW, CREEPER), + new Pattern(YELLOW, SKULL), + new Pattern(RED, HALF_HORIZONTAL)), + + SLOVAKIA("Slovakia", "Slovakian", BLUE, + new Pattern(RED, SKULL), + new Pattern(WHITE, BRICKS), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_LEFT)), + + CZECH_REPUBLIC("The Czech Republic", "Czech Republic", WHITE, + new Pattern(RED, HALF_VERTICAL), + new Pattern(BLUE, TRIANGLE_TOP)), + + NEW_ZEALAND("New Zealand", "New Zealand", RED, + new Pattern(BLUE, CROSS), + new Pattern(BLUE, STRAIGHT_CROSS), + new Pattern(BLUE, CURLY_BORDER), + new Pattern(WHITE, SQUARE_TOP_RIGHT)), + + EU("The European Union", "European Union", BLUE, + new Pattern(YELLOW, CROSS), + new Pattern(YELLOW, STRIPE_MIDDLE), + new Pattern(BLUE, BORDER), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, STRIPE_BOTTOM), + new Pattern(BLUE, CIRCLE_MIDDLE)), + + GREECE("Greece", "Greek", BLUE, + new Pattern(BLUE, HALF_VERTICAL), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(BLUE, SQUARE_TOP_RIGHT)), + + BULGARIA("Bulgaria", "Bulgarian", WHITE, + new Pattern(RED, HALF_VERTICAL), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_CENTER)), + + UKRAINE("Ukraine", "Ukrainian", BLUE, + new Pattern(YELLOW, HALF_VERTICAL)), + + TAIWAN("Taiwan", "Taiwanese", BLUE, + new Pattern(WHITE, CROSS), + new Pattern(BLUE, CURLY_BORDER), + new Pattern(BLUE, FLOWER), + new Pattern(BLUE, CIRCLE_MIDDLE), + new Pattern(BLUE, RHOMBUS_MIDDLE), + new Pattern(RED, HALF_VERTICAL), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, HALF_HORIZONTAL_MIRROR)), + + SOUTH_AFRICA("South Africa", "South African", WHITE, + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(YELLOW, TRIANGLE_TOP), + new Pattern(YELLOW, TRIANGLE_TOP), + new Pattern(YELLOW, TRIANGLE_TOP), + new Pattern(BLACK, TRIANGLE_TOP)), + + AUSTRIA("Austria", "Austrian", RED, + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER)), + + SWITZERLAND("Switzerland", "Swiss", RED, + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, BORDER), + new Pattern(RED, BORDER), + new Pattern(RED, BORDER)), + + BELGIUM("Belgium", "Belgian", YELLOW, + new Pattern(BLACK, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + LUXEMBOURG("Luxembourg", "Luxembourg", RED, + new Pattern(LIGHT_BLUE, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER)), + + AZERBAIJAN("Azerbaijan", "Azerbaijani", RED, + new Pattern(WHITE, FLOWER), + new Pattern(WHITE, FLOWER), + new Pattern(WHITE, FLOWER), + new Pattern(RED, DIAGONAL_LEFT_MIRROR), + new Pattern(RED, DIAGONAL_RIGHT_MIRROR), + new Pattern(LIGHT_BLUE, STRIPE_RIGHT), + new Pattern(GREEN, STRIPE_LEFT)), + + BELARUS("Belarus", "Belarusian", RED, + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(WHITE, TRIANGLES_TOP)), + + PAKISTAN("Pakistan", "Pakistani", GREEN, + new Pattern(WHITE, FLOWER), + new Pattern(GREEN, TRIANGLE_BOTTOM), + new Pattern(GREEN, TRIANGLE_BOTTOM), + new Pattern(GREEN, TRIANGLE_BOTTOM), + new Pattern(GREEN, BORDER), + new Pattern(GREEN, BORDER), + new Pattern(GREEN, BORDER), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(WHITE, STRIPE_TOP)), + + BANGLADESH("Bangladesh", "Bangladeshi", GREEN, + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + WALES("Wales", "Welsh", WHITE, + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(RED, MOJANG), + new Pattern(RED, MOJANG), + new Pattern(RED, SKULL)), + + ARGENTINA("Argentina", "Argentinian", WHITE, + new Pattern(LIGHT_BLUE, STRIPE_LEFT), + new Pattern(LIGHT_BLUE, STRIPE_RIGHT), + new Pattern(YELLOW, CIRCLE_MIDDLE)), + + VENEZUELA("Venezuela", "Venezuelan", BLUE, + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(BLUE, STRAIGHT_CROSS), + new Pattern(YELLOW, STRIPE_RIGHT), + new Pattern(YELLOW, STRIPE_RIGHT), + new Pattern(YELLOW, STRIPE_RIGHT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_LEFT)), + + ESTONIA("Estonia", "Estonian", BLUE, + new Pattern(WHITE, HALF_VERTICAL), + new Pattern(BLACK, STRIPE_CENTER), + new Pattern(BLACK, STRIPE_CENTER), + new Pattern(BLACK, STRIPE_CENTER)), + + IRAN("Iran", "Iranian", WHITE, + new Pattern(GREEN, STRIPE_RIGHT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + AFGHANISTAN("Afghanistan", "Afghanistani", RED, + new Pattern(BLACK, STRIPE_TOP), + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + TAJIKISTAN("Tajikistan", "Tajikistani", WHITE, + new Pattern(YELLOW, CROSS), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_BOTTOM), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT)), + + FAROE_ISLANDS("The Faroe Islands", "Faroese", RED, + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER)), + + ISLE_OF_MAN("Isle of Man", "Isle of Man", RED, + new Pattern(WHITE, SKULL), + new Pattern(WHITE, FLOWER), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT)), + + ISRAEL("Israel", "Israeli", WHITE, + new Pattern(BLUE, STRIPE_LEFT), + new Pattern(BLUE, STRIPE_RIGHT), + new Pattern(BLUE, FLOWER)), + + CROATIA("Croatia", "Croatian", RED, + new Pattern(WHITE, FLOWER), + new Pattern(BLUE, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(RED, CIRCLE_MIDDLE)), + + BOSNIA_AND_HERZEGOVINA("Bosnia and Herzegovina", "Bosnia and Herzegovinian", BLUE, + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(BLUE, BRICKS), + new Pattern(YELLOW, DIAGONAL_RIGHT), + new Pattern(BLUE, STRIPE_BOTTOM)), + + ARMENIA("Armenia", "Armenian", RED, + new Pattern(ORANGE, HALF_VERTICAL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), + + GEORGIA("Georgia", "Georgian", WHITE, + new Pattern(RED, TRIANGLES_TOP), + new Pattern(RED, TRIANGLES_TOP), + new Pattern(RED, TRIANGLES_TOP), + new Pattern(RED, TRIANGLES_BOTTOM), + new Pattern(RED, TRIANGLES_BOTTOM), + new Pattern(RED, TRIANGLES_BOTTOM), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS)), + + LITHUANIA("Lithuania", "Lithuanian", YELLOW, + new Pattern(RED, HALF_VERTICAL), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_CENTER)), + + LATVIA("Latvia", "Latvian", RED, + new Pattern(WHITE, STRIPE_CENTER)), + + MACEDONIA("Macedonia", "Macedonian", RED, + new Pattern(YELLOW, CROSS), + new Pattern(YELLOW, STRAIGHT_CROSS), + new Pattern(RED, RHOMBUS_MIDDLE), + new Pattern(YELLOW, CIRCLE_MIDDLE)), + + MONGOLIA("Mongolia", "Mongolian", BLUE, + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(YELLOW, TRIANGLES_TOP)), + + BRUNEI("Brunei", "Bruneian", YELLOW, + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(BLACK, CROSS), + new Pattern(YELLOW, DIAGONAL_LEFT), + new Pattern(YELLOW, SQUARE_BOTTOM_RIGHT), + new Pattern(RED, CIRCLE_MIDDLE)), + + MALAYSIA("Malaysia", "Malaysian", RED, + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(YELLOW, TRIANGLES_TOP)), + + SINGAPORE("Singapore", "Singaporean", RED, + new Pattern(WHITE, FLOWER), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, STRIPE_CENTER), + new Pattern(WHITE, HALF_VERTICAL)), + + MALTA("Malta", "Maltese", WHITE, + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(GRAY, SQUARE_TOP_RIGHT), + new Pattern(WHITE, SQUARE_TOP_RIGHT)), + + SURINAME("Suriname", "Surinamese", WHITE, + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(YELLOW, FLOWER), + new Pattern(YELLOW, SKULL), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_RIGHT)), + + ROMANIA("Romania", "Romanian", YELLOW, + new Pattern(BLUE, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + MOLDOVA("Moldova", "Moldovan", YELLOW, + new Pattern(BROWN, CIRCLE_MIDDLE), + new Pattern(YELLOW, STRIPE_LEFT), + new Pattern(YELLOW, STRIPE_RIGHT), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + KAZAKHSTAN("Kazakhstan", "Kazakhstani", LIGHT_BLUE, + new Pattern(YELLOW, CREEPER), + new Pattern(LIGHT_BLUE, HALF_VERTICAL), + new Pattern(YELLOW, TRIANGLES_TOP)), + + KYRGYZSTAN("Kyrgyzstan", "Kyrgyzstani", RED, + new Pattern(YELLOW, CIRCLE_MIDDLE)), + + SLOVENIA("Slovenia", "Slovenian", WHITE, + new Pattern(BLUE, CROSS), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, HALF_VERTICAL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), + + SOMALIA("Somalia", "Somalian", LIGHT_BLUE, + new Pattern(WHITE, CROSS), + new Pattern(LIGHT_BLUE, STRIPE_TOP), + new Pattern(LIGHT_BLUE, STRIPE_BOTTOM)), + + ALBANIA("Albania", "Albanian", RED, + new Pattern(BLACK, FLOWER), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, BORDER), + new Pattern(RED, STRIPE_SMALL), + new Pattern(BLACK, CIRCLE_MIDDLE)), + + SERBIA("Serbia", "Serbian", RED, + new Pattern(WHITE, HALF_VERTICAL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE)), + + MONTENEGRO("Montenegro", "Montenegrin", RED, + new Pattern(YELLOW, FLOWER), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(YELLOW, BORDER)), + + THAILAND("Thailand", "Thai", WHITE, + new Pattern(RED, STRIPE_SMALL), + new Pattern(RED, STRIPE_SMALL), + new Pattern(RED, STRIPE_SMALL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), + + MACAU("Macau", "Macau", GREEN, + new Pattern(YELLOW, BRICKS), + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(WHITE, FLOWER), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_RIGHT), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_BOTTOM)), + + COLOMBIA("Colombia", "Colombian", RED, + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(YELLOW, HALF_VERTICAL_MIRROR)), + + CHILE("Chile", "Chilean", BLUE, + new Pattern(WHITE, CROSS), + new Pattern(BLUE, TRIANGLES_TOP), + new Pattern(BLUE, RHOMBUS_MIDDLE), + new Pattern(BLUE, BORDER), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(RED, HALF_VERTICAL)), + + PERU("Peru", "Peruvian", WHITE, + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(GREEN, CIRCLE_MIDDLE)), + + ECUADOR("Ecuador", "Ecuadorian", RED, + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(YELLOW, HALF_VERTICAL_MIRROR), + new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE)), + + DOMINICAN_REPUBLIC("Dominican Republic", "Dominican", WHITE, + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(BLUE, SQUARE_BOTTOM_LEFT), + new Pattern(RED, SQUARE_TOP_LEFT), + new Pattern(RED, SQUARE_BOTTOM_RIGHT), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(GREEN, CIRCLE_MIDDLE)), + + PANAMA("Panama", "Panamanian", WHITE, + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(RED, SQUARE_BOTTOM_LEFT), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, CURLY_BORDER), + new Pattern(RED, SQUARE_BOTTOM_RIGHT), + new Pattern(BLUE, SQUARE_TOP_LEFT)), + + COSTA_RICA("Costa Rica", "Costa Rican", WHITE, + new Pattern(BLUE, STRIPE_SMALL), + new Pattern(BLUE, STRIPE_SMALL), + new Pattern(BLUE, STRIPE_SMALL), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER)), + + URUGUAY("Uruguay", "Uruguayan", WHITE, + new Pattern(BLUE, STRIPE_SMALL), + new Pattern(YELLOW, SQUARE_TOP_RIGHT)), + + PUERTO_RICO("Puerto Rico", "Puerto Rican", RED, + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(BLUE, TRIANGLE_TOP)), + + BOLIVIA("Bolivia", "Bolivian", RED, + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE), + new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE), + new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + CUBA("Cuba", "Cuban", BLUE, + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(RED, TRIANGLE_TOP)), + + GUATEMALA("Guatemala", "Guatemalan", WHITE, + new Pattern(LIGHT_BLUE, STRIPE_TOP), + new Pattern(LIGHT_BLUE, STRIPE_BOTTOM), + new Pattern(GREEN, CIRCLE_MIDDLE)), + + PARAGUAY("Paraguay", "Paraguayan", RED, + new Pattern(BLUE, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + EL_SALVADOR("El Salvador", "El Salvadorian", BLUE, + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(GREEN, CIRCLE_MIDDLE)), + + JAMAICA("Jamaica", "Jamaican", GREEN, + new Pattern(YELLOW, STRIPE_DOWNLEFT), + new Pattern(YELLOW, STRIPE_DOWNLEFT), + new Pattern(YELLOW, STRIPE_DOWNLEFT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(BLACK, TRIANGLE_TOP), + new Pattern(BLACK, TRIANGLE_BOTTOM)), + + HONG_KONG("Hong Kong", "Hong Kongese", RED, + new Pattern(WHITE, FLOWER)), + + UZBEKISTAN("Uzbekistan", "Uzbekistani", RED, + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(LIGHT_BLUE, STRIPE_RIGHT)), + + SRI_LANKA("Sri Lanka", "Sri Lankan", RED, + new Pattern(YELLOW, STRIPE_MIDDLE), + new Pattern(YELLOW, CREEPER), + new Pattern(ORANGE, HALF_HORIZONTAL), + new Pattern(LIME, STRIPE_TOP), + new Pattern(YELLOW, BORDER)), + + SAUDI_ARABIA("Saudi Arabia", "Saudi Arabian", GREEN, + new Pattern(WHITE, SKULL), + new Pattern(WHITE, MOJANG), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, BORDER)), + + EGYPT("Egypt", "Egyptian", WHITE, + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(BLACK, STRIPE_LEFT)), + + UAE("United Arab Emirates", "United Arab Emirates", GREEN, + new Pattern(BLACK, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP)), + + MOROCCO("Morocco", "Moroccan", RED, + new Pattern(GREEN, CROSS), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + QATAR("Qatar", "Qatari", RED, + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP)), + + KENYA("Kenya", "Kenyan", WHITE, + new Pattern(BLACK, STRIPE_RIGHT), + new Pattern(RED, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(WHITE, FLOWER), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + OMAN("Oman", "Omani", WHITE, + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_TOP), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(RED, TRIANGLES_TOP), + new Pattern(RED, SQUARE_TOP_LEFT)), + + KUWAIT("Kuwait", "Kuwaiti", GREEN, + new Pattern(RED, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(BLACK, TRIANGLE_TOP), + new Pattern(WHITE, CIRCLE_MIDDLE)), + + ALGERIA("Algeria", "Algerian", GREEN, + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(WHITE, TRIANGLE_BOTTOM)), + + SYRIA("Syria", "Syrian", WHITE, + new Pattern(GREEN, FLOWER), + new Pattern(GREEN, FLOWER), + new Pattern(GREEN, FLOWER), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(BLACK, STRIPE_LEFT), + new Pattern(BLACK, STRIPE_LEFT), + new Pattern(BLACK, STRIPE_LEFT)), + + LEBANON("Lebanon", "Lebanese", WHITE, + new Pattern(GREEN, FLOWER), + new Pattern(GREEN, FLOWER), + new Pattern(GREEN, FLOWER), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(GREEN, CIRCLE_MIDDLE)), + + TUNISIA("Tunisia", "Tunisian", RED, + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, FLOWER), + new Pattern(RED, TRIANGLE_BOTTOM)), + + SUDAN("Sudan", "Sudanese", RED, + new Pattern(BLACK, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(GREEN, TRIANGLE_TOP)), + + SOUTH_SUDAN("South Sudan", "South Sudanese", WHITE, + new Pattern(BLACK, STRIPE_RIGHT), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(RED, STRIPE_CENTER), + new Pattern(BLUE, TRIANGLE_TOP)), + + LIBYA("Libya", "Libyan", BLACK, + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(BLACK, FLOWER), + new Pattern(BLACK, TRIANGLE_TOP), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(GREEN, STRIPE_LEFT)), + + ANGOLA("Angola", "Angolan", RED, + new Pattern(BLACK, HALF_VERTICAL), + new Pattern(YELLOW, FLOWER), + new Pattern(BLACK, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT)), + + BAHRAIN("Bahrain", "Bahraini", RED, + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP)), + + CYPRUS("Cyprus", "Cyprus", WHITE, + new Pattern(ORANGE, FLOWER), + new Pattern(ORANGE, FLOWER), + new Pattern(ORANGE, FLOWER), + new Pattern(ORANGE, CIRCLE_MIDDLE), + new Pattern(WHITE, DIAGONAL_LEFT_MIRROR), + new Pattern(WHITE, CURLY_BORDER), + new Pattern(WHITE, CURLY_BORDER), + new Pattern(WHITE, CURLY_BORDER)), + + ETHIOPIA("Ethiopia", "Ethiopian", GREEN, + new Pattern(RED, HALF_VERTICAL), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(BLUE, CIRCLE_MIDDLE), + new Pattern(BLUE, CIRCLE_MIDDLE), + new Pattern(BLUE, CIRCLE_MIDDLE)), + + SENEGAL("Senegal", "Senegalese", YELLOW, + new Pattern(GREEN, CROSS), + new Pattern(YELLOW, STRIPE_BOTTOM), + new Pattern(YELLOW, STRIPE_BOTTOM), + new Pattern(YELLOW, STRIPE_TOP), + new Pattern(YELLOW, STRIPE_TOP), + new Pattern(YELLOW, STRIPE_TOP), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + HONDURAS("Honduras", "Honduran", WHITE, + new Pattern(BLUE, FLOWER), + new Pattern(WHITE, STRIPE_LEFT), + new Pattern(WHITE, STRIPE_LEFT), + new Pattern(WHITE, STRIPE_LEFT), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(BLUE, STRIPE_LEFT), + new Pattern(BLUE, STRIPE_RIGHT)), + + GABON("Gabon", "Gabonese", GREEN, + new Pattern(BLUE, HALF_VERTICAL), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER)), + + TANZANIA("Tanzania", "Tanzanian", LIGHT_BLUE, + new Pattern(LIME, DIAGONAL_RIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT)), + + SOLOMON_ISLANDS("Solomon Islands", "Solomon Islands", BLUE, + new Pattern(WHITE, BRICKS), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, BORDER), + new Pattern(BLUE, CURLY_BORDER), + new Pattern(BLUE, RHOMBUS_MIDDLE), + new Pattern(BLUE, HALF_VERTICAL), + new Pattern(GREEN, DIAGONAL_LEFT_MIRROR), + new Pattern(BLACK, STRIPE_DOWNRIGHT), + new Pattern(BLACK, STRIPE_DOWNRIGHT)), + + UGANDA("Uganda", "Ugandan", RED, + new Pattern(BLACK, STRIPE_LEFT), + new Pattern(BLACK, STRIPE_RIGHT), + new Pattern(YELLOW, STRIPE_SMALL), + new Pattern(RED, BORDER)), + + YEMEN("Yemen", "Yemeni", RED, + new Pattern(BLACK, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER)), + + GHANA("Ghana", "Ghanaian", YELLOW, + new Pattern(BLACK, CROSS), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(GREEN, STRIPE_LEFT)), + + IRAQ("Iraq", "Iraqi", WHITE, + new Pattern(GREEN, FLOWER), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(BLACK, STRIPE_LEFT)), + + NEPAL("Nepal", "Nepali", RED, + new Pattern(BLUE, BORDER), + new Pattern(BLUE, BORDER), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, FLOWER)), + + CAMEROON("Cameroon", "Cameroonian", RED, + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(YELLOW, STRIPE_BOTTOM)), + + IVORY_COAST("Ivory Coast", "Ivory Coast", WHITE, + new Pattern(ORANGE, STRIPE_TOP), + new Pattern(ORANGE, STRIPE_TOP), + new Pattern(ORANGE, STRIPE_TOP), + new Pattern(LIME, STRIPE_BOTTOM), + new Pattern(LIME, STRIPE_BOTTOM), + new Pattern(LIME, STRIPE_BOTTOM)), + + JORDAN("Jordan", "Jordanian", BLACK, + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(RED, TRIANGLE_TOP), + new Pattern(RED, TRIANGLE_TOP), + new Pattern(RED, TRIANGLE_TOP)), + + ZAMBIA("Zambia", "Zambian", LIME, + new Pattern(YELLOW, FLOWER), + new Pattern(RED, STRIPE_MIDDLE), + new Pattern(BLACK, HALF_HORIZONTAL_MIRROR), + new Pattern(ORANGE, STRIPE_BOTTOM)), + + CAMBODIA("Cambodia", "Cambodian", RED, + new Pattern(WHITE, FLOWER), + new Pattern(BLUE, STRIPE_LEFT), + new Pattern(BLUE, STRIPE_RIGHT)), + + ZIMBABWE("Zimbabwe", "Zimbabwean", RED, + new Pattern(BLACK, STRAIGHT_CROSS), + new Pattern(YELLOW, STRIPE_LEFT), + new Pattern(YELLOW, STRIPE_RIGHT), + new Pattern(GREEN, BORDER), + new Pattern(WHITE, TRIANGLE_TOP)), + + MOZAMBIQUE("Mozambique", "Mozambique", WHITE, + new Pattern(CYAN, STRIPE_RIGHT), + new Pattern(YELLOW, STRIPE_LEFT), + new Pattern(BLACK, STRIPE_CENTER), + new Pattern(RED, TRIANGLE_TOP)), + + RWANDA("Rwanda", "Rwandan", LIGHT_BLUE, + new Pattern(YELLOW, TRIANGLES_TOP), + new Pattern(LIGHT_BLUE, BORDER), + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER)), + + BERMUDA("Bermuda", "Bermudian", BLUE, + new Pattern(WHITE, BRICKS), + new Pattern(RED, HALF_VERTICAL), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, STRIPE_MIDDLE)), + + BHUTAN("Bhutan", "Bhutanese", YELLOW, + new Pattern(ORANGE, DIAGONAL_LEFT_MIRROR), + new Pattern(WHITE, RHOMBUS_MIDDLE)), + + ; private final String _country; private final String _adjective; From d24b8a229ca989ad6d9e74d60fce8ba6b09f842f Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 29 Jul 2017 07:54:21 -0400 Subject: [PATCH 170/183] Alphabetize CountryFlag data --- .../core/common/util/banner/CountryFlag.java | 1699 ++++++++--------- 1 file changed, 847 insertions(+), 852 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java index b24ef02c3..ff6be3674 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java @@ -18,6 +18,7 @@ import static org.bukkit.block.banner.PatternType.*; */ public enum CountryFlag { + MINEPLEX("Mineplex", "Mineplex", BLACK, new Pattern(ORANGE, TRIANGLE_TOP), new Pattern(BLACK, TRIANGLES_TOP), @@ -26,64 +27,41 @@ public enum CountryFlag new Pattern(BLACK, BORDER), new Pattern(BLACK, STRIPE_BOTTOM)), - USA("The United States of America", "American", RED, - new Pattern(WHITE, STRIPE_SMALL), - new Pattern(BLUE, SQUARE_TOP_RIGHT), - new Pattern(BLUE, SQUARE_TOP_RIGHT), - new Pattern(BLUE, SQUARE_TOP_RIGHT)), + AFGHANISTAN("Afghanistan", "Afghanistani", RED, + new Pattern(BLACK, STRIPE_TOP), + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), - CANADA("Canada", "Canadian", WHITE, - new Pattern(RED, CROSS), - new Pattern(WHITE, STRIPE_LEFT), - new Pattern(RED, STRIPE_MIDDLE), - new Pattern(WHITE, BORDER), + ALBANIA("Albania", "Albanian", RED, + new Pattern(BLACK, FLOWER), new Pattern(RED, STRIPE_TOP), - new Pattern(RED, STRIPE_BOTTOM)), - - UK("The United Kingdom", "British", BLUE, - new Pattern(WHITE, STRIPE_DOWNLEFT), - new Pattern(WHITE, STRIPE_DOWNLEFT), - new Pattern(WHITE, STRIPE_DOWNRIGHT), - new Pattern(WHITE, STRIPE_DOWNRIGHT), - new Pattern(RED, CROSS), - new Pattern(RED, CROSS), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_MIDDLE), - new Pattern(WHITE, STRIPE_MIDDLE), - new Pattern(RED, STRAIGHT_CROSS), - new Pattern(RED, STRAIGHT_CROSS), - new Pattern(RED, STRAIGHT_CROSS)), - - GERMANY("Germany", "German", BLACK, - new Pattern(YELLOW, HALF_VERTICAL), - new Pattern(RED, STRIPE_CENTER), - new Pattern(RED, STRIPE_CENTER), - new Pattern(RED, STRIPE_CENTER)), - - BRAZIL("Brazil", "Brazilian", DyeColor.LIME, - new Pattern(YELLOW, RHOMBUS_MIDDLE), - new Pattern(YELLOW, RHOMBUS_MIDDLE), - new Pattern(YELLOW, RHOMBUS_MIDDLE), - new Pattern(BLUE, CIRCLE_MIDDLE), - new Pattern(BLUE, CIRCLE_MIDDLE)), - - FRANCE("France", "French", WHITE, - new Pattern(BLUE, STRIPE_TOP), - new Pattern(RED, STRIPE_BOTTOM)), - - - MEXICO("Mexico", "Mexican", WHITE, - new Pattern(GREEN, STRIPE_TOP), new Pattern(RED, STRIPE_BOTTOM), - new Pattern(BROWN, CIRCLE_MIDDLE), - new Pattern(BROWN, CIRCLE_MIDDLE), + new Pattern(RED, BORDER), + new Pattern(RED, STRIPE_SMALL), + new Pattern(BLACK, CIRCLE_MIDDLE)), + + ALGERIA("Algeria", "Algerian", GREEN, + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(WHITE, TRIANGLE_BOTTOM)), + + ANGOLA("Angola", "Angolan", RED, + new Pattern(BLACK, HALF_VERTICAL), + new Pattern(YELLOW, FLOWER), + new Pattern(BLACK, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT)), + + ARGENTINA("Argentina", "Argentinian", WHITE, + new Pattern(LIGHT_BLUE, STRIPE_LEFT), + new Pattern(LIGHT_BLUE, STRIPE_RIGHT), new Pattern(YELLOW, CIRCLE_MIDDLE)), - JAPAN("Japan", "Japanese", WHITE, - new Pattern(RED, CIRCLE_MIDDLE), - new Pattern(RED, CIRCLE_MIDDLE), - new Pattern(RED, CIRCLE_MIDDLE)), + ARMENIA("Armenia", "Armenian", RED, + new Pattern(ORANGE, HALF_VERTICAL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), AUSTRALIA("Australia", "Australian", WHITE, new Pattern(BLUE, CROSS), @@ -91,239 +69,11 @@ public enum CountryFlag new Pattern(BLUE, CURLY_BORDER), new Pattern(RED, SQUARE_TOP_RIGHT)), - NETHERLANDS("The Netherlands", "Dutch", WHITE, - new Pattern(RED, PatternType.STRIPE_RIGHT), - new Pattern(RED, PatternType.STRIPE_RIGHT), - new Pattern(BLUE, PatternType.STRIPE_LEFT), - new Pattern(BLUE, PatternType.STRIPE_LEFT)), - - CHINA("China", "Chinese", RED, - new Pattern(YELLOW, SQUARE_TOP_RIGHT), - new Pattern(RED, PatternType.STRIPE_SMALL), - new Pattern(RED, BORDER), - new Pattern(RED, BRICKS)), - - INDIA("India", "Indian", WHITE, - new Pattern(ORANGE, STRIPE_LEFT), - new Pattern(GREEN, STRIPE_RIGHT), - new Pattern(BLUE, CIRCLE_MIDDLE)), - - INDONESIA("Indonesia", "Indonesian", WHITE, - new Pattern(RED, HALF_VERTICAL_MIRROR)), - - RUSSIA("Germany", "German", WHITE, - new Pattern(RED, HALF_VERTICAL), - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_CENTER)), - - NIGERIA("Nigeria", "Nigerian", WHITE, - new Pattern(GREEN, STRIPE_TOP), - new Pattern(GREEN, STRIPE_BOTTOM)), - - VIETNAM("Vietnam", "Vietnamese", RED, - new Pattern(YELLOW, CROSS), - new Pattern(RED, STRIPE_TOP), - new Pattern(RED, STRIPE_BOTTOM)), - - SOUTH_KOREA("South Korea", "South Korean", RED, - new Pattern(BLUE, DIAGONAL_LEFT_MIRROR), - new Pattern(WHITE, STRIPE_TOP), - new Pattern(WHITE, CURLY_BORDER), - new Pattern(WHITE, STRIPE_BOTTOM), - new Pattern(BLACK, TRIANGLES_TOP), - new Pattern(BLACK, TRIANGLES_TOP), - new Pattern(BLACK, TRIANGLES_TOP), - new Pattern(BLACK, TRIANGLES_BOTTOM), - new Pattern(BLACK, TRIANGLES_BOTTOM), - new Pattern(BLACK, TRIANGLES_BOTTOM), - new Pattern(WHITE, TRIANGLES_BOTTOM), - new Pattern(WHITE, TRIANGLES_TOP), - new Pattern(WHITE, BORDER), - new Pattern(WHITE, BORDER)), - - TURKEY("Turkey", "Turkish", RED, - new Pattern(WHITE, CIRCLE_MIDDLE), - new Pattern(RED, FLOWER), - new Pattern(RED, TRIANGLE_BOTTOM)), - - PHILIPPINES("The Philippines", "Philippine", BLUE, - new Pattern(RED, HALF_VERTICAL), - new Pattern(WHITE, TRIANGLE_TOP)), - - ITALY("Italy", "Italian", WHITE, - new Pattern(GREEN, STRIPE_TOP), - new Pattern(RED, STRIPE_BOTTOM)), - - SPAIN("Spain", "Spanish", YELLOW, - new Pattern(BROWN, FLOWER), - new Pattern(YELLOW, HALF_HORIZONTAL_MIRROR)), - - HUNGARY("Hungary", "Hungarian", RED, - new Pattern(GREEN, HALF_VERTICAL), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER)), - - DENMARK("Denmark", "Danish", WHITE, - new Pattern(RED, STRIPE_TOP), - new Pattern(RED, HALF_HORIZONTAL_MIRROR), - new Pattern(WHITE, STRIPE_CENTER)), - - NORWAY("Norway", "Norwegian", BLUE, - new Pattern(WHITE, STRIPE_TOP), - new Pattern(WHITE, STRIPE_TOP), - new Pattern(WHITE, STRIPE_TOP), - new Pattern(WHITE, STRIPE_TOP), - new Pattern(RED, STRIPE_TOP), - new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), - new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), - new Pattern(RED, HALF_HORIZONTAL_MIRROR), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_CENTER)), - - FINLAND("Finland", "Finnish", BLUE, - new Pattern(WHITE, STRIPE_TOP), - new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), - new Pattern(BLUE, STRIPE_CENTER)), - - ICELAND("Iceland", "Icelandic", RED, - new Pattern(WHITE, STRIPE_TOP), - new Pattern(WHITE, STRIPE_TOP), - new Pattern(WHITE, STRIPE_TOP), - new Pattern(WHITE, STRIPE_TOP), - new Pattern(BLUE, STRIPE_TOP), - new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), - new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), - new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(RED, STRIPE_CENTER)), - - SWEDEN("Sweden", "Swedish", YELLOW, - new Pattern(BLUE, STRIPE_TOP), - new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), - new Pattern(YELLOW, STRIPE_CENTER)), - - SCOTLAND("Scotland", "Scottish", BLUE, - new Pattern(WHITE, CROSS), - new Pattern(WHITE, CROSS)), - - IRELAND("Ireland", "Irish", WHITE, - new Pattern(GREEN, STRIPE_TOP), - new Pattern(ORANGE, STRIPE_BOTTOM)), - - ENGLAND("England", "English", WHITE, - new Pattern(RED, STRAIGHT_CROSS), - new Pattern(RED, STRAIGHT_CROSS), - new Pattern(RED, STRAIGHT_CROSS)), - - POLAND("Poland", "Polish", WHITE, - new Pattern(RED, HALF_VERTICAL)), - - PORTUGAL("Portugal", "Portuguese", RED, - new Pattern(GREEN, STRIPE_BOTTOM), - new Pattern(YELLOW, CREEPER), - new Pattern(YELLOW, SKULL), - new Pattern(RED, HALF_HORIZONTAL)), - - SLOVAKIA("Slovakia", "Slovakian", BLUE, - new Pattern(RED, SKULL), - new Pattern(WHITE, BRICKS), - new Pattern(BLUE, STRIPE_TOP), - new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), - new Pattern(WHITE, STRIPE_RIGHT), - new Pattern(WHITE, STRIPE_RIGHT), - new Pattern(WHITE, STRIPE_RIGHT), - new Pattern(RED, STRIPE_LEFT), - new Pattern(RED, STRIPE_LEFT), - new Pattern(RED, STRIPE_LEFT)), - - CZECH_REPUBLIC("The Czech Republic", "Czech Republic", WHITE, - new Pattern(RED, HALF_VERTICAL), - new Pattern(BLUE, TRIANGLE_TOP)), - - NEW_ZEALAND("New Zealand", "New Zealand", RED, - new Pattern(BLUE, CROSS), - new Pattern(BLUE, STRAIGHT_CROSS), - new Pattern(BLUE, CURLY_BORDER), - new Pattern(WHITE, SQUARE_TOP_RIGHT)), - - EU("The European Union", "European Union", BLUE, - new Pattern(YELLOW, CROSS), - new Pattern(YELLOW, STRIPE_MIDDLE), - new Pattern(BLUE, BORDER), - new Pattern(BLUE, STRIPE_TOP), - new Pattern(BLUE, STRIPE_BOTTOM), - new Pattern(BLUE, CIRCLE_MIDDLE)), - - GREECE("Greece", "Greek", BLUE, - new Pattern(BLUE, HALF_VERTICAL), - new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), - new Pattern(WHITE, STRIPE_SMALL), - new Pattern(BLUE, SQUARE_TOP_RIGHT)), - - BULGARIA("Bulgaria", "Bulgarian", WHITE, - new Pattern(RED, HALF_VERTICAL), - new Pattern(GREEN, STRIPE_CENTER), - new Pattern(GREEN, STRIPE_CENTER), - new Pattern(GREEN, STRIPE_CENTER)), - - UKRAINE("Ukraine", "Ukrainian", BLUE, - new Pattern(YELLOW, HALF_VERTICAL)), - - TAIWAN("Taiwan", "Taiwanese", BLUE, - new Pattern(WHITE, CROSS), - new Pattern(BLUE, CURLY_BORDER), - new Pattern(BLUE, FLOWER), - new Pattern(BLUE, CIRCLE_MIDDLE), - new Pattern(BLUE, RHOMBUS_MIDDLE), - new Pattern(RED, HALF_VERTICAL), - new Pattern(RED, HALF_HORIZONTAL_MIRROR), - new Pattern(RED, HALF_HORIZONTAL_MIRROR), - new Pattern(RED, HALF_HORIZONTAL_MIRROR)), - - SOUTH_AFRICA("South Africa", "South African", WHITE, - new Pattern(GREEN, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_LEFT), - new Pattern(RED, STRIPE_RIGHT), - new Pattern(YELLOW, TRIANGLE_TOP), - new Pattern(YELLOW, TRIANGLE_TOP), - new Pattern(YELLOW, TRIANGLE_TOP), - new Pattern(BLACK, TRIANGLE_TOP)), - AUSTRIA("Austria", "Austrian", RED, new Pattern(WHITE, STRIPE_CENTER), new Pattern(WHITE, STRIPE_CENTER), new Pattern(WHITE, STRIPE_CENTER)), - SWITZERLAND("Switzerland", "Swiss", RED, - new Pattern(WHITE, STRAIGHT_CROSS), - new Pattern(WHITE, STRAIGHT_CROSS), - new Pattern(WHITE, STRAIGHT_CROSS), - new Pattern(RED, STRIPE_BOTTOM), - new Pattern(RED, STRIPE_BOTTOM), - new Pattern(RED, STRIPE_BOTTOM), - new Pattern(RED, STRIPE_TOP), - new Pattern(RED, STRIPE_TOP), - new Pattern(RED, STRIPE_TOP), - new Pattern(RED, BORDER), - new Pattern(RED, BORDER), - new Pattern(RED, BORDER)), - - BELGIUM("Belgium", "Belgian", YELLOW, - new Pattern(BLACK, STRIPE_TOP), - new Pattern(RED, STRIPE_BOTTOM)), - - LUXEMBOURG("Luxembourg", "Luxembourg", RED, - new Pattern(LIGHT_BLUE, HALF_VERTICAL), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER)), - AZERBAIJAN("Azerbaijan", "Azerbaijani", RED, new Pattern(WHITE, FLOWER), new Pattern(WHITE, FLOWER), @@ -333,53 +83,186 @@ public enum CountryFlag new Pattern(LIGHT_BLUE, STRIPE_RIGHT), new Pattern(GREEN, STRIPE_LEFT)), - BELARUS("Belarus", "Belarusian", RED, - new Pattern(GREEN, STRIPE_LEFT), - new Pattern(GREEN, STRIPE_LEFT), - new Pattern(GREEN, STRIPE_LEFT), + BAHRAIN("Bahrain", "Bahraini", RED, + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP), new Pattern(WHITE, TRIANGLES_TOP)), - PAKISTAN("Pakistan", "Pakistani", GREEN, - new Pattern(WHITE, FLOWER), - new Pattern(GREEN, TRIANGLE_BOTTOM), - new Pattern(GREEN, TRIANGLE_BOTTOM), - new Pattern(GREEN, TRIANGLE_BOTTOM), - new Pattern(GREEN, BORDER), - new Pattern(GREEN, BORDER), - new Pattern(GREEN, BORDER), - new Pattern(GREEN, STRIPE_TOP), - new Pattern(GREEN, STRIPE_TOP), - new Pattern(GREEN, STRIPE_TOP), - new Pattern(GREEN, STRIPE_BOTTOM), - new Pattern(GREEN, STRIPE_BOTTOM), - new Pattern(GREEN, STRIPE_BOTTOM), - new Pattern(WHITE, STRIPE_TOP)), - BANGLADESH("Bangladesh", "Bangladeshi", GREEN, new Pattern(RED, CIRCLE_MIDDLE), new Pattern(RED, CIRCLE_MIDDLE), new Pattern(RED, CIRCLE_MIDDLE)), - WALES("Wales", "Welsh", WHITE, + BELARUS("Belarus", "Belarusian", RED, + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(WHITE, TRIANGLES_TOP)), + + BELGIUM("Belgium", "Belgian", YELLOW, + new Pattern(BLACK, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + BERMUDA("Bermuda", "Bermudian", BLUE, + new Pattern(WHITE, BRICKS), + new Pattern(RED, HALF_VERTICAL), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, STRIPE_MIDDLE)), + + BHUTAN("Bhutan", "Bhutanese", YELLOW, + new Pattern(ORANGE, DIAGONAL_LEFT_MIRROR), + new Pattern(WHITE, RHOMBUS_MIDDLE)), + + BOLIVIA("Bolivia", "Bolivian", RED, new Pattern(GREEN, HALF_VERTICAL), - new Pattern(RED, MOJANG), - new Pattern(RED, MOJANG), - new Pattern(RED, SKULL)), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE), + new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE), + new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), - ARGENTINA("Argentina", "Argentinian", WHITE, - new Pattern(LIGHT_BLUE, STRIPE_LEFT), - new Pattern(LIGHT_BLUE, STRIPE_RIGHT), - new Pattern(YELLOW, CIRCLE_MIDDLE)), + BOSNIA_AND_HERZEGOVINA("Bosnia and Herzegovina", "Bosnia and Herzegovinian", BLUE, + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(BLUE, BRICKS), + new Pattern(YELLOW, DIAGONAL_RIGHT), + new Pattern(BLUE, STRIPE_BOTTOM)), - VENEZUELA("Venezuela", "Venezuelan", BLUE, - new Pattern(WHITE, CIRCLE_MIDDLE), - new Pattern(BLUE, STRAIGHT_CROSS), - new Pattern(YELLOW, STRIPE_RIGHT), - new Pattern(YELLOW, STRIPE_RIGHT), - new Pattern(YELLOW, STRIPE_RIGHT), - new Pattern(RED, STRIPE_LEFT), - new Pattern(RED, STRIPE_LEFT), - new Pattern(RED, STRIPE_LEFT)), + BRAZIL("Brazil", "Brazilian", LIME, + new Pattern(YELLOW, RHOMBUS_MIDDLE), + new Pattern(YELLOW, RHOMBUS_MIDDLE), + new Pattern(YELLOW, RHOMBUS_MIDDLE), + new Pattern(BLUE, CIRCLE_MIDDLE), + new Pattern(BLUE, CIRCLE_MIDDLE)), + + BRUNEI("Brunei", "Bruneian", YELLOW, + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(BLACK, CROSS), + new Pattern(YELLOW, DIAGONAL_LEFT), + new Pattern(YELLOW, SQUARE_BOTTOM_RIGHT), + new Pattern(RED, CIRCLE_MIDDLE)), + + BULGARIA("Bulgaria", "Bulgarian", WHITE, + new Pattern(RED, HALF_VERTICAL), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_CENTER)), + + CAMBODIA("Cambodia", "Cambodian", RED, + new Pattern(WHITE, FLOWER), + new Pattern(BLUE, STRIPE_LEFT), + new Pattern(BLUE, STRIPE_RIGHT)), + + CAMEROON("Cameroon", "Cameroonian", RED, + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(YELLOW, STRIPE_BOTTOM)), + + CANADA("Canada", "Canadian", WHITE, + new Pattern(RED, CROSS), + new Pattern(WHITE, STRIPE_LEFT), + new Pattern(RED, STRIPE_MIDDLE), + new Pattern(WHITE, BORDER), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + CHILE("Chile", "Chilean", BLUE, + new Pattern(WHITE, CROSS), + new Pattern(BLUE, TRIANGLES_TOP), + new Pattern(BLUE, RHOMBUS_MIDDLE), + new Pattern(BLUE, BORDER), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(RED, HALF_VERTICAL)), + + CHINA("China", "Chinese", RED, + new Pattern(YELLOW, SQUARE_TOP_RIGHT), + new Pattern(RED, PatternType.STRIPE_SMALL), + new Pattern(RED, BORDER), + new Pattern(RED, BRICKS)), + + COLOMBIA("Colombia", "Colombian", RED, + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(YELLOW, HALF_VERTICAL_MIRROR)), + + COSTA_RICA("Costa Rica", "Costa Rican", WHITE, + new Pattern(BLUE, STRIPE_SMALL), + new Pattern(BLUE, STRIPE_SMALL), + new Pattern(BLUE, STRIPE_SMALL), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER)), + + CROATIA("Croatia", "Croatian", RED, + new Pattern(WHITE, FLOWER), + new Pattern(BLUE, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(RED, CIRCLE_MIDDLE)), + + CUBA("Cuba", "Cuban", BLUE, + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(RED, TRIANGLE_TOP)), + + CYPRUS("Cyprus", "Cyprus", WHITE, + new Pattern(ORANGE, FLOWER), + new Pattern(ORANGE, FLOWER), + new Pattern(ORANGE, FLOWER), + new Pattern(ORANGE, CIRCLE_MIDDLE), + new Pattern(WHITE, DIAGONAL_LEFT_MIRROR), + new Pattern(WHITE, CURLY_BORDER), + new Pattern(WHITE, CURLY_BORDER), + new Pattern(WHITE, CURLY_BORDER)), + + CZECH_REPUBLIC("The Czech Republic", "Czech Republic", WHITE, + new Pattern(RED, HALF_VERTICAL), + new Pattern(BLUE, TRIANGLE_TOP)), + + DENMARK("Denmark", "Danish", WHITE, + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_CENTER)), + + DOMINICAN_REPUBLIC("Dominican Republic", "Dominican", WHITE, + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(BLUE, SQUARE_BOTTOM_LEFT), + new Pattern(RED, SQUARE_TOP_LEFT), + new Pattern(RED, SQUARE_BOTTOM_RIGHT), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(GREEN, CIRCLE_MIDDLE)), + + ECUADOR("Ecuador", "Ecuadorian", RED, + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(YELLOW, HALF_VERTICAL_MIRROR), + new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE)), + + EGYPT("Egypt", "Egyptian", WHITE, + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(BLACK, STRIPE_LEFT)), + + EL_SALVADOR("El Salvador", "El Salvadorian", BLUE, + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(GREEN, CIRCLE_MIDDLE)), + + ENGLAND("England", "English", WHITE, + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS)), ESTONIA("Estonia", "Estonian", BLUE, new Pattern(WHITE, HALF_VERTICAL), @@ -387,26 +270,22 @@ public enum CountryFlag new Pattern(BLACK, STRIPE_CENTER), new Pattern(BLACK, STRIPE_CENTER)), - IRAN("Iran", "Iranian", WHITE, - new Pattern(GREEN, STRIPE_RIGHT), - new Pattern(RED, STRIPE_LEFT), - new Pattern(BLACK, CIRCLE_MIDDLE), - new Pattern(BLACK, CIRCLE_MIDDLE), - new Pattern(BLACK, CIRCLE_MIDDLE), - new Pattern(RED, CIRCLE_MIDDLE)), + ETHIOPIA("Ethiopia", "Ethiopian", GREEN, + new Pattern(RED, HALF_VERTICAL), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(BLUE, CIRCLE_MIDDLE), + new Pattern(BLUE, CIRCLE_MIDDLE), + new Pattern(BLUE, CIRCLE_MIDDLE)), - AFGHANISTAN("Afghanistan", "Afghanistani", RED, - new Pattern(BLACK, STRIPE_TOP), - new Pattern(GREEN, STRIPE_BOTTOM), - new Pattern(WHITE, CIRCLE_MIDDLE), - new Pattern(RED, CIRCLE_MIDDLE)), - - TAJIKISTAN("Tajikistan", "Tajikistani", WHITE, + EU("The European Union", "European Union", BLUE, new Pattern(YELLOW, CROSS), - new Pattern(WHITE, STRIPE_TOP), - new Pattern(WHITE, STRIPE_BOTTOM), - new Pattern(GREEN, STRIPE_LEFT), - new Pattern(RED, STRIPE_RIGHT)), + new Pattern(YELLOW, STRIPE_MIDDLE), + new Pattern(BLUE, BORDER), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, STRIPE_BOTTOM), + new Pattern(BLUE, CIRCLE_MIDDLE)), FAROE_ISLANDS("The Faroe Islands", "Faroese", RED, new Pattern(BLUE, STRIPE_TOP), @@ -425,39 +304,21 @@ public enum CountryFlag new Pattern(BLUE, STRIPE_CENTER), new Pattern(RED, STRIPE_CENTER)), - ISLE_OF_MAN("Isle of Man", "Isle of Man", RED, - new Pattern(WHITE, SKULL), - new Pattern(WHITE, FLOWER), - new Pattern(RED, STRIPE_TOP), - new Pattern(RED, STRIPE_BOTTOM), - new Pattern(RED, STRIPE_LEFT), - new Pattern(RED, STRIPE_RIGHT)), - - ISRAEL("Israel", "Israeli", WHITE, - new Pattern(BLUE, STRIPE_LEFT), - new Pattern(BLUE, STRIPE_RIGHT), - new Pattern(BLUE, FLOWER)), - - CROATIA("Croatia", "Croatian", RED, - new Pattern(WHITE, FLOWER), - new Pattern(BLUE, HALF_VERTICAL), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(RED, CIRCLE_MIDDLE)), - - BOSNIA_AND_HERZEGOVINA("Bosnia and Herzegovina", "Bosnia and Herzegovinian", BLUE, - new Pattern(WHITE, STRIPE_DOWNLEFT), - new Pattern(BLUE, BRICKS), - new Pattern(YELLOW, DIAGONAL_RIGHT), - new Pattern(BLUE, STRIPE_BOTTOM)), - - ARMENIA("Armenia", "Armenian", RED, - new Pattern(ORANGE, HALF_VERTICAL), - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_CENTER), + FINLAND("Finland", "Finnish", BLUE, + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), new Pattern(BLUE, STRIPE_CENTER)), + FRANCE("France", "French", WHITE, + new Pattern(BLUE, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + GABON("Gabon", "Gabonese", GREEN, + new Pattern(BLUE, HALF_VERTICAL), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER), + new Pattern(YELLOW, STRIPE_CENTER)), + GEORGIA("Georgia", "Georgian", WHITE, new Pattern(RED, TRIANGLES_TOP), new Pattern(RED, TRIANGLES_TOP), @@ -476,423 +337,28 @@ public enum CountryFlag new Pattern(RED, STRAIGHT_CROSS), new Pattern(RED, STRAIGHT_CROSS)), - LITHUANIA("Lithuania", "Lithuanian", YELLOW, - new Pattern(RED, HALF_VERTICAL), - new Pattern(GREEN, STRIPE_CENTER), - new Pattern(GREEN, STRIPE_CENTER), - new Pattern(GREEN, STRIPE_CENTER)), - - LATVIA("Latvia", "Latvian", RED, - new Pattern(WHITE, STRIPE_CENTER)), - - MACEDONIA("Macedonia", "Macedonian", RED, - new Pattern(YELLOW, CROSS), - new Pattern(YELLOW, STRAIGHT_CROSS), - new Pattern(RED, RHOMBUS_MIDDLE), - new Pattern(YELLOW, CIRCLE_MIDDLE)), - - MONGOLIA("Mongolia", "Mongolian", BLUE, - new Pattern(RED, STRIPE_TOP), - new Pattern(RED, STRIPE_BOTTOM), - new Pattern(YELLOW, TRIANGLES_TOP)), - - BRUNEI("Brunei", "Bruneian", YELLOW, - new Pattern(WHITE, STRIPE_DOWNLEFT), - new Pattern(WHITE, STRIPE_DOWNLEFT), - new Pattern(WHITE, STRIPE_DOWNLEFT), - new Pattern(BLACK, CROSS), - new Pattern(YELLOW, DIAGONAL_LEFT), - new Pattern(YELLOW, SQUARE_BOTTOM_RIGHT), - new Pattern(RED, CIRCLE_MIDDLE)), - - MALAYSIA("Malaysia", "Malaysian", RED, - new Pattern(WHITE, STRIPE_SMALL), - new Pattern(BLUE, SQUARE_TOP_RIGHT), - new Pattern(YELLOW, TRIANGLES_TOP)), - - SINGAPORE("Singapore", "Singaporean", RED, - new Pattern(WHITE, FLOWER), - new Pattern(RED, HALF_HORIZONTAL_MIRROR), - new Pattern(RED, STRIPE_CENTER), - new Pattern(WHITE, HALF_VERTICAL)), - - MALTA("Malta", "Maltese", WHITE, - new Pattern(RED, HALF_HORIZONTAL_MIRROR), - new Pattern(GRAY, SQUARE_TOP_RIGHT), - new Pattern(WHITE, SQUARE_TOP_RIGHT)), - - SURINAME("Suriname", "Surinamese", WHITE, - new Pattern(RED, STRAIGHT_CROSS), - new Pattern(YELLOW, FLOWER), - new Pattern(YELLOW, SKULL), - new Pattern(GREEN, STRIPE_LEFT), - new Pattern(GREEN, STRIPE_RIGHT)), - - ROMANIA("Romania", "Romanian", YELLOW, - new Pattern(BLUE, STRIPE_TOP), - new Pattern(RED, STRIPE_BOTTOM)), - - MOLDOVA("Moldova", "Moldovan", YELLOW, - new Pattern(BROWN, CIRCLE_MIDDLE), - new Pattern(YELLOW, STRIPE_LEFT), - new Pattern(YELLOW, STRIPE_RIGHT), - new Pattern(BLUE, STRIPE_TOP), - new Pattern(RED, STRIPE_BOTTOM)), - - KAZAKHSTAN("Kazakhstan", "Kazakhstani", LIGHT_BLUE, - new Pattern(YELLOW, CREEPER), - new Pattern(LIGHT_BLUE, HALF_VERTICAL), - new Pattern(YELLOW, TRIANGLES_TOP)), - - KYRGYZSTAN("Kyrgyzstan", "Kyrgyzstani", RED, - new Pattern(YELLOW, CIRCLE_MIDDLE)), - - SLOVENIA("Slovenia", "Slovenian", WHITE, - new Pattern(BLUE, CROSS), - new Pattern(WHITE, TRIANGLES_TOP), - new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), - new Pattern(RED, HALF_VERTICAL), - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_CENTER)), - - SOMALIA("Somalia", "Somalian", LIGHT_BLUE, - new Pattern(WHITE, CROSS), - new Pattern(LIGHT_BLUE, STRIPE_TOP), - new Pattern(LIGHT_BLUE, STRIPE_BOTTOM)), - - ALBANIA("Albania", "Albanian", RED, - new Pattern(BLACK, FLOWER), - new Pattern(RED, STRIPE_TOP), - new Pattern(RED, STRIPE_BOTTOM), - new Pattern(RED, BORDER), - new Pattern(RED, STRIPE_SMALL), - new Pattern(BLACK, CIRCLE_MIDDLE)), - - SERBIA("Serbia", "Serbian", RED, - new Pattern(WHITE, HALF_VERTICAL), - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(RED, CIRCLE_MIDDLE), - new Pattern(RED, CIRCLE_MIDDLE), - new Pattern(RED, CIRCLE_MIDDLE), - new Pattern(WHITE, CIRCLE_MIDDLE)), - - MONTENEGRO("Montenegro", "Montenegrin", RED, - new Pattern(YELLOW, FLOWER), - new Pattern(RED, STRIPE_TOP), - new Pattern(RED, STRIPE_BOTTOM), - new Pattern(RED, STRIPE_LEFT), - new Pattern(RED, STRIPE_RIGHT), - new Pattern(YELLOW, BORDER)), - - THAILAND("Thailand", "Thai", WHITE, - new Pattern(RED, STRIPE_SMALL), - new Pattern(RED, STRIPE_SMALL), - new Pattern(RED, STRIPE_SMALL), - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_CENTER)), - - MACAU("Macau", "Macau", GREEN, - new Pattern(YELLOW, BRICKS), - new Pattern(GREEN, HALF_VERTICAL), - new Pattern(WHITE, FLOWER), - new Pattern(GREEN, STRIPE_LEFT), - new Pattern(GREEN, STRIPE_RIGHT), - new Pattern(GREEN, STRIPE_TOP), - new Pattern(GREEN, STRIPE_BOTTOM)), - - COLOMBIA("Colombia", "Colombian", RED, - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(YELLOW, HALF_VERTICAL_MIRROR)), - - CHILE("Chile", "Chilean", BLUE, - new Pattern(WHITE, CROSS), - new Pattern(BLUE, TRIANGLES_TOP), - new Pattern(BLUE, RHOMBUS_MIDDLE), - new Pattern(BLUE, BORDER), - new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), - new Pattern(WHITE, STRIPE_MIDDLE), - new Pattern(RED, HALF_VERTICAL)), - - PERU("Peru", "Peruvian", WHITE, - new Pattern(RED, STRIPE_TOP), - new Pattern(RED, STRIPE_BOTTOM), - new Pattern(YELLOW, CIRCLE_MIDDLE), - new Pattern(YELLOW, CIRCLE_MIDDLE), - new Pattern(YELLOW, CIRCLE_MIDDLE), - new Pattern(GREEN, CIRCLE_MIDDLE)), - - ECUADOR("Ecuador", "Ecuadorian", RED, - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(BLUE, STRIPE_CENTER), - new Pattern(YELLOW, HALF_VERTICAL_MIRROR), - new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE)), - - DOMINICAN_REPUBLIC("Dominican Republic", "Dominican", WHITE, - new Pattern(BLUE, SQUARE_TOP_RIGHT), - new Pattern(BLUE, SQUARE_BOTTOM_LEFT), - new Pattern(RED, SQUARE_TOP_LEFT), - new Pattern(RED, SQUARE_BOTTOM_RIGHT), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(GREEN, CIRCLE_MIDDLE)), - - PANAMA("Panama", "Panamanian", WHITE, - new Pattern(BLUE, SQUARE_TOP_RIGHT), - new Pattern(RED, SQUARE_BOTTOM_LEFT), - new Pattern(WHITE, BORDER), - new Pattern(WHITE, BORDER), - new Pattern(WHITE, BORDER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, CURLY_BORDER), - new Pattern(RED, SQUARE_BOTTOM_RIGHT), - new Pattern(BLUE, SQUARE_TOP_LEFT)), - - COSTA_RICA("Costa Rica", "Costa Rican", WHITE, - new Pattern(BLUE, STRIPE_SMALL), - new Pattern(BLUE, STRIPE_SMALL), - new Pattern(BLUE, STRIPE_SMALL), + GERMANY("Germany", "German", BLACK, + new Pattern(YELLOW, HALF_VERTICAL), new Pattern(RED, STRIPE_CENTER), new Pattern(RED, STRIPE_CENTER), new Pattern(RED, STRIPE_CENTER)), - URUGUAY("Uruguay", "Uruguayan", WHITE, - new Pattern(BLUE, STRIPE_SMALL), - new Pattern(YELLOW, SQUARE_TOP_RIGHT)), + GHANA("Ghana", "Ghanaian", YELLOW, + new Pattern(BLACK, CROSS), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(GREEN, STRIPE_LEFT)), - PUERTO_RICO("Puerto Rico", "Puerto Rican", RED, + GREECE("Greece", "Greek", BLUE, + new Pattern(BLUE, HALF_VERTICAL), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), new Pattern(WHITE, STRIPE_SMALL), - new Pattern(WHITE, STRIPE_SMALL), - new Pattern(WHITE, STRIPE_SMALL), - new Pattern(BLUE, TRIANGLE_TOP)), - - BOLIVIA("Bolivia", "Bolivian", RED, - new Pattern(GREEN, HALF_VERTICAL), - new Pattern(YELLOW, STRIPE_CENTER), - new Pattern(YELLOW, STRIPE_CENTER), - new Pattern(YELLOW, STRIPE_CENTER), - new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE), - new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE), - new Pattern(LIGHT_BLUE, CIRCLE_MIDDLE), - new Pattern(RED, CIRCLE_MIDDLE)), - - CUBA("Cuba", "Cuban", BLUE, - new Pattern(WHITE, STRIPE_SMALL), - new Pattern(WHITE, STRIPE_SMALL), - new Pattern(WHITE, STRIPE_SMALL), - new Pattern(RED, TRIANGLE_TOP)), + new Pattern(BLUE, SQUARE_TOP_RIGHT)), GUATEMALA("Guatemala", "Guatemalan", WHITE, new Pattern(LIGHT_BLUE, STRIPE_TOP), new Pattern(LIGHT_BLUE, STRIPE_BOTTOM), new Pattern(GREEN, CIRCLE_MIDDLE)), - PARAGUAY("Paraguay", "Paraguayan", RED, - new Pattern(BLUE, HALF_VERTICAL), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, CIRCLE_MIDDLE), - new Pattern(WHITE, CIRCLE_MIDDLE), - new Pattern(WHITE, CIRCLE_MIDDLE), - new Pattern(RED, CIRCLE_MIDDLE)), - - EL_SALVADOR("El Salvador", "El Salvadorian", BLUE, - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(GREEN, CIRCLE_MIDDLE)), - - JAMAICA("Jamaica", "Jamaican", GREEN, - new Pattern(YELLOW, STRIPE_DOWNLEFT), - new Pattern(YELLOW, STRIPE_DOWNLEFT), - new Pattern(YELLOW, STRIPE_DOWNLEFT), - new Pattern(YELLOW, STRIPE_DOWNRIGHT), - new Pattern(YELLOW, STRIPE_DOWNRIGHT), - new Pattern(YELLOW, STRIPE_DOWNRIGHT), - new Pattern(BLACK, TRIANGLE_TOP), - new Pattern(BLACK, TRIANGLE_BOTTOM)), - - HONG_KONG("Hong Kong", "Hong Kongese", RED, - new Pattern(WHITE, FLOWER)), - - UZBEKISTAN("Uzbekistan", "Uzbekistani", RED, - new Pattern(GREEN, STRIPE_LEFT), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(LIGHT_BLUE, STRIPE_RIGHT)), - - SRI_LANKA("Sri Lanka", "Sri Lankan", RED, - new Pattern(YELLOW, STRIPE_MIDDLE), - new Pattern(YELLOW, CREEPER), - new Pattern(ORANGE, HALF_HORIZONTAL), - new Pattern(LIME, STRIPE_TOP), - new Pattern(YELLOW, BORDER)), - - SAUDI_ARABIA("Saudi Arabia", "Saudi Arabian", GREEN, - new Pattern(WHITE, SKULL), - new Pattern(WHITE, MOJANG), - new Pattern(GREEN, STRIPE_LEFT), - new Pattern(GREEN, STRIPE_CENTER), - new Pattern(GREEN, BORDER)), - - EGYPT("Egypt", "Egyptian", WHITE, - new Pattern(YELLOW, CIRCLE_MIDDLE), - new Pattern(RED, STRIPE_RIGHT), - new Pattern(BLACK, STRIPE_LEFT)), - - UAE("United Arab Emirates", "United Arab Emirates", GREEN, - new Pattern(BLACK, HALF_VERTICAL), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(RED, STRIPE_TOP), - new Pattern(RED, STRIPE_TOP), - new Pattern(RED, STRIPE_TOP)), - - MOROCCO("Morocco", "Moroccan", RED, - new Pattern(GREEN, CROSS), - new Pattern(RED, STRIPE_TOP), - new Pattern(RED, STRIPE_BOTTOM)), - - QATAR("Qatar", "Qatari", RED, - new Pattern(WHITE, TRIANGLES_TOP), - new Pattern(WHITE, TRIANGLES_TOP), - new Pattern(WHITE, TRIANGLES_TOP)), - - KENYA("Kenya", "Kenyan", WHITE, - new Pattern(BLACK, STRIPE_RIGHT), - new Pattern(RED, STRIPE_CENTER), - new Pattern(GREEN, STRIPE_LEFT), - new Pattern(WHITE, FLOWER), - new Pattern(BLACK, CIRCLE_MIDDLE), - new Pattern(BLACK, CIRCLE_MIDDLE), - new Pattern(BLACK, CIRCLE_MIDDLE), - new Pattern(RED, CIRCLE_MIDDLE)), - - OMAN("Oman", "Omani", WHITE, - new Pattern(GREEN, HALF_VERTICAL), - new Pattern(RED, STRIPE_CENTER), - new Pattern(RED, STRIPE_CENTER), - new Pattern(RED, STRIPE_CENTER), - new Pattern(RED, STRIPE_TOP), - new Pattern(WHITE, TRIANGLES_TOP), - new Pattern(WHITE, TRIANGLES_TOP), - new Pattern(WHITE, TRIANGLES_TOP), - new Pattern(RED, TRIANGLES_TOP), - new Pattern(RED, SQUARE_TOP_LEFT)), - - KUWAIT("Kuwait", "Kuwaiti", GREEN, - new Pattern(RED, HALF_VERTICAL), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(BLACK, TRIANGLE_TOP), - new Pattern(WHITE, CIRCLE_MIDDLE)), - - ALGERIA("Algeria", "Algerian", GREEN, - new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), - new Pattern(RED, CIRCLE_MIDDLE), - new Pattern(WHITE, TRIANGLE_BOTTOM)), - - SYRIA("Syria", "Syrian", WHITE, - new Pattern(GREEN, FLOWER), - new Pattern(GREEN, FLOWER), - new Pattern(GREEN, FLOWER), - new Pattern(WHITE, STRIPE_MIDDLE), - new Pattern(WHITE, STRIPE_MIDDLE), - new Pattern(WHITE, STRIPE_MIDDLE), - new Pattern(RED, STRIPE_RIGHT), - new Pattern(RED, STRIPE_RIGHT), - new Pattern(RED, STRIPE_RIGHT), - new Pattern(BLACK, STRIPE_LEFT), - new Pattern(BLACK, STRIPE_LEFT), - new Pattern(BLACK, STRIPE_LEFT)), - - LEBANON("Lebanon", "Lebanese", WHITE, - new Pattern(GREEN, FLOWER), - new Pattern(GREEN, FLOWER), - new Pattern(GREEN, FLOWER), - new Pattern(WHITE, STRIPE_MIDDLE), - new Pattern(WHITE, STRIPE_MIDDLE), - new Pattern(WHITE, STRIPE_MIDDLE), - new Pattern(RED, STRIPE_LEFT), - new Pattern(RED, STRIPE_RIGHT), - new Pattern(GREEN, CIRCLE_MIDDLE)), - - TUNISIA("Tunisia", "Tunisian", RED, - new Pattern(WHITE, CIRCLE_MIDDLE), - new Pattern(RED, FLOWER), - new Pattern(RED, TRIANGLE_BOTTOM)), - - SUDAN("Sudan", "Sudanese", RED, - new Pattern(BLACK, HALF_VERTICAL), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(GREEN, TRIANGLE_TOP)), - - SOUTH_SUDAN("South Sudan", "South Sudanese", WHITE, - new Pattern(BLACK, STRIPE_RIGHT), - new Pattern(GREEN, STRIPE_LEFT), - new Pattern(RED, STRIPE_CENTER), - new Pattern(BLUE, TRIANGLE_TOP)), - - LIBYA("Libya", "Libyan", BLACK, - new Pattern(WHITE, CIRCLE_MIDDLE), - new Pattern(BLACK, FLOWER), - new Pattern(BLACK, TRIANGLE_TOP), - new Pattern(RED, STRIPE_RIGHT), - new Pattern(GREEN, STRIPE_LEFT)), - - ANGOLA("Angola", "Angolan", RED, - new Pattern(BLACK, HALF_VERTICAL), - new Pattern(YELLOW, FLOWER), - new Pattern(BLACK, STRIPE_LEFT), - new Pattern(RED, STRIPE_RIGHT)), - - BAHRAIN("Bahrain", "Bahraini", RED, - new Pattern(WHITE, TRIANGLES_TOP), - new Pattern(WHITE, TRIANGLES_TOP), - new Pattern(WHITE, TRIANGLES_TOP)), - - CYPRUS("Cyprus", "Cyprus", WHITE, - new Pattern(ORANGE, FLOWER), - new Pattern(ORANGE, FLOWER), - new Pattern(ORANGE, FLOWER), - new Pattern(ORANGE, CIRCLE_MIDDLE), - new Pattern(WHITE, DIAGONAL_LEFT_MIRROR), - new Pattern(WHITE, CURLY_BORDER), - new Pattern(WHITE, CURLY_BORDER), - new Pattern(WHITE, CURLY_BORDER)), - - ETHIOPIA("Ethiopia", "Ethiopian", GREEN, - new Pattern(RED, HALF_VERTICAL), - new Pattern(YELLOW, STRIPE_CENTER), - new Pattern(YELLOW, STRIPE_CENTER), - new Pattern(YELLOW, STRIPE_CENTER), - new Pattern(BLUE, CIRCLE_MIDDLE), - new Pattern(BLUE, CIRCLE_MIDDLE), - new Pattern(BLUE, CIRCLE_MIDDLE)), - - SENEGAL("Senegal", "Senegalese", YELLOW, - new Pattern(GREEN, CROSS), - new Pattern(YELLOW, STRIPE_BOTTOM), - new Pattern(YELLOW, STRIPE_BOTTOM), - new Pattern(YELLOW, STRIPE_TOP), - new Pattern(YELLOW, STRIPE_TOP), - new Pattern(YELLOW, STRIPE_TOP), - new Pattern(GREEN, STRIPE_TOP), - new Pattern(RED, STRIPE_BOTTOM)), - HONDURAS("Honduras", "Honduran", WHITE, new Pattern(BLUE, FLOWER), new Pattern(WHITE, STRIPE_LEFT), @@ -907,17 +373,421 @@ public enum CountryFlag new Pattern(BLUE, STRIPE_LEFT), new Pattern(BLUE, STRIPE_RIGHT)), - GABON("Gabon", "Gabonese", GREEN, + HONG_KONG("Hong Kong", "Hong Kongese", RED, + new Pattern(WHITE, FLOWER)), + + HUNGARY("Hungary", "Hungarian", RED, + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER)), + + ICELAND("Iceland", "Icelandic", RED, + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER)), + + INDIA("India", "Indian", WHITE, + new Pattern(ORANGE, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_RIGHT), + new Pattern(BLUE, CIRCLE_MIDDLE)), + + INDONESIA("Indonesia", "Indonesian", WHITE, + new Pattern(RED, HALF_VERTICAL_MIRROR)), + + IRAN("Iran", "Iranian", WHITE, + new Pattern(GREEN, STRIPE_RIGHT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + IRAQ("Iraq", "Iraqi", WHITE, + new Pattern(GREEN, FLOWER), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(BLACK, STRIPE_LEFT)), + + IRELAND("Ireland", "Irish", WHITE, + new Pattern(GREEN, STRIPE_TOP), + new Pattern(ORANGE, STRIPE_BOTTOM)), + + ISLE_OF_MAN("Isle of Man", "Isle of Man", RED, + new Pattern(WHITE, SKULL), + new Pattern(WHITE, FLOWER), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT)), + + ISRAEL("Israel", "Israeli", WHITE, + new Pattern(BLUE, STRIPE_LEFT), + new Pattern(BLUE, STRIPE_RIGHT), + new Pattern(BLUE, FLOWER)), + + ITALY("Italy", "Italian", WHITE, + new Pattern(GREEN, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + IVORY_COAST("Ivory Coast", "Ivory Coast", WHITE, + new Pattern(ORANGE, STRIPE_TOP), + new Pattern(ORANGE, STRIPE_TOP), + new Pattern(ORANGE, STRIPE_TOP), + new Pattern(LIME, STRIPE_BOTTOM), + new Pattern(LIME, STRIPE_BOTTOM), + new Pattern(LIME, STRIPE_BOTTOM)), + + JAMAICA("Jamaica", "Jamaican", GREEN, + new Pattern(YELLOW, STRIPE_DOWNLEFT), + new Pattern(YELLOW, STRIPE_DOWNLEFT), + new Pattern(YELLOW, STRIPE_DOWNLEFT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(BLACK, TRIANGLE_TOP), + new Pattern(BLACK, TRIANGLE_BOTTOM)), + + JAPAN("Japan", "Japanese", WHITE, + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + JORDAN("Jordan", "Jordanian", BLACK, + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(RED, TRIANGLE_TOP), + new Pattern(RED, TRIANGLE_TOP), + new Pattern(RED, TRIANGLE_TOP)), + + KAZAKHSTAN("Kazakhstan", "Kazakhstani", LIGHT_BLUE, + new Pattern(YELLOW, CREEPER), + new Pattern(LIGHT_BLUE, HALF_VERTICAL), + new Pattern(YELLOW, TRIANGLES_TOP)), + + KENYA("Kenya", "Kenyan", WHITE, + new Pattern(BLACK, STRIPE_RIGHT), + new Pattern(RED, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(WHITE, FLOWER), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(BLACK, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + KUWAIT("Kuwait", "Kuwaiti", GREEN, + new Pattern(RED, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(BLACK, TRIANGLE_TOP), + new Pattern(WHITE, CIRCLE_MIDDLE)), + + KYRGYZSTAN("Kyrgyzstan", "Kyrgyzstani", RED, + new Pattern(YELLOW, CIRCLE_MIDDLE)), + + LATVIA("Latvia", "Latvian", RED, + new Pattern(WHITE, STRIPE_CENTER)), + + LEBANON("Lebanon", "Lebanese", WHITE, + new Pattern(GREEN, FLOWER), + new Pattern(GREEN, FLOWER), + new Pattern(GREEN, FLOWER), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(GREEN, CIRCLE_MIDDLE)), + + LIBYA("Libya", "Libyan", BLACK, + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(BLACK, FLOWER), + new Pattern(BLACK, TRIANGLE_TOP), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(GREEN, STRIPE_LEFT)), + + LITHUANIA("Lithuania", "Lithuanian", YELLOW, + new Pattern(RED, HALF_VERTICAL), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, STRIPE_CENTER)), + + LUXEMBOURG("Luxembourg", "Luxembourg", RED, + new Pattern(LIGHT_BLUE, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER)), + + MACAU("Macau", "Macau", GREEN, + new Pattern(YELLOW, BRICKS), + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(WHITE, FLOWER), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_RIGHT), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_BOTTOM)), + + MACEDONIA("Macedonia", "Macedonian", RED, + new Pattern(YELLOW, CROSS), + new Pattern(YELLOW, STRAIGHT_CROSS), + new Pattern(RED, RHOMBUS_MIDDLE), + new Pattern(YELLOW, CIRCLE_MIDDLE)), + + MALAYSIA("Malaysia", "Malaysian", RED, + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(YELLOW, TRIANGLES_TOP)), + + MALTA("Malta", "Maltese", WHITE, + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(GRAY, SQUARE_TOP_RIGHT), + new Pattern(WHITE, SQUARE_TOP_RIGHT)), + + MEXICO("Mexico", "Mexican", WHITE, + new Pattern(GREEN, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(BROWN, CIRCLE_MIDDLE), + new Pattern(BROWN, CIRCLE_MIDDLE), + new Pattern(YELLOW, CIRCLE_MIDDLE)), + + MOLDOVA("Moldova", "Moldovan", YELLOW, + new Pattern(BROWN, CIRCLE_MIDDLE), + new Pattern(YELLOW, STRIPE_LEFT), + new Pattern(YELLOW, STRIPE_RIGHT), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + MONGOLIA("Mongolia", "Mongolian", BLUE, + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(YELLOW, TRIANGLES_TOP)), + + MONTENEGRO("Montenegro", "Montenegrin", RED, + new Pattern(YELLOW, FLOWER), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(YELLOW, BORDER)), + + MOROCCO("Morocco", "Moroccan", RED, + new Pattern(GREEN, CROSS), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + MOZAMBIQUE("Mozambique", "Mozambique", WHITE, + new Pattern(CYAN, STRIPE_RIGHT), + new Pattern(YELLOW, STRIPE_LEFT), + new Pattern(BLACK, STRIPE_CENTER), + new Pattern(RED, TRIANGLE_TOP)), + + NEPAL("Nepal", "Nepali", RED, + new Pattern(BLUE, BORDER), + new Pattern(BLUE, BORDER), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, FLOWER)), + + NETHERLANDS("The Netherlands", "Dutch", WHITE, + new Pattern(RED, PatternType.STRIPE_RIGHT), + new Pattern(RED, PatternType.STRIPE_RIGHT), + new Pattern(BLUE, PatternType.STRIPE_LEFT), + new Pattern(BLUE, PatternType.STRIPE_LEFT)), + + NEW_ZEALAND("New Zealand", "New Zealand", RED, + new Pattern(BLUE, CROSS), + new Pattern(BLUE, STRAIGHT_CROSS), + new Pattern(BLUE, CURLY_BORDER), + new Pattern(WHITE, SQUARE_TOP_RIGHT)), + + NIGERIA("Nigeria", "Nigerian", WHITE, + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_BOTTOM)), + + NORWAY("Norway", "Norwegian", BLUE, + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), + + OMAN("Oman", "Omani", WHITE, + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_CENTER), + new Pattern(RED, STRIPE_TOP), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(RED, TRIANGLES_TOP), + new Pattern(RED, SQUARE_TOP_LEFT)), + + PAKISTAN("Pakistan", "Pakistani", GREEN, + new Pattern(WHITE, FLOWER), + new Pattern(GREEN, TRIANGLE_BOTTOM), + new Pattern(GREEN, TRIANGLE_BOTTOM), + new Pattern(GREEN, TRIANGLE_BOTTOM), + new Pattern(GREEN, BORDER), + new Pattern(GREEN, BORDER), + new Pattern(GREEN, BORDER), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(WHITE, STRIPE_TOP)), + + PANAMA("Panama", "Panamanian", WHITE, + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(RED, SQUARE_BOTTOM_LEFT), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, CURLY_BORDER), + new Pattern(RED, SQUARE_BOTTOM_RIGHT), + new Pattern(BLUE, SQUARE_TOP_LEFT)), + + PARAGUAY("Paraguay", "Paraguayan", RED, new Pattern(BLUE, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE)), + + PERU("Peru", "Peruvian", WHITE, + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(YELLOW, CIRCLE_MIDDLE), + new Pattern(GREEN, CIRCLE_MIDDLE)), + + PHILIPPINES("The Philippines", "Philippine", BLUE, + new Pattern(RED, HALF_VERTICAL), + new Pattern(WHITE, TRIANGLE_TOP)), + + POLAND("Poland", "Polish", WHITE, + new Pattern(RED, HALF_VERTICAL)), + + PORTUGAL("Portugal", "Portuguese", RED, + new Pattern(GREEN, STRIPE_BOTTOM), + new Pattern(YELLOW, CREEPER), + new Pattern(YELLOW, SKULL), + new Pattern(RED, HALF_HORIZONTAL)), + + PUERTO_RICO("Puerto Rico", "Puerto Rican", RED, + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(BLUE, TRIANGLE_TOP)), + + QATAR("Qatar", "Qatari", RED, + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, TRIANGLES_TOP)), + + ROMANIA("Romania", "Romanian", YELLOW, + new Pattern(BLUE, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + RUSSIA("Germany", "German", WHITE, + new Pattern(RED, HALF_VERTICAL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), + + RWANDA("Rwanda", "Rwandan", LIGHT_BLUE, + new Pattern(YELLOW, TRIANGLES_TOP), + new Pattern(LIGHT_BLUE, BORDER), + new Pattern(GREEN, HALF_VERTICAL), new Pattern(YELLOW, STRIPE_CENTER), new Pattern(YELLOW, STRIPE_CENTER), new Pattern(YELLOW, STRIPE_CENTER)), - TANZANIA("Tanzania", "Tanzanian", LIGHT_BLUE, - new Pattern(LIME, DIAGONAL_RIGHT), - new Pattern(YELLOW, STRIPE_DOWNRIGHT), - new Pattern(YELLOW, STRIPE_DOWNRIGHT), - new Pattern(YELLOW, STRIPE_DOWNRIGHT)), + SAUDI_ARABIA("Saudi Arabia", "Saudi Arabian", GREEN, + new Pattern(WHITE, SKULL), + new Pattern(WHITE, MOJANG), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(GREEN, BORDER)), + + SCOTLAND("Scotland", "Scottish", BLUE, + new Pattern(WHITE, CROSS), + new Pattern(WHITE, CROSS)), + + SENEGAL("Senegal", "Senegalese", YELLOW, + new Pattern(GREEN, CROSS), + new Pattern(YELLOW, STRIPE_BOTTOM), + new Pattern(YELLOW, STRIPE_BOTTOM), + new Pattern(YELLOW, STRIPE_TOP), + new Pattern(YELLOW, STRIPE_TOP), + new Pattern(YELLOW, STRIPE_TOP), + new Pattern(GREEN, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + SERBIA("Serbia", "Serbian", RED, + new Pattern(WHITE, HALF_VERTICAL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(WHITE, CIRCLE_MIDDLE)), + + SINGAPORE("Singapore", "Singaporean", RED, + new Pattern(WHITE, FLOWER), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, STRIPE_CENTER), + new Pattern(WHITE, HALF_VERTICAL)), + + SLOVAKIA("Slovakia", "Slovakian", BLUE, + new Pattern(RED, SKULL), + new Pattern(WHITE, BRICKS), + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(WHITE, STRIPE_RIGHT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_LEFT)), + + SLOVENIA("Slovenia", "Slovenian", WHITE, + new Pattern(BLUE, CROSS), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, HALF_VERTICAL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), SOLOMON_ISLANDS("Solomon Islands", "Solomon Islands", BLUE, new Pattern(WHITE, BRICKS), @@ -930,69 +800,223 @@ public enum CountryFlag new Pattern(BLACK, STRIPE_DOWNRIGHT), new Pattern(BLACK, STRIPE_DOWNRIGHT)), + SOMALIA("Somalia", "Somalian", LIGHT_BLUE, + new Pattern(WHITE, CROSS), + new Pattern(LIGHT_BLUE, STRIPE_TOP), + new Pattern(LIGHT_BLUE, STRIPE_BOTTOM)), + + SOUTH_AFRICA("South Africa", "South African", WHITE, + new Pattern(GREEN, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(YELLOW, TRIANGLE_TOP), + new Pattern(YELLOW, TRIANGLE_TOP), + new Pattern(YELLOW, TRIANGLE_TOP), + new Pattern(BLACK, TRIANGLE_TOP)), + + SOUTH_KOREA("South Korea", "South Korean", RED, + new Pattern(BLUE, DIAGONAL_LEFT_MIRROR), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, CURLY_BORDER), + new Pattern(WHITE, STRIPE_BOTTOM), + new Pattern(BLACK, TRIANGLES_TOP), + new Pattern(BLACK, TRIANGLES_TOP), + new Pattern(BLACK, TRIANGLES_TOP), + new Pattern(BLACK, TRIANGLES_BOTTOM), + new Pattern(BLACK, TRIANGLES_BOTTOM), + new Pattern(BLACK, TRIANGLES_BOTTOM), + new Pattern(WHITE, TRIANGLES_BOTTOM), + new Pattern(WHITE, TRIANGLES_TOP), + new Pattern(WHITE, BORDER), + new Pattern(WHITE, BORDER)), + + SOUTH_SUDAN("South Sudan", "South Sudanese", WHITE, + new Pattern(BLACK, STRIPE_RIGHT), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(RED, STRIPE_CENTER), + new Pattern(BLUE, TRIANGLE_TOP)), + + SPAIN("Spain", "Spanish", YELLOW, + new Pattern(BROWN, FLOWER), + new Pattern(YELLOW, HALF_HORIZONTAL_MIRROR)), + + SRI_LANKA("Sri Lanka", "Sri Lankan", RED, + new Pattern(YELLOW, STRIPE_MIDDLE), + new Pattern(YELLOW, CREEPER), + new Pattern(ORANGE, HALF_HORIZONTAL), + new Pattern(LIME, STRIPE_TOP), + new Pattern(YELLOW, BORDER)), + + SUDAN("Sudan", "Sudanese", RED, + new Pattern(BLACK, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(GREEN, TRIANGLE_TOP)), + + SURINAME("Suriname", "Surinamese", WHITE, + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(YELLOW, FLOWER), + new Pattern(YELLOW, SKULL), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(GREEN, STRIPE_RIGHT)), + + SWEDEN("Sweden", "Swedish", YELLOW, + new Pattern(BLUE, STRIPE_TOP), + new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), + new Pattern(YELLOW, STRIPE_CENTER)), + + SWITZERLAND("Switzerland", "Swiss", RED, + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(WHITE, STRAIGHT_CROSS), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_BOTTOM), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, BORDER), + new Pattern(RED, BORDER), + new Pattern(RED, BORDER)), + + SYRIA("Syria", "Syrian", WHITE, + new Pattern(GREEN, FLOWER), + new Pattern(GREEN, FLOWER), + new Pattern(GREEN, FLOWER), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(RED, STRIPE_RIGHT), + new Pattern(BLACK, STRIPE_LEFT), + new Pattern(BLACK, STRIPE_LEFT), + new Pattern(BLACK, STRIPE_LEFT)), + + TAIWAN("Taiwan", "Taiwanese", BLUE, + new Pattern(WHITE, CROSS), + new Pattern(BLUE, CURLY_BORDER), + new Pattern(BLUE, FLOWER), + new Pattern(BLUE, CIRCLE_MIDDLE), + new Pattern(BLUE, RHOMBUS_MIDDLE), + new Pattern(RED, HALF_VERTICAL), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, HALF_HORIZONTAL_MIRROR), + new Pattern(RED, HALF_HORIZONTAL_MIRROR)), + + TAJIKISTAN("Tajikistan", "Tajikistani", WHITE, + new Pattern(YELLOW, CROSS), + new Pattern(WHITE, STRIPE_TOP), + new Pattern(WHITE, STRIPE_BOTTOM), + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(RED, STRIPE_RIGHT)), + + TANZANIA("Tanzania", "Tanzanian", LIGHT_BLUE, + new Pattern(LIME, DIAGONAL_RIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT), + new Pattern(YELLOW, STRIPE_DOWNRIGHT)), + + THAILAND("Thailand", "Thai", WHITE, + new Pattern(RED, STRIPE_SMALL), + new Pattern(RED, STRIPE_SMALL), + new Pattern(RED, STRIPE_SMALL), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER), + new Pattern(BLUE, STRIPE_CENTER)), + + TUNISIA("Tunisia", "Tunisian", RED, + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, FLOWER), + new Pattern(RED, TRIANGLE_BOTTOM)), + + TURKEY("Turkey", "Turkish", RED, + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(RED, FLOWER), + new Pattern(RED, TRIANGLE_BOTTOM)), + + UAE("United Arab Emirates", "United Arab Emirates", GREEN, + new Pattern(BLACK, HALF_VERTICAL), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_TOP)), + UGANDA("Uganda", "Ugandan", RED, new Pattern(BLACK, STRIPE_LEFT), new Pattern(BLACK, STRIPE_RIGHT), new Pattern(YELLOW, STRIPE_SMALL), new Pattern(RED, BORDER)), + UK("The United Kingdom", "British", BLUE, + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(WHITE, STRIPE_DOWNLEFT), + new Pattern(WHITE, STRIPE_DOWNRIGHT), + new Pattern(WHITE, STRIPE_DOWNRIGHT), + new Pattern(RED, CROSS), + new Pattern(RED, CROSS), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(WHITE, STRIPE_MIDDLE), + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS), + new Pattern(RED, STRAIGHT_CROSS)), + + UKRAINE("Ukraine", "Ukrainian", BLUE, + new Pattern(YELLOW, HALF_VERTICAL)), + + URUGUAY("Uruguay", "Uruguayan", WHITE, + new Pattern(BLUE, STRIPE_SMALL), + new Pattern(YELLOW, SQUARE_TOP_RIGHT)), + + USA("The United States of America", "American", RED, + new Pattern(WHITE, STRIPE_SMALL), + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(BLUE, SQUARE_TOP_RIGHT), + new Pattern(BLUE, SQUARE_TOP_RIGHT)), + + UZBEKISTAN("Uzbekistan", "Uzbekistani", RED, + new Pattern(GREEN, STRIPE_LEFT), + new Pattern(WHITE, STRIPE_CENTER), + new Pattern(LIGHT_BLUE, STRIPE_RIGHT)), + + VENEZUELA("Venezuela", "Venezuelan", BLUE, + new Pattern(WHITE, CIRCLE_MIDDLE), + new Pattern(BLUE, STRAIGHT_CROSS), + new Pattern(YELLOW, STRIPE_RIGHT), + new Pattern(YELLOW, STRIPE_RIGHT), + new Pattern(YELLOW, STRIPE_RIGHT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_LEFT), + new Pattern(RED, STRIPE_LEFT)), + + VIETNAM("Vietnam", "Vietnamese", RED, + new Pattern(YELLOW, CROSS), + new Pattern(RED, STRIPE_TOP), + new Pattern(RED, STRIPE_BOTTOM)), + + WALES("Wales", "Welsh", WHITE, + new Pattern(GREEN, HALF_VERTICAL), + new Pattern(RED, MOJANG), + new Pattern(RED, MOJANG), + new Pattern(RED, SKULL)), + YEMEN("Yemen", "Yemeni", RED, new Pattern(BLACK, HALF_VERTICAL), new Pattern(WHITE, STRIPE_CENTER), new Pattern(WHITE, STRIPE_CENTER), new Pattern(WHITE, STRIPE_CENTER)), - GHANA("Ghana", "Ghanaian", YELLOW, - new Pattern(BLACK, CROSS), - new Pattern(RED, STRIPE_RIGHT), - new Pattern(GREEN, STRIPE_LEFT)), - - IRAQ("Iraq", "Iraqi", WHITE, - new Pattern(GREEN, FLOWER), - new Pattern(RED, STRIPE_RIGHT), - new Pattern(BLACK, STRIPE_LEFT)), - - NEPAL("Nepal", "Nepali", RED, - new Pattern(BLUE, BORDER), - new Pattern(BLUE, BORDER), - new Pattern(WHITE, CIRCLE_MIDDLE), - new Pattern(WHITE, CIRCLE_MIDDLE), - new Pattern(WHITE, CIRCLE_MIDDLE), - new Pattern(RED, FLOWER)), - - CAMEROON("Cameroon", "Cameroonian", RED, - new Pattern(YELLOW, CIRCLE_MIDDLE), - new Pattern(GREEN, STRIPE_TOP), - new Pattern(YELLOW, STRIPE_BOTTOM)), - - IVORY_COAST("Ivory Coast", "Ivory Coast", WHITE, - new Pattern(ORANGE, STRIPE_TOP), - new Pattern(ORANGE, STRIPE_TOP), - new Pattern(ORANGE, STRIPE_TOP), - new Pattern(LIME, STRIPE_BOTTOM), - new Pattern(LIME, STRIPE_BOTTOM), - new Pattern(LIME, STRIPE_BOTTOM)), - - JORDAN("Jordan", "Jordanian", BLACK, - new Pattern(GREEN, HALF_VERTICAL), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(WHITE, STRIPE_CENTER), - new Pattern(RED, TRIANGLE_TOP), - new Pattern(RED, TRIANGLE_TOP), - new Pattern(RED, TRIANGLE_TOP)), - ZAMBIA("Zambia", "Zambian", LIME, new Pattern(YELLOW, FLOWER), new Pattern(RED, STRIPE_MIDDLE), new Pattern(BLACK, HALF_HORIZONTAL_MIRROR), new Pattern(ORANGE, STRIPE_BOTTOM)), - CAMBODIA("Cambodia", "Cambodian", RED, - new Pattern(WHITE, FLOWER), - new Pattern(BLUE, STRIPE_LEFT), - new Pattern(BLUE, STRIPE_RIGHT)), - ZIMBABWE("Zimbabwe", "Zimbabwean", RED, new Pattern(BLACK, STRAIGHT_CROSS), new Pattern(YELLOW, STRIPE_LEFT), @@ -1000,30 +1024,6 @@ public enum CountryFlag new Pattern(GREEN, BORDER), new Pattern(WHITE, TRIANGLE_TOP)), - MOZAMBIQUE("Mozambique", "Mozambique", WHITE, - new Pattern(CYAN, STRIPE_RIGHT), - new Pattern(YELLOW, STRIPE_LEFT), - new Pattern(BLACK, STRIPE_CENTER), - new Pattern(RED, TRIANGLE_TOP)), - - RWANDA("Rwanda", "Rwandan", LIGHT_BLUE, - new Pattern(YELLOW, TRIANGLES_TOP), - new Pattern(LIGHT_BLUE, BORDER), - new Pattern(GREEN, HALF_VERTICAL), - new Pattern(YELLOW, STRIPE_CENTER), - new Pattern(YELLOW, STRIPE_CENTER), - new Pattern(YELLOW, STRIPE_CENTER)), - - BERMUDA("Bermuda", "Bermudian", BLUE, - new Pattern(WHITE, BRICKS), - new Pattern(RED, HALF_VERTICAL), - new Pattern(RED, HALF_HORIZONTAL_MIRROR), - new Pattern(RED, STRIPE_MIDDLE)), - - BHUTAN("Bhutan", "Bhutanese", YELLOW, - new Pattern(ORANGE, DIAGONAL_LEFT_MIRROR), - new Pattern(WHITE, RHOMBUS_MIDDLE)), - ; private final String _country; @@ -1039,11 +1039,6 @@ public enum CountryFlag _patterns = patterns; } - CountryFlag(DyeColor baseColor, Pattern... patterns) - { - this("", "", baseColor, patterns); - } - public ItemStack getBanner() { ItemStack banner = new ItemStack(Material.BANNER); From c2ab6f9dd46e81f6c54b884f60a0f7c7893e1f74 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 29 Jul 2017 22:24:00 -0400 Subject: [PATCH 171/183] Allow flags to handle article formatting --- .../core/common/util/banner/CountryFlag.java | 71 +++++++++++++++---- 1 file changed, 59 insertions(+), 12 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java index ff6be3674..e5ea8f1af 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java @@ -222,7 +222,7 @@ public enum CountryFlag new Pattern(WHITE, CURLY_BORDER), new Pattern(WHITE, CURLY_BORDER)), - CZECH_REPUBLIC("The Czech Republic", "Czech Republic", WHITE, + CZECH_REPUBLIC("Czech Republic", "Czech Republic", true, WHITE, new Pattern(RED, HALF_VERTICAL), new Pattern(BLUE, TRIANGLE_TOP)), @@ -231,7 +231,7 @@ public enum CountryFlag new Pattern(RED, HALF_HORIZONTAL_MIRROR), new Pattern(WHITE, STRIPE_CENTER)), - DOMINICAN_REPUBLIC("Dominican Republic", "Dominican", WHITE, + DOMINICAN_REPUBLIC("Dominican Republic", "Dominican", true, WHITE, new Pattern(BLUE, SQUARE_TOP_RIGHT), new Pattern(BLUE, SQUARE_BOTTOM_LEFT), new Pattern(RED, SQUARE_TOP_LEFT), @@ -279,7 +279,7 @@ public enum CountryFlag new Pattern(BLUE, CIRCLE_MIDDLE), new Pattern(BLUE, CIRCLE_MIDDLE)), - EU("The European Union", "European Union", BLUE, + EU("European Union", "European Union", true, BLUE, new Pattern(YELLOW, CROSS), new Pattern(YELLOW, STRIPE_MIDDLE), new Pattern(BLUE, BORDER), @@ -287,7 +287,7 @@ public enum CountryFlag new Pattern(BLUE, STRIPE_BOTTOM), new Pattern(BLUE, CIRCLE_MIDDLE)), - FAROE_ISLANDS("The Faroe Islands", "Faroese", RED, + FAROE_ISLANDS("Faroe Islands", "Faroese", true, RED, new Pattern(BLUE, STRIPE_TOP), new Pattern(BLUE, STRIPE_TOP), new Pattern(BLUE, STRIPE_TOP), @@ -421,7 +421,7 @@ public enum CountryFlag new Pattern(GREEN, STRIPE_TOP), new Pattern(ORANGE, STRIPE_BOTTOM)), - ISLE_OF_MAN("Isle of Man", "Isle of Man", RED, + ISLE_OF_MAN("Isle of Man", "Isle of Man", true, RED, new Pattern(WHITE, SKULL), new Pattern(WHITE, FLOWER), new Pattern(RED, STRIPE_TOP), @@ -438,7 +438,7 @@ public enum CountryFlag new Pattern(GREEN, STRIPE_TOP), new Pattern(RED, STRIPE_BOTTOM)), - IVORY_COAST("Ivory Coast", "Ivory Coast", WHITE, + IVORY_COAST("Ivory Coast", "Ivory Coast", true, WHITE, new Pattern(ORANGE, STRIPE_TOP), new Pattern(ORANGE, STRIPE_TOP), new Pattern(ORANGE, STRIPE_TOP), @@ -600,7 +600,7 @@ public enum CountryFlag new Pattern(WHITE, CIRCLE_MIDDLE), new Pattern(RED, FLOWER)), - NETHERLANDS("The Netherlands", "Dutch", WHITE, + NETHERLANDS("Netherlands", "Dutch", true, WHITE, new Pattern(RED, PatternType.STRIPE_RIGHT), new Pattern(RED, PatternType.STRIPE_RIGHT), new Pattern(BLUE, PatternType.STRIPE_LEFT), @@ -689,7 +689,7 @@ public enum CountryFlag new Pattern(YELLOW, CIRCLE_MIDDLE), new Pattern(GREEN, CIRCLE_MIDDLE)), - PHILIPPINES("The Philippines", "Philippine", BLUE, + PHILIPPINES("Philippines", "Philippine", true, BLUE, new Pattern(RED, HALF_VERTICAL), new Pattern(WHITE, TRIANGLE_TOP)), @@ -789,7 +789,7 @@ public enum CountryFlag new Pattern(BLUE, STRIPE_CENTER), new Pattern(BLUE, STRIPE_CENTER)), - SOLOMON_ISLANDS("Solomon Islands", "Solomon Islands", BLUE, + SOLOMON_ISLANDS("Solomon Islands", "Solomon Islands", true, BLUE, new Pattern(WHITE, BRICKS), new Pattern(BLUE, HALF_HORIZONTAL_MIRROR), new Pattern(BLUE, BORDER), @@ -936,7 +936,7 @@ public enum CountryFlag new Pattern(RED, FLOWER), new Pattern(RED, TRIANGLE_BOTTOM)), - UAE("United Arab Emirates", "United Arab Emirates", GREEN, + UAE("United Arab Emirates", "United Arab Emirates", true, GREEN, new Pattern(BLACK, HALF_VERTICAL), new Pattern(WHITE, STRIPE_CENTER), new Pattern(WHITE, STRIPE_CENTER), @@ -951,7 +951,7 @@ public enum CountryFlag new Pattern(YELLOW, STRIPE_SMALL), new Pattern(RED, BORDER)), - UK("The United Kingdom", "British", BLUE, + UK("United Kingdom", "British", true, BLUE, new Pattern(WHITE, STRIPE_DOWNLEFT), new Pattern(WHITE, STRIPE_DOWNLEFT), new Pattern(WHITE, STRIPE_DOWNRIGHT), @@ -973,7 +973,7 @@ public enum CountryFlag new Pattern(BLUE, STRIPE_SMALL), new Pattern(YELLOW, SQUARE_TOP_RIGHT)), - USA("The United States of America", "American", RED, + USA("United States of America", "American", true, RED, new Pattern(WHITE, STRIPE_SMALL), new Pattern(BLUE, SQUARE_TOP_RIGHT), new Pattern(BLUE, SQUARE_TOP_RIGHT), @@ -1026,19 +1026,46 @@ public enum CountryFlag ; + private final boolean _article; private final String _country; private final String _adjective; private final DyeColor _baseColor; private final Pattern[] _patterns; + /** + * Create a country flag banner. + * + * @param country Country name. + * @param adjective Country name as an adjective. + * @param baseColor base color of the banner. + * @param patterns List of patterns to apply to the banner. + */ CountryFlag(String country, String adjective, DyeColor baseColor, Pattern... patterns) + { + this(country, adjective, false, baseColor, patterns); + } + + /** + * Create a country flag banner for a country with a name often preceded with "The". + * + * @param country Country name. + * @param adjective Country name as an adjective. + * @param article Whether the country name should be preceded with "The". + * @param baseColor base color of the banner. + * @param patterns List of patterns to apply to the banner. + */ + CountryFlag(String country, String adjective, boolean article, DyeColor baseColor, Pattern... patterns) { _country = country; _adjective = adjective; + _article = article; _baseColor = baseColor; _patterns = patterns; } + /** + * @return a flag banner item. + */ public ItemStack getBanner() { ItemStack banner = new ItemStack(Material.BANNER); @@ -1054,21 +1081,41 @@ public enum CountryFlag return banner; } + /** + * @return the name of the country. + */ public String getCountryName() + { + return (_article ? "The " : "") + _country; + } + + /** + * @return the name of the country without a possible article before the country name. + */ + public String getCountryNameRaw() { return _country; } + /** + * @return the name of the country written in an adjectival manner. + */ public String getCountryAdjective() { return _adjective; } + /** + * @return the banner color. + */ public DyeColor getBaseColor() { return _baseColor; } + /** + * @return the patterns applied to the banner. + */ public List getPatterns() { return Arrays.asList(_patterns); From 488e8af998686929e66e7c66685490d32cd2224b Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 29 Jul 2017 22:24:19 -0400 Subject: [PATCH 172/183] Improve flag name formatting --- .../mineplex/core/gadget/types/FlagGadget.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java index 7b7d71883..ab9697c84 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java @@ -5,6 +5,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.flag.FlagType; import org.bukkit.Material; @@ -12,7 +13,9 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.ItemMeta; /** @@ -24,8 +27,8 @@ public class FlagGadget extends Gadget public FlagGadget(GadgetManager manager, FlagType flag) { - super(manager, GadgetType.FLAG, flag.getFlag().getCountryAdjective() + " Flag", - UtilText.splitLineToArray(C.cGray + "The flag of " + C.cWhite + flag.getFlag().getCountryName(), LineFormat.LORE), + super(manager, GadgetType.FLAG, "Flag of " + flag.getFlag().getCountryName(), + UtilText.splitLineToArray(C.cGray + "Fly the " + flag.getFlag().getCountryAdjective() + " flag atop your head!", LineFormat.LORE), flag.getCost(), Material.WOOL, (byte) 0); setDisplayItem(flag.getFlag().getBanner()); @@ -36,13 +39,14 @@ public class FlagGadget extends Gadget { Manager.removeGadgetType(player, GadgetType.MORPH, this); Manager.removeGadgetType(player, GadgetType.FLAG, this); + Manager.removeGadgetType(player, GadgetType.HAT, this); Manager.removeOutfit(player, OutfitGadget.ArmorSlot.HELMET); _active.add(player); if (message) { - UtilPlayer.message(player, F.main("Gadget", "You unfurled your " + F.elem(getName()) + ".")); + UtilPlayer.message(player, F.main("Gadget", "You unfurled the " + F.elem(getName()) + ".")); } } @@ -50,7 +54,7 @@ public class FlagGadget extends Gadget { if (_active.remove(player)) { - UtilPlayer.message(player, F.main("Gadget", "You put away your " + F.elem(getName()) + ".")); + UtilPlayer.message(player, F.main("Gadget", "You took down the " + F.elem(getName()) + ".")); } } @@ -60,7 +64,8 @@ public class FlagGadget extends Gadget applyArmor(player, message); ItemStack flag = _flag.getFlag().getBanner(); ItemMeta meta = flag.getItemMeta(); - meta.setDisplayName(getDisplayName()); + meta.setDisplayName(C.cGreenB + getDisplayName()); + meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); flag.setItemMeta(meta); player.getInventory().setHelmet(flag); player.updateInventory(); From fbcec02adc8e19228dff13f0944ca0067e06d431 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 29 Jul 2017 22:24:45 -0400 Subject: [PATCH 173/183] Add scrolling to flag cosmetics page --- .../cosmetic/ui/button/open/OpenFlags.java | 2 +- .../core/cosmetic/ui/page/FlagPage.java | 52 +++++++++++++++++-- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java index 987d549ac..d54ad3b10 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenFlags.java @@ -20,6 +20,6 @@ public class OpenFlags extends OpenPageButton @Override protected void leftClick(Player player) { - getMenu().getShop().openPageForPlayer(player, new FlagPage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(), "Flags", player)); + getMenu().getShop().openPageForPlayer(player, new FlagPage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(), "Flags - 1", player)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java index 8de6f4cdf..c5fc5e852 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java @@ -9,6 +9,7 @@ import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -17,10 +18,20 @@ import java.util.List; public class FlagPage extends GadgetPage { + private int _page; + public FlagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, - Player player) + Player player) { - super(plugin, shop, clientManager, donationManager, name, player); + this(plugin, shop, clientManager, donationManager, name, player, 0); + } + + public FlagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, + Player player, int page) + { + super(plugin, shop, clientManager, donationManager, name, player, false); + _page = page; + buildPage(); } @Override @@ -29,9 +40,16 @@ public class FlagPage extends GadgetPage int slot = 10; List list = getPlugin().getGadgetManager().getGadgets(GadgetType.FLAG); + if(list != null) - for (Gadget gadget : list) + { + int size = list.size(); + int limit = (_page + 1) * 28; + + for (int i = _page * 28; i < limit && i < size; ++i) { + Gadget gadget = list.get(i); + addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.FLAG) == gadget) @@ -47,6 +65,34 @@ public class FlagPage extends GadgetPage } } + // back arrow + if (size > 28) + { + if (_page > 0) + { + addButton(45, new ShopItem(Material.ARROW, C.cGreen + "◀ Previous Page (" + C.cWhite + _page + C.cGreen + ")", new String[]{}, 1, false), + (player, clickType) -> + { + FlagPage page = new FlagPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Flags - " + (_page), player, _page - 1); + getShop().openPageForPlayer(player, page); + }); + } + + // next arrow + if (_page < (size - 1) / 28) + { + addButton(53, new ShopItem(Material.ARROW, C.cGreen + "(" + C.cWhite + (_page + 2) + C.cGreen + ") Next Page ►", new String[]{}, 1, false), + (player, clickType) -> + { + FlagPage page = new FlagPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Flags - " + (_page + 2), player, _page + 1); + getShop().openPageForPlayer(player, page); + + + }); + } + } + } + addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() { public void onClick(Player player, ClickType clickType) From 4a7971b8431507fccabd644a1fba6349c37a06d0 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 29 Jul 2017 22:24:58 -0400 Subject: [PATCH 174/183] Add new flag types --- .../core/gadget/gadgets/flag/FlagType.java | 140 +++++++++++++++++- 1 file changed, 139 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java index aec958dd9..f51cf2ab6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java @@ -7,8 +7,146 @@ import mineplex.core.common.util.banner.CountryFlag; */ public enum FlagType { - UNITED_STATES(CountryFlag.USA, -8), + AFGHANISTAN(CountryFlag.AFGHANISTAN, -1), + ALBANIA(CountryFlag.ALBANIA, -1), + ALGERIA(CountryFlag.ALGERIA, -1), + ANGOLA(CountryFlag.ANGOLA, -1), + ARGENTINA(CountryFlag.ARGENTINA, -1), + ARMENIA(CountryFlag.ARMENIA, -1), + AUSTRALIA(CountryFlag.AUSTRALIA, -1), + AUSTRIA(CountryFlag.AUSTRIA, -1), + AZERBAIJAN(CountryFlag.AZERBAIJAN, -1), + BAHRAIN(CountryFlag.BAHRAIN, -1), + BANGLADESH(CountryFlag.BANGLADESH, -1), + BELARUS(CountryFlag.BELARUS, -1), + BELGIUM(CountryFlag.BELGIUM, -1), + BERMUDA(CountryFlag.BERMUDA, -1), + BHUTAN(CountryFlag.BHUTAN, -1), + BOLIVIA(CountryFlag.BOLIVIA, -1), + BOSNIA_AND_HERZEGOVINA(CountryFlag.BOSNIA_AND_HERZEGOVINA, -1), + BRAZIL(CountryFlag.BRAZIL, -1), + BRUNEI(CountryFlag.BRUNEI, -1), + BULGARIA(CountryFlag.BULGARIA, -1), + CAMBODIA(CountryFlag.CAMBODIA, -1), + CAMEROON(CountryFlag.CAMEROON, -1), CANADA(CountryFlag.CANADA, -8), + CHILE(CountryFlag.CHILE, -1), + CHINA(CountryFlag.CHINA, -1), + COLOMBIA(CountryFlag.COLOMBIA, -1), + COSTA_RICA(CountryFlag.COSTA_RICA, -1), + CROATIA(CountryFlag.CROATIA, -1), + CUBA(CountryFlag.CUBA, -1), + CYPRUS(CountryFlag.CYPRUS, -1), + CZECH_REPUBLIC(CountryFlag.CZECH_REPUBLIC, -1), + DENMARK(CountryFlag.DENMARK, -1), + DOMINICAN_REPUBLIC(CountryFlag.DOMINICAN_REPUBLIC, -1), + ECUADOR(CountryFlag.ECUADOR, -1), + EGYPT(CountryFlag.EGYPT, -1), + EL_SALVADOR(CountryFlag.EL_SALVADOR, -1), + ENGLAND(CountryFlag.ENGLAND, -1), + ESTONIA(CountryFlag.ESTONIA, -1), + ETHIOPIA(CountryFlag.ETHIOPIA, -1), + EU(CountryFlag.EU, -1), + FAROE_ISLANDS(CountryFlag.FAROE_ISLANDS, -1), + FINLAND(CountryFlag.FINLAND, -1), + FRANCE(CountryFlag.FRANCE, -1), + GABON(CountryFlag.GABON, -1), + GEORGIA(CountryFlag.GEORGIA, -1), + GERMANY(CountryFlag.GERMANY, -1), + GHANA(CountryFlag.GHANA, -1), + GREECE(CountryFlag.GREECE, -1), + GUATEMALA(CountryFlag.GUATEMALA, -1), + HONDURAS(CountryFlag.HONDURAS, -1), + HONG_KONG(CountryFlag.HONG_KONG, -1), + HUNGARY(CountryFlag.HUNGARY, -1), + ICELAND(CountryFlag.ICELAND, -1), + INDIA(CountryFlag.INDIA, -1), + INDONESIA(CountryFlag.INDONESIA, -1), + IRAN(CountryFlag.IRAN, -1), + IRAQ(CountryFlag.IRAQ, -1), + IRELAND(CountryFlag.IRELAND, -1), + ISLE_OF_MAN(CountryFlag.ISLE_OF_MAN, -1), + ISRAEL(CountryFlag.ISRAEL, -1), + ITALY(CountryFlag.ITALY, -1), + IVORY_COAST(CountryFlag.IVORY_COAST, -1), + JAMAICA(CountryFlag.JAMAICA, -1), + JAPAN(CountryFlag.JAPAN, -1), + JORDAN(CountryFlag.JORDAN, -1), + KAZAKHSTAN(CountryFlag.KAZAKHSTAN, -1), + KENYA(CountryFlag.KENYA, -1), + KUWAIT(CountryFlag.KUWAIT, -1), + KYRGYZSTAN(CountryFlag.KYRGYZSTAN, -1), + LATVIA(CountryFlag.LATVIA, -1), + LEBANON(CountryFlag.LEBANON, -1), + LIBYA(CountryFlag.LIBYA, -1), + LITHUANIA(CountryFlag.LITHUANIA, -1), + LUXEMBOURG(CountryFlag.LUXEMBOURG, -1), + MACAU(CountryFlag.MACAU, -1), + MACEDONIA(CountryFlag.MACEDONIA, -1), + MALAYSIA(CountryFlag.MALAYSIA, -1), + MALTA(CountryFlag.MALTA, -1), + MEXICO(CountryFlag.MEXICO, -1), + MOLDOVA(CountryFlag.MOLDOVA, -1), + MONGOLIA(CountryFlag.MONGOLIA, -1), + MONTENEGRO(CountryFlag.MONTENEGRO, -1), + MOROCCO(CountryFlag.MOROCCO, -1), + MOZAMBIQUE(CountryFlag.MOZAMBIQUE, -1), + NEPAL(CountryFlag.NEPAL, -1), + NETHERLANDS(CountryFlag.NETHERLANDS, -1), + NEW_ZEALAND(CountryFlag.NEW_ZEALAND, -1), + NIGERIA(CountryFlag.NIGERIA, -1), + NORWAY(CountryFlag.NORWAY, -1), + OMAN(CountryFlag.OMAN, -1), + PAKISTAN(CountryFlag.PAKISTAN, -1), + PANAMA(CountryFlag.PANAMA, -1), + PARAGUAY(CountryFlag.PARAGUAY, -1), + PERU(CountryFlag.PERU, -1), + PHILIPPINES(CountryFlag.PHILIPPINES, -1), + POLAND(CountryFlag.POLAND, -1), + PORTUGAL(CountryFlag.PORTUGAL, -1), + PUERTO_RICO(CountryFlag.PUERTO_RICO, -1), + QATAR(CountryFlag.QATAR, -1), + ROMANIA(CountryFlag.ROMANIA, -1), + RUSSIA(CountryFlag.RUSSIA, -1), + RWANDA(CountryFlag.RWANDA, -1), + SAUDI_ARABIA(CountryFlag.SAUDI_ARABIA, -1), + SCOTLAND(CountryFlag.SCOTLAND, -1), + SENEGAL(CountryFlag.SENEGAL, -1), + SERBIA(CountryFlag.SERBIA, -1), + SINGAPORE(CountryFlag.SINGAPORE, -1), + SLOVAKIA(CountryFlag.SLOVAKIA, -1), + SLOVENIA(CountryFlag.SLOVENIA, -1), + SOLOMON_ISLANDS(CountryFlag.SOLOMON_ISLANDS, -1), + SOMALIA(CountryFlag.SOMALIA, -1), + SOUTH_AFRICA(CountryFlag.SOUTH_AFRICA, -1), + SOUTH_KOREA(CountryFlag.SOUTH_KOREA, -1), + SOUTH_SUDAN(CountryFlag.SOUTH_SUDAN, -1), + SPAIN(CountryFlag.SPAIN, -1), + SRI_LANKA(CountryFlag.SRI_LANKA, -1), + SUDAN(CountryFlag.SUDAN, -1), + SURINAME(CountryFlag.SURINAME, -1), + SWEDEN(CountryFlag.SWEDEN, -1), + SWITZERLAND(CountryFlag.SWITZERLAND, -1), + SYRIA(CountryFlag.SYRIA, -1), + TAIWAN(CountryFlag.TAIWAN, -1), + TAJIKISTAN(CountryFlag.TAJIKISTAN, -1), + TANZANIA(CountryFlag.TANZANIA, -1), + THAILAND(CountryFlag.THAILAND, -1), + TUNISIA(CountryFlag.TUNISIA, -1), + TURKEY(CountryFlag.TURKEY, -1), + UAE(CountryFlag.UAE, -1), + UGANDA(CountryFlag.UGANDA, -1), + UK(CountryFlag.UK, -1), + UKRAINE(CountryFlag.UKRAINE, -1), + URUGUAY(CountryFlag.URUGUAY, -1), + USA(CountryFlag.USA, -8), + UZBEKISTAN(CountryFlag.UZBEKISTAN, -1), + VENEZUELA(CountryFlag.VENEZUELA, -1), + VIETNAM(CountryFlag.VIETNAM, -1), + WALES(CountryFlag.WALES, -1), + YEMEN(CountryFlag.YEMEN, -1), + ZAMBIA(CountryFlag.ZAMBIA, -1), + ZIMBABWE(CountryFlag.ZIMBABWE, -1), ; From 4b052e111ac4fae1255c0d1c4a9f0ae200108470 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 29 Jul 2017 22:25:21 -0400 Subject: [PATCH 175/183] Add constructor that allows gadget pages to not be built immediately --- .../src/mineplex/core/cosmetic/ui/page/GadgetPage.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index 03efda5ce..913844276 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -40,10 +40,18 @@ import mineplex.core.shop.page.ShopPageBase; public class GadgetPage extends ShopPageBase { public GadgetPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) + { + this(plugin, shop, clientManager, donationManager, name, player, true); + } + + public GadgetPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, boolean build) { super(plugin, shop, clientManager, donationManager, name, player, 54); - buildPage(); + if (build) + { + buildPage(); + } } protected void buildPage() From ab91e3cfd6dd48ca120095a1cada92236bbf524a Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 29 Jul 2017 22:25:26 -0400 Subject: [PATCH 176/183] Add fruit skin data --- .../src/mineplex/core/common/skin/SkinData.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index fc34a0649..9b84839e4 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -81,6 +81,16 @@ public class SkinData public static final SkinData CANADA_HAT = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg2MDE5MDYwNzYsInByb2ZpbGVJZCI6IjdkYTJhYjNhOTNjYTQ4ZWU4MzA0OGFmYzNiODBlNjhlIiwicHJvZmlsZU5hbWUiOiJHb2xkYXBmZWwiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2M2MTExNTNmODdmMjZjMzRmOTdkODIxM2ZmOTk1ZGJlNjcyZWJkNGM0NjRkNGFkNzM5MWFlNDNjMWU3YTllIn19fQ", "QMw6e1FXl/Xrt+BbfPKsz3OHyOxL9CEPffS9grxRLD6gbLbMD84OT3+bge5V9lBFn9PPnTyID+WTF24qHj4ADTTgK94ykNedCEO6R1wS0FZKPI1UjwOxMhIG5ZeVr7+HxITgGU4Xz94IigBkvW//f2ZGelMvS0GLCrm4iCovEBMUzyYJ2dZ4xgzFSH6v+9efK4/SBAJaj8mHjXpDxU58/vskTGI3T9t5sWlZLXgId9vHcMj0GH3Un6yvUXiMkh38V/rAEM8/R8q08xUVyW0e2R38qWQV2+eKvsG8GmJmgkU/78wA9cKGZdrEz0pnr80eGNCbvXqQvC/czYhEhDapgxfndcHLX8q/Zk3I8msNr340E4ZrQL61Yl7KcVC1qEUQVu3cosq5A6ckXLGvv//HSwXVO8M9ThUbuEC8QjiS/fMFufnVa18lHrVulnfb/2KQ4yPsoCHK/zvGtRkWtD1sLOIfehN+sxCLiaz80ILBiwN0oHITfNHpJzoa4kF/OrxxCualp4Sv5o5TXBv7aWsO18v9ixb9o9CmJKKE8MUl5xmRVz4HQD4dyOfcwtPuxmfcYjJrxqBijdQMrcgLzqqMs+DUqcZZlxM7M5GaNUoEvL9tJNGpZaB2OrBw0DTk5wx15XfANCH4egx8X4+Iy2RUoFthHX3BsVazG7fjSiDnUtI="); public static final SkinData AMERICA_HAT = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg2MDI3MjMyODgsInByb2ZpbGVJZCI6IjNlMjZiMDk3MWFjZDRjNmQ5MzVjNmFkYjE1YjYyMDNhIiwicHJvZmlsZU5hbWUiOiJOYWhlbGUiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzYzMjI0MDhkYzBiZjMxNjU4N2RiNDJiN2Q5ZmViZTUwYWQ4MGY0OGU4Njc5YzI0NTFkOTk3MTdjZmVjNTdkYWQifX19","oRo6DIuhOTaXDkFsgwJ488LWqx5d1QpwtglwG1SdEvkbX1aCMGdZyDm9YIopQRjfBg0uYKQFetOZ1ZkdMmc/aKC5/dm0+Ema7g8AUzjwf4OaSLH1r4C1UJ4ruaNG5diBxNTkYnMa7yT8zvyEr22CA7lUOIgTh8ymBfSGK35RPhsn8jM0hDjdhjemBAlxKpiioByfmAQbwokNBOrXfh/PnKq+iJYg4WpMSZ1zo5Rr0CzLXwu+/T3dvrb6mg7qry7J3Lj5/qn6iIdBcjJBeyvy1sCo45jQ3Rzc6oL/84Vu5Dpn395EqUK8Sa7mdpVpATTcj56TCjkNNtDapXNqyO/IIQuzU4wnBKNQmZefaxRl6LV0DhZ8n8YQaPj6hH/mr2oDsd23+jejjqu6Y95ReTyukp06mIGqgekmrdZV2etML2oMAOTv9ieVvqtfo5gEomYs+NFAL7rMmzjAlhd17VOgqNRMpmJazAHWOYKl8KdOH99wGDe5XcyKHysh+qyHKMvhPJztIeAEaosynF/aGHghH2PM354KCuUVNmdR5G7UZUoG9ZA5ZU3EzZ854jeqxcqw3jzb6qL7A83QNuFqOsb87ugL/jO3QEDdQ9drdf3WAQauQGkU3nYBrls5wxoMrQ+Ceth+FtZw9a1v7dc+DEWOeJKCtOAIskb29pv6OcRe0Wk="); public static final SkinData REVOLUTIONARY = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTg3ODQ5Mzk3NjAsInByb2ZpbGVJZCI6ImIwZDRiMjhiYzFkNzQ4ODlhZjBlODY2MWNlZTk2YWFiIiwicHJvZmlsZU5hbWUiOiJZZWxlaGEiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2I4NTBkZDNkYWQ0MjkxYzFhYmU4NGU2OTM2ZmQ3MDM0ZWVlZTk1OTk2MWI3YjE5NDZhODIxYWRlMTFiODI2YjIifX19","U2xBG+ryUacvZq3WreWF2J4QnQERuvp1okqdlkAYECqvVHz0cars78usPuZYD4s3HyOM0eGASzS4zkQERF6Hk8crnG+ZtqvML5kL+TkxK8gEbn2j5qB+YDG0qTx635mYGC77sGaqE/CsZAlhRYU6lyXILW2616Af8B8orOlpyCMRytijp/OfJREK0bC4I1QnB7AJ2QmBYuZJ9l8473858fJOlCVHjbsC/WRcUvepPSYYxvl8Z5NwayyIVnnz3tGVN6hnM7tzil/gQmsmDwGhlSyify/MEGssvd0sHLTlccA7XX98tyUFHXU84L5MJuNKg/uXTYz+9cRPIgJaptJNfqCoEa/ape+YHlOlK2lm5qRvubvp931X+VwFbcrEuaIFgbqr9cof5JW6DYfpVKvcngi9+K9IzgtPG59Jro5kxb70IfQhZcDkcHGo1pz5Tj7cdJdD7crBeIBaE/EoKU6iaSOrUFoILEdpcWQfaToRnk4L/JMet7zPXBNE/D/vEgQLGLNX7byofdCXSD9njtjLWmHg4rCzwuUqaiWnTCYIkkdg/mFuRQ3oTRRTzdlLXsK90Pz0XU9N6gBhWA9pxhzDJR7YK+mdXODALuMXE6zcCsbVuWhqbnN+EByGdjT9X1QPSN+/5iV9d5JyweiJrF7arf2PmxgEIb9OSjePNKRmHoo="); + public static final SkinData MELON_PERSON = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjA2OTU5MDgsInByb2ZpbGVJZCI6ImNiZDIwN2M3ZDNkZDQwYTg5NTBiZGQ4ZTU4M2IyYjY1IiwicHJvZmlsZU5hbWUiOiJBbGVzc2FuZHJvQ2Vydm8iLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzNiNDQwYjc5NWY3ZGNjZGNiODY3MzBjYzMyYzE0MGQ4NzM2NmRjNDU2YWZhZjA4Y2VkNjE1OTEyOWViMCJ9fX0=","U5yXWm6A0R4gzZRFWeeI0IUwOlpjOUogDIJyPX1b9ItcT1CMkKF/oc2IKmbMJGhwktzV8U3YKh8J3IHHomJYMiZN6WH8QNyzAiw4uaaWd2JFtG5LYRLFI7DPiaXrRW0Wdz4IffFBZ5yyDOIOLcGCExLrxyeKAO7yNah6IMgEbtY8wX6uZYFWkxRx7Orbici2zsDakghXUFcnvNE+plmK3Gxjb45RtYfWeurGzcsCEEjkRK/aQ4aohvCkx5sc4Bl3ObWiDVJ9FvHzPSd09zjnIpL9jyxKQTscbeRFKasjtbJLEbq/yq5cAjI9uGYbPkBG9C1JgmWDZBz9a0bCwRokihKtYJbDAs1417qcyzoH0ylLt85fz+XM7G+MIHba8hZ3aJFZughyslsCg/+5jAm+Ci9yQJgYFf3yHFUrmVktHz+dsWdgrfDqIMXKJWXVKccvHMD0u+yKCMxW6C4RxZmOgnAqYfvPUJqTrAW4FpbFuPBTpFsGYF7QfgIekib8aXsUr0hCh1HqEYqICVXT8Jr38A4ySMZ1NKnbRzEsDwL/4gE5YDtza+qcanY2Ewl906Z+m3uMXXXKM7uYq47RyOYWYyOcyJhr9n7C1pEbyoaTt1m4+u9j9TEMX/8oN7qCSvDhkBH5M+XIt6OJhu7bJObW0HjqUo6yADUx3srK9cX9Rpw="); + + public static final SkinData APPLE = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjMzODU3NzAsInByb2ZpbGVJZCI6IjQzYTgzNzNkNjQyOTQ1MTBhOWFhYjMwZjViM2NlYmIzIiwicHJvZmlsZU5hbWUiOiJTa3VsbENsaWVudFNraW42Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zNWUyZTA5NTk3MTJkY2QzMzU3Y2MzY2VhODVmOTliM2ZkODA5Nzg1NWM3NTRiOWIxNzFmOTYzNTE0MjI1ZCJ9fX0=", "tK+zKZp42fBhSLoXyFMwJ7AYubID12WUhhp9At4YA7A6SuYHj022IrkxWjsl8e7stsd+gmMsPbr25HMHH8JXRQhzH+5qRa3PBVqhYFUHWI7jrrmTk7krhwZOg+Ozw0+TU4nqyRZGeZxwKiy0DcpO7tsgcFQtbJTG27jh4ZGlkqANDHYsqi8BiOXVz51yquuf8x8Bgml+0wyuCrkgUo2a0iXB5la9zs/HnxFJbHi/IHn+a2+RqGa49JhgMCykKkohsgPEqcuCBuUbqs8pxdnUHTqCxmZ/XKjgXq3NpFkfp2RYynDTW5RfZdEbo+D+cbivZgrehBtJatJd8vZu+kmuxwxYR0mdre4MrlRcgn1CpSvPk5/EJrkst8TVv1iEtUeR2l82umw+QfemNOgrOP3K/DT+JX6faRskrLP7J6JAIWP04dEuDI83t1Y7UPX/tSsGOrA2PO/VR8670dwCMS5Wc60RLhT98PKs0ctFaPK4RQRp4XbOw7jtWiNUZ+iy7JOUFLKcoTZNOFqoXs1IVs2JZ/nHJHkzLXkvaHzeM5KlYiq8igCy3XF5CQvVrTsFYX+PELkq+2wpyVgSHITqhUZl96mDAWMFm8IepE0JEkTfp8VrTTXeym3LL5Ecu7Azeoh7SiKf5lSKyLro3hp2N+JvN8l0BPB8qpZAjs4VJd79dns="); + public static final SkinData MELON = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjMzNTc0MjcsInByb2ZpbGVJZCI6ImJiMDgwOTFhOTJlZDQzYWQ5NGYxZWRmZDc0NmIwYTJjIiwicHJvZmlsZU5hbWUiOiJJcDRuZHgiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzFjNDA4MWM4ZjRmY2RjODE5Y2VjZDZmOTRmM2ViZmFiZTBkMDMxMTVkZjJjNjYyODIwYTdhZWJhODljMmUifX19", "qHvPSsGfSDapqJlLxk1BQb2cVFbjggbDbQWCaHkzpfCx7yTojSR29ywqg0F5rLabZ7Q13wG7l2CUkdCsK4urO1qx2MpSK3iVL/mG2x2O3m3Hg7FUU6fcaupP9T8V36n8HNag5uM3lbtnzoNmhwuCS6EbzRbgk5cL38jRwPod4Bxea/UKOBFmrl506Y2pjg0gi3nZVHPmnweNC3kV8FwmHHfFUt2T6QrvULKANLfxTYmIJj9jrG5CZ3oGQj6vnHo0iA5NpMpUYAqLSKrAV2GTVZ8U7SEcTkUgLkXfd7UnNKGWVoH93LUtRyti71fwtx5q591xfqdbRiMQZBz5r5U0kUg9HrCuz8nUaCX4ox9vPJp3TktlRT8cqRyadm+bqVHPccnS0Wt/7HTMC85X1VhB+5EawHdx8umkky404mEJbPcWZZlXfbsDchASMq2tgfeZZufgJX/DY/qyVz8L1Pmp9IXuqnzvV2CaUwjKtyc8gd6ZrOGOmYovhth/IgvRUaChB248Wwh2qe3sQz0PYxAuFMP0D3mf8ctLFmVyR3bPKtxJYW6vrLiZ8a6lg1houf/pQMF4q5HQSzW7Nbic7gR766TXgy5dRxavyToPRuFkCnI3EQwmleeYg88pazcGRWGOEueAM1/4dbNjNsAoif8fCSI3/1UT7lgvcCAinDJe6AE="); + public static final SkinData ORANGE = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjU4OTA3MDMsInByb2ZpbGVJZCI6ImNhYjI4ODVkMTUxNjQ1OTNhZmI2MDkwODJlOTE2NmU3IiwicHJvZmlsZU5hbWUiOiJGYW5jeV9MdWR3aWciLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzU5ZTNlMGUxOTZjY2I3MjRhMjI1NzRmYzdjNjdhNmM2OGVlNDIwZjE3ZWM5MzI3YTUyNjYxZDcyNGQ5OGU1YzcifX19", "Bjj4N79wGgpPDV4oBDtB6B2dva3gN6pP+siJ9r309oJ1LXqPB9kbBIe7bquTKXAJgrNWuK2phASVoFdvJUbc7pazpk5h2ZDdPqWCnP8H7Oq2BtRpCJuvOnINZFGURzkdhbrfnvgoN7WEm3MsdZ6I702ZHrC15rVwTvimKV0bD3kq5W18nYZL446SxdBqKilK1Uly4582ZuEajZ3xsJfdVohPFNDKKu5z3HWPkcPu6jIi4/ACMsxSk7SYic3ZnwN+ULgHAoWymfcta3zmHeNDqYn+68iJRE1+WYHvkXlrO3gdgDqWD2MIyDCvFkLPuPZ/W93zr6V+WAXpH1Pgh6+Sw24EiIKnHR1paCo7eJI+1c4BlYgAwctj36pyRHh7N8Po5GSi7vQKrzoMLoBBJqRVKK5gbIVOWxBBKnhK+q2va5ZVoYPhBb808i4HA538dLk3qeAhVKX/x0uyAGtKgIKa4OlxcBk40LKQ1a/NnC7vOSB6lWLE1PiVoZ8yhe2pJQKy+7nztWehrO1g0IcwLYZSjraAiZ17Zx1fFHYp+4qnjncYewvGDXrcIofG7EEpSCNzY/HsagykPZMyPPSDcwuDZHI08JIPTRkwXTzae2BDggkF4d6PxyLryZE3BnG7lSb6yMKYvsDqpkhuqsUPI4put1DKJEFx+hIlT0I5kVI3rQc="); + public static final SkinData STRAWBERRY = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjU4NjE1MTEsInByb2ZpbGVJZCI6ImFkMWM2Yjk1YTA5ODRmNTE4MWJhOTgyMzY0OTllM2JkIiwicHJvZmlsZU5hbWUiOiJGdXJrYW5iejAwIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS82NmE4ZDlmM2YxOWNmZDZlZGNmNzFjOWM0ZjNhZDA5OGYzZTk1OWE5OTBkNjEyZjQ5YzI1MTgxNzM1M2JjYmUxIn19fQ==", "wxroo0ThDSb1B69kNyZsdtpg5qPxjWSt+LX3hg3KvgxziiNhMVmsLVks6+yz2vaeHPDyqckFO+eaVyb1wCuczFCOxLCKBHVhhBFKEbaF5NZTS0HOK6fvY6jxxETX93TmANgWm9MzrcVMGKvBck/gOI40+kxcVJKUg0Jb3yGQcuY820thGB95qznHDLIbnnTaB3mJr4yog2intDOqSF7I0fnd5U0Qceaor2u0WWiXaVr+SKvA8D9xvOfrc+IGYV55EHuQu1o3fl5qfK1mBASG9xWACCyTdoOkt06MsJCTxxo60ZE1nnL5m3a27XJ5HeiVNKjjrMOqlTfieBN8H0sWxfzMJ5gjFmGjxq6qhnAjn8Gr/SyhDbnTHILOTbh/V8XdZCwqYD7XI/3///LyPCEfoLmPsFnMd9M8V3DIiDJ3GvD8qTQd54vYHnUw6yR/mA6ONx1OxHBHprIaP5urq9MNIljg2PtVtOzSWypObpf3kR+ZhUC0t8hqiapsLAvpzkb7FO12db0Hwr+4NIbZQ8ZYTe0ds2Zb8Iq1BMWOZ16ffwnDnaqulhQN+nIAA+61Q4k5y2sa60lmvr23yX3AV3Ywop13k1Gvc/amrA+ni66i5ezXMa4+V22fUEAqb+VrEF6IMg4Vac50HIbvIpM1QaWP4fqoHE5lHjCRwmqGjEL9WXQ="); + public static final SkinData PINEAPPLE = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjU5Mjc3OTMsInByb2ZpbGVJZCI6ImJiMDgwOTFhOTJlZDQzYWQ5NGYxZWRmZDc0NmIwYTJjIiwicHJvZmlsZU5hbWUiOiJJcDRuZHgiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzczMjVlYmI5NmE3YWYzZTg3ZThiNmNhOWE4YzE5ZTllOWVlZDgxYjU4Y2RhZWUzNTIyMTg2NTc0YzgyN2Y0In19fQ==", "wrrEvFHwXhSivSnSN1VbXwjfZ7JrdizB4kAGCpOgYu090M087cJUoWan5KfjMN4N9DjmxmWt6M/yE25+47iu3grzaxnsIAUY+b7HzYzk1nrII3R9LLRbOF6cr6ug2c9scQ1wTsWHpul8y5U/vNekTN8+rRBBurmzUR+50M/wXh+mVFhVFtI2QFwDOZZWz4Tz/mPqGiRAtfT1UcPmGS9d5qETqWQlOAbtdlhuYQADNKSf3pIizRvbJKrEtDI6+deqzzGj35L7LdnsOO+k0qFz5m75AdbOty0l11ID1XGXf604iOocvNk/mO4oO+C7Na2jdwazgd7TJ0H+7qAz2suXflco+ALGcRJob3ysBleHBY2l1IpCWH6SPQG+mQvyOfi356dS4HM/QnPBswLJZ+q7rpkAyW8nArLP49/s+ou0PRs75EiFM61xzFoQRt1fLhx7X+IP2QYy7KIMWw5oRJvLKedu2bDTilMq5lyj6o7I7mfKIou8+O4P30eOwBFTPpjPe3BLMws7/Muwqh4TeSdTIuEkTca8qxb8RUv136DJkmkMJTYiZg7kNHLRL0oP8Hz1o8sCX9w6MElyHeRv/h+sE6PHP3zApjr3+wAun6CFBnLvtVcOA5/zvYQcNbzN2sdwWf7V+djN5Eqq78FduhK1MqiYXpJq9pM/cM3beM1rXE4="); + public static final SkinData GREEN_APPLE = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjU4MTM1MzIsInByb2ZpbGVJZCI6ImE5MGI4MmIwNzE4NTQ0ZjU5YmE1MTZkMGY2Nzk2NDkwIiwicHJvZmlsZU5hbWUiOiJJbUZhdFRCSCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjY3OGNmNjAzOTg2ZTM4NDcwNjkyZjgwYWJlNDE4ZjM5YTJjYWQ3N2Q4Nzc4YWY4NTc0NmU5MTkzMzdjZmQ2In19fQ==", "xAm3i+xi9OynV2uaqdF0VTws0qCsH3SP3zeEa5gUZejbhzXA7/i4JZC2+Ag9ULj4AaTbZhc1mFMB9+XAozmrWr+BEQjaD8/sbyQIirzUAk/X6ZTCKkp7Xk46mFlKjd4IVvoUSopCa/HCTRZTugjqJrPbdy232/UVC9JBShAcMq7pD7rmH5+O/vVtMcrtT8MjY95vnlhyXyNpDwYhCW9YlmZcG5fS5nPaq8k8mCaNe/fILVf2T/hQqqMTuZiqQk53L+5C8aiU4nySrGATB3UK1OwVTB7t3gen4MQtUT0ursOKoLLbxWboQWjsFYOxycfDeccOcB50iHfqCW8UmARt8mUT17RfWQvwIqlv1uThdnKsFZjx3LAodPAzcqyIoyR8EbCEeV82pDtYG5X7gT/pV/inYDgrLT7ZmONRk2x1TzTC3PicKNXu40OcOU63yaB/nvQY3FURNVCpvWXwPD1QyZBYfKtO4no1/TfPoZPcdGz9E1Xor74AlDAUJTlGQ5+OlQldJiwHvmPxTPJKdgOJLXRVUHcFLV32VtWnmrBRq9pm3qO3MTEVytB4XVaGmsf3zqcwrVur910CpPxDjyXqe1NvxN2I/43FAQInL3iX/NqOpwsx7alSIUe3ZhdqP6l8SSTDK0Sp+1GtvGrvRiX/8dStDfAsNCN0HxvxQQUVM2w="); + public static final SkinData PLUM = new SkinData("eyJ0aW1lc3RhbXAiOjE1MDEzNjQyMzY0NjMsInByb2ZpbGVJZCI6IjBiZTU2MmUxNzIyODQ3YmQ5MDY3MWYxNzNjNjA5NmNhIiwicHJvZmlsZU5hbWUiOiJ4Y29vbHgzIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9lZWIzZjU5NzlhNWVhMGI4MmM4NTUyNmZkYjg0ZjI2YTY4YmY1YTI1NDQ5YzRiNTk2NWU5Y2IxYzQ5NDM5YWY0In19fQ==", "jC6e7Cy7wGmvqSUjIYXwPXQZjAVxnOMoST+IKy/m/g4uklandxhBT9HJskBI+rtVjz67psyLmY941gAtqIbLkRxEhAeT/Qc3iRMV9MN7Ac7b3UaQsnO5gnY3IBZZxSTJhX8oxyTXD+c9k4lsjladzxXA3DcmEn0Cqp0t0oFQA5mEYpa1qGB6NCoXvi5deXNID3PQJjj+PLkohoLKhsDEqbYb3djwGTDKWYGFAwuF7KnA3cuPXa5KN6sPbM7qdjnF3Gke9bkinTn8F7cXVxEpcqAxiUyv8Wv/umHRaEBuDf9yxrDaberkRQu+YIqK6fw805QwcxQePiG/qMU9yZAOuPoolp/SUROHF69pjN9lI8O5Vs08f/K3rSIpgyU16K+lUmE1XIPukUBjNsK2mRTLfJgv8csilzS5jWmVzjr859l0Inr51tGtfQ3VEyUJtIowcOh9GfZWTvaYeDnyGhRUaEpPOmCo1QLIbedAbq51+gYykeQMTmRc+joxxN9SBlF252d7ncOcVAChHxmcFWbPbhV2lMfSTxGmKAx1T9dmw22Z0WTM0NkMG7EsG7wFz1U8f0OY4lyrtVUM7Oy8pc8RuRPhOgQGAvuhA58k6DLgmOpMOVBuEkoOFpZaJKWgVMQI+u9g6COC7WRTF/Z3EW//BFQ09L+uSAPaeyD8rzFqbCo="); + // Comments this out for now, so it doesn't load the player profile // A better way to do this would check for the properties when getting the skull or the skin From 540e450f66011635a8ed565e6376f4b27dba3883 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 29 Jul 2017 22:25:38 -0400 Subject: [PATCH 177/183] Create melon head morph --- .../gadget/gadgets/morph/MorphMelonHead.java | 181 ++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java new file mode 100644 index 000000000..2b503bfad --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java @@ -0,0 +1,181 @@ +package mineplex.core.gadget.gadgets.morph; + +import com.mojang.authlib.GameProfile; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilSound; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.HologramManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import mineplex.core.treasure.event.TreasureFinishEvent; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; +import org.apache.commons.lang3.tuple.Pair; +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +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.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +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 java.time.Month; +import java.time.YearMonth; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; + +/** + * PPC Reward for month of August 2017. Allows users to turn other player's heads into various fruits. + */ +public class MorphMelonHead extends MorphGadget +{ + /** Fruit head texture options */ + private static final Pair[] TEXTURES = { + Pair.of(SkinData.APPLE, C.cDRedB + "Apple Head"), + Pair.of(SkinData.MELON, C.cDGreen + "Melon Head"), + Pair.of(SkinData.ORANGE, C.cGoldB + "Orange Head"), + Pair.of(SkinData.STRAWBERRY, C.cRedB + "Berry Head"), + Pair.of(SkinData.PINEAPPLE, C.cYellowB + "Pineapple Head"), + Pair.of(SkinData.GREEN_APPLE, C.cGreenB + "Apple Head"), + Pair.of(SkinData.PLUM, C.cPurpleB + "Plum Head") + }; + + /** Ticks that a fruit head change lasts */ + private static final long TIME = 240; + + /** Map of players to their current fruit heads */ + private final Map _heads = new HashMap<>(); + + public MorphMelonHead(GadgetManager manager) + { + super(manager, "Melonhead Morph", UtilText.splitLinesToArray(new String[] { + C.cGray + "Transform yourself into a melon.", + C.cGray + "Tag other players to build your melon army!", + "", + C.cGreen + "Left click" + C.cWhite + " players to turn their heads to fruit." + }, LineFormat.LORE), -14, Material.MELON, (byte) 0, YearMonth.of(2017, Month.AUGUST)); + } + + /** + * Sets the player's skin to a Melon texture. + */ + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + GameProfile profile = UtilGameProfile.getGameProfile(player); + profile.getProperties().clear(); + profile.getProperties().put("textures", SkinData.MELON_PERSON.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile); + disguisePlayer.showInTabList(true, 0); + UtilMorph.disguise(player, disguisePlayer, Manager); + } + + /** + * Restores the player's skin. + */ + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + } + + /** + * Detect when a player punches another player. + */ + @EventHandler + public void handlePlayerInteract(EntityDamageByEntityEvent event) + { + if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) + { + if (!isActive((Player) event.getDamager())) + { + return; + } + + Player player = (Player) event.getEntity(); + + if (player.getInventory().getHelmet() != null) + { + return; + } + + if (_heads.containsKey(player.getUniqueId())) + { + return; + } + + Pair data = TEXTURES[ThreadLocalRandom.current().nextInt(TEXTURES.length)]; + ItemStack head = data.getLeft().getSkull(data.getRight(), new ArrayList<>()); + + _heads.put(player.getUniqueId(), head); + player.getInventory().setHelmet(head); + player.getWorld().playSound(player.getEyeLocation(), Sound.CHICKEN_EGG_POP, 1, 0); + UtilFirework.playFirework(player.getEyeLocation(), FireworkEffect.builder().withColor(Color.LIME).with(FireworkEffect.Type.BALL).build()); + player.sendMessage(F.main("Melonhead", C.cYellow + "Wham! " + C.cGray + "You just got " + C.cGreen + "MELON'D!")); + + Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), () -> + { + if (_heads.containsKey(player.getUniqueId())) + { + ItemStack item = _heads.remove(player.getUniqueId()); + + if (player.getInventory().getHelmet() != null && player.getInventory().getHelmet().equals(item)) + { + player.getInventory().setHelmet(null); + + } + } + + }, TIME); + } + } + + + /** + * Clean hash maps on player disconnect. + */ + @EventHandler + public void onPlayerDisconnect(PlayerQuitEvent event) + { + if (isActive(event.getPlayer())) + { + if (_heads.containsKey(event.getPlayer().getUniqueId())) + { + _heads.remove(event.getPlayer().getUniqueId()); + } + } + } +} From 7c77a89b48d1d3a59a9011f11c44f7c3968aa027 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 29 Jul 2017 22:26:12 -0400 Subject: [PATCH 178/183] Add ppc and flags to treasure --- .../src/mineplex/core/gadget/GadgetManager.java | 8 ++++++-- .../mineplex/core/powerplayclub/PowerPlayClubRewards.java | 1 + .../src/mineplex/core/treasure/gui/TreasurePage.java | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 18632e6f6..096d71cc9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -16,6 +16,7 @@ import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; import mineplex.core.gadget.gadgets.flag.FlagType; import mineplex.core.gadget.gadgets.morph.MorphBobRoss; import mineplex.core.gadget.gadgets.morph.MorphFreedomFighter; +import mineplex.core.gadget.gadgets.morph.MorphMelonHead; import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; @@ -469,6 +470,7 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphAwkwardRabbit(this)); addGadget(new MorphBobRoss(this, _hologramManager)); addGadget(new MorphFreedomFighter(this)); + addGadget(new MorphMelonHead(this)); // Particles addGadget(new ParticleFoot(this)); @@ -651,8 +653,10 @@ public class GadgetManager extends MiniPlugin addGadget(new RainbowTaunt(this)); // Flags - addGadget(new FlagGadget(this, FlagType.UNITED_STATES)); - addGadget(new FlagGadget(this, FlagType.CANADA)); + for (FlagType flag : FlagType.values()) + { + addGadget(new FlagGadget(this, flag)); + } // Kit Selectors addGadget(new WaterWingsKitSelector(this)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index 8dc08a791..9f40681c2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -40,6 +40,7 @@ public class PowerPlayClubRewards .put(YearMonth.of(2017, Month.MAY), new UnknownSalesPackageItem("King")) .put(YearMonth.of(2017, Month.JUNE), new UnknownSalesPackageItem("Bob Ross Morph")) .put(YearMonth.of(2017, Month.JULY), new UnknownSalesPackageItem("Freedom Fighter")) + .put(YearMonth.of(2017, Month.AUGUST), new UnknownSalesPackageItem("Melonhead Morph")) .build(); public interface PowerPlayClubItem diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index 9abd2b5e6..d4efbd24a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -752,7 +752,7 @@ public class TreasurePage extends ShopPageBase _gadgetManager.getHatGadget(HatType.AMERICA), _gadgetManager.getHatGadget(HatType.CANADA), _gadgetManager.getFlagGadget(FlagType.CANADA), - _gadgetManager.getFlagGadget(FlagType.UNITED_STATES), + _gadgetManager.getFlagGadget(FlagType.USA), }; Mount freedomMount = _gadgetManager.getMountManager().getMount("Freedom Mount"); if (freedomMount != null) From 04f182c745de40afbdea2e654d111f20ea3bc9e0 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 29 Jul 2017 22:26:21 -0400 Subject: [PATCH 179/183] Add old holiday items into omega chests --- .../mineplex/core/reward/RewardManager.java | 51 +++++++++++++++++-- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 783e16317..f31a0b0f8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -331,6 +331,9 @@ public class RewardManager addGadget(Type.FREEDOM, getGadget(ArrowTrailFreedom.class), rarity, 150); // Omega items + addGadget(Type.OMEGA, getGadget(ArrowTrailRedWhite.class), rarity, 2); + addGadget(Type.OMEGA, getGadget(ArrowTrailFreedom.class), rarity, 2); + addMusicReward(Type.OMEGA, "Blocks Disc", rarity, 25); addMusicReward(Type.OMEGA, "Cat Disc", rarity, 25); addMusicReward(Type.OMEGA, "Chirp Disc", rarity, 25); @@ -513,6 +516,9 @@ public class RewardManager addGadget(Type.OMEGA, getGadget(DoubleJumpStorm.class), rarity, 30); addGadget(Type.OMEGA, getGadget(DoubleJumpCandyCane.class), rarity, 20); addGadget(Type.OMEGA, getGadget(DoubleJumpHalloween.class), rarity, 50); + addGadget(Type.OMEGA, getGadget(DoubleJumpSpring.class), rarity, 40); + addGadget(Type.OMEGA, getGadget(DoubleJumpFreedom.class), rarity, 50); + addGadget(Type.OMEGA, getGadget(DoubleJumpMaple.class), rarity, 50); addGadget(Type.OMEGA, getGadget(DeathFreedom.class), rarity, 15); addGadget(Type.OMEGA, getGadget(DeathStorm.class), rarity, 30); @@ -522,6 +528,8 @@ public class RewardManager addGadget(Type.OMEGA, getGadget(DeathPinataBurst.class), rarity, 27); addGadget(Type.OMEGA, getGadget(DeathShadow.class), rarity, 15); addGadget(Type.OMEGA, getGadget(DeathCandyCane.class), rarity, 25); + addGadget(Type.OMEGA, getGadget(DeathSpring.class), rarity, 60); + addGadget(Type.OMEGA, getGadget(DeathMapleLeaf.class), rarity, 10); addGadget(Type.OMEGA, getGadget(ArrowTrailFreedom.class), rarity, 10); addGadget(Type.OMEGA, getGadget(ArrowTrailConfetti.class), rarity, 27); @@ -531,6 +539,7 @@ public class RewardManager addGadget(Type.OMEGA, getGadget(ArrowTrailStorm.class), rarity, 30); addGadget(Type.OMEGA, getGadget(ArrowTrailShadow.class), rarity, 15); addGadget(Type.OMEGA, getGadget(ArrowTrailCandyCane.class), rarity, 10); + addGadget(Type.OMEGA, getGadget(ArrowTrailSpring.class), rarity, 60); addHat(Type.OMEGA, HatType.UNCLE_SAM, rarity, 25); addHat(Type.OMEGA, HatType.COMPANION_BLOCK, rarity, 15); @@ -540,6 +549,8 @@ public class RewardManager addHat(Type.OMEGA, HatType.SANTA, rarity, 25); addHat(Type.OMEGA, HatType.RUDOLPH, rarity, 25); addHat(Type.OMEGA, HatType.COAL, rarity, 25); + addHat(Type.OMEGA, HatType.AMERICA, rarity, 50); + addHat(Type.OMEGA, HatType.CANADA, rarity, 50); addGadget(Type.OMEGA, getGadget(MorphChicken.class), rarity, 50); addGadget(Type.OMEGA, getGadget(MorphCow.class), rarity, 167); @@ -553,6 +564,7 @@ public class RewardManager addMount(Type.OMEGA, getMount(MountCart.class), rarity, 100); addMount(Type.OMEGA, getMount(MountMule.class), rarity, 200); addMount(Type.OMEGA, getMount(MountSlime.class), rarity, 67); + addMount(Type.OMEGA, getMount(MountLoveTrain.class), rarity, 20); addGadget(Type.OMEGA, getGadget(OutfitRaveSuitBoots.class), rarity, 30); addGadget(Type.OMEGA, getGadget(OutfitRaveSuitChestplate.class), rarity, 30); @@ -562,8 +574,15 @@ public class RewardManager addGadget(Type.OMEGA, getGadget(OutfitSpaceSuitChestplate.class), rarity, 50); addGadget(Type.OMEGA, getGadget(OutfitSpaceSuitLeggings.class), rarity, 50); addGadget(Type.OMEGA, getGadget(OutfitSpaceSuitHelmet.class), rarity, 50); + addGadget(Type.OMEGA, getGadget(OutfitStPatricksChestplate.class),rarity, 50); + addGadget(Type.OMEGA, getGadget(OutfitStPatricksLeggings.class), rarity, 50); + addGadget(Type.OMEGA, getGadget(OutfitStPatricksBoots.class), rarity, 50); + addGadget(Type.OMEGA, getGadget(OutfitFreezeSuitChestplate.class),rarity, 50); + addGadget(Type.OMEGA, getGadget(OutfitFreezeSuitLeggings.class), rarity, 50); + addGadget(Type.OMEGA, getGadget(OutfitFreezeSuitBoots.class), rarity, 50); - addGadget(Type.OMEGA, getGadget(ParticleCandyCane.class), rarity, 25); + addGadget(Type.OMEGA, getGadget(ParticleCandyCane.class), rarity, 20); + addGadget(Type.OMEGA, getGadget(ParticleChristmasTree.class), rarity, 40); addBalloon(Type.OMEGA, BalloonType.BABY_ZOMBIE, rarity, 25, 500); addBalloon(Type.OMEGA, BalloonType.BABY_MUSHROOM, rarity, 50, 500); @@ -778,7 +797,7 @@ public class RewardManager addGadget(Type.FREEDOM, getGadget(ParticleCanadian.class), rarity, 10); addGadget(Type.FREEDOM, getGadget(ParticleStarSpangled.class), rarity, 10); addFlag(Type.FREEDOM, FlagType.CANADA, rarity, 35); - addFlag(Type.FREEDOM, FlagType.UNITED_STATES, rarity, 35); + addFlag(Type.FREEDOM, FlagType.USA, rarity, 35); // Omega items addPetReward(Type.OMEGA, PetType.VILLAGER, rarity, 1); @@ -786,6 +805,9 @@ public class RewardManager addPetReward(Type.OMEGA, PetType.PIG_ZOMBIE, rarity, 1); addPetReward(Type.OMEGA, PetType.BLAZE, rarity, 2); addPetReward(Type.OMEGA, PetType.RABBIT, rarity, 10); + addPetReward(Type.OMEGA, PetType.KILLER_BUNNY, rarity, 3); + addPetReward(Type.OMEGA, PetType.CUPID_PET, rarity, 40); + addPetReward(Type.OMEGA, PetType.LEPRECHAUN, rarity, 8); addGadget(Type.OMEGA, getGadget(MorphBunny.class), rarity, 1); addGadget(Type.OMEGA, getGadget(MorphUncleSam.class), rarity, 5); @@ -795,6 +817,8 @@ public class RewardManager addGadget(Type.OMEGA, getGadget(MorphBlock.class), rarity, 20); addGadget(Type.OMEGA, getGadget(MorphSnowman.class), rarity, 10); addGadget(Type.OMEGA, getGadget(MorphGrimReaper.class), rarity, 25); + addGadget(Type.OMEGA, getGadget(MorphAwkwardRabbit.class), rarity, 30); + addGadget(Type.OMEGA, getGadget(MorphLoveDoctor.class), rarity, 40); addGadget(Type.OMEGA, getGadget(ParticleFreedom.class), rarity, 15); addGadget(Type.OMEGA, getGadget(ParticleWingsAngel.class), rarity, 15); @@ -814,14 +838,23 @@ public class RewardManager addGadget(Type.OMEGA, getGadget(ParticleCoalFumes.class), rarity, 1); addGadget(Type.OMEGA, getGadget(ParticleFrostLord.class), rarity, 10); addGadget(Type.OMEGA, getGadget(ParticlePartyTime.class), rarity, 25); + addGadget(Type.OMEGA, getGadget(ParticleSpringHalo.class), rarity, 8); + addGadget(Type.OMEGA, getGadget(ParticleWingsLove.class), rarity, 10); + addGadget(Type.OMEGA,getGadget(ParticleFreedomFireworks.class),rarity,24); + addGadget(Type.OMEGA, getGadget(ParticleAuraNiceness.class), rarity, 4); + addGadget(Type.OMEGA, getGadget(ParticleCanadian.class), rarity, 1); + addGadget(Type.OMEGA, getGadget(ParticleStarSpangled.class), rarity, 1); - addMount(Type.OMEGA, getMount(MountFreedomHorse.class), rarity, 1); + addMount(Type.OMEGA, getMount(MountFreedomHorse.class), rarity, 5); addMount(Type.OMEGA, getMount(MountZombie.class), rarity, 1); addMount(Type.OMEGA, getMount(MountSpider.class), rarity, 1); addMount(Type.OMEGA, getMount(MountUndead.class), rarity, 1); - addMount(Type.OMEGA, getMount(MountValentinesSheep.class), rarity, 33); + addMount(Type.OMEGA, getMount(MountValentinesSheep.class), rarity, 20); addMount(Type.OMEGA, getMount(MountBabyReindeer.class), rarity, 1); addMount(Type.OMEGA, getMount(MountNightmareSteed.class), rarity, 10); + addMount(Type.OMEGA, getMount(MountChicken.class), rarity, 5); + addMount(Type.OMEGA, getMount(MountCake.class), rarity, 10); + addMount(Type.OMEGA, getMount(MountStPatricksHorse.class), rarity, 3); addGadget(Type.OMEGA, getGadget(WinEffectBabyChicken.class), rarity, 10); addGadget(Type.OMEGA, getGadget(WinEffectLavaTrap.class), rarity, 20); @@ -832,7 +865,8 @@ public class RewardManager addGadget(Type.OMEGA, getGadget(DeathEnchant.class), rarity, 10); addGadget(Type.OMEGA, getGadget(DeathCupidsBrokenHeart.class), rarity, 25); - addGadget(Type.OMEGA, getGadget(DeathFrostLord.class), rarity, 20); + addGadget(Type.OMEGA, getGadget(DeathFrostLord.class), rarity, 15); + addGadget(Type.OMEGA, getGadget(DeathPresentDanger.class), rarity, 27); addGadget(Type.OMEGA, getGadget(DoubleJumpEnchant.class), rarity, 10); addGadget(Type.OMEGA, getGadget(DoubleJumpCupidsWings.class), rarity, 5); @@ -844,6 +878,9 @@ public class RewardManager addHat(Type.OMEGA, HatType.GRINCH, rarity, 25); + addGadget(Type.OMEGA, getGadget(OutfitStPatricksHat.class), rarity, 5); + addGadget(Type.OMEGA, getGadget(OutfitFreezeSuitHelmet.class), rarity, 2); + addBalloon(Type.OMEGA, BalloonType.SQUID, rarity, 10, 5000); addBalloon(Type.OMEGA, BalloonType.SILVERFISH, rarity, 30, 5000); addBalloon(Type.OMEGA, BalloonType.GUARDIAN, rarity, 30, 5000); @@ -863,6 +900,10 @@ public class RewardManager addBalloon(Type.NORMAL, BalloonType.GOLD_BLOCK, rarity, 30, 5000);*/ addBalloon(Type.NORMAL, BalloonType.EMERALD_BLOCK, rarity, 15, 5000); + addGadget(Type.OMEGA, getGadget(BlowAKissTaunt.class), rarity, 7); + addGadget(Type.OMEGA, getGadget(RainbowTaunt.class), rarity, 1); + + // HAUNTED addPetReward(Type.HAUNTED, PetType.RABBIT, rarity, 100); addGadget(Type.HAUNTED, getGadget(MorphGrimReaper.class), rarity, 25); From 8c911586dcafd577f3515086bf77c34d36143594 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 29 Jul 2017 22:53:29 -0400 Subject: [PATCH 180/183] Clean and document code --- .../core/cosmetic/ui/page/FlagPage.java | 4 ++- .../gadget/gadgets/morph/MorphMelonHead.java | 29 +++++-------------- .../core/gadget/types/FlagGadget.java | 2 -- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java index c5fc5e852..34009c2b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/FlagPage.java @@ -9,7 +9,6 @@ import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -37,8 +36,10 @@ public class FlagPage extends GadgetPage @Override protected void buildPage() { + // chose a beginning slot int slot = 10; + // grab all flags List list = getPlugin().getGadgetManager().getGadgets(GadgetType.FLAG); if(list != null) @@ -46,6 +47,7 @@ public class FlagPage extends GadgetPage int size = list.size(); int limit = (_page + 1) * 28; + // loop through the flags for a specific page for (int i = _page * 28; i < limit && i < size; ++i) { Gadget gadget = list.get(i); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java index 2b503bfad..91731165c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java @@ -5,49 +5,28 @@ import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilSound; import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; -import mineplex.core.hologram.Hologram; -import mineplex.core.hologram.HologramManager; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.recharge.Recharge; -import mineplex.core.treasure.event.TreasureFinishEvent; -import mineplex.core.treasure.event.TreasureStartEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilGameProfile; import org.apache.commons.lang3.tuple.Pair; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; -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.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; -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 java.time.Month; import java.time.YearMonth; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -118,6 +97,7 @@ public class MorphMelonHead extends MorphGadget @EventHandler public void handlePlayerInteract(EntityDamageByEntityEvent event) { + // Check it's two players interacting if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) { if (!isActive((Player) event.getDamager())) @@ -127,31 +107,38 @@ public class MorphMelonHead extends MorphGadget Player player = (Player) event.getEntity(); + // do nothing if the player has a helmet already if (player.getInventory().getHelmet() != null) { return; } + // do nothing if the player is supposed to already have a fruit helmet if (_heads.containsKey(player.getUniqueId())) { return; } + // select a head skin and name it Pair data = TEXTURES[ThreadLocalRandom.current().nextInt(TEXTURES.length)]; ItemStack head = data.getLeft().getSkull(data.getRight(), new ArrayList<>()); + // equip the head and notify the player of the action _heads.put(player.getUniqueId(), head); player.getInventory().setHelmet(head); player.getWorld().playSound(player.getEyeLocation(), Sound.CHICKEN_EGG_POP, 1, 0); UtilFirework.playFirework(player.getEyeLocation(), FireworkEffect.builder().withColor(Color.LIME).with(FireworkEffect.Type.BALL).build()); player.sendMessage(F.main("Melonhead", C.cYellow + "Wham! " + C.cGray + "You just got " + C.cGreen + "MELON'D!")); + // schedule the head to be removed later Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), () -> { + // don't do anything if the player has logged off if (_heads.containsKey(player.getUniqueId())) { ItemStack item = _heads.remove(player.getUniqueId()); + // don't remove the helmet if it has already been changed. if (player.getInventory().getHelmet() != null && player.getInventory().getHelmet().equals(item)) { player.getInventory().setHelmet(null); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java index ab9697c84..7a7f255f3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java @@ -5,7 +5,6 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.flag.FlagType; import org.bukkit.Material; @@ -15,7 +14,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.ItemMeta; /** From 2fd67836adb051410fad9e21e9fbaccf70d36c27 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 29 Jul 2017 23:25:40 -0400 Subject: [PATCH 181/183] Add missing bold code --- .../src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java index 91731165c..4b2ce16c6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java @@ -40,7 +40,7 @@ public class MorphMelonHead extends MorphGadget /** Fruit head texture options */ private static final Pair[] TEXTURES = { Pair.of(SkinData.APPLE, C.cDRedB + "Apple Head"), - Pair.of(SkinData.MELON, C.cDGreen + "Melon Head"), + Pair.of(SkinData.MELON, C.cDGreenB + "Melon Head"), Pair.of(SkinData.ORANGE, C.cGoldB + "Orange Head"), Pair.of(SkinData.STRAWBERRY, C.cRedB + "Berry Head"), Pair.of(SkinData.PINEAPPLE, C.cYellowB + "Pineapple Head"), From 8310849f047967151a02cb3e0fc87f848a78d1f2 Mon Sep 17 00:00:00 2001 From: Graphica Date: Sat, 29 Jul 2017 23:25:46 -0400 Subject: [PATCH 182/183] Hide new flags for now --- .../src/mineplex/core/gadget/GadgetManager.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 096d71cc9..2e871dcc8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -653,10 +653,9 @@ public class GadgetManager extends MiniPlugin addGadget(new RainbowTaunt(this)); // Flags - for (FlagType flag : FlagType.values()) - { - addGadget(new FlagGadget(this, flag)); - } + addGadget(new FlagGadget(this, FlagType.CANADA)); + addGadget(new FlagGadget(this, FlagType.USA)); + // Kit Selectors addGadget(new WaterWingsKitSelector(this)); From 08401533941a42c61d6e59d37ff2176f477721d9 Mon Sep 17 00:00:00 2001 From: Graphica Date: Wed, 2 Aug 2017 19:17:18 -0400 Subject: [PATCH 183/183] Add legacy sales package to flags --- .../src/mineplex/core/gadget/types/FlagGadget.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java index 7a7f255f3..3dabbad32 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/FlagGadget.java @@ -27,7 +27,7 @@ public class FlagGadget extends Gadget { super(manager, GadgetType.FLAG, "Flag of " + flag.getFlag().getCountryName(), UtilText.splitLineToArray(C.cGray + "Fly the " + flag.getFlag().getCountryAdjective() + " flag atop your head!", LineFormat.LORE), - flag.getCost(), Material.WOOL, (byte) 0); + flag.getCost(), Material.WOOL, (byte) 0, 1, flag.getFlag().getCountryAdjective() + " Flag"); setDisplayItem(flag.getFlag().getBanner()); _flag = flag;