From 3b9d6adfbcb30ed00b70d0b9db73a2429292b00c Mon Sep 17 00:00:00 2001 From: TadahTech Date: Tue, 23 Aug 2016 01:37:05 -0500 Subject: [PATCH] Lobby Update --- .../core/common/SortedSchematicLoader.java | 1 + .../mineplex/core/common/util/UtilPlayer.java | 88 ++++- .../interactions/NewInteractionsManager.java | 77 +++++ .../src/mineplex/core/antihack/AntiHack.java | 3 +- .../core/brawl/fountain/Fountain.java | 8 +- .../core/brawl/fountain/FountainManager.java | 9 +- .../src/mineplex/core/chat/Chat.java | 3 +- .../mineplex/core/friend/FriendManager.java | 20 +- .../core/friend/command/AddFriend.java | 16 +- .../core/friend/command/FriendsDisplay.java | 9 +- .../core/gadget/gadgets/item/ItemBatGun.java | 28 +- .../commands/IncognitoToggleCommand.java | 3 +- .../interactions/NewInteractionsManager.java | 77 +++++ .../src/mineplex/core/menu/Button.java | 70 ++++ .../{party/ui/button => menu}/IconButton.java | 8 +- .../core/{party/ui => menu}/Menu.java | 142 ++++---- .../core/{party/ui => menu}/MenuListener.java | 37 +- .../src/mineplex/core/menu/MenuManager.java | 18 + .../mineplex/core/message/MessageManager.java | 3 +- .../core/notifier/NotificationManager.java | 12 +- .../src/mineplex/core/party/Lang.java | 42 ++- .../src/mineplex/core/party/Party.java | 125 +++++-- .../core/party/PartyEventListener.java | 10 +- .../src/mineplex/core/party/PartyManager.java | 25 +- .../party/command/TeamPreferenceCommand.java | 167 +++++++++ .../party/manager/PartyInviteManager.java | 2 +- .../core/party/manager/PartyJoinManager.java | 36 +- .../party/manager/PartyMethodManager.java | 29 +- .../core/party/manager/PartyRedisManager.java | 17 +- .../src/mineplex/core/party/ui/Button.java | 45 --- .../src/mineplex/core/party/ui/PartyMenu.java | 27 ++ .../ui/button/tools/LeavePartyButton.java | 6 +- .../party/ui/button/tools/PartyButton.java | 6 +- .../button/tools/SelectPartnerGameButton.java | 40 +++ .../ui/button/tools/invite/BackButton.java | 6 +- .../ui/button/tools/invite/DenyAllButton.java | 6 +- .../ui/button/tools/invite/FilterButton.java | 20 +- .../ui/button/tools/invite/InviteButton.java | 6 +- .../button/tools/invite/NextPageButton.java | 12 +- .../button/tools/invite/PrevPageButton.java | 12 +- .../button/tools/main/InvitePlayerButton.java | 6 +- .../button/tools/main/ViewInvitesButton.java | 4 +- .../button/tools/owner/AddPlayerButton.java | 2 +- .../tools/owner/DisbandPartyButton.java | 6 +- .../button/tools/owner/KickPlayerButton.java | 6 +- .../tools/owner/SelectServerButton.java | 2 +- .../tools/owner/TransferOwnerButton.java | 4 +- .../party/ui/menus/PartnerRequestMenu.java | 55 +++ .../core/party/ui/menus/PartyInvitesMenu.java | 40 ++- .../core/party/ui/menus/PartyMainMenu.java | 12 +- .../core/party/ui/menus/PartyOwnerMenu.java | 37 +- .../core/party/ui/menus/PartyViewMenu.java | 22 +- .../mineplex/core/preferences/Preference.java | 106 ++++++ .../core/preferences/PreferenceCategory.java | 42 +++ .../core/preferences/PreferencesManager.java | 210 ++++++------ .../preferences/PreferencesRepository.java | 222 ++++++------ .../core/preferences/UserPreferences.java | 61 +++- .../command/PreferencesCommand.java | 7 +- .../ui/ExclusivePreferencesPage.java | 241 ------------- .../ui/ExclusivePreferencesShop.java | 29 -- .../preferences/ui/PreferenceMainMenu.java | 67 ++++ .../core/preferences/ui/PreferencesPage.java | 265 --------------- .../core/preferences/ui/PreferencesShop.java | 25 -- .../preferences/ui/buttons/BackButton.java | 41 +++ .../ui/buttons/CategoryButton.java | 29 ++ .../ui/buttons/PreferenceButton.java | 63 ++++ .../ui/buttons/PreferenceDyeButton.java | 43 +++ .../preferences/ui/menus/PreferenceMenu.java | 85 +++++ .../progression/KitProgressionManager.java | 2 - .../core/progression/ProgressiveKit.java | 13 +- .../mineplex/core/progression/gui/Button.java | 36 -- .../mineplex/core/progression/gui/Menu.java | 191 ----------- .../core/progression/gui/MenuListener.java | 45 --- .../gui/buttons/KitAbilityButton.java | 2 +- .../progression/gui/buttons/KitButton.java | 12 +- .../gui/buttons/KitIconButton.java | 3 +- .../buttons/KitPermanentDefaultButton.java | 3 +- .../gui/buttons/KitSelectButton.java | 3 +- .../gui/buttons/KitUpgradeButton.java | 5 +- .../gui/buttons/KitUpgradeMenuButton.java | 25 +- .../progression/gui/buttons/KitXPButton.java | 3 +- .../gui/buttons/misc/BackButton.java | 10 +- .../gui/buttons/misc/IconButton.java | 23 -- .../progression/gui/guis/KitDisplayMenu.java | 33 +- .../gui/guis/KitInformationTrackerMenu.java | 33 +- .../core/progression/gui/guis/KitMenu.java | 69 +--- .../mineplex/core/report/ReportManager.java | 23 +- .../core/treasure/TreasureLocation.java | 65 ++-- .../core/treasure/TreasureManager.java | 127 +++---- .../src/mineplex/clanshub/HubManager.java | 19 +- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 26 +- .../src/mineplex/hub/HubManager.java | 89 +++-- .../src/mineplex/hub/HubScoreboardLine.java | 4 +- .../hub/modules/ForcefieldManager.java | 18 +- .../modules/HalloweenSpookinessManager.java | 15 +- .../hub/modules/HubVisibilityManager.java | 43 ++- .../src/mineplex/hub/modules/JumpManager.java | 26 +- .../src/mineplex/hub/modules/KothManager.java | 39 ++- .../mineplex/hub/modules/ParkourManager.java | 316 +++++++++++------- .../mineplex/hub/modules/SoccerManager.java | 69 ++-- .../mineplex/hub/modules/WorldManager.java | 198 +++++++---- .../hub/profile/buttons/ButtonPrefs.java | 6 +- .../mineplex/hub/server/ServerManager.java | 97 +----- .../src/mineplex/staffServer/StaffServer.java | 9 +- .../src/nautilus/game/arcade/Arcade.java | 28 +- .../nautilus/game/arcade/ArcadeManager.java | 45 ++- .../game/games/valentines/Valentines.java | 78 ++--- .../game/arcade/kit/ProgressingKit.java | 31 +- .../managers/ProgressingKitManager.java | 195 ++++++----- .../arcade/managers/chat/GameChatManager.java | 4 +- 110 files changed, 2789 insertions(+), 2295 deletions(-) create mode 100644 Plugins/Mineplex.Core/interactions/NewInteractionsManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/interactions/NewInteractionsManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/menu/Button.java rename Plugins/Mineplex.Core/src/mineplex/core/{party/ui/button => menu}/IconButton.java (64%) rename Plugins/Mineplex.Core/src/mineplex/core/{party/ui => menu}/Menu.java (61%) rename Plugins/Mineplex.Core/src/mineplex/core/{party/ui => menu}/MenuListener.java (60%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/menu/MenuManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/command/TeamPreferenceCommand.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/Button.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/PartyMenu.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/SelectPartnerGameButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartnerRequestMenu.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferenceCategory.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesShop.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesShop.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/BackButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/CategoryButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceDyeButton.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/menus/PreferenceMenu.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/progression/gui/Button.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/progression/gui/Menu.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/progression/gui/MenuListener.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/IconButton.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/SortedSchematicLoader.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/SortedSchematicLoader.java index 7b985dd82..279747684 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/SortedSchematicLoader.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/SortedSchematicLoader.java @@ -42,6 +42,7 @@ public class SortedSchematicLoader if (entry != null && !entry.getKey().equals(_currentValue)) { _currentValue = entry.getKey(); + Schematic schematic = entry.getValue(); entry.getValue().paste(_pasteLocation, false); } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 366c6fc35..68c22f307 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -1,8 +1,16 @@ package mineplex.core.common.util; -import java.util.*; - -import net.minecraft.server.v1_8_R3.*; +import mineplex.core.common.MinecraftVersion; +import mineplex.core.common.events.PlayerMessageEvent; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ClickEvent.Action; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.Packet; +import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder; +import net.minecraft.server.v1_8_R3.PlayerConnection; +import net.minecraft.server.v1_8_R3.WorldBorder; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; @@ -20,8 +28,17 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.util.BlockIterator; import org.bukkit.util.Vector; -import mineplex.core.common.MinecraftVersion; -import mineplex.core.common.events.PlayerMessageEvent; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.UUID; public class UtilPlayer { @@ -945,6 +962,67 @@ public class UtilPlayer ALLOWED_COMMANDS.remove(player.getUniqueId()); } + /** + * Sends a formatted clickable accept or deny (or view) message to a player + * Both ACCEPT and DENY will always be sent, but VIEW will only be sent when viewCommand is not null + * + * @param player The player to send the message to + * @param header The message header, such as Party or Game + * @param acceptCommand The command to be run if ACCEPT is clicked + * @param acceptDisplayText The text displayed when hovering over ACCEPT + * @param declineCommand The command to be run when DENY is clicked + * @param declineDisplayText The text displayed when hovering over DENY + * @param viewCommand Optional The command to be run when VIEW is clicked + * @param viewDisplayText Optional The text displayed when hovering over VIEW + */ + public static void sendAcceptOrDeny(Player player, String header, + String acceptCommand, String acceptDisplayText, + String declineCommand, String declineDisplayText, + String viewCommand, String viewDisplayText) + { + TextComponent textComponent = new TextComponent(F.main(header, "Reply: ")); + + TextComponent accept = new TextComponent("ACCEPT"); + accept.setColor(net.md_5.bungee.api.ChatColor.GREEN); + accept.setBold(true); + accept.setClickEvent(new ClickEvent(Action.RUN_COMMAND, acceptCommand)); + accept.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{ + new TextComponent(acceptDisplayText) + })); + + textComponent.addExtra(accept); + textComponent.addExtra(" "); + + TextComponent deny = new TextComponent("DENY"); + deny.setColor(net.md_5.bungee.api.ChatColor.RED); + deny.setBold(true); + deny.setClickEvent(new ClickEvent(Action.RUN_COMMAND, declineCommand)); + deny.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{ + new TextComponent(declineDisplayText) + })); + + textComponent.addExtra(deny); + + if(viewCommand != null) + { + textComponent.addExtra(" "); + + TextComponent view = new TextComponent("VIEW"); + view.setColor(net.md_5.bungee.api.ChatColor.YELLOW); + view.setBold(true); + view.setClickEvent(new ClickEvent(Action.RUN_COMMAND, viewCommand)); + if(viewDisplayText != null) + { + view.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{ + new TextComponent(viewDisplayText) + })); + } + textComponent.addExtra(view); + } + + player.spigot().sendMessage(textComponent); + } + /* * Returns whether the UUID belongs to a slim skin */ diff --git a/Plugins/Mineplex.Core/interactions/NewInteractionsManager.java b/Plugins/Mineplex.Core/interactions/NewInteractionsManager.java new file mode 100644 index 000000000..766c2455b --- /dev/null +++ b/Plugins/Mineplex.Core/interactions/NewInteractionsManager.java @@ -0,0 +1,77 @@ +package mineplex.core.interactions; + +import mineplex.core.MiniPlugin; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.Event.Result; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.player.PlayerArmorStandManipulateEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.Inventory; + +/** + * Manages interactions with Armor stands, paintings, and in the main hub, taking items out of chests. + */ +public class NewInteractionsManager extends MiniPlugin +{ + + public NewInteractionsManager() + { + super("Interactions Manager"); + registerEvents(this); + } + + @EventHandler + public void onInteract(PlayerArmorStandManipulateEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onClickBrewingStand(PlayerInteractEvent event) + { + if(event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.BREWING_STAND) + { + event.setCancelled(true); + event.setUseInteractedBlock(Result.DENY); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onChestInteract(InventoryClickEvent event) + { + Player player = (Player) event.getWhoClicked(); + Inventory inventory = event.getClickedInventory(); + + if(inventory == null) + { + return; + } + + if(event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR) + { + return; + } + + if(inventory.getType() != InventoryType.CHEST) + { + return; + } + + if(inventory.getSize() != 27 && inventory.getSize() != 54) + { + return; + } + + if(inventory.getTitle() != null) + { + return; + } + + event.setCancelled(true); + event.setResult(Result.DENY); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 44430ffdb..f5c17371a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -26,6 +26,7 @@ import mineplex.core.common.util.*; import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.portal.Portal; +import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.punish.Category; import mineplex.core.punish.Punish; @@ -187,7 +188,7 @@ public class AntiHack extends MiniPlugin { ((CraftPlayer) player).getHandle().sendMessage(getDetailedMessage(violation)); - } else if (_clientManager.Get(player).GetRank().has(Rank.HELPER) && (violation.getOriginatingServer().equals(_thisServer) || Managers.get(PreferencesManager.class).Get(player).ShowMacReports)) + } else if (_clientManager.Get(player).GetRank().has(Rank.HELPER) && (violation.getOriginatingServer().equals(_thisServer) || Managers.get(PreferencesManager.class).get(player).isActive(Preference.SHOW_MAC_REPORTS))) { ((CraftPlayer) player).getHandle().sendMessage(component); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java index 471bfe8e2..2bf237c43 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java @@ -12,19 +12,13 @@ import mineplex.core.donation.DonationManager; import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; import mineplex.core.stats.StatsManager; -import mineplex.core.thread.ThreadPool; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.Region; import mineplex.serverdata.redis.counter.GoalCounter; import mineplex.serverdata.redis.counter.GoalCounterListener; import mineplex.serverdata.servers.ConnectionData; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; import java.io.File; import java.io.IOException; @@ -63,7 +57,7 @@ public class Fountain implements GoalCounterListener _name = name; _dataKey = dataKey; _location = location; - _hologram = new Hologram(hologramManager, location.clone().add(4, 3, -3), name).start(); + _hologram = new Hologram(hologramManager, new Location(location.getWorld(), -23, 75, 3), name).start(); _counter = new GoalCounter(writeConnection, readConnection, region, dataKey, goal); _counter.addListener(this); _brawlActive = false; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java index d141e1997..8fb7009fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java @@ -3,17 +3,13 @@ package mineplex.core.brawl.fountain; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.brawl.fountain.command.FountainCommand; -import mineplex.core.brawl.fountain.gui.FountainShop; import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilWorld; import mineplex.core.donation.DonationManager; import mineplex.core.hologram.HologramManager; import mineplex.core.stats.StatsManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.Region; -import mineplex.serverdata.redis.counter.Counter; import mineplex.serverdata.servers.ConnectionData; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -22,12 +18,9 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.plugin.java.JavaPlugin; -import java.io.File; - /** * @author Shaun Bennett */ @@ -55,7 +48,7 @@ public class FountainManager extends MiniPlugin int goal = 70000000;//!new File("eu.dat").exists() ? 200000000 : 20000000; _gemFountain = new Fountain(new ConnectionData("10.3.203.80", 6379, ConnectionData.ConnectionType.MASTER, "USRedis"), new ConnectionData("10.3.203.80", 6377, ConnectionData.ConnectionType.SLAVE, "USRedis"), Region.ALL, - new Location(world, -32.5, 72, -23.5), new Location(world, -43.5, 67, -38.5), + new Location(world, -25.5, 73, 19.5), new Location(world, -35.5, 69, 1.5), C.cGreen + "Gem Fountain", "GemFountain_01", goal, this, clientManager, donationManager, _hologramManager, _statsManager); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index c27c6a00a..c1857b7dc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -14,6 +14,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTime; import mineplex.core.incognito.IncognitoManager; +import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -210,7 +211,7 @@ public class Chat extends MiniPlugin { for (Iterator playerIterator = event.getRecipients().iterator(); playerIterator.hasNext();) { - if (!_preferences.Get(playerIterator.next()).ShowChat) + if (!_preferences.get(playerIterator.next()).isActive(Preference.SHOW_CHAT)) playerIterator.remove(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index 2b76462b7..99a168f9f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -1,13 +1,5 @@ package mineplex.core.friend; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; - import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; @@ -25,10 +17,10 @@ import mineplex.core.friend.data.FriendData; import mineplex.core.friend.data.FriendRepository; import mineplex.core.friend.data.FriendStatus; import mineplex.core.portal.Portal; +import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; - import mineplex.serverdata.data.PlayerStatus; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -36,6 +28,14 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; + public class FriendManager extends MiniDbClientPlugin { private static FriendSorter _friendSorter = new FriendSorter(); @@ -271,7 +271,7 @@ public class FriendManager extends MiniDbClientPlugin if (friend.Status == FriendStatusType.Blocked || friend.Status == FriendStatusType.Denied) continue; - if (!_preferenceManager.Get(caller).PendingFriendRequests && friend.Status == FriendStatusType.Pending) + if (!_preferenceManager.get(caller).isActive(Preference.PENDING_FRIEND_REQUESTS) && friend.Status == FriendStatusType.Pending) continue; gotAFriend = true; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java index c7706ddd1..e75cff044 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java @@ -1,12 +1,11 @@ package mineplex.core.friend.command; -import org.bukkit.entity.Player; - import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; import mineplex.core.friend.FriendManager; import mineplex.core.friend.ui.FriendsGUI; +import mineplex.core.preferences.Preference; +import org.bukkit.entity.Player; public class AddFriend extends CommandBase { @@ -20,7 +19,7 @@ public class AddFriend extends CommandBase { if (args == null || args.length < 1) { - if (Plugin.getPreferenceManager().Get(caller).friendDisplayInventoryUI) + if (Plugin.getPreferenceManager().get(caller).isActive(Preference.FRIENDS_DISPLAY_INVENTORY_UI)) { new FriendsGUI(Plugin, caller); } @@ -31,14 +30,11 @@ public class AddFriend extends CommandBase } else { - _commandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback() + _commandCenter.GetClientManager().checkPlayerName(caller, args[0], result -> { - public void run(String result) + if (result != null) { - if (result != null) - { - Plugin.addFriend(caller, result); - } + Plugin.addFriend(caller, result); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java index 14c3b37ed..c0cc87554 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java @@ -1,5 +1,6 @@ package mineplex.core.friend.command; +import mineplex.core.preferences.Preference; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -19,15 +20,15 @@ public class FriendsDisplay extends CommandBase @Override public void Execute(Player caller, final String[] args) { - UserPreferences preferences = Plugin.getPreferenceManager().Get(caller); + UserPreferences preferences = Plugin.getPreferenceManager().get(caller); - preferences.friendDisplayInventoryUI = !preferences.friendDisplayInventoryUI; + preferences.toggle(Preference.FRIENDS_DISPLAY_INVENTORY_UI); - Plugin.getPreferenceManager().savePreferences(caller); + Plugin.getPreferenceManager().save(preferences); caller.playSound(caller.getLocation(), Sound.NOTE_PLING, 1, 1.6f); - if (preferences.friendDisplayInventoryUI) + if (preferences.isActive(Preference.FRIENDS_DISPLAY_INVENTORY_UI)) { Plugin.runAsync(() -> new FriendsGUI(Plugin, caller)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java index f0c658846..67aa5cc1e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java @@ -1,16 +1,5 @@ package mineplex.core.gadget.gadgets.item; -import java.util.ArrayList; -import java.util.HashMap; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Bat; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.util.Vector; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; @@ -18,18 +7,29 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; 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.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.Ammo; import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.preferences.Preference; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Bat; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + +import java.util.ArrayList; +import java.util.HashMap; public class ItemBatGun extends ItemGadget { @@ -102,7 +102,7 @@ public class ItemBatGun extends ItemGadget if (other.equals(cur)) continue; - if (!Manager.getPreferencesManager().Get(other).HubGames || !Manager.getPreferencesManager().Get(other).ShowPlayers) + if (!Manager.getPreferencesManager().get(other).isActive(Preference.HUB_GAMES) || !Manager.getPreferencesManager().get(other).isActive(Preference.SHOW_PLAYERS)) continue; if (!Recharge.Instance.usable(other, "Hit by Bat")) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java index b648ba36b..71f0406c3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java @@ -5,6 +5,7 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.incognito.IncognitoManager; +import mineplex.core.preferences.Preference; import org.bukkit.entity.Player; public class IncognitoToggleCommand extends CommandBase @@ -18,7 +19,7 @@ public class IncognitoToggleCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (Plugin.getPreferences().Get(caller).Invisibility && !Plugin.Get(caller).Status) + if (Plugin.getPreferences().get(caller).isActive(Preference.INVISIBILITY) && !Plugin.Get(caller).Status) { UtilPlayer.message(caller, F.main("Incognito", "You are not allowed to toggle incognito on while Hub Invisibility is enabled.")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/interactions/NewInteractionsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/interactions/NewInteractionsManager.java new file mode 100644 index 000000000..766c2455b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/interactions/NewInteractionsManager.java @@ -0,0 +1,77 @@ +package mineplex.core.interactions; + +import mineplex.core.MiniPlugin; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.Event.Result; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.player.PlayerArmorStandManipulateEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.Inventory; + +/** + * Manages interactions with Armor stands, paintings, and in the main hub, taking items out of chests. + */ +public class NewInteractionsManager extends MiniPlugin +{ + + public NewInteractionsManager() + { + super("Interactions Manager"); + registerEvents(this); + } + + @EventHandler + public void onInteract(PlayerArmorStandManipulateEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onClickBrewingStand(PlayerInteractEvent event) + { + if(event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.BREWING_STAND) + { + event.setCancelled(true); + event.setUseInteractedBlock(Result.DENY); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onChestInteract(InventoryClickEvent event) + { + Player player = (Player) event.getWhoClicked(); + Inventory inventory = event.getClickedInventory(); + + if(inventory == null) + { + return; + } + + if(event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR) + { + return; + } + + if(inventory.getType() != InventoryType.CHEST) + { + return; + } + + if(inventory.getSize() != 27 && inventory.getSize() != 54) + { + return; + } + + if(inventory.getTitle() != null) + { + return; + } + + event.setCancelled(true); + event.setResult(Result.DENY); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/menu/Button.java b/Plugins/Mineplex.Core/src/mineplex/core/menu/Button.java new file mode 100644 index 000000000..666099f18 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/menu/Button.java @@ -0,0 +1,70 @@ +package mineplex.core.menu; + +import mineplex.core.MiniPlugin; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +/** + * An abstract class for managing buttons inside of menus + */ +public abstract class Button +{ + + private ItemStack _item; + private T _plugin; + + public Button(ItemStack item, T plugin) + { + _item = item; + _plugin = plugin; + } + + public Button(ItemStack itemStack) + { + _item = itemStack; + _plugin = null; + } + + /** + * The method called when a players clicks the slot + * + * @param player The player who clicked + * @param clickType Tge type of click + */ + public abstract void onClick(Player player, ClickType clickType); + + /** + * Called when clicking on a specific item is needed, rather than just the slot + * Empty by default + * + * @param player The player who clicked + * @param clickType Tge type of click + * @param item The ItemStack clicked + */ + public void onClick(Player player, ClickType clickType, ItemStack item) + { + + } + + public boolean useItemClick() + { + return false; + } + + public ItemStack getItemStack() + { + return _item; + } + + public void setItemStack(ItemStack item) + { + _item = item; + } + + public T getPlugin() + { + return _plugin; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/IconButton.java b/Plugins/Mineplex.Core/src/mineplex/core/menu/IconButton.java similarity index 64% rename from Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/IconButton.java rename to Plugins/Mineplex.Core/src/mineplex/core/menu/IconButton.java index 0e80c09cd..738472006 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/IconButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/menu/IconButton.java @@ -1,7 +1,5 @@ -package mineplex.core.party.ui.button; +package mineplex.core.menu; -import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; @@ -13,9 +11,9 @@ import org.bukkit.inventory.ItemStack; public class IconButton extends Button { - public IconButton(ItemStack item, PartyManager plugin) + public IconButton(ItemStack item) { - super(item, plugin); + super(item); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/menu/Menu.java similarity index 61% rename from Plugins/Mineplex.Core/src/mineplex/core/party/ui/Menu.java rename to Plugins/Mineplex.Core/src/mineplex/core/menu/Menu.java index 3775d46e9..6871c92d5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/menu/Menu.java @@ -1,10 +1,7 @@ -package mineplex.core.party.ui; +package mineplex.core.menu; -import mineplex.core.common.util.C; +import mineplex.core.MiniPlugin; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.button.IconButton; -import net.md_5.bungee.api.ChatColor; import org.bukkit.Bukkit; import org.bukkit.DyeColor; import org.bukkit.Material; @@ -20,26 +17,20 @@ import java.util.UUID; /** * A class to manage dynamic creation of GUI's */ -public abstract class Menu +public abstract class Menu { - protected static final Button PANE = new IconButton(new ItemBuilder(Material.STAINED_GLASS_PANE) - .setTitle(" ") - .setData(DyeColor.LIGHT_BLUE.getWoolData()) - .build(), null); - - protected static final Button PURCHASE_MORE_SLOTS = new IconButton(new ItemBuilder(Material.REDSTONE_BLOCK) - .setTitle(C.cRed + C.Bold + "Locked!") - .setLore(" ", C.cGray + "Purchase a rank @ mineplex.com/shop", C.cGray + "Purchasing a rank increases your", C.cGray + "party size to allow 10 people!") - .build(), null); + private final ItemStack PANE = new ItemBuilder(Material.STAINED_GLASS_PANE).setTitle(" ").setData(DyeColor.LIGHT_BLUE.getWoolData()).build(); protected static final Button[] EMPTY = new Button[54]; - protected static Map MENUS = new HashMap<>(); - private String _name; + protected static final Map MENUS = new HashMap<>(); + private final String _name; + private final T _plugin; + private boolean _useClose = false; private Button[] _buttons; - protected PartyManager _plugin; + private Player _player; - public Menu(String name, PartyManager plugin) + public Menu(String name, T plugin) { _name = name; _buttons = EMPTY; @@ -51,50 +42,14 @@ public abstract class Menu return MENUS.get(name); } - /** - * Create an icon (no click action) - * - * @param item The itemstack ti display - * @return The created button - */ - protected Button create(ItemStack item) + public T getPlugin() { - return new IconButton(item, _plugin); + return _plugin; } public String getName() { - return ChatColor.translateAlternateColorCodes('&', _name); - } - - public Button[] addPanes(Button[] buttons) - { - for (int i = 0; i < 9; i++) - { - if (buttons[i] == null) - { - buttons[i] = PANE; - } - - if(buttons.length == 9) - { - continue; - } - - if (buttons[i + buttons.length - 9] == null) - { - buttons[i + buttons.length - 9] = PANE; - } - - if (i == 0 || i == 8) - { - for (int a = 9; a < buttons.length; a += 9) - { - buttons[i + a] = PANE; - } - } - } - return buttons; + return _name; } /** @@ -105,6 +60,7 @@ public abstract class Menu */ public void open(Player player) { + _player = player; setButtons(setUp(player)); if (MENUS.get(player.getUniqueId()) != null) @@ -115,7 +71,7 @@ public abstract class Menu MENUS.put(player.getUniqueId(), this); int size = (_buttons.length + 8) / 9 * 9; - Inventory inventory = Bukkit.createInventory(player, size, getName()); + Inventory inventory = Bukkit.createInventory(player, size, _name); for (int i = 0; i < _buttons.length; i++) { @@ -173,9 +129,8 @@ public abstract class Menu * * @param slot The slot to set the new button * @param button The reference to the button - * @param player The player whose GUI we'll be updating */ - public void setButton(int slot, Button button, Player player) + public void setButton(int slot, Button button) { try { @@ -184,24 +139,22 @@ public abstract class Menu { ignored.printStackTrace(); } - update(player); + update(); } /** * Refresh the players view, allows to change what the player sees, without opening and closing the GUI - * - * @param player The player whose view you wish to update */ - public void update(Player player) + public void update() { - InventoryView view = player.getOpenInventory(); + InventoryView view = _player.getOpenInventory(); if (view == null) { return; } - if (!view.getTitle().equalsIgnoreCase(getName())) + if (!view.getTitle().equalsIgnoreCase(_name)) { return; } @@ -222,25 +175,23 @@ public abstract class Menu /** * Reset this players current menu's buttons and refresh the page - * - * @param player The player whose view you wish to update */ - public void resetAndUpdate(Player player) + public void resetAndUpdate() { - InventoryView view = player.getOpenInventory(); + InventoryView view = _player.getOpenInventory(); if (view == null) { return; } - if (!view.getTitle().equalsIgnoreCase(getName())) + if (!view.getTitle().equalsIgnoreCase(_name)) { return; } Inventory inventory = view.getTopInventory(); - Button[] buttons = setUp(player); + Button[] buttons = setUp(_player); for (int i = 0; i < buttons.length; i++) { if (buttons[i] == null) @@ -254,19 +205,56 @@ public abstract class Menu } } - - public void setTitle(String title) + protected Button[] pane(Button[] buttons) { - _name = title; + for (int i = 0; i < 9; i++) + { + if (buttons[i] == null) + { + buttons[i] = new IconButton(PANE); + } + + if (buttons[i + buttons.length - 9] == null) + { + buttons[i + buttons.length - 9] = new IconButton(PANE); + } + + if (i == 0 || i == 8) + { + for (int a = 0; a < buttons.length; a += 9) + { + if (buttons[i + a] == null) + { + buttons[i + a] = new IconButton(PANE); + } + } + } + } + return buttons; } public void onClose(Player player) { - MENUS.remove(player.getUniqueId()); + } public static Menu remove(UUID uniqueId) { return MENUS.remove(uniqueId); } + + public Player getPlayer() + { + return _player; + } + + public boolean isUseClose() + { + return _useClose; + } + + public void setUseClose(boolean useClose) + { + _useClose = useClose; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/MenuListener.java b/Plugins/Mineplex.Core/src/mineplex/core/menu/MenuListener.java similarity index 60% rename from Plugins/Mineplex.Core/src/mineplex/core/party/ui/MenuListener.java rename to Plugins/Mineplex.Core/src/mineplex/core/menu/MenuListener.java index fb28a5a7c..132d68e9b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/MenuListener.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/menu/MenuListener.java @@ -1,12 +1,11 @@ -package mineplex.core.party.ui; +package mineplex.core.menu; -import mineplex.core.party.ui.button.PartyMemberIcon; -import mineplex.core.party.ui.menus.PartyOwnerMenu; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; /** * Listener for the Menu system @@ -41,17 +40,37 @@ public class MenuListener implements Listener return; } - if(button instanceof PartyMemberIcon) + if(button.useItemClick()) { - if(!(gui instanceof PartyOwnerMenu)) - { - return; - } - ((PartyMemberIcon) button).onClick(player, event.getCurrentItem()); + button.onClick(player, event.getClick(), event.getCurrentItem()); return; } button.onClick(player, event.getClick()); } + @EventHandler + public void onClose(InventoryCloseEvent event) + { + String name = event.getInventory().getName(); + Player player = (Player) event.getPlayer(); + Menu gui = Menu.get(player.getUniqueId()); + + if (gui == null) + { + return; + } + + if (!gui.getName().equalsIgnoreCase(name)) + { + return; + } + + if(gui.isUseClose()) + { + gui.onClose(player); + gui.setUseClose(false); + } + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/menu/MenuManager.java b/Plugins/Mineplex.Core/src/mineplex/core/menu/MenuManager.java new file mode 100644 index 000000000..c16022a61 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/menu/MenuManager.java @@ -0,0 +1,18 @@ +package mineplex.core.menu; + +import mineplex.core.MiniPlugin; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * + */ +public class MenuManager extends MiniPlugin +{ + + public MenuManager(JavaPlugin plugin) + { + super("Menu Manager", plugin); + getPluginManager().registerEvents(new MenuListener(), plugin); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index 3cffd8cdf..63c3e632e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -25,6 +25,7 @@ import mineplex.core.message.commands.ResendAdminCommand; import mineplex.core.message.commands.ResendCommand; import mineplex.core.message.redis.RedisMessage; import mineplex.core.message.redis.RedisMessageCallback; +import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.punish.Punish; import mineplex.core.punish.PunishClient; @@ -145,7 +146,7 @@ public class MessageManager extends MiniClientPlugin public String canReceiverMessageThem(String sender, Player target) { // If the receiver has turned off private messaging and the sender isn't a mod - if (!_preferences.Get(target).PrivateMessaging) + if (!_preferences.get(target).isActive(Preference.PRIVATE_MESSAGING)) { return C.cPurple + target.getName() + " has private messaging disabled."; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java index 64cb728bd..a139ba368 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java @@ -1,11 +1,5 @@ package mineplex.core.notifier; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; @@ -14,8 +8,10 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.preferences.PreferencesManager; -import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; public class NotificationManager extends MiniPlugin { @@ -60,7 +56,7 @@ public class NotificationManager extends MiniPlugin { for (Player player : UtilServer.getPlayers()) { - if (!_preferencesManager.Get(player).DisableAds) + if (_preferencesManager.getClientManager().Get(player).GetRank() == Rank.ALL) { player.sendMessage(C.cWhite + " "); player.sendMessage(C.cRedB + " MASSIVE WINTER SALE"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/Lang.java b/Plugins/Mineplex.Core/src/mineplex/core/party/Lang.java index 0cccd2bc9..1826241a7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/Lang.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/Lang.java @@ -1,6 +1,7 @@ package mineplex.core.party; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import org.bukkit.entity.Player; import java.text.MessageFormat; @@ -44,10 +45,25 @@ public enum Lang PARTY_FULL("Error: Your party is full!"), SERVER_CLOSED("Error: Your server is closed and you cannot invite players to join it right now!"), SERVER_FULL("Error: Your server is full and you cannot invite more players to join it right now!"), - PLAYER_IN_DIFFERENT_PARTY("Error: {0} is in a different party.") - + PLAYER_IN_DIFFERENT_PARTY("Error: {0} is in a different party."), + + PARTNER_ALREADY_INVITED("Error: You have already invited {0} to be your partner for {1}."), + PARTNER_NO_GAME("Error: {0} is not a valid game name."), + PARTNER_NO_PLAYER("Error: You didn't specify a player to partner with."), + PARTNER_NOT_ONLINE("Error: {0} is not on your server!"), + PARTNER_PLAYER_NOT_REQUESTED("Error: {0} hasn't made a partner request with you yet!"), + PARTNER_USAGE("Usage: /teampref accept/deny ."), + PARTNER_HOVER_TEXT_ACCEPT("Click to be {0}''s partner for {1}."), + PARTNER_HOVER_TEXT_DENY("Click to decline being {0}''s partner for {1}."), + PARTNER_REQUEST_SENT("Partner request sent to {0} for {1}."), + PARTNER_REQUEST_RECEIVED("Partner request from {0} for {1}."), + PARTNER_REQUEST_DENIED_SENDER("{0} has declined your partner request for {1}."), + PARTNER_REQUEST_DENIED_PLAYER("You have denied {0}''s partner request for {1}."), + PARTNER_REQUEST_ACCEPT_SENDER("{0} has accepted your partner request for {1}."), + PARTNER_REQUEST_ACCEPT_PLAYER("You have accepted {0}''s partner request for {1}."), ; - + + private String _message; Lang(String message) @@ -55,6 +71,16 @@ public enum Lang _message = message; } + public String toString(String... args) + { + return getFormatted(args); + } + + public void sendHeader(Player player, String header, String... args) + { + player.sendMessage(F.main(header, getFormatted(args))); + } + public void send(Player player, String... args) { player.sendMessage(C.mHead + "Party> " + getFormatted(args)); @@ -65,16 +91,16 @@ public enum Lang party.sendMessage(C.mHead + "Party> " + getFormatted(args)); } - private String getFormatted(String[] args) + private String getFormatted(String... args) { String color = C.mBody; - if(args.length == 0) + if (args == null || args.length == 0) { return color + _message; } - if(_message.startsWith("Error:")) + if (_message.startsWith("Error:")) { color = C.cRed; } @@ -83,7 +109,7 @@ public enum Lang String[] coloredArgs = new String[args.length]; - for(int i = 0; i < args.length; i++) + for (int i = 0; i < args.length; i++) { coloredArgs[i] = C.cYellow + args[i] + color; } @@ -96,4 +122,4 @@ public enum Lang return message; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java b/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java index a076a9a34..4c7640728 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/Party.java @@ -35,10 +35,20 @@ public class Party */ private static final int PARTY_MAX_SIZE = 16; + /** + * Partners that have already been placed + */ + private transient final List _teamed; + /** * The current leader of this party */ - private UUID _owner; + private String _owner; + + /** + * The names of all current party members + */ + private List _members; /** * The UUIDS of all current party members @@ -55,12 +65,17 @@ public class Party */ private int _size; + /** + * Team preferences + */ + private Map> _preferences; + /** * Empty constructor for GSON */ public Party() { - + _teamed = Lists.newArrayList(); } /** @@ -68,16 +83,31 @@ public class Party * * @param owner The owner / leader of the party. */ - public Party(UUID owner) + public Party(String owner) { _owner = owner; + _members = Lists.newArrayList(); _invites = Maps.newHashMap(); + _members.add(owner); + _teamed = Lists.newArrayList(); _membersByUUID = Lists.newArrayList(); + _preferences = Maps.newHashMap(); + _membersByUUID.add(Bukkit.getPlayerExact(owner).getUniqueId()); } public String getOwner() { - return Bukkit.getPlayer(_owner).getName(); + return _owner; + } + + /** + * Get the current members by their IGN + * + * @return The list of named party members + */ + public List getMembers() + { + return _members; } public Map getInvites() @@ -94,12 +124,39 @@ public class Party */ public String getName() { - return getOwner(); + return _owner; } - public List getMembers() + /** + * Gets the players preferred teammate for a game + * + * @param player The player's UUID + * @return His team preference + */ + public String getPartner(UUID player, String game) { - return this._membersByUUID; + Map prefs = _preferences.get(player); + if (prefs == null) + { + prefs = Maps.newHashMap(); + _preferences.put(player, prefs); + return null; + } + return prefs.get(game); + } + + /** + * Set a player's partner preference + * + * @param player The player + * @param game The name of the game + * @param partner The name of his partner + */ + public void setPartner(Player player, String game, String partner) + { + Map prefs = _preferences.getOrDefault(player.getUniqueId(), Maps.newHashMap()); + prefs.put(game, partner); + _preferences.put(player.getUniqueId(), prefs); } /** @@ -109,7 +166,7 @@ public class Party */ public void sendMessage(String message) { - getMembers().stream().map(Bukkit::getPlayer).forEach(player -> player.sendMessage(message)); + getMembersByUUID().stream().map(Bukkit::getPlayer).forEach(player -> player.sendMessage(message)); } public int getSize() @@ -133,14 +190,12 @@ public class Party */ public void onPlayerAdd(String player) { - Player pl = Bukkit.getPlayerExact(player); - UUID uuid = pl.getUniqueId(); _invites.remove(player); - if(_membersByUUID.contains(uuid)) + if(_members.contains(player)) { return; } - _membersByUUID.add(uuid); + _members.add(player); Lang.ADD_MEMBER.send(this, player); getMembers().forEach(s -> { @@ -152,42 +207,46 @@ public class Party /** * Called when a member of the party is removed * - * @param uuid The uuid of the player + * @param player The name of the player * @param reason The reason for his removal. */ - public void onPlayerRemove(UUID uuid, PartyRemoveReason reason) + public void onPlayerRemove(String player, PartyRemoveReason reason) { - Player bukkitPlayer = Bukkit.getPlayer(uuid); if(reason == PartyRemoveReason.DISBANDED) { + Player bukkitPlayer = Bukkit.getPlayerExact(player); Lang.DISBANDED.send(bukkitPlayer); bukkitPlayer.closeInventory(); return; } - if(_membersByUUID.size() <= 0) + + if(_members.size() <= 0) { return; } + if(reason == PartyRemoveReason.LEFT) { - if(uuid.equals(_owner) && _membersByUUID.size() > 1) + if(player.equalsIgnoreCase(_owner) && _members.size() > 1) { - _owner = _membersByUUID.get(0); - Lang.TRANSFER_OWNER.send(this, bukkitPlayer.getName(), getOwner()); - PartyTransferOwnerEvent event = new PartyTransferOwnerEvent(this, getOwner(), bukkitPlayer.getName(), TransferReason.LEFT); + _owner = _members.get(0); + Lang.TRANSFER_OWNER.send(this, player, _owner); + PartyTransferOwnerEvent event = new PartyTransferOwnerEvent(this, _owner, player, TransferReason.LEFT); UtilServer.getServer().getPluginManager().callEvent(event); return; } - Lang.REMOVE_PLAYER.send(this, bukkitPlayer.getName()); + Lang.REMOVE_PLAYER.send(this, player); return; } + if(reason == PartyRemoveReason.OTHER) { return; } + if(reason == PartyRemoveReason.KICKED) { - Lang.REMOVE_PLAYER_KICK.send(this, bukkitPlayer.getName()); + Lang.REMOVE_PLAYER_KICK.send(this, player); } } @@ -218,7 +277,7 @@ public class Party */ public void setOwner(String owner) { - _owner = Bukkit.getPlayerExact(owner).getUniqueId(); + _owner = owner; } /** @@ -241,11 +300,6 @@ public class Party _alreadyTeamed = alreadyTeamed; } - public UUID getOwnerId() - { - return this._owner; - } - /** * Check to see if this party contains a certain player name * This is case-insensitive @@ -255,7 +309,7 @@ public class Party */ public boolean contains(String name) { - for(UUID member : _membersByUUID) + for (UUID member : _membersByUUID) { if (Bukkit.getPlayer(member).getName().equalsIgnoreCase(name)) { @@ -264,4 +318,17 @@ public class Party } return false; } + + public boolean isAlreadyTeamed(UUID uuid) + { + return _teamed.contains(uuid); + } + + public void setTeamed(Player... players) + { + for (Player player : players) + { + _teamed.add(player.getUniqueId()); + } + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyEventListener.java b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyEventListener.java index 71a8dd085..9f88df666 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyEventListener.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyEventListener.java @@ -1,11 +1,11 @@ package mineplex.core.party; import mineplex.core.common.Rank; +import mineplex.core.menu.Menu; import mineplex.core.party.constants.PartyRemoveReason; import mineplex.core.party.event.PartyMemberKickGUIEvent; import mineplex.core.party.event.PartySendToServerEvent; import mineplex.core.party.event.PartyTransferOwnerEvent; -import mineplex.core.party.ui.Menu; import mineplex.core.portal.ServerTransferEvent; import mineplex.serverdata.data.MinecraftServer; import org.bukkit.Bukkit; @@ -47,11 +47,11 @@ public class PartyEventListener implements Listener Player bukkitPlayer = Bukkit.getPlayerExact(partyName); - if (party == null && bukkitPlayer != null) + if (party == null) { - party = new Party(bukkitPlayer.getUniqueId()); + party = new Party(partyName); - if (_plugin.getClientManager().Get(bukkitPlayer).GetRank().has(Rank.ULTRA)) + if (bukkitPlayer != null && _plugin.getClientManager().Get(bukkitPlayer).GetRank().has(Rank.ULTRA)) { party.setSize(); } else @@ -109,7 +109,7 @@ public class PartyEventListener implements Listener Player clicked = Bukkit.getPlayerExact(event.getPlayerClicked()); Lang.REMOVED.send(clicked); _plugin.getMethodManager().removeFromParty(clicked, PartyRemoveReason.KICKED); - Menu.get(event.getOwner().getUniqueId()).resetAndUpdate(event.getOwner()); + Menu.get(event.getOwner().getUniqueId()).resetAndUpdate(); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java index 00b4cf38d..13d20aca5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java @@ -10,17 +10,17 @@ import mineplex.core.party.manager.PartyInviteManager; import mineplex.core.party.manager.PartyJoinManager; import mineplex.core.party.manager.PartyMethodManager; import mineplex.core.party.manager.PartyRedisManager; -import mineplex.core.party.ui.MenuListener; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; +import mineplex.serverdata.Region; import mineplex.serverdata.Utility; import mineplex.serverdata.servers.ServerManager; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import java.io.File; import java.util.Map; import java.util.UUID; @@ -58,7 +58,9 @@ public class PartyManager extends MiniPlugin /** * A map of owner (name) -> party server wide */ - private final Map _parties = Maps.newHashMap(); + private final Map _parties = Maps.newHashMap(); + private final Region _region; + public PartyManager(JavaPlugin plugin, Portal portal, CoreClientManager clientManager, PreferencesManager preferenceManager) { @@ -78,13 +80,14 @@ public class PartyManager extends MiniPlugin _methodManager = new PartyMethodManager(this); addCommand(new PartyCommand(this)); - getPluginManager().registerEvents(new MenuListener(), getPlugin()); new PartyEventListener(this); + _region = !new File("eu.dat").exists() ? Region.US : Region.EU; + } public Party getParty(String party) { - return _parties.get(Bukkit.getPlayerExact(party).getUniqueId()); + return _parties.get(party); } public Party getParty(Player player) @@ -94,12 +97,12 @@ public class PartyManager extends MiniPlugin public void addParty(Party party) { - _parties.put(party.getOwnerId(), party); + _parties.put(party.getName(), party); } public void removeParty(Party party) { - _parties.remove(party.getOwnerId()); + _parties.remove(party.getName()); } public Portal getPortal() @@ -147,8 +150,14 @@ public class PartyManager extends MiniPlugin return _players; } - public Map getParties() + public Map getParties() { return _parties; } + + public Region getRegion() + { + return _region; + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/TeamPreferenceCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/TeamPreferenceCommand.java new file mode 100644 index 000000000..ad27de3fa --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/TeamPreferenceCommand.java @@ -0,0 +1,167 @@ +package mineplex.core.party.command; + +import com.google.common.collect.Maps; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.game.GameDisplay; +import mineplex.core.party.Lang; +import mineplex.core.party.Party; +import mineplex.core.party.PartyManager; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import java.util.Map; +import java.util.UUID; + +/** + * Unused for now. + */ +public class TeamPreferenceCommand extends CommandBase +{ + + private static final String[] ARGS = { + "teampref", + "teamprefs", + "teamp", + "tprefs", + "teampreferences" + }; + + private final String ACCEPT = "accept"; + private final String DENY = "deny"; + + private final String ACCEPT_COMMAND = "/teamprefs accept "; + private final String DENY_COMMAND = "/teamprefs deny "; + + private final String HEADER = "Partners"; + + //Player, Partner, GameName + private Map> INVITES = Maps.newHashMap(); + + public TeamPreferenceCommand(PartyManager plugin) + { + super(plugin, Rank.ALL, ARGS); + } + + @Override + public void Execute(Player player, String[] args) + { + if (args.length < 2) + { + Lang.PARTNER_USAGE.sendHeader(player, HEADER); + return; + } + + String arg = args[0]; + + if (arg.equalsIgnoreCase(ACCEPT) || arg.equalsIgnoreCase(DENY)) + { + Party party = Plugin.getParty(player); + + if (party == null) + { + Lang.NO_PARTY.send(player); + return; + } + + String inviter = args[1]; + boolean accept = arg.equalsIgnoreCase(ACCEPT); + Player inviterPlayer = Bukkit.getPlayerExact(inviter); + + if (inviterPlayer == null) + { + Lang.PARTNER_NOT_ONLINE.sendHeader(player, HEADER, inviter); + return; + } + + Map sent = INVITES.get(inviterPlayer.getUniqueId()); + + if (sent == null || sent.isEmpty()) + { + Lang.PARTNER_PLAYER_NOT_REQUESTED.sendHeader(player, HEADER, inviter); + return; + } + + if (sent.get(player.getName()) == null) + { + Lang.PARTNER_PLAYER_NOT_REQUESTED.sendHeader(player, HEADER, inviter); + return; + } + + String gameName = sent.remove(player.getName()); + + if (!accept) + { + Lang.PARTNER_REQUEST_DENIED_PLAYER.send(player, inviterPlayer.getName(), gameName); + Lang.PARTNER_REQUEST_DENIED_SENDER.send(inviterPlayer, player.getName(), gameName); + return; + } + + Lang.PARTNER_REQUEST_ACCEPT_PLAYER.send(player, inviterPlayer.getName(), gameName); + Lang.PARTNER_REQUEST_ACCEPT_SENDER.send(inviterPlayer, player.getName(), gameName); + party.setPartner(player, gameName, inviterPlayer.getName()); + party.setPartner(inviterPlayer, gameName, player.getName()); + return; + } + + Player target = Bukkit.getPlayerExact(arg); + String gameName = ""; + String[] game = new String[args.length - 2]; + System.arraycopy(args, 2, game, 0, game.length); + + for (String s : game) + { + gameName += s + " "; + } + + gameName = gameName.trim(); + + GameDisplay gameDisplay = GameDisplay.matchName(gameName); + + if (gameDisplay == null) + { + Lang.PARTNER_NO_GAME.sendHeader(player, HEADER, gameName); + return; + } + + gameName = gameDisplay.getName(); + + if (alreadyInvited(player, gameName, target.getName())) + { + Lang.PARTNER_ALREADY_INVITED.sendHeader(player, HEADER, target.getName(), gameName); + return; + } + + sendRequest(player, gameName, target); + } + + private void sendRequest(Player player, String game, Player partner) + { + invite(player, game, partner); + String gameName = C.cGreen + (game); + String playerName = C.cGreen + (player.getName()); + String partnerName = C.cGreen + (partner.getName()); + String acceptCommand = ACCEPT_COMMAND + player.getName(); + String declineCommand = DENY_COMMAND + player.getName(); + String acceptText = Lang.PARTNER_HOVER_TEXT_ACCEPT.toString(playerName, gameName); + String declineText = Lang.PARTNER_HOVER_TEXT_DENY.toString(playerName, gameName); + Lang.PARTNER_REQUEST_SENT.sendHeader(player, HEADER, partnerName, gameName); + Lang.PARTNER_REQUEST_RECEIVED.sendHeader(partner, HEADER, playerName, gameName); + UtilPlayer.sendAcceptOrDeny(partner, HEADER, acceptCommand, acceptText, declineCommand, declineText, null, null); + } + + private boolean alreadyInvited(Player player, String game, String partner) + { + Map sent = INVITES.get(player.getUniqueId()); + return !(sent == null || sent.isEmpty()) && sent.get(partner).equalsIgnoreCase(game); + } + + private void invite(Player player, String game, Player partner) + { + Map sent = INVITES.getOrDefault(player.getUniqueId(), Maps.newHashMap()); + sent.put(partner.getName(), game); + INVITES.put(player.getUniqueId(), sent); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java index ba6203f65..bfff39b40 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyInviteManager.java @@ -80,7 +80,7 @@ public class PartyInviteManager } if (newParty == null) { - newParty = new Party(possible.getUniqueId()); + newParty = new Party(possible.getName()); if(_plugin.getClientManager().Get(possible).GetRank().has(Rank.ULTRA)) { newParty.setSize(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java index 9226ce9c6..88a7ef29c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java @@ -8,6 +8,7 @@ import mineplex.core.party.Party; import mineplex.core.party.PartyManager; import mineplex.core.party.constants.JoinResponseReason; import mineplex.core.party.redis.RedisMessageType; +import mineplex.serverdata.servers.ServerManager; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -32,6 +33,27 @@ public class PartyJoinManager _transferring = Lists.newArrayList(); } + /** + * Scans through the party to check if all players are some form of VIP + * If the party contains even 1 non-vip, the party cannot be sent to a full server + * + * @param party The party + * @return true if the party contains all VIP's false if it contains even 1 non-vip + */ + public boolean canJoinFullServer(Party party) + { + List players = party.getMembersByUUID().stream().map(Bukkit::getPlayer).collect(Collectors.toList()); + for (Player player : players) + { + Rank rank = _plugin.getClientManager().Get(player).GetRank(); + if (rank == Rank.ALL) + { + return false; + } + } + return true; + } + /** * Initiates a request to join a server for a specific party * @@ -40,17 +62,7 @@ public class PartyJoinManager */ public void requestServerJoin(String server, Party party) { - boolean canJoinFull = true; - List players = party.getMembers().stream().map(Bukkit::getPlayer).collect(Collectors.toList()); - for (Player player : players) - { - Rank rank = _plugin.getClientManager().Get(player).GetRank(); - if (rank == Rank.ALL) - { - canJoinFull = false; - break; - } - } + boolean canJoinFull = canJoinFullServer(party); _plugin.getRedisManager().publish(server, RedisMessageType.PREJOIN_SERVER_REQUEST, _plugin.getServerName(), party.getOwner(), "" + party.getMembers().size(), "" + canJoinFull); } @@ -75,7 +87,7 @@ public class PartyJoinManager return; } } - + ServerManager.getServerRepository(_plugin.getRegion()).getServerStatus(_plugin.getServerName()).incrementPlayerCount(partySize); _plugin.getRedisManager().publish(serverFrom, RedisMessageType.PREJOIN_SERVER_RESPONSE, initiator, JoinResponseReason.SUCCESS.name(), _plugin.getServerName()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyMethodManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyMethodManager.java index 74086d8ea..548a15b6a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyMethodManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyMethodManager.java @@ -2,11 +2,12 @@ package mineplex.core.party.manager; import com.google.common.collect.Lists; import mineplex.core.common.util.F; +import mineplex.core.menu.Menu; import mineplex.core.party.Lang; import mineplex.core.party.Party; import mineplex.core.party.PartyManager; import mineplex.core.party.constants.PartyRemoveReason; -import mineplex.core.party.ui.Menu; +import mineplex.core.preferences.Preference; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -75,7 +76,7 @@ public class PartyMethodManager //Same Server if (possible != null) { - if(!_plugin.getPreferencesManager().Get(possible).PartyRequests) + if(!_plugin.getPreferencesManager().get(possible).isActive(Preference.PARTY_REQUESTS)) { caller.sendMessage(F.main("Party> ", F.name(target) + " is not accepting invites at this time.")); return; @@ -83,7 +84,7 @@ public class PartyMethodManager if (party == null) { - if(_plugin.getParty(possible) != null) + if(_plugin.getParty(target) != null) { Lang.PLAYER_IN_DIFFERENT_PARTY.send(caller, target); return; @@ -117,7 +118,7 @@ public class PartyMethodManager } //Not on the same server - _plugin.getRedisManager().findAndInvite(target, caller); + _plugin.getRedisManager().findAndInvite(target, caller.getName()); } /** @@ -265,7 +266,8 @@ public class PartyMethodManager { return; } - party.onPlayerRemove(uuid, PartyRemoveReason.OTHER); + String player = Bukkit.getPlayer(uuid).getName(); + party.onPlayerRemove(player, PartyRemoveReason.OTHER); } public void removeFromParty(UUID uuid, PartyRemoveReason reason) @@ -293,7 +295,7 @@ public class PartyMethodManager } party.getMembers().remove(player.getName()); party.getMembersByUUID().remove(uuid); - party.onPlayerRemove(player.getUniqueId(), reason); + party.onPlayerRemove(player.getName(), reason); int size = party.getMembers().size(); if(size <= 1) @@ -303,7 +305,7 @@ public class PartyMethodManager _plugin.removeParty(party); return; } - _plugin.getPlayerParties().remove(party.getMembers().get(0)); + _plugin.getPlayerParties().remove(Bukkit.getPlayerExact(party.getMembers().get(0)).getUniqueId()); party.onPlayerRemove(party.getMembers().get(0), PartyRemoveReason.DISBANDED); _plugin.removeParty(party); } @@ -326,14 +328,19 @@ public class PartyMethodManager public void transferOwner(String newOwner, String oldOwner) { - Party party = _plugin.getParties().remove(Bukkit.getPlayerExact(oldOwner).getUniqueId()); + Party party = _plugin.getParties().remove(oldOwner); + if(party == null) { return; } - _plugin.getParties().put(Bukkit.getPlayerExact(newOwner).getUniqueId(), party); + + _plugin.getParties().put(newOwner, party); party.setOwner(newOwner); - party.getMembers().remove(Bukkit.getPlayerExact(oldOwner).getUniqueId()); - party.getMembers().add(Bukkit.getPlayerExact(oldOwner).getUniqueId()); + party.getMembers().remove(oldOwner); + party.getMembers().add(oldOwner); + UUID uuid = Bukkit.getPlayerExact(oldOwner).getUniqueId(); + party.getMembersByUUID().remove(uuid); + party.getMembersByUUID().add(uuid); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java index f856d0bd8..461b303ac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyRedisManager.java @@ -12,6 +12,7 @@ import mineplex.core.party.constants.JoinResponseReason; import mineplex.core.party.event.PartyDataReceivedEvent; import mineplex.core.party.redis.PartyRedisListener; import mineplex.core.party.redis.RedisMessageType; +import mineplex.core.preferences.Preference; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @@ -120,7 +121,7 @@ public class PartyRedisManager return; } - if(!_plugin.getPreferencesManager().Get(player).PartyRequests) + if(!_plugin.getPreferencesManager().get(player).isActive(Preference.PARTY_REQUESTS)) { publish(first, RedisMessageType.INVITE_PLAYER_NOT_ACCEPTING_INVITES, _serverName, player.getName(), player.getUniqueId().toString(), third); return; @@ -191,9 +192,9 @@ public class PartyRedisManager * @param player The player target * @param sender The sending player */ - public void findAndInvite(String player, Player sender) + public void findAndInvite(String player, String sender) { - sender.sendMessage(F.main("Party", "Locating " + F.elem(player) + "...")); + Bukkit.getPlayerExact(sender).sendMessage(F.main("Party", "Locating " + F.elem(player) + "...")); TASKS.put(player, new BukkitRunnable() { @Override @@ -205,19 +206,25 @@ public class PartyRedisManager return; } TASKS.remove(player); + Player senderPlayer = Bukkit.getPlayerExact(sender); + if (senderPlayer == null) + { + cancel(); + return; + } if (Bukkit.getPlayerExact(player) != null) { cancel(); return; } - sender.sendMessage(F.main("Party", "Could not locate " + F.elem(player) + ".")); + senderPlayer.sendMessage(F.main("Party", "Could not locate " + F.elem(player) + ".")); } }.runTaskLater(_plugin.getPlugin(), 20L * 5)); _plugin.runAsync(() -> { try (Jedis jedis = _writePool.getResource()) { - jedis.publish(FIND_PLAYERS_CHANNEL, RedisMessageType.PLAYER_FIND_REQUEST.format(_serverName, player, sender.getName())); + jedis.publish(FIND_PLAYERS_CHANNEL, RedisMessageType.PLAYER_FIND_REQUEST.format(_serverName, player, sender)); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/Button.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/Button.java deleted file mode 100644 index fe5d4468d..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/Button.java +++ /dev/null @@ -1,45 +0,0 @@ -package mineplex.core.party.ui; - -import mineplex.core.party.PartyManager; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; - -/** - * An abstract class for managing buttons inside of menus - */ -public abstract class Button -{ - - private ItemStack _item; - private PartyManager _plugin; - - public Button(ItemStack item, PartyManager plugin) - { - this._item = item; - _plugin = plugin; - } - - /** - * The method called when a players clicks the slot - * - * @param player The player who clicked - */ - public abstract void onClick(Player player, ClickType clickType); - - public ItemStack getItemStack() - { - return _item; - } - - public void setItemStack(ItemStack item) - { - this._item = item; - } - - public PartyManager getPlugin() - { - return _plugin; - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/PartyMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/PartyMenu.java new file mode 100644 index 000000000..e66709c56 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/PartyMenu.java @@ -0,0 +1,27 @@ +package mineplex.core.party.ui; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.IconButton; +import mineplex.core.menu.Menu; +import mineplex.core.party.PartyManager; +import org.bukkit.Material; + +/** + * A class to manage dynamic creation of GUI's + */ +public abstract class PartyMenu extends Menu +{ + + protected static final Button PURCHASE_MORE_SLOTS = new IconButton(new ItemBuilder(Material.REDSTONE_BLOCK) + .setTitle(C.cRed + C.Bold + "Locked!") + .setLore(" ", C.cGray + "Purchase a rank @ mineplex.com/shop", C.cGray + "Purchasing a rank increases your", C.cGray + "party size to allow 10 people!") + .build()); + + public PartyMenu(String name, PartyManager plugin) + { + super(name, plugin); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/LeavePartyButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/LeavePartyButton.java index 1b409a082..174a46ab6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/LeavePartyButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/LeavePartyButton.java @@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack; /** * Leaves a players current party */ -public class LeavePartyButton extends Button +public class LeavePartyButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.REDSTONE_BLOCK) @@ -36,4 +36,4 @@ public class LeavePartyButton extends Button player.closeInventory(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/PartyButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/PartyButton.java index 463754279..6fee7b430 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/PartyButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/PartyButton.java @@ -1,14 +1,14 @@ package mineplex.core.party.ui.button.tools; +import mineplex.core.menu.Button; import mineplex.core.party.Party; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import org.bukkit.inventory.ItemStack; /** * A wrapper for all buttons which need to interact with a specific party */ -public abstract class PartyButton extends Button +public abstract class PartyButton extends Button { private Party _party; @@ -23,4 +23,4 @@ public abstract class PartyButton extends Button { return _party; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/SelectPartnerGameButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/SelectPartnerGameButton.java new file mode 100644 index 000000000..4d788b0c5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/SelectPartnerGameButton.java @@ -0,0 +1,40 @@ +package mineplex.core.party.ui.button.tools; + +import mineplex.core.common.util.C; +import mineplex.core.game.GameDisplay; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.Menu; +import mineplex.core.party.PartyManager; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +/** + * + */ +public class SelectPartnerGameButton extends Button +{ + + private static final String COMMAND = "/teamprefs "; + + private final String _partner; + private final String _gameName; + + public SelectPartnerGameButton(GameDisplay gameDisplay, String partner, PartyManager plugin) + { + super(new ItemBuilder(gameDisplay.getMaterial()) + .setTitle(C.cYellow + gameDisplay.getName()) + .setData(gameDisplay.getMaterialData()) + .build(), plugin); + _partner = partner; + _gameName = gameDisplay.getName(); + } + + @Override + public void onClick(Player player, ClickType clickType) + { + player.chat(COMMAND + _partner + " " + _gameName); + Menu.get(player.getUniqueId()).setUseClose(true); + player.closeInventory(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/BackButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/BackButton.java index 32dc4edd7..4fe6bce85 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/BackButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/BackButton.java @@ -1,8 +1,8 @@ package mineplex.core.party.ui.button.tools.invite; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack; /** * Sends a player back to the main page */ -public class BackButton extends Button +public class BackButton extends Button { private static ItemStack ITEM = new ItemBuilder(Material.BED) @@ -30,4 +30,4 @@ public class BackButton extends Button player.closeInventory(); player.chat("/party"); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/DenyAllButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/DenyAllButton.java index e39faaca2..7ae041d6f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/DenyAllButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/DenyAllButton.java @@ -1,9 +1,9 @@ package mineplex.core.party.ui.button.tools.invite; import mineplex.core.common.util.C; +import mineplex.core.menu.Button; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import mineplex.core.party.ui.menus.PartyInvitesMenu; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack; /** * Deny's all invites currently pending */ -public class DenyAllButton extends Button +public class DenyAllButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.REDSTONE_BLOCK) @@ -32,4 +32,4 @@ public class DenyAllButton extends Button getPlugin().getInviteManager().getAllInvites(player).forEach(inviteData -> getPlugin().getMethodManager().respondToInvite(player, inviteData.getInvitedTo(), false)); new PartyInvitesMenu(getPlugin()).open(player); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/FilterButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/FilterButton.java index 2a2e5d4ff..cdceafdea 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/FilterButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/FilterButton.java @@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.invite; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import mineplex.core.party.ui.menus.input.InviteFilterMenu; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack; /** * Filters all current pending invites and displays only the results to a player */ -public class FilterButton extends Button +public class FilterButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.NAME_TAG) @@ -22,8 +22,8 @@ public class FilterButton extends Button C.cGray + "Click to bring up an Anvil GUI", C.cGray + "where you type and filter", C.cGray + "Party invites by their name", - " ", - C.cGreen + "Input \"Clear Filter\" to remove the filter") + " ", + C.cGreen + "Input \"Clear Filter\" to remove the filter") .build(); public FilterButton(PartyManager plugin) @@ -36,11 +36,11 @@ public class FilterButton extends Button super(new ItemBuilder(Material.NAME_TAG) .setTitle(C.cYellow + "Filter Invites") .setLore(" ", C.cWhite + "Active Filter: " + C.cGreen + filter, " ", - C.cGray + "Click to bring up an Anvil GUI", - C.cGray + "where you type and filter", - C.cGray + "Party invites by their name", - " ", - C.cGreen + "Input \"Clear Filter\" to remove the filter") + C.cGray + "Click to bring up an Anvil GUI", + C.cGray + "where you type and filter", + C.cGray + "Party invites by their name", + " ", + C.cGreen + "Input \"Clear Filter\" to remove the filter") .setGlow(true) .build(), plugin); } @@ -51,4 +51,4 @@ public class FilterButton extends Button new InviteFilterMenu(getPlugin(), player, null).openInventory(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/InviteButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/InviteButton.java index edc97abb3..01478575f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/InviteButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/InviteButton.java @@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.invite; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -11,7 +11,7 @@ import org.bukkit.event.inventory.ClickType; /** * Represents an invitation, to which a player can accept or deny */ -public class InviteButton extends Button +public class InviteButton extends Button { private String _name; @@ -39,4 +39,4 @@ public class InviteButton extends Button } player.closeInventory(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/NextPageButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/NextPageButton.java index 1b370911e..386cf1962 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/NextPageButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/NextPageButton.java @@ -2,10 +2,10 @@ package mineplex.core.party.ui.button.tools.invite; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.IconButton; import mineplex.core.party.InviteData; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; -import mineplex.core.party.ui.button.IconButton; import mineplex.core.party.ui.menus.PartyInvitesMenu; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -17,7 +17,7 @@ import java.util.List; /** * Shows the next page of invites for a player */ -public class NextPageButton extends Button +public class NextPageButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.SIGN).setTitle(C.cYellow + "Next Page").build(); @@ -37,13 +37,13 @@ public class NextPageButton extends Button _menu.setCurrentPage(_menu.getCurrentPage() + 1); if(_menu.getCurrentPage() == _menu.getPagesNeeded()) { - _menu.setButton(53, new IconButton(new ItemStack(Material.AIR), getPlugin())); + _menu.setButton(53, new IconButton(new ItemStack(Material.AIR))); } List data = _menu.getDataForPage(_menu.getCurrentPage()); for(int i = 0; i < data.size(); i++) { _menu.setButton(i + _menu.getStartingSlot(), new InviteButton(data.get(i).getInvitedTo(), getPlugin())); } - _menu.update(player); + _menu.update(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/PrevPageButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/PrevPageButton.java index 3400a86cd..e0bf5d315 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/PrevPageButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/invite/PrevPageButton.java @@ -2,10 +2,10 @@ package mineplex.core.party.ui.button.tools.invite; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.IconButton; import mineplex.core.party.InviteData; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; -import mineplex.core.party.ui.button.IconButton; import mineplex.core.party.ui.menus.PartyInvitesMenu; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -17,7 +17,7 @@ import java.util.List; /** * Shows the previous page of invites for a player */ -public class PrevPageButton extends Button +public class PrevPageButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.SIGN).setTitle(C.cYellow + "Previous Page").build(); @@ -36,13 +36,13 @@ public class PrevPageButton extends Button _menu.setCurrentPage(_menu.getCurrentPage() - 1); if(_menu.getCurrentPage() == 0) { - _menu.setButton(45, new IconButton(new ItemStack(Material.AIR), getPlugin())); + _menu.setButton(45, new IconButton(new ItemStack(Material.AIR))); } List data = _menu.getDataForPage(_menu.getCurrentPage()); for(int i = 0; i < data.size(); i++) { _menu.setButton(i + _menu.getStartingSlot(), new InviteButton(data.get(i).getInvitedTo(), getPlugin())); } - _menu.update(player); + _menu.update(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/InvitePlayerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/InvitePlayerButton.java index 162912d7b..42bab9475 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/InvitePlayerButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/InvitePlayerButton.java @@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.main; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import mineplex.core.party.ui.menus.input.PartyInvitePlayerMenu; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack; /** * Invites a player to a new party */ -public class InvitePlayerButton extends Button +public class InvitePlayerButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.NAME_TAG) @@ -31,4 +31,4 @@ public class InvitePlayerButton extends Button { new PartyInvitePlayerMenu(getPlugin(), player, null).openInventory(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/ViewInvitesButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/ViewInvitesButton.java index 3ae1c6cf7..6e934cef2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/ViewInvitesButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/main/ViewInvitesButton.java @@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.main; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import mineplex.core.party.ui.menus.PartyInvitesMenu; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack; /** * Opens the {@code {@link PartyInvitesMenu}} */ -public class ViewInvitesButton extends Button +public class ViewInvitesButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.BOOK) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/AddPlayerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/AddPlayerButton.java index e010089bd..72bad2bed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/AddPlayerButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/AddPlayerButton.java @@ -33,4 +33,4 @@ public class AddPlayerButton extends PartyButton new PartyInvitePlayerMenu(getPlugin(), player, getParty()).openInventory(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/DisbandPartyButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/DisbandPartyButton.java index 5c6ad0923..ce2afa915 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/DisbandPartyButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/DisbandPartyButton.java @@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.owner; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack; /** * Disbands a party */ -public class DisbandPartyButton extends Button +public class DisbandPartyButton extends Button { private static final ItemStack ITEM = new ItemBuilder(Material.BARRIER) @@ -35,4 +35,4 @@ public class DisbandPartyButton extends Button getPlugin().getMethodManager().disband(player); player.closeInventory(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/KickPlayerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/KickPlayerButton.java index 03f02fed2..48069adf2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/KickPlayerButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/KickPlayerButton.java @@ -4,7 +4,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.party.Party; -import mineplex.core.party.ui.Menu; +import mineplex.core.party.ui.PartyMenu; import mineplex.core.party.ui.button.tools.PartyButton; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -51,6 +51,6 @@ public class KickPlayerButton extends PartyButton { setItemStack(ITEM_OFF); } - Menu.get(player.getUniqueId()).update(player); + PartyMenu.get(player.getUniqueId()).update(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/SelectServerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/SelectServerButton.java index dbbd0a032..5c2fed842 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/SelectServerButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/SelectServerButton.java @@ -32,4 +32,4 @@ public class SelectServerButton extends PartyButton { UtilServer.getPluginManager().callEvent(new PartySelectServerEvent(player)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/TransferOwnerButton.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/TransferOwnerButton.java index 5d49eae44..2f0ca501c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/TransferOwnerButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/button/tools/owner/TransferOwnerButton.java @@ -20,7 +20,7 @@ public class TransferOwnerButton extends PartyButton private static final ItemStack ITEM = new ItemBuilder(Material.BOOK_AND_QUILL) .setTitle(C.cYellow + "Transfer Ownership") .setLore(" ", C.cGray + "Transfers ownership of the party", C.cGray + "to another player", - " ", C.cDRed + "This cannot be undone!") + " ", C.cDRed + "This cannot be undone!") .build(); public TransferOwnerButton(Party party, PartyManager plugin) @@ -33,4 +33,4 @@ public class TransferOwnerButton extends PartyButton { new PartyTransferOwnerMenu(getPlugin(), player, getParty()).openInventory(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartnerRequestMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartnerRequestMenu.java new file mode 100644 index 000000000..2d0c9989b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartnerRequestMenu.java @@ -0,0 +1,55 @@ +package mineplex.core.party.ui.menus; + +import mineplex.core.game.GameDisplay; +import mineplex.core.menu.Button; +import mineplex.core.party.PartyManager; +import mineplex.core.party.ui.PartyMenu; +import mineplex.core.party.ui.button.tools.SelectPartnerGameButton; +import org.bukkit.entity.Player; + +/** + * + */ +public class PartnerRequestMenu extends PartyMenu +{ + + private final GameDisplay[] GAMES = { + GameDisplay.SurvivalGamesTeams, + GameDisplay.SkywarsTeams, + GameDisplay.UHC, + GameDisplay.SmashTeams, + }; + + private final int INV_SIZE = 54; + private final int START_SLOT = 20; + private final int END_SLOT = 24; + private final int START_SLOT_SECOND = 29; + + private final String _partner; + + public PartnerRequestMenu(String partner, PartyManager plugin) + { + super("Select a game", plugin); + _partner = partner; + } + + @Override + protected Button[] setUp(Player player) + { + Button[] buttons = new Button[INV_SIZE]; + + int slot = START_SLOT; + + for (GameDisplay gameDisplay : GAMES) + { + if (slot > END_SLOT) + { + slot = START_SLOT_SECOND; + } + + buttons[slot++] = new SelectPartnerGameButton(gameDisplay, _partner, getPlugin()); + } + + return pane(buttons); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyInvitesMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyInvitesMenu.java index 8d4f454d3..bfbe08da1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyInvitesMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyInvitesMenu.java @@ -5,12 +5,16 @@ import com.google.common.collect.Maps; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.IconButton; import mineplex.core.party.InviteData; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; -import mineplex.core.party.ui.Menu; -import mineplex.core.party.ui.button.IconButton; -import mineplex.core.party.ui.button.tools.invite.*; +import mineplex.core.party.ui.PartyMenu; +import mineplex.core.party.ui.button.tools.invite.BackButton; +import mineplex.core.party.ui.button.tools.invite.DenyAllButton; +import mineplex.core.party.ui.button.tools.invite.FilterButton; +import mineplex.core.party.ui.button.tools.invite.InviteButton; +import mineplex.core.party.ui.button.tools.invite.NextPageButton; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.Sound; @@ -23,13 +27,13 @@ import java.util.stream.Collectors; /** * The menu showing all pending invites for a player */ -public class PartyInvitesMenu extends Menu +public class PartyInvitesMenu extends PartyMenu { private final IconButton NO_INVITES = new IconButton(new ItemBuilder(Material.STAINED_GLASS_PANE) .setData(DyeColor.RED.getWoolData()) .setTitle(C.cRedB + "No Invites") - .build(), null); + .build()); private final int INV_SIZE = 54; private final int SLOTS_PER_PAGE = 27; @@ -63,9 +67,9 @@ public class PartyInvitesMenu extends Menu Button[] buttons = new Button[INV_SIZE]; boolean showFiltered = false; - buttons[BACK_BUTTON_SLOT] = new BackButton(_plugin); + buttons[BACK_BUTTON_SLOT] = new BackButton(getPlugin()); - List all = (List) _plugin.getInviteManager().getAllInvites(player); + List all = (List) getPlugin().getInviteManager().getAllInvites(player); if (all == null || all.isEmpty()) { @@ -74,18 +78,18 @@ public class PartyInvitesMenu extends Menu buttons[i] = NO_INVITES; } player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f); - return addPanes(buttons); + return pane(buttons); } - buttons[DENY_ALL_BUTTON_SLOW] = new DenyAllButton(_plugin); + buttons[DENY_ALL_BUTTON_SLOW] = new DenyAllButton(getPlugin()); if (_filterBy == null || _filterBy.isEmpty()) { - buttons[FILTER_BUTTON_SLOT] = new FilterButton(_plugin); + buttons[FILTER_BUTTON_SLOT] = new FilterButton(getPlugin()); } else { showFiltered = true; - buttons[FILTER_BUTTON_SLOT] = new FilterButton(_filterBy, _plugin); + buttons[FILTER_BUTTON_SLOT] = new FilterButton(_filterBy, getPlugin()); } if (showFiltered) @@ -101,10 +105,10 @@ public class PartyInvitesMenu extends Menu .setData(DyeColor.RED.getWoolData()) .setTitle(C.cRedB + "No Invites Found") .setLore(" ", C.cGray + "The filter " + F.name(_filterBy) + " had no results.") - .build(), _plugin); + .build()); } player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f); - return addPanes(buttons); + return pane(buttons); } _data = all; @@ -118,7 +122,7 @@ public class PartyInvitesMenu extends Menu pagesNeeded++; size -= SLOTS_PER_PAGE; } - buttons[NEXT_PAGE_SLOT] = new NextPageButton(this, _plugin); + buttons[NEXT_PAGE_SLOT] = new NextPageButton(this, getPlugin()); _pagesNeeded = pagesNeeded; _pagesOfData = Maps.newHashMap(); @@ -147,12 +151,12 @@ public class PartyInvitesMenu extends Menu for (int i = 0; i < all.size(); i++) { String to = all.get(i).getInvitedTo(); - buttons[STARTING_SLOT + i] = new InviteButton(to, _plugin); + buttons[STARTING_SLOT + i] = new InviteButton(to, getPlugin()); } } - return addPanes(buttons); + return pane(buttons); } public void setButton(int slot, Button button) @@ -189,4 +193,4 @@ public class PartyInvitesMenu extends Menu { return _pagesNeeded; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyMainMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyMainMenu.java index 619e2f1f7..055203db3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyMainMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyMainMenu.java @@ -1,8 +1,8 @@ package mineplex.core.party.ui.menus; +import mineplex.core.menu.Button; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; -import mineplex.core.party.ui.Menu; +import mineplex.core.party.ui.PartyMenu; import mineplex.core.party.ui.button.tools.main.InvitePlayerButton; import mineplex.core.party.ui.button.tools.main.ViewInvitesButton; import org.bukkit.entity.Player; @@ -10,7 +10,7 @@ import org.bukkit.entity.Player; /** * The main GUI for parties. */ -public class PartyMainMenu extends Menu +public class PartyMainMenu extends PartyMenu { private final int INV_SIZE = 9; @@ -28,9 +28,9 @@ public class PartyMainMenu extends Menu { Button[] buttons = new Button[INV_SIZE]; - buttons[INVITE_PLAYER_BUTTON_SLOT] = new InvitePlayerButton(_plugin); - buttons[VIEW_INVITES_BUTTON_SLOT] = new ViewInvitesButton(_plugin); + buttons[INVITE_PLAYER_BUTTON_SLOT] = new InvitePlayerButton(getPlugin()); + buttons[VIEW_INVITES_BUTTON_SLOT] = new ViewInvitesButton(getPlugin()); return buttons; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java index 06d603113..563cfaef4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyOwnerMenu.java @@ -1,9 +1,9 @@ package mineplex.core.party.ui.menus; +import mineplex.core.menu.Button; import mineplex.core.party.Party; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; -import mineplex.core.party.ui.Menu; +import mineplex.core.party.ui.PartyMenu; import mineplex.core.party.ui.button.PartyMemberIcon; import mineplex.core.party.ui.button.tools.LeavePartyButton; import mineplex.core.party.ui.button.tools.owner.AddPlayerButton; @@ -20,7 +20,7 @@ import java.util.UUID; /** * The display menu for managing parties by the owner */ -public class PartyOwnerMenu extends Menu +public class PartyOwnerMenu extends PartyMenu { private final int INV_SIZE = 54; @@ -36,7 +36,7 @@ public class PartyOwnerMenu extends Menu private final int SELECT_SERVER_BUTTON_SLOT = 46; private final int LEAVE_PARTY_BUTTON_SLOT = 49; private final int DISBAND_PARTY_BUTTON_SLOW = 52; - + private Party _party; public PartyOwnerMenu(Party party, PartyManager plugin) @@ -55,25 +55,25 @@ public class PartyOwnerMenu extends Menu { Button[] buttons = new Button[INV_SIZE]; //Tools - buttons[ADD_PLAYER_BUTTON_SLOT] = new AddPlayerButton(_plugin, _party); + buttons[ADD_PLAYER_BUTTON_SLOT] = new AddPlayerButton(getPlugin(), _party); //Kick player buttons[KICK_PLAYER_BUTTON_SLOT] = new KickPlayerButton(_party); //Transfer ownership - buttons[TRANSFER_OWNER_BUTTON_SLOT] = new TransferOwnerButton(_party, _plugin); + buttons[TRANSFER_OWNER_BUTTON_SLOT] = new TransferOwnerButton(_party, getPlugin()); //Go to server buttons[SELECT_SERVER_BUTTON_SLOT] = new SelectServerButton(_party); //Leave party - buttons[LEAVE_PARTY_BUTTON_SLOT] = new LeavePartyButton(_plugin); + buttons[LEAVE_PARTY_BUTTON_SLOT] = new LeavePartyButton(getPlugin()); //Disband - buttons[DISBAND_PARTY_BUTTON_SLOW] = new DisbandPartyButton(_plugin); + buttons[DISBAND_PARTY_BUTTON_SLOW] = new DisbandPartyButton(getPlugin()); - List members = _party.getMembers(); - members.remove(_party.getOwnerId()); + List members = _party.getMembers(); + members.remove(_party.getOwner()); buttons[OWNER_HEAD_SLOT] = new PartyMemberIcon(_party.getOwner(), _party, true); int slot = STARTING_SLOT; //Players - for (UUID member: members) + for (String member: members) { if (slot == CUT_OFF_SLOT) { @@ -83,18 +83,9 @@ public class PartyOwnerMenu extends Menu slot = SKIP_TO_SLOT_2; } - buttons[slot++] = new PartyMemberIcon(Bukkit.getPlayer(member).getName(), _party, false); + buttons[slot++] = new PartyMemberIcon(Bukkit.getPlayerExact(member).getName(), _party, false); } - if(_party.getSize() == 5) - { - for(int i = 29; i < 34; i++) - { - buttons[i] = PURCHASE_MORE_SLOTS; - } - } - - - return addPanes(buttons); + return pane(buttons); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java index 3a38e25b2..f907b7875 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/ui/menus/PartyViewMenu.java @@ -1,9 +1,9 @@ package mineplex.core.party.ui.menus; +import mineplex.core.menu.Button; import mineplex.core.party.Party; import mineplex.core.party.PartyManager; -import mineplex.core.party.ui.Button; -import mineplex.core.party.ui.Menu; +import mineplex.core.party.ui.PartyMenu; import mineplex.core.party.ui.button.PartyMemberIcon; import mineplex.core.party.ui.button.tools.LeavePartyButton; import mineplex.core.party.ui.button.tools.view.SuggestPlayerButton; @@ -16,7 +16,7 @@ import java.util.UUID; /** * The menu a player see's when he is a member, and not an owner, of a party. */ -public class PartyViewMenu extends Menu +public class PartyViewMenu extends PartyMenu { private final int INV_SIZE = 54; @@ -28,7 +28,7 @@ public class PartyViewMenu extends Menu private final int SKIP_TO_SLOT_2 = 38; private final int LEAVE_PARTY_BUTTON_SLOT = 3; private final int SUGGEST_PLAYER_BUTTON_SLOT = 5; - + private Party _party; public PartyViewMenu(Party party, PartyManager plugin) @@ -42,17 +42,17 @@ public class PartyViewMenu extends Menu { Button[] buttons = new Button[INV_SIZE]; //Tools - buttons[LEAVE_PARTY_BUTTON_SLOT] = new LeavePartyButton(_plugin); + buttons[LEAVE_PARTY_BUTTON_SLOT] = new LeavePartyButton(getPlugin()); //Suggest Player - buttons[SUGGEST_PLAYER_BUTTON_SLOT] = new SuggestPlayerButton(_party, _plugin); + buttons[SUGGEST_PLAYER_BUTTON_SLOT] = new SuggestPlayerButton(_party, getPlugin()); - List members = _party.getMembers(); - members.remove(_party.getOwnerId()); + List members = _party.getMembers(); + members.remove(_party.getOwner()); buttons[OWNER_HEAD_SLOT] = new PartyMemberIcon(_party.getOwner(), _party, true); int slot = STARTING_SLOT; //Players - for (UUID member : members) + for (String member : members) { if (slot == CUT_OFF_SLOT) { @@ -65,6 +65,6 @@ public class PartyViewMenu extends Menu buttons[slot++] = new PartyMemberIcon(Bukkit.getPlayer(member).getName(), _party, false); } - return addPanes(buttons); + return pane(buttons); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java new file mode 100644 index 000000000..b5fc695be --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java @@ -0,0 +1,106 @@ +package mineplex.core.preferences; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.bukkit.Material; + +import java.util.List; +import java.util.Map; + +/** + * + */ +public enum Preference +{ + + HUB_GAMES(true, PreferenceCategory.USER, Material.FIREBALL, "Hub Player Stacker"), + SHOW_PLAYERS(true, PreferenceCategory.USER, Material.EYE_OF_ENDER, "Hub Player Visibility"), + SHOW_CHAT(true, PreferenceCategory.USER, Material.PAPER, "Player Chat"), + PRIVATE_MESSAGING(true, PreferenceCategory.USER, Material.MAP, "Private Messaging"), + PARTY_REQUESTS(true, PreferenceCategory.USER, Material.SKULL_ITEM, "Party Requests"), + + INVISIBILITY(false, PreferenceCategory.EXCLUSIVE, Material.NETHER_STAR, "Hub Invisibility & Flight"), + FORCE_FIELD(false, PreferenceCategory.EXCLUSIVE, Material.SLIME_BALL, "Hub Forcefield"), + SHOW_MAC_REPORTS(false, PreferenceCategory.EXCLUSIVE, Material.PAPER, "Global GWEN Reports"), + SHOW_USER_REPORTS(false, PreferenceCategory.EXCLUSIVE, Material.BOOK, "User Reports"), + IGNORE_VELOCITY(false, PreferenceCategory.EXCLUSIVE, Material.SADDLE, "Hub Ignore Velocity"), + + PENDING_FRIEND_REQUESTS(true, PreferenceCategory.FRIEND, Material.RED_ROSE, "Show Pending Friend Requests"), + FRIENDS_DISPLAY_INVENTORY_UI(true, PreferenceCategory.FRIEND, Material.CHEST, "Display Friend GUI"), + + CLAN_TIPS(true, PreferenceCategory.MISC, Material.IRON_SWORD, "Show Clan Tips"), + HUB_MUSIC(true, PreferenceCategory.MISC, Material.NOTE_BLOCK, "Hub Music"), + + AUTO_JOIN_NEXT_GAME(true, PreferenceCategory.GAME_PLAY, Material.DIAMOND_SWORD, "Auto Join Next Game"), + COUNTDOWN_ON_CLICK(true, PreferenceCategory.GAME_PLAY, Material.EMERALD, "Countdown to Join"),; + + private static final Map PREFERENCE_MAP = Maps.newHashMap(); + private static final Map> PREFERENCES_BY_CATEGORY = Maps.newHashMap(); + + static + { + int id = 0; + for (Preference preference : values()) + { + preference._id = ++id; + PREFERENCE_MAP.put(preference._id, preference); + List preferences = PREFERENCES_BY_CATEGORY.getOrDefault(preference._category, Lists.newArrayList()); + preferences.add(preference); + PREFERENCES_BY_CATEGORY.put(preference._category, preferences); + } + + } + + private int _id; + private final boolean _default; + private final PreferenceCategory _category; + private final Material _icon; + private final String _name; + private final String[] _lore; + + Preference(boolean defaultSetting, PreferenceCategory category, Material icon, String name, String... lore) + { + _default = defaultSetting; + _category = category; + _icon = icon; + _name = name; + _lore = lore; + } + + public String getName() + { + return _name; + } + + public Material getIcon() + { + return _icon; + } + + public int getId() + { + return _id; + } + + public boolean getDefaultValue() + { + return _default; + } + + public String[] getLore() + { + return _lore; + } + + public static List getByCategory(PreferenceCategory category) + { + return PREFERENCES_BY_CATEGORY.get(category); + } + + public static Preference get(int id) + { + return PREFERENCE_MAP.get(id); + } + + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferenceCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferenceCategory.java new file mode 100644 index 000000000..7e99cd29e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferenceCategory.java @@ -0,0 +1,42 @@ +package mineplex.core.preferences; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +/** + * + */ +public enum PreferenceCategory +{ + + USER("User", Material.PAPER), + EXCLUSIVE("Exclusive", Material.DIAMOND), + GAME_PLAY("Game Mechanic", Material.REDSTONE_COMPARATOR), + MISC("Miscellaneous", Material.COMPASS), + FRIEND("Friend", Material.CHEST), + ; + + private String _name; + private ItemStack _itemStack; + + PreferenceCategory(String name, Material icon) + { + _name = name + " Preferences"; + _itemStack = new ItemBuilder(icon) + .setTitle(C.cYellow + _name) + .build(); + } + + public ItemStack getItem() + { + return _itemStack; + } + + public String getName() + { + return _name; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java index 6d46a269c..96217508b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java @@ -1,11 +1,18 @@ package mineplex.core.preferences; -import java.lang.reflect.Field; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Map.Entry; -import java.util.UUID; - +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.incognito.IncognitoManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.preferences.command.PreferencesCommand; +import mineplex.core.preferences.ui.PreferenceMainMenu; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilGameProfile; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -14,68 +21,124 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.MiniDbClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilInv; -import mineplex.core.donation.DonationManager; -import mineplex.core.incognito.IncognitoManager; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.preferences.command.PreferencesCommand; -import mineplex.core.preferences.ui.ExclusivePreferencesShop; -import mineplex.core.preferences.ui.PreferencesShop; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; -public class PreferencesManager extends MiniDbClientPlugin +public class PreferencesManager extends MiniPlugin { - private PreferencesRepository _repository; - private PreferencesShop _shop; - private ExclusivePreferencesShop _exclusiveShop; + private final PreferencesRepository _repository; + private final CoreClientManager _clientManager; + private final IncognitoManager _incognitoManager; - private IncognitoManager _incognitoManager; - - private NautHashMap _saveBuffer = new NautHashMap(); + private final List _saveBuffer = Lists.newArrayList(); + private final Map _preferences = Maps.newHashMap(); public boolean GiveItem; - public PreferencesManager(JavaPlugin plugin, IncognitoManager incognito, CoreClientManager clientManager, DonationManager donationManager) + public PreferencesManager(JavaPlugin plugin, IncognitoManager incognito, CoreClientManager clientManager) { - super("Preferences", plugin, clientManager); + super("Preferences", plugin); - _repository = new PreferencesRepository(plugin); - _exclusiveShop = new ExclusivePreferencesShop(this, clientManager, donationManager); - _shop = new PreferencesShop(this, clientManager, donationManager, _exclusiveShop); + _repository = new PreferencesRepository(this); + _clientManager = clientManager; _incognitoManager = incognito; - _exclusiveShop.setPreferencesShop(_shop); - addCommand(new PreferencesCommand(this)); } - @Override - protected UserPreferences addPlayer(UUID uuid) + @EventHandler + public void onQuit(PlayerQuitEvent event) { - return new UserPreferences(); - } - - public void savePreferences(Player caller) - { - _saveBuffer.put(caller.getUniqueId().toString(), Get(caller)); + Player player = event.getPlayer(); + int accountId = _clientManager.getAccountId(player); + _repository.saveUserPreferences(_preferences.remove(accountId)); } @EventHandler public void givePlayerItem(PlayerJoinEvent event) { - handlePlayerJoin(event.getPlayer(), false); + Player player = event.getPlayer(); + + int accountId = _clientManager.getAccountId(player); + + _repository.loadClientInformationAsync(accountId); + + handlePlayerJoin(player, false); + } + + @EventHandler + public void storeBuffer(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW) + { + return; + } + + if(_saveBuffer.isEmpty()) + { + return; + } + + List buffer = Lists.newArrayList(_saveBuffer); + + buffer.forEach(_repository::saveUserPreferences); + + buffer.clear(); + _saveBuffer.clear(); + + } + + @EventHandler(priority = EventPriority.LOWEST) + public void playerInteract(PlayerInteractEvent event) + { + if (!GiveItem) + { + return; + } + + if (event.getItem() != null && event.getItem().getType() == Material.REDSTONE_COMPARATOR) + { + openMenu(event.getPlayer()); + event.setCancelled(true); + } + } + + public UserPreferences get(Player player) + { + UserPreferences preferences = _preferences.get(_clientManager.getAccountId(player)); + if(preferences == null) + { + preferences = new UserPreferences(_clientManager.getAccountId(player)); + _repository.loadClientInformation(_clientManager.getAccountId(player)); + } + return preferences; + } + + public void save(UserPreferences preferences) + { + _saveBuffer.add(preferences); + } + + public IncognitoManager getIncognitoManager() + { + return _incognitoManager; + } + + public CoreClientManager getClientManager() + { + return _clientManager; + } + + public void openMenu(Player player) + { + new PreferenceMainMenu(this).open(player); } public void handlePlayerJoin(Player player, boolean force) @@ -112,63 +175,8 @@ public class PreferencesManager extends MiniDbClientPlugin } } - @EventHandler - public void storeBuffer(UpdateEvent event) + public void set(int accountId, UserPreferences preferences) { - if (event.getType() != UpdateType.SLOW) - return; - - final NautHashMap bufferCopy = new NautHashMap(); - - for (Entry entry : _saveBuffer.entrySet()) - { - bufferCopy.put(entry.getKey(), entry.getValue()); - } - - _saveBuffer.clear(); - - getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - _repository.saveUserPreferences(bufferCopy); - } - }); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void playerInteract(PlayerInteractEvent event) - { - if (!GiveItem) - return; - - if (event.getItem() != null && event.getItem().getType() == Material.REDSTONE_COMPARATOR) - { - _shop.attemptShopOpen(event.getPlayer()); - - event.setCancelled(true); - } - } - - public void openShop(Player caller) - { - _shop.attemptShopOpen(caller); - } - - @Override - public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException - { - Set(uuid, _repository.loadClientInformation(resultSet)); - } - - @Override - public String getQuery(int accountId, String uuid, String name) - { - return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds, showUserReports FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;"; - } - - public IncognitoManager getIncognitoManager() - { - return _incognitoManager; + _preferences.put(accountId, preferences); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java index a0ac20836..1efe36f82 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java @@ -1,140 +1,140 @@ package mineplex.core.preferences; +import mineplex.core.database.MinecraftRepository; +import mineplex.core.progression.util.SQLStatement; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.column.ColumnInt; + import java.sql.Connection; import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.sql.SQLException; -import java.util.Map.Entry; - -import mineplex.core.database.MinecraftRepository; -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.core.common.util.NautHashMap; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnVarChar; public class PreferencesRepository extends MinecraftRepository { - // private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS - // accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), - // games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, - // showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, - // privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL - // DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL - // DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL - // NOT NULL DEFAULT 0, showUserReports BOOL NOT NULL DEFAULT 0, PRIMARY - // KEY (id), UNIQUE INDEX uuid_index (uuid));"; - private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;"; - private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ?, clanTips = ?, hubMusic = ?, disableAds = ?, showUserReports = ? WHERE uuid=?;"; - - public PreferencesRepository(JavaPlugin plugin) + + private static String UPSERT_ACCOUNT = "INSERT INTO `preferences` VALUES(?, ?, ?) ON DUPLICATE KEY UPDATE `value`= ?"; + private final String GET_PREFS = "SELECT * FROM `preferences` WHERE `accountId` = ?"; + + private final PreferencesManager _manager; + + public PreferencesRepository(PreferencesManager plugin) { - super(plugin, DBPool.getAccount()); + super(plugin.getPlugin(), DBPool.getAccount()); + _manager = plugin; } - + @Override protected void initialize() { - // executeUpdate(CREATE_ACCOUNT_TABLE); } @Override protected void update() { } - - public void saveUserPreferences(NautHashMap preferences) - { - try (Connection connection = getConnection(); PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_ACCOUNT_PREFERENCES);) - { - for (Entry entry : preferences.entrySet()) - { - preparedStatement.setBoolean(1, entry.getValue().HubGames); - preparedStatement.setBoolean(2, entry.getValue().ShowPlayers); - preparedStatement.setBoolean(3, entry.getValue().ShowChat); - preparedStatement.setBoolean(4, entry.getValue().FriendChat); - preparedStatement.setBoolean(5, entry.getValue().PrivateMessaging); - preparedStatement.setBoolean(6, entry.getValue().PartyRequests); - preparedStatement.setBoolean(7, entry.getValue().Invisibility); - preparedStatement.setBoolean(8, entry.getValue().HubForcefield); - preparedStatement.setBoolean(9, entry.getValue().ShowMacReports); - preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity); - preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests); - preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI); - preparedStatement.setBoolean(13, entry.getValue().ClanTips); - preparedStatement.setBoolean(14, entry.getValue().HubMusic); - preparedStatement.setBoolean(15, entry.getValue().DisableAds); - preparedStatement.setBoolean(16, entry.getValue().ShowUserReports); - System.out.println(">> " + entry.getValue().ClanTips); - preparedStatement.setString(17, entry.getKey()); - - preparedStatement.addBatch(); - } - int[] rowsAffected = preparedStatement.executeBatch(); - int i = 0; - - for (Entry entry : preferences.entrySet()) - { - if (rowsAffected[i] < 1) - { - executeUpdate(INSERT_ACCOUNT, new ColumnVarChar("uuid", 100, entry.getKey())); - - preparedStatement.setBoolean(1, entry.getValue().HubGames); - preparedStatement.setBoolean(2, entry.getValue().ShowPlayers); - preparedStatement.setBoolean(3, entry.getValue().ShowChat); - preparedStatement.setBoolean(4, entry.getValue().FriendChat); - preparedStatement.setBoolean(5, entry.getValue().PrivateMessaging); - preparedStatement.setBoolean(6, entry.getValue().PartyRequests); - preparedStatement.setBoolean(7, entry.getValue().Invisibility); - preparedStatement.setBoolean(8, entry.getValue().HubForcefield); - preparedStatement.setBoolean(9, entry.getValue().ShowMacReports); - preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity); - preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests); - preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI); - preparedStatement.setBoolean(13, entry.getValue().ClanTips); - preparedStatement.setBoolean(14, entry.getValue().HubMusic); - preparedStatement.setBoolean(15, entry.getValue().DisableAds); - preparedStatement.setBoolean(16, entry.getValue().ShowUserReports); - System.out.println(">> " + entry.getValue().ClanTips); - preparedStatement.setString(17, entry.getKey()); - preparedStatement.execute(); - } - - i++; - } - } - catch (Exception exception) + /** + * Save a player's preferences in SQL + * + * @param preferences The player's specific {@code {@link UserPreferences}} instance + */ + public void saveUserPreferences(UserPreferences preferences) + { + async(() -> { - exception.printStackTrace(); - } + int accountId = preferences.getAccountId(); + try (Connection connection = getConnection()) + { + for (Preference preference : Preference.values()) + { + int value = preferences.isActive(preference) ? 1 : 0; + int id = preference.getId(); + PreparedStatement statement = new SQLStatement(UPSERT_ACCOUNT) + .set(1, accountId).set(2, id).set(3, value).set(4, value) + .prepare(connection); + executeUpdate(statement); + System.out.println("Saved: " + accountId + " PID: " + id + ", VALUE: " + value); + } + } catch (SQLException e) + { + e.printStackTrace(); + } + }); } - public UserPreferences loadClientInformation(final ResultSet resultSet) throws SQLException + /** + * This method is run on the main thread, as we need this information to be laoded before a player joins + * It's also not the true main thread, as it's being called on AsyncPlayerPreLoginEvent + * If, for whatever reason, you need this information sometime differently, please call this async. + * + * @param accountId The player's accountID + * @return A loaded preference for the player + */ + public UserPreferences loadClientInformation(int accountId) { - final UserPreferences preferences = new UserPreferences(); + UserPreferences preferences = new UserPreferences(accountId); - if (resultSet.next()) + System.out.println("Loading " + accountId + "'s preferences..."); + + executeQuery(GET_PREFS, resultSet -> { - preferences.HubGames = resultSet.getBoolean(1); - preferences.ShowPlayers = resultSet.getBoolean(2); - preferences.ShowChat = resultSet.getBoolean(3); - preferences.FriendChat = resultSet.getBoolean(4); - preferences.PrivateMessaging = resultSet.getBoolean(5); - preferences.PartyRequests = resultSet.getBoolean(6); - preferences.Invisibility = resultSet.getBoolean(7); - preferences.HubForcefield = resultSet.getBoolean(8); - preferences.ShowMacReports = resultSet.getBoolean(9); - preferences.IgnoreVelocity = resultSet.getBoolean(10); - preferences.PendingFriendRequests = resultSet.getBoolean(11); - preferences.friendDisplayInventoryUI = resultSet.getBoolean(12); - preferences.ClanTips = resultSet.getBoolean(13); - preferences.HubMusic = resultSet.getBoolean(14); - preferences.DisableAds = resultSet.getBoolean(15); - preferences.ShowUserReports = resultSet.getBoolean(16); - } - + while (resultSet.next()) + { + Preference preference = Preference.get(resultSet.getInt("preference")); + boolean value = resultSet.getInt("value") == 1; + preferences.set(preference, value); + System.out.println(preference.name() + ": " + String.valueOf(value)); + } + }, new ColumnInt("accountId", accountId)); + return preferences; } + + /** + * Load a clients data async and then update the local reference + * + * @param accountId The player's accountID + */ + public void loadClientInformationAsync(int accountId) + { + async(() -> { + UserPreferences preferences = loadClientInformation(accountId); + _manager.set(accountId, preferences); + }); + } + + public void async(Runnable runnable) + { + getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), runnable); + } + + /** + * Internal method for updating the table + * + * @param preparedStatement The statement to execute + * @return The amount of rows effected + */ + private int executeUpdate(PreparedStatement preparedStatement) + { + try + { + return preparedStatement.executeUpdate(); + } catch (SQLException e) + { + e.printStackTrace(); + return -1; + } finally + { + try + { + if (preparedStatement != null) + { + preparedStatement.close(); + } + } catch (SQLException e) + { + e.printStackTrace(); + } + } + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java index f6ef8efba..f54b38994 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java @@ -1,22 +1,49 @@ package mineplex.core.preferences; +import com.google.common.collect.Maps; + +import java.util.Map; + public class UserPreferences { - public boolean FilterChat = true; - public boolean HubGames = true; - public boolean ShowPlayers = true; - public boolean ShowChat = true; - public boolean FriendChat = true; - public boolean PrivateMessaging = true; - public boolean PartyRequests = true; - public boolean Invisibility = false; - public boolean HubForcefield = false; - public boolean ShowMacReports = false; - public boolean ShowUserReports = false; - public boolean IgnoreVelocity = false; - public boolean PendingFriendRequests = true; - public boolean friendDisplayInventoryUI = true; - public boolean ClanTips = true; - public volatile boolean HubMusic = true; - public boolean DisableAds = false; + + private int _accountId; + private Map _preferences; + + public UserPreferences(int accountId) + { + _accountId = accountId; + _preferences = Maps.newHashMap(); + } + + public boolean isActive(Preference preference) + { + return _preferences.getOrDefault(preference, preference.getDefaultValue()); + } + + public void toggle(Preference preference) + { + boolean enabled = _preferences.getOrDefault(preference, preference.getDefaultValue()); + _preferences.put(preference, !enabled); + } + + public void enable(Preference preference) + { + _preferences.put(preference, true); + } + + public void disable(Preference preference) + { + _preferences.put(preference, false); + } + + public void set(Preference preference, boolean value) + { + _preferences.put(preference, value); + } + + public int getAccountId() + { + return _accountId; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java index 0bd180f84..a1506b911 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java @@ -1,12 +1,9 @@ package mineplex.core.preferences.command; -import org.bukkit.entity.Player; - -import mineplex.core.chat.Chat; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilServer; import mineplex.core.preferences.PreferencesManager; +import org.bukkit.entity.Player; public class PreferencesCommand extends CommandBase { @@ -18,6 +15,6 @@ public class PreferencesCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - Plugin.openShop(caller); + Plugin.openMenu(caller); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java deleted file mode 100644 index c376b2461..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java +++ /dev/null @@ -1,241 +0,0 @@ -package mineplex.core.preferences.ui; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -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.UtilUI; -import mineplex.core.donation.DonationManager; -import mineplex.core.preferences.PreferencesManager; -import mineplex.core.preferences.UserPreferences; -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ShopPageBase; - -public class ExclusivePreferencesPage extends ShopPageBase -{ - private IButton _toggleHubInvisibility; - private IButton _toggleHubForcefield; - private IButton _toggleHubIgnoreVelocity; - private IButton _toggleMacReports; - private IButton _toggleUserReports; - - private boolean _hubInvisibilityToggled; - private boolean _hubForcefieldToggled; - private boolean _hubIgnoreVelocityToggled; - private boolean _macReportsToggled; - private boolean _userReportsToggled; - - private PreferencesShop _preferencesShop; - - public ExclusivePreferencesPage(PreferencesManager plugin, ExclusivePreferencesShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, PreferencesShop preferencesShop) - { - super(plugin, shop, clientManager, donationManager, name, player, 54); - - _preferencesShop = preferencesShop; - - createButtons(); - buildPage(); - } - - private void createButtons() - { - _toggleHubInvisibility = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleHubInvisibility(player); - } - }; - - _toggleHubForcefield = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleHubForcefield(player); - } - }; - - _toggleMacReports = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleMacReports(player); - } - }; - - _toggleUserReports = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleUserReports(player); - } - }; - - _toggleHubIgnoreVelocity = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleHubIgnoreVelocity(player); - } - }; - } - - @Override - public void playerClosed() - { - super.playerClosed(); - if (preferencesChanged()) - { - getPlugin().savePreferences(getPlayer()); - } - } - - @Override - protected void buildPage() - { - clear(); - - UserPreferences userPreferences = getPlugin().Get(getPlayer()); - Rank rank = getClientManager().Get(getPlayer()).GetRank(); - - addButton(45, new ShopItem(Material.REDSTONE_COMPARATOR, (byte) 0, C.cAqua + "/prefs", new String[] { C.cGold + "Return back to the regular preferences" }, 1, false, false), new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - player.closeInventory(); - _preferencesShop.attemptShopOpen(player); - } - }); - - if (rank.has(Rank.ADMIN) || rank == Rank.JNR_DEV) - { - int[] indices = UtilUI.getIndicesFor(5, 0, 2); - - buildPreference(indices[0], Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility); - buildPreference(indices[1], Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield); - buildPreference(indices[2], Material.PAPER, "Global GWEN Reports", userPreferences.ShowMacReports, _toggleMacReports); - buildPreference(indices[3], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity); - buildPreference(indices[4], Material.BOOK, "User Reports", userPreferences.ShowUserReports, _toggleUserReports); - } - else if (rank.has(Rank.SNR_MODERATOR)) - { - int[] indices = UtilUI.getIndicesFor(3, 0, 2); - - buildPreference(indices[0], Material.PAPER, "Global GWEN Reports", userPreferences.ShowMacReports, _toggleMacReports); - buildPreference(indices[1], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity); - buildPreference(indices[2], Material.BOOK, "User Reports", userPreferences.ShowUserReports, _toggleUserReports); - } - else if (rank.has(Rank.MODERATOR)) - { - int[] indices = UtilUI.getIndicesFor(3, 0, 2); - - buildPreference(indices[0], Material.PAPER, "Global GWEN Reports", userPreferences.ShowMacReports, _toggleMacReports); - buildPreference(indices[1], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity); - buildPreference(indices[2], Material.BOOK, "User Reports", userPreferences.ShowUserReports, _toggleUserReports); - } - else if (rank.has(Rank.HELPER)) - { - int[] indices = UtilUI.getIndicesFor(1, 0, 2); - - buildPreference(indices[0], Material.PAPER, "Global GWEN Reports", userPreferences.ShowMacReports, _toggleMacReports); - } - else if (rank == Rank.YOUTUBE || rank == Rank.TWITCH) - { - int[] indices = UtilUI.getIndicesFor(3, 0, 2); - - buildPreference(indices[0], Material.NETHER_STAR, "Hub Invisibility & Flight", userPreferences.Invisibility, _toggleHubInvisibility); - buildPreference(indices[1], Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield); - buildPreference(indices[2], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity); - } - else if (rank == Rank.YOUTUBE_SMALL) - { - int[] indices = UtilUI.getIndicesFor(2, 0, 2); - buildPreference(indices[0], Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield); - buildPreference(indices[1], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity); - } - } - - private void toggleHubForcefield(org.bukkit.entity.Player player) - { - getPlugin().Get(player).HubForcefield = !getPlugin().Get(player).HubForcefield; - _hubForcefieldToggled = !_hubForcefieldToggled; - buildPage(); - } - - private void toggleHubInvisibility(org.bukkit.entity.Player player) - { - if (getPlugin().getIncognitoManager() != null && getPlugin().getIncognitoManager().Get(player).Status && /* Hub Invis & Incognito stuck prevention */ !getPlugin().Get(player).Invisibility) - { - UtilPlayer.message(player, F.main("Incognito", "You are not allowed to use Hub Visibility whilst in incognito mode.")); - return; - } - - getPlugin().Get(player).Invisibility = !getPlugin().Get(player).Invisibility; - - // Dont save for Mod/SnrMod - prevents them just being invis 24/7 - if (getPlugin().Get(player).Invisibility) - { - if (getClient().GetRank().has(Rank.ADMIN) || getClient().GetRank() == Rank.YOUTUBE || getClient().GetRank() == Rank.YOUTUBE_SMALL || getClient().GetRank() == Rank.TWITCH) - { - _hubInvisibilityToggled = !_hubInvisibilityToggled; - } - } - - player.setFlying(false); - player.setAllowFlight(false); - - buildPage(); - } - - private void toggleMacReports(org.bukkit.entity.Player player) - { - getPlugin().Get(player).ShowMacReports = !getPlugin().Get(player).ShowMacReports; - _macReportsToggled = !_macReportsToggled; - buildPage(); - } - - private void toggleUserReports(org.bukkit.entity.Player player) - { - getPlugin().Get(player).ShowUserReports = !getPlugin().Get(player).ShowUserReports; - _userReportsToggled = !_userReportsToggled; - buildPage(); - } - - private void toggleHubIgnoreVelocity(org.bukkit.entity.Player player) - { - getPlugin().Get(player).IgnoreVelocity = !getPlugin().Get(player).IgnoreVelocity; - _hubIgnoreVelocityToggled = !_hubIgnoreVelocityToggled; - buildPage(); - } - - private void buildPreference(int index, Material material, String name, boolean preference, IButton button) - { - buildPreference(index, material, (byte) 0, name, preference, button); - } - - private void buildPreference(int index, Material material, byte data, String name, boolean preference, IButton button) - { - String[] description = new String[] { "" + (preference ? ChatColor.GREEN + "Enabled" : ChatColor.RED + "Disabled"), ChatColor.RED + " ", ChatColor.RESET + "Click to " + (preference ? "Disable" : "Enable") }; - - addButton(index, new ShopItem(material, data, (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button); - addButton(index + 9, new ShopItem(Material.INK_SACK, (preference ? (byte) 10 : (byte) 8), (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button); - } - - public boolean preferencesChanged() - { - return _hubInvisibilityToggled || _macReportsToggled || _hubIgnoreVelocityToggled || _hubForcefieldToggled || _userReportsToggled; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesShop.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesShop.java deleted file mode 100644 index ba8ec291a..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesShop.java +++ /dev/null @@ -1,29 +0,0 @@ -package mineplex.core.preferences.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.preferences.PreferencesManager; -import mineplex.core.shop.ShopBase; -import mineplex.core.shop.page.ShopPageBase; - -public class ExclusivePreferencesShop extends ShopBase -{ - private PreferencesShop _preferencesShop; - - public ExclusivePreferencesShop(PreferencesManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager) - { - super(plugin, clientManager, donationManager, "Exclusive Preferences"); - } - - public void setPreferencesShop(PreferencesShop preferencesShop) - { - _preferencesShop = preferencesShop; - } - - @Override - protected ShopPageBase> buildPagesFor(Player player) - { - return new ExclusivePreferencesPage(getPlugin(), this, getClientManager(), getDonationManager(), "Exclusive Preferences", player, _preferencesShop); - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java new file mode 100644 index 000000000..17d259457 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java @@ -0,0 +1,67 @@ +package mineplex.core.preferences.ui; + +import com.google.common.collect.Lists; +import mineplex.core.common.Rank; +import mineplex.core.menu.Button; +import mineplex.core.menu.Menu; +import mineplex.core.preferences.PreferenceCategory; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.preferences.ui.buttons.CategoryButton; +import org.bukkit.entity.Player; + +import java.util.List; + +/** + * + */ +public class PreferenceMainMenu extends Menu +{ + + private final int INV_SIZE_MAX = 54; + private final int INV_SIZE_MIN = 45; + + private final int[] SLOTS_MAX = { + 20, 22, 24, 30, 32 + }; + + private final int[] SLOTS_MIN = { + 19, 21, 23, 25 + }; + + + public PreferenceMainMenu(PreferencesManager plugin) + { + super("My Preferences", plugin); + } + + @Override + protected Button[] setUp(Player player) + { + Rank rank = getPlugin().getClientManager().Get(player).GetRank(); + boolean exclusive = rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE_SMALL || rank == Rank.YOUTUBE || rank == Rank.TWITCH; + + Button[] buttons = new Button[exclusive ? INV_SIZE_MAX : INV_SIZE_MIN]; + + List list = Lists.newArrayList(PreferenceCategory.values()); + + int[] slots = SLOTS_MAX; + + if(!exclusive) + { + list.remove(PreferenceCategory.EXCLUSIVE); + slots = SLOTS_MIN; + } + + int size = list.size(); + + for(int i = 0; i < size; i++) + { + int slot = slots[i]; + PreferenceCategory category = list.get(i); + buttons[slot] = new CategoryButton(category, getPlugin()); + } + + return pane(buttons); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java deleted file mode 100644 index 6473981a4..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesPage.java +++ /dev/null @@ -1,265 +0,0 @@ -package mineplex.core.preferences.ui; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilUI; -import mineplex.core.donation.DonationManager; -import mineplex.core.preferences.PreferencesManager; -import mineplex.core.preferences.UserPreferences; -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ShopPageBase; - -public class PreferencesPage extends ShopPageBase -{ - private IButton _toggleHubGames; - private IButton _toggleHubPlayers; - private IButton _toggleChat; - private IButton _togglePrivateChat; - private IButton _toggleHubPartyRequests; - private IButton _togglePendingFriendRequests; - private IButton _toggleClanTips; - private IButton _toggleHubMusic; - private IButton _toggleDisableAds; - - private boolean _hubGamesToggled; - private boolean _hubPlayersToggled; - private boolean _hubChatToggled; - private boolean _hubPrivateChatToggled; - private boolean _hubPartyRequestsToggled; - private boolean _pendingFriendRequestsToggled; - private boolean _clanTipsToggled; - private boolean _hubMusicToggled; - private boolean _disableAdsToggled; - - private ExclusivePreferencesShop _exclusiveShop; - - public PreferencesPage(PreferencesManager plugin, PreferencesShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, ExclusivePreferencesShop exclusiveShop) - { - super(plugin, shop, clientManager, donationManager, name, player, 54); - - _exclusiveShop = exclusiveShop; - - createButtons(); - buildPage(); - } - - private void createButtons() - { - _toggleHubGames = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleHubGames(player); - } - }; - _toggleClanTips = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleClanTips(player); - } - }; - - _toggleHubPlayers = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleHubPlayers(player); - } - }; - - _toggleChat = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleChat(player); - } - }; - - _togglePrivateChat = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - togglePrivateChat(player); - } - }; - - _toggleHubPartyRequests = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleHubPartyRequests(player); - } - }; - - _togglePendingFriendRequests = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - togglePendingFriendRequests(player); - } - }; - - _toggleHubMusic = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleHubMusic(player); - } - }; - - _toggleDisableAds = new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - toggleDisableAds(player); - } - }; - } - - private void toggleHubMusic(Player player) - { - getPlugin().Get(player).HubMusic = !getPlugin().Get(player).HubMusic; - _hubMusicToggled = !_hubMusicToggled; - buildPage(); - } - - private void toggleDisableAds(Player player) - { - getPlugin().Get(player).DisableAds = !getPlugin().Get(player).DisableAds; - _disableAdsToggled = !_disableAdsToggled; - buildPage(); - } - - - private void toggleHubPartyRequests(Player player) - { - getPlugin().Get(player).PartyRequests = !getPlugin().Get(player).PartyRequests; - _hubPartyRequestsToggled = !_hubPartyRequestsToggled; - buildPage(); - } - - private void togglePendingFriendRequests(Player player) - { - getPlugin().Get(player).PendingFriendRequests = !getPlugin().Get(player).PendingFriendRequests; - _pendingFriendRequestsToggled = !_pendingFriendRequestsToggled; - buildPage(); - } - - private void togglePrivateChat(Player player) - { - getPlugin().Get(player).PrivateMessaging = !getPlugin().Get(player).PrivateMessaging; - _hubPrivateChatToggled = !_hubPrivateChatToggled; - buildPage(); - } - - private void toggleChat(Player player) - { - getPlugin().Get(player).ShowChat = !getPlugin().Get(player).ShowChat; - _hubChatToggled = !_hubChatToggled; - buildPage(); - } - - private void toggleHubPlayers(Player player) - { - getPlugin().Get(player).ShowPlayers = !getPlugin().Get(player).ShowPlayers; - _hubPlayersToggled = !_hubPlayersToggled; - buildPage(); - } - - private void toggleClanTips(Player player) - { - getPlugin().Get(player).ClanTips = !getPlugin().Get(player).ClanTips; - _clanTipsToggled = !_clanTipsToggled; - buildPage(); - } - - private void toggleHubGames(Player player) - { - getPlugin().Get(player).HubGames = !getPlugin().Get(player).HubGames; - _hubGamesToggled = !_hubGamesToggled; - buildPage(); - } - - @Override - public void playerClosed() - { - super.playerClosed(); - - System.out.println("Prefs have changed: " + preferencesChanged()); - if (preferencesChanged()) - { - getPlugin().savePreferences(getPlayer()); - } - } - - @Override - protected void buildPage() - { - clear(); - - UserPreferences userPreferences = getPlugin().Get(getPlayer()); - Rank rank = getClientManager().Get(getPlayer()).GetRank(); - - int amount = rank.has(Rank.ULTRA) ? 9 : 8; - int[] indices = UtilUI.getIndicesFor(amount, 0, 2); - - buildPreference(indices[0], Material.FIREBALL, "Hub Player Stacker", userPreferences.HubGames, _toggleHubGames); - buildPreference(indices[1], Material.EYE_OF_ENDER, "Hub Player Visibility", userPreferences.ShowPlayers, _toggleHubPlayers); - buildPreference(indices[2], Material.PAPER, "Player Chat", userPreferences.ShowChat, _toggleChat); - buildPreference(indices[3], Material.EMPTY_MAP, "Private Messaging", userPreferences.PrivateMessaging, _togglePrivateChat); - buildPreference(indices[4], Material.SKULL_ITEM, (byte) 3, "Hub Party Requests", userPreferences.PartyRequests, _toggleHubPartyRequests); - buildPreference(indices[5], Material.RED_ROSE, "Show Pending Friend Requests", userPreferences.PendingFriendRequests, _togglePendingFriendRequests); - buildPreference(indices[6], Material.IRON_SWORD, "Show Clan Tips", userPreferences.ClanTips, _toggleClanTips); - buildPreference(indices[7], Material.NOTE_BLOCK, "Hub Music", userPreferences.HubMusic, _toggleHubMusic); - if (rank.has(Rank.ULTRA)) - buildPreference(indices[8], Material.BARRIER, "Disable Ads", userPreferences.DisableAds, _toggleDisableAds); - - if (rank.has(Rank.HELPER) || rank == Rank.YOUTUBE || rank == Rank.TWITCH || rank == Rank.YOUTUBE_SMALL) - { - addButton(53, new ShopItem(Material.DIAMOND, (byte) 0, C.cAqua + "Exclusive Preferences", new String[]{C.cGold + "This will open a page of preferences", C.cGold + "that are only available to you."}, 1, false, false), new IButton() - { - @Override - public void onClick(Player player, ClickType clickType) - { - player.closeInventory(); - _exclusiveShop.attemptShopOpen(player); - } - }); - } - } - - private void buildPreference(int index, Material material, String name, boolean preference, IButton button) - { - buildPreference(index, material, (byte) 0, name, preference, button); - } - - private void buildPreference(int index, Material material, byte data, String name, boolean preference, IButton button) - { - String[] description = new String[] { "" + (preference ? ChatColor.GREEN + "Enabled" : ChatColor.RED + "Disabled"), ChatColor.RED + " ", ChatColor.RESET + "Click to " + (preference ? "Disable" : "Enable") }; - - addButton(index, new ShopItem(material, data, (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button); - addButton(index + 9, new ShopItem(Material.INK_SACK, (preference ? (byte) 10 : (byte) 8), (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button); - } - - public boolean preferencesChanged() - { - return _hubGamesToggled || _hubPlayersToggled || _hubChatToggled || _hubPrivateChatToggled || _hubPartyRequestsToggled || _pendingFriendRequestsToggled || _clanTipsToggled || _hubMusicToggled || _disableAdsToggled; - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesShop.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesShop.java deleted file mode 100644 index e3b172414..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferencesShop.java +++ /dev/null @@ -1,25 +0,0 @@ -package mineplex.core.preferences.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.preferences.PreferencesManager; -import mineplex.core.shop.ShopBase; -import mineplex.core.shop.page.ShopPageBase; - -public class PreferencesShop extends ShopBase -{ - private ExclusivePreferencesShop _exclusiveShop; - - public PreferencesShop(PreferencesManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager, ExclusivePreferencesShop exclusiveShop) - { - super(plugin, clientManager, donationManager, "My Preferences"); - _exclusiveShop = exclusiveShop; - } - - @Override - protected ShopPageBase> buildPagesFor(Player player) - { - return new PreferencesPage(getPlugin(), this, getClientManager(), getDonationManager(), "My Preferences", player, _exclusiveShop); - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/BackButton.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/BackButton.java new file mode 100644 index 000000000..4ae6d6491 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/BackButton.java @@ -0,0 +1,41 @@ +package mineplex.core.preferences.ui.buttons; + +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.Menu; +import mineplex.core.preferences.PreferencesManager; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +/** + * + */ +public class BackButton extends Button +{ + + private static ItemStack ITEM = new ItemBuilder(Material.BED) + .setTitle(ChatColor.GRAY + "\u21FD Go Back") + .build(); + + public BackButton(PreferencesManager plugin) + { + super(ITEM, plugin); + } + + @Override + public void onClick(Player player, ClickType clickType) + { + Menu.get(player.getUniqueId()).setUseClose(false); + + player.closeInventory(); + + getPlugin().openMenu(player); + + getPlugin().save(getPlugin().get(player)); + + Menu.get(player.getUniqueId()).setUseClose(true); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/CategoryButton.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/CategoryButton.java new file mode 100644 index 000000000..efcbc3770 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/CategoryButton.java @@ -0,0 +1,29 @@ +package mineplex.core.preferences.ui.buttons; + +import mineplex.core.menu.Button; +import mineplex.core.preferences.PreferenceCategory; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.preferences.ui.menus.PreferenceMenu; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +/** + * + */ +public class CategoryButton extends Button +{ + + private PreferenceCategory _category; + + public CategoryButton(PreferenceCategory category, PreferencesManager plugin) + { + super(category.getItem(), plugin); + _category = category; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + new PreferenceMenu(_category, getPlugin()).open(player); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceButton.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceButton.java new file mode 100644 index 000000000..e22daeff5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceButton.java @@ -0,0 +1,63 @@ +package mineplex.core.preferences.ui.buttons; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.Menu; +import mineplex.core.preferences.Preference; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.preferences.UserPreferences; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +/** + * + */ +public class PreferenceButton extends Button +{ + + protected final Preference _preference; + protected final UserPreferences _user; + private final ItemStack _disabled; + private final ItemStack _enabled; + + public PreferenceButton(UserPreferences user, Preference preference, PreferencesManager plugin) + { + super(null, plugin); + _preference = preference; + _user = user; + + Material icon = preference.getIcon(); + boolean head = icon == Material.SKULL_ITEM; + + _disabled = new ItemBuilder(preference.getIcon()) + .setTitle(C.cRed + preference.getName()) + .setLore(C.cRed + "Disabled", " " , C.cWhite + "Click to Enable") + .setData(head ? (short) 3 : 0) + .build(); + + _enabled = new ItemBuilder(preference.getIcon()) + .setTitle(C.cGreen + preference.getName()) + .setLore(C.cGreen + "Enabled", " " , C.cWhite + "Click to Disable") + .setData(head ? (short) 3 : 0) + .build(); + + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _user.toggle(_preference); + Menu.get(player.getUniqueId()).resetAndUpdate(); + } + + @Override + public ItemStack getItemStack() + { + return _user.isActive(_preference) ? _enabled : _disabled; + } + + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceDyeButton.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceDyeButton.java new file mode 100644 index 000000000..886091a16 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceDyeButton.java @@ -0,0 +1,43 @@ +package mineplex.core.preferences.ui.buttons; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.preferences.Preference; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.preferences.UserPreferences; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +/** + * + */ +public class PreferenceDyeButton extends PreferenceButton +{ + + private final ItemStack _disabledDye; + private final ItemStack _enabledDye; + + public PreferenceDyeButton(UserPreferences user, Preference preference, PreferencesManager plugin) + { + super(user, preference, plugin); + + _disabledDye = new ItemBuilder(Material.INK_SACK) + .setData(DyeColor.GRAY.getDyeData()) + .setTitle(C.cRed + preference.getName()) + .setLore(C.cRed + "Disabled", " " , C.cWhite + "Click to Enable") + .build(); + + _enabledDye = new ItemBuilder(Material.INK_SACK) + .setData(DyeColor.LIME.getDyeData()) + .setTitle(C.cGreen + preference.getName()) + .setLore(C.cGreen + "Enabled", " " , C.cWhite + "Click to Disable") + .build(); + } + + @Override + public ItemStack getItemStack() + { + return _user.isActive(_preference) ? _enabledDye : _disabledDye; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/menus/PreferenceMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/menus/PreferenceMenu.java new file mode 100644 index 000000000..c3f0d8a06 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/menus/PreferenceMenu.java @@ -0,0 +1,85 @@ +package mineplex.core.preferences.ui.menus; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilUI; +import mineplex.core.menu.Button; +import mineplex.core.menu.Menu; +import mineplex.core.preferences.Preference; +import mineplex.core.preferences.PreferenceCategory; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.preferences.UserPreferences; +import mineplex.core.preferences.ui.buttons.BackButton; +import mineplex.core.preferences.ui.buttons.PreferenceButton; +import mineplex.core.preferences.ui.buttons.PreferenceDyeButton; +import org.bukkit.entity.Player; + +import java.util.List; + +/** + * + */ +public class PreferenceMenu extends Menu +{ + + private final int INV_SIZE = 54; + + private final PreferenceCategory _category; + + public PreferenceMenu(PreferenceCategory category, PreferencesManager plugin) + { + super(category.getName(), plugin); + _category = category; + setUseClose(true); + } + + @Override + protected Button[] setUp(Player player) + { + Button[] buttons = new Button[INV_SIZE]; + + List preferences = Preference.getByCategory(_category); + Rank rank = getPlugin().getClientManager().Get(player).GetRank(); + UserPreferences user = getPlugin().get(player); + + if (_category == PreferenceCategory.EXCLUSIVE && !rank.has(Rank.ADMIN) && rank != Rank.JNR_DEV) + { + if (rank.has(Rank.MODERATOR) && !rank.has(Rank.ADMIN)) + { + preferences.remove(Preference.INVISIBILITY); + preferences.remove(Preference.FORCE_FIELD); + } + else if (rank == Rank.YOUTUBE || rank == Rank.TWITCH) + { + preferences.remove(Preference.SHOW_MAC_REPORTS); + preferences.remove(Preference.SHOW_USER_REPORTS); + } + else if (rank == Rank.YOUTUBE_SMALL) + { + preferences.remove(Preference.SHOW_MAC_REPORTS); + preferences.remove(Preference.SHOW_USER_REPORTS); + preferences.remove(Preference.INVISIBILITY); + } + } + + int[] slots = UtilUI.getIndicesFor(preferences.size(), 1, 4, 1); + + for(int i = 0; i < preferences.size(); i++) + { + int slot = slots[i]; + Preference preference = preferences.get(i); + buttons[slot] = new PreferenceButton(user, preference, getPlugin()); + buttons[slot + 9] = new PreferenceDyeButton(user, preference, getPlugin()); + } + + buttons[0] = new BackButton(getPlugin()); + + return pane(buttons); + } + + @Override + public void onClose(Player player) + { + remove(player.getUniqueId()); + getPlugin().save(getPlugin().get(player)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java index 1ab09449e..3e0a72490 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java @@ -4,7 +4,6 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.progression.data.PlayerKit; import mineplex.core.progression.data.PlayerKitDataManager; -import mineplex.core.progression.gui.MenuListener; import org.bukkit.plugin.java.JavaPlugin; import java.util.UUID; @@ -25,7 +24,6 @@ public class KitProgressionManager extends MiniClientPlugin _dataManager = new PlayerKitDataManager(); _kitProgressionRepository = new KitProgressionRepository(this); _coreClientManager = clientManager; - getPlugin().getServer().getPluginManager().registerEvents(new MenuListener(), getPlugin()); } public CoreClientManager getClientManager() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java index 7ea77ef52..36dcea873 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import java.util.List; +import java.util.Map; import java.util.UUID; /** @@ -53,7 +54,17 @@ public interface ProgressiveKit * * @return The map of upgrades and their details */ - List getAbilityDetails(); + Map> getAbilityDetails(); + + /** + * Determines whether or not the kit UI is displayed with "Coming Soon" or actual upgrade details. + * + * @return true if the menu should populate from {@code getAbilityDetails} + */ + default boolean showUpgrades() + { + return false; + } /** * Retrieve the current level of this kit diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/Button.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/Button.java deleted file mode 100644 index 5e172ce91..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/Button.java +++ /dev/null @@ -1,36 +0,0 @@ -package mineplex.core.progression.gui; - -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -/** - * An abstract class for managing buttons inside of menus - */ -public abstract class Button -{ - - private ItemStack _item; - - public Button(ItemStack item) - { - this._item = item; - } - - /** - * The method called when a players clicks the slot - * - * @param player The player who clicked - */ - public abstract void onClick(Player player); - - public ItemStack getItemStack() - { - return _item; - } - - public void setItemStack(ItemStack item) - { - this._item = item; - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/Menu.java deleted file mode 100644 index e2089e9ff..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/Menu.java +++ /dev/null @@ -1,191 +0,0 @@ -package mineplex.core.progression.gui; - -import mineplex.core.progression.gui.buttons.misc.IconButton; -import net.md_5.bungee.api.ChatColor; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryView; -import org.bukkit.inventory.ItemStack; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -/** - * A class to manage dynamic creation of GUI's - */ -public abstract class Menu -{ - - protected static final Button[] EMPTY = new Button[45]; - protected static Map MENUS = new HashMap<>(); - private String _name; - protected Button[] _buttons; - - public Menu(String name) - { - _name = name; - _buttons = EMPTY; - } - - public static Menu get(UUID name) - { - return MENUS.get(name); - } - - - /** - * Create an icon (no click action) - * - * @param item The itemstack ti display - * @return The created button - */ - protected Button create(ItemStack item) - { - return new IconButton(item); - } - - public String getName() - { - return ChatColor.translateAlternateColorCodes('&', _name); - } - - /** - * Open and setup the inventory for the player to view - * Store a reference to it inside a map for retrieving later - * - * @param player The player who we wish to show the GUI to - */ - public void open(Player player) - { - setButtons(setUp()); - - if (MENUS.get(player.getUniqueId()) != null) - { - MENUS.remove(player.getUniqueId()); - } - - MENUS.put(player.getUniqueId(), this); - - int size = (_buttons.length + 8) / 9 * 9; - Inventory inventory = Bukkit.createInventory(player, size, getName()); - - for (int i = 0; i < _buttons.length; i++) - { - if (_buttons[i] == null) - { - continue; - } - - ItemStack item = _buttons[i].getItemStack(); - - inventory.setItem(i, item); - } - player.openInventory(inventory); - } - - /** - * Set up the GUI with buttons - * - * @return The setup button array - */ - protected abstract Button[] setUp(); - - public Button[] getButtons() - { - return _buttons; - } - - public void setButtons(Button[] buttons) - { - _buttons = buttons; - } - - /** - * Retrieve the button based off the slot - * - * @param slot The slot in the inventory - * @return The button corresponding to that slot - */ - public Button getButton(int slot) - { - try - { - return _buttons[slot]; - } catch (ArrayIndexOutOfBoundsException e) - { - //There isn't a button there, so no need to throw an error - //e.printStackTrace(); - return null; - } - } - - /** - * Replace a button, or create a new button dynamically - * Update the players GUI - * - * @param slot The slot to set the new button - * @param button The reference to the button - * @param player The player whose GUI we'll be updating - */ - public void setButton(int slot, Button button, Player player) - { - try - { - _buttons[slot] = button; - } catch (ArrayIndexOutOfBoundsException ignored) - { - ignored.printStackTrace(); - } - update(player); - } - - /** - * Refresh the players view, allows to change what the player sees, without opening and closing the GUI - * - * @param player The player whose view you wish to update - */ - public void update(Player player) - { - InventoryView view = player.getOpenInventory(); - - if (view == null) - { - return; - } - - if (!view.getTitle().equalsIgnoreCase(getName())) - { - return; - } - - Inventory inventory = view.getTopInventory(); - for (int i = 0; i < _buttons.length; i++) - { - if (_buttons[i] == null) - { - continue; - } - - ItemStack item = _buttons[i].getItemStack(); - - inventory.setItem(i, item); - } - } - - public void setTitle(String title) - { - _name = title; - } - - public void onClose(Player player) - { - MENUS.remove(player.getUniqueId()); - } - - public static Menu remove(UUID uniqueId) - { - return MENUS.remove(uniqueId); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/MenuListener.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/MenuListener.java deleted file mode 100644 index 3fc59c542..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/MenuListener.java +++ /dev/null @@ -1,45 +0,0 @@ -package mineplex.core.progression.gui; - -import org.bukkit.entity.Player; -import org.bukkit.event.Event; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; - -/** - * Listener for the Menu system - */ -public class MenuListener implements Listener -{ - - @EventHandler - public void onClick(InventoryClickEvent event) - { - String name = event.getInventory().getName(); - Player player = (Player) event.getWhoClicked(); - Menu gui = Menu.get(player.getUniqueId()); - - if (gui == null) - { - return; - } - - if (!gui.getName().equalsIgnoreCase(name)) - { - return; - } - - Button button = gui.getButton(event.getRawSlot()); - - event.setCancelled(true); - event.setResult(Event.Result.DENY); - - if (button == null) - { - return; - } - - button.onClick(player); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitAbilityButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitAbilityButton.java index 817d1a8bf..e01573a05 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitAbilityButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitAbilityButton.java @@ -2,8 +2,8 @@ package mineplex.core.progression.gui.buttons; import com.google.common.collect.Lists; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.IconButton; import mineplex.core.progression.data.KitAbilityDetail; -import mineplex.core.progression.gui.buttons.misc.IconButton; import org.bukkit.inventory.ItemStack; import java.util.Arrays; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitButton.java index 6614e2528..7b3ff477f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitButton.java @@ -1,21 +1,27 @@ package mineplex.core.progression.gui.buttons; +import mineplex.core.menu.Button; +import mineplex.core.progression.KitProgressionManager; import mineplex.core.progression.ProgressiveKit; -import mineplex.core.progression.gui.Button; import org.bukkit.inventory.ItemStack; /** * Similar to KitMenu, this helps with organizing buttons related to kits * Since they all share common features. */ -public abstract class KitButton extends Button +public abstract class KitButton extends Button { private ProgressiveKit _kit; public KitButton(ProgressiveKit kit, ItemStack itemStack) { - super(itemStack); + this(kit, itemStack, null); + } + + public KitButton(ProgressiveKit kit, ItemStack itemStack, KitProgressionManager plugin) + { + super(itemStack, plugin); _kit = kit; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitIconButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitIconButton.java index 24b94d19a..d29f09c20 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitIconButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitIconButton.java @@ -7,6 +7,7 @@ import mineplex.core.itemstack.ItemBuilder; import mineplex.core.progression.ProgressiveKit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import java.util.List; @@ -68,7 +69,7 @@ public class KitIconButton extends KitButton } @Override - public void onClick(Player player) + public void onClick(Player player, ClickType clickType) { getKit().onSelected(player.getUniqueId()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitPermanentDefaultButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitPermanentDefaultButton.java index efaafd3cd..12be52d5a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitPermanentDefaultButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitPermanentDefaultButton.java @@ -6,6 +6,7 @@ import net.md_5.bungee.api.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; /** @@ -37,7 +38,7 @@ public class KitPermanentDefaultButton extends KitButton } @Override - public void onClick(Player player) + public void onClick(Player player, ClickType clickType) { getKit().onSelected(player.getUniqueId()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitSelectButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitSelectButton.java index acdf770fc..b6b302c98 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitSelectButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitSelectButton.java @@ -8,6 +8,7 @@ import net.md_5.bungee.api.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; /** * This manages selecting of the kit for the current game. @@ -31,7 +32,7 @@ public class KitSelectButton extends KitButton } @Override - public void onClick(Player player) + public void onClick(Player player, ClickType clickType) { getKit().onSelected(player.getUniqueId()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeButton.java index cc73ff690..dcb60c4bf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeButton.java @@ -1,10 +1,11 @@ package mineplex.core.progression.gui.buttons; import mineplex.core.common.util.F; +import mineplex.core.menu.Menu; import mineplex.core.progression.ProgressiveKit; -import mineplex.core.progression.gui.Menu; import org.bukkit.Sound; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import java.util.UUID; @@ -26,7 +27,7 @@ public class KitUpgradeButton extends KitButton } @Override - public void onClick(Player player) + public void onClick(Player player, ClickType clickType) { UUID uuid = player.getUniqueId(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeMenuButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeMenuButton.java index d8792c357..99cacbb28 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeMenuButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeMenuButton.java @@ -2,6 +2,7 @@ package mineplex.core.progression.gui.buttons; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.progression.KitProgressionManager; import mineplex.core.progression.ProgressiveKit; import mineplex.core.progression.gui.guis.KitInformationTrackerMenu; import mineplex.core.progression.gui.guis.KitMenu; @@ -9,12 +10,11 @@ import mineplex.core.progression.math.Calculations; import net.md_5.bungee.api.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; -import static mineplex.core.common.util.UtilServer.getPlugin; - /** * This is the button for upgrades. It'll flash when one is available * Displays information regarding upgrades on hover @@ -31,9 +31,9 @@ public class KitUpgradeMenuButton extends KitButton private boolean _flash; private BukkitTask _task; - public KitUpgradeMenuButton(ProgressiveKit kit, Player player) + public KitUpgradeMenuButton(ProgressiveKit kit, Player player, KitProgressionManager plugin) { - super(kit, null); + super(kit, null, plugin); _item = ITEM_STACK; //The current upgrade level out of 5 for this kit @@ -50,13 +50,18 @@ public class KitUpgradeMenuButton extends KitButton //This ONLY flashes if their next upgrade level isn't their same one. _flash = Calculations.isUpgradeLevelEligible(level) && (nextUpgradeLevel > upgradeLevel); + ChatColor color = Calculations.getColor(level, nextUpgradeLevelPlayer); + + if(kit.showUpgrades()) + { + ItemBuilder builder = lore(new ItemBuilder(Material.ENCHANTMENT_TABLE), upgradeLevel, color, diff); + _item = builder.build(); + } + if (_flash) { flash(); } - - ChatColor color = Calculations.getColor(level, nextUpgradeLevelPlayer); - } @Override @@ -73,7 +78,7 @@ public class KitUpgradeMenuButton extends KitButton private void flash() { - this._task = new BukkitRunnable() + _task = new BukkitRunnable() { private ItemStack itemClone = ITEM_STACK.clone(); @@ -103,11 +108,11 @@ public class KitUpgradeMenuButton extends KitButton resetItem = true; } - }.runTaskTimer(getPlugin(), 0L, 10L); + }.runTaskTimer(getPlugin().getPlugin(), 0L, 10L); } @Override - public void onClick(Player player) + public void onClick(Player player, ClickType clickType) { this._flash = false; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitXPButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitXPButton.java index c96cc3a08..186436dc2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitXPButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitXPButton.java @@ -9,6 +9,7 @@ import mineplex.core.progression.math.Calculations; import net.md_5.bungee.api.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import java.util.List; @@ -87,7 +88,7 @@ public class KitXPButton extends KitButton @Override - public void onClick(Player player) + public void onClick(Player player, ClickType clickType) { KitMenu menu = new KitInformationTrackerMenu(getKit()); menu.open(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/BackButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/BackButton.java index 11dd54c5a..be6519c88 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/BackButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/BackButton.java @@ -1,17 +1,19 @@ package mineplex.core.progression.gui.buttons.misc; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.progression.gui.Button; +import mineplex.core.menu.Button; +import mineplex.core.progression.KitProgressionManager; import mineplex.core.progression.gui.guis.KitMenu; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; /** * This button take you back to the specified menu */ -public class BackButton extends Button +public class BackButton extends Button { private static ItemStack ITEM = new ItemBuilder(Material.BED) @@ -22,7 +24,7 @@ public class BackButton extends Button public BackButton(KitMenu toMenu) { - super(ITEM); + super(ITEM, null); _toMenu = toMenu; } @@ -33,7 +35,7 @@ public class BackButton extends Button } @Override - public void onClick(Player player) + public void onClick(Player player, ClickType clickType) { _toMenu.open(player); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/IconButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/IconButton.java deleted file mode 100644 index 36de05e7c..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/misc/IconButton.java +++ /dev/null @@ -1,23 +0,0 @@ -package mineplex.core.progression.gui.buttons.misc; - -import mineplex.core.progression.gui.Button; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -/** - * A button designed for purely cosmetic reasons, but has no impact when clicked. - */ -public class IconButton extends Button -{ - - public IconButton(ItemStack item) - { - super(item); - } - - @Override - public void onClick(Player player) - { - - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java index f46165e34..99eee38d6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java @@ -1,11 +1,19 @@ package mineplex.core.progression.gui.guis; +import mineplex.core.menu.Button; +import mineplex.core.menu.IconButton; import mineplex.core.progression.ProgressiveKit; -import mineplex.core.progression.gui.Button; -import mineplex.core.progression.gui.buttons.*; -import mineplex.core.progression.gui.buttons.misc.IconButton; +import mineplex.core.progression.data.KitAbilityDetail; +import mineplex.core.progression.gui.buttons.KitAbilityButton; +import mineplex.core.progression.gui.buttons.KitIconButton; +import mineplex.core.progression.gui.buttons.KitPermanentDefaultButton; +import mineplex.core.progression.gui.buttons.KitSelectButton; +import mineplex.core.progression.gui.buttons.KitUpgradeMenuButton; +import mineplex.core.progression.gui.buttons.KitXPButton; import org.bukkit.entity.Player; +import java.util.List; + /** * This is the main menu a player sees when we selects an NPC Kit * Displays the most important information about this kit @@ -31,7 +39,7 @@ public class KitDisplayMenu extends KitMenu } @Override - public Button[] setup(Player player) + public Button[] setUp(Player player) { Button[] buttons = new Button[51]; @@ -39,7 +47,7 @@ public class KitDisplayMenu extends KitMenu setUpIcon(buttons, player); - setUpDetails(buttons); + setUpDetails(buttons, player); setUpNextMenuButtons(buttons, player); @@ -55,7 +63,7 @@ public class KitDisplayMenu extends KitMenu private void setUpNextMenuButtons(Button[] buttons, Player player) { buttons[48] = new KitXPButton(getKit(), player); - buttons[50] = new KitUpgradeMenuButton(getKit(), player); + buttons[50] = new KitUpgradeMenuButton(getKit(), player, getPlugin()); } /** @@ -74,8 +82,19 @@ public class KitDisplayMenu extends KitMenu * * @param buttons The array of buttons we're modifying */ - private void setUpDetails(Button[] buttons) + private void setUpDetails(Button[] buttons, Player player) { + if(getKit().showUpgrades()) + { + List details = getKit().getAbilityDetails().get(getKit().getUpgradeLevel(player.getUniqueId())); + int index = 0; + for(int i : UPGRADE_SLOTS) + { + buttons[i] = new KitAbilityButton(details.get(index++)); + } + return; + } + for (int i : UPGRADE_SLOTS) { buttons[i] = new IconButton(COMING_SOON); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java index 89b0708cf..7d5b5261a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java @@ -3,10 +3,12 @@ package mineplex.core.progression.gui.guis; import com.google.common.collect.Lists; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.IconButton; import mineplex.core.progression.ProgressiveKit; -import mineplex.core.progression.gui.Button; +import mineplex.core.progression.data.KitAbilityDetail; +import mineplex.core.progression.gui.buttons.KitUpgradeButton; import mineplex.core.progression.gui.buttons.misc.BackButton; -import mineplex.core.progression.gui.buttons.misc.IconButton; import mineplex.core.progression.math.Calculations; import org.bukkit.ChatColor; import org.bukkit.DyeColor; @@ -15,6 +17,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import java.util.List; +import java.util.Map; import java.util.UUID; /** @@ -48,7 +51,7 @@ public class KitInformationTrackerMenu extends KitMenu } @Override - public Button[] setup(Player player) + public Button[] setUp(Player player) { Button[] buttons = new Button[52]; @@ -144,6 +147,30 @@ public class KitInformationTrackerMenu extends KitMenu */ private void setUpUpgrade(Button[] buttons, Player player) { + if(getKit().showUpgrades()) + { + int upgradeLevel = getKit().getUpgradeLevel(player.getUniqueId()); + Map> details = getKit().getAbilityDetails(); + List list = details.get(upgradeLevel); + if(list == null) + { + throw new IllegalArgumentException("No upgrades for player upgrade level " + upgradeLevel); + } + int index = 0; + for(int i : UPGRADE_SLOTS) + { + KitAbilityDetail detail = list.get(index++); + ItemBuilder itemStack = new ItemBuilder(detail.getIcon()).setTitle(C.cYellow + detail.getDisplayName()).setLore(getKit().getDescription()); + if(getKit().canPurchaseUpgrade(player.getUniqueId(), upgradeLevel) && !getKit().ownsUpgrade(player.getUniqueId(), upgradeLevel)) + { + itemStack.setGlow(true); + } + KitUpgradeButton button = new KitUpgradeButton(getKit(), itemStack.build(), upgradeLevel, detail.getDisplayName()); + buttons[i] = button; + } + return; + } + for (int i : UPGRADE_SLOTS) { buttons[i] = new IconButton(COMING_SOON); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitMenu.java index 4c546aa7b..a76fa4459 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitMenu.java @@ -1,21 +1,18 @@ package mineplex.core.progression.gui.guis; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Menu; +import mineplex.core.progression.KitProgressionManager; import mineplex.core.progression.ProgressiveKit; -import mineplex.core.progression.gui.Button; -import mineplex.core.progression.gui.Menu; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; /** * An implementation of {@link Menu} corresponding to kits */ -public abstract class KitMenu extends Menu +public abstract class KitMenu extends Menu { /** @@ -32,70 +29,12 @@ public abstract class KitMenu extends Menu public KitMenu(ProgressiveKit kit) { - super(kit.getDisplayName()); + super(kit.getDisplayName(), null); _kit = kit; } - /** - * Set up a menu based on the specific player - * - * @param player The player who we want to tailor the GUI to - * @return The setup arrangement of buttons - */ - public abstract Button[] setup(Player player); - - /** - * Open a GUI tailored to the player - * - * @param player The player who we wish to show the GUI to - */ - @Override - public void open(Player player) - { - this.setButtons(setup(player)); - - if (MENUS.get(player.getUniqueId()) != null) - { - MENUS.remove(player.getUniqueId()); - } - - MENUS.put(player.getUniqueId(), this); - - int size = (this._buttons.length + 8) / 9 * 9; - Inventory inventory = Bukkit.createInventory(player, size, getName()); - - for (int i = 0; i < _buttons.length; i++) - { - if (_buttons[i] == null) - { - continue; - } - - ItemStack item = _buttons[i].getItemStack(); - - inventory.setItem(i, item); - } - player.openInventory(inventory); - } - - /** - * Get the kit specific to this GUI - * - * @return This GUI's kit - */ public ProgressiveKit getKit() { return _kit; } - - /** - * We don't want to use this, as we may require per player GUI's - * @return The arrangement of buttons - */ - @Override - public Button[] setUp() - { - return new Button[45]; - } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index 7ad4f881f..e4f74fed4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -1,13 +1,5 @@ package mineplex.core.report; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - import com.google.gson.Gson; import com.google.gson.JsonObject; import mineplex.core.account.CoreClientManager; @@ -21,10 +13,11 @@ import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.portal.Portal; +import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.report.command.ReportHandlerNotification; -import mineplex.core.report.command.ReportNotificationCallback; import mineplex.core.report.command.ReportNotification; +import mineplex.core.report.command.ReportNotificationCallback; import mineplex.core.report.task.ReportHandlerMessageTask; import mineplex.core.stats.PlayerStats; import mineplex.core.stats.StatsManager; @@ -33,16 +26,22 @@ import mineplex.serverdata.Utility; import mineplex.serverdata.commands.ServerCommandManager; import mineplex.serverdata.data.DataRepository; import mineplex.serverdata.redis.RedisDataRepository; - import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.plugin.java.JavaPlugin; - import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedis.exceptions.JedisConnectionException; +import java.time.LocalDateTime; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + /** * ReportManager hooks into a synchronized network-wide report system * with methods for updating/fetching/closing reports in real time. @@ -356,7 +355,7 @@ public class ReportManager public boolean hasReportNotifications(Player player) { boolean isStaff = CommandCenter.Instance.GetClientManager().Get(player).GetRank().has(Rank.MODERATOR); - boolean hasReportNotifications = _preferencesManager.Get(player).ShowUserReports; + boolean hasReportNotifications = _preferencesManager.get(player).isActive(Preference.SHOW_USER_REPORTS); return isStaff && hasReportNotifications; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java index a2cc71f46..7c6f86666 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java @@ -1,9 +1,28 @@ package mineplex.core.treasure; -import java.util.List; - +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; -import mineplex.core.reward.RewardPool; +import mineplex.core.gadget.event.GadgetBlockEvent; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.HologramInteraction; +import mineplex.core.hologram.HologramManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.reward.Reward; +import mineplex.core.status.ServerStatusManager; +import mineplex.core.treasure.event.TreasureFinishEvent; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.treasure.gui.TreasureShop; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -21,28 +40,7 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerVelocityEvent; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.donation.DonationManager; -import mineplex.core.gadget.event.GadgetBlockEvent; -import mineplex.core.hologram.Hologram; -import mineplex.core.hologram.HologramInteraction; -import mineplex.core.hologram.HologramManager; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.reward.Reward; -import mineplex.core.status.ServerStatusManager; -import mineplex.core.treasure.event.TreasureFinishEvent; -import mineplex.core.treasure.event.TreasureStartEvent; -import mineplex.core.treasure.gui.TreasureShop; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import java.util.List; public class TreasureLocation implements Listener { @@ -69,8 +67,7 @@ public class TreasureLocation implements Listener _hologramManager = hologramManager; _statusManager = statusManager; _currentTreasure = null; - _hologram = new Hologram(_hologramManager, chestBlock.getLocation().add(0.5, 2.5, 0.5), C.cGreen + C.Bold - + "Open Treasure"); + _hologram = new Hologram(_hologramManager, chestBlock.getLocation().add(0.5, 1.5, 0.5), C.cGreen + C.Bold + "Open Treasure"); _hologram.setInteraction(new HologramInteraction() { @@ -401,4 +398,18 @@ public class TreasureLocation implements Listener { _shop.attemptShopOpen(player); } + + @Override + public String toString() + { + StringBuilder builder = new StringBuilder(); + builder.append("TesureLoc: ").append(_chestBlock.getX()).append(" : ").append(_chestBlock.getY()).append(" : ").append(_chestBlock.getZ()); + builder.append("BlockLocs: ["); + for(Block block : _chestSpawns) + { + builder.append("BlockLoc: ").append(block.getX()).append(" : ").append(block.getY()).append(" : ").append(block.getZ()).append(",\n"); + } + builder.append("]"); + return builder.toString(); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java index 8ea52f005..27e3e434e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java @@ -1,32 +1,32 @@ package mineplex.core.treasure; -import java.util.ArrayList; -import java.util.List; - -import mineplex.core.gadget.GadgetManager; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.HandlerList; -import org.bukkit.plugin.java.JavaPlugin; - +import com.google.common.collect.Lists; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.GadgetManager; import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.pet.PetManager; import mineplex.core.reward.Reward; import mineplex.core.reward.RewardManager; import mineplex.core.reward.RewardPool; -import mineplex.core.reward.RewardRarity; import mineplex.core.reward.RewardType; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; +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.HandlerList; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.ArrayList; +import java.util.List; /** * Created by Shaun on 8/27/2014. @@ -54,69 +54,78 @@ public class TreasureManager extends MiniPlugin World world = Bukkit.getWorlds().get(0); - _treasureLocations = new ArrayList(); + System.out.println("Treausre Manager Setting the fuck up biotches"); + + _treasureLocations = new ArrayList<>(); { - Block chestBlock = world.getBlockAt(-19, 72, -19); - Block chestLoc1 = world.getBlockAt(-16, 72, -20); - Block chestLoc2 = world.getBlockAt(-18, 72, -22); - Block chestLoc3 = world.getBlockAt(-20, 72, -22); - Block chestLoc4 = world.getBlockAt(-22, 72, -20); - Block chestLoc5 = world.getBlockAt(-22, 72, -18); - Block chestLoc6 = world.getBlockAt(-20, 72, -16); - Block chestLoc7 = world.getBlockAt(-18, 72, -16); - Block chestLoc8 = world.getBlockAt(-16, 72, -18); - Location resetLocation = new Location(world, -23.5, 72, -23.5); - _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager, gadgetManager, statusManager)); + Block chestBlock = world.getBlockAt(-31, 73, -11); + Block[] blocks = setup(chestBlock); + Location resetLocation = new Location(world, -26.5, 72, -11.5); + _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager)); } { - Block chestBlock = world.getBlockAt(19, 72, 19); - Block chestLoc1 = world.getBlockAt(16, 72, 20); - Block chestLoc2 = world.getBlockAt(18, 72, 22); - Block chestLoc3 = world.getBlockAt(20, 72, 22); - Block chestLoc4 = world.getBlockAt(22, 72, 20); - Block chestLoc5 = world.getBlockAt(22, 72, 18); - Block chestLoc6 = world.getBlockAt(20, 72, 16); - Block chestLoc7 = world.getBlockAt(18, 72, 16); - Block chestLoc8 = world.getBlockAt(16, 72, 18); - Location resetLocation = new Location(world, 23.5, 72, 23.5); - _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager, gadgetManager, statusManager)); + Block chestBlock = world.getBlockAt(-22, 73, -34); + Block[] blocks = setup(chestBlock); + Location resetLocation = new Location(world, -22.5, 72, -29.5); + _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager)); } { - Block chestBlock = world.getBlockAt(19, 72, -19); - Block chestLoc1 = world.getBlockAt(16, 72, -20); - Block chestLoc2 = world.getBlockAt(18, 72, -22); - Block chestLoc3 = world.getBlockAt(20, 72, -22); - Block chestLoc4 = world.getBlockAt(22, 72, -20); - Block chestLoc5 = world.getBlockAt(22, 72, -18); - Block chestLoc6 = world.getBlockAt(20, 72, -16); - Block chestLoc7 = world.getBlockAt(18, 72, -16); - Block chestLoc8 = world.getBlockAt(16, 72, -18); - Location resetLocation = new Location(world, 23.5, 72, -23.5); - _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager, gadgetManager, statusManager)); + Block chestBlock = world.getBlockAt(22, 75, -34); + Block[] blocks = setup(chestBlock); + Location resetLocation = new Location(world, 19.5, 74, -30.5); + _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager)); } { - Block chestBlock = world.getBlockAt(-19, 72, 19); - Block chestLoc1 = world.getBlockAt(-16, 72, 20); - Block chestLoc2 = world.getBlockAt(-18, 72, 22); - Block chestLoc3 = world.getBlockAt(-20, 72, 22); - Block chestLoc4 = world.getBlockAt(-22, 72, 20); - Block chestLoc5 = world.getBlockAt(-22, 72, 18); - Block chestLoc6 = world.getBlockAt(-20, 72, 16); - Block chestLoc7 = world.getBlockAt(-18, 72, 16); - Block chestLoc8 = world.getBlockAt(-16, 72, 18); - Location resetLocation = new Location(world, -23.5, 72, 23.5); - _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager, gadgetManager, statusManager)); + Block chestBlock = world.getBlockAt(31, 74, -11); + Block[] blocks = setup(chestBlock); + Location resetLocation = new Location(world, 27.5, 73, -15.5); + _treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager)); } for (TreasureLocation treasureLocation : _treasureLocations) { + System.out.println(treasureLocation.toString()); _plugin.getServer().getPluginManager().registerEvents(treasureLocation, _plugin); } } + private Block[] setup(Block chestBlock) + { + System.out.println("Setting up blocks for " + chestBlock.getX() + ", " + chestBlock.getY() + ", " + chestBlock.getZ()); + List locations = Lists.newArrayList(); + boolean has = false; + for(int x = chestBlock.getX() -3; x <= chestBlock.getX(); x++) + { + for(int z = chestBlock.getZ() - 3; z <= chestBlock.getZ(); z++) + { + Location location = new Location(chestBlock.getWorld(), x, chestBlock.getY(), z); + if(location.getBlock().getRelative(BlockFace.DOWN) == null || location.getBlock().getRelative(BlockFace.DOWN).getType() != Material.SMOOTH_BRICK) + { + has = false; + continue; + } + if(has) + { + has = false; + continue; + } else + { + has = true; + } + locations.add(location); + } + } + Block[] blocks = new Block[locations.size()]; + for(int i = 0; i < blocks.length; i++) + { + blocks[i] = locations.get(i).getBlock(); + } + return blocks; + } + @Override public void disable() { diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index 3a584a0bb..d176fda33 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -1,10 +1,5 @@ package mineplex.clanshub; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.UUID; - import mineplex.clanshub.commands.ForcefieldRadius; import mineplex.clanshub.commands.GadgetToggle; import mineplex.clanshub.commands.GameModeCommand; @@ -31,7 +26,6 @@ import mineplex.core.common.util.UtilTextTop; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.customdata.CustomData; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguiseBase; @@ -60,6 +54,7 @@ import mineplex.core.pet.PetManager; import mineplex.core.playerCount.PlayerCountManager; import mineplex.core.poll.PollManager; import mineplex.core.portal.Portal; +import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; @@ -82,7 +77,6 @@ import net.md_5.bungee.api.chat.HoverEvent.Action; import net.md_5.bungee.api.chat.TextComponent; import net.minecraft.server.v1_8_R3.EntityInsentient; import net.minecraft.server.v1_8_R3.EntityPlayer; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -117,6 +111,11 @@ import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Scoreboard; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.UUID; + /** * Main manager for clans hub */ @@ -288,7 +287,7 @@ public class HubManager extends MiniPlugin if (ent instanceof Player) { - return !_preferences.Get((Player)ent).HubGames; + return !_preferences.get((Player)ent).isActive(Preference.HUB_GAMES); } return true; @@ -497,7 +496,7 @@ public class HubManager extends MiniPlugin event.setMessage(event.getMessage().substring(1, event.getMessage().length())); event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + playerName + " " + C.cPurple + "%2$s"); - for (UUID name : party.getMembers()) + for (UUID name : party.getMembersByUUID()) { Player other = Bukkit.getPlayer(name); @@ -858,7 +857,7 @@ public class HubManager extends MiniPlugin @EventHandler public void ignoreVelocity(PlayerVelocityEvent event) { - if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.Get(event.getPlayer()).IgnoreVelocity) + if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY)) { event.setCancelled(true); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 90e938e8e..3f9bcf022 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -1,22 +1,15 @@ package mineplex.hub; -import mineplex.core.Managers; -import mineplex.core.antihack.AntiHackGuardian; -import mineplex.core.brawl.fountain.FountainManager; -import mineplex.core.thank.ThankManager; -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.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; +import mineplex.core.antihack.AntiHackGuardian; import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.boosters.BoosterManager; +import mineplex.core.brawl.fountain.FountainManager; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; import mineplex.core.common.events.ServerShutdownEvent; @@ -57,6 +50,7 @@ import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; +import mineplex.core.thank.ThankManager; import mineplex.core.titangiveaway.TitanGiveawayManager; import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; @@ -76,6 +70,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; @@ -83,6 +81,8 @@ public class Hub extends JavaPlugin implements IRelation { private String WEB_CONFIG = "webServer"; + private NpcManager _npcManager; + @Override public void onEnable() { @@ -118,13 +118,14 @@ public class Hub extends JavaPlugin implements IRelation PacketHandler packetHandler = require(PacketHandler.class); DisguiseManager disguiseManager = require(DisguiseManager.class); IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler); - PreferencesManager preferenceManager = new PreferencesManager(this, incognito, clientManager, donationManager); + PreferencesManager preferenceManager = new PreferencesManager(this, incognito, clientManager); incognito.setPreferencesManager(preferenceManager); preferenceManager.GiveItem = true; Creature creature = new Creature(this); NpcManager npcManager = new NpcManager(this, creature); + _npcManager = npcManager; InventoryManager inventoryManager = new InventoryManager(this, clientManager); PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore, webServerAddress); PollManager pollManager = new PollManager(this, clientManager, donationManager); @@ -236,4 +237,9 @@ public class Hub extends JavaPlugin implements IRelation { return true; } + + public NpcManager getNpcManager() + { + return _npcManager; + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 990dea9ae..9503b0347 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -14,7 +14,15 @@ import mineplex.core.boosters.BoosterManager; import mineplex.core.botspam.BotSpamManager; import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; @@ -28,7 +36,9 @@ import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.hologram.HologramManager; import mineplex.core.incognito.IncognitoManager; import mineplex.core.incognito.events.IncognitoHidePlayerEvent; +import mineplex.core.interactions.NewInteractionsManager; import mineplex.core.inventory.InventoryManager; +import mineplex.core.menu.MenuManager; import mineplex.core.message.PrivateMessageEvent; import mineplex.core.mount.MountManager; import mineplex.core.noteblock.INoteVerifier; @@ -46,6 +56,7 @@ import mineplex.core.pet.PetManager; import mineplex.core.playerCount.PlayerCountManager; import mineplex.core.poll.PollManager; import mineplex.core.portal.Portal; +import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; @@ -64,10 +75,17 @@ import mineplex.hub.commands.ForcefieldRadius; import mineplex.hub.commands.GadgetToggle; import mineplex.hub.commands.GameModeCommand; import mineplex.hub.commands.NewsCommand; -import mineplex.hub.modules.*; +import mineplex.hub.modules.ForcefieldManager; +import mineplex.hub.modules.HubVisibilityManager; +import mineplex.hub.modules.JumpManager; +import mineplex.hub.modules.KothManager; +import mineplex.hub.modules.NewsManager; +import mineplex.hub.modules.ParkourManager; +import mineplex.hub.modules.SoccerManager; +import mineplex.hub.modules.ValentinesManager; +import mineplex.hub.modules.WorldManager; import mineplex.hub.modules.nonpremium.NonPremiumManager; import mineplex.hub.profile.gui.GUIProfile; -import mineplex.hub.tutorial.TutorialManager; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; @@ -79,7 +97,11 @@ import net.md_5.bungee.api.chat.HoverEvent.Action; import net.md_5.bungee.api.chat.TextComponent; import net.minecraft.server.v1_8_R3.EntityInsentient; import net.minecraft.server.v1_8_R3.EntityPlayer; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.entity.Egg; import org.bukkit.entity.Entity; @@ -93,7 +115,14 @@ import org.bukkit.event.entity.EntityTargetEvent.TargetReason; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.*; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -102,7 +131,11 @@ import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Random; +import java.util.UUID; public class HubManager extends MiniClientPlugin { @@ -122,8 +155,6 @@ public class HubManager extends MiniClientPlugin private GadgetManager _gadgetManager; private MountManager _mountManager; private HubVisibilityManager _visibilityManager; - private TutorialManager _tutorialManager; - private TextManager _textCreator; private ParkourManager _parkour; private PreferencesManager _preferences; private InventoryManager _inventoryManager; @@ -177,18 +208,16 @@ public class HubManager extends MiniClientPlugin _portal = portal; - _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5); + _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 79, -23.5); // Disable item merging ((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0; - _textCreator = new TextManager(this); _parkour = new ParkourManager(this, donationManager, taskManager); new WorldManager(this); _jumpManager = new JumpManager(this); //new TournamentInviter(this); - _news = new NewsManager(this); _mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager); @@ -203,18 +232,18 @@ public class HubManager extends MiniClientPlugin _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); - new SoccerManager(this, _gadgetManager); new KothManager(this, _gadgetManager); new AntiSpamManager(); + new MenuManager(_plugin); + new NewInteractionsManager(); //new TrickOrTreatManager(_plugin, this, taskManager, donationManager, clientManager); _petManager = petManager; _partyManager = partyManager; _preferences = preferences; - _tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator); _visibilityManager = new HubVisibilityManager(this); _forcefieldManager = new ForcefieldManager(this); @@ -299,8 +328,8 @@ public class HubManager extends MiniClientPlugin .register(HubScoreboardLine.GEM_TITLE) .register(HubScoreboardLine.GEM_COUNT) .register(HubScoreboardLine.GEM_EMPTY_SPACER) - .register(HubScoreboardLine.PLAYER_TITLE) - .register(HubScoreboardLine.PLAYER_COUNT) + .register(HubScoreboardLine.SHARDS_TITLE) + .register(HubScoreboardLine.SHARDS_COUNT) .register(HubScoreboardLine.PLAYER_EMPTY_SPACER) .register(HubScoreboardLine.RANK_TITLE) .register(HubScoreboardLine.RANK_NAME) @@ -313,7 +342,7 @@ public class HubManager extends MiniClientPlugin scoreboard.get(HubScoreboardLine.SERVER_TITLE).write(C.cAqua + C.Bold + "Server"); scoreboard.get(HubScoreboardLine.SERVER_NAME).write(_serverName); scoreboard.get(HubScoreboardLine.GEM_TITLE).write(C.cGreen + C.Bold + "Gems"); - scoreboard.get(HubScoreboardLine.PLAYER_TITLE).write(C.cYellow + C.Bold + "Players"); + scoreboard.get(HubScoreboardLine.SHARDS_TITLE).write(C.cYellow + C.Bold + "Treasure Shards"); scoreboard.get(HubScoreboardLine.RANK_TITLE).write(C.cGold + C.Bold + "Rank"); scoreboard.get(HubScoreboardLine.WEBSITE_TITLE).write(C.cRed + C.Bold + "Website"); scoreboard.get(HubScoreboardLine.WEBSITE_VALUE).write("www.mineplex.com"); @@ -325,7 +354,7 @@ public class HubManager extends MiniClientPlugin { scoreboard.setSidebarName(C.cWhite + C.Bold + Get(scoreboard.getOwner()).GetScoreboardText()); scoreboard.get(HubScoreboardLine.GEM_COUNT).write(GetDonation().Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM)); - scoreboard.get(HubScoreboardLine.PLAYER_COUNT).write(_playerCountManager.getPlayerCount()); + scoreboard.get(HubScoreboardLine.SHARDS_COUNT).write(GetDonation().Get(scoreboard.getOwner()).getBalance(GlobalCurrency.TREASURE_SHARD)); String rankName = getRankName(GetClients().Get(scoreboard.getOwner()).GetRank(), GetDonation().Get(scoreboard.getOwner())); @@ -411,7 +440,7 @@ public class HubManager extends MiniClientPlugin { for (Player player : UtilServer.getPlayers()) { - if (_preferences.Get(player).HubMusic) + if (_preferences.get(player).isActive(Preference.HUB_MUSIC)) { UtilTextBottom.display(C.cWhite + "Now Playing " + C.cYellow + song.getName(), player); } @@ -422,7 +451,7 @@ public class HubManager extends MiniClientPlugin @Override public boolean shouldPlay(Player player) { - return _preferences.Get(player).HubMusic; + return _preferences.get(player).isActive(Preference.HUB_MUSIC); } }, 0.5F, false); } @@ -452,7 +481,7 @@ public class HubManager extends MiniClientPlugin if (ent instanceof Player) { - return !_preferences.Get((Player) ent).HubGames; + return !_preferences.get((Player) ent).isActive(Preference.HUB_GAMES); } return true; @@ -676,7 +705,7 @@ public class HubManager extends MiniClientPlugin event.setMessage(event.getMessage().substring(1, event.getMessage().length())); event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + playerName + " " + C.cPurple + "%2$s"); - for (UUID uuid: party.getMembers()) + for (UUID uuid: party.getMembersByUUID()) { Player other = Bukkit.getPlayer(uuid); @@ -690,7 +719,6 @@ public class HubManager extends MiniClientPlugin event.setCancelled(true); } - return; } else { @@ -707,14 +735,10 @@ public class HubManager extends MiniClientPlugin for (Player other : UtilServer.getPlayers()) { - if (_tutorialManager.InTutorial(other)) - { - event.getRecipients().remove(other); - continue; - } - if (!event.isCancelled()) + { other.spigot().sendMessage(component); + } } event.setCancelled(true); } @@ -844,11 +868,6 @@ public class HubManager extends MiniClientPlugin return _bonusManager; } - public TutorialManager GetTutorial() - { - return _tutorialManager; - } - public StatsManager GetStats() { return _statsManager; @@ -908,7 +927,7 @@ public class HubManager extends MiniClientPlugin if (BumpDisabled(ent)) return false; - if (!getPreferences().Get((Player) ent).ShowPlayers) + if (!getPreferences().get((Player) ent).isActive(Preference.SHOW_PLAYERS)) return false; return true; @@ -934,7 +953,7 @@ public class HubManager extends MiniClientPlugin @EventHandler public void ignoreVelocity(PlayerVelocityEvent event) { - if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.Get(event.getPlayer()).IgnoreVelocity) + if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY)) { event.setCancelled(true); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubScoreboardLine.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubScoreboardLine.java index 4071a1db0..539d13f0e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubScoreboardLine.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubScoreboardLine.java @@ -10,8 +10,8 @@ public enum HubScoreboardLine implements ScoreboardLine GEM_TITLE, GEM_COUNT, GEM_EMPTY_SPACER, - PLAYER_TITLE, - PLAYER_COUNT, + SHARDS_TITLE, + SHARDS_COUNT, PLAYER_EMPTY_SPACER, RANK_TITLE, RANK_NAME, diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java index 107fd8aa6..8002a87b4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java @@ -1,13 +1,5 @@ package mineplex.hub.modules; -import java.util.HashMap; - -import org.bukkit.Sound; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerQuitEvent; - import mineplex.core.MiniPlugin; import mineplex.core.common.Rank; import mineplex.core.common.util.F; @@ -16,10 +8,18 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.preferences.Preference; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashMap; public class ForcefieldManager extends MiniPlugin { @@ -42,7 +42,7 @@ public class ForcefieldManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { - if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE_SMALL)) + if (Manager.getPreferences().get(player).isActive(Preference.FORCE_FIELD) && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE_SMALL)) { for (Player other : UtilServer.getPlayers()) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HalloweenSpookinessManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HalloweenSpookinessManager.java index f0754c10f..3f033bcd6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HalloweenSpookinessManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HalloweenSpookinessManager.java @@ -1,24 +1,19 @@ package mineplex.hub.modules; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; - import mineplex.core.MiniPlugin; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseArmorStand; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.preferences.Preference; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; import mineplex.hub.HubType; - import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; @@ -27,6 +22,10 @@ import org.bukkit.entity.Skeleton; import org.bukkit.event.EventHandler; import org.bukkit.util.Vector; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + public class HalloweenSpookinessManager extends MiniPlugin { /** @@ -155,7 +154,7 @@ public class HalloweenSpookinessManager extends MiniPlugin return; //Follow for 2 seconds - if (!_target.isOnline() || _manager.getPreferences().Get(_target).Invisibility || UtilTime.elapsed(_targetTime, 2000)) + if (!_target.isOnline() || _manager.getPreferences().get(_target).isActive(Preference.INVISIBILITY) || UtilTime.elapsed(_targetTime, 2000)) { resetFollowing(); return; @@ -215,7 +214,7 @@ public class HalloweenSpookinessManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { - if (_manager.getPreferences().Get(player).Invisibility) + if (_manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) ) continue; if (UtilMath.offset(player.getLocation(), average) <= 7) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java index 75abcbfbd..b2c29d783 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java @@ -1,28 +1,28 @@ package mineplex.hub.modules; -import java.util.HashMap; -import java.util.HashSet; - +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.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.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilServer; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.visibility.VisibilityManager; -import mineplex.hub.HubManager; +import java.util.HashMap; +import java.util.HashSet; public class HubVisibilityManager extends MiniPlugin { @@ -64,9 +64,8 @@ public class HubVisibilityManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { Rank rank = Manager.GetClients().Get(player).GetRank(); - boolean hideMe = Manager.GetTutorial().InTutorial(player) || - UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 || - (Manager.getPreferences().Get(player).Invisibility && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) || + 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()) @@ -78,9 +77,7 @@ public class HubVisibilityManager extends MiniPlugin if(Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR)) localHideMe = false; - if (localHideMe || - !Manager.getPreferences().Get(other).ShowPlayers || - Manager.GetTutorial().InTutorial(other)) + if (localHideMe || !Manager.getPreferences().get(other).isActive(Preference.SHOW_PLAYERS)) { VisibilityManager.Instance.setVisibility(player, false, other); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java index afa61a5a1..106e9a9c8 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; @@ -22,10 +11,21 @@ import mineplex.core.disguise.disguises.DisguiseBat; import mineplex.core.disguise.disguises.DisguiseChicken; import mineplex.core.disguise.disguises.DisguiseEnderman; import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.preferences.Preference; 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 { @@ -48,7 +48,7 @@ public class JumpManager extends MiniPlugin return; Rank rank = Manager.GetClients().Get(player).GetRank(); - if (Manager.getPreferences().Get(player).Invisibility && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) + if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) { return; } @@ -90,7 +90,7 @@ public class JumpManager extends MiniPlugin continue; Rank rank = Manager.GetClients().Get(player).GetRank(); - if (Manager.getPreferences().Get(player).Invisibility && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) + if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) { player.setAllowFlight(true); continue; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java index 0787e225b..5131a1165 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/KothManager.java @@ -1,19 +1,6 @@ package mineplex.hub.modules; -import java.util.ArrayList; -import java.util.HashSet; - -import org.bukkit.Color; -import org.bukkit.Location; -import org.bukkit.entity.Entity; -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.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import mineplex.core.MiniPlugin; +import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -32,6 +19,18 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; import mineplex.hub.modules.koth.CapturePoint; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +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.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.ArrayList; +import java.util.HashSet; public class KothManager extends MiniPlugin { @@ -59,13 +58,13 @@ public class KothManager extends MiniPlugin Manager = manager; - _cornerPlayerA = new Location(Manager.GetSpawn().getWorld(), -52.5,0,-23.5); - _cornerPlayerB = new Location(Manager.GetSpawn().getWorld(), -133.5,200,80.5); + _cornerPlayerA = new Location(Manager.GetSpawn().getWorld(), -52.5, 0, -21.5); + _cornerPlayerB = new Location(Manager.GetSpawn().getWorld(), -133.5, 197, 82.5); - _cornerHillA = new Location(Manager.GetSpawn().getWorld(), -88.5,60,47.5); - _cornerHillB = new Location(Manager.GetSpawn().getWorld(), -102.5,80,61.5); - - _cp = new CapturePoint(this, "Desert Pyramid", new Location(Manager.GetSpawn().getWorld(), -95.5,72,54.5)); + _cornerHillA = new Location(Manager.GetSpawn().getWorld(), -88.5, 57, 49.5); + _cornerHillB = new Location(Manager.GetSpawn().getWorld(), -102.5, 77, 63.5); + + _cp = new CapturePoint(this, "Desert Pyramid", new Location(Manager.GetSpawn().getWorld(), -95.5, 69, 56.5)); //Store Gadgets for (Gadget gadget : gadgets.getGadgets(GadgetType.COSTUME)) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java index b357aee34..a9f9257a0 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java @@ -1,9 +1,29 @@ package mineplex.hub.modules; -import java.util.HashSet; -import java.util.Iterator; -import java.util.WeakHashMap; - +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.event.GadgetBlockEvent; +import mineplex.core.gadget.event.GadgetEnableEvent; +import mineplex.core.gadget.types.MusicGadget; +import mineplex.core.mount.event.MountActivateEvent; +import mineplex.core.recharge.Recharge; +import mineplex.core.task.TaskManager; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.HubManager; +import mineplex.hub.modules.parkour.ParkourData; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -18,38 +38,47 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.util.Vector; -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilEvent; -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.UtilEvent.ActionType; -import mineplex.core.donation.DonationManager; -import mineplex.core.gadget.event.GadgetEnableEvent; -import mineplex.core.gadget.event.GadgetBlockEvent; -import mineplex.core.gadget.types.MusicGadget; -import mineplex.core.mount.event.MountActivateEvent; -import mineplex.core.recharge.Recharge; -import mineplex.core.task.TaskManager; -import mineplex.core.treasure.event.TreasureStartEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.HubManager; -import mineplex.hub.modules.parkour.ParkourData; +import java.util.HashSet; +import java.util.Iterator; +import java.util.WeakHashMap; public class ParkourManager extends MiniPlugin { + private final String[] RUINS_DESCRIPTION = { + "This is an extremely difficult parkour.", + "You will need to find the correct way through", + "the ruins, overcoming many challenging jumps.", + }; + + private final String[] GWEN_DESCRIPTION = { + "Can you escape from our Guardians?", + "I hear they have infested the water", + "sending anyone who falls in back to the start!", + }; + + private final String[] LAVA_DESCRIPTION = { + "This parkour is HOT! It's so hot that you", + "must keep sprinting for the entire course,", + "or you will die in flames!" + }; + + private final String[] DESERT_DESCRIPTION = { + "Ever heard of Prince of Persia", + "well, this isn't as exciting.", + "yet...." + }; + + private final int RUINS_GEMS = 10000; + private final int GWEN_GEMS = 4000; + private final int LAVA_GEMS = 5000; + private final int DESERT_GEMS = 3000; + public HubManager Manager; private HashSet _active = new HashSet(); @@ -58,13 +87,14 @@ public class ParkourManager extends MiniPlugin //private Location _snakeParkourReturn; private Location _lavaParkourReturn; + private Location _waterReturn; private WeakHashMap _lavaLocation = new WeakHashMap(); private WeakHashMap _lavaTimer = new WeakHashMap(); //Modules protected DonationManager _donationManager; protected TaskManager _taskManager; - + public ParkourManager(HubManager manager, DonationManager donation, TaskManager task) { super("Parkour", manager.getPlugin()); @@ -74,125 +104,132 @@ public class ParkourManager extends MiniPlugin _taskManager = task; _donationManager = donation; - _parkour.add(new ParkourData("Ruins Parkour", new String[] - { - "This is an extremely difficult parkour.", - "You will need to find the correct way through", - "the ruins, overcoming many challenging jumps.", - }, - 6000, new Location(Manager.GetSpawn().getWorld(), 110,66,-44), - new Location(Manager.GetSpawn().getWorld(), 103,100,-60), new Location(Manager.GetSpawn().getWorld(), 150,50,26))); + _parkour.add(new ParkourData("Ruins Parkour", RUINS_DESCRIPTION, RUINS_GEMS, + new Location(Manager.GetSpawn().getWorld(), 113.5, 66, -46.5), + new Location(Manager.GetSpawn().getWorld(), 124, 86, 18), + new Location(Manager.GetSpawn().getWorld(), 105, 57, -48))); + _parkour.add(new ParkourData("G.W.E.N Parkour", GWEN_DESCRIPTION, GWEN_GEMS, + new Location(Manager.GetSpawn().getWorld(), 55.5, 68, -94.5), + new Location(Manager.GetSpawn().getWorld(), 106, 96, -142), + new Location(Manager.GetSpawn().getWorld(), 52, 61, -81))); - _parkour.add(new ParkourData("Lava Parkour", new String[] - { - "This parkour is HOT! It's so hot that you", - "must keep sprinting for the entire course,", - "or you will die in flames!" - }, 4000, new Location(Manager.GetSpawn().getWorld(), -93,67,38), - new Location(Manager.GetSpawn().getWorld(), -86,100,42), new Location(Manager.GetSpawn().getWorld(), -120,50,-17))); - -// _parkour.add(new ParkourSnake("Snake Parkour", new String[] -// { -// "This parkour requires incredible timing", -// "and great agility! Some say it was created", -// "by the devil as a cruel joke!" -// }, 8000, new Location(Manager.GetSpawn().getWorld(), 22,70,-54), -// new Location(Manager.GetSpawn().getWorld(), 35,-200,-90), new Location(Manager.GetSpawn().getWorld(), -30,250,-46))); + _parkour.add(new ParkourData("Lava Parkour", LAVA_DESCRIPTION, LAVA_GEMS, + new Location(Manager.GetSpawn().getWorld(), -95.5, 67, 3.5), + new Location(Manager.GetSpawn().getWorld(), -144, 97, -21), + new Location(Manager.GetSpawn().getWorld(), -88, 62, 41))); - _lavaParkourReturn = new Location(Manager.GetSpawn().getWorld(), -89.5,68,36.5); + _parkour.add(new ParkourData("Desert Village Parkour", DESERT_DESCRIPTION, DESERT_GEMS, + new Location(Manager.GetSpawn().getWorld(), -63.5, 69, 32.5), + new Location(Manager.GetSpawn().getWorld(), -57, 82, -35), + new Location(Manager.GetSpawn().getWorld(), -122, 45, 57))); + + _lavaParkourReturn = new Location(Manager.GetSpawn().getWorld(), -89.5, 68, 36.5); _lavaParkourReturn.setYaw(90); - - //_snakeParkourReturn = new Location(Manager.GetSpawn().getWorld(), 16.5,72,-52.5); - //_snakeParkourReturn.setYaw(180); + _waterReturn = new Location(Manager.GetSpawn().getWorld(), 56.5, 68, -88.5); + _waterReturn.setYaw(-141); } public boolean isParkourMode(Player player) { return _active.contains(player); } - + public void setParkourMode(Player player, boolean enabled) { if (enabled) { _active.add(player); UtilPlayer.message(player, F.main("Parkour", "You have entered " + F.elem("Parkour Mode") + ".")); - + Manager.GetGadget().disableAll(player); - - player.setVelocity(new Vector(0,-1,0)); - } - else + + player.setVelocity(new Vector(0, -1, 0)); + } else { _active.remove(player); UtilPlayer.message(player, F.main("Parkour", "You have exited " + F.elem("Parkour Mode") + ".")); } } - + @EventHandler public void playerVelocity(PlayerVelocityEvent event) { if (isParkourMode(event.getPlayer())) + { event.setCancelled(true); + } } - + @EventHandler public void disableGadgets(GadgetEnableEvent event) { if (isParkourMode(event.getPlayer())) + { event.setCancelled(true); + } } - + @EventHandler public void disableMounts(MountActivateEvent event) { if (isParkourMode(event.getPlayer())) + { event.setCancelled(true); + } } - + @EventHandler public void playerEnterParkour(UpdateEvent event) { if (event.getType() != UpdateType.FAST) + { return; - + } + for (Player player : UtilServer.getPlayers()) { if (isParkourMode(player)) + { continue; - + } + for (ParkourData data : _parkour) if (UtilMath.offset(player.getLocation(), data.NPC) < 6) - if (Recharge.Instance.use(player, data.Name+" Info", 300000, false, false)) + { + if (Recharge.Instance.use(player, data.Name + " Info", 300000, false, false)) + { data.Inform(player); + } + } } } - + @EventHandler public void parkourUpdate(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; - + } + Iterator playerIterator = _active.iterator(); - + while (playerIterator.hasNext()) { Player player = playerIterator.next(); - + player.leaveVehicle(); player.eject(); - + if (!InsideParkour(player.getLocation())) { playerIterator.remove(); UtilPlayer.message(player, F.main("Parkour", "You have exited " + F.elem("Parkour Mode") + ".")); - } - else + } else { - - for (Iterator iterator = player.getActivePotionEffects().iterator(); iterator.hasNext();) + + for (Iterator iterator = player.getActivePotionEffects().iterator(); iterator.hasNext(); ) { player.removePotionEffect(iterator.next().getType()); } @@ -215,19 +252,25 @@ public class ParkourManager extends MiniPlugin UtilPlayer.message(event.getPlayer(), F.main("Parkour", "You cannot break blocks in Parkour Mode!")); } } - + @EventHandler(priority = EventPriority.LOWEST) public void disallowBlockPlace(PlayerInteractEvent event) { if (event.getPlayer().getItemInHand() == null) + { return; - + } + if (!event.getPlayer().getItemInHand().getType().isBlock()) + { return; - + } + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + { return; - + } + if (isParkourMode(event.getPlayer())) { event.getPlayer().teleport(Manager.GetSpawn()); @@ -239,7 +282,9 @@ public class ParkourManager extends MiniPlugin public void lavaReturn(EntityDamageEvent event) { if (event.getCause() != DamageCause.LAVA) + { return; + } if (!(event.getEntity() instanceof Player)) { @@ -247,53 +292,62 @@ public class ParkourManager extends MiniPlugin return; } - Player player = (Player)event.getEntity(); + Player player = (Player) event.getEntity(); if (!isParkourMode(player)) + { return; + } event.getEntity().eject(); event.getEntity().leaveVehicle(); event.getEntity().teleport(_lavaParkourReturn); } - -// @EventHandler(priority = EventPriority.HIGHEST) -// public void snakeReturn(EntityDamageEvent event) -// { -// if (event.getCause() != DamageCause.VOID) -// return; -// -// if (!(event.getEntity() instanceof Player)) -// return; -// -// Player player = (Player)event.getEntity(); -// -// if (!isParkourMode(player)) -// return; -// -// event.getEntity().eject(); -// event.getEntity().leaveVehicle(); -// event.getEntity().teleport(_snakeParkourReturn); -// } + + @EventHandler + public void waterReturn(PlayerMoveEvent event) + { + Player player = event.getPlayer(); + + if (!isParkourMode(player)) + { + return; + } + + if (event.getTo().getBlock().getType() == Material.WATER || event.getTo().getBlock().getType() == Material.STATIONARY_WATER) + { + player.eject(); + player.leaveVehicle(); + player.teleport(_waterReturn); + } + } @EventHandler public void lavaBlockReturn(UpdateEvent event) { if (event.getType() != UpdateType.TICK) + { return; + } for (Player player : UtilServer.getPlayers()) { if (!UtilEnt.isGrounded(player)) + { continue; - + } + if (!isParkourMode(player)) + { continue; + } int id = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getTypeId(); int data = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getData(); - if (id != 0 && id != 112 && id != 114 && !(id == 43 && data == 6) && !(id == 44 && data == 6)) + if (id != 0 && id != 112 && id != 114 && !(id == 43 && data == 6) && !(id == 44 && data == 6)) + { continue; + } if (!_lavaLocation.containsKey(player) || UtilMath.offset(player.getLocation(), _lavaLocation.get(player)) > 1.5) { @@ -315,7 +369,9 @@ public class ParkourManager extends MiniPlugin } if (!inCourse) + { continue; + } _lavaLocation.remove(player); _lavaTimer.remove(player); @@ -334,16 +390,22 @@ public class ParkourManager extends MiniPlugin public void finishParkour(PlayerInteractEntityEvent event) { if (event.getRightClicked() == null) + { return; + } if (!(event.getRightClicked() instanceof LivingEntity)) + { return; + } - LivingEntity ent = (LivingEntity)event.getRightClicked(); + LivingEntity ent = (LivingEntity) event.getRightClicked(); if (ent.getCustomName() == null) + { return; - + } + //Start Message if (ent.getCustomName().contains("Start")) { @@ -352,12 +414,17 @@ public class ParkourManager extends MiniPlugin for (ParkourData data : _parkour) { if (!ent.getCustomName().contains(data.Name)) + { continue; - + } + if (isParkourMode(player)) + { setParkourMode(player, false); - else + } else + { setParkourMode(player, true); + } } } @@ -365,7 +432,7 @@ public class ParkourManager extends MiniPlugin if (ent.getCustomName().contains("Finish")) { final Player player = event.getPlayer(); - + if (!isParkourMode(player)) { //Inform @@ -375,43 +442,46 @@ public class ParkourManager extends MiniPlugin } if (!Recharge.Instance.use(player, "Finish Parkour", 30000, false, false)) + { return; + } for (ParkourData data : _parkour) { if (!ent.getCustomName().contains(data.Name)) + { continue; + } //Inform UtilPlayer.message(player, F.main("Parkour", "You completed " + F.elem(data.Name) + ".")); //Gems - if (!_taskManager.hasCompletedTask(player, data.Name)) + if (!_taskManager.hasCompletedTask(player, data.Name)) { final ParkourData fData = data; - _taskManager.completedTask(new Callback() + _taskManager.completedTask(new Callback() { public void run(Boolean completed) { - _donationManager.RewardGems(new Callback() + _donationManager.RewardGems(new Callback() { public void run(Boolean completed) { if (completed) { UtilPlayer.message(player, F.main("Parkour", "You received " + F.elem(C.cGreen + fData.Gems + " Gems") + ".")); - + //Sound player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); - } - else + } else { _taskManager.Get(player).TasksCompleted.remove(_taskManager.getTaskId(fData.Name)); UtilPlayer.message(player, F.main("Parkour", "There was an error giving " + F.elem(C.cGreen + fData.Gems + " Gems to you. Please click the NPC again.") + ".")); } } - }, "Parkour " + fData.Name, player.getName(), player.getUniqueId(), fData.Gems); + }, "Parkour " + fData.Name, player.getName(), player.getUniqueId(), fData.Gems); //Sound player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); @@ -421,14 +491,14 @@ public class ParkourManager extends MiniPlugin } } } - + @EventHandler public void gadgetBlockChange(GadgetBlockEvent event) { - for (Iterator iterator = event.getBlocks().iterator(); iterator.hasNext();) + for (Iterator iterator = event.getBlocks().iterator(); iterator.hasNext(); ) { Block block = iterator.next(); - + for (ParkourData data : _parkour) { if (data.InBoundary(block.getLocation())) @@ -436,7 +506,7 @@ public class ParkourManager extends MiniPlugin iterator.remove(); break; } - } + } } } @@ -444,8 +514,10 @@ public class ParkourManager extends MiniPlugin { for (ParkourData data : _parkour) if (data.InBoundary(loc)) + { return true; - + } + return false; } @@ -458,7 +530,7 @@ public class ParkourManager extends MiniPlugin UtilPlayer.message(event.getPlayer(), F.main("Parkour", "You can't open chests near Parkour.")); } } - + @EventHandler public void musicDisable(GadgetEnableEvent event) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java index fed5f2501..cb4ca5d0d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java @@ -1,28 +1,5 @@ package mineplex.hub.modules; -import java.util.ArrayList; -import java.util.HashSet; - -import org.bukkit.Color; -import org.bukkit.EntityEffect; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Bat; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Firework; -import org.bukkit.entity.Player; -import org.bukkit.entity.Slime; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.entity.WitherSkull; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerVelocityEvent; -import org.bukkit.util.Vector; - import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -50,6 +27,28 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; +import org.bukkit.Color; +import org.bukkit.EntityEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Bat; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Firework; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerVelocityEvent; +import org.bukkit.util.Vector; + +import java.util.ArrayList; +import java.util.HashSet; public class SoccerManager extends MiniPlugin { @@ -97,21 +96,21 @@ public class SoccerManager extends MiniPlugin super("Football Manager", hubManager.getPlugin()); _hubManager = hubManager; - - _cornerFieldPlayerA = new Location(hubManager.GetSpawn().getWorld(), 28.5,70,-27.5); - _cornerFieldPlayerB = new Location(hubManager.GetSpawn().getWorld(), 50.5,100,-65.5); - _cornerGoalPlayerA = new Location(hubManager.GetSpawn().getWorld(), 35.5,70,-24.5); - _cornerGoalPlayerB = new Location(hubManager.GetSpawn().getWorld(), 43.5,100,-68.5); + _cornerFieldPlayerA = new Location(hubManager.GetSpawn().getWorld(), -13.5, 67, -65.5); + _cornerFieldPlayerB = new Location(hubManager.GetSpawn().getWorld(), 25.5, 100, -87.5); - _cornerFieldA = new Location(hubManager.GetSpawn().getWorld(), 29.75,70,-28.75); - _cornerFieldB = new Location(hubManager.GetSpawn().getWorld(), 49.25,100,-64.25); + _cornerGoalPlayerA = new Location(hubManager.GetSpawn().getWorld(), -17.5, 67, -71.5); + _cornerGoalPlayerB = new Location(hubManager.GetSpawn().getWorld(), 29.5, 100, -80.5); - _cornerRedGoalA = new Location(hubManager.GetSpawn().getWorld(), 36.75,70,-64.25); - _cornerRedGoalB = new Location(hubManager.GetSpawn().getWorld(), 42.25,73.5,-67.25); + _cornerFieldA = new Location(hubManager.GetSpawn().getWorld(), -12.75, 67, -66.75); + _cornerFieldB = new Location(hubManager.GetSpawn().getWorld(), 24.25, 100, -86.25); - _cornerBlueGoalA = new Location(hubManager.GetSpawn().getWorld(), 36.75,70,-25.75); - _cornerBlueGoalB = new Location(hubManager.GetSpawn().getWorld(), 42.25,73.5,-28.75); + _cornerRedGoalA = new Location(hubManager.GetSpawn().getWorld(), 27, 67, -73); + _cornerRedGoalB = new Location(hubManager.GetSpawn().getWorld(), 25, 72.5, -79); + + _cornerBlueGoalA = new Location(hubManager.GetSpawn().getWorld(), -15, 67, -79); + _cornerBlueGoalB = new Location(hubManager.GetSpawn().getWorld(), -13, 72.5, -73); //Store Gadgets for (Gadget gadget : gadgetManager.getGadgets(GadgetType.COSTUME)) @@ -135,7 +134,7 @@ public class SoccerManager extends MiniPlugin _redGoals = 0; if (_ball != null) - _ball.remove();; + _ball.remove(); return; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java index daa44dd72..dfc31346d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java @@ -1,8 +1,21 @@ package mineplex.hub.modules; -import java.util.HashSet; -import java.util.Iterator; - +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.npc.NpcManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.Hub; +import mineplex.hub.HubManager; +import mineplex.hub.HubType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; @@ -38,26 +51,15 @@ import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.weather.WeatherChangeEvent; -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.hub.HubManager; -import mineplex.hub.HubType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import java.util.HashSet; +import java.util.Iterator; public class WorldManager extends MiniPlugin { public HubManager Manager; private HashSet _mobs = new HashSet(); - + private boolean _christmasSnow = false; private long _christSnowTime = 0; @@ -66,25 +68,31 @@ public class WorldManager extends MiniPlugin super("World Manager", manager.getPlugin()); Manager = manager; - + //Added by TheMineBench, to stop day cycles instead of setting the time on update event. World world = UtilWorld.getWorld("world"); - + world.setGameRuleValue("doDaylightCycle", "false"); - - if (Manager.Type == HubType.Halloween) + + if (Manager.Type == HubType.Halloween) + { world.setTime(16000); - else + } else + { world.setTime(6000); + } world.setStorm(false); world.setThundering(false); + fixEntities(); } @EventHandler public void SpawnAnimals(UpdateEvent event) { if (event.getType() != UpdateType.SLOW) + { return; + } Iterator entIterator = _mobs.iterator(); @@ -100,46 +108,62 @@ public class WorldManager extends MiniPlugin } if (_mobs.size() > 16) + { return; + } //Loc double r = Math.random(); Location loc = Manager.GetSpawn(); - if (r > 0.66) loc = new Location(Manager.GetSpawn().getWorld(), -9, 72, 42); - else if (r > 0.33) loc = new Location(Manager.GetSpawn().getWorld(), -36, 72, -28); - else loc = new Location(Manager.GetSpawn().getWorld(), 43, 72, 5); + if (r > 0.66) + { + loc = new Location(Manager.GetSpawn().getWorld(), -9, 72, 42); + } else if (r > 0.33) + { + loc = new Location(Manager.GetSpawn().getWorld(), -36, 72, -28); + } else + { + loc = new Location(Manager.GetSpawn().getWorld(), 43, 72, 5); + } //Spawn if (Manager.Type == HubType.Halloween) { Skeleton ent = loc.getWorld().spawn(loc, Skeleton.class); - if (Math.random() > 0.5) + if (Math.random() > 0.5) + { ent.setSkeletonType(SkeletonType.WITHER); - + } + ent.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.PUMPKIN)); - + ent.setCustomName(C.cYellow + "Pumpkin Minion"); ent.setCustomNameVisible(false); - + _mobs.add(ent); Manager.GetCondition().Factory().Invisible("Perm", ent, ent, 999999999, 0, false, false, true); Manager.GetCondition().Factory().Slow("Perm", ent, ent, 999999999, 1, false, false, false, true); - } - else if (Manager.Type == HubType.Christmas) + } else if (Manager.Type == HubType.Christmas) { _mobs.add(loc.getWorld().spawn(loc, Snowman.class)); - } - else + } else { r = Math.random(); - if (r > 0.66) _mobs.add(loc.getWorld().spawn(loc, Cow.class)); - else if (r > 0.33) _mobs.add(loc.getWorld().spawn(loc, Pig.class)); - else _mobs.add(loc.getWorld().spawn(loc, Chicken.class)); + if (r > 0.66) + { + _mobs.add(loc.getWorld().spawn(loc, Cow.class)); + } else if (r > 0.33) + { + _mobs.add(loc.getWorld().spawn(loc, Pig.class)); + } else + { + _mobs.add(loc.getWorld().spawn(loc, Chicken.class)); + } } } @@ -147,23 +171,25 @@ public class WorldManager extends MiniPlugin public void BlockBreak(BlockBreakEvent event) { if (event.getPlayer().getGameMode() == GameMode.CREATIVE) - return; + { + return; + } event.setCancelled(true); } - + @EventHandler public void BlockBurn(BlockBurnEvent event) { event.setCancelled(true); } - + @EventHandler public void BlockIgnite(BlockIgniteEvent event) { event.setCancelled(true); } - + @EventHandler public void BlockEntityChange(EntityChangeBlockEvent event) { @@ -192,7 +218,9 @@ public class WorldManager extends MiniPlugin public void BlockPlace(BlockPlaceEvent event) { if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + { return; + } event.setCancelled(true); } @@ -201,11 +229,13 @@ public class WorldManager extends MiniPlugin public void BorderUpdate(UpdateEvent event) { if (event.getType() != UpdateType.FASTEST) + { return; + } for (Player player : UtilServer.getPlayers()) { - if (UtilMath.offset(player.getLocation(), Manager.GetSpawn()) > 200) + if (UtilMath.offset(player.getLocation(), Manager.GetSpawn()) > 210) { player.eject(); player.leaveVehicle(); @@ -218,7 +248,9 @@ public class WorldManager extends MiniPlugin public void ItemPickup(PlayerPickupItemEvent event) { if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + { return; + } event.setCancelled(true); } @@ -227,33 +259,46 @@ public class WorldManager extends MiniPlugin public void ItemDrop(PlayerDropItemEvent event) { if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + { return; + } event.setCancelled(true); } - + @EventHandler(priority = EventPriority.LOW) public void ItemDespawn(UpdateEvent event) { if (event.getType() != UpdateType.SEC) + { return; - + } + for (Entity ent : UtilWorld.getWorld("world").getEntities()) { if (!(ent instanceof Item)) + { continue; - - if (((Item)ent).getItemStack().getType() == Material.MONSTER_EGG) + } + + if (((Item) ent).getItemStack().getType() == Material.MONSTER_EGG) + { continue; - + } + if (UtilEnt.GetMetadata(ent, "UtilItemSpawning") != null) + { continue; - + } + if (ent.getTicksLived() > 1200) + { ent.remove(); + } } } -//Removed by TheMineBench, time is now stopped when the WorldManager is created + + //Removed by TheMineBench, time is now stopped when the WorldManager is created /* @EventHandler public void UpdateWeather(UpdateEvent event) @@ -273,22 +318,29 @@ public class WorldManager extends MiniPlugin */ //Added by TheMineBench. Stops weather from changing. @EventHandler - public void OnWeather(WeatherChangeEvent event) { - + public void OnWeather(WeatherChangeEvent event) + { + if (!event.getWorld().getName().equals("world")) + { return; - + } + event.setCancelled(true); } - + @EventHandler public void HalloweenUpdates(UpdateEvent event) { if (event.getType() != UpdateType.FAST) + { return; + } if (Manager.Type != HubType.Halloween) + { return; + } //Block Lightup for (Player player : UtilServer.getPlayers()) @@ -296,7 +348,9 @@ public class WorldManager extends MiniPlugin for (Block block : UtilBlock.getInRadius(player.getLocation(), 3d).keySet()) { if (block.getType() == Material.PUMPKIN) + { Manager.GetBlockRestore().add(block, 91, block.getData(), 2000); + } } } @@ -304,43 +358,50 @@ public class WorldManager extends MiniPlugin for (LivingEntity ent : _mobs) { if (!(ent instanceof Creature)) + { continue; + } - Creature skel = (Creature)ent; + Creature skel = (Creature) ent; if (skel.getTarget() != null && skel.getTarget() instanceof Player && UtilMath.offset(skel, skel.getTarget()) < 6) { skel.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.JACK_O_LANTERN)); - } - else + } else { skel.getEquipment().setHelmet(ItemStackFactory.Instance.CreateStack(Material.PUMPKIN)); } } } - + @EventHandler public void SoundUpdate(UpdateEvent event) { if (Manager.Type != HubType.Halloween) + { return; + } if (event.getType() != UpdateType.SLOW) + { return; + } if (Math.random() > 0.1) + { return; + } for (Player player : UtilServer.getPlayers()) player.playSound(player.getLocation(), Sound.AMBIENCE_CAVE, 3f, 1f); } - + @EventHandler public void BlockForm(BlockFormEvent event) { event.setCancelled(true); } - + @EventHandler public void CreatureTarget(EntityTargetEvent event) { @@ -349,14 +410,16 @@ public class WorldManager extends MiniPlugin event.setCancelled(true); } } - + @EventHandler public void BoatBreak(CustomDamageEvent event) { if (event.GetDamageeEntity() instanceof Boat) + { event.SetCancelled("Boat Cancel"); + } } - + @EventHandler public void combustPrevent(EntityCombustEvent event) { @@ -365,4 +428,19 @@ public class WorldManager extends MiniPlugin event.setCancelled(true); } } + + public void fixEntities() + { + NpcManager npcManager = ((Hub) Manager.getPlugin()).getNpcManager(); + runSyncLater(() -> Manager.GetSpawn().getWorld().getEntities().stream().filter(e -> npcManager.getNpcByEntity(e) != null).forEach(e -> + { + if(e.isCustomNameVisible() && ChatColor.stripColor(e.getCustomName()).equalsIgnoreCase("Carl the Creeper") || ChatColor.stripColor(e.getCustomName()).equalsIgnoreCase("Mineplex Player Servers")) + { + e.teleport(new Location(e.getWorld(), e.getLocation().getX(), e.getLocation().getY(), e.getLocation().getZ(), 180f, 0f)); + return; + } + float pitch = e.getLocation().getBlockX() > 0 ? 90 : 270; + e.teleport(new Location(e.getWorld(), e.getLocation().getX(), e.getLocation().getY(), e.getLocation().getZ(), pitch, 0f)); + }), 120L); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonPrefs.java b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonPrefs.java index 1b9c38395..34471294d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonPrefs.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/profile/buttons/ButtonPrefs.java @@ -3,15 +3,11 @@ package mineplex.hub.profile.buttons; import mineplex.core.common.util.C; import mineplex.core.gui.GuiItem; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.itemstack.ItemStackFactory; import mineplex.hub.profile.gui.GUIProfile; - -import org.bukkit.ChatColor; 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.SkullMeta; public class ButtonPrefs implements GuiItem { @@ -28,7 +24,7 @@ public class ButtonPrefs implements GuiItem @Override public void click(ClickType clickType) { - _profile.getPrefManager().openShop(_player); + _profile.getPrefManager().openMenu(_player); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index c85d9e402..30c56aa5a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -1,15 +1,5 @@ package mineplex.hub.server; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Random; -import java.util.Set; -import java.util.UUID; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.boosters.BoosterManager; @@ -31,7 +21,6 @@ import mineplex.core.party.Party; import mineplex.core.party.PartyManager; import mineplex.core.party.event.PartySelectServerEvent; import mineplex.core.portal.Portal; -import mineplex.core.recharge.Recharge; import mineplex.core.shop.ShopBase; import mineplex.core.status.ServerStatusManager; import mineplex.core.updater.UpdateType; @@ -47,11 +36,9 @@ import mineplex.hub.server.ui.clans.ClansServerShop; import mineplex.serverdata.Region; import mineplex.serverdata.data.MinecraftServer; import mineplex.serverdata.data.ServerGroup; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -65,6 +52,15 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; + public class ServerManager extends MiniPlugin implements BrawlShopProvider { private static final Long FREE_PORTAL_TIMER = -1L; @@ -149,79 +145,10 @@ public class ServerManager extends MiniPlugin implements BrawlShopProvider return; } - final Player player = (Player)event.getEntity(); + Player player = (Player)event.getEntity(); + player.teleport(_hubManager.GetSpawn()); + runSyncLater(() -> {_quickShop.attemptShopOpen(player);}, 3L); - if (!Recharge.Instance.use(player, "Portal Server", 1000, false, false)) - return; - - long timeUntilPortal = getMillisecondsUntilPortal(player, false); - if (!_hubManager.CanPortal(player) || timeUntilPortal > 0) - { - player.closeInventory(); - - if (timeUntilPortal > 0) - { - player.playSound(player.getEyeLocation(), Sound.CHICKEN_EGG_POP, 2, 2); - UtilPlayer.message(player, F.main("Server Portal", "You cannot join a server for " + C.cGreen + UtilTime.convertString(timeUntilPortal, 0, TimeUnit.SECONDS))); - } - - UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hubManager.GetSpawn()), 1.5, true, 0.8, 0, 1.0, true); - - // Need to set their velocity again a tick later - // Setting Y-Velocity while in a portal doesn't seem to do anything... Science! - _plugin.getServer().getScheduler().runTask(_plugin, new Runnable() - { - - @Override - public void run() - { - if (player != null && player.isOnline()) - { - UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hubManager.GetSpawn()), 1, true, 0.5, 0, 1.0, true); - } - } - }); - - return; - } - - String serverKey = _portalToServerKey.get(player.getLocation().getBlock().getLocation().toVector()); - - if (serverKey != null) - { - List serverList = new ArrayList(); - - Collection servers = getServerList(serverKey); - if (servers != null && servers.size() > 0) - serverList.addAll(servers); - - int slots = 1; - - if (serverList.size() > 0) - { - slots = getRequiredSlots(player, serverList.get(0).ServerType); - } - - try - { - Collections.sort(serverList, new ServerSorter(slots)); - - for (ServerInfo serverInfo : serverList) - { - if ((serverInfo.MOTD.contains("Starting") || serverInfo.MOTD.contains("Recruiting") || serverInfo.MOTD.contains("Waiting") || serverInfo.MOTD.contains("Cup")) && (serverInfo.MaxPlayers - serverInfo.CurrentPlayers) >= slots) - { - selectServer(player, serverInfo); - return; - } - } - } - catch (Exception exception) - { - exception.printStackTrace(); - } - - UtilPlayer.message(player, F.main("Server Portal", "There are currently no joinable servers!")); - } } @EventHandler diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index bdef1bc65..124d6dc2a 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -1,8 +1,6 @@ package mineplex.staffServer; -import java.util.UUID; - -import mineplex.core.Managers; +import com.mojang.authlib.GameProfile; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; @@ -30,12 +28,11 @@ import mineplex.core.updater.Updater; import mineplex.staffServer.customerSupport.CustomerSupport; import mineplex.staffServer.salespackage.SalesPackageManager; import net.minecraft.server.v1_8_R3.MinecraftServer; - import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_8_R3.CraftServer; import org.bukkit.plugin.java.JavaPlugin; -import com.mojang.authlib.GameProfile; +import java.util.UUID; import static mineplex.core.Managers.require; @@ -63,7 +60,7 @@ public class StaffServer extends JavaPlugin Punish punish = new Punish(this, webServerAddress, clientManager); new NpcManager(this, new Creature(this)); ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager)); - PreferencesManager preferenceManager = new PreferencesManager(this, null, clientManager, donationManager); + PreferencesManager preferenceManager = new PreferencesManager(this, null, clientManager); preferenceManager.GiveItem = false; Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); 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 303ebc9f7..a657c1669 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -1,27 +1,14 @@ package nautilus.game.arcade; -import java.io.File; -import java.util.HashMap; - -import mineplex.core.Managers; -import mineplex.core.boosters.BoosterManager; -import mineplex.core.thank.ThankManager; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; import mineplex.core.PacketsInteractionFix; -import mineplex.core.customdata.CustomDataManager; -import mineplex.core.globalpacket.GlobalPacketManager; -import net.minecraft.server.v1_8_R3.BiomeBase; -import net.minecraft.server.v1_8_R3.MinecraftServer; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; +import mineplex.core.boosters.BoosterManager; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; import mineplex.core.common.events.ServerShutdownEvent; @@ -29,12 +16,14 @@ import mineplex.core.common.util.FileUtil; import mineplex.core.common.util.UtilServer; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; +import mineplex.core.customdata.CustomDataManager; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; import mineplex.core.friend.FriendManager; import mineplex.core.gadget.GadgetManager; import mineplex.core.give.Give; +import mineplex.core.globalpacket.GlobalPacketManager; import mineplex.core.hologram.HologramManager; import mineplex.core.ignore.IgnoreManager; import mineplex.core.incognito.IncognitoManager; @@ -59,6 +48,7 @@ import mineplex.core.serverConfig.ServerConfiguration; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.teleport.Teleport; +import mineplex.core.thank.ThankManager; import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; @@ -66,6 +56,14 @@ import mineplex.core.visibility.VisibilityManager; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import nautilus.game.arcade.game.GameServerConfig; +import net.minecraft.server.v1_8_R3.BiomeBase; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import java.io.File; +import java.util.HashMap; import static mineplex.core.Managers.require; @@ -120,7 +118,7 @@ public class Arcade extends JavaPlugin PacketHandler packetHandler = require(PacketHandler.class); IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler); - PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager); + PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager); incognito.setPreferencesManager(preferenceManager); 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 7bb2599be..54413b037 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -12,7 +12,13 @@ import mineplex.core.boosters.BoosterManager; import mineplex.core.chat.Chat; import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; import mineplex.core.customdata.CustomDataManager; @@ -34,6 +40,7 @@ import mineplex.core.incognito.IncognitoManager; import mineplex.core.incognito.events.IncognitoStatusChangeEvent; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.menu.MenuManager; import mineplex.core.movement.Movement; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; @@ -90,13 +97,33 @@ import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.games.event.EventModule; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.game.games.uhc.UHC; -import nautilus.game.arcade.managers.*; +import nautilus.game.arcade.managers.GameAchievementManager; +import nautilus.game.arcade.managers.GameCreationManager; +import nautilus.game.arcade.managers.GameFlagManager; +import nautilus.game.arcade.managers.GameHostManager; +import nautilus.game.arcade.managers.GameLobbyManager; +import nautilus.game.arcade.managers.GameLootManager; +import nautilus.game.arcade.managers.GameManager; +import nautilus.game.arcade.managers.GamePlayerManager; +import nautilus.game.arcade.managers.GameRewardManager; +import nautilus.game.arcade.managers.GameSpectatorManager; +import nautilus.game.arcade.managers.GameStatManager; +import nautilus.game.arcade.managers.GameTestingManager; +import nautilus.game.arcade.managers.GameTournamentManager; +import nautilus.game.arcade.managers.GameWorldManager; +import nautilus.game.arcade.managers.IdleManager; +import nautilus.game.arcade.managers.MiscManager; +import nautilus.game.arcade.managers.ProgressingKitManager; +import nautilus.game.arcade.managers.ServerUptimeManager; import nautilus.game.arcade.managers.chat.GameChatManager; import nautilus.game.arcade.player.ArcadePlayer; import nautilus.game.arcade.shop.ArcadeShop; import net.minecraft.server.v1_8_R3.EntityLiving; -import org.bukkit.*; +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; @@ -105,11 +132,17 @@ 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.*; +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.*; +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; @@ -528,7 +561,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation } } }; - + new MenuManager(_plugin); Managers.put(this._scoreboardManager, ScoreboardManager.class); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java index 3007c7085..b1f5f327e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java @@ -1,11 +1,38 @@ package nautilus.game.arcade.game.games.valentines; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; - +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.noteblock.INoteVerifier; +import mineplex.core.noteblock.NBSReader; +import mineplex.core.noteblock.NotePlayer; +import mineplex.core.noteblock.NoteSong; +import mineplex.core.preferences.Preference; +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.SoloGame; +import nautilus.game.arcade.game.games.valentines.kit.KitMasterOfLove; +import nautilus.game.arcade.game.games.valentines.tutorial.TutorialValentines; +import nautilus.game.arcade.kit.Kit; import org.bukkit.EntityEffect; import org.bukkit.Location; import org.bukkit.Material; @@ -25,38 +52,11 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.util.Vector; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextBottom; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.noteblock.INoteVerifier; -import mineplex.core.noteblock.NBSReader; -import mineplex.core.noteblock.NotePlayer; -import mineplex.core.noteblock.NoteSong; -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.SoloGame; -import nautilus.game.arcade.game.games.valentines.kit.KitMasterOfLove; -import nautilus.game.arcade.game.games.valentines.tutorial.TutorialValentines; -import nautilus.game.arcade.kit.Kit; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; public class Valentines extends SoloGame { @@ -703,7 +703,7 @@ public class Valentines extends SoloGame @Override public boolean shouldPlay(Player player) { - return Manager.getPreferences().Get(player).HubMusic; + return Manager.getPreferences().get(player).isActive(Preference.HUB_MUSIC); } }, 0.7F, true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java index 12395f010..b719d2389 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java @@ -1,6 +1,6 @@ package nautilus.game.arcade.kit; -import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; @@ -8,12 +8,13 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.donation.Donor; +import mineplex.core.menu.Menu; import mineplex.core.progression.ProgressiveKit; import mineplex.core.progression.data.KitAbilityDetail; import mineplex.core.progression.data.PlayerKit; import mineplex.core.progression.data.PlayerKitDataManager; -import mineplex.core.progression.gui.Menu; import mineplex.core.progression.math.Calculations; +import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.SalesPackageProcessor; import nautilus.game.arcade.ArcadeManager; @@ -23,8 +24,13 @@ import nautilus.game.arcade.shop.KitPackage; import net.minecraft.server.v1_8_R3.EntityFireworks; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityStatus; import net.minecraft.server.v1_8_R3.World; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.EntityType; @@ -36,6 +42,7 @@ import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.UUID; /** @@ -51,18 +58,14 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit private String _internalName; private PlayerKitDataManager _dataManager; - private List _kitAbilityDetails; + private Map> _kitAbilityDetails; public ProgressingKit(ArcadeManager manager, String name, String internalName, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand) { super(manager, name, kitAvailability, kitDesc, kitPerks, entityType, itemInHand); _internalName = internalName; _dataManager = manager.getKitProgressionManager().getDataManager(); - _kitAbilityDetails = Lists.newArrayList(); - for (Perk perk : kitPerks) - { - _kitAbilityDetails.add(new KitAbilityDetail(perk.getIcon(), perk.GetName(), perk.GetDesc())); - } + _kitAbilityDetails = Maps.newHashMap(); } public ProgressingKit(ArcadeManager manager, String name, String internalName, KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand) @@ -70,11 +73,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit super(manager, name, kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand); _internalName = internalName; _dataManager = manager.getKitProgressionManager().getDataManager(); - _kitAbilityDetails = Lists.newArrayList(); - for (Perk perk : kitPerks) - { - _kitAbilityDetails.add(new KitAbilityDetail(perk.getIcon(), perk.GetName(), perk.GetDesc())); - } + _kitAbilityDetails = Maps.newHashMap(); } @@ -103,7 +102,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit } @Override - public List getAbilityDetails() + public Map> getAbilityDetails() { return _kitAbilityDetails; } @@ -302,7 +301,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit else if (this.GetAvailability() == KitAvailability.Gem && donor.getBalance(GlobalCurrency.GEM) >= this.GetCost()) { SalesPackageBase salesPackage = new KitPackage(Manager.GetGame().GetType().GetKitGameName(Manager.GetGame()), this); - Manager.GetShop().openPageForPlayer(player, new mineplex.core.shop.confirmation.ConfirmationPage<>(player, Manager, Manager.GetShop(), Manager.GetClients(), Manager.GetDonation(), new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, Manager.GetDonation(), () -> + Manager.GetShop().openPageForPlayer(player, new ConfirmationPage<>(player, Manager, Manager.GetShop(), Manager.GetClients(), Manager.GetDonation(), new SalesPackageProcessor(player, GlobalCurrency.GEM, salesPackage, Manager.GetDonation(), () -> { if (player.isOnline()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java index 7895fb33c..fc5945a96 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java @@ -205,116 +205,133 @@ public class ProgressingKitManager implements Listener private void resetDefaultKits() { - Lists.newArrayList(UtilServer.getPlayers()).stream() - .forEach(player -> { - for (Kit kit : _manager.GetGame().GetKits()) - { - //Set default kit - if (kit instanceof ProgressingKit) - { - ProgressingKit progressingKit = (ProgressingKit) kit; - if (progressingKit.isDefault(player.getUniqueId())) - { - progressingKit.onSelected(player.getUniqueId()); - break; - } - } - } - }); + Lists.newArrayList(UtilServer.getPlayers()).forEach(player -> + { + for (Kit kit : _manager.GetGame().GetKits()) + { + //Set default kit + if (kit instanceof ProgressingKit) + { + ProgressingKit progressingKit = (ProgressingKit) kit; + if (progressingKit.isDefault(player.getUniqueId())) + { + progressingKit.onSelected(player.getUniqueId()); + break; + } + } + } + }); } private void displayKitData() { - Lists.newArrayList(UtilServer.getPlayers()).stream() - .forEach(player -> { - KitProgressionData data = _data.remove(player.getUniqueId()); - if (data == null) - { - return; - } + Lists.newArrayList(UtilServer.getPlayers()).forEach(player -> + { + KitProgressionData data = _data.remove(player.getUniqueId()); - player.sendMessage(SPACE); + if (data == null) + { + return; + } - player.sendMessage(LINE); - player.sendMessage(INFO); - player.sendMessage(SPACE); + player.sendMessage(SPACE); - int xpGained = data.getXpGained(); - ProgressingKit kit = data.getKit(); + player.sendMessage(LINE); + player.sendMessage(INFO); + player.sendMessage(SPACE); - PlayerKit playerKit = _manager.getKitProgressionManager().getDataManager().get(player.getUniqueId()); + int xpGained = data.getXpGained(); + ProgressingKit kit = data.getKit(); - //We only want them leveling up once a game, and to make sure XP stays the same - //Limit their total gained to the max amount they can gain, if they've reached it or exceeded it - if (xpGained >= Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId()))) - { - xpGained = Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId())); - } + PlayerKit playerKit = _manager.getKitProgressionManager().getDataManager().get(player.getUniqueId()); + + if(playerKit.getLevel(kit.getInternalName()) >= 100) + { + StringBuilder builder = new StringBuilder(); + String kitName = C.cGoldB + kit.getDisplayName(); + + //Name of the kit + builder.append(kitName).append(" ").append(C.Reset).append(C.cGoldB).append("MAX LEVEL"); + + player.sendMessage(builder.toString()); + player.sendMessage(C.cWhite + "You maxed out this kit! Great job, and thanks for playing on Mineplex!"); + + player.sendMessage(SPACE); + player.sendMessage(LINE); + return; + } + + //We only want them leveling up once a game, and to make sure XP stays the same + //Limit their total gained to the max amount they can gain, if they've reached it or exceeded it + if (xpGained >= Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId()))) + { + xpGained = Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId())); + } - kit.setXp(kit.getXp(player.getUniqueId()) + xpGained, player.getUniqueId()); - boolean leveledUp = false; + kit.setXp(kit.getXp(player.getUniqueId()) + xpGained, player.getUniqueId()); + boolean leveledUp = false; - if (kit.isLevelUpReady(player.getUniqueId())) - { - leveledUp = true; - kit.levelUp(player.getUniqueId()); - } + if (kit.isLevelUpReady(player.getUniqueId())) + { + leveledUp = true; + kit.levelUp(player.getUniqueId()); + } - int currentLevel = kit.getLevel(player.getUniqueId()); - int difference = kit.getXpDifference(player.getUniqueId()); + int currentLevel = kit.getLevel(player.getUniqueId()); + int difference = kit.getXpDifference(player.getUniqueId()); - //We shouldn't need to update the database, but there are some cases where we'll need too (found through testing) - _manager.getKitProgressionManager().getRepository().insertOrUpdate(playerKit, kit.getInternalName()); + //We shouldn't need to update the database, but there are some cases where we'll need too (found through testing) + _manager.getKitProgressionManager().getRepository().insertOrUpdate(playerKit, kit.getInternalName()); - StringBuilder builder = new StringBuilder(); - String kitName = C.cGoldB + kit.getDisplayName(); + StringBuilder builder = new StringBuilder(); + String kitName = C.cGoldB + kit.getDisplayName(); - //Name of the kit - builder.append(kitName) - .append(" ") - .append(C.Reset); + //Name of the kit + builder.append(kitName) + .append(" ") + .append(C.Reset); - //Current level out of 100 - builder.append(C.cYellow) - .append(currentLevel) - .append(C.cGold) - .append("/") - .append(C.cYellow) - .append(100) - .append(" ") - .append(C.Reset); + //Current level out of 100 + builder.append(C.cYellow) + .append(currentLevel) + .append(C.cGold) + .append("/") + .append(C.cYellow) + .append(100) + .append(" ") + .append(C.Reset); - //The amount of XP the player gained - builder.append(C.cGreen) - .append("+") - .append(xpGained) - .append(" ") - .append(C.Reset); + //The amount of XP the player gained + builder.append(C.cGreen) + .append("+") + .append(xpGained) + .append(" ") + .append(C.Reset); - if (!leveledUp) - { - //The XP required to level up - builder.append(C.cYellow) - .append(difference) - .append(" to next level"); - } else - { - builder.append(C.cAquaB) - .append("LEVEL UP! ") - .append(C.cYellow) - .append(Calculations.getXpForNextLevel(currentLevel)) - .append(" to next level"); - player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); - } + if (!leveledUp) + { + //The XP required to level up + builder.append(C.cYellow) + .append(difference) + .append(" to next level"); + } else + { + builder.append(C.cAquaB) + .append("LEVEL UP! ") + .append(C.cYellow) + .append(Calculations.getXpForNextLevel(currentLevel)) + .append(" to next level"); + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); + } - //Send the message finally - player.sendMessage(builder.toString()); - player.sendMessage(C.cWhite + "Level up by using this kit in game!"); + //Send the message finally + player.sendMessage(builder.toString()); + player.sendMessage(C.cWhite + "Level up by using this kit in game!"); - player.sendMessage(SPACE); - player.sendMessage(LINE); - }); + player.sendMessage(SPACE); + player.sendMessage(LINE); + }); } public void addData(Player player, int xpGained, Game game, ProgressingKit kit) 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 944ed3ec4..0e91e1cc8 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 @@ -1,6 +1,5 @@ package nautilus.game.arcade.managers.chat; -import mineplex.core.account.CoreClient; import mineplex.core.common.Rank; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; @@ -26,7 +25,6 @@ import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; -import java.util.stream.Collectors; import java.util.UUID; public class GameChatManager implements Listener @@ -124,7 +122,7 @@ public class GameChatManager implements Listener event.setMessage(event.getMessage().substring(1, event.getMessage().length())); event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + event.getPlayer().getName() + " " + C.cPurple + "%2$s"); - for (UUID member : party.getMembers()) + for (UUID member : party.getMembersByUUID()) { Player other = Bukkit.getPlayer(member);