From ef4aeaaf64994ce0bd257d5297f117f2c62a2dd7 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 2 Aug 2017 12:44:35 -0400 Subject: [PATCH] Initial rank rewrite and quest database fixes --- .../src/mineplex/core/common/Rank.java | 166 ----- .../src/mineplex/core/common/util/F.java | 18 +- .../src/mineplex/core/PlayerSelector.java | 31 +- .../src/mineplex/core/account/CoreClient.java | 157 ++-- .../core/account/CoreClientManager.java | 511 ++++++++----- .../core/account/command/AddRankCommand.java | 99 +++ .../account/command/InfoPlayerCommand.java | 93 +++ .../account/command/ListRanksCommand.java | 28 + .../core/account/command/RanksCommand.java | 35 + .../account/command/RemoveRankCommand.java | 99 +++ .../account/command/ResetPlayerCommand.java | 104 +++ .../core/account/command/SetRankCommand.java | 91 +++ .../core/account/command/TestRank.java | 84 --- .../core/account/command/UpdateRank.java | 130 ---- .../core/account/event/GroupAddEvent.java | 38 + .../core/account/event/GroupRemoveEvent.java | 38 + .../account/event/OnlineGroupAddEvent.java | 41 ++ .../account/event/OnlineGroupRemoveEvent.java | 41 ++ ...ava => OnlinePrimaryGroupUpdateEvent.java} | 24 +- .../event/PrimaryGroupUpdateEvent.java | 38 + .../core/account/event/RankSaveEvent.java | 42 -- .../account/permissions/GroupPermission.java | 35 + .../account/permissions/PermissionGroup.java | 109 +++ .../permissions/PermissionManager.java | 317 ++++++++ .../account/redis/AddPermissionGroup.java | 25 + .../redis/AddPermissionGroupHandler.java | 41 ++ .../core/account/redis/ClearGroups.java | 18 + .../account/redis/ClearGroupsHandler.java | 39 + .../account/redis/PrimaryGroupUpdate.java | 25 + .../redis/PrimaryGroupUpdateHandler.java | 42 ++ .../account/redis/RemovePermissionGroup.java | 25 + .../redis/RemovePermissionGroupHandler.java | 41 ++ .../account/repository/AccountRepository.java | 365 ++++++++-- .../core/account/repository/token/Rank.java | 2 +- .../core/achievement/AchievementCategory.java | 4 +- .../core/achievement/AchievementManager.java | 69 +- .../achievement/command/StatsCommand.java | 12 +- .../src/mineplex/core/antihack/AntiHack.java | 42 +- .../core/antihack/banwave/BanWaveManager.java | 2 +- .../commands/AnticheatOffCommand.java | 5 +- .../antihack/commands/AnticheatOnCommand.java | 5 +- .../commands/DetailedMessagesCommand.java | 5 +- .../core/antihack/commands/GetVlsCommand.java | 5 +- .../antihack/commands/TestBanCommand.java | 5 +- .../antihack/guardians/AntiHackGuardian.java | 41 +- .../antihack/guardians/GuardianManager.java | 48 +- .../core/antihack/logging/AntihackLogger.java | 19 +- .../core/aprilfools/AprilFoolsManager.java | 45 +- .../aprilfools/command/PirateSongCommand.java | 30 +- .../src/mineplex/core/beta/BetaWhitelist.java | 20 +- .../mineplex/core/bonuses/BonusManager.java | 62 +- .../core/bonuses/commands/AllowCommand.java | 14 +- .../bonuses/commands/AnimationCommand.java | 8 +- .../core/bonuses/commands/GuiCommand.java | 10 +- .../bonuses/commands/PowerPlayCommand.java | 25 +- .../core/bonuses/commands/TicketCommand.java | 11 +- .../core/bonuses/gui/buttons/PollButton.java | 45 +- .../bonuses/gui/buttons/RankBonusButton.java | 2 +- .../core/boosters/BoosterManager.java | 55 +- .../core/boosters/command/AddCommand.java | 11 +- .../core/boosters/command/BoosterCommand.java | 16 +- .../core/boosters/command/GuiCommand.java | 8 +- .../core/boosters/command/ReloadCommand.java | 20 +- .../core/boosters/command/ThankCommand.java | 12 +- .../mineplex/core/botspam/BotSpamManager.java | 44 +- .../botspam/command/BotSpamAddCommand.java | 7 +- .../core/botspam/command/BotSpamCommand.java | 5 +- .../command/BotSpamDisableCommand.java | 8 +- .../botspam/command/BotSpamEnableCommand.java | 8 +- .../command/BotSpamGlobalUpdateCommand.java | 6 +- .../botspam/command/BotSpamListCommand.java | 16 +- .../src/mineplex/core/chat/Chat.java | 130 ++-- .../core/chat/command/BroadcastCommand.java | 5 +- .../core/chat/command/ChatSlowCommand.java | 5 +- .../core/chat/command/SilenceCommand.java | 5 +- .../core/chatsnap/SnapshotPlugin.java | 15 +- .../chatsnap/command/ChatSnapCommand.java | 5 +- .../mineplex/core/command/CommandBase.java | 35 +- .../mineplex/core/command/CommandCenter.java | 30 +- .../src/mineplex/core/command/ICommand.java | 13 +- .../mineplex/core/command/LoggedCommand.java | 4 +- .../core/command/LoggingServerCommand.java | 2 +- .../core/command/MultiCommandBase.java | 33 +- .../core/communities/CommunityManager.java | 45 ++ .../commands/CommunityChatCommand.java | 5 +- .../commands/CommunityCommand.java | 24 +- .../commands/CommunityCreateCommand.java | 5 +- .../commands/CommunityDescriptionCommand.java | 8 +- .../commands/CommunityDisbandCommand.java | 8 +- .../commands/CommunityInviteCommand.java | 8 +- .../commands/CommunityJoinCommand.java | 5 +- .../commands/CommunityMCSCommand.java | 8 +- .../commands/CommunityMenuCommand.java | 3 +- .../commands/CommunityRenameCommand.java | 8 +- .../commands/CommunityUnInviteCommand.java | 8 +- .../gui/community/CommunityMemberButton.java | 30 +- .../core/cosmetic/ui/page/WinEffectPage.java | 15 +- .../src/mineplex/core/creature/Creature.java | 51 +- .../core/creature/command/HelpCommand.java | 26 - .../core/creature/command/KillCommand.java | 5 +- .../core/creature/command/MobCommand.java | 14 +- .../disguises/DisguiseInsentient.java | 18 +- .../playerdisguise/DisguiseCommand.java | 15 +- .../playerdisguise/PlayerDisguiseManager.java | 54 +- .../core/donation/DonationManager.java | 17 + .../core/donation/command/CrownCommand.java | 5 +- .../core/donation/command/GemCommand.java | 5 +- .../core/donation/command/ShardCommand.java | 5 +- .../src/mineplex/core/elo/EloManager.java | 46 +- .../src/mineplex/core/elo/EloRepository.java | 449 ++++++------ .../src/mineplex/core/elo/TopEloCommand.java | 117 ++- .../core/facebook/FacebookManager.java | 74 +- .../facebook/command/FacebookCommand.java | 5 +- .../mineplex/core/friend/FriendManager.java | 678 +++++++++--------- .../core/friend/FriendStatusType.java | 2 +- .../core/friend/command/AddFriend.java | 11 +- .../core/friend/command/DeleteFriend.java | 5 +- .../core/friend/command/FriendsDisplay.java | 7 +- .../core/friend/ui/AddFriendPage.java | 3 +- .../mineplex/core/friend/ui/FriendPage.java | 2 +- .../mineplex/core/friend/ui/FriendsGUI.java | 7 +- .../mineplex/core/gadget/GadgetManager.java | 155 ++-- .../core/gadget/commands/AmmoCommand.java | 11 +- .../gadget/commands/LockCosmeticsCommand.java | 12 +- .../gadget/commands/LockInfusedCommand.java | 8 +- .../commands/UnlockCosmeticsCommand.java | 13 +- .../gadgets/arrowtrail/ArrowTrailTitan.java | 10 +- .../core/gadget/gadgets/death/DeathTitan.java | 9 +- .../gadgets/doublejump/DoubleJumpTitan.java | 10 +- .../core/gadget/gadgets/morph/MorphBlaze.java | 6 +- .../gadget/gadgets/morph/MorphCreeper.java | 6 +- .../gadget/gadgets/morph/MorphDinnerbone.java | 35 +- .../core/gadget/gadgets/morph/MorphPig.java | 8 +- .../core/gadget/gadgets/morph/MorphSlime.java | 9 +- .../core/gadget/gadgets/morph/MorphTitan.java | 6 +- .../gadget/gadgets/morph/MorphWither.java | 7 +- .../gadgets/morph/managers/UtilMorph.java | 8 +- .../gadgets/particle/ParticleCoalFumes.java | 2 +- .../gadgets/particle/ParticleKronos.java | 82 --- .../gadgets/particle/ParticleKronosData.java | 112 --- .../gadgets/particle/ParticleLegend.java | 17 +- .../gadgets/particle/ParticleTitan.java | 8 +- .../gadgets/particle/king/CastleManager.java | 10 +- .../gadget/gadgets/taunts/EternalTaunt.java | 14 +- .../rankrooms/WinEffectRankBased.java | 45 +- .../rankwineffects/WinEffectRankEternal.java | 7 +- .../rankwineffects/WinEffectRankHero.java | 7 +- .../rankwineffects/WinEffectRankLegend.java | 7 +- .../rankwineffects/WinEffectRankTitan.java | 7 +- .../rankwineffects/WinEffectRankUltra.java | 7 +- .../mineplex/core/gadget/types/Gadget.java | 31 +- .../core/gadget/types/WinEffectGadget.java | 11 +- .../src/mineplex/core/give/Give.java | 22 +- .../core/give/commands/GiveCommand.java | 21 +- .../globalpacket/GlobalPacketManager.java | 26 +- .../command/GlobalPacketCommand.java | 5 +- .../globalpacket/event/GlobalPacketEvent.java | 15 +- .../listeners/GlobalGiveCoins.java | 36 +- .../listeners/GlobalGiveGems.java | 38 +- .../listeners/GlobalGiveItem.java | 64 +- .../redis/GlobalPacketHandler.java | 4 +- .../redis/GlobalPacketMessage.java | 15 +- .../mineplex/core/ignore/IgnoreManager.java | 364 +++++----- .../mineplex/core/ignore/command/Ignore.java | 9 +- .../core/ignore/command/Unignore.java | 11 +- .../mineplex/core/ignore/data/IgnoreData.java | 14 +- .../core/ignore/data/IgnoreRepository.java | 9 +- .../core/incognito/IncognitoManager.java | 77 +- .../commands/IncognitoToggleCommand.java | 48 +- .../events/IncognitoHidePlayerEvent.java | 1 - .../events/IncognitoStatusChangeEvent.java | 1 - .../incognito/repository/IncognitoClient.java | 2 +- .../repository/IncognitoRepository.java | 3 +- .../core/inventory/InventoryManager.java | 57 +- .../inventory/command/GiveItemCommand.java | 45 +- .../core/leaderboard/LeaderboardManager.java | 17 +- .../mineplex/core/message/MessageManager.java | 212 +++--- .../core/message/commands/AdminCommand.java | 24 +- .../message/commands/AnnounceCommand.java | 17 +- .../message/commands/MessageAdminCommand.java | 8 +- .../core/message/commands/MessageCommand.java | 5 +- .../message/commands/ResendAdminCommand.java | 8 +- .../core/message/commands/ResendCommand.java | 5 +- .../src/mineplex/core/monitor/LagMeter.java | 53 +- .../core/monitor/VersionsCommand.java | 17 +- .../src/mineplex/core/mount/MountManager.java | 14 + .../core/mount/types/MountDragon.java | 10 +- .../mineplex/core/mount/types/MountSheep.java | 4 +- .../mineplex/core/mount/types/MountTitan.java | 8 +- .../core/notifier/NotificationManager.java | 46 +- .../src/mineplex/core/npc/NpcManager.java | 85 ++- .../mineplex/core/npc/command/AddCommand.java | 11 +- .../core/npc/command/ClearCommand.java | 7 +- .../core/npc/command/DeleteCommand.java | 7 +- .../core/npc/command/HomeCommand.java | 7 +- .../mineplex/core/npc/command/NpcCommand.java | 5 +- .../core/npc/command/RefreshCommand.java | 7 +- .../src/mineplex/core/party/PartyManager.java | 13 + .../core/party/command/PartyCLICommand.java | 14 +- .../core/party/command/PartyCommand.java | 10 +- .../core/party/command/PartyGuiCommand.java | 5 +- .../party/command/PartyToggleCommand.java | 5 +- .../party/command/cli/PartyAcceptCommand.java | 5 +- .../party/command/cli/PartyBlockCommand.java | 5 +- .../party/command/cli/PartyDenyCommand.java | 5 +- .../command/cli/PartyDisbandCommand.java | 5 +- .../party/command/cli/PartyHelpCommand.java | 5 +- .../party/command/cli/PartyInviteCommand.java | 5 +- .../command/cli/PartyInvitesCommand.java | 16 +- .../party/command/cli/PartyKickCommand.java | 5 +- .../party/command/cli/PartyLeaveCommand.java | 5 +- .../cli/PartyTransferOwnerCommand.java | 5 +- .../gui/PartyGUIAcceptInviteCommand.java | 5 +- .../gui/PartyGUIDenyInviteCommand.java | 5 +- .../command/gui/PartyGUIInviteCommand.java | 5 +- .../command/gui/PartyGUILeaveCommand.java | 7 +- .../gui/PartyOpenInviteMenuCommand.java | 5 +- .../core/party/manager/PartyJoinManager.java | 8 +- .../HostEventServerCommand.java | 10 +- .../HostPersonalEventServer.java | 10 +- .../personalServer/HostServerCommand.java | 7 +- .../personalServer/PersonalServerManager.java | 96 +-- .../src/mineplex/core/pet/PetManager.java | 36 +- .../core/playerCount/PlayerCountManager.java | 5 +- .../src/mineplex/core/poll/DisplayType.java | 10 +- .../mineplex/core/poll/PlayerPollData.java | 3 +- .../src/mineplex/core/poll/Poll.java | 2 +- .../src/mineplex/core/poll/PollManager.java | 44 +- .../mineplex/core/poll/PollRepository.java | 116 ++- .../src/mineplex/core/poll/PollStats.java | 3 +- .../core/poll/command/PollCommand.java | 92 ++- .../core/portal/Commands/SendCommand.java | 68 -- .../core/portal/Commands/ServerCommand.java | 98 --- .../mineplex/core/portal/GenericServer.java | 4 +- .../src/mineplex/core/portal/Intent.java | 2 +- .../src/mineplex/core/portal/Portal.java | 36 +- .../core/portal/commands/SendCommand.java | 60 ++ .../core/portal/commands/ServerCommand.java | 90 +++ .../events/GenericServerTransferEvent.java | 3 +- .../portal/events/ServerTransferEvent.java | 3 +- .../mineplex/core/preferences/Preference.java | 26 +- .../core/preferences/PreferenceCategory.java | 4 +- .../core/preferences/PreferencesManager.java | 106 ++- .../preferences/PreferencesRepository.java | 33 +- .../core/preferences/UserPreferences.java | 5 +- .../command/PreferencesCommand.java | 10 +- .../preferences/ui/PreferenceMainMenu.java | 26 +- .../preferences/ui/buttons/BackButton.java | 3 +- .../ui/buttons/CategoryButton.java | 3 +- .../ui/buttons/PreferenceButton.java | 5 +- .../ui/buttons/PreferenceDyeButton.java | 3 +- .../preferences/ui/menus/PreferenceMenu.java | 41 +- .../core/punish/Command/PunishCommand.java | 90 +-- .../core/punish/Command/RulesCommand.java | 6 +- .../src/mineplex/core/punish/Punish.java | 34 +- .../mineplex/core/punish/UI/PunishPage.java | 261 ++++--- .../core/punish/clans/ClansBanManager.java | 23 +- .../punish/clans/command/ClansBanCommand.java | 3 +- .../src/mineplex/core/quests/Quest.java | 35 +- .../mineplex/core/quests/QuestManager.java | 160 +++-- .../core/quests/command/GetQuestCommand.java | 11 +- .../quests/command/IncrementQuestCommand.java | 8 +- .../core/quests/command/OpenGuiCommand.java | 7 +- .../core/quests/repository/QuestData.java | 36 + .../quests/repository/QuestRepository.java | 120 +--- .../core/quests/shop/BuyQuestButton.java | 11 +- .../mineplex/core/quests/shop/QuestPage.java | 6 +- .../quests/shop/RedeemDeclineQuestButton.java | 11 +- .../rankGiveaway/eternal/EternalCommand.java | 5 +- .../eternal/EternalGiveawayAnimation.java | 2 +- .../eternal/EternalGiveawayManager.java | 44 +- .../eternal/EternalGiveawayRepository.java | 2 +- .../titangiveaway/TitanGiveawayAnimation.java | 2 +- .../titangiveaway/TitanGiveawayManager.java | 74 +- .../TitanGiveawayRepository.java | 5 +- .../mineplex/core/report/ReportManager.java | 23 + .../mineplex/core/report/ReportPlugin.java | 2 +- .../report/command/ReportCloseCommand.java | 5 +- .../core/report/command/ReportCommand.java | 112 ++- .../report/command/ReportHandleCommand.java | 6 +- .../report/command/ReportHistoryCommand.java | 7 +- .../report/command/ReportInfoCommand.java | 5 +- .../report/command/ReportMetricsCommand.java | 6 +- .../core/report/ui/ReportCreatePage.java | 2 +- .../mineplex/core/reward/RankRewardData.java | 13 +- .../mineplex/core/reward/RewardManager.java | 88 +-- .../core/reward/rewards/RankReward.java | 74 +- .../core/scoreboard/MineplexScoreboard.java | 58 +- .../serverConfig/ServerConfiguration.java | 23 +- .../src/mineplex/core/spawn/Spawn.java | 105 --- .../mineplex/core/spawn/SpawnRepository.java | 58 -- .../core/spawn/command/AddCommand.java | 21 - .../core/spawn/command/ClearCommand.java | 21 - .../core/spawn/command/SpawnCommand.java | 29 - .../src/mineplex/core/stats/StatsManager.java | 19 + .../core/stats/command/GiveStatCommand.java | 3 +- .../stats/command/MasterBuilderUnban.java | 6 +- .../core/stats/command/SetLevelCommand.java | 5 +- .../core/stats/command/TimeCommand.java | 3 +- .../core/status/ServerStatusManager.java | 14 +- .../core/task/repository/TaskRepository.java | 7 +- .../core/teamspeak/TeamspeakManager.java | 34 +- .../core/teamspeak/commands/LinkCommand.java | 5 +- .../core/teamspeak/commands/ListCommand.java | 7 +- .../teamspeak/commands/TeamspeakCommand.java | 5 +- .../teamspeak/commands/UnlinkCommand.java | 5 +- .../src/mineplex/core/teleport/Teleport.java | 84 ++- .../mineplex/core/teleport/Teleporter.java | 14 +- .../core/teleport/command/AllCommand.java | 5 +- .../core/teleport/command/BackCommand.java | 25 +- .../core/teleport/command/HereCommand.java | 9 +- .../core/teleport/command/LocateCommand.java | 5 +- .../teleport/command/TeleportCommand.java | 88 ++- .../core/teleport/redis/RedisLocate.java | 6 +- .../teleport/redis/RedisLocateCallback.java | 2 +- .../src/mineplex/core/thank/ThankManager.java | 27 +- .../core/thank/command/ThankCommand.java | 11 +- .../PlayerScoreboard.java | 29 +- .../elements/ScoreboardElementRank.java | 16 +- .../titles/commands/GiveTrackCommand.java | 11 +- .../core/titles/commands/TrackCommand.java | 8 +- .../core/titles/tracks/TrackManager.java | 55 +- .../titles/tracks/custom/DongerTrack.java | 2 +- .../titles/tracks/custom/EarlyBirdTrack.java | 2 +- .../titles/tracks/custom/HappyGaryTrack.java | 14 +- .../titles/tracks/custom/LeaderTrack.java | 10 +- .../core/titles/tracks/custom/SnekTrack.java | 2 +- .../titles/tracks/custom/TableFlipTrack.java | 10 +- .../titles/tracks/custom/TrackBuilder.java | 2 +- .../titles/tracks/custom/WizardTrack.java | 2 +- .../titles/tracks/staff/BuilderTrack.java | 13 +- .../titles/tracks/staff/ModeratorTrack.java | 13 +- .../tracks/staff/SeniorModeratorTrack.java | 14 +- .../titles/tracks/staff/TraineeTrack.java | 12 +- .../core/tournament/DebugShopCommand.java | 5 +- .../core/tournament/TournamentManager.java | 16 +- .../src/mineplex/core/treasure/Treasure.java | 14 +- .../core/twofactor/TwoFactorAuth.java | 30 +- .../mineplex/core/updater/FileUpdater.java | 19 +- .../updater/command/BuildVersionCommand.java | 5 +- .../updater/command/RestartServerCommand.java | 7 +- .../mineplex/core/website/LinkCommand.java | 3 +- .../mineplex/core/website/UnlinkCommand.java | 3 +- .../core/website/WebsiteLinkManager.java | 221 ++++-- .../src/mineplex/enjinTranslator/Enjin.java | 30 +- .../clans/compensation/ClansCompensation.java | 10 + .../compensation/CompensationCommand.java | 3 +- .../src/mineplex/game/clans/Clans.java | 9 +- .../mineplex/game/clans/clans/ClansAdmin.java | 56 +- .../mineplex/game/clans/clans/ClansGame.java | 15 +- .../game/clans/clans/ClansManager.java | 80 ++- .../clans/amplifiers/AmplifierCommand.java | 7 +- .../clans/clans/amplifiers/AmplifierGUI.java | 19 +- .../clans/amplifiers/AmplifierManager.java | 25 +- .../clans/clans/banners/BannerManager.java | 18 +- .../clans/banners/command/BannerCommand.java | 9 +- .../game/clans/clans/boxes/BoxManager.java | 17 +- .../clans/claimview/ClaimVisualizer.java | 16 +- .../commands/ClaimVisualizeCommand.java | 6 +- .../clans/commands/ClanManagementCommand.java | 64 -- .../clans/commands/ClansAllyChatCommand.java | 5 +- .../clans/commands/ClansChatCommand.java | 5 +- .../clans/clans/commands/ClansCommand.java | 51 +- .../clans/commands/ClansLoginManager.java | 98 --- .../clans/clans/commands/KillCommand.java | 3 +- .../game/clans/clans/commands/MapCommand.java | 22 +- .../clans/clans/commands/RegionsCommand.java | 7 +- .../clans/commands/RestartTutCommand.java | 57 -- .../clans/clans/commands/SpeedCommand.java | 24 +- .../clans/freeze/ClansFreezeManager.java | 30 +- .../clans/freeze/commands/FreezeCommand.java | 9 +- .../freeze/commands/UnfreezeCommand.java | 9 +- .../clans/clans/invsee/InvseeManager.java | 16 +- .../clans/invsee/commands/InvseeCommand.java | 24 +- .../clans/invsee/ui/InvseeInventory.java | 2 +- .../game/clans/clans/mounts/MountManager.java | 22 +- .../clans/clans/mounts/gui/MountSkinPage.java | 4 +- .../clans/nameblacklist/ClansBlacklist.java | 17 +- .../commands/AddBlacklistCommand.java | 8 +- .../ClanNameBlacklistRepository.java | 9 +- .../clans/clans/nether/NetherManager.java | 28 +- .../clans/nether/command/CloseCommand.java | 3 +- .../clans/nether/command/CreateCommand.java | 7 +- .../clans/nether/command/DeleteCommand.java | 7 +- .../nether/command/ForceTeleportCommand.java | 9 +- .../clans/nether/command/ListCommand.java | 9 +- .../clans/nether/command/PortalCommand.java | 21 +- .../clans/nether/command/SpawnCommand.java | 3 +- .../clans/nether/command/WandCommand.java | 9 +- .../clans/clans/observer/ObserverData.java | 2 +- .../clans/clans/observer/ObserverManager.java | 30 +- .../clans/observer/ObserverSettings.java | 15 +- .../observer/command/ObserverCommand.java | 11 +- .../clans/clans/playtime/PlayingClient.java | 2 +- .../game/clans/clans/playtime/Playtime.java | 19 +- .../playtime/command/PlayTimeCommand.java | 6 +- .../scoreboard/ClansPlayerScoreboard.java | 9 +- .../scoreboard/ClansScoreboardManager.java | 26 +- .../game/clans/clans/siege/SiegeManager.java | 13 + .../siege/command/GiveWeaponCommand.java | 3 +- .../game/clans/clans/siege/weapon/Cannon.java | 4 +- .../game/clans/clans/war/WarManager.java | 29 +- .../clans/war/command/WarPointsCommand.java | 10 +- .../clans/clans/war/event/WarEndEvent.java | 2 +- .../clans/clans/war/event/WarStartEvent.java | 2 +- .../clans/worldevent/WorldEventManager.java | 17 + .../worldevent/command/ClearCommand.java | 3 +- .../worldevent/command/RandomCommand.java | 3 +- .../worldevent/command/StartCommand.java | 3 +- .../worldevent/command/WorldEventCommand.java | 14 +- .../clans/worldevent/raid/RaidManager.java | 13 + .../raid/command/StartRaidCommand.java | 3 +- .../game/clans/economy/GoldCommand.java | 5 +- .../game/clans/economy/GoldManager.java | 83 +-- .../game/clans/economy/SetGoldCommand.java | 3 +- .../game/clans/fields/FieldBlock.java | 42 +- .../game/clans/fields/FieldMonster.java | 37 +- .../mineplex/game/clans/fields/FieldOre.java | 25 +- .../fields/commands/FieldBlockCommand.java | 5 +- .../fields/commands/FieldMonsterCommand.java | 5 +- .../fields/commands/FieldOreCommand.java | 5 +- .../game/clans/gameplay/DieCommand.java | 21 - .../game/clans/items/GearManager.java | 55 +- .../clans/items/commands/GearCommand.java | 13 +- .../clans/items/commands/RuneCommand.java | 7 +- .../game/clans/legacytutorial/Tutorial.java | 630 ---------------- .../clans/legacytutorial/TutorialClient.java | 40 -- .../clans/legacytutorial/TutorialManager.java | 211 ------ .../clans/legacytutorial/TutorialTask.java | 267 ------- .../commands/DoSkipTutorialCommand.java | 31 - .../commands/SkipTutorialCommand.java | 31 - .../gettingstarted/TaskClaim.java | 42 -- .../gettingstarted/TaskCreateClan.java | 52 -- .../gettingstarted/TaskCustomizeClass.java | 61 -- .../gettingstarted/TaskDisbandClan.java | 41 -- .../gettingstarted/TaskEquipClass.java | 120 ---- .../gettingstarted/TaskExploreShops.java | 92 --- .../gettingstarted/TaskLeaveSpawn.java | 65 -- .../gettingstarted/TaskMakingMoney.java | 72 -- .../gettingstarted/TaskSetHome.java | 44 -- .../gettingstarted/TaskUseAbility.java | 156 ---- .../gettingstarted/TaskViewClanDetails.java | 38 - .../gettingstarted/TaskWelcome.java | 21 - .../TutorialGettingStarted.java | 108 --- .../game/clans/restart/RestartCommand.java | 3 +- .../game/clans/restart/RestartManager.java | 16 + .../clans/texttutorial/ClassTutorial.java | 14 - .../game/clans/tutorial/TutorialManager.java | 47 +- .../clans/tutorial/command/FinishCommand.java | 11 +- .../clans/tutorial/command/StartCommand.java | 11 +- .../tutorial/command/TutorialCommand.java | 18 +- .../mineplex/clanshub/ClansServerPage.java | 6 +- .../clanshub/ClansTransferManager.java | 20 +- .../mineplex/clanshub/ForcefieldManager.java | 39 +- .../src/mineplex/clanshub/HubManager.java | 332 +++++---- .../mineplex/clanshub/HubScoreboardLine.java | 19 + .../clanshub/HubVisibilityManager.java | 30 +- .../mineplex/clanshub/JoinServerButton.java | 10 +- .../clanshub/commands/ForcefieldRadius.java | 7 +- .../clanshub/commands/GadgetToggle.java | 7 +- .../clanshub/commands/GameModeCommand.java | 13 +- .../RankSelectionButton.java | 12 +- .../SalesAnnouncementCommand.java | 3 +- .../SalesAnnouncementCreationPage.java | 23 +- .../SalesAnnouncementData.java | 10 +- .../SalesAnnouncementManager.java | 19 +- .../SalesAnnouncementRepository.java | 51 +- .../src/mineplex/hub/HubManager.java | 171 +++-- .../mineplex/hub/commands/EggAddCommand.java | 3 +- .../hub/commands/ForcefieldRadius.java | 5 +- .../mineplex/hub/commands/GadgetToggle.java | 5 +- .../hub/commands/GameModeCommand.java | 5 +- .../src/mineplex/hub/commands/HorseSpawn.java | 5 +- .../mineplex/hub/commands/NewYearCommand.java | 14 +- .../mineplex/hub/commands/NewsAddCommand.java | 35 +- .../mineplex/hub/commands/NewsCommand.java | 5 +- .../hub/commands/NewsConfirmCommand.java | 5 +- .../hub/commands/NewsDeleteCommand.java | 21 +- .../hub/commands/NewsListCommand.java | 41 +- .../mineplex/hub/commands/NewsSetCommand.java | 34 +- .../hub/modules/AdminMountManager.java | 12 + .../mineplex/hub/modules/AlienInvasion.java | 108 +-- .../mineplex/hub/modules/EasterEggHunt.java | 19 +- .../hub/modules/ForcefieldManager.java | 46 +- .../hub/modules/HubVisibilityManager.java | 40 +- .../src/mineplex/hub/modules/JumpManager.java | 35 +- .../hub/modules/NewYearCountdown.java | 27 +- .../src/mineplex/hub/modules/NewsManager.java | 31 +- .../RankSelectionButton.java | 12 +- .../SalesAnnouncementCommand.java | 3 +- .../SalesAnnouncementCreationPage.java | 23 +- .../SalesAnnouncementData.java | 10 +- .../SalesAnnouncementManager.java | 19 +- .../SalesAnnouncementRepository.java | 51 +- .../hub/notification/NotificationManager.java | 19 +- .../command/NotificationCommand.java | 8 +- .../src/mineplex/hub/server/ServerInfo.java | 4 +- .../mineplex/hub/server/ServerManager.java | 79 +- .../src/mineplex/hub/server/ui/LobbyMenu.java | 8 +- .../mineplex/hub/server/ui/ServerNpcPage.java | 16 +- .../hub/server/ui/ServerTypePage.java | 18 - .../server/ui/button/JoinServerButton.java | 6 +- .../game/classcombat/Class/ClassManager.java | 62 +- .../game/classcombat/Class/ClientClass.java | 29 +- .../classcombat/shop/ClassShopManager.java | 40 +- .../game/classcombat/shop/page/SkillPage.java | 31 +- .../commands/UpdateRankCommand.java | 17 - .../serverdata/database/RepositoryBase.java | 12 + .../src/mineplex/staffServer/StaffServer.java | 13 +- .../customerSupport/CustomerSupport.java | 53 +- .../CustomerSupportRepository.java | 3 +- .../customerSupport/ListPPCCommand.java | 6 +- .../customerSupport/checkBonusCommand.java | 3 +- .../customerSupport/checkCommand.java | 5 +- .../checkOwnsPackageCommand.java | 5 +- .../password/ChangePasswordCommand.java | 23 - .../password/CreatePasswordCommand.java | 24 - .../staffServer/password/Password.java | 112 --- .../staffServer/password/PasswordCommand.java | 24 - .../password/PasswordRepository.java | 66 -- .../password/RemovePasswordCommand.java | 21 - .../salespackage/SalesPackageManager.java | 103 +-- .../salespackage/command/CoinCommand.java | 10 +- .../command/DisplayPackageCommand.java | 5 +- .../command/GemHunterCommand.java | 10 +- .../salespackage/command/HeroCommand.java | 5 +- .../salespackage/command/ItemCommand.java | 15 +- .../salespackage/command/KitsCommand.java | 5 +- .../command/LifetimeEternalCommand.java | 3 +- .../command/LifetimeHeroCommand.java | 5 +- .../command/LifetimeLegendCommand.java | 5 +- .../command/LifetimeTitanCommand.java | 5 +- .../command/LifetimeUltraCommand.java | 5 +- .../salespackage/command/PetCommand.java | 3 +- .../command/PowerPlayCommand.java | 3 +- .../salespackage/command/RankCommand.java | 49 +- .../salespackage/command/Sales.java | 10 +- .../salespackage/command/UltraCommand.java | 5 +- .../nautilus/game/arcade/ArcadeManager.java | 308 +++----- .../game/arcade/broadcast/BroadcastData.java | 97 --- .../arcade/broadcast/BroadcastManager.java | 120 ---- .../broadcast/command/BroadcastCommand.java | 33 - .../broadcast/command/RotateCommand.java | 21 - .../broadcast/command/manage/AddCommand.java | 22 - .../command/manage/RemoveCommand.java | 22 - .../arcade/command/CancelNextGameCommand.java | 11 +- .../arcade/command/GameCmdModeCommand.java | 74 -- .../game/arcade/command/GameCommand.java | 31 +- .../arcade/command/GoToNextGameCommand.java | 11 +- .../game/arcade/command/KitUnlockCommand.java | 7 +- .../command/OpenGameMechPrefsCommand.java | 9 +- .../arcade/command/RequiredRankCommand.java | 54 -- .../game/arcade/command/SetCommand.java | 16 +- .../game/arcade/command/StartCommand.java | 16 +- .../game/arcade/command/StopCommand.java | 14 +- .../game/arcade/command/TauntCommand.java | 9 +- .../game/arcade/command/WriteCommand.java | 21 - .../game/arcade/game/DebugCommand.java | 19 +- .../src/nautilus/game/arcade/game/Game.java | 106 ++- .../game/arcade/game/RankedTeamGame.java | 39 +- .../battleroyale/BattleRoyalePlayer.java | 20 +- .../game/arcade/game/games/bridge/Bridge.java | 5 +- .../game/games/common/CaptureTheFlag.java | 70 +- .../arcade/game/games/event/EventModule.java | 36 +- .../minecraftleague/MinecraftLeague.java | 111 ++- .../commands/DebugCommand.java | 23 - .../commands/MinecraftLeagueCommand.java | 37 - .../commands/StatusCommand.java | 26 - .../commands/freeze/FreezeCommand.java | 40 -- .../commands/freeze/FreezeManager.java | 133 ---- .../commands/panel/AdminPanel.java | 147 ---- .../commands/panel/GUICommand.java | 26 - .../game/arcade/game/games/moba/Moba.java | 62 +- .../game/games/moba/gold/GoldManager.java | 30 +- .../game/games/moba/minion/MinionManager.java | 34 +- .../moba/progression/MobaProgression.java | 38 +- .../games/moba/training/MobaTraining.java | 50 +- .../arcade/game/games/smash/SuperSmash.java | 98 ++- .../games/speedbuilders/SpeedBuilders.java | 186 ++--- .../typewars/StaffKillMonitorManager.java | 25 +- .../arcade/game/games/typewars/TypeWars.java | 499 +++++++------ .../typewars/spells/SpellGrowthLiner.java | 22 +- .../typewars/spells/SpellShrinkLiner.java | 18 +- .../game/arcade/game/games/uhc/UHC.java | 27 +- .../arcade/game/games/wizards/Wizards.java | 160 ++--- .../arcade/game/modules/RejoinModule.java | 9 +- .../gui/privateServer/page/MenuPage.java | 13 +- .../privateServer/page/RemoveAdminPage.java | 19 +- .../gui/privateServer/page/UnbanPage.java | 19 +- .../game/arcade/kit/ProgressingKit.java | 4 +- .../game/arcade/kit/perks/PerkHorsePet.java | 28 +- .../game/arcade/kit/perks/PerkSkeletons.java | 27 +- .../game/arcade/kit/perks/PerkWolfPet.java | 27 +- .../game/arcade/managers/GameFlagManager.java | 162 +++-- .../game/arcade/managers/GameHostManager.java | 270 +++---- .../game/arcade/managers/GameLootManager.java | 143 ++-- .../arcade/managers/GamePlayerManager.java | 16 +- .../arcade/managers/GameRewardManager.java | 124 ++-- .../game/arcade/managers/GameStatManager.java | 20 +- .../arcade/managers/GameTestingManager.java | 293 -------- .../game/arcade/managers/IdleManager.java | 19 +- .../arcade/managers/NextBestGameManager.java | 33 +- .../arcade/managers/ServerUptimeManager.java | 3 - .../arcade/managers/chat/GameChatManager.java | 69 +- .../arcade/managers/lobby/LobbyManager.java | 91 ++- .../src/mineplex/mavericks/review/Hub.java | 3 +- .../review/MavericksReviewManager.java | 4 +- .../mineplex/mavericks/review/ReviewData.java | 38 +- .../mavericks/review/SimpleChatManager.java | 30 +- .../nautilus/game/arcade/ArcadeFormat.java | 3 +- .../src/mineplex/gemhunters/GemHunters.java | 23 +- .../mineplex/gemhunters/chat/ChatModule.java | 13 +- .../gemhunters/economy/CashOutModule.java | 21 +- .../gemhunters/economy/EconomyModule.java | 29 +- .../economy/command/CashOutItemCommand.java | 7 +- .../economy/command/GiveGemsCommand.java | 10 +- .../economy/command/ResetCooldownCommand.java | 10 +- .../mineplex/gemhunters/loot/LootModule.java | 26 +- .../loot/command/SpawnChestCommand.java | 12 +- .../loot/command/UpdateLootCommand.java | 7 +- .../loot/rewards/LootRankReward.java | 49 +- .../gemhunters/map/ItemMapModule.java | 15 + .../gemhunters/map/command/MapCommand.java | 7 +- .../moderation/ModerationModule.java | 41 +- .../command/ModeratorModeCommand.java | 10 +- .../gemhunters/quest/QuestModule.java | 23 +- .../quest/command/ResetQuestsCommand.java | 7 +- .../gemhunters/spawn/SpawnModule.java | 32 +- .../gemhunters/spawn/command/HubCommand.java | 7 +- .../supplydrop/SupplyDropModule.java | 72 +- .../supplydrop/command/EndCommand.java | 7 +- .../supplydrop/command/StartCommand.java | 14 +- .../supplydrop/command/SupplyDropCommand.java | 12 +- .../gemhunters/util/SlackRewardBot.java | 7 +- .../gemhunters/world/DebugListeners.java | 30 - .../gemhunters/world/Leaderboards.java | 4 +- .../mineplex/gemhunters/world/TimeCycle.java | 4 +- .../gemhunters/world/UndergroundMobs.java | 4 +- .../gemhunters/world/WorldDataModule.java | 3 +- .../gemhunters/world/WorldListeners.java | 21 +- .../worldevent/WorldEventModule.java | 24 +- .../worldevent/command/StartCommand.java | 14 +- .../worldevent/command/StopCommand.java | 7 +- .../worldevent/command/WorldEventCommand.java | 12 +- 644 files changed, 10723 insertions(+), 12055 deletions(-) delete mode 100644 Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/Rank.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/command/AddRankCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/command/InfoPlayerCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/command/ListRanksCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/command/RanksCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/command/RemoveRankCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/command/ResetPlayerCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/command/SetRankCommand.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/command/TestRank.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupAddEvent.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupRemoveEvent.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/event/OnlineGroupAddEvent.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/event/OnlineGroupRemoveEvent.java rename Plugins/Mineplex.Core/src/mineplex/core/account/event/{OnlineRankUpdateEvent.java => OnlinePrimaryGroupUpdateEvent.java} (63%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/event/PrimaryGroupUpdateEvent.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/event/RankSaveEvent.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/permissions/GroupPermission.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/redis/AddPermissionGroup.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/redis/AddPermissionGroupHandler.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/redis/ClearGroups.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/redis/ClearGroupsHandler.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/redis/PrimaryGroupUpdate.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/redis/PrimaryGroupUpdateHandler.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/redis/RemovePermissionGroup.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/redis/RemovePermissionGroupHandler.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/creature/command/HelpCommand.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronosData.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/SendCommand.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/portal/commands/SendCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/portal/commands/ServerCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestData.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/spawn/Spawn.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/spawn/command/AddCommand.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/spawn/command/ClearCommand.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/spawn/command/SpawnCommand.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClanManagementCommand.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DieCommand.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialClient.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialManager.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialTask.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/commands/DoSkipTutorialCommand.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/commands/SkipTutorialCommand.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskClaim.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskCreateClan.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskCustomizeClass.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskDisbandClan.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskEquipClass.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskExploreShops.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskLeaveSpawn.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskMakingMoney.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskSetHome.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskUseAbility.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskViewClanDetails.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskWelcome.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TutorialGettingStarted.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/texttutorial/ClassTutorial.java create mode 100644 Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubScoreboardLine.java delete mode 100644 Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/UpdateRankCommand.java delete mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/ChangePasswordCommand.java delete mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/CreatePasswordCommand.java delete mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/Password.java delete mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordCommand.java delete mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java delete mode 100644 Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/RemovePasswordCommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastData.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastManager.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/BroadcastCommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/RotateCommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/AddCommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/RemoveCommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCmdModeCommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/RequiredRankCommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/WriteCommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DebugCommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/StatusCommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeCommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeManager.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/GUICommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTestingManager.java delete mode 100644 Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/DebugListeners.java diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/Rank.java deleted file mode 100644 index 9b2a37f9a..000000000 --- a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/Rank.java +++ /dev/null @@ -1,166 +0,0 @@ -package mineplex.core.common; - -import org.bukkit.ChatColor; -import org.bukkit.DyeColor; -import org.bukkit.entity.Player; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayerBase; - -public enum Rank -{ - //Staff - LT("Leader", "lt", ChatColor.DARK_RED, "Leaders manage the operation of their respective team \nor projects. They usually operate on affairs within \nthe staff, development, or management team.", 11, DyeColor.RED), - OWNER("Owner", "owner", ChatColor.DARK_RED, "Owners are the founders of Mineplex. \nEach owner manages a different aspect of the \nserver and ensures its efficient operation.", 55, DyeColor.RED), - DEVELOPER("Dev", "dev", ChatColor.DARK_RED, "Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", 5, DyeColor.RED), - ADMIN("Admin", "adm", ChatColor.DARK_RED, "An Administrator’s role is to manage \ntheir respective Senior Moderator team \nand all moderators within it.", 10, DyeColor.RED), - JNR_DEV("Jr.Dev", "jrdev", ChatColor.GOLD, "Junior Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", -1, DyeColor.ORANGE), - SUPPORT("Support", "spp", ChatColor.BLUE, "Support agents handle tickets and \nprovide customer service.", 47, DyeColor.BLUE), - CMOD("C.Mod", "cmod", ChatColor.GOLD, "Clans Moderators are members of the Clans Management Senior Mod team. \nTheir duties include moderation and support within the Clans servers. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), - EVENT_MODERATOR("Sr.Mod", "srmod_event", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 44, DyeColor.ORANGE), - SNR_MODERATOR("Sr.Mod", "srmod", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 44, DyeColor.ORANGE), - CMA("Mod", "mod_cma", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), - MODERATOR("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32, DyeColor.ORANGE), - HELPER("Trainee", "train", ChatColor.GOLD, "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 24, DyeColor.ORANGE), - MAPLEAD("MapLead", "mapl", ChatColor.BLUE, "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders.", 25, DyeColor.BLUE), - MAPPER("Mapper", "mapp", ChatColor.BLUE, "These senior staff members work closely with \nthe development and design teams to build new \nmaps for new and old content!", 100, DyeColor.BLUE), - MAPDEV("Builder", "mapd", ChatColor.BLUE, "These creative staff members help \nbuild maps for your favorite games!", 26, DyeColor.BLUE), - MEDIA("Media", "media", ChatColor.BLUE, "The Media rank is given to talented artists who are\n endorsed to create content for Mineplex.", -1, DyeColor.BLUE), - - EVENT("Event", "evnt", ChatColor.WHITE, "A member of the official Mineplex Events team!", -1, DyeColor.WHITE), - - //Media - YOUTUBE("YouTube", "yt", ChatColor.RED, "A YouTuber who creates content for \nor related to Mineplex.", 22, DyeColor.RED), - YOUTUBE_SMALL("YT", "ytsm", ChatColor.DARK_PURPLE, "A YouTuber who creates content for \nor related to Mineplex. \n\nThey have fewer subscribers than full YouTubers.", 20, DyeColor.PURPLE), - TWITCH("Twitch", "tw", ChatColor.DARK_PURPLE, "A Twitch streamer who often features \nMineplex in their streams.", 21, DyeColor.PURPLE), - - //Player - ETERNAL("Eternal", "et", ChatColor.DARK_AQUA, true, "Fantastic and magical, no one \nexcept the time lords truly understand \nthe power of this rank.\n\nThe fifth purchasable rank at Mineplex.com/shop", 18, DyeColor.CYAN), - TITAN("Titan", "t", ChatColor.RED, true, "Ancient myths spoke of a gigantic being \nwith immense power... \n\nThe fourth purchasable rank at Mineplex.com/shop", 15, DyeColor.RED), - LEGEND("Legend", "l", ChatColor.GREEN, true, "Years they have told stories of this rank, \nonly for the legends to be true. \n\nThe third purchasable rank at Mineplex.com/shop", 14, DyeColor.GREEN), - HERO("Hero", "h", ChatColor.LIGHT_PURPLE, true, "There are many stories of a \nvaliant Hero who was brave enough to \ntame the most fearsome dragon in the land. \n\nThe second purchasable rank at Mineplex.com/shop", 13, DyeColor.MAGENTA), - ULTRA("Ultra", "u", ChatColor.AQUA, true, "A first step into the stories of the mist. \nOnly those brave enough may enter. \n\nThe first purchasable rank at Mineplex.com/shop", 12, DyeColor.LIGHT_BLUE), - ALL("", "", ChatColor.WHITE, null, -1, DyeColor.WHITE); - - private ChatColor _color; - private boolean _donor; - private String _description; - private int _forumId; - private DyeColor _dyeColor; - - public String Name; - public String ScoreboardTag; - - Rank(String name, String scoreboardTag, ChatColor color, String description, int forumId, DyeColor dyeColor) - { - _color = color; - Name = name; - _donor = false; - _description = description; - ScoreboardTag = scoreboardTag; - _forumId = forumId; - _dyeColor = dyeColor; - } - - Rank(String name, String scoreboardTag, ChatColor color, boolean donor, String description, int forumId, DyeColor dyeColor) - { - _color = color; - Name = name; - _donor = donor; - _description = description; - ScoreboardTag = scoreboardTag; - _forumId = forumId; - _dyeColor = dyeColor; - } - - public String getDescription() - { - return _description; - } - - public void setName(String name) - { - Name = name; - } - - public String getRawTag() - { - if (Name.equalsIgnoreCase("ALL")) - return ""; - - return Name; - } - - public boolean has(Rank rank) - { - return has(null, rank, false); - } - - public boolean has(Player player, Rank rank, boolean inform) - { - return has(player, rank, null, inform); - } - - public boolean has(Player player, Rank rank, Rank[] specific, boolean inform) - { - //Specific Rank - if (specific != null) - { - for (Rank curRank : specific) - { - if (compareTo(curRank) == 0) - { - return true; - } - } - } - - // - if (compareTo(rank) <= 0) - return true; - - if (inform) - { - UtilPlayerBase.message(player, C.mHead + "Permissions> " + - C.mBody + "This requires Permission Rank [" + - C.mHead + rank.Name.toUpperCase() + - C.mBody + "]."); - } - - return false; - } - - public String getTag(boolean bold, boolean uppercase) - { - if (Name.equalsIgnoreCase("ALL")) - return ""; - - String name = Name; - if (uppercase) - name = Name.toUpperCase(); - - if (bold) return _color + C.Bold + name; - else return _color + name; - } - - public ChatColor getColor() - { - return _color; - } - - public boolean isDonor() - { - return _donor; - } - - public int getForumId() - { - return _forumId; - } - - public DyeColor getDyeColor() - { - return _dyeColor; - } -} diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/F.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/F.java index 4240b9a9b..5ecc513b3 100644 --- a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/F.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/F.java @@ -2,7 +2,6 @@ package mineplex.core.common.util; import org.bukkit.ChatColor; -import mineplex.core.common.Rank; import mineplex.core.common.currency.Currency; public class F @@ -103,23 +102,10 @@ public class F { return C.wFrame + "[" + C.wField + field + C.wFrame + "] " + C.mBody + data + " "; } - - public static String help(String cmd, String body, Rank rank) - { - return rank.getColor() + cmd + " " + C.mBody + body + " " + rank(rank); - } - public static String help(String cmd, String body, Rank rank, ChatColor displayColor) + public static String help(String cmd, String body, ChatColor displayColor) { - return displayColor + cmd + " " + C.mBody + body + " " + rank(rank); - } - - public static String rank(Rank rank) - { - if (rank == Rank.ALL) - return rank.getColor() + "Player"; - - return rank.getTag(false, false); + return displayColor + cmd + " " + C.mBody + body; } public static String value(String variable, int value) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java index 2fe11c085..c671b55df 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/PlayerSelector.java @@ -1,20 +1,21 @@ package mineplex.core; -import mineplex.core.account.CoreClient; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilMath; -import mineplex.core.incognito.IncognitoManager; +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; +import java.util.function.Predicate; +import java.util.stream.Collectors; + import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; -import java.util.List; -import java.util.concurrent.ThreadLocalRandom; -import java.util.function.Predicate; -import java.util.stream.Collectors; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.common.util.UtilMath; +import mineplex.core.incognito.IncognitoManager; /** * A helper for selecting arbitrary players given a set of conditions @@ -74,13 +75,13 @@ public class PlayerSelector public static final Predicate NOT_SPECTATING = player -> player.getGameMode() != GameMode.SPECTATOR; /** - * This condition will return true if the player has one of the given ranks + * This condition will return true if the player has one of the given ranks as their primary * * @param useDisguisedRank Whether to use the disguised rank of the player should they be disguised * @param ranks The ranks to check * @return The resulting criterion */ - public static Predicate hasAnyRank(boolean useDisguisedRank, Rank... ranks) + public static Predicate hasAnyRank(boolean useDisguisedRank, PermissionGroup... groups) { return player -> { @@ -90,11 +91,11 @@ public class PlayerSelector return true; } CoreClient client = coreClientManager.Get(player); - Rank rank = useDisguisedRank ? client.getRealOrDisguisedRank() : client.GetRank(); + PermissionGroup group = useDisguisedRank ? client.getRealOrDisguisedPrimaryGroup() : client.getPrimaryGroup(); - for (Rank requiredRank : ranks) + for (PermissionGroup requiredGroup : groups) { - if (rank == requiredRank) + if (group.getIdentifier().equals(requiredGroup.getIdentifier())) { return true; } @@ -119,4 +120,4 @@ public class PlayerSelector { return player -> UtilMath.offset(player.getLocation(), center) <= radius; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java index 71c935918..46416bd1e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java @@ -1,15 +1,15 @@ package mineplex.core.account; -import mineplex.core.account.event.OnlineRankUpdateEvent; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilPlayer; -import mineplex.serverdata.Utility; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import java.util.UUID; +import mineplex.core.Managers; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.serverdata.Utility; public class CoreClient { @@ -18,8 +18,8 @@ public class CoreClient private String _name; private UUID _uuid; private Player _player; - private Rank _rank, _lastRank; - private Rank _tempRank, _lastTemp; + private PermissionGroup _primary, _lastPrimary; + private Set _extra = new HashSet<>(); /* * Disguise info @@ -27,7 +27,7 @@ public class CoreClient private String _disguisedName; private String _disguisedSkin; private UUID _disguisedUUID; - private Rank _disguisedRank; + private PermissionGroup _disguisedPrimary; public CoreClient(Player player) { @@ -72,60 +72,73 @@ public class CoreClient { _accountId = accountId; } - - public Rank GetRank() + + protected PermissionGroup getRawPrimaryGroup() { - return GetRank(false); + return _primary; } - public Rank GetRank(boolean bypass) + public PermissionGroup getPrimaryGroup() { - if (_rank == null) - _rank = Rank.ALL; - - if (bypass || _tempRank == null) - return _rank; - else - return _tempRank; - } - - public Rank GetLastRank(boolean temp) - { - if (temp) + if (_primary == null) { - if ((_lastTemp == null) && (_tempRank == null)) - { - return _rank; - } - else if (_lastTemp == null) - { - return _tempRank; - } - return _lastTemp; + _primary = Managers.get(CoreClientManager.class).getPermissionManager().getGroup("player"); + } + + return _primary; + } + + public Set getAdditionalGroups() + { + return _extra; + } + + public PermissionGroup getLastPrimaryGroup() + { + if (_lastPrimary == null) + { + return _primary; + } + + return _lastPrimary; + } + + public boolean isMemberOf(PermissionGroup group) + { + if (_extra.contains(group)) + { + return true; + } + + return group.equals(_primary); + } + + public void setPrimaryGroup(PermissionGroup group) + { + if (_primary != null) + { + _lastPrimary = _primary; } else { - if (_lastRank == null) return _rank; - return _lastRank; + _lastPrimary = group; } + + _primary = group; } - public void SetRank(Rank rank, boolean temp) + public void addAdditionalGroup(PermissionGroup group) { - if (temp) + if (!isMemberOf(group)) { - if (_lastTemp == null) _lastTemp = rank; - else _lastTemp = _tempRank; - _lastRank = _rank; - _tempRank = rank; - } - else - { - if (_rank != null) _lastRank = _rank; - else _lastRank = rank; - _rank = rank; + _extra.add(group); } } + + public void removeAdditionalGroup(PermissionGroup group) + { + _extra.remove(group); + } public long getNetworkSessionLoginTime() { @@ -136,7 +149,8 @@ public class CoreClient { _disguisedName = null; _disguisedSkin = null; - _disguisedRank = null; + _lastPrimary = _disguisedPrimary; + _disguisedPrimary = null; _disguisedUUID = null; } @@ -150,9 +164,9 @@ public class CoreClient return _disguisedSkin; } - public Rank getDisguisedRank() + public PermissionGroup getDisguisedPrimaryGroup() { - return _disguisedRank; + return _disguisedPrimary; } public UUID getDisguisedAsUUID() @@ -169,20 +183,28 @@ public class CoreClient return !_name.equalsIgnoreCase(_disguisedName); } - public void disguise(String name, UUID uuid, Rank rank) + public void disguise(String name, UUID uuid, PermissionGroup group) { _disguisedName = name; _disguisedUUID = uuid; - _disguisedRank = rank; + _disguisedPrimary = group; + if (_primary != null) + { + _lastPrimary = _primary; + } + else + { + _lastPrimary = group; + } } - public Rank getRealOrDisguisedRank() + public PermissionGroup getRealOrDisguisedPrimaryGroup() { - if (_disguisedRank != null) + if (_disguisedPrimary != null) { - return _disguisedRank; + return _disguisedPrimary; } - return GetRank(); + return getPrimaryGroup(); } public void setNetworkSessionLoginTime(long loginTime) @@ -190,22 +212,12 @@ public class CoreClient _networkSessionLoginTime = loginTime; } - public void resetTemp() - { - if (_tempRank != null) - { - OnlineRankUpdateEvent event = new OnlineRankUpdateEvent(_player, _tempRank, _rank, true); - Bukkit.getPluginManager().callEvent(event); - _lastTemp = _tempRank; - _tempRank = null; - UtilPlayer.message(_player, C.cGold + "Your test rank has been reset!"); - } - } - public String getRealOrDisguisedName() { if (getDisguisedAs() != null) + { return getDisguisedAs(); + } return getName(); } @@ -217,7 +229,8 @@ public class CoreClient ", _name='" + _name + '\'' + ", _uuid=" + _uuid + ", _player=" + _player + - ", _rank=" + _rank + + ", _primary=" + _primary + + ", _extra=[" + _extra.stream().map(PermissionGroup::toString).collect(Collectors.joining(", ")) + "]" + '}'; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 30d4ae905..34752c9ef 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -8,15 +8,16 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; +import java.util.stream.Collectors; import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -33,33 +34,57 @@ import com.google.gson.Gson; import mineplex.cache.player.PlayerCache; import mineplex.cache.player.PlayerInfo; import mineplex.core.MiniPlugin; -import mineplex.core.account.command.TestRank; -import mineplex.core.account.command.UpdateRank; +import mineplex.core.account.command.RanksCommand; import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.account.event.ClientWebResponseEvent; -import mineplex.core.account.event.RankSaveEvent; +import mineplex.core.account.event.OnlineGroupAddEvent; +import mineplex.core.account.event.OnlineGroupRemoveEvent; +import mineplex.core.account.event.OnlinePrimaryGroupUpdateEvent; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; +import mineplex.core.account.redis.AddPermissionGroup; +import mineplex.core.account.redis.AddPermissionGroupHandler; +import mineplex.core.account.redis.ClearGroups; +import mineplex.core.account.redis.ClearGroupsHandler; +import mineplex.core.account.redis.PrimaryGroupUpdate; +import mineplex.core.account.redis.PrimaryGroupUpdateHandler; +import mineplex.core.account.redis.RemovePermissionGroup; +import mineplex.core.account.redis.RemovePermissionGroupHandler; import mineplex.core.account.repository.AccountRepository; import mineplex.core.account.repository.token.ClientToken; -import mineplex.core.common.Rank; +import mineplex.core.common.Pair; import mineplex.core.common.timing.TimingManager; import mineplex.core.common.util.Callback; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTasks; +import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilGameProfile; import mineplex.core.utils.UtilScheduler; +import mineplex.serverdata.commands.ServerCommandManager; public class CoreClientManager extends MiniPlugin { + public static final String JOIN_FULL_PERMISSION = "mineplex.core.account.joinfull"; + public static final String RANK_COMMAND_PERMISSION = "mineplex.core.account.rankcommand"; + public static final String ADD_RANK_COMMAND_PERMISSION = "mineplex.core.account.addrank"; + public static final String RANK_INFO_COMMAND_PERMISSION = "mineplex.core.account.rankinfo"; + public static final String LIST_RANKS_COMMAND_PERMISSION = "mineplex.core.account.listranks"; + public static final String REMOVE_RANK_COMMAND_PERMISSION = "mineplex.core.account.removerank"; + public static final String RESET_PLAYER_COMMAND_PERMISSION = "mineplex.core.account.resetplayer"; + public static final String SET_RANK_COMMAND_PERMISSION = "mineplex.core.account.setrank"; + private static final Map CLIENT_LOGIN_LOCKS = new ConcurrentHashMap<>(); private JavaPlugin _plugin; private AccountRepository _repository; + private PermissionManager _perm; private Map _clientList = new HashMap<>(); - private HashSet _duplicateLoginGlitchPreventionList = new HashSet<>(); + private Set _duplicateLoginGlitchPreventionList = new HashSet<>(); private List _loginProcessors = new ArrayList<>(); @@ -68,30 +93,45 @@ public class CoreClientManager extends MiniPlugin private static AtomicInteger _clientsConnecting = new AtomicInteger(0); private static AtomicInteger _clientsProcessing = new AtomicInteger(0); - private final Rank WHITELIST_BYPASS; - private final Set _reservedSlots = Sets.newConcurrentHashSet(); public CoreClientManager(JavaPlugin plugin) - { - this(plugin, Rank.MODERATOR); - } - - public CoreClientManager(JavaPlugin plugin, Rank whitelistBypass) { super("Client Manager", plugin); _plugin = plugin; _repository = new AccountRepository(); - WHITELIST_BYPASS = whitelistBypass; + _perm = new PermissionManager(plugin, this); UtilScheduler.runEvery(UpdateType.TICK, this::checkForIllegalAccounts); + + ServerCommandManager.getInstance().registerCommandType(AddPermissionGroup.class, new AddPermissionGroupHandler(this)); + ServerCommandManager.getInstance().registerCommandType(ClearGroups.class, new ClearGroupsHandler(this)); + ServerCommandManager.getInstance().registerCommandType(PrimaryGroupUpdate.class, new PrimaryGroupUpdateHandler(this)); + ServerCommandManager.getInstance().registerCommandType(RemovePermissionGroup.class, new RemovePermissionGroupHandler(this)); + + generatePermissions(); + } + + private void generatePermissions() + { + _perm.setPermission(_perm.getGroup("ultra"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + _perm.setPermission(_perm.getGroup("admin"), GroupPermission.of(RANK_COMMAND_PERMISSION), true, true); + _perm.setPermission(_perm.getGroup("admin"), GroupPermission.of(ADD_RANK_COMMAND_PERMISSION), true, true); + _perm.setPermission(_perm.getGroup("admin"), GroupPermission.of(RANK_INFO_COMMAND_PERMISSION), true, true); + _perm.setPermission(_perm.getGroup("admin"), GroupPermission.of(LIST_RANKS_COMMAND_PERMISSION), true, true); + _perm.setPermission(_perm.getGroup("admin"), GroupPermission.of(REMOVE_RANK_COMMAND_PERMISSION), true, true); + _perm.setPermission(_perm.getGroup("admin"), GroupPermission.of(RESET_PLAYER_COMMAND_PERMISSION), true, true); + _perm.setPermission(_perm.getGroup("admin"), GroupPermission.of(SET_RANK_COMMAND_PERMISSION), true, true); } - private void checkForIllegalAccounts() { + private void checkForIllegalAccounts() + { // Use getOnlinePlayers because in the future, I might change UtilServer.getPlayers to account for vanish - for (Player player : Bukkit.getOnlinePlayers()) { - if (Get(player).getAccountId() == -1) { + for (Player player : Bukkit.getOnlinePlayers()) + { + if (Get(player).getAccountId() == -1) + { // ew ew getim outta here player.kickPlayer("There was a problem logging you in"); } @@ -102,12 +142,16 @@ public class CoreClientManager extends MiniPlugin { return _repository; } + + public PermissionManager getPermissionManager() + { + return _perm; + } @Override public void addCommands() { - addCommand(new UpdateRank(this)); - addCommand(new TestRank(this)); + addCommand(new RanksCommand(this)); } public CoreClient Add(String name, UUID uuid) @@ -209,7 +253,9 @@ public class CoreClientManager extends MiniPlugin _clientsProcessing.incrementAndGet(); if (!LoadClient(Add(event.getName(), event.getUniqueId()), event.getUniqueId(), event.getAddress().getHostAddress())) + { event.disallow(Result.KICK_OTHER, "There was a problem logging you in."); + } } catch (Exception exception) { @@ -220,19 +266,6 @@ public class CoreClientManager extends MiniPlugin { _clientsProcessing.decrementAndGet(); } - - if (Bukkit.hasWhitelist() && !Get(event.getUniqueId()).GetRank().has(WHITELIST_BYPASS)) - { - for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) - { - if (player.getName().equalsIgnoreCase(event.getName())) - { - return; - } - } - - event.disallow(Result.KICK_WHITELIST, "You are not whitelisted my friend."); - } } finally { @@ -280,8 +313,23 @@ public class CoreClientManager extends MiniPlugin } CoreClient client = Add(token.Name, uuid); - client.SetRank(Rank.valueOf(token.Rank), false); - client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName())); + Pair>> result = _repository.login(_loginProcessors, uuid, client.getName()); + + client.setAccountId(result.getLeft().intValue()); + if (result.getRight().getLeft() == null) + { + PermissionGroup newGroup = _perm.getGroupFromLegacy(token.Rank); + client.setPrimaryGroup(newGroup); + _repository.setPrimaryGroup(client.getAccountId(), newGroup.getIdentifier(), null); + } + else + { + client.setPrimaryGroup(_perm.getGroup(result.getRight().getLeft())); + } + for (String id : result.getRight().getRight()) + { + client.addAdditionalGroup(_perm.getGroup(id)); + } Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); @@ -323,9 +371,7 @@ public class CoreClientManager extends MiniPlugin if (uuid == null) { - uuid = UtilGameProfile.getProfileByName(playerName, false, profile -> - { - }).get().getId(); + uuid = UtilGameProfile.getProfileByName(playerName, false, profile -> {}).get().getId(); } String response = ""; @@ -342,8 +388,23 @@ public class CoreClientManager extends MiniPlugin token = gson.fromJson(response, ClientToken.class); CoreClient client = Add(playerName, uuid); - client.SetRank(Rank.valueOf(token.Rank), false); - client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName())); + Pair>> result = _repository.login(_loginProcessors, uuid, client.getName()); + + client.setAccountId(result.getLeft().intValue()); + if (result.getRight().getLeft() == null) + { + PermissionGroup newGroup = _perm.getGroupFromLegacy(token.Rank); + client.setPrimaryGroup(newGroup); + _repository.setPrimaryGroup(client.getAccountId(), newGroup.getIdentifier(), null); + } + else + { + client.setPrimaryGroup(_perm.getGroup(result.getRight().getLeft())); + } + for (String id : result.getRight().getRight()) + { + client.addAdditionalGroup(_perm.getGroup(id)); + } // JSON sql response Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); @@ -402,8 +463,23 @@ public class CoreClientManager extends MiniPlugin token = gson.fromJson(response, ClientToken.class); CoreClient client = Add(playerName, uuid); - client.SetRank(Rank.valueOf(token.Rank), false); - client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName())); + Pair>> result = _repository.login(_loginProcessors, uuid, client.getName()); + + client.setAccountId(result.getLeft().intValue()); + if (result.getRight().getLeft() == null) + { + PermissionGroup newGroup = _perm.getGroupFromLegacy(token.Rank); + client.setPrimaryGroup(newGroup); + _repository.setPrimaryGroup(client.getAccountId(), newGroup.getIdentifier(), null); + } + else + { + client.setPrimaryGroup(_perm.getGroup(result.getRight().getLeft())); + } + for (String id : result.getRight().getRight()) + { + client.addAdditionalGroup(_perm.getGroup(id)); + } // JSON sql response Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); @@ -436,25 +512,32 @@ public class CoreClientManager extends MiniPlugin long timeStart = System.currentTimeMillis(); CLIENT_LOGIN_LOCKS.put(client.getName(), new Object()); - ClientToken token = null; Gson gson = new Gson(); - runAsync(new Runnable() + runAsync(() -> { - @Override - public void run() + try { - try + Pair>> result = _repository.login(_loginProcessors, uuid, client.getName()); + client.setAccountId(result.getLeft().intValue()); + if (result.getRight().getLeft() == null) { - client.setAccountId(_repository.login(_loginProcessors, uuid, client.getName())); + client.setPrimaryGroup(null); } - catch (SQLException e) + else { - // TODO Auto-generated catch block - e.printStackTrace(); + client.setPrimaryGroup(_perm.getGroup(result.getRight().getLeft())); + } + for (String id : result.getRight().getRight()) + { + client.addAdditionalGroup(_perm.getGroup(id)); } - CLIENT_LOGIN_LOCKS.remove(client.getName()); } + catch (SQLException e) + { + e.printStackTrace(); + } + CLIENT_LOGIN_LOCKS.remove(client.getName()); }); TimingManager.start(client.getName() + " GetClient."); @@ -462,11 +545,6 @@ public class CoreClientManager extends MiniPlugin TimingManager.stop(client.getName() + " GetClient."); TimingManager.start(client.getName() + " Event."); - token = gson.fromJson(response, ClientToken.class); - - client.SetRank(Rank.valueOf(token.Rank), false); - - // _repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString()); // JSON sql response Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); @@ -490,6 +568,16 @@ public class CoreClientManager extends MiniPlugin { System.out.println("MYSQL TOO LONG TO LOGIN...."); } + + ClientToken token = gson.fromJson(response, ClientToken.class); + + if (client.getRawPrimaryGroup() == null) + { + String mssqlRank = token.Rank; + PermissionGroup newGroup = _perm.getGroupFromLegacy(mssqlRank); + client.setPrimaryGroup(newGroup); + _repository.setPrimaryGroup(client.getAccountId(), newGroup.getIdentifier(), null); + } TimingManager.stop(client.getName() + " LoadClient Total."); @@ -520,7 +608,7 @@ public class CoreClientManager extends MiniPlugin CoreClient client = Get(event.getPlayer().getUniqueId()); - if (client == null || client.GetRank() == null) + if (client == null || client.getRawPrimaryGroup() == null) { event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "There was an error logging you in. Please reconnect."); return; @@ -533,7 +621,7 @@ public class CoreClientManager extends MiniPlugin // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() + _reservedSlots.size() >= Bukkit.getServer().getMaxPlayers()) { - if (client.GetRank().has(event.getPlayer(), Rank.ULTRA, false)) + if (_perm.hasPermission(client, GroupPermission.of(JOIN_FULL_PERMISSION))) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); @@ -546,7 +634,7 @@ public class CoreClientManager extends MiniPlugin public void reserveFor(UUID player) { - this._reservedSlots.add(player); + _reservedSlots.add(player); } public void unreserve(UUID uuid) @@ -560,14 +648,14 @@ public class CoreClientManager extends MiniPlugin if (event.getReason().contains("You logged in from another location")) { _duplicateLoginGlitchPreventionList.add(event.getPlayer().getUniqueId()); - Bukkit.getScheduler().runTask(_plugin, new Runnable() + Bukkit.getScheduler().runTask(_plugin, () -> { - public void run() + if (!_clientList.containsKey(event.getPlayer().getUniqueId())) { - if (!_clientList.containsKey(event.getPlayer().getUniqueId())) return; - Player p = _clientList.get(event.getPlayer().getUniqueId()).GetPlayer(); - p.kickPlayer("You're already logged in."); + return; } + Player p = _clientList.get(event.getPlayer().getUniqueId()).GetPlayer(); + p.kickPlayer("You're already logged in."); }); } } @@ -589,108 +677,232 @@ public class CoreClientManager extends MiniPlugin _duplicateLoginGlitchPreventionList.remove(event.getPlayer().getUniqueId()); } } - - public void SaveRank(final String name, final UUID uuid, Rank rank, boolean perm) + + public void setPrimaryGroup(Player player, final PermissionGroup group, Runnable after) { - _repository.saveRank(new Callback() + setPrimaryGroup(Get(player).getAccountId(), group, () -> { - public void run(Rank newRank) + PermissionGroup old = Get(player).getPrimaryGroup(); + Get(player).setPrimaryGroup(group); + UtilServer.CallEvent(new OnlinePrimaryGroupUpdateEvent(player, old, group)); + if (after != null) { - if (_plugin.getServer().getPlayer(name) != null) - { - CoreClient client = Get(name); - - client.SetRank(newRank, false); - } - UtilServer.CallEvent(new RankSaveEvent(uuid, newRank)); + after.run(); } - }, name, uuid, rank, perm); + }); } - - public void SaveRank(final Callback callback, final String name, final UUID uuid, Rank rank, boolean perm) + + public void setPrimaryGroup(final int accountId, final PermissionGroup group, Runnable after) { - _repository.saveRank(new Callback() + _repository.setPrimaryGroup(accountId, group.getIdentifier(), after); + } + + public void addAdditionalGroup(Player player, final PermissionGroup group, Consumer successCallback) + { + addAdditionalGroup(Get(player).getAccountId(), group, success -> { - public void run(Rank newRank) + if (success.booleanValue()) { - if (_plugin.getServer().getPlayer(name) != null) - { - CoreClient client = Get(name); - - client.SetRank(newRank, false); - } - - if (callback != null) - callback.run(newRank); - - UtilServer.CallEvent(new RankSaveEvent(uuid, newRank)); + Get(player).addAdditionalGroup(group); + UtilServer.CallEvent(new OnlineGroupAddEvent(player, group)); } - }, name, uuid, rank, perm); + if (successCallback != null) + { + successCallback.accept(success); + } + }); + } + + public void addAdditionalGroup(final int accountId, final PermissionGroup group, Consumer successCallback) + { + _repository.addAdditionalGroup(accountId, group.getIdentifier(), success -> + { + if (successCallback != null) + { + successCallback.accept(success); + } + if (!success.booleanValue()) + { + System.out.println("Error adding additional group " + group.getIdentifier() + " to account " + accountId + "!"); + } + }); + } + + public void removeAdditionalGroup(Player player, final PermissionGroup group, Consumer successCallback) + { + removeAdditionalGroup(Get(player).getAccountId(), group, success -> + { + if (success.booleanValue()) + { + Get(player).removeAdditionalGroup(group); + UtilServer.CallEvent(new OnlineGroupRemoveEvent(player, group)); + } + if (successCallback != null) + { + successCallback.accept(success); + } + }); + } + + public void removeAdditionalGroup(final int accountId, final PermissionGroup group, Consumer successCallback) + { + _repository.removeAdditionalGroup(accountId, group.getIdentifier(), success -> + { + if (successCallback != null) + { + successCallback.accept(success); + } + if (!success.booleanValue()) + { + System.out.println("Error removing additional group " + group.getIdentifier() + " from account " + accountId + "!"); + } + }); + } + + public void clearGroups(Player player, Consumer successCallback) + { + clearGroups(Get(player).getAccountId(), success -> + { + if (success.booleanValue()) + { + PermissionGroup old = Get(player).getPrimaryGroup(); + Set cleared = Sets.newHashSet(Get(player).getAdditionalGroups()); + Get(player).setPrimaryGroup(_perm.getGroup("player")); + Get(player).getAdditionalGroups().clear(); + UtilServer.CallEvent(new OnlinePrimaryGroupUpdateEvent(player, old, _perm.getGroup("player"))); + for (PermissionGroup clr : cleared) + { + UtilServer.CallEvent(new OnlineGroupRemoveEvent(player, clr)); + } + } + if (successCallback != null) + { + successCallback.accept(success); + } + }); + } + + public void clearGroups(final int accountId, Consumer successCallback) + { + _repository.clearGroups(accountId, success -> + { + if (successCallback != null) + { + successCallback.accept(success); + } + if (!success.booleanValue()) + { + System.out.println("Error clearing groups from account " + accountId + "!"); + } + }); + } + + public void fetchGroups(final int accountId, Consumer>> resultCallback, Runnable onError) + { + _repository.fetchGroups(accountId, pair -> + { + AtomicReference primaryReference = new AtomicReference<>(); + UUID uuid; + if (pair.getLeft() == null && (uuid = _repository.getClientUUID(accountId)) != null) + { + runAsync(() -> + { + String legacy = loadOfflineClient(uuid).Rank; + PermissionGroup defaultGroup = _perm.getGroup("player"); + PermissionGroup loaded = _perm.getGroupFromLegacy(legacy); + if (loaded == null) + { + primaryReference.compareAndSet(null, defaultGroup); + } + else + { + primaryReference.compareAndSet(null, loaded); + } + }); + long start = System.currentTimeMillis(); + while (primaryReference.get() == null && !UtilTime.elapsed(start, 5000)) {} + primaryReference.compareAndSet(null, _perm.getGroup("player")); + } + else + { + PermissionGroup defaultGroup = _perm.getGroup("player"); + PermissionGroup loaded = _perm.getGroup(pair.getLeft()); + if (loaded == null) + { + primaryReference.set(defaultGroup); + } + else + { + primaryReference.set(loaded); + } + } + final Set additional = pair.getRight().stream().map(_perm::getGroup).filter(Objects::nonNull).collect(Collectors.toSet()); + + UtilServer.runSync(() -> resultCallback.accept(Pair.create(primaryReference.get(), additional))); + }, () -> + { + if (onError != null) + { + onError.run(); + } + System.out.println("Error fetching groups of account " + accountId + "!"); + }); } public void checkPlayerNameExact(final Callback callback, final String playerName) { - _repository.matchPlayerName(new Callback>() + _repository.matchPlayerName(matches -> { - public void run(List matches) + for (String match : matches) { - for (String match : matches) + if (match.equalsIgnoreCase(playerName)) { - if (match.equalsIgnoreCase(playerName)) - { - callback.run(true); - } + callback.run(true); } - - callback.run(false); } + + callback.run(false); }, playerName); } public void checkPlayerName(final Player caller, final String playerName, final Callback callback) { - _repository.matchPlayerName(new Callback>() + _repository.matchPlayerName(matches -> { - public void run(List matches) + String tempName = null; + + for (String match : matches) { - String tempName = null; - - for (String match : matches) + if (match.equalsIgnoreCase(playerName)) { - if (match.equalsIgnoreCase(playerName)) - { - tempName = match; - break; - } + tempName = match; + break; } - - final String matchedName = tempName; - - if (matchedName != null) - { - for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext(); ) - { - if (!matchIterator.next().equalsIgnoreCase(playerName)) - { - matchIterator.remove(); - } - } - } - - UtilPlayer.searchOffline(matches, new Callback() - { - public void run(final String target) - { - if (target == null) - { - callback.run(matchedName); - return; - } - - callback.run(matchedName); - } - }, caller, playerName, true); } + + final String matchedName = tempName; + + if (matchedName != null) + { + for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext(); ) + { + if (!matchIterator.next().equalsIgnoreCase(playerName)) + { + matchIterator.remove(); + } + } + } + + UtilPlayer.searchOffline(matches, target -> + { + if (target == null) + { + callback.run(matchedName); + return; + } + + callback.run(matchedName); + }, caller, playerName, true); }, playerName); } @@ -726,29 +938,8 @@ public class CoreClientManager extends MiniPlugin } } - @EventHandler - public void debug(UpdateEvent event) - { - if (event.getType() != UpdateType.SLOWER) - return; - -// System.out.println("====="); -// System.out.println("Connecting : " + _clientsConnecting.get()); -// System.out.println("Processing : " + _clientsProcessing.get()); -// System.out.println("====="); - } - public void addStoredProcedureLoginProcessor(ILoginProcessor processor) { _loginProcessors.add(processor); } - - public boolean hasRank(Player player, Rank rank) - { - CoreClient client = Get(player); - if (client == null) - return false; - - return client.GetRank().has(rank); - } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/AddRankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/AddRankCommand.java new file mode 100644 index 000000000..064f5e204 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/AddRankCommand.java @@ -0,0 +1,99 @@ +package mineplex.core.account.command; + +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.event.OnlineGroupAddEvent; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; + +public class AddRankCommand extends CommandBase +{ + public AddRankCommand(CoreClientManager plugin) + { + super(plugin, CoreClientManager.ADD_RANK_COMMAND_PERMISSION, "add"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 2) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /rank " + _aliasUsed + " ")); + return; + } + final String target = args[0]; + final PermissionGroup group = Plugin.getPermissionManager().getGroup(args[1]); + if (group == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank " + F.elem(args[1]) + " does not exist!")); + return; + } + Plugin.runAsync(() -> + { + UUID uuid = Plugin.loadUUIDFromDB(target); + Plugin.runSync(() -> + { + if (uuid == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!")); + } + else + { + if (Bukkit.getPlayer(uuid) != null) + { + final CoreClient client = Plugin.Get(uuid); + Plugin.addAdditionalGroup(client.getAccountId(), group, success -> + { + if (success.booleanValue()) + { + client.addAdditionalGroup(group); + UtilServer.CallEvent(new OnlineGroupAddEvent(Bukkit.getPlayer(uuid), group)); + UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(Plugin.getName(), "You have gained sub-rank " + F.elem(group.getIdentifier()) + "!")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have added sub-rank " + F.elem(group.getIdentifier()) + " to " + F.elem(target) + "!")); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while adding sub-rank " + F.elem(group.getIdentifier()) + " to " + F.elem(target) + "! They may already have it.")); + } + }); + } + else + { + Plugin.loadAccountIdFromUUID(uuid, id -> + { + Plugin.runSync(() -> + { + if (id.intValue() == -1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!")); + } + else + { + Plugin.addAdditionalGroup(id.intValue(), group, success -> + { + if (success.booleanValue()) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have added sub-rank " + F.elem(group.getIdentifier()) + " to " + F.elem(target) + "!")); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while adding sub-rank " + F.elem(group.getIdentifier()) + " to " + F.elem(target) + "! They may already have it.")); + } + }); + } + }); + }); + } + } + }); + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/InfoPlayerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/InfoPlayerCommand.java new file mode 100644 index 000000000..27f08d485 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/InfoPlayerCommand.java @@ -0,0 +1,93 @@ +package mineplex.core.account.command; + +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +public class InfoPlayerCommand extends CommandBase +{ + public InfoPlayerCommand(CoreClientManager plugin) + { + super(plugin, CoreClientManager.RANK_INFO_COMMAND_PERMISSION, "info"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /rank " + _aliasUsed + " ")); + return; + } + final String target = args[0]; + Plugin.runAsync(() -> + { + UUID uuid = Plugin.loadUUIDFromDB(target); + Plugin.runSync(() -> + { + if (uuid == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!")); + } + else + { + if (Bukkit.getPlayer(uuid) != null) + { + final CoreClient client = Plugin.Get(uuid); + Plugin.fetchGroups(client.getAccountId(), pair -> + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank Information of " + target + ":")); + UtilPlayer.message(caller, C.cBlue + "Primary: " + pair.getLeft().getIdentifier()); + UtilPlayer.message(caller, C.cBlue + "Additional (" + pair.getRight().size() + "):"); + for (PermissionGroup group : pair.getRight()) + { + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + group.getIdentifier()); + } + }, () -> + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while listing " + F.elem(target) + "'s ranks!")); + }); + } + else + { + Plugin.loadAccountIdFromUUID(uuid, id -> + { + Plugin.runSync(() -> + { + if (id.intValue() == -1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!")); + } + else + { + Plugin.fetchGroups(id.intValue(), pair -> + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank Information of " + target + ":")); + UtilPlayer.message(caller, C.cBlue + "Primary: " + pair.getLeft().getIdentifier()); + UtilPlayer.message(caller, C.cBlue + "Additional (" + pair.getRight().size() + "):"); + for (PermissionGroup group : pair.getRight()) + { + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + group.getIdentifier()); + } + }, () -> + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while listing " + F.elem(target) + "'s ranks!")); + }); + } + }); + }); + } + } + }); + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/ListRanksCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/ListRanksCommand.java new file mode 100644 index 000000000..2b4016718 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/ListRanksCommand.java @@ -0,0 +1,28 @@ +package mineplex.core.account.command; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +public class ListRanksCommand extends CommandBase +{ + public ListRanksCommand(CoreClientManager plugin) + { + super(plugin, CoreClientManager.LIST_RANKS_COMMAND_PERMISSION, "list"); + } + + @Override + public void Execute(Player caller, String[] args) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Available Ranks:")); + for (PermissionGroup group : Plugin.getPermissionManager().getGroups()) + { + UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + group.getIdentifier()); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/RanksCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/RanksCommand.java new file mode 100644 index 000000000..27d210602 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/RanksCommand.java @@ -0,0 +1,35 @@ +package mineplex.core.account.command; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.command.MultiCommandBase; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +public class RanksCommand extends MultiCommandBase +{ + public RanksCommand(CoreClientManager plugin) + { + super(plugin, CoreClientManager.RANK_COMMAND_PERMISSION, "rank", "ranks", "permissions"); + + AddCommand(new AddRankCommand(plugin)); + AddCommand(new InfoPlayerCommand(plugin)); + AddCommand(new ListRanksCommand(plugin)); + AddCommand(new RemoveRankCommand(plugin)); + AddCommand(new ResetPlayerCommand(plugin)); + AddCommand(new SetRankCommand(plugin)); + } + + @Override + protected void Help(Player caller, String[] args) + { + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " clear ", "Resets a player's ranks to default", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " set ", "Sets a player's primary rank", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " add ", "Adds a sub-rank to a player", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " remove ", "Removes a sub-rank from a player", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " list", "Lists all existing ranks", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " info ", "Displays a player's rank information", ChatColor.DARK_RED)); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/RemoveRankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/RemoveRankCommand.java new file mode 100644 index 000000000..d80f88901 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/RemoveRankCommand.java @@ -0,0 +1,99 @@ +package mineplex.core.account.command; + +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.event.OnlineGroupRemoveEvent; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; + +public class RemoveRankCommand extends CommandBase +{ + public RemoveRankCommand(CoreClientManager plugin) + { + super(plugin, CoreClientManager.REMOVE_RANK_COMMAND_PERMISSION, "remove"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 2) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /rank " + _aliasUsed + " ")); + return; + } + final String target = args[0]; + final PermissionGroup group = Plugin.getPermissionManager().getGroup(args[1]); + if (group == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank " + F.elem(args[1]) + " does not exist!")); + return; + } + Plugin.runAsync(() -> + { + UUID uuid = Plugin.loadUUIDFromDB(target); + Plugin.runSync(() -> + { + if (uuid == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!")); + } + else + { + if (Bukkit.getPlayer(uuid) != null) + { + final CoreClient client = Plugin.Get(uuid); + Plugin.removeAdditionalGroup(client.getAccountId(), group, success -> + { + if (success.booleanValue()) + { + client.removeAdditionalGroup(group); + UtilServer.CallEvent(new OnlineGroupRemoveEvent(Bukkit.getPlayer(uuid), group)); + UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(Plugin.getName(), "You have lost sub-rank " + F.elem(group.getIdentifier()) + "!")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have removed sub-rank " + F.elem(group.getIdentifier()) + " from " + F.elem(target) + "!")); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while removing sub-rank " + F.elem(group.getIdentifier()) + " from " + F.elem(target) + "! They may not have it.")); + } + }); + } + else + { + Plugin.loadAccountIdFromUUID(uuid, id -> + { + Plugin.runSync(() -> + { + if (id.intValue() == -1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!")); + } + else + { + Plugin.removeAdditionalGroup(id.intValue(), group, success -> + { + if (success.booleanValue()) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have removed sub-rank " + F.elem(group.getIdentifier()) + " from " + F.elem(target) + "!")); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while removing sub-rank " + F.elem(group.getIdentifier()) + " from " + F.elem(target) + "! They may not have it.")); + } + }); + } + }); + }); + } + } + }); + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/ResetPlayerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/ResetPlayerCommand.java new file mode 100644 index 000000000..0033cb665 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/ResetPlayerCommand.java @@ -0,0 +1,104 @@ +package mineplex.core.account.command; + +import java.util.Set; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import com.google.common.collect.Sets; + +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.event.OnlineGroupRemoveEvent; +import mineplex.core.account.event.OnlinePrimaryGroupUpdateEvent; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; + +public class ResetPlayerCommand extends CommandBase +{ + public ResetPlayerCommand(CoreClientManager plugin) + { + super(plugin, CoreClientManager.RESET_PLAYER_COMMAND_PERMISSION, "clear"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /rank " + _aliasUsed + " ")); + return; + } + final String target = args[0]; + Plugin.runAsync(() -> + { + UUID uuid = Plugin.loadUUIDFromDB(target); + Plugin.runSync(() -> + { + if (uuid == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!")); + } + else + { + if (Bukkit.getPlayer(uuid) != null) + { + final CoreClient client = Plugin.Get(uuid); + Plugin.clearGroups(client.getAccountId(), success -> + { + if (success.booleanValue()) + { + PermissionGroup old = client.getPrimaryGroup(); + client.setPrimaryGroup(Plugin.getPermissionManager().getGroup("player")); + Set cleared = Sets.newHashSet(client.getAdditionalGroups()); + client.getAdditionalGroups().clear(); + UtilServer.CallEvent(new OnlinePrimaryGroupUpdateEvent(Bukkit.getPlayer(uuid), old, client.getPrimaryGroup())); + for (PermissionGroup clr : cleared) + { + UtilServer.CallEvent(new OnlineGroupRemoveEvent(Bukkit.getPlayer(uuid), clr)); + } + UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(Plugin.getName(), "Your ranks have been cleared!")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have cleared " + F.elem(target + "'s") + " ranks!")); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while clearing " + F.elem(target) + "'s ranks!")); + } + }); + } + else + { + Plugin.loadAccountIdFromUUID(uuid, id -> + { + Plugin.runSync(() -> + { + if (id.intValue() == -1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!")); + } + else + { + Plugin.clearGroups(id.intValue(), success -> + { + if (success.booleanValue()) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have cleared " + F.elem(target + "'s") + " ranks!")); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "An error occurred while clearing " + F.elem(target) + "'s ranks!")); + } + }); + } + }); + }); + } + } + }); + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/SetRankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/SetRankCommand.java new file mode 100644 index 000000000..c2d6598c2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/SetRankCommand.java @@ -0,0 +1,91 @@ +package mineplex.core.account.command; + +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.event.OnlinePrimaryGroupUpdateEvent; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; + +public class SetRankCommand extends CommandBase +{ + public SetRankCommand(CoreClientManager plugin) + { + super(plugin, CoreClientManager.SET_RANK_COMMAND_PERMISSION, "set"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 2) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /rank " + _aliasUsed + " ")); + return; + } + final String target = args[0]; + final PermissionGroup group = Plugin.getPermissionManager().getGroup(args[1]); + if (group == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank " + F.elem(args[1]) + " does not exist!")); + return; + } + if (!group.canBePrimary()) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "That rank cannot be primary!")); + return; + } + Plugin.runAsync(() -> + { + UUID uuid = Plugin.loadUUIDFromDB(target); + Plugin.runSync(() -> + { + if (uuid == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!")); + } + else + { + if (Bukkit.getPlayer(uuid) != null) + { + final CoreClient client = Plugin.Get(uuid); + Plugin.setPrimaryGroup(client.getAccountId(), group, () -> + { + PermissionGroup old = client.getPrimaryGroup(); + client.setPrimaryGroup(group); + UtilServer.CallEvent(new OnlinePrimaryGroupUpdateEvent(Bukkit.getPlayer(uuid), old, client.getPrimaryGroup())); + UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(Plugin.getName(), "Your rank has been updated to " + F.elem(group.getIdentifier()) + "!")); + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have updated " + F.elem(target + "'s") + " rank to " + F.elem(group.getIdentifier()) + "!")); + }); + } + else + { + Plugin.loadAccountIdFromUUID(uuid, id -> + { + Plugin.runSync(() -> + { + if (id.intValue() == -1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(target) + " was not found!")); + } + else + { + Plugin.setPrimaryGroup(id.intValue(), group, () -> + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "You have updated " + F.elem(target + "'s") + " rank to " + F.elem(group.getIdentifier()) + "!")); + }); + } + }); + }); + } + } + }); + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/TestRank.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/TestRank.java deleted file mode 100644 index e4ed2e7b8..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/TestRank.java +++ /dev/null @@ -1,84 +0,0 @@ -package mineplex.core.account.command; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.account.event.OnlineRankUpdateEvent; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -public class TestRank extends CommandBase -{ - public TestRank(CoreClientManager plugin) - { - super(plugin, Rank.ALL, "testRank"); - } - - @Override - public void Execute(final Player caller, String[] args) - { - if (!Plugin.Get(caller).GetRank(true).has(Rank.SNR_MODERATOR)) - { - UtilPlayer.message(caller, F.main("Permissions", "This requires Permission Rank [" + Rank.SNR_MODERATOR.getTag(false, true) + C.cGray + "].")); - return; - } - - if (!UtilServer.isTestServer()) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem("This command can only be used on test servers!"))); - return; - } - - if (args == null) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + _aliasUsed + " MODERATOR")); - } - else - { - if (args.length == 0) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank argument missing.")); - return; - } - - if (args[0].equalsIgnoreCase("RESET")) - { - Plugin.Get(caller).resetTemp(); - } - else - { - Rank tempRank = null; - - try - { - tempRank = Rank.valueOf(args[0].toUpperCase()); - } - catch (Exception ex) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Invalid rank!")); - return; - } - if (!Plugin.Get(caller).GetRank(true).has(Rank.JNR_DEV)) - { - if (tempRank.has(Rank.TWITCH)) - { - UtilPlayer.message(caller, F.main("Command", "You can only test Player ranks!")); - return; - } - } - - Plugin.Get(caller).SetRank(tempRank, true); - UtilPlayer.message(caller, F.main(Plugin.getName(), "Your rank has been set to " + tempRank.getTag(false, false) + C.cGray + "!")); - UtilPlayer.message(caller, F.main("NOTICE", "This is only to be used for testing purposes. Misuse of this command will result in a demotion.")); - OnlineRankUpdateEvent event = new OnlineRankUpdateEvent(caller, Plugin.Get(caller).GetRank(true), Plugin.Get(caller).GetRank(), true); - Bukkit.getPluginManager().callEvent(event); - } - } - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java deleted file mode 100644 index da9f6343f..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/UpdateRank.java +++ /dev/null @@ -1,130 +0,0 @@ -package mineplex.core.account.command; - -import java.util.Iterator; -import java.util.List; -import java.util.UUID; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.account.event.OnlineRankUpdateEvent; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UUIDFetcher; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.serverdata.commands.UpdateRankCommand; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -public class UpdateRank extends CommandBase -{ - public UpdateRank(CoreClientManager plugin) - { - super(plugin, Rank.ADMIN, "updateRank"); - } - - @Override - public void Execute(final Player caller, String[] args) - { - if (args == null) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + _aliasUsed + " joeschmo MODERATOR")); - } - else - { - if (args.length == 0) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "Player argument missing.")); - return; - } - - final String playerName = args[0]; - Rank tempRank = null; - - try - { - tempRank = Rank.valueOf(args[1]); - } - catch (Exception ex) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Invalid rank!")); - return; - } - - final Rank rank = tempRank; - - Plugin.runAsync(() -> - { - new UpdateRankCommand(caller.getName(), caller.getUniqueId().toString(), playerName, rank.name()).publish(); - }); - - Plugin.getRepository().matchPlayerName(new Callback>() - { - public void run(List matches) - { - boolean matchedExact = false; - - for (String match : matches) - { - if (match.equalsIgnoreCase(playerName)) - { - matchedExact = true; - } - } - - if (matchedExact) - { - for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext();) - { - if (!matchIterator.next().equalsIgnoreCase(playerName)) - { - matchIterator.remove(); - } - } - } - - if (UtilPlayer.isOnline(playerName)) - { - Player p = UtilServer.getServer().getPlayer(playerName); - if (Plugin.Get(p).GetRank() != Plugin.Get(p).GetRank(true)) - Plugin.Get(p).resetTemp(); - - OnlineRankUpdateEvent event = new OnlineRankUpdateEvent(caller, Plugin.Get(caller).GetRank(), rank, false); - Plugin.Get(p).SetRank(rank, false); - Bukkit.getPluginManager().callEvent(event); - - UtilPlayer.message(p, F.main(Plugin.getName(), "Your rank has been updated to " + rank.Name + "!")); - } - - UtilPlayer.searchOffline(matches, new Callback() - { - public void run(final String target) - { - if (target == null) - { - return; - } - - UUID uuid = Plugin.loadUUIDFromDB(playerName); - - if (uuid == null) - uuid = UUIDFetcher.getUUIDOf(playerName); - - Plugin.getRepository().saveRank(new Callback() - { - public void run(Rank rank) - { - caller.sendMessage(F.main(Plugin.getName(), target + "'s rank has been updated to " + rank.Name + "!")); - } - }, target, uuid, rank, true); - - } - }, caller, playerName, true); - } - }, playerName); - } - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupAddEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupAddEvent.java new file mode 100644 index 000000000..016df30d7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupAddEvent.java @@ -0,0 +1,38 @@ +package mineplex.core.account.event; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class GroupAddEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private int _accountId; + private String _groupIdentifier; + + public GroupAddEvent(int accountId, String groupIdentifier) + { + _accountId = accountId; + _groupIdentifier = groupIdentifier; + } + + public int getAccountId() + { + return _accountId; + } + + public String getGroupIdentifier() + { + return _groupIdentifier; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupRemoveEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupRemoveEvent.java new file mode 100644 index 000000000..c84e15819 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/GroupRemoveEvent.java @@ -0,0 +1,38 @@ +package mineplex.core.account.event; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class GroupRemoveEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private int _accountId; + private String _groupIdentifier; + + public GroupRemoveEvent(int accountId, String groupIdentifier) + { + _accountId = accountId; + _groupIdentifier = groupIdentifier; + } + + public int getAccountId() + { + return _accountId; + } + + public String getGroupIdentifier() + { + return _groupIdentifier; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/OnlineGroupAddEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/OnlineGroupAddEvent.java new file mode 100644 index 000000000..728eb9789 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/OnlineGroupAddEvent.java @@ -0,0 +1,41 @@ +package mineplex.core.account.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import mineplex.core.account.permissions.PermissionGroup; + +public class OnlineGroupAddEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _player; + private PermissionGroup _group; + + public OnlineGroupAddEvent(Player player, PermissionGroup group) + { + _player = player; + _group = group; + } + + public Player getPlayer() + { + return _player; + } + + public PermissionGroup getGroup() + { + return _group; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/OnlineGroupRemoveEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/OnlineGroupRemoveEvent.java new file mode 100644 index 000000000..ac70108e7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/OnlineGroupRemoveEvent.java @@ -0,0 +1,41 @@ +package mineplex.core.account.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import mineplex.core.account.permissions.PermissionGroup; + +public class OnlineGroupRemoveEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _player; + private PermissionGroup _group; + + public OnlineGroupRemoveEvent(Player player, PermissionGroup group) + { + _player = player; + _group = group; + } + + public Player getPlayer() + { + return _player; + } + + public PermissionGroup getGroup() + { + return _group; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/OnlineRankUpdateEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/OnlinePrimaryGroupUpdateEvent.java similarity index 63% rename from Plugins/Mineplex.Core/src/mineplex/core/account/event/OnlineRankUpdateEvent.java rename to Plugins/Mineplex.Core/src/mineplex/core/account/event/OnlinePrimaryGroupUpdateEvent.java index 27c4cec25..636e8bbad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/event/OnlineRankUpdateEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/OnlinePrimaryGroupUpdateEvent.java @@ -1,25 +1,23 @@ package mineplex.core.account.event; -import mineplex.core.common.Rank; - import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -public class OnlineRankUpdateEvent extends Event +import mineplex.core.account.permissions.PermissionGroup; + +public class OnlinePrimaryGroupUpdateEvent extends Event { private static final HandlerList handlers = new HandlerList(); private Player _player; - private Rank _from, _to; - private boolean _temp; + private PermissionGroup _from, _to; - public OnlineRankUpdateEvent(Player player, Rank from, Rank to, boolean temp) + public OnlinePrimaryGroupUpdateEvent(Player player, PermissionGroup from, PermissionGroup to) { _player = player; _from = from; _to = to; - _temp = temp; } public Player getPlayer() @@ -27,21 +25,16 @@ public class OnlineRankUpdateEvent extends Event return _player; } - public Rank getFrom() + public PermissionGroup getFrom() { return _from; } - public Rank getTo() + public PermissionGroup getTo() { return _to; } - public boolean isTemporary() - { - return _temp; - } - public HandlerList getHandlers() { return handlers; @@ -51,5 +44,4 @@ public class OnlineRankUpdateEvent extends Event { return handlers; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/PrimaryGroupUpdateEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/PrimaryGroupUpdateEvent.java new file mode 100644 index 000000000..07c0d9bdd --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/PrimaryGroupUpdateEvent.java @@ -0,0 +1,38 @@ +package mineplex.core.account.event; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PrimaryGroupUpdateEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private int _accountId; + private String _groupIdentifier; + + public PrimaryGroupUpdateEvent(int accountId, String groupIdentifier) + { + _accountId = accountId; + _groupIdentifier = groupIdentifier; + } + + public int getAccountId() + { + return _accountId; + } + + public String getGroupIdentifier() + { + return _groupIdentifier; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/RankSaveEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/RankSaveEvent.java deleted file mode 100644 index 8453ab6b7..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/event/RankSaveEvent.java +++ /dev/null @@ -1,42 +0,0 @@ -package mineplex.core.account.event; - -import java.util.UUID; - -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -import mineplex.core.common.Rank; - -public class RankSaveEvent extends Event -{ - private static final HandlerList handlers = new HandlerList(); - - private UUID _uuid; - private Rank _rank; - - public RankSaveEvent(UUID uuid, Rank rank) - { - _uuid = uuid; - _rank = rank; - } - - public UUID getUUID() - { - return _uuid; - } - - public Rank getRank() - { - return _rank; - } - - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { - return handlers; - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/GroupPermission.java b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/GroupPermission.java new file mode 100644 index 000000000..6ca505a47 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/GroupPermission.java @@ -0,0 +1,35 @@ +package mineplex.core.account.permissions; + +import java.util.Objects; + +public class GroupPermission +{ + private final String _identifier; + + public GroupPermission(String identifier) + { + _identifier = Objects.requireNonNull(identifier, "Permission identifier cannot be null"); + } + + @Override + public int hashCode() + { + return _identifier.hashCode(); + } + + @Override + public boolean equals(Object o) + { + if (o == null || !(o instanceof GroupPermission)) + { + return false; + } + + return _identifier.hashCode() == ((GroupPermission)o)._identifier.hashCode(); + } + + public static GroupPermission of(String identifier) + { + return new GroupPermission(identifier); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java new file mode 100644 index 000000000..9ebe3a4a0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java @@ -0,0 +1,109 @@ +package mineplex.core.account.permissions; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +import org.bukkit.ChatColor; + +public class PermissionGroup +{ + protected final Object LOCK = new Object(); + + private final String _id, _display, _description; + private final ChatColor _color; + private final int _forumId; + private final boolean _canBePrimary; + private final Set _inherited; + + public PermissionGroup(String identifier, String display, String description, ChatColor color, int forumId, boolean canBePrimary, String... inherited) + { + _id = Objects.requireNonNull(identifier, "Group identifier cannot be null").toLowerCase(); + _display = Objects.requireNonNull(display, "Group display cannot be null"); + _description = Objects.requireNonNull(description, "Group description cannot be null"); + _color = Objects.requireNonNull(color, "Group color cannot be null"); + _forumId = forumId; + _canBePrimary = canBePrimary; + _inherited = Collections.unmodifiableSet(Arrays.asList(inherited).stream().map(i -> i.hashCode()).collect(Collectors.toSet())); + } + + public String getIdentifier() + { + return _id; + } + + public String getDisplay(boolean color, boolean uppercase, boolean bold, boolean defaultIdentifier) + { + StringBuilder builder = new StringBuilder(); + + if (uppercase) + { + builder.append((_display.isEmpty() && defaultIdentifier) ? _id.toUpperCase() :_display.toUpperCase()); + } + else + { + builder.append((_display.isEmpty() && defaultIdentifier) ? (_id.substring(0, 1).toUpperCase() + _id.substring(1)) :_display); + } + + if (bold) + { + builder.insert(0, ChatColor.BOLD); + } + if (color) + { + builder.insert(0, _color); + } + + return builder.toString(); + } + + public String getDescription() + { + return _description; + } + + public int getForumId() + { + return _forumId; + } + + public ChatColor getColor() + { + return _color; + } + + public boolean canBePrimary() + { + return _canBePrimary; + } + + public boolean inherits(PermissionGroup group) + { + return _inherited.contains(group._id.hashCode()); + } + + @Override + public String toString() + { + return _id; + } + + @Override + public int hashCode() + { + return _id.hashCode(); + } + + @Override + public boolean equals(Object o) + { + if (o == null || !(o instanceof PermissionGroup)) + { + return false; + } + + return ((PermissionGroup)o)._id.hashCode() == _id.hashCode(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionManager.java new file mode 100644 index 000000000..9147c3195 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionManager.java @@ -0,0 +1,317 @@ +package mineplex.core.account.permissions; + +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.collect.Sets; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Pair; +import mineplex.core.common.util.F; + +public class PermissionManager extends MiniPlugin +{ + private final CoreClientManager _clientManager; + private final Map _groups = new HashMap<>(); + private final Map> _specific = new HashMap<>(); + private final Map> _inheritable = new HashMap<>(); + + public PermissionManager(JavaPlugin plugin, CoreClientManager client) + { + super("Permission Manager"); + + _clientManager = client; + generateGroups(); + } + + private Set getPermissions(PermissionGroup group, boolean allowSpecific) + { + Set perms = new HashSet<>(); + + if (group == null) + { + return perms; + } + + _groups.values().forEach(g -> + { + if (group.inherits(g)) + { + perms.addAll(getPermissions(g, false)); + } + }); + + synchronized (group.LOCK) + { + _inheritable.get(group).entrySet().forEach(p -> + { + if (p.getValue().booleanValue()) + { + perms.add(p.getKey()); + } + else + { + perms.remove(p.getKey()); + } + }); + if (allowSpecific) + { + _specific.get(group).entrySet().forEach(p -> + { + if (p.getValue().booleanValue()) + { + perms.add(p.getKey()); + } + else + { + perms.remove(p.getKey()); + } + }); + } + } + + return perms; + } + + private void generateGroups() + { + //STAFF + createPermissionGroup(new PermissionGroup("builder", "Builder", "These creative staff members help \nbuild maps for your favorite games!", ChatColor.BLUE, 26, true, "eternal")); + createPermissionGroup(new PermissionGroup("mapper", "Mapper", "These senior staff members work closely with \nthe development and design teams to build new \nmaps for new and old content!", ChatColor.BLUE, 100, true, "builder")); + createPermissionGroup(new PermissionGroup("maplead", "MapLead", "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders.", ChatColor.BLUE, 25, true, "mapper")); + createPermissionGroup(new PermissionGroup("trainee", "Trainee", "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", ChatColor.GOLD, 24, true, "maplead")); + createPermissionGroup(new PermissionGroup("mod", "Mod", "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", ChatColor.GOLD, 32, true, "trainee")); + createPermissionGroup(new PermissionGroup("srmod", "Sr.Mod", "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", ChatColor.GOLD, 44, true, "mod")); + createPermissionGroup(new PermissionGroup("support", "Support", "Support agents handle tickets and \nprovide customer service.", ChatColor.BLUE, 47, true, "srmod")); + createPermissionGroup(new PermissionGroup("admin", "Admin", "An Administrator’s role is to manage \ntheir respective Senior Moderator team \nand all moderators within it.", ChatColor.DARK_RED, 10, true, "support", "content")); + createPermissionGroup(new PermissionGroup("dev", "Dev", "Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", ChatColor.DARK_RED, 5, true, "admin")); + createPermissionGroup(new PermissionGroup("lt", "Leader", "Leaders manage the operation of their respective team \nor projects. They usually operate on affairs within \nthe staff, development, or management team.", ChatColor.DARK_RED, 11, true, "dev")); + createPermissionGroup(new PermissionGroup("owner", "Owner", "Owners are the core managers of Mineplex. \nEach owner manages a different aspect of the \nserver and ensures its efficient operation.", ChatColor.DARK_RED, 55, true, "lt")); + + //SUB-GROUPS + createPermissionGroup(new PermissionGroup("cmod", "", "Members of the Clans Management team.", ChatColor.WHITE, 32, false)); + createPermissionGroup(new PermissionGroup("eventmod", "", "Members of the Event Management team.", ChatColor.WHITE, -1, false)); + createPermissionGroup(new PermissionGroup("cma", "", "Members of the Clans Management Assistance team.", ChatColor.WHITE, -1, false)); + + //CONTENT + createPermissionGroup(new PermissionGroup("content", "", "", ChatColor.WHITE, -1, false, "eternal")); + createPermissionGroup(new PermissionGroup("twitch", "Twitch", "A Twitch streamer who often features \nMineplex in their streams.", ChatColor.DARK_PURPLE, 21, true, "content")); + createPermissionGroup(new PermissionGroup("yt", "YT", "A YouTuber who creates content for \nor related to Mineplex. \n\nThey have fewer subscribers than full YouTubers.", ChatColor.DARK_PURPLE, 20, true, "content")); + createPermissionGroup(new PermissionGroup("youtube", "YouTube", "A YouTuber who creates content for \nor related to Mineplex.", ChatColor.RED, 22, true, "content")); + + //PLAYER + createPermissionGroup(new PermissionGroup("player", "", "", ChatColor.WHITE, -1, true)); + createPermissionGroup(new PermissionGroup("ultra", "Ultra", "A first step into the stories of the mist. \nOnly those brave enough may enter. \n\nThe first purchasable rank at Mineplex.com/shop", ChatColor.AQUA, 12, true, "player")); + createPermissionGroup(new PermissionGroup("hero", "Hero", "There are many stories of a \nvaliant Hero who was brave enough to \ntame the most fearsome dragon in the land. \n\nThe second purchasable rank at Mineplex.com/shop", ChatColor.LIGHT_PURPLE, 13, true, "ultra")); + createPermissionGroup(new PermissionGroup("legend", "Legend", "Years they have told stories of this rank, \nonly for the legends to be true. \n\nThe third purchasable rank at Mineplex.com/shop", ChatColor.GREEN, 14, true, "hero")); + createPermissionGroup(new PermissionGroup("titan", "Titan", "Ancient myths spoke of a gigantic being \nwith immense power... \n\nThe fourth purchasable rank at Mineplex.com/shop", ChatColor.RED, 15, true, "legend")); + createPermissionGroup(new PermissionGroup("eternal", "Eternal", "Fantastic and magical, no one \nexcept the time lords truly understand \nthe power of this rank.\n\nThe fifth purchasable rank at Mineplex.com/shop", ChatColor.DARK_AQUA, 18, true, "titan")); + } + + public Collection getGroups() + { + Set groups = Sets.newHashSet(_groups.values()); + return groups; + } + + public PermissionGroup getGroup(String identifier) + { + if (identifier == null) + { + return null; + } + return _groups.get(identifier.toLowerCase()); + } + + public PermissionGroup getGroupFromLegacy(String legacyValue) + { + if (legacyValue == null) + { + return null; + } + + String legacy = legacyValue == null ? "all" : legacyValue.toLowerCase(); + String current = null; + + if (legacy.equals("developer")) + { + current = "dev"; + } + else if (legacy.equals("jnr_dev")) + { + current = "player"; + } + else if (legacy.equals("event_moderator")) + { + current = "eventmod"; + } + else if (legacy.equals("snr_moderator")) + { + current = "srmod"; + } + else if (legacy.equals("moderator")) + { + current = "mod"; + } + else if (legacy.equals("helper")) + { + current = "trainee"; + } + else if (legacy.equals("mapdev")) + { + current = "builder"; + } + else if (legacy.equals("media")) + { + current = "player"; + } + else if (legacy.equals("youtube_small")) + { + current = "yt"; + } + else if (legacy.equals("all")) + { + current = "player"; + } + + return getGroup(current); + } + + /** + * Checks if a group is an ancestor of a base group rather than just a direct parent + */ + public boolean inheritsFully(PermissionGroup base, PermissionGroup check) + { + if (base == null || check == null) + { + return false; + } + if (base.inherits(check)) + { + return true; + } + for (PermissionGroup group : _groups.values()) + { + if (base.inherits(group)) + { + boolean inherits = inheritsFully(group, check); + if (inherits) + { + return true; + } + } + } + + return false; + } + + public boolean hasPermission(PermissionGroup group, GroupPermission permission) + { + Set total = getPermissions(group, true); + + return total.contains(permission); + } + + public boolean hasPermission(CoreClient client, GroupPermission permission) + { + if (hasPermission(client.getPrimaryGroup(), permission)) + { + return true; + } + for (PermissionGroup group : client.getAdditionalGroups()) + { + if (hasPermission(group, permission)) + { + return true; + } + } + + return false; + } + + public boolean hasPermission(Pair> groups, GroupPermission permission) + { + if (hasPermission(groups.getLeft(), permission)) + { + return true; + } + for (PermissionGroup group : groups.getRight()) + { + if (hasPermission(group, permission)) + { + return true; + } + } + + return false; + } + + public boolean hasPermission(Player player, GroupPermission permission) + { + CoreClient client = _clientManager.Get(player); + + return hasPermission(client, permission); + } + + private void createPermissionGroup(PermissionGroup group) + { + if (group == null) + { + throw new NullPointerException("Cannot register a null group"); + } + if (_groups.containsKey(group.getIdentifier())) + { + throw new IllegalArgumentException("That group is already registered"); + } + _groups.put(group.getIdentifier().toLowerCase(), group); + _inheritable.put(group, new HashMap<>()); + _specific.put(group, new HashMap<>()); + } + + public void setPermission(PermissionGroup group, GroupPermission permission, boolean inheritable, boolean value) + { + if (group == null) + { + return; + } + synchronized (group.LOCK) + { + if (inheritable) + { + _inheritable.computeIfAbsent(group, (g) -> new HashMap<>()).put(permission, Boolean.valueOf(value)); + } + else + { + _specific.computeIfAbsent(group, (g) -> new HashMap<>()).put(permission, Boolean.valueOf(value)); + } + } + } + + public void revokePermission(PermissionGroup group, GroupPermission permission, boolean inheritable) + { + if (group == null) + { + return; + } + synchronized (group.LOCK) + { + if (inheritable) + { + _inheritable.computeIfAbsent(group, (g) -> new HashMap<>()).remove(permission); + } + else + { + _specific.computeIfAbsent(group, (g) -> new HashMap<>()).remove(permission); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/redis/AddPermissionGroup.java b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/AddPermissionGroup.java new file mode 100644 index 000000000..3ea62e940 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/AddPermissionGroup.java @@ -0,0 +1,25 @@ +package mineplex.core.account.redis; + +import mineplex.serverdata.commands.ServerCommand; + +public class AddPermissionGroup extends ServerCommand +{ + private final int _accountId; + private final String _groupIdentifier; + + public AddPermissionGroup(int accountId, String groupIdentifier) + { + _accountId = accountId; + _groupIdentifier = groupIdentifier; + } + + public int getAccountId() + { + return _accountId; + } + + public String getGroupIdentifier() + { + return _groupIdentifier; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/redis/AddPermissionGroupHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/AddPermissionGroupHandler.java new file mode 100644 index 000000000..3f7befb4c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/AddPermissionGroupHandler.java @@ -0,0 +1,41 @@ +package mineplex.core.account.redis; + +import java.util.Optional; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.serverdata.commands.CommandCallback; + +public class AddPermissionGroupHandler implements CommandCallback +{ + private final CoreClientManager _clientManager; + + public AddPermissionGroupHandler(CoreClientManager clientManager) + { + _clientManager = clientManager; + } + + @Override + public void run(AddPermissionGroup command) + { + _clientManager.runSync(() -> + { + Optional opt = Bukkit.getOnlinePlayers().stream().map(Player.class::cast).filter(player -> _clientManager.getAccountId(player) == command.getAccountId()).findAny(); + + if (opt.isPresent()) + { + PermissionGroup group = _clientManager.getPermissionManager().getGroup(command.getGroupIdentifier()); + if (group != null) + { + _clientManager.Get(opt.get()).addAdditionalGroup(group); + UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "You have gained sub-rank " + F.elem(group.getIdentifier()) + "!")); + } + } + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/redis/ClearGroups.java b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/ClearGroups.java new file mode 100644 index 000000000..2329c9589 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/ClearGroups.java @@ -0,0 +1,18 @@ +package mineplex.core.account.redis; + +import mineplex.serverdata.commands.ServerCommand; + +public class ClearGroups extends ServerCommand +{ + private final int _accountId; + + public ClearGroups(int accountId) + { + _accountId = accountId; + } + + public int getAccountId() + { + return _accountId; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/redis/ClearGroupsHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/ClearGroupsHandler.java new file mode 100644 index 000000000..fb348c498 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/ClearGroupsHandler.java @@ -0,0 +1,39 @@ +package mineplex.core.account.redis; + +import java.util.Optional; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.serverdata.commands.CommandCallback; + +public class ClearGroupsHandler implements CommandCallback +{ + private final CoreClientManager _clientManager; + + public ClearGroupsHandler(CoreClientManager clientManager) + { + _clientManager = clientManager; + } + + @Override + public void run(ClearGroups command) + { + _clientManager.runSync(() -> + { + Optional opt = Bukkit.getOnlinePlayers().stream().map(Player.class::cast).filter(player -> _clientManager.getAccountId(player) == command.getAccountId()).findAny(); + + if (opt.isPresent()) + { + PermissionGroup group = _clientManager.getPermissionManager().getGroup("player"); + _clientManager.Get(opt.get()).setPrimaryGroup(group); + _clientManager.Get(opt.get()).getAdditionalGroups().clear(); + UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "Your ranks have been cleared!")); + } + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/redis/PrimaryGroupUpdate.java b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/PrimaryGroupUpdate.java new file mode 100644 index 000000000..1c00a5340 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/PrimaryGroupUpdate.java @@ -0,0 +1,25 @@ +package mineplex.core.account.redis; + +import mineplex.serverdata.commands.ServerCommand; + +public class PrimaryGroupUpdate extends ServerCommand +{ + private final int _accountId; + private final String _groupIdentifier; + + public PrimaryGroupUpdate(int accountId, String groupIdentifier) + { + _accountId = accountId; + _groupIdentifier = groupIdentifier; + } + + public int getAccountId() + { + return _accountId; + } + + public String getGroupIdentifier() + { + return _groupIdentifier; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/redis/PrimaryGroupUpdateHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/PrimaryGroupUpdateHandler.java new file mode 100644 index 000000000..9ceec3415 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/PrimaryGroupUpdateHandler.java @@ -0,0 +1,42 @@ +package mineplex.core.account.redis; + +import java.util.Optional; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.serverdata.commands.CommandCallback; + +public class PrimaryGroupUpdateHandler implements CommandCallback +{ + private final CoreClientManager _clientManager; + + public PrimaryGroupUpdateHandler(CoreClientManager clientManager) + { + _clientManager = clientManager; + } + + @Override + public void run(PrimaryGroupUpdate command) + { + _clientManager.runSync(() -> + { + Optional opt = Bukkit.getOnlinePlayers().stream().map(Player.class::cast).filter(player -> _clientManager.getAccountId(player) == command.getAccountId()).findAny(); + + if (opt.isPresent()) + { + PermissionGroup group = _clientManager.getPermissionManager().getGroup(command.getGroupIdentifier()); + if (group == null) + { + group = _clientManager.getPermissionManager().getGroup("player"); + } + _clientManager.Get(opt.get()).setPrimaryGroup(group); + UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "Your rank has been updated to " + F.elem(group.getIdentifier()) + "!")); + } + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/redis/RemovePermissionGroup.java b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/RemovePermissionGroup.java new file mode 100644 index 000000000..f232509e1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/RemovePermissionGroup.java @@ -0,0 +1,25 @@ +package mineplex.core.account.redis; + +import mineplex.serverdata.commands.ServerCommand; + +public class RemovePermissionGroup extends ServerCommand +{ + private final int _accountId; + private final String _groupIdentifier; + + public RemovePermissionGroup(int accountId, String groupIdentifier) + { + _accountId = accountId; + _groupIdentifier = groupIdentifier; + } + + public int getAccountId() + { + return _accountId; + } + + public String getGroupIdentifier() + { + return _groupIdentifier; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/redis/RemovePermissionGroupHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/RemovePermissionGroupHandler.java new file mode 100644 index 000000000..3d64f064f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/redis/RemovePermissionGroupHandler.java @@ -0,0 +1,41 @@ +package mineplex.core.account.redis; + +import java.util.Optional; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.serverdata.commands.CommandCallback; + +public class RemovePermissionGroupHandler implements CommandCallback +{ + private final CoreClientManager _clientManager; + + public RemovePermissionGroupHandler(CoreClientManager clientManager) + { + _clientManager = clientManager; + } + + @Override + public void run(RemovePermissionGroup command) + { + _clientManager.runSync(() -> + { + Optional opt = Bukkit.getOnlinePlayers().stream().map(Player.class::cast).filter(player -> _clientManager.getAccountId(player) == command.getAccountId()).findAny(); + + if (opt.isPresent()) + { + PermissionGroup group = _clientManager.getPermissionManager().getGroup(command.getGroupIdentifier()); + if (group != null) + { + _clientManager.Get(opt.get()).removeAdditionalGroup(group); + UtilPlayer.message(opt.get(), F.main(_clientManager.getName(), "You have lost sub-rank " + F.elem(group.getIdentifier()) + "!")); + } + } + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java index 104365605..26448e594 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -5,8 +5,13 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedList; import java.util.List; +import java.util.Set; import java.util.UUID; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -16,27 +21,32 @@ import com.google.gson.reflect.TypeToken; import mineplex.cache.player.PlayerCache; import mineplex.core.account.ILoginProcessor; -import mineplex.core.account.event.RankSaveEvent; +import mineplex.core.account.event.GroupAddEvent; +import mineplex.core.account.event.GroupRemoveEvent; +import mineplex.core.account.event.PrimaryGroupUpdateEvent; import mineplex.core.account.repository.token.LoginToken; -import mineplex.core.account.repository.token.RankUpdateToken; -import mineplex.core.common.Rank; +import mineplex.core.common.Pair; import mineplex.core.common.util.Callback; import mineplex.core.common.util.UtilServer; import mineplex.core.database.MinecraftRepository; import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.ResultSetCallable; +import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnVarChar; public class AccountRepository extends MinecraftRepository { - private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, rank VARCHAR(40), rankPerm BOOL, rankExpire LONG, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuid), UNIQUE INDEX nameIndex (name), INDEX rankIndex (rank));"; + private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuid), UNIQUE INDEX nameIndex (name));"; private static String ACCOUNT_LOGIN_NEW = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now());"; - private static String UPDATE_ACCOUNT_RANK = "UPDATE accounts SET rank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;"; - private static String UPDATE_ACCOUNT_RANK_DONOR = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;"; - private static String UPDATE_ACCOUNT_RANK_PERM = "UPDATE accounts SET rank=?, rankPerm=true WHERE uuid = ?;"; - private static String UPDATE_ACCOUNT_RANK_DONOR_PERM = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=true WHERE uuid = ?;"; - + + private static String CREATE_RANKS_TABLE = "CREATE TABLE IF NOT EXISTS accountRanks (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, rankIdentifier VARCHAR(40), primaryGroup BOOL, PRIMARY KEY(id), INDEX accountIndex (accountId), INDEX rankIndex (rankIdentifier), UNIQUE INDEX additionalIndex (accountId, rankIdentifier, primaryGroup), FOREIGN KEY (accountId) REFERENCES accounts(id));"; + private static String UPDATE_PRIMARY_RANK = "UPDATE accountRanks SET rankIdentifier=? WHERE accountId=? AND primaryGroup=true;"; + private static String ADD_PRIMARY_RANK = "INSERT INTO accountRanks (accountId, rankIdentifier, primaryGroup) VALUES (?, NULL, true);"; + private static String ADD_ADDITIONAL_RANK = "INSERT INTO accountRanks (accountId, rankIdentifier, primaryGroup) VALUES (?, ?, false);"; + private static String REMOVE_ADDITIONAL_RANK = "DELETE FROM accountRanks WHERE accountId=? AND rankIdentifier=? AND primaryGroup=false;"; + private static String REMOVE_ADDITIONAL_RANKS = "DELETE FROM accountRanks WHERE accountId=? AND primaryGroup=false;"; + private static String SELECT_ACCOUNT_UUID_BY_NAME = "SELECT uuid FROM accounts WHERE name = ? ORDER BY lastLogin DESC;"; + private static String SELECT_ACCOUNT_UUID_BY_ID = "SELECT uuid FROM accounts WHERE id= DESC;"; private static String SELECT_ACCOUNT_ID_BY_UUID = "SELECT id FROM accounts WHERE accounts.uuid = ? LIMIT 1"; public AccountRepository() @@ -44,10 +54,12 @@ public class AccountRepository extends MinecraftRepository super(DBPool.getAccount()); } - public int login(final List loginProcessors, final UUID uuid, final String name) throws SQLException + public Pair>> login(final List loginProcessors, final UUID uuid, final String name) throws SQLException { // First we try to grab the account id from cache - this saves an extra trip to database int accountId = PlayerCache.getInstance().getAccountId(uuid); + String primaryId = null; + Set extraIds = new HashSet<>(); System.out.println("LOGIN... IDLE: " + ((BasicDataSource) DBPool.getAccount()).getNumIdle() + " ACTIVE: " + ((BasicDataSource) DBPool.getAccount()).getNumActive()); try (Connection connection = getConnection(); Statement statement = connection.createStatement()) @@ -65,19 +77,15 @@ public class AccountRepository extends MinecraftRepository else { // Player doesn't exist in our database, add them to the accounts table - final List tempList = new ArrayList(1); + final List tempList = new ArrayList<>(1); - executeInsert(ACCOUNT_LOGIN_NEW, new ResultSetCallable() + executeInsert(connection, ACCOUNT_LOGIN_NEW, rs -> { - @Override - public void processResultSet(ResultSet resultSet) throws SQLException + while (rs.next()) { - while (resultSet.next()) - { - tempList.add(resultSet.getInt(1)); - } + tempList.add(rs.getInt(1)); } - }, new ColumnVarChar("uuid", 100, uuid.toString()), new ColumnVarChar("name", 100, name)); + }, () -> {}, new ColumnVarChar("uuid", 100, uuid.toString()), new ColumnVarChar("name", 100, name)); accountId = tempList.get(0); } @@ -86,6 +94,34 @@ public class AccountRepository extends MinecraftRepository { System.out.println(name + " Loaded Account ID From Cache [" + name + " - " + accountId + "]"); } + + { + statement.execute("SELECT * FROM accountRanks WHERE accountId=" + accountId + ";"); + try (ResultSet rankSet = statement.getResultSet()) + { + boolean anyRows = false; + while (rankSet.next()) + { + anyRows = true; + String id = rankSet.getString("rankIdentifier"); + boolean primary = rankSet.getBoolean("primaryGroup"); + + if (primary) + { + primaryId = id; + } + else + { + extraIds.add(id); + } + } + + if (!anyRows) + { + statement.execute(UPDATE_PRIMARY_RANK.replace("?", "" + accountId)); + } + } + } final int finalId = accountId; final String uuidString = uuid.toString(); @@ -120,7 +156,7 @@ public class AccountRepository extends MinecraftRepository } - return accountId; + return Pair.create(Integer.valueOf(accountId), Pair.create(primaryId, extraIds)); } public void getAccountId(UUID uuid, Callback callback) @@ -150,67 +186,256 @@ public class AccountRepository extends MinecraftRepository public UUID getClientUUID(String name) { - final List uuids = new ArrayList(); + final List uuids = new LinkedList<>(); - executeQuery(SELECT_ACCOUNT_UUID_BY_NAME, new ResultSetCallable() + executeQuery(SELECT_ACCOUNT_UUID_BY_NAME, resultSet -> { - @Override - public void processResultSet(ResultSet resultSet) throws SQLException + while (resultSet.next()) { - while (resultSet.next()) - { - uuids.add(UUID.fromString(resultSet.getString(1))); - } + uuids.add(UUID.fromString(resultSet.getString(1))); } }, new ColumnVarChar("name", 100, name)); if (uuids.size() > 0) - return uuids.get(0); - else - return null; - } - - public void saveRank(final Callback callback, final String name, final UUID uuid, final Rank rank, final boolean perm) - { - final RankUpdateToken token = new RankUpdateToken(); - token.Name = name; - token.Rank = rank.toString(); - token.Perm = perm; - - final Consumer extraCallback = response -> { - if (rank == Rank.ULTRA || rank == Rank.HERO || rank == Rank.LEGEND || rank == Rank.TITAN) + return uuids.get(0); + } + else + { + return null; + } + } + + public UUID getClientUUID(final int accountId) + { + StringBuilder uuidBuilder = new StringBuilder(); + executeQuery(SELECT_ACCOUNT_UUID_BY_ID, resultSet -> + { + if (resultSet.next()) { - if (rank.isDonor()) + uuidBuilder.append(resultSet.getString("uuid")); + } + }, new ColumnInt("id", accountId)); + + if (uuidBuilder.length() == 0) + { + return null; + } + else + { + return UUID.fromString(uuidBuilder.toString()); + } + } + + public void setPrimaryGroup(final int accountId, final String rankIdentifier, Runnable after) + { + UtilServer.runAsync(() -> + { + try (Connection c = getConnection()) + { + try (Statement s = c.createStatement(); + ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM accountRanks WHERE accountId=" + accountId + " AND primaryGroup=true;"); + ) { - if (perm) - executeUpdate(UPDATE_ACCOUNT_RANK_DONOR_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString())); - else - executeUpdate(UPDATE_ACCOUNT_RANK_DONOR, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString())); + if (!rs.next()) + { + s.execute(ADD_PRIMARY_RANK.replace("?", "" + accountId)); + } } - if (perm) - executeUpdate(UPDATE_ACCOUNT_RANK_DONOR_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString())); - else - executeUpdate(UPDATE_ACCOUNT_RANK_DONOR, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString())); - } - else - { - if (perm) - executeUpdate(UPDATE_ACCOUNT_RANK_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString())); - else - executeUpdate(UPDATE_ACCOUNT_RANK, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString())); - } - - UtilServer.runSync(() -> - { - if (callback != null) - callback.run(response); - UtilServer.CallEvent(new RankSaveEvent(uuid, rank)); - }); + executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnInt("accountId", accountId), new ColumnVarChar("rankIdentifier", rankIdentifier.length(), rankIdentifier)); + + UtilServer.runSync(() -> + { + if (after != null) + { + after.run(); + } + UtilServer.CallEvent(new PrimaryGroupUpdateEvent(accountId, rankIdentifier)); + }); + } + catch (SQLException e) + { + e.printStackTrace(); + } + }); + } + + public void addAdditionalGroup(final int accountId, final String rankIdentifier, Consumer successCallback) + { + UtilServer.runAsync(() -> + { + executeInsert(ADD_ADDITIONAL_RANK, rs -> + { + if (rs.next()) + { + UtilServer.runSync(() -> + { + if (successCallback != null) + { + successCallback.accept(Boolean.TRUE); + } + UtilServer.CallEvent(new GroupAddEvent(accountId, rankIdentifier)); + }); + } + else + { + if (successCallback != null) + { + UtilServer.runSync(() -> successCallback.accept(Boolean.FALSE)); + } + } + }, () -> + { + if (successCallback != null) + { + UtilServer.runSync(() -> successCallback.accept(Boolean.FALSE)); + } + }, new ColumnInt("accountId", accountId), new ColumnVarChar("rankIdentifier", rankIdentifier.length(), rankIdentifier)); + }); + } + + public void removeAdditionalGroup(final int accountId, final String rankIdentifier, Consumer successCallback) + { + UtilServer.runAsync(() -> + { + AtomicBoolean callbackRun = new AtomicBoolean(); + int updated = executeUpdate(REMOVE_ADDITIONAL_RANK, () -> + { + callbackRun.set(true); + if (successCallback != null) + { + UtilServer.runSync(() -> successCallback.accept(Boolean.FALSE)); + } + }, new ColumnInt("accountId", accountId), new ColumnVarChar("rankIdentifier", rankIdentifier.length(), rankIdentifier)); + + if (!callbackRun.get()) + { + if (updated > 0) + { + UtilServer.runSync(() -> + { + if (successCallback != null) + { + successCallback.accept(Boolean.TRUE); + } + UtilServer.CallEvent(new GroupRemoveEvent(accountId, rankIdentifier)); + }); + } + else + { + UtilServer.runSync(() -> successCallback.accept(Boolean.FALSE)); + } + } + }); + } + + public void clearGroups(final int accountId, Consumer successCallback) + { + UtilServer.runAsync(() -> + { + AtomicBoolean success = new AtomicBoolean(true); + Set removed = new HashSet<>(); + + try (Connection c = getConnection()) + { + try (Statement s = c.createStatement()) + { + try (ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM accountRanks WHERE accountId=" + accountId + " AND primaryGroup=true;")) + { + if (!rs.next()) + { + s.execute(ADD_PRIMARY_RANK.replace("?", "" + accountId)); + } + } + try (ResultSet rs = s.executeQuery("SELECT * FROM accountRanks WHERE accountId=" + accountId + ";")) + { + while (rs.next()) + { + if (!rs.getBoolean("primaryGroup")) + { + removed.add(rs.getString("rankIdentifier")); + } + } + } + } + + executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnInt("accountId", accountId), new ColumnVarChar("rankIdentifier", "player".length(), "player")); + executeUpdate(c, REMOVE_ADDITIONAL_RANKS, () -> success.set(false), new ColumnInt("accountId", accountId)); + } + catch (SQLException e) + { + e.printStackTrace(); + success.set(false); + } + + if (successCallback != null || success.get()) + { + UtilServer.runSync(() -> + { + if (successCallback != null) + { + successCallback.accept(Boolean.valueOf(success.get())); + } + UtilServer.CallEvent(new PrimaryGroupUpdateEvent(accountId, "player")); + for (String ident : removed) + { + UtilServer.CallEvent(new GroupRemoveEvent(accountId, ident)); + } + }); + } + }); + } + + public void fetchGroups(final int accountId, Consumer>> resultCallback, Runnable onError) + { + fetchGroups(accountId, resultCallback, onError, true); + } + + public void fetchGroups(final int accountId, Consumer>> resultCallback, Runnable onError, boolean runAsync) + { + Runnable r = () -> + { + AtomicBoolean errored = new AtomicBoolean(); + AtomicReference primary = new AtomicReference<>(); + Set additional = new HashSet<>(); + + executeQuery("SELECT * FROM accountRanks WHERE accountId=?;", rs -> + { + if (rs.getBoolean("primaryGroup")) + { + primary.set(rs.getString("rankIdentifier")); + } + else + { + additional.add(rs.getString("rankIdentifier")); + } + }, () -> + { + if (onError != null) + { + errored.set(true); + UtilServer.runSync(onError); + } + }, new ColumnInt("accountId", accountId)); + + if (!errored.get()) + { + if (resultCallback != null) + { + resultCallback.accept(Pair.create(primary.get(), additional)); + } + } }; - - handleMSSQLCall("PlayerAccount/RankUpdate", String.format("Error saving %s's rank: ", token.Name), token, Rank.class, extraCallback); + + if (runAsync) + { + UtilServer.runAsync(r); + } + else + { + r.run(); + } } public void matchPlayerName(final Callback> callback, final String userName) @@ -222,4 +447,4 @@ public class AccountRepository extends MinecraftRepository { return handleSyncMSSQLCallStream("PlayerAccount/GetAccount", playerName); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/token/Rank.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/token/Rank.java index a2e891a31..282c78f3e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/token/Rank.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/token/Rank.java @@ -5,4 +5,4 @@ public class Rank public int RankId; public String Name; -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index fd7adbe9b..252733405 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -7,7 +7,7 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilTime; import mineplex.core.game.GameDisplay; @@ -310,7 +310,7 @@ public enum AchievementCategory String displayName = _statDisplays[i].getDisplayName(); // Skip showing Losses, Kills, Deaths for other players - if (!clientManager.Get(player).GetRank().has(Rank.MODERATOR) && !player.getName().equals(targetName) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played"))) + if (!clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(AchievementManager.SEE_FULL_STATS_PERMISSION)) && !player.getName().equals(targetName) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played"))) continue; double statNumber = 0; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java index 0be8e250e..cb945f6c3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java @@ -1,6 +1,7 @@ package mineplex.core.achievement; -import mineplex.core.stats.PlayerStats; +import java.util.UUID; + import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -8,25 +9,24 @@ import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.command.StatsCommand; import mineplex.core.achievement.ui.AchievementShop; -import mineplex.core.common.Rank; import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; import mineplex.core.elo.EloManager; import mineplex.core.incognito.IncognitoManager; +import mineplex.core.stats.PlayerStats; import mineplex.core.stats.StatsManager; import mineplex.core.stats.event.StatChangeEvent; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; - public class AchievementManager extends MiniPlugin { - private static final List NO_FAKE_LEVELS = Arrays.asList("samczsun"); - + public static final String FAKE_LEVEL_TIER_PERMISSION = "mineplex.core.achievement.fakelevel."; + public static final String SEE_FULL_STATS_PERMISSION = "mineplex.core.achievement.seefullstats"; + public static final String STATS_COMMAND_PERMISSION = "mineplex.core.achievement.guicommand"; + private CoreClientManager _clientManager; private IncognitoManager _incognitoManager; private StatsManager _statsManager; @@ -49,6 +49,20 @@ public class AchievementManager extends MiniPlugin _eloManager = eloManager; _clientManager = clientManager; _shop = new AchievementShop(this, _statsManager, clientManager, donationManager, "Achievement"); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(SEE_FULL_STATS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 1), true, true); + pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 2), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 3), true, true); + pm.setPermission(pm.getGroup("lt"), GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 4), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(STATS_COMMAND_PERMISSION), true, true); } public AchievementData get(Player player, Achievement type) @@ -199,32 +213,33 @@ public class AchievementManager extends MiniPlugin return true; } - public int getMineplexLevelNumber(Player sender, Rank rank) + public int getMineplexLevelNumber(Player sender) { int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel(); - - if (NO_FAKE_LEVELS.contains(sender.getName())) + + if (_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 4))) { - return level; - } - - if (rank.has(Rank.MODERATOR)) - level = Math.max(level, 5); - if (rank.has(Rank.SNR_MODERATOR)) - level = Math.max(level, 15); - if (rank.has(Rank.JNR_DEV)) - level = Math.max(level, 25); - if (rank.has(Rank.ADMIN)) - level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel()); - if (rank.has(Rank.OWNER)) level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel()); + } + else if (_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 3))) + { + level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel()); + } + else if (_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 2))) + { + level = Math.max(level, 15); + } + else if (_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 1))) + { + level = Math.max(level, 5); + } return level; } - public String getMineplexLevel(Player sender, Rank rank) + public String getMineplexLevel(Player sender) { - return Achievement.getExperienceString(getMineplexLevelNumber(sender, rank)) + " " + ChatColor.RESET; + return Achievement.getExperienceString(getMineplexLevelNumber(sender)) + " " + ChatColor.RESET; } public CoreClientManager getClientManager() @@ -246,4 +261,4 @@ public class AchievementManager extends MiniPlugin { return _statsManager; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/command/StatsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/command/StatsCommand.java index f25cb32ce..8c9580247 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/command/StatsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/command/StatsCommand.java @@ -1,23 +1,19 @@ package mineplex.core.achievement.command; -import mineplex.core.stats.PlayerStats; - import org.bukkit.entity.Player; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.achievement.AchievementManager; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import java.sql.SQLException; - public class StatsCommand extends CommandBase { public StatsCommand(AchievementManager plugin) { - super(plugin, Rank.ALL, "stats"); + super(plugin, AchievementManager.STATS_COMMAND_PERMISSION, "stats"); } @Override @@ -33,7 +29,7 @@ public class StatsCommand extends CommandBase if (target == null) { - if (Plugin.getClientManager().hasRank(caller, Rank.MODERATOR)) attemptOffline(caller, args); + if (Plugin.getClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(AchievementManager.SEE_FULL_STATS_PERMISSION))) attemptOffline(caller, args); return; } @@ -73,4 +69,4 @@ public class StatsCommand extends CommandBase }); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 5f37a1453..75a9e9636 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -51,6 +51,8 @@ import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.antihack.actions.AntiHackAction; import mineplex.core.antihack.actions.BanwaveAction; import mineplex.core.antihack.actions.GEPBanAction; @@ -68,7 +70,6 @@ import mineplex.core.antihack.gep.GwenExtremePrejudice; import mineplex.core.antihack.guardians.GuardianManager; import mineplex.core.antihack.logging.AntihackLogger; import mineplex.core.antihack.redisnotifications.GwenBanNotification; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; @@ -127,6 +128,14 @@ public class AntiHack extends MiniPlugin private static final String USER_HAS_BEEN_BANNED_BANWAVE = USER_HAS_BEEN_BANNED; public static final int ID_LENGTH = 5; + + public static final String SEE_GUARDIANS_PERMISSION = "mineplex.core.antihack.seeguardians"; + public static final String SEE_ALERTS_PERMISSION = "mineplex.core.antihack.seealerts"; + public static final String SILENTLY_BANNED_PERMISSION = "mineplex.core.antihack.silentlybanned"; + public static final String ANTICHEAT_TOGGLE_COMMAND_PERMISSION = "mineplex.core.antihack.togglecommand"; + public static final String DETAILED_MESSAGES_COMMAND_PERMISSION = "mineplex.core.antihack.detailedmessages"; + public static final String GET_VLS_COMMAND_PERMISSION = "mineplex.core.antihack.getvls"; + public static final String TEST_BAN_COMMAND_PERMISSION = "mineplex.core.antihack.testban"; private final Cache _cooldown = CacheBuilder.newBuilder() .concurrencyLevel(1) @@ -174,7 +183,7 @@ public class AntiHack extends MiniPlugin { player.spigot().sendMessage(detailed); } - else if (_clientManager.Get(player).GetRank().has(Rank.HELPER) && (violation.getOriginatingServer().equals(_thisServer) || _preferences.get(player).isActive(Preference.GLOBAL_GWEN_REPORTS))) + else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(SEE_ALERTS_PERMISSION)) && (violation.getOriginatingServer().equals(_thisServer) || _preferences.get(player).isActive(Preference.GLOBAL_GWEN_REPORTS))) { player.spigot().sendMessage(minimal); } @@ -182,6 +191,29 @@ public class AntiHack extends MiniPlugin }); new GwenExtremePrejudice(UtilServer.getPlugin()); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(SEE_GUARDIANS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("builder"), GroupPermission.of(SEE_GUARDIANS_PERMISSION), true, false); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SEE_GUARDIANS_PERMISSION), true, true); + + pm.setPermission(pm.getGroup("content"), GroupPermission.of(SILENTLY_BANNED_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SILENTLY_BANNED_PERMISSION), true, true); + + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SEE_ALERTS_PERMISSION), true, true); + + if (UtilServer.isTestServer()) + { + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(ANTICHEAT_TOGGLE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(TEST_BAN_COMMAND_PERMISSION), true, true); + } + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(DETAILED_MESSAGES_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(GET_VLS_COMMAND_PERMISSION), true, true); } @Override @@ -232,7 +264,7 @@ public class AntiHack extends MiniPlugin { runAsync(() -> { - new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id, gep).publish(); + new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.getPrimaryGroup().getIdentifier(), CheckManager.getCheckSimpleName(cause), id, gep).publish(); }); _punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, hoursBanned, true, after); @@ -245,7 +277,7 @@ public class AntiHack extends MiniPlugin } }; - if (coreClient.GetRank().has(Rank.TWITCH)) + if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(SILENTLY_BANNED_PERMISSION))) { doPunish.accept(result -> { @@ -294,7 +326,7 @@ public class AntiHack extends MiniPlugin } }; - if (coreClient.GetRank().has(Rank.TWITCH)) + if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(SILENTLY_BANNED_PERMISSION))) { doPunish.accept(response -> {}); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java index 9c56787e6..936b65956 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java @@ -66,7 +66,7 @@ public class BanWaveManager extends MiniPlugin { runAsync(() -> { - new GwenBanwaveNotification(UtilServer.getServerName(), player.getName(), player.getUniqueId().toString(), client.GetRank().name(), CheckManager.getCheckSimpleName(checkClass), id, timeToBan).publish(); + new GwenBanwaveNotification(UtilServer.getServerName(), player.getName(), player.getUniqueId().toString(), client.getPrimaryGroup().getIdentifier(), CheckManager.getCheckSimpleName(checkClass), id, timeToBan).publish(); }); JsonObject custom = new JsonObject(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/AnticheatOffCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/AnticheatOffCommand.java index a3d1f4267..0e7bd0f61 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/AnticheatOffCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/AnticheatOffCommand.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import mineplex.core.antihack.AntiHack; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -12,7 +11,7 @@ public class AnticheatOffCommand extends CommandBase { public AnticheatOffCommand(AntiHack plugin) { - super(plugin, Rank.DEVELOPER, "acoff"); + super(plugin, AntiHack.ANTICHEAT_TOGGLE_COMMAND_PERMISSION, "acoff"); } @Override @@ -21,4 +20,4 @@ public class AnticheatOffCommand extends CommandBase Plugin.disableAnticheat(); UtilPlayer.message(caller, F.main(Plugin.getName(), "Disabled anticheat")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/AnticheatOnCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/AnticheatOnCommand.java index 7c1f3a767..39a7b0f0a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/AnticheatOnCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/AnticheatOnCommand.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import mineplex.core.antihack.AntiHack; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -12,7 +11,7 @@ public class AnticheatOnCommand extends CommandBase { public AnticheatOnCommand(AntiHack plugin) { - super(plugin, Rank.DEVELOPER, "acon"); + super(plugin, AntiHack.ANTICHEAT_TOGGLE_COMMAND_PERMISSION, "acon"); } @Override @@ -21,4 +20,4 @@ public class AnticheatOnCommand extends CommandBase Plugin.enableAnticheat(); UtilPlayer.message(caller, F.main(Plugin.getName(), "Enabled anticheat")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/DetailedMessagesCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/DetailedMessagesCommand.java index e873d22e8..1001a6502 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/DetailedMessagesCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/DetailedMessagesCommand.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import mineplex.core.antihack.AntiHack; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -12,7 +11,7 @@ public class DetailedMessagesCommand extends CommandBase { public DetailedMessagesCommand(AntiHack plugin) { - super(plugin, Rank.DEVELOPER, "detailedmessages"); + super(plugin, AntiHack.DETAILED_MESSAGES_COMMAND_PERMISSION, "detailedmessages"); } @Override @@ -27,4 +26,4 @@ public class DetailedMessagesCommand extends CommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), "Detailed messages disabled")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/GetVlsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/GetVlsCommand.java index 84f32311b..5d90698b8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/GetVlsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/GetVlsCommand.java @@ -9,7 +9,6 @@ import com.mineplex.anticheat.checks.CheckManager; import mineplex.core.antihack.AntiHack; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -17,7 +16,7 @@ public class GetVlsCommand extends CommandBase { public GetVlsCommand(AntiHack plugin) { - super(plugin, Rank.DEVELOPER, "getvls"); + super(plugin, AntiHack.GET_VLS_COMMAND_PERMISSION, "getvls"); } @Override @@ -44,4 +43,4 @@ public class GetVlsCommand extends CommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), "No player specified")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/TestBanCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/TestBanCommand.java index 40ac6c1aa..4ab0accee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/TestBanCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/TestBanCommand.java @@ -8,7 +8,6 @@ import org.bukkit.entity.Player; import mineplex.core.antihack.AntiHack; import mineplex.core.antihack.animations.BanwaveAnimationSpin; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -17,7 +16,7 @@ public class TestBanCommand extends CommandBase { public TestBanCommand(AntiHack plugin) { - super(plugin, Rank.DEVELOPER, "testban"); + super(plugin, AntiHack.TEST_BAN_COMMAND_PERMISSION, "testban"); } @Override @@ -48,4 +47,4 @@ public class TestBanCommand extends CommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), "No player specified")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/AntiHackGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/AntiHackGuardian.java index b1ddf4d48..8bd3079c3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/AntiHackGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/AntiHackGuardian.java @@ -1,16 +1,9 @@ package mineplex.core.antihack.guardians; -import com.mineplex.spigot.ChunkAddEntityEvent; -import mineplex.core.Managers; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilServer; -import mineplex.core.disguise.DisguiseManager; -import mineplex.core.disguise.disguises.DisguiseGuardian; -import mineplex.core.event.StackerEvent; -import net.minecraft.server.v1_8_R3.EntityArmorStand; -import net.minecraft.server.v1_8_R3.EntityPlayer; +import java.util.Random; +import java.util.UUID; +import java.util.function.Function; + import org.bukkit.Location; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArmorStand; @@ -23,9 +16,19 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.util.Vector; -import java.util.Random; -import java.util.UUID; -import java.util.function.Function; +import com.mineplex.spigot.ChunkAddEntityEvent; + +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.antihack.AntiHack; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseGuardian; +import mineplex.core.event.StackerEvent; +import net.minecraft.server.v1_8_R3.EntityArmorStand; +import net.minecraft.server.v1_8_R3.EntityPlayer; public class AntiHackGuardian implements Listener { @@ -115,16 +118,10 @@ public class AntiHackGuardian implements Listener if (!hideForStaff) return true; // Don't let Builder -> Admin see it - Rank rank = clientManager.Get(player).GetRank(); - if (rank.has(Rank.MAPDEV)) + if (!clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(AntiHack.SEE_GUARDIANS_PERMISSION))) { - if (!rank.has(Rank.ADMIN)) - { - return false; - } - } - if (rank == Rank.EVENT) return false; + } return true; }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java index 3d19f0501..b1f8c1d79 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java @@ -1,14 +1,5 @@ package mineplex.core.antihack.guardians; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import mineplex.core.MiniPlugin; -import mineplex.core.PlayerSelector; -import mineplex.core.ReflectivelyCreateMiniPlugin; -import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilLambda; -import org.bukkit.entity.Player; - import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -16,6 +7,18 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import java.util.function.Function; +import org.bukkit.entity.Player; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; + +import mineplex.core.Managers; +import mineplex.core.MiniPlugin; +import mineplex.core.PlayerSelector; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.UtilLambda; + @ReflectivelyCreateMiniPlugin public class GuardianManager extends MiniPlugin { @@ -80,19 +83,18 @@ public class GuardianManager extends MiniPlugin UtilLambda.and( PlayerSelector.NOT_VANISHED, PlayerSelector.hasAnyRank(false, - Rank.ALL, - Rank.ULTRA, - Rank.HERO, - Rank.LEGEND, - Rank.TITAN, - Rank.TWITCH, - Rank.YOUTUBE_SMALL, - Rank.YOUTUBE, - Rank.MEDIA, - Rank.ADMIN, - Rank.DEVELOPER, - Rank.OWNER, - Rank.LT + Managers.get(CoreClientManager.class).getPermissionManager().getGroup("player"), + Managers.get(CoreClientManager.class).getPermissionManager().getGroup("ultra"), + Managers.get(CoreClientManager.class).getPermissionManager().getGroup("hero"), + Managers.get(CoreClientManager.class).getPermissionManager().getGroup("legend"), + Managers.get(CoreClientManager.class).getPermissionManager().getGroup("titan"), + Managers.get(CoreClientManager.class).getPermissionManager().getGroup("twitch"), + Managers.get(CoreClientManager.class).getPermissionManager().getGroup("yt"), + Managers.get(CoreClientManager.class).getPermissionManager().getGroup("youtube"), + Managers.get(CoreClientManager.class).getPermissionManager().getGroup("admin"), + Managers.get(CoreClientManager.class).getPermissionManager().getGroup("dev"), + Managers.get(CoreClientManager.class).getPermissionManager().getGroup("lt"), + Managers.get(CoreClientManager.class).getPermissionManager().getGroup("owner") ), player -> !_stalking.contains(player.getUniqueId()), player -> _stalkingCooldown.getIfPresent(player.getUniqueId()) == null @@ -126,4 +128,4 @@ public class GuardianManager extends MiniPlugin { _guardians.add(guardian); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AntihackLogger.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AntihackLogger.java index 3c3cc03ef..104bfa6c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AntihackLogger.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AntihackLogger.java @@ -6,7 +6,6 @@ import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -19,20 +18,18 @@ import org.tukaani.xz.XZOutputStream; import com.google.gson.Gson; import com.google.gson.JsonNull; import com.google.gson.JsonObject; -import com.mineplex.anticheat.api.PlayerViolationEvent; -import com.mineplex.anticheat.checks.Check; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.antihack.AntiHack; -import mineplex.core.antihack.ViolationLevels; import mineplex.core.antihack.logging.builtin.PartyInfoMetadata; import mineplex.core.antihack.logging.builtin.PlayerInfoMetadata; import mineplex.core.antihack.logging.builtin.ServerInfoMetadata; import mineplex.core.antihack.logging.builtin.ViolationInfoMetadata; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -41,6 +38,8 @@ import mineplex.core.common.util.UtilServer; public class AntihackLogger extends MiniPlugin { public static final Gson GSON = new Gson(); + + private static final String SAVE_METADATA_COMMAND_PERMISSION = "mineplex.core.antihack.savemetadatacommand"; private final CoreClientManager _clientManager = require(CoreClientManager.class); @@ -64,7 +63,9 @@ public class AntihackLogger extends MiniPlugin { if (UtilServer.isTestServer()) { - addCommand(new CommandBase(this, Rank.SNR_MODERATOR, "savemetadata") + PermissionManager pm = _clientManager.getPermissionManager(); + pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(SAVE_METADATA_COMMAND_PERMISSION), true, true); + addCommand(new CommandBase(this, SAVE_METADATA_COMMAND_PERMISSION, "savemetadata") { @Override public void Execute(Player caller, String[] args) @@ -139,13 +140,13 @@ public class AntihackLogger extends MiniPlugin public void registerMetadata(AnticheatMetadata metadata) { - if (!this._metadata.containsKey(metadata.getId())) + if (!_metadata.containsKey(metadata.getId())) { - this._metadata.put(metadata.getId(), metadata); + _metadata.put(metadata.getId(), metadata); } else { throw new IllegalArgumentException("Attempting to register: " + metadata.getId()); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java index 1eb6ee28f..17e7b9679 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java @@ -1,23 +1,27 @@ package mineplex.core.aprilfools; +import java.util.Map; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.AsyncPlayerChatEvent; + import com.google.common.collect.ImmutableMap; + +import mineplex.core.Managers; import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.aprilfools.command.PirateSongCommand; -import mineplex.core.common.Rank; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.twofactor.TwoFactorAuth; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.AsyncPlayerChatEvent; - -import java.util.Map; public class AprilFoolsManager extends MiniPlugin { - /** * Manually can be toggled to enable or disable the April Fools activities. */ @@ -76,13 +80,8 @@ public class AprilFoolsManager extends MiniPlugin .put("developer", "firstmate") .put("admin", "firstmate") .build(); - private static final Map RANK_REPLACEMENTS = ImmutableMap.builder() - .put(Rank.ETERNAL, "Captain") - .put(Rank.TITAN, "FirstMate") - .put(Rank.LEGEND, "Boatswain") - .put(Rank.HERO, "Gunner") - .put(Rank.ULTRA, "Parrot") - .build(); + + public static final String PIRATE_SONG_COMMAND_PERMISSION = "mineplex.core.aprilfools.piratesong"; private static AprilFoolsManager _instance; private final AprilFoolsRepository _repository; @@ -100,14 +99,14 @@ public class AprilFoolsManager extends MiniPlugin _twoFA = require(TwoFactorAuth.class); setEnabled(true); _enabledTitle = UtilServer.isHubServer() || UtilServer.isTestServer(); - - if (_enabled) - { - for (Map.Entry entry : RANK_REPLACEMENTS.entrySet()) - { - entry.getKey().setName(entry.getValue()); - } - } + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PIRATE_SONG_COMMAND_PERMISSION), true, true); } @Override @@ -251,4 +250,4 @@ public class AprilFoolsManager extends MiniPlugin return _instance; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/command/PirateSongCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/command/PirateSongCommand.java index 405d88066..95ac34420 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/command/PirateSongCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/command/PirateSongCommand.java @@ -1,28 +1,28 @@ package mineplex.core.aprilfools.command; -import mineplex.core.aprilfools.AprilFoolsManager; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilTextMiddle; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; +import mineplex.core.aprilfools.AprilFoolsManager; +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.UtilTextMiddle; + public class PirateSongCommand extends CommandBase { - - private static final String[] PIRATE_SONG = { - "Are you ready kids?", - "Aye aye captain!", - "I can't hear you!", - "AYE AYE CAPTAIN!", - "OOOOOOOOOOOOH", - "Who lives in a pineapple under the sea?", - "Spongebob Squarepants!" + private static final String[] PIRATE_SONG = + { + "Are you ready kids?", + "Aye aye captain!", + "I can't hear you!", + "AYE AYE CAPTAIN!", + "OOOOOOOOOOOOH", + "Who lives in a pineapple under the sea?", + "Spongebob Squarepants!" }; public PirateSongCommand(AprilFoolsManager plugin) { - super(plugin, Rank.ADMIN, "piratesong"); + super(plugin, AprilFoolsManager.PIRATE_SONG_COMMAND_PERMISSION, "piratesong"); } @Override @@ -45,4 +45,4 @@ public class PirateSongCommand extends CommandBase } }, 20, 100); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java b/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java index ae121af76..65b755d28 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java @@ -12,7 +12,8 @@ import com.google.common.collect.ImmutableSet; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.powerplayclub.PowerPlayClubRepository; public class BetaWhitelist extends MiniPlugin @@ -40,6 +41,9 @@ public class BetaWhitelist extends MiniPlugin .add(UUID.fromString("6795643a-2b61-41bf-9429-c7549fd128a8")) // umGim .add(UUID.fromString("47ba454a-4999-42f4-a269-2f4114ceb3c7")) // falconviii .build(); + + private static final String BYPASS_WHITELIST_PERMISSION = "mineplex.core.beta.bypasswhitelist"; + private final CoreClientManager _clientManager; private final PowerPlayClubRepository _powerPlayClubRepository; @@ -48,14 +52,22 @@ public class BetaWhitelist extends MiniPlugin super("Beta Whitelist"); _clientManager = clientManager; _powerPlayClubRepository = powerPlayRepository; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(BYPASS_WHITELIST_PERMISSION), true, true); } @EventHandler public void onJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); - Rank rank = _clientManager.Get(player).GetRank(true); - if (rank.has(Rank.ULTRA) // If this player is Ultra+ + if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(BYPASS_WHITELIST_PERMISSION)) // If this player is Ultra+ || _powerPlayClubRepository.getCachedData(player).isSubscribed() // a PPC subscriber, || EXTRA_PLAYERS.contains(player.getUniqueId())) // or explicitly whitelisted, { @@ -65,4 +77,4 @@ public class BetaWhitelist extends MiniPlugin // Otherwise, kick them out event.getPlayer().kickPlayer("Sorry, you aren't whitelisted on this beta server.\n\nSubscribe to " + ChatColor.GOLD + "Power Play Club " + ChatColor.WHITE + "at " + ChatColor.GREEN + "mineplex.com/shop" + ChatColor.WHITE + "!"); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index ef84b512f..378448e0f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -36,6 +36,8 @@ import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; import mineplex.core.account.event.ClientUnloadEvent; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.bonuses.animations.AnimationCarl; import mineplex.core.bonuses.commands.AnimationCommand; import mineplex.core.bonuses.commands.GuiCommand; @@ -48,7 +50,6 @@ import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton; import mineplex.core.bonuses.redis.VoteHandler; import mineplex.core.bonuses.redis.VotifierCommand; import mineplex.core.common.Pair; -import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -93,6 +94,18 @@ public class BonusManager extends MiniClientPlugin implements I private static long timeOffSet = 0; + public static final String ETERNAL_BONUS_PERMISSION = "mineplex.core.bonus.eternal"; + public static final String TITAN_BONUS_PERMISSION = "mineplex.core.bonus.titan"; + public static final String LEGEND_BONUS_PERMISSION = "mineplex.core.bonus.legend"; + public static final String HERO_BONUS_PERMISSION = "mineplex.core.bonus.hero"; + public static final String ULTRA_BONUS_PERMISSION = "mineplex.core.bonus.ultra"; + public static final String MONTHLY_BONUS_PERMISSION = "mineplex.core.bonus.monthly"; + public static final String ALLOW_COMMAND_PERMISSION = "mineplex.core.bonus.allowcommand"; + public static final String ANIMATION_COMMAND_PERMISSION = "mineplex.core.bonus.animation"; + public static final String GUI_COMMAND_PERMISSION = "mineplex.core.bonus.gui"; + public static final String POWER_PLAY_COMMAND_PERMISSION = "mineplex.core.bonus.powerplay"; + public static final String TICKET_COMMAND_PERMISSION = "mineplex.core.bonus.ticket"; + private ArrayList _pendingExplosions = new ArrayList<>(); private ArrayList _pendingExplosionsPlayers = new ArrayList<>(); private final Map> _homeServerMap = new ConcurrentHashMap<>(); @@ -186,6 +199,8 @@ public class BonusManager extends MiniClientPlugin implements I _creeperName = "Carl"; updateOffSet(); + + generatePermissions(); } public BonusManager(JavaPlugin plugin, Location carlLocation, PlayWireManager playWireManager, CoreClientManager clientManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, YoutubeManager youtubeManager, GadgetManager gadgetManager, ThankManager thankManager, String creeperName) @@ -288,8 +303,26 @@ public class BonusManager extends MiniClientPlugin implements I } }); } + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(MONTHLY_BONUS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(ULTRA_BONUS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("hero"), GroupPermission.of(HERO_BONUS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("legend"), GroupPermission.of(LEGEND_BONUS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("titan"), GroupPermission.of(TITAN_BONUS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("eternal"), GroupPermission.of(ETERNAL_BONUS_PERMISSION), true, true); + + //pm.setPermission(pm.getGroup("mod"), GroupPermission.of(ALLOW_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(ANIMATION_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(GUI_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(POWER_PLAY_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TICKET_COMMAND_PERMISSION), true, true); } - @Override public void addCommands() @@ -746,29 +779,27 @@ public class BonusManager extends MiniClientPlugin implements I public BonusAmount getRankBonusAmount(Player player) { - Rank rank = _clientManager.Get(player).GetRank(); - BonusAmount data = new BonusAmount(); - if (rank.has(Rank.ETERNAL)) + if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(ETERNAL_BONUS_PERMISSION))) { data.setIlluminatedChests(2); data.setMythicalChests(2); data.setOmegaChests(1); } - else if (rank.has(Rank.TITAN)) + else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TITAN_BONUS_PERMISSION))) { data.setMythicalChests(5); } - else if (rank.has(Rank.LEGEND)) + else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(LEGEND_BONUS_PERMISSION))) { data.setMythicalChests(3); } - else if (rank.has(Rank.HERO)) + else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(HERO_BONUS_PERMISSION))) { data.setMythicalChests(2); } - else if (rank.has(Rank.ULTRA)) + else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(ULTRA_BONUS_PERMISSION))) { data.setMythicalChests(1); } @@ -984,16 +1015,15 @@ public class BonusManager extends MiniClientPlugin implements I if (canVote(player)) availableRewards++; if (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) availableRewards++; if (_youtubeManager.canYoutube(player)) availableRewards++; - if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++; + if (canRank(player) && _clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(MONTHLY_BONUS_PERMISSION)) && isPastAugust()) availableRewards++; if (canDaily(player)) availableRewards++; - if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++; + if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).getPrimaryGroup()) != null) availableRewards++; if (!_facebookManager.hasRedeemed(player)) availableRewards++; if (_thankManager.Get(player).getThankToClaim() > 0) availableRewards++; if (PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) availableRewards++; Hologram hologram; - if (client.getHologram() == null) { double yAdd = 2.3; @@ -1090,7 +1120,9 @@ public class BonusManager extends MiniClientPlugin implements I final BonusClientData clientData = Get(event.getUniqueId()); if (clientData.getHologram() != null) + { clientData.getHologram().stop(); + } // Save streaks runAsync(() -> _repository.saveStreak(clientData.getAccountId(), clientData)); @@ -1143,12 +1175,14 @@ public class BonusManager extends MiniClientPlugin implements I { if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false)) { - if (_pollManager.hasPoll(player) || canVote(player) || _youtubeManager.canYoutube(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) + if (_pollManager.hasPoll(player) || canVote(player) || _youtubeManager.canYoutube(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(MONTHLY_BONUS_PERMISSION)) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) { if (_showCarl.containsKey(player.getName())) { if (_plugin.getClass().getSimpleName().equalsIgnoreCase("Hub") || _plugin.getClass().getSimpleName().equalsIgnoreCase("ClansHub")) + { UtilPlayer.message(player, C.cDGreen + C.Bold + _creeperName + " the Creeper>" + C.cGreen + " Hey " + player.getName().replace("s", "sss") + "! I have sssome amazing rewardsss for you! Come sssee me!"); + } } } } @@ -1232,4 +1266,4 @@ public class BonusManager extends MiniClientPlugin implements I { return _carlNpc; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AllowCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AllowCommand.java index bbc3e939e..bff252026 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AllowCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AllowCommand.java @@ -1,16 +1,14 @@ package mineplex.core.bonuses.commands; -import java.util.Arrays; +import org.bukkit.entity.Player; import mineplex.core.bonuses.BonusManager; import mineplex.core.command.CommandBase; import mineplex.core.command.CommandCenter; import mineplex.core.command.ICommand; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilPlayer; -import org.bukkit.entity.Player; /** * Allows players to run rank-specific commands @@ -18,12 +16,11 @@ import org.bukkit.entity.Player; */ public class AllowCommand extends CommandBase { - private BonusManager _plugin; public AllowCommand(BonusManager plugin) { - super(plugin, Rank.MODERATOR, "allowCommand", "allowCmd"); + super(plugin, BonusManager.ALLOW_COMMAND_PERMISSION, "allowCommand", "allowCmd"); _plugin = plugin; } @@ -42,9 +39,7 @@ public class AllowCommand extends CommandBase return; } ICommand iCommand = commands.get(args[1]); - Rank playerRank = _plugin.getClientManager().Get(caller).GetRank(); - if (playerRank.compareTo(iCommand.GetRequiredRank()) > 0 - && Arrays.asList(iCommand.GetSpecificRanks()).contains(playerRank)) + if (!_plugin.getClientManager().getPermissionManager().hasPermission(caller, iCommand.getPermission())) { UtilPlayer.message(caller, F.main("Allow Command", "You're not allowed to use that command!")); return; @@ -79,5 +74,4 @@ public class AllowCommand extends CommandBase UtilPlayer.message(caller, F.main("Allow Command", "You allowed the player " + F.name(receiver.getName()) + " to use the command " + F.elem(args[1]) + "!")); UtilPlayer.message(receiver, F.main("Allow Command", "The player " + F.name(caller.getName()) + " allowed you to use the command " + F.elem(args[1]) + "!")); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java index 08ae3db23..18f0dd1dc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java @@ -3,10 +3,9 @@ package mineplex.core.bonuses.commands; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.reward.RewardType; import mineplex.core.bonuses.BonusManager; +import mineplex.core.command.CommandBase; +import mineplex.core.reward.RewardType; public class AnimationCommand extends CommandBase{ @@ -14,7 +13,7 @@ public class AnimationCommand extends CommandBase{ public AnimationCommand(BonusManager plugin) { - super(plugin, Rank.DEVELOPER, "animation"); + super(plugin, BonusManager.ANIMATION_COMMAND_PERMISSION, "animation"); _plugin = plugin; } @@ -30,5 +29,4 @@ public class AnimationCommand extends CommandBase{ } } - } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java index 7fd1b2c3c..a2a6361c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java @@ -2,22 +2,20 @@ package mineplex.core.bonuses.commands; import org.bukkit.entity.Player; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.bonuses.BonusManager; import mineplex.core.bonuses.gui.BonusGui; +import mineplex.core.command.CommandBase; public class GuiCommand extends CommandBase { public GuiCommand(BonusManager plugin) { - super(plugin, Rank.DEVELOPER, "bonus"); + super(plugin, BonusManager.GUI_COMMAND_PERMISSION, "bonus"); } @Override public void Execute(Player caller, String[] args) { new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager(), Plugin.getFacebookManager(), Plugin.getYoutubeManager(), Plugin.getThankManager(), Plugin.getPlayWireManager()).openInventory(); - } - -} + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/PowerPlayCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/PowerPlayCommand.java index cc305f652..db6d95443 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/PowerPlayCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/PowerPlayCommand.java @@ -1,26 +1,25 @@ package mineplex.core.bonuses.commands; -import mineplex.core.bonuses.BonusManager; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.powerplayclub.PowerPlayData; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - import java.time.LocalDate; import java.time.YearMonth; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import mineplex.core.bonuses.BonusManager; +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.powerplayclub.PowerPlayData; + public class PowerPlayCommand extends CommandBase { - private BonusManager _bonusManager; public PowerPlayCommand(BonusManager manager) { - super(manager, Rank.JNR_DEV, "powerplay"); + super(manager, BonusManager.POWER_PLAY_COMMAND_PERMISSION, "powerplay"); _bonusManager = manager; } @@ -45,4 +44,4 @@ public class PowerPlayCommand extends CommandBase caller.sendMessage(ChatColor.GREEN + "Gave a month's subscription to " + player.getName()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java index 307a57427..cb9ccde34 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java @@ -1,19 +1,18 @@ package mineplex.core.bonuses.commands; +import org.bukkit.entity.Player; + +import mineplex.core.bonuses.BonusManager; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.bonuses.BonusManager; - -import org.bukkit.entity.Player; public class TicketCommand extends CommandBase { public TicketCommand(BonusManager plugin) { - super(plugin, Rank.ADMIN, "ticket"); + super(plugin, BonusManager.TICKET_COMMAND_PERMISSION, "ticket"); } @Override @@ -65,4 +64,4 @@ public class TicketCommand extends CommandBase UtilPlayer.message(caller, F.main("Carl", "Invalid Ticket Amount")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java index 6e8c16e17..2fe8f71c9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PollButton.java @@ -2,6 +2,15 @@ package mineplex.core.bonuses.gui.buttons; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; import mineplex.core.account.CoreClientManager; import mineplex.core.bonuses.BonusAmount; @@ -19,14 +28,6 @@ import mineplex.core.poll.Poll; import mineplex.core.poll.PollManager; import mineplex.core.recharge.Recharge; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.Plugin; - public class PollButton extends SimpleGui implements GuiItem { protected boolean _create; @@ -56,7 +57,7 @@ public class PollButton extends SimpleGui implements GuiItem { { if (_create) { - this._poll = _pollManager.getNextPoll(_pollManager.Get(getPlayer()), _clientManager.Get(getPlayer()).GetRank()); + _poll = _pollManager.getNextPoll(_pollManager.Get(getPlayer()), _clientManager.Get(getPlayer()).getPrimaryGroup()); if (_poll != null) { @@ -77,7 +78,7 @@ public class PollButton extends SimpleGui implements GuiItem { @Override public ItemStack getObject() { - ArrayList lore = new ArrayList<>(); + List lore = new ArrayList<>(); if (_poll == null) { lore.add(""); @@ -128,14 +129,15 @@ public class PollButton extends SimpleGui implements GuiItem { public GuiItem getQuestionItem(String question) { - - ArrayList lore = new ArrayList<>(); + List lore = new ArrayList<>(); lore.add(""); for (String string : wrap(question)) + { lore.add(C.cWhite + string); + } lore.add(""); int i = 1; - for(String str : _poll.getAnswers()) + for (String str : _poll.getAnswers()) { lore.add(C.cAqua + "" + i + ".) " + C.cWhite + str); i++; @@ -181,21 +183,20 @@ public class PollButton extends SimpleGui implements GuiItem { private class AnswerItem implements GuiItem { - - private int num; + private int _num; private AnswerItem(Poll poll, int num) { - this.num = num; + _num = num; } @Override public ItemStack getObject() { - ArrayList lore = new ArrayList<>(); + List lore = new ArrayList<>(); lore.add(""); - lore.add(C.cWhite + getPoll().getAnswers()[num]); - return ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.GREEN + "Option " + (num + 1), lore); + lore.add(C.cWhite + getPoll().getAnswers()[_num]); + return ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, ChatColor.GREEN + "Option " + (_num + 1), lore); } @Override @@ -208,11 +209,11 @@ public class PollButton extends SimpleGui implements GuiItem { _create = true; - _pollManager.answerPoll(getPlayer(), _poll, num + 1); + _pollManager.answerPoll(getPlayer(), _poll, _num + 1); getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f); - new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.EMERALD_BLOCK, (byte) 0, 1, ChatColor.GREEN + "Your anwser:", wrap(getPoll().getAnswers()[num])), ChatColor.GREEN + "Moo", 6 * 9, 50, getMaster()).openInventory(); + new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.EMERALD_BLOCK, (byte) 0, 1, ChatColor.GREEN + "Your anwser:", wrap(getPoll().getAnswers()[_num])), ChatColor.GREEN + "Moo", 6 * 9, 50, getMaster()).openInventory(); _bonusManager.addPendingExplosion(getPlayer(), "POLL"); getPlayer().closeInventory(); } @@ -227,4 +228,4 @@ public class PollButton extends SimpleGui implements GuiItem { @Override public void close() {} -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java index 31541dc59..45c674d0e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/RankBonusButton.java @@ -187,7 +187,7 @@ public class RankBonusButton implements GuiItem, Listener { } lore.add(" "); - lore.add(C.cYellow + "Rank: " + C.cWhite + _bonusManager.getClientManager().Get(_player).GetRank().Name); + lore.add(C.cYellow + "Rank: " + C.cWhite + _bonusManager.getClientManager().Get(_player).getPrimaryGroup().getDisplay(false, false, false, true)); BonusAmount bonusAmount = _bonusManager.getRankBonusAmount(_player); bonusAmount.addLore(lore); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java index eec3e3c22..cab12c860 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java @@ -1,7 +1,29 @@ package mineplex.core.boosters; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.boosters.command.BoosterCommand; import mineplex.core.boosters.event.BoosterActivateEvent; import mineplex.core.boosters.event.BoosterExpireEvent; @@ -21,18 +43,6 @@ import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.thank.ThankManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.Event; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; - -import java.util.*; /** * BoosterManager handles the majority of logic for creating and getting Boosters. Every BoosterManager stores a cache @@ -58,6 +68,12 @@ public class BoosterManager extends MiniPlugin public static final ItemStack INTERFACE_ITEM = ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte)0, 1, ChatColor.RESET + C.cGreen + "Game Amplifiers"); // Slot for the booster gui item public static final int INTERFACE_SLOT = 7; + + public static final String ADD_BOOSTER_COMMAND_PERMISSION = "mineplex.core.booster.add"; + public static final String BOOSTER_COMMAND_PERMISSION = "mineplex.core.booster.command"; + public static final String BOOSTER_GUI_COMMAND_PERMISSION = "mineplex.core.booster.gui"; + public static final String RELOAD_BOOSTERS_COMMAND_PERMISSION = "mineplex.core.booster.reload"; + public static final String THANK_COMMAND_PERMISSION = "mineplex.core.booster.thank"; private BoosterRepository _repository; private CoreClientManager _clientManager; @@ -100,6 +116,19 @@ public class BoosterManager extends MiniPlugin _giveInterfaceItem = canActivateBoosters(); new BoosterUpdateRepository(plugin); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(BOOSTER_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(THANK_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(ADD_BOOSTER_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(RELOAD_BOOSTERS_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(BOOSTER_GUI_COMMAND_PERMISSION), true, true); } @Override @@ -397,4 +426,4 @@ public class BoosterManager extends MiniPlugin { runSync(() -> getPluginManager().callEvent(event)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/AddCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/AddCommand.java index b86e382e3..a334efbba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/AddCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/AddCommand.java @@ -1,13 +1,14 @@ package mineplex.core.boosters.command; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + import mineplex.core.boosters.BoosterApiResponse; import mineplex.core.boosters.BoosterManager; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import org.bukkit.entity.Player; /** * @author Shaun Bennett @@ -16,7 +17,7 @@ public class AddCommand extends CommandBase { public AddCommand(BoosterManager plugin) { - super(plugin, Rank.DEVELOPER, "add"); + super(plugin, BoosterManager.ADD_BOOSTER_COMMAND_PERMISSION, "add"); } @Override @@ -49,6 +50,6 @@ public class AddCommand extends CommandBase private void help(Player caller) { - UtilPlayer.message(caller, F.help("amplifier add ", "Add an amplifier to that server group", Rank.DEVELOPER)); + UtilPlayer.message(caller, F.help("amplifier add ", "Add an amplifier to that server group", ChatColor.DARK_RED)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java index 42866745b..fa491b473 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java @@ -1,12 +1,12 @@ package mineplex.core.boosters.command; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + import mineplex.core.boosters.BoosterManager; -import mineplex.core.command.CommandBase; import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import org.bukkit.entity.Player; /** * @author Shaun Bennett @@ -15,7 +15,7 @@ public class BoosterCommand extends MultiCommandBase { public BoosterCommand(BoosterManager plugin) { - super(plugin, Rank.ALL, "amplifier"); + super(plugin, BoosterManager.BOOSTER_COMMAND_PERMISSION, "amplifier"); AddCommand(new AddCommand(plugin)); AddCommand(new GuiCommand(plugin)); @@ -26,8 +26,8 @@ public class BoosterCommand extends MultiCommandBase @Override protected void Help(Player caller, String[] args) { - UtilPlayer.message(caller, F.help("amplifier add ", "Add an amplifier to that group", Rank.DEVELOPER)); - UtilPlayer.message(caller, F.help("amplifier gui", "Open Amplifier GUI", Rank.DEVELOPER)); - UtilPlayer.message(caller, F.help("amplifier thank ", "Thank an Amplifier for a specific Booster Group", Rank.ALL)); + UtilPlayer.message(caller, F.help("amplifier add ", "Add an amplifier to that group", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("amplifier gui", "Open Amplifier GUI", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("amplifier thank ", "Thank an Amplifier for a specific Booster Group", ChatColor.WHITE)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/GuiCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/GuiCommand.java index 762565ce0..a17396680 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/GuiCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/GuiCommand.java @@ -1,9 +1,9 @@ package mineplex.core.boosters.command; +import org.bukkit.entity.Player; + import mineplex.core.boosters.BoosterManager; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import org.bukkit.entity.Player; /** * @author Shaun Bennett @@ -12,7 +12,7 @@ public class GuiCommand extends CommandBase { public GuiCommand(BoosterManager plugin) { - super(plugin, Rank.DEVELOPER, "gui"); + super(plugin, BoosterManager.BOOSTER_GUI_COMMAND_PERMISSION, "gui"); } @Override @@ -20,4 +20,4 @@ public class GuiCommand extends CommandBase { Plugin.openShop(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ReloadCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ReloadCommand.java index 3b8c543fd..d5b0f9ea7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ReloadCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ReloadCommand.java @@ -1,16 +1,11 @@ package mineplex.core.boosters.command; -import mineplex.core.boosters.Booster; -import mineplex.core.boosters.BoosterManager; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; import org.bukkit.entity.Player; -import java.util.List; -import java.util.Map; +import mineplex.core.boosters.BoosterManager; +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; /** * @author Shaun Bennett @@ -19,17 +14,18 @@ public class ReloadCommand extends CommandBase { public ReloadCommand(BoosterManager plugin) { - super(plugin, Rank.DEVELOPER, "reload"); + super(plugin, BoosterManager.RELOAD_BOOSTERS_COMMAND_PERMISSION, "reload"); } @Override public void Execute(Player caller, String[] args) { - Plugin.getBoostersAsync(data -> { + Plugin.getBoostersAsync(data -> + { if (data != null) { UtilPlayer.message(caller, F.main("Amplifier", "Amplifiers reloaded!")); } }); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java index b6a379fc0..0ec536c60 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java @@ -1,17 +1,17 @@ package mineplex.core.boosters.command; +import org.apache.commons.lang3.StringUtils; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + import mineplex.core.boosters.Booster; import mineplex.core.boosters.BoosterManager; import mineplex.core.boosters.tips.BoosterThankManager; import mineplex.core.boosters.tips.TipAddResult; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import org.apache.commons.lang3.StringUtils; -import org.bukkit.Sound; -import org.bukkit.entity.Player; /** * @author Shaun Bennett @@ -20,7 +20,7 @@ public class ThankCommand extends CommandBase { public ThankCommand(BoosterManager plugin) { - super(plugin, Rank.ALL, "thank"); + super(plugin, BoosterManager.THANK_COMMAND_PERMISSION, "thank"); } @Override @@ -71,4 +71,4 @@ public class ThankCommand extends CommandBase }); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java index d42e2b881..f5fb62df6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java @@ -11,23 +11,31 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; +import mineplex.core.botspam.command.BotSpamCommand; +import mineplex.core.botspam.repository.BotSpamRepository; import mineplex.core.message.PrivateMessageEvent; import mineplex.core.punish.Category; import mineplex.core.punish.Punish; -import mineplex.core.botspam.command.BotSpamCommand; -import mineplex.core.botspam.repository.BotSpamRepository; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.commands.ServerCommandManager; public class BotSpamManager extends MiniPlugin { + public static final String BYPASS_BOTSPAM_PERMISSION = "mineplex.core.botspam.bypass"; + public static final String BOTSPAM_COMMAND_PERMISSION = "mineplex.core.botspam.command"; + public static final String ADD_BOTSPAM_COMMAND_PERMISSION = "mineplex.core.botspam.add"; + public static final String TOGGLE_BOTSPAM_COMMAND_PERMISSION = "mineplex.core.botspam.toggle"; + public static final String UPDATE_BOTSPAM_COMMAND_PERMISSION = "mineplex.core.botspam.update"; + public static final String LIST_BOTSPAM_COMMAND_PERMISSION = "mineplex.core.botspam.list"; + private Punish _punish; private CoreClientManager _clientManager; private BotSpamRepository _repository; - private volatile ArrayList _spam = new ArrayList(); + private volatile List _spam = new ArrayList<>(); public BotSpamManager(JavaPlugin plugin, CoreClientManager clientManager, Punish punish) { @@ -39,6 +47,20 @@ public class BotSpamManager extends MiniPlugin _spam = _repository.getSpamText(); ServerCommandManager.getInstance().registerCommandType(ForceUpdateCommand.class, command -> runAsync(() -> _spam = _repository.getSpamText())); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BYPASS_BOTSPAM_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BOTSPAM_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(ADD_BOTSPAM_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TOGGLE_BOTSPAM_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(UPDATE_BOTSPAM_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(LIST_BOTSPAM_COMMAND_PERMISSION), true, true); } @EventHandler @@ -46,11 +68,11 @@ public class BotSpamManager extends MiniPlugin { Player recipient = event.getRecipient(); // Ignore messages sent to staff members - if (_clientManager.hasRank(recipient, Rank.HELPER)) + if (_clientManager.getPermissionManager().hasPermission(recipient, GroupPermission.of(BYPASS_BOTSPAM_PERMISSION))) return; // Ignore messages sent by staff members - if (_clientManager.hasRank(event.getSender(), Rank.HELPER)) + if (_clientManager.getPermissionManager().hasPermission(event.getSender(), GroupPermission.of(BYPASS_BOTSPAM_PERMISSION))) return; for (SpamText spamText : _spam) @@ -68,7 +90,7 @@ public class BotSpamManager extends MiniPlugin public void onChat(final AsyncPlayerChatEvent event) { // Ignore messages sent by staff members - if (_clientManager.hasRank(event.getPlayer(), Rank.HELPER)) + if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(BYPASS_BOTSPAM_PERMISSION))) return; for (final SpamText spamText : _spam) @@ -98,7 +120,9 @@ public class BotSpamManager extends MiniPlugin _spam = _repository.getSpamText(); if (callback != null) + { runSync(callback); + } }); } @@ -114,7 +138,9 @@ public class BotSpamManager extends MiniPlugin spamText.setEnabledBy(caller); if (callback != null) + { callback.run(); + } }); }); } @@ -131,7 +157,9 @@ public class BotSpamManager extends MiniPlugin spamText.setDisabledBy(caller); if (callback != null) + { callback.run(); + } }); }); } @@ -155,4 +183,4 @@ public class BotSpamManager extends MiniPlugin { addCommand(new BotSpamCommand(this)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamAddCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamAddCommand.java index adfa6d20a..4680f444d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamAddCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamAddCommand.java @@ -3,18 +3,17 @@ package mineplex.core.botspam.command; import org.apache.commons.lang3.StringUtils; import org.bukkit.entity.Player; +import mineplex.core.botspam.BotSpamManager; import mineplex.core.botspam.SpamText; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.botspam.BotSpamManager; public class BotSpamAddCommand extends CommandBase { public BotSpamAddCommand(BotSpamManager plugin) { - super(plugin, Rank.ADMIN, "add"); + super(plugin, BotSpamManager.ADD_BOTSPAM_COMMAND_PERMISSION, "add"); } @Override @@ -50,4 +49,4 @@ public class BotSpamAddCommand extends CommandBase UtilPlayer.message(caller, F.main("BotSpam", "/botspam add ")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamCommand.java index 39013e95c..e62de6dd1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamCommand.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import mineplex.core.botspam.BotSpamManager; import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -12,7 +11,7 @@ public class BotSpamCommand extends MultiCommandBase { public BotSpamCommand(BotSpamManager plugin) { - super(plugin, Rank.ADMIN, "botban", "botspam"); + super(plugin, BotSpamManager.BOTSPAM_COMMAND_PERMISSION, "botban", "botspam"); AddCommand(new BotSpamAddCommand(Plugin)); AddCommand(new BotSpamEnableCommand(Plugin)); @@ -30,4 +29,4 @@ public class BotSpamCommand extends MultiCommandBase UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable ")); UtilPlayer.message(caller, F.main("BotSpam", "/botspam globalupdate")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamDisableCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamDisableCommand.java index 2736c30eb..509909ff6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamDisableCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamDisableCommand.java @@ -2,10 +2,9 @@ package mineplex.core.botspam.command; import org.bukkit.entity.Player; +import mineplex.core.botspam.BotSpamManager; import mineplex.core.botspam.SpamText; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.botspam.BotSpamManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -13,7 +12,7 @@ public class BotSpamDisableCommand extends CommandBase { public BotSpamDisableCommand(BotSpamManager plugin) { - super(plugin, Rank.ADMIN, "disable"); + super(plugin, BotSpamManager.TOGGLE_BOTSPAM_COMMAND_PERMISSION, "disable"); } @Override @@ -59,6 +58,5 @@ public class BotSpamDisableCommand extends CommandBase { UtilPlayer.message(caller, F.main("BotSpam", "/botspam disable ")); } - } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamEnableCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamEnableCommand.java index 18746c60c..c6d0cf8b3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamEnableCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamEnableCommand.java @@ -2,10 +2,9 @@ package mineplex.core.botspam.command; import org.bukkit.entity.Player; +import mineplex.core.botspam.BotSpamManager; import mineplex.core.botspam.SpamText; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.botspam.BotSpamManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -13,7 +12,7 @@ public class BotSpamEnableCommand extends CommandBase { public BotSpamEnableCommand(BotSpamManager plugin) { - super(plugin, Rank.ADMIN, "enable"); + super(plugin, BotSpamManager.TOGGLE_BOTSPAM_COMMAND_PERMISSION, "enable"); } @Override @@ -59,6 +58,5 @@ public class BotSpamEnableCommand extends CommandBase { UtilPlayer.message(caller, F.main("BotSpam", "/botspam enable ")); } - } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamGlobalUpdateCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamGlobalUpdateCommand.java index 769410e53..693d26a46 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamGlobalUpdateCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamGlobalUpdateCommand.java @@ -4,9 +4,7 @@ import org.bukkit.entity.Player; import mineplex.core.botspam.BotSpamManager; import mineplex.core.botspam.ForceUpdateCommand; -import mineplex.core.botspam.SpamText; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.serverdata.commands.ServerCommandManager; @@ -15,7 +13,7 @@ public class BotSpamGlobalUpdateCommand extends CommandBase { public BotSpamGlobalUpdateCommand(BotSpamManager plugin) { - super(plugin, Rank.ADMIN, "globalupdate"); + super(plugin, BotSpamManager.UPDATE_BOTSPAM_COMMAND_PERMISSION, "globalupdate"); } @Override @@ -24,4 +22,4 @@ public class BotSpamGlobalUpdateCommand extends CommandBase ServerCommandManager.getInstance().publishCommand(new ForceUpdateCommand()); UtilPlayer.message(caller, F.main("Botspam", "Forced an update across all servers!")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamListCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamListCommand.java index a0be34906..3166f42c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamListCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamListCommand.java @@ -3,28 +3,26 @@ package mineplex.core.botspam.command; import java.util.Collections; import java.util.List; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; - import org.apache.commons.lang.StringUtils; import org.bukkit.entity.Player; import mineplex.core.botspam.BotSpamManager; import mineplex.core.botspam.SpamText; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; public class BotSpamListCommand extends CommandBase { public BotSpamListCommand(BotSpamManager plugin) { - super(plugin, Rank.ADMIN, "list"); + super(plugin, BotSpamManager.LIST_BOTSPAM_COMMAND_PERMISSION, "list"); } @Override @@ -207,4 +205,4 @@ public class BotSpamListCommand extends CommandBase caller.spigot().sendMessage(pageSwitch.create()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index 3949ff3fe..1368e3f8f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -1,25 +1,26 @@ package mineplex.core.chat; -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.achievement.AchievementManager; -import mineplex.core.antispam.AntiSpamManager; -import mineplex.core.chat.command.BroadcastCommand; -import mineplex.core.chat.command.ChatSlowCommand; -import mineplex.core.chat.command.SilenceCommand; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -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; -import mineplex.core.updater.event.UpdateEvent; +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.nio.charset.Charset; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.function.Function; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; + import org.apache.commons.lang3.Validate; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -34,28 +35,40 @@ import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.JSONValue; -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; -import java.nio.charset.Charset; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; -import java.util.function.Function; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; +import mineplex.core.achievement.AchievementManager; +import mineplex.core.chat.command.BroadcastCommand; +import mineplex.core.chat.command.ChatSlowCommand; +import mineplex.core.chat.command.SilenceCommand; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +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.incognito.IncognitoManager; +import mineplex.core.preferences.Preference; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class Chat extends MiniPlugin { + public static final String ALLOW_CAPS_PERMISSION = "mineplex.core.chat.allowcaps"; + public static final String BYPASS_COOLDOWN_PERMISSION = "mineplex.core.chat.bypasscooldown"; + public static final String BYPASS_SLOW_PERMISSION = "mineplex.core.chat.bypasschatslow"; + public static final String BYPASS_SILENCE_PERMISSION = "mineplex.core.chat.bypasssilence"; + public static final String BYPASS_SIGNS_PERMISSION = "mineplex.core.chat.bypasssigns"; + public static final String ALLOW_HACKUSATE_PERMISSION = "mineplex.core.chat.allowhackusate"; + public static final String ALLOW_SIMILAR_PERMISSION = "mineplex.core.chat.allowsimilar"; + public static final String SILENCE_COMMAND_PERMISSION = "mineplex.core.chat.silence"; + public static final String SLOW_CHAT_COMMAND_PERMISSION = "mineplex.core.chat.chatslow"; + public static final String BROADCAST_COMMAND_PERMISSION = "mineplex.core.chat.broadcast"; + private CoreClientManager _clientManager; private PreferencesManager _preferences; private AchievementManager _achievements; @@ -73,7 +86,7 @@ public class Chat extends MiniPlugin private List> _highPriorityFilters = new ArrayList<>(); private List> _lowPriorityFilters = new ArrayList<>(); - private HashMap _playerLastMessage = new HashMap(); + private Map _playerLastMessage = new HashMap<>(); public Chat(JavaPlugin plugin, IncognitoManager incognitoManager, CoreClientManager clientManager, PreferencesManager preferences, AchievementManager achievements, String serverName) { @@ -93,6 +106,23 @@ public class Chat extends MiniPlugin { e.printStackTrace(); } + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(ALLOW_CAPS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(BYPASS_COOLDOWN_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BYPASS_SLOW_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(BYPASS_SILENCE_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BYPASS_SIGNS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(ALLOW_HACKUSATE_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(ALLOW_SIMILAR_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SILENCE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(SLOW_CHAT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(BROADCAST_COMMAND_PERMISSION), true, true); } @Override @@ -190,7 +220,7 @@ public class Chat extends MiniPlugin if (_silenced == 0) return false; - if (_clientManager.Get(player).GetRank().has(player, Rank.MODERATOR, false)) + if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(BYPASS_SILENCE_PERMISSION))) return false; if (_silenced == -1) @@ -208,7 +238,10 @@ public class Chat extends MiniPlugin @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onSignChange(SignChangeEvent event) { - if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.ADMIN)) return; + if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(BYPASS_SIGNS_PERMISSION))) + { + return; + } // Prevent silenced players from using signs if (SilenceCheck(event.getPlayer())) @@ -343,13 +376,13 @@ public class Chat extends MiniPlugin event.setCancelled(true); return; } - else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) && + else if (!_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(BYPASS_COOLDOWN_PERMISSION)) && !Recharge.Instance.use(sender, "Chat Message", 400, false, false)) { UtilPlayer.message(sender, F.main("Chat", "You are sending messages too fast.")); event.setCancelled(true); } - else if (!_clientManager.Get(sender).GetRank().has(Rank.HELPER) && + else if (!_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(ALLOW_HACKUSATE_PERMISSION)) && msgContainsHack(event.getMessage())) { UtilPlayer.message(sender, F.main("Chat", @@ -363,12 +396,12 @@ public class Chat extends MiniPlugin MessageData lastMessage = _playerLastMessage.get(sender.getUniqueId()); long chatSlowTime = 1000L * _chatSlow; long timeDiff = System.currentTimeMillis() - lastMessage.getTimeSent(); - if (timeDiff < chatSlowTime && !_clientManager.Get(sender).GetRank().has(Rank.HELPER)) + if (timeDiff < chatSlowTime && !_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(BYPASS_SLOW_PERMISSION))) { UtilPlayer.message(sender, F.main("Chat", "Chat slow enabled. Please wait " + F.time(UtilTime.convertString(chatSlowTime - timeDiff, 1, UtilTime.TimeUnit.FIT)))); event.setCancelled(true); } - else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) && + else if (!_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(ALLOW_SIMILAR_PERMISSION)) && UtilText.isStringSimilar(event.getMessage(), lastMessage.getMessage(), 0.8f)) { UtilPlayer.message(sender, F.main("Chat", "This message is too similar to your previous message.")); @@ -379,7 +412,7 @@ public class Chat extends MiniPlugin if (!event.isCancelled()) { String oldMessage = event.getMessage(); - if (!_clientManager.Get(sender).GetRank().has(Rank.ADMIN)) + if (!_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(ALLOW_CAPS_PERMISSION))) { int capsCount = 0; for (char c : oldMessage.toCharArray()) @@ -669,5 +702,4 @@ public class Chat extends MiniPlugin _lowPriorityFilters.add(restriction); } } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/BroadcastCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/BroadcastCommand.java index ed97355c8..191cdfc4b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/BroadcastCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/BroadcastCommand.java @@ -4,7 +4,6 @@ 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.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -13,7 +12,7 @@ public class BroadcastCommand extends CommandBase { public BroadcastCommand(Chat plugin) { - super(plugin, Rank.MODERATOR, "s"); + super(plugin, Chat.BROADCAST_COMMAND_PERMISSION, "s"); } @Override @@ -35,4 +34,4 @@ public class BroadcastCommand extends CommandBase UtilServer.broadcast(caller.getName(), announcement); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/ChatSlowCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/ChatSlowCommand.java index d15fc0f72..6eb8c772e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/ChatSlowCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/ChatSlowCommand.java @@ -4,7 +4,6 @@ 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.F; import mineplex.core.common.util.UtilPlayer; @@ -12,7 +11,7 @@ public class ChatSlowCommand extends CommandBase { public ChatSlowCommand(Chat plugin) { - super(plugin, Rank.SNR_MODERATOR, "chatslow"); + super(plugin, Chat.SLOW_CHAT_COMMAND_PERMISSION, "chatslow"); } @Override @@ -48,4 +47,4 @@ public class ChatSlowCommand extends CommandBase { UtilPlayer.message(caller, F.main("Chat", "Usage: /chatslow ")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/SilenceCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/SilenceCommand.java index d1206f8c1..9649cddc1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/SilenceCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/SilenceCommand.java @@ -4,7 +4,6 @@ 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.F; import mineplex.core.common.util.UtilPlayer; @@ -12,7 +11,7 @@ public class SilenceCommand extends CommandBase { public SilenceCommand(Chat plugin) { - super(plugin, Rank.ADMIN, "silence"); + super(plugin, Chat.SILENCE_COMMAND_PERMISSION, "silence"); } @Override @@ -47,4 +46,4 @@ public class SilenceCommand extends CommandBase UtilPlayer.message(caller, F.main("Chat", "Invalid Time Parameter.")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java index 7aaba16a4..fb36270d4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java @@ -11,6 +11,8 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.chatsnap.command.ChatSnapCommand; import mineplex.core.message.PrivateMessageEvent; @@ -19,6 +21,8 @@ import mineplex.core.message.PrivateMessageEvent; */ public class SnapshotPlugin extends MiniPlugin { + public static final String CHAT_SNAP_COMMAND_PERMISSION = "mineplex.core.chatsnap.command"; + private final SnapshotManager _snapshotManager; private final CoreClientManager _clientManager; @@ -27,6 +31,15 @@ public class SnapshotPlugin extends MiniPlugin super("ChatSnap", plugin); _snapshotManager = snapshotManager; _clientManager = clientManager; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("titan"), GroupPermission.of(CHAT_SNAP_COMMAND_PERMISSION), true, true); } public SnapshotManager getSnapshotManager() @@ -79,4 +92,4 @@ public class SnapshotPlugin extends MiniPlugin String message = e.getMessage(); return new SnapshotMessage(senderId, recipientId, message); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java index 1c085c647..b55002e92 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java @@ -9,7 +9,6 @@ import mineplex.core.chatsnap.SnapshotMessage; import mineplex.core.chatsnap.SnapshotPlugin; import mineplex.core.chatsnap.SnapshotRepository; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; @@ -23,7 +22,7 @@ public class ChatSnapCommand extends CommandBase { public ChatSnapCommand(SnapshotPlugin plugin) { - super(plugin, Rank.TITAN, "chatsnap"); + super(plugin, SnapshotPlugin.CHAT_SNAP_COMMAND_PERMISSION, "chatsnap"); } @Override @@ -68,4 +67,4 @@ public class ChatSnapCommand extends CommandBase UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Invalid Usage: " + F.elem("/" + _aliasUsed))); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java index 264fe539f..e0ce0e24d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java @@ -15,34 +15,23 @@ import org.bukkit.entity.Player; import mineplex.core.MiniPlugin; import mineplex.core.PlayerSelector; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.UtilLambda; import mineplex.core.recharge.Recharge; public abstract class CommandBase implements ICommand { - private Rank _requiredRank; - private Rank[] _specificRank; - + private final GroupPermission _permission; private List _aliases; protected PluginType Plugin; protected String _aliasUsed; protected CommandCenter _commandCenter; - public CommandBase(PluginType plugin, Rank requiredRank, String... aliases) + public CommandBase(PluginType plugin, String permission, String... aliases) { Plugin = plugin; - _requiredRank = requiredRank; - _aliases = Arrays.asList(aliases); - } - - public CommandBase(PluginType plugin, Rank requiredRank, Rank[] specificRank, String... aliases) - { - Plugin = plugin; - _requiredRank = requiredRank; - _specificRank = specificRank; - + _permission = GroupPermission.of(permission); _aliases = Arrays.asList(aliases); } @@ -56,19 +45,9 @@ public abstract class CommandBase implements ICom _aliasUsed = alias; } - public Rank GetRequiredRank() + public GroupPermission getPermission() { - return _requiredRank; - } - - public void setRequiredRank(Rank rank) - { - _requiredRank = rank; - } - - public Rank[] GetSpecificRanks() - { - return _specificRank; + return _permission; } public void SetCommandCenter(CommandCenter commandCenter) @@ -158,4 +137,4 @@ public abstract class CommandBase implements ICom } return null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java index 988c6316f..24b7ec3c5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java @@ -1,17 +1,11 @@ package mineplex.core.command; import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import net.minecraft.server.v1_8_R3.PacketPlayInTabComplete; -import net.minecraft.server.v1_8_R3.PacketPlayOutTabComplete; -import net.minecraft.server.v1_8_R3.PlayerConnection; - import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -22,15 +16,19 @@ import com.google.common.collect.Lists; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketInfo; import mineplex.core.recharge.Recharge; +import net.minecraft.server.v1_8_R3.PacketPlayInTabComplete; +import net.minecraft.server.v1_8_R3.PacketPlayOutTabComplete; +import net.minecraft.server.v1_8_R3.PlayerConnection; public class CommandCenter implements Listener, IPacketHandler { @@ -45,6 +43,8 @@ public class CommandCenter implements Listener, IPacketHandler private final PacketHandler _packetHandler = Managers.require(PacketHandler.class); private static AtomicIntegerFieldUpdater chatSpamField = null; + + public static final String BLOCKED_COMMAND_PERMISSION = "mineplex.core.command.blockedexecute"; static { @@ -83,6 +83,8 @@ public class CommandCenter implements Listener, IPacketHandler public void setClientManager(CoreClientManager clientManager) { ClientManager = clientManager; + + clientManager.getPermissionManager().setPermission(clientManager.getPermissionManager().getGroup("dev"), GroupPermission.of(BLOCKED_COMMAND_PERMISSION), true, true); } @EventHandler @@ -104,7 +106,7 @@ public class CommandCenter implements Listener, IPacketHandler { event.setCancelled(true); - if (ClientManager.Get(event.getPlayer()).GetRank().has(event.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true) + if (ClientManager.getPermissionManager().hasPermission(event.getPlayer(), command.getPermission()) || UtilPlayer.isCommandAllowed(event.getPlayer(), commandName.toLowerCase())) { if (!Recharge.Instance.use(event.getPlayer(), "Command", 500, false, false)) @@ -122,10 +124,14 @@ public class CommandCenter implements Listener, IPacketHandler command.Execute(event.getPlayer(), args); } + else + { + UtilPlayerBase.message(event.getPlayer(), C.mHead + "Permissions> " + C.mBody + "You do not have permission for that."); + } return; } - if (BLOCKED_COMMANDS.contains(commandName.toLowerCase()) && !(event.getPlayer().isOp() || ClientManager.Get(event.getPlayer()).GetRank().has(Rank.DEVELOPER))) + if (BLOCKED_COMMANDS.contains(commandName.toLowerCase()) && !(event.getPlayer().isOp() || ClientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(BLOCKED_COMMAND_PERMISSION)))) { event.setCancelled(true); event.getPlayer().sendMessage(MESSAGE); @@ -199,7 +205,7 @@ public class CommandCenter implements Listener, IPacketHandler if (command != null) { - if (ClientManager.Get(packetInfo.getPlayer()).GetRank().has(packetInfo.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), false) + if (ClientManager.getPermissionManager().hasPermission(packetInfo.getPlayer(), command.getPermission()) || UtilPlayer.isCommandAllowed(packetInfo.getPlayer(), commandName.toLowerCase())) { List tmpres = command.onTabComplete(packetInfo.getPlayer(), commandName.toLowerCase(), args); @@ -216,7 +222,7 @@ public class CommandCenter implements Listener, IPacketHandler // System.out.println("Path 2"); for (ICommand command : Commands.values()) { - if (ClientManager.Get(packetInfo.getPlayer()).GetRank().has(packetInfo.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), false) + if (ClientManager.getPermissionManager().hasPermission(packetInfo.getPlayer(), command.getPermission()) || UtilPlayer.isCommandAllowed(packetInfo.getPlayer(), commandName.toLowerCase())) { for (String alias : command.Aliases()) @@ -236,4 +242,4 @@ public class CommandCenter implements Listener, IPacketHandler } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/ICommand.java b/Plugins/Mineplex.Core/src/mineplex/core/command/ICommand.java index f1ba3deaf..24751aaef 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/ICommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/ICommand.java @@ -3,12 +3,12 @@ package mineplex.core.command; import java.util.Collection; import java.util.List; -import mineplex.core.common.Rank; - -import mineplex.core.lifetimes.Component; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.lifetimes.Component; + public interface ICommand extends Component { void SetCommandCenter(CommandCenter commandCenter); @@ -17,9 +17,8 @@ public interface ICommand extends Component Collection Aliases(); void SetAliasUsed(String name); - - Rank GetRequiredRank(); - Rank[] GetSpecificRanks(); + + GroupPermission getPermission(); @Override default void activate() @@ -34,4 +33,4 @@ public interface ICommand extends Component } List onTabComplete(CommandSender sender, String commandLabel, String[] args); -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/LoggedCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/command/LoggedCommand.java index fa6f21d74..643ebaf3b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/LoggedCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/LoggedCommand.java @@ -7,11 +7,9 @@ package mineplex.core.command; */ public interface LoggedCommand { - default void execute(long time, String username, String command, String args) { LoggingServerCommand cmd = new LoggingServerCommand(time, username, command, args); cmd.publish(); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/LoggingServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/command/LoggingServerCommand.java index 34e02073d..8e06dd583 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/LoggingServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/LoggingServerCommand.java @@ -21,4 +21,4 @@ public class LoggingServerCommand extends ServerCommand _command = command; _args = args; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/MultiCommandBase.java b/Plugins/Mineplex.Core/src/mineplex/core/command/MultiCommandBase.java index a8d751c9c..b9913550d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/MultiCommandBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/MultiCommandBase.java @@ -9,23 +9,17 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; +import mineplex.core.common.util.C; import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilPlayerBase; public abstract class MultiCommandBase extends CommandBase { private NautHashMap Commands; - public MultiCommandBase(PluginType plugin, Rank rank, String... aliases) + public MultiCommandBase(PluginType plugin, String permission, String... aliases) { - super(plugin, rank, aliases); - - Commands = new NautHashMap<>(); - } - - public MultiCommandBase(PluginType plugin, Rank rank, Rank[] specificRanks, String... aliases) - { - super(plugin, rank, specificRanks, aliases); + super(plugin, permission, aliases); Commands = new NautHashMap<>(); } @@ -72,11 +66,18 @@ public abstract class MultiCommandBase extends Co ICommand command = Commands.get(commandName); - if (command != null && _commandCenter.ClientManager.Get(caller).GetRank().has(caller, command.GetRequiredRank(), command.GetSpecificRanks(), true)) + if (command != null) { - command.SetAliasUsed(commandName); - - command.Execute(caller, newArgs); + if (_commandCenter.ClientManager.getPermissionManager().hasPermission(caller, command.getPermission())) + { + command.SetAliasUsed(commandName); + + command.Execute(caller, newArgs); + } + else + { + UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that."); + } } else { @@ -105,7 +106,7 @@ public abstract class MultiCommandBase extends Co Stream stream = Commands.values().stream(); if (sender instanceof Player) { - stream = stream.filter(command -> _commandCenter.GetClientManager().Get((Player) sender).GetRank().has((Player) sender, command.GetRequiredRank(), command.GetSpecificRanks(), false)); + stream = stream.filter(command -> _commandCenter.GetClientManager().getPermissionManager().hasPermission((Player)sender, command.getPermission())); } return getMatches(args[0], stream.map(ICommand::Aliases).flatMap(Collection::stream)); } @@ -114,4 +115,4 @@ public abstract class MultiCommandBase extends Co } protected abstract void Help(Player caller, String[] args); -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java index 19a6a5609..c8db5ac87 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java @@ -25,6 +25,8 @@ import mineplex.core.Managers; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; @@ -71,6 +73,24 @@ import mineplex.serverdata.servers.ServerRepository; public class CommunityManager extends MiniDbClientPlugin { + public static final String OWN_COMMUNITY_PERMISSION = "mineplex.core.communities.own"; + public static final String COMMUNITY_CHAT_COMMAND_PERMISSION = "mineplex.core.communities.chat"; + public static final String COMMUNITY_COMMAND_PERMISSION = "mineplex.core.communities.command"; + public static final String COMMUNITY_DESCRIPTION_COMMAND_PERMISSION = "mineplex.core.communities.description"; + public static final String COMMUNITY_DESCRIPTION_STAFF_COMMAND_PERMISSION = "mineplex.core.communities.description.staff"; + public static final String COMMUNITY_DISBAND_COMMAND_PERMISSION = "mineplex.core.communities.disband"; + public static final String COMMUNITY_DISBAND_STAFF_COMMAND_PERMISSION = "mineplex.core.communities.disband.staff"; + public static final String COMMUNITY_INVITE_COMMAND_PERMISSION = "mineplex.core.communities.invite"; + public static final String COMMUNITY_INVITE_STAFF_COMMAND_PERMISSION = "mineplex.core.communities.invite.staff"; + public static final String COMMUNITY_JOIN_COMMAND_PERMISSION = "mineplex.core.communities.join"; + public static final String COMMUNITY_MCS_COMMAND_PERMISSION = "mineplex.core.communities.mcs"; + public static final String COMMUNITY_MCS_STAFF_COMMAND_PERMISSION = "mineplex.core.communities.mcs.staff"; + public static final String COMMUNITY_MENU_COMMAND_PERMISSION = "mineplex.core.communities.menu"; + public static final String COMMUNITY_RENAME_COMMAND_PERMISSION = "mineplex.core.communities.rename"; + public static final String COMMUNITY_RENAME_STAFF_COMMAND_PERMISSION = "mineplex.core.communities.rename.staff"; + public static final String COMMUNITY_UNINVITE_COMMAND_PERMISSION = "mineplex.core.communities.uninvite"; + public static final String COMMUNITY_UNINVITE_STAFF_COMMAND_PERMISSION = "mineplex.core.communities.uninvite.staff"; + private final int UPDATE_CYCLE_SECONDS = 10; // The number of seconds between dirty communities refreshes private final int CACHE_INVALIDATION_SECONDS = 300; // The number of seconds between full communities refreshes public final Pattern ALPHA_NUMERIC_PATTERN = Pattern.compile("[^A-Za-z0-9]"); @@ -183,6 +203,31 @@ public class CommunityManager extends MiniDbClientPlugin ServerCommandManager.getInstance().registerCommandType(CommunityUpdateMembership.class, new CommunityUpdateMembershipHandler(this)); ServerCommandManager.getInstance().registerCommandType(CommunityUpdateName.class, new CommunityUpdateNameHandler(this)); ServerCommandManager.getInstance().registerCommandType(CommunityUpdateSetting.class, new CommunityUpdateSettingHandler(this)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("eternal"), GroupPermission.of(OWN_COMMUNITY_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_CHAT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_DESCRIPTION_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(COMMUNITY_DESCRIPTION_STAFF_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("eternal"), GroupPermission.of(COMMUNITY_DISBAND_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(COMMUNITY_DISBAND_STAFF_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_INVITE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(COMMUNITY_INVITE_STAFF_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_JOIN_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_MCS_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(COMMUNITY_MCS_STAFF_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_MENU_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("eternal"), GroupPermission.of(COMMUNITY_RENAME_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(COMMUNITY_RENAME_STAFF_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMMUNITY_UNINVITE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(COMMUNITY_UNINVITE_STAFF_COMMAND_PERMISSION), true, true); } public boolean ownsCommunity(UUID uuid) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityChatCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityChatCommand.java index a1edba960..d6827f07e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityChatCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityChatCommand.java @@ -4,7 +4,6 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.communities.Community; @@ -14,7 +13,7 @@ public class CommunityChatCommand extends CommandBase { public CommunityChatCommand(CommunityManager plugin) { - super(plugin, Rank.ALL, "chat"); + super(plugin, CommunityManager.COMMUNITY_CHAT_COMMAND_PERMISSION, "chat"); } @Override @@ -22,7 +21,7 @@ public class CommunityChatCommand extends CommandBase { if (args.length < 1) { - UtilPlayer.message(caller, F.help("/com chat ", "Selects which community you chat to", Rank.ALL, ChatColor.AQUA)); + UtilPlayer.message(caller, F.help("/com chat ", "Selects which community you chat to", ChatColor.DARK_AQUA)); return; } Community c = Plugin.getLoadedCommunity(args[0]); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCommand.java index 90af36ac7..e8620afad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCommand.java @@ -4,7 +4,6 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.communities.Community; @@ -16,7 +15,7 @@ public class CommunityCommand extends MultiCommandBase { public CommunityCommand(CommunityManager plugin) { - super(plugin, Rank.ALL, "community", "communities", "com"); + super(plugin, CommunityManager.COMMUNITY_COMMAND_PERMISSION, "community", "communities", "com"); AddCommand(new CommunityChatCommand(plugin)); AddCommand(new CommunityCreateCommand(plugin)); @@ -38,17 +37,16 @@ public class CommunityCommand extends MultiCommandBase if (args[0].equalsIgnoreCase("help")) { UtilPlayer.message(caller, F.main(Plugin.getName(), "Community Commands:")); - UtilPlayer.message(caller, F.help("/com ", "Opens a community's menu", Rank.ALL, ChatColor.DARK_AQUA)); - //UtilPlayer.message(caller, F.help("/com menu", "Opens your community menu", Rank.ALL)); - UtilPlayer.message(caller, F.help("/com invite ", "Invites a player to a community you manage", Rank.ALL, ChatColor.DARK_AQUA)); - UtilPlayer.message(caller, F.help("/com uninvite ", "Revokes a player's invitation to a community you manage", Rank.ALL, ChatColor.DARK_AQUA)); - UtilPlayer.message(caller, F.help("/com join ", "Joins a community that is open or you have been invited to", Rank.ALL, ChatColor.DARK_AQUA)); - UtilPlayer.message(caller, F.help("/com chat ", "Selects which community you chat to", Rank.ALL, ChatColor.DARK_AQUA)); - UtilPlayer.message(caller, F.help("/com create ", "Creates a new community", Rank.ETERNAL, ChatColor.DARK_AQUA)); - UtilPlayer.message(caller, F.help("/com rename ", "Changes the name of a community you own", Rank.ETERNAL, ChatColor.DARK_AQUA)); - UtilPlayer.message(caller, F.help("/com mcs ", "Opens the Mineplex Community Server of a community you manage", Rank.ALL, ChatColor.DARK_AQUA)); - UtilPlayer.message(caller, F.help("/com description ", "Sets the description of a community you manage", Rank.ALL, ChatColor.DARK_AQUA)); - UtilPlayer.message(caller, F.help("/com disband ", "Disbands a community you own", Rank.ETERNAL, ChatColor.DARK_AQUA)); + UtilPlayer.message(caller, F.help("/com ", "Opens a community's menu", ChatColor.DARK_AQUA)); + UtilPlayer.message(caller, F.help("/com invite ", "Invites a player to a community you manage", ChatColor.DARK_AQUA)); + UtilPlayer.message(caller, F.help("/com uninvite ", "Revokes a player's invitation to a community you manage", ChatColor.DARK_AQUA)); + UtilPlayer.message(caller, F.help("/com join ", "Joins a community that is open or you have been invited to", ChatColor.DARK_AQUA)); + UtilPlayer.message(caller, F.help("/com chat ", "Selects which community you chat to", ChatColor.DARK_AQUA)); + UtilPlayer.message(caller, F.help("/com create ", "Creates a new community", ChatColor.DARK_AQUA)); + UtilPlayer.message(caller, F.help("/com rename ", "Changes the name of a community you own", ChatColor.DARK_AQUA)); + UtilPlayer.message(caller, F.help("/com mcs ", "Opens the Mineplex Community Server of a community you manage", ChatColor.DARK_AQUA)); + UtilPlayer.message(caller, F.help("/com description ", "Sets the description of a community you manage", ChatColor.DARK_AQUA)); + UtilPlayer.message(caller, F.help("/com disband ", "Disbands a community you own", ChatColor.DARK_AQUA)); return; } Community community = Plugin.getLoadedCommunity(args[0]); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCreateCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCreateCommand.java index af4d189d4..c90de7437 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCreateCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCreateCommand.java @@ -9,7 +9,6 @@ import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; import mineplex.core.chat.Chat; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.communities.Community; @@ -19,7 +18,7 @@ public class CommunityCreateCommand extends CommandBase { public CommunityCreateCommand(CommunityManager plugin) { - super(plugin, Rank.ETERNAL, "create"); + super(plugin, CommunityManager.OWN_COMMUNITY_PERMISSION, "create"); } @Override @@ -27,7 +26,7 @@ public class CommunityCreateCommand extends CommandBase { if (args.length < 1) { - UtilPlayer.message(caller, F.help("/com create ", "Creates a new community", Rank.ETERNAL, ChatColor.AQUA)); + UtilPlayer.message(caller, F.help("/com create ", "Creates a new community", ChatColor.DARK_AQUA)); return; } Community c = Plugin.getLoadedCommunity(args[0]); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDescriptionCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDescriptionCommand.java index efaae74b2..6ab6f6d9e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDescriptionCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDescriptionCommand.java @@ -5,9 +5,9 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.chat.Chat; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.communities.Community; @@ -20,7 +20,7 @@ public class CommunityDescriptionCommand extends CommandBase { public CommunityDescriptionCommand(CommunityManager plugin) { - super(plugin, Rank.ALL, "description"); + super(plugin, CommunityManager.COMMUNITY_DESCRIPTION_COMMAND_PERMISSION, "description"); } @Override @@ -28,7 +28,7 @@ public class CommunityDescriptionCommand extends CommandBase { if (args.length < 2) { - UtilPlayer.message(caller, F.help("/com description ", "Sets the description of a community you manage", Rank.ALL, ChatColor.AQUA)); + UtilPlayer.message(caller, F.help("/com description ", "Sets the description of a community you manage", ChatColor.DARK_AQUA)); return; } Community c = Plugin.getLoadedCommunity(args[0]); @@ -44,7 +44,7 @@ public class CommunityDescriptionCommand extends CommandBase } if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal()) { - if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN)) + if (!Managers.get(CoreClientManager.class).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_DESCRIPTION_STAFF_COMMAND_PERMISSION))) { UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDisbandCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDisbandCommand.java index a70b77542..fbc51d35c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDisbandCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDisbandCommand.java @@ -5,8 +5,8 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.communities.Community; @@ -18,7 +18,7 @@ public class CommunityDisbandCommand extends CommandBase { public CommunityDisbandCommand(CommunityManager plugin) { - super(plugin, Rank.ETERNAL, "disband"); + super(plugin, CommunityManager.COMMUNITY_DISBAND_COMMAND_PERMISSION, "disband"); } @Override @@ -26,7 +26,7 @@ public class CommunityDisbandCommand extends CommandBase { if (args.length < 1) { - UtilPlayer.message(caller, F.help("/com disband ", "Disbands a community you own", Rank.ETERNAL, ChatColor.AQUA)); + UtilPlayer.message(caller, F.help("/com disband ", "Disbands a community you own", ChatColor.DARK_AQUA)); return; } Community c = Plugin.getLoadedCommunity(args[0]); @@ -37,7 +37,7 @@ public class CommunityDisbandCommand extends CommandBase } if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role != CommunityRole.LEADER) { - if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN)) + if (!Managers.get(CoreClientManager.class).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_DISBAND_STAFF_COMMAND_PERMISSION))) { UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not the leader of " + F.name(c.getName()) + "!")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityInviteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityInviteCommand.java index f3b6e6b65..ca45ce276 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityInviteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityInviteCommand.java @@ -5,8 +5,8 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.communities.Community; @@ -18,7 +18,7 @@ public class CommunityInviteCommand extends CommandBase { public CommunityInviteCommand(CommunityManager plugin) { - super(plugin, Rank.ALL, "invite"); + super(plugin, CommunityManager.COMMUNITY_INVITE_COMMAND_PERMISSION, "invite"); } @Override @@ -26,7 +26,7 @@ public class CommunityInviteCommand extends CommandBase { if (args.length < 2) { - UtilPlayer.message(caller, F.help("/com invite ", "Invites a player to a community you manage", Rank.ALL, ChatColor.AQUA)); + UtilPlayer.message(caller, F.help("/com invite ", "Invites a player to a community you manage", ChatColor.DARK_AQUA)); return; } String player = args[0]; @@ -38,7 +38,7 @@ public class CommunityInviteCommand extends CommandBase } if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal()) { - if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN)) + if (!Managers.get(CoreClientManager.class).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_INVITE_STAFF_COMMAND_PERMISSION))) { UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityJoinCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityJoinCommand.java index b1b167e7b..e551543f8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityJoinCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityJoinCommand.java @@ -4,7 +4,6 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.communities.Community; @@ -15,7 +14,7 @@ public class CommunityJoinCommand extends CommandBase { public CommunityJoinCommand(CommunityManager plugin) { - super(plugin, Rank.ALL, "join"); + super(plugin, CommunityManager.COMMUNITY_JOIN_COMMAND_PERMISSION, "join"); } @Override @@ -23,7 +22,7 @@ public class CommunityJoinCommand extends CommandBase { if (args.length < 1) { - UtilPlayer.message(caller, F.help("/com join ", "Joins a community that is open or you have been invited to", Rank.ALL, ChatColor.AQUA)); + UtilPlayer.message(caller, F.help("/com join ", "Joins a community that is open or you have been invited to", ChatColor.DARK_AQUA)); return; } Community c = Plugin.getLoadedCommunity(args[0]); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMCSCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMCSCommand.java index 683283e3c..6ac7005b3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMCSCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMCSCommand.java @@ -5,8 +5,8 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.communities.Community; @@ -19,7 +19,7 @@ public class CommunityMCSCommand extends CommandBase { public CommunityMCSCommand(CommunityManager plugin) { - super(plugin, Rank.ALL, "mcs"); + super(plugin, CommunityManager.COMMUNITY_MCS_COMMAND_PERMISSION, "mcs"); } @Override @@ -27,7 +27,7 @@ public class CommunityMCSCommand extends CommandBase { if (args.length < 1) { - UtilPlayer.message(caller, F.help("/com mcs ", "Opens the Mineplex Community Server of a community you manage", Rank.ALL, ChatColor.AQUA)); + UtilPlayer.message(caller, F.help("/com mcs ", "Opens the Mineplex Community Server of a community you manage", ChatColor.DARK_AQUA)); return; } Community c = Plugin.getLoadedCommunity(args[0]); @@ -38,7 +38,7 @@ public class CommunityMCSCommand extends CommandBase } if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal()) { - if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN)) + if (!Managers.get(CoreClientManager.class).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_MCS_STAFF_COMMAND_PERMISSION))) { UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMenuCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMenuCommand.java index 1e93f267e..0885f67c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMenuCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMenuCommand.java @@ -3,7 +3,6 @@ package mineplex.core.communities.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.communities.CommunityManager; import mineplex.core.communities.gui.overview.CommunityOverviewPage; @@ -11,7 +10,7 @@ public class CommunityMenuCommand extends CommandBase { public CommunityMenuCommand(CommunityManager plugin) { - super(plugin, Rank.ALL, "menu"); + super(plugin, CommunityManager.COMMUNITY_MENU_COMMAND_PERMISSION, "menu"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityRenameCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityRenameCommand.java index bfa1863bf..c3d2e988e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityRenameCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityRenameCommand.java @@ -7,9 +7,9 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.chat.Chat; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.communities.Community; @@ -21,7 +21,7 @@ public class CommunityRenameCommand extends CommandBase { public CommunityRenameCommand(CommunityManager plugin) { - super(plugin, Rank.ETERNAL, "rename"); + super(plugin, CommunityManager.COMMUNITY_RENAME_COMMAND_PERMISSION, "rename"); } @Override @@ -29,7 +29,7 @@ public class CommunityRenameCommand extends CommandBase { if (args.length < 2) { - UtilPlayer.message(caller, F.help("/com rename ", "Changes the name of a community you own", Rank.ETERNAL, ChatColor.AQUA)); + UtilPlayer.message(caller, F.help("/com rename ", "Changes the name of a community you own", ChatColor.DARK_AQUA)); return; } Community c = Plugin.getLoadedCommunity(args[0]); @@ -41,7 +41,7 @@ public class CommunityRenameCommand extends CommandBase } if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role != CommunityRole.LEADER) { - if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN)) + if (!Managers.get(CoreClientManager.class).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_RENAME_STAFF_COMMAND_PERMISSION))) { UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not the leader of " + F.name(c.getName()) + "!")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityUnInviteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityUnInviteCommand.java index 99b5e9636..1126ac4f4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityUnInviteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityUnInviteCommand.java @@ -5,8 +5,8 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.communities.Community; @@ -18,7 +18,7 @@ public class CommunityUnInviteCommand extends CommandBase { public CommunityUnInviteCommand(CommunityManager plugin) { - super(plugin, Rank.ALL, "uninvite"); + super(plugin, CommunityManager.COMMUNITY_UNINVITE_COMMAND_PERMISSION, "uninvite"); } @Override @@ -26,7 +26,7 @@ public class CommunityUnInviteCommand extends CommandBase { if (args.length < 2) { - UtilPlayer.message(caller, F.help("/com uninvite ", "Revokes a player's invitation to a community you manage", Rank.ALL, ChatColor.AQUA)); + UtilPlayer.message(caller, F.help("/com uninvite ", "Revokes a player's invitation to a community you manage", ChatColor.DARK_AQUA)); return; } String player = args[0]; @@ -38,7 +38,7 @@ public class CommunityUnInviteCommand extends CommandBase } if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal()) { - if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN)) + if (!Managers.get(CoreClientManager.class).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_UNINVITE_STAFF_COMMAND_PERMISSION))) { UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityMemberButton.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityMemberButton.java index 4fd034064..ecf17c91d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityMemberButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/community/CommunityMemberButton.java @@ -5,10 +5,11 @@ import org.bukkit.event.inventory.ClickType; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.communities.Community; +import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityMemberInfo; import mineplex.core.communities.CommunityRole; import mineplex.core.communities.gui.CommunitiesGUIButton; @@ -18,6 +19,7 @@ public class CommunityMemberButton extends CommunitiesGUIButton private Player _viewer; private Community _community; private CommunityMemberInfo _info; + private boolean _fetching = false; public CommunityMemberButton(Player viewer, Community community, CommunityMemberInfo info) { @@ -37,6 +39,10 @@ public class CommunityMemberButton extends CommunitiesGUIButton @Override public void handleClick(ClickType type) { + if (_fetching) + { + return; + } if (type == ClickType.SHIFT_RIGHT) { if (getCommunityManager().Get(_viewer).getRoleIn(_community) != null && getCommunityManager().Get(_viewer).getRoleIn(_community).ordinal() < _info.Role.ordinal()) @@ -59,13 +65,25 @@ public class CommunityMemberButton extends CommunitiesGUIButton UtilPlayer.message(_viewer, F.main(getCommunityManager().getName(), F.name(_info.Name) + " can only own one community at a time!")); return; } - if (!Rank.valueOf(Managers.get(CoreClientManager.class).loadOfflineClient(_info.UUID).Rank).has(Rank.ETERNAL)) + CoreClientManager clientManager = Managers.get(CoreClientManager.class); + _fetching = true; + clientManager.fetchGroups(_info.AccountId, pair -> + { + if (clientManager.getPermissionManager().hasPermission(pair, GroupPermission.of(CommunityManager.OWN_COMMUNITY_PERMISSION))) + { + getCommunityManager().handleRoleUpdate(_viewer, _community, _info, CommunityRole.LEADER); + getCommunityManager().handleRoleUpdate(_viewer, _community, _community.getMembers().get(_viewer.getUniqueId()), CommunityRole.COLEADER); + } + else + { + UtilPlayer.message(_viewer, F.main(getCommunityManager().getName(), "Only Eternal rank and above can own a community!")); + } + _fetching = false; + }, () -> { UtilPlayer.message(_viewer, F.main(getCommunityManager().getName(), "Only Eternal rank and above can own a community!")); - return; - } - getCommunityManager().handleRoleUpdate(_viewer, _community, _info, CommunityRole.LEADER); - getCommunityManager().handleRoleUpdate(_viewer, _community, _community.getMembers().get(_viewer.getUniqueId()), CommunityRole.COLEADER); + _fetching = false; + }); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java index e66674be4..8d9a05f6e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java @@ -2,7 +2,6 @@ package mineplex.core.cosmetic.ui.page; import org.bukkit.Material; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; @@ -12,12 +11,10 @@ import mineplex.core.donation.DonationManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; -import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; public class WinEffectPage extends GadgetPage { - public WinEffectPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) { @@ -34,7 +31,7 @@ public class WinEffectPage extends GadgetPage if (gadget instanceof WinEffectRankBased) { WinEffectRankBased rankBased = (WinEffectRankBased) gadget; - if (getClientManager().Get(getPlayer()).GetRank().has(rankBased.getRank())) + if (getClientManager().getPermissionManager().hasPermission(getPlayer(), rankBased.getUnlockPermission())) { addGadget(gadget, slot); } @@ -61,13 +58,9 @@ public class WinEffectPage extends GadgetPage } } - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) -> { - public void onClick(Player player, ClickType clickType) - { - getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); - } + getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); }); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java index 3678cda49..972dbaa14 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java @@ -4,22 +4,14 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; -import mineplex.core.Managers; -import mineplex.core.MiniPlugin; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.common.util.UtilAction; -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.creature.command.MobCommand; -import mineplex.core.creature.event.CreatureSpawnCustomEvent; -import mineplex.core.itemstack.ItemStackFactory; - import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.entity.*; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -31,14 +23,43 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; +import mineplex.core.Managers; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; +import mineplex.core.common.util.UtilAction; +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.creature.command.MobCommand; +import mineplex.core.creature.event.CreatureSpawnCustomEvent; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class Creature extends MiniPlugin { + public static final String MOB_COMMAND_PERMISSION = "mineplex.core.mob.command"; + public static final String KILL_MOB_COMMAND_PERMISSION = "mineplex.core.mob.kill"; + private boolean _spawnForce = false; private boolean _disableCustom = false; public Creature(JavaPlugin plugin) { super("Creature", plugin); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(MOB_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(KILL_MOB_COMMAND_PERMISSION), true, true); } @Override @@ -315,4 +336,4 @@ public class Creature extends MiniPlugin { _disableCustom = var; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/HelpCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/HelpCommand.java deleted file mode 100644 index ca06bbad5..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/HelpCommand.java +++ /dev/null @@ -1,26 +0,0 @@ -package mineplex.core.creature.command; -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.creature.Creature; - -public class HelpCommand extends CommandBase -{ - public HelpCommand(Creature plugin) - { - super(plugin, Rank.ADMIN, "help"); - } - - @Override - public void Execute(Player caller, String[] args) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "Commands List;")); - UtilPlayer.message(caller, F.help("/mob", "List Entities", Rank.MODERATOR)); - UtilPlayer.message(caller, F.help("/mob kill ", "Remove Entities of Type", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/mob (# baby lock angry s# )", "Create", Rank.ADMIN)); - UtilPlayer.message(caller, F.desc("Professions", "Butcher, Blacksmith, Farmer, Librarian, Priest")); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/KillCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/KillCommand.java index 736aa9cee..e03594157 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/KillCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/KillCommand.java @@ -9,7 +9,6 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; @@ -21,7 +20,7 @@ public class KillCommand extends CommandBase { public KillCommand(Creature plugin) { - super(plugin, Rank.ADMIN, "kill", "k"); + super(plugin, Creature.KILL_MOB_COMMAND_PERMISSION, "kill", "k"); } @Override @@ -70,4 +69,4 @@ public class KillCommand extends CommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), "Killed " + target + ". " + count + " Removed.")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java index 6b9e16de1..7b81112c6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java @@ -2,6 +2,7 @@ package mineplex.core.creature.command; import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Set; import org.bukkit.Material; @@ -21,7 +22,6 @@ import org.bukkit.entity.Wolf; import org.bukkit.entity.Zombie; import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; @@ -32,7 +32,7 @@ public class MobCommand extends MultiCommandBase { public MobCommand(Creature plugin) { - super(plugin, Rank.ADMIN, "mob"); + super(plugin, Creature.MOB_COMMAND_PERMISSION, "mob"); AddCommand(new KillCommand(Plugin)); } @@ -42,7 +42,7 @@ public class MobCommand extends MultiCommandBase { if (args == null || args.length == 0) { - HashMap entMap = new HashMap(); + Map entMap = new HashMap<>(); int count = 0; for (World world : UtilServer.getServer().getWorlds()) @@ -75,7 +75,7 @@ public class MobCommand extends MultiCommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), "Spawning Creature(s);")); //Store Args - HashSet argSet = new HashSet(); + Set argSet = new HashSet<>(); for (int i = 1 ; i < args.length ; i++) if (args[i].length() > 0) argSet.add(args[i]); @@ -83,7 +83,7 @@ public class MobCommand extends MultiCommandBase //Search Count int count = 1; - HashSet argHandle = new HashSet(); + Set argHandle = new HashSet<>(); for (String arg : argSet) { try @@ -110,7 +110,7 @@ public class MobCommand extends MultiCommandBase argSet.remove(arg); //Spawn - HashSet entSet = new HashSet(); + Set entSet = new HashSet<>(); for (int i = 0 ; i < count ; i++) { entSet.add(Plugin.SpawnEntity(caller.getTargetBlock((Set) null, 150).getLocation().add(0.5, 1, 0.5), type)); @@ -274,4 +274,4 @@ public class MobCommand extends MultiCommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), "Spawned " + count + " " + UtilEnt.getName(type) + ".")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java index 94d880968..6c5223d40 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseInsentient.java @@ -1,11 +1,11 @@ package mineplex.core.disguise.disguises; -import mineplex.core.common.*; -import net.minecraft.server.v1_8_R3.EntityInsentient; - -import org.bukkit.*; +import org.bukkit.ChatColor; import org.bukkit.entity.EntityType; +import mineplex.core.account.permissions.PermissionGroup; +import net.minecraft.server.v1_8_R3.EntityInsentient; + public abstract class DisguiseInsentient extends DisguiseLiving { private boolean _showArmor; @@ -23,13 +23,13 @@ public abstract class DisguiseInsentient extends DisguiseLiving setName(name, null); } - public void setName(String name, Rank rank) + public void setName(String name, PermissionGroup group) { - if (rank != null) + if (group != null) { - if (rank.has(Rank.ULTRA)) + if (!group.getDisplay(false, false, false, false).isEmpty()) { - name = rank.getTag(true, true) + " " + ChatColor.RESET + name; + name = group.getDisplay(true, true, true, false) + " " + ChatColor.RESET + name; } } @@ -65,4 +65,4 @@ public abstract class DisguiseInsentient extends DisguiseLiving { _showArmor = false; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java index 4b53402cb..8030c0a44 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java @@ -2,18 +2,19 @@ package mineplex.core.disguise.playerdisguise; import java.util.UUID; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.Listener; +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + public class DisguiseCommand extends CommandBase implements Listener { DisguiseCommand(PlayerDisguiseManager plugin) { - super(plugin, Rank.ADMIN, new Rank[]{Rank.YOUTUBE_SMALL, Rank.YOUTUBE, Rank.TWITCH}, "disguise"); + super(plugin, PlayerDisguiseManager.USE_DISGUISE_PERMISSION, "disguise"); } @Override @@ -33,7 +34,7 @@ public class DisguiseCommand extends CommandBase implemen } if (args.length > 2) { - UtilPlayer.message(caller, F.help("/disguise [username of skin]", "Disguise yourself as 'username' with optional skin belonging to 'username of skin'", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/disguise [username of skin]", "Disguise yourself as 'username' with optional skin belonging to 'username of skin'", ChatColor.DARK_RED)); return; } @@ -42,4 +43,4 @@ public class DisguiseCommand extends CommandBase implemen Plugin.runAsync(() -> // task new PlayerDisguiseNotification(realName, currentUUID, args[0], skin).publish())); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java index 30de25c49..a728e612f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java @@ -1,15 +1,17 @@ package mineplex.core.disguise.playerdisguise; import java.lang.reflect.Field; -import java.util.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import net.minecraft.server.v1_8_R3.MinecraftServer; -import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; -import net.minecraft.server.v1_8_R3.PlayerList; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; @@ -29,13 +31,14 @@ import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.disguise.playerdisguise.events.PlayerDisguisedEvent; @@ -56,10 +59,18 @@ import mineplex.serverdata.Region; import mineplex.serverdata.data.PlayerStatus; import mineplex.serverdata.redis.RedisDataRepository; import mineplex.serverdata.servers.ServerManager; +import net.minecraft.server.v1_8_R3.MinecraftServer; +import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; +import net.minecraft.server.v1_8_R3.PlayerList; @ReflectivelyCreateMiniPlugin public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler { + public static final String USE_DISGUISE_PERMISSION = "mineplex.core.disguise.playerdisguise.use"; + public static final String BLOCKED_DISGUISE_PERMISSION = "mineplex.core.disguise.playerdisguise.blocked"; + public static final String SHORT_DISGUISE_PERMISSION = "mineplex.core.disguise.playerdisguise.short"; + private static final Set MOJANG; private static final Set ILLEGAL_USERNAMES; private static final Set ILLEGAL_CAPES; @@ -137,6 +148,16 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler _redis = new RedisDataRepository<>(Region.ALL, DisguisePlayerBean.class, "disguisedPlayer"); } + + private void generatePermissions() + { + PermissionManager pm = _clients.getPermissionManager(); + + pm.setPermission(pm.getGroup("content"), GroupPermission.of(USE_DISGUISE_PERMISSION), true, true); + pm.setPermission(pm.getGroup("content"), GroupPermission.of(BLOCKED_DISGUISE_PERMISSION), true, true); + pm.setPermission(pm.getGroup("builder"), GroupPermission.of(BLOCKED_DISGUISE_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SHORT_DISGUISE_PERMISSION), true, true); + } @Override public void addCommands() @@ -211,9 +232,11 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler public void onDisguisedPlayerJoin(PlayerJoinEvent event) { CoreClient client = _clients.Get(event.getPlayer()); - - if (!client.GetRank().has(event.getPlayer(), Rank.ADMIN, new Rank[]{Rank.YOUTUBE, Rank.YOUTUBE_SMALL, Rank.TWITCH}, false)) + + if (!getClientManager().getPermissionManager().hasPermission(client, GroupPermission.of(USE_DISGUISE_PERMISSION))) + { return; + } if (_redis.elementExists(client.getAccountId() + client.getName())) { @@ -528,11 +551,10 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler { if (other != null) { - Rank otherRank = other.GetRank(); - if (otherRank.has(Rank.TWITCH)) + if (getClientManager().getPermissionManager().hasPermission(other, GroupPermission.of(BLOCKED_DISGUISE_PERMISSION))) { UtilPlayer.message(caller, - F.main("Disguise", "You can't disguise as staff, YouTubers or Twitchers!")); + F.main("Disguise", "You can't disguise as that person!")); return; } @@ -591,7 +613,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler return false; } - Rank otherRank = otherClient != null ? otherClient.GetRank() : Rank.ALL; + PermissionGroup otherRank = otherClient != null ? otherClient.getPrimaryGroup() : getClientManager().getPermissionManager().getGroup("player"); callerClient.disguise(requestedUsername, requestedProfile.getId(), otherRank); _mapping.put(callerClient.getDisguisedAs().toLowerCase(), callerClient.getName()); @@ -733,7 +755,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler } if (username.length() < 3) { - if (!_clients.Get(caller).GetRank().has(Rank.ADMIN)) + if (!_clients.getPermissionManager().hasPermission(caller, GroupPermission.of(SHORT_DISGUISE_PERMISSION))) { UtilPlayer.message(caller, F.main("Disguise", "The chosen username of " + F.elem(username) + " must be longer than " + F.count("2") + " letters")); return false; @@ -762,4 +784,4 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler } return true; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 8ef17f337..34c44e2ee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -21,6 +21,8 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.account.event.ClientWebResponseEvent; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.donation.command.CrownCommand; import mineplex.core.donation.command.GemCommand; @@ -39,6 +41,10 @@ import mineplex.core.utils.UtilScheduler; @ReflectivelyCreateMiniPlugin public class DonationManager extends MiniClientPlugin { + public static final String CROWN_COMMAND_PERMISSION = "mineplex.core.donation.crowncommand"; + public static final String GEM_COMMAND_PERMISSION = "mineplex.core.donation.gemcommand"; + public static final String SHARD_COMMAND_PERMISSION = "mineplex.core.donation.shardcommand"; + /** * The maximum number of attempts that will be made to perform a transaction created by {@link DonationManager#rewardCurrencyUntilSuccess} */ @@ -94,6 +100,17 @@ public class DonationManager extends MiniClientPlugin }); UtilScheduler.runEvery(UpdateType.FAST, this::processCoinAttemptQueue); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(CROWN_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GEM_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SHARD_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/CrownCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/CrownCommand.java index 72800e748..951033377 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/CrownCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/CrownCommand.java @@ -3,7 +3,6 @@ package mineplex.core.donation.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -13,7 +12,7 @@ public class CrownCommand extends CommandBase { public CrownCommand(DonationManager plugin) { - super(plugin, Rank.ADMIN, "crown"); + super(plugin, DonationManager.CROWN_COMMAND_PERMISSION, "crown"); } @Override @@ -88,4 +87,4 @@ public class CrownCommand extends CommandBase } }); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java index c4124317b..f50fc31fc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java @@ -5,7 +5,6 @@ import org.bukkit.entity.Player; import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -16,7 +15,7 @@ public class GemCommand extends CommandBase { public GemCommand(DonationManager plugin) { - super(plugin, Rank.ADMIN, "gem"); + super(plugin, DonationManager.GEM_COMMAND_PERMISSION, "gem"); } @Override @@ -97,4 +96,4 @@ public class GemCommand extends CommandBase } }); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java index 2df566a42..da0c116f2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java @@ -5,7 +5,6 @@ import org.bukkit.entity.Player; import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -16,7 +15,7 @@ public class ShardCommand extends CommandBase { public ShardCommand(DonationManager plugin) { - super(plugin, Rank.ADMIN, "coin", "shard", "shards"); + super(plugin, DonationManager.SHARD_COMMAND_PERMISSION, "coin", "shard", "shards"); } @Override @@ -97,4 +96,4 @@ public class ShardCommand extends CommandBase } }); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java index e46c10f59..618e01ae3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java @@ -4,21 +4,24 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.UUID; -import mineplex.core.MiniDbClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.itemstack.ItemBuilder; - -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.itemstack.ItemBuilder; + public class EloManager extends MiniDbClientPlugin { + public static final String TOP_ELO_COMMAND_PERMISSION = "mineplex.core.elo.topcommand"; + private EloRepository _repository; private EloRatingSystem _ratingSystem; private NautHashMap _eloTeams = new NautHashMap<>(); @@ -37,6 +40,15 @@ public class EloManager extends MiniDbClientPlugin new KFactor(3100, 3699, 20), new KFactor(3700, 5000, 10) ); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TOP_ELO_COMMAND_PERMISSION), true, true); } public EloRepository getRepo() @@ -44,7 +56,6 @@ public class EloManager extends MiniDbClientPlugin return _repository; } - @Override public void addCommands() { @@ -92,7 +103,8 @@ public class EloManager extends MiniDbClientPlugin try { success = _repository.saveElo(accountId, gameType, oldElo, elo); - } catch (SQLException e) + } + catch (SQLException e) { e.printStackTrace(); } finally @@ -102,7 +114,8 @@ public class EloManager extends MiniDbClientPlugin final boolean finalSuccess = success; - runSync(() -> { + runSync(() -> + { if (finalSuccess) { if (player.isOnline()) @@ -154,7 +167,8 @@ public class EloManager extends MiniDbClientPlugin if (expired) { - _repository.getStrikeExpiry(accountId, strikeExpiration -> { + _repository.getStrikeExpiry(accountId, strikeExpiration -> + { if (System.currentTimeMillis() >= strikeExpiration) { _repository.resetStrikes(accountId); @@ -177,7 +191,8 @@ public class EloManager extends MiniDbClientPlugin if (expired) { - _repository.getStrikeExpiry(accountId, strikeExpiration -> { + _repository.getStrikeExpiry(accountId, strikeExpiration -> + { if (System.currentTimeMillis() >= strikeExpiration) { _repository.resetStrikes(accountId); @@ -231,7 +246,8 @@ public class EloManager extends MiniDbClientPlugin if (team.Winner) { teamWinner = team; - } else + } + else { teamLoser = team; } @@ -373,4 +389,4 @@ public class EloManager extends MiniDbClientPlugin return build.build(); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java index 5d8617a4a..5dfcaa8f3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java @@ -8,255 +8,262 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.database.MinecraftRepository; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnInt; -import mineplex.serverdata.database.column.ColumnLong; - -import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import com.google.common.collect.Lists; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnLong; + public class EloRepository extends RepositoryBase { + private static String INSERT_ELO = "INSERT INTO eloRating (accountId, gameType, elo) VALUES (?, ?, ?);"; + private static String UPDATE_ELO = "UPDATE eloRating SET elo = elo + ? WHERE accountId = ? AND gameType = ?;"; + private static String UPDATE_ELO_ONLY_IF_MATCH = "UPDATE eloRating SET elo = elo + ? WHERE accountId = ? AND gameType = ? AND elo = ?;"; + private static String GRAB_STRIKES = "SELECT strikes FROM rankedBans WHERE accountId = ?;"; + private static String GRAB_STRIKE_EXPIRY = "SELECT strikesExpire FROM rankedBans WHERE accountId = ?;"; + private static String GRAB_BAN_EXPIRY = "SELECT banEnd FROM rankedBans WHERE accountId = ?;"; + private static String UPDATE_BAN = "INSERT INTO rankedBans (accountId, strikes, strikesExpire, banEnd) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE strikes=VALUES(strikes), strikesExpire=VALUES(strikesExpire), banEnd=VALUES(banEnd);"; + private static String DELETE_STRIKES = "UPDATE rankedBans SET strikes = 1 WHERE accountId = ?;"; + private static String GET_NAME_FROM_ID = "SELECT `name` FROM `accounts` WHERE `id`=?;"; - private static String INSERT_ELO = "INSERT INTO eloRating (accountId, gameType, elo) VALUES (?, ?, ?);"; - private static String UPDATE_ELO = "UPDATE eloRating SET elo = elo + ? WHERE accountId = ? AND gameType = ?;"; - private static String UPDATE_ELO_ONLY_IF_MATCH = "UPDATE eloRating SET elo = elo + ? WHERE accountId = ? AND gameType = ? AND elo = ?;"; - private static String GRAB_STRIKES = "SELECT strikes FROM rankedBans WHERE accountId = ?;"; - private static String GRAB_STRIKE_EXPIRY = "SELECT strikesExpire FROM rankedBans WHERE accountId = ?;"; - private static String GRAB_BAN_EXPIRY = "SELECT banEnd FROM rankedBans WHERE accountId = ?;"; - private static String UPDATE_BAN = "INSERT INTO rankedBans (accountId, strikes, strikesExpire, banEnd) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE strikes=VALUES(strikes), strikesExpire=VALUES(strikesExpire), banEnd=VALUES(banEnd);"; - private static String DELETE_STRIKES = "UPDATE rankedBans SET strikes = 1 WHERE accountId = ?;"; - private static String GET_NAME_FROM_ID = "SELECT `name` FROM `accounts` WHERE `id`=?;"; + public EloRepository(JavaPlugin plugin) + { + super(DBPool.getAccount()); + } - public EloRepository(JavaPlugin plugin) - { - super(DBPool.getAccount()); - } + public boolean saveElo(int accountId, int gameType, int oldElo, int elo) throws SQLException + { + List ret = Lists.newArrayList(); + UtilServer.runAsync(() -> + { + boolean updateSucceeded = false; - public boolean saveElo(int accountId, int gameType, int oldElo, int elo) throws SQLException - { - List ret = Lists.newArrayList(); - UtilServer.runAsync(() -> { - boolean updateSucceeded = false; + // If we're increasing in elo we verify the server version matches the database version (prevent d/c and double wins with concurrent matches) + // Otherwise we always take their elo down if they lose. + if (elo > oldElo) + { + updateSucceeded = executeUpdate(UPDATE_ELO_ONLY_IF_MATCH, new ColumnInt("elo", elo - oldElo), new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType), new ColumnInt("elo", oldElo)) > 0; + } + else + { + updateSucceeded = executeUpdate(UPDATE_ELO, new ColumnInt("elo", elo - oldElo), new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType)) > 0; - // If we're increasing in elo we verify the server version matches the database version (prevent d/c and double wins with concurrent matches) - // Otherwise we always take their elo down if they lose. - if (elo > oldElo) - { - updateSucceeded = executeUpdate(UPDATE_ELO_ONLY_IF_MATCH, new ColumnInt("elo", elo - oldElo), new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType), new ColumnInt("elo", oldElo)) > 0; - } else - { - updateSucceeded = executeUpdate(UPDATE_ELO, new ColumnInt("elo", elo - oldElo), new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType)) > 0; + if (!updateSucceeded && executeUpdate(INSERT_ELO, new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType), new ColumnInt("elo", elo)) > 0) + { + updateSucceeded = true; + } + } - if (!updateSucceeded && executeUpdate(INSERT_ELO, new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType), new ColumnInt("elo", elo)) > 0) - { - updateSucceeded = true; - } - } + ret.add(updateSucceeded); + }); - ret.add(updateSucceeded); - }); + if (ret.isEmpty()) + { + ret.add(false); + } - if (ret.isEmpty()) - { - ret.add(false); - } + return ret.get(0); + } - return ret.get(0); - } + public EloClientData loadClientInformation(ResultSet resultSet) throws SQLException + { + EloClientData clientData = new EloClientData(); - public EloClientData loadClientInformation(ResultSet resultSet) throws SQLException - { - EloClientData clientData = new EloClientData(); + while (resultSet.next()) + { + clientData.Elos.put(resultSet.getInt(1), resultSet.getInt(2)); + } - while (resultSet.next()) - { - clientData.Elos.put(resultSet.getInt(1), resultSet.getInt(2)); - } + return clientData; + } - return clientData; - } + public void getStrikeExpiry(int accountId, Callback call) + { + UtilServer.runAsync(() -> executeQuery(GRAB_STRIKE_EXPIRY, resultSet -> + { + boolean called = false; + while (resultSet.next()) + { + called = true; + call.run(resultSet.getLong(1)); + } - public void getStrikeExpiry(int accountId, Callback call) - { - UtilServer.runAsync(() -> executeQuery(GRAB_STRIKE_EXPIRY, resultSet -> { - boolean called = false; - while (resultSet.next()) - { - called = true; - call.run(resultSet.getLong(1)); - } + if (!called) + { + call.run(0L); + } + }, new ColumnInt("accountId", accountId))); + } - if (!called) - { - call.run(0L); - } - }, new ColumnInt("accountId", accountId))); - } + public void getBanExpiryAsync(int accountId, Callback call) + { + UtilServer.runAsync(() -> executeQuery(GRAB_BAN_EXPIRY, resultSet -> + { + boolean called = false; + while (resultSet.next()) + { + called = true; + call.run(resultSet.getLong(1)); + } - public void getBanExpiryAsync(int accountId, Callback call) - { - UtilServer.runAsync(() -> executeQuery(GRAB_BAN_EXPIRY, resultSet -> { - boolean called = false; - while (resultSet.next()) - { - called = true; - call.run(resultSet.getLong(1)); - } + if (!called) + { + call.run(0L); + } + }, new ColumnInt("accountId", accountId))); + } - if (!called) - { - call.run(0L); - } - }, new ColumnInt("accountId", accountId))); - } + public long getBanExpiry(int accountId) + { + List expiry = new ArrayList(); + executeQuery(GRAB_BAN_EXPIRY, resultSet -> + { + while (resultSet.next()) + { + expiry.add(resultSet.getLong(1)); + } + }, new ColumnInt("accountId", accountId)); - public long getBanExpiry(int accountId) - { - List expiry = new ArrayList(); - executeQuery(GRAB_BAN_EXPIRY, resultSet -> { - while (resultSet.next()) - { - expiry.add(resultSet.getLong(1)); - } - }, new ColumnInt("accountId", accountId)); + if (expiry.isEmpty()) + { + expiry.add(System.currentTimeMillis() - 5000); + } - if (expiry.isEmpty()) - expiry.add(System.currentTimeMillis() - 5000); + return expiry.get(0); + } - return expiry.get(0); - } + public void getStrikes(int accountId, Callback call) + { + UtilServer.runAsync(() -> executeQuery(GRAB_STRIKES, resultSet -> + { + boolean called = false; + while (resultSet.next()) + { + called = true; + call.run(resultSet.getInt(1)); + } - public void getStrikes(int accountId, Callback call) - { - UtilServer.runAsync(() -> executeQuery(GRAB_STRIKES, resultSet -> { - boolean called = false; - while (resultSet.next()) - { - called = true; - call.run(resultSet.getInt(1)); - } + if (!called) + { + call.run(0); + } + }, new ColumnInt("accountId", accountId))); + } - if (!called) - { - call.run(0); - } - }, new ColumnInt("accountId", accountId))); - } + public void addRankedBan(int accountId) + { + getStrikes(accountId, strikes -> { + int minutes = 1; + switch (strikes) + { + case 0: + minutes = 1; + break; + case 1: + minutes = 5; + break; + case 2: + minutes = 10; + break; + case 3: + minutes = 20; + break; + case 4: + minutes = 30; + break; + case 5: + minutes = 60; + break; + case 6: + minutes = 120; + break; + case 7: + minutes = 180; + break; + case 8: + minutes = 240; + break; + } + long banEnd = System.currentTimeMillis() + UtilTime.convert(minutes, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + long strikesExpire = System.currentTimeMillis() + UtilTime.convert(1, TimeUnit.DAYS, TimeUnit.MILLISECONDS); + int newStrikes = Math.min(strikes + 1, 8); - public void addRankedBan(int accountId) - { - getStrikes(accountId, strikes -> { - int minutes = 1; - switch (strikes) - { - case 0: - minutes = 1; - break; - case 1: - minutes = 5; - break; - case 2: - minutes = 10; - break; - case 3: - minutes = 20; - break; - case 4: - minutes = 30; - break; - case 5: - minutes = 60; - break; - case 6: - minutes = 120; - break; - case 7: - minutes = 180; - break; - case 8: - minutes = 240; - break; - } - long banEnd = System.currentTimeMillis() + UtilTime.convert(minutes, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); - long strikesExpire = System.currentTimeMillis() + UtilTime.convert(1, TimeUnit.DAYS, TimeUnit.MILLISECONDS); - int newStrikes = Math.min(strikes + 1, 8); + UtilServer.runAsync(() -> executeUpdate(UPDATE_BAN, new ColumnInt("accountId", accountId), new ColumnInt("strikes", newStrikes), new ColumnLong("strikesExpire", strikesExpire), new ColumnLong("banEnd", banEnd))); + }); + } - UtilServer.runAsync(() -> executeUpdate(UPDATE_BAN, new ColumnInt("accountId", accountId), new ColumnInt("strikes", newStrikes), new ColumnLong("strikesExpire", strikesExpire), new ColumnLong("banEnd", banEnd))); - }); - } + public void resetStrikes(int accountId) + { + UtilServer.runAsync(() -> executeUpdate(DELETE_STRIKES, new ColumnInt("accountId", accountId))); + } - public void resetStrikes(int accountId) - { - UtilServer.runAsync(() -> executeUpdate(DELETE_STRIKES, new ColumnInt("accountId", accountId))); - } - - public void getTopElo(int limit, Callback> callback) - { - int gameId = 62; - new BukkitRunnable() - { - @Override - public void run() - { - Connection connection = getConnection(); - PreparedStatement statement = null; - PreparedStatement nameStatement = null; - LinkedList dataList = Lists.newLinkedList(); - try - { - String GET_ELO = "SELECT `elo`,`accountId` FROM `eloRating` WHERE `gameType`=? ORDER BY `elo` DESC LIMIT " + limit + ";" ; - statement = connection.prepareStatement(GET_ELO); - statement.setInt(1, gameId); - ResultSet resultSet = statement.executeQuery(); - while (resultSet.next()) - { - int elo = resultSet.getInt(1); - TopEloData data; - nameStatement = connection.prepareStatement(GET_NAME_FROM_ID); - nameStatement.setInt(1, resultSet.getInt(2)); - ResultSet nameSet = nameStatement.executeQuery(); - if (nameSet.next()) - { - data = new TopEloData(nameSet.getString("name"), elo); - dataList.add(data); - } - } - callback.run(dataList); - } catch (SQLException e) - { - e.printStackTrace(); - } finally - { - try - { - if (nameStatement != null) - { - statement.close(); - } - if (statement != null) - { - statement.close(); - } - if (connection != null) - { - connection.close(); - } - } catch (SQLException e) - { - e.printStackTrace(); - } - } - } - }.runTaskAsynchronously(UtilServer.getPlugin()); - } + public void getTopElo(int limit, int gameId, Callback> callback) + { + new BukkitRunnable() + { + @Override + public void run() + { + Connection connection = getConnection(); + PreparedStatement statement = null; + PreparedStatement nameStatement = null; + LinkedList dataList = Lists.newLinkedList(); + try + { + String GET_ELO = "SELECT `elo`,`accountId` FROM `eloRating` WHERE `gameType`=? ORDER BY `elo` DESC LIMIT " + limit + ";" ; + statement = connection.prepareStatement(GET_ELO); + statement.setInt(1, gameId); + ResultSet resultSet = statement.executeQuery(); + while (resultSet.next()) + { + int elo = resultSet.getInt(1); + TopEloData data; + nameStatement = connection.prepareStatement(GET_NAME_FROM_ID); + nameStatement.setInt(1, resultSet.getInt(2)); + ResultSet nameSet = nameStatement.executeQuery(); + if (nameSet.next()) + { + data = new TopEloData(nameSet.getString("name"), elo); + dataList.add(data); + } + } + callback.run(dataList); + } + catch (SQLException e) + { + e.printStackTrace(); + } + finally + { + try + { + if (nameStatement != null) + { + statement.close(); + } + if (statement != null) + { + statement.close(); + } + if (connection != null) + { + connection.close(); + } + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + } + }.runTaskAsynchronously(UtilServer.getPlugin()); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/elo/TopEloCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/elo/TopEloCommand.java index 9a8e6359c..5e4539ff3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/elo/TopEloCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/elo/TopEloCommand.java @@ -1,81 +1,80 @@ package mineplex.core.elo; -import java.util.List; +import org.bukkit.entity.Player; -import com.google.common.collect.Lists; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.elo.EloManager.EloDivision; +import mineplex.core.game.GameDisplay; import mineplex.core.slack.SlackAPI; import mineplex.core.slack.SlackMessage; import mineplex.core.slack.SlackTeam; -import org.bukkit.entity.Player; /** * Generates a list of top elos */ public class TopEloCommand extends CommandBase { + public TopEloCommand(EloManager plugin) + { + super(plugin, EloManager.TOP_ELO_COMMAND_PERMISSION, "gettopelo", "topelo", "getelo"); + } - private static final List NAMES = Lists.newArrayList("Relyh", "TadahTech", "LCastr0"); - - public TopEloCommand(EloManager plugin) - { - super(plugin, Rank.ADMIN, "gettopelo", "topelo", "getelo"); - } - - @Override - public void Execute(Player caller, String[] args) - { - if (caller.getName().equalsIgnoreCase("samitod") || caller.getName().equalsIgnoreCase("samitoe")) - { - return; - } - if (!NAMES.contains(caller.getName())) - { - return; - } - if (args.length != 1) - { - return; - } - String limitRaw = args[0]; - int limit; + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 2) + { + return; + } + String limitRaw = args[1]; + int limit; + try + { + limit = Integer.parseInt(limitRaw); + } + catch (NumberFormatException e) + { + caller.sendMessage(F.main("Top Elo", "Incorrect number: " + limitRaw + ".")); + return; + } + if (limit <= 0) + { + caller.sendMessage(F.main("Top Elo", "Incorrect number: " + limitRaw + ".")); + return; + } + GameDisplay type; try { - limit = Integer.parseInt(limitRaw); - } catch (NumberFormatException e) + type = GameDisplay.valueOf(args[0]); + } + catch (Exception ex) { - caller.sendMessage(F.main("Top Elo", "Incorrect number: " + limitRaw + ".")); + caller.sendMessage(F.main("Top Elo", "Incorrect game: " + args[0] + ".")); return; } - if (limit <= 0) - { - caller.sendMessage(F.main("Top Elo", "Incorrect number: " + limitRaw + ".")); - return; - } - Plugin.getRepo().getTopElo(limit, data -> { - caller.sendMessage(C.cAquaB + C.Strike + "============================================="); - caller.sendMessage(C.cWhite + "Top Elo Data"); - caller.sendMessage(" "); - StringBuilder builder = new StringBuilder(); - for (int i = 0; i < data.size(); i++) - { - StringBuilder messageBuilder = new StringBuilder("#"); - TopEloData topEloData = data.get(i); - builder.append((i + 1)).append(": ").append(topEloData.getName()) - .append(" ").append(EloDivision.getDivision(topEloData.getElo())).append("").append("\n"); - messageBuilder.append((i + 1)).append(": ").append(topEloData.getName()) - .append(" ").append(EloDivision.getDivision(topEloData.getElo())).append(""); - caller.sendMessage(C.cYellow + messageBuilder.toString()); - } - SlackMessage slackMessage = new SlackMessage(builder.toString()); - SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#top-elo", slackMessage, false); - caller.sendMessage(" "); - caller.sendMessage(C.cAquaB + C.Strike + "============================================="); - }); - } - -} + + Plugin.getRepo().getTopElo(limit, type.getGameId(), data -> + { + caller.sendMessage(C.cAquaB + C.Strike + "============================================="); + caller.sendMessage(C.cWhite + "Top Elo Data"); + caller.sendMessage(" "); + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < data.size(); i++) + { + StringBuilder messageBuilder = new StringBuilder("#"); + TopEloData topEloData = data.get(i); + builder.append((i + 1)).append(": ").append(topEloData.getName()) + .append(" ").append(EloDivision.getDivision(topEloData.getElo())).append("").append("\n"); + messageBuilder.append((i + 1)).append(": ").append(topEloData.getName()) + .append(" ").append(EloDivision.getDivision(topEloData.getElo())).append(""); + caller.sendMessage(C.cYellow + messageBuilder.toString()); + } + SlackMessage slackMessage = new SlackMessage(builder.toString()); + SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#top-elo", slackMessage, false); + caller.sendMessage(" "); + caller.sendMessage(C.cAquaB + C.Strike + "============================================="); + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java index 83b402573..5ee920c36 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java @@ -4,25 +4,26 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.UUID; +import org.apache.commons.lang.StringUtils; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.MiniClientPlugin; import mineplex.core.MiniDbClientPlugin; -import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.Callback; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; import mineplex.core.facebook.command.FacebookCommand; import mineplex.core.inventory.InventoryManager; import mineplex.core.treasure.TreasureType; -import org.apache.commons.lang.StringUtils; public class FacebookManager extends MiniDbClientPlugin { + public static final String FACEBOOK_COMMAND_PERMISSION = "mineplex.core.facebook.command"; + private CoreClientManager _clientManager; private DonationManager _donationManager; private InventoryManager _inventoryManager; @@ -38,6 +39,15 @@ public class FacebookManager extends MiniDbClientPlugin _inventoryManager = inventoryManager; _repository = new FacebookRepository(plugin); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(FACEBOOK_COMMAND_PERMISSION), true, true); } @Override @@ -56,42 +66,34 @@ public class FacebookManager extends MiniDbClientPlugin final int accountId = _clientManager.getAccountId(player); - runAsync(new Runnable() + runAsync(() -> { - @Override - public void run() + _repository.getCode(code, data -> { - _repository.getCode(code, new Callback() + if (data == null) { - @Override - public void run(FacebookCode data) + message(player, "Invalid Code"); + } + else if (data.isActivated()) + { + message(player, "Code has already been redeemed"); + } + else + { + boolean completed = _repository.activateCode(code, accountId); + if (completed) { - if (data == null) - { - message(player, "Invalid Code"); - } - else if (data.isActivated()) - { - message(player, "Code has already been redeemed"); - } - else - { - boolean completed = _repository.activateCode(code, accountId); - if (completed) - { - _inventoryManager.addItemToInventory(player, TreasureType.ANCIENT.getItemName(), 10); - message(player, "Thanks! You earned " + F.elem("10 Ancient Chests")); - player.playSound(player.getLocation(), Sound.NOTE_PIANO, 1f, 1f); -// _donationManager.RewardCoinsLater(getName(), player, 20000); - } - else - { - message(player, "You have already redeemed a code!"); - } - } + _inventoryManager.addItemToInventory(player, TreasureType.ANCIENT.getItemName(), 10); + message(player, "Thanks! You earned " + F.elem("10 Ancient Chests")); + player.playSound(player.getLocation(), Sound.NOTE_PIANO, 1f, 1f); + //_donationManager.RewardCoinsLater(getName(), player, 20000); } - }); - } + else + { + message(player, "You have already redeemed a code!"); + } + } + }); }); } @@ -124,4 +126,4 @@ public class FacebookManager extends MiniDbClientPlugin { return "SELECT * FROM facebook WHERE accountId = " + accountId + ";"; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/facebook/command/FacebookCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/facebook/command/FacebookCommand.java index ff53f4ac9..27eeb83de 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/facebook/command/FacebookCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/facebook/command/FacebookCommand.java @@ -3,7 +3,6 @@ package mineplex.core.facebook.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.facebook.FacebookManager; @@ -13,7 +12,7 @@ public class FacebookCommand extends CommandBase { public FacebookCommand(FacebookManager plugin) { - super(plugin, Rank.ALL, "facebook", "redeem"); + super(plugin, FacebookManager.FACEBOOK_COMMAND_PERMISSION, "facebook", "redeem"); } @Override @@ -33,4 +32,4 @@ public class FacebookCommand extends CommandBase Plugin.tryCode(caller, args[0]); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index 32effd24c..14c6defa7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -16,7 +16,8 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; @@ -39,390 +40,403 @@ import mineplex.serverdata.data.PlayerStatus; public class FriendManager extends MiniDbClientPlugin { - private static FriendSorter _friendSorter = new FriendSorter(); + public static final String FRIEND_COMMAND_PERMISSION = "mineplex.core.friend.command"; + public static final String JOIN_STAFF_PERMISSION = "mineplex.core.friend.joinstaff"; + + private static FriendSorter _friendSorter = new FriendSorter(); - private PreferencesManager _preferenceManager; - private FriendRepository _repository; - private Portal _portal; + private PreferencesManager _preferenceManager; + private FriendRepository _repository; + private Portal _portal; - public FriendManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, Portal portal) - { - super("Friends", plugin, clientManager); + public FriendManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, Portal portal) + { + super("Friends", plugin, clientManager); - _preferenceManager = preferences; - _repository = new FriendRepository(plugin); - _portal = portal; - } + _preferenceManager = preferences; + _repository = new FriendRepository(plugin); + _portal = portal; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(FRIEND_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(JOIN_STAFF_PERMISSION), true, true); + } - public PreferencesManager getPreferenceManager() - { - return _preferenceManager; - } + public PreferencesManager getPreferenceManager() + { + return _preferenceManager; + } - public Portal getPortal() - { - return _portal; - } + public Portal getPortal() + { + return _portal; + } - @Override - public void addCommands() - { - addCommand(new AddFriend(this)); - addCommand(new DeleteFriend(this)); - addCommand(new FriendsDisplay(this)); - } + @Override + public void addCommands() + { + addCommand(new AddFriend(this)); + addCommand(new DeleteFriend(this)); + addCommand(new FriendsDisplay(this)); + } - @Override - protected FriendData addPlayer(UUID uuid) - { - return new FriendData(); - } + @Override + protected FriendData addPlayer(UUID uuid) + { + return new FriendData(); + } - @EventHandler - public void updateFriends(UpdateEvent event) - { - if (event.getType() != UpdateType.SLOW || Bukkit.getOnlinePlayers().size() == 0) - return; + @EventHandler + public void updateFriends(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW || Bukkit.getOnlinePlayers().size() == 0) + return; - final Player[] onlinePlayers = UtilServer.getPlayers(); + final Player[] onlinePlayers = UtilServer.getPlayers(); - Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable() - { - public void run() - { - final NautHashMap newData = _repository.getFriendsForAll(onlinePlayers); + Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable() + { + public void run() + { + final NautHashMap newData = _repository.getFriendsForAll(onlinePlayers); - Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() - { - public void run() - { - for (Player player : Bukkit.getOnlinePlayers()) - { - if (newData.containsKey(player.getUniqueId().toString())) - { - Get(player).setFriends(newData.get(player.getUniqueId().toString()).getFriends()); - } - else - { - Get(player).getFriends().clear(); - } - } - } - }); - } - }); - } + Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() + { + public void run() + { + for (Player player : Bukkit.getOnlinePlayers()) + { + if (newData.containsKey(player.getUniqueId().toString())) + { + Get(player).setFriends(newData.get(player.getUniqueId().toString()).getFriends()); + } + else + { + Get(player).getFriends().clear(); + } + } + } + }); + } + }); + } - public void addFriend(final Player caller, final String name) - { - if (caller.getName().equalsIgnoreCase(name)) - { - caller.sendMessage(F.main(getName(), ChatColor.GRAY + "You cannot add yourself as a friend")); - return; - } + public void addFriend(final Player caller, final String name) + { + if (caller.getName().equalsIgnoreCase(name)) + { + caller.sendMessage(F.main(getName(), ChatColor.GRAY + "You cannot add yourself as a friend")); + return; + } - boolean update = false; - for (FriendStatus status : Get(caller).getFriends()) - { - if (status.Name.equalsIgnoreCase(name)) - { - if (status.Status == FriendStatusType.Pending || status.Status == FriendStatusType.Blocked) - { - update = true; - break; - } - else if (status.Status == FriendStatusType.Denied) - { - caller.sendMessage(F.main(getName(), ChatColor.GREEN + name + ChatColor.GRAY - + " has denied your friend request.")); - return; - } - else if (status.Status == FriendStatusType.Accepted) - { - caller.sendMessage(F.main(getName(), "You are already friends with " + ChatColor.GREEN + name)); - return; - } - else if (status.Status == FriendStatusType.Sent) - { - caller.sendMessage(F.main(getName(), ChatColor.GREEN + name + ChatColor.GRAY - + " has yet to respond to your friend request.")); - return; - } - } - } + boolean update = false; + for (FriendStatus status : Get(caller).getFriends()) + { + if (status.Name.equalsIgnoreCase(name)) + { + if (status.Status == FriendStatusType.Pending || status.Status == FriendStatusType.Blocked) + { + update = true; + break; + } + else if (status.Status == FriendStatusType.Denied) + { + caller.sendMessage(F.main(getName(), ChatColor.GREEN + name + ChatColor.GRAY + + " has denied your friend request.")); + return; + } + else if (status.Status == FriendStatusType.Accepted) + { + caller.sendMessage(F.main(getName(), "You are already friends with " + ChatColor.GREEN + name)); + return; + } + else if (status.Status == FriendStatusType.Sent) + { + caller.sendMessage(F.main(getName(), ChatColor.GREEN + name + ChatColor.GRAY + + " has yet to respond to your friend request.")); + return; + } + } + } - final boolean updateFinal = update; + final boolean updateFinal = update; - Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - if (updateFinal) - { - _repository.updateFriend(caller.getName(), name, "Accepted"); - _repository.updateFriend(name, caller.getName(), "Accepted"); + Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() + { + public void run() + { + if (updateFinal) + { + _repository.updateFriend(caller.getName(), name, "Accepted"); + _repository.updateFriend(name, caller.getName(), "Accepted"); - Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() - { - public void run() - { - for (Iterator statusIterator = Get(caller).getFriends().iterator(); statusIterator - .hasNext();) - { - FriendStatus status = statusIterator.next(); + Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() + { + public void run() + { + for (Iterator statusIterator = Get(caller).getFriends().iterator(); statusIterator + .hasNext();) + { + FriendStatus status = statusIterator.next(); - if (status.Name.equalsIgnoreCase(name)) - { - status.Status = FriendStatusType.Accepted; - break; - } - } - } - }); - } - else - { - _repository.addFriend(caller, name); + if (status.Name.equalsIgnoreCase(name)) + { + status.Status = FriendStatusType.Accepted; + break; + } + } + } + }); + } + else + { + _repository.addFriend(caller, name); - Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() - { - public void run() - { - for (Iterator statusIterator = Get(caller).getFriends().iterator(); statusIterator - .hasNext();) - { - FriendStatus status = statusIterator.next(); + Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() + { + public void run() + { + for (Iterator statusIterator = Get(caller).getFriends().iterator(); statusIterator + .hasNext();) + { + FriendStatus status = statusIterator.next(); - if (status.Name.equalsIgnoreCase(name)) - { - status.Status = FriendStatusType.Sent; - break; - } - } - } - }); - } + if (status.Name.equalsIgnoreCase(name)) + { + status.Status = FriendStatusType.Sent; + break; + } + } + } + }); + } - Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() - { - public void run() - { - if (updateFinal) - caller.sendMessage(F.main(getName(), "You and " + ChatColor.GREEN + name + ChatColor.GRAY - + " are now friends!")); - else - caller.sendMessage(F.main(getName(), "Added " + ChatColor.GREEN + name + ChatColor.GRAY - + " to your friends list!")); - } - }); - } - }); - } + Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() + { + public void run() + { + if (updateFinal) + caller.sendMessage(F.main(getName(), "You and " + ChatColor.GREEN + name + ChatColor.GRAY + + " are now friends!")); + else + caller.sendMessage(F.main(getName(), "Added " + ChatColor.GREEN + name + ChatColor.GRAY + + " to your friends list!")); + } + }); + } + }); + } - public void removeFriend(final Player caller, final String name) - { - Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - _repository.removeFriend(caller.getName(), name); - _repository.removeFriend(name, caller.getName()); + public void removeFriend(final Player caller, final String name) + { + Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() + { + public void run() + { + _repository.removeFriend(caller.getName(), name); + _repository.removeFriend(name, caller.getName()); - Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() - { - public void run() - { - for (Iterator statusIterator = Get(caller).getFriends().iterator(); statusIterator - .hasNext();) - { - FriendStatus status = statusIterator.next(); + Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() + { + public void run() + { + for (Iterator statusIterator = Get(caller).getFriends().iterator(); statusIterator + .hasNext();) + { + FriendStatus status = statusIterator.next(); - if (status.Name.equalsIgnoreCase(name)) - { - status.Status = FriendStatusType.Blocked; - break; - } - } + if (status.Name.equalsIgnoreCase(name)) + { + status.Status = FriendStatusType.Blocked; + break; + } + } - caller.sendMessage(F.main(getName(), "Deleted " + ChatColor.GREEN + name + ChatColor.GRAY - + " from your friends list!")); - } - }); - } - }); - } + caller.sendMessage(F.main(getName(), "Deleted " + ChatColor.GREEN + name + ChatColor.GRAY + + " from your friends list!")); + } + }); + } + }); + } - public void showFriends(Player caller) - { - boolean isStaff = ClientManager.Get(caller).GetRank().has(Rank.HELPER); - boolean gotAFriend = false; - List friendStatuses = Get(caller).getFriends(); - Collections.sort(friendStatuses, _friendSorter); + public void showFriends(Player caller) + { + boolean isStaff = ClientManager.getPermissionManager().hasPermission(caller, GroupPermission.of(JOIN_STAFF_PERMISSION)); + boolean gotAFriend = false; + List friendStatuses = Get(caller).getFriends(); + Collections.sort(friendStatuses, _friendSorter); - caller.sendMessage(C.cAqua + C.Strike + "======================[" + ChatColor.RESET + C.cWhite + C.Bold + "Friends" - + ChatColor.RESET + C.cAqua + C.Strike + "]======================"); + caller.sendMessage(C.cAqua + C.Strike + "======================[" + ChatColor.RESET + C.cWhite + C.Bold + "Friends" + + ChatColor.RESET + C.cAqua + C.Strike + "]======================"); - ArrayList sentLines = new ArrayList(); - ArrayList pendingLines = new ArrayList(); - ArrayList onlineLines = new ArrayList(); - ArrayList offlineLines = new ArrayList(); + List sentLines = new ArrayList<>(); + List pendingLines = new ArrayList<>(); + List onlineLines = new ArrayList<>(); + List offlineLines = new ArrayList<>(); - for (FriendStatus friend : friendStatuses) - { - if (friend.Status == FriendStatusType.Blocked || friend.Status == FriendStatusType.Denied) - continue; + for (FriendStatus friend : friendStatuses) + { + if (friend.Status == FriendStatusType.Blocked || friend.Status == FriendStatusType.Denied) + continue; - if (!_preferenceManager.get(caller).isActive(Preference.PENDING_FRIEND_REQUESTS) && friend.Status == FriendStatusType.Pending) - continue; + if (!_preferenceManager.get(caller).isActive(Preference.PENDING_FRIEND_REQUESTS) && friend.Status == FriendStatusType.Pending) + continue; - gotAFriend = true; + gotAFriend = true; - ChildJsonMessage message = new JsonMessage("").color("white").extra("").color("white"); + ChildJsonMessage message = new JsonMessage("").color("white").extra("").color("white"); - if (friend.Status == FriendStatusType.Accepted) - { - if (friend.Online) - { - if (friend.ServerName.contains("Staff") || friend.ServerName.contains("CUST")) - { - if (isStaff && friend.ServerName.contains("Staff")) - message.add("Teleport").color("green").bold().click("run_command", "/server " + friend.ServerName) - .hover("show_text", "Teleport to " + friend.Name + "'s server."); - else - message.add("No Teleport").color("yellow").bold(); - } - else - message.add("Teleport").color("green").bold().click("run_command", "/server " + friend.ServerName) - .hover("show_text", "Teleport to " + friend.Name + "'s server."); + if (friend.Status == FriendStatusType.Accepted) + { + if (friend.Online) + { + if (friend.ServerName.contains("Staff") || friend.ServerName.contains("CUST")) + { + if (isStaff && friend.ServerName.contains("Staff")) + message.add("Teleport").color("green").bold().click("run_command", "/server " + friend.ServerName) + .hover("show_text", "Teleport to " + friend.Name + "'s server."); + else + message.add("No Teleport").color("yellow").bold(); + } + else + message.add("Teleport").color("green").bold().click("run_command", "/server " + friend.ServerName) + .hover("show_text", "Teleport to " + friend.Name + "'s server."); - message.add(" - ").color("white"); - message.add("Delete").color("red").bold().click("run_command", "/unfriend " + friend.Name) - .hover("show_text", "Remove " + friend.Name + " from your friends list."); - message.add(" - ").color("white"); - message.add(friend.Name).color(friend.Online ? "green" : "gray"); - message.add(" - ").color("white"); + message.add(" - ").color("white"); + message.add("Delete").color("red").bold().click("run_command", "/unfriend " + friend.Name) + .hover("show_text", "Remove " + friend.Name + " from your friends list."); + message.add(" - ").color("white"); + message.add(friend.Name).color(friend.Online ? "green" : "gray"); + message.add(" - ").color("white"); - if (friend.ServerName.contains("Staff") || friend.ServerName.contains("CUST")) - { - if (isStaff && friend.ServerName.contains("Staff")) - message.add(friend.ServerName).color("dark_green"); - else - message.add("Private Staff Server").color("dark_green"); - } - else - message.add(friend.ServerName).color("dark_green"); + if (friend.ServerName.contains("Staff") || friend.ServerName.contains("CUST")) + { + if (isStaff && friend.ServerName.contains("Staff")) + message.add(friend.ServerName).color("dark_green"); + else + message.add("Private Staff Server").color("dark_green"); + } + else + message.add(friend.ServerName).color("dark_green"); - onlineLines.add(message); - } - // Offline Friend - else - { - message.add("Delete").color("red").bold().click("run_command", "/unfriend " + friend.Name) - .hover("show_text", "Remove " + friend.Name + " from your friends list."); - message.add(" - ").color("white"); - message.add(friend.Name).color(friend.Online ? "green" : "gray"); - message.add(" - ").color("white"); - message.add("Offline for ").color("gray").add(UtilTime.MakeStr(friend.LastSeenOnline)).color("gray"); + onlineLines.add(message); + } + // Offline Friend + else + { + message.add("Delete").color("red").bold().click("run_command", "/unfriend " + friend.Name) + .hover("show_text", "Remove " + friend.Name + " from your friends list."); + message.add(" - ").color("white"); + message.add(friend.Name).color(friend.Online ? "green" : "gray"); + message.add(" - ").color("white"); + message.add("Offline for ").color("gray").add(UtilTime.MakeStr(friend.LastSeenOnline)).color("gray"); - offlineLines.add(message); - } - } - // Pending - else if (friend.Status == FriendStatusType.Pending) - { - message.add("Accept").color("green").bold().click("run_command", "/friend " + friend.Name) - .hover("show_text", "Accept " + friend.Name + "'s friend request."); - message.add(" - ").color("white"); - message.add("Deny").color("red").bold().click("run_command", "/unfriend " + friend.Name) - .hover("show_text", "Deny " + friend.Name + "'s friend request."); - message.add(" - ").color("white"); - message.add(friend.Name + " Requested Friendship").color("gray"); + offlineLines.add(message); + } + } + // Pending + else if (friend.Status == FriendStatusType.Pending) + { + message.add("Accept").color("green").bold().click("run_command", "/friend " + friend.Name) + .hover("show_text", "Accept " + friend.Name + "'s friend request."); + message.add(" - ").color("white"); + message.add("Deny").color("red").bold().click("run_command", "/unfriend " + friend.Name) + .hover("show_text", "Deny " + friend.Name + "'s friend request."); + message.add(" - ").color("white"); + message.add(friend.Name + " Requested Friendship").color("gray"); - pendingLines.add(message); - } - // Sent - else if (friend.Status == FriendStatusType.Sent) - { - message.add("Cancel").color("red").bold().click("run_command", "/unfriend " + friend.Name) - .hover("show_text", "Cancel friend request to " + friend.Name); - message.add(" - ").color("white"); - message.add(friend.Name + " Friendship Request").color("gray"); + pendingLines.add(message); + } + // Sent + else if (friend.Status == FriendStatusType.Sent) + { + message.add("Cancel").color("red").bold().click("run_command", "/unfriend " + friend.Name) + .hover("show_text", "Cancel friend request to " + friend.Name); + message.add(" - ").color("white"); + message.add(friend.Name + " Friendship Request").color("gray"); - sentLines.add(message); - } - } + sentLines.add(message); + } + } - // Send In Order - for (JsonMessage msg : sentLines) - msg.sendToPlayer(caller); + // Send In Order + for (JsonMessage msg : sentLines) + msg.sendToPlayer(caller); - for (JsonMessage msg : offlineLines) - msg.sendToPlayer(caller); + for (JsonMessage msg : offlineLines) + msg.sendToPlayer(caller); - for (JsonMessage msg : pendingLines) - msg.sendToPlayer(caller); + for (JsonMessage msg : pendingLines) + msg.sendToPlayer(caller); - for (JsonMessage msg : onlineLines) - msg.sendToPlayer(caller); + for (JsonMessage msg : onlineLines) + msg.sendToPlayer(caller); - if (!gotAFriend) - { - caller.sendMessage(" "); - caller.sendMessage("Welcome to your Friends List!"); - caller.sendMessage(" "); - caller.sendMessage("To add friends, type " + C.cGreen + "/friend "); - caller.sendMessage(" "); - caller.sendMessage("Type " + C.cGreen + "/friend" + ChatColor.RESET + " at any time to interact with your friends!"); - caller.sendMessage(" "); - } + if (!gotAFriend) + { + caller.sendMessage(" "); + caller.sendMessage("Welcome to your Friends List!"); + caller.sendMessage(" "); + caller.sendMessage("To add friends, type " + C.cGreen + "/friend "); + caller.sendMessage(" "); + caller.sendMessage("Type " + C.cGreen + "/friend" + ChatColor.RESET + " at any time to interact with your friends!"); + caller.sendMessage(" "); + } - ChildJsonMessage message = new JsonMessage("").extra(C.cAqua + C.Strike + "======================"); + ChildJsonMessage message = new JsonMessage("").extra(C.cAqua + C.Strike + "======================"); - message.add(C.cDAqua + "Toggle GUI").click("run_command", "/friendsdisplay"); + message.add(C.cDAqua + "Toggle GUI").click("run_command", "/friendsdisplay"); - message.hover("show_text", C.cAqua + "Toggle friends to display in an inventory"); + message.hover("show_text", C.cAqua + "Toggle friends to display in an inventory"); - message.add(C.cAqua + C.Strike + "======================"); + message.add(C.cAqua + C.Strike + "======================"); - message.sendToPlayer(caller); - } + message.sendToPlayer(caller); + } - public boolean isFriends(Player player, String friend) - { - FriendData friendData = Get(player); + public boolean isFriends(Player player, String friend) + { + FriendData friendData = Get(player); - for (FriendStatus friendStatus : friendData.getFriends()) - { - if (friendStatus.Name.equalsIgnoreCase(friend)) - { - return true; - } - } + for (FriendStatus friendStatus : friendData.getFriends()) + { + if (friendStatus.Name.equalsIgnoreCase(friend)) + { + return true; + } + } - return false; - } + return false; + } - public void updatePlayerStatus(UUID playerUUID, PlayerStatus status) - { - _repository.updatePlayerStatus(playerUUID, status); - } + public void updatePlayerStatus(UUID playerUUID, PlayerStatus status) + { + _repository.updatePlayerStatus(playerUUID, status); + } - public PlayerStatus getStatus(UUID playerUUID) - { - return _repository.getStatus(playerUUID); - } + public PlayerStatus getStatus(UUID playerUUID) + { + return _repository.getStatus(playerUUID); + } - @Override - public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException - { - Set(uuid, _repository.loadClientInformation(resultSet)); - } + @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 tA.Name, status, tA.lastLogin, now(), uuidTarget FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget WHERE uuidSource = '" - + uuid + "';"; - } -} + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT tA.Name, status, tA.lastLogin, now(), uuidTarget FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget WHERE uuidSource = '" + + uuid + "';"; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendStatusType.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendStatusType.java index 195e98e24..de12606c5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendStatusType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendStatusType.java @@ -7,4 +7,4 @@ public enum FriendStatusType Accepted, Denied, Blocked -} +} \ No newline at end of file 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 62546317e..a2ca807fd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java @@ -2,20 +2,19 @@ package mineplex.core.friend.command; import java.util.List; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.friend.FriendManager; import mineplex.core.friend.ui.FriendsGUI; import mineplex.core.preferences.Preference; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - public class AddFriend extends CommandBase { public AddFriend(FriendManager plugin) { - super(plugin, Rank.ALL, "friends", "friend", "f"); + super(plugin, FriendManager.FRIEND_COMMAND_PERMISSION, "friends", "friend", "f"); } @Override @@ -49,4 +48,4 @@ public class AddFriend extends CommandBase { return tabCompletePlayerNames(sender, args); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/DeleteFriend.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/DeleteFriend.java index 90959783c..9e382f560 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/DeleteFriend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/DeleteFriend.java @@ -3,7 +3,6 @@ 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.common.util.F; import mineplex.core.friend.FriendManager; @@ -12,7 +11,7 @@ public class DeleteFriend extends CommandBase { public DeleteFriend(FriendManager plugin) { - super(plugin, Rank.ALL, "unfriend"); + super(plugin, FriendManager.FRIEND_COMMAND_PERMISSION, "unfriend"); } @Override @@ -34,4 +33,4 @@ public class DeleteFriend extends CommandBase }); } } -} +} \ No newline at end of file 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 c0cc87554..e069fece4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java @@ -1,20 +1,19 @@ package mineplex.core.friend.command; -import mineplex.core.preferences.Preference; import org.bukkit.Sound; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.friend.FriendManager; import mineplex.core.friend.ui.FriendsGUI; +import mineplex.core.preferences.Preference; import mineplex.core.preferences.UserPreferences; public class FriendsDisplay extends CommandBase { public FriendsDisplay(FriendManager plugin) { - super(plugin, Rank.ALL, "friendsdisplay"); + super(plugin, FriendManager.FRIEND_COMMAND_PERMISSION, "friendsdisplay"); } @Override @@ -37,4 +36,4 @@ public class FriendsDisplay extends CommandBase Plugin.runAsync(() -> Plugin.showFriends(caller)); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/AddFriendPage.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/AddFriendPage.java index 31778c4f0..723e38421 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/AddFriendPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/AddFriendPage.java @@ -184,5 +184,4 @@ public class AddFriendPage implements Listener _currentInventory.setItem(0, new ItemBuilder(Material.PAPER).setRawTitle("Friend's Name").build()); _currentInventory.setItem(2, new ItemBuilder(Material.PAPER).setRawTitle("Search").build()); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendPage.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendPage.java index ada0b2688..745c6cdb3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendPage.java @@ -37,4 +37,4 @@ public enum FriendPage { return _icon; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java index e20fe63b4..6bd47e06a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/FriendsGUI.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; +import java.util.List; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -47,7 +48,6 @@ public class FriendsGUI implements Listener private int _page; private Comparator _friendCompare = new Comparator() { - @Override public int compare(FriendStatus o1, FriendStatus o2) { @@ -84,8 +84,7 @@ public class FriendsGUI implements Listener public void buildDeleteFriends() { - - ArrayList friends = new ArrayList(); + List friends = new ArrayList<>(); for (FriendStatus friend : getFriendData().getFriends()) { @@ -601,4 +600,4 @@ public class FriendsGUI implements Listener HandlerList.unregisterAll(this); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 2e871dcc8..825be43a7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -10,19 +10,6 @@ import java.util.Set; import java.util.UUID; import java.util.function.Predicate; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; -import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; -import mineplex.core.gadget.gadgets.flag.FlagType; -import mineplex.core.gadget.gadgets.morph.MorphBobRoss; -import mineplex.core.gadget.gadgets.morph.MorphFreedomFighter; -import mineplex.core.gadget.gadgets.morph.MorphMelonHead; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; -import mineplex.core.gadget.set.SetCanadian; -import mineplex.core.gadget.types.FlagGadget; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -40,9 +27,10 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; @@ -59,50 +47,54 @@ import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.event.PlayerToggleSwimEvent; import mineplex.core.gadget.event.TauntCommandEvent; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailTitan; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.balloons.BalloonItem; import mineplex.core.gadget.gadgets.balloons.BalloonType; +import mineplex.core.gadget.gadgets.death.DeathBlood; import mineplex.core.gadget.gadgets.death.DeathCandyCane; -import mineplex.core.gadget.gadgets.death.DeathPresentDanger; import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; import mineplex.core.gadget.gadgets.death.DeathEmerald; +import mineplex.core.gadget.gadgets.death.DeathEnchant; import mineplex.core.gadget.gadgets.death.DeathFreedom; import mineplex.core.gadget.gadgets.death.DeathFrostLord; -import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; import mineplex.core.gadget.gadgets.death.DeathMusic; import mineplex.core.gadget.gadgets.death.DeathPinataBurst; +import mineplex.core.gadget.gadgets.death.DeathPresentDanger; import mineplex.core.gadget.gadgets.death.DeathShadow; import mineplex.core.gadget.gadgets.death.DeathSpring; +import mineplex.core.gadget.gadgets.death.DeathStorm; import mineplex.core.gadget.gadgets.death.DeathTitan; -import mineplex.core.gadget.gadgets.death.DeathBlood; -import mineplex.core.gadget.gadgets.death.DeathEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.flag.FlagType; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.GameModifierMount; import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.MountType; @@ -140,6 +132,7 @@ import mineplex.core.gadget.gadgets.morph.MorphAwkwardRabbit; import mineplex.core.gadget.gadgets.morph.MorphBat; import mineplex.core.gadget.gadgets.morph.MorphBlaze; import mineplex.core.gadget.gadgets.morph.MorphBlock; +import mineplex.core.gadget.gadgets.morph.MorphBobRoss; import mineplex.core.gadget.gadgets.morph.MorphBunny; import mineplex.core.gadget.gadgets.morph.MorphChicken; import mineplex.core.gadget.gadgets.morph.MorphChristmasKing; @@ -147,9 +140,11 @@ import mineplex.core.gadget.gadgets.morph.MorphCow; import mineplex.core.gadget.gadgets.morph.MorphCreeper; import mineplex.core.gadget.gadgets.morph.MorphDinnerbone; import mineplex.core.gadget.gadgets.morph.MorphEnderman; +import mineplex.core.gadget.gadgets.morph.MorphFreedomFighter; import mineplex.core.gadget.gadgets.morph.MorphGoldPot; import mineplex.core.gadget.gadgets.morph.MorphGrimReaper; import mineplex.core.gadget.gadgets.morph.MorphLoveDoctor; +import mineplex.core.gadget.gadgets.morph.MorphMelonHead; import mineplex.core.gadget.gadgets.morph.MorphMetalMan; import mineplex.core.gadget.gadgets.morph.MorphPig; import mineplex.core.gadget.gadgets.morph.MorphPumpkinKing; @@ -183,13 +178,22 @@ import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksChestplate import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksHat; import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksLeggings; import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitBoosterManager; +import mineplex.core.gadget.gadgets.particle.ParticleBlood; +import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; import mineplex.core.gadget.gadgets.particle.ParticleChristmasTree; import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes; +import mineplex.core.gadget.gadgets.particle.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.gadgets.particle.ParticleFairy; import mineplex.core.gadget.gadgets.particle.ParticleFireRings; -import mineplex.core.gadget.gadgets.particle.king.CastleManager; -import mineplex.core.gadget.gadgets.particle.king.ParticleKing; +import mineplex.core.gadget.gadgets.particle.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleHeart; import mineplex.core.gadget.gadgets.particle.ParticleLegend; +import mineplex.core.gadget.gadgets.particle.ParticleMusic; +import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; +import mineplex.core.gadget.gadgets.particle.ParticleRain; +import mineplex.core.gadget.gadgets.particle.ParticleTitan; import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel; import mineplex.core.gadget.gadgets.particle.ParticleWingsBee; import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons; @@ -197,19 +201,14 @@ import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; import mineplex.core.gadget.gadgets.particle.ParticleWingsLove; import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie; import mineplex.core.gadget.gadgets.particle.ParticleYinYang; -import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; -import mineplex.core.gadget.gadgets.particle.ParticleHeart; -import mineplex.core.gadget.gadgets.particle.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; -import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; -import mineplex.core.gadget.gadgets.particle.ParticleRain; -import mineplex.core.gadget.gadgets.particle.ParticleMusic; -import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; -import mineplex.core.gadget.gadgets.particle.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; +import mineplex.core.gadget.gadgets.particle.king.CastleManager; +import mineplex.core.gadget.gadgets.particle.king.ParticleKing; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; -import mineplex.core.gadget.gadgets.particle.ParticleTitan; -import mineplex.core.gadget.gadgets.particle.ParticleBlood; -import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; import mineplex.core.gadget.gadgets.taunts.EternalTaunt; import mineplex.core.gadget.gadgets.taunts.RainbowTaunt; @@ -224,13 +223,13 @@ import mineplex.core.gadget.gadgets.wineffect.WinEffectPodium; import mineplex.core.gadget.gadgets.wineffect.WinEffectRiseOfTheElderGuardian; import mineplex.core.gadget.gadgets.wineffect.WinEffectSnowTrails; import mineplex.core.gadget.gadgets.wineffect.WinEffectWinterWarfare; -import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankEternal; import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankHero; import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankLegend; import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankTitan; import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankUltra; import mineplex.core.gadget.persistence.UserGadgetPersistence; +import mineplex.core.gadget.set.SetCanadian; import mineplex.core.gadget.set.SetCandyCane; import mineplex.core.gadget.set.SetCupidsLove; import mineplex.core.gadget.set.SetEmerald; @@ -252,6 +251,7 @@ import mineplex.core.gadget.types.ArrowEffectGadget; import mineplex.core.gadget.types.BalloonGadget; import mineplex.core.gadget.types.DeathEffectGadget; import mineplex.core.gadget.types.DoubleJumpEffectGadget; +import mineplex.core.gadget.types.FlagGadget; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetSet; import mineplex.core.gadget.types.GadgetType; @@ -280,6 +280,22 @@ import mineplex.core.treasure.TreasureManager; public class GadgetManager extends MiniPlugin { + public static final String TITAN_ARROW_TRAIL_PERMISSION = "mineplex.core.gadget.arrowtrail.titan"; + public static final String TITAN_DEATH_EFFECT_PERMISSION = "mineplex.core.gadget.deatheffect.titan"; + public static final String TITAN_DOUBLE_JUMP_PERMISSION = "mineplex.core.gadget.doublejump.titan"; + public static final String ETERNAL_TAUNT_PERMISSION = "mineplex.core.gadget.taunt.eternal"; + public static final String LEGEND_PARTICLE_EFFECT_PERMISSION = "mineplex.core.gadget.particleeffect.legend"; + public static final String TITAN_PARTICLE_EFFECT_PERMISSION = "mineplex.core.gadget.particleeffect.titan"; + public static final String HERO_MORPH_BLAZE_PERMISSION = "mineplex.core.gadget.morph.hero.blaze"; + public static final String HERO_MORPH_CREEPER_PERMISSION = "mineplex.core.gadget.morph.hero.creeper"; + public static final String ULTRA_MORPH_PERMISSION = "mineplex.core.gadget.morph.ultra"; + public static final String TITAN_MORPH_PERMISSION = "mineplex.core.gadget.morph.titan"; + public static final String LEGEND_MORPH_PERMISSION = "mineplex.core.gadget.morph.legend"; + public static final String AMMO_COMMAND_PERMISSION = "mineplex.core.gadget.ammocommand"; + public static final String LOCK_INFUSED_COMMAND_PERMISSION = "mineplex.core.gadget.lockinfused"; + public static final String LOCK_COSMETICS_COMMAND_PERMISSION = "mineplex.core.gadget.lockcosmetics"; + public static final String UNLOCK_COSMETICS_COMMAND_PERMISSION = "mineplex.core.gadget.unlockcosmetics"; + private final CoreClientManager _clientManager; private final DonationManager _donationManager; private final InventoryManager _inventoryManager; @@ -300,7 +316,6 @@ public class GadgetManager extends MiniPlugin private Map> _gadgets; private Map _singleParticleSelectors; - private List _rankBasedWinEffects; private final Map _lastMove = new HashMap<>(); private final Map> _playerActiveGadgetMap = new HashMap<>(); @@ -342,6 +357,36 @@ public class GadgetManager extends MiniPlugin createGadgets(); createSets(); + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("titan"), GroupPermission.of(TITAN_ARROW_TRAIL_PERMISSION), true, true); + pm.setPermission(pm.getGroup("titan"), GroupPermission.of(TITAN_DEATH_EFFECT_PERMISSION), true, true); + pm.setPermission(pm.getGroup("titan"), GroupPermission.of(TITAN_DOUBLE_JUMP_PERMISSION), true, true); + pm.setPermission(pm.getGroup("eternal"), GroupPermission.of(ETERNAL_TAUNT_PERMISSION), true, true); + pm.setPermission(pm.getGroup("legend"), GroupPermission.of(LEGEND_PARTICLE_EFFECT_PERMISSION), true, true); + pm.setPermission(pm.getGroup("titan"), GroupPermission.of(TITAN_PARTICLE_EFFECT_PERMISSION), true, true); + pm.setPermission(pm.getGroup("hero"), GroupPermission.of(HERO_MORPH_BLAZE_PERMISSION), true, true); + pm.setPermission(pm.getGroup("hero"), GroupPermission.of(HERO_MORPH_CREEPER_PERMISSION), true, true); + pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(ULTRA_MORPH_PERMISSION), true, true); + pm.setPermission(pm.getGroup("titan"), GroupPermission.of(TITAN_MORPH_PERMISSION), true, true); + pm.setPermission(pm.getGroup("legend"), GroupPermission.of(LEGEND_MORPH_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(AMMO_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(LOCK_INFUSED_COMMAND_PERMISSION), true, true); + if (UtilServer.isTestServer()) + { + pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(LOCK_COSMETICS_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(UNLOCK_COSMETICS_COMMAND_PERMISSION), true, true); + } + else + { + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(LOCK_COSMETICS_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(UNLOCK_COSMETICS_COMMAND_PERMISSION), true, true); + } } @Override @@ -384,7 +429,6 @@ public class GadgetManager extends MiniPlugin private void createGadgets() { _gadgets = new HashMap<>(); - _rankBasedWinEffects = new ArrayList<>(); _singleParticleSelectors = new HashMap<>(); // Items @@ -686,11 +730,14 @@ public class GadgetManager extends MiniPlugin public T getGadget(Class c) { - for(GadgetType type : GadgetType.values()) + for (GadgetType type : GadgetType.values()) { - for(Gadget gadget : getGadgets(type)) + for (Gadget gadget : getGadgets(type)) { - if(gadget.getClass().equals(c)) return (T) gadget; + if (gadget.getClass().equals(c)) + { + return (T) gadget; + } } } return null; @@ -726,9 +773,6 @@ public class GadgetManager extends MiniPlugin _gadgets.put(gadget.getGadgetType(), new ArrayList<>()); _gadgets.get(gadget.getGadgetType()).add(gadget); - - if (gadget instanceof WinEffectRankBased) - _rankBasedWinEffects.add((WinEffectRankBased) gadget); } @EventHandler @@ -893,18 +937,6 @@ public class GadgetManager extends MiniPlugin return null; } - public WinEffectRankBased getRankBasedWinEffect(WinEffectRankBased.WinEffectType winEffectType, Rank rank) - { - for (WinEffectRankBased winEffectRankBased : _rankBasedWinEffects) - { - if (winEffectRankBased.getWinEffectType().equals(winEffectType) && winEffectRankBased.getRank().equals(rank)) - { - return winEffectRankBased; - } - } - return null; - } - public SingleParticleKitSelector getSingleParticleKitSelector(SingleParticleKitSelector.SingleParticleSelectors singleParticleSelectors) { return (SingleParticleKitSelector) _singleParticleSelectors.get(singleParticleSelectors); @@ -1527,5 +1559,4 @@ public class GadgetManager extends MiniPlugin { return _castleManager; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java index c2d289d9c..088447c37 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java @@ -3,7 +3,6 @@ package mineplex.core.gadget.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.gadget.GadgetManager; @@ -12,19 +11,19 @@ import mineplex.core.gadget.types.GadgetType; public class AmmoCommand extends CommandBase { - private GadgetManager _plugin; public AmmoCommand(GadgetManager plugin) { - super(plugin, Rank.JNR_DEV, "ammo"); + super(plugin, GadgetManager.AMMO_COMMAND_PERMISSION, "ammo"); + _plugin = plugin; } @Override public void Execute(Player caller, String[] args) { - if(args.length == 2) + if (args.length == 2) { String gadgetName = args[0]; String amount = args[1]; @@ -101,8 +100,10 @@ public class AmmoCommand extends CommandBase for (Gadget gadget : _plugin.getGadgets(GadgetType.ITEM)) { if (gadget.getName().equalsIgnoreCase(gadgetName.replaceAll("_", " "))) + { return gadget; + } } return null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java index a4968bead..2d0ed2bd9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java @@ -4,7 +4,6 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -18,24 +17,18 @@ import mineplex.core.pet.PetType; public class LockCosmeticsCommand extends CommandBase { - private GadgetManager _plugin; public LockCosmeticsCommand(GadgetManager plugin) { - super(plugin, Rank.SNR_MODERATOR, "lockCosmetics"); + super(plugin, GadgetManager.LOCK_COSMETICS_COMMAND_PERMISSION, "lockCosmetics"); + _plugin = plugin; } @Override public void Execute(Player caller, String[] args) { - if (!UtilServer.isTestServer()) - { - UtilPlayer.message(caller, F.main("Lock Cosmetics", "This command requires a test server!")); - return; - } - // Adds all cosmetic types if (args.length == 0) { @@ -122,5 +115,4 @@ public class LockCosmeticsCommand extends CommandBase } UtilPlayer.message(caller, F.main("Lock Cosmetics", "Removed " + removed + UtilText.plural(" pet", removed) + "!")); } - } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java index d57b89228..ae10cfd5d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java @@ -7,7 +7,6 @@ import java.util.List; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; @@ -27,12 +26,12 @@ import mineplex.core.mount.Mount; public class LockInfusedCommand extends CommandBase { - private GadgetManager _manager; public LockInfusedCommand(GadgetManager manager) { - super(manager, Rank.JNR_DEV, "lockinfused"); + super(manager, GadgetManager.LOCK_INFUSED_COMMAND_PERMISSION, "lockinfused"); + _manager = manager; } @@ -77,5 +76,4 @@ public class LockInfusedCommand extends CommandBase _manager.getDonationManager().Get(player).removeAllOwnedUnknownSalesPackages(mount.getName()); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java index 69e6f863d..a3d0f74c5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java @@ -4,7 +4,6 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -18,24 +17,18 @@ import mineplex.core.pet.PetType; public class UnlockCosmeticsCommand extends CommandBase { - private GadgetManager _plugin; public UnlockCosmeticsCommand(GadgetManager plugin) { - super(plugin, Rank.SNR_MODERATOR, "unlockCosmetics"); + super(plugin, GadgetManager.UNLOCK_COSMETICS_COMMAND_PERMISSION, "unlockCosmetics"); + _plugin = plugin; } @Override public void Execute(Player caller, String[] args) { - if (!UtilServer.isTestServer()) - { - UtilPlayer.message(caller, F.main("Unlock Cosmetics", "This command requires a test server!")); - return; - } - // Adds all cosmetic types if (args.length == 0) { @@ -145,4 +138,4 @@ public class UnlockCosmeticsCommand extends CommandBase } UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added " + added + UtilText.plural(" pet", added) + "!")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java index 29c39b7d0..6d5722908 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailTitan.java @@ -5,14 +5,14 @@ import org.bukkit.entity.Arrow; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.ArrowEffectGadget; @@ -43,9 +43,9 @@ public class ArrowTrailTitan extends ArrowEffectGadget @EventHandler public void titanOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) + if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.TITAN_ARROW_TRAIL_PERMISSION))) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java index 0e56f8308..6579c3d4d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathTitan.java @@ -5,8 +5,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.blood.BloodEvent; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; @@ -32,10 +32,9 @@ public class DeathTitan extends DeathEffectGadget @EventHandler public void titanOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) + if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.TITAN_DEATH_EFFECT_PERMISSION))) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } - } - -} + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java index 9c81a3309..9a95f32c9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpTitan.java @@ -5,14 +5,14 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.DoubleJumpEffectGadget; @@ -37,9 +37,9 @@ public class DoubleJumpTitan extends DoubleJumpEffectGadget @EventHandler public void titanOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) + if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.TITAN_DOUBLE_JUMP_PERMISSION))) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java index abd40e459..a986fe1a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBlaze.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; @@ -81,9 +81,9 @@ public class MorphBlaze extends MorphGadget @EventHandler public void HeroOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO)) + if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.HERO_MORPH_BLAZE_PERMISSION))) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java index bcce06361..6396bf28d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java @@ -10,7 +10,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; @@ -168,7 +168,7 @@ public class MorphCreeper extends MorphGadget @EventHandler public void HeroOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO)) + if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.HERO_MORPH_CREEPER_PERMISSION))) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } @@ -179,4 +179,4 @@ public class MorphCreeper extends MorphGadget { _active.remove(event.getPlayer()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphDinnerbone.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphDinnerbone.java index ba67af21c..eb505deaa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphDinnerbone.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphDinnerbone.java @@ -1,5 +1,7 @@ package mineplex.core.gadget.gadgets.morph; +import static mineplex.core.common.util.UtilServer.runSync; + import java.time.Month; import java.time.YearMonth; import java.util.Arrays; @@ -8,17 +10,6 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import net.minecraft.server.v1_8_R3.DataWatcher; -import net.minecraft.server.v1_8_R3.EntityArmorStand; -import net.minecraft.server.v1_8_R3.EntitySlime; -import net.minecraft.server.v1_8_R3.MathHelper; -import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; -import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; -import net.minecraft.server.v1_8_R3.PacketPlayOutNewAttachEntity; -import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; -import net.minecraft.server.v1_8_R3.World; - import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; @@ -31,9 +22,8 @@ import com.mojang.authlib.GameProfile; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.DummyEntity; -import mineplex.core.common.Rank; -import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilEnt; @@ -48,8 +38,15 @@ import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketInfo; import mineplex.core.utils.UtilGameProfile; - -import static mineplex.core.common.util.UtilServer.runSync; +import net.minecraft.server.v1_8_R3.DataWatcher; +import net.minecraft.server.v1_8_R3.EntityArmorStand; +import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; +import net.minecraft.server.v1_8_R3.PacketPlayOutNewAttachEntity; +import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_8_R3.World; public class MorphDinnerbone extends MorphGadget implements IPacketHandler { @@ -303,14 +300,14 @@ public class MorphDinnerbone extends MorphGadget implements IPacketHandler private DataWatcher getArmorStandWatcher(Player ownerOfTrack) { - Rank rank = _coreClientManager.Get(ownerOfTrack).getRealOrDisguisedRank(); + PermissionGroup group = _coreClientManager.Get(ownerOfTrack).getRealOrDisguisedPrimaryGroup(); String name = ownerOfTrack.getName(); - if (rank != null) + if (group != null) { - if (rank.has(Rank.ULTRA)) + if (!group.getDisplay(false, false, false, false).isEmpty()) { - name = rank.getTag(true, true) + " " + ChatColor.RESET + name; + name = group.getDisplay(true, true, true, false) + " " + ChatColor.RESET + name; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java index d45504531..3ed4f1b18 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java @@ -11,7 +11,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; @@ -82,9 +82,9 @@ public class MorphPig extends MorphGadget } @EventHandler - public void HeroOwner(PlayerJoinEvent event) + public void UltraOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.ULTRA)) + if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.ULTRA_MORPH_PERMISSION))) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } @@ -180,4 +180,4 @@ public class MorphPig extends MorphGadget { _double.remove(event.getPlayer()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java index 925934a72..9632b3219 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSlime.java @@ -6,7 +6,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; -import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; @@ -23,7 +22,6 @@ import mineplex.core.recharge.Recharge; public class MorphSlime extends MorphGadget { - private CoreClientManager _clientManager; private AchievementManager _achievementManager; public MorphSlime(GadgetManager manager, AchievementManager achievements) @@ -40,7 +38,6 @@ public class MorphSlime extends MorphGadget Material.SLIME_BALL, (byte)0); _achievementManager = achievements; - _clientManager = manager.getClientManager(); } @Override @@ -50,7 +47,7 @@ public class MorphSlime extends MorphGadget DisguiseSlime disguise = new DisguiseSlime(player); - int size = 1 + (_achievementManager.getMineplexLevelNumber(player, _clientManager.Get(player).GetRank())) / 8; + int size = 1 + _achievementManager.getMineplexLevelNumber(player) / 8; if (size < 1) size = 1; @@ -90,7 +87,7 @@ public class MorphSlime extends MorphGadget player.getWorld().playSound(player.getLocation(), Sound.SLIME_ATTACK, 1f, 1f); //Size - int size = 1 + (_achievementManager.getMineplexLevelNumber(player, _clientManager.Get(player).GetRank())) / 8; + int size = 1 + _achievementManager.getMineplexLevelNumber(player) / 8; if (size < 1) size = 1; @@ -101,4 +98,4 @@ public class MorphSlime extends MorphGadget //Vel UtilAction.velocity(player, 1 + (size * 0.2), 0, 10, true); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java index 24cd35247..935f0db95 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java @@ -16,7 +16,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; @@ -225,7 +225,7 @@ public class MorphTitan extends MorphGadget @EventHandler public void titanOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) + if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.TITAN_MORPH_PERMISSION))) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } @@ -251,4 +251,4 @@ public class MorphTitan extends MorphGadget } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java index 503cef717..8fedc0989 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java @@ -15,7 +15,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; @@ -39,7 +39,6 @@ import mineplex.core.inventory.ClientItem; import mineplex.core.inventory.data.Item; import mineplex.core.mount.DragonMount; import mineplex.core.mount.Mount; -import mineplex.core.mount.types.MountDragon; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -191,7 +190,7 @@ public class MorphWither extends MorphGadget public void legendOwner(PlayerJoinEvent event) { // TODO HARDCODED Wither Morph Database Item Id - 550 - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND)) + if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.LEGEND_MORPH_PERMISSION))) { Manager.getInventoryManager().Get(event.getPlayer()).addItem(new ClientItem(new Item(550, getName()), 1)); } @@ -219,4 +218,4 @@ public class MorphWither extends MorphGadget Manager.getDisguiseManager().updateDisguise(disguise); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/UtilMorph.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/UtilMorph.java index e186e7845..4f9dba8e4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/UtilMorph.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/UtilMorph.java @@ -13,7 +13,6 @@ import mineplex.core.gadget.GadgetManager; public class UtilMorph { - /** * UtilMorph helps disguising and undisguising players, avoiding the use of deprecated methods */ @@ -32,7 +31,7 @@ public class UtilMorph if (disguiseBase instanceof DisguiseInsentient) { DisguiseInsentient disguiseInsentient = (DisguiseInsentient) disguiseBase; - disguiseInsentient.setName(player.getName(), gadgetManager.getClientManager().Get(player).getRealOrDisguisedRank()); + disguiseInsentient.setName(player.getName(), gadgetManager.getClientManager().Get(player).getRealOrDisguisedPrimaryGroup()); disguiseInsentient.setCustomNameVisible(true); gadgetManager.getDisguiseManager().disguise(disguiseInsentient); } @@ -55,7 +54,7 @@ public class UtilMorph if (disguiseBase instanceof DisguiseInsentient) { DisguiseInsentient disguiseInsentient = (DisguiseInsentient) disguiseBase; - disguiseInsentient.setName(player.getName(), gadgetManager.getClientManager().Get(player).getRealOrDisguisedRank()); + disguiseInsentient.setName(player.getName(), gadgetManager.getClientManager().Get(player).getRealOrDisguisedPrimaryGroup()); if (!wither) { disguiseInsentient.setCustomNameVisible(true); @@ -94,5 +93,4 @@ public class UtilMorph _disguises.remove(player.getUniqueId()); } } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java index 651993fb9..409f3aa4d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java @@ -21,7 +21,7 @@ public class ParticleCoalFumes extends ParticleGadget public ParticleCoalFumes(GadgetManager manager) { super(manager, "Coal Fumes", - UtilText.splitLineToArray(C.cGray + "Being on the Naughty List does have some hattori... if you love coal, that is...", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "Being on the Naughty List does have some perks... if you love coal, that is...", LineFormat.LORE), -1, Material.COAL, (byte) 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java deleted file mode 100644 index 92239bdfd..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronos.java +++ /dev/null @@ -1,82 +0,0 @@ -package mineplex.core.gadget.gadgets.particle; - -import java.util.HashMap; - -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.gadget.GadgetManager; -import mineplex.core.gadget.types.ParticleGadget; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -public class ParticleKronos extends ParticleGadget -{ - private HashMap _glass = new HashMap(); - - public ParticleKronos(GadgetManager manager) - { - super(manager, "Titanic Aura", new String[] - { - C.cGray + "A symbol of Titan power", - C.cGray + "whos ancestry traces back to Kronos,", - C.cGray + "Titan Lord of Time.", - " ", - C.cRed + "???" - //When purchasable: C.cRed + "Unlocked with Titan Rank" - }, - -2, - Material.EYE_OF_ENDER, (byte)0); - } - - @Override - public void playParticle(Player player, UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - - //Create - if (!_glass.containsKey(player)) - _glass.put(player, new ParticleKronosData(player)); - - _glass.get(player).update(Manager.isMoving(player)); - } - - @EventHandler - public void titanOwner(PlayerJoinEvent event) - { - /*Until it becomes purchasable*/if (Manager.getClientManager().Get(event.getPlayer()).GetRank().equals(Rank.TITAN)) - //if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) - { - Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); - } - } - - @Override - public void disableCustom(Player player, boolean message) - { - if (_active.remove(player)) - UtilPlayer.message(player, F.main("Gadget", "You unsummoned " + F.elem(getName()) + ".")); - - clean(player); - } - - @EventHandler - public void quit(PlayerQuitEvent event) - { - clean(event.getPlayer()); - } - - private void clean(Player player) - { - _glass.remove(player); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronosData.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronosData.java deleted file mode 100644 index 289a60099..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleKronosData.java +++ /dev/null @@ -1,112 +0,0 @@ -package mineplex.core.gadget.gadgets.particle; - -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 org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class ParticleKronosData -{ - private static class Sin - { - static final float[] table = new float[16384]; - - static - { - for (int i = 0; i < 16384; i++) - { - table[i] = ((float)Math.sin((i + 0.5F) / 16384.0F * 6.283186F)); - } - for (int i = 0; i < 360; i += 90) - { - table[((int)(i * 45.511112F) & 0x3FFF)] = ((float)Math.sin(i * 0.01745329F)); - } - } - } - - private int _step; - private Player _player; - - public ParticleKronosData(Player player) - { - _player = player; - } - - public void update(boolean moving) - { - if (moving) - UtilParticle.PlayParticle(ParticleType.ENCHANTMENT_TABLE, _player.getLocation().add(0, 1f, 0), 0.2f, 0.2f, 0.2f, 0, 1, - ViewDist.NORMAL, UtilServer.getPlayers()); - else - { - Vector v = new Vector(); - Location loc = _player.getLocation().clone(); - for (int i = 0; i < 8; i++) - { - _step += 1; - - float f1 = 3.141593F / 120 * _step; - float f2 = sinFloat(f1 * 2.718282F * 8 / 120) * 1F; - float f3 = f2 * 3.141593F * f1; - - v.setX(1F * f2 * -cosFloat(f3)); - v.setZ(1F * f2 * -sinFloat(f3)); - v.setY(0.6F * f2 + 0.6F + 2.0F); - - rotateVector(v, 0, 0, 0); - - UtilParticle.PlayParticle(ParticleType.ENCHANTMENT_TABLE, loc.add(v), 0, 0, 0, 0, 1, - ViewDist.NORMAL, UtilServer.getPlayers()); - - loc.subtract(v); - } - - //Sound - _player.getWorld().playSound(_player.getLocation(), Sound.CAT_HISS, 0.2f, 1f); - } - } - - private void rotateVector(Vector vector, double x, double y, double z) - { - double cos; - double sin; - double new1; - double new2; - - //x-axis - cos = Math.cos(x); - sin = Math.sin(x); - new1 = vector.getY() * cos - vector.getZ() * sin; - new2 = vector.getY() * sin + vector.getZ() * cos; - vector.setY(new1).setZ(new2); - - //y-axis - cos = Math.cos(y); - sin = Math.sin(y); - new1 = vector.getX() * cos - vector.getZ() * sin; - new2 = vector.getX() * sin + vector.getZ() * cos; - vector.setX(new1).setZ(new2); - - //z-axis - cos = Math.cos(z); - sin = Math.sin(z); - new1 = vector.getX() * cos - vector.getY() * sin; - new2 = vector.getX() * sin + vector.getY() * cos; - vector.setX(new1).setY(new2); - } - - private float sinFloat(float f) - { - return Sin.table[((int)(f * 2607.5945F) & 0x3FFF)]; - } - - private float cosFloat(float f) - { - return Sin.table[((int)((f + 1.570796F) * 2607.5945F) & 0x3FFF)]; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java index 9f1a9afa4..9129b3870 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java @@ -1,6 +1,6 @@ package mineplex.core.gadget.gadgets.particle; -import java.awt.*; +import java.awt.Color; import org.bukkit.Location; import org.bukkit.Material; @@ -8,7 +8,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilMath; @@ -35,10 +35,11 @@ public class ParticleLegend extends ParticleGadget private static final double HEIGHT_MODIFIER_BASE = 0.1; private static final double HEIGHT_MODIFIER_MAX = 1.3; private static final double HEIGHT_MODIFIER_INTERVAL = 0.15; - private static final Color[] SELECTABLE_COLORS = { - new Color(60, 170, 25), - new Color(33, 92, 13), - new Color(0, 0, 0) + private static final Color[] SELECTABLE_COLORS = + { + new Color(60, 170, 25), + new Color(33, 92, 13), + new Color(0, 0, 0) }; private final int _pillars = pillars(); @@ -209,9 +210,9 @@ public class ParticleLegend extends ParticleGadget public void legendOwner(PlayerJoinEvent event) { // TODO HARDCODED Legendary Aura Database Item Id - 552 - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND)) + if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.LEGEND_PARTICLE_EFFECT_PERMISSION))) { Manager.getInventoryManager().Get(event.getPlayer()).addItem(new ClientItem(new Item(552, getName()), 1)); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java index 7d062f713..aafbafef2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java @@ -7,13 +7,13 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.updater.UpdateType; @@ -94,9 +94,9 @@ public class ParticleTitan extends ParticleGadget @EventHandler public void titanOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) + if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.TITAN_PARTICLE_EFFECT_PERMISSION))) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/CastleManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/CastleManager.java index c1a8415d5..82f92870a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/CastleManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/CastleManager.java @@ -24,10 +24,11 @@ import org.spigotmc.event.entity.EntityDismountEvent; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilColor; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilWorld; @@ -45,7 +46,6 @@ import mineplex.core.updater.event.UpdateEvent; */ public class CastleManager extends MiniPlugin { - private King _king; private Location _castleLocationA = new Location(UtilWorld.getWorld("world"), 32, 71, -4); @@ -612,9 +612,9 @@ public class CastleManager extends MiniPlugin if (_king != null) { King king = getKing(); - Rank rank = _coreClientManager.Get(king.getKing()).getRealOrDisguisedRank(); + PermissionGroup group = _coreClientManager.Get(king.getKing()).getRealOrDisguisedPrimaryGroup(); material = Material.WOOL; - data = rank.getDyeColor().getWoolData(); + data = UtilColor.chatColorToWoolData(group.getColor()); } for (Location location : _woolLocations) { @@ -692,4 +692,4 @@ public class CastleManager extends MiniPlugin if (isInsideCastle(event.getLocation())) event.setCancelled(true); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java index 6e0a7e133..bdd3fcc7e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java @@ -6,8 +6,6 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import mineplex.core.disguise.disguises.DisguiseBase; -import mineplex.core.game.GameDisplay; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -20,24 +18,25 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.util.Vector; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.events.EnableArcadeSpawnEvent; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.TauntGadget; +import mineplex.core.game.GameDisplay; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; public class EternalTaunt extends TauntGadget { - private static final int COOLDOWN = 30000; private static final int PVP_COOLDOWN = 10000; @@ -146,7 +145,7 @@ public class EternalTaunt extends TauntGadget @EventHandler public void titanOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.ETERNAL)) + if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.ETERNAL_TAUNT_PERMISSION))) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } @@ -160,9 +159,10 @@ public class EternalTaunt extends TauntGadget for (Item item : clocks) { if (event.getItem().equals(item)) + { event.setCancelled(true); + } } } } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java index 48381aafa..16d7823d3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java @@ -1,10 +1,9 @@ package mineplex.core.gadget.gadgets.wineffect.rankrooms; import org.bukkit.Material; -import org.bukkit.entity.Player; -import mineplex.core.Managers; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.WinEffectGadget; @@ -13,8 +12,9 @@ import mineplex.core.gadget.types.WinEffectGadget; */ public abstract class WinEffectRankBased extends WinEffectGadget { - - private Rank _rank; + public static final String PERMISSION_BASE = "mineplex.core.gadget.wineffect.ranked."; + + private PermissionGroup _rank; private WinEffectType _winEffectType; /** @@ -23,43 +23,31 @@ public abstract class WinEffectRankBased extends WinEffectGadget * @param winEffectType The win effect type, used to display in menus * @param alternativeSalepackageNames */ - public WinEffectRankBased(GadgetManager manager, String name, String[] lore, Material material, byte data, Rank rank, WinEffectType winEffectType, String... alternativeSalepackageNames) + public WinEffectRankBased(GadgetManager manager, String name, String[] lore, Material material, byte data, PermissionGroup rank, WinEffectType winEffectType, String... alternativeSalepackageNames) { super(manager, name, lore, -1, material, data, true, alternativeSalepackageNames); _rank = rank; _winEffectType = winEffectType; - _schematicName = winEffectType.getSchematic().replace("%r%", rank.getRawTag()); + _schematicName = winEffectType.getSchematic().replace("%r%", rank.getIdentifier().substring(0, 1).toUpperCase() + rank.getIdentifier().substring(1)); + + manager.getClientManager().getPermissionManager().setPermission(rank, getUnlockPermission(), true, true); } - public Rank getRank() + public PermissionGroup getRank() { return _rank; } + + public GroupPermission getUnlockPermission() + { + return GroupPermission.of(PERMISSION_BASE + _rank.getIdentifier()); + } public WinEffectType getWinEffectType() { return _winEffectType; } - /** - * Gets the highest possible rank for the player - * @param player The player - * @return The highest rank for that player or null if GadgetManager isn't loaded - */ - public static Rank getHighestRankForPlayer(Player player) - { - GadgetManager gadgetManager = Managers.get(GadgetManager.class); - if (gadgetManager != null) - { - Rank rank = gadgetManager.getClientManager().Get(player).GetRank(); - if (rank.has(Rank.ETERNAL)) - return Rank.ETERNAL; - else - return rank; - } - return null; - } - public enum WinEffectType { RANK_WIN_EFFECT("WinRank%r%"); @@ -76,5 +64,4 @@ public abstract class WinEffectRankBased extends WinEffectGadget return _schematic; } } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java index 03ddfa4d5..8c9415ec2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java @@ -13,7 +13,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.util.Vector; import mineplex.core.common.MaterialData; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; @@ -28,7 +27,6 @@ import mineplex.core.updater.event.UpdateEvent; public class WinEffectRankEternal extends WinEffectRankBased { - private DisguisePlayer _npc; private Guardian _guardian = null; private int _step = 0; @@ -41,7 +39,7 @@ public class WinEffectRankEternal extends WinEffectRankBased { super(manager, "Eternal Win Effect", UtilText.splitLinesToArray(new String[]{C.cGray + "GWEN is ALWAYS watching."}, LineFormat.LORE), - Material.PRISMARINE_SHARD, (byte) 0, Rank.ETERNAL, WinEffectType.RANK_WIN_EFFECT); + Material.PRISMARINE_SHARD, (byte) 0, manager.getClientManager().getPermissionManager().getGroup("eternal"), WinEffectType.RANK_WIN_EFFECT); } @Override @@ -149,5 +147,4 @@ public class WinEffectRankEternal extends WinEffectRankBased ArmorStand armorStand = (ArmorStand) _npc.getEntity().getBukkitEntity(); armorStand.setHealth(0); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java index f71cf48b6..d06caba29 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java @@ -13,7 +13,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.util.Vector; import mineplex.core.common.MaterialData; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; @@ -28,7 +27,6 @@ import mineplex.core.updater.event.UpdateEvent; public class WinEffectRankHero extends WinEffectRankBased { - private DisguisePlayer _npc; private EnderDragon _enderDragon = null; private int _step = 0; @@ -41,7 +39,7 @@ public class WinEffectRankHero extends WinEffectRankBased { super(manager, "Hero Win Effect", UtilText.splitLinesToArray(new String[]{C.cGray + "To become a True Hero you must first defeat the Dragon."}, LineFormat.LORE), - Material.DRAGON_EGG, (byte) 0, Rank.HERO, WinEffectType.RANK_WIN_EFFECT); + Material.DRAGON_EGG, (byte) 0, manager.getClientManager().getPermissionManager().getGroup("hero"), WinEffectType.RANK_WIN_EFFECT); } @Override @@ -129,5 +127,4 @@ public class WinEffectRankHero extends WinEffectRankBased ArmorStand armorStand = (ArmorStand) _npc.getEntity().getBukkitEntity(); armorStand.setHealth(0); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java index ab96a352c..de38f79dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java @@ -13,7 +13,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.util.Vector; import mineplex.core.common.MaterialData; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; @@ -28,7 +27,6 @@ import mineplex.core.updater.event.UpdateEvent; public class WinEffectRankLegend extends WinEffectRankBased { - private DisguisePlayer _npc; private Wither _wither = null; private int _step = 0; @@ -41,7 +39,7 @@ public class WinEffectRankLegend extends WinEffectRankBased { super(manager, "Legend Win Effect", UtilText.splitLinesToArray(new String[]{C.cGray + "Can you weather this Withering Assault?"}, LineFormat.LORE), - Material.SKULL_ITEM, (byte) 1, Rank.LEGEND, WinEffectType.RANK_WIN_EFFECT); + Material.SKULL_ITEM, (byte) 1, manager.getClientManager().getPermissionManager().getGroup("legend"), WinEffectType.RANK_WIN_EFFECT); } @Override @@ -124,5 +122,4 @@ public class WinEffectRankLegend extends WinEffectRankBased ArmorStand armorStand = (ArmorStand) _npc.getEntity().getBukkitEntity(); armorStand.setHealth(0); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java index 93c508ae5..e15eec81b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java @@ -12,7 +12,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; import mineplex.core.common.MaterialData; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; @@ -27,7 +26,6 @@ import mineplex.core.updater.event.UpdateEvent; public class WinEffectRankTitan extends WinEffectRankBased { - private DisguisePlayer _npc; private Giant _giant = null; private int _step = 0; @@ -38,7 +36,7 @@ public class WinEffectRankTitan extends WinEffectRankBased { super(manager, "Titan Win Effect", UtilText.splitLinesToArray(new String[]{C.cGray + "Legend has it that the Titans were so powerful they towered over even the gods."}, LineFormat.LORE), - Material.ROTTEN_FLESH, (byte) 0, Rank.TITAN, WinEffectType.RANK_WIN_EFFECT); + Material.ROTTEN_FLESH, (byte) 0, manager.getClientManager().getPermissionManager().getGroup("titan"), WinEffectType.RANK_WIN_EFFECT); } @Override @@ -111,5 +109,4 @@ public class WinEffectRankTitan extends WinEffectRankBased } } } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java index afb57433c..c6e1edfd2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java @@ -13,7 +13,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityExplodeEvent; import mineplex.core.common.MaterialData; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; @@ -28,7 +27,6 @@ import mineplex.core.updater.event.UpdateEvent; public class WinEffectRankUltra extends WinEffectRankBased { - private static final int RADIUS = 5; private DisguisePlayer _npc; @@ -38,7 +36,7 @@ public class WinEffectRankUltra extends WinEffectRankBased public WinEffectRankUltra(GadgetManager manager) { super(manager, "Ultra Win Effect", UtilText.splitLinesToArray(new String[]{C.cGray + "Always check behind you."}, LineFormat.LORE), - Material.SKULL_ITEM, (byte) 4, Rank.ULTRA, WinEffectType.RANK_WIN_EFFECT); + Material.SKULL_ITEM, (byte) 4, manager.getClientManager().getPermissionManager().getGroup("ultra"), WinEffectType.RANK_WIN_EFFECT); } @Override @@ -110,5 +108,4 @@ public class WinEffectRankUltra extends WinEffectRankBased armorStand.setHealth(0); } } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java index aab6e9c71..c8a512f84 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java @@ -184,14 +184,29 @@ public abstract class Gadget extends SalesPackageBase implements Listener public boolean ownsGadget(Player player) { - if(isFree() || _free) { return true; } - if(Manager.getDonationManager().Get(player).ownsUnknownSalesPackage(getName())) { return true; } - if(Manager.getInventoryManager().Get(player).getItemCount(getName()) > 0) { return true; } - - for(String alt : _alternativePackageNames) + if (isFree() || _free) { - if(Manager.getDonationManager().Get(player).ownsUnknownSalesPackage(alt)) { return true; } - if(Manager.getInventoryManager().Get(player).getItemCount(alt) > 0) { return true; } + return true; + } + if (Manager.getDonationManager().Get(player).ownsUnknownSalesPackage(getName())) + { + return true; + } + if (Manager.getInventoryManager().Get(player).getItemCount(getName()) > 0) + { + return true; + } + + for (String alt : _alternativePackageNames) + { + if (Manager.getDonationManager().Get(player).ownsUnknownSalesPackage(alt)) + { + return true; + } + if (Manager.getInventoryManager().Get(player).getItemCount(alt) > 0) + { + return true; + } } return false; @@ -226,4 +241,4 @@ public abstract class Gadget extends SalesPackageBase implements Listener { return _displayItem; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java index faf54e131..313d32549 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java @@ -24,6 +24,7 @@ import org.bukkit.util.Vector; import com.mojang.authlib.GameProfile; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.block.schematic.Schematic; import mineplex.core.common.block.schematic.UtilSchematic; import mineplex.core.common.skin.SkinData; @@ -489,7 +490,12 @@ public abstract class WinEffectGadget extends Gadget */ protected String getRank(Player player) { - return Manager.getClientManager().Get(player).getRealOrDisguisedRank().getTag(true, true) + " " + C.Reset; + PermissionGroup group = Manager.getClientManager().Get(player).getRealOrDisguisedPrimaryGroup(); + if (group.getDisplay(false, false, false, false).isEmpty()) + { + return C.Reset + ""; + } + return group.getDisplay(true, true, true, false) + " " + C.Reset; } public int getGameTime() @@ -506,5 +512,4 @@ public abstract class WinEffectGadget extends Gadget { _baseLocation = baseLocation; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java b/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java index 21234daa6..64912f153 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java @@ -2,15 +2,18 @@ package mineplex.core.give; import java.util.HashMap; import java.util.LinkedList; -import java.util.Map.Entry; +import java.util.Map; -import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.structs.ItemContainer; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilInv; @@ -22,11 +25,22 @@ import mineplex.core.itemstack.ItemStackFactory; public class Give extends MiniPlugin { + public static final String GIVE_COMMAND_PERMISSION = "mineplex.core.give.command"; + public static Give Instance; protected Give(JavaPlugin plugin) { super("Give Factory", plugin); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_COMMAND_PERMISSION), true, true); } public static void Initialize(JavaPlugin plugin) @@ -105,7 +119,7 @@ public class Give extends MiniPlugin } //Enchants - HashMap enchs = new HashMap(); + Map enchs = new HashMap<>(); if (enchants.length() > 0) { for (String cur : enchants.split(",")) @@ -161,4 +175,4 @@ public class Give extends MiniPlugin UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.Type, curItem.Data, false)) + " to " + F.elem(giveList.getFirst().getName()) + ".")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/give/commands/GiveCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/give/commands/GiveCommand.java index 78ddb95c0..673fdbfc2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/give/commands/GiveCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/give/commands/GiveCommand.java @@ -3,19 +3,18 @@ package mineplex.core.give.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.give.Give; public class GiveCommand extends CommandBase { - public GiveCommand(Give plugin) - { - super(plugin, Rank.ADMIN, "give", "g", "item", "i"); - } + public GiveCommand(Give plugin) + { + super(plugin, Give.GIVE_COMMAND_PERMISSION, "give", "g", "item", "i"); + } - @Override - public void Execute(final Player caller, final String[] args) - { - Plugin.parseInput(caller, args); - } -} + @Override + public void Execute(final Player caller, final String[] args) + { + Plugin.parseInput(caller, args); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java index 29a908e16..8316d5fe8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java @@ -1,14 +1,18 @@ package mineplex.core.globalpacket; import java.util.Arrays; +import java.util.List; import java.util.UUID; +import java.util.stream.Collectors; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; @@ -27,6 +31,8 @@ import mineplex.serverdata.commands.ServerCommandManager; public class GlobalPacketManager extends MiniPlugin { + public static final String GLOBAL_PACKET_COMMAND_PERMISSION = "mineplex.core.globalpacket.command"; + private CoreClientManager _clientManager; private ServerStatusManager _statusManager; private InventoryManager _inventoryManager; @@ -48,26 +54,36 @@ public class GlobalPacketManager extends MiniPlugin getPluginManager().registerEvents(new GlobalGiveItem(inventoryManager, _rewardManager), getPlugin()); getPluginManager().registerEvents(new GlobalGiveGems(donationManager), getPlugin()); getPluginManager().registerEvents(new GlobalGiveCoins(donationManager, clientManager), getPlugin()); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GLOBAL_PACKET_COMMAND_PERMISSION), true, true); } public void callGlobalCommand(Player caller, String[] args) { String callerName = null; UUID callerUUID = null; - Rank callerRank = null; + List callerRanks = null; if (caller != null) { callerName = caller.getName(); callerUUID = caller.getUniqueId(); - callerRank = _clientManager.Get(caller).GetRank(); + callerRanks = _clientManager.Get(caller).getAdditionalGroups().stream().map(PermissionGroup::getIdentifier).collect(Collectors.toList()); + callerRanks.add(_clientManager.Get(caller).getPrimaryGroup().getIdentifier()); UtilPlayer.message(caller, F.main("Global", "Sending Global Command with Arguments;")); UtilPlayer.message(caller, F.main("Global", F.elem(Arrays.toString(args)))); UtilPlayer.message(caller, F.main("Global", "Please be patient for a response.")); } - GlobalPacketMessage message = new GlobalPacketMessage(callerName, callerUUID, callerRank, _statusManager.getCurrentServerName(), args); + GlobalPacketMessage message = new GlobalPacketMessage(callerName, callerUUID, callerRanks, _statusManager.getCurrentServerName(), args); message.publish(); } @@ -76,4 +92,4 @@ public class GlobalPacketManager extends MiniPlugin { addCommand(new GlobalPacketCommand(this)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/command/GlobalPacketCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/command/GlobalPacketCommand.java index 994262900..533596104 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/command/GlobalPacketCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/command/GlobalPacketCommand.java @@ -3,7 +3,6 @@ package mineplex.core.globalpacket.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.globalpacket.GlobalPacketManager; @@ -12,7 +11,7 @@ public class GlobalPacketCommand extends CommandBase { public GlobalPacketCommand(GlobalPacketManager plugin) { - super(plugin, Rank.JNR_DEV, "global", "globalpacket"); + super(plugin, GlobalPacketManager.GLOBAL_PACKET_COMMAND_PERMISSION, "global", "globalpacket"); } @Override @@ -27,4 +26,4 @@ public class GlobalPacketCommand extends CommandBase Plugin.callGlobalCommand(caller, args); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/event/GlobalPacketEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/event/GlobalPacketEvent.java index ba4c63fe5..9f2b564b0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/event/GlobalPacketEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/event/GlobalPacketEvent.java @@ -1,28 +1,27 @@ package mineplex.core.globalpacket.event; +import java.util.List; import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import mineplex.core.common.Rank; - public class GlobalPacketEvent extends Event { private Player _caller; private String _callerName; private UUID _callerUUID; - private Rank _callerRank; + private List _callerGroups; private String _sourceServer; private String[] _parts; - public GlobalPacketEvent(Player caller, String callerName, UUID callerUUID, Rank callerRank, String sourceServer, String[] parts) + public GlobalPacketEvent(Player caller, String callerName, UUID callerUUID, List callerGroups, String sourceServer, String[] parts) { _caller = caller; _callerName = callerName; _callerUUID = callerUUID; - _callerRank = callerRank; + _callerGroups = callerGroups; _sourceServer = sourceServer; _parts = parts; } @@ -55,9 +54,9 @@ public class GlobalPacketEvent extends Event /** * Get the rank of the player that called this global command */ - public Rank getCallerRank() + public List getCallerGroups() { - return _callerRank; + return _callerGroups; } /** @@ -80,4 +79,4 @@ public class GlobalPacketEvent extends Event private static final HandlerList handlers = new HandlerList(); public static HandlerList getHandlerList() { return handlers; } public HandlerList getHandlers() { return handlers; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveCoins.java b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveCoins.java index 13f42d45d..f32e1ed5b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveCoins.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveCoins.java @@ -5,24 +5,21 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.donation.DonationManager; +import mineplex.core.globalpacket.GlobalPacketManager; import mineplex.core.globalpacket.event.GlobalPacketEvent; -/** - * Created by William (WilliamTiger). - * 17/11/15 - */ public class GlobalGiveCoins implements Listener { - private DonationManager _donationManager; private CoreClientManager _clientManager; @@ -35,8 +32,25 @@ public class GlobalGiveCoins implements Listener @EventHandler public void giveCoins(final GlobalPacketEvent e) { - if (!e.getCallerRank().has(Rank.ADMIN)) + boolean allowed = false; + PermissionManager pm = _clientManager.getPermissionManager(); + for (String id : e.getCallerGroups()) + { + PermissionGroup group = pm.getGroup(id); + if (group != null) + { + if (pm.hasPermission(pm.getGroup(id), GroupPermission.of(GlobalPacketManager.GLOBAL_PACKET_COMMAND_PERMISSION))) + { + allowed = true; + break; + } + } + } + + if (!allowed) + { return; + } if (e.getParts() == null || e.getParts().length < 1) return; @@ -47,7 +61,9 @@ public class GlobalGiveCoins implements Listener if (e.getParts().length != 2) { if (e.getCaller() != null) + { UtilPlayer.message(e.getCaller(), F.main("Global", "/global givecoins ")); + } return; } @@ -61,7 +77,9 @@ public class GlobalGiveCoins implements Listener { // No number if (e.getCaller() != null) + { UtilPlayer.message(e.getCaller(), F.main("Global", "[" + F.elem(amount + "") + "] is not a valid amount.")); + } return; } @@ -79,4 +97,4 @@ public class GlobalGiveCoins implements Listener }); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveGems.java b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveGems.java index 187d55ca1..d1fa9a06e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveGems.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveGems.java @@ -4,24 +4,23 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import mineplex.core.common.Rank; +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.donation.DonationManager; +import mineplex.core.globalpacket.GlobalPacketManager; import mineplex.core.globalpacket.event.GlobalPacketEvent; -/** - * Created by William (WilliamTiger). - * 17/11/15 - */ public class GlobalGiveGems implements Listener { - private DonationManager _donationManager; public GlobalGiveGems(DonationManager donationManager) @@ -32,8 +31,25 @@ public class GlobalGiveGems implements Listener @EventHandler public void giveGems(final GlobalPacketEvent e) { - if (!e.getCallerRank().has(Rank.ADMIN)) + boolean allowed = false; + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + for (String id : e.getCallerGroups()) + { + PermissionGroup group = pm.getGroup(id); + if (group != null) + { + if (pm.hasPermission(pm.getGroup(id), GroupPermission.of(GlobalPacketManager.GLOBAL_PACKET_COMMAND_PERMISSION))) + { + allowed = true; + break; + } + } + } + + if (!allowed) + { return; + } if (e.getParts() == null || e.getParts().length < 1) return; @@ -44,7 +60,9 @@ public class GlobalGiveGems implements Listener if (e.getParts().length != 2) { if (e.getCaller() != null) + { UtilPlayer.message(e.getCaller(), F.main("Global", "/global givegems ")); + } return; } @@ -58,7 +76,9 @@ public class GlobalGiveGems implements Listener { // No number if (e.getCaller() != null) + { UtilPlayer.message(e.getCaller(), F.main("Global", "[" + F.elem(amount + "") + "] is not a valid amount.")); + } return; } @@ -73,4 +93,4 @@ public class GlobalGiveGems implements Listener }); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveItem.java b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveItem.java index 53cd1dde6..876e5005d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveItem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveItem.java @@ -4,27 +4,25 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import mineplex.core.common.Rank; +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.globalpacket.GlobalPacketManager; import mineplex.core.globalpacket.event.GlobalPacketEvent; import mineplex.core.inventory.InventoryManager; import mineplex.core.reward.Reward; -import mineplex.core.reward.RewardData; import mineplex.core.reward.RewardManager; import mineplex.core.reward.RewardType; -/** - * Created by William (WilliamTiger). - * 17/11/15 - */ public class GlobalGiveItem implements Listener { - private InventoryManager _inventoryManager; private RewardManager _rewardManager; @@ -58,8 +56,25 @@ public class GlobalGiveItem implements Listener @EventHandler public void giveItem(final GlobalPacketEvent e) { - if (!e.getCallerRank().has(Rank.ADMIN)) + boolean allowed = false; + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + for (String id : e.getCallerGroups()) + { + PermissionGroup group = pm.getGroup(id); + if (group != null) + { + if (pm.hasPermission(pm.getGroup(id), GroupPermission.of(GlobalPacketManager.GLOBAL_PACKET_COMMAND_PERMISSION))) + { + allowed = true; + break; + } + } + } + + if (!allowed) + { return; + } if (e.getParts() == null || e.getParts().length < 1) return; @@ -70,7 +85,9 @@ public class GlobalGiveItem implements Listener if (e.getParts().length != 3) { if (e.getCaller() != null) + { UtilPlayer.message(e.getCaller(), F.main("Global", "/global giveitem ")); + } return; } @@ -91,7 +108,9 @@ public class GlobalGiveItem implements Listener String list = ""; for (GlobalItem i : GlobalItem.values()) + { list += i.toString() + " "; + } UtilPlayer.message(e.getCaller(), C.cYellow + list); } @@ -110,7 +129,9 @@ public class GlobalGiveItem implements Listener // Not a number if (e.getCaller() != null) + { UtilPlayer.message(e.getCaller(), F.main("Global", "[" + F.elem(e.getParts()[2]) + "] is not a valid number.")); + } return; } @@ -121,14 +142,10 @@ public class GlobalGiveItem implements Listener { final int fAmount = amount; final GlobalItem fItem = item; - _inventoryManager.addItemToInventory(new Callback() + _inventoryManager.addItemToInventory(data -> { - @Override - public void run(Boolean data) - { - UtilPlayer.message(p, F.main("Global", "You received " + F.elem(fAmount + " " + fItem.getInvName() + "(s)") + " from " + F.name(e.getCallerName()) + ".")); - UtilTextMiddle.display(C.cYellow + fAmount + " " + fItem.getInvName() + "(s)", C.cGold + "received from " + e.getCallerName() + "!", p); - } + UtilPlayer.message(p, F.main("Global", "You received " + F.elem(fAmount + " " + fItem.getInvName() + "(s)") + " from " + F.name(e.getCallerName()) + ".")); + UtilTextMiddle.display(C.cYellow + fAmount + " " + fItem.getInvName() + "(s)", C.cGold + "received from " + e.getCallerName() + "!", p); }, p, item.getInvName(), amount); } @@ -139,18 +156,13 @@ public class GlobalGiveItem implements Listener for (final Player p : UtilServer.getPlayers()) { Reward reward = _rewardManager.nextReward(p, null, false, RewardType.GAME_LOOT, true); - reward.giveReward(RewardType.GAME_LOOT, p, new Callback() + reward.giveReward(RewardType.GAME_LOOT, p, data -> { - @Override - public void run(RewardData data) - { - UtilPlayer.message(p, F.main("Global", "You received " + F.elem("Game Loot") + " from " + F.name(e.getCallerName()) + ".")); - UtilPlayer.message(p, F.main("Global", "You won " + F.elem(data.getFriendlyName()) + "!")); - UtilTextMiddle.display(C.cYellow + data.getFriendlyName(), C.cGold + "received from " + e.getCallerName() + "!", p); - } + UtilPlayer.message(p, F.main("Global", "You received " + F.elem("Game Loot") + " from " + F.name(e.getCallerName()) + ".")); + UtilPlayer.message(p, F.main("Global", "You won " + F.elem(data.getFriendlyName()) + "!")); + UtilTextMiddle.display(C.cYellow + data.getFriendlyName(), C.cGold + "received from " + e.getCallerName() + "!", p); }); } } } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/redis/GlobalPacketHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/redis/GlobalPacketHandler.java index c3a141231..4c76811d2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/redis/GlobalPacketHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/redis/GlobalPacketHandler.java @@ -32,8 +32,8 @@ public class GlobalPacketHandler implements CommandCallback } GlobalPacketEvent event = new GlobalPacketEvent(caller, packetMessage.getCallerName(), packetMessage.getCallerUUID(), - packetMessage.getCallerRank(), packetMessage.getSourceServer(), packetMessage.getParts()); + packetMessage.getCallerGroups(), packetMessage.getSourceServer(), packetMessage.getParts()); UtilServer.getServer().getPluginManager().callEvent(event); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/redis/GlobalPacketMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/redis/GlobalPacketMessage.java index 2138942a5..5c9cbd95b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/redis/GlobalPacketMessage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/redis/GlobalPacketMessage.java @@ -1,23 +1,23 @@ package mineplex.core.globalpacket.redis; +import java.util.List; import java.util.UUID; -import mineplex.core.common.Rank; import mineplex.serverdata.commands.ServerCommand; public class GlobalPacketMessage extends ServerCommand { private String _callerName; private UUID _callerUUID; - private Rank _callerRank; + private List _callerGroups; private String _sourceServer; private String[] _parts; - public GlobalPacketMessage(String callerName, UUID callerUUID, Rank callerRank, String sourceServer, String[] parts) + public GlobalPacketMessage(String callerName, UUID callerUUID, List callerGroups, String sourceServer, String[] parts) { _callerName = callerName; _callerUUID = callerUUID; - _callerRank = callerRank; + _callerGroups = callerGroups; _sourceServer = sourceServer; _parts = parts; } @@ -32,9 +32,9 @@ public class GlobalPacketMessage extends ServerCommand return _callerUUID; } - public Rank getCallerRank() + public List getCallerGroups() { - return _callerRank; + return _callerGroups; } public String getSourceServer() @@ -46,5 +46,4 @@ public class GlobalPacketMessage extends ServerCommand { return _parts; } -} - +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java index 86b378193..a92966d58 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java @@ -7,9 +7,18 @@ import java.util.Iterator; import java.util.List; import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; @@ -21,226 +30,223 @@ import mineplex.core.ignore.data.IgnoreRepository; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.plugin.java.JavaPlugin; - public class IgnoreManager extends MiniDbClientPlugin { - private PreferencesManager _preferenceManager; - private IgnoreRepository _repository; - private Portal _portal; + public static final String IGNORE_COMMAND_PERMISSION = "mineplex.core.ignore.command"; + public static final String BYPASS_IGNORE_PERMISSION = "mineplex.core.ignore.bypass"; + + private PreferencesManager _preferenceManager; + private IgnoreRepository _repository; + private Portal _portal; - public IgnoreManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, Portal portal) - { - super("Ignore", plugin, clientManager); + public IgnoreManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, Portal portal) + { + super("Ignore", plugin, clientManager); - _preferenceManager = preferences; - _repository = new IgnoreRepository(plugin); - _portal = portal; - } + _preferenceManager = preferences; + _repository = new IgnoreRepository(plugin); + _portal = portal; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(IGNORE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BYPASS_IGNORE_PERMISSION), true, true); + } - public PreferencesManager getPreferenceManager() - { - return _preferenceManager; - } + public PreferencesManager getPreferenceManager() + { + return _preferenceManager; + } - public Portal getPortal() - { - return _portal; - } + public Portal getPortal() + { + return _portal; + } - public boolean isIgnoring(Player caller, Player target) - { - return isIgnoring(caller, target.getName()); - } + public boolean isIgnoring(Player caller, Player target) + { + return isIgnoring(caller, target.getName()); + } - public boolean isIgnoring(Player caller, String target) - { - IgnoreData data = Get(caller); + public boolean isIgnoring(Player caller, String target) + { + IgnoreData data = Get(caller); - for (String ignored : data.getIgnored()) - { - if (ignored.equalsIgnoreCase(target)) - { - return true; - } - } + for (String ignored : data.getIgnored()) + { + if (ignored.equalsIgnoreCase(target)) + { + return true; + } + } - return false; - } + return false; + } - @Override - public void addCommands() - { - addCommand(new Ignore(this)); - addCommand(new Unignore(this)); - } + @Override + public void addCommands() + { + addCommand(new Ignore(this)); + addCommand(new Unignore(this)); + } - @Override - protected IgnoreData addPlayer(UUID uuid) - { - return new IgnoreData(); - } + @Override + protected IgnoreData addPlayer(UUID uuid) + { + return new IgnoreData(); + } - @EventHandler(priority = EventPriority.LOWEST) - public void onChat(AsyncPlayerChatEvent event) - { - if (ClientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER)) - return; + @EventHandler(priority = EventPriority.LOWEST) + public void onChat(AsyncPlayerChatEvent event) + { + if (ClientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(BYPASS_IGNORE_PERMISSION))) + { + return; + } - Iterator itel = event.getRecipients().iterator(); + Iterator itel = event.getRecipients().iterator(); - while (itel.hasNext()) - { - Player player = itel.next(); + while (itel.hasNext()) + { + Player player = itel.next(); - IgnoreData info = Get(player); + IgnoreData info = Get(player); - for (String ignored : info.getIgnored()) - { - if (ignored.equalsIgnoreCase(event.getPlayer().getName())) - { - itel.remove(); + for (String ignored : info.getIgnored()) + { + if (ignored.equalsIgnoreCase(event.getPlayer().getName())) + { + itel.remove(); - break; - } - } - } - } + break; + } + } + } + } - public void addIgnore(final Player caller, final String name) - { - if (caller.getName().equalsIgnoreCase(name)) - { - caller.sendMessage(F.main(getName(), ChatColor.GRAY + "You cannot ignore yourself")); - return; - } + public void addIgnore(final Player caller, final String name) + { + if (caller.getName().equalsIgnoreCase(name)) + { + caller.sendMessage(F.main(getName(), ChatColor.GRAY + "You cannot ignore yourself")); + return; + } - for (String status : Get(caller).getIgnored()) - { - if (status.equalsIgnoreCase(name)) - { - caller.sendMessage(F.main(getName(), ChatColor.GREEN + name + ChatColor.GRAY + " has already been ignored.")); - return; + for (String status : Get(caller).getIgnored()) + { + if (status.equalsIgnoreCase(name)) + { + caller.sendMessage(F.main(getName(), ChatColor.GREEN + name + ChatColor.GRAY + " has already been ignored.")); + return; + } + } - } - } + IgnoreData ignoreData = Get(caller); - IgnoreData ignoreData = Get(caller); + if (ignoreData != null) + { + ignoreData.getIgnored().add(name); + } - if (ignoreData != null) - { - ignoreData.getIgnored().add(name); - } + Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), () -> + { + _repository.addIgnore(caller, name); - Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - _repository.addIgnore(caller, name); + Bukkit.getServer().getScheduler().runTask(_plugin, () -> + { + caller.sendMessage(F.main(getName(), "Now ignoring " + ChatColor.GREEN + name)); + }); + }); + } - Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable() - { - public void run() - { - caller.sendMessage(F.main(getName(), "Now ignoring " + ChatColor.GREEN + name)); - } - }); - } - }); - } + public void removeIgnore(final Player caller, final String name) + { + IgnoreData ignoreData = Get(caller); - public void removeIgnore(final Player caller, final String name) - { - IgnoreData ignoreData = Get(caller); + if (ignoreData != null) + { + Iterator itel = ignoreData.getIgnored().iterator(); - if (ignoreData != null) - { - Iterator itel = ignoreData.getIgnored().iterator(); + while (itel.hasNext()) + { + String ignored = itel.next(); - while (itel.hasNext()) - { - String ignored = itel.next(); + if (ignored.equalsIgnoreCase(name)) + { + itel.remove(); + break; + } + } + } - if (ignored.equalsIgnoreCase(name)) - { - itel.remove(); - break; - } - } - } + caller.sendMessage(F.main(getName(), "No longer ignoring " + ChatColor.GREEN + name + ChatColor.GRAY + "!")); - caller.sendMessage(F.main(getName(), "No longer ignoring " + ChatColor.GREEN + name + ChatColor.GRAY + "!")); + Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), () -> + { + _repository.removeIgnore(caller.getName(), name); + }); + } - Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - _repository.removeIgnore(caller.getName(), name); - } - }); - } + public void showIgnores(Player caller) + { + List ignoredPlayers = Get(caller).getIgnored(); - public void showIgnores(Player caller) - { - List ignoredPlayers = Get(caller).getIgnored(); + caller.sendMessage(C.cAqua + C.Strike + "=====================[" + ChatColor.RESET + C.cWhite + C.Bold + "Ignoring" + + ChatColor.RESET + C.cAqua + C.Strike + "]======================"); - caller.sendMessage(C.cAqua + C.Strike + "=====================[" + ChatColor.RESET + C.cWhite + C.Bold + "Ignoring" - + ChatColor.RESET + C.cAqua + C.Strike + "]======================"); + List sentLines = new ArrayList<>(); - ArrayList sentLines = new ArrayList(); + for (String ignored : ignoredPlayers) + { - for (String ignored : ignoredPlayers) - { + ChildJsonMessage message = new JsonMessage("").color("white").extra("").color("white"); - ChildJsonMessage message = new JsonMessage("").color("white").extra("").color("white"); + message.add("Ignoring " + ignored).color("gray"); - message.add("Ignoring " + ignored).color("gray"); + message.add(" - ").color("white"); - message.add(" - ").color("white"); + message.add("Unignore").color("red").bold().click("run_command", "/unignore " + ignored) + .hover("show_text", "Stop ignoring " + ignored); - message.add("Unignore").color("red").bold().click("run_command", "/unignore " + ignored) - .hover("show_text", "Stop ignoring " + ignored); + sentLines.add(message); + } - sentLines.add(message); - } + // Send In Order + for (JsonMessage msg : sentLines) + msg.sendToPlayer(caller); - // Send In Order - for (JsonMessage msg : sentLines) - msg.sendToPlayer(caller); + if (sentLines.isEmpty()) + { + caller.sendMessage(" "); + caller.sendMessage("Welcome to your Ignore List!"); + caller.sendMessage(" "); + caller.sendMessage("To ignore people, type " + C.cGreen + "/ignore "); + caller.sendMessage(" "); + caller.sendMessage("Type " + C.cGreen + "/ignore" + ChatColor.RESET + " at any time to view the ignored!"); + caller.sendMessage(" "); + } - if (sentLines.isEmpty()) - { - caller.sendMessage(" "); - caller.sendMessage("Welcome to your Ignore List!"); - caller.sendMessage(" "); - caller.sendMessage("To ignore people, type " + C.cGreen + "/ignore "); - caller.sendMessage(" "); - caller.sendMessage("Type " + C.cGreen + "/ignore" + ChatColor.RESET + " at any time to view the ignored!"); - caller.sendMessage(" "); - } + ChildJsonMessage message = new JsonMessage("").extra(C.cAqua + C.Strike + + "====================================================="); - ChildJsonMessage message = new JsonMessage("").extra(C.cAqua + C.Strike - + "====================================================="); + message.sendToPlayer(caller); + } - message.sendToPlayer(caller); - } + @Override + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException + { + Set(uuid, _repository.loadClientInformation(resultSet)); + } - @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 tA.Name FROM accountIgnore INNER Join accounts AS fA ON fA.uuid = uuidIgnorer INNER JOIN accounts AS tA ON tA.uuid = uuidIgnored LEFT JOIN playerMap ON tA.name = playerName WHERE uuidIgnorer = '" - + uuid + "';"; - } -} + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT tA.Name FROM accountIgnore INNER Join accounts AS fA ON fA.uuid = uuidIgnorer INNER JOIN accounts AS tA ON tA.uuid = uuidIgnored LEFT JOIN playerMap ON tA.name = playerName WHERE uuidIgnorer = '" + + uuid + "';"; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Ignore.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Ignore.java index 91dc5c1d7..2216cecb6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Ignore.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Ignore.java @@ -1,17 +1,16 @@ package mineplex.core.ignore.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.ignore.IgnoreManager; -import org.bukkit.entity.Player; - public class Ignore extends CommandBase { public Ignore(IgnoreManager plugin) { - super(plugin, Rank.ALL, "ignore"); + super(plugin, IgnoreManager.IGNORE_COMMAND_PERMISSION, "ignore"); } @Override @@ -35,4 +34,4 @@ public class Ignore extends CommandBase }); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Unignore.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Unignore.java index 723a58ac3..84463ab11 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Unignore.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Unignore.java @@ -1,25 +1,26 @@ package mineplex.core.ignore.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.common.util.F; import mineplex.core.ignore.IgnoreManager; -import org.bukkit.entity.Player; - public class Unignore extends CommandBase { public Unignore(IgnoreManager plugin) { - super(plugin, Rank.ALL, "unignore"); + super(plugin, IgnoreManager.IGNORE_COMMAND_PERMISSION, "unignore"); } @Override public void Execute(final Player caller, final String[] args) { if (args == null) + { caller.sendMessage(F.main(Plugin.getName(), "You need to include a player's name.")); + } else { _commandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback() @@ -34,4 +35,4 @@ public class Unignore extends CommandBase }); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreData.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreData.java index 48f3e055d..150e6f21d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreData.java @@ -1,14 +1,14 @@ package mineplex.core.ignore.data; import java.util.ArrayList; +import java.util.List; public class IgnoreData { - private ArrayList _ignored = new ArrayList(); + private List _ignored = new ArrayList<>(); - public ArrayList getIgnored() - { - return _ignored; - } - -} + public List getIgnored() + { + return _ignored; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java index d69fa55b1..f02bd6a2e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/data/IgnoreRepository.java @@ -3,14 +3,13 @@ package mineplex.core.ignore.data; import java.sql.ResultSet; import java.sql.SQLException; -import mineplex.core.database.MinecraftRepository; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnVarChar; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - public class IgnoreRepository extends RepositoryBase { private static String ADD_IGNORE_RECORD = "INSERT INTO accountIgnore (uuidIgnorer, uuidIgnored) SELECT fA.uuid AS uuidIgnorer, tA.uuid AS uuidIgnored FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;"; @@ -48,4 +47,4 @@ public class IgnoreRepository extends RepositoryBase return ignoreData; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java index 6242b48ba..b350d81c7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java @@ -1,8 +1,21 @@ package mineplex.core.incognito; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.UUID; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -15,20 +28,14 @@ import mineplex.core.packethandler.PacketHandler; 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.event.EventPriority; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerKickEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.UUID; public class IncognitoManager extends MiniDbClientPlugin { + public static final String USE_INCOGNITO_PERMISSION = "mineplex.core.incognito.use"; + public static final String BYPASS_INCOGNITO_PERMISSION = "mineplex.core.incognito.bypass"; + public static final String EXTRA_INCOGNITO_PERMISSION = "mineplex.core.incognito.extra"; + public static final String INCOGNITO_COMMAND_PERMISSION = "mineplex.core.incognito.command"; + private CoreClientManager _clientManager; private IncognitoRepository _repository; private PreferencesManager _preferencesManager; @@ -39,6 +46,41 @@ public class IncognitoManager extends MiniDbClientPlugin _repository = new IncognitoRepository(this); _clientManager = clientManager; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(USE_INCOGNITO_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BYPASS_INCOGNITO_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(EXTRA_INCOGNITO_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(INCOGNITO_COMMAND_PERMISSION), true, true); + } + + private boolean canSeeThroughIncognito(Player viewer, Player target) + { + boolean bypass = _clientManager.getPermissionManager().hasPermission(viewer, GroupPermission.of(BYPASS_INCOGNITO_PERMISSION)); + boolean extra1 = _clientManager.getPermissionManager().hasPermission(viewer, GroupPermission.of(EXTRA_INCOGNITO_PERMISSION)); + boolean extra2 = _clientManager.getPermissionManager().hasPermission(target, GroupPermission.of(EXTRA_INCOGNITO_PERMISSION)); + + if (bypass) + { + if (extra2) + { + return extra1; + } + else + { + return true; + } + } + else + { + return false; + } } public void addCommands() @@ -80,7 +122,7 @@ public class IncognitoManager extends MiniDbClientPlugin { Player player = event.getPlayer(); - if (Get(event.getPlayer()).Status && !_clientManager.hasRank(event.getPlayer(), Rank.HELPER)) + if (Get(event.getPlayer()).Status && !_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(USE_INCOGNITO_PERMISSION))) { Get(event.getPlayer()).Status = false; runAsync(() -> _repository.setStatus(_clientManager.getAccountId(player), false)); @@ -102,7 +144,7 @@ public class IncognitoManager extends MiniDbClientPlugin for (Player other : UtilServer.getPlayers()) { - if (customEvent != null && !customEvent.isCancelled() && !_clientManager.hasRank(other, _clientManager.Get(player).GetRank())) + if (customEvent != null && !customEvent.isCancelled() && !canSeeThroughIncognito(other, player)) { other.hidePlayer(player); } @@ -111,7 +153,7 @@ public class IncognitoManager extends MiniDbClientPlugin { IncognitoHidePlayerEvent customEvent2 = UtilServer.CallEvent(new IncognitoHidePlayerEvent(other)); - if (!customEvent2.isCancelled() && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank())) + if (!customEvent2.isCancelled() && !canSeeThroughIncognito(player, other)) { player.hidePlayer(other); } @@ -135,7 +177,7 @@ public class IncognitoManager extends MiniDbClientPlugin { IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(player)); - if (!customEvent.isCancelled() && !_clientManager.hasRank(other, _clientManager.Get(player).GetRank())) + if (!customEvent.isCancelled() && !canSeeThroughIncognito(other, player)) { other.hidePlayer(player); } @@ -151,7 +193,7 @@ public class IncognitoManager extends MiniDbClientPlugin { IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(other)); - if (!customEvent.isCancelled() && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank())) + if (!customEvent.isCancelled() && !canSeeThroughIncognito(player, other)) { player.hidePlayer(other); } @@ -188,7 +230,6 @@ public class IncognitoManager extends MiniDbClientPlugin { UtilPlayer.message(player, " "); UtilPlayer.message(player, C.cGoldB + "You are currently incognito."); - UtilPlayer.message(player, C.cYellow + "This means you are invisible to all except for those who are " + _clientManager.Get(player).GetRank().getTag(true, false) + C.mBody + "+"); UtilPlayer.message(player, " "); } 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 71f0406c3..726550ead 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java @@ -1,36 +1,36 @@ package mineplex.core.incognito.commands; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.incognito.IncognitoManager; import mineplex.core.preferences.Preference; -import org.bukkit.entity.Player; public class IncognitoToggleCommand extends CommandBase { + public IncognitoToggleCommand(IncognitoManager plugin) + { + super(plugin, IncognitoManager.INCOGNITO_COMMAND_PERMISSION, "incognito", "vanish"); + } - public IncognitoToggleCommand(IncognitoManager plugin) - { - super(plugin, Rank.HELPER, "incognito", "vanish"); - } + @Override + public void Execute(Player caller, String[] args) + { + 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; + } - @Override - public void Execute(Player caller, String[] args) - { - 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; - } - - if (Plugin.toggle(caller)) - { - UtilPlayer.message(caller, F.main("Incognito", "You are now incognito. Your status will only change when you run " + F.elem("/" + _aliasUsed) + " again.")); - } else - { - UtilPlayer.message(caller, F.main("Incognito", "You are no longer incognito. Your status will only change when you run " + F.elem("/" + _aliasUsed) + " again.")); - } - } -} + if (Plugin.toggle(caller)) + { + UtilPlayer.message(caller, F.main("Incognito", "You are now incognito. Your status will only change when you run " + F.elem("/" + _aliasUsed) + " again.")); + } + else + { + UtilPlayer.message(caller, F.main("Incognito", "You are no longer incognito. Your status will only change when you run " + F.elem("/" + _aliasUsed) + " again.")); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoHidePlayerEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoHidePlayerEvent.java index 54dabeebc..22da26671 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoHidePlayerEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoHidePlayerEvent.java @@ -43,5 +43,4 @@ public class IncognitoHidePlayerEvent extends Event { return handlers; } - } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoStatusChangeEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoStatusChangeEvent.java index 79e3291ee..1a8d49a89 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoStatusChangeEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/events/IncognitoStatusChangeEvent.java @@ -60,5 +60,4 @@ public class IncognitoStatusChangeEvent extends Event { return _show; } - } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/repository/IncognitoClient.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/repository/IncognitoClient.java index 75a1aea5f..53f491e60 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/repository/IncognitoClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/repository/IncognitoClient.java @@ -4,4 +4,4 @@ public class IncognitoClient { public boolean Status; public boolean Hidden; -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/repository/IncognitoRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/repository/IncognitoRepository.java index adebcf4cf..ca68651d8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/repository/IncognitoRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/repository/IncognitoRepository.java @@ -1,6 +1,5 @@ package mineplex.core.incognito.repository; -import mineplex.core.database.MinecraftRepository; import mineplex.core.incognito.IncognitoManager; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; @@ -27,4 +26,4 @@ public class IncognitoRepository extends RepositoryBase { executeUpdate(CREATE_TABLE); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index 88342d0c4..f0a51f0c9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -1,15 +1,11 @@ package mineplex.core.inventory; -import mineplex.cache.player.PlayerCache; -import mineplex.core.MiniDbClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.inventory.command.GiveItemCommand; -import mineplex.core.inventory.data.InventoryRepository; -import mineplex.core.inventory.data.Item; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import java.util.UUID; + import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.HumanEntity; @@ -25,22 +21,31 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import mineplex.cache.player.PlayerCache; +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.inventory.command.GiveItemCommand; +import mineplex.core.inventory.data.InventoryRepository; +import mineplex.core.inventory.data.Item; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class InventoryManager extends MiniDbClientPlugin { + public static final String GIVE_ITEM_COMMAND_PERMISSION = "mineplex.core.inventory.giveitem"; + private static Object _inventoryLock = new Object(); private InventoryRepository _repository; - private NautHashMap _items = new NautHashMap(); - private NautHashMap _itemIdNameMap = new NautHashMap(); + private NautHashMap _items = new NautHashMap<>(); + private NautHashMap _itemIdNameMap = new NautHashMap<>(); - private NautHashMap> _inventoryQueue = new NautHashMap>(); + private NautHashMap> _inventoryQueue = new NautHashMap<>(); public InventoryManager(JavaPlugin plugin, CoreClientManager clientManager) { @@ -48,13 +53,19 @@ public class InventoryManager extends MiniDbClientPlugin _repository = new InventoryRepository(plugin); - Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(getPlugin(), new Runnable() + Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(getPlugin(), () -> { - public void run() - { - updateItems(); - } + updateItems(); }, 20L); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_ITEM_COMMAND_PERMISSION), true, true); } private void updateItems() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java index b5f03fe3e..4e9365946 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java @@ -5,8 +5,6 @@ import java.util.UUID; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -17,7 +15,7 @@ public class GiveItemCommand extends CommandBase { public GiveItemCommand(InventoryManager plugin) { - super(plugin, Rank.ADMIN, "giveitem"); + super(plugin, InventoryManager.GIVE_ITEM_COMMAND_PERMISSION, "giveitem"); } @Override @@ -65,34 +63,27 @@ public class GiveItemCommand extends CommandBase } else { - Plugin.runAsync(new Runnable() + Plugin.runAsync(() -> { - @Override - public void run() - { - UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName); + UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName); - if (uuid != null) + if (uuid != null) + { + Plugin.addItemToInventoryForOffline(success -> { - Plugin.addItemToInventoryForOffline(new Callback() + if (success.booleanValue()) { - public void run (Boolean success) - { - if (success) - { - UtilPlayer.message(caller, F.main("Item", "You gave " + F.elem(amount + " " + itemName) + " to offline player " + F.name(playerName))); - } - else - { - UtilPlayer.message(caller, F.main("Item", "An error occured while trying to give item to " + F.name(playerName) + "!")); - } - } - }, uuid, item.Name, amount); - } - else - { - UtilPlayer.message(caller, F.main("Item", "Player " + F.name(playerName) + " does not exist!")); - } + UtilPlayer.message(caller, F.main("Item", "You gave " + F.elem(amount + " " + itemName) + " to offline player " + F.name(playerName))); + } + else + { + UtilPlayer.message(caller, F.main("Item", "An error occured while trying to give item to " + F.name(playerName) + "!")); + } + }, uuid, item.Name, amount); + } + else + { + UtilPlayer.message(caller, F.main("Item", "Player " + F.name(playerName) + " does not exist!")); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java index e2849a5d0..3ddc463e9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java @@ -12,8 +12,10 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.Managers; import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.hologram.HologramManager; @@ -21,6 +23,8 @@ import mineplex.core.stats.StatsManager; public class LeaderboardManager extends MiniPlugin { + public static final String CYCLE_LEADERBOARD_COMMAND_PERMISSION = "mineplex.core.leaderboard.cycle"; + private final Map _leaderboards = new HashMap<>(); private final long REFRESH_RATE; private final LeaderboardRepository _repo; @@ -32,7 +36,7 @@ public class LeaderboardManager extends MiniPlugin _repo = new LeaderboardRepository(plugin); - addCommand(new CommandBase(this, Rank.DEVELOPER, "cycleleaderboard") + addCommand(new CommandBase(this, CYCLE_LEADERBOARD_COMMAND_PERMISSION, "cycleleaderboard") { @Override public void Execute(Player caller, String[] args) @@ -67,6 +71,15 @@ public class LeaderboardManager extends MiniPlugin } } }, 0, 20 * 2); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(CYCLE_LEADERBOARD_COMMAND_PERMISSION), true, true); } private void refreshBoards() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index cbb4950e9..f52668514 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -1,9 +1,23 @@ package mineplex.core.message; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.chat.Chat; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; @@ -33,21 +47,19 @@ import mineplex.core.punish.Punishment; import mineplex.core.punish.PunishmentSentence; import mineplex.serverdata.commands.AnnouncementCommand; import mineplex.serverdata.commands.ServerCommandManager; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; public class MessageManager extends MiniClientPlugin { + public static final String SEE_ADMIN_PERMISSION = "mineplex.core.message.seeadmin"; + public static final String BYPASS_INCOGNITO_PERMISSION = "mineplex.core.message.bypassincognito"; + public static final String BYPASS_SPAM_PERMISSION = "mineplex.core.message.bypassspam"; + public static final String ADMIN_COMMAND_PERMISSION = "mineplex.core.message.admincommand"; + public static final String ANNOUNCE_COMMAND_PERMISSION = "mineplex.core.message.announce"; + public static final String MESSAGE_ADMIN_COMMAND_PERMISSION = "mineplex.core.message.messageadmin"; + public static final String MESSAGE_COMMAND_PERMISSION = "mineplex.core.message.message"; + public static final String RESEND_ADMIN_COMMAND_PERMISSION = "mineplex.core.message.resendadmin"; + public static final String RESEND_COMMAND_PERMISSION = "mineplex.core.message.resend"; + private CoreClientManager _clientManager; private FriendManager _friendsManager; private IgnoreManager _ignoreManager; @@ -76,14 +88,9 @@ public class MessageManager extends MiniClientPlugin ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class, command -> { - Rank rank; - try + PermissionGroup group = _clientManager.getPermissionManager().getGroup(command.getRank()); + if (group == null) { - rank = Rank.valueOf(command.getRank()); - } - catch (Exception e) - { - e.printStackTrace(); return; } @@ -91,10 +98,12 @@ public class MessageManager extends MiniClientPlugin for (Player player : Bukkit.getOnlinePlayers()) { - if (_clientManager.hasRank(player, rank)) + if (_clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), group)) { if (command.getDisplayTitle()) + { UtilTextMiddle.display(C.cYellow + "Announcement", message, 10, 120, 10, player); + } UtilPlayer.message(player, F.main("Announcement", C.cAqua + message)); } @@ -103,6 +112,23 @@ public class MessageManager extends MiniClientPlugin ServerCommandManager.getInstance().registerCommandType("RedisMessage", RedisMessage.class, this::receiveMessage); ServerCommandManager.getInstance().registerCommandType("RedisMessageCallback", RedisMessageCallback.class, this::receiveMessageCallback); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BYPASS_INCOGNITO_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BYPASS_SPAM_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SEE_ADMIN_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(ADMIN_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(ANNOUNCE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(MESSAGE_ADMIN_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(MESSAGE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(RESEND_ADMIN_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(RESEND_COMMAND_PERMISSION), true, true); } public void addCommands() @@ -222,7 +248,7 @@ public class MessageManager extends MiniClientPlugin // My attempt at trying to mitigate some of the spam bots - Phinary // Triggers if they are whispering a new player - if (!GetClientManager().Get(from).GetRank().has(Rank.HELPER) && Get(from).LastTo != null + if (!GetClientManager().getPermissionManager().hasPermission(from, GroupPermission.of(BYPASS_SPAM_PERMISSION)) && Get(from).LastTo != null && !Get(from).LastTo.equalsIgnoreCase(to.getName())) { long delta = System.currentTimeMillis() - Get(from).LastToTime; @@ -248,7 +274,7 @@ public class MessageManager extends MiniClientPlugin Get(from).LastToTime = System.currentTimeMillis(); // Chiss or defek7 - if (GetClientManager().Get(to).getRealOrDisguisedRank() == Rank.DEVELOPER) + if (GetClientManager().Get(to).getRealOrDisguisedPrimaryGroup().getIdentifier().equals("dev")) { UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development."); UtilPlayer.message(from, C.cPurple + "Please be patient if they do not reply instantly."); @@ -268,7 +294,7 @@ public class MessageManager extends MiniClientPlugin public void DoMessageAdmin(Player from, Player to, String message) { // Inform - UtilPlayer.message(from, C.cPurple + "-> " + F.rank(_clientManager.Get(to).getRealOrDisguisedRank()) + " " + to.getName() + " " + UtilPlayer.message(from, C.cPurple + "-> " + _clientManager.Get(to).getRealOrDisguisedPrimaryGroup().getDisplay(true, false, false, true) + " " + to.getName() + " " + C.cPurple + message); // Inform Admins @@ -276,10 +302,10 @@ public class MessageManager extends MiniClientPlugin { if (!to.equals(staff) && !from.equals(staff)) { - if (_clientManager.Get(staff).GetRank().has(Rank.HELPER)) + if (_clientManager.getPermissionManager().hasPermission(staff, GroupPermission.of(SEE_ADMIN_PERMISSION))) { - UtilPlayer.message(staff, F.rank(_clientManager.Get(from).getRealOrDisguisedRank()) + " " + from.getName() + C.cPurple - + " -> " + F.rank(_clientManager.Get(to).getRealOrDisguisedRank()) + " " + to.getName() + " " + C.cPurple + message); + UtilPlayer.message(staff, _clientManager.Get(from).getRealOrDisguisedPrimaryGroup().getDisplay(true, false, false, true) + " " + from.getName() + C.cPurple + + " -> " + _clientManager.Get(to).getRealOrDisguisedPrimaryGroup().getDisplay(true, false, false, true) + " " + to.getName() + " " + C.cPurple + message); } } } @@ -288,7 +314,7 @@ public class MessageManager extends MiniClientPlugin Get(from).LastAdminTo = to.getName(); // Send - UtilPlayer.message(to, C.cPurple + "<- " + F.rank(_clientManager.Get(from).getRealOrDisguisedRank()) + " " + from.getName() + " " + UtilPlayer.message(to, C.cPurple + "<- " + _clientManager.Get(from).getRealOrDisguisedPrimaryGroup().getDisplay(true, false, false, true) + " " + from.getName() + " " + C.cPurple + message); // Sound @@ -387,7 +413,7 @@ public class MessageManager extends MiniClientPlugin to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f); - String toRank = F.rank(_clientManager.Get(to).getRealOrDisguisedRank()); + String toRank = _clientManager.Get(to).getRealOrDisguisedPrimaryGroup().getDisplay(true, false, false, true); // Message the sender RedisMessageCallback message = new RedisMessageCallback(globalMessage, true, to.getName(), @@ -399,7 +425,7 @@ public class MessageManager extends MiniClientPlugin { if (!to.equals(staff)) { - if (_clientManager.Get(staff).GetRank().has(Rank.HELPER)) + if (_clientManager.getPermissionManager().hasPermission(staff, GroupPermission.of(SEE_ADMIN_PERMISSION))) { UtilPlayer.message(staff, @@ -470,14 +496,14 @@ public class MessageManager extends MiniClientPlugin if (message.isStaffMessage() && message.getLastReplied() != null) { - String recevierRank = F.rank(_clientManager.Get(target).getRealOrDisguisedRank()); + String recevierRank = _clientManager.Get(target).getRealOrDisguisedPrimaryGroup().getDisplay(true, false, false, true); // Inform Admins for (Player staff : UtilServer.getPlayers()) { if (!target.equals(staff)) { - if (_clientManager.Get(staff).GetRank().has(Rank.HELPER)) + if (_clientManager.getPermissionManager().hasPermission(staff, GroupPermission.of(SEE_ADMIN_PERMISSION))) { UtilPlayer.message(staff, @@ -519,20 +545,14 @@ public class MessageManager extends MiniClientPlugin final FriendStatus friendInfo = friend; - runAsync(new Runnable() + runAsync(() -> { - @Override - public void run() - { - final String newMessage = _chat.getFilteredMessage(sender, message); - - runSync(() -> sendMessage(sender, target, newMessage, adminMessage, isReply, friendInfo)); - } + final String newMessage = _chat.getFilteredMessage(sender, message); + runSync(() -> sendMessage(sender, target, newMessage, adminMessage, isReply, friendInfo)); }); } - private void sendMessage(final Player sender, String target, String message, final boolean adminMessage, boolean isReply, - FriendStatus friend) + private void sendMessage(final Player sender, String target, String message, final boolean adminMessage, boolean isReply, FriendStatus friend) { // We now have the friend object, if its not null. We are sending the message to that player. @@ -554,7 +574,7 @@ public class MessageManager extends MiniClientPlugin // If this is a message inside the server if (to != null) { - if (_incognitoManager.Get(to).Status && !_clientManager.Get(sender.getUniqueId()).GetRank().has(Rank.HELPER)) + if (_incognitoManager.Get(to).Status && !_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(BYPASS_INCOGNITO_PERMISSION))) { UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "].")); return; @@ -579,63 +599,55 @@ public class MessageManager extends MiniClientPlugin // If this is a admin message, or the sender isn't muted/ignoring the target if (adminMessage || canSenderMessageThem(sender, playerTarget)) { - runAsync(new Runnable() + runAsync(() -> + { + // TODO Newgarbo wrote this stuff inefficiently and for sake of time and thousands of players i'm going to just comment this out + /* + if (IncognitoManager.Instance.getRepository().GetStatus(playerTarget)) { - @Override - public void run() - { - // TODO Newgarbo wrote this stuff inefficiently and for sake of time and thousands of players i'm going to just comment this out - /* - if (IncognitoManager.Instance.getRepository().GetStatus(playerTarget)) - { - UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "].")); - return; - } - */ - - runSync(new Runnable() - { - public void run() - { - // Construct the command to send to redis - RedisMessage globalMessage = new RedisMessage(_serverName, - sender.getName(), - adminMessage ? null : friend.ServerName, - playerTarget, - message, - // Include the sender's rank if this is a admin message. So we can format the receivers chat. - adminMessage ? F.rank(_clientManager.Get(sender).getRealOrDisguisedRank()) : null); - - final UUID uuid = globalMessage.getUUID(); - - // A backup for the rare case where the message fails to deliver. Server doesn't respond - BukkitRunnable runnable = new BukkitRunnable() - { - public void run() - { - _messageTimeouts.remove(uuid); - - // Inform the player that the message failed to deliver - UtilPlayer.message( - sender, - F.main((adminMessage ? "Admin " : "") + "Message", C.mBody + " Failed to send message to [" - + C.mElem + playerTarget + C.mBody + "].")); - } - }; - - // This will activate in 2 seconds - runnable.runTaskLater(getPlugin(), 40); - - // The key is the UUID its trading between servers - _messageTimeouts.put(uuid, runnable); - - // Time to send the message! - globalMessage.publish(); - } - }); - } + UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "].")); + return; } - ); + */ + + runSync(() -> + { + // Construct the command to send to redis + RedisMessage globalMessage = new RedisMessage(_serverName, + sender.getName(), + adminMessage ? null : friend.ServerName, + playerTarget, + message, + // Include the sender's rank if this is a admin message. So we can format the receivers chat. + adminMessage ? _clientManager.Get(sender).getRealOrDisguisedPrimaryGroup().getDisplay(true, false, false, true) : null); + + final UUID uuid = globalMessage.getUUID(); + + // A backup for the rare case where the message fails to deliver. Server doesn't respond + BukkitRunnable runnable = new BukkitRunnable() + { + public void run() + { + _messageTimeouts.remove(uuid); + + // Inform the player that the message failed to deliver + UtilPlayer.message( + sender, + F.main((adminMessage ? "Admin " : "") + "Message", C.mBody + " Failed to send message to [" + + C.mElem + playerTarget + C.mBody + "].")); + } + }; + + // This will activate in 2 seconds + runnable.runTaskLater(getPlugin(), 40); + + // The key is the UUID its trading between servers + _messageTimeouts.put(uuid, runnable); + + // Time to send the message! + globalMessage.publish(); + }); + }); } } } @@ -647,6 +659,6 @@ public class MessageManager extends MiniClientPlugin public PreferencesManager getPreferences() { - return this._preferences; + return _preferences; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java index 8630d80ad..0efd84f5e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java @@ -1,21 +1,22 @@ package mineplex.core.message.commands; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.message.MessageManager; import mineplex.core.recharge.Recharge; -import org.bukkit.Sound; -import org.bukkit.entity.Player; public class AdminCommand extends CommandBase { public AdminCommand(MessageManager plugin) { - super(plugin, Rank.ALL, "a","admin"); + super(plugin, MessageManager.ADMIN_COMMAND_PERMISSION, "a","admin"); } @Override @@ -42,21 +43,16 @@ public class AdminCommand extends CommandBase String message = F.combine(args, 0, null, false); //Inform - UtilPlayer.message(caller, F.rank(Plugin.GetClientManager().Get(caller).getRealOrDisguisedRank()) + " " + caller.getName() + " " + C.cPurple + message); + UtilPlayer.message(caller, Plugin.GetClientManager().Get(caller).getRealOrDisguisedPrimaryGroup().getDisplay(true, false, false, true) + " " + caller.getName() + " " + C.cPurple + message); //Send for (Player to : UtilServer.getPlayers()) { - if (Plugin.GetClientManager().Get(to).GetRank().has(Rank.HELPER)) + if (Plugin.GetClientManager().getPermissionManager().hasPermission(to, GroupPermission.of(MessageManager.SEE_ADMIN_PERMISSION))) { - if (!to.equals(caller)) - UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).getRealOrDisguisedRank()) + " " + caller.getName() + " " + C.cPurple + message); - - if(Plugin.GetClientManager().Get(to).GetRank().has(Rank.JNR_DEV)) { - if(Plugin.GetClientManager().Get(to).isDisguised() || !caller.canSee(to)) - continue; + UtilPlayer.message(to, Plugin.GetClientManager().Get(caller).getRealOrDisguisedPrimaryGroup().getDisplay(true, false, false, true) + " " + caller.getName() + " " + C.cPurple + message); } //Sound @@ -64,7 +60,7 @@ public class AdminCommand extends CommandBase } } - if (!Plugin.GetClientManager().hasRank(caller, Rank.HELPER) && Recharge.Instance.use(caller, "AdminCommand.InformMsg", 60 * 1000, false, false)) + if (!Plugin.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(MessageManager.SEE_ADMIN_PERMISSION)) && Recharge.Instance.use(caller, "AdminCommand.InformMsg", 60 * 1000, false, false)) { UtilPlayer.message(caller, F.main(Plugin.getName(), "If there are any staff currently online, you will receive a reply shortly.")); } @@ -73,4 +69,4 @@ public class AdminCommand extends CommandBase //Logger().logChat("Staff Chat", from, staff, message); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java index d233056d0..64dd203f7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java @@ -3,8 +3,8 @@ package mineplex.core.message.commands; import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.message.MessageManager; @@ -14,7 +14,7 @@ public class AnnounceCommand extends CommandBase { public AnnounceCommand(MessageManager plugin) { - super(plugin, Rank.ADMIN, "announce"); + super(plugin, MessageManager.ANNOUNCE_COMMAND_PERMISSION, "announce"); } @Override @@ -26,19 +26,14 @@ public class AnnounceCommand extends CommandBase } else { - Rank rank = Rank.ALL; - - try - { - rank = Rank.valueOf(args[0]); - } - catch (IllegalArgumentException ex) + PermissionGroup group = Plugin.GetClientManager().getPermissionManager().getGroup(args[0]); + if (group == null) { UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Invalid rank!")); return; } - new AnnouncementCommand(true, rank.toString(), F.combine(args, 1, null, false)).publish(); + new AnnouncementCommand(true, group.getIdentifier(), F.combine(args, 1, null, false)).publish(); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java index 192cf3c0d..896fdc370 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java @@ -2,11 +2,11 @@ package mineplex.core.message.commands; import java.util.List; +import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.message.MessageManager; @@ -16,7 +16,7 @@ public class MessageAdminCommand extends CommandBase { public MessageAdminCommand(MessageManager plugin) { - super(plugin, Rank.HELPER, "ma"); + super(plugin, MessageManager.MESSAGE_ADMIN_COMMAND_PERMISSION, "ma"); } @Override @@ -24,7 +24,7 @@ public class MessageAdminCommand extends CommandBase { if (args == null || args.length == 0) { - UtilPlayer.message(caller, F.help(Plugin.getName(), "/ma [message]", GetRequiredRank())); + UtilPlayer.message(caller, F.help(Plugin.getName(), "/ma [message]", ChatColor.GOLD)); } else { @@ -55,4 +55,4 @@ public class MessageAdminCommand extends CommandBase { return tabCompletePlayerNames(sender, args); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java index 0dd7724e7..bbcef7911 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java @@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.message.MessageManager; @@ -16,7 +15,7 @@ public class MessageCommand extends CommandBase { public MessageCommand(MessageManager plugin) { - super(plugin, Rank.ALL, "m", "msg", "message", "tell", "t", "w", "whisper", "MSG"); + super(plugin, MessageManager.MESSAGE_COMMAND_PERMISSION, "m", "msg", "message", "tell", "t", "w", "whisper", "MSG"); } @Override @@ -56,4 +55,4 @@ public class MessageCommand extends CommandBase { return tabCompletePlayerNames(sender, args); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendAdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendAdminCommand.java index 492f8d7bb..22a8c3a8e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendAdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendAdminCommand.java @@ -1,9 +1,9 @@ package mineplex.core.message.commands; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.message.MessageManager; @@ -13,7 +13,7 @@ public class ResendAdminCommand extends CommandBase { public ResendAdminCommand(MessageManager plugin) { - super(plugin, Rank.HELPER, "ra"); + super(plugin, MessageManager.RESEND_ADMIN_COMMAND_PERMISSION, "ra"); } @Override @@ -21,7 +21,7 @@ public class ResendAdminCommand extends CommandBase { if (args == null || args.length == 0) { - UtilPlayer.message(caller, F.help(Plugin.getName(), "/ra [message]", GetRequiredRank())); + UtilPlayer.message(caller, F.help(Plugin.getName(), "/ra [message]", ChatColor.GOLD)); } else { @@ -56,4 +56,4 @@ public class ResendAdminCommand extends CommandBase Plugin.sendMessage(caller, lastTo, message, true, true); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendCommand.java index 65baece24..49062c0bb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendCommand.java @@ -3,7 +3,6 @@ package mineplex.core.message.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.message.MessageManager; @@ -12,7 +11,7 @@ public class ResendCommand extends CommandBase { public ResendCommand(MessageManager plugin) { - super(plugin, Rank.ALL, "r"); + super(plugin, MessageManager.RESEND_COMMAND_PERMISSION, "r"); } @Override @@ -47,4 +46,4 @@ public class ResendCommand extends CommandBase Plugin.sendMessage(caller, lastTo, message, true, false); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java index 4a89c9d7d..1c4e0a281 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java @@ -2,8 +2,6 @@ package mineplex.core.monitor; import java.util.HashSet; -import net.minecraft.server.v1_8_R3.MinecraftServer; - import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -13,21 +11,26 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import net.minecraft.server.v1_8_R3.MinecraftServer; public class LagMeter extends MiniPlugin { + public static final String VERSIONS_COMMAND_PERMISSION = "mineplex.core.monitor.versions"; + public static final String LAG_COMMAND_PERMISSION = "mineplex.core.monitor.lag"; + public static final String MONITOR_COMMAND_PERMISSION = "mineplex.core.monitor.monitor"; + private CoreClientManager _clientManager; private long _lastRun = -1; private int _count; private double _ticksPerSecond; private double _ticksPerSecondAverage; private long _lastAverage; - private long _start; private HashSet _monitoring = new HashSet(); @@ -39,7 +42,16 @@ public class LagMeter extends MiniPlugin _lastRun = System.currentTimeMillis(); _lastAverage = System.currentTimeMillis(); - _start = System.currentTimeMillis(); + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(VERSIONS_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(LAG_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(MONITOR_COMMAND_PERMISSION), true, true); } @Override @@ -51,23 +63,26 @@ public class LagMeter extends MiniPlugin @EventHandler public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) { - if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.MODERATOR)) - { - if (event.getMessage().trim().equalsIgnoreCase("/lag")) + if (event.getMessage().trim().equalsIgnoreCase("/lag") && _clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(LAG_COMMAND_PERMISSION))) + { + sendUpdate(event.getPlayer()); + event.setCancelled(true); + return; + } + if (event.getMessage().trim().equalsIgnoreCase("/monitor") && _clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(MONITOR_COMMAND_PERMISSION))) + { + if (_monitoring.contains(event.getPlayer())) { - sendUpdate(event.getPlayer()); - event.setCancelled(true); + _monitoring.remove(event.getPlayer()); } - else if (event.getMessage().trim().equalsIgnoreCase("/monitor")) + else { - if (_monitoring.contains(event.getPlayer())) - _monitoring.remove(event.getPlayer()); - else - _monitoring.add(event.getPlayer()); - - event.setCancelled(true); + _monitoring.add(event.getPlayer()); } - } + + event.setCancelled(true); + return; + } } @EventHandler @@ -149,4 +164,4 @@ public class LagMeter extends MiniPlugin player.sendMessage(F.main(getName(), ChatColor.GRAY + "Free-------" + ChatColor.YELLOW + (Runtime.getRuntime().freeMemory() / 1048576) + "MB")); player.sendMessage(F.main(getName(), ChatColor.GRAY + "Max--------" + ChatColor.YELLOW + (Runtime.getRuntime().maxMemory() / 1048576)) + "MB"); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java index 43454f57c..4bfbe976d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java @@ -7,16 +7,13 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import javax.print.attribute.IntegerSyntax; - -import com.mineplex.ProtocolVersion; - import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; +import com.mineplex.ProtocolVersion; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -32,7 +29,7 @@ public class VersionsCommand extends CommandBase public VersionsCommand(LagMeter plugin) { - super(plugin, Rank.DEVELOPER, "versions", "getver"); + super(plugin, LagMeter.VERSIONS_COMMAND_PERMISSION, "versions", "getver"); } private void ensureVersions() @@ -85,7 +82,8 @@ public class VersionsCommand extends CommandBase F.main("Version", C.cYellow + pretty + C.cGray + ": " + C.cGreen + entry.getValue() + C.cGray + " players")); } - } else if (args.length == 1) + } + else if (args.length == 1) { List players = UtilPlayer.matchOnline(caller, args[0], true); if (!players.isEmpty()) @@ -98,9 +96,10 @@ public class VersionsCommand extends CommandBase F.main("Version", C.cYellow + player.getName() + C.cGray + " is on version " + C.cGreen + pretty)); } - } else + } + else { UtilPlayer.message(caller, F.main("Version", "Invalid argument list.")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java index 6371980f2..2c9a85c40 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java @@ -16,6 +16,8 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -43,6 +45,9 @@ import mineplex.core.mount.types.MountZombie; public class MountManager extends MiniPlugin { + public static final String HERO_MOUNT_PERMISSION = "mineplex.core.mount.hero"; + public static final String TITAN_MOUNT_PERMISSION = "mineplex.core.mount.titan"; + private CoreClientManager _clientManager; private DonationManager _donationManager; private BlockRestore _blockRestore; @@ -61,6 +66,15 @@ public class MountManager extends MiniPlugin _disguiseManager = disguiseManager; CreateGadgets(); + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("hero"), GroupPermission.of(HERO_MOUNT_PERMISSION), true, true); + pm.setPermission(pm.getGroup("titan"), GroupPermission.of(TITAN_MOUNT_PERMISSION), true, true); } private void CreateGadgets() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java index 6241195dc..f0806b8b1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java @@ -8,14 +8,14 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.player.PlayerJoinEvent; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilText; import mineplex.core.mount.DragonData; import mineplex.core.mount.DragonMount; import mineplex.core.mount.MountManager; @@ -106,9 +106,9 @@ public class MountDragon extends DragonMount @EventHandler public void HeroOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.HERO)) + if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(MountManager.HERO_MOUNT_PERMISSION))) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java index 88c444306..b281900da 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java @@ -52,7 +52,7 @@ public class MountSheep extends HorseMount horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); DisguiseSheep disguise = new DisguiseSheep(horse); - disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguise.setName(player.getName(), Manager.getClientManager().Get(player).getRealOrDisguisedPrimaryGroup()); //disguise.setColor(DyeColor.getByColor(org.bukkit.Color.fromRGB(100, 0, 200))); Manager.getDisguiseManager().disguise(disguise); @@ -85,4 +85,4 @@ public class MountSheep extends HorseMount else if (horse.getTicksLived() % 4 == 3) sheep.setColor(DyeColor.BLUE); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java index 556de0243..f0e463eb0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java @@ -10,7 +10,7 @@ import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; @@ -33,7 +33,7 @@ public class MountTitan extends Mount @Override public void enableCustom(Player player) { - if(getActive().size() >= 3) + if (getActive().size() >= 3) { UtilPlayer.message(player, F.main("Mount", "The maximum amount of simultaneous " + F.elem(getName()) + " in this lobby has been reached.")); return; @@ -135,9 +135,9 @@ public class MountTitan extends Mount @EventHandler public void titanOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN)) + if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(MountManager.TITAN_MOUNT_PERMISSION))) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java index a139ba368..2898f78b1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java @@ -1,24 +1,23 @@ package mineplex.core.notifier; +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; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; 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.event.UpdateEvent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; public class NotificationManager extends MiniPlugin { private boolean _enabled = true; private CoreClientManager _clientManager; - private PreferencesManager _preferencesManager; private String _summerLine = C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + @@ -28,12 +27,11 @@ public class NotificationManager extends MiniPlugin C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█" + C.cBlack + "█" + C.cYellow + "█"; - public NotificationManager(JavaPlugin plugin, CoreClientManager client, PreferencesManager preferencesManager) + public NotificationManager(JavaPlugin plugin, CoreClientManager client) { super("Notification Manager", plugin); _clientManager = client; - _preferencesManager = preferencesManager; } @EventHandler @@ -56,7 +54,7 @@ public class NotificationManager extends MiniPlugin { for (Player player : UtilServer.getPlayers()) { - if (_preferencesManager.getClientManager().Get(player).GetRank() == Rank.ALL) + if (_clientManager.Get(player).getPrimaryGroup().getIdentifier().equals("player")) { player.sendMessage(C.cWhite + " "); player.sendMessage(C.cRedB + " MASSIVE WINTER SALE"); @@ -71,20 +69,22 @@ public class NotificationManager extends MiniPlugin { for (Player player : UtilServer.getPlayers()) { - Rank rank = _clientManager.Get(player).GetRank(); - - if (rank.has(Rank.LEGEND)) + PermissionGroup group = _clientManager.Get(player).getPrimaryGroup(); + + if (_clientManager.getPermissionManager().inheritsFully(group, _clientManager.getPermissionManager().getGroup("legend"))) + { continue; + } - if (rank == Rank.ALL) + if (group.getIdentifier().equals("player")) { UtilPlayer.message(player, C.cWhite + " 50% Off Sale! " + " Purchase " + C.cAqua + C.Bold + "Ultra Rank" + C.cWhite + " for $15"); } - else if (rank == Rank.ULTRA) + else if (group.getIdentifier().equals("ultra")) { UtilPlayer.message(player, C.cWhite + " 50% Off Sale! " + " Upgrade to " + C.cPurple + C.Bold + "Hero Rank" + C.cWhite + " for $15!"); } - else if (rank == Rank.HERO) + else if (group.getIdentifier().equals("hero")) { UtilPlayer.message(player, C.cWhite + " 50% Off Sale! " + "Upgrade to " + C.cGreen + C.Bold + "Legend Rank" + C.cWhite + " for $15!"); } @@ -97,10 +97,12 @@ public class NotificationManager extends MiniPlugin { for (Player player : UtilServer.getPlayers()) { - Rank rank = _clientManager.Get(player).GetRank(); - - if (rank.has(Rank.LEGEND)) + PermissionGroup group = _clientManager.Get(player).getPrimaryGroup(); + + if (_clientManager.getPermissionManager().inheritsFully(group, _clientManager.getPermissionManager().getGroup("legend"))) + { continue; + } UtilPlayer.message(player, _summerLine); UtilPlayer.message(player, " "); @@ -110,17 +112,17 @@ public class NotificationManager extends MiniPlugin C.cGreen + C.Bold + "75% OFF"); UtilPlayer.message(player, " "); - if (rank == Rank.ALL) + if (group.getIdentifier().equals("player")) { UtilPlayer.message(player, C.cWhite + " " + player.getName() + ", you can get 75% Off " + C.cAqua + C.Bold + "All Lifetime Ranks" + C.cWhite + "!"); UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!"); } - else if (rank == Rank.ULTRA) + else if (group.getIdentifier().equals("ultra")) { UtilPlayer.message(player, C.cWhite + " Hello " + player.getName() + ", upgrade to " + C.cPurple + C.Bold + "HERO RANK" + C.cWhite + " for only $7.50!"); UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!"); } - else if (rank == Rank.HERO) + else if (group.getIdentifier().equals("hero")) { UtilPlayer.message(player, C.cWhite + " Hello " + player.getName() + ", upgrade to " + C.cGreen + C.Bold + "LEGEND RANK" + C.cWhite + " for only $7.50!"); UtilPlayer.message(player, C.cWhite + " This is our biggest sale ever, " + C.cRed + C.Line + "ends Sunday 16th" + C.cWhite + "!"); @@ -133,4 +135,4 @@ public class NotificationManager extends MiniPlugin UtilPlayer.message(player, _summerLine); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index fc87a6a09..4cdd16faa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -2,20 +2,38 @@ package mineplex.core.npc; import java.sql.Connection; import java.sql.SQLException; -import java.util.*; +import java.util.ArrayList; +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.Queue; +import java.util.Set; +import java.util.UUID; -import com.mojang.authlib.GameProfile; -import mineplex.core.aprilfools.AprilFoolsManager; -import mineplex.core.common.skin.SkinData; -import mineplex.core.disguise.DisguiseManager; -import mineplex.core.disguise.disguises.DisguisePlayer; -import mineplex.core.utils.UtilGameProfile; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.World; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; -import org.bukkit.entity.*; +import org.bukkit.entity.Ageable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Sheep; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Slime; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityCombustEvent; @@ -28,16 +46,20 @@ import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; -import net.minecraft.server.v1_8_R3.EntityInsentient; +import org.jooq.Result; +import org.jooq.impl.DSL; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; import mineplex.core.creature.Creature; import mineplex.core.creature.event.CreatureKillEntitiesEvent; -import mineplex.serverdata.database.DBPool; +import mineplex.core.disguise.DisguiseManager; import mineplex.core.npc.command.NpcCommand; import mineplex.core.npc.event.NpcDamageByEntityEvent; import mineplex.core.npc.event.NpcInteractEntityEvent; @@ -46,8 +68,8 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.database.Tables; import mineplex.database.tables.records.NpcsRecord; -import org.jooq.Result; -import org.jooq.impl.DSL; +import mineplex.serverdata.database.DBPool; +import net.minecraft.server.v1_8_R3.EntityInsentient; public class NpcManager extends MiniPlugin { @@ -83,7 +105,14 @@ public class NpcManager extends MiniPlugin } } } - + + public static final String ADD_NPC_COMMAND_PERMISSION = "mineplex.core.npc.add"; + public static final String CLEAR_NPCS_COMMAND_PERMISSION = "mineplex.core.npc.clear"; + public static final String DELETE_NPC_COMMAND_PERMISSION = "mineplex.core.npc.delete"; + public static final String NPC_HOME_COMMAND_PERMISSION = "mineplex.core.npc.home"; + public static final String NPC_COMMAND_PERMISSION = "mineplex.core.npc.command"; + public static final String REFRESH_NPCS_COMMAND_PERMISSION = "mineplex.core.npc.refresh"; + private final Creature _creature; private final List _npcs = new ArrayList<>(); private final Queue _queuedNpcs = new LinkedList<>(); @@ -118,6 +147,20 @@ public class NpcManager extends MiniPlugin { e.printStackTrace(); } + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(ADD_NPC_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(CLEAR_NPCS_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(DELETE_NPC_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(NPC_HOME_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(NPC_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(REFRESH_NPCS_COMMAND_PERMISSION), true, true); } @Override @@ -129,14 +172,16 @@ public class NpcManager extends MiniPlugin public void help(Player caller, String message) { UtilPlayer.message(caller, F.main(_moduleName, "Commands List:")); - UtilPlayer.message(caller, F.help("/npc add [radius] [adult] [name]", "Create a new NPC.", Rank.DEVELOPER)); - UtilPlayer.message(caller, F.help("/npc del ", "Right click NPC to delete.", Rank.DEVELOPER)); - UtilPlayer.message(caller, F.help("/npc home", "Teleport NPCs to home locations.", Rank.DEVELOPER)); - UtilPlayer.message(caller, F.help("/npc clear", "Deletes all NPCs.", Rank.DEVELOPER)); - UtilPlayer.message(caller, F.help("/npc refresh", "Refresh NPCs from database.", Rank.DEVELOPER)); + UtilPlayer.message(caller, F.help("/npc add [radius] [adult] [name]", "Create a new NPC.", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/npc del ", "Right click NPC to delete.", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/npc home", "Teleport NPCs to home locations.", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/npc clear", "Deletes all NPCs.", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/npc refresh", "Refresh NPCs from database.", ChatColor.DARK_RED)); if (message != null) + { UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + message)); + } } public void help(Player caller) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java index e17daf159..d07282996 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java @@ -6,21 +6,22 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.npc.NpcManager; public class AddCommand extends CommandBase { public AddCommand(NpcManager plugin) { - super(plugin, Rank.JNR_DEV, "add"); + super(plugin, NpcManager.ADD_NPC_COMMAND_PERMISSION, "add"); } @Override public void Execute(Player caller, String[] args) { if (args == null || args.length == 0) + { Plugin.help(caller); + } else { EntityType type; @@ -52,14 +53,18 @@ public class AddCommand extends CommandBase boolean adult = true; if (args.length >= 3) + { adult = Boolean.parseBoolean(args[2]); + } String name = null; if (args.length >= 4) { name = args[3]; for (int i = 4; i < args.length; i++) + { name += " " + args[i]; + } } try @@ -72,4 +77,4 @@ public class AddCommand extends CommandBase } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/ClearCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/ClearCommand.java index aae8c26a0..d622e08d8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/ClearCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/ClearCommand.java @@ -5,7 +5,6 @@ import java.sql.SQLException; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.npc.NpcManager; @@ -14,14 +13,16 @@ public class ClearCommand extends CommandBase { public ClearCommand(NpcManager plugin) { - super(plugin, Rank.DEVELOPER, "clear"); + super(plugin, NpcManager.CLEAR_NPCS_COMMAND_PERMISSION, "clear"); } @Override public void Execute(Player caller, String[] args) { if (args.length > 0) + { Plugin.help(caller); + } else { try @@ -36,4 +37,4 @@ public class ClearCommand extends CommandBase } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java index f6a698add..b51b142fa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java @@ -3,7 +3,6 @@ package mineplex.core.npc.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.npc.NpcManager; @@ -12,14 +11,16 @@ public class DeleteCommand extends CommandBase { public DeleteCommand(NpcManager plugin) { - super(plugin, Rank.JNR_DEV, "del"); + super(plugin, NpcManager.DELETE_NPC_COMMAND_PERMISSION, "del"); } @Override public void Execute(Player caller, String[] args) { if (args.length > 0) + { Plugin.help(caller); + } else { Plugin.prepDeleteNpc(caller); @@ -27,4 +28,4 @@ public class DeleteCommand extends CommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), "Now right click npc.")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java index 51e8a622e..74e59c78c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java @@ -3,7 +3,6 @@ package mineplex.core.npc.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.npc.NpcManager; @@ -12,14 +11,16 @@ public class HomeCommand extends CommandBase { public HomeCommand(NpcManager plugin) { - super(plugin, Rank.DEVELOPER, new Rank[] {Rank.JNR_DEV}, "home"); + super(plugin, NpcManager.NPC_HOME_COMMAND_PERMISSION, "home"); } @Override public void Execute(Player caller, String[] args) { if (args.length > 0) + { Plugin.help(caller); + } else { Plugin.teleportNpcsHome(); @@ -27,4 +28,4 @@ public class HomeCommand extends CommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), "Npcs teleported to home locations.")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/NpcCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/NpcCommand.java index 81bd78c4a..9956a3ceb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/NpcCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/NpcCommand.java @@ -3,14 +3,13 @@ package mineplex.core.npc.command; import org.bukkit.entity.Player; import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; import mineplex.core.npc.NpcManager; public class NpcCommand extends MultiCommandBase { public NpcCommand(NpcManager plugin) { - super(plugin, Rank.JNR_DEV, "npc"); + super(plugin, NpcManager.NPC_COMMAND_PERMISSION, "npc"); AddCommand(new AddCommand(plugin)); AddCommand(new DeleteCommand(plugin)); @@ -24,4 +23,4 @@ public class NpcCommand extends MultiCommandBase { Plugin.help(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/RefreshCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/RefreshCommand.java index 465b8ee02..d705b1e8f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/RefreshCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/RefreshCommand.java @@ -5,7 +5,6 @@ import java.sql.SQLException; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.npc.NpcManager; @@ -14,14 +13,16 @@ public class RefreshCommand extends CommandBase { public RefreshCommand(NpcManager plugin) { - super(plugin, Rank.SNR_MODERATOR, "refresh"); + super(plugin, NpcManager.REFRESH_NPCS_COMMAND_PERMISSION, "refresh"); } @Override public void Execute(Player caller, String[] args) { if (args.length > 0) + { Plugin.help(caller); + } else { try @@ -37,4 +38,4 @@ public class RefreshCommand extends CommandBase } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java index a53d6906b..7f1fd67bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java @@ -14,6 +14,8 @@ import org.bukkit.scheduler.BukkitTask; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.HoverEvent; @@ -41,6 +43,8 @@ import mineplex.serverdata.commands.ServerCommandManager; public class PartyManager extends MiniPlugin { + public static final String PARTY_COMMAND_PERMISSION = "mineplex.core.party.command"; + /** * The item given to a player in his hotbar to manage the Parties via the new UI. */ @@ -96,6 +100,15 @@ public class PartyManager extends MiniPlugin _region = !new File("eu.dat").exists() ? Region.US : Region.EU; _messageManager = require(MessageManager.class); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(PARTY_COMMAND_PERMISSION), true, true); } @Deprecated diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCLICommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCLICommand.java index a5cdc12e6..7b1a67ba9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCLICommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCLICommand.java @@ -1,14 +1,8 @@ package mineplex.core.party.command; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; - import org.bukkit.entity.Player; import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.party.Party; @@ -22,12 +16,16 @@ import mineplex.core.party.command.cli.PartyInvitesCommand; import mineplex.core.party.command.cli.PartyKickCommand; import mineplex.core.party.command.cli.PartyLeaveCommand; import mineplex.core.party.command.cli.PartyTransferOwnerCommand; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; public class PartyCLICommand extends MultiCommandBase { public PartyCLICommand(PartyManager plugin) { - super(plugin, Rank.ALL, "cli", "c"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "cli", "c"); AddCommand(new PartyAcceptCommand(plugin)); AddCommand(new PartyDenyCommand(plugin)); @@ -156,4 +154,4 @@ public class PartyCLICommand extends MultiCommandBase caller.spigot().sendMessage(builder.create()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCommand.java index 0fbaf7373..0da3e6b57 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCommand.java @@ -1,6 +1,5 @@ package mineplex.core.party.command; -import java.util.Arrays; import java.util.List; import org.bukkit.command.CommandSender; @@ -8,9 +7,6 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.party.PartyManager; import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; @@ -24,7 +20,7 @@ public class PartyCommand extends MultiCommandBase public PartyCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "party", "z"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "party", "z"); AddCommand(new PartyGuiCommand(plugin)); AddCommand(new PartyCLICommand(plugin)); @@ -76,7 +72,5 @@ public class PartyCommand extends MultiCommandBase } } return super.onTabComplete(sender, commandLabel, args); - } -} - +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyGuiCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyGuiCommand.java index a22589667..9738d7cf6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyGuiCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyGuiCommand.java @@ -3,7 +3,6 @@ package mineplex.core.party.command; import org.bukkit.entity.Player; import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; import mineplex.core.party.Party; import mineplex.core.party.PartyManager; import mineplex.core.party.command.gui.PartyGUIAcceptInviteCommand; @@ -19,7 +18,7 @@ public class PartyGuiCommand extends MultiCommandBase { public PartyGuiCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "gui", "g"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "gui", "g"); AddCommand(new PartyOpenInviteMenuCommand(plugin)); AddCommand(new PartyGUIAcceptInviteCommand(plugin)); @@ -53,4 +52,4 @@ public class PartyGuiCommand extends MultiCommandBase Plugin.invite(caller, args[0]); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyToggleCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyToggleCommand.java index ff61eef79..76a52acfb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyToggleCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyToggleCommand.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -18,7 +17,7 @@ public class PartyToggleCommand extends CommandBase public PartyToggleCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "toggle", "t"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "toggle", "t"); } @Override @@ -34,4 +33,4 @@ public class PartyToggleCommand extends CommandBase UtilPlayer.message(caller, F.main("Party", "The Party GUI is now " + C.cRed + "disabled" + C.mBody + "!")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyAcceptCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyAcceptCommand.java index 349e2fec6..c830a8127 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyAcceptCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyAcceptCommand.java @@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.party.InviteData; @@ -16,7 +15,7 @@ public class PartyAcceptCommand extends CommandBase { public PartyAcceptCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "accept", "a"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "accept", "a"); } @Override @@ -46,4 +45,4 @@ public class PartyAcceptCommand extends CommandBase return null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyBlockCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyBlockCommand.java index 902dada8c..59a5c96b8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyBlockCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyBlockCommand.java @@ -3,14 +3,13 @@ package mineplex.core.party.command.cli; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.party.PartyManager; public class PartyBlockCommand extends CommandBase { public PartyBlockCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "block", "b"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "block", "b"); } @Override @@ -18,4 +17,4 @@ public class PartyBlockCommand extends CommandBase { } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyDenyCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyDenyCommand.java index 5d0f52d47..d954db59e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyDenyCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyDenyCommand.java @@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.party.InviteData; @@ -17,7 +16,7 @@ public class PartyDenyCommand extends CommandBase { public PartyDenyCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "deny", "d"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "deny", "d"); } @Override @@ -45,4 +44,4 @@ public class PartyDenyCommand extends CommandBase return null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyDisbandCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyDisbandCommand.java index 0d1265b58..e7e6f961e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyDisbandCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyDisbandCommand.java @@ -3,14 +3,13 @@ package mineplex.core.party.command.cli; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.party.PartyManager; public class PartyDisbandCommand extends CommandBase { public PartyDisbandCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "disband", "db"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "disband", "db"); } @Override @@ -18,4 +17,4 @@ public class PartyDisbandCommand extends CommandBase { Plugin.disband(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyHelpCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyHelpCommand.java index 31626f8ac..168078522 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyHelpCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyHelpCommand.java @@ -3,7 +3,6 @@ package mineplex.core.party.command.cli; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.party.PartyManager; @@ -12,7 +11,7 @@ public class PartyHelpCommand extends CommandBase { public PartyHelpCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "help", "h"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "help", "h"); } @Override @@ -31,4 +30,4 @@ public class PartyHelpCommand extends CommandBase UtilPlayer.message(caller, F.main("Party", F.elem("/party [gui/g]") + " - Opens the party GUI")); UtilPlayer.message(caller, F.main("Party", F.elem("/party [toggle/t]") + " - Toggles between the GUI and the chat")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyInviteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyInviteCommand.java index 3e67e92a6..24537d3e3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyInviteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyInviteCommand.java @@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.party.Party; @@ -16,7 +15,7 @@ public class PartyInviteCommand extends CommandBase { public PartyInviteCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "invite", "i"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "invite", "i"); } @Override @@ -43,4 +42,4 @@ public class PartyInviteCommand extends CommandBase return null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyInvitesCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyInvitesCommand.java index 09dd58e77..b37de9989 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyInvitesCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyInvitesCommand.java @@ -6,22 +6,20 @@ import java.util.Comparator; import java.util.List; import java.util.UUID; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; - import org.apache.commons.lang.StringUtils; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.party.InviteData; import mineplex.core.party.PartyManager; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; public class PartyInvitesCommand extends CommandBase { @@ -29,7 +27,7 @@ public class PartyInvitesCommand extends CommandBase public PartyInvitesCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "invites", "is"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "invites", "is"); } @Override @@ -197,4 +195,4 @@ public class PartyInvitesCommand extends CommandBase caller.spigot().sendMessage(pageSwitch.create()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyKickCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyKickCommand.java index 5613e5758..8f856364d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyKickCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyKickCommand.java @@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.party.Party; @@ -16,7 +15,7 @@ public class PartyKickCommand extends CommandBase { public PartyKickCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "kick", "k"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "kick", "k"); } @Override @@ -56,4 +55,4 @@ public class PartyKickCommand extends CommandBase return null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyLeaveCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyLeaveCommand.java index 90b9f305c..d7d6300c1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyLeaveCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyLeaveCommand.java @@ -3,14 +3,13 @@ package mineplex.core.party.command.cli; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.party.PartyManager; public class PartyLeaveCommand extends CommandBase { public PartyLeaveCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "leave", "l"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "leave", "l"); } @Override @@ -18,4 +17,4 @@ public class PartyLeaveCommand extends CommandBase { Plugin.leaveParty(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyTransferOwnerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyTransferOwnerCommand.java index 68dac5f57..be6cc2e55 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyTransferOwnerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyTransferOwnerCommand.java @@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.party.Lang; @@ -18,7 +17,7 @@ public class PartyTransferOwnerCommand extends CommandBase { public PartyTransferOwnerCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "transfer", "tr"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "transfer", "tr"); } @Override @@ -83,4 +82,4 @@ public class PartyTransferOwnerCommand extends CommandBase return null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIAcceptInviteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIAcceptInviteCommand.java index 9f1f6fa80..eceeb6721 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIAcceptInviteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIAcceptInviteCommand.java @@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.party.InviteData; @@ -16,7 +15,7 @@ public class PartyGUIAcceptInviteCommand extends CommandBase { public PartyGUIAcceptInviteCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "partyaccept", "accept", "a"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "partyaccept", "accept", "a"); } @Override @@ -46,4 +45,4 @@ public class PartyGUIAcceptInviteCommand extends CommandBase return null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIDenyInviteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIDenyInviteCommand.java index 6b53c1c61..f261512b1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIDenyInviteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIDenyInviteCommand.java @@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.party.InviteData; @@ -17,7 +16,7 @@ public class PartyGUIDenyInviteCommand extends CommandBase { public PartyGUIDenyInviteCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "partydeny", "deny", "d"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "partydeny", "deny", "d"); } @Override @@ -45,4 +44,4 @@ public class PartyGUIDenyInviteCommand extends CommandBase return null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIInviteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIInviteCommand.java index 2ae17a558..c4b850ae7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIInviteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIInviteCommand.java @@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.party.Party; @@ -16,7 +15,7 @@ public class PartyGUIInviteCommand extends CommandBase { public PartyGUIInviteCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "partyinvite", "invite", "i"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "partyinvite", "invite", "i"); } @Override @@ -43,4 +42,4 @@ public class PartyGUIInviteCommand extends CommandBase return null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUILeaveCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUILeaveCommand.java index e4858300b..ba6b6546b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUILeaveCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUILeaveCommand.java @@ -3,16 +3,13 @@ package mineplex.core.party.command.gui; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.party.PartyManager; public class PartyGUILeaveCommand extends CommandBase { public PartyGUILeaveCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "leave", "l"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "leave", "l"); } @Override @@ -20,4 +17,4 @@ public class PartyGUILeaveCommand extends CommandBase { Plugin.leaveParty(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyOpenInviteMenuCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyOpenInviteMenuCommand.java index 0064e920c..0ab7d0db9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyOpenInviteMenuCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyOpenInviteMenuCommand.java @@ -3,7 +3,6 @@ package mineplex.core.party.command.gui; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.party.PartyManager; import mineplex.core.party.ui.menus.PartyInvitesMenu; @@ -11,7 +10,7 @@ public class PartyOpenInviteMenuCommand extends CommandBase { public PartyOpenInviteMenuCommand(PartyManager plugin) { - super(plugin, Rank.ALL, "openinvitesmenu", "invitesmenu", "im", "invites", "is"); + super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "openinvitesmenu", "invitesmenu", "im", "invites", "is"); } @Override @@ -19,4 +18,4 @@ public class PartyOpenInviteMenuCommand extends CommandBase { new PartyInvitesMenu(Plugin).open(caller); } -} +} \ No newline at end of file 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 85f33fabc..2768f4c43 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java @@ -19,8 +19,9 @@ import org.bukkit.scheduler.BukkitTask; import com.google.common.collect.Lists; import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.command.CommandCenter; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; @@ -155,7 +156,7 @@ public class PartyJoinManager implements Listener List all = new ArrayList<>(); for (Player player : party.getMembers()) { - if (_plugin.getClientManager().Get(player).GetRank() == Rank.ALL) + if (!_plugin.getClientManager().getPermissionManager().hasPermission(player, GroupPermission.of(CoreClientManager.JOIN_FULL_PERMISSION))) { unranked.add(player.getUniqueId()); } @@ -356,5 +357,4 @@ public class PartyJoinManager implements Listener CommandCenter.getCommands().get("party").Execute(event.getPlayer(), new String[0]); } } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java index acad080eb..2e275e014 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.command.LoggedCommand; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; @@ -13,17 +12,16 @@ public class HostEventServerCommand extends CommandBase i { public HostEventServerCommand(PersonalServerManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] - { - Rank.EVENT_MODERATOR - }, "hostevent"); + super(plugin, PersonalServerManager.EVENT_COMMAND_PERMISSION, "hostevent"); } @Override public void Execute(Player caller, String[] args) { if (!Recharge.Instance.use(caller, "Host Event", 30000, false, false)) + { return; + } if(Plugin.getClients().Get(caller).isDisguised()) { @@ -32,4 +30,4 @@ public class HostEventServerCommand extends CommandBase i } Plugin.hostServer(caller, caller.getName(), true); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java index 8284c78e9..27b137c9a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.command.LoggedCommand; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; @@ -13,19 +12,18 @@ public class HostPersonalEventServer extends CommandBase { public HostPersonalEventServer(PersonalServerManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] - { - Rank.EVENT_MODERATOR - }, "hostmes"); + super(plugin, PersonalServerManager.PERSONAL_EVENT_COMMAND_PERMISSION, "hostmes"); } @Override public void Execute(Player caller, String[] args) { if (!Recharge.Instance.use(caller, "Host Event", 30000, false, false)) + { return; + } - if(Plugin.getClients().Get(caller).isDisguised()) + if (Plugin.getClients().Get(caller).isDisguised()) { UtilPlayer.message(caller, F.main("Disguise", "You can't create a event server while you are disguised!")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java index 1c85b6dfc..568d5f806 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java @@ -3,7 +3,6 @@ package mineplex.core.personalServer; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; @@ -12,7 +11,7 @@ public class HostServerCommand extends CommandBase { public HostServerCommand(PersonalServerManager plugin) { - super(plugin, Rank.LEGEND, "hostserver", "mps"); + super(plugin, PersonalServerManager.MPS_PERMISSION, "hostserver", "mps"); } @Override @@ -21,11 +20,11 @@ public class HostServerCommand extends CommandBase if (!Recharge.Instance.use(caller, "Host Server", 30000, false, false)) return; - if(Plugin.getClients().Get(caller).isDisguised()) + if (Plugin.getClients().Get(caller).isDisguised()) { UtilPlayer.message(caller, F.main("Disguise", "You can't create a MPS while you are disguised!")); return; } Plugin.hostServer(caller, caller.getName(), false); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java index 556d3758a..b50518c8e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java @@ -5,13 +5,13 @@ 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.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.Color; import mineplex.core.common.jsonchat.HoverEvent; @@ -30,15 +30,18 @@ import mineplex.serverdata.servers.ServerRepository; public class PersonalServerManager extends MiniPlugin { + public static final String MPS_PERMISSION = "mineplex.core.personalServer.mps"; + public static final String ADVANCED_MPS_PERMISSION = "mineplex.core.personalServer.advanced"; + public static final String EVENT_COMMAND_PERMISSION = "mineplex.core.personalServer.event"; + public static final String PERSONAL_EVENT_COMMAND_PERMISSION = "mineplex.core.personalServer.personalevent"; + private ServerRepository _repository; private CoreClientManager _clientManager; private boolean _us; - private int _interfaceSlot = 6; private ItemStack _interfaceItem; private boolean _useInterfaceItem = true; - private boolean _giveInterfaceItem = true; public PersonalServerManager(JavaPlugin plugin, CoreClientManager clientManager) { @@ -54,14 +57,22 @@ public class PersonalServerManager extends MiniPlugin _repository = ServerManager.getServerRepository(region); _interfaceItem = ItemStackFactory.Instance.CreateStack(Material.SPECKLED_MELON, (byte)0, 1, C.cGreen + "/hostserver"); + + generatePermissions(); } - - @EventHandler - public void onJoin(PlayerJoinEvent event) + + private void generatePermissions() { - if (_giveInterfaceItem) - { - } + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("legend"), GroupPermission.of(MPS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("content"), GroupPermission.of(ADVANCED_MPS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("yt"), GroupPermission.of(ADVANCED_MPS_PERMISSION), true, false); + pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(ADVANCED_MPS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("eventmod"), GroupPermission.of(EVENT_COMMAND_PERMISSION), false, true); + pm.setPermission(pm.getGroup("eventmod"), GroupPermission.of(PERSONAL_EVENT_COMMAND_PERMISSION), false, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(EVENT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PERSONAL_EVENT_COMMAND_PERMISSION), true, true); } @EventHandler @@ -74,15 +85,17 @@ public class PersonalServerManager extends MiniPlugin if (_interfaceItem.equals(event.getPlayer().getItemInHand())) { if (!Recharge.Instance.use(event.getPlayer(), "Host Server Melon", 30000, false, false)) + { return; + } - if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.LEGEND)) + if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(MPS_PERMISSION))) { showHostMessage(event.getPlayer()); } else { - UtilPlayer.message(event.getPlayer(), F.main("Server", "Only players with " + F.rank(Rank.LEGEND) + C.mBody + "+ can host private servers")); + UtilPlayer.message(event.getPlayer(), F.main("Server", "Only players with " + C.cGreen + "Legend" + C.mBody + "+ can host private servers")); } } } @@ -134,9 +147,7 @@ public class PersonalServerManager extends MiniPlugin int ram = 1024; int cpu = 1; - Rank rank = _clientManager.Get(player).GetRank(); - - if (rank.has(Rank.SNR_MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH) + if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(ADVANCED_MPS_PERMISSION))) { ram = 2048; cpu = 4; @@ -191,42 +202,37 @@ public class PersonalServerManager extends MiniPlugin private void createGroup(final Player host, final String serverName, final int ram, final int cpu, final int minPlayers, final int maxPlayers, final String games, final boolean event) { - getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() + getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), () -> { - public void run() + for (ServerGroup existingServerGroup : _repository.getServerGroups(null)) { - for (ServerGroup existingServerGroup : _repository.getServerGroups(null)) + if (existingServerGroup.getPrefix().equalsIgnoreCase(serverName) || existingServerGroup.getName().equalsIgnoreCase(serverName)) { - if (existingServerGroup.getPrefix().equalsIgnoreCase(serverName) || existingServerGroup.getName().equalsIgnoreCase(serverName)) + if (host.getName().equalsIgnoreCase(existingServerGroup.getHost())) { - if (host.getName().equalsIgnoreCase(existingServerGroup.getHost())) - host.sendMessage(F.main(getName(), "Your server is still being created or already exists. If you haven't been connected in 20 seconds, type /server " + serverName + "-1.")); - else - host.sendMessage(C.cRed + "Sorry, but you're not allowed to create a MPS server because you have chosen a name to glitch the system :)"); - - return; + host.sendMessage(F.main(getName(), "Your server is still being created or already exists. If you haven't been connected in 20 seconds, type /server " + serverName + "-1.")); } + else + { + host.sendMessage(C.cRed + "Sorry, but you're not allowed to create a MPS server because you have chosen a name to glitch the system :)"); + } + + return; } - - final ServerGroup serverGroup = new ServerGroup(serverName, serverName, host.getName(), ram, cpu, 1, 0, UtilMath.random.nextInt(250) + 19999, "", true, "Lobby_MPS.zip", "Arcade.jar", "plugins/Arcade/", minPlayers, maxPlayers, - true, false, false, games, "", "", "Player", true, event, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU, "", "", "", ""); - - getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() - { - public void run() - { - _repository.updateServerGroup(serverGroup); - Bukkit.getScheduler().runTask(getPlugin(), new Runnable() - { - public void run() - { - host.sendMessage(F.main(getName(), serverName + "-1 successfully created. You will be sent to it shortly.")); - host.sendMessage(F.main(getName(), "If you haven't been connected in 20 seconds, type /server " + serverName + "-1.")); - } - }); - } - }); } + + final ServerGroup serverGroup = new ServerGroup(serverName, serverName, host.getName(), ram, cpu, 1, 0, UtilMath.random.nextInt(250) + 19999, "", true, "Lobby_MPS.zip", "Arcade.jar", "plugins/Arcade/", minPlayers, maxPlayers, + true, false, false, games, "", "", "Player", true, event, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU, "", "", "", ""); + + getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), () -> + { + _repository.updateServerGroup(serverGroup); + Bukkit.getScheduler().runTask(getPlugin(), () -> + { + host.sendMessage(F.main(getName(), serverName + "-1 successfully created. You will be sent to it shortly.")); + host.sendMessage(F.main(getName(), "If you haven't been connected in 20 seconds, type /server " + serverName + "-1.")); + }); + }); }); } @@ -239,4 +245,4 @@ public class PersonalServerManager extends MiniPlugin { _useInterfaceItem = use; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index 902e5218a..b6580846c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -8,9 +8,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.UUID; -import net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.NavigationAbstract; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -50,8 +47,9 @@ import com.google.gson.Gson; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.ClientWebResponseEvent; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.common.Rank; import mineplex.core.common.shape.ShapeWings; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.F; @@ -77,9 +75,14 @@ import mineplex.core.pet.repository.PetRepository; import mineplex.core.pet.repository.token.ClientPetTokenWrapper; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import net.minecraft.server.v1_8_R3.EntityCreature; +import net.minecraft.server.v1_8_R3.NavigationAbstract; public class PetManager extends MiniClientPlugin { + public static final String WIDDER_PET_PERMISSION = "mineplex.core.pet.widder"; + public static final String GUARDIAN_PET_PERMISSION = "mineplex.core.pet.guardian"; + private static Object _petOwnerSynch = new Object(); private static Object _petRenameSynch = new Object(); @@ -108,8 +111,8 @@ public class PetManager extends MiniClientPlugin private ShapeWings _cupidWingsWhite = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '%', ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_HEART_WING_PATTERN); private ShapeWings _cupidWingsEdge = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0, 0, 0), 1, 0, true, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_HEART_WING_PATTERN); - public PetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager - , InventoryManager inventoryManager, DisguiseManager disguiseManager, mineplex.core.creature.Creature creatureModule, BlockRestore restore) + public PetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, + InventoryManager inventoryManager, DisguiseManager disguiseManager, mineplex.core.creature.Creature creatureModule, BlockRestore restore) { super("Pet Manager", plugin); @@ -123,6 +126,16 @@ public class PetManager extends MiniClientPlugin _activePetOwners = new HashMap<>(); _failedAttempts = new HashMap<>(); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("legend"), GroupPermission.of(WIDDER_PET_PERMISSION), true, true); + pm.setPermission(pm.getGroup("titan"), GroupPermission.of(GUARDIAN_PET_PERMISSION), true, true); } public void addPetOwnerToQueue(String playerName, PetType petType) @@ -187,18 +200,21 @@ public class PetManager extends MiniClientPlugin public void onJoin(PlayerJoinEvent event) { Player p = event.getPlayer(); - Rank rank = _clientManager.Get(p).GetRank(); - if (rank.has(Rank.LEGEND)) + if (_clientManager.getPermissionManager().hasPermission(p, GroupPermission.of(WIDDER_PET_PERMISSION))) { if (!Get(p).getPets().containsKey(PetType.WITHER)) + { Get(p).getPets().put(PetType.WITHER, "Widder"); + } } - if (rank.has(Rank.TITAN)) + if (_clientManager.getPermissionManager().hasPermission(p, GroupPermission.of(GUARDIAN_PET_PERMISSION))) { if (!Get(p).getPets().containsKey(PetType.SKELETON)) + { Get(p).getPets().put(PetType.SKELETON, "Guardian"); + } } } @@ -211,7 +227,9 @@ public class PetManager extends MiniClientPlugin removePet(player, true); } else + { return; + } } PetSpawnEvent petSpawnEvent = new PetSpawnEvent(player, petType.getEntityType(), location); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/playerCount/PlayerCountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/playerCount/PlayerCountManager.java index ee1e1ddfb..0f069bd4f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/playerCount/PlayerCountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/playerCount/PlayerCountManager.java @@ -65,9 +65,10 @@ public class PlayerCountManager extends MiniPlugin public void refresh(UpdateEvent event) { if (event.getType() != UpdateType.SEC_08) + { return; + } runAsync(this::updatePlayerCount); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/DisplayType.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/DisplayType.java index 958fb9a0c..68726f4cc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/DisplayType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/DisplayType.java @@ -1,6 +1,6 @@ package mineplex.core.poll; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.PermissionGroup; public enum DisplayType { @@ -8,16 +8,16 @@ public enum DisplayType RANKED, NOT_RANKED; - public boolean shouldDisplay(Rank rank) + public boolean shouldDisplay(PermissionGroup group) { switch (this) { case RANKED: - return rank.has(Rank.ULTRA); + return !group.getIdentifier().equals("player"); case NOT_RANKED: - return !rank.has(Rank.ULTRA); + return group.getIdentifier().equals("player"); default: return true; } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/PlayerPollData.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PlayerPollData.java index 3465fae3b..267da016a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/PlayerPollData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PlayerPollData.java @@ -44,5 +44,4 @@ public class PlayerPollData { return Loaded && System.currentTimeMillis() > _nextPollTime; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/Poll.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/Poll.java index 715b1f275..191113142 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/Poll.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/Poll.java @@ -70,4 +70,4 @@ public class Poll } return false; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java index ddca26a97..bf46f14bc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java @@ -6,7 +6,6 @@ import java.util.List; import java.util.UUID; import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; @@ -14,22 +13,25 @@ import org.bukkit.plugin.java.JavaPlugin; import com.google.gson.JsonObject; -import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer; -import net.minecraft.server.v1_8_R3.PacketPlayOutChat; - import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; import mineplex.core.poll.command.PollCommand; +import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer; +import net.minecraft.server.v1_8_R3.PacketPlayOutChat; public class PollManager extends MiniDbClientPlugin { + public static final String POLL_COMMAND_PERMISSION = "mineplex.core.poll.command"; + public static final String POLL_STAFF_COMMAND_PERMISSION = "mineplex.core.poll.command.staff"; + private PollRepository _repository; private DonationManager _donationManager; private List _polls; @@ -42,14 +44,20 @@ public class PollManager extends MiniDbClientPlugin _donationManager = donationManager; - plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() + plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> { - @Override - public void run() - { - _polls = _repository.retrievePolls(); - } + _polls = _repository.retrievePolls(); }, 1L, 1200L); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(POLL_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(POLL_COMMAND_PERMISSION), true, true); } @Override @@ -91,12 +99,14 @@ public class PollManager extends MiniDbClientPlugin } }*/ - public Poll getNextPoll(PlayerPollData pollData, Rank playerRank) + public Poll getNextPoll(PlayerPollData pollData, PermissionGroup primaryGroup) { for (Poll poll : _polls) { - if (poll.isEnabled() && poll.getDisplayType().shouldDisplay(playerRank) && !pollData.hasAnswered(poll)) + if (poll.isEnabled() && poll.getDisplayType().shouldDisplay(primaryGroup) && !pollData.hasAnswered(poll)) + { return poll; + } } return null; @@ -104,7 +114,7 @@ public class PollManager extends MiniDbClientPlugin public boolean hasPoll(Player player) { - return getNextPoll(Get(player), getClientManager().Get(player).GetRank()) != null; + return getNextPoll(Get(player), getClientManager().Get(player).getPrimaryGroup()) != null; } public void displayPoll(Player player, Poll poll) @@ -188,7 +198,9 @@ public class PollManager extends MiniDbClientPlugin for (Poll poll : _polls) { if (poll.getId() == pollId) + { return poll; + } } return null; } @@ -220,4 +232,4 @@ public class PollManager extends MiniDbClientPlugin { return "SELECT pollId, value FROM accountPolls WHERE accountPolls.accountId = '" + accountId + "';"; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java index b65345cf4..4887c0d19 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollRepository.java @@ -6,12 +6,10 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.ResultSetCallable; import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnVarChar; @@ -35,41 +33,37 @@ public class PollRepository extends RepositoryBase public List retrievePolls() { - final List polls = new ArrayList(); + final List polls = new ArrayList<>(); - executeQuery(RETRIEVE_POLLS, new ResultSetCallable() + executeQuery(RETRIEVE_POLLS, resultSet -> { - @Override - public void processResultSet(ResultSet resultSet) throws SQLException + while (resultSet.next()) { - while (resultSet.next()) + int pollId = resultSet.getInt(1); + boolean enabled = resultSet.getBoolean(2); + String question = resultSet.getString(3); + String answerA = resultSet.getString(4); + String answerB = resultSet.getString(5); + String answerC = resultSet.getString(6); + String answerD = resultSet.getString(7); + int coinReward = resultSet.getInt(8); + DisplayType displayType; + + switch(resultSet.getInt(9)) { - int pollId = resultSet.getInt(1); - boolean enabled = resultSet.getBoolean(2); - String question = resultSet.getString(3); - String answerA = resultSet.getString(4); - String answerB = resultSet.getString(5); - String answerC = resultSet.getString(6); - String answerD = resultSet.getString(7); - int coinReward = resultSet.getInt(8); - DisplayType displayType; - - switch(resultSet.getInt(9)) - { - case 1: - displayType = DisplayType.RANKED; - break; - case 2: - displayType = DisplayType.NOT_RANKED; - break; - default: - displayType = DisplayType.ALL; - } - - Poll poll = new Poll(pollId, enabled, coinReward, question, answerA, answerB, answerC, answerD, displayType); - - polls.add(poll); + case 1: + displayType = DisplayType.RANKED; + break; + case 2: + displayType = DisplayType.NOT_RANKED; + break; + default: + displayType = DisplayType.ALL; } + + Poll poll = new Poll(pollId, enabled, coinReward, question, answerA, answerB, answerC, answerD, displayType); + + polls.add(poll); } }); @@ -120,43 +114,39 @@ public class PollRepository extends RepositoryBase { final PollStats stats = new PollStats(); - executeQuery(RETRIEVE_POLL_STATS, new ResultSetCallable() + executeQuery(RETRIEVE_POLL_STATS, resultSet -> { - @Override - public void processResultSet(ResultSet resultSet) throws SQLException + int aCount = 0; + int bCount = 0; + int cCount = 0; + int dCount = 0; + + while (resultSet.next()) { - int aCount = 0; - int bCount = 0; - int cCount = 0; - int dCount = 0; - - while (resultSet.next()) + int responseCount = resultSet.getInt(2); + switch (resultSet.getInt(1)) { - int responseCount = resultSet.getInt(2); - switch (resultSet.getInt(1)) - { - case 1: - aCount = responseCount; - break; - case 2: - bCount = responseCount; - break; - case 3: - cCount = responseCount; - break; - case 4: - dCount = responseCount; - break; - } + case 1: + aCount = responseCount; + break; + case 2: + bCount = responseCount; + break; + case 3: + cCount = responseCount; + break; + case 4: + dCount = responseCount; + break; } - - stats.setACount(aCount); - stats.setBCount(bCount); - stats.setCCount(cCount); - stats.setDCount(dCount); } + + stats.setACount(aCount); + stats.setBCount(bCount); + stats.setCCount(cCount); + stats.setDCount(dCount); }, new ColumnInt("pollId", pollId)); return stats; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollStats.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollStats.java index 5f3ecdb2a..364894e75 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollStats.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollStats.java @@ -74,5 +74,4 @@ public class PollStats { _dCount = dCount; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/command/PollCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/command/PollCommand.java index 12a118d5f..c7850dafd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/command/PollCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/command/PollCommand.java @@ -7,8 +7,8 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -25,7 +25,7 @@ public class PollCommand extends CommandBase { public PollCommand(PollManager plugin) { - super(plugin, Rank.ALL, "poll"); + super(plugin, PollManager.POLL_COMMAND_PERMISSION, "poll"); } @Override @@ -39,7 +39,7 @@ public class PollCommand extends CommandBase return; } - if (args[0].equalsIgnoreCase("list") && _commandCenter.GetClientManager().Get(caller).GetRank().has(Rank.MODERATOR)) + if (args[0].equalsIgnoreCase("list") && _commandCenter.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(PollManager.POLL_STAFF_COMMAND_PERMISSION))) { if (args.length == 1) { @@ -80,58 +80,50 @@ public class PollCommand extends CommandBase } UtilPlayer.message(caller, "Fetching Poll Stats...."); - Bukkit.getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable() + Bukkit.getScheduler().runTaskAsynchronously(Plugin.getPlugin(), () -> { - @Override - public void run() + final PollStats stats = Plugin.getPollStats(pollId); + Bukkit.getScheduler().runTask(Plugin.getPlugin(), () -> { - final PollStats stats = Plugin.getPollStats(pollId); - Bukkit.getScheduler().runTask(Plugin.getPlugin(), new Runnable() + for (int i = 0; i < 5; i++) { - @Override - public void run() + UtilPlayer.message(caller, ""); + } + + UtilPlayer.message(caller, "Question: " + C.cYellow + poll.getQuestion()); + UtilPlayer.message(caller, "Enabled: " + C.cYellow + poll.isEnabled()); + UtilPlayer.message(caller, "Poll Id: " + C.cYellow + poll.getId()); + UtilPlayer.message(caller, "Reward: " + C.cYellow + poll.getCoinReward()); + UtilPlayer.message(caller, "Display Type: " + C.cYellow + poll.getDisplayType()); + UtilPlayer.message(caller, ""); + + DecimalFormat decimalFormat = new DecimalFormat("#.#"); + double aPercent = stats.getAPercent(); + double bPercent = stats.getBPercent(); + double cPercent = stats.getCPercent(); + double dPercent = stats.getDPercent(); + for (int i = 0; i < poll.getAnswers().length; i++) + { + String answer = poll.getAnswers()[i]; + if (answer != null) { - for (int i = 0; i < 5; i++) - { - UtilPlayer.message(caller, ""); - } + double percent = 0; + if (i == 0) + percent = aPercent; + if (i == 1) + percent = bPercent; + if (i == 2) + percent = cPercent; + if (i == 3) + percent = dPercent; - UtilPlayer.message(caller, "Question: " + C.cYellow + poll.getQuestion()); - UtilPlayer.message(caller, "Enabled: " + C.cYellow + poll.isEnabled()); - UtilPlayer.message(caller, "Poll Id: " + C.cYellow + poll.getId()); - UtilPlayer.message(caller, "Reward: " + C.cYellow + poll.getCoinReward()); - UtilPlayer.message(caller, "Display Type: " + C.cYellow + poll.getDisplayType()); - UtilPlayer.message(caller, ""); - - DecimalFormat decimalFormat = new DecimalFormat("#.#"); - double aPercent = stats.getAPercent(); - double bPercent = stats.getBPercent(); - double cPercent = stats.getCPercent(); - double dPercent = stats.getDPercent(); - for (int i = 0; i < poll.getAnswers().length; i++) - { - String answer = poll.getAnswers()[i]; - if (answer != null) - { - double percent = 0; - if (i == 0) - percent = aPercent; - if (i == 1) - percent = bPercent; - if (i == 2) - percent = cPercent; - if (i == 3) - percent = dPercent; - - UtilPlayer.message(caller, answer); - UtilPlayer.message(caller, getProgressBar(percent, 60) + " " + C.cWhite + "(" + C.cYellow + decimalFormat.format(100d*percent) + "%" + C.cWhite + ")"); - } - } - UtilPlayer.message(caller, " "); - UtilPlayer.message(caller, "Total Responses: " + C.cYellow + stats.getTotal()); + UtilPlayer.message(caller, answer); + UtilPlayer.message(caller, getProgressBar(percent, 60) + " " + C.cWhite + "(" + C.cYellow + decimalFormat.format(100d*percent) + "%" + C.cWhite + ")"); } - }); - } + } + UtilPlayer.message(caller, " "); + UtilPlayer.message(caller, "Total Responses: " + C.cYellow + stats.getTotal()); + }); }); } } @@ -201,4 +193,4 @@ public class PollCommand extends CommandBase return sb.toString(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/SendCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/SendCommand.java deleted file mode 100644 index f0c7c59bf..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/SendCommand.java +++ /dev/null @@ -1,68 +0,0 @@ -package mineplex.core.portal.commands; - -import org.bukkit.entity.Player; - -import mineplex.core.command.*; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.portal.Portal; - -public class SendCommand extends CommandBase -{ - public SendCommand(Portal plugin) - { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "send"); - } - - @Override - public void Execute(final Player player, final String[] args) - { - if(args == null || args.length == 0) - { - UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Your arguments are inappropriate for this command!")); - return; - } - else if(args.length == 2) - { - final String playerTarget = args[0]; - final String serverTarget = args[1]; - - _commandCenter.GetClientManager().checkPlayerName(player, playerTarget, new Callback() - { - public void run(final String playerName) - { - if (playerName == null) - { - UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "Player " + C.cGold + playerTarget + C.cGray + " does not exist!")); - return; - } - - Plugin.doesServerExist(serverTarget, new Callback() - { - public void run(Boolean serverExists) - { - if (!serverExists) - { - UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "Server " + C.cGold + serverTarget + C.cGray + " does not exist!")); - return; - } - - Portal.transferPlayer(playerName, serverTarget); - - UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "You have sent player: " + C.cGold + playerName + C.cGray + " to server: " + C.cGold + serverTarget + C.cGray + "!")); - return; - } - }); - } - }); - } - else - { - UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Your arguments are inappropriate for this command!")); - return; - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java deleted file mode 100644 index 5511e0105..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java +++ /dev/null @@ -1,98 +0,0 @@ -package mineplex.core.portal.commands; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.portal.Intent; -import mineplex.core.portal.Portal; - -public class ServerCommand extends CommandBase -{ - public ServerCommand(Portal plugin) - { - super(plugin, Rank.ALL, "server"); - } - - @Override - public void Execute(final Player player, final String[] args) - { - final Rank playerRank = _commandCenter.GetClientManager().Get(player).GetRank(); - final String serverName = Plugin.getPlugin().getConfig().getString("serverstatus.name"); - - if (args == null || args.length == 0) - { - UtilPlayer.message(player, - F.main(Plugin.getName(), C.cGray + "You are currently on server: " + C.cGold + serverName)); - } - else if (args.length == 1) - { - if (serverName.equalsIgnoreCase(args[0])) - { - UtilPlayer.message( - player, - F.main(Plugin.getName(), "You are already on " + C.cGold + serverName + C.cGray - + "!")); - } - else - { - Plugin.doesServerExist(args[0], new Callback() - { - public void run(final Boolean serverExists) - { - if (!serverExists) - { - UtilPlayer.message( - player, - F.main(Plugin.getName(), "Server " + C.cGold + args[0] - + C.cGray + " does not exist!")); - return; - } - - boolean deniedAccess = false; - String servUp = args[0].toUpperCase(); - - if (servUp.contains("STAFF")) - { - if (!playerRank.has(Rank.HELPER)) - deniedAccess = true; - } - else if (servUp.contains("TEST")) - { - if (!playerRank.has(Rank.MODERATOR)) - deniedAccess = true; - } - else if (servUp.startsWith("CLANS-")) - { - if (!playerRank.has(Rank.HELPER)) - { - UtilPlayer.message(player, F.main(Plugin.getName(), "Clans servers can only be joined via the Clans Hub!")); - return; - } - } - - if (deniedAccess) - { - UtilPlayer.message( - player, - F.main(Plugin.getName(), C.cRed + "You don't have permission to join " + C.cGold + args[0])); - } - else - { - Plugin.sendPlayerToServer(player, args[0], Intent.PLAYER_REQUEST); - } - } - }); - } - } - else - { - UtilPlayer.message(player, - F.main(Plugin.getName(), C.cRed + "Your arguments are inappropriate for this command!")); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/GenericServer.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/GenericServer.java index 94059bbb3..1947e1853 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/GenericServer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/GenericServer.java @@ -23,11 +23,11 @@ public enum GenericServer GenericServer(String name) { - this._name = name; + _name = name; } public String getName() { return _name; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Intent.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Intent.java index 5bf35f346..f427be87a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Intent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Intent.java @@ -17,4 +17,4 @@ public enum Intent * A transfer was initiated from a remote server (i.e. /send) */ FORCE_TRANSFER -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 062a529d3..5d0d53f95 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -18,7 +18,8 @@ import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -39,6 +40,12 @@ import mineplex.serverdata.servers.ServerRepository; public class Portal extends MiniPlugin { + public static final String JOIN_FULL_PERMISSION = "mineplex.core.portal.joinfull"; + public static final String JOIN_STAFF_PERMISSION = "mineplex.core.portal.joinstaff"; + public static final String SERVER_COMMAND_CLANS_PERMISSION = "mineplex.core.portal.server.clans"; + public static final String SERVER_COMMAND_PERMISSION = "mineplex.core.portal.server"; + public static final String SEND_COMMAND_PERMISSION = "mineplex.core.portal.send"; + // The singleton instance of Portal private static Portal instance; @@ -80,6 +87,19 @@ public class Portal extends MiniPlugin sendPlayerToServer(player, command.getTargetServer(), Intent.FORCE_TRANSFER); } }); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(SERVER_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SEND_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(JOIN_STAFF_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SERVER_COMMAND_CLANS_PERMISSION), true, true); } public void sendAllPlayersToGenericServer(GenericServer hub, Intent kick) @@ -109,7 +129,9 @@ public class Portal extends MiniPlugin public void sendPlayerToServer(Player player, String serverName, Intent intent) { if (_connectingPlayers.contains(player.getName())) + { return; + } ServerTransferEvent event = new ServerTransferEvent(player, serverName, intent); UtilServer.CallEvent(event); @@ -119,8 +141,6 @@ public class Portal extends MiniPlugin return; } - Rank playerRank = _clientManager.Get(player).GetRank(); - runAsync(() -> { final MinecraftServer server = _repository.getServerStatus(serverName); @@ -135,7 +155,7 @@ public class Portal extends MiniPlugin UtilPlayer.message(player, F.main(getName(), C.cGold + serverName + C.cRed + " is restarting!")); return; } - if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.has(Rank.ULTRA)) + if (server.getPlayerCount() < server.getMaxPlayerCount() || server.getGroup().equalsIgnoreCase("Clans") || _clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(JOIN_FULL_PERMISSION))) { sendPlayer(player, serverName); } @@ -160,7 +180,9 @@ public class Portal extends MiniPlugin public void doesServerExist(final String serverName, final Callback callback) { if (callback == null) + { return; + } runAsync(() -> { @@ -209,9 +231,7 @@ public class Portal extends MiniPlugin out.writeUTF("Connect"); out.writeUTF(serverName); } - catch (IOException ignored) - { - } + catch (IOException ignored) {} player.sendPluginMessage(getPlugin(), "BungeeCord", b.toByteArray()); _connectingPlayers.add(player.getName()); @@ -236,4 +256,4 @@ public class Portal extends MiniPlugin { return _repository; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/SendCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/SendCommand.java new file mode 100644 index 000000000..ea13de43a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/SendCommand.java @@ -0,0 +1,60 @@ +package mineplex.core.portal.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.portal.Portal; + +public class SendCommand extends CommandBase +{ + public SendCommand(Portal plugin) + { + super(plugin, Portal.SEND_COMMAND_PERMISSION, "send"); + } + + @Override + public void Execute(final Player player, final String[] args) + { + if (args == null || args.length == 0) + { + UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Your arguments are inappropriate for this command!")); + return; + } + else if (args.length == 2) + { + final String playerTarget = args[0]; + final String serverTarget = args[1]; + + _commandCenter.GetClientManager().checkPlayerName(player, playerTarget, playerName -> + { + if (playerName == null) + { + UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "Player " + C.cGold + playerTarget + C.cGray + " does not exist!")); + return; + } + + Plugin.doesServerExist(serverTarget, serverExists -> + { + if (!serverExists.booleanValue()) + { + UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "Server " + C.cGold + serverTarget + C.cGray + " does not exist!")); + return; + } + + Portal.transferPlayer(playerName, serverTarget); + + UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "You have sent player: " + C.cGold + playerName + C.cGray + " to server: " + C.cGold + serverTarget + C.cGray + "!")); + return; + }); + }); + } + else + { + UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Your arguments are inappropriate for this command!")); + return; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/ServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/ServerCommand.java new file mode 100644 index 000000000..02257a78b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/ServerCommand.java @@ -0,0 +1,90 @@ +package mineplex.core.portal.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.portal.Intent; +import mineplex.core.portal.Portal; + +public class ServerCommand extends CommandBase +{ + public ServerCommand(Portal plugin) + { + super(plugin, Portal.SERVER_COMMAND_PERMISSION, "server"); + } + + @Override + public void Execute(final Player player, final String[] args) + { + final String serverName = Plugin.getPlugin().getConfig().getString("serverstatus.name"); + + if (args == null || args.length == 0) + { + UtilPlayer.message(player, + F.main(Plugin.getName(), C.cGray + "You are currently on server: " + C.cGold + serverName)); + } + else if (args.length == 1) + { + if (serverName.equalsIgnoreCase(args[0])) + { + UtilPlayer.message( + player, + F.main(Plugin.getName(), "You are already on " + C.cGold + serverName + C.cGray + + "!")); + } + else + { + Plugin.doesServerExist(args[0], serverExists -> + { + if (!serverExists.booleanValue()) + { + UtilPlayer.message( + player, + F.main(Plugin.getName(), "Server " + C.cGold + args[0] + + C.cGray + " does not exist!")); + return; + } + + boolean deniedAccess = false; + String servUp = args[0].toUpperCase(); + + if (servUp.contains("STAFF")) + { + if (!_commandCenter.GetClientManager().getPermissionManager().hasPermission(player, GroupPermission.of(Portal.JOIN_STAFF_PERMISSION))) + { + deniedAccess = true; + } + } + else if (servUp.startsWith("CLANS-")) + { + if (!_commandCenter.GetClientManager().getPermissionManager().hasPermission(player, GroupPermission.of(Portal.SERVER_COMMAND_CLANS_PERMISSION))) + { + UtilPlayer.message(player, F.main(Plugin.getName(), "Clans servers can only be joined via the Clans Hub!")); + return; + } + } + + if (deniedAccess) + { + UtilPlayer.message( + player, + F.main(Plugin.getName(), C.cRed + "You don't have permission to join " + C.cGold + args[0])); + } + else + { + Plugin.sendPlayerToServer(player, args[0], Intent.PLAYER_REQUEST); + } + }); + } + } + else + { + UtilPlayer.message(player, + F.main(Plugin.getName(), C.cRed + "Your arguments are inappropriate for this command!")); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/events/GenericServerTransferEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/events/GenericServerTransferEvent.java index b0b130e38..b4e8d1db8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/events/GenericServerTransferEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/events/GenericServerTransferEvent.java @@ -61,5 +61,4 @@ public class GenericServerTransferEvent extends Event implements Cancellable { return HANDLER_LIST; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/events/ServerTransferEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/events/ServerTransferEvent.java index cdc3d41e0..a8b5905a9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/events/ServerTransferEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/events/ServerTransferEvent.java @@ -60,5 +60,4 @@ public class ServerTransferEvent extends Event implements Cancellable { return HANDLER_LIST; } - -} +} \ 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 index 66c0f116c..f043bc622 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java @@ -1,12 +1,15 @@ 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; +import org.bukkit.Material; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import mineplex.core.account.permissions.GroupPermission; + /** * All ID's are assigned by enum order. *

@@ -19,7 +22,6 @@ import java.util.Map; */ public enum Preference { - HUB_GAMES(true, PreferenceCategory.USER, Material.FIREBALL, "Hub Games"), SHOW_PLAYERS(true, PreferenceCategory.USER, Material.EYE_OF_ENDER, "Hub Player Visibility"), SHOW_CHAT(true, PreferenceCategory.USER, Material.PAPER, "Player Chat"), @@ -108,6 +110,16 @@ public enum Preference { return _lore; } + + public GroupPermission getPermission() + { + return GroupPermission.of("mineplex.core.preferences." + getId()); + } + + public PreferenceCategory getCategory() + { + return _category; + } public static List getByCategory(PreferenceCategory category) { @@ -118,6 +130,4 @@ public enum Preference { return PREFERENCE_MAP.get(id); } - - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferenceCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferenceCategory.java index 1f870bd4e..3e84d139c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferenceCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferenceCategory.java @@ -10,7 +10,6 @@ import org.bukkit.inventory.ItemStack; */ public enum PreferenceCategory { - USER("User", Material.PAPER), EXCLUSIVE("Exclusive", Material.DIAMOND), GAME_PLAY("Game Mechanic", Material.REDSTONE_COMPARATOR), @@ -38,5 +37,4 @@ public enum PreferenceCategory { return _name; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java index 15a9d01ff..13ac102fd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java @@ -1,21 +1,13 @@ package mineplex.core.preferences; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.account.ILoginProcessor; -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 java.lang.reflect.Field; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -28,16 +20,31 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.plugin.java.JavaPlugin; -import java.lang.reflect.Field; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.ILoginProcessor; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; +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; public class PreferencesManager extends MiniPlugin implements ILoginProcessor { + public static final String VIEW_EXCLUSIVE_MENU_PERMISSION = "mineplex.core.preferences.exclusives"; + public static final String PREFERENCES_COMMAND_PERMISSION = "mineplex.core.preferences.command"; + private final PreferencesRepository _repository; private final CoreClientManager _clientManager; private final IncognitoManager _incognitoManager; @@ -58,6 +65,55 @@ public class PreferencesManager extends MiniPlugin implements ILoginProcessor _clientManager.addStoredProcedureLoginProcessor(this); addCommand(new PreferencesCommand(this)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + for (Preference p : Preference.values()) + { + if (p.getCategory() == PreferenceCategory.EXCLUSIVE) + { + if (p == Preference.INVISIBILITY) + { + pm.setPermission(pm.getGroup("admin"), p.getPermission(), true, true); + pm.setPermission(pm.getGroup("content"), p.getPermission(), true, true); + pm.setPermission(pm.getGroup("yt"), p.getPermission(), false, false); + } + else if (p == Preference.FORCE_FIELD) + { + pm.setPermission(pm.getGroup("content"), p.getPermission(), true, true); + pm.setPermission(pm.getGroup("eventmod"), p.getPermission(), false, true); + } + else if (p == Preference.GLOBAL_GWEN_REPORTS) + { + pm.setPermission(pm.getGroup("trainee"), p.getPermission(), true, true); + } + else if (p == Preference.SHOW_USER_REPORTS) + { + pm.setPermission(pm.getGroup("trainee"), p.getPermission(), true, true); + } + else if (p == Preference.IGNORE_VELOCITY) + { + pm.setPermission(pm.getGroup("builder"), p.getPermission(), true, true); + } + else + { + pm.setPermission(pm.getGroup("admin"), p.getPermission(), true, true); + } + } + else + { + pm.setPermission(pm.getGroup("player"), p.getPermission(), true, true); + } + } + + pm.setPermission(pm.getGroup("content"), GroupPermission.of(VIEW_EXCLUSIVE_MENU_PERMISSION), true, true); + pm.setPermission(pm.getGroup("builder"), GroupPermission.of(VIEW_EXCLUSIVE_MENU_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(PREFERENCES_COMMAND_PERMISSION), true, true); } @EventHandler @@ -85,7 +141,7 @@ public class PreferencesManager extends MiniPlugin implements ILoginProcessor return; } - if(_saveBuffer.isEmpty()) + if (_saveBuffer.isEmpty()) { return; } @@ -201,4 +257,4 @@ public class PreferencesManager extends MiniPlugin implements ILoginProcessor { return "SELECT * FROM `preferences` WHERE `accountId` = " + accountId + ";"; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java index a1b7c422e..52edf7fde 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java @@ -1,20 +1,18 @@ package mineplex.core.preferences; -import mineplex.core.database.MinecraftRepository; -import mineplex.core.progression.util.SQLStatement; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnInt; - import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +import mineplex.core.progression.util.SQLStatement; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; + public class PreferencesRepository extends RepositoryBase { - - 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 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; @@ -45,7 +43,8 @@ public class PreferencesRepository extends RepositoryBase .prepare(connection); executeUpdate(statement); } - } catch (SQLException e) + } + catch (SQLException e) { e.printStackTrace(); } @@ -84,7 +83,8 @@ public class PreferencesRepository extends RepositoryBase */ public void loadClientInformationAsync(int accountId) { - async(() -> { + async(() -> + { UserPreferences preferences = loadClientInformation(accountId); _manager.set(accountId, preferences); }); @@ -106,11 +106,13 @@ public class PreferencesRepository extends RepositoryBase try { return preparedStatement.executeUpdate(); - } catch (SQLException e) + } + catch (SQLException e) { e.printStackTrace(); return -1; - } finally + } + finally { try { @@ -118,10 +120,11 @@ public class PreferencesRepository extends RepositoryBase { preparedStatement.close(); } - } catch (SQLException e) + } + catch (SQLException e) { e.printStackTrace(); } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java index f54b38994..9a292b099 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/UserPreferences.java @@ -6,8 +6,7 @@ import java.util.Map; public class UserPreferences { - - private int _accountId; + private final int _accountId; private Map _preferences; public UserPreferences(int accountId) @@ -46,4 +45,4 @@ public class UserPreferences { return _accountId; } -} +} \ No newline at end of file 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 a1506b911..d95f3367b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java @@ -1,15 +1,15 @@ package mineplex.core.preferences.command; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.preferences.PreferencesManager; import org.bukkit.entity.Player; +import mineplex.core.command.CommandBase; +import mineplex.core.preferences.PreferencesManager; + public class PreferencesCommand extends CommandBase { public PreferencesCommand(PreferencesManager plugin) { - super(plugin, Rank.ALL, "prefs"); + super(plugin, PreferencesManager.PREFERENCES_COMMAND_PERMISSION, "prefs"); } @Override @@ -17,4 +17,4 @@ public class PreferencesCommand extends CommandBase { Plugin.openMenu(caller); } -} +} \ 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 index d8ee17525..ef0ab707b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java @@ -1,23 +1,24 @@ package mineplex.core.preferences.ui; +import java.util.List; + +import org.bukkit.entity.Player; + import com.google.common.collect.Lists; -import mineplex.core.common.Rank; + +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.UtilUI; 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; @@ -27,16 +28,14 @@ public class PreferenceMainMenu extends Menu } @Override - protected Button[] setUp(Player player) + protected Button[] setUp(Player player) { - Rank rank = getPlugin().getClientManager().Get(player).GetRank(); - boolean exclusive = rank.has(Rank.MAPDEV) || rank == Rank.YOUTUBE_SMALL || rank == Rank.YOUTUBE || rank == Rank.TWITCH; - - Button[] buttons = new Button[exclusive ? INV_SIZE_MAX : INV_SIZE_MIN]; + boolean exclusive = getPlugin().getClientManager().getPermissionManager().hasPermission(player, GroupPermission.of(PreferencesManager.VIEW_EXCLUSIVE_MENU_PERMISSION)); + Button[] buttons = new Button[exclusive ? INV_SIZE_MAX : INV_SIZE_MIN]; List list = Lists.newArrayList(PreferenceCategory.values()); - if(!exclusive) + if (!exclusive) { list.remove(PreferenceCategory.EXCLUSIVE); } @@ -45,7 +44,7 @@ public class PreferenceMainMenu extends Menu int size = list.size(); - for(int i = 0; i < size; i++) + for (int i = 0; i < size; i++) { int slot = slots[i]; PreferenceCategory category = list.get(i); @@ -54,5 +53,4 @@ public class PreferenceMainMenu extends Menu return pane(buttons); } - -} +} \ 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 index 4ae6d6491..29eb630a6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/BackButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/BackButton.java @@ -15,7 +15,6 @@ 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(); @@ -38,4 +37,4 @@ public class BackButton extends Button Menu.get(player.getUniqueId()).setUseClose(true); } -} +} \ No newline at end of file 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 index efcbc3770..9267b5da2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/CategoryButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/CategoryButton.java @@ -12,7 +12,6 @@ import org.bukkit.event.inventory.ClickType; */ public class CategoryButton extends Button { - private PreferenceCategory _category; public CategoryButton(PreferenceCategory category, PreferencesManager plugin) @@ -26,4 +25,4 @@ public class CategoryButton extends Button { new PreferenceMenu(_category, getPlugin()).open(player); } -} +} \ No newline at end of file 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 index fcec68213..17ca3853d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceButton.java @@ -20,7 +20,6 @@ import java.util.List; */ public class PreferenceButton extends Button { - protected final Preference _preference; protected final UserPreferences _user; private final ItemStack _disabled; @@ -74,6 +73,4 @@ public class PreferenceButton extends Button { return _user.isActive(_preference) ? _enabled : _disabled; } - - -} +} \ No newline at end of file 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 index 886091a16..fabb0568d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceDyeButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/buttons/PreferenceDyeButton.java @@ -14,7 +14,6 @@ import org.bukkit.inventory.ItemStack; */ public class PreferenceDyeButton extends PreferenceButton { - private final ItemStack _disabledDye; private final ItemStack _enabledDye; @@ -40,4 +39,4 @@ public class PreferenceDyeButton extends PreferenceButton { return _user.isActive(_preference) ? _enabledDye : _disabledDye; } -} +} \ No newline at end of file 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 index c077facb8..2945b6a01 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/menus/PreferenceMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/menus/PreferenceMenu.java @@ -1,7 +1,11 @@ package mineplex.core.preferences.ui.menus; +import java.util.List; + +import org.bukkit.entity.Player; + import com.google.common.collect.Lists; -import mineplex.core.common.Rank; + import mineplex.core.common.util.UtilUI; import mineplex.core.menu.Button; import mineplex.core.menu.Menu; @@ -12,16 +16,12 @@ 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; @@ -34,35 +34,14 @@ public class PreferenceMenu extends Menu } @Override - protected Button[] setUp(Player player) + protected Button[] setUp(Player player) { - Button[] buttons = new Button[INV_SIZE]; + Button[] buttons = new Button[INV_SIZE]; List preferences = Lists.newArrayList(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.HELPER) && !rank.has(Rank.ADMIN)) - { - preferences.remove(Preference.INVISIBILITY); - - if (rank != Rank.EVENT_MODERATOR) - preferences.remove(Preference.FORCE_FIELD); - } - else if (rank == Rank.YOUTUBE || rank == Rank.TWITCH) - { - preferences.remove(Preference.GLOBAL_GWEN_REPORTS); - preferences.remove(Preference.SHOW_USER_REPORTS); - } - else if (rank == Rank.YOUTUBE_SMALL) - { - preferences.remove(Preference.GLOBAL_GWEN_REPORTS); - preferences.remove(Preference.SHOW_USER_REPORTS); - preferences.remove(Preference.INVISIBILITY); - } - } + + preferences.removeIf(pref -> !getPlugin().getClientManager().getPermissionManager().hasPermission(player, pref.getPermission())); int[] slots = UtilUI.getIndicesFor(preferences.size(), 1, 4, 1); @@ -85,4 +64,4 @@ public class PreferenceMenu extends Menu remove(player.getUniqueId()); getPlugin().save(getPlugin().get(player)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java index 2b5ef2dbf..ba23432e7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java @@ -5,37 +5,27 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; - -import mineplex.core.account.CoreClient; -import mineplex.core.common.util.F; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.punish.Punish; -import mineplex.core.punish.Tokens.PunishClientToken; import mineplex.core.punish.UI.PunishPage; public class PunishCommand extends CommandBase { public PunishCommand(Punish plugin) { - super(plugin, Rank.HELPER, "punish", "p"); + super(plugin, Punish.PUNISHMENT_COMMAND_PERMISSION, "punish", "p"); } @Override public void Execute(final Player caller, String[] args) { - Rank playerRank = this.Plugin.GetClients().Get(caller).GetRank(); - if (playerRank == Rank.JNR_DEV || playerRank == Rank.DEVELOPER) - { - return; - } - if (args == null || args.length < 2) { Plugin.Help(caller); @@ -90,52 +80,42 @@ public class PunishCommand extends CommandBase String finalPlayerName = playerName; //Check repo - Plugin.GetRepository().MatchPlayerName(new Callback>() + Plugin.GetRepository().MatchPlayerName(matches -> { - public void run(List matches) + boolean matchedExact = false; + + for (String match : matches) { - boolean matchedExact = false; - - for (String match : matches) + if (match.equalsIgnoreCase(finalPlayerName)) { - if (match.equalsIgnoreCase(finalPlayerName)) - { - matchedExact = true; - } + matchedExact = true; } - - if (matchedExact) - { - for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext();) - { - if (!matchIterator.next().equalsIgnoreCase(finalPlayerName)) - { - matchIterator.remove(); - } - } - } - - UtilPlayer.searchOffline(matches, new Callback() - { - public void run(final String target) - { - if (target == null) - { - return; - } - - Plugin.GetRepository().LoadPunishClient(target, new Callback() - { - public void run(PunishClientToken clientToken) - { - Plugin.LoadClient(clientToken); - new PunishPage(Plugin, caller, target, finalReason, false, null, null); - } - }); - - } - }, caller, finalPlayerName, true); } + + if (matchedExact) + { + for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext();) + { + if (!matchIterator.next().equalsIgnoreCase(finalPlayerName)) + { + matchIterator.remove(); + } + } + } + + UtilPlayer.searchOffline(matches, t -> + { + if (t == null) + { + return; + } + + Plugin.GetRepository().LoadPunishClient(t, clientToken -> + { + Plugin.LoadClient(clientToken); + new PunishPage(Plugin, caller, t, finalReason, false, null, null); + }); + }, caller, finalPlayerName, true); }, playerName); } } @@ -145,4 +125,4 @@ public class PunishCommand extends CommandBase { return tabCompletePlayerNames(sender, args); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/RulesCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/RulesCommand.java index 7e043c09b..5beba0e02 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/RulesCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/RulesCommand.java @@ -3,19 +3,17 @@ package mineplex.core.punish.Command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.punish.Punish; public class RulesCommand extends CommandBase { - private static final String RULES_MESSAGE = "The rules can be found here:" + C.cGreen + " www.mineplex.com/rules"; public RulesCommand(Punish plugin) { - super(plugin, Rank.ALL, "rules"); + super(plugin, Punish.RULES_COMMAND_PERMISSION, "rules"); } @Override @@ -23,4 +21,4 @@ public class RulesCommand extends CommandBase { caller.sendMessage(F.main("Rules", RULES_MESSAGE)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java index d905ec7bd..698b0641b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java @@ -1,10 +1,12 @@ package mineplex.core.punish; import java.util.HashMap; +import java.util.Map; import java.util.function.Consumer; import java.util.logging.Level; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -23,8 +25,9 @@ import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.ClientWebResponseEvent; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.Constants; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -45,7 +48,12 @@ import mineplex.serverdata.commands.ServerCommandManager; public class Punish extends MiniPlugin { - private HashMap _punishClients; + public static final String ALERT_PUNISHMENT_PERMISSION = "mineplex.core.punish.alert"; + public static final String PUNISHMENT_COMMAND_PERMISSION = "mineplex.core.punish.command"; + public static final String FULL_PUNISHMENT_ACCESS_PERMISSION = "mineplex.core.punish.full"; + public static final String RULES_COMMAND_PERMISSION = "mineplex.core.punish.rules"; + + private Map _punishClients; private PunishRepository _repository; private CoreClientManager _clientManager; private ClansBanManager _clansPunish; @@ -59,12 +67,24 @@ public class Punish extends MiniPlugin { super("Punish", plugin); - _punishClients = new HashMap(); + _punishClients = new HashMap<>(); _clientManager = clientManager; _repository = new PunishRepository(); _clansPunish = new ClansBanManager(plugin, clientManager, clansServer); ServerCommandManager.getInstance().registerCommandType("PunishCommand", mineplex.serverdata.commands.PunishCommand.class, new PunishmentHandler(this)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(ALERT_PUNISHMENT_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(PUNISHMENT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(FULL_PUNISHMENT_ACCESS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(RULES_COMMAND_PERMISSION), true, true); } public ClansBanManager getClansPunish() @@ -176,7 +196,7 @@ public class Punish extends MiniPlugin public void Help(Player caller) { UtilPlayer.message(caller, F.main(_moduleName, "Commands List:")); - UtilPlayer.message(caller, F.help("/punish", " ", Rank.MODERATOR)); + UtilPlayer.message(caller, F.help("/punish", " ", ChatColor.GOLD)); } public void AddPunishment(final String playerName, final Category category, final String reason, final Player caller, final int severity, boolean ban, long duration) @@ -369,7 +389,7 @@ public class Punish extends MiniPlugin { for (Player player : UtilServer.getPlayers()) { - if (_clientManager.Get(player).GetRank().has(Rank.HELPER) || player.getName().equals(punishee)) + if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(ALERT_PUNISHMENT_PERMISSION)) || player.getName().equals(punishee)) { player.sendMessage(msg); } @@ -393,7 +413,7 @@ public class Punish extends MiniPlugin category = Category.valueOf(punishment.Category); punishmentType = PunishmentSentence.valueOf(punishment.Sentence); } - catch(IllegalArgumentException e) + catch (IllegalArgumentException e) { getPlugin().getLogger().log(Level.WARNING, "Skipping loading of punishment id " + punishment.PunishmentId + ", invalid category or punishment type."); continue; @@ -443,4 +463,4 @@ public class Punish extends MiniPlugin return n * (factorial(n-1)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java index 0886521c8..738a7a538 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import org.bukkit.ChatColor; @@ -15,16 +16,14 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; -import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.inventory.ItemStack; import mineplex.core.Managers; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.antihack.AntiHack; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.NautHashMap; @@ -62,7 +61,7 @@ public class PunishPage extends CraftInventoryCustom implements Listener super(null, 54, " Punish"); _plugin = plugin; - _buttonMap = new NautHashMap(); + _buttonMap = new NautHashMap<>(); _player = player; _target = target; @@ -84,18 +83,18 @@ public class PunishPage extends CraftInventoryCustom implements Listener PunishClient client = _plugin.GetClient(_target); - HashMap> offenseMap = new HashMap>(); + Map> offenseMap = new HashMap<>(); for (Category category : Category.values()) { //Initialise Offences - offenseMap.put(category, new HashMap()); + offenseMap.put(category, new HashMap<>()); offenseMap.get(category).put(1, 0); offenseMap.get(category).put(2, 0); offenseMap.get(category).put(3, 0); } - List> punishments = new ArrayList>(); + List> punishments = new ArrayList<>(); for (Category category : client.GetPunishments().keySet()) { @@ -105,7 +104,9 @@ public class PunishPage extends CraftInventoryCustom implements Listener //Count by Severity if (!punishment.GetRemoved() && punishment.GetSeverity() > 0 && punishment.GetSeverity() < 4) + { offenseMap.get(category).put(punishment.GetSeverity(), 1 + offenseMap.get(category).get(punishment.GetSeverity())); + } } } @@ -127,7 +128,8 @@ public class PunishPage extends CraftInventoryCustom implements Listener //XXX Mute { - AddButton(19, new ShopItem(Material.INK_SACK, (byte)2, "Severity 1", new String[] { + AddButton(19, new ShopItem(Material.INK_SACK, (byte)2, "Severity 1", new String[] + { ChatColor.RESET + "Past Offences: " + ChatColor.YELLOW + offenseMap.get(Category.ChatOffense).get(1), ChatColor.RESET + "Mute Duration: " + ChatColor.YELLOW + getDurationString(Category.ChatOffense, 1, offenseMap), " ", @@ -148,9 +150,10 @@ public class PunishPage extends CraftInventoryCustom implements Listener examplePrefixNote + "Give Warning if 0 Past Offences and 0 Warnings.", }, 1, false, true), new PunishButton(this, Category.ChatOffense, 1, false, getDuration(Category.ChatOffense, 1, offenseMap))); - if (_plugin.GetClients().Get(_player).GetRank().has(Rank.MODERATOR)) + if (_plugin.GetClients().getPermissionManager().hasPermission(_player, GroupPermission.of(Punish.FULL_PUNISHMENT_ACCESS_PERMISSION))) { - AddButton(28, new ShopItem(Material.INK_SACK, (byte)11, "Severity 2", new String[] { + AddButton(28, new ShopItem(Material.INK_SACK, (byte)11, "Severity 2", new String[] + { ChatColor.RESET + "Past Offences: " + ChatColor.YELLOW + offenseMap.get(Category.ChatOffense).get(2), ChatColor.RESET + "Mute Duration: " + ChatColor.YELLOW + getDurationString(Category.ChatOffense, 2, offenseMap), " ", @@ -169,7 +172,8 @@ public class PunishPage extends CraftInventoryCustom implements Listener examplePrefixEx + " 'F|_| - { - - }); + + AddButton(8, disguiseWarning, (player, clickType) -> {}); } Collections.sort(punishments, new PunishmentSorter()); @@ -357,58 +325,64 @@ public class PunishPage extends CraftInventoryCustom implements Listener for (Entry punishmentEntry : punishments) { if (punishmentEntry.getKey() == Category.Advertisement) + { continue; + } if (slot >= 54) + { break; + } ShopItem button = null; switch (punishmentEntry.getKey()) { - case ChatOffense: - button = _chatOffenseButton.clone(); - break; - case Exploiting: - button = _exploitingButton.clone(); - break; - case Hacking: - button = _hackingButton.clone(); - break; - case Warning: - button = _warningButton.clone(); - break; - case PermMute: - button = _permMuteButton.clone(); - break; - case ReportAbuse: - button = _permReportBanButton.clone(); - break; - case Other: - button = _permBanButton.clone(); - break; - default: - break; + case ChatOffense: + button = _chatOffenseButton.clone(); + break; + case Exploiting: + button = _exploitingButton.clone(); + break; + case Hacking: + button = _hackingButton.clone(); + break; + case Warning: + button = _warningButton.clone(); + break; + case PermMute: + button = _permMuteButton.clone(); + break; + case ReportAbuse: + button = _permReportBanButton.clone(); + break; + case Other: + button = _permBanButton.clone(); + break; + default: + break; } Punishment punishment = punishmentEntry.getValue(); //Reason Lines for LORE - ArrayList reasonLines = new ArrayList(); + List reasonLines = new ArrayList<>(); String reason = punishment.GetReason(); while (reason.length() > 0) { int index = Math.min(reason.length(), 24); while (index < reason.length() && reason.charAt(index) != ' ') + { index++; + } reasonLines.add(reason.substring(0, index)); reason = reason.substring(index, reason.length()); } //LORE - ArrayList output = new ArrayList(); + List output = new ArrayList<>(); output.add(C.cYellow + "Punishment Type: " + ChatColor.RESET + punishment.GetCategory().toString()); @@ -424,9 +398,13 @@ public class PunishPage extends CraftInventoryCustom implements Listener for (int i=0 ; i 0) && !punishment.GetRemoved() && punishment.GetActive()) { button.addUnsafeEnchantment(Enchantment.DURABILITY, 1); @@ -475,7 +452,9 @@ public class PunishPage extends CraftInventoryCustom implements Listener if (_buttonMap.containsKey(event.getRawSlot())) { if (event.getWhoClicked() instanceof Player) + { _buttonMap.get(event.getRawSlot()).onClick(((Player) event.getWhoClicked()), event.getClick()); + } } event.setCancelled(true); @@ -511,38 +490,36 @@ public class PunishPage extends CraftInventoryCustom implements Listener public void RemovePunishment(final Punishment punishment, final ItemStack item) { - _plugin.RemovePunishment(punishment, _target, _player, _reason, new Callback() - { - @Override - public void run(String result) - { - PunishmentResponse punishResponse = PunishmentResponse.valueOf(result); + _plugin.RemovePunishment(punishment, _target, _player, _reason, result -> + { + PunishmentResponse punishResponse = PunishmentResponse.valueOf(result); - if (punishResponse != PunishmentResponse.PunishmentRemoved) - { - _player.sendMessage(F.main(_plugin.getName(), "There was a problem removing the punishment.")); - } - else - { - punishment.Remove(_player.getName(), _reason); - _player.closeInventory(); - ClosePunish(); - } + if (punishResponse != PunishmentResponse.PunishmentRemoved) + { + _player.sendMessage(F.main(_plugin.getName(), "There was a problem removing the punishment.")); } - }); + else + { + punishment.Remove(_player.getName(), _reason); + _player.closeInventory(); + ClosePunish(); + } + }); } - public String getDurationString(Category category, int severity, HashMap> pastOffences) + public String getDurationString(Category category, int severity, Map> pastOffences) { int hours = getDuration(category, severity, pastOffences); if (hours == -1) + { return "Permanent"; + } return UtilTime.MakeStr((long)hours * 3600000L); } - public int getDuration(Category category, int severity, HashMap> pastOffences) + public int getDuration(Category category, int severity, Map> pastOffences) { if (category == Category.ChatOffense) { @@ -596,7 +573,9 @@ public class PunishPage extends CraftInventoryCustom implements Listener { //Permanent! if (pastOffences.get(category).get(2) > 0) + { return -1; + } hours = 720; } @@ -616,16 +595,20 @@ public class PunishPage extends CraftInventoryCustom implements Listener int amount = 0; if (zeroBase) + { baseAmount = 0; + } // At what point does Bonus > pastLimit int breakLimitCount = 0; while (baseAmount + addAmount * breakLimitCount * breakLimitCount < pastLimit) + { breakLimitCount++; + } amount += Math.min(baseAmount + addAmount * offenses * offenses, pastLimit); amount += Math.max(0, (offenses - breakLimitCount) * pastLimit); return amount; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java index f8940291b..a2e5fb8d4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/ClansBanManager.java @@ -13,7 +13,8 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -25,6 +26,9 @@ import mineplex.serverdata.commands.ServerCommandManager; public class ClansBanManager extends MiniPlugin { + public static final String ALERT_PUNISHMENT_PERMISSION = "mineplex.core.punish.clans.alert"; + public static final String PUNISHMENT_COMMAND_PERMISSION = "mineplex.core.punish.clans.command"; + private final CoreClientManager _clientManager; private final ClansBanRepository _repository; private final boolean _fullOperation; @@ -52,6 +56,21 @@ public class ClansBanManager extends MiniPlugin }); }); } + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(ALERT_PUNISHMENT_PERMISSION), true, true); + pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(ALERT_PUNISHMENT_PERMISSION), false, true); + pm.setPermission(pm.getGroup("cma"), GroupPermission.of(ALERT_PUNISHMENT_PERMISSION), false, true); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PUNISHMENT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(PUNISHMENT_COMMAND_PERMISSION), false, true); + pm.setPermission(pm.getGroup("cma"), GroupPermission.of(PUNISHMENT_COMMAND_PERMISSION), false, true); } @Override @@ -93,7 +112,7 @@ public class ClansBanManager extends MiniPlugin { for (Player notify : Bukkit.getOnlinePlayers()) { - if (_clientManager.Get(notify).GetRank().has(notify, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false)) + if (_clientManager.getPermissionManager().hasPermission(notify, GroupPermission.of(ALERT_PUNISHMENT_PERMISSION))) { UtilPlayer.message(notify, F.main(getName(), F.elem(targetName) + " is now banned " + banTimeFormatted + ".")); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/command/ClansBanCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/command/ClansBanCommand.java index 7daa6e7d7..415ef3ac3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/command/ClansBanCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/clans/command/ClansBanCommand.java @@ -3,7 +3,6 @@ package mineplex.core.punish.clans.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; import mineplex.core.punish.clans.ClansBanManager; @@ -13,7 +12,7 @@ public class ClansBanCommand extends CommandBase { public ClansBanCommand(ClansBanManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "cbans", "cb", "cban", "cp", "cpunish", "clanspunish", "clanpunish"); + super(plugin, ClansBanManager.PUNISHMENT_COMMAND_PERMISSION, "cbans", "cb", "cban", "cp", "cpunish", "clanspunish", "clanpunish"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java index d5a24a69e..21383c468 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/Quest.java @@ -12,8 +12,6 @@ import mineplex.core.game.GameDisplay; */ public class Quest { - private static final Object _progressLock = new Object(); - private int _questID; private String _questName; @@ -139,36 +137,24 @@ public class Quest _current = progress; } - public void increment(int value) + public synchronized void increment(int value) { - synchronized (_progressLock) - { - _current += value; - } + _current += value; } - public void increment() + public synchronized void increment() { - synchronized (_progressLock) - { - _current++; - } + _current++; } - public void decrement(int value) + public synchronized void decrement(int value) { - synchronized (_progressLock) - { - _current -= value; - } + _current -= value; } - public void decrement() + public synchronized void decrement() { - synchronized (_progressLock) - { - _current--; - } + _current--; } public boolean isCompleted() @@ -235,6 +221,5 @@ public class Quest public Quest clone() { return new Quest(_questID, _questName, _questTask, _questCost, _questReward, _rarity, _type, _trigger, _item, _statToComplete); - } - -} + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java index 26741b195..61c78d994 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -1,16 +1,17 @@ package mineplex.core.quests; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.function.Consumer; -import net.md_5.bungee.api.ChatColor; - -import org.apache.commons.lang3.tuple.Triple; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -19,14 +20,12 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import mineplex.core.MiniClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Pair; +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -41,6 +40,7 @@ import mineplex.core.npc.NpcManager; import mineplex.core.quests.command.GetQuestCommand; import mineplex.core.quests.command.IncrementQuestCommand; import mineplex.core.quests.command.OpenGuiCommand; +import mineplex.core.quests.repository.QuestData; import mineplex.core.quests.repository.QuestRepository; import mineplex.core.quests.shop.QuestShop; import mineplex.core.stats.StatsManager; @@ -51,14 +51,19 @@ import mineplex.quest.common.QuestSupplier; import mineplex.serverdata.redis.messaging.PubSubJedisClient; import mineplex.serverdata.redis.messaging.PubSubRouter; import mineplex.serverdata.servers.ServerManager; +import net.md_5.bungee.api.ChatColor; /** * QuestManager * * @author xXVevzZXx */ -public class QuestManager extends MiniClientPlugin +public class QuestManager extends MiniDbClientPlugin { + public static final String GET_QUEST_COMMAND_PERMISSION = "mineplex.core.quests.get"; + public static final String INCREMENT_QUEST_COMMAND_PERMISSION = "mineplex.core.quests.increment"; + public static final String QUEST_GUI_COMMAND_PERMISSION = "mineplex.core.quests.gui"; + public static final String QUEST_NAME = "Mineplex Mission"; private static final String GOOGLE_SHEET = "QUESTS_SHEET"; @@ -66,11 +71,10 @@ public class QuestManager extends MiniClientPlugin private QuestRepository _repository; private GoogleSheetsManager _sheetsManager; - private CoreClientManager _clients; private DonationManager _donationManager; private InventoryManager _inventoryManager; - public ArrayList _availableQuests; + public List _availableQuests; private QuestSupplier _questSupplier = new RedisQuestSupplier(getPlugin(), new PubSubRouter(new PubSubJedisClient(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection()))); @@ -81,12 +85,10 @@ public class QuestManager extends MiniClientPlugin public QuestManager(HologramManager hologramManager, Location npc, InventoryManager inventoryManager, DonationManager donationManager) { - super("Quest Manager"); + super("Quest Manager", hologramManager.getPlugin(), donationManager.getClientManager()); _repository = new QuestRepository(); _sheetsManager = require(GoogleSheetsManager.class); - _clients = require(CoreClientManager.class); - _availableQuests = new ArrayList<>(); _donationManager = donationManager; _inventoryManager = inventoryManager; _hologramManager = hologramManager; @@ -104,10 +106,21 @@ public class QuestManager extends MiniClientPlugin slime.setSize(3); if (npc != null) { - _questNPC.setLocation(npc); + _questNPC.setLocation(npc); } _enableNPC = true; } + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GET_QUEST_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(INCREMENT_QUEST_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(QUEST_GUI_COMMAND_PERMISSION), true, true); } @EventHandler @@ -127,8 +140,6 @@ public class QuestManager extends MiniClientPlugin _visualTick = !_visualTick; } - - public void updateSlimeVisual(Player player , String rewardPrefix) { @@ -158,7 +169,7 @@ public class QuestManager extends MiniClientPlugin if (client.getHologram() == null) { double yAdd = 2.3; - if(!UtilPlayer.is1_9(player)) + if (!UtilPlayer.is1_9(player)) { yAdd = 2.45; } @@ -194,15 +205,17 @@ public class QuestManager extends MiniClientPlugin addCommand(new IncrementQuestCommand(this)); } - public void setupQuests() + private void setupQuests() { - _availableQuests.clear(); + List quests = new ArrayList<>(); Map>> sheet = _sheetsManager.getSheetData(GOOGLE_SHEET); List> table = new ArrayList<>(); for (String key : sheet.keySet()) { if (key.equalsIgnoreCase(GOOGLE_TABLE)) + { table = sheet.get(key); + } } int size = table.size(); @@ -220,7 +233,7 @@ public class QuestManager extends MiniClientPlugin String item = table.get(i).get(8); String rarity = table.get(i).get(9); - _availableQuests.add(new Quest(Integer.parseInt(id), name, task, + quests.add(new Quest(Integer.parseInt(id), name, task, Integer.parseInt(cost), reward, QuestRarity.getByName(rarity), @@ -228,6 +241,8 @@ public class QuestManager extends MiniClientPlugin TriggerType.getByName(trigger), item.split(","), Integer.parseInt(statcompletion))); + + _availableQuests = Collections.unmodifiableList(quests); } } @@ -240,7 +255,7 @@ public class QuestManager extends MiniClientPlugin Entity entity = event.getRightClicked(); if (entity.equals(_questNPC.getEntity())) { - new QuestShop(this, _clients, _donationManager).attemptShopOpen(event.getPlayer()); + new QuestShop(this, getClientManager(), _donationManager).attemptShopOpen(event.getPlayer()); } } @@ -255,49 +270,19 @@ public class QuestManager extends MiniClientPlugin Player player = (Player) event.getDamager(); if (event.getEntity().equals(_questNPC.getEntity())) { - new QuestShop(this, _clients, _donationManager).attemptShopOpen(player); + new QuestShop(this, getClientManager(), _donationManager).attemptShopOpen(player); } } } - @EventHandler - public void playerJoin(PlayerJoinEvent event) - { - QuestClientData questData = Get(event.getPlayer()); - _repository.getQuests(_clients.Get(event.getPlayer()), new Callback>>>() - { - @Override - public void run(ArrayList>> data) - { - for (Pair> pair : data) - { - int id = pair.getLeft(); - int value = pair.getRight().getLeft(); - long time = pair.getRight().getMiddle(); - int timesCompleted = pair.getRight().getRight(); - - for (Quest quest : _availableQuests) - { - if (quest.getID() == id) - { - Quest clone = quest.clone(); - clone.setProgress(value); - clone.setLastCompleted(time); - clone.setTimesCompleted(timesCompleted); - questData.addQuest(clone); - } - } - } - } - }); - } - public Quest getQuestByID(int id) { - for (Quest quest : _availableQuests) + for (Quest quest : getAvailableQuests()) { if (quest.getID() == id) + { return quest; + } } return null; } @@ -310,7 +295,7 @@ public class QuestManager extends MiniClientPlugin if (other.getID() == quest.getID()) { other.setProgress(0); - _repository.addQuest(_clients.Get(player), other); + _repository.addQuest(getClientManager().Get(player).getAccountId(), other.getID()); return; } } @@ -318,7 +303,7 @@ public class QuestManager extends MiniClientPlugin Quest clone = quest.clone(); clone.setProgress(0); Get(player).addQuest(clone); - _repository.addNew(_clients.Get(player), quest); + _repository.addNew(getClientManager().Get(player).getAccountId(), quest.getID()); } public void resetQuest(Player player, Quest quest, boolean completed) @@ -330,7 +315,7 @@ public class QuestManager extends MiniClientPlugin } Get(player).removeQuest(quest.getID()); - _repository.resetQuest(_clients.Get(player), quest, completed); + _repository.resetQuest(getClientManager().Get(player).getAccountId(), quest.getID(), completed); } public void incrementQuest(Player player, Quest quest, int value) @@ -340,7 +325,7 @@ public class QuestManager extends MiniClientPlugin { UtilPlayer.message(player, F.main(QUEST_NAME, "You have completed the " + QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName())); } - _repository.incrementQuest(_clients.Get(player), quest, value); + _repository.incrementQuest(getClientManager().Get(player).getAccountId(), quest.getID(), value); } public Set getCurrentQuests() @@ -381,11 +366,6 @@ public class QuestManager extends MiniClientPlugin UtilPlayer.message(player, F.main(QUEST_NAME, "You have recieved " + color + quest.getRewardAmount() + " " + quest.getRewardName() + " " + ChatColor.GRAY + "for completing: " + ChatColor.YELLOW + quest.getName())); } } - - public CoreClientManager getClients() - { - return _clients; - } public DonationManager getDonations() { @@ -403,14 +383,60 @@ public class QuestManager extends MiniClientPlugin return new QuestClientData(); } + @SuppressWarnings("deprecation") @Override public void saveData(String name, int accountId) { Get(name).getHologram().stop(); } - public ArrayList getAvailableQuests() + public List getAvailableQuests() { return _availableQuests; } -} + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT questId, progress, questCompletion, lastCompleted FROM accountQuest WHERE accountId=" + accountId + ";"; + } + + @Override + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException + { + final Set retrieved = new HashSet<>(); + + while (resultSet.next()) + { + final int id = resultSet.getInt("questId"); + final int progress = resultSet.getInt("progress"); + final int timesCompleted = resultSet.getInt("questCompletion"); + final long lastCompleted = resultSet.getLong("lastCompleted"); + + retrieved.add(new QuestData(id, progress, timesCompleted, lastCompleted)); + } + + final QuestClientData questData = Get(uuid); + + if (!retrieved.isEmpty()) + { + runSync(() -> + { + retrieved.forEach(data -> + { + Optional match = getAvailableQuests().stream().filter(quest -> quest.getID() == data.QuestId).findAny(); + + if (match.isPresent()) + { + Quest clone = match.get().clone(); + clone.setProgress(data.QuestProgress); + clone.setLastCompleted(data.LastCompleted); + clone.setTimesCompleted(data.TimesCompleted); + + questData.addQuest(clone); + } + }); + }); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java index 414ac6b48..ba8b6028b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java @@ -1,12 +1,12 @@ package mineplex.core.quests.command; import java.util.ArrayList; +import java.util.List; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -22,7 +22,7 @@ public class GetQuestCommand extends CommandBase { public GetQuestCommand(QuestManager plugin) { - super(plugin, Rank.ADMIN, "GetMineplexMission"); + super(plugin, QuestManager.GET_QUEST_COMMAND_PERMISSION, "GetMineplexMission"); } @Override @@ -40,7 +40,7 @@ public class GetQuestCommand extends CommandBase return; } - ArrayList players = new ArrayList<>(); + List players = new ArrayList<>(); if (args.length == 2) { if (UtilPlayer.searchExact(args[1]) != null) @@ -66,12 +66,13 @@ public class GetQuestCommand extends CommandBase { Plugin.addNewQuest(player, quest); UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Added " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName())); - if (!args[1].equalsIgnoreCase("all")) { if (caller != players.get(0)) + { UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + player.getName())); + } } } @@ -80,4 +81,4 @@ public class GetQuestCommand extends CommandBase UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + "everyone")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/IncrementQuestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/IncrementQuestCommand.java index 0ebb57fb3..0c659c4f7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/IncrementQuestCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/IncrementQuestCommand.java @@ -4,7 +4,6 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.quests.Quest; @@ -19,7 +18,7 @@ public class IncrementQuestCommand extends CommandBase { public IncrementQuestCommand(QuestManager plugin) { - super(plugin, Rank.ADMIN, "IncrementMineplexMission"); + super(plugin, QuestManager.INCREMENT_QUEST_COMMAND_PERMISSION, "IncrementMineplexMission"); } @Override @@ -61,7 +60,8 @@ public class IncrementQuestCommand extends CommandBase UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Incremented " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " by " + increment)); if (caller != player) + { UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You incremented the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " for " + ChatColor.YELLOW + player.getName() + ChatColor.GRAY + " by " + increment)); + } } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java index df0f68f2c..3ddce78fc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java @@ -3,7 +3,6 @@ package mineplex.core.quests.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.quests.QuestManager; import mineplex.core.quests.shop.QuestShop; @@ -16,12 +15,12 @@ public class OpenGuiCommand extends CommandBase { public OpenGuiCommand(QuestManager plugin) { - super(plugin, Rank.ALL, "Missions"); + super(plugin, QuestManager.QUEST_GUI_COMMAND_PERMISSION, "Missions"); } @Override public void Execute(Player caller, String[] args) { - new QuestShop(Plugin, Plugin.getClients(), Plugin.getDonations()).attemptShopOpen(caller); + new QuestShop(Plugin, Plugin.getClientManager(), Plugin.getDonations()).attemptShopOpen(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestData.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestData.java new file mode 100644 index 000000000..f41f1675a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestData.java @@ -0,0 +1,36 @@ +package mineplex.core.quests.repository; + +public class QuestData +{ + public final int QuestId; + public final int QuestProgress; + public final int TimesCompleted; + public final long LastCompleted; + + public QuestData(int questId, int questProgress, int timesCompleted, long lastCompleted) + { + QuestId = questId; + QuestProgress = questProgress; + TimesCompleted = timesCompleted; + LastCompleted = lastCompleted; + } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof QuestData) + { + return ((QuestData)obj).QuestId == QuestId; + } + else + { + return false; + } + } + + @Override + public int hashCode() + { + return QuestId; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java index 4592781c1..09e2fb6b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/repository/QuestRepository.java @@ -1,19 +1,8 @@ package mineplex.core.quests.repository; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; - -import org.apache.commons.lang3.tuple.Triple; - -import mineplex.core.account.CoreClient; -import mineplex.core.common.Pair; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.UtilServer; -import mineplex.core.quests.Quest; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.ResultSetCallable; import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnLong; @@ -24,14 +13,12 @@ import mineplex.serverdata.database.column.ColumnLong; */ public class QuestRepository extends RepositoryBase { - private static final String INSTERT_NEW_QUEST = "INSERT INTO accountQuest (accountId, questId, progress, questCompletion, lastCompleted) VALUES (?, ?, ?, ?, ?);"; + private static final String INSERT_NEW_QUEST = "INSERT INTO accountQuest (accountId, questId, progress, questCompletion, lastCompleted) VALUES (?, ?, ?, ?, ?);"; private static final String INCREMENT_QUEST = "UPDATE accountQuest SET progress=progress+? WHERE accountId=? AND questId=?;"; private static final String RESET_QUEST = "UPDATE accountQuest SET progress=-1 WHERE accountId=? AND questId=?;"; private static final String START_QUEST = "UPDATE accountQuest SET progress=0 WHERE accountId=? AND questId=?;"; private static final String COMPLETE_QUEST = "UPDATE accountQuest SET progress=-1, questCompletion=questCompletion+1, lastCompleted=? WHERE accountId=? AND questId=?;"; - private static final String FETCH_QUESTS = "SELECT questId, progress, questCompletion, lastCompleted FROM accountQuest WHERE accountId=?"; - public String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS accountQuest (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, questId INT NOT NULL, progress INT, questCompletion INT, lastCompleted BIGINT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts (id), UNIQUE INDEX questIndex (accountId, questId), INDEX progressIndex (progress), INDEX completionIndex (questCompletion));"; public QuestRepository() @@ -43,98 +30,53 @@ public class QuestRepository extends RepositoryBase public void createTable() { - UtilServer.runAsync(new Runnable() + UtilServer.runAsync(() -> { - @Override - public void run() + executeUpdate(CREATE_TABLE); + }); + } + + public void resetQuest(int accountId, int questId, boolean completed) + { + UtilServer.runAsync(() -> + { + if (completed) { - executeUpdate(CREATE_TABLE); + executeUpdate(COMPLETE_QUEST, new ColumnLong("lastCompleted", System.currentTimeMillis()), new ColumnInt("accountId", accountId), new ColumnInt("questId", questId)); + } + else + { + executeUpdate(RESET_QUEST, new ColumnInt("accountId", accountId), new ColumnInt("questId", questId)); } }); } - public void getQuests(CoreClient client, Callback>>> callback) + public void addQuest(int accountId, int questId) { - UtilServer.runAsync(new Runnable() + UtilServer.runAsync(() -> { - @Override - public void run() - { - executeQuery(FETCH_QUESTS, new ResultSetCallable() - { - @Override - public void processResultSet(ResultSet resultSet) throws SQLException - { - ArrayList>> list = new ArrayList<>(); - while (resultSet.next()) - { - list.add(Pair.create(resultSet.getInt(1), Triple.of(resultSet.getInt(2), resultSet.getLong(4), resultSet.getInt(3)))); - } - callback.run(list); - } - } ,new ColumnInt("accountId", client.getAccountId())); - } + executeUpdate(START_QUEST, new ColumnInt("accountId", accountId), new ColumnInt("questId", questId)); }); } - public void resetQuest(CoreClient client, Quest quest, boolean completed) + public void addNew(int accountId, int questId) { - UtilServer.runAsync(new Runnable() + UtilServer.runAsync(() -> { - @Override - public void run() - { - if (completed) - { - executeUpdate(COMPLETE_QUEST, new ColumnLong("lastCompleted", System.currentTimeMillis()), new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); - } - else - { - executeUpdate(RESET_QUEST, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); - } - } + executeInsert(INSERT_NEW_QUEST, null, + new ColumnInt("accountId", accountId), + new ColumnInt("questId", questId), + new ColumnInt("progress", 0), + new ColumnInt("questCompletion", 0), + new ColumnLong("lastCompleted", (long) 0)); }); } - public void addQuest(CoreClient client, Quest quest) + public void incrementQuest(int accountId, int questId, int value) { - UtilServer.runAsync(new Runnable() + UtilServer.runAsync(() -> { - @Override - public void run() - { - executeUpdate(START_QUEST, new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); - } + executeUpdate(INCREMENT_QUEST, new ColumnInt("progress", value), new ColumnInt("accountId", accountId), new ColumnInt("questId", questId)); }); } - - public void addNew(CoreClient client, Quest quest) - { - UtilServer.runAsync(new Runnable() - { - @Override - public void run() - { - executeInsert(INSTERT_NEW_QUEST, null, - new ColumnInt("accountId", client.getAccountId()), - new ColumnInt("questId", quest.getID()), - new ColumnInt("progress", 0), - new ColumnInt("questCompletion", 0), - new ColumnLong("lastCompleted", (long) 0)); - } - }); - } - - public void incrementQuest(CoreClient client, Quest quest, int value) - { - UtilServer.runAsync(new Runnable() - { - @Override - public void run() - { - executeUpdate(INCREMENT_QUEST, new ColumnInt("progress", value), new ColumnInt("accountId", client.getAccountId()), new ColumnInt("questId", quest.getID())); - } - }); - } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java index b1f70eea1..8cd9f3de6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/BuyQuestButton.java @@ -1,7 +1,5 @@ package mineplex.core.quests.shop; -import net.md_5.bungee.api.ChatColor; - import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -19,6 +17,7 @@ import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.SalesPackageProcessor; +import net.md_5.bungee.api.ChatColor; /** * BuyQuestButton @@ -84,10 +83,8 @@ public class BuyQuestButton implements IButton _questManager.addNewQuest(player, _quest); UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "You have bought: " + ChatColor.YELLOW + _quest.getName())); player.closeInventory(); - new QuestShop(_questManager, _questManager.getClients(), _questManager.getDonations()).attemptShopOpen(player); + new QuestShop(_questManager, _questManager.getClientManager(), _questManager.getDonations()).attemptShopOpen(player); - }), salesPackage.buildIcon())); - + }), salesPackage.buildIcon())); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java index 8dd619e51..0bb65ddf6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/QuestPage.java @@ -1,6 +1,5 @@ package mineplex.core.quests.shop; -import java.util.ArrayList; import java.util.Arrays; import org.apache.commons.lang3.ArrayUtils; @@ -110,7 +109,7 @@ public class QuestPage extends ShopPageBase public void onClick(Player player, ClickType clickType) { player.closeInventory(); - new QuestStatShop(_manager, _manager.getClients(), _manager.getDonations()).attemptShopOpen(player); + new QuestStatShop(_manager, _manager.getClientManager(), _manager.getDonations()).attemptShopOpen(player); } }); @@ -152,5 +151,4 @@ public class QuestPage extends ShopPageBase { return _questShop; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java index 19bbef7d9..d25fd5a5c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/shop/RedeemDeclineQuestButton.java @@ -2,20 +2,13 @@ package mineplex.core.quests.shop; import java.util.function.Consumer; -import javax.jws.Oneway; - -import net.md_5.bungee.api.ChatColor; - -import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; -import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.donation.DonationManager; -import mineplex.core.inventory.InventoryManager; import mineplex.core.quests.Quest; import mineplex.core.quests.QuestManager; import mineplex.core.quests.event.QuestInteractEvent; @@ -96,6 +89,6 @@ public class RedeemDeclineQuestButton implements IButton } player.closeInventory(); - new QuestShop(_questManager, _questManager.getClients(), _donations).attemptShopOpen(player); + new QuestShop(_questManager, _questManager.getClientManager(), _donations).attemptShopOpen(player); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalCommand.java index 182b19556..7e257b6e4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalCommand.java @@ -5,7 +5,6 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -13,7 +12,7 @@ public class EternalCommand extends CommandBase { public EternalCommand(EternalGiveawayManager plugin) { - super(plugin, Rank.OWNER, "eternaltest"); + super(plugin, EternalGiveawayManager.ETERNAL_COMMAND_PERMISSION, "eternaltest"); } @Override @@ -43,4 +42,4 @@ public class EternalCommand extends CommandBase }); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayAnimation.java index f933a5acc..9ca3a33b5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayAnimation.java @@ -58,4 +58,4 @@ public class EternalGiveawayAnimation implements Listener { HandlerList.unregisterAll(this); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayManager.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayManager.java index ad0ac15ba..fc0a3949f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayManager.java @@ -7,8 +7,9 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.rankGiveaway.redis.EternalGiveawayMessage; import mineplex.core.rankGiveaway.redis.GiveawayMessageHandler; import mineplex.core.status.ServerStatusManager; @@ -17,9 +18,12 @@ import mineplex.serverdata.commands.ServerCommandManager; public class EternalGiveawayManager extends MiniPlugin { - + public static final String ETERNAL_COMMAND_PERMISSION = "mineplex.core.rankGiveaway.eternal.command"; + private static final double RANK_FIND_CHANCE = 0.001; - + + private final PermissionGroup _group; + private EternalGiveawayRepository _repository; private CoreClientManager _clientManager; private ServerStatusManager _statusManager; @@ -33,8 +37,19 @@ public class EternalGiveawayManager extends MiniPlugin _clientManager = clientManager; _statusManager = statusManager; _random = new Random(); + + _group = _clientManager.getPermissionManager().getGroup("eternal"); ServerCommandManager.getInstance().registerCommandType("EternalGiveawayMessage", EternalGiveawayMessage.class, new GiveawayMessageHandler(plugin)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("lt"), GroupPermission.of(ETERNAL_COMMAND_PERMISSION), true, true); } @Override @@ -67,15 +82,15 @@ public class EternalGiveawayManager extends MiniPlugin if (pass && _repository.addEternal(accountId, region, serverName)) { - runSync(() -> giveRank(rank -> + runSync(() -> giveRank(player, () -> { - if (rank == Rank.ETERNAL) + EternalGiveawayMessage message = new EternalGiveawayMessage(player.getName(), _repository.getEternalCount() + 1); + message.publish(); + if (onSuccess != null) { - EternalGiveawayMessage message = new EternalGiveawayMessage(player.getName(), _repository.getEternalCount() + 1); - message.publish(); - if (onSuccess != null) onSuccess.run(); + onSuccess.run(); } - }, Rank.ETERNAL, player)); + })); } }); } @@ -85,7 +100,7 @@ public class EternalGiveawayManager extends MiniPlugin */ private boolean hasEternal(Player player) { - return _clientManager.hasRank(player, Rank.ETERNAL); + return _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _group); } public Region getRegion() @@ -98,9 +113,8 @@ public class EternalGiveawayManager extends MiniPlugin return _statusManager.getCurrentServerName(); } - private void giveRank(Callback callback, Rank rank, Player player) + private void giveRank(Player player, Runnable after) { - _clientManager.Get(player).SetRank(rank, false); - _clientManager.getRepository().saveRank(callback, player.getName(), player.getUniqueId(), rank, true); + _clientManager.setPrimaryGroup(player, _group, after); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayRepository.java index 867d5d5c6..c913a46a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayRepository.java @@ -69,4 +69,4 @@ public class EternalGiveawayRepository extends RepositoryBase { return _eternalCount; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayAnimation.java index 1ce6c4b8d..766bce45c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayAnimation.java @@ -61,4 +61,4 @@ public class TitanGiveawayAnimation implements Listener // _location.getWorld().setTime(_worldTime); HandlerList.unregisterAll(this); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java index 93fe89cab..943e5021d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java @@ -7,21 +7,21 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; -import mineplex.core.status.ServerStatusManager; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.rankGiveaway.redis.GiveawayMessageHandler; import mineplex.core.rankGiveaway.redis.TitanChestGiveawayHandler; import mineplex.core.rankGiveaway.redis.TitanChestGiveawayMessage; import mineplex.core.rankGiveaway.redis.TitanGiveawayMessage; +import mineplex.core.status.ServerStatusManager; import mineplex.serverdata.Region; import mineplex.serverdata.commands.ServerCommandManager; public class TitanGiveawayManager extends MiniPlugin { - private static final double RANK_FIND_CHANCE = 0.001; - + + private final PermissionGroup _group; + private TitanGiveawayRepository _repository; private CoreClientManager _clientManager; private ServerStatusManager _statusManager; @@ -35,6 +35,8 @@ public class TitanGiveawayManager extends MiniPlugin _clientManager = clientManager; _statusManager = statusManager; _random = new Random(); + + _group = _clientManager.getPermissionManager().getGroup("titan"); ServerCommandManager.getInstance().registerCommandType("TitanGiveawayMessage", TitanGiveawayMessage.class, new GiveawayMessageHandler(plugin)); ServerCommandManager.getInstance().registerCommandType("TitanChestGiveawayMessage", TitanChestGiveawayMessage.class, new TitanChestGiveawayHandler(_statusManager)); @@ -50,36 +52,25 @@ public class TitanGiveawayManager extends MiniPlugin final String serverName = getServerName(); // Need to check database that we can give away a rank - runAsync(new Runnable() + runAsync(() -> { - @Override - public void run() - { - final boolean pass = _repository.canGiveaway(region); + final boolean pass = _repository.canGiveaway(region); - if (pass && _repository.addTitan(accountId, region, serverName)) + if (pass && _repository.addTitan(accountId, region, serverName)) + { + runSync(() -> { - runSync(new Runnable() + giveRank(player, () -> { - @Override - public void run() + TitanGiveawayMessage message = new TitanGiveawayMessage(player.getName(), _repository.getTitanCount() + 1); + message.publish(); + if (onSuccess != null) { - giveRank(new Callback() - { - @Override - public void run(Rank rank) - { - if (rank == Rank.TITAN) - { - TitanGiveawayMessage message = new TitanGiveawayMessage(player.getName(), _repository.getTitanCount() + 1); - message.publish(); - if (onSuccess != null) onSuccess.run(); - } - } - }, Rank.TITAN, player); + onSuccess.run(); } }); - } + + }); } }); } @@ -90,7 +81,7 @@ public class TitanGiveawayManager extends MiniPlugin */ private boolean hasTitan(Player player) { - return _clientManager.hasRank(player, Rank.TITAN); + return _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _group); } public Region getRegion() @@ -103,27 +94,8 @@ public class TitanGiveawayManager extends MiniPlugin return _statusManager.getCurrentServerName(); } - private void giveRank(Callback callback, Rank rank, Player player) + private void giveRank(Player player, Runnable after) { - _clientManager.Get(player).SetRank(rank, false); - _clientManager.getRepository().saveRank(callback, player.getName(), player.getUniqueId(), rank, true); + _clientManager.setPrimaryGroup(player, _group, after); } - -// @EventHandler -// public void onCommand(final PlayerCommandPreprocessEvent event) -// { -// if (event.getMessage().contains("pumpkin")) -// { -// openPumpkin(event.getPlayer(), new Runnable() -// { -// @Override -// public void run() -// { -// Location location = event.getPlayer().getLocation().add(1, 0.5, 1); -// new TitanGiveawayAnimation(TitanGiveawayManager.this, location, 3000L); -// } -// }); -// event.setCancelled(true); -// } -// } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayRepository.java index bc8201eae..2533add45 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayRepository.java @@ -4,14 +4,13 @@ import java.sql.CallableStatement; import java.sql.Connection; import java.sql.Types; -import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.serverdata.Region; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnVarChar; -import mineplex.serverdata.Region; public class TitanGiveawayRepository extends RepositoryBase { @@ -56,4 +55,4 @@ public class TitanGiveawayRepository extends RepositoryBase { return _titanCount; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index eabff2edb..750436645 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -18,6 +18,8 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.chatsnap.SnapshotManager; import mineplex.core.chatsnap.SnapshotMetadata; import mineplex.core.chatsnap.redis.PushSnapshotsCommand; @@ -51,6 +53,13 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class ReportManager { + public static final String REPORT_CLOSE_COMMAND_PERMISSION = "mineplex.core.report.close"; + public static final String REPORT_COMMAND_PERMISSION = "mineplex.core.report.command"; + public static final String REPORT_HANDLE_COMMAND_PERMISSION = "mineplex.core.report.handle"; + public static final String REPORT_HISTORY_COMMAND_PERMISSION = "mineplex.core.report.history"; + public static final String REPORT_INFO_COMMAND_PERMISSION = "mineplex.core.report.info"; + public static final String REPORT_METRICS_COMMAND_PERMISSION = "mineplex.core.report.metrics"; + private static final String NAME = "Report"; private static final int INITIAL_PRIORITY = 15; private static final int ABUSE_BAN_THRESHOLD = 3; @@ -91,6 +100,20 @@ public class ReportManager commandManager.registerCommandType("HandlerNotification", HandlerNotification.class, notificationCallback); commandManager.registerCommandType("ReportersNotification", ReportersNotification.class, notificationCallback); commandManager.registerCommandType("PushSnapshotsCommand", PushSnapshotsCommand.class, pushHandler); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(REPORT_CLOSE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("titan"), GroupPermission.of(REPORT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(REPORT_HANDLE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(REPORT_HISTORY_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(REPORT_INFO_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(REPORT_METRICS_COMMAND_PERMISSION), true, true); } public SnapshotManager getSnapshotManager() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java index a37718c7e..79cef76fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportPlugin.java @@ -53,4 +53,4 @@ public class ReportPlugin extends MiniPlugin { _manager.onPlayerQuit(e.getPlayer()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java index 35c6fef1e..cea39dace 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java @@ -5,7 +5,6 @@ import java.util.logging.Level; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.BukkitFuture; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -22,7 +21,7 @@ public class ReportCloseCommand extends CommandBase { public ReportCloseCommand(ReportPlugin plugin) { - super(plugin, Rank.MODERATOR, "reportclose", "rc"); + super(plugin, ReportManager.REPORT_CLOSE_COMMAND_PERMISSION, "reportclose", "rc"); } @Override @@ -64,4 +63,4 @@ public class ReportCloseCommand extends CommandBase }); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java index 89be81d30..cd13726b8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java @@ -7,7 +7,6 @@ import org.bukkit.entity.Player; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -23,91 +22,84 @@ public class ReportCommand extends CommandBase { public ReportCommand(ReportPlugin plugin) { - super(plugin, Rank.ALL, "report"); + super(plugin, ReportManager.REPORT_COMMAND_PERMISSION, "report"); } - + @Override public void Execute(final Player reporter, final String[] args) { CoreClientManager clientManager = _commandCenter.GetClientManager(); - if (!clientManager.hasRank(reporter, Rank.TITAN)) - { - UtilPlayer.message(reporter, F.main(Plugin.getName(), C.cRed + "The report feature is currently in a trial phase for Titan players")); - } - else - { - ReportManager reportManager = Plugin.getManager(); - boolean canReport = reportManager.canReport(reporter); + ReportManager reportManager = Plugin.getManager(); + boolean canReport = reportManager.canReport(reporter); - if (canReport) + if (canReport) + { + if (args == null || args.length < 2) { - if(args == null || args.length < 2) - { - UtilPlayer.message(reporter, F.main(Plugin.getName(), C.cRed + "Invalid Usage: " + F.elem("/" + _aliasUsed + " "))); - } - else - { - int reporterId = clientManager.getAccountId(reporter); - String playerName = args[0]; - Player suspect = UtilPlayer.searchOnline(reporter, playerName, false); - String reason = F.combine(args, 1, null, false); + UtilPlayer.message(reporter, F.main(Plugin.getName(), C.cRed + "Invalid Usage: " + F.elem("/" + _aliasUsed + " "))); + } + else + { + int reporterId = clientManager.getAccountId(reporter); + String playerName = args[0]; + Player suspect = UtilPlayer.searchOnline(reporter, playerName, false); + String reason = F.combine(args, 1, null, false); - reportManager.getOpenReports(reporterId).whenComplete((reports, throwable) -> + reportManager.getOpenReports(reporterId).whenComplete((reports, throwable) -> + { + if (throwable == null) { - if (throwable == null) + if (reports.size() < ReportManager.MAXIMUM_REPORTS) { - if (reports.size() < ReportManager.MAXIMUM_REPORTS) + if (suspect != null) { - if (suspect != null) + // allow developer (iKeirNez) to report himself (for easy testing reasons) + if (suspect == reporter && !reportManager.isDevMode(reporter.getUniqueId())) { - // allow developer (iKeirNez) to report himself (for easy testing reasons) - if (suspect == reporter && !reportManager.isDevMode(reporter.getUniqueId())) - { - UtilPlayer.message(reporter, F.main(Plugin.getName(), - C.cRed + "You cannot report yourself.")); - } - else - { - CoreClient suspectClient = clientManager.Get(suspect); - new ReportCreatePage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); - } + UtilPlayer.message(reporter, F.main(Plugin.getName(), + C.cRed + "You cannot report yourself.")); } else { - clientManager.loadClientByName(playerName, suspectClient -> - { - if (suspectClient != null) - { - new ReportCreatePage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); - } - else - { - UtilPlayer.message(reporter, F.main(Plugin.getName(), - C.cRed + "Unable to find player '" + playerName + "'!")); - } - }); + CoreClient suspectClient = clientManager.Get(suspect); + new ReportCreatePage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); } } else { - UtilPlayer.message(reporter, F.main(Plugin.getName(), - C.cRed + "Cannot create report, you have reached the limit.")); + clientManager.loadClientByName(playerName, suspectClient -> + { + if (suspectClient != null) + { + new ReportCreatePage(Plugin, reporter, reporterId, suspectClient, reason).openInventory(); + } + else + { + UtilPlayer.message(reporter, F.main(Plugin.getName(), + C.cRed + "Unable to find player '" + playerName + "'!")); + } + }); } } else { UtilPlayer.message(reporter, F.main(Plugin.getName(), - C.cRed + "An error occurred, please try again.")); - Plugin.getPlugin().getLogger().log(Level.SEVERE, "Error whilst fetching open reports.", throwable); + C.cRed + "Cannot create report, you have reached the limit.")); } - }); - } - } - else - { - UtilPlayer.message(reporter, C.cRed + "You are banned from using the report feature."); + } + else + { + UtilPlayer.message(reporter, F.main(Plugin.getName(), + C.cRed + "An error occurred, please try again.")); + Plugin.getPlugin().getLogger().log(Level.SEVERE, "Error whilst fetching open reports.", throwable); + } + }); } } + else + { + UtilPlayer.message(reporter, C.cRed + "You are banned from using the report feature."); + } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java index 4241202b2..b2138f74b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java @@ -3,10 +3,10 @@ package mineplex.core.report.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.report.ReportManager; import mineplex.core.report.ReportPlugin; import mineplex.core.report.ui.ReportHandlePage; @@ -18,7 +18,7 @@ public class ReportHandleCommand extends CommandBase { public ReportHandleCommand(ReportPlugin plugin) { - super(plugin, Rank.MODERATOR, "reporthandle", "rh"); + super(plugin, ReportManager.REPORT_HANDLE_COMMAND_PERMISSION, "reporthandle", "rh"); } @Override @@ -35,4 +35,4 @@ public class ReportHandleCommand extends CommandBase UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Invalid Usage: " + F.elem("/" + _aliasUsed))); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java index 98a7b6abe..73dd1aaf5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java @@ -3,8 +3,8 @@ package mineplex.core.report.command; import org.bukkit.entity.Player; import com.google.common.primitives.Longs; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.JsonMessage; @@ -12,6 +12,7 @@ import mineplex.core.common.util.BukkitFuture; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.report.ReportManager; import mineplex.core.report.ReportPlugin; import mineplex.core.report.ReportRole; @@ -22,7 +23,7 @@ public class ReportHistoryCommand extends CommandBase { public ReportHistoryCommand(ReportPlugin reportPlugin) { - super(reportPlugin, Rank.MODERATOR, "reporthistory", "rhis"); + super(reportPlugin, ReportManager.REPORT_HISTORY_COMMAND_PERMISSION, "reporthistory", "rhis"); } @Override @@ -93,4 +94,4 @@ public class ReportHistoryCommand extends CommandBase UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Invalid Usage: " + F.elem("/" + _aliasUsed + " "))); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java index 894d03847..1ffa4ca10 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java @@ -9,7 +9,6 @@ import org.bukkit.entity.Player; import mineplex.core.chatsnap.SnapshotMetadata; import mineplex.core.chatsnap.SnapshotRepository; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.HoverEvent; import mineplex.core.common.jsonchat.JsonMessage; @@ -30,7 +29,7 @@ public class ReportInfoCommand extends CommandBase { public ReportInfoCommand(ReportPlugin plugin) { - super(plugin, Rank.MODERATOR, "reportinfo"); + super(plugin, ReportManager.REPORT_INFO_COMMAND_PERMISSION, "reportinfo"); } @Override @@ -120,4 +119,4 @@ public class ReportInfoCommand extends CommandBase UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "Invalid Usage: " + F.elem("/" + _aliasUsed + " "))); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java index 5a061ea61..0cc497605 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java @@ -3,11 +3,11 @@ package mineplex.core.report.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.BukkitFuture; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.report.ReportManager; import mineplex.core.report.ReportPlugin; import mineplex.core.report.data.metrics.ReportMetrics; @@ -21,7 +21,7 @@ public class ReportMetricsCommand extends CommandBase public ReportMetricsCommand(ReportPlugin plugin) { - super(plugin, Rank.MODERATOR, "reportmetrics"); + super(plugin, ReportManager.REPORT_METRICS_COMMAND_PERMISSION, "reportmetrics"); } @Override @@ -120,4 +120,4 @@ public class ReportMetricsCommand extends CommandBase UtilPlayer.message(player, F.main("Report Metrics", "Denied: " + F.elem(reportMetrics.getDenied()))); UtilPlayer.message(player, F.main("Report Metrics", "Flagged Abusive: " + F.elem(reportMetrics.getFlagged()))); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java index 4dd452f64..da7bc84ec 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ui/ReportCreatePage.java @@ -108,4 +108,4 @@ public class ReportCreatePage extends SimpleGui implements ReportCategoryCallba _reporter.closeInventory(); addReport(button.getCategory()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RankRewardData.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RankRewardData.java index 995175533..afaf7374b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RankRewardData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RankRewardData.java @@ -1,22 +1,21 @@ package mineplex.core.reward; -import mineplex.core.common.Rank; - import org.bukkit.inventory.ItemStack; +import mineplex.core.account.permissions.PermissionGroup; + public class RankRewardData extends RewardData { - private Rank _rank; + private PermissionGroup _rank; - public RankRewardData(String friendlyName, ItemStack displayItem, RewardRarity rarity, Rank rank) + public RankRewardData(String friendlyName, ItemStack displayItem, RewardRarity rarity, PermissionGroup rank) { super(null, friendlyName, displayItem, rarity); _rank = rank; } - public Rank getWonRank() + public PermissionGroup getWonRank() { return _rank; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index f31a0b0f8..e891fff2a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -5,64 +5,59 @@ import java.util.EnumMap; import java.util.List; import java.util.Random; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; -import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; -import mineplex.core.gadget.gadgets.flag.FlagType; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; import mineplex.core.gadget.gadgets.balloons.BalloonType; +import mineplex.core.gadget.gadgets.death.DeathBlood; import mineplex.core.gadget.gadgets.death.DeathCandyCane; -import mineplex.core.gadget.gadgets.death.DeathPresentDanger; import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; import mineplex.core.gadget.gadgets.death.DeathEmerald; +import mineplex.core.gadget.gadgets.death.DeathEnchant; import mineplex.core.gadget.gadgets.death.DeathFreedom; import mineplex.core.gadget.gadgets.death.DeathFrostLord; -import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; import mineplex.core.gadget.gadgets.death.DeathMusic; import mineplex.core.gadget.gadgets.death.DeathPinataBurst; +import mineplex.core.gadget.gadgets.death.DeathPresentDanger; import mineplex.core.gadget.gadgets.death.DeathShadow; import mineplex.core.gadget.gadgets.death.DeathSpring; -import mineplex.core.gadget.gadgets.death.DeathBlood; -import mineplex.core.gadget.gadgets.death.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween; +import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.flag.FlagType; import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin; import mineplex.core.gadget.gadgets.hat.HatType; import mineplex.core.gadget.gadgets.item.ItemBatGun; @@ -114,28 +109,32 @@ import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksBoots; import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksChestplate; import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksHat; import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksLeggings; +import mineplex.core.gadget.gadgets.particle.ParticleBlood; +import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; import mineplex.core.gadget.gadgets.particle.ParticleChristmasTree; import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes; +import mineplex.core.gadget.gadgets.particle.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.gadgets.particle.ParticleFairy; import mineplex.core.gadget.gadgets.particle.ParticleFireRings; +import mineplex.core.gadget.gadgets.particle.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.ParticleMusic; +import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; +import mineplex.core.gadget.gadgets.particle.ParticleRain; import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel; import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons; import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; import mineplex.core.gadget.gadgets.particle.ParticleWingsLove; import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie; import mineplex.core.gadget.gadgets.particle.ParticleYinYang; -import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; -import mineplex.core.gadget.gadgets.particle.ParticleHeart; -import mineplex.core.gadget.gadgets.particle.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; -import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; -import mineplex.core.gadget.gadgets.particle.ParticleRain; -import mineplex.core.gadget.gadgets.particle.ParticleMusic; -import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; -import mineplex.core.gadget.gadgets.particle.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; -import mineplex.core.gadget.gadgets.particle.ParticleBlood; -import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; import mineplex.core.gadget.gadgets.taunts.RainbowTaunt; import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken; @@ -1203,12 +1202,12 @@ public class RewardManager public void addReward(RewardPool.Type pool, Reward reward) { - if(pool == Type.NORMAL) + if (pool == Type.NORMAL) { _rewardPools.get(Type.CARL_SPINNER).add(reward); _rewardPools.get(Type.MYTHICAL).add(reward); - if(!(reward instanceof InventoryReward)) + if (!(reward instanceof InventoryReward)) { _rewardPools.get(Type.ILLUMINATED).add(reward); } @@ -1308,7 +1307,7 @@ public class RewardManager if (rarity == RewardRarity.MYTHICAL) { PowerPlayReward rew = new PowerPlayReward(_clientManager, SubscriptionDuration.MONTH, rarity, 0, 0); - if (canGiveMythical && (type == RewardType.MYTHICAL_CHEST || type == RewardType.TRICK_OR_TREAT_CHEST || type == RewardType.THANKFUL_CHEST) && !_clientManager.Get(player).GetRank().has(Rank.TITAN)) + if (canGiveMythical && (type == RewardType.MYTHICAL_CHEST || type == RewardType.TRICK_OR_TREAT_CHEST || type == RewardType.THANKFUL_CHEST) && !_clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _clientManager.getPermissionManager().getGroup("titan"))) { return new RankReward(_clientManager, 0, 0, rarity); } @@ -1316,7 +1315,7 @@ public class RewardManager { return rew; } - else if (!canGiveMythical || _clientManager.Get(player).GetRank().has(Rank.LEGEND)) + else if (!canGiveMythical || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _clientManager.getPermissionManager().getGroup("legend"))) { rarity = RewardRarity.LEGENDARY; } @@ -1329,7 +1328,7 @@ public class RewardManager List treasureList = _rewardPools.get(pool).getRewards(rarity); int totalWeight = 0; - ArrayList possibleRewards = new ArrayList(); + List possibleRewards = new ArrayList<>(); for (Reward treasure : treasureList) { boolean isExcluded = false; @@ -1392,11 +1391,16 @@ public class RewardManager public boolean hasItemsToGivePlayer(RewardPool.Type pool, Player player) { - for(RewardRarity rarity : new RewardRarity[]{ - RewardRarity.COMMON, RewardRarity.MYTHICAL, RewardRarity.LEGENDARY, RewardRarity.RARE, RewardRarity.UNCOMMON}) + for (RewardRarity rarity : new RewardRarity[] { - if(_rewardPools.get(pool).hasItemsToGive(rarity, player)) return true; + RewardRarity.COMMON, RewardRarity.MYTHICAL, RewardRarity.LEGENDARY, RewardRarity.RARE, RewardRarity.UNCOMMON + }) + { + if (_rewardPools.get(pool).hasItemsToGive(rarity, player)) + { + return true; + } } return false; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java index 4e3cdf4f4..c50d33dd2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java @@ -7,7 +7,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.reward.RankRewardData; import mineplex.core.reward.Reward; import mineplex.core.reward.RewardData; @@ -26,56 +26,88 @@ public class RankReward extends Reward _clientManager = clientManager; _random = new Random(); } + + private PermissionGroup getNext(PermissionGroup current, boolean canPassLegend) + { + PermissionGroup newGroup = null; + + switch (current.getIdentifier()) + { + case "player": + newGroup = _clientManager.getPermissionManager().getGroup("ultra"); + break; + case "ultra": + newGroup = _clientManager.getPermissionManager().getGroup("hero"); + break; + case "hero": + newGroup = _clientManager.getPermissionManager().getGroup("legend"); + break; + case "legend": + if (canPassLegend) + { + newGroup = _clientManager.getPermissionManager().getGroup("titan"); + } + break; + case "titan": + if (canPassLegend) + { + newGroup = _clientManager.getPermissionManager().getGroup("eternal"); + } + break; + default: + break; + } + + return newGroup; + } @Override public RewardData giveRewardCustom(Player player, RewardType rewardType) { - Rank rank = null; - if (_clientManager.Get(player).GetRank() == Rank.ALL) rank = Rank.ULTRA; - else if (_clientManager.Get(player).GetRank() == Rank.ULTRA) rank = Rank.HERO; - else if (_clientManager.Get(player).GetRank() == Rank.HERO) rank = Rank.LEGEND; - else if ((rewardType == RewardType.MYTHICAL_CHEST || rewardType == RewardType.TRICK_OR_TREAT_CHEST || rewardType == RewardType.THANKFUL_CHEST) && _clientManager.Get(player).GetRank() == Rank.LEGEND) rank = Rank.TITAN; - else if ((rewardType == RewardType.MYTHICAL_CHEST || rewardType == RewardType.TRICK_OR_TREAT_CHEST || rewardType == RewardType.THANKFUL_CHEST) && _clientManager.Get(player).GetRank() == Rank.TITAN) rank = Rank.ETERNAL; + PermissionGroup group = getNext(_clientManager.Get(player).getPrimaryGroup(), rewardType == RewardType.MYTHICAL_CHEST || rewardType == RewardType.TRICK_OR_TREAT_CHEST || rewardType == RewardType.THANKFUL_CHEST); if (rewardType == RewardType.MYTHICAL_CHEST && _random.nextDouble() < 0.01) // 1 Percent - rank = Rank.ETERNAL; + { + group = _clientManager.getPermissionManager().getGroup("eternal"); + } - if (rank == null) + if (group == null) + { return new RewardData(null, getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER), getRarity()); + } - _clientManager.Get(player).SetRank(rank, false); - _clientManager.getRepository().saveRank(null, player.getName(), player.getUniqueId(), rank, true); + _clientManager.setPrimaryGroup(player, group, () -> {}); - return new RankRewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR), getRarity(), rank); + return new RankRewardData(getRarity().getColor() + group.getDisplay(false, false, false, true) + " Rank", new ItemStack(Material.NETHER_STAR), getRarity(), group); } @Override public RewardData getFakeRewardData(Player player) { - Rank rank = null; - if (_clientManager.Get(player).GetRank() == Rank.ALL) rank = Rank.ULTRA; - else if (_clientManager.Get(player).GetRank() == Rank.ULTRA) rank = Rank.HERO; - else if (_clientManager.Get(player).GetRank() == Rank.HERO) rank = Rank.LEGEND; - else if (_clientManager.Get(player).GetRank() == Rank.LEGEND) rank = Rank.TITAN; + PermissionGroup group = getNext(_clientManager.Get(player).getPrimaryGroup(), true); - if (rank == null) + if (group == null) + { return new RewardData(null, getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER), getRarity()); + } - return new RankRewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR), getRarity(), rank); + return new RankRewardData(getRarity().getColor() + group.getDisplay(false, false, false, true) + " Rank", new ItemStack(Material.NETHER_STAR), getRarity(), group); } @Override public boolean canGiveReward(Player player) { - return !_clientManager.Get(player).GetRank().has(Rank.LEGEND); + return !_clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _clientManager.getPermissionManager().getGroup("eternal")); } @Override public boolean equals(Object obj) { if (obj instanceof RankReward) + { return true; + } return false; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/MineplexScoreboard.java b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/MineplexScoreboard.java index 833d19637..7a88f68ef 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/MineplexScoreboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/scoreboard/MineplexScoreboard.java @@ -78,11 +78,11 @@ public class MineplexScoreboard */ public MineplexScoreboard(Player owner) { - this._owner = owner; - this._scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); + _owner = owner; + _scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); - this._sidebar = _scoreboard.registerNewObjective("sidebar", "sidebar"); - this._sidebar.setDisplaySlot(DisplaySlot.SIDEBAR); + _sidebar = _scoreboard.registerNewObjective("sidebar", "sidebar"); + _sidebar.setDisplaySlot(DisplaySlot.SIDEBAR); for (char c : CHARS) { @@ -98,7 +98,7 @@ public class MineplexScoreboard */ public MineplexScoreboard register(ScoreboardLine line) { - this._buffered.add(line); + _buffered.add(line); return this; } @@ -138,23 +138,23 @@ public class MineplexScoreboard public void recalculate() { // Starting fresh - if (this._calculated.size() == 0) + if (_calculated.size() == 0) { - for (int i = 0; i < this._buffered.size() && !_availableTrackers.isEmpty(); i++) + for (int i = 0; i < _buffered.size() && !_availableTrackers.isEmpty(); i++) { String tracker = _availableTrackers.pop(); - ScoreboardLine line = this._buffered.get(i); - this._calculated.add(line); - this._calculatedMap.put(line, new ScoreboardElement(this, this._sidebar, line, tracker, this._buffered.size() - i)); + ScoreboardLine line = _buffered.get(i); + _calculated.add(line); + _calculatedMap.put(line, new ScoreboardElement(this, _sidebar, line, tracker, _buffered.size() - i)); } } // Otherwise compute deltas else { // Delete all removed lines - for (ScoreboardLine calculated : this._calculated) + for (ScoreboardLine calculated : _calculated) { - if (!this._buffered.contains(calculated)) + if (!_buffered.contains(calculated)) { ScoreboardElement element = get(calculated); element.delete(); @@ -166,37 +166,37 @@ public class MineplexScoreboard _calculated.clear(); _calculatedMap.clear(); - for (int i = 0; i < this._buffered.size(); i++) + for (int i = 0; i < _buffered.size(); i++) { - ScoreboardLine line = this._buffered.get(i); + ScoreboardLine line = _buffered.get(i); ScoreboardElement element = prevCalculatedMap.get(line); - int expectedScore = this._buffered.size() - i; + int expectedScore = _buffered.size() - i; // existing if (element != null) { - Score score = this._sidebar.getScore(element.getTracker()); + Score score = _sidebar.getScore(element.getTracker()); if (score.getScore() != expectedScore) { score.setScore(expectedScore); element.setLineNumber(expectedScore); } - this._calculated.add(line); - this._calculatedMap.put(line, element); + _calculated.add(line); + _calculatedMap.put(line, element); } // new else { String tracker = _availableTrackers.pop(); - this._calculated.add(line); - this._calculatedMap.put(line, new ScoreboardElement(this, this._sidebar, line, tracker, expectedScore)); + _calculated.add(line); + _calculatedMap.put(line, new ScoreboardElement(this, _sidebar, line, tracker, expectedScore)); } } } - this._buffered.clear(); - this._buffered.addAll(this._calculated); + _buffered.clear(); + _buffered.addAll(_calculated); } /** @@ -219,7 +219,7 @@ public class MineplexScoreboard */ public ScoreboardElement get(ScoreboardLine line) { - return this._calculatedMap.get(line); + return _calculatedMap.get(line); } /** @@ -229,7 +229,7 @@ public class MineplexScoreboard */ public Player getOwner() { - return this._owner; + return _owner; } /** @@ -239,9 +239,9 @@ public class MineplexScoreboard */ public void setSidebarName(String sidebarName) { - if (!StringUtils.equals(this._sidebar.getName(), sidebarName)) + if (!StringUtils.equals(_sidebar.getName(), sidebarName)) { - this._sidebar.setDisplayName(sidebarName); + _sidebar.setDisplayName(sidebarName); } } @@ -252,16 +252,16 @@ public class MineplexScoreboard */ public Scoreboard getHandle() { - return this._scoreboard; + return _scoreboard; } void returnTracker(String tracker) { - this._availableTrackers.add(tracker); + _availableTrackers.add(tracker); } Set getCustomTrackers() { return _customTrackers; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java b/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java index 576e37ffd..168c15de7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java @@ -2,8 +2,6 @@ package mineplex.core.serverConfig; import java.lang.reflect.Field; -import net.minecraft.server.v1_8_R3.PlayerList; - import org.bukkit.craftbukkit.v1_8_R3.CraftServer; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerLoginEvent; @@ -12,13 +10,17 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.serverdata.Region; import mineplex.serverdata.data.ServerGroup; import mineplex.serverdata.servers.ServerManager; +import net.minecraft.server.v1_8_R3.PlayerList; public class ServerConfiguration extends MiniPlugin { + public static final String JOIN_STAFF_SERVER_PERMISSION = "mineplex.core.serverConfig.joinstaff"; + private CoreClientManager _clientManager; private Field _playerListMaxPlayers; @@ -51,17 +53,28 @@ public class ServerConfiguration extends MiniPlugin _plugin.getServer().setWhitelist(_serverGroup.getWhitelist()); ((CraftServer)_plugin.getServer()).getServer().setPVP(_serverGroup.getPvp()); // ((CraftServer)_plugin.getServer()).getServer().setResourcePack(_serverGroup.getResourcePack()); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(JOIN_STAFF_SERVER_PERMISSION), true, true); } @EventHandler public void onPlayerLogin(PlayerLoginEvent event) { - if (_serverGroup.getStaffOnly() && !_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) + if (_serverGroup.getStaffOnly() && !_clientManager.getPermissionManager().hasPermission(_clientManager.Get(event.getPlayer().getUniqueId()), GroupPermission.of(JOIN_STAFF_SERVER_PERMISSION))) + { event.disallow(Result.KICK_OTHER, "This is a staff only server."); + } } public ServerGroup getServerGroup() { return _serverGroup; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/spawn/Spawn.java b/Plugins/Mineplex.Core/src/mineplex/core/spawn/Spawn.java deleted file mode 100644 index ca1de6576..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/spawn/Spawn.java +++ /dev/null @@ -1,105 +0,0 @@ -package mineplex.core.spawn; - -import java.util.ArrayList; -import java.util.List; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.spawn.command.SpawnCommand; - -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.plugin.java.JavaPlugin; - -public class Spawn extends MiniPlugin -{ - private SpawnRepository _repository; - - private List _spawns = new ArrayList(); - - public Spawn(JavaPlugin plugin, String serverName) - { - super("Spawn", plugin); - - _repository = new SpawnRepository(plugin, serverName); - - for (String spawn : _repository.retrieveSpawns()) - { - _spawns.add(UtilWorld.strToLoc(spawn)); - } - } - - @Override - public void addCommands() - { - addCommand(new SpawnCommand(this)); - } - - public Location getSpawn() - { - if (_spawns.isEmpty()) - return UtilServer.getServer().getWorld("world").getSpawnLocation(); - - return _spawns.get(UtilMath.r(_spawns.size())); - } - - public void AddSpawn(Player player) - { - //Set Spawn Point - final Location loc = player.getLocation(); - - //Set World Spawn - player.getWorld().setSpawnLocation((int)loc.getX(), (int)loc.getY(), (int)loc.getZ()); - - //Add Spawn - _spawns.add(loc); - - //Save - runAsync(new Runnable() - { - public void run() - { - _repository.addSpawn(UtilWorld.locToStr(loc)); - } - }); - - //Inform - UtilPlayer.message(player, F.main(_moduleName, "You added a Spawn Node.")); - - //Log - log("Added Spawn [" + UtilWorld.locToStr(loc) + "] by [" + player.getName() + "]."); - } - - public void ClearSpawn(Player player) - { - //Add Spawn - _spawns.clear(); - - //Save - runAsync(new Runnable() - { - public void run() - { - _repository.clearSpawns(); - } - }); - - //Inform - UtilPlayer.message(player, F.main(_moduleName, "You cleared all Spawn Nodes.")); - - //Log - log("Cleared Spawn [ALL] by [" + player.getName() + "]."); - } - - @EventHandler - public void handleRespawn(PlayerRespawnEvent event) - { - event.setRespawnLocation(getSpawn()); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java deleted file mode 100644 index 393a68e1b..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java +++ /dev/null @@ -1,58 +0,0 @@ -package mineplex.core.spawn; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import mineplex.core.database.MinecraftRepository; -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.ResultSetCallable; -import mineplex.serverdata.database.column.ColumnVarChar; - -public class SpawnRepository extends RepositoryBase -{ - private static String CREATE_SPAWN_TABLE = "CREATE TABLE IF NOT EXISTS spawns (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(100), location VARCHAR(100), PRIMARY KEY (id), INDEX serverNameIndex (serverName));"; - private static String RETRIEVE_SPAWNS = "SELECT location FROM spawns WHERE serverName = ?;"; - private static String ADD_SERVER_SPAWN = "INSERT INTO spawns (serverName, location) VALUES (?, ?);"; - private static String DELETE_SERVER_SPAWN = "DELETE FROM spawns WHERE serverName = ?;"; - - private String _serverName; - - public SpawnRepository(JavaPlugin plugin, String serverName) - { - super(DBPool.getAccount()); - _serverName = serverName; - } - - public void addSpawn(String location) - { - executeUpdate(ADD_SERVER_SPAWN, new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("location", 100, location)); - } - - public void clearSpawns() - { - executeUpdate(DELETE_SERVER_SPAWN, new ColumnVarChar("serverName", 100, _serverName)); - } - - public List retrieveSpawns() - { - final List spawns = new ArrayList(); - - executeQuery(RETRIEVE_SPAWNS, new ResultSetCallable() - { - public void processResultSet(ResultSet resultSet) throws SQLException - { - while (resultSet.next()) - { - spawns.add(resultSet.getString(1)); - } - } - }, new ColumnVarChar("serverName", 100, _serverName)); - - return spawns; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/spawn/command/AddCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/spawn/command/AddCommand.java deleted file mode 100644 index 22f17ba3c..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/spawn/command/AddCommand.java +++ /dev/null @@ -1,21 +0,0 @@ -package mineplex.core.spawn.command; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.spawn.Spawn; - -public class AddCommand extends CommandBase -{ - public AddCommand(Spawn plugin) - { - super(plugin, Rank.ADMIN, "add", "a"); - } - - @Override - public void Execute(Player caller, String[] args) - { - Plugin.AddSpawn(caller); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/spawn/command/ClearCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/spawn/command/ClearCommand.java deleted file mode 100644 index f7438dc89..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/spawn/command/ClearCommand.java +++ /dev/null @@ -1,21 +0,0 @@ -package mineplex.core.spawn.command; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.spawn.Spawn; - -public class ClearCommand extends CommandBase -{ - public ClearCommand(Spawn plugin) - { - super(plugin, Rank.ADMIN, "clear"); - } - - @Override - public void Execute(Player caller, String[] args) - { - Plugin.ClearSpawn(caller); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/spawn/command/SpawnCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/spawn/command/SpawnCommand.java deleted file mode 100644 index db96ee8dd..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/spawn/command/SpawnCommand.java +++ /dev/null @@ -1,29 +0,0 @@ -package mineplex.core.spawn.command; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.spawn.Spawn; - -public class SpawnCommand extends MultiCommandBase -{ - public SpawnCommand(Spawn plugin) - { - super(plugin, Rank.ADMIN, "spawn"); - - AddCommand(new AddCommand(plugin)); - AddCommand(new ClearCommand(plugin)); - } - - @Override - public void Help(Player caller, String[] args) - { - UtilPlayer.message(caller, F.main("Spawn", "Commands List:")); - UtilPlayer.message(caller, F.help("/spawn add", "Add Location as Spawn", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/spawn clear", "Remove All Spawns", Rank.ADMIN)); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index c4290ff84..e1af4a22e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -19,6 +19,8 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTasks; import mineplex.core.leaderboard.LeaderboardManager; @@ -36,6 +38,11 @@ import mineplex.core.utils.UtilScheduler; */ public class StatsManager extends MiniDbClientPlugin { + public static final String GIVE_STAT_COMMAND_PERMISSION = "mineplex.core.stats.givestat"; + public static final String TIME_COMMAND_PERMISSION = "mineplex.core.stats.time"; + public static final String SET_LEVEL_COMMAND_PERMISSION = "mineplex.core.stats.setlevel"; + public static final String MASTER_BUILDERS_UNBAN_COMMAND_PERMISSION = "mineplex.core.stats.mbunban"; + private static final Object STATS_LOCK = new Object(); private final CoreClientManager _coreClientManager; @@ -73,6 +80,18 @@ public class StatsManager extends MiniDbClientPlugin { _stats.put(stat.getName(), stat.getId()); } + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_STAT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(TIME_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SET_LEVEL_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(MASTER_BUILDERS_UNBAN_COMMAND_PERMISSION), true, true); } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java index 79fa1d233..c9f4ab88a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java @@ -4,7 +4,6 @@ import org.apache.commons.lang3.StringUtils; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.stats.StatsManager; @@ -13,7 +12,7 @@ public class GiveStatCommand extends CommandBase { public GiveStatCommand(StatsManager plugin) { - super(plugin, Rank.ADMIN, "givestat"); + super(plugin, StatsManager.GIVE_STAT_COMMAND_PERMISSION, "givestat"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java index fb8d77cc9..c87838495 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java @@ -3,7 +3,6 @@ package mineplex.core.stats.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.stats.StatsManager; @@ -12,7 +11,7 @@ public class MasterBuilderUnban extends CommandBase { public MasterBuilderUnban(StatsManager plugin) { - super(plugin, Rank.ADMIN, "buildunban"); + super(plugin, StatsManager.MASTER_BUILDERS_UNBAN_COMMAND_PERMISSION, "buildunban"); } @Override @@ -63,5 +62,4 @@ public class MasterBuilderUnban extends CommandBase }, caller, args[0], false); }, args[0]); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/SetLevelCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/SetLevelCommand.java index 0cea4ef87..28b2b32a6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/SetLevelCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/SetLevelCommand.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import mineplex.core.achievement.Achievement; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.stats.StatsManager; @@ -13,7 +12,7 @@ public class SetLevelCommand extends CommandBase { public SetLevelCommand(StatsManager plugin) { - super(plugin, Rank.ADMIN, "setlevel"); + super(plugin, StatsManager.SET_LEVEL_COMMAND_PERMISSION, "setlevel"); } @Override @@ -60,4 +59,4 @@ public class SetLevelCommand extends CommandBase Plugin.setStat(target, Achievement.GLOBAL_MINEPLEX_LEVEL.getStats()[0], amountNeeded); UtilPlayer.message(caller, F.main("Stats", "Updated " + F.elem(target.getName()) + "'s level to " + F.elem(level))); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/TimeCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/TimeCommand.java index 62b815568..a5ce676d9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/TimeCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/TimeCommand.java @@ -5,7 +5,6 @@ import java.util.function.Consumer; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; @@ -16,7 +15,7 @@ public class TimeCommand extends CommandBase { public TimeCommand(StatsManager plugin) { - super(plugin, Rank.MODERATOR, "time"); + super(plugin, StatsManager.TIME_COMMAND_PERMISSION, "time"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java index 69a8a4e65..13fdc26b2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java @@ -1,6 +1,7 @@ package mineplex.core.status; import java.io.File; +import java.util.Arrays; import java.util.Collection; import org.bukkit.Bukkit; @@ -169,7 +170,7 @@ public class ServerStatusManager extends MiniPlugin for (Player player : Bukkit.getOnlinePlayers()) { - if (_clientManager.Get(player).GetRank().isDonor()) + if (Arrays.asList("ultra", "hero", "legend", "titan", "eternal").contains(_clientManager.Get(player).getPrimaryGroup().getIdentifier())) { donorsOnline++; } @@ -189,14 +190,11 @@ public class ServerStatusManager extends MiniPlugin if (!_enabled) return; - getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() + getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), () -> { - public void run() + if (callback != null) { - if (callback != null) - { - callback.run(_repository.getServerGroups(null)); - } + callback.run(_repository.getServerGroups(null)); } }); } @@ -211,4 +209,4 @@ public class ServerStatusManager extends MiniPlugin _enabled = false; saveServerStatus(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/task/repository/TaskRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/task/repository/TaskRepository.java index 429e2874d..c0d2becd8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/task/repository/TaskRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/task/repository/TaskRepository.java @@ -5,16 +5,15 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import mineplex.core.database.MinecraftRepository; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.task.Task; +import mineplex.core.task.TaskClient; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.ResultSetCallable; import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnVarChar; -import mineplex.core.task.Task; -import mineplex.core.task.TaskClient; public class TaskRepository extends RepositoryBase { @@ -67,4 +66,4 @@ public class TaskRepository extends RepositoryBase { executeUpdate(ADD_TASK, new ColumnVarChar("name", 100, task)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java index 68e3bccdd..771714a9a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java @@ -10,12 +10,6 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; - import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -23,10 +17,10 @@ import org.bukkit.scheduler.BukkitTask; import mineplex.core.MiniClientPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; -import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; -import mineplex.core.bonuses.BonusManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -37,10 +31,20 @@ import mineplex.core.teamspeak.redis.TeamspeakLinkResponse; import mineplex.core.teamspeak.redis.TeamspeakUnlinkRequest; import mineplex.core.teamspeak.redis.TeamspeakUnlinkResponse; import mineplex.serverdata.commands.ServerCommandManager; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; @ReflectivelyCreateMiniPlugin public class TeamspeakManager extends MiniClientPlugin implements ILoginProcessor { + public static final String LINK_COMMAND_PERMISSION = "mineplex.core.teamspeak.link"; + public static final String LIST_COMMAND_PERMISSION = "mineplex.core.teamspeak.list"; + public static final String TEAMSPEAK_COMMAND_PERMISSION = "mineplex.core.teamspeak.command"; + public static final String UNLINK_COMMAND_PERMISSION = "mineplex.core.teamspeak.unlink"; + public static final String TEAMSPEAK_CHANNEL_NAME = "Teamspeak Rank Channel"; public static final int MAX_LINKED_ACCOUNTS = 5; @@ -115,6 +119,18 @@ public class TeamspeakManager extends MiniClientPlugin impl }); _clientManager.addStoredProcedureLoginProcessor(this); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(LINK_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(LIST_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(TEAMSPEAK_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(UNLINK_COMMAND_PERMISSION), true, true); } @Override @@ -370,4 +386,4 @@ public class TeamspeakManager extends MiniClientPlugin impl caller.spigot().sendMessage(pageSwitch.create()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/LinkCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/LinkCommand.java index 83fa22d07..0faa794ae 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/LinkCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/LinkCommand.java @@ -3,7 +3,6 @@ package mineplex.core.teamspeak.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.teamspeak.TeamspeakManager; @@ -12,7 +11,7 @@ public class LinkCommand extends CommandBase { public LinkCommand(TeamspeakManager plugin) { - super(plugin, Rank.ALL, "link"); + super(plugin, TeamspeakManager.LINK_COMMAND_PERMISSION, "link"); } @Override @@ -26,4 +25,4 @@ public class LinkCommand extends CommandBase Plugin.link(caller, args[0]); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/ListCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/ListCommand.java index 18b4ebf56..26bf72363 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/ListCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/ListCommand.java @@ -3,16 +3,13 @@ package mineplex.core.teamspeak.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.teamspeak.TeamspeakManager; public class ListCommand extends CommandBase { public ListCommand(TeamspeakManager plugin) { - super(plugin, Rank.ALL, "list"); + super(plugin, TeamspeakManager.LIST_COMMAND_PERMISSION, "list"); } @Override @@ -20,4 +17,4 @@ public class ListCommand extends CommandBase { Plugin.displayUnlinkPrompt(caller, args.length == 0 ? "1" : args[0]); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/TeamspeakCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/TeamspeakCommand.java index c14e57d8c..03867fc95 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/TeamspeakCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/TeamspeakCommand.java @@ -3,7 +3,6 @@ package mineplex.core.teamspeak.commands; import org.bukkit.entity.Player; import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.teamspeak.TeamspeakManager; @@ -12,7 +11,7 @@ public class TeamspeakCommand extends MultiCommandBase { public TeamspeakCommand(TeamspeakManager plugin) { - super(plugin, Rank.ALL, "teamspeak", "ts"); + super(plugin, TeamspeakManager.TEAMSPEAK_COMMAND_PERMISSION, "teamspeak", "ts"); AddCommand(new LinkCommand(plugin)); AddCommand(new ListCommand(plugin)); @@ -25,4 +24,4 @@ public class TeamspeakCommand extends MultiCommandBase UtilPlayer.message(caller, F.main("Teamspeak", "To link a new Teamspeak account, run " + F.elem("/teamspeak link"))); UtilPlayer.message(caller, F.main("Teamspeak", "To list all linked Teamspeak accounts, run " + F.elem("/teamspeak list"))); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/UnlinkCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/UnlinkCommand.java index 063b90a80..2c68eca00 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/UnlinkCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/UnlinkCommand.java @@ -3,7 +3,6 @@ package mineplex.core.teamspeak.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.teamspeak.TeamspeakManager; @@ -12,7 +11,7 @@ public class UnlinkCommand extends CommandBase { public UnlinkCommand(TeamspeakManager plugin) { - super(plugin, Rank.ALL, "unlink"); + super(plugin, TeamspeakManager.UNLINK_COMMAND_PERMISSION, "unlink"); } @Override @@ -26,4 +25,4 @@ public class UnlinkCommand extends CommandBase Plugin.unlink(caller, args[0]); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java index d93abe6e9..10baf4d8c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java @@ -1,8 +1,22 @@ package mineplex.core.teleport; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.world.WorldUnloadEvent; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.ClientUnloadEvent; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.HoverEvent; @@ -21,20 +35,15 @@ import mineplex.core.teleport.redis.RedisLocateCallback; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.commands.ServerCommandManager; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.world.WorldUnloadEvent; -import org.bukkit.plugin.java.JavaPlugin; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.UUID; public class Teleport extends MiniPlugin { + public static final String FIND_COMMAND_PERMISSION = "mineplex.core.teleport.find"; + public static final String TELEPORT_COMMAND_PERMISSION = "mineplex.core.teleport.teleport"; + public static final String TELEPORT_LOCATION_COMMAND_PERMISSION = "mineplex.core.teleport.teleport.location"; + public static final String TELEPORT_OTHER_COMMAND_PERMISSION = "mineplex.core.teleport.teleport.other"; + public static final String TELEPORT_ALL_COMMAND_PERMISSION = "mineplex.core.teleport.teleport.all"; + private Map _failedRedisLocates = new HashMap<>(); private LinkedList teleportList = new LinkedList<>(); @@ -81,6 +90,19 @@ public class Teleport extends MiniPlugin message.sendToPlayer(player); } }); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(FIND_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(TELEPORT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TELEPORT_LOCATION_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TELEPORT_OTHER_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TELEPORT_ALL_COMMAND_PERMISSION), true, true); } @Override @@ -100,7 +122,7 @@ public class Teleport extends MiniPlugin return; } - RedisLocate locate = new RedisLocate(_serverName, player.getName(), player.getUniqueId(), _clientManager.Get(player).GetRank().name(), target); + RedisLocate locate = new RedisLocate(_serverName, player.getName(), player.getUniqueId(), target); locate.publish(); int id = getScheduler().runTaskLater(_plugin, () -> @@ -136,23 +158,31 @@ public class Teleport extends MiniPlugin teleportList.removeFirst().doTeleport(); } - public void playerToPlayer(Player caller, String from, String to) + public void playerToPlayer(Player caller, String target, String to) { LinkedList listA = new LinkedList(); //ALL - if (from.equals("%ALL%")) + if (target.equals("%ALL%")) + { for (Player cur : UtilServer.getPlayers()) + { listA.add(cur); - //Normal + } + } + //Normal else - listA = UtilPlayer.matchOnline(caller, from, true); + { + listA = UtilPlayer.matchOnline(caller, target, true); + } //To Player pB = UtilPlayer.searchOnline(caller, to, true); if (listA.isEmpty() || pB == null) + { return; + } if (listA.size() == 1) { @@ -207,10 +237,13 @@ public class Teleport extends MiniPlugin //Register if (first) + { Add(pA, pB.getLocation(), mA, true, caller, mB, pA.getName() + " teleported to " + pB.getName() + " via " + caller.getName()); - + } else + { Add(pA, pB.getLocation(), mA, true, caller, null, pA.getName() + " teleported to " + pB.getName() + " via " + caller.getName()); + } first = false; } @@ -226,7 +259,9 @@ public class Teleport extends MiniPlugin Player player = UtilPlayer.searchOnline(caller, target, true); if (player == null) + { return; + } try { @@ -237,21 +272,32 @@ public class Teleport extends MiniPlugin Location pLoc = player.getLocation(); if (sX.startsWith("~")) + { x += pLoc.getBlockX(); + } if (sY.startsWith("~")) + { y += pLoc.getBlockY(); + } if (sZ.startsWith("~")) + { z += pLoc.getBlockZ(); + } Location loc = new Location(Bukkit.getWorld(world), x, y, z); //Inform String mA = null; - if (caller == player) mA = F.main("Teleport", "You teleported to " + UtilWorld.locToStrClean(loc) + "."); + if (caller == player) + { + mA = F.main("Teleport", "You teleported to " + UtilWorld.locToStrClean(loc) + "."); + } else + { mA = F.main("Teleport", F.elem(caller.getName()) + " teleported you to " + UtilWorld.locToStrClean(loc) + "."); + } //Register Add(player, loc, mA, true, caller, null, player.getName() + " teleported to " + UtilWorld.locToStrClean(loc) + " via " + caller.getName()); @@ -310,4 +356,4 @@ public class Teleport extends MiniPlugin { return _clientManager; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleporter.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleporter.java index 03728e2d3..043bebf90 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleporter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleporter.java @@ -18,12 +18,12 @@ public class Teleporter public Teleporter(Teleport teleport, Player pA, Player pB, String mA, String mB, Location loc, boolean record, String log) { - this._tp = teleport; - this._pA = pA; - this._pB = pB; - this._mA = mA; - this._mB = mB; - this._loc = loc; + _tp = teleport; + _pA = pA; + _pB = pB; + _mA = mA; + _mB = mB; + _loc = loc; } public void doTeleport() @@ -59,4 +59,4 @@ public class Teleporter if (_pB != null && _mB != null) UtilPlayer.message(_pB, _mB); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/AllCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/AllCommand.java index 80c37e1e3..a95438732 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/AllCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/AllCommand.java @@ -3,14 +3,13 @@ package mineplex.core.teleport.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.teleport.Teleport; public class AllCommand extends CommandBase { public AllCommand(Teleport plugin) { - super(plugin, Rank.OWNER, "all"); + super(plugin, Teleport.TELEPORT_ALL_COMMAND_PERMISSION, "all"); } @Override @@ -18,4 +17,4 @@ public class AllCommand extends CommandBase { Plugin.playerToPlayer(caller, "%ALL%", caller.getName()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/BackCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/BackCommand.java index 3f4d5b97d..1d8a6aaef 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/BackCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/BackCommand.java @@ -3,32 +3,46 @@ package mineplex.core.teleport.command; import org.bukkit.Location; import org.bukkit.entity.Player; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.core.teleport.Teleport; public class BackCommand extends CommandBase { public BackCommand(Teleport plugin) { - super(plugin, Rank.MODERATOR, "back", "b"); + super(plugin, Teleport.TELEPORT_COMMAND_PERMISSION, "back", "b"); } @Override public void Execute(Player caller, String[] args) { if (args.length == 0) + { Back(caller, caller.getName(), "1"); + } else if (args.length == 1) + { Back(caller, args[0], "1"); + } else + { Back(caller, args[0], args[1]); + } } private void Back(Player caller, String target, String amountString) { + if (!target.equals(caller.getName()) && !_commandCenter.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(Teleport.TELEPORT_OTHER_COMMAND_PERMISSION))) + { + UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that."); + return; + } + int amount = 1; try { @@ -39,18 +53,21 @@ public class BackCommand extends CommandBase UtilPlayer.message(caller, F.main("Teleport", "Invalid Amount [" + amountString + "]. Defaulting to [1].")); } - Player player = UtilPlayer.searchOnline(caller, target, true); if (player == null) + { return; + } Location loc = null; int back = 0; for (int i = 0 ; i < amount ; i++) { if (Plugin.GetTPHistory(player) == null || Plugin.GetTPHistory(player).isEmpty()) + { break; + } loc = Plugin.GetTPHistory(player).removeFirst(); back++; @@ -67,4 +84,4 @@ public class BackCommand extends CommandBase String mB = F.main("Teleport", "You undid the last " + F.count(""+back) + " teleport(s) for " + F.elem(player.getName()) + "."); Plugin.Add(player, loc, mA, false, caller, mB, "Undid last " + back + " teleports for " + player.getName() + " via " + caller.getName()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/HereCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/HereCommand.java index 264695e3a..a78b0d646 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/HereCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/HereCommand.java @@ -3,22 +3,25 @@ package mineplex.core.teleport.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.teleport.Teleport; public class HereCommand extends CommandBase { public HereCommand(Teleport plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "here", "h"); + super(plugin, Teleport.TELEPORT_OTHER_COMMAND_PERMISSION, "here", "h"); } @Override public void Execute(Player caller, String[] args) { if (args.length == 1) + { Plugin.playerToPlayer(caller, args[0], caller.getName()); + } else if (args.length == 2) + { Plugin.playerToPlayer(caller, args[0], args[1]); + } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/LocateCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/LocateCommand.java index c2ef276c7..c463e90f0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/LocateCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/LocateCommand.java @@ -3,7 +3,6 @@ package mineplex.core.teleport.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.teleport.Teleport; @@ -12,7 +11,7 @@ public class LocateCommand extends CommandBase { public LocateCommand(Teleport plugin) { - super(plugin, Rank.HELPER, "locate", "where", "find"); + super(plugin, Teleport.FIND_COMMAND_PERMISSION, "locate", "where", "find"); } @Override @@ -26,4 +25,4 @@ public class LocateCommand extends CommandBase Plugin.locatePlayer(caller, args[0]); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TeleportCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TeleportCommand.java index dc41bf849..cc759e88d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TeleportCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TeleportCommand.java @@ -1,18 +1,21 @@ package mineplex.core.teleport.command; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.command.MultiCommandBase; -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.UtilPlayerBase; import mineplex.core.teleport.Teleport; public class TeleportCommand extends MultiCommandBase { public TeleportCommand(Teleport plugin) { - super(plugin, Rank.MODERATOR, "tp", "teleport"); + super(plugin, Teleport.TELEPORT_COMMAND_PERMISSION, "tp", "teleport"); AddCommand(new AllCommand(plugin)); AddCommand(new BackCommand(plugin)); @@ -22,40 +25,79 @@ public class TeleportCommand extends MultiCommandBase @Override protected void Help(Player caller, String[] args) { - if (Plugin.getServerName().contains("Clans") && !Plugin.getClientManager().hasRank(caller, Rank.ADMIN) && !caller.isOp()) + //Caller to Player + if (args.length == 1) { - caller.sendMessage(F.main("Clans", "You cannot use /tp in clans!")); - return; + if (_commandCenter.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(Teleport.TELEPORT_COMMAND_PERMISSION))) + { + Plugin.playerToPlayer(caller, caller.getName(), args[0]); + } + else + { + UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that."); + } } - //Caller to Player - if (args.length == 1 && _commandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.MODERATOR, true)) - Plugin.playerToPlayer(caller, caller.getName(), args[0]); - //Player to Player - else if (args.length == 2 && _commandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.ADMIN, true)) - Plugin.playerToPlayer(caller, args[0], args[1]); + else if (args.length == 2) + { + if (_commandCenter.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(Teleport.TELEPORT_OTHER_COMMAND_PERMISSION))) + { + Plugin.playerToPlayer(caller, args[0], args[1]); + } + else + { + UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that."); + } + } //Caller to Loc - else if (args.length == 3 && _commandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.ADMIN, true)) - Plugin.playerToLoc(caller, caller.getName(), args[0], args[1], args[2]); + else if (args.length == 3) + { + if (_commandCenter.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(Teleport.TELEPORT_LOCATION_COMMAND_PERMISSION))) + { + Plugin.playerToLoc(caller, caller.getName(), args[0], args[1], args[2]); + } + else + { + UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that."); + } + } //Player to world else if (args.length == 5) - Plugin.playerToLoc(caller, args[0], args[1], args[2], args[3], args[4]); + { + if (_commandCenter.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(Teleport.TELEPORT_LOCATION_COMMAND_PERMISSION)) && _commandCenter.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(Teleport.TELEPORT_OTHER_COMMAND_PERMISSION))) + { + Plugin.playerToLoc(caller, args[0], args[1], args[2], args[3], args[4]); + } + else + { + UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that."); + } + } //Player to Loc - else if (args.length == 4 && _commandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.ADMIN, true)) - Plugin.playerToLoc(caller, args[0], args[1], args[2], args[3]); + else if (args.length == 4) + { + if (_commandCenter.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(Teleport.TELEPORT_LOCATION_COMMAND_PERMISSION)) && _commandCenter.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(Teleport.TELEPORT_OTHER_COMMAND_PERMISSION))) + { + Plugin.playerToLoc(caller, args[0], args[1], args[2], args[3]); + } + else + { + UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that."); + } + } else { UtilPlayer.message(caller, F.main(Plugin.getName(), "Commands List:")); - UtilPlayer.message(caller, F.help("/tp ", "Teleport to Player", Rank.MODERATOR)); - UtilPlayer.message(caller, F.help("/tp b(ack) (amount) (player)", "Undo Teleports", Rank.MODERATOR)); - UtilPlayer.message(caller, F.help("/tp here ", "Teleport Player to Self", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/tp ", "Teleport Player to Player", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/tp ", "Teleport to Location", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/tp all", "Teleport All to Self", Rank.OWNER)); + UtilPlayer.message(caller, F.help("/tp ", "Teleport to Player", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/tp b(ack) (amount) (player)", "Undo Teleports", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/tp here ", "Teleport Player to Self", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/tp ", "Teleport Player to Player", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/tp ", "Teleport to Location", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/tp all", "Teleport All to Self", ChatColor.DARK_RED)); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocate.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocate.java index d630a78ce..aabac509f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocate.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocate.java @@ -8,18 +8,16 @@ public class RedisLocate extends ServerCommand { private String _sender; private UUID _senderUUID; - private String _senderRank; private String _sendingServer; private String _target; private UUID _uuid = UUID.randomUUID(); - public RedisLocate(String sendingServer, String sender, UUID senderUUID, String senderRank, String target) + public RedisLocate(String sendingServer, String sender, UUID senderUUID, String target) { _sender = sender; _senderUUID = senderUUID; - _senderRank = senderRank; _target = target; _sendingServer = sendingServer; } @@ -48,4 +46,4 @@ public class RedisLocate extends ServerCommand { return _senderUUID; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateCallback.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateCallback.java index d841a188a..72fc6efa8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateCallback.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/redis/RedisLocateCallback.java @@ -48,4 +48,4 @@ public class RedisLocateCallback extends ServerCommand { return _uuid; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java index 44291ba7f..5135c2a8f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java @@ -1,7 +1,16 @@ package mineplex.core.thank; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.UUID; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -10,13 +19,6 @@ import mineplex.core.donation.DonationManager; import mineplex.core.recharge.Recharge; import mineplex.core.thank.command.ThankCommand; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.UUID; - /** * This class handles /thank and amplifier thanks, along with allowing players to claim the rewards they earn */ @@ -24,6 +26,8 @@ public class ThankManager extends MiniDbClientPlugin { public static final int DEFAULT_RECEIVER_REWARD = 5; public static final int DEFAULT_SENDER_REWARD = 5; + + public static final String THANK_COMMAND_PERMISSION = "mineplex.core.thank.command"; private DonationManager _donationManager; @@ -36,6 +40,15 @@ public class ThankManager extends MiniDbClientPlugin _donationManager = donationManager; _thankRepository = new ThankRepository(); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(THANK_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java index ac26750e1..7985c3e19 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java @@ -1,15 +1,14 @@ package mineplex.core.thank.command; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.thank.ThankManager; import mineplex.core.thank.ThankResult; -import org.bukkit.Sound; -import org.bukkit.entity.Player; /** * @author Shaun Bennett @@ -18,7 +17,7 @@ public class ThankCommand extends CommandBase { public ThankCommand(ThankManager plugin) { - super(plugin, Rank.ALL, "thank"); + super(plugin, ThankManager.THANK_COMMAND_PERMISSION, "thank"); } @Override @@ -71,4 +70,4 @@ public class ThankCommand extends CommandBase }); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/PlayerScoreboard.java b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/PlayerScoreboard.java index 8a7175388..c6b4f5d7c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/PlayerScoreboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thereallyoldscoreboardapiweshouldremove/PlayerScoreboard.java @@ -1,6 +1,7 @@ package mineplex.core.thereallyoldscoreboardapiweshouldremove; import java.util.ArrayList; +import java.util.List; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -10,7 +11,7 @@ import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Team; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; public class PlayerScoreboard @@ -22,7 +23,7 @@ public class PlayerScoreboard private Scoreboard _scoreboard; private Objective _sideObjective; - private ArrayList _currentLines = new ArrayList(); + private List _currentLines = new ArrayList<>(); private String[] _teamNames; @@ -35,12 +36,16 @@ public class PlayerScoreboard { _scoreboard.registerNewTeam("Vanished").setSuffix(C.cBlue + "*"); - for (Rank rank : Rank.values()) + for (PermissionGroup group : _manager.getClients().getPermissionManager().getGroups()) { - if (rank != Rank.ALL) - _scoreboard.registerNewTeam(rank.ScoreboardTag).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); + if (!group.getDisplay(false, false, false, false).isEmpty()) + { + _scoreboard.registerNewTeam(group.getIdentifier()).setPrefix(group.getDisplay(true, true, true, false) + ChatColor.RESET + " "); + } else - _scoreboard.registerNewTeam(rank.ScoreboardTag).setPrefix(""); + { + _scoreboard.registerNewTeam(group.getIdentifier()).setPrefix(""); + } } _scoreboard.registerNewTeam("Party").setPrefix(ChatColor.LIGHT_PURPLE + C.Bold + "Party" + ChatColor.RESET + " "); @@ -48,13 +53,17 @@ public class PlayerScoreboard for (Player otherPlayer : Bukkit.getOnlinePlayers()) { if (otherPlayer.equals(player)) + { continue; + } if (_manager.getClients().Get(otherPlayer) == null) + { continue; + } - String rankName = _manager.getClients().Get(player).GetRank().ScoreboardTag; - String otherRankName = _manager.getClients().Get(otherPlayer).GetRank().ScoreboardTag; + String rankName = _manager.getClients().Get(player).getRealOrDisguisedPrimaryGroup().getIdentifier(); + String otherRankName = _manager.getClients().Get(otherPlayer).getRealOrDisguisedPrimaryGroup().getIdentifier(); //Add Other to Self _scoreboard.getTeam(otherRankName).addPlayer(otherPlayer); @@ -92,7 +101,7 @@ public class PlayerScoreboard if (data == null) return; - ArrayList lines = data.getLines(manager, player); + List lines = data.getLines(manager, player); for (int i=0 ; i getLines(ScoreboardManager manager, Player player, List out) { - List output = new ArrayList(); - - if (manager.getClients().Get(player).GetRank().has(Rank.ULTRA)) + List output = new ArrayList<>(); + + PermissionGroup group = manager.getClients().Get(player).getRealOrDisguisedPrimaryGroup(); + String display = group.getDisplay(false, false, false, false); + + if (!display.isEmpty()) { - output.add(manager.getClients().Get(player).GetRank().Name); + output.add(display); } else if (manager.getDonation().Get(player).ownsUnknownSalesPackage("SuperSmashMobs ULTRA") || manager.getDonation().Get(player).ownsUnknownSalesPackage("Survival Games ULTRA") || @@ -34,5 +37,4 @@ public class ScoreboardElementRank implements ScoreboardElement return output; } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/GiveTrackCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/GiveTrackCommand.java index 88c8f9c8f..58ec1dfc5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/GiveTrackCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/GiveTrackCommand.java @@ -3,11 +3,11 @@ package mineplex.core.titles.commands; import java.util.List; import java.util.stream.Collectors; +import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.titles.tracks.ItemizedTrack; @@ -18,7 +18,7 @@ public class GiveTrackCommand extends CommandBase { public GiveTrackCommand(TrackManager plugin) { - super(plugin, Rank.ADMIN, "givetrack" ); + super(plugin, TrackManager.GIVE_TRACK_COMMAND_PERMISSION, "givetrack"); } @Override @@ -26,7 +26,7 @@ public class GiveTrackCommand extends CommandBase { if (args.length < 2) { - UtilPlayer.message(caller, F.help("/givetrack ", "Give a player an unlockable track", GetRequiredRank())); + UtilPlayer.message(caller, F.help("/givetrack ", "Give a player an unlockable track", ChatColor.DARK_RED)); return; } @@ -47,7 +47,8 @@ public class GiveTrackCommand extends CommandBase return; } - Plugin.unlockTrack(player, track, result -> { + Plugin.unlockTrack(player, track, result -> + { switch (result) { case PLAYER_NOT_FOUND: @@ -76,4 +77,4 @@ public class GiveTrackCommand extends CommandBase } return null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/TrackCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/TrackCommand.java index f17dc9574..1db41c304 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/TrackCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/TrackCommand.java @@ -6,14 +6,10 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.Managers; -import mineplex.core.account.CoreClientManager; import mineplex.core.command.CommandBase; -import mineplex.core.common.MinecraftVersion; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.titles.Titles; -import mineplex.core.titles.tracks.ItemizedTrack; import mineplex.core.titles.tracks.Track; import mineplex.core.titles.tracks.TrackManager; @@ -23,7 +19,7 @@ public class TrackCommand extends CommandBase public TrackCommand(Titles plugin) { - super(plugin, Rank.ALL, "track"); + super(plugin, TrackManager.TRACK_COMMAND_PERMISSION, "track"); _trackManager = Managers.require(TrackManager.class); } @@ -69,4 +65,4 @@ public class TrackCommand extends CommandBase } return null; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java index fc5c8b3d6..4289f775e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java @@ -7,26 +7,21 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; -import mineplex.core.titles.tracks.award.AlienInvasionTrack; -import mineplex.core.titles.tracks.award.AprilFools2017Track; -import mineplex.core.titles.tracks.award.ClansRaidTrack; -import mineplex.core.titles.tracks.staff.BuilderTrack; -import mineplex.core.titles.tracks.staff.ModeratorTrack; -import mineplex.core.titles.tracks.staff.SeniorModeratorTrack; -import mineplex.core.titles.tracks.staff.TraineeTrack; -import mineplex.core.titles.tracks.standard.GemHuntersTrack; -import net.md_5.bungee.api.ChatColor; - import org.bukkit.Bukkit; import org.bukkit.entity.Player; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.Callback; import mineplex.core.inventory.InventoryManager; import mineplex.core.titles.commands.GiveTrackCommand; +import mineplex.core.titles.tracks.award.AlienInvasionTrack; +import mineplex.core.titles.tracks.award.AprilFools2017Track; import mineplex.core.titles.tracks.award.Bridges2017Track; +import mineplex.core.titles.tracks.award.ClansRaidTrack; import mineplex.core.titles.tracks.custom.DongerTrack; import mineplex.core.titles.tracks.custom.EarlyBirdTrack; import mineplex.core.titles.tracks.custom.HappyGaryTrack; @@ -35,7 +30,12 @@ import mineplex.core.titles.tracks.custom.SnekTrack; import mineplex.core.titles.tracks.custom.TableFlipTrack; import mineplex.core.titles.tracks.custom.TrackBuilder; import mineplex.core.titles.tracks.custom.WizardTrack; +import mineplex.core.titles.tracks.staff.BuilderTrack; +import mineplex.core.titles.tracks.staff.ModeratorTrack; +import mineplex.core.titles.tracks.staff.SeniorModeratorTrack; +import mineplex.core.titles.tracks.staff.TraineeTrack; import mineplex.core.titles.tracks.standard.GemCollectorTrack; +import mineplex.core.titles.tracks.standard.GemHuntersTrack; import mineplex.core.titles.tracks.standard.HolidayCheerTrack; import mineplex.core.titles.tracks.standard.LevelerTrack; import mineplex.core.titles.tracks.standard.LuckyTrack; @@ -48,10 +48,21 @@ import mineplex.core.titles.tracks.standard.SweetToothTrack; import mineplex.core.titles.tracks.standard.TreasureHunterTrack; import mineplex.core.titles.tracks.standard.UnluckyTrack; import mineplex.core.titles.tracks.standard.WarriorTrack; +import net.md_5.bungee.api.ChatColor; @ReflectivelyCreateMiniPlugin public class TrackManager extends MiniPlugin { + public static final String HAPPY_GARY_PERMISSION = "mineplex.core.title.happygary"; + public static final String LEADER_PERMISSION = "mineplex.core.title.leader"; + public static final String TABLE_FLIP_PERMISSION = "mineplex.core.title.tableflip"; + public static final String BUILDER_PERMISSION = "mineplex.core.title.builder"; + public static final String MOD_PERMISSION = "mineplex.core.title.mod"; + public static final String SR_MOD_PERMISSION = "mineplex.core.title.srmod"; + public static final String TRAINEE_PERMISSION = "mineplex.core.title.trainee"; + public static final String TRACK_COMMAND_PERMISSION = "mineplex.core.title.track"; + public static final String GIVE_TRACK_COMMAND_PERMISSION = "mineplex.core.title.givetrack"; + private final Map, Track> _registeredTracks = new LinkedHashMap<>(); private final Map _trackById = new HashMap<>(); @@ -149,6 +160,30 @@ public class TrackManager extends MiniPlugin registerTrack(animatedTrack("whaaat", "Whaaaaaat?", "(°o°)", "(°o°);(°o。);(。o。);(。o°);(°o°);(°o。);(。o。);(。o°)", 5)); // registerTrack(animatedTrack("spinning", "Spinning", "(゚◇゚)", "(゚◇゚);( ゚◇);( ゚);(  );(゚ );(◇゚ );(゚◇", 5)); // registerTrack(animatedTrack("unknown", "Unknown", "(・∇・)", "(・∇・);( ・∇);( ・);(  );(・ );(∇・ );(・∇・)", 5)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _coreClientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(HAPPY_GARY_PERMISSION), true, true); + pm.setPermission(pm.getGroup("lt"), GroupPermission.of(LEADER_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TABLE_FLIP_PERMISSION), true, true); + pm.setPermission(pm.getGroup("builder"), GroupPermission.of(BUILDER_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BUILDER_PERMISSION), true, false); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BUILDER_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(MOD_PERMISSION), true, true); + pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(MOD_PERMISSION), true, false); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(MOD_PERMISSION), true, true); + pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(SR_MOD_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(TRAINEE_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(TRAINEE_PERMISSION), true, false); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TRAINEE_PERMISSION), true, true); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_TRACK_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(TRACK_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/DongerTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/DongerTrack.java index bdefb8144..3aaeee7ce 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/DongerTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/DongerTrack.java @@ -29,4 +29,4 @@ public class DongerTrack extends Track new TrackFormat(ChatColor.AQUA, ChatColor.BLUE) )); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/EarlyBirdTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/EarlyBirdTrack.java index 5fd11ec04..583f22e8b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/EarlyBirdTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/EarlyBirdTrack.java @@ -65,4 +65,4 @@ public class EarlyBirdTrack extends Track { _wonEternal.remove(event.getPlayer().getUniqueId()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/HappyGaryTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/HappyGaryTrack.java index 25b98d970..094c0263c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/HappyGaryTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/HappyGaryTrack.java @@ -1,17 +1,13 @@ package mineplex.core.titles.tracks.custom; -import java.util.Set; - -import net.md_5.bungee.api.ChatColor; - -import com.google.common.collect.Sets; - import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.titles.tracks.Track; import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackManager; import mineplex.core.titles.tracks.TrackTier; +import net.md_5.bungee.api.ChatColor; public class HappyGaryTrack extends Track { @@ -25,7 +21,7 @@ public class HappyGaryTrack extends Track .addTier(new TrackTier( "☆゚°˖* ᕕ(ᐛ)ᕗ", null, - player -> _coreClientManager.hasRank(player, Rank.ADMIN), + player -> _coreClientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TrackManager.HAPPY_GARY_PERMISSION)), new TrackFormat(ChatColor.GOLD, ChatColor.GOLD) .animated(1, "☆゚°˖* ᕕ(ᐛ)ᕗ", @@ -36,4 +32,4 @@ public class HappyGaryTrack extends Track ) )); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/LeaderTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/LeaderTrack.java index e7a600b17..0d8f56ba5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/LeaderTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/LeaderTrack.java @@ -1,13 +1,13 @@ package mineplex.core.titles.tracks.custom; -import net.md_5.bungee.api.ChatColor; - import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.titles.tracks.Track; import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackManager; import mineplex.core.titles.tracks.TrackTier; +import net.md_5.bungee.api.ChatColor; public class LeaderTrack extends Track { @@ -21,8 +21,8 @@ public class LeaderTrack extends Track .addTier(new TrackTier( "What's a Leader?", null, - player -> _coreClientManager.Get(player).GetRank().has(Rank.LT), + player -> _coreClientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TrackManager.LEADER_PERMISSION)), new TrackFormat(ChatColor.DARK_RED, ChatColor.RED) )); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/SnekTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/SnekTrack.java index 5744f36b3..665c5be79 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/SnekTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/SnekTrack.java @@ -28,4 +28,4 @@ public class SnekTrack extends Track new TrackFormat(ChatColor.DARK_GREEN, ChatColor.GREEN) )); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/TableFlipTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/TableFlipTrack.java index 8ea5f3590..ff5f732f4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/TableFlipTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/TableFlipTrack.java @@ -1,13 +1,13 @@ package mineplex.core.titles.tracks.custom; -import net.md_5.bungee.api.ChatColor; - import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.titles.tracks.Track; import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackManager; import mineplex.core.titles.tracks.TrackTier; +import net.md_5.bungee.api.ChatColor; public class TableFlipTrack extends Track { @@ -21,7 +21,7 @@ public class TableFlipTrack extends Track .addTier(new TrackTier( "(╯°□°)╯ ︵ ┻━┻", null, - player -> _coreClientManager.hasRank(player, Rank.ADMIN), + player -> _coreClientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TrackManager.TABLE_FLIP_PERMISSION)), new TrackFormat(ChatColor.AQUA, ChatColor.AQUA) .animated(5, "(\\°-°)\\ ┬┬", @@ -39,4 +39,4 @@ public class TableFlipTrack extends Track ) )); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/TrackBuilder.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/TrackBuilder.java index 1747b2c73..14193f357 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/TrackBuilder.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/TrackBuilder.java @@ -170,4 +170,4 @@ public class TrackBuilder Validate.isTrue(id.length() <= 32, "ID must not be longer than 32 characters"); return new TrackBuilder(id); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/WizardTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/WizardTrack.java index 3f0e85c3e..0128d3dde 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/WizardTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/WizardTrack.java @@ -37,4 +37,4 @@ public class WizardTrack extends Track ) )); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/BuilderTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/BuilderTrack.java index e4254358c..b177ffade 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/BuilderTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/BuilderTrack.java @@ -1,18 +1,18 @@ package mineplex.core.titles.tracks.staff; +import org.bukkit.entity.Player; + import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.titles.tracks.ItemizedTrack; -import mineplex.core.titles.tracks.Track; import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackManager; import mineplex.core.titles.tracks.TrackTier; import net.md_5.bungee.api.ChatColor; -import org.bukkit.entity.Player; public class BuilderTrack extends ItemizedTrack { - private final CoreClientManager _clientManager = Managers.get(CoreClientManager.class); public BuilderTrack() @@ -30,7 +30,6 @@ public class BuilderTrack extends ItemizedTrack @Override public boolean owns(Player player) { - Rank rank = _clientManager.Get(player).GetRank(true); - return rank == Rank.MAPDEV || rank == Rank.MAPLEAD || rank == Rank.MAPPER || rank.has(Rank.ADMIN); + return _clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TrackManager.BUILDER_PERMISSION)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/ModeratorTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/ModeratorTrack.java index 042d54e11..f26f55afa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/ModeratorTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/ModeratorTrack.java @@ -1,18 +1,18 @@ package mineplex.core.titles.tracks.staff; +import org.bukkit.entity.Player; + import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.titles.tracks.ItemizedTrack; -import mineplex.core.titles.tracks.Track; import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackManager; import mineplex.core.titles.tracks.TrackTier; import net.md_5.bungee.api.ChatColor; -import org.bukkit.entity.Player; public class ModeratorTrack extends ItemizedTrack { - private final CoreClientManager _clientManager = Managers.get(CoreClientManager.class); public ModeratorTrack() @@ -30,7 +30,6 @@ public class ModeratorTrack extends ItemizedTrack @Override public boolean owns(Player player) { - Rank rank = _clientManager.Get(player).GetRank(true); - return rank == Rank.MODERATOR || rank == Rank.CMA || rank.has(Rank.ADMIN); + return _clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TrackManager.MOD_PERMISSION)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java index 3521e362d..51ceef55f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/SeniorModeratorTrack.java @@ -1,19 +1,18 @@ package mineplex.core.titles.tracks.staff; +import org.bukkit.entity.Player; + import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.titles.tracks.ItemizedTrack; -import mineplex.core.titles.tracks.Track; import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackManager; import mineplex.core.titles.tracks.TrackTier; import net.md_5.bungee.api.ChatColor; -import org.bukkit.entity.Player; public class SeniorModeratorTrack extends ItemizedTrack { - private final CoreClientManager _clientManager = Managers.get(CoreClientManager.class); public SeniorModeratorTrack() @@ -31,7 +30,6 @@ public class SeniorModeratorTrack extends ItemizedTrack @Override public boolean owns(Player player) { - Rank rank = _clientManager.Get(player).GetRank(true); - return rank == Rank.SNR_MODERATOR || rank == Rank.CMOD || rank.has(Rank.ADMIN); + return _clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TrackManager.SR_MOD_PERMISSION)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/TraineeTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/TraineeTrack.java index 3aa827567..7dc87b46a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/TraineeTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/staff/TraineeTrack.java @@ -1,17 +1,18 @@ package mineplex.core.titles.tracks.staff; +import org.bukkit.entity.Player; + import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.titles.tracks.ItemizedTrack; import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackManager; import mineplex.core.titles.tracks.TrackTier; import net.md_5.bungee.api.ChatColor; -import org.bukkit.entity.Player; public class TraineeTrack extends ItemizedTrack { - private final CoreClientManager _clientManager = Managers.get(CoreClientManager.class); public TraineeTrack() @@ -29,7 +30,6 @@ public class TraineeTrack extends ItemizedTrack @Override public boolean owns(Player player) { - Rank rank = _clientManager.Get(player).GetRank(true); - return rank == Rank.HELPER || rank.has(Rank.ADMIN); + return _clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TrackManager.TRAINEE_PERMISSION)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/tournament/DebugShopCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/tournament/DebugShopCommand.java index c7b3a9bae..65338a99c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/tournament/DebugShopCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/tournament/DebugShopCommand.java @@ -3,13 +3,12 @@ package mineplex.core.tournament; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; public class DebugShopCommand extends CommandBase { public DebugShopCommand(TournamentManager plugin) { - super(plugin, Rank.ALL, "ots"); + super(plugin, TournamentManager.DEBUG_SHOP_COMMAND_PERMISSION, "ots"); } @Override @@ -17,4 +16,4 @@ public class DebugShopCommand extends CommandBase { Plugin.openShop(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java b/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java index 26b9cc491..1e2d785ee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java @@ -7,10 +7,11 @@ import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scoreboard.Team; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.donation.DonationManager; import mineplex.core.recharge.Recharge; @@ -23,6 +24,8 @@ import mineplex.core.tournament.ui.TournamentShop; public class TournamentManager extends MiniDbClientPlugin { + public static final String DEBUG_SHOP_COMMAND_PERMISSION = "mineplex.core.tournament.debugshop"; + private TournamentRepository _repository; private TournamentShop _shop; private HashSet _tournaments = new HashSet<>(); @@ -35,6 +38,15 @@ public class TournamentManager extends MiniDbClientPlugin _shop = new TournamentShop(this, clientManager, donationManager); addCommand(new DebugShopCommand(this)); _tournaments = _repository.getTournaments(); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(DEBUG_SHOP_COMMAND_PERMISSION), true, true); } @Override @@ -136,4 +148,4 @@ public class TournamentManager extends MiniDbClientPlugin } }); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java index cb408fd84..66a0fcdde 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java @@ -9,9 +9,6 @@ import java.util.Random; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import net.minecraft.server.v1_8_R3.BlockPosition; -import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction; - import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; @@ -20,7 +17,6 @@ import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers; import org.bukkit.entity.Player; import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -48,14 +44,16 @@ import mineplex.core.treasure.animation.LootMythicalAnimation; import mineplex.core.treasure.animation.LootRareAnimation; import mineplex.core.treasure.animation.LootUncommonAnimation; import mineplex.core.treasure.animation.TreasureRemoveAnimation; +import net.minecraft.server.v1_8_R3.BlockPosition; +import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction; public class Treasure { private BlockRestore _blockRestore; - private List _chestBlockInfo = new ArrayList(); - private List _openedChestBlockInfo = new ArrayList(); - private List _otherBlockInfo = new ArrayList(); + private List _chestBlockInfo = new ArrayList<>(); + private List _openedChestBlockInfo = new ArrayList<>(); + private List _otherBlockInfo = new ArrayList<>(); private Player _player; private Random _random; @@ -326,7 +324,7 @@ public class Treasure { if (rewardData instanceof RankRewardData) { - if (((RankRewardData)rewardData).getWonRank() == Rank.TITAN) + if (((RankRewardData)rewardData).getWonRank().getIdentifier().equals("titan")) { TitanChestGiveawayMessage message = new TitanChestGiveawayMessage(_player.getName(), _statusManager.getCurrentServerName()); message.publish(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java b/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java index 3da03286e..d716bc389 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java @@ -33,10 +33,13 @@ import mineplex.core.Managers; import mineplex.core.MiniClientPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.BukkitFuture; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.core.common.util.UtilServer; import mineplex.core.recharge.Recharge; import mineplex.serverdata.commands.TwoFactorResetCommand; @@ -45,6 +48,9 @@ import mineplex.serverdata.database.DBPool; @ReflectivelyCreateMiniPlugin public class TwoFactorAuth extends MiniClientPlugin { + public static final String USE_2FA_PERMISSION = "mineplex.core.twofactor.use"; + public static final String RESET_2FA_PERMISSION = "mineplex.core.twofactor.reset"; + private final Map setupData = new HashMap<>(); private final Set authenticating = new HashSet<>(); @@ -63,19 +69,29 @@ public class TwoFactorAuth extends MiniClientPlugin _clientManager.addStoredProcedureLoginProcessor( _repository.buildLastIpLoginProcessor((uuid, ip) -> Get(uuid).setLastLoginIp(ip)) ); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("builder"), GroupPermission.of(USE_2FA_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(RESET_2FA_PERMISSION), true, true); } @Override public void addCommands() { - addCommand(new CommandBase(this, Rank.MAPDEV, "2fa", "tfa") + addCommand(new CommandBase(this, USE_2FA_PERMISSION, "2fa", "tfa") { @Override public void Execute(Player caller, String[] args) { if (args.length < 1 || !args[0].toLowerCase().equals("reset")) { - if (_clientManager.Get(caller).GetRank(true).has(Rank.ADMIN)) + if (_clientManager.getPermissionManager().hasPermission(caller, GroupPermission.of(RESET_2FA_PERMISSION))) { caller.sendMessage(F.main("2FA", "Usage: /2fa reset [player]")); } @@ -109,9 +125,9 @@ public class TwoFactorAuth extends MiniClientPlugin return; } - if (!_clientManager.Get(caller).GetRank(true).has(Rank.ADMIN)) + if (!_clientManager.getPermissionManager().hasPermission(caller, GroupPermission.of(RESET_2FA_PERMISSION))) { - caller.sendMessage(F.main("2FA", "Only admins can reset 2FA for other players")); + UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that."); return; } @@ -207,7 +223,7 @@ public class TwoFactorAuth extends MiniClientPlugin else { // 2FA not set up yet. - if (_clientManager.Get(player).GetRank(true).has(Rank.MAPDEV)) + if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(USE_2FA_PERMISSION))) { runSync(() -> setup2FA(event.getPlayer())); } @@ -396,4 +412,4 @@ public class TwoFactorAuth extends MiniClientPlugin { return new TwoFactorData(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java index be2a4a954..5685d5b9d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java @@ -16,7 +16,11 @@ import org.bukkit.event.server.ServerCommandEvent; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -33,6 +37,9 @@ import mineplex.serverdata.commands.ServerCommandManager; public class FileUpdater extends MiniPlugin { + public static final String RESTART_COMMAND_PERMISSION = "mineplex.core.updater.restart"; + public static final String BVERSION_COMMAND_PERMISSION = "mineplex.core.updater.bversion"; + private Portal _portal; private NautHashMap _jarMd5Map = new NautHashMap(); @@ -63,6 +70,16 @@ public class FileUpdater extends MiniPlugin ServerCommandManager.getInstance().registerCommandType("RestartCommand", RestartCommand.class, new RestartHandler(plugin, _serverName, _region)); loadBuildProperties(); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(BVERSION_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(RESTART_COMMAND_PERMISSION), true, true); } @Override @@ -277,4 +294,4 @@ public class FileUpdater extends MiniPlugin { return _region; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/command/BuildVersionCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/command/BuildVersionCommand.java index 0e5e2b10f..ab36c62ed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/command/BuildVersionCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/command/BuildVersionCommand.java @@ -5,7 +5,6 @@ import java.util.Properties; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.updater.FileUpdater; @@ -13,7 +12,7 @@ public class BuildVersionCommand extends CommandBase { public BuildVersionCommand(FileUpdater plugin) { - super(plugin, Rank.MODERATOR, "bversion"); + super(plugin, FileUpdater.BVERSION_COMMAND_PERMISSION, "bversion"); } @Override @@ -30,4 +29,4 @@ public class BuildVersionCommand extends CommandBase caller.sendMessage(" " + C.cGold + "User " + C.cWhite + user); caller.sendMessage(" " + C.cGold + "Git " + C.cWhite + git); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/command/RestartServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/command/RestartServerCommand.java index 544ae231e..4bd7da7d1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/command/RestartServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/command/RestartServerCommand.java @@ -3,7 +3,6 @@ package mineplex.core.updater.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -16,7 +15,7 @@ public class RestartServerCommand extends CommandBase { public RestartServerCommand(FileUpdater plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "restart"); + super(plugin, FileUpdater.RESTART_COMMAND_PERMISSION, "restart"); } @Override @@ -38,8 +37,10 @@ public class RestartServerCommand extends CommandBase UtilPlayer.message(caller, F.main("Restart", "Sent restart command to " + C.cGold + args[0] + C.cGray + ".")); } else + { UtilPlayer.message(caller, F.main("Restart", C.cGold + args[0] + C.cGray + " doesn't exist.")); + } } }); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/website/LinkCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/website/LinkCommand.java index 74dcbe768..3051f57f0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/website/LinkCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/LinkCommand.java @@ -3,7 +3,6 @@ package mineplex.core.website; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -11,7 +10,7 @@ public class LinkCommand extends CommandBase { public LinkCommand(WebsiteLinkManager plugin) { - super(plugin, Rank.ALL, "link"); + super(plugin, WebsiteLinkManager.LINK_COMMAND_PERMISSION, "link"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/website/UnlinkCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/website/UnlinkCommand.java index b6060c863..0245ce421 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/website/UnlinkCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/UnlinkCommand.java @@ -3,13 +3,12 @@ package mineplex.core.website; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; public class UnlinkCommand extends CommandBase { public UnlinkCommand(WebsiteLinkManager plugin) { - super(plugin, Rank.ADMIN, "unlink"); + super(plugin, WebsiteLinkManager.UNLINK_COMMAND_PERMISSION, "unlink"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java b/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java index 3ab0e1637..4893abe15 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java @@ -7,6 +7,7 @@ import java.net.Authenticator; import java.net.MalformedURLException; import java.net.URL; import java.sql.Connection; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; @@ -15,6 +16,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.TimeZone; import java.util.UUID; import java.util.function.BiConsumer; @@ -27,6 +29,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; +import com.google.common.collect.Sets; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; @@ -34,8 +37,13 @@ import com.google.gson.JsonSyntaxException; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.account.event.RankSaveEvent; -import mineplex.core.common.Rank; +import mineplex.core.account.event.GroupAddEvent; +import mineplex.core.account.event.GroupRemoveEvent; +import mineplex.core.account.event.PrimaryGroupUpdateEvent; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; +import mineplex.core.common.Pair; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -46,6 +54,9 @@ import mineplex.serverdata.database.DBPool; public class WebsiteLinkManager extends MiniDbClientPlugin { + public static final String LINK_COMMAND_PERMISSION = "mineplex.core.website.link"; + public static final String UNLINK_COMMAND_PERMISSION = "mineplex.core.website.unlink"; + private final JsonParser PARSER = new JsonParser(); private final String API_URL = "https://xen.mineplex.com/api.php"; private final String API_KEY = "dd412425-edb0-477c-abee-2d0b507c59ef"; @@ -60,6 +71,16 @@ public class WebsiteLinkManager extends MiniDbClientPlugin addCommand(new UnlinkCommand(this)); Authenticator.setDefault(new MineplexAuthenticator("minexen", "c4cADuj&ChaQ")); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(LINK_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(UNLINK_COMMAND_PERMISSION), true, true); } public void unlink(Player sender, String target) @@ -89,11 +110,11 @@ public class WebsiteLinkManager extends MiniDbClientPlugin List remove = new ArrayList<>(); remove.add(POWER_PLAY_TAG_ID); remove.add(LINKED_TAG_ID); - for (Rank rank : Rank.values()) + for (PermissionGroup group : getClientManager().getPermissionManager().getGroups()) { - if (rank.getForumId() != -1) + if (group.getForumId() != -1) { - remove.add(rank.getForumId()); + remove.add(Integer.valueOf(group.getForumId())); } } String call = "action=editUser&user=" + user.username + "&custom_fields=mcAcctIdPC="; @@ -175,7 +196,8 @@ public class WebsiteLinkManager extends MiniDbClientPlugin { final int forumId = getForumId(code); final int accountId = getClientManager().getAccountId(player); - final Rank rank = getClientManager().Get(player).GetRank(true); + final PermissionGroup group = getClientManager().Get(player).getPrimaryGroup(); + final Set additional = getClientManager().Get(player).getAdditionalGroups(); PowerPlayData d = UtilServer.CallEvent(new PPCDataRequestEvent(player)).getData(); final boolean powerPlay = (d != null && d.isSubscribed()); if (forumId == -1) @@ -197,12 +219,12 @@ public class WebsiteLinkManager extends MiniDbClientPlugin UtilPlayer.message(player, F.main(getName(), "That link code is invalid!")); return; } - completeLink(player, data, accountId, rank, powerPlay); + completeLink(player, data, accountId, group, additional, powerPlay); }); }); } - private void completeLink(Player player, XenForoData data, int accountId, Rank rank, boolean powerPlay) + private void completeLink(Player player, XenForoData data, int accountId, PermissionGroup group, Set additional, boolean powerPlay) { try (Connection c = DBPool.getAccount().getConnection()) { @@ -212,9 +234,16 @@ public class WebsiteLinkManager extends MiniDbClientPlugin String call = "action=editUser&user=" + data.username + "&custom_fields=mcAcctIdPC=" + accountId; List adding = new ArrayList<>(); adding.add(91); - if (rank.getForumId() != -1) + if (group.getForumId() != -1) { - adding.add(rank.getForumId()); + adding.add(Integer.valueOf(group.getForumId())); + } + for (PermissionGroup addit : additional) + { + if (addit.getForumId() != -1) + { + adding.add(Integer.valueOf(addit.getForumId())); + } } if (powerPlay) { @@ -624,62 +653,156 @@ public class WebsiteLinkManager extends MiniDbClientPlugin } @EventHandler - public void handleRankSave(RankSaveEvent event) + public void handleRankSave(PrimaryGroupUpdateEvent event) { - Consumer dataCallback = id -> + Consumer>> dataCallback = (p) -> { List remove = new ArrayList<>(); List add = new ArrayList<>(); - for (Rank rank : Rank.values()) + for (PermissionGroup group : getClientManager().getPermissionManager().getGroups()) { - if (rank.getForumId() != -1 && rank != event.getRank()) + if (group.getForumId() != -1 && !event.getGroupIdentifier().equals(group.getIdentifier()) && !p.getRight().contains(group.getIdentifier())) { - remove.add(rank.getForumId()); + remove.add(Integer.valueOf(group.getForumId())); } } - if (event.getRank().getForumId() != -1) + PermissionGroup group = getClientManager().getPermissionManager().getGroup(event.getGroupIdentifier()); + if (group.getForumId() != -1) { - add.add(event.getRank().getForumId()); + add.add(Integer.valueOf(group.getForumId())); } - refreshSiteTags(id, remove, add, false, () -> {}, false, () -> {}, false); + + refreshSiteTags(p.getLeft().intValue(), remove, add, false, () -> {}, false, () -> {}, false); }; - if (Bukkit.getPlayer(event.getUUID()) != null) + runAsync(() -> { - ForumUserData fd = Get(event.getUUID()); - if (fd.Linked) + int id = -1; + try (Connection c = DBPool.getAccount().getConnection(); + PreparedStatement s = c.prepareStatement("SELECT userId FROM forumLink WHERE accountId=" + event.getAccountId() + ";"); + ResultSet rs = s.executeQuery(); + ) { - final int userId = fd.LinkedForumId; - runAsync(() -> + if (rs.next()) { - dataCallback.accept(userId); - }); + id = rs.getInt(1); + } } - } - else - { - runAsync(() -> + catch (SQLException ex) { - getClientManager().getRepository().getAccountId(event.getUUID(), accountId -> + ex.printStackTrace(); + } + if (id == -1) + { + return; + } + final int userId = id; + getClientManager().getRepository().fetchGroups(event.getAccountId(), pair -> + { + dataCallback.accept(Pair.create(Integer.valueOf(userId), pair.getRight())); + }, () -> {}, false); + }); + } + + @EventHandler + public void handleRankSave(GroupAddEvent event) + { + Consumer>> dataCallback = (p) -> + { + List remove = new ArrayList<>(); + List add = new ArrayList<>(); + for (PermissionGroup group : getClientManager().getPermissionManager().getGroups()) + { + if (group.getForumId() != -1 && !event.getGroupIdentifier().equals(group.getIdentifier()) && !p.getRight().contains(group.getIdentifier())) { - runAsync(() -> - { - try (Connection c = DBPool.getAccount().getConnection()) - { - ResultSet rs = c.prepareStatement("SELECT userId FROM forumLink WHERE accountId=" + accountId + ";").executeQuery(); - if (rs.next()) - { - Integer userId = rs.getInt(1); - dataCallback.accept(userId); - } - } - catch (SQLException e) - { - e.printStackTrace(); - } - }); - }); - }); - } + remove.add(Integer.valueOf(group.getForumId())); + } + } + PermissionGroup group = getClientManager().getPermissionManager().getGroup(event.getGroupIdentifier()); + if (group.getForumId() != -1) + { + add.add(Integer.valueOf(group.getForumId())); + } + + refreshSiteTags(p.getLeft().intValue(), remove, add, false, () -> {}, false, () -> {}, false); + }; + runAsync(() -> + { + int id = -1; + try (Connection c = DBPool.getAccount().getConnection(); + PreparedStatement s = c.prepareStatement("SELECT userId FROM forumLink WHERE accountId=" + event.getAccountId() + ";"); + ResultSet rs = s.executeQuery(); + ) + { + if (rs.next()) + { + id = rs.getInt(1); + } + } + catch (SQLException ex) + { + ex.printStackTrace(); + } + if (id == -1) + { + return; + } + final int userId = id; + getClientManager().getRepository().fetchGroups(event.getAccountId(), pair -> + { + Set groups = Sets.newHashSet(pair.getRight()); + groups.add(pair.getLeft()); + groups.remove(event.getGroupIdentifier()); + dataCallback.accept(Pair.create(Integer.valueOf(userId), groups)); + }, () -> {}, false); + }); + } + + @EventHandler + public void handleRankSave(GroupRemoveEvent event) + { + Consumer>> dataCallback = (p) -> + { + List remove = new ArrayList<>(); + List add = new ArrayList<>(); + for (PermissionGroup group : getClientManager().getPermissionManager().getGroups()) + { + if (group.getForumId() != -1 && !p.getRight().contains(group.getIdentifier())) + { + remove.add(Integer.valueOf(group.getForumId())); + } + } + + refreshSiteTags(p.getLeft().intValue(), remove, add, false, () -> {}, false, () -> {}, false); + }; + runAsync(() -> + { + int id = -1; + try (Connection c = DBPool.getAccount().getConnection(); + PreparedStatement s = c.prepareStatement("SELECT userId FROM forumLink WHERE accountId=" + event.getAccountId() + ";"); + ResultSet rs = s.executeQuery(); + ) + { + if (rs.next()) + { + id = rs.getInt(1); + } + } + catch (SQLException ex) + { + ex.printStackTrace(); + } + if (id == -1) + { + return; + } + final int userId = id; + getClientManager().getRepository().fetchGroups(event.getAccountId(), pair -> + { + Set groups = Sets.newHashSet(pair.getRight()); + groups.add(pair.getLeft()); + dataCallback.accept(Pair.create(Integer.valueOf(userId), groups)); + }, () -> {}, false); + }); } @EventHandler diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java index b36ab85d8..0f3f9e658 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java @@ -13,7 +13,7 @@ import org.bukkit.entity.Player; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; import mineplex.core.donation.DonationManager; @@ -145,24 +145,34 @@ public class Enjin extends MiniPlugin implements CommandExecutor protected boolean checkForRankPurchase(String[] args, final String name, final UUID playerUUID, final CoreClient client) { - if (args.length != 4 || !args[0].equalsIgnoreCase("rank")) + if (args.length != 3 || !args[0].equalsIgnoreCase("rank")) + { return false; - - final Rank rank = mineplex.core.common.Rank.valueOf(args[2]); - final boolean perm = Boolean.parseBoolean(args[3]); + } + + PermissionGroup c = _clientManager.getPermissionManager().getGroup(args[2]); + if (c == null) + { + c = _clientManager.getPermissionManager().getGroupFromLegacy(args[2]); + } + if (c == null) + { + return false; + } + final PermissionGroup rank = _clientManager.getPermissionManager().getGroup(args[2]); _clientManager.loadClientByName(name, loadedClient -> { - if (rank == Rank.ALL || loadedClient.GetRank() == Rank.ALL || !loadedClient.GetRank().has(rank) || loadedClient.GetRank() == rank) + if (rank.getIdentifier().equals("player") || loadedClient.getPrimaryGroup().getIdentifier().equals("player") || !_clientManager.getPermissionManager().inheritsFully(loadedClient.getPrimaryGroup(), rank) || loadedClient.getPrimaryGroup().hashCode() == rank.hashCode()) { - _clientManager.SaveRank(data -> _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.Name + (perm ? " Permanent" : " Monthly"), 1, data == rank), name, playerUUID, rank, perm); + _clientManager.setPrimaryGroup(client.getAccountId(), rank, () -> _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.getIdentifier() + "Permanent", 1, true)); - System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + rank + " " + (perm ? "permanently." : "for 1 month.")); + System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + rank.getIdentifier() + " " + "permanently."); } else { - System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " DENIED INFERIOR " + rank + " " + (perm ? "permanently." : "for 1 month.")); - _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.Name + (perm ? " Permanent" : " Monthly"), 1, false); + System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " DENIED INFERIOR " + rank.getIdentifier() + " " + "permanently."); + _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.getIdentifier() + " Permanent", 1, false); } }); diff --git a/Plugins/Mineplex.Game.Clans.Compensation/src/mineplex/game/clans/compensation/ClansCompensation.java b/Plugins/Mineplex.Game.Clans.Compensation/src/mineplex/game/clans/compensation/ClansCompensation.java index f73364d6c..6cce7e431 100644 --- a/Plugins/Mineplex.Game.Clans.Compensation/src/mineplex/game/clans/compensation/ClansCompensation.java +++ b/Plugins/Mineplex.Game.Clans.Compensation/src/mineplex/game/clans/compensation/ClansCompensation.java @@ -27,6 +27,10 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -67,6 +71,8 @@ import mineplex.game.clans.items.legendaries.WindBlade; public class ClansCompensation extends JavaPlugin implements Listener { + public static final String COMPENSATION_COMMAND_PERMISSION = "mineplex.clans.compensation.command"; + private final List _compensating = new ArrayList<>(); private boolean _debug; @@ -75,6 +81,10 @@ public class ClansCompensation extends JavaPlugin implements Listener { System.out.println("[INFO] Enabling ClansCompensation"); Bukkit.getPluginManager().registerEvents(this, this); + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(COMPENSATION_COMMAND_PERMISSION), true, true); + } ClansManager.getInstance().addCommand(new CompensationCommand(ClansManager.getInstance(), this)); loadUUIDs(uuids -> { diff --git a/Plugins/Mineplex.Game.Clans.Compensation/src/mineplex/game/clans/compensation/CompensationCommand.java b/Plugins/Mineplex.Game.Clans.Compensation/src/mineplex/game/clans/compensation/CompensationCommand.java index 6e0d344fb..019daf5c5 100644 --- a/Plugins/Mineplex.Game.Clans.Compensation/src/mineplex/game/clans/compensation/CompensationCommand.java +++ b/Plugins/Mineplex.Game.Clans.Compensation/src/mineplex/game/clans/compensation/CompensationCommand.java @@ -5,7 +5,6 @@ import java.util.Random; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -23,7 +22,7 @@ public class CompensationCommand extends CommandBase public CompensationCommand(ClansManager plugin, ClansCompensation main) { - super(plugin, Rank.ALL, "compensation"); + super(plugin, ClansCompensation.COMPENSATION_COMMAND_PERMISSION, "compensation"); _main = main; char[] characters = "abcdefghijklmnopqrstuvwxyz".toCharArray(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 487ea34ce..b67c40b58 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -1,10 +1,10 @@ package mineplex.game.clans; +import static mineplex.core.Managers.require; + import java.io.File; import java.io.IOException; -import net.minecraft.server.v1_8_R3.MinecraftServer; - import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.World; @@ -57,7 +57,6 @@ import mineplex.core.report.ReportManager; import mineplex.core.report.ReportPlugin; import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.serverConfig.ServerConfiguration; -import mineplex.core.spawn.Spawn; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.teleport.Teleport; @@ -74,8 +73,7 @@ import mineplex.game.clans.shop.mining.MiningShop; import mineplex.game.clans.shop.pvp.PvpShop; import mineplex.game.clans.spawn.travel.TravelShop; import mineplex.game.clans.world.WorldManager; - -import static mineplex.core.Managers.require; +import net.minecraft.server.v1_8_R3.MinecraftServer; public class Clans extends JavaPlugin { @@ -136,7 +134,6 @@ public class Clans extends JavaPlugin ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager)); // TODO: Add spawn locations to a configuration file of some sort? - new Spawn(this, serverStatusManager.getCurrentServerName()); Give.Initialize(this); Teleport teleport = new Teleport(this, _clientManager); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java index 8798c636f..960bab251 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java @@ -3,13 +3,17 @@ package mineplex.game.clans.clans; import java.util.ArrayList; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; +import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilInput; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.core.ClaimLocation; @@ -19,17 +23,29 @@ import mineplex.game.clans.core.war.ClanWarData; public class ClansAdmin { + public static final String USE_ADMIN_COMMANDS_PERMISSION = "mineplex.clans.management.command"; + private ClansManager Clans; public ClansAdmin(ClansManager clans) { Clans = clans; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Clans.getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(USE_ADMIN_COMMANDS_PERMISSION), true, true); } public void command(Player caller, String[] args) { - if (!Clans.getClientManager().hasRank(caller, Rank.ADMIN) && !Clans.getClientManager().Get(caller).GetRank().equals(Rank.CMOD) && !caller.isOp()) + if (!Clans.getClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(USE_ADMIN_COMMANDS_PERMISSION)) && !caller.isOp()) { + UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that."); return; } @@ -101,25 +117,25 @@ public class ClansAdmin { UtilPlayer.message(caller, F.main("Clans Admin", "Admin Commands List;")); - UtilPlayer.message(caller, F.help("/c x create ", "Create Admin Clan", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x create ", "Create Admin Clan", ChatColor.GOLD)); - UtilPlayer.message(caller, F.help("/c x set ", "Set Mimic Clan", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x wp [remove/set/add] ", "Modify war points", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x set ", "Set Mimic Clan", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c x wp [remove/set/add] ", "Modify war points", ChatColor.GOLD)); - UtilPlayer.message(caller, F.help("/c x home (set)", "Teleport to Mimic Home", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x invite ", "Invite Player to Mimic", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x promote ", "Promote Player in Mimic", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x demote ", "Demote Player in Mimic", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x kick ", "Kick Player from Mimic", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x ally ", "Send Alliance to Mimic", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x neutral ", "Set Neutrality", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x enemy ", "Start Invasion", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x rename ", "Change the name of Mimic", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x claim", "Claim Territory for Mimic", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x unclaim (all)", "Unclaim Territory for Mimic", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x delete", "Delete Mimic Clan", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x autoclaim", "AutoClaim for Mimic Clan", Rank.CMOD)); - UtilPlayer.message(caller, F.help("/c x timer ", "Reset Clan Create Timer", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/c x home (set)", "Teleport to Mimic Home", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c x invite ", "Invite Player to Mimic", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c x promote ", "Promote Player in Mimic", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c x demote ", "Demote Player in Mimic", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c x kick ", "Kick Player from Mimic", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c x ally ", "Send Alliance to Mimic", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c x neutral ", "Set Neutrality", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c x enemy ", "Start Invasion", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c x rename ", "Change the name of Mimic", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c x claim", "Claim Territory for Mimic", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c x unclaim (all)", "Unclaim Territory for Mimic", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c x delete", "Delete Mimic Clan", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c x autoclaim", "AutoClaim for Mimic Clan", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c x timer ", "Reset Clan Create Timer", ChatColor.GOLD)); UtilPlayer.message(caller, F.main("Mimic Clan", Clans.Get(caller).getMimic())); } @@ -918,4 +934,4 @@ public class ClansAdmin //Inform UtilPlayer.message(caller, F.main("Clans Admin", "Territory Safe Zone: " + F.tf(claim.isSafe(caller.getLocation())))); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index a02020ecc..8bdfba5b5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -44,8 +44,9 @@ import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestoreData; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; @@ -70,6 +71,8 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class ClansGame extends MiniPlugin { + public static final String DUPE_ALERT_PERMISSION = "mineplex.clans.game.dupealert"; + private static final int CLICKS_TO_OPEN_TRAPPED = 10; private ClansManager _clans; @@ -79,6 +82,14 @@ public class ClansGame extends MiniPlugin _clans = clans; setupSafes(); + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clans.getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(DUPE_ALERT_PERMISSION), true, true); } private void setupSafes() @@ -163,7 +174,7 @@ public class ClansGame extends MiniPlugin event.setCancelled(true); for (Player p : Bukkit.getOnlinePlayers()) { - if (ClansManager.getInstance().getClientManager().hasRank(p, Rank.HELPER)) + if (ClansManager.getInstance().getClientManager().getPermissionManager().hasPermission(p, GroupPermission.of(DUPE_ALERT_PERMISSION))) { UtilPlayer.message(p, F.elem("[" + C.cRedB + "!" + C.cGray + "] ") + event.getPlayer().getName() + " just tried to use a duped item/block!"); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 2fed14075..3c81e7998 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -42,11 +42,12 @@ import com.google.common.io.ByteStreams; import mineplex.core.Managers; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; import mineplex.core.common.Pair; -import mineplex.core.common.Rank; import mineplex.core.common.events.PlayerMessageEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -92,7 +93,6 @@ import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.amplifiers.AmplifierManager; import mineplex.game.clans.clans.banners.BannerManager; import mineplex.game.clans.clans.boxes.BoxManager; -import mineplex.game.clans.clans.commands.ClanManagementCommand; import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand; import mineplex.game.clans.clans.commands.ClansCommand; @@ -157,8 +157,20 @@ import mineplex.minecraft.game.core.fire.Fire; import mineplex.minecraft.game.core.mechanics.Weapon; import mineplex.serverdata.commands.ServerCommandManager; -public class ClansManager extends MiniClientPluginimplements IRelation +public class ClansManager extends MiniClientPlugin implements IRelation { + public static final String ALLY_CHAT_COMMAND_PERMISSION = "mineplex.clans.command.allychat"; + public static final String CLAN_CHAT_COMMAND_PERMISSION = "mineplex.clans.command.clanchat"; + public static final String CLANS_COMMAND_PERMISSION = "mineplex.clans.command.main"; + public static final String SUICIDE_COMMAND_PERMISSION = "mineplex.clans.command.suicide"; + public static final String MAP_COMMAND_PERMISSION = "mineplex.clans.command.map"; + public static final String REGION_CLEAR_COMMAND_PERMISSION = "mineplex.clans.command.regionclear"; + public static final String SPEED_COMMAND_PERMISSION = "mineplex.clans.command.speed"; + public static final String FORCE_JOIN_COMMAND_PERMISSION = "mineplex.clans.command.speed"; + public static final String AUTO_OP_PERMISSION = "mineplex.clans.autoop"; + public static final String PREFIX_SHOWN_PERMISSION = "mineplex.clans.showprefix"; + public static final String JOIN_FULL_PERMISSION = "mineplex.clans.joinfull"; + public static final int CLAIMABLE_RADIUS = 800; public static final int WORLD_RADIUS = 1200; private static final TimeZone TIME_ZONE = TimeZone.getDefault(); @@ -200,7 +212,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati private Playtime _playTracker; private TutorialManager _tutorial; - private mineplex.game.clans.legacytutorial.TutorialManager _legacyTutorial; private ClassManager _classManager; private BannerManager _bannerManager; @@ -403,8 +414,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati _goldManager = new GoldManager(this, _clientManager, donationManager, _clanDataAccess); - _legacyTutorial = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, _taskManager, donationManager, preferencesManager, this, packetHandler); - for (ClanToken token : _clanDataAccess.getRepository().retrieveClans()) { loadClan(token, false); @@ -478,6 +487,31 @@ public class ClansManager extends MiniClientPluginimplements IRelati new BoxManager(plugin); _restartManager = new RestartManager(plugin); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.revokePermission(pm.getGroup("mod"), GroupPermission.of(Teleport.TELEPORT_COMMAND_PERMISSION), true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(Teleport.TELEPORT_COMMAND_PERMISSION), true, true); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(CLANS_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(ALLY_CHAT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(CLAN_CHAT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(MAP_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(SUICIDE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(REGION_CLEAR_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(SPEED_COMMAND_PERMISSION), false, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SPEED_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FORCE_JOIN_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(AUTO_OP_PERMISSION), true, true); + pm.setPermission(pm.getGroup("content"), GroupPermission.of(PREFIX_SHOWN_PERMISSION), true, true); + pm.setPermission(pm.getGroup("content"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + pm.setPermission(pm.getGroup("builder"), GroupPermission.of(PREFIX_SHOWN_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); } @Override @@ -487,7 +521,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati addCommand(new RegionsCommand(this)); addCommand(new ClansChatCommand(this)); addCommand(new ClansAllyChatCommand(this)); - addCommand(new ClanManagementCommand(this)); // addCommand(new MapCommand(this)); addCommand(new SpeedCommand(this)); addCommand(new KillCommand(this)); @@ -526,11 +559,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati { return _disguiseManager; } - - public mineplex.game.clans.legacytutorial.TutorialManager getLegacyTutorial() - { - return _legacyTutorial; - } public TutorialManager getTutorial() { @@ -788,7 +816,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati clanInfo.playerOnline(player); } - if (_clientManager.hasRank(player, Rank.DEVELOPER)) + if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(AUTO_OP_PERMISSION))) { player.setOp(true); } @@ -980,9 +1008,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati ClanInfo clan = _clanUtility.getClanByPlayer(event.getPlayer()); - String rank = _clientManager.Get(event.getPlayer()).GetRank().getTag(true, true) + " "; + String rank = _clientManager.Get(event.getPlayer()).getPrimaryGroup().getDisplay(true, true, true, false) + " "; - if (!_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH)) + if (!_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(PREFIX_SHOWN_PERMISSION))) { rank = ""; } @@ -1002,7 +1030,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati event.setCancelled(true); - System.out.println((clan == null ? "" : clan.getName()) + " " + _clientManager.Get(event.getPlayer()).GetRank().name() + " " + event.getPlayer().getName() + " " + event.getMessage()); + System.out.println((clan == null ? "" : clan.getName()) + " " + _clientManager.Get(event.getPlayer()).getPrimaryGroup().getIdentifier() + " " + event.getPlayer().getName() + " " + event.getMessage()); } @@ -1034,9 +1062,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati public void chatClan(ClanInfo clan, Player caller, String message) { - String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " "; + String rank = _clientManager.Get(caller).getPrimaryGroup().getDisplay(true, true, true, false) + " "; - if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH)) + if (!_clientManager.getPermissionManager().hasPermission(caller, GroupPermission.of(PREFIX_SHOWN_PERMISSION))) { rank = ""; } @@ -1046,9 +1074,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati public void chatAlly(ClanInfo clan, Player caller, String message) { - String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " "; + String rank = _clientManager.Get(caller).getPrimaryGroup().getDisplay(true, true, true, false) + " "; - if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH)) + if (!_clientManager.getPermissionManager().hasPermission(caller, GroupPermission.of(PREFIX_SHOWN_PERMISSION))) { rank = ""; } @@ -1264,12 +1292,8 @@ public class ClansManager extends MiniClientPluginimplements IRelati @EventHandler(priority = EventPriority.HIGHEST) public void onJoin(PlayerLoginEvent event) { - Rank rank = _clientManager.Get(event.getPlayer()).GetRank(); - - if (rank.has(Rank.HELPER)) + if (_restartManager.isRestarting()) { - event.allow(); - event.setResult(PlayerLoginEvent.Result.ALLOWED); return; } @@ -1277,7 +1301,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati for (Player player : UtilServer.getPlayers()) { - if (_clientManager.hasRank(player, Rank.HELPER)) + if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(JOIN_FULL_PERMISSION))) { continue; } @@ -1285,7 +1309,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati online++; } - if (online >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && rank != Rank.YOUTUBE && rank != Rank.YOUTUBE_SMALL && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp()) + if (online >= UtilServer.getServer().getMaxPlayers() && !_clientManager.getPermissionManager().hasPermission(_clientManager.Get(event.getPlayer()), GroupPermission.of(JOIN_FULL_PERMISSION)) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp()) { event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This Clans server is full! Try again soon"); } @@ -1365,7 +1389,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati @EventHandler public void message(PlayerMessageEvent event) { - if(!_tutorial.inTutorial(event.getPlayer())) + if (!_tutorial.inTutorial(event.getPlayer())) { return; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java index a50ff3366..08a65a809 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierCommand.java @@ -1,10 +1,9 @@ package mineplex.game.clans.clans.amplifiers; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; - import org.bukkit.entity.Player; +import mineplex.core.command.CommandBase; + /** * Main amplifier command */ @@ -12,7 +11,7 @@ public class AmplifierCommand extends CommandBase { public AmplifierCommand(AmplifierManager plugin) { - super(plugin, Rank.ALL, "amplifier", "runeamplifier"); + super(plugin, AmplifierManager.AMPLIFIER_COMMAND_PERMISSION, "amplifier", "runeamplifier"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java index b62061957..a5edc48de 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierGUI.java @@ -1,12 +1,7 @@ package mineplex.game.clans.clans.amplifiers; import java.util.HashMap; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.game.clans.clans.amplifiers.AmplifierManager.AmplifierType; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -20,6 +15,12 @@ import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.amplifiers.AmplifierManager.AmplifierType; + /** * GUI manager for amplifiers */ @@ -28,8 +29,8 @@ public class AmplifierGUI implements Listener private Player _viewer; private AmplifierManager _manager; private Inventory _inventory; - private final HashMap _items = new HashMap<>(); - private final HashMap _boundSlots = new HashMap<>(); + private final Map _items = new HashMap<>(); + private final Map _boundSlots = new HashMap<>(); private AmplifierType _selected; public AmplifierGUI(Player viewer, AmplifierManager manager) @@ -56,7 +57,7 @@ public class AmplifierGUI implements Listener * Fetches all the items registered as buttons in this inventory gui * @return A list of the items registered as buttons in this inventory gui */ - public HashMap getItems() + public Map getItems() { return _items; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java index 00d0073cc..4696e517e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/amplifiers/AmplifierManager.java @@ -1,6 +1,14 @@ package mineplex.game.clans.clans.amplifiers; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.core.MiniPlugin; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -11,17 +19,13 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.plugin.java.JavaPlugin; - /** * Manager for using amplifiers in clans */ public class AmplifierManager extends MiniPlugin { + public static final String AMPLIFIER_COMMAND_PERMISSION = "mineplex.clans.amplifier.command"; + public static final double AMPLIFIER_RUNE_DROP_MULTIPLIER = 2; private static final String AMPLIFIER_NAME = "Rune Amplifier"; private Amplifier _active; @@ -31,6 +35,15 @@ public class AmplifierManager extends MiniPlugin super("Rune Amplifiers", plugin); addCommand(new AmplifierCommand(this)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(AMPLIFIER_COMMAND_PERMISSION), true, true); } /** diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java index 6b5503b3c..a8ccc4b49 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/BannerManager.java @@ -24,7 +24,8 @@ import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilPlayer; @@ -40,6 +41,9 @@ import net.minecraft.server.v1_8_R3.MinecraftServer; */ public class BannerManager extends MiniPlugin { + public static final String BANNER_COMMAND_PERMISSION = "mineplex.clans.banner.command"; + public static final String BANNER_ACCESS_PERMISSION = "mineplex.clans.banner.access"; + public final Map LoadedBanners = new HashMap<>(); private final BlockFace[] _radial = { BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST }; private BannerRepository _repo; @@ -51,6 +55,16 @@ public class BannerManager extends MiniPlugin new BannerPacketManager(); addCommand(new BannerCommand(this)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(BANNER_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BANNER_ACCESS_PERMISSION), true, true); } /** @@ -69,7 +83,7 @@ public class BannerManager extends MiniPlugin { level = 2; } - if (ClansManager.getInstance().getClientManager().hasRank(player, Rank.ADMIN)) + if (ClansManager.getInstance().getClientManager().getPermissionManager().hasPermission(player, GroupPermission.of(BANNER_ACCESS_PERMISSION))) { level = 2; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java index dab08ae35..05ff02e3e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/banners/command/BannerCommand.java @@ -2,8 +2,10 @@ package mineplex.game.clans.clans.banners.command; import java.util.LinkedList; +import org.bukkit.DyeColor; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.ClanInfo; @@ -14,9 +16,6 @@ import mineplex.game.clans.clans.banners.BannerPattern; import mineplex.game.clans.clans.banners.ClanBanner; import mineplex.game.clans.clans.banners.gui.nonedit.NonEditOverviewGUI; -import org.bukkit.DyeColor; -import org.bukkit.entity.Player; - /** * Main banner usage command */ @@ -24,7 +23,7 @@ public class BannerCommand extends CommandBase { public BannerCommand(BannerManager plugin) { - super(plugin, Rank.ALL, "banner"); + super(plugin, BannerManager.BANNER_COMMAND_PERMISSION, "banner"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java index c0019ad74..b720390e5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/boxes/BoxManager.java @@ -17,15 +17,19 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.Managers; import mineplex.core.MiniPlugin; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.boxes.extra.BuilderBoxInventory; import mineplex.game.clans.clans.boxes.extra.DyeBoxSpinner; public class BoxManager extends MiniPlugin { + public static final String BOX_COMMAND_PERMISSION = "mineplex.clans.box.command"; + private BuilderBoxInventory _builderBox; public BoxManager(JavaPlugin plugin) @@ -36,7 +40,7 @@ public class BoxManager extends MiniPlugin _builderBox = new BuilderBoxInventory(); - addCommand(new CommandBase(this, Rank.ALL, "boxes", "box") + addCommand(new CommandBase(this, BOX_COMMAND_PERMISSION, "boxes", "box") { @Override public void Execute(Player caller, String[] args) @@ -44,6 +48,15 @@ public class BoxManager extends MiniPlugin shop.attemptShopOpen(caller); } }); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(BOX_COMMAND_PERMISSION), true, true); } @EventHandler(priority=EventPriority.HIGHEST) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java index ef76e4a6b..2a6d807a3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/ClaimVisualizer.java @@ -4,8 +4,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import net.minecraft.server.v1_8_R3.EnumDirection; - import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; @@ -18,6 +16,8 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilBlock; @@ -36,9 +36,12 @@ import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.ClanLeaveEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; import mineplex.game.clans.core.ClaimLocation; +import net.minecraft.server.v1_8_R3.EnumDirection; public class ClaimVisualizer extends MiniPlugin { + public static final String VISUALIZE_COMMAND_PERMISSION = "mineplex.clans.visualize.command"; + private ClansManager _clansManager; private List _visualizing; @@ -57,6 +60,15 @@ public class ClaimVisualizer extends MiniPlugin { _calculated.put(clan, new NautHashMap<>()); } + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(VISUALIZE_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/commands/ClaimVisualizeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/commands/ClaimVisualizeCommand.java index dcfa074c9..b467fe504 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/commands/ClaimVisualizeCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/claimview/commands/ClaimVisualizeCommand.java @@ -3,14 +3,13 @@ package mineplex.game.clans.clans.claimview.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.game.clans.clans.claimview.ClaimVisualizer; public class ClaimVisualizeCommand extends CommandBase { public ClaimVisualizeCommand(ClaimVisualizer plugin) { - super(plugin, Rank.ALL, "showclaims"); + super(plugin, ClaimVisualizer.VISUALIZE_COMMAND_PERMISSION, "showclaims"); } @Override @@ -18,5 +17,4 @@ public class ClaimVisualizeCommand extends CommandBase { Plugin.toggleVisualizer(caller); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClanManagementCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClanManagementCommand.java deleted file mode 100644 index baf413b43..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClanManagementCommand.java +++ /dev/null @@ -1,64 +0,0 @@ -package mineplex.game.clans.clans.commands; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.game.clans.clans.ClanInfo; -import mineplex.game.clans.clans.ClansManager; - -import org.bukkit.entity.Player; - -public class ClanManagementCommand extends CommandBase -{ - private ClansManager _clansManager; - - public ClanManagementCommand(ClansManager plugin) - { - super(plugin, Rank.ADMIN, "clanmanagement", "cm"); - _clansManager = plugin; - } - - @Override - public void Execute(final Player caller, String[] args) - { - if (args == null || args.length == 0) - { - message(caller, "Incorrect number of arguments!"); - } - else if (args[0].equalsIgnoreCase("delete") && args.length > 1) - { - final String clanName = args[1]; - final ClanInfo clan = Plugin.getClanUtility().searchClan(caller, args[1], false); - - if (clan != null) - { - _clansManager.getClanDataAccess().delete(clan, new Callback() - { - @Override - public void run(Boolean data) - { - if (data) - { - message(caller, String.format("Deleted the clan %s!", clanName)); - } - else - { - message(caller, "There was a database error while trying to delete " + clanName); - } - } - }); - } - else - { - message(caller, String.format("Unable to locate clan %s!", clanName)); - } - } - } - - public static void message(Player player, String message) - { - UtilPlayer.message(player, F.main("Clans", message)); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansAllyChatCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansAllyChatCommand.java index fdbd287a4..ab714ccb6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansAllyChatCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansAllyChatCommand.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.punish.Punish; @@ -16,7 +15,7 @@ public class ClansAllyChatCommand extends CommandBase { public ClansAllyChatCommand(ClansManager plugin) { - super(plugin, Rank.ALL, "ac"); + super(plugin, ClansManager.ALLY_CHAT_COMMAND_PERMISSION, "ac"); } @Override @@ -54,4 +53,4 @@ public class ClansAllyChatCommand extends CommandBase } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java index 3ce97064c..67eade7d6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansChatCommand.java @@ -4,7 +4,6 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.punish.Punish; @@ -16,7 +15,7 @@ public class ClansChatCommand extends CommandBase { public ClansChatCommand(ClansManager plugin) { - super(plugin, Rank.ALL, "cc", "fc"); + super(plugin, ClansManager.CLAN_CHAT_COMMAND_PERMISSION, "cc", "fc"); } @Override @@ -55,4 +54,4 @@ public class ClansChatCommand extends CommandBase } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index aaa084382..92fa5f5b2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -1,12 +1,10 @@ - package mineplex.game.clans.clans.commands; import java.util.Collections; import java.util.List; -import net.minecraft.server.v1_8_R3.EnumDirection; - import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.Material; @@ -15,14 +13,15 @@ import org.bukkit.entity.Player; import com.google.common.collect.Lists; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilInput; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; @@ -42,13 +41,15 @@ import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent; import mineplex.game.clans.core.ClaimLocation; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.spawn.Spawn; +import net.minecraft.server.v1_8_R3.EnumDirection; public class ClansCommand extends CommandBase { private ClansManager _clansManager; + public ClansCommand(ClansManager plugin) { - super(plugin, Rank.ALL, "c", "clan", "clans", "factions"); + super(plugin, ClansManager.CLANS_COMMAND_PERMISSION, "c", "clan", "clans", "factions"); _clansManager = plugin; } @@ -147,9 +148,9 @@ public class ClansCommand extends CommandBase return; } - if (!Plugin.getClientManager().hasRank(caller, Rank.ADMIN)) + if (!Plugin.getClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(ClansManager.FORCE_JOIN_COMMAND_PERMISSION))) { - UtilPlayer.message(caller, F.main("Clans", "This requires ADMIN+ permission.")); + UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that."); return; } @@ -225,29 +226,29 @@ public class ClansCommand extends CommandBase } UtilPlayer.message(caller, F.main("Clans", "Commands List;")); - UtilPlayer.message(caller, F.help("/c create ", "Create new Clan", Rank.ALL)); - UtilPlayer.message(caller, F.help("/c join ", "Join a Clan", Rank.ALL)); - UtilPlayer.message(caller, F.help("/c leave ", "Leave your Clan", Rank.ALL)); - UtilPlayer.message(caller, F.help("/cc (Message)", "Clan Chat (Toggle)", Rank.ALL)); + UtilPlayer.message(caller, F.help("/c create ", "Create new Clan", ChatColor.WHITE)); + UtilPlayer.message(caller, F.help("/c join ", "Join a Clan", ChatColor.WHITE)); + UtilPlayer.message(caller, F.help("/c leave ", "Leave your Clan", ChatColor.WHITE)); + UtilPlayer.message(caller, F.help("/cc (Message)", "Clan Chat (Toggle)", ChatColor.WHITE)); - UtilPlayer.message(caller, F.help("/c stuck", "Teleports you to the nearest Wilderness location", Rank.ALL)); + UtilPlayer.message(caller, F.help("/c stuck", "Teleports you to the nearest Wilderness location", ChatColor.WHITE)); - UtilPlayer.message(caller, F.help("/c promote ", "Promote Player in Clan", Rank.MODERATOR)); - UtilPlayer.message(caller, F.help("/c demote ", "Demote Player in Clan", Rank.MODERATOR)); + UtilPlayer.message(caller, F.help("/c promote ", "Promote Player in Clan", ChatColor.GOLD)); + UtilPlayer.message(caller, F.help("/c demote ", "Demote Player in Clan", ChatColor.GOLD)); - UtilPlayer.message(caller, F.help("/c home (set)", "Teleport to Clan Home", Rank.MODERATOR)); + UtilPlayer.message(caller, F.help("/c home (set)", "Teleport to Clan Home", ChatColor.GOLD)); - UtilPlayer.message(caller, F.help("/c invite ", "Invite Player to Clan", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c kick ", "Kick Player from Clan", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c neutral ", "Request Neutrality with Clan", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c enemy ", "Declare ClanWar with Clan", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c ally ", "Send Alliance to Clan", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c claim", "Claim Territory", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/c unclaim (all)", "Unclaim Territory", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/c invite ", "Invite Player to Clan", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/c kick ", "Kick Player from Clan", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/c neutral ", "Request Neutrality with Clan", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/c enemy ", "Declare ClanWar with Clan", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/c ally ", "Send Alliance to Clan", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/c claim", "Claim Territory", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/c unclaim (all)", "Unclaim Territory", ChatColor.DARK_RED)); - UtilPlayer.message(caller, F.help("/c delete", "Delete your Clan", Rank.OWNER)); + UtilPlayer.message(caller, F.help("/c delete", "Delete your Clan", ChatColor.DARK_RED)); - UtilPlayer.message(caller, F.help("/c ", "View Clan Information", Rank.ALL)); + UtilPlayer.message(caller, F.help("/c ", "View Clan Information", ChatColor.WHITE)); } public void create(final Player caller, final String[] args) @@ -1223,4 +1224,4 @@ public class ClansCommand extends CommandBase UtilPlayer.message(caller, clan.mTerritory()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java deleted file mode 100644 index ff64efdb3..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansLoginManager.java +++ /dev/null @@ -1,98 +0,0 @@ -package mineplex.game.clans.clans.commands; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.UUID; -import java.util.concurrent.ConcurrentLinkedQueue; - -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.account.ILoginProcessor; -import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.portal.Portal; -import mineplex.database.Tables; -import org.jooq.impl.DSL; - -public class ClansLoginManager extends MiniPlugin implements ILoginProcessor -{ - private boolean _enabled; - private String _serverName; - private ConcurrentLinkedQueue _queue; - - private CoreClientManager _clientManager; - - public ClansLoginManager(JavaPlugin plugin, CoreClientManager clientManager, String serverName) - { - super("Clans Login Manager", plugin); - - _serverName = serverName; - _enabled = true; - _queue = new ConcurrentLinkedQueue(); - clientManager.addStoredProcedureLoginProcessor(this); - _clientManager = clientManager; - } - - @EventHandler - public void onPlayerJoin(PlayerLoginEvent event) - { - if (_queue.contains(event.getPlayer().getName()) && !event.getPlayer().isOp() && _clientManager.hasRank(event.getPlayer(), Rank.CMOD)) - { - event.setKickMessage("This is not your Clans home server"); - event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - } - - _queue.remove(event.getPlayer().getName()); - } - - private void kickPlayer(final String playerName, final String homeServer) - { - runSyncLater(new Runnable() - { - @Override - public void run() - { - Player player = UtilPlayer.searchExact(playerName); - if (player != null && player.isOnline() && !player.isOp()) - { - player.kickPlayer("This is not your home server. To play clans, connect to " + homeServer); - } - } - }, 20); - } - - @Override - public void processLoginResultSet(final String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException - { - if (_enabled) - { - while (resultSet.next()) - { - final String serverName = resultSet.getString(1); - - if (serverName != null) - { - if (!serverName.equals(_serverName)) - { - _queue.add(playerName); - kickPlayer(playerName, serverName); - } - } - } - } - } - - @Override - public String getQuery(int accountId, String uuid, String name) - { - return "SELECT `clanServer`.`serverName` FROM `accountClan` JOIN `clans` ON `clans`.`id` = `accountClan`.`clanId` JOIN `clanServer` ON `clanServer`.`id` = `clans`.`serverId` WHERE `accountClan`.`accountId` = " + accountId + ";"; - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java index 2f16ab4b0..7df4c360f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/KillCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.clans.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; @@ -15,7 +14,7 @@ public class KillCommand extends CommandBase { public KillCommand(ClansManager plugin) { - super(plugin, Rank.ALL, "suicide", "kill"); + super(plugin, ClansManager.SUICIDE_COMMAND_PERMISSION, "suicide", "kill"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/MapCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/MapCommand.java index e9d8b13ba..3233e9229 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/MapCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/MapCommand.java @@ -1,33 +1,15 @@ package mineplex.game.clans.clans.commands; -import java.util.ArrayList; - -import org.bukkit.Chunk; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilInput; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.recharge.Recharge; -import mineplex.game.clans.clans.ClanInfo; -import mineplex.game.clans.clans.ClanRole; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.ClansUtility.ClanRelation; -import mineplex.game.clans.clans.ClientClan; public class MapCommand extends CommandBase { public MapCommand(ClansManager plugin) { - super(plugin, Rank.ALL, "map", "clansmap"); + super(plugin, ClansManager.MAP_COMMAND_PERMISSION, "map", "clansmap"); } @Override @@ -35,4 +17,4 @@ public class MapCommand extends CommandBase { //Plugin.getItemMapManager().setMap(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RegionsCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RegionsCommand.java index 573c5a177..4b7d33669 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RegionsCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RegionsCommand.java @@ -3,20 +3,17 @@ package mineplex.game.clans.clans.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.regions.ClansRegions; public class RegionsCommand extends CommandBase { - private ClansManager _manager; public RegionsCommand(ClansManager plugin) { - super(plugin, Rank.ADMIN,"region-reset"); + super(plugin, ClansManager.REGION_CLEAR_COMMAND_PERMISSION, "region-reset"); _manager = plugin; } @@ -27,4 +24,4 @@ public class RegionsCommand extends CommandBase UtilPlayer.message(caller, F.main("Regions", "Resetting clans regions!")); _manager.getClanRegions().resetRegions(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java deleted file mode 100644 index 9910889d0..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java +++ /dev/null @@ -1,57 +0,0 @@ -package mineplex.game.clans.clans.commands; - -import java.util.Iterator; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.task.TaskManager; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.legacytutorial.Tutorial; -import mineplex.game.clans.legacytutorial.TutorialManager; -import mineplex.game.clans.legacytutorial.gettingstarted.TutorialGettingStarted; - -public class RestartTutCommand extends CommandBase -{ - public RestartTutCommand(TutorialManager plugin) - { - super(plugin, Rank.ALL, "rst", "rstut", "reset"); - } - - @Override - public void Execute(Player caller, String[] args) - { - if (ClansManager.getInstance().getClan(caller) != null) - { - UtilPlayer.message(caller, F.main("Tutorial", "You cannot restart the tutorial while in a clan")); - return; - } - - if (ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()) != null - && ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).isSafe(caller.getLocation())) - { - String ignoreString = String.format(Tutorial.TUTORIAL_REWARD_TASK, "GettingStartedTutorial"); - Integer ignoreInt = TaskManager.Instance.getTaskId(ignoreString); - - Iterator it = TaskManager.Instance.Get(caller).TasksCompleted.iterator(); - while (it.hasNext()) - { - Integer i = it.next(); - if (i != null && (ignoreInt == null || i.intValue() != ignoreInt.intValue())) - { - it.remove(); - } - } - - TutorialManager.Instance.cancelTutorial(caller); - TutorialManager.Instance.startTutorial(TutorialGettingStarted.class, caller); - } - else - { - UtilPlayer.message(caller, F.main("Clans", "You must be in a Safe Zone to restart the tutorial.")); - } - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/SpeedCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/SpeedCommand.java index 0f2550345..8b6121148 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/SpeedCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/SpeedCommand.java @@ -1,18 +1,19 @@ package mineplex.game.clans.clans.commands; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.ClansManager; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; public class SpeedCommand extends CommandBase { public SpeedCommand(ClansManager plugin) { - super(plugin, Rank.CMOD, "speed"); + super(plugin, ClansManager.SPEED_COMMAND_PERMISSION, "speed"); } @Override @@ -20,7 +21,7 @@ public class SpeedCommand extends CommandBase { if (args.length < 3) { - UtilPlayer.message(caller, F.help("/speed ", "Set a player's walk/fly speed to an amount", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/speed ", "Set a player's walk/fly speed to an amount", ChatColor.GOLD)); return; } Player player = Bukkit.getPlayer(args[0]); @@ -86,12 +87,17 @@ public class SpeedCommand extends CommandBase } } - private String validateSpeed(float value) { - if(value < 0.0F) { - if(value < -1.0F) { + private String validateSpeed(float value) + { + if (value < 0.0F) + { + if (value < -1.0F) + { return value + " is too low"; } - } else if(value > 1.0F) { + } + else if(value > 1.0F) + { return value + " is too high"; } return null; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java index 6442c239e..f600cd3dc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/ClansFreezeManager.java @@ -20,7 +20,8 @@ import org.bukkit.potion.PotionEffectType; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; @@ -37,6 +38,10 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class ClansFreezeManager extends MiniPlugin { + public static final String FREEZE_COMMAND_PERMISSION = "mineplex.clans.freeze.freeze"; + public static final String UNFREEZE_COMMAND_PERMISSION = "mineplex.clans.freeze.unfreeze"; + public static final String NOTIFY_PERMISSION = "mineplex.clans.freeze.notify"; + private static final long FREEZE_MESSAGE_INTERVAL = 10000; private final CoreClientManager _clientManager; private final Map _frozen = new HashMap<>(); @@ -46,6 +51,23 @@ public class ClansFreezeManager extends MiniPlugin super("Freeze", plugin); _clientManager = clientManager; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(FREEZE_COMMAND_PERMISSION), false, true); + pm.setPermission(pm.getGroup("cma"), GroupPermission.of(FREEZE_COMMAND_PERMISSION), false, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FREEZE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(UNFREEZE_COMMAND_PERMISSION), false, true); + pm.setPermission(pm.getGroup("cma"), GroupPermission.of(UNFREEZE_COMMAND_PERMISSION), false, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(UNFREEZE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(NOTIFY_PERMISSION), false, true); + pm.setPermission(pm.getGroup("cma"), GroupPermission.of(NOTIFY_PERMISSION), false, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(NOTIFY_PERMISSION), true, true); } @Override @@ -65,7 +87,7 @@ public class ClansFreezeManager extends MiniPlugin event.getPlayer().removePotionEffect(PotionEffectType.JUMP); for (Player staff : UtilServer.GetPlayers()) { - if (_clientManager.Get(staff).GetRank().has(null, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false)) + if (_clientManager.getPermissionManager().hasPermission(staff, GroupPermission.of(NOTIFY_PERMISSION))) { UtilPlayer.message(staff, F.main(getName(), F.elem(event.getPlayer().getName()) + " has logged out while frozen!")); } @@ -214,7 +236,7 @@ public class ClansFreezeManager extends MiniPlugin player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999, -10)); for (Player alert : UtilServer.GetPlayers()) { - if (_clientManager.Get(alert).GetRank().has(null, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false)) + if (_clientManager.getPermissionManager().hasPermission(alert, GroupPermission.of(NOTIFY_PERMISSION))) { UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been frozen by " + F.elem(staff.getName()) + "!")); } @@ -235,7 +257,7 @@ public class ClansFreezeManager extends MiniPlugin player.removePotionEffect(PotionEffectType.JUMP); for (Player alert : UtilServer.GetPlayers()) { - if (_clientManager.Get(alert).GetRank().has(null, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false)) + if (_clientManager.getPermissionManager().hasPermission(alert, GroupPermission.of(NOTIFY_PERMISSION))) { UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been unfrozen by " + F.elem(staff.getName()) + "!")); continue; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/FreezeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/FreezeCommand.java index a5c55a670..a55e9ed6b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/FreezeCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/FreezeCommand.java @@ -1,14 +1,13 @@ package mineplex.game.clans.clans.freeze.commands; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.freeze.ClansFreezeManager; -import org.bukkit.entity.Player; - /** * Command to freeze players */ @@ -16,7 +15,7 @@ public class FreezeCommand extends CommandBase { public FreezeCommand(ClansFreezeManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "freeze"); + super(plugin, ClansFreezeManager.FREEZE_COMMAND_PERMISSION, "freeze"); } @Override @@ -41,4 +40,4 @@ public class FreezeCommand extends CommandBase Plugin.freeze(target, caller); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/UnfreezeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/UnfreezeCommand.java index 7f9f7bd92..4d385e5fe 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/UnfreezeCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/freeze/commands/UnfreezeCommand.java @@ -1,14 +1,13 @@ package mineplex.game.clans.clans.freeze.commands; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.freeze.ClansFreezeManager; -import org.bukkit.entity.Player; - /** * Command to unfreeze players */ @@ -16,7 +15,7 @@ public class UnfreezeCommand extends CommandBase { public UnfreezeCommand(ClansFreezeManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "unfreeze"); + super(plugin, ClansFreezeManager.UNFREEZE_COMMAND_PERMISSION, "unfreeze"); } @Override @@ -41,4 +40,4 @@ public class UnfreezeCommand extends CommandBase Plugin.unfreeze(target, caller); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/InvseeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/InvseeManager.java index ab8af7853..3a9ea7b47 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/InvseeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/InvseeManager.java @@ -1,6 +1,8 @@ package mineplex.game.clans.clans.invsee; import mineplex.core.MiniPlugin; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.UtilServer; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.invsee.commands.InvseeCommand; @@ -14,11 +16,23 @@ import java.util.UUID; public class InvseeManager extends MiniPlugin { + public static final String INVSEE_COMMAND_PERMISSION = "mineplex.clans.invsee.command"; + private final Map _viewing = new HashMap<>(); public InvseeManager(ClansManager manager) { super("Invsee Manager", manager.getPlugin()); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(INVSEE_COMMAND_PERMISSION), false, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(INVSEE_COMMAND_PERMISSION), true, true); } @Override @@ -60,4 +74,4 @@ public class InvseeManager extends MiniPlugin } UtilServer.Unregister(invseeInventory); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/commands/InvseeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/commands/InvseeCommand.java index 36b0466a8..c85271765 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/commands/InvseeCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/commands/InvseeCommand.java @@ -1,25 +1,27 @@ package mineplex.game.clans.clans.invsee.commands; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; + import com.mojang.authlib.GameProfile; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.invsee.InvseeManager; import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.WorldNBTStorage; -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; - -import java.util.UUID; public class InvseeCommand extends CommandBase { public InvseeCommand(InvseeManager plugin) { - super(plugin, Rank.CMOD, "invsee"); + super(plugin, InvseeManager.INVSEE_COMMAND_PERMISSION, "invsee"); } @Override @@ -27,7 +29,7 @@ public class InvseeCommand extends CommandBase { if (args.length == 0) { - UtilPlayer.message(caller, F.help("/invsee ", "View a player's inventory", Rank.CMOD)); + UtilPlayer.message(caller, F.help("/invsee ", "View a player's inventory", ChatColor.GOLD)); return; } UUID uuid = null; @@ -35,9 +37,7 @@ public class InvseeCommand extends CommandBase { uuid = UUID.fromString(args[0]); } - catch (IllegalArgumentException failed) - { - } + catch (IllegalArgumentException failed) {} OfflinePlayer exactPlayer = Bukkit.getServer().getPlayerExact(args[0]); if (exactPlayer == null) @@ -91,4 +91,4 @@ public class InvseeCommand extends CommandBase Plugin.doInvsee(exactPlayer, caller); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java index 61fcf7cd7..3db074dae 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/invsee/ui/InvseeInventory.java @@ -407,4 +407,4 @@ public class InvseeInventory implements Listener MAPPING_CRAFTING_REVERSE.put(craftingMapping[i], i); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java index 0100cb175..8e74774ad 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/MountManager.java @@ -26,9 +26,10 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandBase; import mineplex.core.common.Pair; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; @@ -50,6 +51,10 @@ import mineplex.serverdata.Utility; public class MountManager extends MiniDbClientPlugin { + public static final String MOUNT_COMMAND_PERMISSION = "mineplex.clans.mount.command"; + public static final String GIVE_MOUNT_COMMAND_PERMISSION = "mineplex.clans.mount.give"; + public static final String MOUNT_SKIN_UNLOCK_PERMISSION = "mineplex.clans.mount.unlockskins"; + private static final double[] JUMP_STARS = {0.8, 1, 1.2}; private static final double[] SPEED_STARS = {0.2, 0.27, 0.33}; private static final int[] STRENGTH_STARS = {1, 2, 3}; @@ -75,7 +80,7 @@ public class MountManager extends MiniDbClientPlugin final MountShop shop = new MountShop(this); - addCommand(new CommandBase(this, Rank.ALL, "mounts", "mount") + addCommand(new CommandBase(this, MOUNT_COMMAND_PERMISSION, "mounts", "mount") { @Override public void Execute(Player caller, String[] args) @@ -84,7 +89,7 @@ public class MountManager extends MiniDbClientPlugin } }); - addCommand(new CommandBase(this, Rank.ADMIN, "givemount") + addCommand(new CommandBase(this, GIVE_MOUNT_COMMAND_PERMISSION, "givemount") { @Override public void Execute(Player caller, String[] args) @@ -143,6 +148,17 @@ public class MountManager extends MiniDbClientPlugin caller.getInventory().addItem(new MountClaimToken(jump, speed, strength, type).toItem()); } }); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(MOUNT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_MOUNT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(MOUNT_SKIN_UNLOCK_PERMISSION), true, true); } public DonationManager getDonationManager() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountSkinPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountSkinPage.java index 64498e6c1..4ff28d999 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountSkinPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/mounts/gui/MountSkinPage.java @@ -8,7 +8,7 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.shop.page.ShopPageBase; @@ -47,7 +47,7 @@ public class MountSkinPage extends ShopPageBase private boolean hasUnlocked(Player player, SkinType type) { - if (getClientManager().Get(player).GetRank().has(Rank.ADMIN)) + if (getClientManager().getPermissionManager().hasPermission(player, GroupPermission.of(MountManager.MOUNT_SKIN_UNLOCK_PERMISSION))) { return true; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/ClansBlacklist.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/ClansBlacklist.java index 3cdc005f9..e609a1985 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/ClansBlacklist.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/ClansBlacklist.java @@ -6,13 +6,18 @@ import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.nameblacklist.commands.AddBlacklistCommand; import mineplex.game.clans.clans.nameblacklist.repository.ClanNameBlacklistRepository; public class ClansBlacklist extends MiniPlugin { + public static final String BLACKLIST_COMMAND_PERMISSION = "mineplex.clans.nameblacklist.command"; + private List _blacklist; private ClanNameBlacklistRepository _repository; @@ -23,6 +28,16 @@ public class ClansBlacklist extends MiniPlugin _repository = new ClanNameBlacklistRepository(plugin, this); runAsync(() -> _repository.loadNames(this::setBlacklist)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(BLACKLIST_COMMAND_PERMISSION), false, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BLACKLIST_COMMAND_PERMISSION), true, true); } // Fetch new blacklisted clans every 16 seconds (in case someone blacklists a clan name on a different server) @@ -59,4 +74,4 @@ public class ClansBlacklist extends MiniPlugin { return _repository; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/commands/AddBlacklistCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/commands/AddBlacklistCommand.java index e05417ff5..8f2cfe840 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/commands/AddBlacklistCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/commands/AddBlacklistCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.clans.nameblacklist.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -13,7 +12,7 @@ public class AddBlacklistCommand extends CommandBase { public AddBlacklistCommand(ClansBlacklist plugin) { - super(plugin, Rank.CMOD, "blacklistname"); + super(plugin, ClansBlacklist.BLACKLIST_COMMAND_PERMISSION, "blacklistname"); } @Override @@ -27,7 +26,8 @@ public class AddBlacklistCommand extends CommandBase { final String blacklist = args[0]; - Plugin.runAsync(() -> { + Plugin.runAsync(() -> + { Plugin.getRepository().add(blacklist, caller.getName()); UtilPlayer.message(caller, F.main("Clans", "Successfully added " + F.elem(blacklist) + " to the clan name blacklist.")); }); @@ -37,4 +37,4 @@ public class AddBlacklistCommand extends CommandBase UtilPlayer.message(caller, C.cGold + "/blacklistname - Blacklists a clan name."); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/repository/ClanNameBlacklistRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/repository/ClanNameBlacklistRepository.java index 662900a31..f9924092e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/repository/ClanNameBlacklistRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nameblacklist/repository/ClanNameBlacklistRepository.java @@ -7,7 +7,6 @@ import java.util.List; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.common.util.Callback; -import mineplex.core.database.MinecraftRepository; import mineplex.game.clans.clans.nameblacklist.ClansBlacklist; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; @@ -47,7 +46,8 @@ public class ClanNameBlacklistRepository extends RepositoryBase public void loadNames(final Callback> callback) { - executeQuery(GET, resultSet -> { + executeQuery(GET, resultSet -> + { final List list = new ArrayList<>(); while (resultSet.next()) @@ -66,6 +66,5 @@ public class ClanNameBlacklistRepository extends RepositoryBase protected void update() { executeUpdate(CREATE); - } - -} + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java index 77d53a997..5472ba7a0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/NetherManager.java @@ -34,7 +34,8 @@ import org.bukkit.potion.PotionEffectType; import com.google.common.collect.Lists; import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.generator.VoidGenerator; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -61,6 +62,14 @@ import mineplex.game.clans.spawn.Spawn; */ public class NetherManager extends MiniPlugin { + public static final String PORTAL_COMMAND_PERMISSION = "mineplex.clans.nether.command"; + public static final String PORTAL_CLOSE_COMMAND_PERMISSION = "mineplex.clans.nether.close"; + public static final String PORTAL_CREATE_COMMAND_PERMISSION = "mineplex.clans.nether.create"; + public static final String PORTAL_DELETE_COMMAND_PERMISSION = "mineplex.clans.nether.delete"; + public static final String PORTAL_FORCE_COMMAND_PERMISSION = "mineplex.clans.nether.force"; + public static final String PORTAL_LIST_COMMAND_PERMISSION = "mineplex.clans.nether.list"; + public static final String PORTAL_OPEN_COMMAND_PERMISSION = "mineplex.clans.nether.open"; + private static final long PORTAL_OPEN_DURATION = UtilTime.convert(10, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); private static final String CLAIM_WAND_NAME = C.cRedB + "Portal Claim Wand"; private static final String[] CLAIM_WAND_LORE = new String[] {C.cYellow + "Left Click to select the Portal's first corner", C.cYellow + "Right Click to select the Portal's second corner"}; @@ -88,6 +97,21 @@ public class NetherManager extends MiniPlugin _miniboss = new NetherMinibossManager(this); addCommand(new PortalCommand(this)); addCommand(new ForceTeleportCommand(this)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PORTAL_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PORTAL_CLOSE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PORTAL_CREATE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PORTAL_DELETE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PORTAL_FORCE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PORTAL_LIST_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(PORTAL_OPEN_COMMAND_PERMISSION), true, true); } private void begin() @@ -542,7 +566,7 @@ public class NetherManager extends MiniPlugin { return; } - if (!ClansManager.getInstance().getClientManager().hasRank(event.getPlayer(), Rank.ADMIN)) + if (!ClansManager.getInstance().getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(PORTAL_CREATE_COMMAND_PERMISSION))) { return; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java index d6a456fad..def457994 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CloseCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.clans.nether.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.nether.NetherManager; @@ -15,7 +14,7 @@ public class CloseCommand extends CommandBase { public CloseCommand(NetherManager plugin) { - super(plugin, Rank.ADMIN, "close"); + super(plugin, NetherManager.PORTAL_CLOSE_COMMAND_PERMISSION, "close"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java index c7395e4f3..dc94f32b0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/CreateCommand.java @@ -1,13 +1,12 @@ package mineplex.game.clans.clans.nether.command; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.nether.NetherManager; -import org.bukkit.entity.Player; - /** * Command to create a nether portal */ @@ -15,7 +14,7 @@ public class CreateCommand extends CommandBase { public CreateCommand(NetherManager plugin) { - super(plugin, Rank.ADMIN, "create"); + super(plugin, NetherManager.PORTAL_CREATE_COMMAND_PERMISSION, "create"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java index cb513218c..018b2993c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/DeleteCommand.java @@ -1,14 +1,13 @@ package mineplex.game.clans.clans.nether.command; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.nether.NetherManager; import mineplex.game.clans.clans.nether.NetherPortal; -import org.bukkit.entity.Player; - /** * Command to delete a nether portal */ @@ -16,7 +15,7 @@ public class DeleteCommand extends CommandBase { public DeleteCommand(NetherManager plugin) { - super(plugin, Rank.ADMIN, "delete", "remove"); + super(plugin, NetherManager.PORTAL_DELETE_COMMAND_PERMISSION, "delete", "remove"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java index 0bc4ac0be..571c4d530 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ForceTeleportCommand.java @@ -1,7 +1,9 @@ package mineplex.game.clans.clans.nether.command; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffectType; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; @@ -11,9 +13,6 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.nether.NetherManager; import mineplex.game.clans.spawn.Spawn; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffectType; - /** * Command to artificially portal */ @@ -21,7 +20,7 @@ public class ForceTeleportCommand extends CommandBase { public ForceTeleportCommand(NetherManager plugin) { - super(plugin, Rank.ADMIN, "forcePortal"); + super(plugin, NetherManager.PORTAL_FORCE_COMMAND_PERMISSION, "forcePortal"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java index d475cf342..c78dc028d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/ListCommand.java @@ -1,11 +1,10 @@ package mineplex.game.clans.clans.nether.command; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.game.clans.clans.nether.NetherManager; - import org.bukkit.entity.Player; +import mineplex.core.command.CommandBase; +import mineplex.game.clans.clans.nether.NetherManager; + /** * Command to list all nether portals */ @@ -13,7 +12,7 @@ public class ListCommand extends CommandBase { public ListCommand(NetherManager plugin) { - super(plugin, Rank.ADMIN, "list"); + super(plugin, NetherManager.PORTAL_LIST_COMMAND_PERMISSION, "list"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java index f39d5276f..c99b0b67d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/PortalCommand.java @@ -1,13 +1,13 @@ package mineplex.game.clans.clans.nether.command; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.nether.NetherManager; -import org.bukkit.entity.Player; - /** * Base portal command */ @@ -15,7 +15,8 @@ public class PortalCommand extends MultiCommandBase { public PortalCommand(NetherManager plugin) { - super(plugin, Rank.ADMIN, "netherportal", "portal"); + super(plugin, NetherManager.PORTAL_COMMAND_PERMISSION, "netherportal", "portal"); + AddCommand(new CreateCommand(plugin)); AddCommand(new DeleteCommand(plugin)); AddCommand(new ListCommand(plugin)); @@ -27,11 +28,11 @@ public class PortalCommand extends MultiCommandBase @Override protected void Help(Player caller, String[] args) { - UtilPlayer.message(caller, F.help("/" + _aliasUsed + " spawn", "Forces a Nether Portal to spawn", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/" + _aliasUsed + " close", "Closes all Nether Portals", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/" + _aliasUsed + " list", "Lists all loaded Nether Portals", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/" + _aliasUsed + " wand", "Gives you a Nether Portal claim wand", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/" + _aliasUsed + " create", "Creates a Nether Portal with the corners you have selected", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/" + _aliasUsed + " delete", "Deletes a loaded Nether Portal", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " spawn", "Forces a Nether Portal to spawn", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " close", "Closes all Nether Portals", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " list", "Lists all loaded Nether Portals", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " wand", "Gives you a Nether Portal claim wand", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " create", "Creates a Nether Portal with the corners you have selected", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " delete", "Deletes a loaded Nether Portal", ChatColor.DARK_RED)); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java index 2763dff60..e75b00831 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/SpawnCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.clans.nether.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.nether.NetherManager; @@ -15,7 +14,7 @@ public class SpawnCommand extends CommandBase { public SpawnCommand(NetherManager plugin) { - super(plugin, Rank.ADMIN, "spawn"); + super(plugin, NetherManager.PORTAL_OPEN_COMMAND_PERMISSION, "spawn"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java index ef57df1db..f9f01facf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/nether/command/WandCommand.java @@ -1,11 +1,10 @@ package mineplex.game.clans.clans.nether.command; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.game.clans.clans.nether.NetherManager; - import org.bukkit.entity.Player; +import mineplex.core.command.CommandBase; +import mineplex.game.clans.clans.nether.NetherManager; + /** * Command to give yourself a portal creation wand */ @@ -13,7 +12,7 @@ public class WandCommand extends CommandBase { public WandCommand(NetherManager plugin) { - super(plugin, Rank.ADMIN, "wand"); + super(plugin, NetherManager.PORTAL_CREATE_COMMAND_PERMISSION, "wand"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverData.java index 8e9e14fe0..1754224e6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverData.java @@ -26,4 +26,4 @@ public class ObserverData { return _settings; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java index 50ad63fdf..88674c53a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java @@ -19,16 +19,18 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.observer.command.ObserverCommand; -import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.minecraft.game.core.condition.ConditionManager; public class ObserverManager extends MiniPlugin { + public static final String OBSERVE_COMMAND_PERMISSION = "mineplex.clans.observe.command"; + // Used to Cloak Players private ConditionManager _conditionManager; private ClansManager _clansManager; @@ -40,7 +42,16 @@ public class ObserverManager extends MiniPlugin _conditionManager = conditionManager; _clansManager = clansManager; - _observerMap = new HashMap(); + _observerMap = new HashMap<>(); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("helper"), GroupPermission.of(OBSERVE_COMMAND_PERMISSION), false, true); } public void setObserver(Player player) @@ -79,7 +90,9 @@ public class ObserverManager extends MiniPlugin public void onDamage(EntityDamageByEntityEvent event) { if (_observerMap.containsKey(event.getDamager()) || _observerMap.containsKey(event.getEntity())) + { event.setCancelled(true); + } } @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @@ -116,8 +129,11 @@ public class ObserverManager extends MiniPlugin if (data != null) { if (!data.getSettings().contains(ObserverSettings.CAN_BREAK_BLOCKS)) + { event.setCancelled(true); - } } + } + } + } @EventHandler public void onInventoryClick(InventoryClickEvent event) @@ -127,7 +143,9 @@ public class ObserverManager extends MiniPlugin if (data != null) { if (!data.getSettings().contains(ObserverSettings.CAN_CLICK_INVENTORY)) + { event.setCancelled(true); + } } } @@ -139,7 +157,9 @@ public class ObserverManager extends MiniPlugin if (data != null) { if (!data.getSettings().contains(ObserverSettings.CAN_PICKUP_ITEMS)) + { event.setCancelled(true); + } } } @@ -179,4 +199,4 @@ public class ObserverManager extends MiniPlugin { addCommand(new ObserverCommand(this)); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverSettings.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverSettings.java index 08c0628a1..23bfc046b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverSettings.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverSettings.java @@ -1,9 +1,5 @@ package mineplex.game.clans.clans.observer; -import java.util.EnumSet; - -import mineplex.core.common.Rank; - public enum ObserverSettings { CAN_OPEN_CHESTS, @@ -11,13 +7,4 @@ public enum ObserverSettings CAN_INTERACT, CAN_PICKUP_ITEMS, CAN_CLICK_INVENTORY; - - - public static EnumSet getSettings(Rank rank) - { - if (rank.has(Rank.DEVELOPER)) - return EnumSet.of(CAN_OPEN_CHESTS, CAN_BREAK_BLOCKS); - - return EnumSet.noneOf(ObserverSettings.class); - } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/command/ObserverCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/command/ObserverCommand.java index e4a016c1f..1d9a3a9e9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/command/ObserverCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/command/ObserverCommand.java @@ -3,18 +3,15 @@ package mineplex.game.clans.clans.observer.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.clans.observer.ObserverManager; public class ObserverCommand extends CommandBase { public ObserverCommand(ObserverManager plugin) { - super(plugin, Rank.HELPER, "observer", "o"); + super(plugin, ObserverManager.OBSERVE_COMMAND_PERMISSION, "observer", "o"); } @Override @@ -31,7 +28,9 @@ public class ObserverCommand extends CommandBase else { if (!Plugin.canEnterObserverMode(caller, true)) + { return; + } Plugin.setObserver(caller); UtilPlayer.message(caller, F.main("Observer", "You have entered " + F.elem("Observer Mode"))); @@ -55,9 +54,7 @@ public class ObserverCommand extends CommandBase { UtilPlayer.message(caller, F.main("Observer", "You must enter " + F.elem("Observer Mode") + " to teleport")); } - } } - } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java index dcbad45bd..e7a805574 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/PlayingClient.java @@ -15,4 +15,4 @@ public class PlayingClient StartTime = System.currentTimeMillis(); FirstSession = taskManager.hasCompletedTask(player, ClansPlayerTasks.FIRST_SESSION.id()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java index f85a8fe52..df959ce48 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java @@ -1,5 +1,7 @@ package mineplex.game.clans.clans.playtime; +import java.util.UUID; + import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -8,16 +10,18 @@ import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.MiniClientPlugin; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.stats.StatsManager; import mineplex.core.task.TaskManager; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansPlayerStats; import mineplex.game.clans.clans.playtime.command.PlayTimeCommand; -import java.util.UUID; - public class Playtime extends MiniClientPlugin { + public static final String CLANS_TIME_COMMAND_PERMISSION = "mineplex.clans.playtime.command"; + private StatsManager _statsManager; public Playtime(ClansManager clans, StatsManager statsManager) @@ -27,6 +31,15 @@ public class Playtime extends MiniClientPlugin _statsManager = statsManager; addCommand(new PlayTimeCommand(_statsManager, this)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _statsManager.getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(CLANS_TIME_COMMAND_PERMISSION), true, true); } @Override @@ -85,4 +98,4 @@ public class Playtime extends MiniClientPlugin { return (System.currentTimeMillis() - Get(player).StartTime) / 1000; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/PlayTimeCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/PlayTimeCommand.java index 61b9fc451..29ae7f027 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/PlayTimeCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/PlayTimeCommand.java @@ -1,15 +1,11 @@ package mineplex.game.clans.clans.playtime.command; -import java.sql.SQLException; - import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; -import mineplex.core.stats.PlayerStats; import mineplex.core.stats.StatsManager; import mineplex.game.clans.clans.ClansPlayerStats; import mineplex.game.clans.clans.playtime.Playtime; @@ -20,7 +16,7 @@ public class PlayTimeCommand extends CommandBase public PlayTimeCommand(StatsManager plugin, Playtime tracker) { - super(plugin, Rank.MODERATOR, "clanstime"); + super(plugin, Playtime.CLANS_TIME_COMMAND_PERMISSION, "clanstime"); _playTracker = tracker; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java index 5b2f870b6..a209bdeeb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java @@ -77,12 +77,15 @@ public class ClansPlayerScoreboard extends PlayerScoreboard { if (otherPlayer.getGameMode().equals(GameMode.CREATIVE)) { - String teamName = UtilText.trim(16, _clansManager.getClientManager().Get(otherPlayer).GetRank().getRawTag() + "CREATIVE"); + String teamName = UtilText.trim(16, _clansManager.getClientManager().Get(otherPlayer).getPrimaryGroup().getIdentifier() + "CREATIVE"); Team team = scoreboard.getTeam(teamName); if (team == null) { team = scoreboard.registerNewTeam(teamName); - team.setPrefix(UtilText.trim(16, _clansManager.getClientManager().Get(otherPlayer).GetRank().getTag(true, true) + ChatColor.RESET + " ")); + if (!_clansManager.getClientManager().Get(otherPlayer).getPrimaryGroup().getDisplay(false, false, false, false).isEmpty()) + { + team.setPrefix(UtilText.trim(16, _clansManager.getClientManager().Get(otherPlayer).getPrimaryGroup().getDisplay(true, true, true, false) + ChatColor.RESET + " ")); + } team.setSuffix(C.cRed + " STAFF MODE"); } @@ -134,4 +137,4 @@ public class ClansPlayerScoreboard extends PlayerScoreboard { return (clanInfo == null ? "" : clanInfo.getId() + "") + relation.ordinal(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java index d3e6f3bc4..80d73923f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java @@ -7,7 +7,7 @@ import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.account.event.OnlineRankUpdateEvent; +import mineplex.core.account.event.OnlinePrimaryGroupUpdateEvent; import mineplex.core.donation.DonationManager; import mineplex.core.thereallyoldscoreboardapiweshouldremove.PlayerScoreboard; import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardData; @@ -65,27 +65,23 @@ public class ClansScoreboardManager extends ScoreboardManager @EventHandler public void onGamemodeChanged(PlayerGameModeChangeEvent event) { - Bukkit.getScheduler().scheduleSyncDelayedTask(_clansManager.getPlugin(), new Runnable() { - public void run() + Bukkit.getScheduler().scheduleSyncDelayedTask(_clansManager.getPlugin(), () -> + { + for (Player player : Bukkit.getOnlinePlayers()) { - for (Player player : Bukkit.getOnlinePlayers()) - { - refresh(player); - } + refresh(player); } }, 20); } @EventHandler - public void onRankUpdate(OnlineRankUpdateEvent event) + public void onRankUpdate(OnlinePrimaryGroupUpdateEvent event) { - Bukkit.getScheduler().scheduleSyncDelayedTask(_clansManager.getPlugin(), new Runnable() { - public void run() + Bukkit.getScheduler().scheduleSyncDelayedTask(_clansManager.getPlugin(), () -> + { + for (Player player : Bukkit.getOnlinePlayers()) { - for (Player player : Bukkit.getOnlinePlayers()) - { - refresh(player); - } + refresh(player); } }, 20); } @@ -114,4 +110,4 @@ public class ClansScoreboardManager extends ScoreboardManager { ((ClansPlayerScoreboard) getCurrentScoreboard(player)).refreshTeams(player); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java index 223266074..1b6aae164 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java @@ -3,6 +3,8 @@ package mineplex.game.clans.clans.siege; import java.util.Stack; import mineplex.core.MiniPlugin; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilInv; @@ -37,6 +39,8 @@ import com.google.gson.Gson; public class SiegeManager extends MiniPlugin { + public static final String GIVE_CANNON_COMMAND_PERMISSION = "mineplex.clans.siege.givecannon"; + private ClansManager _clansManager; private OutpostManager _outpostManager; @@ -88,6 +92,15 @@ public class SiegeManager extends MiniPlugin ); addCommand(new GiveWeaponCommand(this)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_CANNON_COMMAND_PERMISSION), true, true); } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/command/GiveWeaponCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/command/GiveWeaponCommand.java index 2a2589632..8544c2a6d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/command/GiveWeaponCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/command/GiveWeaponCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.clans.siege.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; @@ -14,7 +13,7 @@ public class GiveWeaponCommand extends CommandBase { public GiveWeaponCommand(SiegeManager plugin) { - super(plugin, Rank.ADMIN, "giveweapon", "siegeweapon", "givecannon"); + super(plugin, SiegeManager.GIVE_CANNON_COMMAND_PERMISSION, "giveweapon", "siegeweapon", "givecannon"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java index 9a558b8c5..9814e04c7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java @@ -18,7 +18,7 @@ import org.bukkit.util.Vector; import com.google.common.collect.Lists; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -285,7 +285,7 @@ public class Cannon extends SiegeWeapon event.setCancelled(true); for (Player p : Bukkit.getOnlinePlayers()) { - if (ClansManager.getInstance().getClientManager().hasRank(p, Rank.HELPER)) + if (ClansManager.getInstance().getClientManager().getPermissionManager().hasPermission(p, GroupPermission.of(ClansGame.DUPE_ALERT_PERMISSION))) { UtilPlayer.message(p, F.elem("[" + C.cRedB + "!" + C.cGray + "] ") + event.getWhoClicked().getName() + " just tried to use a duped item/block!"); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index 05011fe57..b0bc05f01 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -7,7 +7,17 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockDispenseEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.core.MiniPlugin; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -30,16 +40,10 @@ import mineplex.game.clans.clans.war.event.WarSiegeEndEvent; import mineplex.game.clans.clans.war.event.WarSiegeStartEvent; import mineplex.game.clans.core.war.ClanWarData; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.BlockDispenseEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.plugin.java.JavaPlugin; - public class WarManager extends MiniPlugin implements ScoreboardElement { + public static final String WAR_POINT_COMMAND_PERMISSION = "mineplex.clans.war.command"; + public static final int WAR_START_POINTS = 0; public static final int WAR_FINISH_POINTS = 25; public static final long INVADE_LENGTH = 60000L * 30; // 30 Minutes @@ -59,6 +63,15 @@ public class WarManager extends MiniPlugin implements ScoreboardElement _clansManager = clansManager; _besiegedMap = new HashMap<>(); _besiegerMap = new HashMap<>(); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(WAR_POINT_COMMAND_PERMISSION), true, true); } public ClansManager getClansManager() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/command/WarPointsCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/command/WarPointsCommand.java index e44c0f21c..7fa506d3a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/command/WarPointsCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/command/WarPointsCommand.java @@ -3,21 +3,20 @@ package mineplex.game.clans.clans.war.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.core.war.ClanWarData; import mineplex.game.clans.clans.war.WarManager; +import mineplex.game.clans.core.war.ClanWarData; public class WarPointsCommand extends CommandBase { public WarPointsCommand(WarManager plugin) { - super(plugin, Rank.ALL, "warpoints", "wp", "dom"); + super(plugin, WarManager.WAR_POINT_COMMAND_PERMISSION, "warpoints", "wp", "dom"); } @Override @@ -58,9 +57,6 @@ public class WarPointsCommand extends CommandBase UtilPlayer.message(caller, F.main("War", "War Points: " + clan.getFormattedWarPoints(search))); UtilPlayer.message(caller, F.main("War", "Age: " + F.elem(UtilTime.convertString(System.currentTimeMillis() - war.getTimeFormed().getTime(), 1, UtilTime.TimeUnit.FIT)))); } - } - - } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarEndEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarEndEvent.java index cd3a356bd..d9fbc4cb6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarEndEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarEndEvent.java @@ -23,4 +23,4 @@ public class WarEndEvent extends Event private static final HandlerList handlers = new HandlerList(); public static HandlerList getHandlerList() { return handlers; } public HandlerList getHandlers() { return handlers; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarStartEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarStartEvent.java index dbfdaf050..131021acf 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarStartEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/event/WarStartEvent.java @@ -23,4 +23,4 @@ public class WarStartEvent extends Event private static final HandlerList handlers = new HandlerList(); public static HandlerList getHandlerList() { return handlers; } public HandlerList getHandlers() { return handlers; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index 032d86c2f..a7ed0cde0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -13,6 +13,8 @@ import org.bukkit.plugin.java.JavaPlugin; import com.google.common.collect.Lists; import mineplex.core.MiniPlugin; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.common.util.C; @@ -37,6 +39,10 @@ import mineplex.minecraft.game.core.damage.DamageManager; public class WorldEventManager extends MiniPlugin implements ScoreboardElement { + public static final String WORLD_EVENT_COMMAND_PERMISSION = "mineplex.clans.worldevent.command"; + public static final String START_EVENT_COMMAND_PERMISSION = "mineplex.clans.worldevent.start"; + public static final String STOP_EVENT_COMMAND_PERMISSION = "mineplex.clans.worldevent.stop"; + private final List _runningEvents; private Random _random; @@ -73,6 +79,17 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement _raidManager = new RaidManager(plugin); updateNextEventTime(); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(WORLD_EVENT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(START_EVENT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(STOP_EVENT_COMMAND_PERMISSION), true, true); } public void addCommands() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java index 58c63968a..a7d0be727 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/ClearCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.clans.worldevent.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.worldevent.WorldEventManager; @@ -12,7 +11,7 @@ public class ClearCommand extends CommandBase { public ClearCommand(WorldEventManager plugin) { - super(plugin, Rank.ADMIN, "clear"); + super(plugin, WorldEventManager.STOP_EVENT_COMMAND_PERMISSION, "clear"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java index 1c74e7e5b..790d1133d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/RandomCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.clans.worldevent.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.worldevent.WorldEventManager; @@ -16,7 +15,7 @@ public class RandomCommand extends CommandBase { public RandomCommand(WorldEventManager plugin) { - super(plugin, Rank.ADMIN, "random", "rand"); + super(plugin, WorldEventManager.START_EVENT_COMMAND_PERMISSION, "random", "rand"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java index 1db7667de..c9b9d4e9f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.clans.worldevent.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -15,7 +14,7 @@ public class StartCommand extends CommandBase { public StartCommand(WorldEventManager plugin) { - super(plugin, Rank.ADMIN, "start", "create"); + super(plugin, WorldEventManager.START_EVENT_COMMAND_PERMISSION, "start", "create"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java index 62e42c6e8..c9b4cbba5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/WorldEventCommand.java @@ -1,18 +1,18 @@ package mineplex.game.clans.clans.worldevent.command; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.worldevent.WorldEventManager; public class WorldEventCommand extends MultiCommandBase { public WorldEventCommand(WorldEventManager plugin) { - super(plugin, Rank.ADMIN, "worldevent", "we", "event"); + super(plugin, WorldEventManager.WORLD_EVENT_COMMAND_PERMISSION, "worldevent", "we", "event"); AddCommand(new StartCommand(Plugin)); AddCommand(new ClearCommand(Plugin)); @@ -22,8 +22,8 @@ public class WorldEventCommand extends MultiCommandBase @Override protected void Help(Player caller, String[] args) { - UtilPlayer.message(caller, F.help("/" + _aliasUsed + " start ", "Start a World Event", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/" + _aliasUsed + " clear", "Clears all World Events", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/" + _aliasUsed + " random", "Starts a random World Event", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " start ", "Start a World Event", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " clear", "Clears all World Events", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/" + _aliasUsed + " random", "Starts a random World Event", ChatColor.DARK_RED)); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java index f4363b0f5..371f23b2f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java @@ -18,6 +18,8 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitTask; import mineplex.core.MiniPlugin; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -37,6 +39,8 @@ import mineplex.minecraft.game.core.damage.DamageManager; public class RaidManager extends MiniPlugin { + public static final String START_RAID_COMMAND_PERMISSION = "mineplex.clans.raids.startcommand"; + private static final int MAX_PARTICIPANTS = 10; private Set _raids = new HashSet<>(); @@ -54,6 +58,15 @@ public class RaidManager extends MiniPlugin items.add(new ItemBuilder(Material.IRON_INGOT).setAmount(2).setTitle(C.cDRedB + "Old Silver Token").setLore(C.cRed + "This token pulses with an evil aura.").setGlow(true).build()); _altars.add(new RaidAltar(new Location(Bukkit.getWorld("world"), 361, 57, -990).getBlock(), RaidType.CHARLES_WITHERTON, items)); } + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(START_RAID_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/command/StartRaidCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/command/StartRaidCommand.java index 5701d38a2..f8f7fe0dc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/command/StartRaidCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/command/StartRaidCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.clans.worldevent.raid.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -14,7 +13,7 @@ public class StartRaidCommand extends CommandBase { public StartRaidCommand(RaidManager plugin) { - super(plugin, Rank.ADMIN, "startraid"); + super(plugin, RaidManager.START_RAID_COMMAND_PERMISSION, "startraid"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java index 3455f5d58..b8ffdc98d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.economy; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -12,7 +11,7 @@ public class GoldCommand extends CommandBase { public GoldCommand(GoldManager plugin) { - super(plugin, Rank.ADMIN, "givegold"); + super(plugin, GoldManager.GIVE_GOLD_COMMAND_PERMISSION, "givegold"); } @Override @@ -81,4 +80,4 @@ public class GoldCommand extends CommandBase } }, accountId, targetName, gold, true); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java index db67d9a1e..d13d69a66 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java @@ -27,6 +27,8 @@ import org.bukkit.util.Vector; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -44,6 +46,8 @@ import mineplex.game.clans.shop.bank.BankShop; public class GoldManager extends MiniDbClientPlugin { + public static final String GIVE_GOLD_COMMAND_PERMISSION = "mineplex.clans.gold.give"; + public static final String SET_GOLD_COMMAND_PERMISSION = "mineplex.clans.gold.set"; public static final double GEM_CONVERSION_RATE = 16; // The number of gold coins when converted from a single gem public static final double DEATH_TAX = 0.04d; // Percentage of gold lost on death @@ -74,6 +78,16 @@ public class GoldManager extends MiniDbClientPlugin _itemSet = new HashSet(); _playerPickupMap = new HashMap(); _bankShop = new BankShop(plugin, clientManager, donationManager); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_GOLD_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SET_GOLD_COMMAND_PERMISSION), true, true); } @Override @@ -95,26 +109,18 @@ public class GoldManager extends MiniDbClientPlugin if (droppedGold > 0) { - deductGold(new Callback() + deductGold(success -> { - public void run(Boolean success) + runSync(() -> { - runSync(new Runnable() - { - @Override - public void run() - { - GoldManager.notify(player, "You dropped " + F.elem(droppedGold + "") + " gold on your death!"); - - dropGold(deathLocation, droppedGold); - } - }); -// if (killer != null) -// { -// addGold(killer, droppedGold); -// GoldManager.notify(killer, String.format("You looted %d gold off of %s's corpse!", droppedGold, player.getName())); -// } - } + GoldManager.notify(player, "You dropped " + F.elem(droppedGold + "") + " gold on your death!"); + dropGold(deathLocation, droppedGold); + }); + // if (killer != null) + // { + // addGold(killer, droppedGold); + // GoldManager.notify(killer, String.format("You looted %d gold off of %s's corpse!", droppedGold, player.getName())); + // } }, player, droppedGold); } } @@ -287,19 +293,16 @@ public class GoldManager extends MiniDbClientPlugin public void purchaseToken(final Player player, final int tokenValue) { final GoldToken token = new GoldToken(tokenValue); - deductGold(new Callback() + deductGold(success -> { - public void run(Boolean success) + if (success.booleanValue()) { - if (success) - { - player.getInventory().addItem(token.toItemStack()); - GoldManager.notify(player, String.format("You have purchased a gold token worth %dg!", tokenValue)); - } - else - { - GoldManager.notify(player, String.format("You have purchased a gold token worth %dg!", tokenValue)); - } + player.getInventory().addItem(token.toItemStack()); + GoldManager.notify(player, String.format("You have purchased a gold token worth %dg!", tokenValue)); + } + else + { + GoldManager.notify(player, String.format("You have purchased a gold token worth %dg!", tokenValue)); } }, player, tokenValue); } @@ -328,7 +331,7 @@ public class GoldManager extends MiniDbClientPlugin { _donationManager.getGoldRepository().setGold(success -> { - if (success) + if (success.booleanValue()) { if (updateTotal) { @@ -390,7 +393,7 @@ public class GoldManager extends MiniDbClientPlugin _donationManager.getGoldRepository().rewardGold(success -> { - if (success) + if (success.booleanValue()) { if (updateTotal) { @@ -426,24 +429,6 @@ public class GoldManager extends MiniDbClientPlugin if (resultSet.next()) { Get(playerUUID).setBalance(resultSet.getInt(1)); - - if (resultSet.getInt(1) < 0) - { - setGold(new Callback() - { - public void run(Boolean success) - { - if (success) - { - System.out.println("Fixed negative gold balance for " + playerName + "!"); - } - else - { - System.out.println("Failed to fix negative gold balance for " + playerName + "!"); - } - } - }, "", playerName, accountId, 0, true); - } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/SetGoldCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/SetGoldCommand.java index b44c0d834..d49d0039b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/SetGoldCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/SetGoldCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.economy; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -12,7 +11,7 @@ public class SetGoldCommand extends CommandBase { public SetGoldCommand(GoldManager plugin) { - super(plugin, Rank.ADMIN, "setgold"); + super(plugin, GoldManager.SET_GOLD_COMMAND_PERMISSION, "setgold"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java index 48921d8a4..3b6d1333d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java @@ -6,6 +6,7 @@ import java.util.Map; import java.util.Set; import java.util.WeakHashMap; +import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; @@ -18,7 +19,8 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; @@ -37,21 +39,23 @@ import mineplex.minecraft.game.core.condition.ConditionManager; public class FieldBlock extends MiniPlugin { + public static final String FIELD_BLOCK_COMMAND_PERMISSION = "mineplex.clans.field.block"; + private ConditionFactory _conditionFactory; private Energy _energy; private FieldRepository _repository; private Map _blocks; private ClansManager _clansManager; - private Set _active = new HashSet(); + private Set _active = new HashSet<>(); //Player Info - private Map _title = new WeakHashMap(); - private Map _stock = new WeakHashMap(); - private Map _regen = new WeakHashMap(); - private Map _emptyId = new WeakHashMap(); - private Map _emptyData = new WeakHashMap(); - private Map _lootString = new WeakHashMap(); + private Map _title = new WeakHashMap<>(); + private Map _stock = new WeakHashMap<>(); + private Map _regen = new WeakHashMap<>(); + private Map _emptyId = new WeakHashMap<>(); + private Map _emptyData = new WeakHashMap<>(); + private Map _lootString = new WeakHashMap<>(); private String _serverName; @@ -64,11 +68,19 @@ public class FieldBlock extends MiniPlugin _energy = energy; _repository = repository; _clansManager = clansManager; - _blocks = new HashMap(); + _blocks = new HashMap<>(); _serverName = serverName; load(); + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FIELD_BLOCK_COMMAND_PERMISSION), true, true); } @Override @@ -102,12 +114,12 @@ public class FieldBlock extends MiniPlugin public void help(Player caller) { UtilPlayer.message(caller, F.main(_moduleName, "Commands List;")); - UtilPlayer.message(caller, F.help("/fo toggle", "Toggle Tools", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fb loot ", "Set Loot", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fb empty ", "Set Empty Block", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fb stock <#>", "Set Stock Max", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fb regen ", "Set Stock Regen", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fb wipe", "Delete All Block Fields (Database)", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/fo toggle", "Toggle Tools", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fb loot ", "Set Loot", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fb empty ", "Set Empty Block", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fb stock <#>", "Set Stock Max", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fb regen ", "Set Stock Regen", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fb wipe", "Delete All Block Fields (Database)", ChatColor.DARK_RED)); } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldMonster.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldMonster.java index ba314af44..bfd4e64eb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldMonster.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldMonster.java @@ -5,6 +5,7 @@ import java.util.Map; import java.util.Set; import java.util.WeakHashMap; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -12,13 +13,15 @@ import org.bukkit.event.HandlerList; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilWorld; import mineplex.core.creature.Creature; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.fields.commands.FieldMonsterCommand; import mineplex.game.clans.fields.monsters.FieldMonsterBase; import mineplex.game.clans.fields.repository.FieldMonsterToken; @@ -26,6 +29,8 @@ import mineplex.game.clans.fields.repository.FieldRepository; public class FieldMonster extends MiniPlugin { + public static final String FIELD_MONSTER_COMMAND_PERMISSION = "mineplex.clans.field.monster"; + private Creature _creature; private FieldRepository _repository; private Set _pits; @@ -43,6 +48,14 @@ public class FieldMonster extends MiniPlugin _serverName = serverName; Load(); + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FIELD_MONSTER_COMMAND_PERMISSION), true, true); } @Override @@ -54,17 +67,17 @@ public class FieldMonster extends MiniPlugin public void Help(Player caller) { UtilPlayer.message(caller, F.main(getName(), "Commands List;")); - UtilPlayer.message(caller, F.help("/fm type ", "Set Monster Type", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fm max <#>", "Set Monster Limit", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fm rate ", "Set Monster Rate", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fm radius <#>", "Set Area Radius", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fm height <#>", "Set Area Height", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fm create ", "Create at your Location", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fm delete ", "Delete Field", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fm list", "List Monster Fields", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fm info ", "Display Monster Field", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fm kill", "Kills all Field Monsters", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fm wipe", "Delete All Monster Field (Database)", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/fm type ", "Set Monster Type", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fm max <#>", "Set Monster Limit", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fm rate ", "Set Monster Rate", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fm radius <#>", "Set Area Radius", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fm height <#>", "Set Area Height", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fm create ", "Create at your Location", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fm delete ", "Delete Field", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fm list", "List Monster Fields", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fm info ", "Display Monster Field", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fm kill", "Kills all Field Monsters", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fm wipe", "Delete All Monster Field (Database)", ChatColor.DARK_RED)); } public void Create(Player caller, String name) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldOre.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldOre.java index ccc507af6..d113291e7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldOre.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldOre.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; @@ -19,7 +20,8 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; @@ -30,12 +32,15 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.fields.commands.FieldOreCommand; import mineplex.game.clans.fields.repository.FieldOreToken; import mineplex.game.clans.fields.repository.FieldRepository; public class FieldOre extends MiniPlugin { + public static final String FIELD_ORE_COMMAND_PERMISSION = "mineplex.clans.field.ore"; + private FieldRepository _repository; private Set _active = new HashSet(); @@ -57,6 +62,14 @@ public class FieldOre extends MiniPlugin _serverName = serverName; load(); + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FIELD_ORE_COMMAND_PERMISSION), true, true); } @Override @@ -68,11 +81,11 @@ public class FieldOre extends MiniPlugin public void help(Player caller) { UtilPlayer.message(caller, F.main(_moduleName, "Commands List;")); - UtilPlayer.message(caller, F.help("/fo toggle", "Toggle Tools", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fo list", "List Ores", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fo fill", "Set Ores to Ore", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fo reset", "Reset Ores to Stone", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/fo wipe", "Delete All Ore Fields (Database)", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/fo toggle", "Toggle Tools", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fo list", "List Ores", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fo fill", "Set Ores to Ore", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fo reset", "Reset Ores to Stone", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/fo wipe", "Delete All Ore Fields (Database)", ChatColor.DARK_RED)); } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldBlockCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldBlockCommand.java index 9c55bf6d1..8d374c75f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldBlockCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldBlockCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.fields.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -13,7 +12,7 @@ public class FieldBlockCommand extends CommandBase { public FieldBlockCommand(FieldBlock plugin) { - super(plugin, Rank.ADMIN, "fb"); + super(plugin, FieldBlock.FIELD_BLOCK_COMMAND_PERMISSION, "fb"); } @Override @@ -132,4 +131,4 @@ public class FieldBlockCommand extends CommandBase Plugin.showSettings(caller); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldMonsterCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldMonsterCommand.java index c419a8578..e1da01efc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldMonsterCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldMonsterCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.fields.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; @@ -15,7 +14,7 @@ public class FieldMonsterCommand extends CommandBase { public FieldMonsterCommand(FieldMonster plugin) { - super(plugin, Rank.ADMIN, "fm"); + super(plugin, FieldMonster.FIELD_MONSTER_COMMAND_PERMISSION, "fm"); } @Override @@ -167,4 +166,4 @@ public class FieldMonsterCommand extends CommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), "Invalid Command.")); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldOreCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldOreCommand.java index 371bdf76f..752135886 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldOreCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/commands/FieldOreCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.fields.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.fields.FieldOre; @@ -12,7 +11,7 @@ public class FieldOreCommand extends CommandBase { public FieldOreCommand(FieldOre plugin) { - super(plugin, Rank.ADMIN, "fo"); + super(plugin, FieldOre.FIELD_ORE_COMMAND_PERMISSION, "fo"); } @Override @@ -57,4 +56,4 @@ public class FieldOreCommand extends CommandBase Plugin.wipe(caller); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DieCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DieCommand.java deleted file mode 100644 index 84d80a4b0..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/DieCommand.java +++ /dev/null @@ -1,21 +0,0 @@ -package mineplex.game.clans.gameplay; - -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; - -public class DieCommand extends CommandBase -{ - public DieCommand(Gameplay plugin) - { - super(plugin, Rank.ALL, "die"); - } - - @Override - public void Execute(Player caller, String[] args) - { - Plugin.getDamageManager().NewDamageEvent(caller, null, null, DamageCause.SUICIDE, 5000, false, true, true, null, null); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index 0b439df86..035c2dc75 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -10,8 +10,27 @@ import java.util.Map; import java.util.Set; import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonSyntaxException; + import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; @@ -68,28 +87,14 @@ import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; -import org.bukkit.Bukkit; -import org.bukkit.Color; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.plugin.java.JavaPlugin; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonSyntaxException; - /** * Handles converting legendary itemstacks to their respective CustomItem objects */ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable { + public static final String RUNE_COMMAND_PERMISSION = "mineplex.clans.items.rune"; + public static final String GEAR_COMMAND_PERMISSION = "mineplex.clans.items.gear"; + private static final String ITEM_SERIALIZATION_TAG = "-JSON-"; private static final Gson GSON; @@ -216,7 +221,8 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable // Mapping of player names (key) to cached gear set (value). private Map _playerGears = new HashMap<>(); - + + private CoreClientManager _clientManager; private GearShop _shop; private RuneManager _rune; @@ -230,7 +236,8 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable } _instance = this; - + + _clientManager = clientManager; _shop = new GearShop(this, clientManager, donationManager); _rune = new RuneManager("Rune", plugin); @@ -241,6 +248,16 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable packetHandler.addPacketHandler(this, PacketPlayOutSetSlot.class, PacketPlayOutWindowItems.class); plugin.getServer().getScheduler().runTaskTimer(plugin, this, 1L, 1L); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(RUNE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GEAR_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/GearCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/GearCommand.java index 8309d5fc5..85a561c58 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/GearCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/GearCommand.java @@ -3,17 +3,13 @@ package mineplex.game.clans.items.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.game.clans.items.GearManager; public class GearCommand extends CommandBase { - private GearManager _gearManager; - public GearCommand(GearManager plugin) { - super(plugin, Rank.ADMIN, "gear", "custom-gear"); - _gearManager = plugin; + super(plugin, GearManager.GEAR_COMMAND_PERMISSION, "gear", "custom-gear"); } @Override @@ -21,12 +17,11 @@ public class GearCommand extends CommandBase { if (args == null || args.length == 0) { - _gearManager.openShop(caller); + Plugin.openShop(caller); } else { caller.updateInventory(); } - } - -} + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java index b3cc4272a..a5ebe8538 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/RuneCommand.java @@ -1,7 +1,8 @@ package mineplex.game.clans.items.commands; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilInv; @@ -10,8 +11,6 @@ import mineplex.game.clans.items.GearManager; import mineplex.game.clans.items.runes.RuneManager; import mineplex.game.clans.items.runes.RuneManager.RuneAttribute; -import org.bukkit.entity.Player; - /** * Command to give yourself a rune */ @@ -21,7 +20,7 @@ public class RuneCommand extends CommandBase public RuneCommand(GearManager plugin) { - super(plugin, Rank.ADMIN, "rune", "giverune", "getrune"); + super(plugin, GearManager.RUNE_COMMAND_PERMISSION, "rune", "giverune", "getrune"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java deleted file mode 100644 index 8840daa19..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/Tutorial.java +++ /dev/null @@ -1,630 +0,0 @@ -package mineplex.game.clans.legacytutorial; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; - -import org.bukkit.Color; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.jsonchat.ClickEvent; -import mineplex.core.common.jsonchat.JsonMessage; -import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.donation.DonationManager; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; -import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; -import mineplex.core.task.TaskManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.ClansPlayerTasks; -import mineplex.game.clans.clans.event.ClanJoinEvent; -import mineplex.game.clans.clans.event.ClanTipEvent; -import mineplex.game.clans.clans.playtime.Playtime; -import mineplex.game.clans.economy.GoldManager; - -/** - * I call this a tutorial, even though it is more accurately, "a set of - * achievements or goals, that are in some-what of a tutorial fashion." But that - * would be too long of a class name, so I'll stick with "Tutorial" for now. - */ -public abstract class Tutorial implements ScoreboardElement, Listener -{ - public static String TASK_COMPLETE_TASK = "tttatatta%sTask%s"; - public static String TUTORIAL_COMPLETE_TASK = "tatatatatat%sDone"; //do not change - public static String TUTORIAL_REWARD_TASK = "tatatatatat%sRewardGiven"; //do not change - public static String SKIPPED_TASK = "tatatatata%sSkip"; - - protected final TutorialManager _manager; - protected final GoldManager _goldManager; - protected final ClansManager _clansManager; - protected final TaskManager _taskManager; - protected final DonationManager _donationManager; - - // protected final LinkedHashMap> _tasks; - private final ArrayList> _tasks; - protected final LinkedHashMap> _nameToTask; - protected final LinkedHashMap _inTutorial; - - protected boolean _doScoreboard; - protected boolean _ghostMode; - - protected boolean _startOnJoin; - - protected String _technicalName; - protected String _displayName; - - protected int _goldReward = -1; - protected int _gemReward = -1; - protected int _coinReward = -1; - - protected Playtime _playtime; - - public Tutorial(final GoldManager goldManager, final Playtime playtime, final TaskManager taskManager, final ClansManager clansManager, final DonationManager donationManager, final TutorialManager manager, final PacketHandler packetHandler) - { - _clansManager = clansManager; - _goldManager = goldManager; - _donationManager = donationManager; - _taskManager = taskManager; - _manager = manager; - _tasks = new ArrayList>(); - _inTutorial = new LinkedHashMap<>(); - _nameToTask = new LinkedHashMap<>(); - _playtime = playtime; - - _manager.getPluginManager().registerEvents(this, _manager.getPlugin()); - } - - @Override - public List getLines(final ScoreboardManager manager, final Player player, final List out) - { - final List lines = new ArrayList<>(); - - if (!isInTutorial(player)) - { - return lines; - } - - if (!_doScoreboard) - { - return lines; - } - - if (get(player).CurrentTask == null) - { - return lines; - } - - out.clear(); - - final TutorialClient client = _inTutorial.get(player.getName()); - - lines.add(C.cAqua + "Tutorial"); - - for (final TutorialTask task : _tasks) - { - if (get(player).CurrentTask.equals(task)) - { - lines.add(C.cDAqua + task.getID() + ". " + task.getDisplayName()); - } - else if (client.CurrentTask.getID() > task.getID()) - { - lines.add(C.cGreen + task.getID() + ". " + task.getDisplayName()); - } - else - { - lines.add(C.cRed + task.getID() + ". " + task.getDisplayName()); - } - } - - lines.add(C.cYellow + "To skip, type: /skiptutorial"); - - return lines; - } - - public TutorialTask getTask(int index) - { - return _tasks.get(index); - } - - protected void addTask(TutorialTask task) - { - _tasks.add(task); - _nameToTask.put(task.getTechnicalName(), task); - } - - protected boolean hasFinishedTask(Player player, TutorialTask task) - { - if (get(player).QueuedFinish) - { - return true; - } - - return get(player).CurrentTask.getID() < task.getID(); - } - - private TutorialTask getLastTask() - { - return _tasks.get(_tasks.size() - 1); - } - - protected void finishTask(final Player player, final TutorialTask task) - { - if (player == null) - { - return; - } - - get(player).LastDescriptionSentTime = 0; - get(player).CurrentTask.visibleFinish(player); - - // 6 Seconds for player to read the finish message (sent by the line above) - // (will be instant if get(player).CurrentTask.getFinishMessage() is null). - _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() - { - public void run() - { - final TutorialTask lastTask = getLastTask(); - // Cycle to next task, or null if last task. - get(player).CurrentTask = task.equals(lastTask) ? null : _tasks.get(task.getDataId() + 1); - System.out.println("Next Task: " + get(player).CurrentTask); - - if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName()))) - { - _taskManager.completedTask(new Callback() - { - public void run(final Boolean completed) - { - // If last task, end tutorial. - if (task.equals(lastTask)) - { - finishFor(player); - } - else - { - // Start next task in 1.5 Seconds (just to give a more smooth feel to the tutorial) - _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() - { - public void run() - { - System.out.println("STARTING NEXT TASK!"); - get(player).CurrentTask.startFor(player); - get(player).CurrentTaskStartTime = System.currentTimeMillis(); - } - }, 30L); - } - - player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); - } - }, player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())); - } - } - }, get(player).CurrentTask._finishMessage == null ? 1L : 6 * 20L); - } - - public TutorialTask getTask(final String technicalName) - { - return _nameToTask.get(technicalName); - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) - public void onPickupItem(final PlayerPickupItemEvent event) - { - if (_ghostMode && isInTutorial(event.getPlayer())) - { - event.setCancelled(true); - } - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) - public void onDropItem(final PlayerDropItemEvent event) - { - if (_ghostMode && isInTutorial(event.getPlayer())) - { - event.setCancelled(true); - } - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) - public void onBreakBlock(final BlockBreakEvent event) - { - if (_ghostMode && isInTutorial(event.getPlayer())) - { - event.setCancelled(true); - } - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) - public void onPlaceBlock(final BlockPlaceEvent event) - { - if (_ghostMode && isInTutorial(event.getPlayer())) - { - event.setCancelled(true); - } - } - - private void finishFor(final Player player) - { -// if (player.getOpenInventory() != null) -// { -// _inTutorial.get(player.getName()).QueuedFinish = true; -// return; -// } - _manager.finishTutorial(player); - _inTutorial.remove(player.getName()); - onFinished(player); - - if (_playtime.Get(player).FirstSession) - { - _playtime.Get(player).StartTime = System.currentTimeMillis(); - _playtime.Get(player).FirstSession = false; - TaskManager.Instance.completedTask(null, player, ClansPlayerTasks.FIRST_SESSION.id()); - } - - _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() - { - public void run() - { - UtilTextMiddle.display(C.cWhite + "Clans Tutorial", C.cGreen + "You have completed the Clans Tutorial!", 20, 20 * 3, 20, player); - onFinishedDelay(player); - - // Do Reward - if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_REWARD_TASK, _technicalName))) - { - _taskManager.completedTask(new Callback() - { - @Override - public void run(Boolean data) - { - if (_goldReward != -1) - { - _goldManager.addGold(player, _goldReward); - UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gold") + ".")); - } - - if (_gemReward != -1) - { - _donationManager.rewardCurrency(GlobalCurrency.GEM, player, "Clans", _gemReward, success -> - { - if (success) - { - UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gems") + ".")); - } - }); - } - - if (_coinReward != -1) - { - _donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, player, "Clans", _coinReward, success -> - { - if (success) - { - UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_coinReward + " Coins") + ".")); - } - }); - } - } - }, player, String.format(TUTORIAL_REWARD_TASK, _technicalName)); - } - else - { - UtilInv.remove(player, Material.IRON_AXE, (byte) 0, 1); - - UtilInv.remove(player, Material.IRON_HELMET, (byte) 0, 1); - UtilInv.remove(player, Material.IRON_CHESTPLATE, (byte) 0, 1); - UtilInv.remove(player, Material.IRON_LEGGINGS, (byte) 0, 1); - UtilInv.remove(player, Material.IRON_BOOTS, (byte) 0, 1); - - ItemStack[] armor = player.getInventory().getArmorContents(); - for (int i = 0; i < armor.length; i++) - { - if (UtilItem.isIronProduct(armor[i])) - { - armor[i] = null; - } - } - player.getInventory().setArmorContents(armor); - } - - _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() - { - public void run() - { - // Sets the tutorial as complete in the TaskManager and effects. - _taskManager.completedTask(new Callback() - { - public void run(final Boolean completed) - { - if (_ghostMode) - { - for (Player other : UtilServer.getPlayers()) - { - other.showPlayer(player); - player.showPlayer(other); - } - } - - for (int i = 0; i < 8; i++) - { - final int index = i; - _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() - { - public void run() - { - UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, (index % 2 == 0) ? Color.RED : Color.LIME, false, false, new Vector(0, 0, 0), 0); - } - }, i * 10); - } - } - }, player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)); - } - }, 20 * 2); - } - }, 20 * 2); - } - - // Implementation left to sub classes. - protected void onFinished(final Player player) - { - } - - protected void onFinishedDelay(final Player player) - { - } - - // Implementation left to sub classes. - protected void onBegin(final Player player) - { - } - - public void startFor(final Player player) - { - if (!_manager.isInTutorial(player)) - { - _manager.setTutorial(player, this); - } - - _inTutorial.put(player.getName(), new TutorialClient(player, this)); - - get(player).CurrentTask.startFor(player); - - player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); - - if (_ghostMode) - { - for (Player other : UtilServer.getPlayers()) - { - other.hidePlayer(player); - player.hidePlayer(other); - } - } - - onBegin(player); - } - - public void cancelFor(final Player player) - { - get(player).CurrentTask.cleanup(player); - get(player).CurrentTaskStartTime = -1; - _inTutorial.remove(player.getName()); - - _manager.finishTutorial(player); - - if (_ghostMode) - { - for (Player other : UtilServer.getPlayers()) - { - if (!isInTutorial(other)) other.showPlayer(player); - player.showPlayer(other); - } - } - - if (_playtime.Get(player).FirstSession) - { - _playtime.Get(player).StartTime = System.currentTimeMillis(); - _playtime.Get(player).FirstSession = false; - TaskManager.Instance.completedTask(null, player, ClansPlayerTasks.FIRST_SESSION.id()); - } - } - - public boolean isInTutorial(final Player player) - { - return _inTutorial.containsKey(player.getName()); - } - - public boolean isInTutorial(final String player) - { - return _inTutorial.containsKey(player); - } - - public boolean hasCompleted(final Player player) - { - return _taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)); - } - - public boolean hasSkipped(final Player player) - { - return _taskManager.hasCompletedTask(player, String.format(SKIPPED_TASK, _technicalName)); - } - - public void skip(final Player player) - { - new JsonMessage("") - .extra( - F.main( - "Tutorial", - "Are you sure you want to skip the tutorial? We " - )) - .extra("strongly") - .color("gold") - .extra(" advise you do complete it. You will be rewarded with armor, weapons and") - .color("gray") - .extra(" 30000 Gold") - .color("yellow") - .extra("!") - .color("gray") - - .sendToPlayer(player); - - new JsonMessage("") - .extra( - F.main( - "Tutorial", - "Click " - )) - .extra("here") - .color("aqua") - .click(ClickEvent.RUN_COMMAND, "/yesiconfirmiwanttoskip") - .extra(" here to confirm you want to skip the tutorial!") - .color("gray") - - .sendToPlayer(player); - } - - public void doSkip(final Player player) - { - _taskManager.completedTask(new Callback() - { - public void run(Boolean data) - { - cancelFor(player); - } - }, player, String.format(SKIPPED_TASK, _technicalName)); - } - - public String getTechnicalName() - { - return _technicalName; - } - - public TutorialClient get(final Player player) - { - return _inTutorial.get(player.getName()); - } - - @EventHandler - public void onClanTip(ClanTipEvent event) - { - if (isInTutorial(event.getPlayer())) - { - event.setCancelled(true); - } - } - - @EventHandler - public void taskInfo(final UpdateEvent evt) - { - if (evt.getType() != UpdateType.SEC) - { - return; - } - - for (Player player : UtilServer.getPlayers()) - { - if (isInTutorial(player)) - { - if (get(player).QueuedFinish) - { - if (player.getOpenInventory() == null) - { - get(player).QueuedFinish = false; - finishFor(player); - } - else - { - continue; - } - } - - get(player).CurrentTask.trySendDescription(player, false); - } - } - } - - @EventHandler - public void chat(final AsyncPlayerChatEvent evt) - { - if (!isInTutorial(evt.getPlayer())) - { - return; - } - - Iterator iterator = evt.getRecipients().iterator(); - - while (iterator.hasNext()) - { - if (isInTutorial(iterator.next())) - { - iterator.remove(); - } - } - - evt.setCancelled(true); - } - - @EventHandler - public void onJoinClan(ClanJoinEvent event) - { - if (isInTutorial(event.getPlayer())) - { - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerJoin(final PlayerJoinEvent evt) - { - if (!hasSkipped(evt.getPlayer()) && _startOnJoin) - { - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() - { - public void run() - { - if (!hasCompleted(evt.getPlayer())) - { - startFor(evt.getPlayer()); - } - } - }, 40L); - } - } - - public void cleanup(Player player) - { - System.out.println("Cleaning up Player in " + getClass().getName()); - - if (get(player) != null && get(player).CurrentTask != null) - { - System.out.println("Cleaning up current task: " + get(player).CurrentTask.getClass().getName()); - get(player).CurrentTask.cleanup(player); - } - - System.out.println("removing from in tutorial"); - _inTutorial.remove(player.getName()); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialClient.java deleted file mode 100644 index a73f4fdd6..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialClient.java +++ /dev/null @@ -1,40 +0,0 @@ -package mineplex.game.clans.legacytutorial; - -import org.bukkit.entity.Player; - -public class TutorialClient -{ - public Player Player; - public TutorialTask CurrentTask; - public long LastDescriptionSentTime = System.currentTimeMillis() - 3000; - public boolean InClanOnStart; - public boolean QueuedFinish; - public long CurrentTaskStartTime; - - public TutorialClient(Player player, Tutorial tutorial) - { - Player = player; - - CurrentTask = tutorial.getTask(0); - CurrentTaskStartTime = System.currentTimeMillis(); - - InClanOnStart = tutorial._clansManager.isInClan(player); - - /* - for (TutorialTask task : tutorial._tasks.values()) - { - if (TaskManager.Instance.hasCompletedTask(player, String.format( - Tutorial.TASK_COMPLETE_TASK, - task.getTutorial().getTechnicalName(), - task.getTechnicalName() - ))) - { - if (CurrentTask.getID() <= task.getID()) - { - CurrentTask = task.getTutorial().getTasks().get(Math.min(task.getTutorial().getTasks().size(), task.getID() + 1)); - } - } - } - */ - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialManager.java deleted file mode 100644 index 56142641d..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialManager.java +++ /dev/null @@ -1,211 +0,0 @@ -package mineplex.game.clans.legacytutorial; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.donation.DonationManager; -import mineplex.core.packethandler.IPacketHandler; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.packethandler.PacketInfo; -import mineplex.core.preferences.PreferencesManager; -import mineplex.core.task.TaskManager; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.commands.RestartTutCommand; -import mineplex.game.clans.clans.playtime.Playtime; -import mineplex.game.clans.economy.GoldManager; -import mineplex.game.clans.legacytutorial.commands.DoSkipTutorialCommand; -import mineplex.game.clans.legacytutorial.commands.SkipTutorialCommand; -import net.md_5.bungee.api.ChatColor; -import net.minecraft.server.v1_8_R3.PacketPlayOutChat; - -public class TutorialManager extends MiniPlugin -{ - public static TutorialManager Instance; - - private final Map, Tutorial> _tutorials = new HashMap<>(); - private final Map _playerTutorials = new HashMap<>(); - - private final TaskManager _taskManager; - - public TutorialManager(final JavaPlugin plugin, final Playtime playtime, final GoldManager goldManager, final TaskManager taskManager, final DonationManager donationManager, final PreferencesManager preferencesManager, final ClansManager clansManager, final PacketHandler packetHandler) - { - super("Tutorials", plugin); - - Instance = this; - - _taskManager = taskManager; - -// _tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, playtime, clansManager, donationManager, goldManager, taskManager, packetHandler)); - } - - public void addCommands() - { - addCommand(new SkipTutorialCommand(this)); - addCommand(new DoSkipTutorialCommand(this)); - addCommand(new RestartTutCommand(this)); - } - - public boolean startTutorial(final Class tutorial, final Player player) - { - if (isInTutorial(player)) - { - cancelTutorial(player); - } - - if (_tutorials.containsKey(tutorial)) - { - _tutorials.get(tutorial).startFor(player); - - return isInTutorial(player); - } - - return false; - } - - public boolean isInTutorial(final Player player) - { - return _playerTutorials.containsKey(player.getName()); - } - - public void cancelTutorial(final Player player) - { - if (isInTutorial(player)) - { - getTutorial(player).cancelFor(player); - - UtilPlayer.message(player, F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); - _playerTutorials.remove(player.getName()); - } - } - - public void skipTutorial(final Player player) - { - if (isInTutorial(player)) - { - getTutorial(player).skip(player); - } - } - - public void doSkip(final Player player) - { - if (isInTutorial(player)) - { - UtilPlayer.message(player, F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); - getTutorial(player).doSkip(player); - } - } - - @EventHandler - public void quit(PlayerQuitEvent event) - { - System.out.println("Player Quit. In Tutorial: " + isInTutorial(event.getPlayer())); - - if (!isInTutorial(event.getPlayer())) - return; - - getTutorial(event.getPlayer()).cleanup(event.getPlayer()); - _playerTutorials.remove(event.getPlayer().getName()); - } - - public void finishTutorial(Player player) - { - _playerTutorials.remove(player.getName()); - } - - public void setTutorial(Player player, Tutorial tutorial) - { - _playerTutorials.put(player.getName(), tutorial); - } - - public Tutorial getTutorial(final Player player) - { - return _playerTutorials.get(player.getName()); - } - - public Map, Tutorial> getTutorials() - { - return _tutorials; - } - - public TaskManager getTaskManager() - { - return _taskManager; - } - - // Stolen from UtilTabTitle - private static class TextConverter - { - public static String convert(String text) - { - if (text == null || text.length() == 0) - { - return "\"\""; - } - - char c; - int i; - int len = text.length(); - StringBuilder sb = new StringBuilder(len + 4); - String t; - sb.append('"'); - - for (i = 0; i < len; i += 1) - { - c = text.charAt(i); - switch (c) - { - case '\\': - case '"': - sb.append('\\'); - sb.append(c); - break; - case '/': - sb.append('\\'); - sb.append(c); - break; - case '\b': - sb.append("\\b"); - break; - case '\t': - sb.append("\\t"); - break; - case '\n': - sb.append("\\n"); - break; - case '\f': - sb.append("\\f"); - break; - case '\r': - sb.append("\\r"); - break; - default: - if (c < ' ') - { - t = "000" + Integer.toHexString(c); - sb.append("\\u").append(t.substring(t.length() - 4)); - } - else - { - sb.append(c); - } - } - } - sb.append('"'); - return sb.toString(); - } - - public static String setPlayerName(Player player, String text) - { - return text.replaceAll("(?i)\\{PLAYER\\}", player.getName()); - } - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialTask.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialTask.java deleted file mode 100644 index 15598cd14..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/TutorialTask.java +++ /dev/null @@ -1,267 +0,0 @@ -package mineplex.game.clans.legacytutorial; - -import java.util.Iterator; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.NautArrayList; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClanInfo; -import mineplex.game.clans.clans.ClansManager; - -public class TutorialTask implements Listener -{ - protected T _tutorial; - - protected long _autoCompleteTime = -1; - - protected String _displayName; - protected String _technicalName; - - protected String _description; - protected String _finishMessage; - - protected String[] _subtasks; - - protected Location _taskPos; - - // How much time after the beginning the task/last teleport it should take to teleport back to _taskPos. - protected int _taskTpDelay = 2 * 60 * 20; - - protected long _descriptionWaitTime = 30000; - - protected NautArrayList _inTask = new NautArrayList<>(); - - private long _lastTaskTp; - private int _id; - - public TutorialTask(T tutorial, int id) - { - _tutorial = tutorial; - _id = id; - - UtilServer.getServer().getPluginManager().registerEvents(this, _tutorial._manager.getPlugin()); - } - - protected void customStartFor(final Player player) - { - } - - protected void customEndFor(final Player player) - { - } - - protected final void startFor(final Player player) - { - _inTask.add(player.getName()); - - trySendDescription(player, true); - - customStartFor(player); - - if (_taskPos != null) - { - player.teleport(_taskPos); - _lastTaskTp = System.currentTimeMillis(); - if (_taskTpDelay != -1) - { - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_tutorial._manager.getPlugin(), new Runnable(){ - public void run() - { - if (isDoing(player)) - { - player.teleport(_taskPos); - _lastTaskTp = System.currentTimeMillis(); - } - } - }, _taskTpDelay); - } - } - - if (_autoCompleteTime != -1) - { - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_tutorial._manager.getPlugin(), new Runnable(){ - public void run() - { - if (isDoing(player)) - { - finishFor(player); - } - } - }, _autoCompleteTime); - } - } - - //@EventHandler - //todo: fix the multiline subtitles - public void displaySubtasks(UpdateEvent event) - { - if (!event.getType().equals(UpdateType.SEC)) - { - return; - } - - if (_subtasks == null || _subtasks.length == 0) - { - return; - } - - Iterator iterator = _inTask.iterator(); - while (iterator.hasNext()) - { - Player player = Bukkit.getPlayer(iterator.next()); - - if ((System.currentTimeMillis() - _tutorial.get(player).CurrentTaskStartTime) >= 15000) - { - if (isDoing(player)) - { - UtilTextMiddle.display("", UtilText.arrayToString(_subtasks, "\n"), 1, 25, 25, player); - } - } - } - } - - public boolean isDoing(Player player) - { - return _inTask != null && player != null && _inTask.contains(player.getName()); - } - - public void trySendDescription(Player player, boolean force) - { - if (!_tutorial.isInTutorial(player)) - { - return; - } - - TutorialClient client = _tutorial.get(player); - - if (client.QueuedFinish) - { - return; - } - - if (force || System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime()) - { - String description = _description; - ClanInfo clan = getClans().getClan(player); - if (clan != null) description = description.replace("(clan)", clan.getName()); - description = description.replace("{", C.cAqua).replace("}", C.cWhite); - - UtilPlayer.message(player, " "); - UtilPlayer.message(player, " "); - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cYellowB + "Part " + (_id + 1) + ": " + _displayName); - UtilPlayer.message(player, C.cWhite + " " + description); - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); - - UtilTextMiddle.display("", getDisplayName(), player); - - client.LastDescriptionSentTime = System.currentTimeMillis(); - } - } - - public final boolean hasFinished(final Player player) - { - if (_tutorial.get(player).QueuedFinish) - { - return true; - } - - // CurrentTask will be null if player has finished tutorial - return _tutorial.get(player).CurrentTask == null || _tutorial.get(player).CurrentTask.getID() < getID(); - } - - public String getDisplayName() - { - return _displayName; - } - - public String getDescription() - { - return _description; - } - - public String getFinishMessage() - { - return _finishMessage; - } - - public String getTechnicalName() - { - return _technicalName; - } - - public TutorialManager getManager() - { - return _tutorial._manager; - } - - public ClansManager getClans() - { - return _tutorial._clansManager; - } - - public int getDataId() - { - return _id; - } - - public int getID() - { - return _id + 1; - } - - public void finishFor(Player player) - { - customEndFor(player); - cleanup(player); - _tutorial.finishTask(player, this); - } - - public void visibleFinish(Player player) - { - if (_finishMessage != null) - { - String finishMessage = _finishMessage; - ClanInfo clan = getClans().getClan(player); - if (clan != null) finishMessage = finishMessage.replace("(clan)", clan.getName()); - finishMessage = finishMessage.replace("{", C.cAqua).replace("}", C.cWhite); - - UtilPlayer.message(player, " "); - UtilPlayer.message(player, " "); - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cWhite + finishMessage); - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); - } - } - - public void cleanup(Player player) - { - _inTask.remove(player.getName()); - } - - public long getDescriptionWaitTime() - { - return _descriptionWaitTime; - } - - public T getTutorial() - { - return _tutorial; - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/commands/DoSkipTutorialCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/commands/DoSkipTutorialCommand.java deleted file mode 100644 index 599a875c5..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/commands/DoSkipTutorialCommand.java +++ /dev/null @@ -1,31 +0,0 @@ -package mineplex.game.clans.legacytutorial.commands; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.game.clans.legacytutorial.TutorialManager; - -public class DoSkipTutorialCommand extends CommandBase -{ - public DoSkipTutorialCommand(final TutorialManager plugin) - { - super(plugin, Rank.ALL, "yesiconfirmiwanttoskip"); - } - - @Override - public void Execute(final Player caller, final String[] args) - { - if (Plugin.isInTutorial(caller)) - { - Plugin.doSkip(caller); - } - else - { - UtilPlayer.message(caller, F.main("Tutorials", "You are not currently in a tutorial.")); - } - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/commands/SkipTutorialCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/commands/SkipTutorialCommand.java deleted file mode 100644 index 2a8b36d20..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/commands/SkipTutorialCommand.java +++ /dev/null @@ -1,31 +0,0 @@ -package mineplex.game.clans.legacytutorial.commands; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.game.clans.legacytutorial.TutorialManager; - -public class SkipTutorialCommand extends CommandBase -{ - public SkipTutorialCommand(final TutorialManager plugin) - { - super(plugin, Rank.ALL, "skiptutorial", "skiptut", "st"); - } - - @Override - public void Execute(final Player caller, final String[] args) - { - if (Plugin.isInTutorial(caller)) - { - Plugin.skipTutorial(caller); - } - else - { - UtilPlayer.message(caller, F.main("Tutorials", "You are not currently in a tutorial.")); - } - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskClaim.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskClaim.java deleted file mode 100644 index c0b966649..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskClaim.java +++ /dev/null @@ -1,42 +0,0 @@ -package mineplex.game.clans.legacytutorial.gettingstarted; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent; -import mineplex.game.clans.legacytutorial.TutorialTask; - -public class TaskClaim extends TutorialTask -{ - public TaskClaim(TutorialGettingStarted tutorial, int id) - { - super(tutorial, id); - - _displayName = "Claim some Territory"; - _technicalName = "ClaimTerr"; - - _description = "Clans can claim 16x16 areas of Territory! " - + "Once claimed, only your Clan can break/place blocks here. " - + "This is the perfect place to build a base and stash your items! " - + "You can only claim in the Wilderness, and not next to other Clan's Territory. " - + "To claim some territory, go into the Clans GUI by typing {/c} and {Left-Clicking} the Territory button. (Looks like a flag)"; - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onClansCommand(PlayerPreClaimTerritoryEvent event) - { - if (!isDoing(event.getClaimer())) - { - return; - } - - if (!ClansManager.getInstance().isInClan(event.getClaimer())) - { - return; - } - - finishFor(event.getClaimer()); - event.setCancelled(true); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskCreateClan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskCreateClan.java deleted file mode 100644 index 97cfa9ba2..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskCreateClan.java +++ /dev/null @@ -1,52 +0,0 @@ -package mineplex.game.clans.legacytutorial.gettingstarted; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -import mineplex.core.common.util.UtilServer; -import mineplex.game.clans.clans.event.ClanCreatedEvent; -import mineplex.game.clans.legacytutorial.TutorialTask; - -public class TaskCreateClan extends TutorialTask -{ - public TaskCreateClan(TutorialGettingStarted tutorial, int id) - { - super(tutorial, id); - - _displayName = "Create a Clan"; - _technicalName = "ClanCreation"; - - _description = "Before beginning, use the {/c create } command to start up your own Clan! " - + "If you are already in a Clan, don't worry, you will automatically skip this part."; - } - - @Override - public void customStartFor(final Player player) - { - if (_tutorial.get(player).InClanOnStart) - { - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getManager().getPlugin(), new Runnable(){ - public void run() - { - if (isDoing(player)) - { - finishFor(player); - } - } - }, 6 * 20); - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onClanCreated(ClanCreatedEvent event) - { - if (!isDoing(event.getFounder())) - { - return; - } - - finishFor(event.getFounder()); - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskCustomizeClass.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskCustomizeClass.java deleted file mode 100644 index c591dae4f..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskCustomizeClass.java +++ /dev/null @@ -1,61 +0,0 @@ -package mineplex.game.clans.legacytutorial.gettingstarted; - -import java.util.Iterator; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.spawn.Spawn; -import mineplex.game.clans.legacytutorial.TutorialTask; -import mineplex.minecraft.game.classcombat.Class.ClientClass; - -public class TaskCustomizeClass extends TutorialTask -{ - public TaskCustomizeClass(TutorialGettingStarted tutorial, int id) - { - super(tutorial, id); - - _displayName = "Customize Class"; - _technicalName = "CustomizeKlass"; - - _description = "Now that you have equipped a class, use this enchantment table to customize your class builds. " - + "Click on the enchantment table, and click the edit build button. " - + "Make sure to select an axe ability to try out in the next task!"; - - _taskPos = new Location(Spawn.getSpawnWorld(), 6, 66, -300, -180f, 0f); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onUpdate(final UpdateEvent event) - { - if (!event.getType().equals(UpdateType.SEC)) - { - return; - } - - Iterator iterator = _inTask.iterator(); - while (iterator.hasNext()) - { - Player player = Bukkit.getPlayer(iterator.next()); - final ClientClass clientclass = ClansManager.getInstance().getClassManager().Get(player); - - if (clientclass != null && clientclass.GetSavingCustomBuild() != null && clientclass.GetSavingCustomBuild().AxeSkill != null) - { - finishFor(player); - iterator.remove(); - } - } - } - - @Override - public void cleanup(Player player) - { - // handled in onUpdate - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskDisbandClan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskDisbandClan.java deleted file mode 100644 index 8fbc07f2c..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskDisbandClan.java +++ /dev/null @@ -1,41 +0,0 @@ -package mineplex.game.clans.legacytutorial.gettingstarted; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -import mineplex.game.clans.clans.event.ClanDisbandedEvent; -import mineplex.game.clans.legacytutorial.TutorialTask; - -public class TaskDisbandClan extends TutorialTask -{ - public TaskDisbandClan(TutorialGettingStarted tutorial, int id) - { - super(tutorial, id); - - _displayName = "Disband your Clan"; - _technicalName = "DisbandClan"; - - _description = "Finally, let's disband your Clan to end the Tutorial. " - + "Simply type {/c disband} to do this. " - + "This will delete your Clan, and you'll be able to create or join a new one! " - + "If you were already in a Clan before you originally begun the Tutorial, you will automatically skip this part."; - } - - @Override - public void customStartFor(final Player player) - { - } - - @EventHandler - public void sell(ClanDisbandedEvent event) - { - if (!isDoing(event.getDisbander())) - { - return; - } - - System.out.println("COMPLETE DISBAND CLAN!"); - - finishFor(event.getDisbander()); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskEquipClass.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskEquipClass.java deleted file mode 100644 index a2896c445..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskEquipClass.java +++ /dev/null @@ -1,120 +0,0 @@ -package mineplex.game.clans.legacytutorial.gettingstarted; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.NautArrayList; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilItem; -import mineplex.core.task.TaskManager; -import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; -import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; -import mineplex.game.clans.spawn.Spawn; -import mineplex.game.clans.legacytutorial.TutorialTask; -import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent; - -public class TaskEquipClass extends TutorialTask -{ - public TaskEquipClass(TutorialGettingStarted tutorial, int id) - { - super(tutorial, id); - - _displayName = "Equip a Class"; - _technicalName = "AuszustattenKlasse"; - - _description = "Use the PvP Gear shop, and right-click the Villager. " - + "Purchase Iron Armor from the PvP Shop. " - + "Then put on your armor to equip the Knight Class."; - -// _subtasks = new String[] { -// "Open the PvP Shop", -// "Buy Iron Armor Set", -// "Equip Iron Armor" -// }; - - _taskPos = new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f); - } - - private NautHashMap> _bought = new NautHashMap<>(); - - @EventHandler - public void onClassEquipped(ClassEquipEvent event) - { - if (!isDoing(event.getUser())) - { - return; - } - - finishFor(event.getUser()); - } - - @Override - public void customEndFor(Player player) - { - _bought.get(player.getName()).clear(); - _bought.remove(player.getName()); - } - - @Override - public void customStartFor(Player player) - { - _bought.put(player.getName(), new NautArrayList()); - - if (getClans().getClassManager().Get(player).GetGameClass() != null) - { - finishFor(player); - } - } - - @EventHandler - public void button(ClansShopAddButtonEvent event) - { - if (!isDoing(event.getPlayer())) - { - return; - } - - if (!(UtilItem.isArmor(event.getMaterial()) && UtilItem.isIronProduct(event.getMaterial()))) - { - return; - } - - if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tuttoooooe" + event.getMaterial().name()) && !_bought.get(event.getPlayer().getName()).contains(event.getMaterial())) - { - event.setBuyPrice(0); - event.setSellPrice(0); - } - } - - @EventHandler - public void buy(final ClansPlayerBuyItemEvent event) - { - if (!isDoing(event.getPlayer())) - { - return; - } - - if (!(UtilItem.isArmor(event.getItem().getType()) && UtilItem.isIronProduct(event.getItem().getType()))) - { - return; - } - - if (event.getCost() == 0 && _bought.get(event.getPlayer().getName()).contains(event.getItem().getType())) - { - event.setCancelled(true); - return; - } - - TaskManager.Instance.completedTask(new Callback() { - @Override - public void run(Boolean data) - { - } - }, event.getPlayer(), "tuttoooooe" + event.getItem().getType().name()); - - _bought.get(event.getPlayer().getName()).add(event.getItem().getType()); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskExploreShops.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskExploreShops.java deleted file mode 100644 index eb4b8cb6b..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskExploreShops.java +++ /dev/null @@ -1,92 +0,0 @@ -package mineplex.game.clans.legacytutorial.gettingstarted; - -import java.util.Iterator; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.event.EnergyPageBuildEvent; -import mineplex.game.clans.spawn.Spawn; -import mineplex.game.clans.legacytutorial.TutorialTask; - -public class TaskExploreShops extends TutorialTask -{ - public TaskExploreShops(TutorialGettingStarted tutorial, int id) - { - super(tutorial, id); - - _displayName = "Welcome to the Shops"; - _technicalName = "WillkommenZumGeschaft"; - - _description = "Welcome to the Shops! Here you can buy all kinds of things that you may require during your adventure. " - + "You can also sell certain items to the Villagers to make a bit of extra Gold. " - + "Clan Energy is required to maintain the clan, without it, you will lose all claimed Territory! " - + "Go to the Energy Shop and buy {Max Energy}. (FREE)"; - - _finishMessage = "Great! " - + "Clans use energy to control Territory. " - + "More territory will cause your energy to drain faster, so make sure you remember to refill it regularly!"; - } - - @Override - public void customStartFor(Player player) - { - player.teleport(new Location(Spawn.getSpawnWorld(), 17, 66.5, -330, -180f, 0f)); - - ClansManager.getInstance().getClan(player).adjustEnergy(-(ClansManager.getInstance().getClan(player).getEnergyCostPerMinute() * 60)); - } - - @EventHandler - public void onItemPut(EnergyPageBuildEvent event) - { - if (!isDoing(event.getPlayer())) - { - return; - } - - if (!ClansManager.getInstance().isInClan(event.getPlayer())) - { - return; - } - - if (ClansManager.getInstance().getClan(event.getPlayer()).getEnergyPurchasable() == 0) - { - finishFor(event.getPlayer()); - _inTask.remove(event.getPlayer().getName()); - return; - } - - event.setFree(true); - } - - @Override - public void cleanup(Player player) - { - // handled in on update - } - - @EventHandler - public void onUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.TWOSEC) - { - return; - } - - Iterator iterator = _inTask.iterator(); - while (iterator.hasNext()) - { - Player player = Bukkit.getPlayer(iterator.next()); - if (ClansManager.getInstance().getClan(player).getEnergy() == ClansManager.getInstance().getClan(player).getEnergyMax()) - { - finishFor(player); - iterator.remove(); - } - } - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskLeaveSpawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskLeaveSpawn.java deleted file mode 100644 index 5a812ce65..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskLeaveSpawn.java +++ /dev/null @@ -1,65 +0,0 @@ -package mineplex.game.clans.legacytutorial.gettingstarted; - -import java.util.Iterator; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.legacytutorial.TutorialTask; - -public class TaskLeaveSpawn extends TutorialTask -{ - public TaskLeaveSpawn(TutorialGettingStarted tutorial, int id) - { - super(tutorial, id); - - _displayName = "Leave Spawn Islands"; - _technicalName = "LeaveSpawn"; - - _description = "Now you can leave the Spawn Island. " - + "Don't worry, you won't get hurt from the fall! " - + "Once you're down there, run out a couple of blocks to get to the Wilderness. " - + "When you finish the tutorial, you will be vulnerable to player attacks out there, so be careful!"; - } - - @Override - public void customStartFor(Player player) - { - if (player.getLocation().getY() < 100) - { - finishFor(player); - _inTask.remove(player.getName()); - } - } - - @EventHandler - public void update(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - { - return; - } - - Iterator iterator = _inTask.iterator(); - while (iterator.hasNext()) - { - String playerName = iterator.next(); - Player player = UtilPlayer.searchExact(playerName); - - if (player != null && player.getLocation().getY() < 100 && getClans().getClanUtility().getClaim(player.getLocation()) == null) - { - finishFor(player); - iterator.remove(); - } - } - } - - @Override - public void cleanup(Player player) - { - // We handle this in update() to avoid ConcurrentModificationException - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskMakingMoney.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskMakingMoney.java deleted file mode 100644 index 7b33cd35a..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskMakingMoney.java +++ /dev/null @@ -1,72 +0,0 @@ -package mineplex.game.clans.legacytutorial.gettingstarted; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerItemConsumeEvent; -import org.bukkit.inventory.ItemStack; - -import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent; -import mineplex.game.clans.spawn.Spawn; -import mineplex.game.clans.legacytutorial.TutorialTask; - -public class TaskMakingMoney extends TutorialTask -{ - public TaskMakingMoney(TutorialGettingStarted tutorial, int id) - { - super(tutorial, id); - - _displayName = "Making Money (Farming)"; - _technicalName = "ImAFarmer"; - - _description = "We have given you a carrot to sell in the Organic Produce Shop. " - + "Click on the Villager, and {Right-Click} the carrot to sell your carrots in exchange for Gold."; - - _finishMessage = "Good job! " - + "Farming and selling foods like carrots and potatoes are great ways to make money. " - + "You can also sell blocks, ores, and many other items that a Shop may be interested in buying."; - - _taskPos = new Location(Spawn.getSpawnWorld(), 25.536, 66, -316.844, -100f, 0f); - } - - @Override - public void customStartFor(Player player) - { - player.getInventory().addItem(new ItemStack(Material.CARROT_ITEM, 1)); - } - - @EventHandler - public void eat(PlayerItemConsumeEvent event) - { - if (!isDoing(event.getPlayer())) - { - return; - } - - if (!event.getItem().getType().equals(Material.CARROT_ITEM)) - { - return; - } - - event.setCancelled(true); - } - - @EventHandler - public void button(ClansPlayerSellItemEvent event) - { - if (!isDoing(event.getPlayer())) - { - return; - } - - if (!event.getItem().getType().equals(Material.CARROT_ITEM)) - { - return; - } - - System.out.println("FINISH CARROT"); - - finishFor(event.getPlayer()); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskSetHome.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskSetHome.java deleted file mode 100644 index 42a185e30..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskSetHome.java +++ /dev/null @@ -1,44 +0,0 @@ -package mineplex.game.clans.legacytutorial.gettingstarted; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; -import mineplex.game.clans.legacytutorial.TutorialTask; - -public class TaskSetHome extends TutorialTask -{ - public TaskSetHome(TutorialGettingStarted tutorial, int id) - { - super(tutorial, id); - - _displayName = "Set Clan Home"; - _technicalName = "SetClanHome"; - - _description = "You are now ready to set a Clan Home. " - + "To do this, use the {/c sethome} command. " - + "After you set a Clan Home, you or any of your Clan mates will be able to teleport back to the Clan Home by typing {/c home} whenever they are at Spawn."; - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onSetHome(ClansCommandExecutedEvent event) - { - if (!isDoing(event.getPlayer())) - { - return; - } - - if (!ClansManager.getInstance().isInClan(event.getPlayer())) - { - return; - } - - if (!event.getCommand().equals("homeset")) - { - return; - } - - finishFor(event.getPlayer()); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskUseAbility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskUseAbility.java deleted file mode 100644 index 6c180ae03..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskUseAbility.java +++ /dev/null @@ -1,156 +0,0 @@ -package mineplex.game.clans.legacytutorial.gettingstarted; - -import java.util.Iterator; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.NautArrayList; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.task.TaskManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; -import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; -import mineplex.game.clans.spawn.Spawn; -import mineplex.game.clans.legacytutorial.TutorialTask; - -public class TaskUseAbility extends TutorialTask -{ - public TaskUseAbility(TutorialGettingStarted tutorial, int id) - { - super(tutorial, id); - - _displayName = "Use a Class Ability"; - _technicalName = "KlassAbilityUsage"; - - _description = "Now that you have equipped a class, you can start using abilities. " - + "Purchase an Iron Axe from the PvP Shop. " - + "Right-Click with your Iron Axe to use your Axe Ability!"; - - _taskPos = new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f); - } - - private NautHashMap> _bought = new NautHashMap<>(); - private NautHashMap _teleported = new NautHashMap<>(); - - @Override - public void customStartFor(Player player) - { - _bought.put(player.getName(), new NautArrayList()); - } - - @Override - public void customEndFor(Player player) - { - _bought.get(player.getName()).clear(); - _bought.remove(player.getName()); - _teleported.remove(player.getName()); - } - - @EventHandler - public void teleportPlayer(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) return; - - Iterator iterator = _inTask.iterator(); - while (iterator.hasNext()) - { - Player _player = Bukkit.getPlayer(iterator.next()); - - if (!_teleported.containsKey(_player.getName()) && _player != null && _player.isOnline() && _player.getOpenInventory().getType() == InventoryType.CRAFTING) - { - _player.teleport(new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f)); - _teleported.put(_player.getName(), true); - } - } - } - - /* - @EventHandler - public void onAbilityUesd(SkillTriggerEvent event) - { - if (!isDoing(event.GetPlayer())) - { - return; - } - - finishFor(event.GetPlayer()); - } - */ - - @EventHandler - public void onRightClick(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if (!isDoing(player)) - return; - - if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) - { - ItemStack item = player.getItemInHand(); - if (item != null && item.getType() == Material.IRON_AXE) - { - finishFor(player); - } - } - } - - @EventHandler - public void button(ClansShopAddButtonEvent event) - { - if (!isDoing(event.getPlayer())) - { - return; - } - - if (!event.getMaterial().equals(Material.IRON_AXE)) - { - return; - } - - if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tuttoooooe" + event.getMaterial().name()) - && !_bought.get(event.getPlayer().getName()).contains(event.getMaterial())) - { - event.setBuyPrice(0); - event.setSellPrice(0); - } - } - - @EventHandler - public void buy(final ClansPlayerBuyItemEvent event) - { - if (!isDoing(event.getPlayer())) - { - return; - } - - if (!event.getItem().getType().equals(Material.IRON_AXE)) - { - return; - } - - if (event.getCost() == 0 && _bought.get(event.getPlayer().getName()).contains(event.getItem().getType())) - { - event.setCancelled(true); - return; - } - - TaskManager.Instance.completedTask(new Callback() { - @Override - public void run(Boolean data) - { - } - }, event.getPlayer(), "tuttoooooe" + event.getItem().getType().name()); - _bought.get(event.getPlayer().getName()).add(event.getItem().getType()); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskViewClanDetails.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskViewClanDetails.java deleted file mode 100644 index d0af8ac05..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskViewClanDetails.java +++ /dev/null @@ -1,38 +0,0 @@ -package mineplex.game.clans.legacytutorial.gettingstarted; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; -import mineplex.game.clans.legacytutorial.TutorialTask; - -public class TaskViewClanDetails extends TutorialTask -{ - public TaskViewClanDetails(TutorialGettingStarted tutorial, int id) - { - super(tutorial, id); - - _displayName = "Viewing Clan Details"; - _technicalName = "CommandClanX"; - - _description = "Now you can view information about your clan. " - + "To do this type {/c (clan)}! " - + "You can also use any clan's name to get some information about them as well."; - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onClansCommand(ClansCommandExecutedEvent event) - { - if (!isDoing(event.getPlayer())) - { - return; - } - - System.out.println(event.getCommand()); - - if (event.getCommand().equals("info")) - { - finishFor(event.getPlayer()); - } - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskWelcome.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskWelcome.java deleted file mode 100644 index 1100966bc..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TaskWelcome.java +++ /dev/null @@ -1,21 +0,0 @@ -package mineplex.game.clans.legacytutorial.gettingstarted; - -import mineplex.game.clans.legacytutorial.TutorialTask; - -public class TaskWelcome extends TutorialTask -{ - public TaskWelcome(TutorialGettingStarted tutorial, int id) - { - super(tutorial, id); - - _autoCompleteTime = 20 * 10; - - _displayName = "Welcome"; - _technicalName = "Welcome"; - - _description = "Welcome to Clans! " - + "In this game mode, you are able to create a Clan, invite your friends to the Clan, build a base, claim it to protect, and fight others with your new powerful Clan!" - + "You can also join a friend's Clan if they invite you to it!" - + "When you finish the tutorial, you will be awarded {30,000 Gold}"; - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TutorialGettingStarted.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TutorialGettingStarted.java deleted file mode 100644 index 99c2cb4e5..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/legacytutorial/gettingstarted/TutorialGettingStarted.java +++ /dev/null @@ -1,108 +0,0 @@ -package mineplex.game.clans.legacytutorial.gettingstarted; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.donation.DonationManager; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.task.TaskManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.playtime.Playtime; -import mineplex.game.clans.economy.GoldManager; -import mineplex.game.clans.legacytutorial.Tutorial; -import mineplex.game.clans.legacytutorial.TutorialManager; -import mineplex.game.clans.spawn.Spawn; - -public class TutorialGettingStarted extends Tutorial -{ - public TutorialGettingStarted(final TutorialManager manager, final Playtime playtime, final ClansManager clansManager, final DonationManager donationManager, final GoldManager goldManager, final TaskManager taskManager, final PacketHandler packetHandler) - { - super(goldManager, playtime, taskManager, clansManager, donationManager, manager, packetHandler); - -// addTask(new TaskWelcome(this, 1)); - - int id = -1; - addTask(new TaskCreateClan(this, ++id)); - addTask(new TaskViewClanDetails(this, ++id)); - addTask(new TaskLeaveSpawn(this, ++id)); - addTask(new TaskClaim(this, ++id)); - addTask(new TaskSetHome(this, ++id)); - addTask(new TaskExploreShops(this, ++id)); - addTask(new TaskEquipClass(this, ++id)); - addTask(new TaskCustomizeClass(this, ++id)); - addTask(new TaskUseAbility(this, ++id)); - addTask(new TaskMakingMoney(this, ++id)); - addTask(new TaskDisbandClan(this, ++id)); - - _doScoreboard = true; - _ghostMode = true; - _startOnJoin = true; - _goldReward = 30000; - - _technicalName = "GettingStartedTutorial"; - _displayName = "Getting Started"; - } - - @Override - public void onFinished(final Player player) - { - player.resetPlayerTime(); - player.teleport(Spawn.getNorthSpawn()); - } - - @Override - protected void onFinishedDelay(Player player) - { - UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); - UtilPlayer.message(player, C.cYellowB + "CONGRATULATIONS"); - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cWhite + "You have completed the Clans basic tutorial and have been awarded " + C.cAqua + "30,000 Gold"); - UtilPlayer.message(player, C.cWhite + "You can now begin your adventure, but do take a moment to read the signs around spawn for more information!"); - UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); - } - - @Override - public void onBegin(final Player player) - { - UtilPlayer.message(player, " "); - UtilPlayer.message(player, " "); - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cYellowB + "Getting Started"); - UtilPlayer.message(player, C.cWhite + " Welcome to Clans! " - + "In this game mode you are able to create a clan, invite your friends to play with you, build a base, and wage war against others! " - + "When you finish the tutorial, you will be awarded " + C.cAqua + "30,000 Gold"); - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); - } - - - @EventHandler(priority = EventPriority.MONITOR) - public void onUpdate(final UpdateEvent event) - { - if (!event.getType().equals(UpdateType.SEC)) - { - return; - } - - for (Player player : UtilServer.getPlayers()) - { - if (isInTutorial(player)) - { - for (Player other : UtilServer.getPlayers()) - { - other.hidePlayer(player.getPlayer()); - player.hidePlayer(other); - } - } - } - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartCommand.java index 4a33d2f5f..5c62376dd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.restart; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -11,7 +10,7 @@ public class RestartCommand extends CommandBase { public RestartCommand(RestartManager plugin) { - super(plugin, Rank.ADMIN, "forceRestart"); + super(plugin, RestartManager.RESTART_COMMAND_PERMISSION, "forceRestart"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java index 572534b0d..cf73ef3c7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java @@ -11,7 +11,11 @@ import org.bukkit.event.player.PlayerLoginEvent.Result; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; @@ -32,6 +36,8 @@ import net.minecraft.server.v1_8_R3.MinecraftServer; public class RestartManager extends MiniPlugin { + public static final String RESTART_COMMAND_PERMISSION = "mineplex.clans.restart.command"; + private static final int MAX_RESTART_TIME = 2; //Server won't auto restart after 2am private final LinkedList _warnings = new LinkedList<>(); private Long _restartUnlock; @@ -68,6 +74,16 @@ public class RestartManager extends MiniPlugin { SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#clans-server-status", new SlackMessage("Clans Uptime", "crossed_swords", _serverName + " has started up!"), true); } + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(RESTART_COMMAND_PERMISSION), false, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(RESTART_COMMAND_PERMISSION), true, true); } private boolean inRestartZone(int hour) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/texttutorial/ClassTutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/texttutorial/ClassTutorial.java deleted file mode 100644 index d6e3b3e79..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/texttutorial/ClassTutorial.java +++ /dev/null @@ -1,14 +0,0 @@ -package mineplex.game.clans.texttutorial; - -import mineplex.core.texttutorial.tutorial.Phase; -import mineplex.core.texttutorial.tutorial.Tutorial; - -public class ClassTutorial extends Tutorial -{ - public ClassTutorial() - { - super("Class Guide", "Clans.TextTutorial.Class", 0); - - addPhase(new Phase(null, "Classes", new String[] { "" })); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java index 135689cdc..e2474a504 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java @@ -5,32 +5,39 @@ import java.util.EnumMap; import java.util.Iterator; import java.util.List; +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.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.chat.Chat; import mineplex.core.chat.FilterPriority; import mineplex.core.common.events.PlayerRecieveBroadcastEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.donation.DonationManager; import mineplex.core.hologram.HologramManager; import mineplex.core.npc.NpcManager; +import mineplex.core.task.TaskManager; import mineplex.core.thereallyoldscoreboardapiweshouldremove.ScoreboardManager; import mineplex.core.thereallyoldscoreboardapiweshouldremove.elements.ScoreboardElement; -import mineplex.core.task.TaskManager; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.message.ClansMessageManager; import mineplex.game.clans.tutorial.command.TutorialCommand; import mineplex.game.clans.tutorial.gui.TutorialShop; import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.java.JavaPlugin; - public class TutorialManager extends MiniPlugin implements ScoreboardElement { + public static final String TUTORIAL_COMMAND_PERMISSION = "mineplex.clans.tutorial.command"; + public static final String START_TUTORIAL_COMMAND_PERMISSION = "mineplex.clans.tutorial.start"; + public static final String FINISH_TUTORIAL_COMMAND_PERMISSION = "mineplex.clans.tutorial.finish"; + private CoreClientManager _clientManager; private DonationManager _donationManager; private ClansMessageManager _clansMessageManager; @@ -51,7 +58,8 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, clansManager, _clansMessageManager, hologram, npcManager, taskManager)); - chat.AddFilter(event -> { + chat.AddFilter(event -> + { if (inTutorial(event.getPlayer())) { UtilPlayer.message(event.getPlayer(), F.main("Clans", "You are not allowed to speak while in a tutorial.")); @@ -73,6 +81,31 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement return Boolean.FALSE; }, FilterPriority.HIGH); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + if (UtilServer.isTestServer()) + { + pm.setPermission(pm.getGroup("player"), GroupPermission.of(TUTORIAL_COMMAND_PERMISSION), true, true); + } + else + { + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TUTORIAL_COMMAND_PERMISSION), true, true); + } + if (UtilServer.isTestServer()) + { + pm.setPermission(pm.getGroup("player"), GroupPermission.of(FINISH_TUTORIAL_COMMAND_PERMISSION), true, true); + } + else + { + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FINISH_TUTORIAL_COMMAND_PERMISSION), true, true); + } + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(START_TUTORIAL_COMMAND_PERMISSION), true, true); } @EventHandler @@ -183,4 +216,4 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement return new ArrayList(0); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/FinishCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/FinishCommand.java index f402cc601..a8b3a3a52 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/FinishCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/FinishCommand.java @@ -3,23 +3,18 @@ package mineplex.game.clans.tutorial.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilServer; import mineplex.game.clans.tutorial.TutorialManager; public class FinishCommand extends CommandBase { public FinishCommand(TutorialManager plugin) { - super(plugin, Rank.ALL, "finish", "end"); + super(plugin, TutorialManager.FINISH_TUTORIAL_COMMAND_PERMISSION, "finish", "end"); } @Override public void Execute(Player caller, String[] args) { - if (_commandCenter.GetClientManager().hasRank(caller, UtilServer.isTestServer() ? Rank.ALL : Rank.JNR_DEV)) - { - Plugin.finishTutorial(caller); - } + Plugin.finishTutorial(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/StartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/StartCommand.java index 2e100d21b..a019dfec3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/StartCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/StartCommand.java @@ -3,7 +3,6 @@ package mineplex.game.clans.tutorial.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.tutorial.TutorialManager; @@ -13,7 +12,7 @@ public class StartCommand extends CommandBase { public StartCommand(TutorialManager plugin) { - super(plugin, Rank.DEVELOPER, "start"); + super(plugin, TutorialManager.START_TUTORIAL_COMMAND_PERMISSION, "start"); } @Override @@ -30,12 +29,18 @@ public class StartCommand extends CommandBase for (TutorialType check : TutorialType.values()) { if (check.name().equalsIgnoreCase(args[0])) + { type = check; + } } if (type != null) + { Plugin.openTutorialMenu(caller, type); + } else + { UtilPlayer.message(caller, F.main("Tutorial", "Invalid Tutorial " + F.elem(args[0]))); + } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java index 137b4135f..05de8d0dc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java @@ -1,18 +1,17 @@ package mineplex.game.clans.tutorial.command; +import org.bukkit.entity.Player; + import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.game.clans.tutorial.TutorialManager; -import org.bukkit.entity.Player; public class TutorialCommand extends MultiCommandBase { public TutorialCommand(TutorialManager plugin) { - super(plugin, Rank.ALL, "tutorial", "tut"); + super(plugin, TutorialManager.TUTORIAL_COMMAND_PERMISSION, "tutorial", "tut"); AddCommand(new StartCommand(plugin)); AddCommand(new FinishCommand(plugin)); @@ -23,13 +22,4 @@ public class TutorialCommand extends MultiCommandBase { UtilPlayer.message(caller, F.main("Tutorial", "/tutorial start ")); } - - @Override - public void Execute(Player caller, String[] args) - { - if (_commandCenter.GetClientManager().hasRank(caller, UtilServer.isTestServer() ? Rank.ALL : Rank.JNR_DEV)) - { - super.Execute(caller, args); - } - } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java index 983c5ef29..97848929d 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java @@ -7,7 +7,7 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilTime; @@ -34,7 +34,7 @@ public class ClansServerPage extends ShopPageBase { + public static final String STAFF_PAGE_PERMISSION = "mineplex.clanshub.transfer.staff"; + public static final String ALLOW_HARDCORE_PERMISSION = "mineplex.clanshub.transfer.hardcore"; + public static final String JOIN_FULL_PERMISSION = "mineplex.clanshub.transfer.joinfull"; + private static final long SERVER_RELOAD_INTERVAL = 5000; private PartyManager _party; private Portal _portal; private HubManager _hub; private Region _region; - private final HashMap _servers = new HashMap(); + private final Map _servers = new HashMap<>(); private boolean _loading = false; private long _lastLoaded; private ClansServerShop _serverShop; @@ -59,6 +66,17 @@ public class ClansTransferManager extends MiniDbClientPlugin _hub = hub; _region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU; _serverShop = new ClansServerShop(this, client, donation); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(STAFF_PAGE_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(ALLOW_HARDCORE_PERMISSION), true, true); + pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); } /** diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java index 29d8c755a..913d5f6e4 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java @@ -1,7 +1,17 @@ package mineplex.clanshub; +import java.util.HashMap; +import java.util.Map; + +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.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; @@ -12,28 +22,35 @@ import mineplex.core.preferences.Preference; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -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; /** * Manager for player forcefields */ public class ForcefieldManager extends MiniPlugin { + public static final String BYPASS_FORCEFIELD_PERMISSION = "mineplex.clanshub.forcefield.bypass"; + public static final String FORCEFIELD_RADIUS_COMMAND_PERMISSION = "mineplex.clanshub.forcefield.radius"; + public HubManager Manager; - private HashMap _radius = new HashMap(); + private Map _radius = new HashMap<>(); public ForcefieldManager(HubManager manager) { super("Forcefield", manager.getPlugin()); Manager = manager; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Manager.GetClients().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), true, true); + pm.setPermission(pm.getGroup("eventmod"), GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), false, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(FORCEFIELD_RADIUS_COMMAND_PERMISSION), true, true); } @EventHandler @@ -44,7 +61,7 @@ public class ForcefieldManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { - 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)) + if (Manager.getPreferences().get(player).isActive(Preference.FORCE_FIELD) && Manager.GetClients().getPermissionManager().hasPermission(player, Preference.FORCE_FIELD.getPermission())) { for (Player other : UtilServer.getPlayers()) { @@ -58,7 +75,7 @@ public class ForcefieldManager extends MiniPlugin if (UtilMath.offset(other, player) > range) continue; - if (Manager.GetClients().Get(other).GetRank().has(Rank.JNR_DEV)) + if (Manager.GetClients().getPermissionManager().hasPermission(other, GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION))) continue; if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false)) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index 19d55cb24..3033ddecb 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -3,13 +3,8 @@ package mineplex.clanshub; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; - -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; -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 java.util.List; +import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -41,9 +36,6 @@ import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Scoreboard; import mineplex.clanshub.commands.ForcefieldRadius; import mineplex.clanshub.commands.GadgetToggle; @@ -54,6 +46,9 @@ import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.benefit.BenefitManager; import mineplex.core.blockrestore.BlockRestore; @@ -62,7 +57,6 @@ import mineplex.core.boosters.BoosterManager; import mineplex.core.botspam.BotSpamManager; import mineplex.core.chat.ChatFormat; import mineplex.core.chat.IChatMessageFormatter; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilInv; @@ -80,6 +74,7 @@ import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.donation.DonationManager; +import mineplex.core.donation.Donor; import mineplex.core.facebook.FacebookManager; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.event.GadgetCollideEntityEvent; @@ -113,6 +108,8 @@ import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; +import mineplex.core.scoreboard.MineplexScoreboard; +import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; @@ -127,12 +124,25 @@ import mineplex.core.youtube.YoutubeManager; import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.condition.ConditionManager; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +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; /** * Main manager for clans hub */ public class HubManager extends MiniPlugin implements IChatMessageFormatter { + public static final String GADGET_TOGGLE_COMMAND_PERMISSION = "mineplex.clanshub.gadget"; + public static final String GAMEMODE_COMMAND_PERMISSION = "mineplex.clanshub.gamemode"; + public static final String AUTO_OP_PERMISSION = "mineplex.clanshub.op"; + public static final String VANISH_PERMISSION = "mineplex.clanshub.vanish"; + public static final String SPAWN_PM_PERMISSION = "mineplex.clanshub.spawnpm"; + public static final String JOIN_FULL_PERMISSION = "mineplex.clanshub.joinfull"; + private BlockRestore _blockRestore; private CoreClientManager _clientManager; private ConditionManager _conditionManager; @@ -160,17 +170,13 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter private final TwoFactorAuth _twofactor = Managers.require(TwoFactorAuth.class); private Location _spawn; - private int _scoreboardTick = 0; - - private HashMap _scoreboards = new HashMap(); private String _serverName = ""; - private int _lastPlayerCount = 0; private boolean _shuttingDown; - private HashMap _portalTime = new HashMap(); + private Map _portalTime = new HashMap<>(); - private HashMap> _creativeAdmin = new HashMap>(); + private Map> _creativeAdmin = new HashMap<>(); public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager, CastleManager castleManager) { @@ -249,7 +255,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter _achievementManager.setGiveInterfaceItem(true); _packetHandler = packetHandler; - new NotificationManager(getPlugin(), clientManager, _preferences); + new NotificationManager(getPlugin(), clientManager); new BotSpamManager(plugin, clientManager, punish); ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; @@ -269,6 +275,138 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter new PersonalServerManager(plugin, _clientManager).setUseInterfaceItem(false); new CommunityManager(plugin, _clientManager); + + ScoreboardManager scoreboardManager = new ScoreboardManager(plugin) + { + @Override + public void setup(MineplexScoreboard scoreboard) + { + for (PermissionGroup group : _clientManager.getPermissionManager().getGroups()) + { + if (!group.getDisplay(false, false, false, false).isEmpty()) + { + scoreboard.getHandle().registerNewTeam(group.getIdentifier()).setPrefix(group.getDisplay(true, true, true, false) + ChatColor.RESET + " "); + } + else + { + scoreboard.getHandle().registerNewTeam(group.getIdentifier()).setPrefix(""); + } + } + + scoreboard.register(HubScoreboardLine.SERVER_TITLE) + .register(HubScoreboardLine.SERVER_NAME) + .register(HubScoreboardLine.SERVER_EMPTY_SPACER) + .register(HubScoreboardLine.PLAYER_TITLE) + .register(HubScoreboardLine.PLAYER_COUNT) + .register(HubScoreboardLine.PLAYER_EMPTY_SPACER) + .register(HubScoreboardLine.RANK_TITLE) + .register(HubScoreboardLine.RANK_NAME) + .register(HubScoreboardLine.RANK_EMPTY_SPACER) + .register(HubScoreboardLine.WEBSITE_TITLE) + .register(HubScoreboardLine.WEBSITE_VALUE) + .register(HubScoreboardLine.END_EMPTY_SPACER) + .recalculate(); + + scoreboard.get(HubScoreboardLine.SERVER_TITLE).write(C.cAqua + C.Bold + "Server"); + scoreboard.get(HubScoreboardLine.SERVER_NAME).write(_serverName); + scoreboard.get(HubScoreboardLine.PLAYER_TITLE).write(C.cYellow + C.Bold + "Players"); + 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"); + } + + @Override + public void draw(MineplexScoreboard scoreboard) + { + scoreboard.setSidebarName(C.cRed + C.Bold + C.Line + "Mineplex Clans"); + scoreboard.get(HubScoreboardLine.PLAYER_COUNT).write(_playerCountManager.getPlayerCount()); + + String rankName = getRankName(GetClients().Get(scoreboard.getOwner()).getPrimaryGroup(), GetDonation().Get(scoreboard.getOwner())); + + PermissionGroup disguisedRank = GetClients().Get(scoreboard.getOwner()).getDisguisedPrimaryGroup(); + String disguisedAs = GetClients().Get(scoreboard.getOwner()).getDisguisedAs(); + if (disguisedRank != null && disguisedAs != null) + { + rankName = getRankName(disguisedRank, GetDonation().Get(GetClients().Get(scoreboard.getOwner()).getDisguisedAsUUID())) + " (" + rankName + ")"; + } + + scoreboard.get(HubScoreboardLine.RANK_NAME).write(rankName); + } + + @Override + public void handlePlayerJoin(String playerName) + { + Player player = Bukkit.getPlayerExact(playerName); + + PermissionGroup group = _clientManager.Get(player).getRealOrDisguisedPrimaryGroup(); + + for (MineplexScoreboard scoreboard : getScoreboards().values()) + { + scoreboard.getHandle().getTeam(group.getIdentifier()).addEntry(playerName); + } + + if (get(player) != null) + { + for (Player player1 : Bukkit.getOnlinePlayers()) + { + group = _clientManager.Get(player1).getRealOrDisguisedPrimaryGroup(); + get(player).getHandle().getTeam(group.getIdentifier()).addEntry(player1.getName()); + } + } + } + + @Override + public void handlePlayerQuit(String playerName) + { + Player player = Bukkit.getPlayerExact(playerName); + + PermissionGroup group = _clientManager.Get(player).getRealOrDisguisedPrimaryGroup(); + + for (MineplexScoreboard scoreboard : getScoreboards().values()) + { + scoreboard.getHandle().getTeam(group.getIdentifier()).removeEntry(playerName); + } + } + + private String getRankName(PermissionGroup group, Donor donor) + { + String display = group.getDisplay(false, false, false, false); + if (display.isEmpty()) + { + if (donor.ownsUnknownSalesPackage("SuperSmashMobs ULTRA") || + donor.ownsUnknownSalesPackage("Survival Games ULTRA") || + donor.ownsUnknownSalesPackage("Minigames ULTRA") || + donor.ownsUnknownSalesPackage("CastleSiege ULTRA") || + donor.ownsUnknownSalesPackage("Champions ULTRA")) + { + display = "Single Ultra"; + } + else + { + display = "No Rank"; + } + } + + return display; + } + }; + + Managers.put(scoreboardManager, ScoreboardManager.class); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GADGET_TOGGLE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GAMEMODE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(AUTO_OP_PERMISSION), true, true); + pm.setPermission(pm.getGroup("cmod"), GroupPermission.of(VANISH_PERMISSION), false, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(VANISH_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SPAWN_PM_PERMISSION), true, true); + pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); } @Override @@ -331,30 +469,33 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20) { - if (!client.GetRank().has(Rank.ULTRA)) + if (!_clientManager.getPermissionManager().hasPermission(client, GroupPermission.of(JOIN_FULL_PERMISSION))) { - Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() + Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> { - public void run() - { - _portal.sendPlayerToGenericServer(event.getPlayer(), GenericServer.CLANS_HUB, Intent.KICK); - } + _portal.sendPlayerToGenericServer(event.getPlayer(), GenericServer.CLANS_HUB, Intent.KICK); }); event.allow(); } } else + { event.allow(); + } } @EventHandler(priority = EventPriority.LOW) public void handleOP(PlayerJoinEvent event) { - if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.ADMIN)) + if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(AUTO_OP_PERMISSION))) + { event.getPlayer().setOp(true); + } else + { event.getPlayer().setOp(false); + } } @EventHandler @@ -382,38 +523,6 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter //Health player.setHealth(20); - - //Scoreboard - Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); - player.setScoreboard(board); - _scoreboards.put(player, board); - - //Objective - Objective obj = board.registerNewObjective(C.Bold + "Player Data", "dummy"); - obj.setDisplaySlot(DisplaySlot.SIDEBAR); - - for (Rank rank : Rank.values()) - { - if (rank != Rank.ALL) - board.registerNewTeam(rank.ScoreboardTag).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); - else - board.registerNewTeam(rank.ScoreboardTag).setPrefix(""); - } - - for (Player otherPlayer : Bukkit.getOnlinePlayers()) - { - if (_clientManager.Get(otherPlayer) == null) - continue; - - String rankName = _clientManager.Get(player).GetRank().ScoreboardTag; - String otherRankName = _clientManager.Get(otherPlayer).GetRank().ScoreboardTag; - - //Add Other to Self - board.getTeam(otherRankName).addPlayer(otherPlayer); - - //Add Self to Other - otherPlayer.getScoreboard().getTeam(rankName).addPlayer(player); - } } @EventHandler @@ -425,11 +534,6 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter event.getPlayer().eject(); event.getPlayer().setOp(false); - for (Player player : UtilServer.getPlayers()) - player.getScoreboard().resetScores(event.getPlayer().getName()); - - _scoreboards.remove(event.getPlayer()); - _portalTime.remove(event.getPlayer().getName()); } @@ -437,7 +541,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter public void playerPrivateMessage(PrivateMessageEvent event) { //Dont Let PM Near Spawn! - if (UtilMath.offset2d(GetSpawn(), event.getSender().getLocation()) == 0 && !_clientManager.Get(event.getSender()).GetRank().has(Rank.HELPER)) + if (UtilMath.offset2d(GetSpawn(), event.getSender().getLocation()) == 0 && !_clientManager.getPermissionManager().hasPermission(event.getSender(), GroupPermission.of(SPAWN_PM_PERMISSION))) { UtilPlayer.message(event.getSender(), F.main("Chat", "You must leave spawn before you can Private Message!")); event.setCancelled(true); @@ -447,7 +551,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter @EventHandler public void Incog(IncognitoHidePlayerEvent event) { - if (!_clientManager.hasRank(event.getPlayer(), Rank.CMOD)) + if (!_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(VANISH_PERMISSION))) { event.setCancelled(true); } @@ -460,7 +564,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter return; //Dont Let Chat Near Spawn! - if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER)) + if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(SPAWN_PM_PERMISSION))) { UtilPlayer.message(event.getPlayer(), F.main("Chat", "You must leave spawn before you can chat!")); event.setCancelled(true); @@ -470,15 +574,17 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter Player player = event.getPlayer(); String playerName = player.getName(); - Rank rank = GetClients().Get(player).getRealOrDisguisedRank(); + PermissionGroup group = _clientManager.Get(player).getRealOrDisguisedPrimaryGroup(); //Level Prefix - String levelStr = _achievementManager.getMineplexLevel(player, rank); + String levelStr = _achievementManager.getMineplexLevel(player); //Rank Prefix String rankStr = ""; - if (rank != Rank.ALL) - rankStr = rank.getTag(true, true) + " "; + if (!group.getDisplay(false, false, false, false).isEmpty()) + { + rankStr = group.getDisplay(true, true, true, false) + " "; + } //Party Chat if (event.getMessage().charAt(0) == '@') { @@ -504,7 +610,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + playerName); TextComponent component = new TextComponent(); - rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()).create())); + rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(group.getDisplay(true, true, true, true) + ChatColor.WHITE + "\n" + group.getDescription()).create())); component.setText(levelStr); component.addExtra(rankComponent); @@ -525,21 +631,23 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter @Override public ChatFormat getChatFormat(Player player, String message) { - Rank rank = GetClients().Get(player).getRealOrDisguisedRank(); + PermissionGroup group = _clientManager.Get(player).getRealOrDisguisedPrimaryGroup(); //Level Prefix - String levelStr = _achievementManager.getMineplexLevel(player, rank); + String levelStr = _achievementManager.getMineplexLevel(player); //Rank Prefix String rankStr = ""; - if (rank != Rank.ALL) - rankStr = rank.getTag(true, true) + " "; + if (!group.getDisplay(false, false, false, false).isEmpty()) + { + rankStr = group.getDisplay(true, true, true, false) + " "; + } TextComponent rankComponent = new TextComponent(rankStr); TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + "%1$s"); TextComponent component = new TextComponent(); - rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()).create())); + rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(group.getDisplay(true, true, true, true) + ChatColor.WHITE + "\n" + group.getDescription()).create())); component.setText(levelStr); component.addExtra(rankComponent); @@ -606,74 +714,14 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter } @EventHandler - public void UpdateScoreboard(UpdateEvent event) + public void UpdateDisplay(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - _scoreboardTick = (_scoreboardTick + 1)%3; - - if (_scoreboardTick != 0) - return; - - int playerCount = _playerCountManager.getPlayerCount(); - - for (Player player : UtilServer.getPlayers()) + Bukkit.getOnlinePlayers().stream().filter(player -> _clientManager.Get(player).getPrimaryGroup().getIdentifier().equals("player")).forEach(player -> { - //Return to Main Scoreboard - if (!player.getScoreboard().equals(_scoreboards.get(player))) - player.setScoreboard(_scoreboards.get(player)); - - //Objective - Objective obj = player.getScoreboard().getObjective(DisplaySlot.SIDEBAR); - - //Title - obj.setDisplayName(C.cRed + C.Bold + C.Line + "Mineplex Clans"); - - int line = 15; - - //Space - obj.getScore(" ").setScore(line--); - - //Server - obj.getScore(C.cAqua + C.Bold + "Server").setScore(line--); - obj.getScore(_serverName).setScore(line--); - - //Space - obj.getScore(" ").setScore(line--); - - //Players - obj.getScore(C.cYellow + C.Bold + "Players").setScore(line--); - player.getScoreboard().resetScores(_lastPlayerCount + ""); - obj.getScore(playerCount + "").setScore(line--); - - //Space - obj.getScore(" ").setScore(line--); - - //Display Rank - obj.getScore(C.cGold + C.Bold + "Rank").setScore(line--); - //Remove Old - player.getScoreboard().resetScores(_clientManager.Get(player).GetLastRank(false).Name); - player.getScoreboard().resetScores(_clientManager.Get(player).GetLastRank(true).Name); - player.getScoreboard().resetScores("No Rank"); - //Add New - if (GetClients().Get(player).GetRank() != Rank.ALL) - obj.getScore(GetClients().Get(player).GetRank().Name).setScore(line--); - else - obj.getScore("No Rank").setScore(line--); - - //Space - obj.getScore(" ").setScore(line--); - - //Website - obj.getScore(C.cRed + C.Bold + "Website").setScore(line--); - obj.getScore("www.mineplex.com").setScore(line--); - } - - _lastPlayerCount = playerCount; - Bukkit.getOnlinePlayers().stream().filter(player -> _clientManager.Get(player).GetRank() == Rank.ALL).forEach(player -> - { - UtilTextBottom.display(C.cGray + "Visit " + F.elem("http://www.mineplex.com/shop") + " for exclusive hattori!", player); + UtilTextBottom.display(C.cGray + "Visit " + F.elem("http://www.mineplex.com/shop") + " for exclusive perks!", player); }); } @@ -872,7 +920,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter @EventHandler public void ignoreVelocity(PlayerVelocityEvent event) { - if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY)) + if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), Preference.IGNORE_VELOCITY.getPermission()) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY)) { event.setCancelled(true); } @@ -942,7 +990,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter @EventHandler public void clearGameMode(PlayerQuitEvent event) { - ArrayList creative = _creativeAdmin.remove(event.getPlayer().getName()); + List creative = _creativeAdmin.remove(event.getPlayer().getName()); if (creative == null) return; @@ -1010,7 +1058,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter { if (pet instanceof LivingEntity) { - DisguiseBase disguise = _disguiseManager.getDisguise((LivingEntity) pet); + DisguiseBase disguise = _disguiseManager.getActiveDisguise((LivingEntity) pet); if (disguise instanceof DisguiseWither) { @@ -1020,7 +1068,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter } } - for (Mount mount : _mountManager.getMounts()) + for (Mount mount : _mountManager.getMounts()) { if (mount instanceof MountDragon) { diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubScoreboardLine.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubScoreboardLine.java new file mode 100644 index 000000000..8ec0839b0 --- /dev/null +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubScoreboardLine.java @@ -0,0 +1,19 @@ +package mineplex.clanshub; + +import mineplex.core.scoreboard.ScoreboardLine; + +public enum HubScoreboardLine implements ScoreboardLine +{ + SERVER_TITLE, + SERVER_NAME, + SERVER_EMPTY_SPACER, + PLAYER_TITLE, + PLAYER_COUNT, + PLAYER_EMPTY_SPACER, + RANK_TITLE, + RANK_NAME, + RANK_EMPTY_SPACER, + WEBSITE_TITLE, + WEBSITE_VALUE, + END_EMPTY_SPACER; +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java index 51ad84a0f..de3bd0897 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java @@ -1,24 +1,28 @@ package mineplex.clanshub; +import java.util.HashSet; + +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.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.UtilMath; 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 org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerQuitEvent; - -import java.util.HashSet; /** * Manager for Hub Visibility of players */ public class HubVisibilityManager extends MiniPlugin { + public static final String BYPASS_INVISIBILITY_PERMISSION = "mineplex.clanshub.invisibility.bypass"; + public HubManager Manager; private HashSet _hiddenPlayers = new HashSet(); @@ -28,6 +32,15 @@ public class HubVisibilityManager extends MiniPlugin super("Visibility Manager", manager.getPlugin()); Manager = manager; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Manager.GetClients().getPermissionManager(); + + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(BYPASS_INVISIBILITY_PERMISSION), true, true); } /** @@ -63,9 +76,8 @@ public class HubVisibilityManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { - Rank rank = Manager.GetClients().Get(player).GetRank(); boolean hideMe = UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 || - (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) || + (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && Manager.GetClients().getPermissionManager().hasPermission(player, Preference.INVISIBILITY.getPermission())) || _hiddenPlayers.contains(player); for (Player other : UtilServer.getPlayers()) @@ -74,7 +86,7 @@ public class HubVisibilityManager extends MiniPlugin if (player.equals(other)) continue; - if (Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR)) + if (Manager.GetClients().getPermissionManager().hasPermission(other, GroupPermission.of(BYPASS_INVISIBILITY_PERMISSION))) localHideMe = false; if (localHideMe || !Manager.getPreferences().get(other).isActive(Preference.SHOW_PLAYERS)) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java index 658accdf4..1a6c1a4b5 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java @@ -1,12 +1,12 @@ package mineplex.clanshub; -import mineplex.core.common.Rank; -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.page.ShopPageBase; - import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.page.ShopPageBase; + /** * GUI button to select a server from a display */ @@ -41,7 +41,7 @@ public class JoinServerButton implements IButton System.out.println("Selecting server :" + serverInfo.Name); int slots = 1; - if (serverInfo.getAvailableSlots() < slots && !_page.getClient().GetRank().has(Rank.ULTRA)) + if (serverInfo.getAvailableSlots() < slots && !_page.getClientManager().getPermissionManager().hasPermission(player, GroupPermission.of(ClansTransferManager.JOIN_FULL_PERMISSION))) { _page.playDenySound(player); } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java index 113cfacf3..b8a1b9876 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java @@ -1,10 +1,9 @@ package mineplex.clanshub.commands; +import org.bukkit.entity.Player; + import mineplex.clanshub.ForcefieldManager; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; - -import org.bukkit.entity.Player; /** * Command for controlling forcefield radius @@ -13,7 +12,7 @@ public class ForcefieldRadius extends CommandBase { public ForcefieldRadius(ForcefieldManager plugin) { - super(plugin, Rank.ADMIN, "radius", "forcefield"); + super(plugin, ForcefieldManager.FORCEFIELD_RADIUS_COMMAND_PERMISSION, "radius", "forcefield"); } @Override diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java index c30b61fae..bf962ea94 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java @@ -1,10 +1,9 @@ package mineplex.clanshub.commands; +import org.bukkit.entity.Player; + import mineplex.clanshub.HubManager; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; - -import org.bukkit.entity.Player; /** * Command for toggling gadgets @@ -13,7 +12,7 @@ public class GadgetToggle extends CommandBase { public GadgetToggle(HubManager plugin) { - super(plugin, Rank.ADMIN, "gadget"); + super(plugin, HubManager.GADGET_TOGGLE_COMMAND_PERMISSION, "gadget"); } @Override diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java index f79e55f38..70577de2d 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java @@ -1,14 +1,13 @@ package mineplex.clanshub.commands; -import mineplex.clanshub.HubManager; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; - import org.bukkit.GameMode; import org.bukkit.entity.Player; +import mineplex.clanshub.HubManager; +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + /** * Command for setting gamemode */ @@ -16,7 +15,7 @@ public class GameModeCommand extends CommandBase { public GameModeCommand(HubManager plugin) { - super(plugin, Rank.ADMIN, "gamemode", "gm"); + super(plugin, HubManager.GAMEMODE_COMMAND_PERMISSION, "gamemode", "gm"); } @Override diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/RankSelectionButton.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/RankSelectionButton.java index c482fbf81..9e18ace1c 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/RankSelectionButton.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/RankSelectionButton.java @@ -3,18 +3,18 @@ package mineplex.clanshub.salesannouncements; import org.bukkit.Material; import org.bukkit.event.inventory.ClickType; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; public class RankSelectionButton extends SalesAnnouncementGUIButton { private SalesAnnouncementCreationPage _page; - private Rank _rank; + private PermissionGroup _rank; - public RankSelectionButton(Rank rank, SalesAnnouncementCreationPage page) + public RankSelectionButton(PermissionGroup rank, SalesAnnouncementCreationPage page) { - super(new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(rank.getColor() + (rank.Name.isEmpty() ? "Default" : rank.Name)).addLore(C.cRed + "Click to Toggle On").build()); + super(new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(rank.getDisplay(true, false, false, true)).addLore(C.cRed + "Click to Toggle On").build()); _rank = rank; _page = page; } @@ -27,13 +27,13 @@ public class RankSelectionButton extends SalesAnnouncementGUIButton { if (_page.Selected.contains(_rank)) { - Button = new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(_rank.getColor() + (_rank.Name.isEmpty() ? "Default" : _rank.Name)).addLore(C.cRed + "Click to Toggle On").build(); + Button = new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(_rank.getDisplay(true, false, false, true)).addLore(C.cRed + "Click to Toggle On").build(); _page.Selected.remove(_rank); _page.updateButtons(true); } else { - Button = new ItemBuilder(Material.EMERALD_BLOCK).setTitle(_rank.getColor() + (_rank.Name.isEmpty() ? "Default" : _rank.Name)).addLore(C.cGreen + "Click to Toggle Off").build(); + Button = new ItemBuilder(Material.EMERALD_BLOCK).setTitle(_rank.getDisplay(true, false, false, true)).addLore(C.cGreen + "Click to Toggle Off").build(); _page.Selected.add(_rank); _page.updateButtons(true); } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementCommand.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementCommand.java index 7a36de786..0f847cbc4 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementCommand.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementCommand.java @@ -3,7 +3,6 @@ package mineplex.clanshub.salesannouncements; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -11,7 +10,7 @@ public class SalesAnnouncementCommand extends CommandBase _buttons = new HashMap<>(); - public List Selected = Lists.newArrayList(); + public List Selected = new ArrayList<>(); public SalesAnnouncementCreationPage(Player player, String message) { @@ -41,10 +42,16 @@ public class SalesAnnouncementCreationPage implements Listener private void setup() { - for (int i = 0; i < Rank.values().length; i++) + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + PermissionGroup[] ranks = pm.getGroups().toArray(new PermissionGroup[pm.getGroups().size()]); + int slot = 0; + for (int i = 0; i < ranks.length; i++) { - Rank rank = Rank.values()[i]; - _buttons.put(i, new RankSelectionButton(rank, this)); + PermissionGroup rank = ranks[i]; + if (rank.canBePrimary()) + { + _buttons.put(slot++, new RankSelectionButton(rank, this)); + } } _buttons.put(31, new RankSelectionFinalizeButton(this)); updateButtons(false); @@ -57,7 +64,7 @@ public class SalesAnnouncementCreationPage implements Listener public void finalizeSelection() { - Managers.get(SalesAnnouncementManager.class).createAnnouncement(_viewer, Selected.toArray(new Rank[Selected.size()]), _message); + Managers.get(SalesAnnouncementManager.class).createAnnouncement(_viewer, Selected.toArray(new PermissionGroup[Selected.size()]), _message); Managers.get(SalesAnnouncementManager.class).runSyncLater(() -> _viewer.closeInventory(), 1L); } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementData.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementData.java index 23c2f5e7a..ea7cbf661 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementData.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementData.java @@ -6,18 +6,18 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; public class SalesAnnouncementData { private final Integer _id; - private final Rank[] _displayTo; + private final PermissionGroup[] _displayTo; private final String _message; private boolean _enabled; - public SalesAnnouncementData(Integer id, Rank[] displayTo, String message, boolean enabled) + public SalesAnnouncementData(Integer id, PermissionGroup[] displayTo, String message, boolean enabled) { _id = id; _displayTo = displayTo; @@ -30,12 +30,12 @@ public class SalesAnnouncementData return _id; } - public Rank[] getDisplayTo() + public PermissionGroup[] getDisplayTo() { return _displayTo; } - public boolean shouldDisplayTo(Rank rank) + public boolean shouldDisplayTo(PermissionGroup rank) { return Arrays.asList(_displayTo).contains(rank); } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java index bc76e23fa..ea20a9265 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementManager.java @@ -11,7 +11,9 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -20,6 +22,8 @@ import mineplex.serverdata.commands.ServerCommandManager; public class SalesAnnouncementManager extends MiniPlugin { + public static final String SALES_COMMAND_PERMISSION = "mineplex.clanshub.salesannouncements.command"; + private static final String LINE = C.cDGreenB + C.Strike + "============================================="; private final Map _data = new HashMap<>(); private final SalesAnnouncementRepository _repo; @@ -35,6 +39,15 @@ public class SalesAnnouncementManager extends MiniPlugin ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this)); ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SALES_COMMAND_PERMISSION), true, true); } public Map getLoadedAnnouncements() @@ -47,7 +60,7 @@ public class SalesAnnouncementManager extends MiniPlugin return getPlugin().getConfig().getString("serverstatus.name"); } - public void createAnnouncement(Player creator, Rank[] displayTo, String message) + public void createAnnouncement(Player creator, PermissionGroup[] displayTo, String message) { if (_data.size() >= 9 * 6) { @@ -129,7 +142,7 @@ public class SalesAnnouncementManager extends MiniPlugin return; } Player player = event.getPlayer(); - Rank rank = Managers.get(CoreClientManager.class).Get(player).GetRank(); + PermissionGroup rank = Managers.get(CoreClientManager.class).Get(player).getPrimaryGroup(); runSyncLater(() -> { diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java index 78762f61c..41b50f1e6 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java @@ -7,9 +7,10 @@ import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; -import com.google.common.collect.Lists; - -import mineplex.core.common.Rank; +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.Callback; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; @@ -29,12 +30,14 @@ public class SalesAnnouncementRepository extends RepositoryBase private final JavaPlugin _plugin; private final boolean _clans; + private final PermissionManager _pm; public SalesAnnouncementRepository(JavaPlugin plugin, boolean clans) { super(DBPool.getAccount()); _plugin = plugin; _clans = clans; + _pm = Managers.get(CoreClientManager.class).getPermissionManager(); } private void runAsync(Runnable runnable) @@ -58,19 +61,29 @@ public class SalesAnnouncementRepository extends RepositoryBase { int id = resultSet.getInt("id"); String rankString = resultSet.getString("ranks"); - List ranks = Lists.newArrayList(); + List ranks = new ArrayList<>(); if (rankString.contains(",") && !rankString.startsWith(",") && !rankString.endsWith(",")) { for (String rankStr : rankString.split(",")) { - ranks.add(Rank.valueOf(rankStr)); + PermissionGroup group = _pm.getGroup(rankStr); + if (group == null) + { + group = _pm.getGroupFromLegacy(rankStr); + } + ranks.add(group); } } else { - ranks.add(Rank.valueOf(rankString)); + PermissionGroup group = _pm.getGroup(rankString); + if (group == null) + { + group = _pm.getGroupFromLegacy(rankString); + } + ranks.add(group); } - Rank[] displayTo = ranks.toArray(new Rank[ranks.size()]); + PermissionGroup[] displayTo = ranks.toArray(new PermissionGroup[ranks.size()]); String message = resultSet.getString("message"); boolean enabled = resultSet.getBoolean("enabled"); @@ -96,19 +109,29 @@ public class SalesAnnouncementRepository extends RepositoryBase { int aId = resultSet.getInt("id"); String rankString = resultSet.getString("ranks"); - List ranks = Lists.newArrayList(); + List ranks = new ArrayList<>(); if (rankString.contains(",") && !rankString.startsWith(",") && !rankString.endsWith(",")) { for (String rankStr : rankString.split(",")) { - ranks.add(Rank.valueOf(rankStr)); + PermissionGroup group = _pm.getGroup(rankStr); + if (group == null) + { + group = _pm.getGroupFromLegacy(rankStr); + } + ranks.add(group); } } else { - ranks.add(Rank.valueOf(rankString)); + PermissionGroup group = _pm.getGroup(rankString); + if (group == null) + { + group = _pm.getGroupFromLegacy(rankString); + } + ranks.add(group); } - Rank[] displayTo = ranks.toArray(new Rank[ranks.size()]); + PermissionGroup[] displayTo = ranks.toArray(new PermissionGroup[ranks.size()]); String message = resultSet.getString("message"); boolean enabled = resultSet.getBoolean("enabled"); @@ -122,14 +145,14 @@ public class SalesAnnouncementRepository extends RepositoryBase }); } - public void createAnnouncement(final Rank[] displayTo, final String message, Callback callback) + public void createAnnouncement(final PermissionGroup[] displayTo, final String message, Callback callback) { runAsync(() -> { - String rankStr = displayTo[0].toString(); + String rankStr = displayTo[0].getIdentifier(); for (int i = 1; i < displayTo.length; i++) { - rankStr += ("," + displayTo[i].toString()); + rankStr += ("," + displayTo[i].getIdentifier()); } executeInsert(INSERT_ANNOUNCEMENT, resultSet -> { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 05a1c7222..e360404d7 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -1,16 +1,12 @@ package mineplex.hub; + import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.UUID; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; -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; @@ -45,6 +41,9 @@ import mineplex.core.Managers; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antispam.AntiSpamManager; import mineplex.core.benefit.BenefitManager; @@ -54,7 +53,6 @@ import mineplex.core.boosters.BoosterManager; import mineplex.core.botspam.BotSpamManager; import mineplex.core.chat.ChatFormat; import mineplex.core.chat.IChatMessageFormatter; -import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -140,9 +138,23 @@ import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.condition.ConditionManager; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +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; public class HubManager extends MiniClientPlugin implements IChatMessageFormatter { + public static final String GADGET_TOGGLE_COMMAND_PERMISSION = "mineplex.hub.gadget"; + public static final String GAMEMODE_COMMAND_PERMISSION = "mineplex.hub.gamemode"; + public static final String AUTO_OP_PERMISSION = "mineplex.hub.op"; + public static final String VANISH_PERMISSION = "mineplex.hub.vanish"; + public static final String SPAWN_PM_PERMISSION = "mineplex.hub.spawnpm"; + public static final String NEWS_COMMAND_PERMISSION = "mineplex.hub.news"; + public static final String JOIN_FULL_PERMISSION = "mineplex.hub.joinfull"; + // ☃❅ Snowman! public HubType Type = HubType.Normal; @@ -188,9 +200,9 @@ public class HubManager extends MiniClientPlugin implements IChatMess private final String _serverName; private boolean _shuttingDown; - private HashMap _portalTime = new HashMap(); + private Map _portalTime = new HashMap<>(); - private HashMap> _creativeAdmin = new HashMap>(); + private Map> _creativeAdmin = new HashMap<>(); public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager, CastleManager castleManager) { @@ -262,7 +274,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess _achievementManager.setGiveInterfaceItem(true); _packetHandler = packetHandler; - new NotificationManager(getPlugin(), clientManager, _preferences); + new NotificationManager(getPlugin(), clientManager); new BotSpamManager(plugin, clientManager, punish); ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle().pvpMode = true; @@ -301,12 +313,20 @@ public class HubManager extends MiniClientPlugin implements IChatMess @Override public void setup(MineplexScoreboard scoreboard) { - for (Rank rank : Rank.values()) + for (PermissionGroup group : _clientManager.getPermissionManager().getGroups()) { - if (rank == Rank.ALL) - scoreboard.getHandle().registerNewTeam(rank.ScoreboardTag).setPrefix(""); + if (!group.canBePrimary()) + { + continue; + } + if (!group.getDisplay(false, false, false, false).isEmpty()) + { + scoreboard.getHandle().registerNewTeam(group.getIdentifier()).setPrefix(group.getDisplay(true, true, true, false) + ChatColor.RESET + " "); + } else - scoreboard.getHandle().registerNewTeam(rank.ScoreboardTag).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); + { + scoreboard.getHandle().registerNewTeam(group.getIdentifier()).setPrefix(""); + } } scoreboard.register(HubScoreboardLine.SERVER_TITLE) @@ -343,9 +363,9 @@ public class HubManager extends MiniClientPlugin implements IChatMess scoreboard.get(HubScoreboardLine.GEM_COUNT).write(GetDonation().Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM)); 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())); + String rankName = getRankName(GetClients().Get(scoreboard.getOwner()).getPrimaryGroup(), GetDonation().Get(scoreboard.getOwner())); - Rank disguisedRank = GetClients().Get(scoreboard.getOwner()).getDisguisedRank(); + PermissionGroup disguisedRank = GetClients().Get(scoreboard.getOwner()).getDisguisedPrimaryGroup(); String disguisedAs = GetClients().Get(scoreboard.getOwner()).getDisguisedAs(); if (disguisedRank != null && disguisedAs != null) { @@ -363,19 +383,19 @@ public class HubManager extends MiniClientPlugin implements IChatMess HubClient hubclient = HubManager.this.Get(player); hubclient.setName(playerName); - CoreClient client = GetClients().Get(player.getUniqueId()); + PermissionGroup group = _clientManager.Get(player).getRealOrDisguisedPrimaryGroup(); for (MineplexScoreboard scoreboard : getScoreboards().values()) { - scoreboard.getHandle().getTeam(client.getRealOrDisguisedRank().ScoreboardTag).addEntry(playerName); + scoreboard.getHandle().getTeam(group.getIdentifier()).addEntry(playerName); } if (get(player) != null) { for (Player player1 : Bukkit.getOnlinePlayers()) { - client = GetClients().Get(player1); - get(player).getHandle().getTeam(client.getRealOrDisguisedRank().ScoreboardTag).addEntry(player1.getName()); + group = _clientManager.Get(player1).getRealOrDisguisedPrimaryGroup(); + get(player).getHandle().getTeam(group.getIdentifier()).addEntry(player1.getName()); } } } @@ -385,32 +405,61 @@ public class HubManager extends MiniClientPlugin implements IChatMess { Player player = Bukkit.getPlayerExact(playerName); - CoreClient client = GetClients().Get(player); + PermissionGroup group = _clientManager.Get(player).getRealOrDisguisedPrimaryGroup(); for (MineplexScoreboard scoreboard : getScoreboards().values()) { - scoreboard.getHandle().getTeam(client.getRealOrDisguisedRank().ScoreboardTag).removeEntry(playerName); + scoreboard.getHandle().getTeam(group.getIdentifier()).removeEntry(playerName); } } - private String getRankName(Rank rank, Donor donor) + private String getRankName(PermissionGroup group, Donor donor) { - String rankName; - if (rank.has(Rank.ULTRA)) - rankName = rank.Name; - else if (donor.ownsUnknownSalesPackage("SuperSmashMobs ULTRA") || + String display = group.getDisplay(false, false, false, false); + if (display.isEmpty()) + { + if (donor.ownsUnknownSalesPackage("SuperSmashMobs ULTRA") || donor.ownsUnknownSalesPackage("Survival Games ULTRA") || donor.ownsUnknownSalesPackage("Minigames ULTRA") || donor.ownsUnknownSalesPackage("CastleSiege ULTRA") || donor.ownsUnknownSalesPackage("Champions ULTRA")) - rankName = "Single Ultra"; - else - rankName = "No Rank"; - return rankName; + { + display = "Single Ultra"; + } + else + { + display = "No Rank"; + } + } + + return display; } }; Managers.put(scoreboardManager, ScoreboardManager.class); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GADGET_TOGGLE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GAMEMODE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(NEWS_COMMAND_PERMISSION), true, true); + if (UtilServer.isDevServer() || UtilServer.isTestServer()) + { + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(AUTO_OP_PERMISSION), true, true); + pm.setPermission(pm.getGroup("qam"), GroupPermission.of(AUTO_OP_PERMISSION), false, true); + } + else + { + pm.setPermission(pm.getGroup("lt"), GroupPermission.of(AUTO_OP_PERMISSION), true, true); + } + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(VANISH_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SPAWN_PM_PERMISSION), true, true); + pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); } @Override @@ -496,34 +545,26 @@ public class HubManager extends MiniClientPlugin implements IChatMess // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20) { - if (!client.GetRank().has(Rank.ULTRA)) + if (!_clientManager.getPermissionManager().hasPermission(client, GroupPermission.of(JOIN_FULL_PERMISSION))) { - Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() + Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> { - public void run() - { - _portal.sendPlayerToGenericServer(event.getPlayer(), GenericServer.HUB, Intent.KICK); - } + _portal.sendPlayerToGenericServer(event.getPlayer(), GenericServer.HUB, Intent.KICK); }); event.allow(); } } else + { event.allow(); + } } @EventHandler(priority = EventPriority.LOW) public void AdminOP(PlayerJoinEvent event) { - // Give developers operator on their servers - Rank minimum = Rank.OWNER; - if (UtilServer.isTestServer() || UtilServer.isDevServer()) - { - minimum = Rank.JNR_DEV; - } - - if (_clientManager.Get(event.getPlayer()).GetRank().has(minimum)) + if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(AUTO_OP_PERMISSION))) event.getPlayer().setOp(true); else event.getPlayer().setOp(false); @@ -590,7 +631,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess public void playerPrivateMessage(PrivateMessageEvent event) { //Dont Let PM Near Spawn! - if (UtilMath.offset2d(GetSpawn(), event.getSender().getLocation()) == 0 && !_clientManager.Get(event.getSender()).GetRank().has(Rank.HELPER)) + if (UtilMath.offset2d(GetSpawn(), event.getSender().getLocation()) == 0 && !!_clientManager.getPermissionManager().hasPermission(event.getSender(), GroupPermission.of(SPAWN_PM_PERMISSION))) { UtilPlayer.message(event.getSender(), F.main("Chat", "You must leave spawn before you can Private Message!")); event.setCancelled(true); @@ -600,7 +641,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess @EventHandler public void Incog(IncognitoHidePlayerEvent event) { - if (!_clientManager.hasRank(event.getPlayer(), Rank.ADMIN)) + if (!_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(VANISH_PERMISSION))) { event.setCancelled(true); } @@ -613,7 +654,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess return; //Dont Let Chat Near Spawn! - if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER)) + if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(SPAWN_PM_PERMISSION))) { UtilPlayer.message(event.getPlayer(), F.main("Chat", "You must leave spawn before you can chat!")); event.setCancelled(true); @@ -622,15 +663,17 @@ public class HubManager extends MiniClientPlugin implements IChatMess Player player = event.getPlayer(); String playerName = player.getName(); - Rank rank = GetClients().Get(player).getRealOrDisguisedRank(); + PermissionGroup group = GetClients().Get(player).getRealOrDisguisedPrimaryGroup(); //Level Prefix - String levelStr = _achievementManager.getMineplexLevel(player, rank); + String levelStr = _achievementManager.getMineplexLevel(player); //Rank Prefix String rankStr = ""; - if (rank != Rank.ALL) - rankStr = rank.getTag(true, true) + " "; + if (!group.getDisplay(false, false, false, false).isEmpty()) + { + rankStr = group.getDisplay(true, true, true, false) + " "; + } //Party Chat if (event.getMessage().charAt(0) == '@') { @@ -663,7 +706,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + playerName); TextComponent component = new TextComponent(); - rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()).create())); + rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(group.getDisplay(true, true, true, true) + ChatColor.WHITE + "\n" + group.getDescription()).create())); component.setText(levelStr); component.addExtra(rankComponent); @@ -684,21 +727,23 @@ public class HubManager extends MiniClientPlugin implements IChatMess @Override public ChatFormat getChatFormat(Player player, String message) { - Rank rank = GetClients().Get(player).getRealOrDisguisedRank(); + PermissionGroup group = GetClients().Get(player).getRealOrDisguisedPrimaryGroup(); //Level Prefix - String levelStr = _achievementManager.getMineplexLevel(player, rank); + String levelStr = _achievementManager.getMineplexLevel(player); //Rank Prefix String rankStr = ""; - if (rank != Rank.ALL) - rankStr = rank.getTag(true, true) + " "; + if (!group.getDisplay(false, false, false, false).isEmpty()) + { + rankStr = group.getDisplay(true, true, true, false) + " "; + } TextComponent rankComponent = new TextComponent(rankStr); TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + "%1$s"); TextComponent component = new TextComponent(); - rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()).create())); + rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(group.getDisplay(true, true, true, true) + ChatColor.WHITE + "\n" + group.getDescription()).create())); component.setText(levelStr); component.addExtra(rankComponent); @@ -915,9 +960,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess @EventHandler public void ignoreVelocity(PlayerVelocityEvent event) { - Player player = event.getPlayer(); - - if (_clientManager.Get(player).GetRank().has(Rank.TWITCH) && _preferences.get(player).isActive(Preference.IGNORE_VELOCITY) && !getJumpManager().isDoubleJumping(player)) + if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), Preference.IGNORE_VELOCITY.getPermission()) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY) && !getJumpManager().isDoubleJumping(event.getPlayer())) { event.setCancelled(true); } @@ -975,7 +1018,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess @EventHandler public void clearGameMode(PlayerQuitEvent event) { - ArrayList creative = _creativeAdmin.remove(event.getPlayer().getName()); + List creative = _creativeAdmin.remove(event.getPlayer().getName()); if (creative == null) return; @@ -1038,4 +1081,4 @@ public class HubManager extends MiniClientPlugin implements IChatMess { return _questManager; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/EggAddCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/EggAddCommand.java index 277136334..d52c8c416 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/EggAddCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/EggAddCommand.java @@ -3,7 +3,6 @@ package mineplex.hub.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.hub.modules.EasterEggHunt; @@ -12,7 +11,7 @@ public class EggAddCommand extends CommandBase { public EggAddCommand(EasterEggHunt plugin) { - super(plugin, Rank.ADMIN, "addegg"); + super(plugin, EasterEggHunt.ADD_EGG_COMMAND_PERMISSION, "addegg"); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/ForcefieldRadius.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/ForcefieldRadius.java index 03ea7fce2..0962c1f7b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/ForcefieldRadius.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/ForcefieldRadius.java @@ -3,14 +3,13 @@ package mineplex.hub.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.hub.modules.ForcefieldManager; public class ForcefieldRadius extends CommandBase { public ForcefieldRadius(ForcefieldManager plugin) { - super(plugin, Rank.OWNER, new String[] {"radius"}); + super(plugin, ForcefieldManager.FORCEFIELD_RADIUS_COMMAND_PERMISSION, "radius"); } @Override @@ -18,4 +17,4 @@ public class ForcefieldRadius extends CommandBase { Plugin.ForcefieldRadius(caller, args); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java index 2d99ce5d7..fb7f1f180 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java @@ -3,14 +3,13 @@ package mineplex.hub.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.hub.HubManager; public class GadgetToggle extends CommandBase { public GadgetToggle(HubManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, new String[] {"gadget"}); + super(plugin, HubManager.GADGET_TOGGLE_COMMAND_PERMISSION, "gadget"); } @Override @@ -18,4 +17,4 @@ public class GadgetToggle extends CommandBase { Plugin.ToggleGadget(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GameModeCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GameModeCommand.java index 4416e7b15..282aed008 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GameModeCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GameModeCommand.java @@ -4,7 +4,6 @@ import org.bukkit.GameMode; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.hub.HubManager; @@ -13,7 +12,7 @@ public class GameModeCommand extends CommandBase { public GameModeCommand(HubManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, new String[] {"gm"}); + super(plugin, HubManager.GAMEMODE_COMMAND_PERMISSION, "gm"); } @Override @@ -42,4 +41,4 @@ public class GameModeCommand extends CommandBase UtilPlayer.message(caller, F.main("Game Mode", target.getName() + " Creative Mode: " + F.tf(target.getGameMode() == GameMode.CREATIVE))); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HorseSpawn.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HorseSpawn.java index d9155039e..7c7ea1382 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HorseSpawn.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HorseSpawn.java @@ -3,14 +3,13 @@ package mineplex.hub.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.hub.modules.AdminMountManager; public class HorseSpawn extends CommandBase { public HorseSpawn(AdminMountManager plugin) { - super(plugin, Rank.OWNER, new String[] {"horse"}); + super(plugin, AdminMountManager.HORSE_COMMAND_PERMISSION, "horse"); } @Override @@ -18,4 +17,4 @@ public class HorseSpawn extends CommandBase { Plugin.HorseCommand(caller, args); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java index 2e1ec8432..5ecfe9f55 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java @@ -1,10 +1,8 @@ package mineplex.hub.commands; -import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.hub.modules.NewYearCountdown; @@ -18,7 +16,7 @@ public class NewYearCommand extends CommandBase { public NewYearCommand(NewYearCountdown plugin) { - super(plugin, Rank.JNR_DEV, "newyear", "nycountdown", "nyc"); + super(plugin, NewYearCountdown.NEW_YEARS_COMMAND_PERMISSION, "newyear", "nycountdown", "nyc"); } @Override @@ -53,15 +51,15 @@ public class NewYearCommand extends CommandBase private boolean validateInteger(String str) { - boolean passed = false; try { - int i = Integer.valueOf(str); - passed = true; + Integer.valueOf(str); + + return true; } catch (Exception e) { + return false; } - return passed; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsAddCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsAddCommand.java index 79a1c8de2..493dffa88 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsAddCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsAddCommand.java @@ -3,19 +3,18 @@ package mineplex.hub.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.hub.HubManager; import mineplex.hub.modules.NewsManager; +import net.md_5.bungee.api.ChatColor; public class NewsAddCommand extends CommandBase { public NewsAddCommand(HubManager plugin) { - super(plugin, Rank.ADMIN, "add"); + super(plugin, HubManager.NEWS_COMMAND_PERMISSION, "add"); } @Override @@ -35,7 +34,7 @@ public class NewsAddCommand extends CommandBase { newsEntry += args[i] + " "; } - newsEntry = newsEntry.substring(0, newsEntry.length() - 1); + newsEntry = ChatColor.translateAlternateColorCodes('&', newsEntry.substring(0, newsEntry.length() - 1)); // Check for 256 character length for MySQL! if (newsEntry.length() > 256) @@ -44,28 +43,20 @@ public class NewsAddCommand extends CommandBase return; } - newsMang.AddNewsEntry(newsEntry, new Callback() + final String entry = newsEntry; + + newsMang.AddNewsEntry(entry, success -> { - public void run(Boolean success) + if (success.booleanValue()) { - if (success) - { - String newsEntry = ""; - for (int i = 0; i < args.length; i++) - { - newsEntry += args[i] + " "; - } - newsEntry = newsEntry.substring(0, newsEntry.length() - 1); - - UtilPlayer.message(caller, F.main(Plugin.getName(), C.cGray + "The news entry: " + C.cGold + newsEntry + C.cGray + " has been added to the database!")); - } - else - { - UtilPlayer.message(caller, F.main(Plugin.getName(), C.cRed + "There was an error adding the news entry to the database!")); - } + UtilPlayer.message(caller, F.main(Plugin.getName(), C.cGray + "The news entry: " + C.cGold + entry + C.cGray + " has been added to the database!")); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), C.cRed + "There was an error adding the news entry to the database!")); } }); return; } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java index a9e6cf029..bb6d95d99 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java @@ -3,14 +3,13 @@ package mineplex.hub.commands; import org.bukkit.entity.Player; import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; import mineplex.hub.HubManager; public class NewsCommand extends MultiCommandBase { public NewsCommand(HubManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "news"); + super(plugin, HubManager.NEWS_COMMAND_PERMISSION, "news"); AddCommand(new NewsAddCommand(plugin)); AddCommand(new NewsDeleteCommand(plugin)); @@ -24,4 +23,4 @@ public class NewsCommand extends MultiCommandBase { Plugin.GetNewsManager().Help(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsConfirmCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsConfirmCommand.java index 42dbe5159..a83c900e2 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsConfirmCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsConfirmCommand.java @@ -3,7 +3,6 @@ package mineplex.hub.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -14,7 +13,7 @@ public class NewsConfirmCommand extends CommandBase { public NewsConfirmCommand(HubManager plugin) { - super(plugin, Rank.ADMIN, "¢¤₦₣¡₨₥"); + super(plugin, HubManager.NEWS_COMMAND_PERMISSION, "¢¤₦₣¡₨₥"); } @Override @@ -42,4 +41,4 @@ public class NewsConfirmCommand extends CommandBase return; } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsDeleteCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsDeleteCommand.java index 0c5e600ed..d4ce529b4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsDeleteCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsDeleteCommand.java @@ -3,9 +3,7 @@ package mineplex.hub.commands; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.hub.HubManager; @@ -15,7 +13,7 @@ public class NewsDeleteCommand extends CommandBase { public NewsDeleteCommand(HubManager plugin) { - super(plugin, Rank.ADMIN, "delete"); + super(plugin, HubManager.NEWS_COMMAND_PERMISSION, "delete"); } @Override @@ -39,18 +37,15 @@ public class NewsDeleteCommand extends CommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), C.cRed + "The specified news position is invalid!")); return; } - newsMang.DeleteNewsEntry(newsPosition, new Callback() + newsMang.DeleteNewsEntry(newsPosition, success -> { - public void run(Boolean success) + if (success.booleanValue()) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been deleted!")); + } + else { - if (success) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been deleted!")); - } - else - { - UtilPlayer.message(caller, F.main(Plugin.getName(), C.cRed + "There was an error deleting the news entry; likely the specified news position was invalid!")); - } + UtilPlayer.message(caller, F.main(Plugin.getName(), C.cRed + "There was an error deleting the news entry; likely the specified news position was invalid!")); } }); return; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java index fa32eb919..974a08e40 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java @@ -1,14 +1,11 @@ package mineplex.hub.commands; -import java.util.HashMap; import java.util.Iterator; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -19,7 +16,7 @@ public class NewsListCommand extends CommandBase { public NewsListCommand(HubManager plugin) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "list"); + super(plugin, HubManager.NEWS_COMMAND_PERMISSION, "list"); } @Override @@ -31,29 +28,23 @@ public class NewsListCommand extends CommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), C.cGray + "Current server news messages:")); - newsMang.RetriveNewsEntries(new Callback>() + newsMang.RetriveNewsEntries(entries -> { - public void run(final HashMap newsEntries) + // Order newsEntries set or its output by newsPosition, not hash order... + newsMang.RetrieveMaxNewsPosition(maxPosition -> { - // Order newsEntries set or its output by newsPosition, not hash order... - newsMang.RetrieveMaxNewsPosition(new Callback() + String[] newsStrings = new String[maxPosition.intValue()]; + for (Iterator iterator = entries.keySet().iterator(); iterator.hasNext();) { - public void run(Integer maxPosition) - { - String[] newsStrings = new String[maxPosition]; - for (Iterator iterator = newsEntries.keySet().iterator(); iterator.hasNext();) - { - String newsPosition = iterator.next(); - newsStrings[Integer.parseInt(newsPosition) - 1] = newsEntries.get(newsPosition); - } - - for (int i = 0; i < newsStrings.length; i++) - { - UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.getName() + "> \", color:blue, \"extra\":[{\"text\":\"[DELETE] \", color:red, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news ¢¤₦₣¡₨₥ " + (i + 1) + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Deletes News Entry " + (i + 1) + " : " + newsStrings[i] + "\"}}, {\"text\":\"News " + (i + 1) + "\", color:gold}, {\"text\":\" : \", color:gray}, {\"text\":\"" + newsStrings[i] + "\", color:white}]}"); - } - } - }); - } + String newsPosition = iterator.next(); + newsStrings[Integer.parseInt(newsPosition) - 1] = entries.get(newsPosition); + } + + for (int i = 0; i < newsStrings.length; i++) + { + UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.getName() + "> \", color:blue, \"extra\":[{\"text\":\"[DELETE] \", color:red, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news ¢¤₦₣¡₨₥ " + (i + 1) + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Deletes News Entry " + (i + 1) + " : " + newsStrings[i] + "\"}}, {\"text\":\"News " + (i + 1) + "\", color:gold}, {\"text\":\" : \", color:gray}, {\"text\":\"" + newsStrings[i] + "\", color:white}]}"); + } + }); }); return; } @@ -63,4 +54,4 @@ public class NewsListCommand extends CommandBase return; } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsSetCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsSetCommand.java index d91e346f8..d5b6083b7 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsSetCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsSetCommand.java @@ -1,11 +1,10 @@ package mineplex.hub.commands; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.hub.HubManager; @@ -15,7 +14,7 @@ public class NewsSetCommand extends CommandBase { public NewsSetCommand(HubManager plugin) { - super(plugin, Rank.ADMIN, "set"); + super(plugin, HubManager.NEWS_COMMAND_PERMISSION, "set"); } @Override @@ -36,7 +35,7 @@ public class NewsSetCommand extends CommandBase { newsEntry += args[i] + " "; } - newsEntry = newsEntry.substring(0, newsEntry.length() - 1); + newsEntry = ChatColor.translateAlternateColorCodes('&', newsEntry.substring(0, newsEntry.length() - 1)); // Check for 256 character length for MySQL! if (newsEntry.length() > 256) @@ -54,25 +53,18 @@ public class NewsSetCommand extends CommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), C.cRed + "The specified news position is invalid!")); return; } - newsMang.SetNewsEntry(newsEntry, newsPosition, new Callback() + + final String entry = newsEntry; + + newsMang.SetNewsEntry(entry, newsPosition, success -> { - public void run(Boolean success) + if (success.booleanValue()) { - if (success) - { - String newsEntry = ""; - for (int i = 1; i < args.length; i++) - { - newsEntry += args[i] + " "; - } - newsEntry = newsEntry.substring(0, newsEntry.length() - 1); - - UtilPlayer.message(caller, F.main(Plugin.getName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been updated to: " + C.cGold + newsEntry + C.cGray + "!")); - } - else - { - UtilPlayer.message(caller, F.main(Plugin.getName(), C.cRed + "There was an error updating the news entry; likely the specified news position was invalid!")); - } + UtilPlayer.message(caller, F.main(Plugin.getName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been updated to: " + C.cGold + entry + C.cGray + "!")); + } + else + { + UtilPlayer.message(caller, F.main(Plugin.getName(), C.cRed + "There was an error updating the news entry; likely the specified news position was invalid!")); } }); return; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java index d1ba19b1f..5bb966c14 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java @@ -16,6 +16,8 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import mineplex.core.MiniPlugin; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.utils.UtilVariant; @@ -24,6 +26,8 @@ import mineplex.hub.commands.HorseSpawn; public class AdminMountManager extends MiniPlugin { + public static final String HORSE_COMMAND_PERMISSION = "mineplex.hub.horse"; + private HubManager Manager; private HashMap _mounts = new HashMap(); @@ -33,6 +37,14 @@ public class AdminMountManager extends MiniPlugin super("Mount Manager", manager.getPlugin()); Manager = manager; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Manager.GetClients().getPermissionManager(); + pm.setPermission(pm.getGroup("lt"), GroupPermission.of(HORSE_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AlienInvasion.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AlienInvasion.java index 8e022d3fb..df2f47e12 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AlienInvasion.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AlienInvasion.java @@ -28,11 +28,13 @@ import org.bukkit.util.BlockVector; import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.Achievement; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.command.CommandBase; import mineplex.core.common.Pair; -import mineplex.core.common.Rank; import mineplex.core.common.block.schematic.Schematic; import mineplex.core.common.block.schematic.SchematicData; import mineplex.core.common.block.schematic.UtilSchematic; @@ -55,54 +57,59 @@ import mineplex.hub.server.ServerManager; @ReflectivelyCreateMiniPlugin public class AlienInvasion extends MiniPlugin { - + public static final String TOGGLE_ANIMATION_COMMAND_PERMISSION = "mineplex.hub.alieninvasion"; + private static final String SCHEMATIC_PATH = ".." + File.separator + ".." + File.separator + "update" + File.separator + "files" + File.separator + "UFO.schematic"; - private static final int[][] UFO_SPAWNS = { - { - 0, 81, -14 - }, - { - 15, 91, -11 - }, - { - -10, 94, 5 - }, - { - -25, 97, -26 - }, - { - -17, 94, -47 - }, - { - 20, 95, -55, - }, - { - 45, 106, -23 - }, - { - 50, 110, 16 - }, - { - -33, 125, 5 - }, - { - 30, 102, 10 - } + private static final int[][] UFO_SPAWNS = + { + { + 0, 81, -14 + }, + { + 15, 91, -11 + }, + { + -10, 94, 5 + }, + { + -25, 97, -26 + }, + { + -17, 94, -47 + }, + { + 20, 95, -55, + }, + { + 45, 106, -23 + }, + { + 50, 110, 16 + }, + { + -33, 125, 5 + }, + { + 30, 102, 10 + } }; + /** * Bob Ross is not an alien */ - private static final String[] ALIEN_SPEAK = { - "Every day is a good day when you paint", - "Beat the devil out of it", - "Happy little clouds", - "Happy little trees", - "I believe", - "I wonder if anyone can see these messages", - "Get involved", - "Ruff", - "Hey you, I see you using the game log output. You should totally go to Moppletop's wall on enjin and say HOI" + private static final String[] ALIEN_SPEAK = + { + "Every day is a good day when you paint", + "Beat the devil out of it", + "Happy little clouds", + "Happy little trees", + "I believe", + "I wonder if anyone can see these messages", + "Get involved", + "Ruff", + "Hey you, I see you using the game log output. You should totally go to Moppletop's wall on enjin and say HOI" }; + private static final ItemStack HELMET = new ItemStack(Material.GLASS); private final BlockRestore _restore; @@ -136,7 +143,7 @@ public class AlienInvasion extends MiniPlugin _beaconBlocks = new HashSet<>(); _aliens = new HashSet<>(); - addCommand(new CommandBase(this, Rank.ADMIN, "alien-animation-start") + addCommand(new CommandBase(this, TOGGLE_ANIMATION_COMMAND_PERMISSION, "alien-animation-start") { @Override public void Execute(Player caller, String[] args) @@ -144,7 +151,7 @@ public class AlienInvasion extends MiniPlugin startAnimation(); } }); - addCommand(new CommandBase(this, Rank.ADMIN, "alien-animation-stop") + addCommand(new CommandBase(this, TOGGLE_ANIMATION_COMMAND_PERMISSION, "alien-animation-stop") { @Override public void Execute(Player caller, String[] args) @@ -154,6 +161,15 @@ public class AlienInvasion extends MiniPlugin }); startAnimation(); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(TOGGLE_ANIMATION_COMMAND_PERMISSION), true, true); } public void startAnimation() @@ -367,4 +383,4 @@ public class AlienInvasion extends MiniPlugin { player.sendMessage(C.cGreen + C.Scramble + ALIEN_SPEAK[UtilMath.r(ALIEN_SPEAK.length)]); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java index 29db6d3fc..a28e73247 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java @@ -27,6 +27,8 @@ import org.bukkit.util.Vector; import mineplex.core.Managers; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -46,11 +48,14 @@ import mineplex.serverdata.database.DBPool; public class EasterEggHunt extends MiniDbClientPlugin { + public static final String ADD_EGG_COMMAND_PERMISSION = "mineplex.hub.addeasteregg"; + private static final int SHARD_REWARD = 500; private static final String ITEM_REWARD = "Omega Chest"; private static final int EGGS_PER_DAY = 30; - private static final BlockFace[] BLOCK_FACES = { + private static final BlockFace[] BLOCK_FACES = + { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, @@ -61,7 +66,8 @@ public class EasterEggHunt extends MiniDbClientPlugin BlockFace.NORTH_WEST }; - private static final String[] EGG_SKINS = { + private static final String[] EGG_SKINS = + { "KingCrazy_", "Trajectories" }; @@ -89,6 +95,15 @@ public class EasterEggHunt extends MiniDbClientPlugin }); addCommand(new EggAddCommand(this)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(ADD_EGG_COMMAND_PERMISSION), true, true); } private String vecToStr(Vector vec) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java index dfcfbf71f..52292ffaa 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java @@ -1,7 +1,16 @@ 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.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; @@ -13,16 +22,12 @@ 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 { + public static final String BYPASS_FORCEFIELD_PERMISSION = "mineplex.hub.forcefield.bypass"; + public static final String FORCEFIELD_RADIUS_COMMAND_PERMISSION = "mineplex.hub.forcefield.radius"; + public HubManager Manager; private HashMap _radius = new HashMap(); @@ -32,6 +37,17 @@ public class ForcefieldManager extends MiniPlugin super("Forcefield", manager.getPlugin()); Manager = manager; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Manager.GetClients().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), true, true); + pm.setPermission(pm.getGroup("eventmod"), GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), false, true); + pm.setPermission(pm.getGroup("lt"), GroupPermission.of(FORCEFIELD_RADIUS_COMMAND_PERMISSION), true, true); } @EventHandler @@ -42,13 +58,7 @@ public class ForcefieldManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { - 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.EVENT_MODERATOR || - 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().getPermissionManager().hasPermission(player, Preference.FORCE_FIELD.getPermission())) { for (Player other : UtilServer.getPlayers()) { @@ -62,9 +72,7 @@ public class ForcefieldManager extends MiniPlugin if (UtilMath.offset(other, player) > range) continue; - if (Manager.GetClients().Get(other).GetRank().has(Rank.ADMIN) || - Manager.GetClients().Get(other).GetRank() == Rank.JNR_DEV || - Manager.GetClients().Get(other).GetRank() == Rank.EVENT_MODERATOR) + if (Manager.GetClients().getPermissionManager().hasPermission(other, GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION))) continue; if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false)) @@ -102,4 +110,4 @@ public class ForcefieldManager extends MiniPlugin { _radius.remove(event.getPlayer()); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java index f2d58351f..c6a1fc63a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java @@ -1,21 +1,5 @@ package mineplex.hub.modules; -import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -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.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; - import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -23,9 +7,23 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +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; + public class HubVisibilityManager extends MiniPlugin { - private static final String JUST_SPAWNED_FLAG = "JustSpawned"; private static final int HIDE_SPAWN_RADIUS_SQUARED = 4; @@ -140,15 +138,11 @@ public class HubVisibilityManager extends MiniPlugin private boolean shouldHide(Player subject) { - Rank subjectRank = Manager.GetClients().Get(subject).GetRank(); - return // Close to spawn closeToSpawn(subject) || // Enabled Invisibility - Manager.getPreferences().get(subject).isActive(Preference.INVISIBILITY) && - // AND Is Moderator+ OR Youtube OR Twitch - (subjectRank.has(Rank.MODERATOR) || subjectRank == Rank.YOUTUBE || subjectRank == Rank.TWITCH) || + (Manager.getPreferences().get(subject).isActive(Preference.INVISIBILITY) && Manager.GetClients().getPermissionManager().hasPermission(subject, Preference.INVISIBILITY.getPermission())) || // OR Player has been explicitly hidden _hiddenPlayers.contains(subject); } @@ -157,4 +151,4 @@ public class HubVisibilityManager extends MiniPlugin { return UtilMath.offset2dSquared(player.getLocation(), Manager.GetSpawn()) < HIDE_SPAWN_RADIUS_SQUARED; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java index b5bef12d6..697d944ad 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java @@ -1,7 +1,18 @@ package mineplex.hub.modules; +import java.util.HashSet; +import java.util.Set; + +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; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; @@ -16,22 +27,12 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; -import org.bukkit.Effect; -import org.bukkit.GameMode; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerToggleFlightEvent; -import org.bukkit.util.Vector; - -import java.util.HashSet; public class JumpManager extends MiniPlugin { public HubManager Manager; - private HashSet _preparedDoubleJump = new HashSet<>(); + private Set _preparedDoubleJump = new HashSet<>(); public JumpManager(HubManager manager) { @@ -50,14 +51,13 @@ public class JumpManager extends MiniPlugin return; } - Rank rank = Manager.GetClients().Get(player).GetRank(); - if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) + if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && Manager.GetClients().getPermissionManager().hasPermission(player, Preference.INVISIBILITY.getPermission())) { return; } //Chicken Cancel - DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); if (disguise != null && ((disguise instanceof DisguiseChicken && !((DisguiseChicken)disguise).isBaby()) || disguise instanceof DisguiseBat || disguise instanceof DisguiseEnderman || disguise instanceof DisguiseWither)) return; @@ -92,8 +92,7 @@ public class JumpManager extends MiniPlugin if (player.getGameMode() == GameMode.CREATIVE) continue; - Rank rank = Manager.GetClients().Get(player).GetRank(); - if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) + if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && Manager.GetClients().getPermissionManager().hasPermission(player, Preference.INVISIBILITY.getPermission())) { player.setAllowFlight(true); continue; @@ -133,4 +132,4 @@ public class JumpManager extends MiniPlugin { return !Recharge.Instance.usable(player, "Double Jump"); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index 1138cd90e..c7e5f67af 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -1,11 +1,15 @@ package mineplex.hub.modules; -import java.awt.*; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; import java.awt.font.FontRenderContext; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Random; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -19,7 +23,11 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.Vector; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandCenter; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilFirework; @@ -42,6 +50,8 @@ import mineplex.serverdata.commands.ServerCommandManager; */ public class NewYearCountdown extends MiniPlugin { + public static final String NEW_YEARS_COMMAND_PERMISSION = "mineplex.hub.newyears"; + private boolean _inProgress; private Location _center; private Location _spawn; @@ -59,6 +69,14 @@ public class NewYearCountdown extends MiniPlugin _center = new Location(UtilWorld.getWorld("world"), 0.5, 85, 37.5); _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5); _inProgress = false; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(NEW_YEARS_COMMAND_PERMISSION), true, true); } @Override @@ -159,6 +177,7 @@ public class NewYearCountdown extends MiniPlugin return; for (int y = 0; y < _currentFrame.getHeight(); y++) + { for (int x = 0; x < _currentFrame.getWidth(); x++) { if (java.awt.Color.black.getRGB() != _currentFrame.getRGB(x, y)) @@ -168,6 +187,7 @@ public class NewYearCountdown extends MiniPlugin UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, _center.add(v), 0, 0, 0, 0, 1, UtilParticle.ViewDist.MAX); _center.subtract(v); } + } } private BufferedImage stringToBufferedImage(Font font, String s) @@ -277,5 +297,4 @@ public class NewYearCountdown extends MiniPlugin List types = Arrays.asList(UtilParticle.ParticleType.FLAME, UtilParticle.ParticleType.HAPPY_VILLAGER, UtilParticle.ParticleType.RED_DUST, UtilParticle.ParticleType.FIREWORKS_SPARK); return types.get(new Random().nextInt(types.size())); } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index 74febb1a9..d7136a56a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -12,7 +12,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -187,34 +186,30 @@ public class NewsManager extends MiniPlugin if (callback == null) return; - Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() + Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), () -> { - public void run() + final Integer position = _repository.retrieveMaxNewsPosition(); + + Bukkit.getScheduler().runTask(getPlugin(), () -> { - final Integer position = _repository.retrieveMaxNewsPosition(); - - Bukkit.getScheduler().runTask(getPlugin(), new Runnable() - { - public void run() - { - callback.run(position); - } - }); - } + callback.run(position); + }); }); } public void Help(Player caller, String message) { UtilPlayer.message(caller, F.main(_moduleName, "Available news arguments for this command:")); - UtilPlayer.message(caller, F.help(C.cGold + "/news list", "Lists (numbered) stored news messages from database.", Rank.ADMIN)); - UtilPlayer.message(caller, F.help(C.cGold + "/news add ", "Adds specified news entry string to database at end of table.", Rank.ADMIN)); - UtilPlayer.message(caller, F.help(C.cGold + "/news delete #", "Removes specified (numbered) news entry string from database.", Rank.ADMIN)); - UtilPlayer.message(caller, F.help(C.cGold + "/news set # ", "Updates specified (numbered) news entry string in database.", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("*Please Note:", "Updates to server news entries from the database are on a 4 minute refresh cycle!", Rank.ADMIN)); + UtilPlayer.message(caller, F.help(C.cGold + "/news list", "Lists (numbered) stored news messages from database.", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help(C.cGold + "/news add ", "Adds specified news entry string to database at end of table.", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help(C.cGold + "/news delete #", "Removes specified (numbered) news entry string from database.", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help(C.cGold + "/news set # ", "Updates specified (numbered) news entry string in database.", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("*Please Note:", "Updates to server news entries from the database are on a 4 minute refresh cycle!", ChatColor.DARK_RED)); if (message != null) + { UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + message)); + } } public void Help(Player caller) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/RankSelectionButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/RankSelectionButton.java index a517e831e..50adb929f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/RankSelectionButton.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/RankSelectionButton.java @@ -3,18 +3,18 @@ package mineplex.hub.modules.salesannouncements; import org.bukkit.Material; import org.bukkit.event.inventory.ClickType; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; public class RankSelectionButton extends SalesAnnouncementGUIButton { private SalesAnnouncementCreationPage _page; - private Rank _rank; + private PermissionGroup _rank; - public RankSelectionButton(Rank rank, SalesAnnouncementCreationPage page) + public RankSelectionButton(PermissionGroup rank, SalesAnnouncementCreationPage page) { - super(new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(rank.getColor() + (rank.Name.isEmpty() ? "Default" : rank.Name)).addLore(C.cRed + "Click to Toggle On").build()); + super(new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(rank.getDisplay(true, false, false, true)).addLore(C.cRed + "Click to Toggle On").build()); _rank = rank; _page = page; } @@ -27,13 +27,13 @@ public class RankSelectionButton extends SalesAnnouncementGUIButton { if (_page.Selected.contains(_rank)) { - Button = new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(_rank.getColor() + (_rank.Name.isEmpty() ? "Default" : _rank.Name)).addLore(C.cRed + "Click to Toggle On").build(); + Button = new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(_rank.getDisplay(true, false, false, true)).addLore(C.cRed + "Click to Toggle On").build(); _page.Selected.remove(_rank); _page.updateButtons(true); } else { - Button = new ItemBuilder(Material.EMERALD_BLOCK).setTitle(_rank.getColor() + (_rank.Name.isEmpty() ? "Default" : _rank.Name)).addLore(C.cGreen + "Click to Toggle Off").build(); + Button = new ItemBuilder(Material.EMERALD_BLOCK).setTitle(_rank.getDisplay(true, false, false, true)).addLore(C.cGreen + "Click to Toggle Off").build(); _page.Selected.add(_rank); _page.updateButtons(true); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementCommand.java index 58f7f4930..8dd02cbd6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementCommand.java @@ -3,7 +3,6 @@ package mineplex.hub.modules.salesannouncements; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -11,7 +10,7 @@ public class SalesAnnouncementCommand extends CommandBase _buttons = new HashMap<>(); - public List Selected = Lists.newArrayList(); + public List Selected = new ArrayList<>(); public SalesAnnouncementCreationPage(Player player, String message) { @@ -41,10 +42,16 @@ public class SalesAnnouncementCreationPage implements Listener private void setup() { - for (int i = 0; i < Rank.values().length; i++) + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + PermissionGroup[] ranks = pm.getGroups().toArray(new PermissionGroup[pm.getGroups().size()]); + int slot = 0; + for (int i = 0; i < ranks.length; i++) { - Rank rank = Rank.values()[i]; - _buttons.put(i, new RankSelectionButton(rank, this)); + PermissionGroup rank = ranks[i]; + if (rank.canBePrimary()) + { + _buttons.put(slot++, new RankSelectionButton(rank, this)); + } } _buttons.put(31, new RankSelectionFinalizeButton(this)); updateButtons(false); @@ -57,7 +64,7 @@ public class SalesAnnouncementCreationPage implements Listener public void finalizeSelection() { - Managers.get(SalesAnnouncementManager.class).createAnnouncement(_viewer, Selected.toArray(new Rank[Selected.size()]), _message); + Managers.get(SalesAnnouncementManager.class).createAnnouncement(_viewer, Selected.toArray(new PermissionGroup[Selected.size()]), _message); Managers.get(SalesAnnouncementManager.class).runSyncLater(() -> _viewer.closeInventory(), 1L); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementData.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementData.java index 964962bf7..7dddc1079 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementData.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementData.java @@ -6,18 +6,18 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; public class SalesAnnouncementData { private final Integer _id; - private final Rank[] _displayTo; + private final PermissionGroup[] _displayTo; private final String _message; private boolean _enabled; - public SalesAnnouncementData(Integer id, Rank[] displayTo, String message, boolean enabled) + public SalesAnnouncementData(Integer id, PermissionGroup[] displayTo, String message, boolean enabled) { _id = id; _displayTo = displayTo; @@ -30,12 +30,12 @@ public class SalesAnnouncementData return _id; } - public Rank[] getDisplayTo() + public PermissionGroup[] getDisplayTo() { return _displayTo; } - public boolean shouldDisplayTo(Rank rank) + public boolean shouldDisplayTo(PermissionGroup rank) { return Arrays.asList(_displayTo).contains(rank); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java index 266f340d9..331be8c18 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementManager.java @@ -11,7 +11,9 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -20,6 +22,8 @@ import mineplex.serverdata.commands.ServerCommandManager; public class SalesAnnouncementManager extends MiniPlugin { + public static final String SALES_COMMAND_PERMISSION = "mineplex.hub.salesannouncements.command"; + private static final String LINE = C.cDGreenB + C.Strike + "============================================="; private final Map _data = new HashMap<>(); private final SalesAnnouncementRepository _repo; @@ -35,6 +39,15 @@ public class SalesAnnouncementManager extends MiniPlugin ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this)); ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SALES_COMMAND_PERMISSION), true, true); } public Map getLoadedAnnouncements() @@ -47,7 +60,7 @@ public class SalesAnnouncementManager extends MiniPlugin return getPlugin().getConfig().getString("serverstatus.name"); } - public void createAnnouncement(Player creator, Rank[] displayTo, String message) + public void createAnnouncement(Player creator, PermissionGroup[] displayTo, String message) { if (_data.size() >= 9 * 6) { @@ -129,7 +142,7 @@ public class SalesAnnouncementManager extends MiniPlugin return; } Player player = event.getPlayer(); - Rank rank = Managers.get(CoreClientManager.class).Get(player).GetRank(); + PermissionGroup rank = Managers.get(CoreClientManager.class).Get(player).getPrimaryGroup(); runSyncLater(() -> { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java index 43584cd7e..fdeb59602 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java @@ -7,9 +7,10 @@ import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; -import com.google.common.collect.Lists; - -import mineplex.core.common.Rank; +import mineplex.core.Managers; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.Callback; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; @@ -29,12 +30,14 @@ public class SalesAnnouncementRepository extends RepositoryBase private final JavaPlugin _plugin; private final boolean _clans; + private final PermissionManager _pm; public SalesAnnouncementRepository(JavaPlugin plugin, boolean clans) { super(DBPool.getAccount()); _plugin = plugin; _clans = clans; + _pm = Managers.get(CoreClientManager.class).getPermissionManager(); } private void runAsync(Runnable runnable) @@ -58,19 +61,29 @@ public class SalesAnnouncementRepository extends RepositoryBase { int id = resultSet.getInt("id"); String rankString = resultSet.getString("ranks"); - List ranks = Lists.newArrayList(); + List ranks = new ArrayList<>(); if (rankString.contains(",") && !rankString.startsWith(",") && !rankString.endsWith(",")) { for (String rankStr : rankString.split(",")) { - ranks.add(Rank.valueOf(rankStr)); + PermissionGroup group = _pm.getGroup(rankStr); + if (group == null) + { + group = _pm.getGroupFromLegacy(rankStr); + } + ranks.add(group); } } else { - ranks.add(Rank.valueOf(rankString)); + PermissionGroup group = _pm.getGroup(rankString); + if (group == null) + { + group = _pm.getGroupFromLegacy(rankString); + } + ranks.add(group); } - Rank[] displayTo = ranks.toArray(new Rank[ranks.size()]); + PermissionGroup[] displayTo = ranks.toArray(new PermissionGroup[ranks.size()]); String message = resultSet.getString("message"); boolean enabled = resultSet.getBoolean("enabled"); @@ -96,19 +109,29 @@ public class SalesAnnouncementRepository extends RepositoryBase { int aId = resultSet.getInt("id"); String rankString = resultSet.getString("ranks"); - List ranks = Lists.newArrayList(); + List ranks = new ArrayList<>(); if (rankString.contains(",") && !rankString.startsWith(",") && !rankString.endsWith(",")) { for (String rankStr : rankString.split(",")) { - ranks.add(Rank.valueOf(rankStr)); + PermissionGroup group = _pm.getGroup(rankStr); + if (group == null) + { + group = _pm.getGroupFromLegacy(rankStr); + } + ranks.add(group); } } else { - ranks.add(Rank.valueOf(rankString)); + PermissionGroup group = _pm.getGroup(rankString); + if (group == null) + { + group = _pm.getGroupFromLegacy(rankString); + } + ranks.add(group); } - Rank[] displayTo = ranks.toArray(new Rank[ranks.size()]); + PermissionGroup[] displayTo = ranks.toArray(new PermissionGroup[ranks.size()]); String message = resultSet.getString("message"); boolean enabled = resultSet.getBoolean("enabled"); @@ -122,14 +145,14 @@ public class SalesAnnouncementRepository extends RepositoryBase }); } - public void createAnnouncement(final Rank[] displayTo, final String message, Callback callback) + public void createAnnouncement(final PermissionGroup[] displayTo, final String message, Callback callback) { runAsync(() -> { - String rankStr = displayTo[0].toString(); + String rankStr = displayTo[0].getIdentifier(); for (int i = 1; i < displayTo.length; i++) { - rankStr += ("," + displayTo[i].toString()); + rankStr += ("," + displayTo[i].getIdentifier()); } executeInsert(INSERT_ANNOUNCEMENT, resultSet -> { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/notification/NotificationManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/notification/NotificationManager.java index 69c863958..8a0852c7d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/notification/NotificationManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/notification/NotificationManager.java @@ -12,6 +12,8 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.Color; import mineplex.core.common.jsonchat.JsonMessage; @@ -23,17 +25,30 @@ import mineplex.hub.notification.gui.NotificationShop; public class NotificationManager extends MiniPlugin { + public static final String NOTIFICATION_COMMAND_PERMISSION = "mineplex.hub.notification.command"; + private static NotificationComparator COMPARATOR = new NotificationComparator(); private NotificationShop _shop; + private CoreClientManager _clientManager; private List _notifiers; public NotificationManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) { super("Notification", plugin); - _notifiers = new ArrayList(); + _notifiers = new ArrayList<>(); + _clientManager = clientManager; _shop = new NotificationShop(this, clientManager, donationManager); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(NOTIFICATION_COMMAND_PERMISSION), true, true); } @EventHandler @@ -110,4 +125,4 @@ public class NotificationManager extends MiniPlugin } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/notification/command/NotificationCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/notification/command/NotificationCommand.java index 789a9896c..1f1dc11a9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/notification/command/NotificationCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/notification/command/NotificationCommand.java @@ -3,17 +3,13 @@ package mineplex.hub.notification.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.hub.mail.MailManager; -import mineplex.hub.mail.MailMessage; -import mineplex.hub.mail.PlayerMailData; import mineplex.hub.notification.NotificationManager; public class NotificationCommand extends CommandBase { public NotificationCommand(NotificationManager plugin) { - super(plugin, Rank.ALL, "notifications"); + super(plugin, NotificationManager.NOTIFICATION_COMMAND_PERMISSION, "notifications"); } @Override @@ -21,4 +17,4 @@ public class NotificationCommand extends CommandBase { Plugin.openShop(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerInfo.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerInfo.java index 7a2dae3c7..00036ca0f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerInfo.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerInfo.java @@ -1,6 +1,6 @@ package mineplex.hub.server; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.UtilServer; import mineplex.serverdata.data.MinecraftServer; @@ -13,7 +13,7 @@ public class ServerInfo public String Map; public String ServerType; public String Game; - public Rank HostRank = Rank.ALL; + public PermissionGroup HostRank = null; public MinecraftServer Server; public int getAvailableSlots() diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 38839f738..1fccbc717 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -19,17 +19,16 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityPortalEnterEvent; import org.bukkit.event.entity.EntityPortalEvent; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPortalEvent; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.boosters.BoosterManager; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -40,7 +39,6 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.donation.DonationManager; -import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.party.PartyManager; import mineplex.core.party.event.PartySelectServerEvent; import mineplex.core.portal.Intent; @@ -63,8 +61,9 @@ import mineplex.serverdata.data.ServerGroup; public class ServerManager extends MiniPlugin { - private static final Long FREE_PORTAL_TIMER = -1L; - private static final Long BETA_PORTAL_TIMER = 120000L; + public static final String JOIN_FULL_PERMISSION = "mineplex.hub.servermanager.joinfull"; + public static final String FEATURE_SERVER_PERMISSION = "mineplex.hub.servermanager.featureserver"; + private static final Random random = new Random(); public final int TOP_SERVERS = 3; // The number of top contending servers for auto-joining games @@ -90,9 +89,6 @@ public class ServerManager extends MiniPlugin private ClansServerShop _clansShop; - // Join Time for Free Players Timer - private NautHashMap _joinTime = new NautHashMap(); - private QuickShop _quickShop; private LobbyShop _lobbyShop; @@ -121,6 +117,17 @@ public class ServerManager extends MiniPlugin // TODO: Find more appropriate place to initialize Clans server shop? _clansShop = new ClansServerShop(this, _clientManager, _donationManager); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + pm.setPermission(pm.getGroup("content"), GroupPermission.of(FEATURE_SERVER_PERMISSION), true, true); + pm.setPermission(pm.getGroup("builder"), GroupPermission.of(FEATURE_SERVER_PERMISSION), true, true); } @EventHandler(priority = EventPriority.LOW) @@ -183,24 +190,6 @@ public class ServerManager extends MiniPlugin */ } - @EventHandler(priority = EventPriority.LOW) - public void playerJoin(PlayerJoinEvent event) - { - event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.COMPASS.getId(), (byte)0, 1, ChatColor.GREEN + "Game Menu")); - event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WATCH.getId(), (byte)0, 1, ChatColor.GREEN + "Lobby Menu")); - - if (_clientManager.Get(event.getPlayer()).GetRank() == Rank.ALL) - { - _joinTime.put(event.getPlayer().getName(), System.currentTimeMillis()); - } - } - - @EventHandler - public void playerQuit(PlayerQuitEvent event) - { - _joinTime.remove(event.getPlayer().getName()); - } - @EventHandler public void playerInteract(PlayerInteractEvent event) { @@ -219,22 +208,6 @@ public class ServerManager extends MiniPlugin } } - public Long getMillisecondsUntilPortal(Player player, boolean beta) - { -// Party party = _partyManager.GetParty(player); - long timeLeft = 0; - - if (_joinTime.containsKey(player.getName())) - { - timeLeft = (_joinTime.get(player.getName()) - System.currentTimeMillis()) + (beta ? BETA_PORTAL_TIMER : FREE_PORTAL_TIMER); - - if (timeLeft <= 0) - timeLeft = 0; - } - - return timeLeft; - } - public void addServerGroup(ServerGroup serverGroup) { _serverKeyInfoMap.put(serverGroup.getPrefix(), new HashSet()); @@ -372,11 +345,11 @@ public class ServerManager extends MiniPlugin { if (arg != null && arg.startsWith("HostRank.") && arg.length() > "HostRank.".length()) { - String rankEnum = arg.split("\\.")[1]; + String identifier = arg.split("\\.")[1]; try { - serverInfo.HostRank = Rank.valueOf(rankEnum); + serverInfo.HostRank = _clientManager.getPermissionManager().getGroup(identifier); } catch (Exception e) { @@ -436,13 +409,13 @@ public class ServerManager extends MiniPlugin public void help(Player caller, String message) { UtilPlayer.message(caller, F.main(_moduleName, "Commands List:")); - UtilPlayer.message(caller, F.help("/servernpc create ", " is name of npc.", Rank.OWNER)); - UtilPlayer.message(caller, F.help("/servernpc delete ", " is name of npc.", Rank.OWNER)); - UtilPlayer.message(caller, F.help("/servernpc addserver | ", "Adds server.", Rank.OWNER)); - UtilPlayer.message(caller, F.help("/servernpc removeserver ", "Removes server.", Rank.OWNER)); - UtilPlayer.message(caller, F.help("/servernpc listnpcs", "Lists all server npcs.", Rank.OWNER)); - UtilPlayer.message(caller, F.help("/servernpc listservers ", "Lists all servers.", Rank.OWNER)); - UtilPlayer.message(caller, F.help("/servernpc listoffline", "Shows all servers offline.", Rank.OWNER)); + UtilPlayer.message(caller, F.help("/servernpc create ", " is name of npc.", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/servernpc delete ", " is name of npc.", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/servernpc addserver | ", "Adds server.", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/servernpc removeserver ", "Removes server.", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/servernpc listnpcs", "Lists all server npcs.", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/servernpc listservers ", "Lists all servers.", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/servernpc listoffline", "Shows all servers offline.", ChatColor.DARK_RED)); if (message != null) UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + message)); @@ -680,7 +653,7 @@ public class ServerManager extends MiniPlugin { int slots = 0; - if (!_clientManager.Get(player).GetRank().has(Rank.ULTRA) && !_donationManager.Get(player).ownsUnknownSalesPackage(serverType + " ULTRA")) + if (!_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(JOIN_FULL_PERMISSION)) && !_donationManager.Get(player).ownsUnknownSalesPackage(serverType + " ULTRA")) slots++; return slots; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java index 63d49220f..c4de0ced1 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java @@ -5,11 +5,11 @@ import java.util.Collections; import java.util.List; import org.bukkit.ChatColor; -import org.bukkit.entity.Player; import org.bukkit.Material; +import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; import mineplex.core.shop.item.ShopItem; @@ -68,7 +68,7 @@ public class LobbyMenu extends ShopPageBase implements if (serverInfo.CurrentPlayers >= serverInfo.MaxPlayers) { - if (!getClient().GetRank().has(Rank.ULTRA)) + if (!getClientManager().getPermissionManager().hasPermission(getPlayer(), GroupPermission.of(ServerManager.JOIN_FULL_PERMISSION))) lore.add(openFull); else lore.add(openFullUltra); @@ -109,4 +109,4 @@ public class LobbyMenu extends ShopPageBase implements getPlugin().selectServer(player, serverInfo); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java index 08804cb72..bf53746c8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java @@ -15,7 +15,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; import mineplex.core.game.GameDisplay; @@ -92,7 +92,7 @@ public class ServerNpcPage extends ShopPageInventory lore = new ArrayList(); @@ -210,7 +210,7 @@ public class ServerNpcPage extends ShopPageInventory lore = new ArrayList(); + List lore = new ArrayList<>(); lore.add(host); lore.add(" "); lore.add(ChatColor.RESET + C.cYellow + "Players: " + C.cWhite + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers); @@ -414,10 +414,10 @@ public class ServerNpcPage extends ShopPageInventory implements IClassFactory { + public static final String VIEW_OTHER_SKILLS = "mineplex.classcombat.skillunlock"; + private CoreClientManager _clientManager; private DonationManager _donationManager; private SkillFactory _skillFactory; private ItemFactory _itemFactory; private ClassRepository _repository; private GadgetManager _gadgetManager; - private HashMap _classes; - private HashMap _classSalesPackageIdMap; + private Map _classes; + private Map _classSalesPackageIdMap; private final Object _clientLock = new Object(); private boolean _enabled = true; - private ConcurrentHashMap> _messageSuppressed; + private Map> _messageSuppressed; public ClassManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, SkillFactory skillFactory, ItemFactory itemFactory) @@ -59,11 +63,13 @@ public class ClassManager extends MiniClientPlugin implements IClas _skillFactory = skillFactory; _itemFactory = itemFactory; _repository = new ClassRepository(); - _classes = new HashMap(); - _classSalesPackageIdMap = new HashMap(); - _messageSuppressed = new ConcurrentHashMap>(); + _classes = new HashMap<>(); + _classSalesPackageIdMap = new HashMap<>(); + _messageSuppressed = new ConcurrentHashMap<>(); PopulateClasses(); + + generatePermissions(); } public ClassManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, GadgetManager gadgetManager, @@ -78,11 +84,20 @@ public class ClassManager extends MiniClientPlugin implements IClas _skillFactory = skillFactory; _itemFactory = itemFactory; _repository = new ClassRepository(); - _classes = new HashMap(); - _classSalesPackageIdMap = new HashMap(); - _messageSuppressed = new ConcurrentHashMap>(); + _classes = new HashMap<>(); + _classSalesPackageIdMap = new HashMap<>(); + _messageSuppressed = new ConcurrentHashMap<>(); PopulateClasses(); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(VIEW_OTHER_SKILLS), true, true); } @EventHandler @@ -346,7 +361,7 @@ public class ClassManager extends MiniClientPlugin implements IClas Player target = event.getPlayer(); //Target Other - if (args.length > 1 && _clientManager.Get(event.getPlayer()).GetRank().has(Rank.MODERATOR)) + if (args.length > 1 && _clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(VIEW_OTHER_SKILLS))) { target = UtilPlayer.searchOnline(event.getPlayer(), args[1], true); @@ -359,7 +374,9 @@ public class ClassManager extends MiniClientPlugin implements IClas ClientClass client = Get(target.getUniqueId()); if (client == null) + { event.getPlayer().sendMessage(target.getName() + " does not have a ClientClass."); + } else { client.DisplaySkills(event.getPlayer()); @@ -394,4 +411,9 @@ public class ClassManager extends MiniClientPlugin implements IClas { return _messageSuppressed.get(name); } -} + + public CoreClientManager getClientManager() + { + return _clientManager; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index fe9fcdd82..bd559e5fe 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -12,7 +12,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import mineplex.core.account.CoreClient; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -30,6 +30,7 @@ import mineplex.minecraft.game.classcombat.Skill.ISkill.SkillType; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.Knight.AxeThrow; import mineplex.minecraft.game.classcombat.item.ItemFactory; +import mineplex.minecraft.game.classcombat.shop.ClassShopManager; public class ClientClass { @@ -572,16 +573,20 @@ public class ClientClass { try { - if (skillName == null || skill == null || expectedType == null) - return false; - - if (!skillName.isEmpty() && (skill == null || skill.GetSkillType() != expectedType || (!skill.IsFree() && !_donor.ownsUnknownSalesPackage("Champions " + skillName) && !_client.GetRank().has(Rank.ULTRA) && !_donor.ownsUnknownSalesPackage("Competitive ULTRA")))) - return false; - - } catch (NullPointerException ex) + if (skillName == null || skill == null || expectedType == null) + { + return false; + } + + if (!skillName.isEmpty() && (skill == null || skill.GetSkillType() != expectedType || (!skill.IsFree() && !_donor.ownsUnknownSalesPackage("Champions " + skillName) && !_classFactory.getClientManager().getPermissionManager().hasPermission(_client, GroupPermission.of(ClassShopManager.SKILL_UNLOCK_LEGACY_PERMISSION)) && !_donor.ownsUnknownSalesPackage("Competitive ULTRA")))) + { + return false; + } + } + catch (NullPointerException ex) { System.out.println("Somehow a Nullpointer happens here if someone uses /disguise.\n" + - "shouldnt be a problem because Youtube+ can have all skills."); + "shouldnt be a problem because Youtube+ can have all skills."); } return true; } @@ -608,10 +613,14 @@ public class ClientClass for (SkillType type : SkillType.values()) { if (type == SkillType.GlobalPassive) + { continue; + } if (!_skillMap.containsKey(type)) + { continue; + } ISkill skill = _skillMap.get(type); @@ -624,4 +633,4 @@ public class ClientClass } } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassShopManager.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassShopManager.java index 5c3d5e13a..a8f43184a 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassShopManager.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassShopManager.java @@ -5,15 +5,19 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.Achievement; import mineplex.core.achievement.AchievementManager; -import mineplex.core.common.Rank; import mineplex.minecraft.game.classcombat.Class.ClassManager; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.item.ItemFactory; public class ClassShopManager extends MiniPlugin { + public static final String SKILL_UNLOCK_PERMISSION = "mineplex.classcombat.skillunlock"; + public static final String SKILL_UNLOCK_LEGACY_PERMISSION = "mineplex.classcombat.skillunlock.legacy"; + private ClassManager _classManager; private SkillFactory _skillFactory; private ItemFactory _itemFactory; @@ -29,6 +33,16 @@ public class ClassShopManager extends MiniPlugin _itemFactory = itemFactory; _achievementManager = achievementManager; _clientManager = clientManager; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SKILL_UNLOCK_PERMISSION), true, true); + pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(SKILL_UNLOCK_LEGACY_PERMISSION), true, true); } public ClassManager GetClassManager() @@ -48,21 +62,21 @@ public class ClassShopManager extends MiniPlugin public boolean hasAchievements(Player player) { - if (_clientManager.Get(player).GetRank().has(Rank.HELPER)) + if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(SKILL_UNLOCK_PERMISSION))) return true; return _achievementManager.hasCategory(player, new Achievement[] { - Achievement.CHAMPIONS_ACE, - Achievement.CHAMPIONS_ASSASSINATION, - Achievement.CHAMPIONS_EARTHQUAKE, - Achievement.CHAMPIONS_FLAWLESS_VICTORY, - Achievement.CHAMPIONS_MASS_ELECTROCUTION, - Achievement.CHAMPIONS_THE_LONGEST_SHOT, - Achievement.CHAMPIONS_WINS, - Achievement.CHAMPIONS_CAPTURES, - Achievement.CHAMPIONS_CLUTCH, - Achievement.CHAMPIONS_SPECIAL_WIN + Achievement.CHAMPIONS_ACE, + Achievement.CHAMPIONS_ASSASSINATION, + Achievement.CHAMPIONS_EARTHQUAKE, + Achievement.CHAMPIONS_FLAWLESS_VICTORY, + Achievement.CHAMPIONS_MASS_ELECTROCUTION, + Achievement.CHAMPIONS_THE_LONGEST_SHOT, + Achievement.CHAMPIONS_WINS, + Achievement.CHAMPIONS_CAPTURES, + Achievement.CHAMPIONS_CLUTCH, + Achievement.CHAMPIONS_SPECIAL_WIN }); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java index f6d0b809c..cb6916902 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java @@ -1,7 +1,16 @@ package mineplex.minecraft.game.classcombat.shop.page; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; @@ -18,17 +27,13 @@ import mineplex.minecraft.game.classcombat.Skill.ISkill; import mineplex.minecraft.game.classcombat.item.Item; import mineplex.minecraft.game.classcombat.shop.ClassCombatShop; import mineplex.minecraft.game.classcombat.shop.ClassShopManager; -import mineplex.minecraft.game.classcombat.shop.button.*; +import mineplex.minecraft.game.classcombat.shop.button.DeselectItemButton; +import mineplex.minecraft.game.classcombat.shop.button.PurchaseItemButton; +import mineplex.minecraft.game.classcombat.shop.button.PurchaseSkillButton; +import mineplex.minecraft.game.classcombat.shop.button.SelectItemButton; +import mineplex.minecraft.game.classcombat.shop.button.SelectSkillButton; import mineplex.minecraft.game.classcombat.shop.salespackage.ItemSalesPackage; import mineplex.minecraft.game.classcombat.shop.salespackage.SkillSalesPackage; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.List; public class SkillPage extends ShopPageBase { @@ -394,7 +399,7 @@ public class SkillPage extends ShopPageBase private boolean isSkillLocked(ISkill skill) { - if (skill.IsFree() || getClientManager().Get(getPlayer()).GetRank().has(Rank.HELPER) || getDonationManager().Get(getPlayer()).ownsUnknownSalesPackage("Champions ULTRA") || getDonationManager().Get(getPlayer()).ownsUnknownSalesPackage("Champions " + skill.GetName())) + if (skill.IsFree() || getClientManager().getPermissionManager().hasPermission(getPlayer(), GroupPermission.of(ClassShopManager.SKILL_UNLOCK_PERMISSION)) || getDonationManager().Get(getPlayer()).ownsUnknownSalesPackage("Champions ULTRA") || getDonationManager().Get(getPlayer()).ownsUnknownSalesPackage("Champions " + skill.GetName())) return false; return true; @@ -402,7 +407,7 @@ public class SkillPage extends ShopPageBase private boolean isItemLocked(Item item) { - if (item.isFree() || getClientManager().Get(getPlayer()).GetRank().has(Rank.HELPER) || getDonationManager().Get(getPlayer()).ownsUnknownSalesPackage("Champions ULTRA") || getDonationManager().Get(getPlayer()).ownsUnknownSalesPackage("Champions " + item.GetName())) + if (item.isFree() || getClientManager().getPermissionManager().hasPermission(getPlayer(), GroupPermission.of(ClassShopManager.SKILL_UNLOCK_PERMISSION)) || getDonationManager().Get(getPlayer()).ownsUnknownSalesPackage("Champions ULTRA") || getDonationManager().Get(getPlayer()).ownsUnknownSalesPackage("Champions " + item.GetName())) return false; return true; @@ -500,4 +505,4 @@ public class SkillPage extends ShopPageBase buildPage(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/UpdateRankCommand.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/UpdateRankCommand.java deleted file mode 100644 index e3c2478c7..000000000 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/UpdateRankCommand.java +++ /dev/null @@ -1,17 +0,0 @@ -package mineplex.serverdata.commands; - -public class UpdateRankCommand extends ServerCommand -{ - private String _callerName; - private String _callerUUID; - private String _targetName; - private String _targetRankNew; - - public UpdateRankCommand(String callerName, String callerUUID, String targetName, String targetRankNew) - { - _callerName = callerName; - _callerUUID = callerUUID; - _targetName = targetName; - _targetRankNew = targetRankNew; - } -} diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/RepositoryBase.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/RepositoryBase.java index 996b5ed40..fe4fd9a38 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/RepositoryBase.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/database/RepositoryBase.java @@ -152,6 +152,10 @@ public abstract class RepositoryBase catch (SQLException exception) { exception.printStackTrace(); + if (onSQLError != null) + { + onSQLError.run(); + } } catch (Exception exception) { @@ -232,6 +236,10 @@ public abstract class RepositoryBase catch (SQLException exception) { exception.printStackTrace(); + if (onSQLError != null) + { + onSQLError.run(); + } } catch (Exception exception) { @@ -270,6 +278,10 @@ public abstract class RepositoryBase catch (SQLException exception) { exception.printStackTrace(); + if (onSQLError != null) + { + onSQLError.run(); + } } catch (Exception exception) { diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index c6597f877..50a8bf9a2 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -1,8 +1,8 @@ package mineplex.staffServer; -import java.util.UUID; +import static mineplex.core.Managers.require; -import net.minecraft.server.v1_8_R3.MinecraftServer; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_8_R3.CraftServer; @@ -16,7 +16,6 @@ import mineplex.core.achievement.AchievementManager; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; import mineplex.core.common.Constants; -import mineplex.core.common.Rank; import mineplex.core.creature.Creature; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; @@ -39,8 +38,7 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.staffServer.customerSupport.CustomerSupport; import mineplex.staffServer.salespackage.SalesPackageManager; - -import static mineplex.core.Managers.require; +import net.minecraft.server.v1_8_R3.MinecraftServer; public class StaffServer extends JavaPlugin { @@ -53,7 +51,7 @@ public class StaffServer extends JavaPlugin //Static Modules CommandCenter.Initialize(this); - CoreClientManager clientManager = new CoreClientManager(this, Rank.DEVELOPER); + CoreClientManager clientManager = new CoreClientManager(this); CommandCenter.Instance.setClientManager(clientManager); Recharge.Initialize(this); @@ -77,7 +75,6 @@ public class StaffServer extends JavaPlugin PowerPlayClubRepository powerPlayRepo = new PowerPlayClubRepository(this, clientManager, donationManager); new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this, clientManager), statsManager, powerPlayRepo), powerPlayRepo); - //new Password(this, serverStatusManager.getCurrentServerName()); //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); @@ -104,4 +101,4 @@ public class StaffServer extends JavaPlugin require(ProfileCacheManager.class); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 2f7e0cd5c..6d6c95db8 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -29,7 +29,8 @@ import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -47,6 +48,12 @@ import mineplex.staffServer.salespackage.SalesPackageManager; public class CustomerSupport extends MiniPlugin implements ResultSetCallable { + public static final String CHECK_BONUS_COMMAND_PERMISSION = "mineplex.customersupport.checkbonus"; + public static final String CHECK_COMMAND_PERMISSION = "mineplex.customersupport.check"; + public static final String CHECK_OWNS_PACKAGE_COMMAND_PERMISSION = "mineplex.customersupport.checkownspackage"; + public static final String LIST_PPC_COMMAND_PERMISSION = "mineplex.customersupport.listppc"; + public static final String JOIN_SERVER_PERMISSION = "mineplex.customersupport.joinserver"; + private CoreClientManager _clientManager; private DonationManager _donationManager; private SalesPackageManager _salesPackageManager; @@ -75,12 +82,25 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable addCommand(new checkBonusCommand(this)); addCommand(new checkOwnsPackageCommand(this)); addCommand(new ListPPCCommand(this, _powerPlayRepo)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("support"), GroupPermission.of(CHECK_BONUS_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("support"), GroupPermission.of(CHECK_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("support"), GroupPermission.of(CHECK_OWNS_PACKAGE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("support"), GroupPermission.of(LIST_PPC_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("support"), GroupPermission.of(JOIN_SERVER_PERMISSION), true, true); } @EventHandler public void Join(PlayerJoinEvent event) { - if (!_clientManager.Get(event.getPlayer()).GetRank().has(Rank.SUPPORT)) + if (!_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(JOIN_SERVER_PERMISSION))) { event.getPlayer().kickPlayer("Only for support staff."); return; @@ -130,7 +150,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cDGreen + C.Strike + "============================================="); StringBuilder basic = new StringBuilder(C.cBlue + "Name: " + C.cYellow + playerName); basic.append(" "); - basic.append(C.cBlue + "Rank: " + C.cYellow + (client.GetRank() == null ? C.cRed + "Error rank null!" : (client.GetRank().Name.isEmpty() ? "Regular" : client.GetRank().Name))); + basic.append(C.cBlue + "Rank: " + C.cYellow + client.getPrimaryGroup().getDisplay(false, false, false, true)); if (!bonuses) { basic.append(" "); @@ -434,7 +454,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Game Amplifiers Received: " + C.cYellow + boostersReceived); caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min/60 min) Received: " + C.cYellow + runeAmplifier20 + "/" + runeAmplifier60); caller.sendMessage(C.cBlue + "Clans Dye Boxes Received: " + C.cYellow + clansDyeBoxesReceived + " " + C.cBlue + "Clans Builder Boxes Received: " + C.cYellow + clansBuilderBoxesReceived); - caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Usage") + " " + C.cBlue + "Clan Banner Editor: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Editor")); + caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedPackageStr(client.getUniqueId(), "Clan Banner Usage") + " " + C.cBlue + "Clan Banner Editor: " + getLockedPackageStr(client.getUniqueId(), "Clan Banner Editor")); YearMonth yearMonth = YearMonth.now(); caller.sendMessage(C.cBlue + "Power Play Subscription (" + yearMonth.getMonth().getDisplayName(TextStyle.FULL, Locale.US) + ") " + (powerPlayData.isSubscribed() ? C.cGreen + "Active" : C.cRed + "Inactive")); if (powerPlayData.isSubscribed()) @@ -471,22 +491,15 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable public void showPlayerPackageInfo(Player caller, CoreClient client, String salesPackage) { - CustomerSupport instance = this; - runAsync(new Runnable() + runAsync(() -> { - public void run() + _repository.loadBonusLogForAccountId(client.getAccountId(), CustomerSupport.this); + + runSync(() -> { - _repository.loadBonusLogForAccountId(client.getAccountId(), instance); - - runSync(new Runnable() - { - public void run() - { - caller.sendMessage(C.cBlue + salesPackage + ": " + getLockedFreedomStr(client.getUniqueId(), salesPackage)); - _accountBonusLog.remove(client.getAccountId()); - } - }); - } + caller.sendMessage(C.cBlue + salesPackage + ": " + getLockedPackageStr(client.getUniqueId(), salesPackage)); + _accountBonusLog.remove(client.getAccountId()); + }); }); } @@ -537,7 +550,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable _accountBonusLog.put(accountId, log); } - private String getLockedFreedomStr(UUID uuid, String name) + private String getLockedPackageStr(UUID uuid, String name) { if (_donationManager.Get(uuid).ownsUnknownSalesPackage(name)) { @@ -545,4 +558,4 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable } return C.cRed + C.Bold + "Locked"; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupportRepository.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupportRepository.java index 286c3ac9c..fb902bed2 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupportRepository.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupportRepository.java @@ -2,7 +2,6 @@ package mineplex.staffServer.customerSupport; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.database.MinecraftRepository; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; @@ -17,4 +16,4 @@ public class CustomerSupportRepository extends RepositoryBase { executeQuery("SELECT accountId, items.name, itemChange, time FROM bonusLog INNER JOIN items ON itemId = items.id WHERE accountId = " + accountId + " ORDER BY bonusLog.id DESC;", customerSupport); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/ListPPCCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/ListPPCCommand.java index 6d3c1243a..1b109a4b0 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/ListPPCCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/ListPPCCommand.java @@ -17,7 +17,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -31,7 +30,8 @@ public class ListPPCCommand extends CommandBase public ListPPCCommand(CustomerSupport customerSupport, PowerPlayClubRepository powerPlayRepo) { - super(customerSupport, Rank.MODERATOR, "listppc", "checkppc"); + super(customerSupport, CustomerSupport.LIST_PPC_COMMAND_PERMISSION, "listppc", "checkppc"); + _powerPlayRepo = powerPlayRepo; } @@ -114,4 +114,4 @@ public class ListPPCCommand extends CommandBase stack.setItemMeta(meta); return stack; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java index 2c679185f..da1df77b5 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java @@ -3,7 +3,6 @@ package mineplex.staffServer.customerSupport; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -11,7 +10,7 @@ public class checkBonusCommand extends CommandBase { public checkBonusCommand(CustomerSupport plugin) { - super(plugin, Rank.MODERATOR, "checkbonus"); + super(plugin, CustomerSupport.CHECK_BONUS_COMMAND_PERMISSION, "checkbonus"); } @Override diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java index 373a7a998..23c061b15 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java @@ -3,7 +3,6 @@ package mineplex.staffServer.customerSupport; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -11,7 +10,7 @@ public class checkCommand extends CommandBase { public checkCommand(CustomerSupport plugin) { - super(plugin, Rank.MODERATOR, "check", "c"); + super(plugin, CustomerSupport.CHECK_COMMAND_PERMISSION, "check", "c"); } @Override @@ -44,4 +43,4 @@ public class checkCommand extends CommandBase }); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkOwnsPackageCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkOwnsPackageCommand.java index 97cd469e7..200b572e0 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkOwnsPackageCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkOwnsPackageCommand.java @@ -3,7 +3,6 @@ package mineplex.staffServer.customerSupport; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -11,7 +10,7 @@ public class checkOwnsPackageCommand extends CommandBase { public checkOwnsPackageCommand(CustomerSupport plugin) { - super(plugin, Rank.MODERATOR, "checkownspackage"); + super(plugin, CustomerSupport.CHECK_OWNS_PACKAGE_COMMAND_PERMISSION, "checkownspackage"); } @Override @@ -51,4 +50,4 @@ public class checkOwnsPackageCommand extends CommandBase }); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/ChangePasswordCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/ChangePasswordCommand.java deleted file mode 100644 index 055b1ff0f..000000000 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/ChangePasswordCommand.java +++ /dev/null @@ -1,23 +0,0 @@ -package mineplex.staffServer.password; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; - -public class ChangePasswordCommand extends CommandBase -{ - public ChangePasswordCommand(Password plugin) - { - super(plugin, Rank.ADMIN, "changepassword"); - } - - @Override - public void Execute(Player caller, String[] args) - { - if (args != null && args.length == 1) - { - Plugin.changePassword(caller, args[0]); - } - } -} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/CreatePasswordCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/CreatePasswordCommand.java deleted file mode 100644 index 19f3086ad..000000000 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/CreatePasswordCommand.java +++ /dev/null @@ -1,24 +0,0 @@ -package mineplex.staffServer.password; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; - -public class CreatePasswordCommand extends CommandBase -{ - public CreatePasswordCommand(Password plugin) - { - super(plugin, Rank.ADMIN, "createpassword"); - } - - @Override - public void Execute(Player caller, String[] args) - { - if (args != null && args.length == 1) - { - resetCommandCharge(caller); - Plugin.createPassword(caller, args[0]); - } - } -} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/Password.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/Password.java deleted file mode 100644 index e1bfcf6f0..000000000 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/Password.java +++ /dev/null @@ -1,112 +0,0 @@ -package mineplex.staffServer.password; - -import java.util.HashSet; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.F; - -public class Password extends MiniPlugin -{ - private PasswordRepository _repository; - private HashSet _accepted = new HashSet(); - - private String _serverName; - private String _password = null; - - public Password(JavaPlugin plugin, String serverName) - { - super("Password", plugin); - - _serverName = serverName; - - _repository = new PasswordRepository(plugin, serverName); - _password = _repository.retrievePassword(); - } - - @Override - public void addCommands() - { - addCommand(new PasswordCommand(this)); - addCommand(new ChangePasswordCommand(this)); - addCommand(new RemovePasswordCommand(this)); - addCommand(new CreatePasswordCommand(this)); - } - - @EventHandler - public void promptForPassword(final PlayerJoinEvent event) - { - if (_password == null) - return; - - event.getPlayer().sendMessage(F.main(getName(), "Please enter the server password within 10 seconds.")); - - getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() - { - public void run() - { - if (!_accepted.contains(event.getPlayer())) - event.getPlayer().kickPlayer("You don't know the password!"); - } - }, 200L); - } - - public void checkPassword(Player caller, String attempt) - { - if (_password == null) - return; - - if (attempt.equals(_password)) - { - _accepted.add(caller); - caller.sendMessage(F.main(getName(), "That is correct, enjoy your time here...and GET TO WORK ;)")); - } - } - - public void changePassword(Player caller, String password) - { - _password = password; - - runAsync(new Runnable() - { - public void run() - { - _repository.updatePassword(_password); - } - }); - - caller.sendMessage(F.main(getName(), "Password changed to " + _password)); - } - - public void removePassword(Player caller) - { - runAsync(new Runnable() - { - public void run() - { - _password = null; - _repository.removePassword(); - } - }); - caller.sendMessage(F.main(getName(), "Password removed for " + _serverName)); - } - - public void createPassword(Player caller, String password) - { - _password = password; - - runAsync(new Runnable() - { - public void run() - { - _repository.createPassword(_password); - } - }); - - caller.sendMessage(F.main(getName(), "Password created : " + _password)); - } -} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordCommand.java deleted file mode 100644 index f24d88d40..000000000 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordCommand.java +++ /dev/null @@ -1,24 +0,0 @@ -package mineplex.staffServer.password; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; - -public class PasswordCommand extends CommandBase -{ - public PasswordCommand(Password plugin) - { - super(plugin, Rank.MODERATOR, "pass", "password"); - } - - @Override - public void Execute(Player caller, String[] args) - { - if (args != null && args.length == 1) - { - resetCommandCharge(caller); - Plugin.checkPassword(caller, args[0]); - } - } -} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java deleted file mode 100644 index b3d1986f1..000000000 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java +++ /dev/null @@ -1,66 +0,0 @@ -package mineplex.staffServer.password; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import mineplex.core.database.MinecraftRepository; -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.ResultSetCallable; -import mineplex.serverdata.database.column.ColumnVarChar; - -public class PasswordRepository extends RepositoryBase -{ - private static String CREATE_SERVER_PASSWORD_TABLE = "CREATE TABLE IF NOT EXISTS serverPassword (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(100), password VARCHAR(100), PRIMARY KEY (id));"; - private static String RETRIEVE_SERVER_PASSWORD = "SELECT password FROM serverPassword WHERE server = ?;"; - private static String CREATE_SERVER_PASSWORD = "INSERT INTO serverPassword (server, password) VALUES(?, ?);"; - private static String UPDATE_SERVER_PASSWORD = "UPDATE serverPassword SET password = ? WHERE server = ?;"; - private static String REMOVE_SERVER_PASSWORD = "DELETE FROM serverPassword WHERE server = ?;"; - - private String _serverName; - - public PasswordRepository(JavaPlugin plugin, String serverName) - { - super(DBPool.getAccount()); - _serverName = serverName; - } - - public String retrievePassword() - { - final List passwords = new ArrayList(); - - executeQuery(RETRIEVE_SERVER_PASSWORD, new ResultSetCallable() - { - @Override - public void processResultSet(ResultSet resultSet) throws SQLException - { - while (resultSet.next()) - { - passwords.add(resultSet.getString(1)); - } - } - - }, new ColumnVarChar("serverName", 100, _serverName)); - - return passwords.size() > 0 ? passwords.get(0) : null; - } - - public void updatePassword(String password) - { - executeUpdate(UPDATE_SERVER_PASSWORD, new ColumnVarChar("password", 100, password), new ColumnVarChar("serverName", 100, _serverName)); - } - - public void removePassword() - { - executeUpdate(REMOVE_SERVER_PASSWORD, new ColumnVarChar("serverName", 100, _serverName)); - } - - public void createPassword(String password) - { - executeUpdate(CREATE_SERVER_PASSWORD, new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("password", 100, password)); - } -} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/RemovePasswordCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/RemovePasswordCommand.java deleted file mode 100644 index 029489189..000000000 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/RemovePasswordCommand.java +++ /dev/null @@ -1,21 +0,0 @@ -package mineplex.staffServer.password; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; - -public class RemovePasswordCommand extends CommandBase -{ - public RemovePasswordCommand(Password plugin) - { - super(plugin, Rank.ADMIN, "removepassword"); - } - - @Override - public void Execute(Player caller, String[] args) - { - resetCommandCharge(caller); - Plugin.removePassword(caller); - } -} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index 509ea9286..bac2330f6 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -5,6 +5,8 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.NautHashMap; import mineplex.core.donation.DonationManager; @@ -47,6 +49,9 @@ import mineplex.staffServer.salespackage.salespackages.TrickOrTreatChest; public class SalesPackageManager extends MiniPlugin { + public static final String SALES_COMMAND_PERMISSION = "mineplex.customersupport.salescommand"; + public static final String DISPLAY_PACKAGE_COMMAND_PERMISSION = "mineplex.customersupport.displaypackage"; + private CoreClientManager _clientManager; private DonationManager _donationManager; private InventoryManager _inventoryManager; @@ -70,53 +75,63 @@ public class SalesPackageManager extends MiniPlugin //Strutt20 asked me to remove some of the stuff from the menu - AddSalesPackage(new Coins(this, 5000)); - AddSalesPackage(new Coins(this, 25000)); - AddSalesPackage(new Coins(this, 75000)); - //AddSalesPackage(new MonthlyUltra(this)); - //AddSalesPackage(new MonthlyHero(this)); - AddSalesPackage(new DefaultRank(this)); - AddSalesPackage(new LifetimeUltra(this)); - AddSalesPackage(new LifetimeHero(this)); - AddSalesPackage(new LifetimeLegend(this)); - AddSalesPackage(new LifetimeTitan(this)); - AddSalesPackage(new LifetimeEternal(this)); - //AddSalesPackage(new GemHunter(this, 4)); - //AddSalesPackage(new GemHunter(this, 8)); - AddSalesPackage(new ApplyKits(this)); - AddSalesPackage(new OldChest(this)); - AddSalesPackage(new AncientChest(this)); - AddSalesPackage(new MythicalChest(this)); - AddSalesPackage(new IlluminatedChest(this)); - AddSalesPackage(new FreedomChest(this)); - AddSalesPackage(new GingerbreadChest(this)); - //AddSalesPackage(new ValentinesGift(this)); - //AddSalesPackage(new FrostLord(this)); - //AddSalesPackage(new EasterBunny(this)); - AddSalesPackage(new ClanBannerUsage(this)); - AddSalesPackage(new ClanBannerEditor(this)); - AddSalesPackage(new RuneAmplifier(this, 20)); - AddSalesPackage(new RuneAmplifier(this, 60)); - AddSalesPackage(new ClansBox(this, "Dye")); - AddSalesPackage(new ClansBox(this, "Builder")); - AddSalesPackage(new PowerPlayClub(this, false)); - AddSalesPackage(new PowerPlayClub(this, true)); - AddSalesPackage(new OmegaChest(this)); - AddSalesPackage(new HauntedChest(this)); - AddSalesPackage(new MinestrikeChest(this)); - AddSalesPackage(new LoveChest(this)); - AddSalesPackage(new StPatricksChest(this)); - AddSalesPackage(new SpringChest(this)); - AddSalesPackage(new TrickOrTreatChest(this)); - AddSalesPackage(new ThankfulChest(this)); + addSalesPackage(new Coins(this, 5000)); + addSalesPackage(new Coins(this, 25000)); + addSalesPackage(new Coins(this, 75000)); + //addSalesPackage(new MonthlyUltra(this)); + //addSalesPackage(new MonthlyHero(this)); + addSalesPackage(new DefaultRank(this)); + addSalesPackage(new LifetimeUltra(this)); + addSalesPackage(new LifetimeHero(this)); + addSalesPackage(new LifetimeLegend(this)); + addSalesPackage(new LifetimeTitan(this)); + addSalesPackage(new LifetimeEternal(this)); + //addSalesPackage(new GemHunter(this, 4)); + //addSalesPackage(new GemHunter(this, 8)); + addSalesPackage(new ApplyKits(this)); + addSalesPackage(new OldChest(this)); + addSalesPackage(new AncientChest(this)); + addSalesPackage(new MythicalChest(this)); + addSalesPackage(new IlluminatedChest(this)); + addSalesPackage(new FreedomChest(this)); + addSalesPackage(new GingerbreadChest(this)); + //addSalesPackage(new ValentinesGift(this)); + //addSalesPackage(new FrostLord(this)); + //addSalesPackage(new EasterBunny(this)); + addSalesPackage(new ClanBannerUsage(this)); + addSalesPackage(new ClanBannerEditor(this)); + addSalesPackage(new RuneAmplifier(this, 20)); + addSalesPackage(new RuneAmplifier(this, 60)); + addSalesPackage(new ClansBox(this, "Dye")); + addSalesPackage(new ClansBox(this, "Builder")); + addSalesPackage(new PowerPlayClub(this, false)); + addSalesPackage(new PowerPlayClub(this, true)); + addSalesPackage(new OmegaChest(this)); + addSalesPackage(new HauntedChest(this)); + addSalesPackage(new MinestrikeChest(this)); + addSalesPackage(new LoveChest(this)); + addSalesPackage(new StPatricksChest(this)); + addSalesPackage(new SpringChest(this)); + addSalesPackage(new TrickOrTreatChest(this)); + addSalesPackage(new ThankfulChest(this)); for (PetType petType : PetType.values()) { - AddSalesPackage(new Pet(this, petType.getName(), petType)); + addSalesPackage(new Pet(this, petType.getName(), petType)); } + + generatePermissions(); } - private void AddSalesPackage(SalesPackageBase salesPackage) + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("support"), GroupPermission.of(SALES_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("support"), GroupPermission.of(DISPLAY_PACKAGE_COMMAND_PERMISSION), true, true); + } + + private void addSalesPackage(SalesPackageBase salesPackage) { _salesPackages.put(salesPackage.getName(), salesPackage); } @@ -153,10 +168,6 @@ public class SalesPackageManager extends MiniPlugin return _petRepo; } - public void help(Player player) - { - } - public void displayPackage(Player caller, String playerName, String packageName) { _salesPackages.get(packageName).displayToAgent(caller, playerName); @@ -213,4 +224,4 @@ public class SalesPackageManager extends MiniPlugin { return _statsManager; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/CoinCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/CoinCommand.java index 48a56f825..90f84e4c0 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/CoinCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/CoinCommand.java @@ -1,16 +1,10 @@ package mineplex.staffServer.salespackage.command; -import java.util.UUID; - import org.bukkit.entity.Player; -import mineplex.core.account.CoreClient; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; -import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; import mineplex.staffServer.salespackage.SalesPackageManager; @@ -18,7 +12,7 @@ public class CoinCommand extends CommandBase { public CoinCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "coin", "shard", "shards"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "coin", "shard", "shards"); } @Override @@ -50,4 +44,4 @@ public class CoinCommand extends CommandBase caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); }); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/DisplayPackageCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/DisplayPackageCommand.java index 3d1075296..189d98f38 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/DisplayPackageCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/DisplayPackageCommand.java @@ -3,14 +3,13 @@ package mineplex.staffServer.salespackage.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.staffServer.salespackage.SalesPackageManager; public class DisplayPackageCommand extends CommandBase { public DisplayPackageCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "display"); + super(plugin, SalesPackageManager.DISPLAY_PACKAGE_COMMAND_PERMISSION, "display"); } @Override @@ -35,4 +34,4 @@ public class DisplayPackageCommand extends CommandBase else Plugin.displayPackage(caller, playerName, packageName); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java index 877e81be4..fdab3fc26 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java @@ -1,17 +1,17 @@ package mineplex.staffServer.salespackage.command; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.staffServer.salespackage.SalesPackageManager; -import org.bukkit.entity.Player; public class GemHunterCommand extends CommandBase { public GemHunterCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "gemhunter"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "gemhunter"); } @Override @@ -40,7 +40,9 @@ public class GemHunterCommand extends CommandBase caller.sendMessage(F.main(Plugin.getName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!")); } else + { caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); + } }); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/HeroCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/HeroCommand.java index 5d18f1224..8421d3ed8 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/HeroCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/HeroCommand.java @@ -5,14 +5,13 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.staffServer.salespackage.SalesPackageManager; public class HeroCommand extends CommandBase { public HeroCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "hero"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "hero"); } @Override @@ -27,4 +26,4 @@ public class HeroCommand extends CommandBase resetCommandCharge(caller); Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 90")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java index 3c3f64728..603bf39ec 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java @@ -1,7 +1,10 @@ package mineplex.staffServer.salespackage.command; +import java.util.UUID; + +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -9,15 +12,11 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.server.util.TransactionResponse; import mineplex.staffServer.salespackage.SalesPackageManager; -import org.bukkit.entity.Player; - -import java.util.UUID; - public class ItemCommand extends CommandBase { public ItemCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "item"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "item"); } @Override @@ -84,7 +83,9 @@ public class ItemCommand extends CommandBase }); } else + { caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!")); + } }); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/KitsCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/KitsCommand.java index e6f771976..5cbc405ca 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/KitsCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/KitsCommand.java @@ -3,7 +3,6 @@ package mineplex.staffServer.salespackage.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.staffServer.salespackage.SalesPackageManager; @@ -11,7 +10,7 @@ public class KitsCommand extends CommandBase { public KitsCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "kits"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "kits"); } @Override @@ -25,4 +24,4 @@ public class KitsCommand extends CommandBase Plugin.getDonationManager().applyKits(playerName); caller.sendMessage(F.main(Plugin.getName(), "Unlocked kits for " + playerName + "'s account!")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeEternalCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeEternalCommand.java index 9f2437ddc..690b03b34 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeEternalCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeEternalCommand.java @@ -5,14 +5,13 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.staffServer.salespackage.SalesPackageManager; public class LifetimeEternalCommand extends CommandBase { public LifetimeEternalCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "lifetimeeternal"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "lifetimeeternal"); } @Override diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeHeroCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeHeroCommand.java index 2fe666e7a..14385201b 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeHeroCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeHeroCommand.java @@ -5,14 +5,13 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.staffServer.salespackage.SalesPackageManager; public class LifetimeHeroCommand extends CommandBase { public LifetimeHeroCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "lifetimehero"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "lifetimehero"); } @Override @@ -24,4 +23,4 @@ public class LifetimeHeroCommand extends CommandBase resetCommandCharge(caller); Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales item " + args[0] + " 2 Item Mythical Chest")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeLegendCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeLegendCommand.java index 57d766c7b..64ec8d171 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeLegendCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeLegendCommand.java @@ -5,14 +5,13 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.staffServer.salespackage.SalesPackageManager; public class LifetimeLegendCommand extends CommandBase { public LifetimeLegendCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "lifetimelegend"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "lifetimelegend"); } @Override @@ -24,4 +23,4 @@ public class LifetimeLegendCommand extends CommandBase resetCommandCharge(caller); Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales item " + args[0] + " 3 Item Mythical Chest")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeTitanCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeTitanCommand.java index 77650c86e..95b106ec4 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeTitanCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeTitanCommand.java @@ -5,14 +5,13 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.staffServer.salespackage.SalesPackageManager; public class LifetimeTitanCommand extends CommandBase { public LifetimeTitanCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "lifetimetitan"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "lifetimetitan"); } @Override @@ -24,4 +23,4 @@ public class LifetimeTitanCommand extends CommandBase resetCommandCharge(caller); Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales item " + args[0] + " 5 Item Mythical Chest")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeUltraCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeUltraCommand.java index 0022e4ff0..4c3fba148 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeUltraCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeUltraCommand.java @@ -5,14 +5,13 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.staffServer.salespackage.SalesPackageManager; public class LifetimeUltraCommand extends CommandBase { public LifetimeUltraCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "lifetimeultra"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "lifetimeultra"); } @Override @@ -24,4 +23,4 @@ public class LifetimeUltraCommand extends CommandBase resetCommandCharge(caller); Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales item " + args[0] + " 1 Item Mythical Chest")); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java index 4fcca75da..b74aa4952 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java @@ -7,7 +7,6 @@ import org.bukkit.entity.Player; import com.google.gson.Gson; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.pet.PetClient; @@ -20,7 +19,7 @@ public class PetCommand extends CommandBase { public PetCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "pet"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "pet"); } @Override diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PowerPlayCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PowerPlayCommand.java index 6c21148a0..167c1427b 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PowerPlayCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PowerPlayCommand.java @@ -5,7 +5,6 @@ import java.time.LocalDate; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.staffServer.salespackage.SalesPackageManager; @@ -14,7 +13,7 @@ public class PowerPlayCommand extends CommandBase { public PowerPlayCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "powerplay"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "powerplay"); } @Override diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java index d46ae258e..f7f290025 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java @@ -1,43 +1,60 @@ package mineplex.staffServer.salespackage.command; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import java.util.UUID; import org.bukkit.entity.Player; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; -import mineplex.core.common.util.UUIDFetcher; +import mineplex.core.common.util.UtilPlayer; import mineplex.staffServer.salespackage.SalesPackageManager; public class RankCommand extends CommandBase { + private static final List ACCEPTED_RANKS = Collections.unmodifiableList(Arrays.asList("player", "ultra", "hero", "legend", "titan", "eternal")); + public RankCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "rank"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "rank"); } @Override public void Execute(Player caller, String[] args) { - if (args == null || args.length != 3) + if (args == null || args.length != 2) + { return; + } String playerName = args[0]; String rank = args[1]; - boolean perm = Boolean.parseBoolean(args[2]); - UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName); - - if (uuid == null) - uuid = UUIDFetcher.getUUIDOf(playerName); - - final Rank rankEnum = Rank.valueOf(rank); - - if (rankEnum == Rank.HERO || rankEnum == Rank.ULTRA || rankEnum == Rank.LEGEND || rankEnum == Rank.TITAN || rankEnum == Rank.ETERNAL || rankEnum == Rank.ALL) + if (ACCEPTED_RANKS.contains(rank)) { - Plugin.getClientManager().SaveRank(playerName, uuid, mineplex.core.common.Rank.valueOf(rank), perm); - caller.sendMessage(F.main(Plugin.getName(), playerName + "'s rank has been updated to " + rank + "!")); + PermissionGroup group = Plugin.getClientManager().getPermissionManager().getGroup(rank); + Plugin.runAsync(() -> + { + UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName); + + Plugin.getClientManager().loadAccountIdFromUUID(uuid, id -> + { + Plugin.runSync(() -> + { + if (id.intValue() == -1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not find " + F.elem(playerName) + "!")); + } + else + { + Plugin.getClientManager().setPrimaryGroup(id.intValue(), group, () -> UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(playerName) + "'s rank has been updated to " + rank + "!"))); + } + }); + }); + }); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java index 565f61ced..c44a8a435 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java @@ -3,14 +3,13 @@ package mineplex.staffServer.salespackage.command; import org.bukkit.entity.Player; import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; import mineplex.staffServer.salespackage.SalesPackageManager; public class Sales extends MultiCommandBase { public Sales(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "sales"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "sales"); AddCommand(new RankCommand(plugin)); AddCommand(new CoinCommand(plugin)); @@ -29,8 +28,5 @@ public class Sales extends MultiCommandBase } @Override - protected void Help(Player caller, String[] args) - { - Plugin.help(caller); - } -} + protected void Help(Player caller, String[] args) {} +} \ No newline at end of file diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/UltraCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/UltraCommand.java index 996bec1b4..4c3b98e48 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/UltraCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/UltraCommand.java @@ -5,14 +5,13 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.staffServer.salespackage.SalesPackageManager; public class UltraCommand extends CommandBase { public UltraCommand(SalesPackageManager plugin) { - super(plugin, Rank.MODERATOR, "ultra"); + super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "ultra"); } @Override @@ -27,4 +26,4 @@ public class UltraCommand extends CommandBase resetCommandCharge(caller); Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 30")); } -} +} \ No newline at end of file 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 2bfab0d6b..b9be3c919 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -1,16 +1,51 @@ package nautilus.game.arcade; +import java.io.File; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.scoreboard.Team; +import org.bukkit.util.Vector; + import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.bonuses.BonusManager; 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.timing.TimingManager; import mineplex.core.common.util.C; @@ -93,14 +128,11 @@ import mineplex.serverdata.Region; import nautilus.game.arcade.addons.SoupAddon; import nautilus.game.arcade.booster.GameBoosterManager; import nautilus.game.arcade.command.CancelNextGameCommand; -import nautilus.game.arcade.command.GameCmdModeCommand; import nautilus.game.arcade.command.GameCommand; import nautilus.game.arcade.command.GoToNextGameCommand; import nautilus.game.arcade.command.KitUnlockCommand; import nautilus.game.arcade.command.OpenGameMechPrefsCommand; -import nautilus.game.arcade.command.RequiredRankCommand; import nautilus.game.arcade.command.TauntCommand; -import nautilus.game.arcade.command.WriteCommand; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; @@ -119,7 +151,6 @@ 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.HolidayManager; @@ -135,40 +166,26 @@ import nautilus.game.arcade.managers.lobby.legacy.LegacyGameLobbyManager; import nautilus.game.arcade.player.ArcadePlayer; import nautilus.game.arcade.shop.ArcadeShop; import net.minecraft.server.v1_8_R3.EntityLiving; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockSpreadEvent; -import org.bukkit.event.block.LeavesDecayEvent; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.server.ServerListPingEvent; -import org.bukkit.potion.PotionEffect; -import org.bukkit.scoreboard.Team; -import org.bukkit.util.Vector; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashSet; public class ArcadeManager extends MiniPlugin implements IRelation { + public static final String USE_MENU_DURING_GAME_PERMISSION = "mineplex.arcade.menu.duringgame"; + public static final String NEXT_BEST_GAME_PERMISSION = "mineplex.arcade.nextbestgame"; + public static final String KIT_UNLOCK_COMMAND_PERMISSION = "mineplex.arcade.kitunlockcommand"; + public static final String TAUNT_COMMAND_PERMISSION = "mineplex.arcade.taunt"; + public static final String GAME_COMMAND_PERMISSION = "mineplex.arcade.gamecommand"; + public static final String SET_GAME_COMMAND_PERMISSION = "mineplex.arcade.gamecommand.set"; + public static final String START_GAME_COMMAND_PERMISSION = "mineplex.arcade.gamecommand.start"; + public static final String STOP_GAME_COMMAND_PERMISSION = "mineplex.arcade.gamecommand.stop"; + public static final String AUTO_OP_PERMISSION = "mineplex.arcade.autoop"; + public static final String KIT_ACCESS_PERMISSION = "mineplex.arcade.kitaccess"; + public static final String FEATURED_SERVER_PERMISSION = "mineplex.arcade.featuredserver"; + public static final String INFORM_RANKED_MODERATION_POTENTIAL_PERMISSION = "mineplex.arcade.ranked.informmoderation"; + public static final String JOIN_FULL_PERMISSION = "mineplex.arcade.joinfull"; + public static final String JOIN_FULL_STAFF_PERMISSION = "mineplex.arcade.joinfull.staff"; + public static final String BYPASS_WHITELIST_PERMISSION = "mineplex.arcade.bypasswhitelist"; + public static final String BYPASS_MPS_WHITELIST_PERMISSION = "mineplex.arcade.bypasswhitelist.mps"; + // Modules private BlockRestore _blockRestore; private Blood _blood; @@ -238,8 +255,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation private PacketHandler _packetHandler; // Observers - private HashSet _specList = new HashSet(); - private HashSet _fakeObserve = new HashSet(); + private Set _specList = new HashSet<>(); // Server Games private GameServerConfig _serverConfig; @@ -251,11 +267,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation private HashSet _youtube = new HashSet(); //Server Property - private Rank _requiredRank; - - //Game commands - public static final String GAME_CMD_MODE_FILE = "GAME_CMD_MODE.dat"; - private Rank _gameCommandRank; public final boolean IsHolidayEnabled; @@ -354,7 +365,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation new HolidayManager(this, titanGiveaway, eternalGiveawayManager); new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _cosmeticManager.getGadgetManager(), statsManager); - new GameTestingManager(this); require(PlayerDisguiseManager.class); new GameBoosterManager(plugin, boosterManager, hologramManager, npcManager, serverConfig.BoosterGroup); @@ -392,10 +402,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation Bukkit.getScheduler().runTaskLater(plugin, () -> Portal.transferPlayer(GetHost(), _serverStatusManager.getCurrentServerName()), 80L); } - loadRequiredRank(); - - _gameCommandRank = checkGameCommandMode() ? Rank.ALL : Rank.JNR_DEV; - Region region = new File("eu.dat").exists() ? Region.EU : Region.US; _nextBestGameManager = new NextBestGameManager(serverConfig.ServerGroup, region, _partyManager); @@ -422,7 +428,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation for (MineplexScoreboard scoreboard : getScoreboards().values()) { - scoreboard.getHandle().getTeam(client.getRealOrDisguisedRank().ScoreboardTag).addEntry(playerName); + scoreboard.getHandle().getTeam(client.getRealOrDisguisedPrimaryGroup().getIdentifier()).addEntry(playerName); } Player player = Bukkit.getPlayerExact(playerName); @@ -433,7 +439,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation { client = GetClients().Get(player1); - get(player).getHandle().getTeam(client.getRealOrDisguisedRank().ScoreboardTag).addEntry(player1.getName()); + get(player).getHandle().getTeam(client.getRealOrDisguisedPrimaryGroup().getIdentifier()).addEntry(player1.getName()); } } @@ -441,7 +447,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation { GameTeam gameTeam = null; if (GetGame() != null && GetGame().GetTeam(onlinePlayer) != null) + { gameTeam = GetGame().GetTeam(onlinePlayer); + } _gameLobbyManager.AddPlayerToScoreboards(onlinePlayer, gameTeam); } @@ -466,19 +474,23 @@ public class ArcadeManager extends MiniPlugin implements IRelation for (MineplexScoreboard scoreboard : getScoreboards().values()) { - scoreboard.getHandle().getTeam(client.getRealOrDisguisedRank().ScoreboardTag).removeEntry(playerName); + scoreboard.getHandle().getTeam(client.getRealOrDisguisedPrimaryGroup().getIdentifier()).removeEntry(playerName); } } @Override public void setup(MineplexScoreboard scoreboard) { - for (Rank rank : Rank.values()) + for (PermissionGroup group : _clientManager.getPermissionManager().getGroups()) { - if (rank == Rank.ALL) - scoreboard.getHandle().registerNewTeam(rank.ScoreboardTag).setPrefix(""); + if (!group.getDisplay(false, false, false, false).isEmpty()) + { + scoreboard.getHandle().registerNewTeam(group.getIdentifier()).setPrefix(group.getDisplay(true, true, true, false) + ChatColor.RESET + " "); + } else - scoreboard.getHandle().registerNewTeam(rank.ScoreboardTag).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " "); + { + scoreboard.getHandle().registerNewTeam(group.getIdentifier()).setPrefix(""); + } } scoreboard.register(ArcadeScoreboardLine.PLAYERS_SPACER) @@ -590,16 +602,47 @@ public class ArcadeManager extends MiniPlugin implements IRelation Titles.BOOK_SLOT = 4; _sheetsManager = require(GoogleSheetsManager.class); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _clientManager.getPermissionManager(); + + pm.setPermission(pm.getGroup("content"), GroupPermission.of(USE_MENU_DURING_GAME_PERMISSION), true, true); + pm.setPermission(pm.getGroup("builder"), GroupPermission.of(USE_MENU_DURING_GAME_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(NEXT_BEST_GAME_PERMISSION), true, true); + pm.setPermission(pm.getGroup("content"), GroupPermission.of(KIT_UNLOCK_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("player"), GroupPermission.of(TAUNT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GAME_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SET_GAME_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(START_GAME_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(STOP_GAME_COMMAND_PERMISSION), true, true); + if (UtilServer.isTestServer() || UtilServer.isDevServer()) + { + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(AUTO_OP_PERMISSION), true, true); + } + else + { + pm.setPermission(pm.getGroup("lt"), GroupPermission.of(AUTO_OP_PERMISSION), true, true); + } + pm.setPermission(pm.getGroup("builder"), GroupPermission.of(KIT_ACCESS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("builder"), GroupPermission.of(FEATURED_SERVER_PERMISSION), true, true); + pm.setPermission(pm.getGroup("content"), GroupPermission.of(FEATURED_SERVER_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(INFORM_RANKED_MODERATION_POTENTIAL_PERMISSION), true, true); + pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(JOIN_FULL_STAFF_PERMISSION), true, true); + pm.setPermission(pm.getGroup("builder"), GroupPermission.of(BYPASS_WHITELIST_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BYPASS_WHITELIST_PERMISSION), false, false); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(BYPASS_MPS_WHITELIST_PERMISSION), true, true); } @Override public void addCommands() { addCommand(new GameCommand(this)); - addCommand(new WriteCommand(this)); addCommand(new KitUnlockCommand(this)); - addCommand(new RequiredRankCommand(this)); - addCommand(new GameCmdModeCommand(this)); } public GameChatManager getGameChatManager() @@ -939,9 +982,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation String extrainformation = "|" + _serverConfig.ServerType + "|" + (_game == null ? "Unknown" : _game.GetName()) + "|" + ((_game == null || _game.WorldData == null) ? "Unknown" : _game.WorldData.MapName); - if (_gameHostManager.isPrivateServer() && _gameHostManager.hasRank(Rank.TWITCH)) + if (_gameHostManager.isPrivateServer() && _gameHostManager.hasPermission(GroupPermission.of(FEATURED_SERVER_PERMISSION))) { - extrainformation += "|HostRank." + _gameHostManager.getHostRank().toString(); + extrainformation += "|HostRank." + _gameHostManager.getHostRank().getIdentifier(); } //Always Joinable /*if (_game != null && _game.JoinInProgress) @@ -1073,37 +1116,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation { if (Bukkit.getServer().hasWhitelist()) { - if (_requiredRank != null) - { - if (_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), _requiredRank, false)) - { - event.allow(); - event.setResult(PlayerLoginEvent.Result.ALLOWED); - - if (_serverConfig.Tournament && _clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.MODERATOR, false)) - { - event.getPlayer().setOp(true); - } - } - else - { - for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) - { - if (player.getName().equalsIgnoreCase(event.getPlayer().getName())) - { - event.allow(); - event.setResult(PlayerLoginEvent.Result.ALLOWED); - return; - } - } - - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Required Rank for this server: " + _requiredRank.getColor() + _requiredRank.Name); - return; - } - } - if (_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.MODERATOR, false) || - _clientManager.Get(event.getPlayer().getUniqueId()).GetRank() == Rank.MAPDEV || - _clientManager.Get(event.getPlayer().getUniqueId()).GetRank() == Rank.MAPLEAD) + if (_clientManager.getPermissionManager().hasPermission(_clientManager.Get(event.getPlayer().getUniqueId()), GroupPermission.of(BYPASS_WHITELIST_PERMISSION))) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); @@ -1134,13 +1147,13 @@ public class ArcadeManager extends MiniPlugin implements IRelation // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers()) { - if (_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) + if (_clientManager.getPermissionManager().hasPermission(_clientManager.Get(event.getPlayer().getUniqueId()), GroupPermission.of(JOIN_FULL_STAFF_PERMISSION))) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); return; } - else if (_clientManager.Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.ULTRA, false) + else if (_clientManager.getPermissionManager().hasPermission(_clientManager.Get(event.getPlayer().getUniqueId()), GroupPermission.of(JOIN_FULL_PERMISSION)) || _donationManager.Get(event.getPlayer().getUniqueId()).ownsUnknownSalesPackage(_serverConfig.ServerType + " ULTRA")) { @@ -1173,17 +1186,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation @EventHandler(priority = EventPriority.LOW) public void AdminOP(PlayerJoinEvent event) { - // Give developers operator on their servers - Rank minimum = Rank.OWNER; - if (UtilServer.isTestServer() || UtilServer.isDevServer()) + if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(AUTO_OP_PERMISSION))) { - minimum = Rank.JNR_DEV; - } - - if (_clientManager.Get(event.getPlayer()).GetRank().has(minimum)) event.getPlayer().setOp(true); + } else + { event.getPlayer().setOp(false); + } } public boolean IsAlive(Player player) @@ -1445,17 +1455,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation _specList.remove(event.getPlayer()); } - public void toggleFakeObserver(Player player) - { - if (!_fakeObserve.remove(player)) - _fakeObserve.add(player); - } - public boolean IsObserver(Player player) { - if (_fakeObserve.contains(player)) - return true; - if (_incognitoManager.Get(player).Status) { _specList.add(player); @@ -1816,40 +1817,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation return false; } - public void loadRequiredRank() - { - _requiredRank = null; - - for (File file : new File(".").listFiles()) - { - if (!file.getName().startsWith("RequiredRank")) - continue; - - try - { - _requiredRank = Rank.valueOf(file.getName().split("=")[1]); - System.out.println("set required rank to " + _requiredRank.Name); - } - catch (IllegalArgumentException e) - { - System.out.println("==============================="); - System.out.println("Wrong required rank definition."); - System.out.println("[" + file.getName().split("=")[1] + "] Does not exist!"); - System.out.println("==============================="); - } - } - } - - public Rank getRequiredRank() - { - return _requiredRank; - } - - public void setRequiredRank(Rank rank) - { - _requiredRank = rank; - } - @EventHandler(priority = EventPriority.LOWEST) public void explosionCancel(EntityExplodeEvent event) { @@ -1894,61 +1861,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation return new ArcadePlayer(player, getCustomDataManager(), this); } - /** - * Returns whether this server has a file, stating that it allows game commands. - * - * @return Whether this server is in game command mode. - */ - private boolean checkGameCommandMode() - { - return new File(GAME_CMD_MODE_FILE).exists(); - } - - /** - * Returns the minimum rank requirement to use game commands. - * - * @return The minimum rank requirement. - */ - public Rank getGameCommandRank() - { - return _gameCommandRank; - } - - /** - * Sets this server's minimum rank requirement to use game commands. - * - * @param rank The minimum rank requirement. - */ - public void setGameCommandMode(Rank rank) - { - _gameCommandRank = rank; - } - - /** - * Finds whether or not a player can use a game command or not. - *

- * Sends a denial alert if they can't. - * - * @param player The player attempting to use the command. - * @return Whether or not the player can successfully use the command. - */ - public boolean canPlayerUseGameCmd(Player player) - { - if (_gameCommandRank == null) - { - player.sendMessage(F.main("Game", "Game commands are currently disabled")); - return false; - } - // Check whether they are of high enough rank status. - if (!GetClients().hasRank(player, _gameCommandRank) && !(_gameHostManager.isEventServer() && _gameHostManager.isAdmin(player, false))) - { - player.sendMessage(F.main("Game", "You are not allowed to use game commands.")); - return false; - } - - return true; - } - @EventHandler public void clearDisguises(GameStateChangeEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastData.java deleted file mode 100644 index fe4b389da..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastData.java +++ /dev/null @@ -1,97 +0,0 @@ -package nautilus.game.arcade.broadcast; - -import java.util.ArrayList; -import java.util.List; - -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.recharge.Recharge; -import net.minecraft.server.v1_8_R3.PacketPlayOutCamera; - -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; - -public class BroadcastData -{ - private Player _player; - private BroadcastManager _plugin; - - private boolean _rotate; - - private List _gamePlayers; - private List _recentlyViewed; - private Player _currentlyViewing; - - public BroadcastData(Player player, BroadcastManager plugin) - { - _player = player; - _plugin = plugin; - - _recentlyViewed = new ArrayList(); - - setRotating(false); - } - - private void setRotating(boolean rotate) - { - _rotate = rotate; - UtilPlayer.message(_player, F.main(_plugin.getName(), "Player Rotation: " + rotate)); - } - - public boolean isRotating() - { - return _rotate; - } - - public Player currentView() - { - return _currentlyViewing; - } - - public Player nextPlayer() - { - if (_gamePlayers.size() == _recentlyViewed.size()) - _recentlyViewed.clear(); - - for (Player player : _gamePlayers) - { - if (!player.isOnline() || !player.isValid() || player.isDead()) - continue; - - if (!_recentlyViewed.contains(player)) - return player; - } - - return null; - } - - public void toggleRotating(List gamePlayers) - { - if (!isRotating()) - { - if (gamePlayers == null) - return; - - if (gamePlayers.size() == 0) - return; - - _gamePlayers = gamePlayers; - } - if (isRotating()) - { - PacketPlayOutCamera restore = new PacketPlayOutCamera((net.minecraft.server.v1_8_R3.Entity)_player); - ((CraftPlayer)_player).getHandle().playerConnection.sendPacket(restore); - } - setRotating(!isRotating()); - } - - public void goToNext(Player player) - { - Recharge.Instance.useForce(_player, "Broadcaster Rotation", UtilTime.convert(10, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false); - _currentlyViewing = player; - PacketPlayOutCamera view = new PacketPlayOutCamera((net.minecraft.server.v1_8_R3.Entity)player); - ((CraftPlayer)_player).getHandle().playerConnection.sendPacket(view); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastManager.java deleted file mode 100644 index d3693e598..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastManager.java +++ /dev/null @@ -1,120 +0,0 @@ -package nautilus.game.arcade.broadcast; - -import java.util.concurrent.ConcurrentHashMap; - -import mineplex.core.MiniPlugin; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.Game.GameState; - -import org.bukkit.GameMode; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; - -public class BroadcastManager extends MiniPlugin -{ - ArcadeManager ArcadeManager; - private ConcurrentHashMap _broadcasters; - - public BroadcastManager(JavaPlugin plugin, ArcadeManager manager) - { - super("Broadcasting Manager", plugin); - ArcadeManager = manager; - _broadcasters = new ConcurrentHashMap(); - } - - public boolean isBroadcaster(Player player) - { - return _broadcasters.containsKey(player); - } - - public void addBroadcaster(Player player) - { - _broadcasters.put(player, new BroadcastData(player, this)); - if (ArcadeManager.GetGame() != null) - { - ArcadeManager.GetGame().RemoveTeamPreference(player); - ArcadeManager.GetGame().GetPlayerKits().remove(player); - ArcadeManager.GetGame().GetPlayerGems().remove(player); - try - { - ArcadeManager.GetGame().GetTeam(player).RemovePlayer(player); - } - catch (Exception e) {} - ArcadeManager.Clear(player); - ArcadeManager.toggleFakeObserver(player); - } - player.getInventory().clear(); - player.setGameMode(GameMode.SPECTATOR); - } - - public void removeBroadcaster(Player player) - { - _broadcasters.remove(player); - ArcadeManager.toggleFakeObserver(player); - if (ArcadeManager.GetGame().InProgress()) - ArcadeManager.addSpectator(player, true); - player.setGameMode(GameMode.SURVIVAL); - } - - @EventHandler - public void handleBroadcasting(GameStateChangeEvent event) - { - if (event.GetState() == GameState.Dead) - { - for (BroadcastData data : _broadcasters.values()) - { - if (data.isRotating()) - data.toggleRotating(null); - } - _broadcasters.clear(); - } - } - - @EventHandler - public void handleRotation(UpdateEvent event) - { - if (event.getType() == UpdateType.FASTEST) - { - Game game = ArcadeManager.GetGame(); - if (game == null) - return; - if (!game.InProgress()) - return; - - for (Player player : _broadcasters.keySet()) - { - if (!Recharge.Instance.usable(player, "Broadcaster Rotation", false)) - continue; - } - } - } - - @EventHandler - public void handleRotation(PlayerQuitEvent event) - { - Game game = ArcadeManager.GetGame(); - if (game == null) - return; - if (!game.InProgress()) - return; - - if (_broadcasters.containsKey(event.getPlayer())) - _broadcasters.remove(event.getPlayer()); - - for (BroadcastData data : _broadcasters.values()) - { - if (data.currentView() == null) - continue; - - if (data.currentView() == event.getPlayer()); - data.goToNext(data.nextPlayer()); - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/BroadcastCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/BroadcastCommand.java deleted file mode 100644 index 49d4858d2..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/BroadcastCommand.java +++ /dev/null @@ -1,33 +0,0 @@ -package nautilus.game.arcade.broadcast.command; - -import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import nautilus.game.arcade.broadcast.BroadcastManager; -import nautilus.game.arcade.broadcast.command.manage.AddCommand; -import nautilus.game.arcade.broadcast.command.manage.RemoveCommand; - -import org.bukkit.entity.Player; - -public class BroadcastCommand extends MultiCommandBase -{ - public BroadcastCommand(BroadcastManager plugin) - { - super(plugin, Rank.ADMIN, new Rank[] {Rank.TWITCH, Rank.YOUTUBE, Rank.YOUTUBE_SMALL, Rank.JNR_DEV}, "broadcaster"); - AddCommand(new AddCommand(plugin)); - AddCommand(new RemoveCommand(plugin)); - AddCommand(new RotateCommand(plugin)); - } - - @Override - protected void Help(Player caller, String[] args) - { - UtilPlayer.message(caller, F.main(Plugin.getName(), "Commands List:")); - UtilPlayer.message(caller, F.help("/broadcaster add ", "Puts a player in Broadcast mode for this game", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/broadcaster remove ", "Takes a player out of Broadcast mode", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/broadcaster rotate", "Toggles rotating view between game players", Rank.TWITCH)); - UtilPlayer.message(caller, F.main("Tip", "Rotation is great for a background to commentary!")); - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/RotateCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/RotateCommand.java deleted file mode 100644 index b455ce4af..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/RotateCommand.java +++ /dev/null @@ -1,21 +0,0 @@ -package nautilus.game.arcade.broadcast.command; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import nautilus.game.arcade.broadcast.BroadcastManager; - -public class RotateCommand extends CommandBase -{ - public RotateCommand(BroadcastManager plugin) { - super(plugin, Rank.TWITCH, "rotate"); - } - - @Override - public void Execute(Player caller, String[] args) - { - - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/AddCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/AddCommand.java deleted file mode 100644 index ee67c8609..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/AddCommand.java +++ /dev/null @@ -1,22 +0,0 @@ -package nautilus.game.arcade.broadcast.command.manage; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import nautilus.game.arcade.broadcast.BroadcastManager; - -public class AddCommand extends CommandBase -{ - public AddCommand(BroadcastManager plugin) - { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "add"); - } - - @Override - public void Execute(Player caller, String[] args) - { - - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/RemoveCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/RemoveCommand.java deleted file mode 100644 index 021202498..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/RemoveCommand.java +++ /dev/null @@ -1,22 +0,0 @@ -package nautilus.game.arcade.broadcast.command.manage; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import nautilus.game.arcade.broadcast.BroadcastManager; - -public class RemoveCommand extends CommandBase -{ - public RemoveCommand(BroadcastManager plugin) - { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "remove"); - } - - @Override - public void Execute(Player caller, String[] args) - { - - } - -} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/CancelNextGameCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/CancelNextGameCommand.java index ea04eefa4..c08d4e4e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/CancelNextGameCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/CancelNextGameCommand.java @@ -1,19 +1,18 @@ package nautilus.game.arcade.command; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import nautilus.game.arcade.ArcadeManager; import org.bukkit.entity.Player; +import mineplex.core.command.CommandBase; +import nautilus.game.arcade.ArcadeManager; + /** * */ public class CancelNextGameCommand extends CommandBase { - public CancelNextGameCommand(ArcadeManager plugin) { - super(plugin, Rank.ALL, "cancelsendingtonextbestgame"); + super(plugin, ArcadeManager.NEXT_BEST_GAME_PERMISSION, "cancelsendingtonextbestgame"); } @Override @@ -21,4 +20,4 @@ public class CancelNextGameCommand extends CommandBase { Plugin.getNextBestGameManager().cancel(caller, Plugin.getPartyManager().getPartyByPlayer(caller)); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCmdModeCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCmdModeCommand.java deleted file mode 100644 index fa0cd3003..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCmdModeCommand.java +++ /dev/null @@ -1,74 +0,0 @@ -package nautilus.game.arcade.command; - -import java.io.File; -import java.io.IOException; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; - -import io.netty.util.internal.chmv8.ForkJoinPool.ManagedBlocker; -import nautilus.game.arcade.ArcadeManager; - -/** - * A command to toggle this server's game command mode state. - */ -public class GameCmdModeCommand extends CommandBase -{ - public GameCmdModeCommand(ArcadeManager plugin) - { - super(plugin, Rank.JNR_DEV, "gamecmdrank"); - } - - @Override - public void Execute(Player caller, String[] args) - { - if (args.length < 1) - { - caller.sendMessage(F.main("Game", "/gamecmdrank ")); - return; - } - - File file = new File(ArcadeManager.GAME_CMD_MODE_FILE); - Rank rank = Plugin.getGameCommandRank(); - Rank newRank = null; - - try - { - newRank = Rank.valueOf(args[0]); - } - catch (IllegalArgumentException e) - { - caller.sendMessage(F.main("Game", C.cRedB + "Invalid rank!")); - return; - } - - if (newRank == Rank.ALL) - { - if (!file.exists()) - { - try - { - file.createNewFile(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - } - else - { - if (file.exists()) - { - file.delete(); - } - } - - Plugin.setGameCommandMode(newRank); - caller.sendMessage(F.main("Game", "Players now need at least rank " + newRank.getTag(true, true) + C.cGray + " to use game commands.")); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java index 9ddf2cfc9..0d1256f2e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java @@ -1,22 +1,22 @@ package nautilus.game.arcade.command; -import org.bukkit.entity.Player; - -import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; - -import nautilus.game.arcade.ArcadeManager; import static nautilus.game.arcade.command.SetCommand.MAP_PREFIX; import static nautilus.game.arcade.command.SetCommand.MODE_PREFIX; import static nautilus.game.arcade.command.SetCommand.SOURCE_PREFIX; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import mineplex.core.command.MultiCommandBase; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.ArcadeManager; + public class GameCommand extends MultiCommandBase { public GameCommand(ArcadeManager plugin) { - super(plugin, Rank.ALL, "game"); + super(plugin, ArcadeManager.GAME_COMMAND_PERMISSION, "game"); AddCommand(new StartCommand(Plugin)); AddCommand(new StopCommand(Plugin)); @@ -26,12 +26,9 @@ public class GameCommand extends MultiCommandBase @Override protected void Help(Player caller, String[] args) { - if (Plugin.canPlayerUseGameCmd(caller)) - { - UtilPlayer.message(caller, F.main("Game", "Available Commands")); - UtilPlayer.message(caller, F.help("/game start", "Start the current game", Plugin.getGameCommandRank())); - UtilPlayer.message(caller, F.help("/game stop", "Stop the current game", Plugin.getGameCommandRank())); - caller.sendMessage(F.help(String.format("/game set [%s(gamemode)] [%s(mapsource)] [%s(mapname)]", MODE_PREFIX, SOURCE_PREFIX, MAP_PREFIX), "Set the current game or next game", Plugin.getGameCommandRank())); - } + UtilPlayer.message(caller, F.main("Game", "Available Commands")); + UtilPlayer.message(caller, F.help("/game start", "Start the current game", ChatColor.DARK_RED)); + UtilPlayer.message(caller, F.help("/game stop", "Stop the current game", ChatColor.DARK_RED)); + caller.sendMessage(F.help(String.format("/game set [%s(gamemode)] [%s(mapsource)] [%s(mapname)]", MODE_PREFIX, SOURCE_PREFIX, MAP_PREFIX), "Set the current game or next game", ChatColor.DARK_RED)); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GoToNextGameCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GoToNextGameCommand.java index d92c4cee8..894c0a605 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GoToNextGameCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GoToNextGameCommand.java @@ -1,19 +1,18 @@ package nautilus.game.arcade.command; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import nautilus.game.arcade.ArcadeManager; import org.bukkit.entity.Player; +import mineplex.core.command.CommandBase; +import nautilus.game.arcade.ArcadeManager; + /** * */ public class GoToNextGameCommand extends CommandBase { - public GoToNextGameCommand(ArcadeManager plugin) { - super(plugin, Rank.ALL, "gotonextbestgame"); + super(plugin, ArcadeManager.NEXT_BEST_GAME_PERMISSION, "gotonextbestgame"); } @Override @@ -21,4 +20,4 @@ public class GoToNextGameCommand extends CommandBase { Plugin.getNextBestGameManager().onCommand(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java index 443ae6bb9..21d8846bf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java @@ -2,15 +2,14 @@ package nautilus.game.arcade.command; import org.bukkit.entity.Player; -import nautilus.game.arcade.ArcadeManager; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; +import nautilus.game.arcade.ArcadeManager; public class KitUnlockCommand extends CommandBase { public KitUnlockCommand(ArcadeManager plugin) { - super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE, Rank.YOUTUBE_SMALL, Rank.TWITCH, Rank.JNR_DEV}, new String[] {"youtube", "twitch", "kits"}); + super(plugin, ArcadeManager.KIT_UNLOCK_COMMAND_PERMISSION, new String[] {"youtube", "twitch", "kits"}); } @Override @@ -18,4 +17,4 @@ public class KitUnlockCommand extends CommandBase { Plugin.toggleUnlockKits(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/OpenGameMechPrefsCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/OpenGameMechPrefsCommand.java index 83dfd80c9..093cba16e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/OpenGameMechPrefsCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/OpenGameMechPrefsCommand.java @@ -1,21 +1,20 @@ package nautilus.game.arcade.command; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.preferences.PreferenceCategory; import mineplex.core.preferences.ui.menus.PreferenceMenu; import nautilus.game.arcade.ArcadeManager; -import org.bukkit.entity.Player; /** * */ public class OpenGameMechPrefsCommand extends CommandBase { - public OpenGameMechPrefsCommand(ArcadeManager plugin) { - super(plugin, Rank.ALL, "opengamemechanicpreferences"); + super(plugin, ArcadeManager.NEXT_BEST_GAME_PERMISSION, "opengamemechanicpreferences"); } @Override @@ -23,4 +22,4 @@ public class OpenGameMechPrefsCommand extends CommandBase { new PreferenceMenu(PreferenceCategory.GAME_PLAY, Plugin.getPreferences()).open(caller); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/RequiredRankCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/RequiredRankCommand.java deleted file mode 100644 index 410a5454d..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/RequiredRankCommand.java +++ /dev/null @@ -1,54 +0,0 @@ -package nautilus.game.arcade.command; - -import org.bukkit.entity.Player; - -import nautilus.game.arcade.ArcadeManager; -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; - -public class RequiredRankCommand extends CommandBase -{ - - private ArcadeManager _manager; - - public RequiredRankCommand(ArcadeManager plugin) - { - super(plugin, Rank.DEVELOPER, new Rank[]{Rank.JNR_DEV}, "Requiredrank"); - _manager = plugin; - } - - @Override - public void Execute(Player caller, String[] args) - { - if(!UtilServer.isTestServer()) - { - UtilPlayer.message(caller, F.main("Command", "This is not a test server..")); - return; - } - if(args.length == 0) - { - UtilPlayer.message(caller, F.main("Command", "Invalid rank input.")); - return; - } - if(args[0].equalsIgnoreCase("Reset")) - { - _manager.setRequiredRank(null); - UtilPlayer.message(caller, F.main("Command", "You reset the required rank to null.")); - return; - } - try - { - Rank rank = Rank.valueOf(args[0]); - _manager.setRequiredRank(rank); - UtilPlayer.message(caller, F.main("Command", "You set the required rank to: " + rank.getColor() + rank.Name)); - } - catch (IllegalArgumentException e) - { - UtilPlayer.message(caller, F.main("Command", "Invalid rank input.")); - } - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java index 0365b2441..3b8d8d446 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java @@ -6,14 +6,13 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; +import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; - import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameMode; import nautilus.game.arcade.GameType; @@ -27,7 +26,7 @@ public class SetCommand extends CommandBase public SetCommand(ArcadeManager plugin) { - super(plugin, Rank.ALL, "set"); + super(plugin, ArcadeManager.SET_GAME_COMMAND_PERMISSION, "set"); } @Override @@ -36,14 +35,9 @@ public class SetCommand extends CommandBase if (Plugin.GetGame() == null) return; - if (!Plugin.canPlayerUseGameCmd(caller)) - { - return; - } - if (args.length == 0) { - caller.sendMessage(F.help(String.format("/game set [%s(gamemode)] [%s(mapsource)] [%s(mapname)]", MODE_PREFIX, SOURCE_PREFIX, MAP_PREFIX), "Set the current game or next game", Plugin.getGameCommandRank())); + caller.sendMessage(F.help(String.format("/game set [%s(gamemode)] [%s(mapsource)] [%s(mapname)]", MODE_PREFIX, SOURCE_PREFIX, MAP_PREFIX), "Set the current game or next game", ChatColor.DARK_RED)); return; } @@ -346,7 +340,7 @@ public class SetCommand extends CommandBase @Override public List onTabComplete(CommandSender sender, String commandLabel, String[] args) { - if (!(sender instanceof Player) || !Plugin.canPlayerUseGameCmd((Player) sender)) + if (!(sender instanceof Player) && !_commandCenter.GetClientManager().getPermissionManager().hasPermission((Player)sender, getPermission())) { return null; } @@ -437,4 +431,4 @@ public class SetCommand extends CommandBase return null; } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java index 2a754461e..a0569a288 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StartCommand.java @@ -2,29 +2,23 @@ package nautilus.game.arcade.command; import org.bukkit.entity.Player; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.Game.GameState; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game.GameState; public class StartCommand extends CommandBase { public StartCommand(ArcadeManager plugin) { - super(plugin, Rank.ALL, "start"); + super(plugin, ArcadeManager.START_GAME_COMMAND_PERMISSION, "start"); } @Override public void Execute(Player caller, String[] args) { - if (!Plugin.canPlayerUseGameCmd(caller)) - { - return; - } - if (Plugin.GetGame() == null || Plugin.GetGame().GetState() == GameState.Loading) { UtilPlayer.message(caller, F.main("Game", "The game is currently loading, it cannot be started!")); @@ -39,7 +33,7 @@ public class StartCommand extends CommandBase int seconds = 10; - if(args.length > 0) + if (args.length > 0) { try { @@ -55,4 +49,4 @@ public class StartCommand extends CommandBase Plugin.GetGame().Announce(C.cAqua + C.Bold + caller.getName() + " has started the game."); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StopCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StopCommand.java index 3b46e0c55..bf72dfed4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StopCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StopCommand.java @@ -3,29 +3,23 @@ package nautilus.game.arcade.command; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.Game.GameState; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game.GameState; public class StopCommand extends CommandBase { public StopCommand(ArcadeManager plugin) { - super(plugin, Rank.ALL, "stop"); + super(plugin, ArcadeManager.STOP_GAME_COMMAND_PERMISSION, "stop"); } @Override public void Execute(Player caller, String[] args) { - if (!Plugin.canPlayerUseGameCmd(caller)) - { - return; - } - if (Plugin.GetGame() == null) { UtilPlayer.message(caller, F.main("Game", "There is no game to stop!")); @@ -50,4 +44,4 @@ public class StopCommand extends CommandBase Plugin.GetGame().Announce(C.cAqua + C.Bold + caller.getName() + " has stopped the game."); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/TauntCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/TauntCommand.java index af64ce746..1e1bfa70b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/TauntCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/TauntCommand.java @@ -5,23 +5,20 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.UtilPlayer; import mineplex.core.gadget.event.TauntCommandEvent; import mineplex.core.game.GameDisplay; import mineplex.minecraft.game.core.combat.CombatManager; - import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game; public class TauntCommand extends CommandBase { - private ArcadeManager _arcadeManager; public TauntCommand(ArcadeManager manager) { - super(manager, Rank.ALL, "taunt"); + super(manager, ArcadeManager.TAUNT_COMMAND_PERMISSION, "taunt"); _arcadeManager = manager; } @@ -40,6 +37,4 @@ public class TauntCommand extends CommandBase gameDisplay); Bukkit.getPluginManager().callEvent(event); } - - -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/WriteCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/WriteCommand.java deleted file mode 100644 index deae6be77..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/WriteCommand.java +++ /dev/null @@ -1,21 +0,0 @@ -package nautilus.game.arcade.command; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import nautilus.game.arcade.ArcadeManager; -import org.bukkit.entity.Player; - -public class WriteCommand extends CommandBase -{ - public WriteCommand(ArcadeManager plugin) - { - super(plugin, Rank.OWNER, new Rank[] {}, "write"); - } - - @Override - public void Execute(Player caller, String[] args) - { - caller.sendMessage(F.main("Command", "This command has been removed!")); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommand.java index fec572ef5..f0fcc170f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommand.java @@ -1,17 +1,26 @@ package nautilus.game.arcade.game; +import org.bukkit.entity.Player; + import mineplex.core.Managers; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import nautilus.game.arcade.ArcadeManager; -import org.bukkit.entity.Player; public abstract class DebugCommand extends CommandBase { - public DebugCommand(String commandName, Rank requiredRank, Rank... specificRanks) + private final String _defaultGroup; + + public DebugCommand(String commandName, String permission, String defaultGroup) { - super(Managers.get(ArcadeManager.class), requiredRank, specificRanks, commandName); + super(Managers.get(ArcadeManager.class), permission, commandName); + + _defaultGroup = defaultGroup; + } + + public String getDefaultGroup() + { + return _defaultGroup; } public abstract void Execute(Player caller, String[] args); -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 46c6dd349..6d6a5097e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -1,15 +1,67 @@ package nautilus.game.arcade.game; +import java.util.ArrayList; +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.Map.Entry; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; + +import org.apache.commons.lang3.tuple.Triple; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Hanging; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.hanging.HangingBreakEvent; +import org.bukkit.event.hanging.HangingPlaceEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.world.WorldLoadEvent; +import org.bukkit.scoreboard.NameTagVisibility; +import org.bukkit.scoreboard.Team; +import org.bukkit.util.Vector; + import com.google.common.collect.Lists; import com.mojang.authlib.GameProfile; + import mineplex.core.Managers; -import mineplex.core.MiniPlugin; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.antihack.AntiHack; import mineplex.core.arcadeevents.CoreGameStartEvent; import mineplex.core.arcadeevents.CoreGameStopEvent; import mineplex.core.command.CommandCenter; -import mineplex.core.common.Rank; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTabTitle; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.elo.EloPlayer; import mineplex.core.elo.EloTeam; @@ -39,7 +91,11 @@ import nautilus.game.arcade.game.games.draw.Draw; import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; import nautilus.game.arcade.game.modules.AntiExpOrbModule; import nautilus.game.arcade.game.modules.Module; -import nautilus.game.arcade.kit.*; +import nautilus.game.arcade.kit.ChampionsKit; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.managers.lobby.LobbyManager; import nautilus.game.arcade.quest.ChestOpenQuestTracker; @@ -53,38 +109,20 @@ import nautilus.game.arcade.quest.PlayGameQuestTracker; import nautilus.game.arcade.quest.QuestTracker; import nautilus.game.arcade.quest.WinQuestTracker; import nautilus.game.arcade.scoreboard.GameScoreboard; -import nautilus.game.arcade.stats.*; +import nautilus.game.arcade.stats.AssistsStatTracker; +import nautilus.game.arcade.stats.DamageDealtStatTracker; +import nautilus.game.arcade.stats.DamageTakenStatTracker; +import nautilus.game.arcade.stats.DeathsStatTracker; +import nautilus.game.arcade.stats.ExperienceStatTracker; +import nautilus.game.arcade.stats.GamesPlayedStatTracker; +import nautilus.game.arcade.stats.KillsStatTracker; +import nautilus.game.arcade.stats.LoseStatTracker; +import nautilus.game.arcade.stats.StatTracker; +import nautilus.game.arcade.stats.WinStatTracker; import nautilus.game.arcade.wineffect.WinEffectManager; import nautilus.game.arcade.world.WorldData; import net.minecraft.server.v1_8_R3.EntityItem; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; -import org.apache.commons.lang3.tuple.Triple; -import org.bukkit.*; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Hanging; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.FoodLevelChangeEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.hanging.HangingBreakEvent; -import org.bukkit.event.hanging.HangingPlaceEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.world.WorldLoadEvent; -import org.bukkit.scoreboard.NameTagVisibility; -import org.bukkit.scoreboard.Team; -import org.bukkit.util.Vector; - -import java.util.*; -import java.util.Map.Entry; public abstract class Game extends ListenerComponent implements Lifetimed { @@ -495,9 +533,11 @@ public abstract class Game extends ListenerComponent implements Lifetimed public void registerDebugCommand(DebugCommand debugCommand) { + PermissionManager pm = Manager.GetClients().getPermissionManager(); + pm.setPermission(pm.getGroup(debugCommand.getDefaultGroup()), debugCommand.getPermission(), true, true); if (UtilServer.isTestServer()) { - debugCommand.setRequiredRank(Rank.SNR_MODERATOR); + pm.setPermission(pm.getGroup("srmod"), debugCommand.getPermission(), true, true); } _debugCommands.add(debugCommand); for (String string : debugCommand.Aliases()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/RankedTeamGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/RankedTeamGame.java index 702e5ddb8..d75caa55d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/RankedTeamGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/RankedTeamGame.java @@ -4,15 +4,6 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilTime; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; -import nautilus.game.arcade.kit.Kit; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.event.EventHandler; @@ -22,6 +13,14 @@ import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerLoginEvent.Result; import org.bukkit.event.player.PlayerQuitEvent; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; +import nautilus.game.arcade.kit.Kit; + /** * Wrapper for team games to implement for simple universal use of Elo and Ranked methods. */ @@ -40,18 +39,16 @@ public abstract class RankedTeamGame extends TeamGame private int getAccountId(UUID uuid) { - final List id = new ArrayList(); - Manager.GetClients().getRepository().getAccountId(uuid, new Callback() + final List id = new ArrayList<>(); + Manager.GetClients().getRepository().getAccountId(uuid, data -> { - @Override - public void run(Integer data) - { - id.add(data); - } + id.add(data); }); if (id.isEmpty()) + { id.add(0); + } return id.get(0); } @@ -96,11 +93,15 @@ public abstract class RankedTeamGame extends TeamGame public void onLogin(PlayerLoginEvent event) { if (MaxPlayers == -1) + { return; + } if (Bukkit.getOnlinePlayers().size() < MaxPlayers) + { return; + } String message = ChatColor.RED + "This game has reached maximum capacity!"; - if (Manager.GetClients().Get(event.getPlayer().getUniqueId()).GetRank().has(event.getPlayer(), Rank.HELPER, false)) + if (Manager.GetClients().getPermissionManager().hasPermission(Manager.GetClients().Get(event.getPlayer().getUniqueId()), GroupPermission.of(ArcadeManager.INFORM_RANKED_MODERATION_POTENTIAL_PERMISSION))) { if (InProgress()) { @@ -108,7 +109,7 @@ public abstract class RankedTeamGame extends TeamGame } else { - message = message + " You may join for moderation purposes after the game has started!"; + message += " You may join for moderation purposes after the game has started!"; } } event.disallow(Result.KICK_OTHER, message); @@ -125,4 +126,4 @@ public abstract class RankedTeamGame extends TeamGame } } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java index c01c52658..46b9bd85c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/battleroyale/BattleRoyalePlayer.java @@ -1,10 +1,8 @@ package nautilus.game.arcade.game.games.battleroyale; -import mineplex.core.common.Rank; -import mineplex.core.common.util.MapUtil; -import mineplex.core.common.util.UtilColor; -import mineplex.core.common.util.UtilEnt; -import nautilus.game.arcade.ArcadeManager; +import java.util.HashSet; +import java.util.Set; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEnderDragon; @@ -14,12 +12,14 @@ import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import java.util.HashSet; -import java.util.Set; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilEnt; +import nautilus.game.arcade.ArcadeManager; class BattleRoyalePlayer { - private final Player _player; private final Location _location; private final Location _goal; @@ -37,8 +37,8 @@ class BattleRoyalePlayer _cageBlocks = new HashSet<>(); // Colour the cage based on the player's rank - Rank rank = manager.GetClients().Get(player).GetRank(); - byte data = UtilColor.chatColorToWoolData(rank.getColor()); + PermissionGroup group = manager.GetClients().Get(player).getPrimaryGroup(); + byte data = UtilColor.chatColorToWoolData(group.getColor()); // Build the cage buildCage(data); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index 99b9e3b6e..7dec96c42 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -226,9 +226,8 @@ public class Bridge extends TeamGame implements OreObsfucation } } - registerDebugCommand(new DebugCommand("bridge", getArcadeManager().getGameCommandRank()) + registerDebugCommand(new DebugCommand("bridge", "mineplex.arcade.bridge.bridge", "admin") { - @Override public void Execute(Player caller, String[] args) { @@ -237,7 +236,7 @@ public class Bridge extends TeamGame implements OreObsfucation } }); - registerDebugCommand(new DebugCommand("bridgeinfo", getArcadeManager().getGameCommandRank()) + registerDebugCommand(new DebugCommand("bridgeinfo", "mineplex.arcade.bridge.bridgeinfo", "admin") { @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java index 364e73e8a..c7df57cac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java @@ -5,7 +5,28 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; -import mineplex.core.common.Rank; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.ItemDespawnEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.RadarData; @@ -37,28 +58,10 @@ import nautilus.game.arcade.game.games.common.dominate_data.Resupply; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockPhysicsEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.ItemDespawnEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffectType; - public class CaptureTheFlag extends TeamGame { + public static final String SUDDEN_DEATH_COMMAND_PERMISSION = "mineplex.arcade.ctf.suddendeath"; + //Map Data private Location _redFlag; private Location _blueFlag; @@ -108,6 +111,19 @@ public class CaptureTheFlag extends TeamGame .register(this); this.DeathSpectateSecs = 10; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Manager.GetClients().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SUDDEN_DEATH_COMMAND_PERMISSION), true, true); + if (UtilServer.isTestServer()) + { + pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(SUDDEN_DEATH_COMMAND_PERMISSION), true, true); + } } @Override @@ -721,20 +737,12 @@ public class CaptureTheFlag extends TeamGame if (event.getMessage().contains("/suddendeath")) { - boolean authorized = Manager.GetClients().Get(event.getPlayer()).GetRank().has(Rank.JNR_DEV); - - if (UtilServer.isTestServer()) - if (Manager.GetClients().Get(event.getPlayer()).GetRank().has(Rank.SNR_MODERATOR)) - authorized = true; + boolean authorized = Manager.GetClients().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(SUDDEN_DEATH_COMMAND_PERMISSION)); if (Manager.GetGameHostManager().isPrivateServer()) if (Manager.GetGameHostManager().isAdmin(event.getPlayer(), false)) authorized = true; - if (Manager.GetGameHostManager().isEventServer()) - if (Manager.GetClients().Get(event.getPlayer()).GetRank().has(Rank.SNR_MODERATOR)) - authorized = true; - if (authorized) { if (_redScore < _blueScore) @@ -828,4 +836,4 @@ public class CaptureTheFlag extends TeamGame event.SetBrute(); } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java index f2e180c82..9acc0a99e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java @@ -39,7 +39,8 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -61,7 +62,6 @@ import mineplex.core.mount.Mount; import mineplex.core.punish.PunishClient; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; - import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.games.bridge.Bridge; @@ -71,7 +71,8 @@ import nautilus.game.arcade.kit.Kit; public class EventModule extends MiniPlugin { - + public static final String SET_HOST_COMMAND_PERMISSION = "mineplex.arcade.event.sethost"; + private ArcadeManager Manager; private NautHashMap _potionEffectsDuration = new NautHashMap<>(); @@ -94,6 +95,19 @@ public class EventModule extends MiniPlugin _mobGriefing = true; _stacker = new ArrayList<>(); _damage = new ArrayList<>(); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Manager.GetClients().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SET_HOST_COMMAND_PERMISSION), true, true); + if (_plugin.getConfig().getString("serverstatus.name").equals("SMTestServer-1")) + { + pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(SET_HOST_COMMAND_PERMISSION), true, true); + } } @EventHandler @@ -111,20 +125,10 @@ public class EventModule extends MiniPlugin if (!event.getMessage().toLowerCase().startsWith("/sethost ")) return; - boolean allowed = Manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.JNR_DEV, true); - - - if (!allowed) - { - allowed = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1") && - Manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.SNR_MODERATOR, true); - } - - if (!allowed) + if (!Manager.GetClients().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(SET_HOST_COMMAND_PERMISSION))) { return; } - Manager.GetServerConfig().HostName = event.getMessage().split(" ")[1]; @@ -132,7 +136,9 @@ public class EventModule extends MiniPlugin Manager.GetGameHostManager().setHost(Bukkit.getPlayerExact(Manager.GetServerConfig().HostName)); if (Manager.GetGameHostManager().getHost() != null) - Manager.GetGameHostManager().setHostRank(Manager.GetClients().Get(Manager.GetGameHostManager().getHost()).GetRank()); + { + Manager.GetGameHostManager().setHostRank(Manager.GetClients().Get(Manager.GetGameHostManager().getHost()).getPrimaryGroup()); + } Manager.GetGameHostManager().setDefaultConfig(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index d0d92f862..4896966a1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -1,51 +1,9 @@ package nautilus.game.arcade.game.games.minecraftleague; -import com.google.common.base.Objects; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.message.PrivateMessageEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.combat.DeathMessageType; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerDeathOutEvent; -import nautilus.game.arcade.events.PlayerGameRespawnEvent; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.RankedTeamGame; -import nautilus.game.arcade.game.games.minecraftleague.commands.MinecraftLeagueCommand; -import nautilus.game.arcade.game.games.minecraftleague.commands.freeze.FreezeManager; -import nautilus.game.arcade.game.games.minecraftleague.data.BlockProtection; -import nautilus.game.arcade.game.games.minecraftleague.data.MapZone; -import nautilus.game.arcade.game.games.minecraftleague.data.Spawner; -import nautilus.game.arcade.game.games.minecraftleague.data.TeamBeacon; -import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; -import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase; -import nautilus.game.arcade.game.games.minecraftleague.data.TowerAlert; -import nautilus.game.arcade.game.games.minecraftleague.data.TowerManager; -import nautilus.game.arcade.game.games.minecraftleague.data.map.ItemMapManager; -import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer; -import nautilus.game.arcade.game.games.minecraftleague.tracker.AltarBuilderTracker; -import nautilus.game.arcade.game.games.minecraftleague.tracker.FirstStrikeTracker; -import nautilus.game.arcade.game.games.minecraftleague.tracker.HeadHunterTracker; -import nautilus.game.arcade.game.games.minecraftleague.tracker.SavingUpTracker; -import nautilus.game.arcade.game.games.minecraftleague.tracker.TowerDefenderTracker; -import nautilus.game.arcade.game.games.minecraftleague.variation.ExtraScoreboardData; -import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation; -import nautilus.game.arcade.game.games.minecraftleague.variation.VariationManager; -import nautilus.game.arcade.game.modules.compass.CompassModule; -import nautilus.game.arcade.kit.Kit; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -100,9 +58,51 @@ import org.bukkit.material.MaterialData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; +import com.google.common.base.Objects; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.message.PrivateMessageEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerDeathOutEvent; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.RankedTeamGame; +import nautilus.game.arcade.game.games.minecraftleague.data.BlockProtection; +import nautilus.game.arcade.game.games.minecraftleague.data.MapZone; +import nautilus.game.arcade.game.games.minecraftleague.data.Spawner; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamBeacon; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase; +import nautilus.game.arcade.game.games.minecraftleague.data.TowerAlert; +import nautilus.game.arcade.game.games.minecraftleague.data.TowerManager; +import nautilus.game.arcade.game.games.minecraftleague.data.map.ItemMapManager; +import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer; +import nautilus.game.arcade.game.games.minecraftleague.tracker.AltarBuilderTracker; +import nautilus.game.arcade.game.games.minecraftleague.tracker.FirstStrikeTracker; +import nautilus.game.arcade.game.games.minecraftleague.tracker.HeadHunterTracker; +import nautilus.game.arcade.game.games.minecraftleague.tracker.SavingUpTracker; +import nautilus.game.arcade.game.games.minecraftleague.tracker.TowerDefenderTracker; +import nautilus.game.arcade.game.games.minecraftleague.variation.ExtraScoreboardData; +import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation; +import nautilus.game.arcade.game.games.minecraftleague.variation.VariationManager; +import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.kit.Kit; public class MinecraftLeague extends RankedTeamGame { @@ -121,7 +121,6 @@ public class MinecraftLeague extends RankedTeamGame public ConcurrentHashMap ExtraSb = new ConcurrentHashMap(); private long _liveTime = 0; - private MinecraftLeagueCommand _cmd; private long _lastIncrease; private long _lastOreReset; private long _lastGrindReset; @@ -133,7 +132,6 @@ public class MinecraftLeague extends RankedTeamGame private VariationManager _vman; //public ObjectiveManager Objective; - private FreezeManager _freeze; private TowerManager _tower; public TowerAlert Alert; public boolean ScoreboardAutoWrite = true; @@ -209,10 +207,8 @@ public class MinecraftLeague extends RankedTeamGame _vman = new VariationManager(this); //Objective = new ObjectiveManager(this); - _freeze = new FreezeManager(); _tower = new TowerManager(this); Alert = new TowerAlert(); - Bukkit.getPluginManager().registerEvents(_freeze, manager.getPlugin()); Bukkit.getPluginManager().registerEvents(_tower, manager.getPlugin()); new CompassModule() @@ -426,11 +422,6 @@ public class MinecraftLeague extends RankedTeamGame return _tower; } - public FreezeManager getFreezeManager() - { - return _freeze; - } - /*public TeamMap getMap(GameTeam team) { return _maps.get(team); @@ -677,8 +668,6 @@ public class MinecraftLeague extends RankedTeamGame Manager.GetDamage().SetEnabled(false); Manager.GetCreature().SetForce(false); Manager.GetCreature().SetDisableCustomDrops(true); - _cmd = new MinecraftLeagueCommand(Manager, this); - Manager.addCommand(_cmd); Manager.getGameChatManager().TeamSpy = false; //Objective.setMainObjective(new GearObjective()); } @@ -691,10 +680,8 @@ public class MinecraftLeague extends RankedTeamGame Manager.GetDamage().SetEnabled(true); Manager.GetCreature().SetForce(false); Manager.GetCreature().SetDisableCustomDrops(false); - Manager.removeCommand(_cmd); Manager.getGameChatManager().TeamSpy = true; HandlerList.unregisterAll(MapManager); - HandlerList.unregisterAll(_freeze); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DebugCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DebugCommand.java deleted file mode 100644 index a6b7929dc..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DebugCommand.java +++ /dev/null @@ -1,23 +0,0 @@ -package nautilus.game.arcade.game.games.minecraftleague.commands; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import nautilus.game.arcade.ArcadeManager; - -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; - -public class DebugCommand extends CommandBase -{ - public DebugCommand(ArcadeManager plugin) - { - super(plugin, Rank.DEVELOPER, new Rank[] {Rank.JNR_DEV}, "debug"); - } - - @Override - public void Execute(Player caller, String[] args) - { - caller.getWorld().spawnEntity(caller.getLocation(), EntityType.ENDER_CRYSTAL); - } - -} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java deleted file mode 100644 index 17e41d437..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package nautilus.game.arcade.game.games.minecraftleague.commands; - -import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; -import nautilus.game.arcade.game.games.minecraftleague.commands.freeze.FreezeCommand; -import nautilus.game.arcade.game.games.minecraftleague.commands.panel.GUICommand; - -import org.bukkit.entity.Player; - -public class MinecraftLeagueCommand extends MultiCommandBase -{ - private MinecraftLeague _host; - - public MinecraftLeagueCommand(ArcadeManager plugin, MinecraftLeague host) - { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "mcLeague"); - AddCommand(new GUICommand(plugin, host)); - AddCommand(new FreezeCommand(plugin, host)); - AddCommand(new StatusCommand(plugin, host)); - AddCommand(new DebugCommand(plugin)); - _host = host; - } - - @Override - protected void Help(Player caller, String[] args) - { - UtilPlayer.message(caller, F.main(_host.GetName(), "Commands List:")); - UtilPlayer.message(caller, F.help("/mcLeague gui", "Opens a GUI for controlling Respawn Crystals", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/mcLeague freeze ", "Freezes or unfreezes a player [for cheaters]", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/mcLeague status", "Gets statistics about both Respawn Crystals", Rank.DEVELOPER)); - UtilPlayer.message(caller, F.help("/mcLeague debug", "Spawns a Tower Mob at your position", Rank.DEVELOPER)); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/StatusCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/StatusCommand.java deleted file mode 100644 index 38dfd2b5e..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/StatusCommand.java +++ /dev/null @@ -1,26 +0,0 @@ -package nautilus.game.arcade.game.games.minecraftleague.commands; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; - -import org.bukkit.entity.Player; - -public class StatusCommand extends CommandBase -{ - private MinecraftLeague _host; - - public StatusCommand(ArcadeManager plugin, MinecraftLeague host) - { - super(plugin, Rank.DEVELOPER, new Rank[] {Rank.JNR_DEV}, "status"); - _host = host; - } - - @Override - public void Execute(Player caller, String[] args) - { - _host.handleCommand(caller); - } - -} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeCommand.java deleted file mode 100644 index 0297354a2..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeCommand.java +++ /dev/null @@ -1,40 +0,0 @@ -package nautilus.game.arcade.game.games.minecraftleague.commands.freeze; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; - -import org.bukkit.entity.Player; - -public class FreezeCommand extends CommandBase -{ - private MinecraftLeague _host; - - public FreezeCommand(ArcadeManager plugin, MinecraftLeague host) - { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "freeze"); - _host = host; - } - - @Override - public void Execute(Player caller, String[] args) - { - if (args.length < 1) - { - UtilPlayer.message(caller, F.help("/mcLeague freeze ", "Freezes or unfreezes a player [for cheaters]", Rank.ADMIN)); - return; - } - - String name = args[0]; - Player get = UtilPlayer.searchOnline(caller, name, true); - - if (get != null) - { - _host.getFreezeManager().toggleFreeze(get, caller); - } - } - -} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeManager.java deleted file mode 100644 index c657ba71a..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeManager.java +++ /dev/null @@ -1,133 +0,0 @@ -package nautilus.game.arcade.game.games.minecraftleague.commands.freeze; - -import java.util.concurrent.ConcurrentHashMap; - -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilPlayer; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ClickEvent.Action; -import net.md_5.bungee.api.chat.TextComponent; - -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -public class FreezeManager implements Listener -{ - private ConcurrentHashMap _frozen = new ConcurrentHashMap(); - - private void showBan(String player, Player staff) - { - ClickEvent prep = new ClickEvent(Action.SUGGEST_COMMAND, "/p " + player + " Logging out during Freeze [MCL]"); - TextComponent message = new TextComponent(player + " has logged out while frozen! Click here for a ready-made punishment command!"); - message.setColor(ChatColor.DARK_RED); - message.setClickEvent(prep); - - staff.spigot().sendMessage(message); - } - - public boolean isFrozen(Player player) - { - return _frozen.containsKey(player.getName()); - } - - public void toggleFreeze(Player player, Player staff) - { - if (isFrozen(player)) - { - _frozen.remove(player.getName()); - UtilPlayer.message(staff, F.main("Freeze", "You have unfrozen " + player.getName())); - UtilPlayer.message(player, F.main("Freeze", "You have been unfrozen by " + staff.getName())); - } - else - { - _frozen.put(player.getName(), staff.getName()); - UtilPlayer.message(staff, F.main("Freeze", "You have frozen " + player.getName())); - UtilPlayer.message(player, F.main("Freeze", "You have been frozen by " + staff.getName())); - player.teleport(UtilBlock.getHighest(player.getWorld(), player.getLocation().getBlockX(), player.getLocation().getBlockZ()).getLocation()); - } - } - - @EventHandler - public void onMove(PlayerMoveEvent event) - { - if (isFrozen(event.getPlayer())) - { - Location to = event.getTo(); - Location from = event.getFrom(); - Location move = new Location(from.getWorld(), from.getX(), from.getY(), from.getZ()); - move.setPitch(to.getPitch()); - move.setYaw(to.getYaw()); - - event.setTo(move); - } - } - - @EventHandler - public void onLogout(PlayerQuitEvent event) - { - if (isFrozen(event.getPlayer())) - { - if (UtilPlayer.searchExact(_frozen.get(event.getPlayer().getName())) != null) - { - showBan(event.getPlayer().getName(), UtilPlayer.searchExact(_frozen.get(event.getPlayer().getName()))); - _frozen.remove(event.getPlayer().getName()); - } - } - } - - @EventHandler - public void onDamage(EntityDamageEvent event) - { - if (event.getEntity() instanceof Player) - if (isFrozen((Player)event.getEntity())) - event.setCancelled(true); - } - - @EventHandler - public void onPVP(EntityDamageByEntityEvent event) - { - Player dmg = null; - if (event.getDamager() instanceof Player) - { - dmg = (Player)event.getDamager(); - } - if (event.getDamager() instanceof Projectile) - { - if (((Projectile)event.getDamager()).getShooter() instanceof Player) - { - dmg = (Player) ((Projectile)event.getDamager()).getShooter(); - } - } - - if (dmg == null) - return; - - if (isFrozen(dmg)) - event.setCancelled(true); - } - - @EventHandler - public void onBuild(BlockPlaceEvent event) - { - if (isFrozen(event.getPlayer())) - event.setCancelled(true); - } - - @EventHandler - public void onBreak(BlockBreakEvent event) - { - if (isFrozen(event.getPlayer())) - event.setCancelled(true); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java deleted file mode 100644 index 83db013c1..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java +++ /dev/null @@ -1,147 +0,0 @@ -package nautilus.game.arcade.game.games.minecraftleague.commands.panel; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -public class AdminPanel implements Listener -{ - private Player _admin; - private MinecraftLeague _host; - private Inventory _menu; - private ConcurrentHashMap _buttons; - private ConcurrentHashMap _slots; - - public AdminPanel(Player admin, MinecraftLeague host) - { - _admin = admin; - _host = host; - _menu = Bukkit.createInventory(admin, 9, C.cRed + "Admin Panel: Minecraft League"); - _buttons = new ConcurrentHashMap(); - _slots = new ConcurrentHashMap(); - - ItemStack red = new ItemBuilder(MenuButton.CRYSTAL.getRepresentation()) - .setTitle(C.cRed + "Red Core") - .setLore(C.cGray + "Alive: " + host.getTowerManager().getTeamTowers(host.GetTeam(ChatColor.RED)).getLast().Alive, - C.cGray + "Health: " + host.getTowerManager().getTeamTowers(host.GetTeam(ChatColor.RED)).getLast().getHealth()) - .build(); - - ItemStack blue = new ItemBuilder(MenuButton.CRYSTAL.getRepresentation()) - .setTitle(C.cAqua + "Blue Core") - .setLore(C.cGray + "Alive: " + host.getTowerManager().getTeamTowers(host.GetTeam(ChatColor.AQUA)).getLast().Alive, - C.cGray + "Health: " + host.getTowerManager().getTeamTowers(host.GetTeam(ChatColor.AQUA)).getLast().getHealth()) - .build(); - - _buttons.put(red, host.GetTeam(ChatColor.RED)); - _buttons.put(blue, host.GetTeam(ChatColor.AQUA)); - _slots.put(host.GetTeam(ChatColor.RED), 2); - _slots.put(host.GetTeam(ChatColor.AQUA), 6); - - _menu.setItem(2, red); - _menu.setItem(6, blue); - //2, 6 - - admin.openInventory(_menu); - Bukkit.getPluginManager().registerEvents(this, _host.Manager.getPlugin()); - } - - public boolean updateInv() - { - if (!_admin.getOpenInventory().getTopInventory().getName().equalsIgnoreCase(_menu.getName())) - return false; - for (ItemStack item : _buttons.keySet()) - { - GameTeam team = _buttons.get(item); - ItemMeta im = item.getItemMeta(); - List lore = new ArrayList(); - lore.add(C.cGray + "Alive: " + _host.getTowerManager().getTeamTowers(team).getLast().Alive); - lore.add(C.cGray + "Health: " + _host.getTowerManager().getTeamTowers(team).getLast().getHealth()); - im.setLore(lore); - item.setItemMeta(im); - _buttons.remove(item); - _buttons.put(item, team); - _menu.setItem(_slots.get(team), item); - } - _admin.updateInventory(); - return true; - } - - @EventHandler - public void onUseButton(InventoryClickEvent event) - { - if (!_host.IsLive()) - return; - - if (!event.getClickedInventory().equals(_menu)) - return; - - if (!event.getWhoClicked().getName().equals(_admin.getName())) - return; - - if (event.getCurrentItem() == null) - return; - - event.setCancelled(true); - } - - @EventHandler - public void update(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - if (!UtilPlayer.isOnline(_admin.getName())) - { - HandlerList.unregisterAll(this); - return; - } - if (!_host.IsLive()) - { - if (_host.GetState() == GameState.Dead) - HandlerList.unregisterAll(this); - if (_host.GetState() == GameState.End) - _admin.closeInventory(); - return; - } - if (!updateInv()) - HandlerList.unregisterAll(this); - } - - private enum MenuButton - { - CRYSTAL(Material.EYE_OF_ENDER); - - private Material _rep; - - private MenuButton(Material representation) - { - _rep = representation; - } - - public Material getRepresentation() - { - return _rep; - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/GUICommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/GUICommand.java deleted file mode 100644 index 508f1b768..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/GUICommand.java +++ /dev/null @@ -1,26 +0,0 @@ -package nautilus.game.arcade.game.games.minecraftleague.commands.panel; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; - -import org.bukkit.entity.Player; - -public class GUICommand extends CommandBase -{ - private MinecraftLeague _host; - - public GUICommand(ArcadeManager plugin, MinecraftLeague host) - { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "gui"); - _host = host; - } - - @Override - public void Execute(Player caller, String[] args) - { - new AdminPanel(caller, _host); - } - -} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index e35238b84..a53c3f9f3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,8 +1,27 @@ package nautilus.game.arcade.game.games.moba; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerQuitEvent; + import mineplex.core.Managers; import mineplex.core.common.Pair; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; @@ -56,38 +75,19 @@ import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; public class Moba extends TeamGame { - - private static final String[] ITEM_IMAGES = { - "Anath_the_Burnt.png", - "Bardolf.png", - "Biff.png", - "Dana.png", - "Devon.png", - "Hattori.png", - "Larissa.png", - "Rowena.png" + private static final String[] ITEM_IMAGES = + { + "Anath_the_Burnt.png", + "Bardolf.png", + "Biff.png", + "Dana.png", + "Devon.png", + "Hattori.png", + "Larissa.png", + "Rowena.png" }; private final HeroKit[] _kits; @@ -160,7 +160,7 @@ public class Moba extends TeamGame .setGiveCompassToAlive(false) .register(this); - registerDebugCommand(new DebugCommand("kit", Rank.ADMIN) + registerDebugCommand(new DebugCommand("kit", "mineplex.arcade.moba.kit", "admin") { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index 4ce28a71d..cfcbacf36 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -1,25 +1,23 @@ package nautilus.game.arcade.game.games.moba.gold; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.DebugCommand; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; -import nautilus.game.arcade.game.games.moba.structure.point.CapturePointCaptureEvent; -import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; +import java.util.HashMap; +import java.util.Map; + import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import java.util.HashMap; -import java.util.Map; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.DebugCommand; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; +import nautilus.game.arcade.game.games.moba.structure.point.CapturePointCaptureEvent; +import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; public class GoldManager implements Listener { @@ -41,7 +39,7 @@ public class GoldManager implements Listener _playerGold = new HashMap<>(); - host.registerDebugCommand(new DebugCommand("gold", Rank.ADMIN) + host.registerDebugCommand(new DebugCommand("gold", "mineplex.arcade.moba.gold.give", "admin") { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index e5fe816f0..5d91d0f41 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -1,6 +1,20 @@ package nautilus.game.arcade.game.games.moba.minion; -import mineplex.core.common.Rank; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.PigZombie; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -13,25 +27,9 @@ import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; import nautilus.game.arcade.game.games.moba.util.MobaConstants; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.entity.PigZombie; -import org.bukkit.entity.Player; -import org.bukkit.entity.Zombie; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.TimeUnit; public class MinionManager implements Listener { - private static final long MINION_SPAWN_TIME = TimeUnit.SECONDS.toMillis(30); private final Moba _host; @@ -48,7 +46,7 @@ public class MinionManager implements Listener _waves = new HashSet<>(); _enabled = true; - host.registerDebugCommand(new DebugCommand("removeminions", Rank.DEVELOPER) + host.registerDebugCommand(new DebugCommand("removeminions", "mineplex.arcade.moba.minion.remove", "dev") { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java index 6ccdc62af..f539d02fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/progression/MobaProgression.java @@ -1,6 +1,22 @@ package nautilus.game.arcade.game.games.moba.progression; -import mineplex.core.common.Rank; +import java.text.DecimalFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -20,22 +36,6 @@ import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; import nautilus.game.arcade.game.games.moba.progression.ui.MobaRoleShop; import nautilus.game.arcade.game.games.moba.util.MobaUtil; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerInteractAtEntityEvent; - -import java.text.DecimalFormat; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; public class MobaProgression implements Listener { @@ -66,7 +66,7 @@ public class MobaProgression implements Listener _roleViewers = new HashMap<>(); _roleShop = new MobaRoleShop(host.getArcadeManager()); - host.registerDebugCommand(new DebugCommand("fakeexp", Rank.DEVELOPER) + host.registerDebugCommand(new DebugCommand("fakeexp", "mineplex.arcade.moba.progression.fakeexp", "dev") { @Override public void Execute(Player caller, String[] args) @@ -76,7 +76,7 @@ public class MobaProgression implements Listener caller.sendMessage(F.main("Debug", "Gave you " + F.elem(exp) + " fake exp.")); } }); - host.registerDebugCommand(new DebugCommand("setmobalevel", Rank.DEVELOPER) + host.registerDebugCommand(new DebugCommand("setmobalevel", "mineplex.arcade.moba.progression.setlevel", "dev") { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java index 59b4c33c2..ffb3d0b46 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -1,6 +1,29 @@ package nautilus.game.arcade.game.games.moba.training; -import mineplex.core.common.Rank; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Villager.Profession; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -24,29 +47,6 @@ import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.TrainingGameModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.scoreboard.GameScoreboard; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton; -import org.bukkit.entity.Villager; -import org.bukkit.entity.Villager.Profession; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.TimeUnit; -import java.util.function.Function; public class MobaTraining extends Moba { @@ -191,7 +191,7 @@ public class MobaTraining extends Moba (int) (Math.ceil(subject.getHealth() / 2D))) .register(this); - registerDebugCommand(new DebugCommand("skip", Rank.ALL) + registerDebugCommand(new DebugCommand("skip", "mineplex.arcade.moba.training.skip", "player") { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java index ecf16a805..da75b92f2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java @@ -1,15 +1,52 @@ package nautilus.game.arcade.game.games.smash; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.EnderCrystal; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; + import com.google.common.collect.Sets; + import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.common.Rank; -import mineplex.core.common.util.*; -import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilFirework; +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.UtilTextMiddle; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.hologram.Hologram; import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.mount.Mount; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -23,37 +60,34 @@ import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.games.smash.events.SmashActivateEvent; -import nautilus.game.arcade.game.games.smash.kits.*; +import nautilus.game.arcade.game.games.smash.kits.KitBlaze; +import nautilus.game.arcade.game.games.smash.kits.KitChicken; +import nautilus.game.arcade.game.games.smash.kits.KitCow; +import nautilus.game.arcade.game.games.smash.kits.KitCreeper; +import nautilus.game.arcade.game.games.smash.kits.KitEnderman; +import nautilus.game.arcade.game.games.smash.kits.KitGolem; +import nautilus.game.arcade.game.games.smash.kits.KitGuardian; +import nautilus.game.arcade.game.games.smash.kits.KitMagmaCube; +import nautilus.game.arcade.game.games.smash.kits.KitPig; +import nautilus.game.arcade.game.games.smash.kits.KitSheep; +import nautilus.game.arcade.game.games.smash.kits.KitSkeletalHorse; +import nautilus.game.arcade.game.games.smash.kits.KitSkeleton; +import nautilus.game.arcade.game.games.smash.kits.KitSkySquid; +import nautilus.game.arcade.game.games.smash.kits.KitSlime; +import nautilus.game.arcade.game.games.smash.kits.KitSnowman; +import nautilus.game.arcade.game.games.smash.kits.KitSpider; +import nautilus.game.arcade.game.games.smash.kits.KitWitch; +import nautilus.game.arcade.game.games.smash.kits.KitWitherSkeleton; +import nautilus.game.arcade.game.games.smash.kits.KitWolf; +import nautilus.game.arcade.game.games.smash.kits.KitZombie; import nautilus.game.arcade.game.games.smash.perks.SmashUltimate; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.managers.PerkSpreadsheetModule; -import org.bukkit.*; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.block.Block; -import org.bukkit.entity.EnderCrystal; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.entity.*; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; public abstract class SuperSmash extends Game { - private static final int MAX_LIVES = 4; private static final int POWERUP_SPAWN_Y_INCREASE = 120; private static final int HUNGER_DELAY = 250; @@ -103,7 +137,7 @@ public abstract class SuperSmash extends Game new PerkSpreadsheetModule(this, "SMASH_KITS"); - registerDebugCommand(new DebugCommand("cooldown", Rank.ADMIN) + registerDebugCommand(new DebugCommand("cooldown", "mineplex.arcade.smash.cooldown", "admin") { @Override public void Execute(Player caller, String[] args) @@ -116,7 +150,7 @@ public abstract class SuperSmash extends Game Announce(C.cWhiteB + caller.getName() + C.cAquaB + " reset cooldowns!"); } }); - registerDebugCommand(new DebugCommand("nextsmash", Rank.ADMIN) + registerDebugCommand(new DebugCommand("nextsmash", "mineplex.arcade.smash.nextsmash", "admin") { @Override public void Execute(Player caller, String[] args) @@ -125,7 +159,7 @@ public abstract class SuperSmash extends Game Announce(C.cWhiteB + caller.getName() + C.cAquaB + " spawned a smash crystal!"); } }); - registerDebugCommand(new DebugCommand("smash", Rank.ADMIN) + registerDebugCommand(new DebugCommand("smash", "mineplex.arcade.smash.smash", "admin") { @Override public void Execute(Player caller, String[] args) @@ -133,7 +167,7 @@ public abstract class SuperSmash extends Game giveSmashItem(caller); } }); - registerDebugCommand(new DebugCommand("kit", Rank.ADMIN) + registerDebugCommand(new DebugCommand("kit", "mineplex.arcade.smash.kit", "admin") { @Override public void Execute(Player caller, String[] args) @@ -159,7 +193,7 @@ public abstract class SuperSmash extends Game caller.sendMessage(F.main("Kit", "Sorry that is not a kit!")); } }); - registerDebugCommand(new DebugCommand("lives", Rank.ADMIN) + registerDebugCommand(new DebugCommand("lives", "mineplex.arcade.smash.lives", "admin") { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java index a69086bd0..b2843e4e1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java @@ -1,48 +1,12 @@ package nautilus.game.arcade.game.games.speedbuilders; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.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.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.disguise.disguises.DisguiseGuardian; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.games.speedbuilders.data.BuildData; -import nautilus.game.arcade.game.games.speedbuilders.data.DemolitionData; -import nautilus.game.arcade.game.games.speedbuilders.data.MobData; -import nautilus.game.arcade.game.games.speedbuilders.data.RecreationData; -import nautilus.game.arcade.game.games.speedbuilders.events.PerfectBuildEvent; -import nautilus.game.arcade.game.games.speedbuilders.kits.DefaultKit; -import nautilus.game.arcade.game.games.speedbuilders.quests.PerfectBuildQuestTracker; -import nautilus.game.arcade.game.games.speedbuilders.stattrackers.DependableTracker; -import nautilus.game.arcade.game.games.speedbuilders.stattrackers.FirstBuildTracker; -import nautilus.game.arcade.game.games.speedbuilders.stattrackers.PerfectionistTracker; -import nautilus.game.arcade.game.games.speedbuilders.stattrackers.SpeediestBuilderizerTracker; -import nautilus.game.arcade.game.modules.compass.CompassModule; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.chat.ChatStatData; -import nautilus.game.arcade.stats.BlockPlaceStatTracker; -import net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map.Entry; +import java.util.stream.Collectors; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Effect; @@ -77,7 +41,6 @@ import org.bukkit.event.entity.ItemMergeEvent; import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketFillEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; @@ -90,10 +53,49 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map.Entry; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.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.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguiseGuardian; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.DebugCommand; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.speedbuilders.data.BuildData; +import nautilus.game.arcade.game.games.speedbuilders.data.DemolitionData; +import nautilus.game.arcade.game.games.speedbuilders.data.MobData; +import nautilus.game.arcade.game.games.speedbuilders.data.RecreationData; +import nautilus.game.arcade.game.games.speedbuilders.events.PerfectBuildEvent; +import nautilus.game.arcade.game.games.speedbuilders.kits.DefaultKit; +import nautilus.game.arcade.game.games.speedbuilders.quests.PerfectBuildQuestTracker; +import nautilus.game.arcade.game.games.speedbuilders.stattrackers.DependableTracker; +import nautilus.game.arcade.game.games.speedbuilders.stattrackers.FirstBuildTracker; +import nautilus.game.arcade.game.games.speedbuilders.stattrackers.PerfectionistTracker; +import nautilus.game.arcade.game.games.speedbuilders.stattrackers.SpeediestBuilderizerTracker; +import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.chat.ChatStatData; +import nautilus.game.arcade.stats.BlockPlaceStatTracker; +import net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange; public class SpeedBuilders extends SoloGame { @@ -203,6 +205,52 @@ public class SpeedBuilders extends SoloGame .setGiveCompassToSpecs(true) .setGiveCompassToAlive(false) .register(this); + + registerDebugCommand(new DebugCommand("setnext", "mineplex.arcade.speedbuilders.setnext", "builder") + { + @Override + public void Execute(Player caller, String[] args) + { + if (!UtilServer.isTestServer()) + { + UtilPlayer.message(caller, F.main("Build", C.cYellow + "You can only use this on testing servers!")); + + return; + } + + if (args.length == 0) + { + UtilPlayer.message(caller, F.main("Build", C.cYellow + "You need to specify a next build!")); + + return; + } + + String buildName = Arrays.asList(args).stream().collect(Collectors.joining(" ")); + + BuildData build = null; + + for (BuildData buildData : _buildData) + { + if (buildData.BuildText.toUpperCase().startsWith(buildName.toUpperCase())) + { + build = buildData; + + break; + } + } + + if (build == null) + { + UtilPlayer.message(caller, F.main("Build", "That build does not exist!")); + } + else + { + _nextBuild = build; + + UtilPlayer.message(caller, F.main("Build", "Set next build to " + F.elem(build.BuildText))); + } + } + }); } @Override @@ -1629,48 +1677,6 @@ public class SpeedBuilders extends SoloGame event.setCancelled(true); } - @EventHandler - public void setNextBuild(PlayerCommandPreprocessEvent event) - { - if (!event.getMessage().startsWith("/setnext ")) - return; - - event.setCancelled(true); - - if (!Manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.MAPDEV, true)) - return; - - if (!UtilServer.isTestServer()) - { - UtilPlayer.message(event.getPlayer(), F.main("Build", C.cYellow + "You can only use this on testing servers!")); - - return; - } - - String buildName = event.getMessage().substring(9); - - BuildData build = null; - - for (BuildData buildData : _buildData) - { - if (buildData.BuildText.toUpperCase().startsWith(buildName.toUpperCase())) - { - build = buildData; - - break; - } - } - - if (build == null) - UtilPlayer.message(event.getPlayer(), F.main("Build", "That build does not exist!")); - else - { - _nextBuild = build; - - UtilPlayer.message(event.getPlayer(), F.main("Build", "Set next build to " + F.elem(build.BuildText))); - } - } - @EventHandler public void moveSetFlight(PlayerMoveEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java index dc6a87727..92a3c90a9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/StaffKillMonitorManager.java @@ -6,7 +6,8 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -17,10 +18,7 @@ import nautilus.game.arcade.game.games.typewars.TypeWars.KillType; public class StaffKillMonitorManager implements Listener { - /** - * Created by: Mysticate - * Timestamp: December 30, 2015 - */ + public static final String MONITOR_KILLS_COMMAND_PERMISSION = "mineplex.arcade.typewars.monitorkills"; private TypeWars _host; private String _command = "/words"; @@ -31,7 +29,16 @@ public class StaffKillMonitorManager implements Listener { _host = host; - host.Manager.registerEvents(this);; + host.Manager.registerEvents(this); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _host.Manager.GetClients().getPermissionManager(); + + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(MONITOR_KILLS_COMMAND_PERMISSION), true, true); } public TypeWars getHost() @@ -43,7 +50,9 @@ public class StaffKillMonitorManager implements Listener public void onEnd(GameStateChangeEvent event) { if (event.GetState() == GameState.End) + { HandlerList.unregisterAll(this); + } } @EventHandler @@ -67,7 +76,7 @@ public class StaffKillMonitorManager implements Listener if (!_host.IsLive()) return; - if (!_host.Manager.GetClients().hasRank(event.getPlayer(), Rank.HELPER)) + if (!_host.Manager.GetClients().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(MONITOR_KILLS_COMMAND_PERMISSION))) return; event.setCancelled(true); @@ -98,4 +107,4 @@ public class StaffKillMonitorManager implements Listener _monitoring.put(event.getPlayer(), player); UtilPlayer.message(event.getPlayer(), F.main("TypeWars", "You are now monitoring " + F.name(player.getName()) + ". Type " + F.elem(_command) + " to stop.")); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java index 6e7845689..062acf389 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java @@ -1,6 +1,33 @@ package nautilus.game.arcade.game.games.typewars; -import mineplex.core.common.Rank; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Giant; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerChatEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.util.Vector; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -24,6 +51,7 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.typewars.kits.KitTypeWarsBase; @@ -44,39 +72,14 @@ import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.world.WorldData; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Giant; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntitySpawnEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.util.Vector; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; public class TypeWars extends TeamGame { - private ArrayList _activeMinions; - private ArrayList _deadMinions; - private ArrayList _finishedMinions; + private List _activeMinions; + private List _deadMinions; + private List _finishedMinions; - private HashMap _moneyMap; + private Map _moneyMap; private long _lastSpawnedRed; private long _timeToSpawnRed; @@ -84,19 +87,19 @@ public class TypeWars extends TeamGame private long _lastSpawnedBlue; private long _timeToSpawnBlue; - private ArrayList _pendingNukes; + private List _pendingNukes; - private HashMap> _lineGrowth; - private HashMap> _lineShorten; - private HashMap> _minionSpawns; + private Map> _lineGrowth; + private Map> _lineShorten; + private Map> _minionSpawns; - private HashMap> _giantAttackZones; - private HashMap _giants; - private HashMap _giantLocs; - private HashMap _minionsSpawned; - private HashMap _giantsAttacked; + private Map> _giantAttackZones; + private Map _giants; + private Map _giantLocs; + private Map _minionsSpawned; + private Map _giantsAttacked; - private HashSet _playerTitles; + private Set _playerTitles; public TypeWars(ArcadeManager manager) { @@ -183,6 +186,39 @@ public class TypeWars extends TeamGame .giveTeamArmor() .giveHotbarItem() .register(this); + + registerDebugCommand(new DebugCommand("money", "mineplex.arcade.type.money", "dev") + { + @Override + public void Execute(Player caller, String[] args) + { + _moneyMap.put(caller, 1000); + UtilPlayer.message(caller, F.main("Money", "You got some Money")); + } + }); + registerDebugCommand(new DebugCommand("boss", "mineplex.arcade.type.boss", "dev") + { + @Override + public void Execute(Player caller, String[] args) + { + if (!IsPlaying(caller)) + return; + + GameTeam teams = GetTeam(caller); + for (GameTeam team : GetTeamList()) + { + if (team == teams) + continue; + + int rdm = UtilMath.r(_minionSpawns.get(teams).size()); + TypeWars.this.CreatureAllowOverride = true; + Minion minion = new Minion(Manager, _minionSpawns.get(teams).get(rdm), _minionSpawns.get(team).get(rdm), teams, caller, true, MinionSize.BOSS.getRandomType(), rdm); + _activeMinions.add(minion); + TypeWars.this.CreatureAllowOverride = false; + UtilPlayer.message(caller, F.main("Boss", "You have spawned a Boss")); + } + } + }); } @EventHandler @@ -195,15 +231,15 @@ public class TypeWars extends TeamGame _playerTitles.add(player); } - if(event.GetState() == GameState.Prepare) + if (event.GetState() == GameState.Prepare) { initSpawns(); prepareGiants(); } - if(event.GetState() != GameState.Live) + if (event.GetState() != GameState.Live) return; - for(GameTeam team : GetTeamList()) + for (GameTeam team : GetTeamList()) { _lineGrowth.put(team, new ArrayList()); _lineShorten.put(team, new ArrayList()); @@ -232,10 +268,10 @@ public class TypeWars extends TeamGame blue.add(0, 2, 0); int i = 0; - for(GameTeam team : GetTeamList()) + for (GameTeam team : GetTeamList()) { Location loc = red; - if(i == 1) + if (i == 1) loc = blue; this.CreatureAllowOverride = true; @@ -276,13 +312,13 @@ public class TypeWars extends TeamGame _giants.put(team, giant); i++; } - for(GameTeam team : GetTeamList()) + for (GameTeam team : GetTeamList()) { - for(GameTeam otherTeam : GetTeamList()) + for (GameTeam otherTeam : GetTeamList()) { - if(team != otherTeam) + if (team != otherTeam) { - for(Location location : _giantAttackZones.get(team)) + for (Location location : _giantAttackZones.get(team)) { Location giantLoc = _giants.get(otherTeam).getLocation(); location.setYaw(UtilAlg.GetYaw(new Vector(giantLoc.getBlockX() - location.getBlockX(), giantLoc.getBlockY() - location.getBlockY(), giantLoc.getBlockZ() - location.getBlockZ()))); @@ -295,13 +331,13 @@ public class TypeWars extends TeamGame @EventHandler public void fixGiants(UpdateEvent event) { - if(event.getType() != UpdateType.TICK) + if (event.getType() != UpdateType.TICK) return; - if(GetState() != GameState.Prepare) + if (GetState() != GameState.Prepare) return; - for(Giant giant : _giantLocs.keySet()) + for (Giant giant : _giantLocs.keySet()) { giant.teleport(_giantLocs.get(giant)); } @@ -310,13 +346,13 @@ public class TypeWars extends TeamGame @EventHandler public void Players(UpdateEvent event) { - if(GetState() != GameState.Live && GetState() != GameState.End) + if (GetState() != GameState.Live && GetState() != GameState.End) return; - if(event.getType() != UpdateType.TICK) + if (event.getType() != UpdateType.TICK) return; - for(Player player : GetPlayers(true)) + for (Player player : GetPlayers(true)) { Recharge.Instance.Reset(player, "Chat Message"); @@ -324,9 +360,9 @@ public class TypeWars extends TeamGame player.setFlying(true); UtilTextBottom.display(C.cGreen + "You have $" + _moneyMap.get(player), player); - for(Minion minion : _activeMinions) + for (Minion minion : _activeMinions) { - if(UtilMath.offset(minion.getEntity().getLocation(), player.getLocation()) < 1) + if (UtilMath.offset(minion.getEntity().getLocation(), player.getLocation()) < 1) { UtilAction.velocity(player, UtilAlg.getTrajectory(minion.getEntity().getLocation(), player.getLocation()), 1, true, 1, 1, 1, true); } @@ -404,7 +440,7 @@ public class TypeWars extends TeamGame targetRed = locations.get(locations.size() - 3); targetBlue = locations.get(3); - if(event.getTutorial().getTeam() == GetTeamList().get(1)) + if (event.getTutorial().getTeam() == GetTeamList().get(1)) { event.getTutorial().getPhase(1).setLocation(_tutorialLocationRed); event.getTutorial().getPhase(1).setTarget(targetRed); @@ -424,12 +460,12 @@ public class TypeWars extends TeamGame @Override public void run() { - for(Player player : event.getTutorial().getPlayers().keySet()) + for (Player player : event.getTutorial().getPlayers().keySet()) { Location location = player.getLocation().clone(); - for(GameTeam team : GetTeamList()) + for (GameTeam team : GetTeamList()) { - if(team != event.getTutorial().getTeam()) + if (team != event.getTutorial().getTeam()) { location.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(location, _giants.get(team).getLocation()))); location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _giants.get(team).getLocation()))); @@ -451,10 +487,10 @@ public class TypeWars extends TeamGame @EventHandler public void tutorialFrames(GameStateChangeEvent event) { - if(event.GetState() != GameState.Live) + if (event.GetState() != GameState.Live) return; - for(Giant giant : _giants.values()) + for (Giant giant : _giants.values()) { giant.setHealth(100); } @@ -464,75 +500,30 @@ public class TypeWars extends TeamGame _finishedMinions.clear(); } - @EventHandler - public void testCommands(PlayerCommandPreprocessEvent event) - { - if(GetState() != GameState.Live) - return; - - if(event.getMessage().contains("/Money")) - { - - if(!Manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.DEVELOPER, true)) - return; - - _moneyMap.put(event.getPlayer(), 1000); - UtilPlayer.message(event.getPlayer(), F.main("Money", "You got some Money")); - event.setCancelled(true); - return; - } - - if(event.getMessage().contains("/Boss")) - { - if(!Manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.DEVELOPER, true)) - return; - - if(!IsPlaying(event.getPlayer())) - return; - - - event.setCancelled(true); - GameTeam teams = GetTeam(event.getPlayer()); - for(GameTeam team : GetTeamList()) - { - if(team == teams) - continue; - - int rdm = UtilMath.r(_minionSpawns.get(teams).size()); - this.CreatureAllowOverride = true; - Minion minion = new Minion(Manager, _minionSpawns.get(teams).get(rdm), _minionSpawns.get(team).get(rdm), teams, event.getPlayer(), true, MinionSize.BOSS.getRandomType(), rdm); - _activeMinions.add(minion); - this.CreatureAllowOverride = false; - UtilPlayer.message(event.getPlayer(), F.main("Boss", "You have spawned a Boss")); - } - } - - } - @EventHandler public void interact(PlayerInteractEvent event) { - if(event.getItem() == null) + if (event.getItem() == null) return; - if(GetState() != GameState.Live) + if (GetState() != GameState.Live) return; - for(MinionSize type : MinionSize.values()) + for (MinionSize type : MinionSize.values()) { - if(type.getDisplayItem().getType() == event.getItem().getType() && type.getDisplayItem().getDurability() == event.getItem().getDurability()) + if (type.getDisplayItem().getType() == event.getItem().getType() && type.getDisplayItem().getDurability() == event.getItem().getDurability()) { - if(type.getCost() > _moneyMap.get(event.getPlayer())) + if (type.getCost() > _moneyMap.get(event.getPlayer())) { UtilTextMiddle.display("", ChatColor.GRAY + "You dont have enough money to spawn this Minion.", event.getPlayer()); return; } GameTeam teams = GetTeam(event.getPlayer()); - for(GameTeam team : GetTeamList()) + for (GameTeam team : GetTeamList()) { - if(teams != team) + if (teams != team) { - if(getMinions(teams).size() >= 60) + if (getMinions(teams).size() >= 60) { UtilTextMiddle.display("", ChatColor.GRAY + "Your Team can't have more than 60 Minions", 5, 30, 5, event.getPlayer()); return; @@ -556,7 +547,7 @@ public class TypeWars extends TeamGame @EventHandler public void mobSpawn(EntitySpawnEvent event) { - if(event.getEntityType() == EntityType.CREEPER) + if (event.getEntityType() == EntityType.CREEPER) { event.setCancelled(true); } @@ -571,15 +562,15 @@ public class TypeWars extends TeamGame @EventHandler public void spawnMinions(UpdateEvent event) { - if(event.getType() != UpdateType.TICK) + if (event.getType() != UpdateType.TICK) return; - if(!IsLive()) + if (!IsLive()) return; - if(UtilTime.elapsed(_lastSpawnedRed, _timeToSpawnRed)) + if (UtilTime.elapsed(_lastSpawnedRed, _timeToSpawnRed)) { - if(getMinions(GetTeamList().get(0)).size() < 60) + if (getMinions(GetTeamList().get(0)).size() < 60) { _lastSpawnedRed = System.currentTimeMillis(); @@ -587,7 +578,7 @@ public class TypeWars extends TeamGame int rdm = UtilMath.r(_minionSpawns.get(GetTeamList().get(0)).size()); Minion minion = null; - if(_minionsSpawned.get(GetTeamList().get(0)) >= 100) + if (_minionsSpawned.get(GetTeamList().get(0)) >= 100) { _minionsSpawned.put(GetTeamList().get(0), 0); minion = new Minion(Manager, _minionSpawns.get(GetTeamList().get(0)).get(rdm), _minionSpawns.get(GetTeamList().get(1)).get(rdm), GetTeamList().get(0), null, true, MinionSize.BOSS.getRandomType(), rdm); @@ -601,21 +592,21 @@ public class TypeWars extends TeamGame this.CreatureAllowOverride = false; - if(_timeToSpawnRed > 5000 / (GetTeamList().get(1).GetPlayers(true).size() > 0 ? GetTeamList().get(1).GetPlayers(true).size() : 1)) + if (_timeToSpawnRed > 5000 / (GetTeamList().get(1).GetPlayers(true).size() > 0 ? GetTeamList().get(1).GetPlayers(true).size() : 1)) _timeToSpawnRed = _timeToSpawnRed - 75; } } - if(UtilTime.elapsed(_lastSpawnedBlue, _timeToSpawnBlue)) + if (UtilTime.elapsed(_lastSpawnedBlue, _timeToSpawnBlue)) { - if(getMinions(GetTeamList().get(1)).size() < 60) + if (getMinions(GetTeamList().get(1)).size() < 60) { _lastSpawnedBlue = System.currentTimeMillis(); this.CreatureAllowOverride = true; int rdm = UtilMath.r(_minionSpawns.get(GetTeamList().get(1)).size()); Minion minion = null; - if(_minionsSpawned.get(GetTeamList().get(1)) >= 100) + if (_minionsSpawned.get(GetTeamList().get(1)) >= 100) { _minionsSpawned.put(GetTeamList().get(1), 0); minion = new Minion(Manager, _minionSpawns.get(GetTeamList().get(1)).get(rdm), _minionSpawns.get(GetTeamList().get(0)).get(rdm), GetTeamList().get(1), null, true, MinionSize.BOSS.getRandomType(), rdm); @@ -628,7 +619,7 @@ public class TypeWars extends TeamGame _activeMinions.add(minion); this.CreatureAllowOverride = false; - if(_timeToSpawnBlue > 5000 / (GetTeamList().get(0).GetPlayers(true).size() > 0 ? GetTeamList().get(0).GetPlayers(true).size() : 1)) + if (_timeToSpawnBlue > 5000 / (GetTeamList().get(0).GetPlayers(true).size() > 0 ? GetTeamList().get(0).GetPlayers(true).size() : 1)) _timeToSpawnBlue = _timeToSpawnRed - 75; } @@ -638,10 +629,10 @@ public class TypeWars extends TeamGame @EventHandler public void updateMinions(UpdateEvent event) { - if(event.getType() != UpdateType.TICK) + if (event.getType() != UpdateType.TICK) return; - if(GetState() != GameState.Live && GetState() != GameState.Prepare) + if (GetState() != GameState.Live && GetState() != GameState.Prepare) return; Iterator minionIterator = _activeMinions.iterator(); @@ -650,26 +641,26 @@ public class TypeWars extends TeamGame { Minion minion = minionIterator.next(); - if(minion.isSpawned()) + if (minion.isSpawned()) { - if(minion.isMoving()) + if (minion.isMoving()) { - if(!UtilEnt.CreatureMoveFast(minion.getEntity(), minion.getTarget(), minion.getWalkSpeed())) + if (!UtilEnt.CreatureMoveFast(minion.getEntity(), minion.getTarget(), minion.getWalkSpeed())) { GameTeam enemy = null; - for(GameTeam teams : GetTeamList()) + for (GameTeam teams : GetTeamList()) { - if(teams != minion.getTeam()) + if (teams != minion.getTeam()) enemy = teams; } Location nextTarget = _giantAttackZones.get(enemy).get(minion.getSpawnID()); - if(!nextTarget.equals(minion.getTarget())) + if (!nextTarget.equals(minion.getTarget())) { minion.setTarget(nextTarget); } else { - if(!_finishedMinions.contains(minion)) + if (!_finishedMinions.contains(minion)) _finishedMinions.add(minion); } } @@ -683,15 +674,15 @@ public class TypeWars extends TeamGame @EventHandler public void checkDeadMinions(UpdateEvent event) { - if(GetState() != GameState.Live && GetState() != GameState.End) + if (GetState() != GameState.Live && GetState() != GameState.End) return; - if(event.getType() != UpdateType.FASTER) + if (event.getType() != UpdateType.FASTER) return; - for(Minion minion : _deadMinions) + for (Minion minion : _deadMinions) { - if(!minion.getEntity().isDead()) + if (!minion.getEntity().isDead()) minion.despawn(null, false); } } @@ -699,24 +690,24 @@ public class TypeWars extends TeamGame @EventHandler public void giants(UpdateEvent event) { - if(GetState() != GameState.Live) + if (GetState() != GameState.Live) return; - if(event.getType() != UpdateType.SLOW) + if (event.getType() != UpdateType.SLOW) return; - for(GameTeam team : _giants.keySet()) + for (GameTeam team : _giants.keySet()) { ArrayList minions = new ArrayList<>(); - for(Minion minion : _finishedMinions) + for (Minion minion : _finishedMinions) { - if(!minion.getEntity().isDead()) + if (!minion.getEntity().isDead()) { - if(minion.getTeam() != team) + if (minion.getTeam() != team) minions.add(minion); } } - if(minions.isEmpty()) + if (minions.isEmpty()) continue; Giant giant = _giants.get(team); @@ -724,7 +715,7 @@ public class TypeWars extends TeamGame Location loc = giant.getLocation().clone(); loc.setYaw(UtilAlg.GetYaw(new Vector(minion.getEntity().getLocation().getBlockX() - loc.getBlockX(), minion.getEntity().getLocation().getBlockY() - loc.getBlockY(), minion.getEntity().getLocation().getBlockZ() - loc.getBlockZ()))); giant.teleport(loc); - for(Player player : team.GetPlayers(false)) + for (Player player : team.GetPlayers(false)) { player.playSound(giant.getLocation(), Sound.ZOMBIE_WOODBREAK, 100, 1); player.playSound(giant.getLocation(), Sound.ZOMBIE_IDLE, 1, 1); @@ -733,7 +724,7 @@ public class TypeWars extends TeamGame UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, minion.getEntity().getLocation(), 0, 0, 0, 1, 1, ViewDist.LONG, UtilServer.getPlayers()); minion.despawn(null, true); - if(!minion.hasLives()) + if (!minion.hasLives()) _deadMinions.add(minion); } } @@ -741,44 +732,44 @@ public class TypeWars extends TeamGame @EventHandler public void minionAttack(UpdateEvent event) { - if(GetState() != GameState.Live && GetState() != GameState.Prepare) + if (GetState() != GameState.Live && GetState() != GameState.Prepare) return; - if(event.getType() != UpdateType.SEC) + if (event.getType() != UpdateType.SEC) return; - for(GameTeam team : _giants.keySet()) + for (GameTeam team : _giants.keySet()) { int damage = 0; - for(Minion minion : _finishedMinions) + for (Minion minion : _finishedMinions) { - if(minion.getTeam() == team) + if (minion.getTeam() == team) continue; - if(minion.getEntity().isDead()) + if (minion.getEntity().isDead()) continue; damage++; } - if(damage == 0) + if (damage == 0) continue; - for(GameTeam otherTeam : GetTeamList()) + for (GameTeam otherTeam : GetTeamList()) { - if(team != otherTeam) + if (team != otherTeam) { _giants.get(team).getWorld().playSound(_giants.get(team).getEyeLocation(), Sound.ZOMBIE_HURT, 100, 1); _giants.get(team).damage(damage); } } - if(!_giantsAttacked.containsKey(team) || UtilTime.elapsed(_giantsAttacked.get(team), 10000)) + if (!_giantsAttacked.containsKey(team) || UtilTime.elapsed(_giantsAttacked.get(team), 10000)) { _giantsAttacked.put(team, System.currentTimeMillis()); - for(Player player : GetPlayers(true)) + for (Player player : GetPlayers(true)) { - if(GetTeam(player) == team) + if (GetTeam(player) == team) { - if(IsLive()) + if (IsLive()) { UtilTextMiddle.display("", "Your giant is under Attack!", 0, 30, 9, player); } @@ -791,7 +782,7 @@ public class TypeWars extends TeamGame @EventHandler public void minionAnimation(UpdateEvent event) { - if(event.getType() != UpdateType.TICK) + if (event.getType() != UpdateType.TICK) return; Iterator minionIterator = _activeMinions.iterator(); @@ -804,7 +795,7 @@ public class TypeWars extends TeamGame public double getScore(GameTeam team) { - if(_giants.get(team).isDead()) + if (_giants.get(team).isDead()) { return 0; } @@ -814,23 +805,23 @@ public class TypeWars extends TeamGame @EventHandler public void chatCheck(AsyncPlayerChatEvent event) { - if(!IsLive()) + if (!IsLive()) return; - if(!GetPlayers(true).contains(event.getPlayer())) + if (!GetPlayers(true).contains(event.getPlayer())) return; - if(event.getMessage().split(" ").length == 1) + if (event.getMessage().split(" ").length == 1) event.setCancelled(true); } @EventHandler public void chatCheck(PlayerChatEvent event) { - if(!IsLive()) + if (!IsLive()) return; - if(!GetPlayers(true).contains(event.getPlayer())) + if (!GetPlayers(true).contains(event.getPlayer())) return; try @@ -839,13 +830,13 @@ public class TypeWars extends TeamGame Bukkit.getPluginManager().callEvent(new TypeAttemptEvent(event.getPlayer(), event.getMessage(), minion != null)); - if(minion == null) + if (minion == null) return; MinionKillEvent minionEvent = new MinionKillEvent(event.getPlayer(), minion, KillType.TYPED); Bukkit.getPluginManager().callEvent(minionEvent); - if(minionEvent.isCancelled()) + if (minionEvent.isCancelled()) return; killMinion(minion, event.getPlayer()); @@ -853,7 +844,7 @@ public class TypeWars extends TeamGame int spawned = _minionsSpawned.get(GetTeam(event.getPlayer())); _minionsSpawned.put(GetTeam(event.getPlayer()), spawned + 1); - if(_playerTitles.contains(event.getPlayer())) + if (_playerTitles.contains(event.getPlayer())) { _playerTitles.remove(event.getPlayer()); UtilTextMiddle.clear(event.getPlayer()); @@ -872,7 +863,7 @@ public class TypeWars extends TeamGame public void killMinion(Minion minion, Player player) { - if(!minion.hasLives()) + if (!minion.hasLives()) { _activeMinions.remove(minion); _deadMinions.add(minion); @@ -882,32 +873,32 @@ public class TypeWars extends TeamGame private Minion getFarestMininion(Player player, String msg) { - for(Minion minion : _activeMinions) + for (Minion minion : _activeMinions) { - if(msg != null && !minion.getName().equalsIgnoreCase(msg)) + if (msg != null && !minion.getName().equalsIgnoreCase(msg)) continue; - if(GetTeam(player) == minion.getTeam()) + if (GetTeam(player) == minion.getTeam()) continue; boolean found = true; - for(Minion otherMinion : _activeMinions) + for (Minion otherMinion : _activeMinions) { - if(minion == otherMinion) + if (minion == otherMinion) continue; - if(msg != null && !otherMinion.getName().equalsIgnoreCase(msg)) + if (msg != null && !otherMinion.getName().equalsIgnoreCase(msg)) continue; - if(GetTeam(player) == otherMinion.getTeam()) + if (GetTeam(player) == otherMinion.getTeam()) continue; - if(UtilMath.offset(minion.getEntity().getLocation(), minion.getTarget()) > UtilMath.offset(otherMinion.getEntity().getLocation(), otherMinion.getTarget())) + if (UtilMath.offset(minion.getEntity().getLocation(), minion.getTarget()) > UtilMath.offset(otherMinion.getEntity().getLocation(), otherMinion.getTarget())) found = false; } - if(found) + if (found) return minion; else continue; @@ -923,14 +914,14 @@ public class TypeWars extends TeamGame ArrayList winners = new ArrayList<>(); - for(GameTeam team : GetTeamList()) + for (GameTeam team : GetTeamList()) { - for(GameTeam otherTeam : GetTeamList()) + for (GameTeam otherTeam : GetTeamList()) { - if(team == otherTeam) + if (team == otherTeam) continue; - if(getScore(team) <= 0) + if (getScore(team) <= 0) { _giants.get(team).damage(1); winners.add(otherTeam); @@ -938,7 +929,7 @@ public class TypeWars extends TeamGame } } - if(winners.isEmpty()) + if (winners.isEmpty()) return; GameTeam winner = winners.get(UtilMath.r(winners.size())); @@ -968,9 +959,9 @@ public class TypeWars extends TeamGame AddGems(player, 10, "Participation", false, false); AddGems(player, getPlayerKills(player), getPlayerKills(player) + " Minions killed", false, true); - for(MinionSize size : MinionSize.values()) + for (MinionSize size : MinionSize.values()) { - if(size == MinionSize.BOSS || size == MinionSize.FREAK || size == MinionSize.EASY) + if (size == MinionSize.BOSS || size == MinionSize.FREAK || size == MinionSize.EASY) continue; AddGems(player, getSpawnedMinions(player, size) * size.getGemReward(), getSpawnedMinions(player, size) + " " + size.getDisplayName() + " Minions spawned", false, true); @@ -983,13 +974,13 @@ public class TypeWars extends TeamGame Scoreboard.writeNewLine(); - for(GameTeam team : GetTeamList()) + for (GameTeam team : GetTeamList()) { Scoreboard.write(team.GetColor() + C.Bold + team.GetName() + " Team"); Scoreboard.write(team.GetColor() + "Health: " + Math.round(getScore(team))); Scoreboard.write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60"); String wpm = String.valueOf((double) getTeamKills(team) / ((double) (System.currentTimeMillis() - GetStateTime())/60000)); - if(wpm.length() > 4) + if (wpm.length() > 4) wpm = wpm.substring(0, 4); Scoreboard.write(team.GetColor() + "WPM: " + wpm); @@ -1006,7 +997,7 @@ public class TypeWars extends TeamGame @EventHandler public void preventFire(UpdateEvent event) { - if(event.getType() != UpdateType.TICK) + if (event.getType() != UpdateType.TICK) return; Iterator minionIterator = _activeMinions.iterator(); @@ -1019,28 +1010,28 @@ public class TypeWars extends TeamGame @EventHandler public void updateHotbarItems(UpdateEvent event) { - if(!IsLive()) + if (!IsLive()) return; if (event.getType() != UpdateType.FASTEST) return; - for(Player player : GetPlayers(true)) + for (Player player : GetPlayers(true)) { int e = 0; - for(Spell spell : ((KitTypeWarsBase) GetKit(player)).getSpells()) + for (Spell spell : ((KitTypeWarsBase) GetKit(player)).getSpells()) { - if(spell instanceof SpellKillEverything) + if (spell instanceof SpellKillEverything) { - if(spell.hasUsed(player)) + if (spell.hasUsed(player)) { player.getInventory().setItem(e, new ItemStack(Material.AIR)); continue; } } - if(_moneyMap.get(player) >= spell.getCost()) + if (_moneyMap.get(player) >= spell.getCost()) { - if(spell.getCost() > 0) + if (spell.getCost() > 0) player.getInventory().setItem(e, ItemStackFactory.Instance.CreateStack(spell.getMaterial(), (byte) 0, Math.round(_moneyMap.get(player)/spell.getCost()), C.cGreen + "Activate " + spell.getName() + " Cost: " + spell.getCost())); else player.getInventory().setItem(e, ItemStackFactory.Instance.CreateStack(spell.getMaterial(), (byte) 0, 1, C.cGreen + "Activate " + spell.getName() + " Cost: " + spell.getCost())); @@ -1053,12 +1044,12 @@ public class TypeWars extends TeamGame } int i = 4; - for(MinionSize type : MinionSize.values()) + for (MinionSize type : MinionSize.values()) { - if(type == MinionSize.BOSS || type == MinionSize.FREAK) + if (type == MinionSize.BOSS || type == MinionSize.FREAK) continue; - if(_moneyMap.get(player) >= type.getCost()) + if (_moneyMap.get(player) >= type.getCost()) { player.getInventory().setItem(i, ItemStackFactory.Instance.CreateStack(type.getDisplayItem().getType(), (byte) 0, Math.round(_moneyMap.get(player)/type.getCost()), (short) type.getDisplayItem().getDurability(), C.cGreen + "Spawn " + type.getDisplayName() + " Minion Cost: " + type.getCost(), new String[]{})); } @@ -1076,12 +1067,12 @@ public class TypeWars extends TeamGame @EventHandler public void lines(UpdateEvent event) { - if(event.getType() != UpdateType.FASTEST) + if (event.getType() != UpdateType.FASTEST) return; - for(ArrayList locs : _lineGrowth.values()) + for (List locs : _lineGrowth.values()) { - for(Location loc : locs) + for (Location loc : locs) { double radius = _animationTicks / 20D; int particleAmount = _animationTicks / 2; @@ -1096,9 +1087,9 @@ public class TypeWars extends TeamGame } } } - for(ArrayList locs : _lineShorten.values()) + for (List locs : _lineShorten.values()) { - for(Location loc : locs) + for (Location loc : locs) { double radius = _animationTicks / 20D; int particleAmount = _animationTicks / 2; @@ -1115,7 +1106,7 @@ public class TypeWars extends TeamGame } _animationTicks++; - if(_animationTicks > 15) + if (_animationTicks > 15) _animationTicks = 0; Iterator minionIterator = _activeMinions.iterator(); @@ -1123,40 +1114,40 @@ public class TypeWars extends TeamGame while(minionIterator.hasNext()) { Minion minion = minionIterator.next(); - for(GameTeam team : _lineGrowth.keySet()) + for (GameTeam team : _lineGrowth.keySet()) { - for(Location loc : _lineGrowth.get(team)) + for (Location loc : _lineGrowth.get(team)) { - if(minion.getEntity().getLocation().getBlockX() != loc.getBlockX()) + if (minion.getEntity().getLocation().getBlockX() != loc.getBlockX()) continue; - if(minion.getEntity().getLocation().getBlockZ() != loc.getBlockZ()) + if (minion.getEntity().getLocation().getBlockZ() != loc.getBlockZ()) continue; - if(!minion.isNameChangeable()) + if (!minion.isNameChangeable()) continue; - if(team != minion.getTeam()) + if (team != minion.getTeam()) continue; int oldname = minion.getName().length() + 2; minion.changeRandomName(oldname, oldname, false); } } - for(GameTeam team : _lineShorten.keySet()) + for (GameTeam team : _lineShorten.keySet()) { - for(Location loc : _lineShorten.get(team)) + for (Location loc : _lineShorten.get(team)) { - if(minion.getEntity().getLocation().getBlockX() != loc.getBlockX()) + if (minion.getEntity().getLocation().getBlockX() != loc.getBlockX()) continue; - if(minion.getEntity().getLocation().getBlockZ() != loc.getBlockZ()) + if (minion.getEntity().getLocation().getBlockZ() != loc.getBlockZ()) continue; - if(!minion.isNameChangeable()) + if (!minion.isNameChangeable()) continue; - if(team == minion.getTeam()) + if (team == minion.getTeam()) continue; int oldname = minion.getName().length() - 2; @@ -1176,20 +1167,20 @@ public class TypeWars extends TeamGame if (GetTeamList().isEmpty()) return; - if(!IsLive()) + if (!IsLive()) return; Scoreboard.reset(); Scoreboard.writeNewLine(); - for(GameTeam team : GetTeamList()) + for (GameTeam team : GetTeamList()) { Scoreboard.write(team.GetColor() + C.Bold + team.GetName() + " Team"); Scoreboard.write(team.GetColor() + "Health: " + Math.round(getScore(team))); Scoreboard.write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60"); String wpm = String.valueOf((double) getTeamKills(team) / ((double) (System.currentTimeMillis() - GetStateTime())/60000)); - if(wpm.length() > 4) + if (wpm.length() > 4) wpm = wpm.substring(0, 4); Scoreboard.write(team.GetColor() + "WPM: " + wpm); @@ -1206,7 +1197,7 @@ public class TypeWars extends TeamGame while(minionIterator.hasNext()) { Minion minion = minionIterator.next(); - if(minion.getTeam() == team) + if (minion.getTeam() == team) minionList.add(minion); } return minionList; @@ -1217,47 +1208,47 @@ public class TypeWars extends TeamGame @EventHandler public void nuke(UpdateEvent event) { - if(event.getType() != UpdateType.TICK) + if (event.getType() != UpdateType.TICK) return; - if(_pendingNukes.isEmpty()) + if (_pendingNukes.isEmpty()) return; Player player = _pendingNukes.get(0); GameTeam team = GetTeam(player); GameTeam otherTeam = null; - for(GameTeam teams : GetTeamList()) + for (GameTeam teams : GetTeamList()) { - if(teams != team) + if (teams != team) { otherTeam = teams; } } ArrayList testLocs = UtilShapes.getLinesDistancedPoints(_minionSpawns.get(team).get(0), _minionSpawns.get(otherTeam).get(0), 1); - if(_nukeFrame >= testLocs.size()) + if (_nukeFrame >= testLocs.size()) { _nukeFrame = 0; _pendingNukes.remove(0); return; } - if(_nukeFrame < 25) + if (_nukeFrame < 25) { _giants.get(team).getWorld().playSound(_giants.get(team).getLocation(), Sound.ZOMBIE_IDLE, 1, 1); } boolean cansee = true; int i = 0; - for(Location loc : _minionSpawns.get(team)) + for (Location loc : _minionSpawns.get(team)) { cansee = !cansee; ArrayList locations = UtilShapes.getLinesDistancedPoints(loc, _minionSpawns.get(otherTeam).get(i), 1); Location location = locations.get(_nukeFrame); - if(cansee) + if (cansee) { UtilParticle.PlayParticle(UtilParticle.ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); - for(Player players : GetPlayers(false)) + for (Player players : GetPlayers(false)) players.playSound(location, Sound.EXPLODE, 1, 1); } @@ -1265,14 +1256,14 @@ public class TypeWars extends TeamGame while(minionIterator.hasNext()) { Minion minion = minionIterator.next(); - if(minion.getTeam() == team) + if (minion.getTeam() == team) continue; - if(UtilMath.offset(location, minion.getEntity().getLocation()) > 1) + if (UtilMath.offset(location, minion.getEntity().getLocation()) > 1) continue; minion.despawn(player, true); - if(!minion.hasLives()) + if (!minion.hasLives()) { minionIterator.remove(); _deadMinions.add(minion); @@ -1282,14 +1273,14 @@ public class TypeWars extends TeamGame while(finishedMinionIterator.hasNext()) { Minion minion = finishedMinionIterator.next(); - if(minion.getTeam() == team) + if (minion.getTeam() == team) continue; - if(UtilMath.offset(location, minion.getEntity().getLocation()) > 3) + if (UtilMath.offset(location, minion.getEntity().getLocation()) > 3) continue; minion.despawn(player, true); - if(!minion.hasLives()) + if (!minion.hasLives()) { finishedMinionIterator.remove(); _deadMinions.add(minion); @@ -1303,11 +1294,11 @@ public class TypeWars extends TeamGame public int getPlayerKills(Player player) { int kills = 0; - for(Minion minion : _deadMinions) + for (Minion minion : _deadMinions) { - if(minion.getKiller() != null) + if (minion.getKiller() != null) { - if(minion.getKiller().getName().contentEquals(player.getName())) + if (minion.getKiller().getName().contentEquals(player.getName())) { kills++; } @@ -1319,7 +1310,7 @@ public class TypeWars extends TeamGame public int getTeamKills(GameTeam team) { int kills = 0; - for(Player player : team.GetPlayers(true)) + for (Player player : team.GetPlayers(true)) { kills = kills + getPlayerKills(player); } @@ -1329,46 +1320,46 @@ public class TypeWars extends TeamGame public int getSpawnedMinions(Player player, MinionSize size) { int spawns = 0; - for(Minion minion : _deadMinions) + for (Minion minion : _deadMinions) { - if(minion.getType().getSize() != size) + if (minion.getType().getSize() != size) continue; - if(minion.getPlayer() == null) + if (minion.getPlayer() == null) continue; - if(minion.getPlayer().getName().contentEquals(player.getName())) + if (minion.getPlayer().getName().contentEquals(player.getName())) spawns++; } return spawns; } - public HashMap getMoneyMap() + public Map getMoneyMap() { return _moneyMap; } - public ArrayList getActiveMinions() + public List getActiveMinions() { return _activeMinions; } - public ArrayList getDeadMinions() + public List getDeadMinions() { return _deadMinions; } - public HashMap> getMinionSpawns() + public Map> getMinionSpawns() { return _minionSpawns; } - public HashMap> getLineGrowth() + public Map> getLineGrowth() { return _lineGrowth; } - public HashMap> getLineShorten() + public Map> getLineShorten() { return _lineShorten; } @@ -1377,4 +1368,4 @@ public class TypeWars extends TeamGame { _pendingNukes.add(player); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellGrowthLiner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellGrowthLiner.java index 1ba8efa83..501c2308e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellGrowthLiner.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellGrowthLiner.java @@ -2,19 +2,18 @@ package nautilus.game.arcade.game.games.typewars.spells; import java.util.ArrayList; import java.util.Iterator; - -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilParticle.ParticleType; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.typewars.Spell; +import java.util.List; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; +import mineplex.core.common.util.UtilParticle.ParticleType; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Spell; + public class SpellGrowthLiner extends Spell { - public SpellGrowthLiner(ArcadeManager manager) { super(manager, "Growth Line", 7, Material.STICK, 2000L, 10, 0, false); @@ -29,7 +28,7 @@ public class SpellGrowthLiner extends Spell @Override public boolean execute(final Player player, Location location) { - final ArrayList line = getLine(player, location); + final List line = getLine(player, location); for(Location loc : line) { getTypeWars().getLineGrowth().get(getManager().GetGame().GetTeam(player)).add(loc); @@ -49,10 +48,10 @@ public class SpellGrowthLiner extends Spell return true; } - private ArrayList getLine(Player player, Location location) + private List getLine(Player player, Location location) { - ArrayList line = new ArrayList<>(); - ArrayList spawns = getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player)); + List line = new ArrayList<>(); + List spawns = getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player)); for(Location loc : spawns) { if(loc.getBlockX() == location.getBlockX() || loc.getBlockX() == location.getBlockX() - 1 || loc.getBlockX() == location.getBlockX() + 1) @@ -131,5 +130,4 @@ public class SpellGrowthLiner extends Spell } return line; } - -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellShrinkLiner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellShrinkLiner.java index 4bf3471e8..f0982f17e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellShrinkLiner.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellShrinkLiner.java @@ -2,18 +2,18 @@ package nautilus.game.arcade.game.games.typewars.spells; import java.util.ArrayList; import java.util.Iterator; - -import mineplex.core.common.util.UtilParticle.ParticleType; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.typewars.Spell; +import java.util.List; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; +import mineplex.core.common.util.UtilParticle.ParticleType; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Spell; + public class SpellShrinkLiner extends Spell { - public SpellShrinkLiner(ArcadeManager manager) { super(manager, "Shrinking Line", 7, Material.BLAZE_ROD, 2000L, 10, 0, false); @@ -28,7 +28,7 @@ public class SpellShrinkLiner extends Spell @Override public boolean execute(final Player player, Location location) { - final ArrayList line = getLine(player, location); + final List line = getLine(player, location); for(Location loc : line) { getTypeWars().getLineShorten().get(getManager().GetGame().GetTeam(player)).add(loc); @@ -48,10 +48,10 @@ public class SpellShrinkLiner extends Spell return true; } - private ArrayList getLine(Player player, Location location) + private List getLine(Player player, Location location) { - ArrayList line = new ArrayList<>(); - ArrayList spawns = getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player)); + List line = new ArrayList<>(); + List spawns = getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player)); for(Location loc : spawns) { if(loc.getBlockX() == location.getBlockX() || loc.getBlockX() == location.getBlockX() - 1 || loc.getBlockX() == location.getBlockX() + 1) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index 8a26603b4..dbafb1179 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -66,7 +66,6 @@ import org.spigotmc.ActivationRange; import mineplex.core.boosters.event.BoosterItemGiveEvent; import mineplex.core.common.Pair; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -90,7 +89,6 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatLog; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; - import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GamePrepareCountdownCommence; @@ -108,7 +106,6 @@ import nautilus.game.arcade.game.games.uhc.stat.CollectFoodStat; import nautilus.game.arcade.game.games.uhc.stat.HalfHeartHealStat; import nautilus.game.arcade.game.games.uhc.stat.HoeCraftingStat; import nautilus.game.arcade.game.games.uhc.stat.LuckyMinerStat; -import nautilus.game.arcade.game.modules.AntiExpOrbModule; import nautilus.game.arcade.game.modules.OreVeinEditorModule; import nautilus.game.arcade.game.modules.PlayerHeadModule; import nautilus.game.arcade.game.modules.RejoinModule; @@ -299,7 +296,7 @@ public abstract class UHC extends Game registerQuestTrackers(new TameQuestTracker(this)); - registerDebugCommand(new DebugCommand("startpvp", Rank.ADMIN) + registerDebugCommand(new DebugCommand("startpvp", "mineplex.arcade.uhc.startpvp", "admin") { @Override public void Execute(Player caller, String[] args) @@ -323,7 +320,7 @@ public abstract class UHC extends Game } }); - registerDebugCommand(new DebugCommand("worldinfo", Rank.ADMIN) + registerDebugCommand(new DebugCommand("worldinfo", "mineplex.arcade.uhc.worldinfo", "admin") { @Override public void Execute(Player caller, String[] args) @@ -445,7 +442,7 @@ public abstract class UHC extends Game return; } }); - registerDebugCommand(new DebugCommand("uhcgames", Rank.ADMIN) + registerDebugCommand(new DebugCommand("uhcgames", "mineplex.arcade.uhc.uhcgames", "admin") { @Override public void Execute(Player caller, String[] args) @@ -453,7 +450,7 @@ public abstract class UHC extends Game UtilPlayer.message(caller, F.main("Debug", "As of now, there have been " + _gamesRun + " games played")); } }); - registerDebugCommand(new DebugCommand("uhcgc", Rank.DEVELOPER) + registerDebugCommand(new DebugCommand("uhcgc", "mineplex.arcade.uhc.gc","dev") { @Override public void Execute(Player caller, String[] args) @@ -462,7 +459,7 @@ public abstract class UHC extends Game UtilPlayer.message(caller, F.main("Debug", "Cleaned up!")); } }); - registerDebugCommand(new DebugCommand("setcombatlogtimeout", Rank.DEVELOPER) + registerDebugCommand(new DebugCommand("setcombatlogtimeout", "mineplex.arcade.uhc.combatlogtimeout", "dev") { @Override public void Execute(Player caller, String[] args) @@ -493,7 +490,7 @@ public abstract class UHC extends Game } } }); - registerDebugCommand(new DebugCommand("dm", Rank.ADMIN) + registerDebugCommand(new DebugCommand("dm", "mineplex.arcade.uhc.deathmatch", "admin") { @Override @@ -505,7 +502,7 @@ public abstract class UHC extends Game UtilPlayer.message(caller, F.main("Debug", "Starting deathmatch")); } }); - registerDebugCommand(new DebugCommand("uhcentities", Rank.DEVELOPER) + registerDebugCommand(new DebugCommand("uhcentities", "mineplex.arcade.uhc.entities", "dev") { @Override @@ -526,7 +523,7 @@ public abstract class UHC extends Game } } }); - registerDebugCommand(new DebugCommand("uhcchunk", Rank.DEVELOPER) + registerDebugCommand(new DebugCommand("uhcchunk", "mineplex.arcade.uhc.chunk", "dev") { @Override @@ -577,7 +574,7 @@ public abstract class UHC extends Game } } }); - registerDebugCommand(new DebugCommand("uhcallchunks", Rank.DEVELOPER) + registerDebugCommand(new DebugCommand("uhcallchunks", "mineplex.arcade.uhc.callchunks", "dev") { @Override @@ -652,10 +649,6 @@ public abstract class UHC extends Game public void createSpawns(Callback callback) { - // Disable game commands - Rank lastGameCommandsRank = Manager.getGameCommandRank(); - Manager.setGameCommandMode(null); - // Wipe Spawns for (GameTeam team : GetTeamList()) { @@ -708,7 +701,6 @@ public abstract class UHC extends Game } else { - Manager.setGameCommandMode(lastGameCommandsRank); cancel(); callback.run(true); } @@ -766,7 +758,6 @@ public abstract class UHC extends Game if (currentTeamId.get() >= GetTeamList().size()) { - Manager.setGameCommandMode(lastGameCommandsRank); cancel(); callback.run(true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java index b5f05cd4c..49fbedc37 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java @@ -10,9 +10,56 @@ import java.util.List; import java.util.Map.Entry; import java.util.Random; -import mineplex.core.common.Rank; +import org.apache.commons.lang.IllegalClassException; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; +import org.bukkit.block.Chest; +import org.bukkit.block.DoubleChest; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftFireball; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Fireball; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.enchantment.EnchantItemEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.AnvilInventory; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.Recipe; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + import mineplex.core.common.util.C; -import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; @@ -56,56 +103,6 @@ import net.minecraft.server.v1_8_R3.EntityFireball; import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; -import org.apache.commons.lang.IllegalClassException; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.BlockState; -import org.bukkit.block.Chest; -import org.bukkit.block.DoubleChest; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftFireball; -import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Fireball; -import org.bukkit.entity.Item; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.enchantment.EnchantItemEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.inventory.PrepareItemCraftEvent; -import org.bukkit.event.player.PlayerChatEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerItemHeldEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.AnvilInventory; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.inventory.Recipe; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; - public class Wizards extends SoloGame { private ArrayList _droppedWandsBooks = new ArrayList(); @@ -1061,65 +1058,6 @@ public class Wizards extends SoloGame } } - @EventHandler - public void onChat(PlayerChatEvent event) - { - if (Manager.GetClients().Get(event.getPlayer()).GetRank().has(Rank.ADMIN)) - { - if (event.getMessage().equalsIgnoreCase("spells")) - { - Wizard wizard = getWizard(event.getPlayer()); - for (SpellType type : SpellType.values()) - { - if (wizard.getSpellLevel(type) < type.getMaxLevel()) - { - wizard.learnSpell(type); - } - } - - event.setCancelled(true); - event.getPlayer().sendMessage(F.main("Wizards", "All spells leveled up by one")); - } - - if (event.getMessage().equalsIgnoreCase("allspells")) - { - for (Player player : GetPlayers(true)) - { - Wizard wizard = getWizard(player); - for (SpellType type : SpellType.values()) - { - if (wizard.getSpellLevel(type) < type.getMaxLevel()) - { - wizard.learnSpell(type); - } - } - - player.sendMessage(F.main("Wizards", "All spells leveled up by one")); - } - - event.setCancelled(true); - } - - if (event.getMessage().equalsIgnoreCase("overtime")) - { - setGameLiveTime(System.currentTimeMillis() - (int) (9.95 * 60 * 1000)); - event.setCancelled(true); - } - - if (event.getMessage().equalsIgnoreCase("hit me")) - { - summonMeteor(event.getPlayer().getLocation(), _endgameSize); - event.setCancelled(true); - } - - if (event.getMessage().startsWith("setyield")) - { - _endgameSize = Float.parseFloat(event.getMessage().split(" ")[1]); - event.setCancelled(true); - } - } - } - @EventHandler public void onClick(InventoryClickEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/RejoinModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/RejoinModule.java index 66445b092..1d95ee594 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/RejoinModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/RejoinModule.java @@ -13,7 +13,6 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -21,14 +20,12 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; - import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.kit.Kit; public class RejoinModule extends Module { - private Set _data = new HashSet<>(); private int _rejoinTime = (int) TimeUnit.MINUTES.toMillis(2); @@ -36,9 +33,8 @@ public class RejoinModule extends Module @Override protected void setup() { - getGame().registerDebugCommand(new DebugCommand("rejoin", Rank.ADMIN) + getGame().registerDebugCommand(new DebugCommand("rejoin", "mineplex.arcade.rejoin.command", "admin") { - @Override public void Execute(Player caller, String[] args) { @@ -306,5 +302,4 @@ public class RejoinModule extends Module return _time; } } - -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java index c31d8d7cd..2e9dd58ae 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.gui.privateServer.page; import java.util.ArrayList; +import java.util.List; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -8,7 +9,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemBuilder; @@ -20,10 +21,10 @@ import nautilus.game.arcade.gui.privateServer.button.EditRotationButton; import nautilus.game.arcade.gui.privateServer.button.GameVotingButton; import nautilus.game.arcade.gui.privateServer.button.GiveAdminButton; import nautilus.game.arcade.gui.privateServer.button.KillButton; +import nautilus.game.arcade.gui.privateServer.button.OptionsButton; import nautilus.game.arcade.gui.privateServer.button.PlayerHeadButton; import nautilus.game.arcade.gui.privateServer.button.RemoveAdminButton; import nautilus.game.arcade.gui.privateServer.button.SetGameButton; -import nautilus.game.arcade.gui.privateServer.button.OptionsButton; import nautilus.game.arcade.gui.privateServer.button.StartGameButton; import nautilus.game.arcade.gui.privateServer.button.StopGameButton; import nautilus.game.arcade.gui.privateServer.button.UnbanButton; @@ -43,7 +44,7 @@ public class MenuPage extends BasePage addButton(4, getOwnerHead(), new PlayerHeadButton(getPlugin(), this)); boolean host = _manager.isHost(getPlayer()); - boolean disableChangeButtons = !getClientManager().Get(getPlayer()).GetRank().has(Rank.YOUTUBE) && getPlugin().isGameInProgress(); + boolean disableChangeButtons = !getClientManager().getPermissionManager().hasPermission(getPlayer(), GroupPermission.of(ArcadeManager.USE_MENU_DURING_GAME_PERMISSION)) && getPlugin().isGameInProgress(); { // Change Buttons - If a game is in progress and user isn't Youtube+ rank, they cannot @@ -122,7 +123,7 @@ public class MenuPage extends BasePage { String title = C.cGreen + C.Bold + _manager.getOwner().getName() + "'s Mineplex Community Server"; ItemStack head = new ItemBuilder(new ItemStack(_manager.getOwner().getFavoriteGame().getMaterial(), 1, _manager.getOwner().getFavoriteGame().getMaterialData(), null)).setTitle(ChatColor.RESET + title).build(); - ArrayList lore = new ArrayList(); + List lore = new ArrayList<>(); lore.add(" "); lore.add(ChatColor.RESET + C.cYellow + "Server Name: " + C.cWhite + getPlugin().getPlugin().getConfig().getString("serverstatus.name")); lore.add(ChatColor.RESET + C.cYellow + "Players Online: " + C.cWhite + UtilServer.getPlayers().length); @@ -138,7 +139,7 @@ public class MenuPage extends BasePage } String title = C.cGreen + C.Bold + getPlugin().GetHost() + "'s Mineplex Private Server"; ItemStack head = getPlayerHead(getPlugin().GetHost(), ChatColor.RESET + title); - ArrayList lore = new ArrayList(); + List lore = new ArrayList<>(); lore.add(" "); lore.add(ChatColor.RESET + C.cYellow + "Server Name: " + C.cWhite + getPlugin().getPlugin().getConfig().getString("serverstatus.name")); lore.add(ChatColor.RESET + C.cYellow + "Players Online: " + C.cWhite + UtilServer.getPlayers().length); @@ -152,4 +153,4 @@ public class MenuPage extends BasePage return new ShopItem(head, title, title, 1, false, false); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/RemoveAdminPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/RemoveAdminPage.java index 34730259e..171bae259 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/RemoveAdminPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/RemoveAdminPage.java @@ -1,11 +1,10 @@ package nautilus.game.arcade.gui.privateServer.page; -import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; @@ -29,7 +28,7 @@ public class RemoveAdminPage extends BasePage { addBackButton(4); - HashSet admins = _manager.getAdminList(); + Set admins = _manager.getAdminList(); Iterator iterator = admins.iterator(); int slot = 9; @@ -45,15 +44,11 @@ public class RemoveAdminPage extends BasePage private IButton getRemoveAdminButton(final int slot, final String playerName) { - return new IButton() + return (player, clickType) -> { - @Override - public void onClick(Player player, ClickType clickType) - { - _manager.removeAdmin(playerName); - removeButton(slot); - UtilPlayer.message(getPlayer(), F.main("Server", "You removed Co-Host power from " + F.name(playerName) + ".")); - } + _manager.removeAdmin(playerName); + removeButton(slot); + UtilPlayer.message(getPlayer(), F.main("Server", "You removed Co-Host power from " + F.name(playerName) + ".")); }; } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/UnbanPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/UnbanPage.java index 51012057f..43755ac5c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/UnbanPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/UnbanPage.java @@ -1,11 +1,10 @@ package nautilus.game.arcade.gui.privateServer.page; -import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; @@ -29,7 +28,7 @@ public class UnbanPage extends BasePage { addBackButton(4); - HashSet blackList = _manager.getBlacklist(); + Set blackList = _manager.getBlacklist(); Iterator iterator = blackList.iterator(); int slot = 9; @@ -54,15 +53,11 @@ public class UnbanPage extends BasePage private IButton getUnbanButton(final int slot, final String playerName) { - return new IButton() + return (player, clickType) -> { - @Override - public void onClick(Player player, ClickType clickType) - { - _manager.getBlacklist().remove(playerName); - removeButton(slot); - UtilPlayer.message(getPlayer(), F.main("Server", F.name(playerName) + " can now join this private server.")); - } + _manager.getBlacklist().remove(playerName); + removeButton(slot); + UtilPlayer.message(getPlayer(), F.main("Server", F.name(playerName) + " can now join this private server.")); }; } -} +} \ No newline at end of file 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 ff7c6fdeb..114657691 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 @@ -24,7 +24,7 @@ import org.bukkit.scheduler.BukkitRunnable; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -385,7 +385,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit Manager.hasKitsUnlocked(player) || (this.GetAvailability() == KitAvailability.Achievement && Manager.GetAchievement().hasCategory(player, this.getAchievementRequirement())) || donor.ownsUnknownSalesPackage(Manager.GetGame().GetType().GetKitGameName(Manager.GetGame()) + " " + this.GetName()) || - Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || + Manager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(ArcadeManager.KIT_ACCESS_PERMISSION)) || donor.ownsUnknownSalesPackage(Manager.GetServerConfig().ServerType + " ULTRA") || Manager.GetServerConfig().Tournament) { return true; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java index ae8c54f91..0b4cfd188 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java @@ -14,11 +14,9 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.inventory.ItemStack; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -36,9 +34,10 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilVariant; import mineplex.minecraft.game.core.damage.CustomDamageEvent; - import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.kit.Perk; public class PerkHorsePet extends Perk @@ -123,9 +122,9 @@ public class PerkHorsePet extends Perk { // Players alive at the end of the game don't die, so their horse sticks around. // We need to iterate through them just in case they have a horse to kill. - for(Player player : event.GetGame().GetPlayers(true)) + for (Player player : event.GetGame().GetPlayers(true)) { - this.despawnHorse(player); + despawnHorse(player); } } } @@ -214,22 +213,15 @@ public class PerkHorsePet extends Perk } @EventHandler - public void modTeleport(PlayerCommandPreprocessEvent event) + public void outOfGame(PlayerStateChangeEvent event) { if (!Manager.GetGame().IsLive()) return; - if (!event.getMessage().toLowerCase().startsWith("/tp") && !event.getMessage().toLowerCase().startsWith("/teleport")) - return; - - if (!Manager.GetClients().hasRank(event.getPlayer(), Rank.MODERATOR) - || Manager.GetClients().hasRank(event.getPlayer(), Rank.DEVELOPER)) - return; - - if (event.getMessage().split(" ").length < 2) - return; - - despawnHorse(event.getPlayer()); + if (event.GetState() == PlayerState.OUT) + { + despawnHorse(event.GetPlayer()); + } } @EventHandler @@ -326,4 +318,4 @@ public class PerkHorsePet extends Perk GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager(); return gadgetManager.getActiveKitModifier(KitModifierType.SurvivalGames_HorsemanKit, player); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java index e393104bf..47f91f4bd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSkeletons.java @@ -5,9 +5,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; -import net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.NavigationAbstract; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -22,10 +19,8 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerEvent; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; @@ -40,8 +35,11 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilVariant; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; - +import nautilus.game.arcade.events.PlayerStateChangeEvent; +import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.kit.Perk; +import net.minecraft.server.v1_8_R3.EntityCreature; +import net.minecraft.server.v1_8_R3.NavigationAbstract; public class PerkSkeletons extends Perk { @@ -335,22 +333,15 @@ public class PerkSkeletons extends Perk } @EventHandler - public void modTeleport(PlayerCommandPreprocessEvent event) + public void outOfGame(PlayerStateChangeEvent event) { if (!Manager.GetGame().IsLive()) return; - if (!event.getMessage().toLowerCase().startsWith("/tp") && !event.getMessage().toLowerCase().startsWith("/teleport")) - return; - - if (!Manager.GetClients().hasRank(event.getPlayer(), Rank.MODERATOR) - || Manager.GetClients().hasRank(event.getPlayer(), Rank.DEVELOPER)) - return; - - if (event.getMessage().split(" ").length < 2) - return; - - despawnSkels(event.getPlayer()); + if (event.GetState() == PlayerState.OUT) + { + despawnSkels(event.GetPlayer()); + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java index 065bfb462..b2ad89c68 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWolfPet.java @@ -4,9 +4,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; -import net.minecraft.server.v1_8_R3.EntityCreature; -import net.minecraft.server.v1_8_R3.NavigationAbstract; - import org.bukkit.DyeColor; import org.bukkit.EntityEffect; import org.bukkit.Location; @@ -23,11 +20,9 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.SpigotUtil; @@ -47,8 +42,11 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; - +import nautilus.game.arcade.events.PlayerStateChangeEvent; +import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.kit.Perk; +import net.minecraft.server.v1_8_R3.EntityCreature; +import net.minecraft.server.v1_8_R3.NavigationAbstract; public class PerkWolfPet extends Perk { @@ -306,22 +304,15 @@ public class PerkWolfPet extends Perk } @EventHandler - public void modTeleport(PlayerCommandPreprocessEvent event) + public void outOfGame(PlayerStateChangeEvent event) { if (!Manager.GetGame().IsLive()) return; - - if (!event.getMessage().toLowerCase().startsWith("/tp") && !event.getMessage().toLowerCase().startsWith("/teleport")) - return; - if (!Manager.GetClients().hasRank(event.getPlayer(), Rank.MODERATOR) - || Manager.GetClients().hasRank(event.getPlayer(), Rank.DEVELOPER)) - return; - - if (event.getMessage().split(" ").length < 2) - return; - - despawnWolf(event.getPlayer()); + if (event.GetState() == PlayerState.OUT) + { + despawnWolf(event.GetPlayer()); + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index ce46fb56a..c3a0c20ec 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -1,38 +1,10 @@ package nautilus.game.arcade.managers; -import mineplex.core.Managers; -import mineplex.core.antihack.AntiHack; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -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.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.preferences.Preference; -import mineplex.core.recharge.Recharge; -import mineplex.core.teleport.event.MineplexTeleportEvent; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerDeathOutEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.kit.perks.event.PerkDestructorBlockEvent; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -75,20 +47,64 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.util.Vector; -import java.util.concurrent.ConcurrentHashMap; +import mineplex.core.Managers; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; +import mineplex.core.antihack.AntiHack; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.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.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.preferences.Preference; +import mineplex.core.recharge.Recharge; +import mineplex.core.teleport.event.MineplexTeleportEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerDeathOutEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.kit.perks.event.PerkDestructorBlockEvent; public class GameFlagManager implements Listener { + public static final String BYPASS_TELEPORT_KICK_PERMISSION = "mineplex.arcade.flag.teleport.bypass"; + ArcadeManager Manager; SecondaryDamageManager Secondary; - private ConcurrentHashMap _respawnTimers = new ConcurrentHashMap(); - private ConcurrentHashMap _respawnRunnables = new ConcurrentHashMap(); + private Map _respawnTimers = new HashMap<>(); + private Map _respawnRunnables = new HashMap<>(); public GameFlagManager(ArcadeManager manager) { Manager = manager; Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Manager.GetClients().getPermissionManager(); + + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(BYPASS_TELEPORT_KICK_PERMISSION), true, true); } @EventHandler @@ -758,13 +774,10 @@ public class GameFlagManager implements Listener Manager.addSpectator(player, game.DeathTeleport); } - Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> { - public void run() - { - player.setFireTicks(0); - UtilAction.zeroVelocity(player); - } + player.setFireTicks(0); + UtilAction.zeroVelocity(player); }, 0); } //TIMER @@ -801,35 +814,29 @@ public class GameFlagManager implements Listener UtilPlayer.message(player, C.cWhite + C.Bold + "You will respawn in " + time + " seconds..."); UtilTextMiddle.display(null, "Respawning in " + time + " seconds...", 5, 40, 5, player); } - Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> { - public void run() - { - Long t = Double.valueOf(timeF).longValue(); - _respawnTimers.put(player, System.currentTimeMillis() + UtilTime.convert(t, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)); - } + Long t = Double.valueOf(timeF).longValue(); + _respawnTimers.put(player, Long.valueOf(System.currentTimeMillis() + UtilTime.convert(t, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))); }, 6); - int run = Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + int run = Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> { - public void run() + //Teleport + if (game.IsAlive(player)) { - //Teleport - if (game.IsAlive(player)) - { - game.RespawnPlayer(player); - } - else - { - Manager.addSpectator(player, game.DeathTeleport); - } - - player.setFireTicks(0); - UtilAction.zeroVelocity(player); - - _respawnRunnables.remove(player); + game.RespawnPlayer(player); } + else + { + Manager.addSpectator(player, game.DeathTeleport); + } + + player.setFireTicks(0); + UtilAction.zeroVelocity(player); + + _respawnRunnables.remove(player); }, (int)(time * 20d)); - _respawnRunnables.put(player, run); + _respawnRunnables.put(player, Integer.valueOf(run)); } } @@ -1018,7 +1025,7 @@ public class GameFlagManager implements Listener if (event.isCancelled()) return; - if (Manager.GetClients().Get(event.getPlayer()).GetRank().has(Rank.DEVELOPER)) + if (Manager.GetClients().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(BYPASS_TELEPORT_KICK_PERMISSION))) return; Game game = Manager.GetGame(); @@ -1278,7 +1285,7 @@ public class GameFlagManager implements Listener _respawnTimers.clear(); for (Integer r : _respawnRunnables.values()) { - Bukkit.getScheduler().cancelTask(r); + Bukkit.getScheduler().cancelTask(r.intValue()); } _respawnRunnables.clear(); return; @@ -1288,30 +1295,37 @@ public class GameFlagManager implements Listener _respawnTimers.clear(); for (Integer r : _respawnRunnables.values()) { - Bukkit.getScheduler().cancelTask(r); + Bukkit.getScheduler().cancelTask(r.intValue()); } _respawnRunnables.clear(); return; } - for (Player player : _respawnTimers.keySet()) + Iterator> respawnIterator = _respawnTimers.entrySet().iterator(); + while (respawnIterator.hasNext()) { + Entry next = respawnIterator.next(); + Player player = next.getKey(); if (!player.isOnline()) { - _respawnTimers.remove(player); + respawnIterator.remove(); continue; } - if (System.currentTimeMillis() >= _respawnTimers.get(player)) + if (System.currentTimeMillis() >= next.getValue().longValue()) { - _respawnTimers.remove(player); + respawnIterator.remove(); continue; } - long sec = UtilTime.convert(_respawnTimers.get(player) - System.currentTimeMillis(), TimeUnit.MILLISECONDS, TimeUnit.SECONDS); + long sec = UtilTime.convert(next.getValue().longValue() - System.currentTimeMillis(), TimeUnit.MILLISECONDS, TimeUnit.SECONDS); ChatColor color = ChatColor.RED; if (sec < 8) + { color = ChatColor.YELLOW; + } if (sec < 4) + { color = ChatColor.GREEN; + } UtilTextBottom.display(color + "Respawning In: " + sec + " Seconds", player); } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 0867fb6cc..47c385336 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -3,6 +3,9 @@ package nautilus.game.arcade.managers; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.stream.Stream; import org.bukkit.Bukkit; @@ -23,8 +26,10 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.Plugin; import mineplex.core.Managers; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.antihack.AntiHack; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilGear; @@ -42,7 +47,6 @@ import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; - import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -52,34 +56,35 @@ import nautilus.game.arcade.gui.privateServer.page.GameVotingPage; public class GameHostManager implements Listener { + public static final String AUTO_ADMIN_ACCESS_PERMISSION = "mineplex.arcade.host.autoadmin"; + public static final String INCREASE_MAX_PLAYERS_LEVEL_PERMISSION = "mineplex.arcade.host.increasemax."; + private final AntiHack _antiHack; - private ArrayList ultraGames = new ArrayList(); - private ArrayList heroGames = new ArrayList(); - private ArrayList legendGames = new ArrayList(); + private List _games = new ArrayList<>(); ArcadeManager Manager; private Player _host; - private Rank _hostRank; + private PermissionGroup _hostRank; private long _serverStartTime = System.currentTimeMillis(); private long _serverExpireTime = 21600000; private long _lastOnline = System.currentTimeMillis(); private long _expireTime = 300000; private boolean _hostExpired = false; - private HashSet _onlineAdmins = new HashSet(); - private HashSet _adminList = new HashSet(); - private HashSet _whitelist = new HashSet(); - private HashSet _blacklist = new HashSet(); + private Set _onlineAdmins = new HashSet<>(); + private Set _adminList = new HashSet<>(); + private Set _whitelist = new HashSet<>(); + private Set _blacklist = new HashSet<>(); private PrivateServerShop _shop; private boolean _isEventServer = false; - private HashMap _permissionMap = new HashMap(); + private Map _permissionMap = new HashMap<>(); private boolean _voteInProgress = false; - private HashMap _votes = new HashMap(); + private Map _votes = new HashMap<>(); private int _voteNotificationStage = 1; public GameHostManager(ArcadeManager manager) @@ -89,72 +94,80 @@ public class GameHostManager implements Listener _shop = new PrivateServerShop(manager, manager.GetClients(), manager.GetDonation()); Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); - //Ultra Games - ultraGames.add(GameType.Smash); - - ultraGames.add(GameType.BaconBrawl); - ultraGames.add(GameType.DeathTag); - ultraGames.add(GameType.DragonEscape); - ultraGames.add(GameType.Dragons); - ultraGames.add(GameType.Micro); - ultraGames.add(GameType.Paintball); - ultraGames.add(GameType.Quiver); - ultraGames.add(GameType.Runner); - ultraGames.add(GameType.Sheep); - ultraGames.add(GameType.Snake); - ultraGames.add(GameType.SneakyAssassins); - ultraGames.add(GameType.TurfWars); - ultraGames.add(GameType.Spleef); - ultraGames.add(GameType.Lobbers); - ultraGames.add(GameType.Evolution); - ultraGames.add(GameType.MonsterMaze); - ultraGames.add(GameType.Gladiators); - - //HeroKit Games - heroGames.add(GameType.ChampionsDominate); - heroGames.add(GameType.ChampionsTDM); - heroGames.add(GameType.ChampionsCTF); - heroGames.add(GameType.HideSeek); - heroGames.add(GameType.Draw); - - //Legend Games - legendGames.add(GameType.Bridge); - legendGames.add(GameType.SurvivalGames); - legendGames.add(GameType.CastleSiege); - legendGames.add(GameType.WitherAssault); - legendGames.add(GameType.Wizards); - legendGames.add(GameType.Build); - legendGames.add(GameType.UHC); - legendGames.add(GameType.MineStrike); - legendGames.add(GameType.Skywars); - legendGames.add(GameType.SpeedBuilders); - legendGames.add(GameType.TypeWars); + //Games + _games.add(GameType.Smash); + _games.add(GameType.BaconBrawl); + _games.add(GameType.DeathTag); + _games.add(GameType.DragonEscape); + _games.add(GameType.Dragons); + _games.add(GameType.Micro); + _games.add(GameType.Paintball); + _games.add(GameType.Quiver); + _games.add(GameType.Runner); + _games.add(GameType.Sheep); + _games.add(GameType.Snake); + _games.add(GameType.SneakyAssassins); + _games.add(GameType.TurfWars); + _games.add(GameType.Spleef); + _games.add(GameType.Lobbers); + _games.add(GameType.Evolution); + _games.add(GameType.MonsterMaze); + _games.add(GameType.Gladiators); + _games.add(GameType.ChampionsDominate); + _games.add(GameType.ChampionsTDM); + _games.add(GameType.ChampionsCTF); + _games.add(GameType.HideSeek); + _games.add(GameType.Draw); + _games.add(GameType.Bridge); + _games.add(GameType.SurvivalGames); + _games.add(GameType.CastleSiege); + _games.add(GameType.WitherAssault); + _games.add(GameType.Wizards); + _games.add(GameType.Build); + _games.add(GameType.UHC); + _games.add(GameType.MineStrike); + _games.add(GameType.Skywars); + _games.add(GameType.SpeedBuilders); + _games.add(GameType.TypeWars); // Team variants - Currently being remade. /* - legendGames.add(GameType.DragonEscapeTeams); - legendGames.add(GameType.DragonsTeams); - legendGames.add(GameType.QuiverTeams); - legendGames.add(GameType.SmashTeams); - legendGames.add(GameType.SpleefTeams); - legendGames.add(GameType.SurvivalGamesTeams); + _games.add(GameType.DragonEscapeTeams); + _games.add(GameType.DragonsTeams); + _games.add(GameType.QuiverTeams); + _games.add(GameType.SmashTeams); + _games.add(GameType.SpleefTeams); + _games.add(GameType.SurvivalGamesTeams); */ //Rejected / Other - legendGames.add(GameType.MilkCow); - legendGames.add(GameType.SearchAndDestroy); - legendGames.add(GameType.ZombieSurvival); - legendGames.add(GameType.SurvivalGamesTeams); - legendGames.add(GameType.SkywarsTeams); - legendGames.add(GameType.SmashTeams); - legendGames.add(GameType.SnowFight); - legendGames.add(GameType.Gravity); - legendGames.add(GameType.Barbarians); - legendGames.add(GameType.SmashDomination); + _games.add(GameType.MilkCow); + _games.add(GameType.SearchAndDestroy); + _games.add(GameType.ZombieSurvival); + _games.add(GameType.SurvivalGamesTeams); + _games.add(GameType.SkywarsTeams); + _games.add(GameType.SmashTeams); + _games.add(GameType.SnowFight); + _games.add(GameType.Gravity); + _games.add(GameType.Barbarians); + _games.add(GameType.SmashDomination); //Config Defaults if (Manager.GetHost() != null && Manager.GetHost().length() > 0) { setDefaultConfig(); } + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Manager.GetClients().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(AUTO_ADMIN_ACCESS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 2), true, true); + pm.setPermission(pm.getGroup("eternal"), GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 1), true, true); + pm.setPermission(pm.getGroup("content"), GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 2), true, true); + pm.setPermission(pm.getGroup("yt"), GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 2), false, false); } public ArrayList hasWarning() @@ -235,6 +248,13 @@ public class GameHostManager implements Listener public void handleLogin(PlayerLoginEvent event) { Player p = event.getPlayer(); + boolean alwaysAllow = Manager.GetClients().getPermissionManager().hasPermission(Manager.GetClients().Get(p.getUniqueId()), GroupPermission.of(ArcadeManager.BYPASS_MPS_WHITELIST_PERMISSION)); + + if (alwaysAllow) + { + return; + } + if (isCommunityServer()) { if (getOwner().getMembers().containsKey(p.getUniqueId())) @@ -244,8 +264,10 @@ public class GameHostManager implements Listener event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not a member of this MCS."); return; } - if (Manager.GetServerConfig().PlayerServerWhitelist){ - if (!getWhitelist().contains(p.getName().toLowerCase())){ + if (Manager.GetServerConfig().PlayerServerWhitelist) + { + if (!getWhitelist().contains(p.getName().toLowerCase())) + { if ((Manager.GetHost() != null) && (Manager.GetHost().equalsIgnoreCase(p.getName()))) { return; @@ -287,15 +309,19 @@ public class GameHostManager implements Listener if (Manager.GetHost().equals(event.getPlayer().getName())) { _host = event.getPlayer(); - _hostRank = Manager.GetClients().Get(_host).GetRank(); + _hostRank = Manager.GetClients().Get(_host).getPrimaryGroup(); System.out.println("Game Host Joined."); //Limit player count! if (Manager.GetServerConfig().MaxPlayers > getMaxPlayerCap()) + { Manager.GetServerConfig().MaxPlayers = getMaxPlayerCap(); + } if (isEventServer()) + { worldeditPermissionSet(event.getPlayer(), true); + } } else if (isAdmin(event.getPlayer(), false)) { @@ -303,7 +329,9 @@ public class GameHostManager implements Listener _onlineAdmins.add(event.getPlayer()); if (isEventServer()) + { worldeditPermissionSet(event.getPlayer(), true); + } } } @@ -345,7 +373,6 @@ public class GameHostManager implements Listener } } - @EventHandler public void updateHostExpired(UpdateEvent event) { @@ -377,7 +404,6 @@ public class GameHostManager implements Listener setHostExpired(true, "This server has expired! Thank you for playing!"); } - public boolean isHostExpired() { if (!isPrivateServer()) @@ -422,38 +448,21 @@ public class GameHostManager implements Listener } } - public HashSet getWhitelist() + public Set getWhitelist() { return _whitelist; } - public HashSet getBlacklist() + public Set getBlacklist() { return _blacklist; } - public HashSet getAdminList() + public Set getAdminList() { return _adminList; } - @EventHandler - public void getAdmin(PlayerCommandPreprocessEvent event) - { - if (!event.getMessage().equalsIgnoreCase("/getadmin")) - return; - - event.setCancelled(true); - - if (!isPrivateServer()) - return; - - if (!Manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.JNR_DEV, true) && !event.getPlayer().isOp()) - return; - - giveAdmin(event.getPlayer()); - } - @EventHandler public void broadcastCommand(PlayerCommandPreprocessEvent event) { @@ -566,9 +575,9 @@ public class GameHostManager implements Listener { if (isCommunityServer()) { - return (getOwner().getMembers().containsKey(player.getUniqueId()) && getOwner().getMembers().get(player.getUniqueId()).Role.ordinal() <= CommunityRole.COLEADER.ordinal()) || (includeStaff && Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN)); + return (getOwner().getMembers().containsKey(player.getUniqueId()) && getOwner().getMembers().get(player.getUniqueId()).Role.ordinal() <= CommunityRole.COLEADER.ordinal()) || (includeStaff && Manager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(AUTO_ADMIN_ACCESS_PERMISSION))); } - return player.equals(_host) || _adminList.contains(player.getName()) || (includeStaff && Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN)); + return player.equals(_host) || _adminList.contains(player.getName()) || (includeStaff && Manager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(AUTO_ADMIN_ACCESS_PERMISSION))); } public boolean isHost(Player player) @@ -614,7 +623,7 @@ public class GameHostManager implements Listener String[] args = event.getMessage().split(" "); - for (int i=1 ; i getAvailableGames(Player player) + public boolean hasPermission(GroupPermission permission) { - ArrayList games = new ArrayList(); - - if (hasRank(Rank.ULTRA)) - games.addAll(ultraGames); - if (hasRank(Rank.HERO)) - games.addAll(heroGames); - if (hasRank(Rank.LEGEND)) - games.addAll(legendGames); - - return games; + PermissionManager pm = Manager.GetClients().getPermissionManager(); + if (isCommunityServer()) + { + return pm.hasPermission(pm.getGroup("eternal"), permission); + } + if (_hostRank == null) + { + return false; + } + + return pm.hasPermission(_hostRank, permission); } - public HashMap> getGames(Player p) + public List getAvailableGames(Player player) { - HashMap> games = new HashMap>(); + return _games; + } + + public Map> getGames(Player p) + { + Map> games = new HashMap<>(); for (GameCategory cat : GameCategory.values()) { - ArrayList types = new ArrayList<>(); + List types = new ArrayList<>(); for (GameType type : getAvailableGames(p)) { if (type.getGameCategory().equals(cat)) @@ -775,16 +793,16 @@ public class GameHostManager implements Listener { return 20; } - if (hasRank(Rank.SNR_MODERATOR) || _hostRank == Rank.YOUTUBE || _hostRank == Rank.TWITCH) + if (hasPermission(GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 2))) + { return 100; - else if (_hostRank == Rank.YOUTUBE_SMALL || _hostRank == Rank.ETERNAL) + } + else if (hasPermission(GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 1))) + { return 60; - else if (hasRank(Rank.LEGEND)) - return 40; - else if (hasRank(Rank.HERO)) - return 12; - else - return 4; + } + + return 40; } @EventHandler @@ -829,7 +847,7 @@ public class GameHostManager implements Listener _isEventServer = var; } - public HashMap getVotes() + public Map getVotes() { return _votes; } @@ -844,14 +862,14 @@ public class GameHostManager implements Listener return _voteInProgress; } - public Rank getHostRank() + public PermissionGroup getHostRank() { return _hostRank; } - public void setHostRank(Rank rank) + public void setHostRank(PermissionGroup group) { - _hostRank = rank; + _hostRank = group; } public Player getHost() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java index 48ddb346b..bb2173e26 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLootManager.java @@ -16,9 +16,9 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilFirework; @@ -26,7 +26,6 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.pet.PetManager; import mineplex.core.reward.Reward; -import mineplex.core.reward.RewardData; import mineplex.core.reward.RewardManager; import mineplex.core.reward.RewardRarity; import mineplex.core.reward.RewardType; @@ -37,6 +36,8 @@ import nautilus.game.arcade.game.Game.GameState; public class GameLootManager implements Listener { + public static final String LOOT_CHANCE_MULT_LEVEL_PERMISSION = "mineplex.arcade.loot.chancemult."; + private ArcadeManager Manager; private RewardManager _rewardManager; @@ -62,6 +63,17 @@ public class GameLootManager implements Listener _rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Mythical Chest", "Mythical Chest", 1, 1, new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 1, 0)); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Manager.GetClients().getPermissionManager(); + + pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 1), true, true); + pm.setPermission(pm.getGroup("hero"), GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 2), true, true); + pm.setPermission(pm.getGroup("legend"), GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 3), true, true); } @EventHandler @@ -106,25 +118,22 @@ public class GameLootManager implements Listener if (event.GetState() != GameState.Dead) return; - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> { - public void run() - { - int rewardsGiven = 0; - - for (Player player : _players) - { - if (giveReward(player, false)) - rewardsGiven++; - } - - if (rewardsGiven == 0 && !_players.isEmpty()) - { - giveReward(UtilAlg.Random(_players), true); - } + int rewardsGiven = 0; - _players.clear(); + for (Player player : _players) + { + if (giveReward(player, false)) + rewardsGiven++; } + + if (rewardsGiven == 0 && !_players.isEmpty()) + { + giveReward(UtilAlg.Random(_players), true); + } + + _players.clear(); }, 240); //Delay after Achievements } @@ -135,11 +144,11 @@ public class GameLootManager implements Listener { double chance = Math.min(0.5, 0.1 + (System.currentTimeMillis() - _startTime)/3600000d); - if (Manager.GetClients().Get(player).GetRank().has(Rank.ULTRA)) + if (Manager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 1))) { - if (Manager.GetClients().Get(player).GetRank().has(Rank.HERO)) + if (Manager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 2))) { - if (Manager.GetClients().Get(player).GetRank().has(Rank.LEGEND)) + if (Manager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 3))) { chance *= 1.6; } @@ -155,61 +164,59 @@ public class GameLootManager implements Listener } if (Math.random() > chance) + { return false; + } } final Reward reward = _rewardManager.nextReward(player, null, false, RewardType.GAME_LOOT, true); - reward.giveReward(RewardType.GAME_LOOT, player, new Callback() + reward.giveReward(RewardType.GAME_LOOT, player, rewardData -> { - @Override - public void run(RewardData rewardData) + String outputName = reward.getRarity().getColor() + rewardData.getFriendlyName(); + + String rarityName = ""; + if (reward.getRarity() != RewardRarity.COMMON) + rarityName = " " + reward.getRarity().getColor() + reward.getRarity().getName(); + + //Log + System.out.println(F.name(player.getName()) + " found" + rarityName + " " + outputName); + + //Self Display + UtilTextMiddle.display(C.cGreen + "Game Loot", "You found " + outputName, 20, 120, 20, player); + //if (reward.getRarity() == RewardRarity.COMMON) + // UtilPlayer.message(player, F.main("Loot", "You found " + rarityName + outputName)); + + Random _random = new Random(); + + //Announce + //if (reward.getRarity() != RewardRarity.COMMON) { - String outputName = reward.getRarity().getColor() + rewardData.getFriendlyName(); + Bukkit.broadcastMessage(F.main("Loot", F.name(player.getName()) + " found" + rarityName + " " + outputName)); + } - String rarityName = ""; - if (reward.getRarity() != RewardRarity.COMMON) - rarityName = " " + reward.getRarity().getColor() + reward.getRarity().getName(); + //Effect + if (reward.getRarity() == RewardRarity.UNCOMMON) + { + FireworkEffect effect = FireworkEffect.builder().withColor(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255))) + .withFade(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255))) + .with(FireworkEffect.Type.STAR) + .build(); - //Log - System.out.println(F.name(player.getName()) + " found" + rarityName + " " + outputName); + UtilFirework.playFirework(player.getEyeLocation(), effect); + } + else if (reward.getRarity() == RewardRarity.RARE) + { + FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL).withColor(Color.YELLOW).withFade(Color.WHITE).build(); + UtilFirework.playFirework(player.getEyeLocation(), effect); - //Self Display - UtilTextMiddle.display(C.cGreen + "Game Loot", "You found " + outputName, 20, 120, 20, player); - //if (reward.getRarity() == RewardRarity.COMMON) - // UtilPlayer.message(player, F.main("Loot", "You found " + rarityName + outputName)); + player.getWorld().playSound(player.getEyeLocation().add(0.5, 0.5, 0.5), Sound.WITHER_SPAWN, 5F, 1.2F); + } + else if (reward.getRarity() == RewardRarity.LEGENDARY) + { + FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.RED).withFade(Color.BLACK).build(); + UtilFirework.playFirework(player.getEyeLocation(), effect); - Random _random = new Random(); - - //Announce - //if (reward.getRarity() != RewardRarity.COMMON) - { - Bukkit.broadcastMessage(F.main("Loot", F.name(player.getName()) + " found" + rarityName + " " + outputName)); - } - - //Effect - if (reward.getRarity() == RewardRarity.UNCOMMON) - { - FireworkEffect effect = FireworkEffect.builder().withColor(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255))) - .withFade(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255))) - .with(FireworkEffect.Type.STAR) - .build(); - - UtilFirework.playFirework(player.getEyeLocation(), effect); - } - else if (reward.getRarity() == RewardRarity.RARE) - { - FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL).withColor(Color.YELLOW).withFade(Color.WHITE).build(); - UtilFirework.playFirework(player.getEyeLocation(), effect); - - player.getWorld().playSound(player.getEyeLocation().add(0.5, 0.5, 0.5), Sound.WITHER_SPAWN, 5F, 1.2F); - } - else if (reward.getRarity() == RewardRarity.LEGENDARY) - { - FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.RED).withFade(Color.BLACK).build(); - UtilFirework.playFirework(player.getEyeLocation(), effect); - - player.getWorld().playSound(player.getEyeLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F); - } + player.getWorld().playSound(player.getEyeLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F); } }); @@ -230,4 +237,4 @@ public class GameLootManager implements Listener event.setCancelled(true); } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java index 98d0cfb35..4270a6031 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java @@ -19,7 +19,6 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.scheduler.BukkitRunnable; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -360,16 +359,6 @@ public class GamePlayerManager implements Listener Player player = event.getPlayer(); - if (Manager.GetClients().Get(player).GetRank().has(Rank.MODERATOR)) - return; - - if (event.getMessage().toLowerCase().startsWith("/tp")) - { - UtilPlayer.message(player, F.main("Game", "Spectate Teleport changed to " + F.elem("/spec ") + ".")); - event.setCancelled(true); - return; - } - if (!event.getMessage().toLowerCase().startsWith("/spec")) return; @@ -412,8 +401,8 @@ public class GamePlayerManager implements Listener return; } - Manager.runSyncLater(() -> { - + Manager.runSyncLater(() -> + { for (Player player : game.GetPlayers(true)) { GameTeam team = game.GetTeam(player); @@ -445,5 +434,4 @@ public class GamePlayerManager implements Listener }, TEAMMATE_MESSAGE_DELAY); } - } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java index 2e5e4fbdf..585fce757 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java @@ -1,29 +1,7 @@ package nautilus.game.arcade.managers; -import com.mojang.authlib.GameProfile; - -import mineplex.core.achievement.Achievement; -import mineplex.core.boosters.Booster; -import mineplex.core.common.Rank; -import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.common.util.*; -import mineplex.core.titles.tracks.standard.GemCollectorTrack; -import mineplex.minecraft.game.core.combat.CombatComponent; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import mineplex.serverdata.Utility; - -import nautilus.game.arcade.ArcadeFormat; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.FirstBloodEvent; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerStateChangeEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.GemData; - -import net.minecraft.server.v1_8_R3.EntityHuman; +import java.lang.reflect.Field; +import java.util.HashMap; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity; @@ -34,14 +12,41 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import java.lang.reflect.Field; -import java.util.HashMap; +import com.mojang.authlib.GameProfile; + +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; +import mineplex.core.achievement.Achievement; +import mineplex.core.boosters.Booster; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.titles.tracks.standard.GemCollectorTrack; +import mineplex.minecraft.game.core.combat.CombatComponent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.serverdata.Utility; +import nautilus.game.arcade.ArcadeFormat; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.FirstBloodEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.GemData; +import net.minecraft.server.v1_8_R3.EntityHuman; /** * This class is used to reward gems and shards at the end of a game, or when players leave the server. */ public class GameRewardManager implements Listener { + public static final String SHARD_MULT_LEVEL_PERMISSION = "mineplex.arcade.reward."; ArcadeManager Manager; boolean DoubleGem = false; @@ -52,6 +57,19 @@ public class GameRewardManager implements Listener Manager = manager; Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Manager.GetClients().getPermissionManager(); + + pm.setPermission(pm.getGroup("ultra"), GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 1), true, true); + pm.setPermission(pm.getGroup("hero"), GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 2), true, true); + pm.setPermission(pm.getGroup("legend"), GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 3), true, true); + pm.setPermission(pm.getGroup("titan"), GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 4), true, true); + pm.setPermission(pm.getGroup("eternal"), GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 5), true, true); } @EventHandler @@ -219,19 +237,22 @@ public class GameRewardManager implements Listener if (DoubleGem && game.GemDoubleEnabled && !game.CrownsEnabled) gemsToReward += baseGemsEarned; - Rank rank = Manager.GetClients().Get(player).GetRank(); int accountId = Manager.GetClients().getAccountId(player); - - if (rank == rank.ULTRA) - shardsToReward += baseShardsEarned * 0.5; - else if (rank == rank.HERO) - shardsToReward += baseShardsEarned * 1; - else if (rank == rank.LEGEND) - shardsToReward += baseShardsEarned * 1.5; - else if (rank == Rank.TITAN) - shardsToReward += baseShardsEarned * 2; - else if (rank.has(Rank.ETERNAL)) - shardsToReward += baseShardsEarned * 2.5; + + double shardMult = 0; + + for (int i = 1; i < 6; i++) + { + if (Manager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + i))) + { + shardMult += 0.5; + } + } + + if (shardMult > 0) + { + shardsToReward *= shardMult; + } if (!game.CrownsEnabled) { @@ -378,24 +399,23 @@ public class GameRewardManager implements Listener final int baseShards = earnedGems; int shards = baseShards; double extraMult = 0; - - Rank rank = Manager.GetClients().Get(player).GetRank(); - - if (rank == rank.ULTRA) - extraMult = 0.5; - else if (rank == rank.HERO) - extraMult = 1; - else if (rank == rank.LEGEND) - extraMult = 1.5; - else if (rank.has(Rank.TITAN)) - extraMult = 2; + + PermissionGroup group = Manager.GetClients().Get(player).getPrimaryGroup(); + + for (int i = 1; i < 6; i++) + { + if (Manager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + i))) + { + extraMult += 0.5; + } + } UtilPlayer.message(player, F.elem(C.cAqua + "+" + baseShards + " Treasure Shards") + " for " + F.elem("Earning " + baseShards + " Gems")); - if (rank.has(Rank.ULTRA)) + if (extraMult > 0) { int extraShards = ((int) (extraMult * baseShards)); UtilPlayer.message(player, F.elem(C.cAqua + "+" + extraShards + " Treasure Shards") + " for " + - F.elem(rank.getTag(true, true)) + F.elem(" Rank" + C.cAqua + " +" + Math.round((extraMult * 100)) + "%")); + F.elem(group.getDisplay(true, true, true, true)) + F.elem(" Rank" + C.cAqua + " +" + Math.round((extraMult * 100)) + "%")); } Booster booster = Manager.getBoosterManager().getActiveBooster(); if (game.GemBoosterEnabled && booster != null) @@ -422,6 +442,4 @@ public class GameRewardManager implements Listener UtilPlayer.message(player, ArcadeFormat.Line); } - - } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java index 5916af5b1..4348ae7eb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java @@ -12,7 +12,8 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -24,6 +25,8 @@ import nautilus.game.arcade.stats.StatTracker; public class GameStatManager implements Listener { + public static final String STAT_BOOST_COMMAND_PERMISSION = "mineplex.arcade.stat.boost"; + ArcadeManager Manager; private final HashMap _joinTimes = new HashMap<>(); @@ -33,7 +36,16 @@ public class GameStatManager implements Listener Manager = manager; Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); - } + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Manager.GetClients().getPermissionManager(); + + pm.setPermission(pm.getGroup("lt"), GroupPermission.of(STAT_BOOST_COMMAND_PERMISSION), true, true); + } @EventHandler public void StatEnableDisable(GameStateChangeEvent event) @@ -116,7 +128,7 @@ public class GameStatManager implements Listener @EventHandler public void statBoostCommand(PlayerCommandPreprocessEvent event) { - if (event.getMessage().startsWith("/statboost ") && Manager.GetClients().Get(event.getPlayer()).GetRank().has(Rank.OWNER)) + if (event.getMessage().startsWith("/statboost ") && Manager.GetClients().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(STAT_BOOST_COMMAND_PERMISSION))) { event.setCancelled(true); @@ -143,4 +155,4 @@ public class GameStatManager implements Listener event.getPlayer().sendMessage("Gave Stats: " + player.getName()); } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTestingManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTestingManager.java deleted file mode 100644 index fdc2339d3..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameTestingManager.java +++ /dev/null @@ -1,293 +0,0 @@ -package nautilus.game.arcade.managers; - -import java.util.HashSet; -import java.util.Set; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerLoginEvent.Result; - -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import nautilus.game.arcade.ArcadeManager; - -public class GameTestingManager implements Listener -{ - /** - * Created by: Mysticate - * Timestamp: November 25, 2015 - */ - - private ArcadeManager _manager; - - private boolean _enabled; - - private boolean _capped = false; - private int _cap = 16; - private String _capMessage = ""; - - private boolean _whitelisted = false; - private Set _whitelistAdded = new HashSet(); - private String _whitelistMessage = ""; - - public GameTestingManager(ArcadeManager manager) - { - _manager = manager; - - _manager.getPluginManager().registerEvents(this, _manager.getPlugin()); - - _enabled = UtilServer.isTestServer(); - } - - public ArcadeManager getManager() - { - return _manager; - } - - public void setCapped(boolean cap) - { - _capped = cap; - } - - public boolean isCapped() - { - return _capped; - } - - public void setCap(int cap) - { - _cap = cap; - } - - public int getCap() - { - return _cap; - } - - public boolean isWhitelisted(String name) - { - return _whitelistAdded.contains(new String(name).toLowerCase()); - } - - public void setWhitelisted(String name, boolean whitelist) - { - if (isWhitelisted(name)) - { - _whitelistAdded.remove(name.toLowerCase()); - } - else - { - _whitelistAdded.add(new String(name).toLowerCase()); - } - } - - @EventHandler - public void onLogin(PlayerLoginEvent event) - { - if (!_enabled) - return; - - if (_capped) - { - if (UtilServer.getPlayers().length >= _cap) - { - if (!isWhitelisted(event.getPlayer().getName())) - { - event.disallow(Result.KICK_FULL, C.cGray + "That server has a set cap!\n" - + C.cGray + "Current players " + C.cYellow + UtilServer.getPlayers().length + "/" + _cap + "\n" - + C.cGreen + _capMessage); - } - return; - } - } - - if (_whitelisted) - { - if (!isWhitelisted(event.getPlayer().getName())) - { - event.disallow(Result.KICK_FULL, C.cGray + "That server has a testing whitelist!\n" - + C.cGray + "Current players " + C.cYellow + UtilServer.getPlayers().length + "/" + _cap + "\n" - + C.cGreen + _capMessage); - } - return; - } - } - - @EventHandler - public void onCommandTesting(PlayerCommandPreprocessEvent event) - { - if (!_enabled) - return; - - String[] args = event.getMessage().split(" "); - String cmd = args[0]; - - if (!cmd.equalsIgnoreCase("/testing")) - return; - - event.setCancelled(true); - - if (!_manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.JNR_DEV, true)) - return; - - if (args.length == 1) // Help - { - sendGlobalHelp(event.getPlayer()); - return; - } - else if (args[1].equalsIgnoreCase("cap")) - { - if (args.length == 2) - { - sendCapHelp(event.getPlayer()); - return; - } - - if (args.length == 3) // No cap arguments - { - if (args[2].equalsIgnoreCase("toggle")) - { - _capped = !_capped; - UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing cap enabled " + F.tf(_capped) + ".")); - return; - } - - try - { - _cap = Integer.valueOf(args[2]); - UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing cap set to " + F.elem("" + _cap) + ".")); - } - catch (Exception ex) - { - sendCapHelp(event.getPlayer()); - } - return; - } - - if (args.length >= 4) - { - if (args[2].equalsIgnoreCase("message")) - { - String message = ""; - for (int i = 3 ; i < args.length ; i++) - message += (args[i] + " "); - - _capMessage = message.trim(); - UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing cap message set to " + F.elem(_capMessage) + ".")); - return; - } - - sendCapHelp(event.getPlayer()); - return; - } - - sendCapHelp(event.getPlayer()); - return; - } - else if (args[1].equalsIgnoreCase("whitelist")) - { - if (args.length == 2) - { - sendWhitelistHelp(event.getPlayer()); - return; - } - - if (args.length == 3) // No cap arguments - { - if (args[2].equalsIgnoreCase("toggle")) - { - _whitelisted = !_whitelisted; - UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing whitelist enabled " + F.tf(_whitelisted) + ".")); - return; - } - - sendWhitelistHelp(event.getPlayer()); - return; - } - - if (args.length == 4) - { - if (args[2].equalsIgnoreCase("add")) - { - String playerName = args[3]; - - if (isWhitelisted(playerName)) - { - UtilPlayer.message(event.getPlayer(), F.main("Testing", "That player is already whitelisted!")); - } - else - { - setWhitelisted(playerName, true); - UtilPlayer.message(event.getPlayer(), F.main("Testing", "You have whitelisted " + F.name(playerName) + ".")); - } - return; - } - else if (args[2].equalsIgnoreCase("remove")) - { - String playerName = args[3]; - - if (!isWhitelisted(playerName)) - { - UtilPlayer.message(event.getPlayer(), F.main("Testing", "That player is not whitelisted!")); - } - else - { - setWhitelisted(playerName, false); - UtilPlayer.message(event.getPlayer(), F.main("Testing", "You have removed " + F.name(playerName) + " from the whitelist.")); - } - return; - } - } - - if (args.length >= 4) - { - if (args[2].equalsIgnoreCase("message")) - { - String message = ""; - for (int i = 3 ; i < args.length ; i++) - message += (args[i] + " "); - - _whitelistMessage = message.trim(); - UtilPlayer.message(event.getPlayer(), F.main("Testing", "Testing whitelist message set to " + F.elem(_whitelistMessage) + ".")); - return; - } - - sendWhitelistHelp(event.getPlayer()); - return; - } - - sendWhitelistHelp(event.getPlayer()); - return; - } - } - - private void sendGlobalHelp(Player player) - { - UtilPlayer.message(player, ""); - UtilPlayer.message(player, F.main("Testing", "/testing cap")); - UtilPlayer.message(player, F.main("Testing", "/testing whitelist")); - } - - private void sendCapHelp(Player player) - { - UtilPlayer.message(player, ""); - UtilPlayer.message(player, F.main("Testing", "/testing cap toggle")); - UtilPlayer.message(player, F.main("Testing", "/testing cap ")); - UtilPlayer.message(player, F.main("Testing", "/testing cap message ")); - } - - private void sendWhitelistHelp(Player player) - { - UtilPlayer.message(player, ""); - UtilPlayer.message(player, F.main("Testing", "/testing whitelist toggle")); - UtilPlayer.message(player, F.main("Testing", "/testing whitelist add ")); - UtilPlayer.message(player, F.main("Testing", "/testing whitelist remove ")); - UtilPlayer.message(player, F.main("Testing", "/testing whitelist message ")); - } -} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java index a4aad6220..6fafbbeae 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java @@ -14,7 +14,8 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -23,12 +24,13 @@ import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; - import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; public class IdleManager implements Listener { + public static final String BYPASS_KICK_PERMISSION = "mineplex.arcade.idle.bypass"; + private final ArcadeManager _arcadeManager; private final Map _yaw = new HashMap<>(); private final Map _idle = new HashMap<>(); @@ -39,6 +41,15 @@ public class IdleManager implements Listener { _arcadeManager = manager; UtilServer.RegisterEvents(this); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _arcadeManager.GetClients().getPermissionManager(); + + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(BYPASS_KICK_PERMISSION), true, true); } @EventHandler @@ -110,7 +121,7 @@ public class IdleManager implements Listener if (_arcadeManager.GetGame().GetState() != GameState.Recruit && !_arcadeManager.GetGame().IsAlive(player)) continue; - if (_arcadeManager.GetClients().Get(player).GetRank().has(Rank.MODERATOR)) + if (_arcadeManager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(BYPASS_KICK_PERMISSION))) continue; //Start Beeps @@ -152,4 +163,4 @@ public class IdleManager implements Listener } } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/NextBestGameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/NextBestGameManager.java index b74132e1c..65268f9dc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/NextBestGameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/NextBestGameManager.java @@ -5,11 +5,6 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; - import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Sound; @@ -26,7 +21,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import mineplex.core.Managers; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; @@ -40,7 +35,6 @@ import mineplex.core.preferences.Preference; import mineplex.serverdata.Region; import mineplex.serverdata.data.MinecraftServer; import mineplex.serverdata.servers.ServerManager; - import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.Game; @@ -50,6 +44,10 @@ import nautilus.game.arcade.game.games.halloween2016.Halloween2016; import nautilus.game.arcade.game.games.minestrike.Minestrike; import nautilus.game.arcade.game.games.paintball.Paintball; import nautilus.game.arcade.game.games.wither.WitherGame; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; /** * Controls a speed-up feature designed to keep players playing. @@ -431,7 +429,7 @@ public class NextBestGameManager implements Listener } else { - MinecraftServer server = findBestGame(_partyManager.getClientManager().Get(player).GetRank(), party); + MinecraftServer server = findBestGame(_partyManager.getClientManager().getPermissionManager().hasPermission(_partyManager.getClientManager().Get(player), GroupPermission.of(ArcadeManager.JOIN_FULL_PERMISSION)), party); if (server == null) { @@ -451,13 +449,13 @@ public class NextBestGameManager implements Listener } else { - MinecraftServer server = findBestGame(_partyManager.getClientManager().Get(player).GetRank(), null); + MinecraftServer server = findBestGame(_partyManager.getClientManager().getPermissionManager().hasPermission(_partyManager.getClientManager().Get(player), GroupPermission.of(ArcadeManager.JOIN_FULL_PERMISSION)), null); player.getInventory().clear(); sendToServer(player, server); } } - private MinecraftServer findBestGame(Rank playerRank, Party party) + private MinecraftServer findBestGame(boolean joinFull, Party party) { List servers = Lists.newArrayList(ServerManager.getServerRepository(_region).getServersByGroup(_serverGroup)); MinecraftServer server = null; @@ -508,7 +506,7 @@ public class NextBestGameManager implements Listener { if (tooFull == FULL_CAP_PLAYERCOUNT) { - if (canJoinFull(playerRank) && !FULL_CAP.contains(_serverGroup)) + if (joinFull && !FULL_CAP.contains(_serverGroup)) { server = other; break; @@ -595,11 +593,6 @@ public class NextBestGameManager implements Listener return countdown; } - private boolean canJoinFull(Rank rank) - { - return rank != null && rank != Rank.ALL; - } - private boolean isInUnjoinableState(String motd) { return (motd == null || motd.isEmpty() || @@ -658,7 +651,6 @@ public class NextBestGameManager implements Listener private final class CountdownRunnable extends BukkitRunnable { - private int _ticks = 15; private Player _player; private Party _party; @@ -702,7 +694,7 @@ public class NextBestGameManager implements Listener if (_party != null) { - MinecraftServer server = findBestGame(null, _party); + MinecraftServer server = findBestGame(false, _party); if (server == null) { @@ -719,7 +711,7 @@ public class NextBestGameManager implements Listener return; } - MinecraftServer server = findBestGame(_partyManager.getClientManager().Get(_player).GetRank(), null); + MinecraftServer server = findBestGame(_partyManager.getClientManager().getPermissionManager().hasPermission(_partyManager.getClientManager().Get(_player), GroupPermission.of(ArcadeManager.JOIN_FULL_PERMISSION)), null); if (server == null) { @@ -746,5 +738,4 @@ public class NextBestGameManager implements Listener _ticks--; } } - -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ServerUptimeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ServerUptimeManager.java index bbc63306b..2bad13a3e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ServerUptimeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ServerUptimeManager.java @@ -9,7 +9,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -83,7 +82,6 @@ public class ServerUptimeManager implements Listener System.out.println("Opening server!"); UtilServer.getServer().setWhitelist(false); - Manager.setRequiredRank(null); _closed = false; } else @@ -94,7 +92,6 @@ public class ServerUptimeManager implements Listener System.out.println("Closing server!"); _informed = System.currentTimeMillis(); _closeServer = true; - Manager.setRequiredRank(Rank.HELPER); UtilServer.getServer().setWhitelist(true); UtilServer.broadcast(F.main("Server", "Servertime expired! I will shutdown soon.")); 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 17a1cb5d8..0f09e11e4 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 @@ -15,13 +15,14 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.jooq.tools.json.JSONObject; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.party.Party; - import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; @@ -29,7 +30,10 @@ import nautilus.game.arcade.game.GameTeam; public class GameChatManager implements Listener { - + public static final String TEAM_SPY_PERMISSION = "mineplex.arcade.chat.teamspy"; + public static final String SPEC_ALWAYS_SPEAK_PERMISSION = "mineplex.arcade.chat.spectator.alwaysspeak"; + public static final String SPEC_ALWAYS_HEAR_PERMISSION = "mineplex.arcade.chat.spectator.alwayshear"; + private ArcadeManager _manager; private LinkedList _chatStats; @@ -42,9 +46,20 @@ public class GameChatManager implements Listener _manager.getPluginManager().registerEvents(this, _manager.getPlugin()); - _chatStats = new LinkedList(); + _chatStats = new LinkedList<>(); TeamSpy = true; + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _manager.GetClients().getPermissionManager(); + + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(TEAM_SPY_PERMISSION), true, true); + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(SPEC_ALWAYS_SPEAK_PERMISSION), true, true); + pm.setPermission(pm.getGroup("mod"), GroupPermission.of(SPEC_ALWAYS_HEAR_PERMISSION), true, true); } @EventHandler @@ -78,16 +93,22 @@ public class GameChatManager implements Listener //Dead Prefix String dead = ""; if (_manager.GetGame() != null) + { if (_manager.GetGame().GetTeam(sender) != null) + { if (!_manager.GetGame().IsAlive(sender)) + { dead = C.cGray + "Dead " + C.Reset; + } + } + } - Rank rank = _manager.GetClients().Get(sender).getRealOrDisguisedRank(); + PermissionGroup group = _manager.GetClients().Get(sender).getRealOrDisguisedPrimaryGroup(); //Level String levelStr = ""; if (!_manager.GetGameHostManager().isPrivateServer()) - levelStr = _manager.GetAchievement().getMineplexLevel(sender, rank); + levelStr = _manager.GetAchievement().getMineplexLevel(sender); String rankStr = ""; //Rank Prefix & MPS Host Prefix @@ -109,9 +130,9 @@ public class GameChatManager implements Listener else rankStr = C.cDGreen + C.Bold + "MPS Co-Host " + C.Reset; } - else if (rank != Rank.ALL) + else if (!group.getDisplay(false, false, false, false).isEmpty()) { - rankStr = rank.getTag(true, true) + " " + C.Reset; + rankStr = group.getDisplay(true, true, true, false) + " " + C.Reset; } //Party Chat @@ -159,7 +180,7 @@ public class GameChatManager implements Listener { event.setFormat(levelStr + rankStr + senderName + " " + C.cWhite + "%2$s"); - if (safeSend(sender, format, rankStr, rank, name, message, event.getRecipients())) + if (safeSend(sender, format, rankStr, group, name, message, event.getRecipients())) { event.setCancelled(true); } @@ -220,12 +241,12 @@ public class GameChatManager implements Listener { Player receiver = recipientIterator.next(); - if (_manager.IsAlive(sender) || _manager.GetClients().Get(sender).GetRank().has(Rank.HELPER)) + if (_manager.IsAlive(sender) || _manager.GetClients().getPermissionManager().hasPermission(sender, GroupPermission.of(SPEC_ALWAYS_SPEAK_PERMISSION))) { continue; } - if (!_manager.IsAlive(receiver) || _manager.GetClients().Get(receiver).GetRank().has(Rank.MODERATOR)) + if (!_manager.IsAlive(receiver) || _manager.GetClients().getPermissionManager().hasPermission(receiver, GroupPermission.of(SPEC_ALWAYS_HEAR_PERMISSION))) { continue; } @@ -234,7 +255,7 @@ public class GameChatManager implements Listener } } - if (safeSend(sender, format, rankStr, rank, name, message, event.getRecipients())) + if (safeSend(sender, format, rankStr, group, name, message, event.getRecipients())) { event.setCancelled(true); } @@ -248,10 +269,12 @@ public class GameChatManager implements Listener { Player receiver = recipientIterator.next(); - if (!_manager.GetServerConfig().Tournament && _manager.GetClients().Get(receiver).GetRank().has(Rank.MODERATOR)) + if (!_manager.GetServerConfig().Tournament && _manager.GetClients().getPermissionManager().hasPermission(receiver, GroupPermission.of(TEAM_SPY_PERMISSION))) { if (TeamSpy) + { continue; + } } GameTeam recTeam = _manager.GetGame().GetTeam(receiver); @@ -263,19 +286,21 @@ public class GameChatManager implements Listener } if (!recTeam.equals(sendTeam)) + { recipientIterator.remove(); + } } - if (safeSend(sender, format, rankStr, rank, name, message, event.getRecipients())) + if (safeSend(sender, format, rankStr, group, name, message, event.getRecipients())) { event.setCancelled(true); } } } - public boolean safeSend(Player sender, String prefix, String rankStr, Rank rank, String name, String message, Collection sendto) + public boolean safeSend(Player sender, String prefix, String rankStr, PermissionGroup group, String name, String message, Collection sendto) { - final JsonMessage json = buildJSON(sender, prefix, rankStr, rank, name, _chatStats, message); + final JsonMessage json = buildJSON(sender, prefix, rankStr, group, name, _chatStats, message); try { json.send(JsonMessage.MessageType.CHAT_BOX, sendto.toArray(new Player[sendto.size()])); @@ -298,18 +323,18 @@ public class GameChatManager implements Listener } } - private JsonMessage buildJSON(Player player, String prefix, String rankStr, Rank rank, String name, LinkedList hoverText, String message) + private JsonMessage buildJSON(Player player, String prefix, String rankStr, PermissionGroup group, String name, LinkedList hoverText, String message) { if (_manager.GetGame() == null || (_manager.GetGame().GetState() != GameState.Prepare && _manager.GetGame().GetState() != GameState.Live && _manager.GetGame().GetState() != GameState.End)) { - if (rank == Rank.ALL) + if (group.getDisplay(false, false, false, false).isEmpty()) { return new JsonMessage("").extra(JSONObject.escape(prefix)) .add(JSONObject.escape(rankStr)).add(JSONObject.escape(name)).add(JSONObject.escape(message)); } return new JsonMessage("").extra(JSONObject.escape(prefix)) - .add(JSONObject.escape(rankStr)).hover("show_text", rank.getColor() + rank.getTag(true, true) + C.cWhite + "\n" + rank.getDescription()) + .add(JSONObject.escape(rankStr)).hover("show_text", group.getDisplay(true, true, true, false) + C.cWhite + "\n" + group.getDescription()) .add(JSONObject.escape(name)).add(JSONObject.escape(message)); } @@ -380,14 +405,14 @@ public class GameChatManager implements Listener stats += C.cWhite + JSONObject.escape(temp.get(i).getKey()) + C.cGray + JSONObject.escape(temp.get(i).getValue()) + (i >= temp.size() - 1 ? "" : "\\n"); } - if (rank == Rank.ALL) + if (group.getDisplay(false, false, false, false).isEmpty()) { return new JsonMessage("").extra(JSONObject.escape(prefix)) .add(JSONObject.escape(rankStr)).add(JSONObject.escape(name)).hover("show_text", stats).add(JSONObject.escape(message)); } return new JsonMessage("").extra(JSONObject.escape(prefix)) - .add(JSONObject.escape(rankStr)).hover("show_text", rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()) + .add(JSONObject.escape(rankStr)).hover("show_text", group.getDisplay(true, true, true, false) + ChatColor.WHITE + "\n" + group.getDescription()) .add(JSONObject.escape(name)).hover("show_text", stats).add(JSONObject.escape(message)); } @@ -402,4 +427,4 @@ public class GameChatManager implements Listener return Double.parseDouble(new DecimalFormat(format).format(ratio)); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java index 5f83fe93d..684b89ab6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java @@ -1,34 +1,8 @@ package nautilus.game.arcade.managers.lobby; -import com.google.common.collect.Maps; +import java.io.File; +import java.util.Map; -import mineplex.core.Managers; -import mineplex.core.PlayerSelector; -import mineplex.core.account.CoreClient; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilBlockText; -import mineplex.core.common.util.UtilBlockText.TextAlign; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilLambda; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.donation.Donor; -import mineplex.core.event.CustomTagEvent; -import mineplex.core.scoreboard.MineplexScoreboard; -import mineplex.core.titles.Titles; -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.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.managers.LobbyEnt; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -53,15 +27,40 @@ import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.scoreboard.Team; -import java.io.File; -import java.util.Map; +import com.google.common.collect.Maps; + +import mineplex.core.PlayerSelector; +import mineplex.core.account.CoreClient; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlockText; +import mineplex.core.common.util.UtilBlockText.TextAlign; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilLambda; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.donation.Donor; +import mineplex.core.event.CustomTagEvent; +import mineplex.core.scoreboard.MineplexScoreboard; +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.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.managers.LobbyEnt; /** * */ public abstract class LobbyManager implements Listener { - protected static final World WORLD = Bukkit.getWorld("world"); protected final ArcadeManager _manager; @@ -513,7 +512,7 @@ public abstract class LobbyManager implements Listener return entityName; } - if (client.GetRank() == null) + if (client.getPrimaryGroup() == null) { System.out.println("client rank is null"); } @@ -533,7 +532,7 @@ public abstract class LobbyManager implements Listener (ent.GetKit().GetAvailability() == KitAvailability.Achievement && _manager.GetAchievement().hasCategory(player, ent.GetKit().getAchievementRequirement())) || //Achievement donor.ownsUnknownSalesPackage(_manager.GetGame().GetType().GetKitGameName(game) + " " + ent.GetKit().GetName()) || //Green - _manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || //STAFF + _manager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(ArcadeManager.KIT_ACCESS_PERMISSION)) || //STAFF donor.ownsUnknownSalesPackage(_manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old) _manager.GetServerConfig().Tournament) //Tournament { @@ -581,15 +580,15 @@ public abstract class LobbyManager implements Listener public void AddPlayerToScoreboards(Player player, GameTeam gameTeam) { - Rank rank; + PermissionGroup group; if (player == null) { - rank = Rank.ALL; + group = _manager.GetClients().getPermissionManager().getGroup("player"); } else { - rank = _manager.GetClients().Get(player).getRealOrDisguisedRank(); + group = _manager.GetClients().Get(player).getRealOrDisguisedPrimaryGroup(); } String teamId = getTeamId(gameTeam, player); @@ -608,13 +607,13 @@ public abstract class LobbyManager implements Listener } else { - if (rank == Rank.ALL) + if (group.getDisplay(false, false, false, false).isEmpty()) { team.setPrefix(gameTeam.GetColor() + ""); } else { - team.setPrefix(rank.getTag(true, true) + ChatColor.RESET + " " + gameTeam.GetColor()); + team.setPrefix(group.getDisplay(true, true, true, false) + ChatColor.RESET + " " + gameTeam.GetColor()); } } } @@ -628,7 +627,7 @@ public abstract class LobbyManager implements Listener public void RemovePlayerFromTeam(Player player, GameTeam gameTeam) { - Rank rank = _manager.GetClients().Get(player).getRealOrDisguisedRank(); + PermissionGroup group = _manager.GetClients().Get(player).getRealOrDisguisedPrimaryGroup(); String teamId = getTeamId(gameTeam, player); @@ -639,32 +638,32 @@ public abstract class LobbyManager implements Listener { team.removeEntry(player.getName()); } - scoreboard.getHandle().getTeam(rank.ScoreboardTag).addEntry(player.getName()); + scoreboard.getHandle().getTeam(group.getIdentifier()).addEntry(player.getName()); } } public String getTeamId(GameTeam gameTeam, Player player) { - Rank rank; + PermissionGroup group; if (player == null) { - rank = Rank.ALL; + group = _manager.GetClients().getPermissionManager().getGroup("player"); } else { - rank = _manager.GetClients().Get(player).getRealOrDisguisedRank(); + group = _manager.GetClients().Get(player).getRealOrDisguisedPrimaryGroup(); } - String rankName = rank.ScoreboardTag; + String rankName = group.getIdentifier(); if (player != null) { - boolean rankIsUltra = !rank.has(Rank.ULTRA) && + boolean rankIsUltra = group.getIdentifier().equals("player") && _manager.GetDonation().Get(player).ownsUnknownSalesPackage(_manager.GetServerConfig().ServerType + " ULTRA"); if (rankIsUltra) { - rankName = Rank.ULTRA.ScoreboardTag; + rankName = "ultra"; } } diff --git a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java index 4fbb830fa..2466d0d57 100644 --- a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java +++ b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/Hub.java @@ -159,5 +159,4 @@ public class Hub extends JavaPlugin MinecraftServer.getServer().getPropertyManager().setProperty("debug", false); SpigotConfig.debug = false; } - -} +} \ No newline at end of file diff --git a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/MavericksReviewManager.java b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/MavericksReviewManager.java index 7dfe4810f..1eb7889f9 100644 --- a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/MavericksReviewManager.java +++ b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/MavericksReviewManager.java @@ -811,6 +811,4 @@ public class MavericksReviewManager extends MiniPlugin } })); } - - -} +} \ No newline at end of file diff --git a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/ReviewData.java b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/ReviewData.java index f8c8bcab2..7df925615 100644 --- a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/ReviewData.java +++ b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/ReviewData.java @@ -41,11 +41,11 @@ public class ReviewData public void setData(MavericksBuildWrapper data) { - if(!_logg.contains(_data)) + if (!_logg.contains(_data)) { _logg.add(_data); } - if(!_logg.contains(data)) + if (!_logg.contains(data)) { _logg.add(data); } @@ -56,10 +56,13 @@ public class ReviewData { int index = _logg.indexOf(_data); - if(index <= 0) return null; + if (index <= 0) + { + return null; + } MavericksBuildWrapper data = _logg.get(index-1); - if(data != null && data.isReviewed()) + if (data != null && data.isReviewed()) { _data = data; return getPrevious(); @@ -71,11 +74,17 @@ public class ReviewData { int index = _logg.indexOf(_data); - if(index == -1) return null; - if(index+1 >= _logg.size()) return null; + if (index == -1) + { + return null; + } + if (index+1 >= _logg.size()) + { + return null; + } MavericksBuildWrapper data = _logg.get(index+1); - if(data != null && data.isReviewed()) + if (data != null && data.isReviewed()) { _data = data; return getNext(); @@ -101,10 +110,16 @@ public class ReviewData public List getEntitiesInArea() { List list = new ArrayList<>(); - for(Entity e : _loc.getWorld().getEntities()) + for (Entity e : _loc.getWorld().getEntities()) { - if(e instanceof Player) continue; - if(isInsideArea(e.getLocation())) list.add(e); + if (e instanceof Player) + { + continue; + } + if (isInsideArea(e.getLocation())) + { + list.add(e); + } } return list; } @@ -113,5 +128,4 @@ public class ReviewData { return loc.toVector().isInAABB(getAreaMin().toVector(), getAreaMax().toVector()); } - -} +} \ No newline at end of file diff --git a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/SimpleChatManager.java b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/SimpleChatManager.java index c900b060a..634a23440 100644 --- a/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/SimpleChatManager.java +++ b/Plugins/mavericks-review-hub/src/mineplex/mavericks/review/SimpleChatManager.java @@ -9,8 +9,8 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.achievement.AchievementManager; -import mineplex.core.common.Rank; import mineplex.core.common.util.UtilServer; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; @@ -21,8 +21,7 @@ import net.md_5.bungee.api.chat.TextComponent; * A simple manager for formating the chat */ public class SimpleChatManager extends MiniPlugin -{ - +{ private CoreClientManager _coreClientManager; private AchievementManager _achievementManager; @@ -37,26 +36,30 @@ public class SimpleChatManager extends MiniPlugin public void PlayerChat(AsyncPlayerChatEvent event) { if (event.isCancelled()) + { return; + } Player player = event.getPlayer(); String playerName = player.getName(); - Rank rank = _coreClientManager.Get(player).getRealOrDisguisedRank(); - //Level Prefix - String levelStr = _achievementManager.getMineplexLevel(player, rank); + String levelStr = _achievementManager.getMineplexLevel(player); + + PermissionGroup group = _coreClientManager.Get(player).getRealOrDisguisedPrimaryGroup(); //Rank Prefix String rankStr = ""; - if (rank != Rank.ALL) - rankStr = rank.getTag(true, true) + " "; + if (!group.getDisplay(false, false, false, false).isEmpty()) + { + rankStr = group.getDisplay(true, true, true, false) + " "; + } TextComponent rankComponent = new TextComponent(rankStr); TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + playerName); TextComponent component = new TextComponent(); - rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()).create())); + rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(group.getDisplay(true, true, true, true) + ChatColor.WHITE + "\n" + group.getDescription()).create())); component.setText(levelStr); component.addExtra(rankComponent); @@ -72,13 +75,12 @@ public class SimpleChatManager extends MiniPlugin // event.setMessage(event.getMessage()); // event.setFormat(levelStr + rankStr + C.cYellow + playerName + " " + C.cWhite + "%2$s"); - if(!event.isCancelled()) + if (!event.isCancelled()) + { other.spigot().sendMessage(component); + } } Bukkit.getConsoleSender().sendMessage(component.toLegacyText()); event.setCancelled(true); - } - - -} +} \ No newline at end of file diff --git a/Plugins/mavericks-review-hub/src/nautilus/game/arcade/ArcadeFormat.java b/Plugins/mavericks-review-hub/src/nautilus/game/arcade/ArcadeFormat.java index 2fd9cfca7..5e2fb4591 100644 --- a/Plugins/mavericks-review-hub/src/nautilus/game/arcade/ArcadeFormat.java +++ b/Plugins/mavericks-review-hub/src/nautilus/game/arcade/ArcadeFormat.java @@ -1,10 +1,11 @@ package nautilus.game.arcade; import mineplex.core.common.util.C; + /** * Copy from {@link nautilus.game.arcade.ArcadeFormat} */ public class ArcadeFormat { public static String Line = C.cDGreen + C.Strike + "============================================="; -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index a010a5ac6..7f87ee998 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -1,5 +1,13 @@ package mineplex.gemhunters; +import static mineplex.core.Managers.require; + +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.plugin.java.JavaPlugin; +import org.spigotmc.SpigotConfig; + import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; import mineplex.core.account.CoreClientManager; @@ -82,7 +90,6 @@ import mineplex.gemhunters.shop.ShopModule; import mineplex.gemhunters.spawn.SpawnModule; import mineplex.gemhunters.supplydrop.SupplyDropModule; import mineplex.gemhunters.tutorial.GemHuntersTutorial; -import mineplex.gemhunters.world.DebugListeners; import mineplex.gemhunters.world.Leaderboards; import mineplex.gemhunters.world.TimeCycle; import mineplex.gemhunters.world.UndergroundMobs; @@ -92,13 +99,6 @@ import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; import net.minecraft.server.v1_8_R3.MinecraftServer; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.plugin.java.JavaPlugin; -import org.spigotmc.SpigotConfig; - -import static mineplex.core.Managers.require; /** * Gem Hunters main class
@@ -189,7 +189,8 @@ public class GemHunters extends JavaPlugin // GWEN AntiHack antiHack = require(AntiHack.class); - Bukkit.getScheduler().runTask(this, () -> { + Bukkit.getScheduler().runTask(this, () -> + { antiHack.setStrict(true); antiHack.enableAnticheat(); }); @@ -298,7 +299,6 @@ public class GemHunters extends JavaPlugin new WorldListeners(this); new TimeCycle(this); new UndergroundMobs(this); - new DebugListeners(this); new Leaderboards(); // UpdateEvent!!! @@ -323,5 +323,4 @@ public class GemHunters extends JavaPlugin { getServer().getPluginManager().callEvent(new ServerShutdownEvent(this)); } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/chat/ChatModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/chat/ChatModule.java index f53b1eb44..61286d772 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/chat/ChatModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/chat/ChatModule.java @@ -1,7 +1,5 @@ package mineplex.gemhunters.chat; -import mineplex.gemhunters.economy.EconomyModule; -import mineplex.gemhunters.progression.ProgressionModule; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -12,12 +10,14 @@ import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.chat.Chat; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.party.Party; import mineplex.core.party.PartyManager; +import mineplex.gemhunters.economy.EconomyModule; +import mineplex.gemhunters.progression.ProgressionModule; /** * This module handles player chat. @@ -67,8 +67,8 @@ public class ChatModule extends MiniPlugin Player player = event.getPlayer(); String playerName = player.getName(); - Rank rank = _clientManager.Get(player).getRealOrDisguisedRank(); - String rankString = rank == Rank.ALL ? "" : rank.getTag(true, true); + PermissionGroup group = _clientManager.Get(player).getRealOrDisguisedPrimaryGroup(); + String rankString = group.getDisplay(false, false, false, false).isEmpty() ? "" : group.getDisplay(true, true, true, false); // Create a message that follows the rest of the network's chat format String message = (rankString + " " + C.cYellow + playerName + " "); @@ -108,5 +108,4 @@ public class ChatModule extends MiniPlugin other.sendMessage(message); } } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java index d64c059d3..3702b2fd3 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java @@ -1,7 +1,11 @@ package mineplex.gemhunters.economy; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -46,7 +50,9 @@ import java.util.UUID; @ReflectivelyCreateMiniPlugin public class CashOutModule extends MiniPlugin { - + public static final String CASH_OUT_ITEM_COMMAND_PERMISSION = "mineplex.gemhunters.economy.cashoutitem"; + public static final String RESET_COOLDOWN_COMMAND_PERMISSION = "mineplex.gemhunters.economy.resetcooldown"; + private static final DecimalFormat ARMOUR_STAND_FORMAT = new DecimalFormat("0.0"); public static final ItemStack CASH_OUT_ITEM = new ItemBuilder(Material.EMERALD).setTitle(C.cGreen + "Cash Out").addLore("", "Click to begin the process to cash out.", "Cashing out gives you your gems, shards,", "chests and any particles you have.", "However you will lose all your current loot!").build(); @@ -69,6 +75,16 @@ public class CashOutModule extends MiniPlugin _sessions = new HashMap<>(); _aboutToCashOut = new HashSet<>(); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(CASH_OUT_ITEM_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(RESET_COOLDOWN_COMMAND_PERMISSION), true, true); } @Override @@ -313,5 +329,4 @@ public class CashOutModule extends MiniPlugin { player.kickPlayer(C.cGreen + "Imagine you are being sent to the lobby."); } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java index 9fac54ea7..bab9b4046 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java @@ -1,7 +1,16 @@ package mineplex.gemhunters.economy; +import java.util.UUID; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.PlayerDeathEvent; + import mineplex.core.MiniClientPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; @@ -11,17 +20,12 @@ import mineplex.gemhunters.economy.command.GiveGemsCommand; import mineplex.gemhunters.economy.event.PlayerCashOutCompleteEvent; import mineplex.gemhunters.economy.event.PlayerEarnGemsEvent; import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.PlayerDeathEvent; - -import java.util.UUID; @ReflectivelyCreateMiniPlugin public class EconomyModule extends MiniClientPlugin { - + public static final String GIVE_GEMS_COMMAND_PERMISSION = "mineplex.gemhunters.economy.givegems"; + public static final float GEM_KILL_FACTOR = 0.5F; public static final int GEM_START_COST = 100; @@ -35,6 +39,15 @@ public class EconomyModule extends MiniClientPlugin super("Economy"); _donation = require(DonationManager.class); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = _donation.getClientManager().getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(GIVE_GEMS_COMMAND_PERMISSION), true, true); } @Override @@ -140,4 +153,4 @@ public class EconomyModule extends MiniClientPlugin { return 0; } -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/command/CashOutItemCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/command/CashOutItemCommand.java index 8479a5088..81724cdbf 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/command/CashOutItemCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/command/CashOutItemCommand.java @@ -3,16 +3,14 @@ package mineplex.gemhunters.economy.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.gemhunters.economy.CashOutModule; public class CashOutItemCommand extends CommandBase { - public CashOutItemCommand(CashOutModule plugin) { - super(plugin, Rank.ALL, "cashout", "ct", "cashitem", "cashoutitem"); + super(plugin, CashOutModule.CASH_OUT_ITEM_COMMAND_PERMISSION, "cashout", "ct", "cashitem", "cashoutitem"); } @Override @@ -26,5 +24,4 @@ public class CashOutItemCommand extends CommandBase caller.sendMessage(F.main(Plugin.getName(), "Giving you a new cash out item.")); caller.getInventory().addItem(CashOutModule.CASH_OUT_ITEM); } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/command/GiveGemsCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/command/GiveGemsCommand.java index c658546d2..56a33a296 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/command/GiveGemsCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/command/GiveGemsCommand.java @@ -1,19 +1,18 @@ package mineplex.gemhunters.economy.command; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.gemhunters.economy.EconomyModule; public class GiveGemsCommand extends CommandBase { - public GiveGemsCommand(EconomyModule plugin) { - super(plugin, Rank.ADMIN, "givegems"); + super(plugin, EconomyModule.GIVE_GEMS_COMMAND_PERMISSION, "givegems"); } @Override @@ -21,7 +20,7 @@ public class GiveGemsCommand extends CommandBase { if (args.length < 2) { - caller.sendMessage(F.help("/" + _aliasUsed + " ", "Adds an amount of gems to a player's gems earned.", Rank.ADMIN)); + caller.sendMessage(F.help("/" + _aliasUsed + " ", "Adds an amount of gems to a player's gems earned.", ChatColor.DARK_RED)); return; } @@ -43,5 +42,4 @@ public class GiveGemsCommand extends CommandBase caller.sendMessage(F.main(Plugin.getName(), "That is not a number.")); } } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/command/ResetCooldownCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/command/ResetCooldownCommand.java index f95a82f8f..baa590794 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/command/ResetCooldownCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/command/ResetCooldownCommand.java @@ -1,17 +1,16 @@ package mineplex.gemhunters.economy.command; +import org.bukkit.entity.Player; + import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.recharge.Recharge; import mineplex.gemhunters.economy.CashOutModule; -import org.bukkit.entity.Player; public class ResetCooldownCommand extends CommandBase { - public ResetCooldownCommand(CashOutModule plugin) { - super(plugin, Rank.DEVELOPER, "resetcashout"); + super(plugin, CashOutModule.RESET_COOLDOWN_COMMAND_PERMISSION, "resetcashout"); } @Override @@ -19,5 +18,4 @@ public class ResetCooldownCommand extends CommandBase { Recharge.Instance.useForce(caller, "Cash Out", 0); } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java index 07e0afb7c..31ef09684 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java @@ -1,7 +1,11 @@ package mineplex.gemhunters.loot; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; @@ -61,7 +65,9 @@ import java.util.concurrent.TimeUnit; @ReflectivelyCreateMiniPlugin public class LootModule extends MiniPlugin { - + public static final String SPAWN_CHEST_COMMAND_PERMISSION = "mineplex.gemhunters.loot.spawn"; + public static final String UPDATE_LOOT_COMMAND_PERMISSION = "mineplex.gemhunters.loot.update"; + private static final String SHEET_FILE_NAME = "GEM_HUNTERS_CHESTS"; private static final String CHEST_MASTER_SHEET_NAME = "CHEST_MASTER"; private static final long CHEST_DESPAWN_TIME_OPENED = TimeUnit.SECONDS.toMillis(15); @@ -70,7 +76,8 @@ public class LootModule extends MiniPlugin private static final int MAX_CHEST_CHECK_DISTANCE_SQUARED = 4; private static final LootItemDeserialiser DESERIALISER = new LootItemDeserialiser(); private static final ChestPropertiesDeserialiser CHEST_DESERIALISER = new ChestPropertiesDeserialiser(); - private static final ItemStack[] SPAWN_ITEMS = { + private static final ItemStack[] SPAWN_ITEMS = + { new ItemStack(Material.WOOD_SWORD), new ItemStack(Material.APPLE, 3), }; @@ -103,8 +110,8 @@ public class LootModule extends MiniPlugin _itemRewards = new HashSet<>(); _shownPlayers = new HashSet<>(); - runSyncLater(() -> { - + runSyncLater(() -> + { updateChestLoot(); // Spawn some chests @@ -117,8 +124,17 @@ public class LootModule extends MiniPlugin addSpawnedChest(key, true); } } - }, 20); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SPAWN_CHEST_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(UPDATE_LOOT_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/command/SpawnChestCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/command/SpawnChestCommand.java index 9e0040952..96301c1f1 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/command/SpawnChestCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/command/SpawnChestCommand.java @@ -1,20 +1,19 @@ package mineplex.gemhunters.loot.command; +import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.gemhunters.loot.LootModule; public class SpawnChestCommand extends CommandBase -{ - +{ public SpawnChestCommand(LootModule plugin) { - super(plugin, Rank.ADMIN, "spawnchest"); + super(plugin, LootModule.SPAWN_CHEST_COMMAND_PERMISSION, "spawnchest"); } @Override @@ -22,7 +21,7 @@ public class SpawnChestCommand extends CommandBase { if (args.length == 0) { - caller.sendMessage(F.help("/" + _aliasUsed + " ", "Spawns a chest at your location.", GetRequiredRank())); + caller.sendMessage(F.help("/" + _aliasUsed + " ", "Spawns a chest at your location.", ChatColor.DARK_RED)); return; } @@ -43,5 +42,4 @@ public class SpawnChestCommand extends CommandBase caller.getLocation().getBlock().setType(Material.CHEST); Plugin.addSpawnedChest(caller.getLocation(), colour); } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/command/UpdateLootCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/command/UpdateLootCommand.java index c556148a8..ea17046b2 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/command/UpdateLootCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/command/UpdateLootCommand.java @@ -3,7 +3,6 @@ package mineplex.gemhunters.loot.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.gemhunters.loot.LootModule; @@ -13,10 +12,9 @@ import mineplex.gemhunters.loot.LootModule; */ public class UpdateLootCommand extends CommandBase { - public UpdateLootCommand(LootModule plugin) { - super(plugin, Rank.ADMIN, "updateloot"); + super(plugin, LootModule.UPDATE_LOOT_COMMAND_PERMISSION, "updateloot"); } @Override @@ -29,5 +27,4 @@ public class UpdateLootCommand extends CommandBase caller.sendMessage(F.main(Plugin.getName(), "This command is currently disabled due to development issues.")); } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootRankReward.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootRankReward.java index e0e592fd3..0a50f4377 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootRankReward.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootRankReward.java @@ -2,20 +2,19 @@ package mineplex.gemhunters.loot.rewards; import java.util.concurrent.TimeUnit; -import mineplex.gemhunters.util.SlackRewardBot; import org.bukkit.inventory.ItemStack; import mineplex.core.Managers; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.core.donation.DonationManager; +import mineplex.gemhunters.util.SlackRewardBot; public class LootRankReward extends LootItemReward { - private static final long CASH_OUT_DELAY = TimeUnit.MINUTES.toMillis(15); private static final int CONSOLATION_PRICE = 10000; @@ -31,55 +30,53 @@ public class LootRankReward extends LootItemReward } @Override - public void onCollectItem() - { - } + public void onCollectItem() {} @Override public void onSuccessful() { CoreClient client = _clientManager.Get(_player); - Rank rank = client.GetRank(); - Rank newRank = null; + PermissionGroup group = client.getPrimaryGroup(); + PermissionGroup newGroup = null; // I could have done this so it runs off the order of the Rank enum, // however knowing some people that might get changed so I'm just going // to hard code what you get. - switch (rank) + switch (group.getIdentifier()) { - case ALL: - newRank = Rank.ULTRA; + case "player": + newGroup = _clientManager.getPermissionManager().getGroup("ultra"); break; - case ULTRA: - newRank = Rank.HERO; + case "ultra": + newGroup = _clientManager.getPermissionManager().getGroup("hero"); break; - case HERO: - newRank = Rank.LEGEND; + case "hero": + newGroup = _clientManager.getPermissionManager().getGroup("legend"); break; - case LEGEND: - newRank = Rank.TITAN; + case "legend": + newGroup = _clientManager.getPermissionManager().getGroup("titan"); break; - case TITAN: - newRank = Rank.ETERNAL; + case "titan": + newGroup = _clientManager.getPermissionManager().getGroup("eternal"); break; default: break; } // A suitable rank could not be found. - if (newRank == null) + if (newGroup == null) { - _player.sendMessage(F.main("Loot", "Since you already have eternal ( You are lucky :) ). So instead you can have " + CONSOLATION_PRICE + " shards.")); + _player.sendMessage(F.main("Loot", "You already have eternal ( You are lucky :) ). So instead you can have " + CONSOLATION_PRICE + " shards.")); _donation.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, _player, "Earned", CONSOLATION_PRICE, success -> SlackRewardBot.logReward(_player, this, (success ? "Success" : "Failure") + " (Shard Dupe)")); return; } - _clientManager.SaveRank(callback -> SlackRewardBot.logReward(_player, this, callback.Name), _player.getName(), _player.getUniqueId(), newRank, true); + final String status = newGroup.getIdentifier(); + + _clientManager.setPrimaryGroup(_player, newGroup, () -> SlackRewardBot.logReward(_player, this, status)); } @Override - public void onDeath() - { - } -} + public void onDeath() {} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/ItemMapModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/ItemMapModule.java index c556b8273..9664c8827 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/ItemMapModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/ItemMapModule.java @@ -40,8 +40,12 @@ import com.google.common.collect.HashMultiset; import com.google.common.collect.Iterables; import com.google.common.collect.Multisets; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEvent; @@ -76,6 +80,8 @@ import net.minecraft.server.v1_8_R3.WorldServer; @ReflectivelyCreateMiniPlugin public class ItemMapModule extends MiniPlugin { + public static final String MAP_COMMAND_PERMISSION = "mineplex.gemhunters.map.command"; + // Every BLOCK_SCAN_INTERVAL we add as a new region to scan private static final int BLOCK_SCAN_INTERVAL = 16 * 3; // 1536 is the width of the entire world from one borderland to the other @@ -293,6 +299,15 @@ public class ItemMapModule extends MiniPlugin rebuildScan(); initialScan(); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(MAP_COMMAND_PERMISSION), true, true); } private void initialScan() diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/command/MapCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/command/MapCommand.java index 6464457ef..81af9692d 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/command/MapCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/command/MapCommand.java @@ -3,16 +3,14 @@ package mineplex.gemhunters.map.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.gemhunters.map.ItemMapModule; public class MapCommand extends CommandBase { - public MapCommand(ItemMapModule plugin) { - super(plugin, Rank.ALL, "map", "getmap"); + super(plugin, ItemMapModule.MAP_COMMAND_PERMISSION, "map", "getmap"); } @Override @@ -21,5 +19,4 @@ public class MapCommand extends CommandBase caller.sendMessage(F.main(Plugin.getName(), "Giving you a new map.")); Plugin.setMap(caller); } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/moderation/ModerationModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/moderation/ModerationModule.java index 8d1c4baf4..f3ef916ec 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/moderation/ModerationModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/moderation/ModerationModule.java @@ -8,12 +8,14 @@ import org.bukkit.GameMode; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; -import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.incognito.IncognitoManager; import mineplex.core.incognito.events.IncognitoStatusChangeEvent; @@ -25,7 +27,10 @@ import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent; @ReflectivelyCreateMiniPlugin public class ModerationModule extends MiniPlugin { - + public static final String MODERATOR_MODE_COMMAND_PERMISSION = "mineplex.gemhunters.moderation.command"; + public static final String MODERATOR_MODE_BYPASS_PERMISSION = "mineplex.gemhunters.moderation.bypass"; + public static final String AUTO_OP_PERMISSION = "mineplex.gemhunters.moderation.autoop"; + private final CoreClientManager _client; private final IncognitoManager _incognito; private final SpawnModule _spawn; @@ -41,6 +46,17 @@ public class ModerationModule extends MiniPlugin _spawn = require(SpawnModule.class); _moderators = new HashSet<>(); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(MODERATOR_MODE_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(MODERATOR_MODE_BYPASS_PERMISSION), true, true); + pm.setPermission(pm.getGroup("dev"), GroupPermission.of(AUTO_OP_PERMISSION), true, true); } @Override @@ -94,6 +110,19 @@ public class ModerationModule extends MiniPlugin enableModeratorMode(player); } + + @EventHandler + public void autoOp(PlayerJoinEvent event) + { + if (_client.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(AUTO_OP_PERMISSION))) + { + event.getPlayer().setOp(true); + } + else + { + event.getPlayer().setOp(false); + } + } public void enableModeratorMode(Player player) { @@ -125,8 +154,6 @@ public class ModerationModule extends MiniPlugin public boolean isBypassing(Player player) { - CoreClient client = _client.Get(player); - return client.GetRank().has(Rank.ADMIN); + return _client.getPermissionManager().hasPermission(player, GroupPermission.of(MODERATOR_MODE_BYPASS_PERMISSION)); } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/moderation/command/ModeratorModeCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/moderation/command/ModeratorModeCommand.java index 6a2faa9ee..3e9d8a0a2 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/moderation/command/ModeratorModeCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/moderation/command/ModeratorModeCommand.java @@ -3,15 +3,13 @@ package mineplex.gemhunters.moderation.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.gemhunters.moderation.ModerationModule; public class ModeratorModeCommand extends CommandBase { - public ModeratorModeCommand(ModerationModule plugin) { - super(plugin, Rank.HELPER, "modmode", "staffmode", "mm", "o"); + super(plugin, ModerationModule.MODERATOR_MODE_COMMAND_PERMISSION, "modmode", "staffmode", "mm", "o"); } @Override @@ -25,7 +23,5 @@ public class ModeratorModeCommand extends CommandBase { Plugin.enableModeratorMode(caller); } - } - - -} + } +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java index 305b1f9c8..a37b8a945 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java @@ -24,8 +24,12 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.metadata.FixedMetadataValue; +import mineplex.core.Managers; import mineplex.core.MiniClientPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.UtilItem.ItemAttribute; import mineplex.core.itemstack.ItemBuilder; @@ -49,14 +53,16 @@ import mineplex.gemhunters.world.WorldDataModule; @ReflectivelyCreateMiniPlugin public class QuestModule extends MiniClientPlugin { - + public static final String RESET_QUESTS_COMMAND_PERMISSION = "mineplex.gemhunters.quest.reset"; + private static final int MAX_QUESTS = 5; private static final long RESET_QUESTS_TIME = TimeUnit.MINUTES.toMillis(15); private static final Material MATERIAL = Material.PAPER; private static final String ITEM_METADATA = "quest"; // -1 for the reward dictates that the quest's reward will be handled by the subclass - private final Quest[] _quests = { + private final Quest[] _quests = + { new ChestOpenerQuest(0, "Chest Opener", 100, 250, 5), new ChestOpenerQuest(1, "Grand Chest Opener", 200, 500, 20), new ChestOpenerQuest(2, "Superior Chest Opener", 500, 750, 40), @@ -103,13 +109,20 @@ public class QuestModule extends MiniClientPlugin runSyncLater(() -> { - for (Location location : _worldData.getCustomLocation("QUEST_NPC")) { new QuestNPC(this, location, menu); } - }, 20); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(RESET_QUESTS_COMMAND_PERMISSION), true, true); } @Override @@ -513,4 +526,4 @@ public class QuestModule extends MiniClientPlugin } } } -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/command/ResetQuestsCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/command/ResetQuestsCommand.java index c1b29f3ae..6c92c19e2 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/command/ResetQuestsCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/command/ResetQuestsCommand.java @@ -3,7 +3,6 @@ package mineplex.gemhunters.quest.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.gemhunters.quest.QuestModule; @@ -11,10 +10,9 @@ import mineplex.gemhunters.quest.QuestPlayerData; public class ResetQuestsCommand extends CommandBase { - public ResetQuestsCommand(QuestModule plugin) { - super(plugin, Rank.ADMIN, "resetquest"); + super(plugin, QuestModule.RESET_QUESTS_COMMAND_PERMISSION, "resetquest"); } @Override @@ -43,5 +41,4 @@ public class ResetQuestsCommand extends CommandBase playerData.clear(); Plugin.updateQuests(target); } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java index 6b1e7fda7..5188b76bc 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java @@ -1,10 +1,5 @@ package mineplex.gemhunters.spawn; -import mineplex.core.common.util.*; -import mineplex.core.recharge.Recharge; -import mineplex.gemhunters.playerstatus.PlayerStatus; -import mineplex.gemhunters.playerstatus.PlayerStatusModule; -import mineplex.gemhunters.playerstatus.PlayerStatusType; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -20,14 +15,25 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitRunnable; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; import mineplex.core.portal.Portal; +import mineplex.core.recharge.Recharge; import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent; -import mineplex.gemhunters.death.quitnpc.QuitNPC; -import mineplex.gemhunters.death.quitnpc.QuitNPCModule; +import mineplex.gemhunters.playerstatus.PlayerStatusModule; +import mineplex.gemhunters.playerstatus.PlayerStatusType; import mineplex.gemhunters.safezone.SafezoneModule; import mineplex.gemhunters.spawn.command.HubCommand; import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent; @@ -38,7 +44,8 @@ import mineplex.gemhunters.world.WorldDataModule; @ReflectivelyCreateMiniPlugin public class SpawnModule extends MiniPlugin { - + public static final String HUB_COMMAND_PERMISSION = "mineplex.gemhunters.spawn.hub"; + public static final int WORLD_BORDER_RADIUS = 1024; private static final int MAX_SPAWNING_Y = 73; private static final int MIN_PLAYER_DISTANCE_SQUARED = 6400; @@ -58,6 +65,15 @@ public class SpawnModule extends MiniPlugin _status = require(PlayerStatusModule.class); _safezone = require(SafezoneModule.class); _worldData = require(WorldDataModule.class); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("player"), GroupPermission.of(HUB_COMMAND_PERMISSION), true, true); } @Override diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/command/HubCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/command/HubCommand.java index 803fe5256..990d3d62b 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/command/HubCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/command/HubCommand.java @@ -3,7 +3,6 @@ package mineplex.gemhunters.spawn.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; import mineplex.core.portal.Portal; @@ -11,10 +10,9 @@ import mineplex.gemhunters.spawn.SpawnModule; public class HubCommand extends CommandBase { - public HubCommand(SpawnModule plugin) { - super(plugin, Rank.ALL, "hub", "lobby"); + super(plugin, SpawnModule.HUB_COMMAND_PERMISSION, "hub", "lobby"); } @Override @@ -22,5 +20,4 @@ public class HubCommand extends CommandBase { Portal.getInstance().sendPlayerToGenericServer(caller, GenericServer.HUB, Intent.PLAYER_REQUEST); } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/SupplyDropModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/SupplyDropModule.java index 54816bcbf..ad124fa42 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/SupplyDropModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/SupplyDropModule.java @@ -1,36 +1,51 @@ package mineplex.gemhunters.supplydrop; -import mineplex.core.MiniPlugin; -import mineplex.core.ReflectivelyCreateMiniPlugin; -import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.common.Pair; -import mineplex.core.common.util.*; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.gemhunters.loot.LootModule; -import mineplex.gemhunters.supplydrop.command.SupplyDropCommand; -import mineplex.gemhunters.world.WorldDataModule; -import org.bukkit.Color; -import org.bukkit.FireworkEffect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.FallingBlock; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.scheduler.BukkitRunnable; - import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.scheduler.BukkitRunnable; + +import mineplex.core.Managers; +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.Pair; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.gemhunters.loot.LootModule; +import mineplex.gemhunters.supplydrop.command.SupplyDropCommand; +import mineplex.gemhunters.world.WorldDataModule; + @ReflectivelyCreateMiniPlugin public class SupplyDropModule extends MiniPlugin { - + public static final String SUPPLY_DROP_COMMAND_PERMISSION = "mineplex.gemhunters.supplydrop.command"; + public static final String START_SUPPLY_DROP_COMMAND_PERMISSION = "mineplex.gemhunters.supplydrop.start"; + public static final String STOP_SUPPLY_DROP_COMMAND_PERMISSION = "mineplex.gemhunters.supplydrop.stop"; + private static final long SEQUENCE_TIMER = TimeUnit.MINUTES.toMillis(20); private static final String CHEST_COLOUR = "RED"; @@ -58,6 +73,17 @@ public class SupplyDropModule extends MiniPlugin _beaconBlocks = new HashSet<>(); _lastSupplyDrop = System.currentTimeMillis(); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(SUPPLY_DROP_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(START_SUPPLY_DROP_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(STOP_SUPPLY_DROP_COMMAND_PERMISSION), true, true); } @Override @@ -231,4 +257,4 @@ public class SupplyDropModule extends MiniPlugin return _locationKeys; } -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/command/EndCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/command/EndCommand.java index 3265371b6..078bfaa73 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/command/EndCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/command/EndCommand.java @@ -3,16 +3,14 @@ package mineplex.gemhunters.supplydrop.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.gemhunters.supplydrop.SupplyDropModule; public class EndCommand extends CommandBase { - public EndCommand(SupplyDropModule plugin) { - super(plugin, Rank.ADMIN, "stop"); + super(plugin, SupplyDropModule.STOP_SUPPLY_DROP_COMMAND_PERMISSION, "stop"); } @Override @@ -27,5 +25,4 @@ public class EndCommand extends CommandBase caller.sendMessage(F.main(Plugin.getName(), "Stopping the current supply drop.")); Plugin.stopSequence(); } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/command/StartCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/command/StartCommand.java index 5df5d9188..25a357906 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/command/StartCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/command/StartCommand.java @@ -3,17 +3,15 @@ package mineplex.gemhunters.supplydrop.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.gemhunters.supplydrop.SupplyDropModule; public class StartCommand extends CommandBase { - public StartCommand(SupplyDropModule plugin) { - super(plugin, Rank.ADMIN, "start"); + super(plugin, SupplyDropModule.START_SUPPLY_DROP_COMMAND_PERMISSION, "start"); } @Override @@ -48,14 +46,15 @@ public class StartCommand extends CommandBase } else { - String input = ""; + StringBuilder inputBuilder = new StringBuilder(); for (int i = 0; i < args.length; i++) { - input += args[i] + " "; + inputBuilder.append(args[i]); + inputBuilder.append(" "); } - input = input.trim(); + String input = inputBuilder.toString().trim(); for (String key : Plugin.getLocationKeys()) { @@ -75,5 +74,4 @@ public class StartCommand extends CommandBase } } } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/command/SupplyDropCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/command/SupplyDropCommand.java index 3e0db5ba7..2b38bab40 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/command/SupplyDropCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/command/SupplyDropCommand.java @@ -1,18 +1,17 @@ package mineplex.gemhunters.supplydrop.command; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.gemhunters.supplydrop.SupplyDropModule; public class SupplyDropCommand extends MultiCommandBase { - public SupplyDropCommand(SupplyDropModule plugin) { - super(plugin, Rank.ADMIN, "supplydrop", "supply", "sd"); + super(plugin, SupplyDropModule.SUPPLY_DROP_COMMAND_PERMISSION, "supplydrop", "supply", "sd"); AddCommand(new StartCommand(plugin)); AddCommand(new EndCommand(plugin)); @@ -22,8 +21,7 @@ public class SupplyDropCommand extends MultiCommandBase protected void Help(Player caller, String[] args) { caller.sendMessage(F.main(Plugin.getName(), "Command List:")); - caller.sendMessage(F.help("/" + _aliasUsed + " start [location]", "Starts the supply drop sequence at a certain location. Leaving [location] blank picks a random one.", Rank.ADMIN)); - caller.sendMessage(F.help("/" + _aliasUsed + " stop", "Stops the current supply drop.", Rank.ADMIN)); + caller.sendMessage(F.help("/" + _aliasUsed + " start [location]", "Starts the supply drop sequence at a certain location. Leaving [location] blank picks a random one.", ChatColor.DARK_RED)); + caller.sendMessage(F.help("/" + _aliasUsed + " stop", "Stops the current supply drop.", ChatColor.DARK_RED)); } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/util/SlackRewardBot.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/util/SlackRewardBot.java index 923bae01e..0bc203bed 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/util/SlackRewardBot.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/util/SlackRewardBot.java @@ -42,9 +42,6 @@ public class SlackRewardBot "\nTPS: " + FORMAT.format(_lag.getTicksPerSecond())), true); } - catch (MalformedURLException e) - { - } + catch (MalformedURLException e) {} } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/DebugListeners.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/DebugListeners.java deleted file mode 100644 index 8e59d81e4..000000000 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/DebugListeners.java +++ /dev/null @@ -1,30 +0,0 @@ -package mineplex.gemhunters.world; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.plugin.java.JavaPlugin; - -public class DebugListeners implements Listener -{ - - private static final String[] OPS = { "Moppletop" }; - - public DebugListeners(JavaPlugin plugin) - { - plugin.getServer().getPluginManager().registerEvents(this, plugin); - } - - @EventHandler - public void autoOp(PlayerJoinEvent event) - { - for (String s : OPS) - { - if (s.equals(event.getPlayer().getName())) - { - event.getPlayer().setOp(true); - } - } - } - -} diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/Leaderboards.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/Leaderboards.java index 5ef1793f0..2c6edf938 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/Leaderboards.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/Leaderboards.java @@ -9,7 +9,6 @@ import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; public class Leaderboards { - private final LeaderboardManager _manager; private final WorldDataModule _worldData; @@ -29,5 +28,4 @@ public class Leaderboards _manager.registerLeaderboard("TOP_GEM_HUNTERS_GEMS", new Leaderboard("Top Gems Cashed Out", Pair.create("Gem", "Gems"), new String[] {"Gem Hunters.GemsEarned"}, LeaderboardSQLType.ALL, _worldData.getCustomLocation("TOP_GEMS").get(0), 10)); _manager.registerLeaderboard("TOP_GEM_HUNTERS_DAILY_GEMS", new Leaderboard("Top Daily Gems Cashed Out", Pair.create("Gem", "Gems"), new String[] {"Gem Hunters.GemsEarned"}, LeaderboardSQLType.DAILY, _worldData.getCustomLocation("TOP_DAILY_GEMS").get(0), 10)); } -} - +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/TimeCycle.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/TimeCycle.java index fa5c4b52c..33574a55b 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/TimeCycle.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/TimeCycle.java @@ -11,7 +11,6 @@ import mineplex.core.updater.event.UpdateEvent; public class TimeCycle implements Listener { - private static final int TICKS_DAY = 1; private static final int TICKS_NIGHT = 2; @@ -59,5 +58,4 @@ public class TimeCycle implements Listener { return _world.getTime() > 12000; } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/UndergroundMobs.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/UndergroundMobs.java index 74c8c5a19..4430de954 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/UndergroundMobs.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/UndergroundMobs.java @@ -24,7 +24,6 @@ import mineplex.core.updater.event.UpdateEvent; public class UndergroundMobs implements Listener { - private static final int MAX_MOBS = 400; private static final String SEWER_KEY = "SEWER_MOB"; private static final String SUBWAY_KEY = "SUBWAY_MOBS"; @@ -95,5 +94,4 @@ public class UndergroundMobs implements Listener event.setCancelled(true); } } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldDataModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldDataModule.java index b7315dc08..cbcd453f7 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldDataModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldDataModule.java @@ -22,7 +22,6 @@ import mineplex.core.common.timing.TimingManager; @ReflectivelyCreateMiniPlugin public class WorldDataModule extends MiniPlugin { - public World World; public int MinX = 0; public int MinZ = 0; @@ -301,4 +300,4 @@ public class WorldDataModule extends MiniPlugin { return DATA_LOCATIONS; } -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldListeners.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldListeners.java index 0dfab4fb3..6d9612c9a 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldListeners.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldListeners.java @@ -14,14 +14,25 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.*; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockExpEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.hanging.HangingBreakEvent; -import org.bukkit.event.inventory.FurnaceSmeltEvent; -import org.bukkit.event.player.*; +import org.bukkit.event.player.PlayerArmorStandManipulateEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -32,7 +43,6 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class WorldListeners implements Listener { - private final JavaPlugin _plugin; public WorldListeners(JavaPlugin plugin) @@ -246,5 +256,4 @@ public class WorldListeners implements Listener { return player.getGameMode() != GameMode.CREATIVE; } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventModule.java index cc81c84cc..a73176f87 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventModule.java @@ -11,8 +11,12 @@ import java.util.concurrent.TimeUnit; import mineplex.gemhunters.worldevent.ufo.UFOWorldEvent; import org.bukkit.event.EventHandler; +import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; @@ -29,7 +33,10 @@ import mineplex.gemhunters.worldevent.wither.WitherWorldEvent; @ReflectivelyCreateMiniPlugin public class WorldEventModule extends MiniPlugin { - + public static final String WORLD_EVENT_COMMAND_PERMISSION = "mineplex.gemhunters.worldevent.command"; + public static final String START_WORLD_EVENT_COMMAND_PERMISSION = "mineplex.gemhunters.worldevent.start"; + public static final String STOP_WORLD_EVENT_COMMAND_PERMISSION = "mineplex.gemhunters.worldevent.stop"; + private static final long EVENT_TIMER = TimeUnit.MINUTES.toMillis(30); private static final long EVENT_COOLDOWN_TIMER = TimeUnit.MINUTES.toMillis(40); private static final long COMPLETE_TIMER = TimeUnit.SECONDS.toMillis(30); @@ -41,15 +48,24 @@ public class WorldEventModule extends MiniPlugin super("World Event"); _events = Arrays.asList( - new GiantWorldEvent(), new BlizzardWorldEvent(), //new NetherPortalWorldEvent(), new WitherWorldEvent(), new GwenMartWorldEvent(), new UFOWorldEvent() - ); + + generatePermissions(); + } + + private void generatePermissions() + { + PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); + + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(WORLD_EVENT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(START_WORLD_EVENT_COMMAND_PERMISSION), true, true); + pm.setPermission(pm.getGroup("admin"), GroupPermission.of(STOP_WORLD_EVENT_COMMAND_PERMISSION), true, true); } @Override @@ -163,4 +179,4 @@ public class WorldEventModule extends MiniPlugin { return EVENT_TIMER; } -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/command/StartCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/command/StartCommand.java index 45177f9a0..d24b12995 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/command/StartCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/command/StartCommand.java @@ -3,7 +3,6 @@ package mineplex.gemhunters.worldevent.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.gemhunters.worldevent.WorldEventModule; @@ -11,10 +10,9 @@ import mineplex.gemhunters.worldevent.WorldEventType; public class StartCommand extends CommandBase { - public StartCommand(WorldEventModule plugin) { - super(plugin, Rank.ADMIN, "start"); + super(plugin, WorldEventModule.START_WORLD_EVENT_COMMAND_PERMISSION, "start"); } @Override @@ -27,14 +25,15 @@ public class StartCommand extends CommandBase return; } - String name = ""; + StringBuilder nameBuilder = new StringBuilder(); for (int i = 0; i < args.length; i++) { - name += args[i] + " "; + nameBuilder.append(args[i]); + nameBuilder.append(" "); } - name = name.trim(); + String name = nameBuilder.toString().trim(); for (WorldEventType eventType : WorldEventType.values()) { @@ -53,5 +52,4 @@ public class StartCommand extends CommandBase caller.sendMessage(C.cGray + "- " + F.elem(eventType.getName())); } } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/command/StopCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/command/StopCommand.java index 0c2887354..b245b5623 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/command/StopCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/command/StopCommand.java @@ -3,7 +3,6 @@ package mineplex.gemhunters.worldevent.command; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.gemhunters.worldevent.WorldEvent; @@ -12,10 +11,9 @@ import mineplex.gemhunters.worldevent.WorldEventState; public class StopCommand extends CommandBase { - public StopCommand(WorldEventModule plugin) { - super(plugin, Rank.ADMIN, "stop"); + super(plugin, WorldEventModule.STOP_WORLD_EVENT_COMMAND_PERMISSION, "stop"); } @Override @@ -49,5 +47,4 @@ public class StopCommand extends CommandBase caller.sendMessage(C.cGray + "- " + F.elem(event.getEventType().name())); } } - -} +} \ No newline at end of file diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/command/WorldEventCommand.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/command/WorldEventCommand.java index 9669379b4..13b11112c 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/command/WorldEventCommand.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/command/WorldEventCommand.java @@ -1,18 +1,17 @@ package mineplex.gemhunters.worldevent.command; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.gemhunters.worldevent.WorldEventModule; public class WorldEventCommand extends MultiCommandBase { - public WorldEventCommand(WorldEventModule plugin) { - super(plugin, Rank.ADMIN, "worldevent", "we"); + super(plugin, WorldEventModule.WORLD_EVENT_COMMAND_PERMISSION, "worldevent", "we"); AddCommand(new StartCommand(plugin)); AddCommand(new StopCommand(plugin)); @@ -22,8 +21,7 @@ public class WorldEventCommand extends MultiCommandBase protected void Help(Player caller, String[] args) { caller.sendMessage(F.main(Plugin.getName(), "Command List:")); - caller.sendMessage(F.help("/" + _aliasUsed + " start [name]", "Starts a world event. Leaving [name] blank picks a random one.", Rank.ADMIN)); - caller.sendMessage(F.help("/" + _aliasUsed + " stop [name]", "Stops a world event. Leaving [name] blank stops all events.", Rank.ADMIN)); + caller.sendMessage(F.help("/" + _aliasUsed + " start [name]", "Starts a world event. Leaving [name] blank picks a random one.", ChatColor.DARK_RED)); + caller.sendMessage(F.help("/" + _aliasUsed + " stop [name]", "Stops a world event. Leaving [name] blank stops all events.", ChatColor.DARK_RED)); } - -} +} \ No newline at end of file