From 994f957bc3f3226a1ee2c95b71ac9f14d1e24103 Mon Sep 17 00:00:00 2001 From: cnr Date: Mon, 28 Aug 2017 12:51:47 -0500 Subject: [PATCH] Eliminate GroupPermission --- .../src/mineplex/core/account/CoreClient.java | 25 +- .../core/account/CoreClientManager.java | 60 +-- .../core/account/command/AddRankCommand.java | 2 +- .../account/command/InfoPlayerCommand.java | 2 +- .../account/command/ListRanksCommand.java | 2 +- .../core/account/command/RanksCommand.java | 2 +- .../account/command/RemoveRankCommand.java | 2 +- .../account/command/ResetPlayerCommand.java | 2 +- .../core/account/command/SetRankCommand.java | 2 +- .../account/permissions/GroupPermission.java | 35 -- .../core/account/permissions/Permission.java | 9 + .../account/permissions/PermissionGroup.java | 20 +- .../permissions/PermissionGroupHelper.java | 54 ++ .../permissions/PermissionManager.java | 135 ----- .../core/achievement/AchievementCategory.java | 3 +- .../core/achievement/AchievementManager.java | 44 +- .../achievement/command/StatsCommand.java | 6 +- .../src/mineplex/core/antihack/AntiHack.java | 68 ++- .../commands/AnticheatOffCommand.java | 2 +- .../antihack/commands/AnticheatOnCommand.java | 2 +- .../commands/DetailedMessagesCommand.java | 2 +- .../core/antihack/commands/GetVlsCommand.java | 2 +- .../antihack/commands/TestBanCommand.java | 2 +- .../antihack/guardians/AntiHackGuardian.java | 8 +- .../core/antihack/logging/AntihackLogger.java | 15 +- .../core/aprilfools/AprilFoolsManager.java | 15 +- .../aprilfools/command/PirateSongCommand.java | 2 +- .../src/mineplex/core/beta/BetaWhitelist.java | 23 +- .../mineplex/core/bonuses/BonusManager.java | 73 ++- .../core/bonuses/commands/AllowCommand.java | 4 +- .../bonuses/commands/AnimationCommand.java | 2 +- .../core/bonuses/commands/GuiCommand.java | 2 +- .../bonuses/commands/PowerPlayCommand.java | 2 +- .../core/bonuses/commands/TicketCommand.java | 2 +- .../core/boosters/BoosterManager.java | 30 +- .../core/boosters/command/AddCommand.java | 2 +- .../core/boosters/command/BoosterCommand.java | 2 +- .../core/boosters/command/GuiCommand.java | 2 +- .../core/boosters/command/ReloadCommand.java | 2 +- .../core/boosters/command/ThankCommand.java | 2 +- .../mineplex/core/botspam/BotSpamManager.java | 45 +- .../botspam/command/BotSpamAddCommand.java | 2 +- .../core/botspam/command/BotSpamCommand.java | 2 +- .../command/BotSpamDisableCommand.java | 2 +- .../botspam/command/BotSpamEnableCommand.java | 2 +- .../command/BotSpamGlobalUpdateCommand.java | 2 +- .../botspam/command/BotSpamListCommand.java | 13 +- .../src/mineplex/core/chat/Chat.java | 61 +-- .../core/chat/command/BroadcastCommand.java | 2 +- .../core/chat/command/ChatSlowCommand.java | 2 +- .../core/chat/command/SilenceCommand.java | 2 +- .../core/chatsnap/SnapshotPlugin.java | 15 +- .../chatsnap/command/ChatSnapCommand.java | 2 +- .../mineplex/core/command/CommandBase.java | 10 +- .../mineplex/core/command/CommandCenter.java | 29 +- .../src/mineplex/core/command/ICommand.java | 4 +- .../core/command/MultiCommandBase.java | 12 +- .../core/communities/CommunityManager.java | 77 +-- .../commands/CommunityChatCommand.java | 2 +- .../commands/CommunityCommand.java | 2 +- .../commands/CommunityCreateCommand.java | 2 +- .../commands/CommunityDescriptionCommand.java | 5 +- .../commands/CommunityDisbandCommand.java | 5 +- .../commands/CommunityInviteCommand.java | 5 +- .../commands/CommunityJoinCommand.java | 2 +- .../commands/CommunityMCSCommand.java | 5 +- .../commands/CommunityMenuCommand.java | 2 +- .../commands/CommunityRenameCommand.java | 5 +- .../commands/CommunityUnInviteCommand.java | 5 +- .../gui/community/CommunityMemberButton.java | 3 +- .../core/cosmetic/ui/page/WinEffectPage.java | 5 +- .../src/mineplex/core/creature/Creature.java | 21 +- .../core/creature/command/KillCommand.java | 2 +- .../core/creature/command/MobCommand.java | 2 +- .../playerdisguise/DisguiseCommand.java | 2 +- .../playerdisguise/PlayerDisguiseManager.java | 35 +- .../core/donation/DonationManager.java | 23 +- .../core/donation/command/CrownCommand.java | 2 +- .../core/donation/command/GemCommand.java | 2 +- .../core/donation/command/ShardCommand.java | 2 +- .../src/mineplex/core/elo/EloManager.java | 19 +- .../src/mineplex/core/elo/TopEloCommand.java | 2 +- .../core/facebook/FacebookManager.java | 15 +- .../facebook/command/FacebookCommand.java | 2 +- .../mineplex/core/friend/FriendManager.java | 21 +- .../core/friend/command/AddFriend.java | 2 +- .../core/friend/command/DeleteFriend.java | 2 +- .../core/friend/command/FriendsDisplay.java | 2 +- .../mineplex/core/gadget/GadgetManager.java | 78 +-- .../core/gadget/commands/AmmoCommand.java | 2 +- .../gadget/commands/LockCosmeticsCommand.java | 3 +- .../gadget/commands/LockInfusedCommand.java | 2 +- .../commands/UnlockCosmeticsCommand.java | 2 +- .../gadgets/arrowtrail/ArrowTrailTitan.java | 3 +- .../core/gadget/gadgets/death/DeathTitan.java | 3 +- .../gadgets/doublejump/DoubleJumpTitan.java | 3 +- .../core/gadget/gadgets/morph/MorphBlaze.java | 3 +- .../gadget/gadgets/morph/MorphCreeper.java | 3 +- .../core/gadget/gadgets/morph/MorphPig.java | 3 +- .../core/gadget/gadgets/morph/MorphTitan.java | 3 +- .../gadget/gadgets/morph/MorphWither.java | 3 +- .../gadgets/particle/ParticleLegend.java | 5 +- .../gadgets/particle/ParticleTitan.java | 3 +- .../gadget/gadgets/taunts/EternalTaunt.java | 3 +- .../rankrooms/WinEffectRankBased.java | 7 +- .../src/mineplex/core/give/Give.java | 19 +- .../core/give/commands/GiveCommand.java | 2 +- .../globalpacket/GlobalPacketManager.java | 15 +- .../command/GlobalPacketCommand.java | 2 +- .../listeners/GlobalGiveCoins.java | 5 +- .../listeners/GlobalGiveGems.java | 7 +- .../listeners/GlobalGiveItem.java | 7 +- .../mineplex/core/ignore/IgnoreManager.java | 21 +- .../mineplex/core/ignore/command/Ignore.java | 2 +- .../core/ignore/command/Unignore.java | 2 +- .../core/incognito/IncognitoManager.java | 19 +- .../commands/IncognitoToggleCommand.java | 2 +- .../core/inventory/InventoryManager.java | 14 +- .../inventory/command/GiveItemCommand.java | 2 +- .../core/leaderboard/LeaderboardManager.java | 17 +- .../mineplex/core/message/MessageManager.java | 61 +-- .../core/message/commands/AdminCommand.java | 7 +- .../message/commands/AnnounceCommand.java | 2 +- .../message/commands/MessageAdminCommand.java | 2 +- .../core/message/commands/MessageCommand.java | 2 +- .../message/commands/ResendAdminCommand.java | 2 +- .../core/message/commands/ResendCommand.java | 2 +- .../src/mineplex/core/monitor/LagMeter.java | 30 +- .../core/monitor/VersionsCommand.java | 2 +- .../src/mineplex/core/mount/MountManager.java | 19 +- .../core/mount/types/MountDragon.java | 3 +- .../mineplex/core/mount/types/MountTitan.java | 3 +- .../core/notifier/NotificationManager.java | 4 +- .../src/mineplex/core/npc/NpcManager.java | 40 +- .../mineplex/core/npc/command/AddCommand.java | 2 +- .../core/npc/command/ClearCommand.java | 2 +- .../core/npc/command/DeleteCommand.java | 2 +- .../core/npc/command/HomeCommand.java | 2 +- .../mineplex/core/npc/command/NpcCommand.java | 2 +- .../core/npc/command/RefreshCommand.java | 2 +- .../src/mineplex/core/party/PartyManager.java | 15 +- .../core/party/command/PartyCLICommand.java | 11 +- .../core/party/command/PartyCommand.java | 2 +- .../core/party/command/PartyGuiCommand.java | 2 +- .../party/command/PartyToggleCommand.java | 2 +- .../party/command/cli/PartyAcceptCommand.java | 2 +- .../party/command/cli/PartyBlockCommand.java | 2 +- .../party/command/cli/PartyDenyCommand.java | 2 +- .../command/cli/PartyDisbandCommand.java | 2 +- .../party/command/cli/PartyHelpCommand.java | 2 +- .../party/command/cli/PartyInviteCommand.java | 2 +- .../command/cli/PartyInvitesCommand.java | 13 +- .../party/command/cli/PartyKickCommand.java | 2 +- .../party/command/cli/PartyLeaveCommand.java | 2 +- .../cli/PartyTransferOwnerCommand.java | 2 +- .../gui/PartyGUIAcceptInviteCommand.java | 2 +- .../gui/PartyGUIDenyInviteCommand.java | 2 +- .../command/gui/PartyGUIInviteCommand.java | 2 +- .../command/gui/PartyGUILeaveCommand.java | 2 +- .../gui/PartyOpenInviteMenuCommand.java | 2 +- .../core/party/manager/PartyJoinManager.java | 3 +- .../HostEventServerCommand.java | 2 +- .../HostPersonalEventServer.java | 2 +- .../personalServer/HostServerCommand.java | 2 +- .../personalServer/PersonalServerManager.java | 42 +- .../src/mineplex/core/pet/PetManager.java | 25 +- .../src/mineplex/core/poll/PollManager.java | 23 +- .../core/poll/command/PollCommand.java | 5 +- .../src/mineplex/core/portal/Portal.java | 31 +- .../core/portal/commands/SendCommand.java | 2 +- .../core/portal/commands/ServerCommand.java | 7 +- .../mineplex/core/preferences/Preference.java | 9 +- .../core/preferences/PreferencesManager.java | 40 +- .../command/PreferencesCommand.java | 2 +- .../preferences/ui/PreferenceMainMenu.java | 7 +- .../preferences/ui/menus/PreferenceMenu.java | 2 +- .../core/punish/Command/PunishCommand.java | 2 +- .../core/punish/Command/RulesCommand.java | 2 +- .../src/mineplex/core/punish/Punish.java | 27 +- .../mineplex/core/punish/UI/PunishPage.java | 186 +++---- .../core/punish/clans/ClansBanManager.java | 31 +- .../punish/clans/command/ClansBanCommand.java | 2 +- .../mineplex/core/quests/QuestManager.java | 25 +- .../core/quests/command/GetQuestCommand.java | 2 +- .../quests/command/IncrementQuestCommand.java | 2 +- .../core/quests/command/OpenGuiCommand.java | 2 +- .../rankGiveaway/eternal/EternalCommand.java | 2 +- .../eternal/EternalGiveawayManager.java | 17 +- .../titangiveaway/TitanGiveawayManager.java | 2 +- .../mineplex/core/report/ReportManager.java | 33 +- .../report/command/ReportCloseCommand.java | 2 +- .../core/report/command/ReportCommand.java | 2 +- .../report/command/ReportHandleCommand.java | 2 +- .../report/command/ReportHistoryCommand.java | 2 +- .../report/command/ReportInfoCommand.java | 2 +- .../report/command/ReportMetricsCommand.java | 2 +- .../mineplex/core/reward/RewardManager.java | 4 +- .../core/reward/rewards/RankReward.java | 2 +- .../serverConfig/ServerConfiguration.java | 17 +- .../src/mineplex/core/stats/StatsManager.java | 25 +- .../core/stats/command/GiveStatCommand.java | 2 +- .../stats/command/MasterBuilderUnban.java | 2 +- .../core/stats/command/SetLevelCommand.java | 2 +- .../core/stats/command/TimeCommand.java | 2 +- .../core/teamspeak/TeamspeakManager.java | 25 +- .../core/teamspeak/commands/LinkCommand.java | 2 +- .../core/teamspeak/commands/ListCommand.java | 2 +- .../teamspeak/commands/TeamspeakCommand.java | 2 +- .../teamspeak/commands/UnlinkCommand.java | 2 +- .../src/mineplex/core/teleport/Teleport.java | 43 +- .../core/teleport/command/AllCommand.java | 2 +- .../core/teleport/command/BackCommand.java | 5 +- .../core/teleport/command/HereCommand.java | 2 +- .../core/teleport/command/LocateCommand.java | 2 +- .../teleport/command/ModLocateCommand.java | 2 +- .../teleport/command/TeleportCommand.java | 22 +- .../command/TraineeLocateCommand.java | 2 +- .../src/mineplex/core/thank/ThankManager.java | 14 +- .../core/thank/command/ThankCommand.java | 2 +- .../titles/commands/GiveTrackCommand.java | 2 +- .../core/titles/commands/TrackCommand.java | 2 +- .../core/titles/tracks/TrackManager.java | 59 +-- .../titles/tracks/custom/HappyGaryTrack.java | 6 +- .../titles/tracks/custom/LeaderTrack.java | 6 +- .../titles/tracks/custom/TableFlipTrack.java | 6 +- .../titles/tracks/staff/BuilderTrack.java | 6 +- .../titles/tracks/staff/ModeratorTrack.java | 6 +- .../tracks/staff/SeniorModeratorTrack.java | 6 +- .../titles/tracks/staff/TraineeTrack.java | 6 +- .../core/tournament/DebugShopCommand.java | 2 +- .../core/tournament/TournamentManager.java | 15 +- .../core/twofactor/TwoFactorAuth.java | 30 +- .../mineplex/core/updater/FileUpdater.java | 23 +- .../updater/command/BuildVersionCommand.java | 2 +- .../updater/command/RestartServerCommand.java | 2 +- .../mineplex/core/website/LinkCommand.java | 2 +- .../mineplex/core/website/UnlinkCommand.java | 2 +- .../core/website/WebsiteLinkManager.java | 19 +- .../src/mineplex/enjinTranslator/Enjin.java | 5 +- .../clans/compensation/ClansCompensation.java | 17 +- .../compensation/CompensationCommand.java | 13 +- .../mineplex/game/clans/clans/ClansAdmin.java | 17 +- .../mineplex/game/clans/clans/ClansGame.java | 17 +- .../game/clans/clans/ClansManager.java | 81 +-- .../clans/amplifiers/AmplifierCommand.java | 2 +- .../clans/amplifiers/AmplifierManager.java | 14 +- .../clans/clans/banners/BannerManager.java | 20 +- .../clans/banners/command/BannerCommand.java | 2 +- .../game/clans/clans/boxes/BoxManager.java | 17 +- .../clans/claimview/ClaimVisualizer.java | 15 +- .../commands/ClaimVisualizeCommand.java | 2 +- .../clans/commands/ClansAllyChatCommand.java | 2 +- .../clans/commands/ClansChatCommand.java | 2 +- .../clans/clans/commands/ClansCommand.java | 8 +- .../clans/clans/commands/KillCommand.java | 2 +- .../game/clans/clans/commands/MapCommand.java | 2 +- .../clans/clans/commands/RegionsCommand.java | 2 +- .../clans/clans/commands/SpeedCommand.java | 2 +- .../clans/freeze/ClansFreezeManager.java | 41 +- .../clans/freeze/commands/FreezeCommand.java | 2 +- .../freeze/commands/UnfreezeCommand.java | 2 +- .../clans/clans/invsee/InvseeManager.java | 17 +- .../clans/invsee/commands/InvseeCommand.java | 9 +- .../game/clans/clans/mounts/MountManager.java | 27 +- .../clans/clans/mounts/gui/MountSkinPage.java | 3 +- .../clans/nameblacklist/ClansBlacklist.java | 18 +- .../commands/AddBlacklistCommand.java | 2 +- .../clans/clans/nether/NetherManager.java | 39 +- .../clans/nether/command/CloseCommand.java | 2 +- .../clans/nether/command/CreateCommand.java | 2 +- .../clans/nether/command/DeleteCommand.java | 2 +- .../nether/command/ForceTeleportCommand.java | 2 +- .../clans/nether/command/ListCommand.java | 2 +- .../clans/nether/command/PortalCommand.java | 2 +- .../clans/nether/command/SpawnCommand.java | 2 +- .../clans/nether/command/WandCommand.java | 2 +- .../clans/clans/observer/ObserverManager.java | 14 +- .../observer/command/ObserverCommand.java | 2 +- .../game/clans/clans/playtime/Playtime.java | 15 +- .../playtime/command/PlayTimeCommand.java | 2 +- .../game/clans/clans/siege/SiegeManager.java | 15 +- .../siege/command/GiveWeaponCommand.java | 2 +- .../game/clans/clans/siege/weapon/Cannon.java | 3 +- .../game/clans/clans/war/WarManager.java | 15 +- .../clans/war/command/WarPointsCommand.java | 2 +- .../clans/worldevent/WorldEventManager.java | 22 +- .../worldevent/command/ClearCommand.java | 2 +- .../worldevent/command/RandomCommand.java | 2 +- .../worldevent/command/StartCommand.java | 2 +- .../worldevent/command/WorldEventCommand.java | 2 +- .../clans/worldevent/raid/RaidManager.java | 15 +- .../raid/command/StartRaidCommand.java | 2 +- .../game/clans/economy/GoldCommand.java | 2 +- .../game/clans/economy/GoldManager.java | 17 +- .../game/clans/economy/SetGoldCommand.java | 2 +- .../game/clans/fields/FieldBlock.java | 14 +- .../game/clans/fields/FieldMonster.java | 15 +- .../mineplex/game/clans/fields/FieldOre.java | 15 +- .../fields/commands/FieldBlockCommand.java | 2 +- .../fields/commands/FieldMonsterCommand.java | 2 +- .../fields/commands/FieldOreCommand.java | 2 +- .../game/clans/items/GearManager.java | 19 +- .../clans/items/commands/GearCommand.java | 2 +- .../clans/items/commands/RuneCommand.java | 2 +- .../game/clans/restart/RestartCommand.java | 2 +- .../game/clans/restart/RestartManager.java | 21 +- .../game/clans/tutorial/TutorialManager.java | 33 +- .../clans/tutorial/command/FinishCommand.java | 2 +- .../clans/tutorial/command/StartCommand.java | 2 +- .../tutorial/command/TutorialCommand.java | 2 +- .../mineplex/clanshub/ClansServerPage.java | 5 +- .../clanshub/ClansTransferManager.java | 24 +- .../mineplex/clanshub/ForcefieldManager.java | 24 +- .../src/mineplex/clanshub/HubManager.java | 53 +- .../clanshub/HubVisibilityManager.java | 20 +- .../mineplex/clanshub/JoinServerButton.java | 3 +- .../clanshub/commands/ForcefieldRadius.java | 2 +- .../clanshub/commands/GadgetToggle.java | 2 +- .../clanshub/commands/GameModeCommand.java | 2 +- .../SalesAnnouncementCommand.java | 2 +- .../SalesAnnouncementManager.java | 14 +- .../SalesAnnouncementRepository.java | 7 +- .../src/mineplex/hub/HubManager.java | 54 +- .../mineplex/hub/commands/EggAddCommand.java | 2 +- .../hub/commands/ForcefieldRadius.java | 2 +- .../mineplex/hub/commands/GadgetToggle.java | 2 +- .../hub/commands/GameModeCommand.java | 2 +- .../src/mineplex/hub/commands/HorseSpawn.java | 2 +- .../mineplex/hub/commands/NewYearCommand.java | 2 +- .../mineplex/hub/commands/NewsAddCommand.java | 5 +- .../mineplex/hub/commands/NewsCommand.java | 2 +- .../hub/commands/NewsConfirmCommand.java | 2 +- .../hub/commands/NewsDeleteCommand.java | 2 +- .../hub/commands/NewsListCommand.java | 2 +- .../mineplex/hub/commands/NewsSetCommand.java | 2 +- .../hub/modules/AdminMountManager.java | 13 +- .../mineplex/hub/modules/AlienInvasion.java | 20 +- .../mineplex/hub/modules/EasterEggHunt.java | 15 +- .../hub/modules/ForcefieldManager.java | 24 +- .../hub/modules/HubVisibilityManager.java | 2 +- .../src/mineplex/hub/modules/JumpManager.java | 4 +- .../hub/modules/NewYearCountdown.java | 15 +- .../SalesAnnouncementCommand.java | 2 +- .../SalesAnnouncementManager.java | 15 +- .../SalesAnnouncementRepository.java | 7 +- .../hub/notification/NotificationManager.java | 15 +- .../command/NotificationCommand.java | 2 +- .../mineplex/hub/server/ServerManager.java | 23 +- .../src/mineplex/hub/server/ui/LobbyMenu.java | 3 +- .../mineplex/hub/server/ui/ServerNpcPage.java | 9 +- .../server/ui/button/JoinServerButton.java | 3 +- .../game/classcombat/Class/ClassManager.java | 17 +- .../game/classcombat/Class/ClientClass.java | 5 +- .../classcombat/shop/ClassShopManager.java | 21 +- .../game/classcombat/shop/page/SkillPage.java | 5 +- .../customerSupport/CustomerSupport.java | 31 +- .../customerSupport/ListPPCCommand.java | 2 +- .../customerSupport/checkBonusCommand.java | 2 +- .../customerSupport/checkCommand.java | 2 +- .../checkOwnsPackageCommand.java | 2 +- .../salespackage/SalesPackageManager.java | 18 +- .../salespackage/command/CoinCommand.java | 2 +- .../command/DisplayPackageCommand.java | 2 +- .../command/GemHunterCommand.java | 2 +- .../salespackage/command/HeroCommand.java | 2 +- .../salespackage/command/ItemCommand.java | 2 +- .../salespackage/command/KitsCommand.java | 2 +- .../command/LifetimeEternalCommand.java | 2 +- .../command/LifetimeHeroCommand.java | 2 +- .../command/LifetimeLegendCommand.java | 2 +- .../command/LifetimeTitanCommand.java | 2 +- .../command/LifetimeUltraCommand.java | 2 +- .../salespackage/command/PetCommand.java | 2 +- .../command/PowerPlayCommand.java | 2 +- .../salespackage/command/RankCommand.java | 2 +- .../salespackage/command/Sales.java | 2 +- .../salespackage/command/UltraCommand.java | 2 +- .../nautilus/game/arcade/ArcadeManager.java | 115 ++-- .../arcade/command/CancelNextGameCommand.java | 2 +- .../game/arcade/command/GameCommand.java | 10 +- .../arcade/command/GoToNextGameCommand.java | 2 +- .../game/arcade/command/KitUnlockCommand.java | 2 +- .../command/OpenGameMechPrefsCommand.java | 2 +- .../game/arcade/command/SetCommand.java | 4 +- .../game/arcade/command/StartCommand.java | 2 +- .../game/arcade/command/StopCommand.java | 2 +- .../game/arcade/command/TauntCommand.java | 2 +- .../game/arcade/game/DebugCommand.java | 21 +- .../arcade/game/DebugCommandExecutor.java | 9 + .../src/nautilus/game/arcade/game/Game.java | 15 +- .../game/arcade/game/RankedTeamGame.java | 4 +- .../game/arcade/game/games/bridge/Bridge.java | 38 +- .../game/games/common/CaptureTheFlag.java | 18 +- .../arcade/game/games/event/EventModule.java | 18 +- .../game/arcade/game/games/moba/Moba.java | 48 +- .../game/games/moba/gold/GoldManager.java | 39 +- .../game/games/moba/minion/MinionManager.java | 24 +- .../moba/progression/MobaProgression.java | 35 +- .../games/moba/training/MobaTraining.java | 24 +- .../arcade/game/games/smash/SuperSmash.java | 106 ++-- .../games/speedbuilders/SpeedBuilders.java | 125 +++-- .../typewars/StaffKillMonitorManager.java | 17 +- .../arcade/game/games/typewars/TypeWars.java | 103 ++-- .../game/arcade/game/games/uhc/UHC.java | 491 ++++++++---------- .../arcade/game/modules/RejoinModule.java | 55 +- .../gui/privateServer/page/MenuPage.java | 4 +- .../game/arcade/kit/ProgressingKit.java | 21 +- .../game/arcade/managers/GameFlagManager.java | 22 +- .../game/arcade/managers/GameHostManager.java | 43 +- .../game/arcade/managers/GameLootManager.java | 53 +- .../arcade/managers/GameRewardManager.java | 42 +- .../game/arcade/managers/GameStatManager.java | 17 +- .../game/arcade/managers/IdleManager.java | 17 +- .../arcade/managers/NextBestGameManager.java | 17 +- .../arcade/managers/chat/GameChatManager.java | 30 +- .../arcade/managers/lobby/LobbyManager.java | 16 +- .../gemhunters/economy/CashOutModule.java | 21 +- .../gemhunters/economy/EconomyModule.java | 14 +- .../economy/command/CashOutItemCommand.java | 2 +- .../economy/command/GiveGemsCommand.java | 2 +- .../economy/command/ResetCooldownCommand.java | 2 +- .../mineplex/gemhunters/loot/LootModule.java | 21 +- .../loot/command/SpawnChestCommand.java | 2 +- .../loot/command/UpdateLootCommand.java | 2 +- .../gemhunters/map/ItemMapModule.java | 17 +- .../gemhunters/map/command/MapCommand.java | 2 +- .../moderation/ModerationModule.java | 33 +- .../command/ModeratorModeCommand.java | 2 +- .../gemhunters/quest/QuestModule.java | 17 +- .../quest/command/ResetQuestsCommand.java | 2 +- .../gemhunters/spawn/SpawnModule.java | 17 +- .../gemhunters/spawn/command/HubCommand.java | 2 +- .../supplydrop/SupplyDropModule.java | 25 +- .../supplydrop/command/EndCommand.java | 2 +- .../supplydrop/command/StartCommand.java | 2 +- .../supplydrop/command/SupplyDropCommand.java | 2 +- .../worldevent/WorldEventModule.java | 24 +- .../worldevent/command/StartCommand.java | 2 +- .../worldevent/command/StopCommand.java | 2 +- .../worldevent/command/WorldEventCommand.java | 2 +- 440 files changed, 2749 insertions(+), 2950 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/permissions/GroupPermission.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroupHelper.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommandExecutor.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java index 0fb9ff7b2..101521b3a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClient.java @@ -7,7 +7,7 @@ import java.util.stream.Collectors; import org.bukkit.entity.Player; -import mineplex.core.Managers; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; import mineplex.serverdata.Utility; @@ -93,24 +93,19 @@ public class CoreClient return _extra; } - public PermissionGroup getLastPrimaryGroup() + public boolean inheritsFrom(PermissionGroup group) { - if (_lastPrimary == null) - { - return _primary; - } - - return _lastPrimary; + return _primary.inheritsFrom(group) || _extra.stream().anyMatch(memberGroup -> memberGroup.inheritsFrom(group)); } - + + public boolean hasPermission(Permission permission) + { + return _primary.hasPermission(permission) || _extra.stream().anyMatch(memberGroup -> memberGroup.hasPermission(permission)); + } + public boolean isMemberOf(PermissionGroup group) { - if (_extra.contains(group)) - { - return true; - } - - return group.equals(_primary); + return group == _primary || _extra.contains(group); } public void setPrimaryGroup(PermissionGroup group) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index c62e356b9..531a8937b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -39,9 +39,9 @@ import mineplex.core.account.event.ClientWebResponseEvent; 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; +import mineplex.core.account.permissions.PermissionGroupHelper; import mineplex.core.account.redis.AddPermissionGroup; import mineplex.core.account.redis.AddPermissionGroupHandler; import mineplex.core.account.redis.ClearGroups; @@ -68,20 +68,22 @@ 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"; - + public enum Perm implements Permission + { + JOIN_FULL, + RANK_COMMAND, + ADD_RANK_COMMAND, + RANK_INFO_COMMAND, + LIST_RANKS_COMMAND, + REMOVE_RANK_COMMAND, + RESET_PLAYER_COMMAND, + SET_RANK_COMMAND, + } + private static final Map CLIENT_LOGIN_LOCKS = new ConcurrentHashMap<>(); private JavaPlugin _plugin; private AccountRepository _repository; - private PermissionManager _perm; private Map _clientList = new HashMap<>(); private Set _duplicateLoginGlitchPreventionList = new HashSet<>(); @@ -100,7 +102,6 @@ public class CoreClientManager extends MiniPlugin _plugin = plugin; _repository = new AccountRepository(); - _perm = new PermissionManager(plugin, this); UtilScheduler.runEvery(UpdateType.TICK, this::checkForIllegalAccounts); @@ -114,14 +115,14 @@ public class CoreClientManager extends MiniPlugin private void generatePermissions() { - _perm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); - _perm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RANK_COMMAND_PERMISSION), true, true); - _perm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(ADD_RANK_COMMAND_PERMISSION), true, true); - _perm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RANK_INFO_COMMAND_PERMISSION), true, true); - _perm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(LIST_RANKS_COMMAND_PERMISSION), true, true); - _perm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(REMOVE_RANK_COMMAND_PERMISSION), true, true); - _perm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RESET_PLAYER_COMMAND_PERMISSION), true, true); - _perm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SET_RANK_COMMAND_PERMISSION), true, true); + PermissionGroup.ULTRA.setPermission(Perm.JOIN_FULL, true, true); + PermissionGroup.ADMIN.setPermission(Perm.RANK_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.ADD_RANK_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.RANK_INFO_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.LIST_RANKS_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.REMOVE_RANK_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.RESET_PLAYER_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.SET_RANK_COMMAND, true, true); } private void checkForIllegalAccounts() @@ -142,11 +143,6 @@ public class CoreClientManager extends MiniPlugin return _repository; } - public PermissionManager getPermissionManager() - { - return _perm; - } - @Override public void addCommands() { @@ -317,7 +313,7 @@ public class CoreClientManager extends MiniPlugin client.setAccountId(result.getLeft()); if (result.getRight().getLeft() == null) { - PermissionGroup newGroup = _perm.getGroupFromLegacy(token.Rank); + PermissionGroup newGroup = PermissionGroupHelper.getGroupFromLegacy(token.Rank); client.setPrimaryGroup(newGroup); _repository.setPrimaryGroup(client.getAccountId(), newGroup, null); } @@ -392,7 +388,7 @@ public class CoreClientManager extends MiniPlugin client.setAccountId(result.getLeft()); if (result.getRight().getLeft() == null) { - PermissionGroup newGroup = _perm.getGroupFromLegacy(token.Rank); + PermissionGroup newGroup = PermissionGroupHelper.getGroupFromLegacy(token.Rank); client.setPrimaryGroup(newGroup); _repository.setPrimaryGroup(client.getAccountId(), newGroup, null); } @@ -467,7 +463,7 @@ public class CoreClientManager extends MiniPlugin client.setAccountId(result.getLeft()); if (result.getRight().getLeft() == null) { - PermissionGroup newGroup = _perm.getGroupFromLegacy(token.Rank); + PermissionGroup newGroup = PermissionGroupHelper.getGroupFromLegacy(token.Rank); client.setPrimaryGroup(newGroup); _repository.setPrimaryGroup(client.getAccountId(), newGroup, null); } @@ -567,7 +563,7 @@ public class CoreClientManager extends MiniPlugin if (client.getRawPrimaryGroup() == null) { String mssqlRank = token.Rank; - PermissionGroup newGroup = _perm.getGroupFromLegacy(mssqlRank); + PermissionGroup newGroup = PermissionGroupHelper.getGroupFromLegacy(mssqlRank); client.setPrimaryGroup(newGroup); _repository.setPrimaryGroup(client.getAccountId(), newGroup, null); } @@ -619,7 +615,7 @@ public class CoreClientManager extends MiniPlugin // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() + _reservedSlots.size() >= Bukkit.getServer().getMaxPlayers()) { - if (_perm.hasPermission(client, GroupPermission.of(JOIN_FULL_PERMISSION))) + if (client.hasPermission(Perm.JOIN_FULL)) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); @@ -807,7 +803,7 @@ public class CoreClientManager extends MiniPlugin { String legacy = loadOfflineClient(uuid).Rank; PermissionGroup defaultGroup = PermissionGroup.PLAYER; - PermissionGroup loaded = _perm.getGroupFromLegacy(legacy); + PermissionGroup loaded = PermissionGroupHelper.getGroupFromLegacy(legacy); if (loaded == null) { primaryReference.compareAndSet(null, defaultGroup); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/AddRankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/AddRankCommand.java index 9fec61a05..6e9271da2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/AddRankCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/AddRankCommand.java @@ -19,7 +19,7 @@ public class AddRankCommand extends CommandBase { public AddRankCommand(CoreClientManager plugin) { - super(plugin, CoreClientManager.ADD_RANK_COMMAND_PERMISSION, "add"); + super(plugin, CoreClientManager.Perm.ADD_RANK_COMMAND, "add"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/InfoPlayerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/InfoPlayerCommand.java index 839dea4a7..9026d9bdd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/InfoPlayerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/InfoPlayerCommand.java @@ -17,7 +17,7 @@ public class InfoPlayerCommand extends CommandBase { public InfoPlayerCommand(CoreClientManager plugin) { - super(plugin, CoreClientManager.RANK_INFO_COMMAND_PERMISSION, "info"); + super(plugin, CoreClientManager.Perm.RANK_INFO_COMMAND, "info"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/ListRanksCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/ListRanksCommand.java index 5cd4132f5..df94fd919 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/ListRanksCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/ListRanksCommand.java @@ -16,7 +16,7 @@ public class ListRanksCommand extends CommandBase { public ListRanksCommand(CoreClientManager plugin) { - super(plugin, CoreClientManager.LIST_RANKS_COMMAND_PERMISSION, "list"); + super(plugin, CoreClientManager.Perm.LIST_RANKS_COMMAND, "list"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/RanksCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/RanksCommand.java index 27d210602..130bd0dff 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/RanksCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/RanksCommand.java @@ -12,7 +12,7 @@ public class RanksCommand extends MultiCommandBase { public RanksCommand(CoreClientManager plugin) { - super(plugin, CoreClientManager.RANK_COMMAND_PERMISSION, "rank", "ranks", "permissions"); + super(plugin, CoreClientManager.Perm.RANK_COMMAND, "rank", "ranks", "permissions"); AddCommand(new AddRankCommand(plugin)); AddCommand(new InfoPlayerCommand(plugin)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/RemoveRankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/RemoveRankCommand.java index 9b9645948..830d413e2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/RemoveRankCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/RemoveRankCommand.java @@ -19,7 +19,7 @@ public class RemoveRankCommand extends CommandBase { public RemoveRankCommand(CoreClientManager plugin) { - super(plugin, CoreClientManager.REMOVE_RANK_COMMAND_PERMISSION, "remove"); + super(plugin, CoreClientManager.Perm.REMOVE_RANK_COMMAND, "remove"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/ResetPlayerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/ResetPlayerCommand.java index 4a35f302b..d11bf4153 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/ResetPlayerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/ResetPlayerCommand.java @@ -22,7 +22,7 @@ public class ResetPlayerCommand extends CommandBase { public ResetPlayerCommand(CoreClientManager plugin) { - super(plugin, CoreClientManager.RESET_PLAYER_COMMAND_PERMISSION, "clear"); + super(plugin, CoreClientManager.Perm.RESET_PLAYER_COMMAND, "clear"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/command/SetRankCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/account/command/SetRankCommand.java index e14bb71b0..4d4d69140 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/command/SetRankCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/command/SetRankCommand.java @@ -19,7 +19,7 @@ public class SetRankCommand extends CommandBase { public SetRankCommand(CoreClientManager plugin) { - super(plugin, CoreClientManager.SET_RANK_COMMAND_PERMISSION, "set"); + super(plugin, CoreClientManager.Perm.SET_RANK_COMMAND, "set"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/GroupPermission.java b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/GroupPermission.java deleted file mode 100644 index c68a55996..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/GroupPermission.java +++ /dev/null @@ -1,35 +0,0 @@ -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.equals(((GroupPermission)o)._identifier); - } - - 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/Permission.java b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/Permission.java index 8bd4e9402..e1c135161 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/Permission.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/Permission.java @@ -3,9 +3,11 @@ package mineplex.core.account.permissions; /** * A Permission that can be assigned to {@link PermissionGroup}s * + *

* This interface is intended to be paired with enum data types, as only * enum-based permissions are accepted by {@link PermissionGroup#setPermission(Enum, boolean, boolean)} * + *

* Example usage: *

  * {@code
@@ -14,5 +16,12 @@ package mineplex.core.account.permissions;
  * PermissionGroup.PLAYER.setPermission(ExamplePerm.EXAMPLE_ONE, true, true);
  * }
  * 
+ * + *

+ * Permissions can either be inheritable (passed on to child groups) or group-specific. Group-specific permissions + * override inherited permissions, but still allow the inherited permission to be propagated to children. + * + *

+ * In the case that two parents share the same inheritable permission, the values will be merged with logical OR */ public interface Permission {} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java index f415e83ec..d5aea51eb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroup.java @@ -118,7 +118,7 @@ public enum PermissionGroup } } - public boolean getPermission(Permission permission) + public boolean hasPermission(Permission permission) { synchronized(PERMS_LOCK) { @@ -126,6 +126,19 @@ public enum PermissionGroup } } + public boolean inheritsFrom(PermissionGroup group) + { + for (PermissionGroup parent : _parentGroups) + { + if (parent == group || parent.inheritsFrom(group)) + { + return true; + } + } + + return this == group; + } + private void bakePermissions() { // Calculate inherited permissions @@ -206,11 +219,6 @@ public enum PermissionGroup return _canBePrimary; } - public boolean inherits(PermissionGroup group) - { - return _parentGroups.contains(group); - } - public static Optional getGroup(String name) { return Stream.of(values()).filter(group -> group.name().equalsIgnoreCase(name)).findFirst(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroupHelper.java b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroupHelper.java new file mode 100644 index 000000000..f306aab8f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionGroupHelper.java @@ -0,0 +1,54 @@ +package mineplex.core.account.permissions; + +public class PermissionGroupHelper +{ + public static PermissionGroup getGroupFromLegacy(String legacyValue) + { + if (legacyValue == null) + { + return null; + } + + String legacy = legacyValue.toLowerCase(); + final PermissionGroup current; + + switch (legacy) + { + case "developer": + current = PermissionGroup.DEV; + break; + case "jnr_dev": + current = PermissionGroup.PLAYER; + break; + case "event_moderator": + current = PermissionGroup.EVENTMOD; + break; + case "snr_moderator": + current = PermissionGroup.SRMOD; + break; + case "moderator": + current = PermissionGroup.MOD; + break; + case "helper": + current = PermissionGroup.TRAINEE; + break; + case "mapdev": + current = PermissionGroup.BUILDER; + break; + case "media": + current = PermissionGroup.PLAYER; + break; + case "youtube_small": + current = PermissionGroup.YT; + break; + case "all": + current = PermissionGroup.PLAYER; + break; + default: + current = PermissionGroup.getGroup(legacy).get(); + break; + } + + return current; + } +} \ 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 deleted file mode 100644 index a3fb9d352..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/permissions/PermissionManager.java +++ /dev/null @@ -1,135 +0,0 @@ -package mineplex.core.account.permissions; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClient; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Pair; - -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; - } - - private Set getPermissions(PermissionGroup group, boolean allowSpecific) - { - // TODO: replace - return null; - } - - public PermissionGroup getGroupFromLegacy(String legacyValue) - { - if (legacyValue == null) - { - return null; - } - - String legacy = legacyValue.toLowerCase(); - final PermissionGroup current; - - if (legacy.equals("developer")) - { - current = PermissionGroup.DEV; - } - else if (legacy.equals("jnr_dev")) - { - current = PermissionGroup.PLAYER; - } - else if (legacy.equals("event_moderator")) - { - current = PermissionGroup.EVENTMOD; - } - else if (legacy.equals("snr_moderator")) - { - current = PermissionGroup.SRMOD; - } - else if (legacy.equals("moderator")) - { - current = PermissionGroup.MOD; - } - else if (legacy.equals("helper")) - { - current = PermissionGroup.TRAINEE; - } - else if (legacy.equals("mapdev")) - { - current = PermissionGroup.BUILDER; - } - else if (legacy.equals("media")) - { - current = PermissionGroup.PLAYER; - } - else if (legacy.equals("youtube_small")) - { - current = PermissionGroup.YT; - } - else if (legacy.equals("all")) - { - current = PermissionGroup.PLAYER; - } - else - { - current = PermissionGroup.getGroup(legacy).get(); - } - - return 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) - { - // TODO: replace - return false; - } - - public boolean hasPermission(PermissionGroup group, GroupPermission permission) - { - // TODO: replace - return false; - } - - public boolean hasPermission(CoreClient client, GroupPermission permission) - { - // TODO: replace - return false; - } - - public boolean hasPermission(Pair> groups, GroupPermission permission) - { - // TODO: replace - return false; - } - - public boolean hasPermission(Player player, GroupPermission permission) - { - // TODO: replace - return false; - } - - public void setPermission(PermissionGroup group, GroupPermission permission, boolean inheritable, boolean value) - { - // TODO: replace - } - - public void revokePermission(PermissionGroup group, GroupPermission permission, boolean inheritable) - { - // TODO: replace - } -} \ 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 252733405..7e846e8d5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -7,7 +7,6 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; -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 +309,7 @@ public enum AchievementCategory String displayName = _statDisplays[i].getDisplayName(); // Skip showing Losses, Kills, Deaths for other players - 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"))) + if (!clientManager.Get(player).hasPermission(AchievementManager.Perm.SEE_FULL_STATS) && !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 8a11ae11a..c1aafddbe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java @@ -9,9 +9,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.command.StatsCommand; import mineplex.core.achievement.ui.AchievementShop; import mineplex.core.common.util.NautHashMap; @@ -24,10 +23,16 @@ import mineplex.core.stats.event.StatChangeEvent; public class AchievementManager extends MiniPlugin { - 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"; - + public enum Perm implements Permission + { + FAKE_LEVEL_50, + FAKE_LEVEL_30, + FAKE_LEVEL_15, + FAKE_LEVEL_5, + SEE_FULL_STATS, + STATS_COMMAND, + } + private CoreClientManager _clientManager; private IncognitoManager _incognitoManager; private StatsManager _statsManager; @@ -56,14 +61,12 @@ public class AchievementManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(SEE_FULL_STATS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 1), true, true); - pm.setPermission(PermissionGroup.SRMOD, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 2), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 3), true, true); - pm.setPermission(PermissionGroup.LT, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 4), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(STATS_COMMAND_PERMISSION), true, true); + PermissionGroup.MOD.setPermission(Perm.SEE_FULL_STATS, true, true); + PermissionGroup.MOD.setPermission(Perm.FAKE_LEVEL_5, true, true); + PermissionGroup.SRMOD.setPermission(Perm.FAKE_LEVEL_15, true, true); + PermissionGroup.ADMIN.setPermission(Perm.FAKE_LEVEL_30, true, true); + PermissionGroup.LT.setPermission(Perm.FAKE_LEVEL_50, true, true); + PermissionGroup.PLAYER.setPermission(Perm.STATS_COMMAND, true, true); } public AchievementData get(Player player, Achievement type) @@ -217,20 +220,17 @@ public class AchievementManager extends MiniPlugin public int getMineplexLevelNumber(Player sender) { int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel(); - - if (_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 4))) + + if (_clientManager.Get(sender).hasPermission(Perm.FAKE_LEVEL_50)) { 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))) + } else if (_clientManager.Get(sender).hasPermission(Perm.FAKE_LEVEL_30)) { 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))) + } else if (_clientManager.Get(sender).hasPermission(Perm.FAKE_LEVEL_15)) { level = Math.max(level, 15); - } - else if (_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(FAKE_LEVEL_TIER_PERMISSION + 1))) + } else if (_clientManager.Get(sender).hasPermission(Perm.FAKE_LEVEL_5)) { level = Math.max(level, 5); } 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 8c9580247..b3e398d6b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/command/StatsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/command/StatsCommand.java @@ -2,7 +2,6 @@ package mineplex.core.achievement.command; 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.util.C; @@ -13,7 +12,7 @@ public class StatsCommand extends CommandBase { public StatsCommand(AchievementManager plugin) { - super(plugin, AchievementManager.STATS_COMMAND_PERMISSION, "stats"); + super(plugin, AchievementManager.Perm.STATS_COMMAND, "stats"); } @Override @@ -29,7 +28,8 @@ public class StatsCommand extends CommandBase if (target == null) { - if (Plugin.getClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(AchievementManager.SEE_FULL_STATS_PERMISSION))) attemptOffline(caller, args); + if (Plugin.getClientManager().Get(caller).hasPermission(AchievementManager.Perm.SEE_FULL_STATS)) + attemptOffline(caller, args); return; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 0698939f2..df6a39c87 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -56,9 +56,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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.antihack.actions.AntiHackAction; import mineplex.core.antihack.actions.BanwaveAction; import mineplex.core.antihack.actions.GEPBanAction; @@ -89,8 +88,6 @@ import mineplex.core.punish.Punishment; import mineplex.core.punish.PunishmentResponse; import mineplex.serverdata.commands.ServerCommandManager; -import static mineplex.core.account.permissions.GroupPermission.of; - @ReflectivelyCreateMiniPlugin public class AntiHack extends MiniPlugin { @@ -131,14 +128,17 @@ 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"; + + public enum Perm implements Permission + { + SEE_GUARDIANS, + SEE_ALERTS, + SILENTLY_BANNED, + ANTICHEAT_TOGGLE_COMMAND, + DETAILED_MESSAGES_COMMAND, + GET_VLS_COMMAND, + TEST_BAN_COMMAND, + } private final Cache _cooldown = CacheBuilder.newBuilder() .concurrencyLevel(1) @@ -186,7 +186,7 @@ public class AntiHack extends MiniPlugin { player.spigot().sendMessage(detailed); } - else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(SEE_ALERTS_PERMISSION)) && (violation.getOriginatingServer().equals(_thisServer) || _preferences.get(player).isActive(Preference.GLOBAL_GWEN_REPORTS))) + else if (_clientManager.Get(player).hasPermission(Perm.SEE_ALERTS) && (violation.getOriginatingServer().equals(_thisServer) || _preferences.get(player).isActive(Preference.GLOBAL_GWEN_REPORTS))) { player.spigot().sendMessage(minimal); } @@ -200,25 +200,24 @@ public class AntiHack extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(SEE_GUARDIANS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(SEE_GUARDIANS_PERMISSION), true, false); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SEE_GUARDIANS_PERMISSION), true, true); - - pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(SILENTLY_BANNED_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, of(SILENTLY_BANNED_PERMISSION), true, true); - - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(SEE_ALERTS_PERMISSION), true, true); + PermissionGroup.PLAYER.setPermission(Perm.SEE_GUARDIANS, true, true); + PermissionGroup.BUILDER.setPermission(Perm.SEE_GUARDIANS, true, false); + PermissionGroup.ADMIN.setPermission(Perm.SEE_GUARDIANS, true, true); + + PermissionGroup.CONTENT.setPermission(Perm.SILENTLY_BANNED, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.SILENTLY_BANNED, true, true); + + PermissionGroup.TRAINEE.setPermission(Perm.SEE_ALERTS, true, true); if (UtilServer.isTestServer()) { - pm.setPermission(PermissionGroup.DEV, GroupPermission.of(ANTICHEAT_TOGGLE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.DEV, GroupPermission.of(TEST_BAN_COMMAND_PERMISSION), true, true); + PermissionGroup.DEV.setPermission(Perm.ANTICHEAT_TOGGLE_COMMAND, true, true); + PermissionGroup.DEV.setPermission(Perm.TEST_BAN_COMMAND, true, true); } - pm.setPermission(PermissionGroup.DEV, GroupPermission.of(DETAILED_MESSAGES_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.DEV, GroupPermission.of(GET_VLS_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.QA, GroupPermission.of(DETAILED_MESSAGES_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.QA, GroupPermission.of(GET_VLS_COMMAND_PERMISSION), true, true); + PermissionGroup.DEV.setPermission(Perm.DETAILED_MESSAGES_COMMAND, true, true); + PermissionGroup.DEV.setPermission(Perm.GET_VLS_COMMAND, true, true); + PermissionGroup.QA.setPermission(Perm.DETAILED_MESSAGES_COMMAND, true, true); + PermissionGroup.QA.setPermission(Perm.GET_VLS_COMMAND, true, true); } @Override @@ -280,15 +279,14 @@ public class AntiHack extends MiniPlugin } }; - if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(SILENTLY_BANNED_PERMISSION))) + if (_clientManager.Get(player).hasPermission(Perm.SILENTLY_BANNED)) { doPunish.accept(result -> { _pendingBan.remove(player); _banned.add(player.getUniqueId()); }); - } - else + } else { runBanAnimation(player, () -> { @@ -329,11 +327,11 @@ public class AntiHack extends MiniPlugin } }; - if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(SILENTLY_BANNED_PERMISSION))) + if (_clientManager.Get(player).hasPermission(Perm.SILENTLY_BANNED)) { - doPunish.accept(response -> {}); - } - else + doPunish.accept(response -> { + }); + } else { runBanAnimation(player, () -> { 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 0e7bd0f61..62b01de35 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/AnticheatOffCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/AnticheatOffCommand.java @@ -11,7 +11,7 @@ public class AnticheatOffCommand extends CommandBase { public AnticheatOffCommand(AntiHack plugin) { - super(plugin, AntiHack.ANTICHEAT_TOGGLE_COMMAND_PERMISSION, "acoff"); + super(plugin, AntiHack.Perm.ANTICHEAT_TOGGLE_COMMAND, "acoff"); } @Override 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 39a7b0f0a..9a158f6ae 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/AnticheatOnCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/AnticheatOnCommand.java @@ -11,7 +11,7 @@ public class AnticheatOnCommand extends CommandBase { public AnticheatOnCommand(AntiHack plugin) { - super(plugin, AntiHack.ANTICHEAT_TOGGLE_COMMAND_PERMISSION, "acon"); + super(plugin, AntiHack.Perm.ANTICHEAT_TOGGLE_COMMAND, "acon"); } @Override 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 1001a6502..3c7e8c391 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/DetailedMessagesCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/DetailedMessagesCommand.java @@ -11,7 +11,7 @@ public class DetailedMessagesCommand extends CommandBase { public DetailedMessagesCommand(AntiHack plugin) { - super(plugin, AntiHack.DETAILED_MESSAGES_COMMAND_PERMISSION, "detailedmessages"); + super(plugin, AntiHack.Perm.DETAILED_MESSAGES_COMMAND, "detailedmessages"); } @Override 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 5d90698b8..4a8f25bbd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/GetVlsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/GetVlsCommand.java @@ -16,7 +16,7 @@ public class GetVlsCommand extends CommandBase { public GetVlsCommand(AntiHack plugin) { - super(plugin, AntiHack.GET_VLS_COMMAND_PERMISSION, "getvls"); + super(plugin, AntiHack.Perm.GET_VLS_COMMAND, "getvls"); } @Override 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 4ab0accee..fb91de269 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/TestBanCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/commands/TestBanCommand.java @@ -16,7 +16,7 @@ public class TestBanCommand extends CommandBase { public TestBanCommand(AntiHack plugin) { - super(plugin, AntiHack.TEST_BAN_COMMAND_PERMISSION, "testban"); + super(plugin, AntiHack.Perm.TEST_BAN_COMMAND, "testban"); } @Override 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 8bd3079c3..3453e8682 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/AntiHackGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/AntiHackGuardian.java @@ -4,6 +4,9 @@ import java.util.Random; import java.util.UUID; import java.util.function.Function; +import net.minecraft.server.v1_8_R3.EntityArmorStand; +import net.minecraft.server.v1_8_R3.EntityPlayer; + import org.bukkit.Location; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArmorStand; @@ -20,15 +23,12 @@ 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 { @@ -118,7 +118,7 @@ public class AntiHackGuardian implements Listener if (!hideForStaff) return true; // Don't let Builder -> Admin see it - if (!clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(AntiHack.SEE_GUARDIANS_PERMISSION))) + if (!clientManager.Get(player).hasPermission(AntiHack.Perm.SEE_GUARDIANS)) { return false; } 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 91e45f771..3161efe73 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AntihackLogger.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/logging/AntihackLogger.java @@ -22,9 +22,8 @@ import com.google.gson.JsonObject; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.antihack.AntiHack; import mineplex.core.antihack.logging.builtin.PartyInfoMetadata; import mineplex.core.antihack.logging.builtin.PlayerInfoMetadata; @@ -39,8 +38,11 @@ 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"; + + public enum Perm implements Permission + { + SAVE_METADATA_COMMAND, + } private final CoreClientManager _clientManager = require(CoreClientManager.class); @@ -67,15 +69,14 @@ public class AntihackLogger extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(PermissionGroup.QA, GroupPermission.of(SAVE_METADATA_COMMAND_PERMISSION), true, true); + PermissionGroup.QA.setPermission(Perm.SAVE_METADATA_COMMAND, true, true); } public void addCommands() { if (UtilServer.isTestServer()) { - addCommand(new CommandBase(this, SAVE_METADATA_COMMAND_PERMISSION, "savemetadata") + addCommand(new CommandBase(this, Perm.SAVE_METADATA_COMMAND, "savemetadata") { @Override public void Execute(Player caller, String[] args) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java index a6e23e930..75af5e7f4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java @@ -8,12 +8,9 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.aprilfools.command.PirateSongCommand; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; @@ -81,8 +78,11 @@ public class AprilFoolsManager extends MiniPlugin .put("developer", "firstmate") .put("admin", "firstmate") .build(); - - public static final String PIRATE_SONG_COMMAND_PERMISSION = "mineplex.core.aprilfools.piratesong"; + + public enum Perm implements Permission + { + PIRATE_SONG_COMMAND, + } private static AprilFoolsManager _instance; private final AprilFoolsRepository _repository; @@ -106,8 +106,7 @@ public class AprilFoolsManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PIRATE_SONG_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.PIRATE_SONG_COMMAND, true, true); } @Override 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 95ac34420..2c1ee6c55 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/command/PirateSongCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/command/PirateSongCommand.java @@ -22,7 +22,7 @@ public class PirateSongCommand extends CommandBase public PirateSongCommand(AprilFoolsManager plugin) { - super(plugin, AprilFoolsManager.PIRATE_SONG_COMMAND_PERMISSION, "piratesong"); + super(plugin, AprilFoolsManager.Perm.PIRATE_SONG_COMMAND, "piratesong"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java b/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java index 3c50b529d..40e4da78c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java @@ -12,9 +12,8 @@ import com.google.common.collect.ImmutableSet; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.powerplayclub.PowerPlayClubRepository; public class BetaWhitelist extends MiniPlugin @@ -42,9 +41,12 @@ 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"; - + + public enum Perm implements Permission + { + BYPASS_WHITELIST, + } + private final CoreClientManager _clientManager; private final PowerPlayClubRepository _powerPlayClubRepository; @@ -59,18 +61,17 @@ public class BetaWhitelist extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(BYPASS_WHITELIST_PERMISSION), true, true); + + PermissionGroup.ULTRA.setPermission(Perm.BYPASS_WHITELIST, true, true); } @EventHandler public void onJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); - 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, + if (_clientManager.Get(player).hasPermission(Perm.BYPASS_WHITELIST) // If this player is Ultra+ + || _powerPlayClubRepository.getCachedData(player).isSubscribed() // a PPC subscriber, + || EXTRA_PLAYERS.contains(player.getUniqueId())) // or explicitly whitelisted, { return; // allow them in } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index b4dd34457..ad21ed84d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -39,9 +39,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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.bonuses.animations.AnimationCarl; import mineplex.core.bonuses.commands.AnimationCommand; import mineplex.core.bonuses.commands.GuiCommand; @@ -94,18 +93,21 @@ public class BonusManager extends MiniClientPlugin implements I public static final TimeZone TIMEZONE = TimeZone.getTimeZone("UTC"); 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"; + + public enum Perm implements Permission + { + ETERNAL_BONUS, + TITAN_BONUS, + LEGEND_BONUS, + HERO_BONUS, + ULTRA_BONUS, + MONTHLY_BONUS, + ALLOW_COMMAND, + ANIMATION_COMMAND, + GUI_COMMAND, + POWER_PLAY_COMMAND, + TICKET_COMMAND, + } private ArrayList _pendingExplosions = new ArrayList<>(); private ArrayList _pendingExplosionsPlayers = new ArrayList<>(); @@ -310,19 +312,18 @@ public class BonusManager extends MiniClientPlugin implements I private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(MONTHLY_BONUS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(ULTRA_BONUS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.HERO, GroupPermission.of(HERO_BONUS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.LEGEND, GroupPermission.of(LEGEND_BONUS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(TITAN_BONUS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ETERNAL, GroupPermission.of(ETERNAL_BONUS_PERMISSION), true, true); - - //pm.setPermission(pm.getGroup("mod"), GroupPermission.of(ALLOW_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.DEV, GroupPermission.of(ANIMATION_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.DEV, GroupPermission.of(GUI_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(POWER_PLAY_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TICKET_COMMAND_PERMISSION), true, true); + PermissionGroup.ULTRA.setPermission(Perm.MONTHLY_BONUS, true, true); + PermissionGroup.ULTRA.setPermission(Perm.ULTRA_BONUS, true, true); + PermissionGroup.HERO.setPermission(Perm.HERO_BONUS, true, true); + PermissionGroup.LEGEND.setPermission(Perm.LEGEND_BONUS, true, true); + PermissionGroup.TITAN.setPermission(Perm.TITAN_BONUS, true, true); + PermissionGroup.ETERNAL.setPermission(Perm.ETERNAL_BONUS, true, true); + + //pm.setPermission(pm.getGroup("mod"), Perm.ALLOW_COMMAND, true, true); + PermissionGroup.DEV.setPermission(Perm.ANIMATION_COMMAND, true, true); + PermissionGroup.DEV.setPermission(Perm.GUI_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.POWER_PLAY_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.TICKET_COMMAND, true, true); } @Override @@ -782,25 +783,21 @@ public class BonusManager extends MiniClientPlugin implements I { BonusAmount data = new BonusAmount(); - if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(ETERNAL_BONUS_PERMISSION))) + if (_clientManager.Get(player).hasPermission(Perm.ETERNAL_BONUS)) { data.setIlluminatedChests(2); data.setMythicalChests(2); data.setOmegaChests(1); - } - else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TITAN_BONUS_PERMISSION))) + } else if (_clientManager.Get(player).hasPermission(Perm.TITAN_BONUS)) { data.setMythicalChests(5); - } - else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(LEGEND_BONUS_PERMISSION))) + } else if (_clientManager.Get(player).hasPermission(Perm.LEGEND_BONUS)) { data.setMythicalChests(3); - } - else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(HERO_BONUS_PERMISSION))) + } else if (_clientManager.Get(player).hasPermission(Perm.HERO_BONUS)) { data.setMythicalChests(2); - } - else if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(ULTRA_BONUS_PERMISSION))) + } else if (_clientManager.Get(player).hasPermission(Perm.ULTRA_BONUS)) { data.setMythicalChests(1); } @@ -1016,7 +1013,7 @@ 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.getPermissionManager().hasPermission(player, GroupPermission.of(MONTHLY_BONUS_PERMISSION)) && isPastAugust()) availableRewards++; + if (canRank(player) && _clientManager.Get(player).hasPermission(Perm.MONTHLY_BONUS) && isPastAugust()) availableRewards++; if (canDaily(player)) availableRewards++; if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).getPrimaryGroup()) != null) availableRewards++; if (!_facebookManager.hasRedeemed(player)) availableRewards++; @@ -1176,7 +1173,7 @@ public class BonusManager extends MiniClientPlugin implements I { if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false)) { - if (_pollManager.hasPoll(player) || canVote(player) || _youtubeManager.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 (_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.Get(player).hasPermission(Perm.MONTHLY_BONUS) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) { if (_showCarl.containsKey(player.getName())) { 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 bff252026..93119ef5e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AllowCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AllowCommand.java @@ -20,7 +20,7 @@ public class AllowCommand extends CommandBase public AllowCommand(BonusManager plugin) { - super(plugin, BonusManager.ALLOW_COMMAND_PERMISSION, "allowCommand", "allowCmd"); + super(plugin, BonusManager.Perm.ALLOW_COMMAND, "allowCommand", "allowCmd"); _plugin = plugin; } @@ -39,7 +39,7 @@ public class AllowCommand extends CommandBase return; } ICommand iCommand = commands.get(args[1]); - if (!_plugin.getClientManager().getPermissionManager().hasPermission(caller, iCommand.getPermission())) + if (!_plugin.getClientManager().Get(caller).hasPermission(iCommand.getPermission())) { UtilPlayer.message(caller, F.main("Allow Command", "You're not allowed to use that command!")); return; 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 18f0dd1dc..96d54ae38 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/AnimationCommand.java @@ -13,7 +13,7 @@ public class AnimationCommand extends CommandBase{ public AnimationCommand(BonusManager plugin) { - super(plugin, BonusManager.ANIMATION_COMMAND_PERMISSION, "animation"); + super(plugin, BonusManager.Perm.ANIMATION_COMMAND, "animation"); _plugin = plugin; } 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 a2a6361c4..bd48a0205 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/GuiCommand.java @@ -10,7 +10,7 @@ public class GuiCommand extends CommandBase { public GuiCommand(BonusManager plugin) { - super(plugin, BonusManager.GUI_COMMAND_PERMISSION, "bonus"); + super(plugin, BonusManager.Perm.GUI_COMMAND, "bonus"); } @Override 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 db6d95443..627caa91d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/PowerPlayCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/PowerPlayCommand.java @@ -19,7 +19,7 @@ public class PowerPlayCommand extends CommandBase public PowerPlayCommand(BonusManager manager) { - super(manager, BonusManager.POWER_PLAY_COMMAND_PERMISSION, "powerplay"); + super(manager, BonusManager.Perm.POWER_PLAY_COMMAND, "powerplay"); _bonusManager = manager; } 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 cb9ccde34..b2cb33b36 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java @@ -12,7 +12,7 @@ public class TicketCommand extends CommandBase { public TicketCommand(BonusManager plugin) { - super(plugin, BonusManager.TICKET_COMMAND_PERMISSION, "ticket"); + super(plugin, BonusManager.Perm.TICKET_COMMAND, "ticket"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java index 730598c35..1601f7d51 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/BoosterManager.java @@ -22,9 +22,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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.boosters.command.BoosterCommand; import mineplex.core.boosters.event.BoosterActivateEvent; import mineplex.core.boosters.event.BoosterExpireEvent; @@ -69,12 +68,15 @@ 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"; + + public enum Perm implements Permission + { + ADD_BOOSTER_COMMAND, + BOOSTER_COMMAND, + BOOSTER_GUI_COMMAND, + RELOAD_BOOSTERS_COMMAND, + THANK_COMMAND, + } private BoosterRepository _repository; private CoreClientManager _clientManager; @@ -123,13 +125,11 @@ public class BoosterManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(BOOSTER_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(THANK_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.DEV, GroupPermission.of(ADD_BOOSTER_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.DEV, GroupPermission.of(RELOAD_BOOSTERS_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.DEV, GroupPermission.of(BOOSTER_GUI_COMMAND_PERMISSION), true, true); + PermissionGroup.PLAYER.setPermission(Perm.BOOSTER_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.THANK_COMMAND, true, true); + PermissionGroup.DEV.setPermission(Perm.ADD_BOOSTER_COMMAND, true, true); + PermissionGroup.DEV.setPermission(Perm.RELOAD_BOOSTERS_COMMAND, true, true); + PermissionGroup.DEV.setPermission(Perm.BOOSTER_GUI_COMMAND, true, true); } @Override 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 a334efbba..fd351b639 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/AddCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/AddCommand.java @@ -17,7 +17,7 @@ public class AddCommand extends CommandBase { public AddCommand(BoosterManager plugin) { - super(plugin, BoosterManager.ADD_BOOSTER_COMMAND_PERMISSION, "add"); + super(plugin, BoosterManager.Perm.ADD_BOOSTER_COMMAND, "add"); } @Override 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 fa491b473..c4f64670b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java @@ -15,7 +15,7 @@ public class BoosterCommand extends MultiCommandBase { public BoosterCommand(BoosterManager plugin) { - super(plugin, BoosterManager.BOOSTER_COMMAND_PERMISSION, "amplifier"); + super(plugin, BoosterManager.Perm.BOOSTER_COMMAND, "amplifier"); AddCommand(new AddCommand(plugin)); AddCommand(new GuiCommand(plugin)); 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 a17396680..9d1554066 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/GuiCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/GuiCommand.java @@ -12,7 +12,7 @@ public class GuiCommand extends CommandBase { public GuiCommand(BoosterManager plugin) { - super(plugin, BoosterManager.BOOSTER_GUI_COMMAND_PERMISSION, "gui"); + super(plugin, BoosterManager.Perm.BOOSTER_GUI_COMMAND, "gui"); } @Override 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 d5b0f9ea7..a9a65ff18 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ReloadCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ReloadCommand.java @@ -14,7 +14,7 @@ public class ReloadCommand extends CommandBase { public ReloadCommand(BoosterManager plugin) { - super(plugin, BoosterManager.RELOAD_BOOSTERS_COMMAND_PERMISSION, "reload"); + super(plugin, BoosterManager.Perm.RELOAD_BOOSTERS_COMMAND, "reload"); } @Override 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 0ec536c60..dea04245d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/ThankCommand.java @@ -20,7 +20,7 @@ public class ThankCommand extends CommandBase { public ThankCommand(BoosterManager plugin) { - super(plugin, BoosterManager.THANK_COMMAND_PERMISSION, "thank"); + super(plugin, BoosterManager.Perm.THANK_COMMAND, "thank"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java index 8261150d3..21dc7a869 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java @@ -11,9 +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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.botspam.command.BotSpamCommand; import mineplex.core.botspam.repository.BotSpamRepository; import mineplex.core.message.PrivateMessageEvent; @@ -25,13 +24,16 @@ 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"; - + public enum Perm implements Permission + { + BYPASS_BOTSPAM, + BOTSPAM_COMMAND, + ADD_BOTSPAM_COMMAND, + TOGGLE_BOTSPAM_COMMAND, + UPDATE_BOTSPAM_COMMAND, + LIST_BOTSPAM_COMMAND, + } + private Punish _punish; private CoreClientManager _clientManager; private BotSpamRepository _repository; @@ -48,20 +50,19 @@ 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(PermissionGroup.TRAINEE, GroupPermission.of(BYPASS_BOTSPAM_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BOTSPAM_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(ADD_BOTSPAM_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TOGGLE_BOTSPAM_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(UPDATE_BOTSPAM_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(LIST_BOTSPAM_COMMAND_PERMISSION), true, true); + + PermissionGroup.TRAINEE.setPermission(Perm.BYPASS_BOTSPAM, true, true); + PermissionGroup.ADMIN.setPermission(Perm.BOTSPAM_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.ADD_BOTSPAM_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.TOGGLE_BOTSPAM_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.UPDATE_BOTSPAM_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.LIST_BOTSPAM_COMMAND, true, true); } @EventHandler @@ -69,11 +70,11 @@ public class BotSpamManager extends MiniPlugin { Player recipient = event.getRecipient(); // Ignore messages sent to staff members - if (_clientManager.getPermissionManager().hasPermission(recipient, GroupPermission.of(BYPASS_BOTSPAM_PERMISSION))) + if (_clientManager.Get(recipient).hasPermission(Perm.BYPASS_BOTSPAM)) return; // Ignore messages sent by staff members - if (_clientManager.getPermissionManager().hasPermission(event.getSender(), GroupPermission.of(BYPASS_BOTSPAM_PERMISSION))) + if (_clientManager.Get(event.getSender()).hasPermission(Perm.BYPASS_BOTSPAM)) return; for (SpamText spamText : _spam) @@ -91,7 +92,7 @@ public class BotSpamManager extends MiniPlugin public void onChat(final AsyncPlayerChatEvent event) { // Ignore messages sent by staff members - if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(BYPASS_BOTSPAM_PERMISSION))) + if (_clientManager.Get(event.getPlayer()).hasPermission(Perm.BYPASS_BOTSPAM)) return; for (final SpamText spamText : _spam) 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 4680f444d..cf74a6c80 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamAddCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamAddCommand.java @@ -13,7 +13,7 @@ public class BotSpamAddCommand extends CommandBase { public BotSpamAddCommand(BotSpamManager plugin) { - super(plugin, BotSpamManager.ADD_BOTSPAM_COMMAND_PERMISSION, "add"); + super(plugin, BotSpamManager.Perm.ADD_BOTSPAM_COMMAND, "add"); } @Override 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 e62de6dd1..cafeb9d02 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamCommand.java @@ -11,7 +11,7 @@ public class BotSpamCommand extends MultiCommandBase { public BotSpamCommand(BotSpamManager plugin) { - super(plugin, BotSpamManager.BOTSPAM_COMMAND_PERMISSION, "botban", "botspam"); + super(plugin, BotSpamManager.Perm.BOTSPAM_COMMAND, "botban", "botspam"); AddCommand(new BotSpamAddCommand(Plugin)); AddCommand(new BotSpamEnableCommand(Plugin)); 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 509909ff6..69f1307ad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamDisableCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamDisableCommand.java @@ -12,7 +12,7 @@ public class BotSpamDisableCommand extends CommandBase { public BotSpamDisableCommand(BotSpamManager plugin) { - super(plugin, BotSpamManager.TOGGLE_BOTSPAM_COMMAND_PERMISSION, "disable"); + super(plugin, BotSpamManager.Perm.TOGGLE_BOTSPAM_COMMAND, "disable"); } @Override 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 c6d0cf8b3..a18160f30 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamEnableCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamEnableCommand.java @@ -12,7 +12,7 @@ public class BotSpamEnableCommand extends CommandBase { public BotSpamEnableCommand(BotSpamManager plugin) { - super(plugin, BotSpamManager.TOGGLE_BOTSPAM_COMMAND_PERMISSION, "enable"); + super(plugin, BotSpamManager.Perm.TOGGLE_BOTSPAM_COMMAND, "enable"); } @Override 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 693d26a46..0ba5257f0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamGlobalUpdateCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamGlobalUpdateCommand.java @@ -13,7 +13,7 @@ public class BotSpamGlobalUpdateCommand extends CommandBase { public BotSpamGlobalUpdateCommand(BotSpamManager plugin) { - super(plugin, BotSpamManager.UPDATE_BOTSPAM_COMMAND_PERMISSION, "globalupdate"); + super(plugin, BotSpamManager.Perm.UPDATE_BOTSPAM_COMMAND, "globalupdate"); } @Override 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 3166f42c4..2ada9ed69 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamListCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamListCommand.java @@ -3,6 +3,12 @@ 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; @@ -12,17 +18,12 @@ import mineplex.core.command.CommandBase; 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, BotSpamManager.LIST_BOTSPAM_COMMAND_PERMISSION, "list"); + super(plugin, BotSpamManager.Perm.LIST_BOTSPAM_COMMAND, "list"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index a426b0302..dc466f5b8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -36,9 +36,8 @@ import org.json.simple.JSONValue; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.chat.command.BroadcastCommand; import mineplex.core.chat.command.ChatSlowCommand; @@ -58,16 +57,19 @@ 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"; + public enum Perm implements Permission + { + ALLOW_CAPS, + BYPASS_COOLDOWN, + BYPASS_SLOW, + BYPASS_SILENCE, + BYPASS_SIGNS, + ALLOW_HACKUSATE, + ALLOW_SIMILAR, + SILENCE_COMMAND, + SLOW_CHAT_COMMAND, + BROADCAST_COMMAND, + } private CoreClientManager _clientManager; private PreferencesManager _preferences; @@ -112,17 +114,16 @@ public class Chat extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(ALLOW_CAPS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(BYPASS_COOLDOWN_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(BYPASS_SLOW_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(BYPASS_SILENCE_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BYPASS_SIGNS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(ALLOW_HACKUSATE_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(ALLOW_SIMILAR_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SILENCE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.SRMOD, GroupPermission.of(SLOW_CHAT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(BROADCAST_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.ALLOW_CAPS, true, true); + PermissionGroup.MOD.setPermission(Perm.BYPASS_COOLDOWN, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.BYPASS_SLOW, true, true); + PermissionGroup.MOD.setPermission(Perm.BYPASS_SILENCE, true, true); + PermissionGroup.ADMIN.setPermission(Perm.BYPASS_SIGNS, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.ALLOW_HACKUSATE, true, true); + PermissionGroup.MOD.setPermission(Perm.ALLOW_SIMILAR, true, true); + PermissionGroup.ADMIN.setPermission(Perm.SILENCE_COMMAND, true, true); + PermissionGroup.SRMOD.setPermission(Perm.SLOW_CHAT_COMMAND, true, true); + PermissionGroup.MOD.setPermission(Perm.BROADCAST_COMMAND, true, true); } @Override @@ -220,7 +221,7 @@ public class Chat extends MiniPlugin if (_silenced == 0) return false; - if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(BYPASS_SILENCE_PERMISSION))) + if (_clientManager.Get(player).hasPermission(Perm.BYPASS_SILENCE)) return false; if (_silenced == -1) @@ -238,7 +239,7 @@ public class Chat extends MiniPlugin @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onSignChange(SignChangeEvent event) { - if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(BYPASS_SIGNS_PERMISSION))) + if (_clientManager.Get(event.getPlayer()).hasPermission(Perm.BYPASS_SIGNS)) { return; } @@ -376,13 +377,13 @@ public class Chat extends MiniPlugin event.setCancelled(true); return; } - else if (!_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(BYPASS_COOLDOWN_PERMISSION)) && + else if (!_clientManager.Get(sender).hasPermission(Perm.BYPASS_COOLDOWN) && !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.getPermissionManager().hasPermission(sender, GroupPermission.of(ALLOW_HACKUSATE_PERMISSION)) && + else if (!_clientManager.Get(sender).hasPermission(Perm.ALLOW_HACKUSATE) && msgContainsHack(event.getMessage())) { UtilPlayer.message(sender, F.main("Chat", @@ -396,12 +397,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.getPermissionManager().hasPermission(sender, GroupPermission.of(BYPASS_SLOW_PERMISSION))) + if (timeDiff < chatSlowTime && !_clientManager.Get(sender).hasPermission(Perm.BYPASS_SLOW)) { 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.getPermissionManager().hasPermission(sender, GroupPermission.of(ALLOW_SIMILAR_PERMISSION)) && + else if (!_clientManager.Get(sender).hasPermission(Perm.ALLOW_SIMILAR) && UtilText.isStringSimilar(event.getMessage(), lastMessage.getMessage(), 0.8f)) { UtilPlayer.message(sender, F.main("Chat", "This message is too similar to your previous message.")); @@ -412,7 +413,7 @@ public class Chat extends MiniPlugin if (!event.isCancelled()) { String oldMessage = event.getMessage(); - if (!_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(ALLOW_CAPS_PERMISSION))) + if (!_clientManager.Get(sender).hasPermission(Perm.ALLOW_CAPS)) { int capsCount = 0; for (char c : oldMessage.toCharArray()) 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 191cdfc4b..fc9f5a717 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/BroadcastCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/BroadcastCommand.java @@ -12,7 +12,7 @@ public class BroadcastCommand extends CommandBase { public BroadcastCommand(Chat plugin) { - super(plugin, Chat.BROADCAST_COMMAND_PERMISSION, "s"); + super(plugin, Chat.Perm.BROADCAST_COMMAND, "s"); } @Override 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 6eb8c772e..a4f6e50d8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/ChatSlowCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/ChatSlowCommand.java @@ -11,7 +11,7 @@ public class ChatSlowCommand extends CommandBase { public ChatSlowCommand(Chat plugin) { - super(plugin, Chat.SLOW_CHAT_COMMAND_PERMISSION, "chatslow"); + super(plugin, Chat.Perm.SLOW_CHAT_COMMAND, "chatslow"); } @Override 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 9649cddc1..d707e1d18 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/SilenceCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/SilenceCommand.java @@ -11,7 +11,7 @@ public class SilenceCommand extends CommandBase { public SilenceCommand(Chat plugin) { - super(plugin, Chat.SILENCE_COMMAND_PERMISSION, "silence"); + super(plugin, Chat.Perm.SILENCE_COMMAND, "silence"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java index d6a5d8580..e45edc4dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/SnapshotPlugin.java @@ -11,9 +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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.chatsnap.command.ChatSnapCommand; import mineplex.core.message.PrivateMessageEvent; @@ -22,8 +21,11 @@ import mineplex.core.message.PrivateMessageEvent; */ public class SnapshotPlugin extends MiniPlugin { - public static final String CHAT_SNAP_COMMAND_PERMISSION = "mineplex.core.chatsnap.command"; - + public enum Perm implements Permission + { + CHAT_SNAP_COMMAND, + } + private final SnapshotManager _snapshotManager; private final CoreClientManager _clientManager; @@ -38,9 +40,8 @@ public class SnapshotPlugin extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(CHAT_SNAP_COMMAND_PERMISSION), true, true); + + PermissionGroup.TITAN.setPermission(Perm.CHAT_SNAP_COMMAND, true, true); } public SnapshotManager getSnapshotManager() 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 b55002e92..e66275011 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chatsnap/command/ChatSnapCommand.java @@ -22,7 +22,7 @@ public class ChatSnapCommand extends CommandBase { public ChatSnapCommand(SnapshotPlugin plugin) { - super(plugin, SnapshotPlugin.CHAT_SNAP_COMMAND_PERMISSION, "chatsnap"); + super(plugin, SnapshotPlugin.Perm.CHAT_SNAP_COMMAND, "chatsnap"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java index e0ce0e24d..a31c04e1e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java @@ -15,23 +15,23 @@ import org.bukkit.entity.Player; import mineplex.core.MiniPlugin; import mineplex.core.PlayerSelector; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.common.util.UtilLambda; import mineplex.core.recharge.Recharge; public abstract class CommandBase implements ICommand { - private final GroupPermission _permission; + private final Permission _permission; private List _aliases; protected PluginType Plugin; protected String _aliasUsed; protected CommandCenter _commandCenter; - public CommandBase(PluginType plugin, String permission, String... aliases) + public CommandBase(PluginType plugin, Permission permission, String... aliases) { Plugin = plugin; - _permission = GroupPermission.of(permission); + _permission = permission; _aliases = Arrays.asList(aliases); } @@ -45,7 +45,7 @@ public abstract class CommandBase implements ICom _aliasUsed = alias; } - public GroupPermission getPermission() + public Permission getPermission() { return _permission; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java index 95544aa92..5806b7763 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java @@ -20,7 +20,7 @@ import com.google.common.collect.Lists; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -46,8 +46,11 @@ 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"; + + public enum Perm implements Permission + { + BLOCKED_COMMAND, + } static { @@ -81,17 +84,17 @@ public class CommandCenter implements Listener, IPacketHandler Plugin.getServer().getPluginManager().registerEvents(this, Plugin); _packetHandler.addPacketHandler(this, true, PacketPlayInTabComplete.class); + + PermissionGroup.DEV.setPermission(Perm.BLOCKED_COMMAND, true, true); + if (UtilServer.isTestServer()) + { + PermissionGroup.QAM.setPermission(Perm.BLOCKED_COMMAND, false, true); + } } public void setClientManager(CoreClientManager clientManager) { ClientManager = clientManager; - - clientManager.getPermissionManager().setPermission(PermissionGroup.DEV, GroupPermission.of(BLOCKED_COMMAND_PERMISSION), true, true); - if (UtilServer.isTestServer()) - { - clientManager.getPermissionManager().setPermission(PermissionGroup.QAM, GroupPermission.of(BLOCKED_COMMAND_PERMISSION), false, true); - } } @EventHandler @@ -113,7 +116,7 @@ public class CommandCenter implements Listener, IPacketHandler { event.setCancelled(true); - if (ClientManager.getPermissionManager().hasPermission(event.getPlayer(), command.getPermission()) + if (ClientManager.Get(event.getPlayer()).hasPermission(command.getPermission()) || UtilPlayer.isCommandAllowed(event.getPlayer(), commandName.toLowerCase())) { if (!Recharge.Instance.use(event.getPlayer(), "Command", 500, false, false)) @@ -138,7 +141,7 @@ public class CommandCenter implements Listener, IPacketHandler return; } - if (BLOCKED_COMMANDS.contains(commandName.toLowerCase()) && !(event.getPlayer().isOp() || ClientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(BLOCKED_COMMAND_PERMISSION)))) + if (BLOCKED_COMMANDS.contains(commandName.toLowerCase()) && !(event.getPlayer().isOp() || ClientManager.Get(event.getPlayer()).hasPermission(Perm.BLOCKED_COMMAND))) { event.setCancelled(true); event.getPlayer().sendMessage(MESSAGE); @@ -212,7 +215,7 @@ public class CommandCenter implements Listener, IPacketHandler if (command != null) { - if (ClientManager.getPermissionManager().hasPermission(packetInfo.getPlayer(), command.getPermission()) + if (ClientManager.Get(packetInfo.getPlayer()).hasPermission(command.getPermission()) || UtilPlayer.isCommandAllowed(packetInfo.getPlayer(), commandName.toLowerCase())) { List tmpres = command.onTabComplete(packetInfo.getPlayer(), commandName.toLowerCase(), args); @@ -229,7 +232,7 @@ public class CommandCenter implements Listener, IPacketHandler // System.out.println("Path 2"); for (ICommand command : Commands.values()) { - if (ClientManager.getPermissionManager().hasPermission(packetInfo.getPlayer(), command.getPermission()) + if (ClientManager.Get(packetInfo.getPlayer()).hasPermission(command.getPermission()) || UtilPlayer.isCommandAllowed(packetInfo.getPlayer(), commandName.toLowerCase())) { for (String alias : command.Aliases()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/ICommand.java b/Plugins/Mineplex.Core/src/mineplex/core/command/ICommand.java index 24751aaef..7643f5cf4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/ICommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/ICommand.java @@ -6,7 +6,7 @@ import java.util.List; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.lifetimes.Component; public interface ICommand extends Component @@ -18,7 +18,7 @@ public interface ICommand extends Component void SetAliasUsed(String name); - GroupPermission getPermission(); + Permission getPermission(); @Override default void activate() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/MultiCommandBase.java b/Plugins/Mineplex.Core/src/mineplex/core/command/MultiCommandBase.java index b8a99d967..6f2da14ba 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/MultiCommandBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/MultiCommandBase.java @@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.MiniPlugin; +import mineplex.core.account.permissions.Permission; import mineplex.core.common.util.C; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilPlayerBase; @@ -17,7 +18,7 @@ public abstract class MultiCommandBase extends Co { private NautHashMap Commands; - public MultiCommandBase(PluginType plugin, String permission, String... aliases) + public MultiCommandBase(PluginType plugin, Permission permission, String... aliases) { super(plugin, permission, aliases); @@ -68,13 +69,12 @@ public abstract class MultiCommandBase extends Co if (command != null) { - if (_commandCenter.ClientManager.getPermissionManager().hasPermission(caller, command.getPermission())) + if (_commandCenter.ClientManager.Get(caller).hasPermission(command.getPermission())) { command.SetAliasUsed(commandName); - + command.Execute(caller, newArgs); - } - else + } else { UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that."); } @@ -106,7 +106,7 @@ public abstract class MultiCommandBase extends Co Stream stream = Commands.values().stream(); if (sender instanceof Player) { - stream = stream.filter(command -> _commandCenter.GetClientManager().getPermissionManager().hasPermission((Player)sender, command.getPermission())); + stream = stream.filter(command -> _commandCenter.GetClientManager().Get((Player) sender).hasPermission(command.getPermission())); } return getMatches(args[0], stream.map(ICommand::Aliases).flatMap(Collection::stream)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java index 50fc93401..d5ddb7531 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java @@ -25,9 +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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; @@ -74,23 +73,26 @@ 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"; + public enum Perm implements Permission + { + OWN_COMMUNITY, + COMMUNITY_CHAT_COMMAND, + COMMUNITY_COMMAND, + COMMUNITY_DESCRIPTION_COMMAND, + COMMUNITY_DESCRIPTION_STAFF_COMMAND, + COMMUNITY_DISBAND_COMMAND, + COMMUNITY_DISBAND_STAFF_COMMAND, + COMMUNITY_INVITE_COMMAND, + COMMUNITY_INVITE_STAFF_COMMAND, + COMMUNITY_JOIN_COMMAND, + COMMUNITY_MCS_COMMAND, + COMMUNITY_MCS_STAFF_COMMAND, + COMMUNITY_MENU_COMMAND, + COMMUNITY_RENAME_COMMAND, + COMMUNITY_RENAME_STAFF_COMMAND, + COMMUNITY_UNINVITE_COMMAND, + COMMUNITY_UNINVITE_STAFF_COMMAND, + } 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 @@ -210,25 +212,24 @@ public class CommunityManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ETERNAL, GroupPermission.of(OWN_COMMUNITY_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_CHAT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_DESCRIPTION_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(COMMUNITY_DESCRIPTION_STAFF_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ETERNAL, GroupPermission.of(COMMUNITY_DISBAND_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(COMMUNITY_DISBAND_STAFF_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_INVITE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(COMMUNITY_INVITE_STAFF_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_JOIN_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_MCS_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(COMMUNITY_MCS_STAFF_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_MENU_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ETERNAL, GroupPermission.of(COMMUNITY_RENAME_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(COMMUNITY_RENAME_STAFF_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(COMMUNITY_UNINVITE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(COMMUNITY_UNINVITE_STAFF_COMMAND_PERMISSION), true, true); + + PermissionGroup.ETERNAL.setPermission(Perm.OWN_COMMUNITY, true, true); + PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_CHAT_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_DESCRIPTION_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.COMMUNITY_DESCRIPTION_STAFF_COMMAND, true, true); + PermissionGroup.ETERNAL.setPermission(Perm.COMMUNITY_DISBAND_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.COMMUNITY_DISBAND_STAFF_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_INVITE_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.COMMUNITY_INVITE_STAFF_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_JOIN_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_MCS_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.COMMUNITY_MCS_STAFF_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_MENU_COMMAND, true, true); + PermissionGroup.ETERNAL.setPermission(Perm.COMMUNITY_RENAME_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.COMMUNITY_RENAME_STAFF_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_UNINVITE_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.COMMUNITY_UNINVITE_STAFF_COMMAND, 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 d6827f07e..8efbc10a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityChatCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityChatCommand.java @@ -13,7 +13,7 @@ public class CommunityChatCommand extends CommandBase { public CommunityChatCommand(CommunityManager plugin) { - super(plugin, CommunityManager.COMMUNITY_CHAT_COMMAND_PERMISSION, "chat"); + super(plugin, CommunityManager.Perm.COMMUNITY_CHAT_COMMAND, "chat"); } @Override 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 e8620afad..f5010b330 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCommand.java @@ -15,7 +15,7 @@ public class CommunityCommand extends MultiCommandBase { public CommunityCommand(CommunityManager plugin) { - super(plugin, CommunityManager.COMMUNITY_COMMAND_PERMISSION, "community", "communities", "com"); + super(plugin, CommunityManager.Perm.COMMUNITY_COMMAND, "community", "communities", "com"); AddCommand(new CommunityChatCommand(plugin)); AddCommand(new CommunityCreateCommand(plugin)); 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 c90de7437..60e5ad93a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCreateCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCreateCommand.java @@ -18,7 +18,7 @@ public class CommunityCreateCommand extends CommandBase { public CommunityCreateCommand(CommunityManager plugin) { - super(plugin, CommunityManager.OWN_COMMUNITY_PERMISSION, "create"); + super(plugin, CommunityManager.Perm.OWN_COMMUNITY, "create"); } @Override 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 6ab6f6d9e..bd6fd73e4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDescriptionCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDescriptionCommand.java @@ -5,7 +5,6 @@ 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.util.F; @@ -20,7 +19,7 @@ public class CommunityDescriptionCommand extends CommandBase { public CommunityDescriptionCommand(CommunityManager plugin) { - super(plugin, CommunityManager.COMMUNITY_DESCRIPTION_COMMAND_PERMISSION, "description"); + super(plugin, CommunityManager.Perm.COMMUNITY_DESCRIPTION_COMMAND, "description"); } @Override @@ -44,7 +43,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).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_DESCRIPTION_STAFF_COMMAND_PERMISSION))) + if (!Managers.get(CoreClientManager.class).Get(caller).hasPermission(CommunityManager.Perm.COMMUNITY_DESCRIPTION_STAFF_COMMAND)) { 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 fbc51d35c..ad4c5df97 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDisbandCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDisbandCommand.java @@ -5,7 +5,6 @@ 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.util.F; import mineplex.core.common.util.UtilPlayer; @@ -18,7 +17,7 @@ public class CommunityDisbandCommand extends CommandBase { public CommunityDisbandCommand(CommunityManager plugin) { - super(plugin, CommunityManager.COMMUNITY_DISBAND_COMMAND_PERMISSION, "disband"); + super(plugin, CommunityManager.Perm.COMMUNITY_DISBAND_COMMAND, "disband"); } @Override @@ -37,7 +36,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).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_DISBAND_STAFF_COMMAND_PERMISSION))) + if (!Managers.get(CoreClientManager.class).Get(caller).hasPermission(CommunityManager.Perm.COMMUNITY_DISBAND_STAFF_COMMAND)) { 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 ca45ce276..fe2fec71c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityInviteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityInviteCommand.java @@ -5,7 +5,6 @@ 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.util.F; import mineplex.core.common.util.UtilPlayer; @@ -18,7 +17,7 @@ public class CommunityInviteCommand extends CommandBase { public CommunityInviteCommand(CommunityManager plugin) { - super(plugin, CommunityManager.COMMUNITY_INVITE_COMMAND_PERMISSION, "invite"); + super(plugin, CommunityManager.Perm.COMMUNITY_INVITE_COMMAND, "invite"); } @Override @@ -38,7 +37,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).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_INVITE_STAFF_COMMAND_PERMISSION))) + if (!Managers.get(CoreClientManager.class).Get(caller).hasPermission(CommunityManager.Perm.COMMUNITY_INVITE_STAFF_COMMAND)) { 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 e551543f8..e271430fd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityJoinCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityJoinCommand.java @@ -14,7 +14,7 @@ public class CommunityJoinCommand extends CommandBase { public CommunityJoinCommand(CommunityManager plugin) { - super(plugin, CommunityManager.COMMUNITY_JOIN_COMMAND_PERMISSION, "join"); + super(plugin, CommunityManager.Perm.COMMUNITY_JOIN_COMMAND, "join"); } @Override 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 6ac7005b3..d8232bf37 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMCSCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMCSCommand.java @@ -5,7 +5,6 @@ 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.util.F; import mineplex.core.common.util.UtilPlayer; @@ -19,7 +18,7 @@ public class CommunityMCSCommand extends CommandBase { public CommunityMCSCommand(CommunityManager plugin) { - super(plugin, CommunityManager.COMMUNITY_MCS_COMMAND_PERMISSION, "mcs"); + super(plugin, CommunityManager.Perm.COMMUNITY_MCS_COMMAND, "mcs"); } @Override @@ -38,7 +37,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).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_MCS_STAFF_COMMAND_PERMISSION))) + if (!Managers.get(CoreClientManager.class).Get(caller).hasPermission(CommunityManager.Perm.COMMUNITY_MCS_STAFF_COMMAND)) { 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 0885f67c4..b798eb371 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMenuCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMenuCommand.java @@ -10,7 +10,7 @@ public class CommunityMenuCommand extends CommandBase { public CommunityMenuCommand(CommunityManager plugin) { - super(plugin, CommunityManager.COMMUNITY_MENU_COMMAND_PERMISSION, "menu"); + super(plugin, CommunityManager.Perm.COMMUNITY_MENU_COMMAND, "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 c3d2e988e..6383e5369 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityRenameCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityRenameCommand.java @@ -7,7 +7,6 @@ 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.util.F; @@ -21,7 +20,7 @@ public class CommunityRenameCommand extends CommandBase { public CommunityRenameCommand(CommunityManager plugin) { - super(plugin, CommunityManager.COMMUNITY_RENAME_COMMAND_PERMISSION, "rename"); + super(plugin, CommunityManager.Perm.COMMUNITY_RENAME_COMMAND, "rename"); } @Override @@ -41,7 +40,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).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_RENAME_STAFF_COMMAND_PERMISSION))) + if (!Managers.get(CoreClientManager.class).Get(caller).hasPermission(CommunityManager.Perm.COMMUNITY_RENAME_STAFF_COMMAND)) { 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 1126ac4f4..02dfc01f3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityUnInviteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityUnInviteCommand.java @@ -5,7 +5,6 @@ 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.util.F; import mineplex.core.common.util.UtilPlayer; @@ -18,7 +17,7 @@ public class CommunityUnInviteCommand extends CommandBase { public CommunityUnInviteCommand(CommunityManager plugin) { - super(plugin, CommunityManager.COMMUNITY_UNINVITE_COMMAND_PERMISSION, "uninvite"); + super(plugin, CommunityManager.Perm.COMMUNITY_UNINVITE_COMMAND, "uninvite"); } @Override @@ -38,7 +37,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).getPermissionManager().hasPermission(caller, GroupPermission.of(CommunityManager.COMMUNITY_UNINVITE_STAFF_COMMAND_PERMISSION))) + if (!Managers.get(CoreClientManager.class).Get(caller).hasPermission(CommunityManager.Perm.COMMUNITY_UNINVITE_STAFF_COMMAND)) { 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 83eace4dd..c3d5ac8ed 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,7 +5,6 @@ import org.bukkit.event.inventory.ClickType; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.communities.Community; @@ -69,7 +68,7 @@ public class CommunityMemberButton extends CommunitiesGUIButton _fetching = true; clientManager.fetchGroups(_info.AccountId, (primaryGroup, additionalGroups) -> { - if (clientManager.getPermissionManager().hasPermission(primaryGroup, GroupPermission.of(CommunityManager.OWN_COMMUNITY_PERMISSION))) + if (primaryGroup.hasPermission(CommunityManager.Perm.OWN_COMMUNITY)) { getCommunityManager().handleRoleUpdate(_viewer, _community, _info, CommunityRole.LEADER); getCommunityManager().handleRoleUpdate(_viewer, _community, _community.getMembers().get(_viewer.getUniqueId()), CommunityRole.COLEADER); 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 8d9a05f6e..7159655bf 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 @@ -31,11 +31,10 @@ public class WinEffectPage extends GadgetPage if (gadget instanceof WinEffectRankBased) { WinEffectRankBased rankBased = (WinEffectRankBased) gadget; - if (getClientManager().getPermissionManager().hasPermission(getPlayer(), rankBased.getUnlockPermission())) + if (getClientManager().Get(getPlayer()).inheritsFrom(rankBased.getUnlockRank())) { addGadget(gadget, slot); - } - else + } else { addGadget(gadget, slot, true); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java b/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java index d83aedcc3..d876c3557 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/Creature.java @@ -23,12 +23,9 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; @@ -42,9 +39,12 @@ 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"; - + public enum Perm implements Permission + { + MOB_COMMAND, + KILL_MOB_COMMAND, + } + private boolean _spawnForce = false; private boolean _disableCustom = false; @@ -57,10 +57,9 @@ public class Creature extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(MOB_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(KILL_MOB_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.MOB_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.KILL_MOB_COMMAND, true, true); } @Override 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 e03594157..f8595e2b9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/KillCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/KillCommand.java @@ -20,7 +20,7 @@ public class KillCommand extends CommandBase { public KillCommand(Creature plugin) { - super(plugin, Creature.KILL_MOB_COMMAND_PERMISSION, "kill", "k"); + super(plugin, Creature.Perm.KILL_MOB_COMMAND, "kill", "k"); } @Override 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 7b81112c6..8168c1ab8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/creature/command/MobCommand.java @@ -32,7 +32,7 @@ public class MobCommand extends MultiCommandBase { public MobCommand(Creature plugin) { - super(plugin, Creature.MOB_COMMAND_PERMISSION, "mob"); + super(plugin, Creature.Perm.MOB_COMMAND, "mob"); AddCommand(new KillCommand(Plugin)); } 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 8030c0a44..5d595e247 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java @@ -14,7 +14,7 @@ public class DisguiseCommand extends CommandBase implemen { DisguiseCommand(PlayerDisguiseManager plugin) { - super(plugin, PlayerDisguiseManager.USE_DISGUISE_PERMISSION, "disguise"); + super(plugin, PlayerDisguiseManager.Perm.USE_DISGUISE, "disguise"); } @Override 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 7740939b5..bb67d35da 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java @@ -36,9 +36,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.Permission; 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; @@ -68,10 +67,13 @@ import mineplex.serverdata.servers.ServerManager; @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"; - + public enum Perm implements Permission + { + USE_DISGUISE, + BLOCKED_DISGUISE, + SHORT_DISGUISE, + } + private static final Set MOJANG; private static final Set ILLEGAL_USERNAMES; private static final Set ILLEGAL_CAPES; @@ -154,14 +156,13 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler private void generatePermissions() { - PermissionManager pm = _clients.getPermissionManager(); - - pm.setPermission(PermissionGroup.TM, GroupPermission.of(USE_DISGUISE_PERMISSION), false, true); - pm.setPermission(PermissionGroup.MC, GroupPermission.of(USE_DISGUISE_PERMISSION), false, true); - pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(USE_DISGUISE_PERMISSION), true, true); - pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(BLOCKED_DISGUISE_PERMISSION), true, true); - pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(BLOCKED_DISGUISE_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SHORT_DISGUISE_PERMISSION), true, true); + + PermissionGroup.TM.setPermission(Perm.USE_DISGUISE, false, true); + PermissionGroup.MC.setPermission(Perm.USE_DISGUISE, false, true); + PermissionGroup.CONTENT.setPermission(Perm.USE_DISGUISE, true, true); + PermissionGroup.CONTENT.setPermission(Perm.BLOCKED_DISGUISE, true, true); + PermissionGroup.BUILDER.setPermission(Perm.BLOCKED_DISGUISE, true, true); + PermissionGroup.ADMIN.setPermission(Perm.SHORT_DISGUISE, true, true); } @Override @@ -238,7 +239,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler { CoreClient client = _clients.Get(event.getPlayer()); - if (!getClientManager().getPermissionManager().hasPermission(client, GroupPermission.of(USE_DISGUISE_PERMISSION))) + if (!client.hasPermission(Perm.USE_DISGUISE)) { return; } @@ -556,7 +557,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler { if (other != null) { - if (getClientManager().getPermissionManager().hasPermission(other, GroupPermission.of(BLOCKED_DISGUISE_PERMISSION))) + if (other.hasPermission(Perm.BLOCKED_DISGUISE)) { UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as that person!")); @@ -760,7 +761,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler } if (username.length() < 3) { - if (!_clients.getPermissionManager().hasPermission(caller, GroupPermission.of(SHORT_DISGUISE_PERMISSION))) + if (!_clients.Get(caller).hasPermission(Perm.SHORT_DISGUISE)) { UtilPlayer.message(caller, F.main("Disguise", "The chosen username of " + F.elem(username) + " must be longer than " + F.count("2") + " letters")); return false; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 4529ed773..86c31256f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -21,9 +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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.donation.command.CrownCommand; import mineplex.core.donation.command.GemCommand; @@ -42,10 +41,13 @@ 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"; - + public enum Perm implements Permission + { + CROWN_COMMAND, + GEM_COMMAND, + SHARD_COMMAND, + } + /** * The maximum number of attempts that will be made to perform a transaction created by {@link DonationManager#rewardCurrencyUntilSuccess} */ @@ -107,11 +109,10 @@ public class DonationManager extends MiniClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(CROWN_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GEM_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SHARD_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.CROWN_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.GEM_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.SHARD_COMMAND, 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 951033377..f43310ed2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/CrownCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/CrownCommand.java @@ -12,7 +12,7 @@ public class CrownCommand extends CommandBase { public CrownCommand(DonationManager plugin) { - super(plugin, DonationManager.CROWN_COMMAND_PERMISSION, "crown"); + super(plugin, DonationManager.Perm.CROWN_COMMAND, "crown"); } @Override 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 f50fc31fc..057e6b829 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/GemCommand.java @@ -15,7 +15,7 @@ public class GemCommand extends CommandBase { public GemCommand(DonationManager plugin) { - super(plugin, DonationManager.GEM_COMMAND_PERMISSION, "gem"); + super(plugin, DonationManager.Perm.GEM_COMMAND, "gem"); } @Override 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 da0c116f2..0906cdc9e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/ShardCommand.java @@ -15,7 +15,7 @@ public class ShardCommand extends CommandBase { public ShardCommand(DonationManager plugin) { - super(plugin, DonationManager.SHARD_COMMAND_PERMISSION, "coin", "shard", "shards"); + super(plugin, DonationManager.Perm.SHARD_COMMAND, "coin", "shard", "shards"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java index 3dd42b6bd..34c7cdfc5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloManager.java @@ -11,9 +11,8 @@ 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.Permission; 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.NautHashMap; @@ -21,8 +20,11 @@ import mineplex.core.itemstack.ItemBuilder; public class EloManager extends MiniDbClientPlugin { - public static final String TOP_ELO_COMMAND_PERMISSION = "mineplex.core.elo.topcommand"; - + public enum Perm implements Permission + { + TOP_ELO_COMMAND, + } + private EloRepository _repository; private EloRatingSystem _ratingSystem; private NautHashMap _eloTeams = new NautHashMap<>(); @@ -46,11 +48,10 @@ public class EloManager extends MiniDbClientPlugin } private void generatePermissions() - { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TOP_ELO_COMMAND_PERMISSION), true, true); - } + { + + PermissionGroup.ADMIN.setPermission(Perm.TOP_ELO_COMMAND, true, true); + } public EloRepository getRepo() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/elo/TopEloCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/elo/TopEloCommand.java index 5e4539ff3..e79f9b3cc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/elo/TopEloCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/elo/TopEloCommand.java @@ -18,7 +18,7 @@ public class TopEloCommand extends CommandBase { public TopEloCommand(EloManager plugin) { - super(plugin, EloManager.TOP_ELO_COMMAND_PERMISSION, "gettopelo", "topelo", "getelo"); + super(plugin, EloManager.Perm.TOP_ELO_COMMAND, "gettopelo", "topelo", "getelo"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java index 7ab10f38e..754d96365 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/facebook/FacebookManager.java @@ -11,9 +11,8 @@ 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.Permission; 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; @@ -23,8 +22,11 @@ import mineplex.core.treasure.TreasureType; public class FacebookManager extends MiniDbClientPlugin { - public static final String FACEBOOK_COMMAND_PERMISSION = "mineplex.core.facebook.command"; - + public enum Perm implements Permission + { + FACEBOOK_COMMAND, + } + private CoreClientManager _clientManager; private DonationManager _donationManager; private InventoryManager _inventoryManager; @@ -46,9 +48,8 @@ public class FacebookManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(FACEBOOK_COMMAND_PERMISSION), true, true); + + PermissionGroup.PLAYER.setPermission(Perm.FACEBOOK_COMMAND, true, true); } @Override 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 27eeb83de..85dbd7285 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/facebook/command/FacebookCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/facebook/command/FacebookCommand.java @@ -12,7 +12,7 @@ public class FacebookCommand extends CommandBase { public FacebookCommand(FacebookManager plugin) { - super(plugin, FacebookManager.FACEBOOK_COMMAND_PERMISSION, "facebook", "redeem"); + super(plugin, FacebookManager.Perm.FACEBOOK_COMMAND, "facebook", "redeem"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java index 457af40fa..d2ec01e7e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/FriendManager.java @@ -16,9 +16,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; @@ -41,9 +40,12 @@ import mineplex.serverdata.data.PlayerStatus; public class FriendManager extends MiniDbClientPlugin { - public static final String FRIEND_COMMAND_PERMISSION = "mineplex.core.friend.command"; - public static final String JOIN_STAFF_PERMISSION = "mineplex.core.friend.joinstaff"; - + public enum Perm implements Permission + { + FRIEND_COMMAND, + JOIN_STAFF, + } + private static FriendSorter _friendSorter = new FriendSorter(); private PreferencesManager _preferenceManager; @@ -63,10 +65,9 @@ public class FriendManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(FRIEND_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(JOIN_STAFF_PERMISSION), true, true); + + PermissionGroup.PLAYER.setPermission(Perm.FRIEND_COMMAND, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.JOIN_STAFF, true, true); } public PreferencesManager getPreferenceManager() @@ -269,7 +270,7 @@ public class FriendManager extends MiniDbClientPlugin public void showFriends(Player caller) { - boolean isStaff = ClientManager.getPermissionManager().hasPermission(caller, GroupPermission.of(JOIN_STAFF_PERMISSION)); + boolean isStaff = ClientManager.Get(caller).hasPermission(Perm.JOIN_STAFF); boolean gotAFriend = false; List friendStatuses = Get(caller).getFriends(); Collections.sort(friendStatuses, _friendSorter); 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 a2ca807fd..ba1c32102 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java @@ -14,7 +14,7 @@ public class AddFriend extends CommandBase { public AddFriend(FriendManager plugin) { - super(plugin, FriendManager.FRIEND_COMMAND_PERMISSION, "friends", "friend", "f"); + super(plugin, FriendManager.Perm.FRIEND_COMMAND, "friends", "friend", "f"); } @Override 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 9e382f560..477791c43 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/DeleteFriend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/DeleteFriend.java @@ -11,7 +11,7 @@ public class DeleteFriend extends CommandBase { public DeleteFriend(FriendManager plugin) { - super(plugin, FriendManager.FRIEND_COMMAND_PERMISSION, "unfriend"); + super(plugin, FriendManager.Perm.FRIEND_COMMAND, "unfriend"); } @Override 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 e069fece4..a007e16df 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/FriendsDisplay.java @@ -13,7 +13,7 @@ public class FriendsDisplay extends CommandBase { public FriendsDisplay(FriendManager plugin) { - super(plugin, FriendManager.FRIEND_COMMAND_PERMISSION, "friendsdisplay"); + super(plugin, FriendManager.Perm.FRIEND_COMMAND, "friendsdisplay"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 49cb1f978..f6dc9a8bf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -27,9 +27,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.Permission; 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.common.util.F; @@ -281,22 +280,25 @@ 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"; - + public enum Perm implements Permission + { + TITAN_ARROW_TRAIL, + TITAN_DEATH_EFFECT, + TITAN_DOUBLE_JUMP, + ETERNAL_TAUNT, + LEGEND_PARTICLE_EFFECT, + TITAN_PARTICLE_EFFECT, + HERO_MORPH_BLAZE, + HERO_MORPH_CREEPER, + ULTRA_MORPH, + TITAN_MORPH, + LEGEND_MORPH, + AMMO_COMMAND, + LOCK_INFUSED_COMMAND, + LOCK_COSMETICS_COMMAND, + UNLOCK_COSMETICS_COMMAND, + } + private final CoreClientManager _clientManager; private final DonationManager _donationManager; private final InventoryManager _inventoryManager; @@ -363,30 +365,28 @@ public class GadgetManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(TITAN_ARROW_TRAIL_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(TITAN_DEATH_EFFECT_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(TITAN_DOUBLE_JUMP_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ETERNAL, GroupPermission.of(ETERNAL_TAUNT_PERMISSION), true, true); - pm.setPermission(PermissionGroup.LEGEND, GroupPermission.of(LEGEND_PARTICLE_EFFECT_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(TITAN_PARTICLE_EFFECT_PERMISSION), true, true); - pm.setPermission(PermissionGroup.HERO, GroupPermission.of(HERO_MORPH_BLAZE_PERMISSION), true, true); - pm.setPermission(PermissionGroup.HERO, GroupPermission.of(HERO_MORPH_CREEPER_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(ULTRA_MORPH_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(TITAN_MORPH_PERMISSION), true, true); - pm.setPermission(PermissionGroup.LEGEND, GroupPermission.of(LEGEND_MORPH_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(AMMO_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(LOCK_INFUSED_COMMAND_PERMISSION), true, true); + + PermissionGroup.TITAN.setPermission(Perm.TITAN_ARROW_TRAIL, true, true); + PermissionGroup.TITAN.setPermission(Perm.TITAN_DEATH_EFFECT, true, true); + PermissionGroup.TITAN.setPermission(Perm.TITAN_DOUBLE_JUMP, true, true); + PermissionGroup.ETERNAL.setPermission(Perm.ETERNAL_TAUNT, true, true); + PermissionGroup.LEGEND.setPermission(Perm.LEGEND_PARTICLE_EFFECT, true, true); + PermissionGroup.TITAN.setPermission(Perm.TITAN_PARTICLE_EFFECT, true, true); + PermissionGroup.HERO.setPermission(Perm.HERO_MORPH_BLAZE, true, true); + PermissionGroup.HERO.setPermission(Perm.HERO_MORPH_CREEPER, true, true); + PermissionGroup.ULTRA.setPermission(Perm.ULTRA_MORPH, true, true); + PermissionGroup.TITAN.setPermission(Perm.TITAN_MORPH, true, true); + PermissionGroup.LEGEND.setPermission(Perm.LEGEND_MORPH, true, true); + PermissionGroup.ADMIN.setPermission(Perm.AMMO_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.LOCK_INFUSED_COMMAND, true, true); if (UtilServer.isTestServer()) { - pm.setPermission(PermissionGroup.QA, GroupPermission.of(LOCK_COSMETICS_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.QA, GroupPermission.of(UNLOCK_COSMETICS_COMMAND_PERMISSION), true, true); - } - else + PermissionGroup.QA.setPermission(Perm.LOCK_COSMETICS_COMMAND, true, true); + PermissionGroup.QA.setPermission(Perm.UNLOCK_COSMETICS_COMMAND, true, true); + } else { - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(LOCK_COSMETICS_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(UNLOCK_COSMETICS_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.LOCK_COSMETICS_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.UNLOCK_COSMETICS_COMMAND, true, true); } } 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 088447c37..290776ee9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/AmmoCommand.java @@ -15,7 +15,7 @@ public class AmmoCommand extends CommandBase public AmmoCommand(GadgetManager plugin) { - super(plugin, GadgetManager.AMMO_COMMAND_PERMISSION, "ammo"); + super(plugin, GadgetManager.Perm.AMMO_COMMAND, "ammo"); _plugin = plugin; } 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 2d0ed2bd9..4b7981445 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java @@ -6,7 +6,6 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; 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.donation.Donor; import mineplex.core.gadget.GadgetManager; @@ -21,7 +20,7 @@ public class LockCosmeticsCommand extends CommandBase public LockCosmeticsCommand(GadgetManager plugin) { - super(plugin, GadgetManager.LOCK_COSMETICS_COMMAND_PERMISSION, "lockCosmetics"); + super(plugin, GadgetManager.Perm.LOCK_COSMETICS_COMMAND, "lockCosmetics"); _plugin = plugin; } 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 ae10cfd5d..ed8da5930 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockInfusedCommand.java @@ -30,7 +30,7 @@ public class LockInfusedCommand extends CommandBase public LockInfusedCommand(GadgetManager manager) { - super(manager, GadgetManager.LOCK_INFUSED_COMMAND_PERMISSION, "lockinfused"); + super(manager, GadgetManager.Perm.LOCK_INFUSED_COMMAND, "lockinfused"); _manager = manager; } 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 a3d0f74c5..61f177c8f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java @@ -21,7 +21,7 @@ public class UnlockCosmeticsCommand extends CommandBase public UnlockCosmeticsCommand(GadgetManager plugin) { - super(plugin, GadgetManager.UNLOCK_COSMETICS_COMMAND_PERMISSION, "unlockCosmetics"); + super(plugin, GadgetManager.Perm.UNLOCK_COSMETICS_COMMAND, "unlockCosmetics"); _plugin = plugin; } 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 6d5722908..f87c51d43 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,7 +5,6 @@ import org.bukkit.entity.Arrow; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilParticle; @@ -43,7 +42,7 @@ public class ArrowTrailTitan extends ArrowEffectGadget @EventHandler public void titanOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.TITAN_ARROW_TRAIL_PERMISSION))) + if (Manager.getClientManager().Get(event.getPlayer()).hasPermission(GadgetManager.Perm.TITAN_ARROW_TRAIL)) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } 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 6579c3d4d..1adb0d99a 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,7 +5,6 @@ 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.util.C; import mineplex.core.common.util.LineFormat; @@ -32,7 +31,7 @@ public class DeathTitan extends DeathEffectGadget @EventHandler public void titanOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.TITAN_DEATH_EFFECT_PERMISSION))) + if (Manager.getClientManager().Get(event.getPlayer()).hasPermission(GadgetManager.Perm.TITAN_DEATH_EFFECT)) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } 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 9a95f32c9..6152bbb64 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,7 +5,6 @@ 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.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilParticle; @@ -37,7 +36,7 @@ public class DoubleJumpTitan extends DoubleJumpEffectGadget @EventHandler public void titanOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.TITAN_DOUBLE_JUMP_PERMISSION))) + if (Manager.getClientManager().Get(event.getPlayer()).hasPermission(GadgetManager.Perm.TITAN_DOUBLE_JUMP)) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } 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 a986fe1a4..aaf9718d4 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,6 @@ 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.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; @@ -81,7 +80,7 @@ public class MorphBlaze extends MorphGadget @EventHandler public void HeroOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.HERO_MORPH_BLAZE_PERMISSION))) + if (Manager.getClientManager().Get(event.getPlayer()).hasPermission(GadgetManager.Perm.HERO_MORPH_BLAZE)) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } 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 6396bf28d..1dffb0098 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,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -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 +167,7 @@ public class MorphCreeper extends MorphGadget @EventHandler public void HeroOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.HERO_MORPH_CREEPER_PERMISSION))) + if (Manager.getClientManager().Get(event.getPlayer()).hasPermission(GadgetManager.Perm.HERO_MORPH_CREEPER)) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } 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 3ed4f1b18..913c26fb2 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,6 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; @@ -84,7 +83,7 @@ public class MorphPig extends MorphGadget @EventHandler public void UltraOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.ULTRA_MORPH_PERMISSION))) + if (Manager.getClientManager().Get(event.getPlayer()).hasPermission(GadgetManager.Perm.ULTRA_MORPH)) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } 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 935f0db95..632d798cd 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,6 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; -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 +224,7 @@ public class MorphTitan extends MorphGadget @EventHandler public void titanOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.TITAN_MORPH_PERMISSION))) + if (Manager.getClientManager().Get(event.getPlayer()).hasPermission(GadgetManager.Perm.TITAN_MORPH)) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } 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 8fedc0989..12045f40d 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,6 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; @@ -190,7 +189,7 @@ public class MorphWither extends MorphGadget public void legendOwner(PlayerJoinEvent event) { // TODO HARDCODED Wither Morph Database Item Id - 550 - if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.LEGEND_MORPH_PERMISSION))) + if (Manager.getClientManager().Get(event.getPlayer()).hasPermission(GadgetManager.Perm.LEGEND_MORPH)) { Manager.getInventoryManager().Get(event.getPlayer()).addItem(new ClientItem(new Item(550, getName()), 1)); } 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 9129b3870..8f0fe6b1c 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.Color; +import java.awt.*; import org.bukkit.Location; import org.bukkit.Material; @@ -8,7 +8,6 @@ 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.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilMath; @@ -210,7 +209,7 @@ public class ParticleLegend extends ParticleGadget public void legendOwner(PlayerJoinEvent event) { // TODO HARDCODED Legendary Aura Database Item Id - 552 - if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.LEGEND_PARTICLE_EFFECT_PERMISSION))) + if (Manager.getClientManager().Get(event.getPlayer()).hasPermission(GadgetManager.Perm.LEGEND_PARTICLE_EFFECT)) { Manager.getInventoryManager().Get(event.getPlayer()).addItem(new ClientItem(new Item(552, getName()), 1)); } 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 aafbafef2..7edb0b416 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,7 +7,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilParticle; @@ -94,7 +93,7 @@ public class ParticleTitan extends ParticleGadget @EventHandler public void titanOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.TITAN_PARTICLE_EFFECT_PERMISSION))) + if (Manager.getClientManager().Get(event.getPlayer()).hasPermission(GadgetManager.Perm.TITAN_PARTICLE_EFFECT)) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } 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 bdd3fcc7e..84cd12c94 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 @@ -18,7 +18,6 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.util.Vector; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; @@ -145,7 +144,7 @@ public class EternalTaunt extends TauntGadget @EventHandler public void titanOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(GadgetManager.ETERNAL_TAUNT_PERMISSION))) + if (Manager.getClientManager().Get(event.getPlayer()).hasPermission(GadgetManager.Perm.ETERNAL_TAUNT)) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } 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 535ae846d..e9e7a2b89 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 @@ -2,7 +2,6 @@ package mineplex.core.gadget.gadgets.wineffect.rankrooms; import org.bukkit.Material; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.WinEffectGadget; @@ -29,8 +28,6 @@ public abstract class WinEffectRankBased extends WinEffectGadget _rank = rank; _winEffectType = winEffectType; _schematicName = winEffectType.getSchematic().replace("%r%", rank.name().substring(0, 1).toUpperCase() + rank.name().substring(1)); - - manager.getClientManager().getPermissionManager().setPermission(rank, getUnlockPermission(), true, true); } public PermissionGroup getRank() @@ -38,9 +35,9 @@ public abstract class WinEffectRankBased extends WinEffectGadget return _rank; } - public GroupPermission getUnlockPermission() + public PermissionGroup getUnlockRank() { - return GroupPermission.of(PERMISSION_BASE + _rank.name()); + return _rank; } public WinEffectType getWinEffectType() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java b/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java index 01412b1c8..da24c5436 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/give/Give.java @@ -9,12 +9,9 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.structs.ItemContainer; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilInv; @@ -26,8 +23,11 @@ import mineplex.core.itemstack.ItemStackFactory; public class Give extends MiniPlugin { - public static final String GIVE_COMMAND_PERMISSION = "mineplex.core.give.command"; - + public enum Perm implements Permission + { + GIVE_COMMAND, + } + public static Give Instance; protected Give(JavaPlugin plugin) @@ -39,12 +39,11 @@ public class Give extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.GIVE_COMMAND, true, true); if (UtilServer.isTestServer()) { - pm.setPermission(PermissionGroup.QA, GroupPermission.of(GIVE_COMMAND_PERMISSION), true, true); + PermissionGroup.QA.setPermission(Perm.GIVE_COMMAND, true, true); } } 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 673fdbfc2..13f86e8ae 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/give/commands/GiveCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/give/commands/GiveCommand.java @@ -9,7 +9,7 @@ public class GiveCommand extends CommandBase { public GiveCommand(Give plugin) { - super(plugin, Give.GIVE_COMMAND_PERMISSION, "give", "g", "item", "i"); + super(plugin, Give.Perm.GIVE_COMMAND, "give", "g", "item", "i"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java index ebdec39f3..2ebc0d0a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/GlobalPacketManager.java @@ -10,9 +10,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.Permission; 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; @@ -31,8 +30,11 @@ import mineplex.serverdata.commands.ServerCommandManager; public class GlobalPacketManager extends MiniPlugin { - public static final String GLOBAL_PACKET_COMMAND_PERMISSION = "mineplex.core.globalpacket.command"; - + public enum Perm implements Permission + { + GLOBAL_PACKET_COMMAND, + } + private CoreClientManager _clientManager; private ServerStatusManager _statusManager; private InventoryManager _inventoryManager; @@ -60,9 +62,8 @@ public class GlobalPacketManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GLOBAL_PACKET_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.GLOBAL_PACKET_COMMAND, true, true); } public void callGlobalCommand(Player caller, String[] args) 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 533596104..84daffd32 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/command/GlobalPacketCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/command/GlobalPacketCommand.java @@ -11,7 +11,7 @@ public class GlobalPacketCommand extends CommandBase { public GlobalPacketCommand(GlobalPacketManager plugin) { - super(plugin, GlobalPacketManager.GLOBAL_PACKET_COMMAND_PERMISSION, "global", "globalpacket"); + super(plugin, GlobalPacketManager.Perm.GLOBAL_PACKET_COMMAND, "global", "globalpacket"); } @Override 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 f45949955..8aa2c302c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveCoins.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveCoins.java @@ -5,9 +5,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; 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.F; @@ -33,10 +31,9 @@ public class GlobalGiveCoins implements Listener public void giveCoins(final GlobalPacketEvent e) { boolean allowed = false; - PermissionManager pm = _clientManager.getPermissionManager(); for (String id : e.getCallerGroups()) { - if (pm.hasPermission(PermissionGroup.valueOf(id), GroupPermission.of(GlobalPacketManager.GLOBAL_PACKET_COMMAND_PERMISSION))) + if (PermissionGroup.valueOf(id).hasPermission(GlobalPacketManager.Perm.GLOBAL_PACKET_COMMAND)) { allowed = true; break; 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 5ef585a2f..fd38327e3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveGems.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveGems.java @@ -4,11 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -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.F; @@ -32,10 +28,9 @@ public class GlobalGiveGems implements Listener public void giveGems(final GlobalPacketEvent e) { boolean allowed = false; - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); for (String id : e.getCallerGroups()) { - if (pm.hasPermission(PermissionGroup.valueOf(id), GroupPermission.of(GlobalPacketManager.GLOBAL_PACKET_COMMAND_PERMISSION))) + if (PermissionGroup.valueOf(id).hasPermission(GlobalPacketManager.Perm.GLOBAL_PACKET_COMMAND)) { allowed = true; break; 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 c7875f217..66fb5523c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveItem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/globalpacket/listeners/GlobalGiveItem.java @@ -4,11 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -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.F; import mineplex.core.common.util.UtilPlayer; @@ -57,10 +53,9 @@ public class GlobalGiveItem implements Listener public void giveItem(final GlobalPacketEvent e) { boolean allowed = false; - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); for (String id : e.getCallerGroups()) { - if (pm.hasPermission(PermissionGroup.valueOf(id), GroupPermission.of(GlobalPacketManager.GLOBAL_PACKET_COMMAND_PERMISSION))) + if (PermissionGroup.valueOf(id).hasPermission(GlobalPacketManager.Perm.GLOBAL_PACKET_COMMAND)) { allowed = true; break; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java index 133dedb27..e1fe61fb4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/IgnoreManager.java @@ -17,9 +17,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; @@ -33,9 +32,12 @@ import mineplex.core.preferences.PreferencesManager; public class IgnoreManager extends MiniDbClientPlugin { - public static final String IGNORE_COMMAND_PERMISSION = "mineplex.core.ignore.command"; - public static final String BYPASS_IGNORE_PERMISSION = "mineplex.core.ignore.bypass"; - + public enum Perm implements Permission + { + IGNORE_COMMAND, + BYPASS_IGNORE, + } + private PreferencesManager _preferenceManager; private IgnoreRepository _repository; private Portal _portal; @@ -53,10 +55,9 @@ public class IgnoreManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(IGNORE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(BYPASS_IGNORE_PERMISSION), true, true); + + PermissionGroup.PLAYER.setPermission(Perm.IGNORE_COMMAND, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.BYPASS_IGNORE, true, true); } public PreferencesManager getPreferenceManager() @@ -105,7 +106,7 @@ public class IgnoreManager extends MiniDbClientPlugin @EventHandler(priority = EventPriority.LOWEST) public void onChat(AsyncPlayerChatEvent event) { - if (ClientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(BYPASS_IGNORE_PERMISSION))) + if (ClientManager.Get(event.getPlayer()).hasPermission(Perm.BYPASS_IGNORE)) { return; } 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 2216cecb6..0bff21ee7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Ignore.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Ignore.java @@ -10,7 +10,7 @@ public class Ignore extends CommandBase { public Ignore(IgnoreManager plugin) { - super(plugin, IgnoreManager.IGNORE_COMMAND_PERMISSION, "ignore"); + super(plugin, IgnoreManager.Perm.IGNORE_COMMAND, "ignore"); } @Override 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 84463ab11..083ff017c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Unignore.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/ignore/command/Unignore.java @@ -11,7 +11,7 @@ public class Unignore extends CommandBase { public Unignore(IgnoreManager plugin) { - super(plugin, IgnoreManager.IGNORE_COMMAND_PERMISSION, "unignore"); + super(plugin, IgnoreManager.Perm.IGNORE_COMMAND, "unignore"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java index 136fd3a7b..0654c5361 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/IncognitoManager.java @@ -14,9 +14,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -32,8 +31,11 @@ import mineplex.core.updater.event.UpdateEvent; public class IncognitoManager extends MiniDbClientPlugin { - public static final String USE_INCOGNITO_PERMISSION = "mineplex.core.incognito.use"; - + public enum Perm implements Permission + { + USE_INCOGNITO, + } + private CoreClientManager _clientManager; private IncognitoRepository _repository; private PreferencesManager _preferencesManager; @@ -50,9 +52,8 @@ public class IncognitoManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(USE_INCOGNITO_PERMISSION), true, true); + + PermissionGroup.TRAINEE.setPermission(Perm.USE_INCOGNITO, true, true); } private boolean canSeeThroughIncognito(Player viewer, Player target) @@ -60,7 +61,7 @@ public class IncognitoManager extends MiniDbClientPlugin PermissionGroup viewerGroup = _clientManager.Get(viewer).getPrimaryGroup(); PermissionGroup targetGroup = _clientManager.Get(target).getPrimaryGroup(); - return viewerGroup == targetGroup || _clientManager.getPermissionManager().inheritsFully(viewerGroup, targetGroup); + return viewerGroup.inheritsFrom(targetGroup); } @@ -103,7 +104,7 @@ public class IncognitoManager extends MiniDbClientPlugin { Player player = event.getPlayer(); - if (Get(event.getPlayer()).Status && !_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(USE_INCOGNITO_PERMISSION))) + if (Get(event.getPlayer()).Status && !_clientManager.Get(event.getPlayer()).hasPermission(Perm.USE_INCOGNITO)) { Get(event.getPlayer()).Status = false; runAsync(() -> _repository.setStatus(_clientManager.getAccountId(player), false)); 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 e4d41d2b2..06cf8ccb7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/incognito/commands/IncognitoToggleCommand.java @@ -12,7 +12,7 @@ public class IncognitoToggleCommand extends CommandBase { public IncognitoToggleCommand(IncognitoManager plugin) { - super(plugin, IncognitoManager.USE_INCOGNITO_PERMISSION, "incognito", "vanish"); + super(plugin, IncognitoManager.Perm.USE_INCOGNITO, "incognito", "vanish"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index b53e87292..6df32e218 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -24,9 +24,8 @@ import org.bukkit.plugin.java.JavaPlugin; 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; import mineplex.core.inventory.command.GiveItemCommand; @@ -37,8 +36,11 @@ import mineplex.core.updater.event.UpdateEvent; public class InventoryManager extends MiniDbClientPlugin { - public static final String GIVE_ITEM_COMMAND_PERMISSION = "mineplex.core.inventory.giveitem"; - + public enum Perm implements Permission + { + GIVE_ITEM_COMMAND, + } + private static Object _inventoryLock = new Object(); private InventoryRepository _repository; @@ -64,9 +66,7 @@ public class InventoryManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_ITEM_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.GIVE_ITEM_COMMAND, 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 4e9365946..3cc4042d7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java @@ -15,7 +15,7 @@ public class GiveItemCommand extends CommandBase { public GiveItemCommand(InventoryManager plugin) { - super(plugin, InventoryManager.GIVE_ITEM_COMMAND_PERMISSION, "giveitem"); + super(plugin, InventoryManager.Perm.GIVE_ITEM_COMMAND, "giveitem"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java index 6a12074af..8ce00fde8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java @@ -12,10 +12,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandBase; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; @@ -24,8 +22,11 @@ import mineplex.core.stats.StatsManager; public class LeaderboardManager extends MiniPlugin { - public static final String CYCLE_LEADERBOARD_COMMAND_PERMISSION = "mineplex.core.leaderboard.cycle"; - + public enum Perm implements Permission + { + CYCLE_LEADERBOARD_COMMAND, + } + private final Map _leaderboards = new HashMap<>(); private final long REFRESH_RATE; private final LeaderboardRepository _repo; @@ -37,7 +38,7 @@ public class LeaderboardManager extends MiniPlugin _repo = new LeaderboardRepository(plugin); - addCommand(new CommandBase(this, CYCLE_LEADERBOARD_COMMAND_PERMISSION, "cycleleaderboard") + addCommand(new CommandBase(this, Perm.CYCLE_LEADERBOARD_COMMAND, "cycleleaderboard") { @Override public void Execute(Player caller, String[] args) @@ -78,9 +79,7 @@ public class LeaderboardManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.DEV, GroupPermission.of(CYCLE_LEADERBOARD_COMMAND_PERMISSION), true, true); + PermissionGroup.DEV.setPermission(Perm.CYCLE_LEADERBOARD_COMMAND, 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 7e552d810..e5b4e60a6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -14,9 +14,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.chat.Chat; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -50,15 +49,18 @@ import mineplex.serverdata.commands.ServerCommandManager; 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"; + public enum Perm implements Permission + { + SEE_ADMIN, + BYPASS_INCOGNITO, + BYPASS_SPAM, + ADMIN_COMMAND, + ANNOUNCE_COMMAND, + MESSAGE_ADMIN_COMMAND, + MESSAGE_COMMAND, + RESEND_ADMIN_COMMAND, + RESEND_COMMAND, + } private CoreClientManager _clientManager; private FriendManager _friendsManager; @@ -93,7 +95,7 @@ public class MessageManager extends MiniClientPlugin for (Player player : Bukkit.getOnlinePlayers()) { - if (_clientManager.Get(player).getPrimaryGroup() == group || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), group)) + if (_clientManager.Get(player).getPrimaryGroup().inheritsFrom(group)) { if (command.getDisplayTitle()) { @@ -113,17 +115,16 @@ public class MessageManager extends MiniClientPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(BYPASS_INCOGNITO_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(BYPASS_SPAM_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(SEE_ADMIN_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(ADMIN_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(ANNOUNCE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(MESSAGE_ADMIN_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(MESSAGE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(RESEND_ADMIN_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(RESEND_COMMAND_PERMISSION), true, true); + + PermissionGroup.TRAINEE.setPermission(Perm.BYPASS_INCOGNITO, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.BYPASS_SPAM, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.SEE_ADMIN, true, true); + PermissionGroup.PLAYER.setPermission(Perm.ADMIN_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.ANNOUNCE_COMMAND, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.MESSAGE_ADMIN_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.MESSAGE_COMMAND, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.RESEND_ADMIN_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.RESEND_COMMAND, true, true); } public void addCommands() @@ -243,7 +244,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().getPermissionManager().hasPermission(from, GroupPermission.of(BYPASS_SPAM_PERMISSION)) && Get(from).LastTo != null + if (!GetClientManager().Get(from).hasPermission(Perm.BYPASS_SPAM) && Get(from).LastTo != null && !Get(from).LastTo.equalsIgnoreCase(to.getName())) { long delta = System.currentTimeMillis() - Get(from).LastToTime; @@ -296,7 +297,7 @@ public class MessageManager extends MiniClientPlugin { if (!to.equals(staff) && !from.equals(staff)) { - if (_clientManager.getPermissionManager().hasPermission(staff, GroupPermission.of(SEE_ADMIN_PERMISSION))) + if (_clientManager.Get(staff).hasPermission(Perm.SEE_ADMIN)) { 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); @@ -419,11 +420,11 @@ public class MessageManager extends MiniClientPlugin { if (!to.equals(staff)) { - if (_clientManager.getPermissionManager().hasPermission(staff, GroupPermission.of(SEE_ADMIN_PERMISSION))) + if (_clientManager.Get(staff).hasPermission(Perm.SEE_ADMIN)) { UtilPlayer.message(staff, - globalMessage.getRank() + " " + globalMessage.getSender() + C.cPurple + " " + message.getMessage()); + globalMessage.getRank() + " " + globalMessage.getSender() + C.cPurple + " " + message.getMessage()); } } } @@ -497,11 +498,11 @@ public class MessageManager extends MiniClientPlugin { if (!target.equals(staff)) { - if (_clientManager.getPermissionManager().hasPermission(staff, GroupPermission.of(SEE_ADMIN_PERMISSION))) + if (_clientManager.Get(staff).hasPermission(Perm.SEE_ADMIN)) { UtilPlayer.message(staff, - recevierRank + " " + target.getName() + " " + C.cPurple + message.getMessage()); + recevierRank + " " + target.getName() + " " + C.cPurple + message.getMessage()); } } } @@ -568,7 +569,7 @@ public class MessageManager extends MiniClientPlugin // If this is a message inside the server if (to != null) { - if (_incognitoManager.Get(to).Status && !_clientManager.getPermissionManager().hasPermission(sender, GroupPermission.of(BYPASS_INCOGNITO_PERMISSION))) + if (_incognitoManager.Get(to).Status && !_clientManager.Get(sender).hasPermission(Perm.BYPASS_INCOGNITO)) { UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "].")); return; 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 0efd84f5e..a854fab6c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AdminCommand.java @@ -3,7 +3,6 @@ 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.util.C; import mineplex.core.common.util.F; @@ -16,7 +15,7 @@ public class AdminCommand extends CommandBase { public AdminCommand(MessageManager plugin) { - super(plugin, MessageManager.ADMIN_COMMAND_PERMISSION, "a","admin"); + super(plugin, MessageManager.Perm.ADMIN_COMMAND, "a","admin"); } @Override @@ -48,7 +47,7 @@ public class AdminCommand extends CommandBase //Send for (Player to : UtilServer.getPlayers()) { - if (Plugin.GetClientManager().getPermissionManager().hasPermission(to, GroupPermission.of(MessageManager.SEE_ADMIN_PERMISSION))) + if (Plugin.GetClientManager().Get(to).hasPermission(MessageManager.Perm.SEE_ADMIN)) { if (!to.equals(caller)) { @@ -60,7 +59,7 @@ public class AdminCommand extends CommandBase } } - if (!Plugin.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(MessageManager.SEE_ADMIN_PERMISSION)) && Recharge.Instance.use(caller, "AdminCommand.InformMsg", 60 * 1000, false, false)) + if (!Plugin.GetClientManager().Get(caller).hasPermission(MessageManager.Perm.SEE_ADMIN) && 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.")); } 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 d6ab828af..ebab8c3d8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java @@ -16,7 +16,7 @@ public class AnnounceCommand extends CommandBase { public AnnounceCommand(MessageManager plugin) { - super(plugin, MessageManager.ANNOUNCE_COMMAND_PERMISSION, "announce"); + super(plugin, MessageManager.Perm.ANNOUNCE_COMMAND, "announce"); } @Override 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 896fdc370..01ddc88a5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java @@ -16,7 +16,7 @@ public class MessageAdminCommand extends CommandBase { public MessageAdminCommand(MessageManager plugin) { - super(plugin, MessageManager.MESSAGE_ADMIN_COMMAND_PERMISSION, "ma"); + super(plugin, MessageManager.Perm.MESSAGE_ADMIN_COMMAND, "ma"); } @Override 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 bbcef7911..7da920d28 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java @@ -15,7 +15,7 @@ public class MessageCommand extends CommandBase { public MessageCommand(MessageManager plugin) { - super(plugin, MessageManager.MESSAGE_COMMAND_PERMISSION, "m", "msg", "message", "tell", "t", "w", "whisper", "MSG"); + super(plugin, MessageManager.Perm.MESSAGE_COMMAND, "m", "msg", "message", "tell", "t", "w", "whisper", "MSG"); } @Override 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 22a8c3a8e..b73898530 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendAdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendAdminCommand.java @@ -13,7 +13,7 @@ public class ResendAdminCommand extends CommandBase { public ResendAdminCommand(MessageManager plugin) { - super(plugin, MessageManager.RESEND_ADMIN_COMMAND_PERMISSION, "ra"); + super(plugin, MessageManager.Perm.RESEND_ADMIN_COMMAND, "ra"); } @Override 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 49062c0bb..566cfe845 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/ResendCommand.java @@ -11,7 +11,7 @@ public class ResendCommand extends CommandBase { public ResendCommand(MessageManager plugin) { - super(plugin, MessageManager.RESEND_COMMAND_PERMISSION, "r"); + super(plugin, MessageManager.Perm.RESEND_COMMAND, "r"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java index 3624af989..4790dc301 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java @@ -13,9 +13,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.Permission; 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.updater.UpdateType; @@ -23,9 +22,12 @@ import mineplex.core.updater.event.UpdateEvent; 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"; + public enum Perm implements Permission + { + VERSIONS_COMMAND, + LAG_COMMAND, + MONITOR_COMMAND, + } private CoreClientManager _clientManager; private long _lastRun = -1; @@ -48,14 +50,12 @@ public class LagMeter extends MiniPlugin } private void generatePermissions() - { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(VERSIONS_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.QA, GroupPermission.of(VERSIONS_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(LAG_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(MONITOR_COMMAND_PERMISSION), true, true); - } + { + PermissionGroup.ADMIN.setPermission(Perm.VERSIONS_COMMAND, true, true); + PermissionGroup.QA.setPermission(Perm.VERSIONS_COMMAND, true, true); + PermissionGroup.MOD.setPermission(Perm.LAG_COMMAND, true, true); + PermissionGroup.MOD.setPermission(Perm.MONITOR_COMMAND, true, true); + } @Override public void addCommands() @@ -66,13 +66,13 @@ public class LagMeter extends MiniPlugin @EventHandler public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) { - if (event.getMessage().trim().equalsIgnoreCase("/lag") && _clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(LAG_COMMAND_PERMISSION))) + if (event.getMessage().trim().equalsIgnoreCase("/lag") && _clientManager.Get(event.getPlayer()).hasPermission(Perm.LAG_COMMAND)) { sendUpdate(event.getPlayer()); event.setCancelled(true); return; } - if (event.getMessage().trim().equalsIgnoreCase("/monitor") && _clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(MONITOR_COMMAND_PERMISSION))) + if (event.getMessage().trim().equalsIgnoreCase("/monitor") && _clientManager.Get(event.getPlayer()).hasPermission(Perm.MONITOR_COMMAND)) { if (_monitoring.contains(event.getPlayer())) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java index 4bfbe976d..510365706 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/VersionsCommand.java @@ -29,7 +29,7 @@ public class VersionsCommand extends CommandBase public VersionsCommand(LagMeter plugin) { - super(plugin, LagMeter.VERSIONS_COMMAND_PERMISSION, "versions", "getver"); + super(plugin, LagMeter.Perm.VERSIONS_COMMAND, "versions", "getver"); } private void ensureVersions() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java index 7f92c9832..4425f1488 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java @@ -16,9 +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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -46,9 +45,12 @@ 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"; - + public enum Perm implements Permission + { + HERO_MOUNT, + TITAN_MOUNT, + } + private CoreClientManager _clientManager; private DonationManager _donationManager; private BlockRestore _blockRestore; @@ -72,10 +74,9 @@ public class MountManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.HERO, GroupPermission.of(HERO_MOUNT_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(TITAN_MOUNT_PERMISSION), true, true); + + PermissionGroup.HERO.setPermission(Perm.HERO_MOUNT, true, true); + PermissionGroup.TITAN.setPermission(Perm.TITAN_MOUNT, 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 f0806b8b1..96aa412d5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java @@ -8,7 +8,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.player.PlayerJoinEvent; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilParticle; @@ -106,7 +105,7 @@ public class MountDragon extends DragonMount @EventHandler public void HeroOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(MountManager.HERO_MOUNT_PERMISSION))) + if (Manager.getClientManager().Get(event.getPlayer()).hasPermission(MountManager.Perm.HERO_MOUNT)) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } 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 f0e463eb0..0005919b8 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,6 @@ import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; @@ -135,7 +134,7 @@ public class MountTitan extends Mount @EventHandler public void titanOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(MountManager.TITAN_MOUNT_PERMISSION))) + if (Manager.getClientManager().Get(event.getPlayer()).hasPermission(MountManager.Perm.TITAN_MOUNT)) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java index 30662f532..0229af318 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/notifier/NotificationManager.java @@ -71,7 +71,7 @@ public class NotificationManager extends MiniPlugin { PermissionGroup group = _clientManager.Get(player).getPrimaryGroup(); - if (group == PermissionGroup.LEGEND || _clientManager.getPermissionManager().inheritsFully(group, PermissionGroup.LEGEND)) + if (group.inheritsFrom(PermissionGroup.LEGEND)) { continue; } @@ -99,7 +99,7 @@ public class NotificationManager extends MiniPlugin { PermissionGroup group = _clientManager.Get(player).getPrimaryGroup(); - if (group == PermissionGroup.LEGEND || _clientManager.getPermissionManager().inheritsFully(group, PermissionGroup.LEGEND)) + if (group.inheritsFrom(PermissionGroup.LEGEND)) { continue; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index fd11476fe..591235d34 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -51,12 +51,9 @@ import org.bukkit.util.Vector; import org.jooq.Result; import org.jooq.impl.DSL; -import mineplex.core.Managers; import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; @@ -107,13 +104,16 @@ 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"; + + public enum Perm implements Permission + { + ADD_NPC_COMMAND, + CLEAR_NPCS_COMMAND, + DELETE_NPC_COMMAND, + NPC_HOME_COMMAND, + NPC_COMMAND, + REFRESH_NPCS_COMMAND, + } private final Creature _creature; private final List _npcs = new ArrayList<>(); @@ -121,8 +121,6 @@ public class NpcManager extends MiniPlugin final Map _npcMap = new HashMap<>(); private final Set _npcDeletingPlayers = new HashSet<>(); - private final DisguiseManager _disguise; - public NpcManager(JavaPlugin plugin, Creature creature) { super("NpcManager", plugin); @@ -139,7 +137,7 @@ public class NpcManager extends MiniPlugin _plugin.getServer().getPluginManager().registerEvents(this, _plugin); - _disguise = require(DisguiseManager.class); + require(DisguiseManager.class); try { @@ -155,14 +153,12 @@ public class NpcManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(ADD_NPC_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.DEV, GroupPermission.of(CLEAR_NPCS_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(DELETE_NPC_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(NPC_HOME_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(NPC_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(REFRESH_NPCS_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.ADD_NPC_COMMAND, true, true); + PermissionGroup.DEV.setPermission(Perm.CLEAR_NPCS_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.DELETE_NPC_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.NPC_HOME_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.NPC_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.REFRESH_NPCS_COMMAND, true, true); } @Override 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 d07282996..6db5d9794 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/AddCommand.java @@ -12,7 +12,7 @@ public class AddCommand extends CommandBase { public AddCommand(NpcManager plugin) { - super(plugin, NpcManager.ADD_NPC_COMMAND_PERMISSION, "add"); + super(plugin, NpcManager.Perm.ADD_NPC_COMMAND, "add"); } @Override 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 d622e08d8..919dde494 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/ClearCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/ClearCommand.java @@ -13,7 +13,7 @@ public class ClearCommand extends CommandBase { public ClearCommand(NpcManager plugin) { - super(plugin, NpcManager.CLEAR_NPCS_COMMAND_PERMISSION, "clear"); + super(plugin, NpcManager.Perm.CLEAR_NPCS_COMMAND, "clear"); } @Override 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 b51b142fa..f6faec662 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/DeleteCommand.java @@ -11,7 +11,7 @@ public class DeleteCommand extends CommandBase { public DeleteCommand(NpcManager plugin) { - super(plugin, NpcManager.DELETE_NPC_COMMAND_PERMISSION, "del"); + super(plugin, NpcManager.Perm.DELETE_NPC_COMMAND, "del"); } @Override 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 74e59c78c..bdc8622e2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/HomeCommand.java @@ -11,7 +11,7 @@ public class HomeCommand extends CommandBase { public HomeCommand(NpcManager plugin) { - super(plugin, NpcManager.NPC_HOME_COMMAND_PERMISSION, "home"); + super(plugin, NpcManager.Perm.NPC_HOME_COMMAND, "home"); } @Override 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 9956a3ceb..a57c3d07d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/NpcCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/NpcCommand.java @@ -9,7 +9,7 @@ public class NpcCommand extends MultiCommandBase { public NpcCommand(NpcManager plugin) { - super(plugin, NpcManager.NPC_COMMAND_PERMISSION, "npc"); + super(plugin, NpcManager.Perm.NPC_COMMAND, "npc"); AddCommand(new AddCommand(plugin)); AddCommand(new DeleteCommand(plugin)); 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 d705b1e8f..a715de32a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/command/RefreshCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/command/RefreshCommand.java @@ -13,7 +13,7 @@ public class RefreshCommand extends CommandBase { public RefreshCommand(NpcManager plugin) { - super(plugin, NpcManager.REFRESH_NPCS_COMMAND_PERMISSION, "refresh"); + super(plugin, NpcManager.Perm.REFRESH_NPCS_COMMAND, "refresh"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java index 4becd0422..a9e72247d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java @@ -14,9 +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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.HoverEvent; @@ -44,8 +43,11 @@ import mineplex.serverdata.commands.ServerCommandManager; public class PartyManager extends MiniPlugin { - public static final String PARTY_COMMAND_PERMISSION = "mineplex.core.party.command"; - + public enum Perm implements Permission + { + PARTY_COMMAND, + } + /** * The item given to a player in his hotbar to manage the Parties via the new UI. */ @@ -107,9 +109,8 @@ public class PartyManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(PARTY_COMMAND_PERMISSION), true, true); + + PermissionGroup.PLAYER.setPermission(Perm.PARTY_COMMAND, 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 7b1a67ba9..4d1aa78d1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCLICommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCLICommand.java @@ -1,5 +1,10 @@ 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; @@ -16,16 +21,12 @@ 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, PartyManager.PARTY_COMMAND_PERMISSION, "cli", "c"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "cli", "c"); AddCommand(new PartyAcceptCommand(plugin)); AddCommand(new PartyDenyCommand(plugin)); 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 0da3e6b57..6825400e3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyCommand.java @@ -20,7 +20,7 @@ public class PartyCommand extends MultiCommandBase public PartyCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "party", "z"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "party", "z"); AddCommand(new PartyGuiCommand(plugin)); AddCommand(new PartyCLICommand(plugin)); 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 9738d7cf6..4be13f1a1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyGuiCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyGuiCommand.java @@ -18,7 +18,7 @@ public class PartyGuiCommand extends MultiCommandBase { public PartyGuiCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "gui", "g"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "gui", "g"); AddCommand(new PartyOpenInviteMenuCommand(plugin)); AddCommand(new PartyGUIAcceptInviteCommand(plugin)); 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 76a52acfb..a403e7ab0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyToggleCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/PartyToggleCommand.java @@ -17,7 +17,7 @@ public class PartyToggleCommand extends CommandBase public PartyToggleCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "toggle", "t"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "toggle", "t"); } @Override 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 c830a8127..957552e14 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 @@ -15,7 +15,7 @@ public class PartyAcceptCommand extends CommandBase { public PartyAcceptCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "accept", "a"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "accept", "a"); } @Override 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 59a5c96b8..eddb7bfeb 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 @@ -9,7 +9,7 @@ public class PartyBlockCommand extends CommandBase { public PartyBlockCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "block", "b"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "block", "b"); } @Override 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 d954db59e..39d89dc84 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 @@ -16,7 +16,7 @@ public class PartyDenyCommand extends CommandBase { public PartyDenyCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "deny", "d"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "deny", "d"); } @Override 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 e7e6f961e..9828c17eb 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 @@ -9,7 +9,7 @@ public class PartyDisbandCommand extends CommandBase { public PartyDisbandCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "disband", "db"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "disband", "db"); } @Override 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 168078522..7ccd011a3 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 @@ -11,7 +11,7 @@ public class PartyHelpCommand extends CommandBase { public PartyHelpCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "help", "h"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "help", "h"); } @Override 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 24537d3e3..1dbe57fdd 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 @@ -15,7 +15,7 @@ public class PartyInviteCommand extends CommandBase { public PartyInviteCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "invite", "i"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "invite", "i"); } @Override 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 b37de9989..4da075a0b 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,6 +6,12 @@ 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; @@ -15,11 +21,6 @@ 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 { @@ -27,7 +28,7 @@ public class PartyInvitesCommand extends CommandBase public PartyInvitesCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "invites", "is"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "invites", "is"); } @Override 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 8f856364d..7a378d29a 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 @@ -15,7 +15,7 @@ public class PartyKickCommand extends CommandBase { public PartyKickCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "kick", "k"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "kick", "k"); } @Override 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 d7d6300c1..cc3e43022 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 @@ -9,7 +9,7 @@ public class PartyLeaveCommand extends CommandBase { public PartyLeaveCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "leave", "l"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "leave", "l"); } @Override 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 be6cc2e55..335794c9f 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 @@ -17,7 +17,7 @@ public class PartyTransferOwnerCommand extends CommandBase { public PartyTransferOwnerCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "transfer", "tr"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "transfer", "tr"); } @Override 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 eceeb6721..f3a8b783e 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 @@ -15,7 +15,7 @@ public class PartyGUIAcceptInviteCommand extends CommandBase { public PartyGUIAcceptInviteCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "partyaccept", "accept", "a"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "partyaccept", "accept", "a"); } @Override 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 f261512b1..5d8bc27de 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 @@ -16,7 +16,7 @@ public class PartyGUIDenyInviteCommand extends CommandBase { public PartyGUIDenyInviteCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "partydeny", "deny", "d"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "partydeny", "deny", "d"); } @Override 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 c4b850ae7..117d2dce4 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 @@ -15,7 +15,7 @@ public class PartyGUIInviteCommand extends CommandBase { public PartyGUIInviteCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "partyinvite", "invite", "i"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "partyinvite", "invite", "i"); } @Override 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 ba6b6546b..3acce0019 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 @@ -9,7 +9,7 @@ public class PartyGUILeaveCommand extends CommandBase { public PartyGUILeaveCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "leave", "l"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "leave", "l"); } @Override 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 0ab7d0db9..e05533d81 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 @@ -10,7 +10,7 @@ public class PartyOpenInviteMenuCommand extends CommandBase { public PartyOpenInviteMenuCommand(PartyManager plugin) { - super(plugin, PartyManager.PARTY_COMMAND_PERMISSION, "openinvitesmenu", "invitesmenu", "im", "invites", "is"); + super(plugin, PartyManager.Perm.PARTY_COMMAND, "openinvitesmenu", "invitesmenu", "im", "invites", "is"); } @Override 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 2768f4c43..83ff95fca 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java @@ -20,7 +20,6 @@ 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.util.F; import mineplex.core.common.util.UtilItem; @@ -156,7 +155,7 @@ public class PartyJoinManager implements Listener List all = new ArrayList<>(); for (Player player : party.getMembers()) { - if (!_plugin.getClientManager().getPermissionManager().hasPermission(player, GroupPermission.of(CoreClientManager.JOIN_FULL_PERMISSION))) + if (!_plugin.getClientManager().Get(player).hasPermission(CoreClientManager.Perm.JOIN_FULL)) { unranked.add(player.getUniqueId()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java index 2e275e014..ba590a3bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java @@ -12,7 +12,7 @@ public class HostEventServerCommand extends CommandBase i { public HostEventServerCommand(PersonalServerManager plugin) { - super(plugin, PersonalServerManager.EVENT_COMMAND_PERMISSION, "hostevent"); + super(plugin, PersonalServerManager.Perm.EVENT_COMMAND, "hostevent"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java index 27b137c9a..25d712fc1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java @@ -12,7 +12,7 @@ public class HostPersonalEventServer extends CommandBase { public HostPersonalEventServer(PersonalServerManager plugin) { - super(plugin, PersonalServerManager.PERSONAL_EVENT_COMMAND_PERMISSION, "hostmes"); + super(plugin, PersonalServerManager.Perm.PERSONAL_EVENT_COMMAND, "hostmes"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java index 568d5f806..8e9d99d94 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostServerCommand.java @@ -11,7 +11,7 @@ public class HostServerCommand extends CommandBase { public HostServerCommand(PersonalServerManager plugin) { - super(plugin, PersonalServerManager.MPS_PERMISSION, "hostserver", "mps"); + super(plugin, PersonalServerManager.Perm.MPS, "hostserver", "mps"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java index 32c959b95..203c3b8b6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java @@ -10,9 +10,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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.Color; import mineplex.core.common.jsonchat.HoverEvent; @@ -31,11 +30,14 @@ 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"; - + public enum Perm implements Permission + { + MPS, + ADVANCED_MPS, + EVENT_COMMAND, + PERSONAL_EVENT_COMMAND, + } + private ServerRepository _repository; private CoreClientManager _clientManager; @@ -64,16 +66,15 @@ public class PersonalServerManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.LEGEND, GroupPermission.of(MPS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(ADVANCED_MPS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.YT, GroupPermission.of(ADVANCED_MPS_PERMISSION), true, false); - pm.setPermission(PermissionGroup.SRMOD, GroupPermission.of(ADVANCED_MPS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.EVENTMOD, GroupPermission.of(EVENT_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.EVENTMOD, GroupPermission.of(PERSONAL_EVENT_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(EVENT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PERSONAL_EVENT_COMMAND_PERMISSION), true, true); + + PermissionGroup.LEGEND.setPermission(Perm.MPS, true, true); + PermissionGroup.CONTENT.setPermission(Perm.ADVANCED_MPS, true, true); + PermissionGroup.YT.setPermission(Perm.ADVANCED_MPS, true, false); + PermissionGroup.SRMOD.setPermission(Perm.ADVANCED_MPS, true, true); + PermissionGroup.EVENTMOD.setPermission(Perm.EVENT_COMMAND, false, true); + PermissionGroup.EVENTMOD.setPermission(Perm.PERSONAL_EVENT_COMMAND, false, true); + PermissionGroup.ADMIN.setPermission(Perm.EVENT_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.PERSONAL_EVENT_COMMAND, true, true); } @EventHandler @@ -90,11 +91,10 @@ public class PersonalServerManager extends MiniPlugin return; } - if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(MPS_PERMISSION))) + if (_clientManager.Get(event.getPlayer()).hasPermission(Perm.MPS)) { showHostMessage(event.getPlayer()); - } - else + } else { UtilPlayer.message(event.getPlayer(), F.main("Server", "Only players with " + C.cGreen + "Legend" + C.mBody + "+ can host private servers")); } @@ -148,7 +148,7 @@ public class PersonalServerManager extends MiniPlugin int ram = 1024; int cpu = 1; - if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(ADVANCED_MPS_PERMISSION))) + if (_clientManager.Get(player).hasPermission(Perm.ADVANCED_MPS)) { ram = 2048; cpu = 4; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index c3aff01d9..82e7076a8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -50,9 +50,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.shape.ShapeWings; import mineplex.core.common.skin.SkinData; @@ -82,9 +81,12 @@ import mineplex.core.updater.event.UpdateEvent; 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"; - + public enum Perm implements Permission + { + WIDDER_PET, + GUARDIAN_PET, + } + private static Object _petOwnerSynch = new Object(); private static Object _petRenameSynch = new Object(); @@ -134,10 +136,9 @@ public class PetManager extends MiniClientPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.LEGEND, GroupPermission.of(WIDDER_PET_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(GUARDIAN_PET_PERMISSION), true, true); + + PermissionGroup.LEGEND.setPermission(Perm.WIDDER_PET, true, true); + PermissionGroup.TITAN.setPermission(Perm.GUARDIAN_PET, true, true); } public void addPetOwnerToQueue(String playerName, PetType petType) @@ -203,15 +204,15 @@ public class PetManager extends MiniClientPlugin { Player p = event.getPlayer(); - if (_clientManager.getPermissionManager().hasPermission(p, GroupPermission.of(WIDDER_PET_PERMISSION))) + if (_clientManager.Get(p).hasPermission(Perm.WIDDER_PET)) { if (!Get(p).getPets().containsKey(PetType.WITHER)) { Get(p).getPets().put(PetType.WITHER, "Widder"); } } - - if (_clientManager.getPermissionManager().hasPermission(p, GroupPermission.of(GUARDIAN_PET_PERMISSION))) + + if (_clientManager.Get(p).hasPermission(Perm.GUARDIAN_PET)) { if (!Get(p).getPets().containsKey(PetType.SKELETON)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java index 9983703ab..dd3959281 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/PollManager.java @@ -5,6 +5,9 @@ import java.sql.SQLException; import java.util.List; import java.util.UUID; +import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer; +import net.minecraft.server.v1_8_R3.PacketPlayOutChat; + import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -15,23 +18,23 @@ import com.google.gson.JsonObject; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; 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.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"; - + public enum Perm implements Permission + { + POLL_COMMAND, + POLL_STAFF_COMMAND, + } + private PollRepository _repository; private DonationManager _donationManager; private List _polls; @@ -54,10 +57,8 @@ public class PollManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(POLL_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(POLL_COMMAND_PERMISSION), true, true); + PermissionGroup.PLAYER.setPermission(Perm.POLL_COMMAND, true, true); + PermissionGroup.MOD.setPermission(Perm.POLL_COMMAND, true, true); } @Override 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 c7850dafd..c0de37c91 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/poll/command/PollCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/poll/command/PollCommand.java @@ -7,7 +7,6 @@ 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.jsonchat.JsonMessage; import mineplex.core.common.util.C; @@ -25,7 +24,7 @@ public class PollCommand extends CommandBase { public PollCommand(PollManager plugin) { - super(plugin, PollManager.POLL_COMMAND_PERMISSION, "poll"); + super(plugin, PollManager.Perm.POLL_COMMAND, "poll"); } @Override @@ -39,7 +38,7 @@ public class PollCommand extends CommandBase return; } - if (args[0].equalsIgnoreCase("list") && _commandCenter.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(PollManager.POLL_STAFF_COMMAND_PERMISSION))) + if (args[0].equalsIgnoreCase("list") && _commandCenter.GetClientManager().Get(caller).hasPermission(PollManager.Perm.POLL_STAFF_COMMAND)) { if (args.length == 1) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index e503ad59f..b00cc1564 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -18,9 +18,8 @@ import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; 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; @@ -41,11 +40,14 @@ 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"; + public enum Perm implements Permission + { + JOIN_FULL, + JOIN_STAFF, + SERVER_COMMAND_CLANS, + SERVER_COMMAND, + SEND_COMMAND, + } // The singleton instance of Portal private static Portal instance; @@ -94,13 +96,12 @@ public class Portal extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(SERVER_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SEND_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(JOIN_STAFF_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(SERVER_COMMAND_CLANS_PERMISSION), true, true); + + PermissionGroup.ULTRA.setPermission(Perm.JOIN_FULL, true, true); + PermissionGroup.PLAYER.setPermission(Perm.SERVER_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.SEND_COMMAND, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.JOIN_STAFF, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.SERVER_COMMAND_CLANS, true, true); } public void sendAllPlayersToGenericServer(GenericServer hub, Intent kick) @@ -156,7 +157,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() || server.getGroup().equalsIgnoreCase("Clans") || _clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(JOIN_FULL_PERMISSION))) + if (server.getPlayerCount() < server.getMaxPlayerCount() || server.getGroup().equalsIgnoreCase("Clans") || _clientManager.Get(player).hasPermission(Perm.JOIN_FULL)) { sendPlayer(player, serverName); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/SendCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/SendCommand.java index ea13de43a..294e793f6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/SendCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/SendCommand.java @@ -12,7 +12,7 @@ public class SendCommand extends CommandBase { public SendCommand(Portal plugin) { - super(plugin, Portal.SEND_COMMAND_PERMISSION, "send"); + super(plugin, Portal.Perm.SEND_COMMAND, "send"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/ServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/ServerCommand.java index 02257a78b..fd97de43c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/ServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/ServerCommand.java @@ -2,7 +2,6 @@ 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; @@ -14,7 +13,7 @@ public class ServerCommand extends CommandBase { public ServerCommand(Portal plugin) { - super(plugin, Portal.SERVER_COMMAND_PERMISSION, "server"); + super(plugin, Portal.Perm.SERVER_COMMAND, "server"); } @Override @@ -54,14 +53,14 @@ public class ServerCommand extends CommandBase if (servUp.contains("STAFF")) { - if (!_commandCenter.GetClientManager().getPermissionManager().hasPermission(player, GroupPermission.of(Portal.JOIN_STAFF_PERMISSION))) + if (!_commandCenter.GetClientManager().Get(player).hasPermission(Portal.Perm.JOIN_STAFF)) { deniedAccess = true; } } else if (servUp.startsWith("CLANS-")) { - if (!_commandCenter.GetClientManager().getPermissionManager().hasPermission(player, GroupPermission.of(Portal.SERVER_COMMAND_CLANS_PERMISSION))) + if (!_commandCenter.GetClientManager().Get(player).hasPermission(Portal.Perm.SERVER_COMMAND_CLANS)) { UtilPlayer.message(player, F.main(Plugin.getName(), "Clans servers can only be joined via the Clans Hub!")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java index f043bc622..3aba5513f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java @@ -8,7 +8,7 @@ import org.bukkit.Material; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; /** * All ID's are assigned by enum order. @@ -20,7 +20,7 @@ import mineplex.core.account.permissions.GroupPermission; * Name: The string shown to players in the menu and for toggling * Lore: A description of the preference */ -public enum Preference +public enum Preference implements Permission { HUB_GAMES(true, PreferenceCategory.USER, Material.FIREBALL, "Hub Games"), SHOW_PLAYERS(true, PreferenceCategory.USER, Material.EYE_OF_ENDER, "Hub Player Visibility"), @@ -111,11 +111,6 @@ public enum Preference return _lore; } - public GroupPermission getPermission() - { - return GroupPermission.of("mineplex.core.preferences." + getId()); - } - public PreferenceCategory getCategory() { return _category; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java index afdcdfded..2846091dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesManager.java @@ -27,9 +27,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; @@ -43,9 +42,12 @@ 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"; - + public enum Perm implements Permission + { + VIEW_EXCLUSIVE_MENU, + PREFERENCES_COMMAND, + } + private final PreferencesRepository _repository; private final CoreClientManager _clientManager; private final IncognitoManager _incognitoManager; @@ -72,49 +74,47 @@ public class PreferencesManager extends MiniPlugin implements ILoginProcessor private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - for (Preference p : Preference.values()) { if (p.getCategory() == PreferenceCategory.EXCLUSIVE) { if (p == Preference.INVISIBILITY) { - pm.setPermission(PermissionGroup.ADMIN, p.getPermission(), true, true); - pm.setPermission(PermissionGroup.CONTENT, p.getPermission(), true, true); - pm.setPermission(PermissionGroup.YT, p.getPermission(), false, false); + PermissionGroup.ADMIN.setPermission(p, true, true); + PermissionGroup.CONTENT.setPermission(p, true, true); + PermissionGroup.YT.setPermission(p, false, false); } else if (p == Preference.FORCE_FIELD) { - pm.setPermission(PermissionGroup.CONTENT, p.getPermission(), true, true); - pm.setPermission(PermissionGroup.EVENTMOD, p.getPermission(), false, true); + PermissionGroup.CONTENT.setPermission(p, true, true); + PermissionGroup.EVENTMOD.setPermission(p, false, true); } else if (p == Preference.GLOBAL_GWEN_REPORTS) { - pm.setPermission(PermissionGroup.TRAINEE, p.getPermission(), true, true); + PermissionGroup.TRAINEE.setPermission(p, true, true); } else if (p == Preference.SHOW_USER_REPORTS) { - pm.setPermission(PermissionGroup.TRAINEE, p.getPermission(), true, true); + PermissionGroup.TRAINEE.setPermission(p, true, true); } else if (p == Preference.IGNORE_VELOCITY) { - pm.setPermission(PermissionGroup.BUILDER, p.getPermission(), true, true); + PermissionGroup.BUILDER.setPermission(p, true, true); } else { - pm.setPermission(PermissionGroup.ADMIN, p.getPermission(), true, true); + PermissionGroup.ADMIN.setPermission(p, true, true); } } else { - pm.setPermission(PermissionGroup.PLAYER, p.getPermission(), true, true); + PermissionGroup.PLAYER.setPermission(p, true, true); } } - pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(VIEW_EXCLUSIVE_MENU_PERMISSION), true, true); - pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(VIEW_EXCLUSIVE_MENU_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(PREFERENCES_COMMAND_PERMISSION), true, true); + PermissionGroup.CONTENT.setPermission(Perm.VIEW_EXCLUSIVE_MENU, true, true); + PermissionGroup.BUILDER.setPermission(Perm.VIEW_EXCLUSIVE_MENU, true, true); + PermissionGroup.PLAYER.setPermission(Perm.PREFERENCES_COMMAND, true, true); } @EventHandler 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 d95f3367b..c56d9c874 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/command/PreferencesCommand.java @@ -9,7 +9,7 @@ public class PreferencesCommand extends CommandBase { public PreferencesCommand(PreferencesManager plugin) { - super(plugin, PreferencesManager.PREFERENCES_COMMAND_PERMISSION, "prefs"); + super(plugin, PreferencesManager.Perm.PREFERENCES_COMMAND, "prefs"); } @Override 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 ef0ab707b..e61e6d064 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java @@ -6,7 +6,6 @@ import org.bukkit.entity.Player; import com.google.common.collect.Lists; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.UtilUI; import mineplex.core.menu.Button; import mineplex.core.menu.Menu; @@ -19,8 +18,8 @@ import mineplex.core.preferences.ui.buttons.CategoryButton; */ public class PreferenceMainMenu extends Menu { - private final int INV_SIZE_MAX = 54; - private final int INV_SIZE_MIN = 45; + private static final int INV_SIZE_MAX = 54; + private static final int INV_SIZE_MIN = 45; public PreferenceMainMenu(PreferencesManager plugin) { @@ -30,7 +29,7 @@ public class PreferenceMainMenu extends Menu @Override protected Button[] setUp(Player player) { - boolean exclusive = getPlugin().getClientManager().getPermissionManager().hasPermission(player, GroupPermission.of(PreferencesManager.VIEW_EXCLUSIVE_MENU_PERMISSION)); + boolean exclusive = getPlugin().getClientManager().Get(player).hasPermission(PreferencesManager.Perm.VIEW_EXCLUSIVE_MENU); Button[] buttons = new Button[exclusive ? INV_SIZE_MAX : INV_SIZE_MIN]; List list = Lists.newArrayList(PreferenceCategory.values()); 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 2945b6a01..20decc819 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 @@ -41,7 +41,7 @@ public class PreferenceMenu extends Menu List preferences = Lists.newArrayList(Preference.getByCategory(_category)); UserPreferences user = getPlugin().get(player); - preferences.removeIf(pref -> !getPlugin().getClientManager().getPermissionManager().hasPermission(player, pref.getPermission())); + preferences.removeIf(pref -> !getPlugin().getClientManager().Get(player).hasPermission(pref)); int[] slots = UtilUI.getIndicesFor(preferences.size(), 1, 4, 1); 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 ba23432e7..0fefed051 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java @@ -20,7 +20,7 @@ public class PunishCommand extends CommandBase { public PunishCommand(Punish plugin) { - super(plugin, Punish.PUNISHMENT_COMMAND_PERMISSION, "punish", "p"); + super(plugin, Punish.Perm.PUNISHMENT_COMMAND, "punish", "p"); } @Override 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 5beba0e02..9ef5a5baa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/RulesCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/RulesCommand.java @@ -13,7 +13,7 @@ public class RulesCommand extends CommandBase public RulesCommand(Punish plugin) { - super(plugin, Punish.RULES_COMMAND_PERMISSION, "rules"); + super(plugin, Punish.Perm.RULES_COMMAND, "rules"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java index 06615747d..4bead83d3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java @@ -25,9 +25,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.Constants; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -49,10 +48,13 @@ import mineplex.serverdata.commands.ServerCommandManager; public class Punish extends MiniPlugin { - 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"; + public enum Perm implements Permission + { + ALERT_PUNISHMENT, + PUNISHMENT_COMMAND, + FULL_PUNISHMENT_ACCESS, + RULES_COMMAND, + } private Map _punishClients; private PunishRepository _repository; @@ -80,12 +82,11 @@ public class Punish extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(ALERT_PUNISHMENT_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(PUNISHMENT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(FULL_PUNISHMENT_ACCESS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(RULES_COMMAND_PERMISSION), true, true); + + PermissionGroup.TRAINEE.setPermission(Perm.ALERT_PUNISHMENT, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.PUNISHMENT_COMMAND, true, true); + PermissionGroup.MOD.setPermission(Perm.FULL_PUNISHMENT_ACCESS, true, true); + PermissionGroup.PLAYER.setPermission(Perm.RULES_COMMAND, true, true); } public ClansBanManager getClansPunish() @@ -390,7 +391,7 @@ public class Punish extends MiniPlugin { for (Player player : UtilServer.getPlayers()) { - if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(ALERT_PUNISHMENT_PERMISSION)) || player.getName().equals(punishee)) + if (_clientManager.Get(player).hasPermission(Perm.ALERT_PUNISHMENT) || player.getName().equals(punishee)) { player.sendMessage(msg); } 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 738a7a538..5e0da19c9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/UI/PunishPage.java @@ -21,7 +21,6 @@ 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.util.C; import mineplex.core.common.util.F; @@ -150,40 +149,40 @@ 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().getPermissionManager().hasPermission(_player, GroupPermission.of(Punish.FULL_PUNISHMENT_ACCESS_PERMISSION))) + if (_plugin.GetClients().Get(_player).hasPermission(Punish.Perm.FULL_PUNISHMENT_ACCESS)) { - 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), - " ", - examplePrefix + "Medium Spam", - examplePrefixEx + " Sending the same message 6-20 times", - " ", - examplePrefix + "Medium Advertising;", - examplePrefixEx + " 'join crap.server.net' - posted once", - " ", - examplePrefix + "Medium Abuse/Harassment", - examplePrefixEx + " 'piss off you stupid newb'", - examplePrefixEx + " 'SHIT ADMINS ARE SHIT!!!'", - examplePrefixEx + " 'you're terrible, learn to play'", - " ", - examplePrefix + "Avoiding Chat Filter", - examplePrefixEx + " 'F|_| { public ClansBanCommand(ClansBanManager plugin) { - super(plugin, ClansBanManager.PUNISHMENT_COMMAND_PERMISSION, "cbans", "cb", "cban", "cp", "cpunish", "clanspunish", "clanpunish"); + super(plugin, ClansBanManager.Perm.PUNISHMENT_COMMAND, "cbans", "cb", "cban", "cp", "cpunish", "clanspunish", "clanpunish"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java index 8ae77d09b..f2ed28796 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/QuestManager.java @@ -24,9 +24,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import mineplex.core.MiniDbClientPlugin; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; 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.F; @@ -62,10 +61,13 @@ import mineplex.serverdata.servers.ServerManager; */ 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 enum Perm implements Permission + { + GET_QUEST_COMMAND, + INCREMENT_QUEST_COMMAND, + QUEST_GUI_COMMAND, + } + public static final String QUEST_NAME = "Mineplex Mission"; private static final String GOOGLE_SHEET = "QUESTS_SHEET"; @@ -118,12 +120,11 @@ public class QuestManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GET_QUEST_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.QA, GroupPermission.of(GET_QUEST_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(INCREMENT_QUEST_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(QUEST_GUI_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.GET_QUEST_COMMAND, true, true); + PermissionGroup.QA.setPermission(Perm.GET_QUEST_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.INCREMENT_QUEST_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.QUEST_GUI_COMMAND, true, true); } @EventHandler 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 ba8b6028b..c7ac7f255 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java @@ -22,7 +22,7 @@ public class GetQuestCommand extends CommandBase { public GetQuestCommand(QuestManager plugin) { - super(plugin, QuestManager.GET_QUEST_COMMAND_PERMISSION, "GetMineplexMission"); + super(plugin, QuestManager.Perm.GET_QUEST_COMMAND, "GetMineplexMission"); } @Override 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 0c659c4f7..78afa532c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/IncrementQuestCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/IncrementQuestCommand.java @@ -18,7 +18,7 @@ public class IncrementQuestCommand extends CommandBase { public IncrementQuestCommand(QuestManager plugin) { - super(plugin, QuestManager.INCREMENT_QUEST_COMMAND_PERMISSION, "IncrementMineplexMission"); + super(plugin, QuestManager.Perm.INCREMENT_QUEST_COMMAND, "IncrementMineplexMission"); } @Override 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 3ddce78fc..c8a8f4d57 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/OpenGuiCommand.java @@ -15,7 +15,7 @@ public class OpenGuiCommand extends CommandBase { public OpenGuiCommand(QuestManager plugin) { - super(plugin, QuestManager.QUEST_GUI_COMMAND_PERMISSION, "Missions"); + super(plugin, QuestManager.Perm.QUEST_GUI_COMMAND, "Missions"); } @Override 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 7e257b6e4..18711bb0c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalCommand.java @@ -12,7 +12,7 @@ public class EternalCommand extends CommandBase { public EternalCommand(EternalGiveawayManager plugin) { - super(plugin, EternalGiveawayManager.ETERNAL_COMMAND_PERMISSION, "eternaltest"); + super(plugin, EternalGiveawayManager.Perm.ETERNAL_COMMAND, "eternaltest"); } @Override 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 884ff4f44..ee151cdc3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/eternal/EternalGiveawayManager.java @@ -7,9 +7,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.Permission; 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; @@ -18,8 +17,11 @@ import mineplex.serverdata.commands.ServerCommandManager; public class EternalGiveawayManager extends MiniPlugin { - public static final String ETERNAL_COMMAND_PERMISSION = "mineplex.core.rankGiveaway.eternal.command"; - + public enum Perm implements Permission + { + ETERNAL_COMMAND, + } + private static final double RANK_FIND_CHANCE = 0.001; private final PermissionGroup _group; @@ -47,9 +49,8 @@ public class EternalGiveawayManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.LT, GroupPermission.of(ETERNAL_COMMAND_PERMISSION), true, true); + + PermissionGroup.LT.setPermission(Perm.ETERNAL_COMMAND, true, true); } @Override @@ -100,7 +101,7 @@ public class EternalGiveawayManager extends MiniPlugin */ private boolean hasEternal(Player player) { - return _clientManager.Get(player).getPrimaryGroup() == PermissionGroup.ETERNAL || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _group); + return _clientManager.Get(player).getPrimaryGroup().inheritsFrom(PermissionGroup.ETERNAL); } public Region getRegion() 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 991714e40..1fec9e2cf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/titangiveaway/TitanGiveawayManager.java @@ -81,7 +81,7 @@ public class TitanGiveawayManager extends MiniPlugin */ private boolean hasTitan(Player player) { - return _clientManager.Get(player).getPrimaryGroup() == PermissionGroup.TITAN || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _group); + return _clientManager.Get(player).getPrimaryGroup().inheritsFrom(PermissionGroup.TITAN); } public Region getRegion() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java index d4b31daa3..6b236698d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportManager.java @@ -18,9 +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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.chatsnap.SnapshotManager; import mineplex.core.chatsnap.SnapshotMetadata; import mineplex.core.chatsnap.redis.PushSnapshotsCommand; @@ -55,12 +54,15 @@ 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"; + public enum Perm implements Permission + { + REPORT_CLOSE_COMMAND, + REPORT_COMMAND, + REPORT_HANDLE_COMMAND, + REPORT_HISTORY_COMMAND, + REPORT_INFO_COMMAND, + REPORT_METRICS_COMMAND, + } private static final String NAME = "Report"; private static final int INITIAL_PRIORITY = 15; @@ -108,14 +110,13 @@ public class ReportManager private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(REPORT_CLOSE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(REPORT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(REPORT_HANDLE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(REPORT_HISTORY_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(REPORT_INFO_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(REPORT_METRICS_COMMAND_PERMISSION), true, true); + + PermissionGroup.MOD.setPermission(Perm.REPORT_CLOSE_COMMAND, true, true); + PermissionGroup.TITAN.setPermission(Perm.REPORT_COMMAND, true, true); + PermissionGroup.MOD.setPermission(Perm.REPORT_HANDLE_COMMAND, true, true); + PermissionGroup.MOD.setPermission(Perm.REPORT_HISTORY_COMMAND, true, true); + PermissionGroup.MOD.setPermission(Perm.REPORT_INFO_COMMAND, true, true); + PermissionGroup.MOD.setPermission(Perm.REPORT_METRICS_COMMAND, true, true); } public SnapshotManager getSnapshotManager() 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 cea39dace..e2f59edd9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCloseCommand.java @@ -21,7 +21,7 @@ public class ReportCloseCommand extends CommandBase { public ReportCloseCommand(ReportPlugin plugin) { - super(plugin, ReportManager.REPORT_CLOSE_COMMAND_PERMISSION, "reportclose", "rc"); + super(plugin, ReportManager.Perm.REPORT_CLOSE_COMMAND, "reportclose", "rc"); } @Override 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 cd13726b8..3f67ad18b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportCommand.java @@ -22,7 +22,7 @@ public class ReportCommand extends CommandBase { public ReportCommand(ReportPlugin plugin) { - super(plugin, ReportManager.REPORT_COMMAND_PERMISSION, "report"); + super(plugin, ReportManager.Perm.REPORT_COMMAND, "report"); } @Override 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 b2138f74b..961ca962f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHandleCommand.java @@ -18,7 +18,7 @@ public class ReportHandleCommand extends CommandBase { public ReportHandleCommand(ReportPlugin plugin) { - super(plugin, ReportManager.REPORT_HANDLE_COMMAND_PERMISSION, "reporthandle", "rh"); + super(plugin, ReportManager.Perm.REPORT_HANDLE_COMMAND, "reporthandle", "rh"); } @Override 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 73dd1aaf5..bab3df57e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportHistoryCommand.java @@ -23,7 +23,7 @@ public class ReportHistoryCommand extends CommandBase { public ReportHistoryCommand(ReportPlugin reportPlugin) { - super(reportPlugin, ReportManager.REPORT_HISTORY_COMMAND_PERMISSION, "reporthistory", "rhis"); + super(reportPlugin, ReportManager.Perm.REPORT_HISTORY_COMMAND, "reporthistory", "rhis"); } @Override 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 1ffa4ca10..906205339 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportInfoCommand.java @@ -29,7 +29,7 @@ public class ReportInfoCommand extends CommandBase { public ReportInfoCommand(ReportPlugin plugin) { - super(plugin, ReportManager.REPORT_INFO_COMMAND_PERMISSION, "reportinfo"); + super(plugin, ReportManager.Perm.REPORT_INFO_COMMAND, "reportinfo"); } @Override 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 0cc497605..dc73807af 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/command/ReportMetricsCommand.java @@ -21,7 +21,7 @@ public class ReportMetricsCommand extends CommandBase public ReportMetricsCommand(ReportPlugin plugin) { - super(plugin, ReportManager.REPORT_METRICS_COMMAND_PERMISSION, "reportmetrics"); + super(plugin, ReportManager.Perm.REPORT_METRICS_COMMAND, "reportmetrics"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 57867be59..c378404b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -1308,7 +1308,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).getPrimaryGroup() == PermissionGroup.TITAN || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), PermissionGroup.TITAN))) + if (canGiveMythical && (type == RewardType.MYTHICAL_CHEST || type == RewardType.TRICK_OR_TREAT_CHEST || type == RewardType.THANKFUL_CHEST) && !_clientManager.Get(player).getPrimaryGroup().inheritsFrom(PermissionGroup.TITAN)) { return new RankReward(_clientManager, 0, 0, rarity); } @@ -1316,7 +1316,7 @@ public class RewardManager { return rew; } - else if (!canGiveMythical || (_clientManager.Get(player).getPrimaryGroup() == PermissionGroup.LEGEND || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), PermissionGroup.LEGEND))) + else if (!canGiveMythical || _clientManager.Get(player).getPrimaryGroup().inheritsFrom(PermissionGroup.LEGEND)) { rarity = RewardRarity.LEGENDARY; } 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 cb530df67..1f30a79ea 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/RankReward.java @@ -97,7 +97,7 @@ public class RankReward extends Reward @Override public boolean canGiveReward(Player player) { - return !_clientManager.Get(player).getPrimaryGroup().equals("eternal") && !_clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), PermissionGroup.ETERNAL); + return !_clientManager.Get(player).getPrimaryGroup().inheritsFrom(PermissionGroup.ETERNAL); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java b/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java index a986f6fd4..7f91330ad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java @@ -12,17 +12,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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.serverdata.Region; import mineplex.serverdata.data.ServerGroup; import mineplex.serverdata.servers.ServerManager; public class ServerConfiguration extends MiniPlugin { - public static final String JOIN_STAFF_SERVER_PERMISSION = "mineplex.core.serverConfig.joinstaff"; - + public enum Perm implements Permission + { + JOIN_STAFF_SERVER, + } + private CoreClientManager _clientManager; private Field _playerListMaxPlayers; @@ -61,15 +63,14 @@ public class ServerConfiguration extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(JOIN_STAFF_SERVER_PERMISSION), true, true); + + PermissionGroup.TRAINEE.setPermission(Perm.JOIN_STAFF_SERVER, true, true); } @EventHandler public void onPlayerLogin(PlayerLoginEvent event) { - if (_serverGroup.getStaffOnly() && !_clientManager.getPermissionManager().hasPermission(_clientManager.Get(event.getPlayer().getUniqueId()), GroupPermission.of(JOIN_STAFF_SERVER_PERMISSION))) + if (_serverGroup.getStaffOnly() && !_clientManager.Get(event.getPlayer().getUniqueId()).hasPermission(Perm.JOIN_STAFF_SERVER)) { event.disallow(Result.KICK_OTHER, "This is a staff only server."); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index cfedaa4b7..e88be1e36 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -19,9 +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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTasks; import mineplex.core.leaderboard.LeaderboardManager; @@ -39,10 +38,13 @@ 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"; + public enum Perm implements Permission + { + GIVE_STAT_COMMAND, + TIME_COMMAND, + SET_LEVEL_COMMAND, + MASTER_BUILDERS_UNBAN_COMMAND, + } private static final Object STATS_LOCK = new Object(); @@ -87,12 +89,11 @@ public class StatsManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_STAT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(TIME_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SET_LEVEL_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(MASTER_BUILDERS_UNBAN_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.GIVE_STAT_COMMAND, true, true); + PermissionGroup.MOD.setPermission(Perm.TIME_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.SET_LEVEL_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.MASTER_BUILDERS_UNBAN_COMMAND, 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 c9f4ab88a..747259157 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java @@ -12,7 +12,7 @@ public class GiveStatCommand extends CommandBase { public GiveStatCommand(StatsManager plugin) { - super(plugin, StatsManager.GIVE_STAT_COMMAND_PERMISSION, "givestat"); + super(plugin, StatsManager.Perm.GIVE_STAT_COMMAND, "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 c87838495..31b3d8abf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/MasterBuilderUnban.java @@ -11,7 +11,7 @@ public class MasterBuilderUnban extends CommandBase { public MasterBuilderUnban(StatsManager plugin) { - super(plugin, StatsManager.MASTER_BUILDERS_UNBAN_COMMAND_PERMISSION, "buildunban"); + super(plugin, StatsManager.Perm.MASTER_BUILDERS_UNBAN_COMMAND, "buildunban"); } @Override 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 28b2b32a6..7e029ff1c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/SetLevelCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/SetLevelCommand.java @@ -12,7 +12,7 @@ public class SetLevelCommand extends CommandBase { public SetLevelCommand(StatsManager plugin) { - super(plugin, StatsManager.SET_LEVEL_COMMAND_PERMISSION, "setlevel"); + super(plugin, StatsManager.Perm.SET_LEVEL_COMMAND, "setlevel"); } @Override 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 a5ce676d9..25e9c7ea4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/TimeCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/TimeCommand.java @@ -15,7 +15,7 @@ public class TimeCommand extends CommandBase { public TimeCommand(StatsManager plugin) { - super(plugin, StatsManager.TIME_COMMAND_PERMISSION, "time"); + super(plugin, StatsManager.Perm.TIME_COMMAND, "time"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java index 54491bbaf..add9e93ac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java @@ -25,9 +25,8 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; 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; @@ -42,10 +41,13 @@ import mineplex.serverdata.commands.ServerCommandManager; @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 enum Perm implements Permission + { + LINK_COMMAND, + LIST_COMMAND, + TEAMSPEAK_COMMAND, + UNLINK_COMMAND, + } public static final String TEAMSPEAK_CHANNEL_NAME = "Teamspeak Rank Channel"; @@ -127,12 +129,11 @@ public class TeamspeakManager extends MiniClientPlugin impl private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(LINK_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(LIST_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(TEAMSPEAK_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(UNLINK_COMMAND_PERMISSION), true, true); + + PermissionGroup.PLAYER.setPermission(Perm.LINK_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.LIST_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.TEAMSPEAK_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.UNLINK_COMMAND, true, true); } @Override 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 0faa794ae..01e8ac339 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/LinkCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/LinkCommand.java @@ -11,7 +11,7 @@ public class LinkCommand extends CommandBase { public LinkCommand(TeamspeakManager plugin) { - super(plugin, TeamspeakManager.LINK_COMMAND_PERMISSION, "link"); + super(plugin, TeamspeakManager.Perm.LINK_COMMAND, "link"); } @Override 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 26bf72363..c5b58b106 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/ListCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/ListCommand.java @@ -9,7 +9,7 @@ public class ListCommand extends CommandBase { public ListCommand(TeamspeakManager plugin) { - super(plugin, TeamspeakManager.LIST_COMMAND_PERMISSION, "list"); + super(plugin, TeamspeakManager.Perm.LIST_COMMAND, "list"); } @Override 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 03867fc95..21a3698f3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/TeamspeakCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/TeamspeakCommand.java @@ -11,7 +11,7 @@ public class TeamspeakCommand extends MultiCommandBase { public TeamspeakCommand(TeamspeakManager plugin) { - super(plugin, TeamspeakManager.TEAMSPEAK_COMMAND_PERMISSION, "teamspeak", "ts"); + super(plugin, TeamspeakManager.Perm.TEAMSPEAK_COMMAND, "teamspeak", "ts"); AddCommand(new LinkCommand(plugin)); AddCommand(new ListCommand(plugin)); 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 2c68eca00..31eb3f18a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/UnlinkCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/UnlinkCommand.java @@ -11,7 +11,7 @@ public class UnlinkCommand extends CommandBase { public UnlinkCommand(TeamspeakManager plugin) { - super(plugin, TeamspeakManager.UNLINK_COMMAND_PERMISSION, "unlink"); + super(plugin, TeamspeakManager.Perm.UNLINK_COMMAND, "unlink"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java index f656f2b27..042dae4cf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java @@ -17,9 +17,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ChildJsonMessage; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.HoverEvent; @@ -45,14 +44,17 @@ import mineplex.serverdata.commands.ServerCommandManager; public class Teleport extends MiniPlugin { - public static final String FIND_COMMAND_PERMISSION = "mineplex.core.teleport.find"; - public static final String FIND_MOD_COMMAND_PERMISSION = "mineplex.core.teleport.find.mod"; - public static final String FIND_TRAINEE_COMMAND_PERMISSION = "mineplex.core.teleport.find.trainee"; - 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"; - + public enum Perm implements Permission + { + FIND_COMMAND, + FIND_MOD_COMMAND, + FIND_TRAINEE_COMMAND, + TELEPORT_COMMAND, + TELEPORT_LOCATION_COMMAND, + TELEPORT_OTHER_COMMAND, + TELEPORT_ALL_COMMAND, + } + private Map _failedRedisLocates = new HashMap<>(); private Map _failedRankLocates = new HashMap<>(); @@ -160,17 +162,16 @@ public class Teleport extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(FIND_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MC, GroupPermission.of(FIND_MOD_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FIND_MOD_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TM, GroupPermission.of(FIND_TRAINEE_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FIND_TRAINEE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(TELEPORT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TELEPORT_LOCATION_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TELEPORT_OTHER_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TELEPORT_ALL_COMMAND_PERMISSION), true, true); + + PermissionGroup.TRAINEE.setPermission(Perm.FIND_COMMAND, true, true); + PermissionGroup.MC.setPermission(Perm.FIND_MOD_COMMAND, false, true); + PermissionGroup.ADMIN.setPermission(Perm.FIND_MOD_COMMAND, true, true); + PermissionGroup.TM.setPermission(Perm.FIND_TRAINEE_COMMAND, false, true); + PermissionGroup.ADMIN.setPermission(Perm.FIND_TRAINEE_COMMAND, true, true); + PermissionGroup.MOD.setPermission(Perm.TELEPORT_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.TELEPORT_LOCATION_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.TELEPORT_OTHER_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.TELEPORT_ALL_COMMAND, true, true); } @Override 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 a95438732..83aa691c2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/AllCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/AllCommand.java @@ -9,7 +9,7 @@ public class AllCommand extends CommandBase { public AllCommand(Teleport plugin) { - super(plugin, Teleport.TELEPORT_ALL_COMMAND_PERMISSION, "all"); + super(plugin, Teleport.Perm.TELEPORT_ALL_COMMAND, "all"); } @Override 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 1f6bc8788..6e38b9979 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/BackCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/BackCommand.java @@ -3,7 +3,6 @@ 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.util.C; import mineplex.core.common.util.F; @@ -15,7 +14,7 @@ public class BackCommand extends CommandBase { public BackCommand(Teleport plugin) { - super(plugin, Teleport.TELEPORT_COMMAND_PERMISSION, "back", "b"); + super(plugin, Teleport.Perm.TELEPORT_COMMAND, "back", "b"); } @Override @@ -37,7 +36,7 @@ public class BackCommand extends CommandBase 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))) + if (!target.equals(caller.getName()) && !_commandCenter.GetClientManager().Get(caller).hasPermission(Teleport.Perm.TELEPORT_OTHER_COMMAND)) { UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that."); return; 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 a78b0d646..5986d659d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/HereCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/HereCommand.java @@ -9,7 +9,7 @@ public class HereCommand extends CommandBase { public HereCommand(Teleport plugin) { - super(plugin, Teleport.TELEPORT_OTHER_COMMAND_PERMISSION, "here", "h"); + super(plugin, Teleport.Perm.TELEPORT_OTHER_COMMAND, "here", "h"); } @Override 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 c463e90f0..0d9ba1c41 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/LocateCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/LocateCommand.java @@ -11,7 +11,7 @@ public class LocateCommand extends CommandBase { public LocateCommand(Teleport plugin) { - super(plugin, Teleport.FIND_COMMAND_PERMISSION, "locate", "where", "find"); + super(plugin, Teleport.Perm.FIND_COMMAND, "locate", "where", "find"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/ModLocateCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/ModLocateCommand.java index 355328c56..b62e094fa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/ModLocateCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/ModLocateCommand.java @@ -10,7 +10,7 @@ public class ModLocateCommand extends CommandBase { public ModLocateCommand(Teleport plugin) { - super(plugin, Teleport.FIND_MOD_COMMAND_PERMISSION, "mlocate", "mwhere", "mfind"); + super(plugin, Teleport.Perm.FIND_MOD_COMMAND, "mlocate", "mwhere", "mfind"); } @Override 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 4097274c5..e0e218dfc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TeleportCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TeleportCommand.java @@ -3,7 +3,6 @@ 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.util.C; import mineplex.core.common.util.F; @@ -15,7 +14,7 @@ public class TeleportCommand extends MultiCommandBase { public TeleportCommand(Teleport plugin) { - super(plugin, Teleport.TELEPORT_COMMAND_PERMISSION, "tp", "teleport"); + super(plugin, Teleport.Perm.TELEPORT_COMMAND, "tp", "teleport"); AddCommand(new AllCommand(plugin)); AddCommand(new BackCommand(plugin)); @@ -28,11 +27,10 @@ public class TeleportCommand extends MultiCommandBase //Caller to Player if (args.length == 1) { - if (_commandCenter.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(Teleport.TELEPORT_COMMAND_PERMISSION))) + if (_commandCenter.GetClientManager().Get(caller).hasPermission(Teleport.Perm.TELEPORT_COMMAND)) { Plugin.playerToPlayer(caller, caller.getName(), args[0]); - } - else + } else { UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that."); } @@ -41,11 +39,10 @@ public class TeleportCommand extends MultiCommandBase //Player to Player else if (args.length == 2) { - if (_commandCenter.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(Teleport.TELEPORT_OTHER_COMMAND_PERMISSION))) + if (_commandCenter.GetClientManager().Get(caller).hasPermission(Teleport.Perm.TELEPORT_OTHER_COMMAND)) { Plugin.playerToPlayer(caller, args[0], args[1]); - } - else + } else { UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that."); } @@ -54,11 +51,10 @@ public class TeleportCommand extends MultiCommandBase //Caller to Loc else if (args.length == 3) { - if (_commandCenter.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(Teleport.TELEPORT_LOCATION_COMMAND_PERMISSION))) + if (_commandCenter.GetClientManager().Get(caller).hasPermission(Teleport.Perm.TELEPORT_LOCATION_COMMAND)) { Plugin.playerToLoc(caller, caller.getName(), args[0], args[1], args[2]); - } - else + } else { UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that."); } @@ -67,7 +63,7 @@ public class TeleportCommand extends MultiCommandBase //Player to world else if (args.length == 5) { - 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))) + if (_commandCenter.GetClientManager().Get(caller).hasPermission(Teleport.Perm.TELEPORT_LOCATION_COMMAND) && _commandCenter.GetClientManager().Get(caller).hasPermission(Teleport.Perm.TELEPORT_OTHER_COMMAND)) { Plugin.playerToLoc(caller, args[0], args[1], args[2], args[3], args[4]); } @@ -80,7 +76,7 @@ public class TeleportCommand extends MultiCommandBase //Player to Loc 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))) + if (_commandCenter.GetClientManager().Get(caller).hasPermission(Teleport.Perm.TELEPORT_LOCATION_COMMAND) && _commandCenter.GetClientManager().Get(caller).hasPermission(Teleport.Perm.TELEPORT_OTHER_COMMAND)) { Plugin.playerToLoc(caller, args[0], args[1], args[2], args[3]); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TraineeLocateCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TraineeLocateCommand.java index cdaa8a4df..c805744d3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TraineeLocateCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/command/TraineeLocateCommand.java @@ -10,7 +10,7 @@ public class TraineeLocateCommand extends CommandBase { public TraineeLocateCommand(Teleport plugin) { - super(plugin, Teleport.FIND_TRAINEE_COMMAND_PERMISSION, "tlocate", "twhere", "tfind"); + super(plugin, Teleport.Perm.FIND_TRAINEE_COMMAND, "tlocate", "twhere", "tfind"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java index 317460416..58299fd55 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/ThankManager.java @@ -9,9 +9,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -27,8 +26,11 @@ 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"; + + public enum Perm implements Permission + { + THANK_COMMAND, + } private DonationManager _donationManager; @@ -47,9 +49,7 @@ public class ThankManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(THANK_COMMAND_PERMISSION), true, true); + PermissionGroup.PLAYER.setPermission(Perm.THANK_COMMAND, 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 7985c3e19..2e19281a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/thank/command/ThankCommand.java @@ -17,7 +17,7 @@ public class ThankCommand extends CommandBase { public ThankCommand(ThankManager plugin) { - super(plugin, ThankManager.THANK_COMMAND_PERMISSION, "thank"); + super(plugin, ThankManager.Perm.THANK_COMMAND, "thank"); } @Override 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 58ec1dfc5..08af784c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/GiveTrackCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/GiveTrackCommand.java @@ -18,7 +18,7 @@ public class GiveTrackCommand extends CommandBase { public GiveTrackCommand(TrackManager plugin) { - super(plugin, TrackManager.GIVE_TRACK_COMMAND_PERMISSION, "givetrack"); + super(plugin, TrackManager.Perm.GIVE_TRACK_COMMAND, "givetrack"); } @Override 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 1db41c304..2c1ff6038 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/TrackCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/TrackCommand.java @@ -19,7 +19,7 @@ public class TrackCommand extends CommandBase public TrackCommand(Titles plugin) { - super(plugin, TrackManager.TRACK_COMMAND_PERMISSION, "track"); + super(plugin, TrackManager.Perm.TRACK_COMMAND, "track"); _trackManager = Managers.require(TrackManager.class); } 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 ebead132e..c36f5a604 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java @@ -15,9 +15,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.Callback; import mineplex.core.inventory.InventoryManager; import mineplex.core.titles.commands.GiveTrackCommand; @@ -55,15 +54,18 @@ import mineplex.core.titles.tracks.standard.WarriorTrack; @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"; + public enum Perm implements Permission + { + HAPPY_GARY, + LEADER, + TABLE_FLIP, + BUILDER, + MOD, + SR_MOD, + TRAINEE, + TRACK_COMMAND, + GIVE_TRACK_COMMAND, + } private final Map, Track> _registeredTracks = new LinkedHashMap<>(); private final Map _trackById = new HashMap<>(); @@ -168,24 +170,23 @@ public class TrackManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _coreClientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(HAPPY_GARY_PERMISSION), true, true); - pm.setPermission(PermissionGroup.LT, GroupPermission.of(LEADER_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TABLE_FLIP_PERMISSION), true, true); - pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(BUILDER_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(BUILDER_PERMISSION), true, false); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BUILDER_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(MOD_PERMISSION), true, true); - pm.setPermission(PermissionGroup.SRMOD, GroupPermission.of(MOD_PERMISSION), true, false); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(MOD_PERMISSION), true, true); - pm.setPermission(PermissionGroup.SRMOD, GroupPermission.of(SR_MOD_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(TRAINEE_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(TRAINEE_PERMISSION), true, false); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TRAINEE_PERMISSION), true, true); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_TRACK_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(TRACK_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.HAPPY_GARY, true, true); + PermissionGroup.LT.setPermission(Perm.LEADER, true, true); + PermissionGroup.ADMIN.setPermission(Perm.TABLE_FLIP, true, true); + PermissionGroup.BUILDER.setPermission(Perm.BUILDER, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.BUILDER, true, false); + PermissionGroup.ADMIN.setPermission(Perm.BUILDER, true, true); + PermissionGroup.MOD.setPermission(Perm.MOD, true, true); + PermissionGroup.SRMOD.setPermission(Perm.MOD, true, false); + PermissionGroup.ADMIN.setPermission(Perm.MOD, true, true); + PermissionGroup.SRMOD.setPermission(Perm.SR_MOD, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.TRAINEE, true, true); + PermissionGroup.MOD.setPermission(Perm.TRAINEE, true, false); + PermissionGroup.ADMIN.setPermission(Perm.TRAINEE, true, true); + + PermissionGroup.ADMIN.setPermission(Perm.GIVE_TRACK_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.TRACK_COMMAND, true, true); } @Override 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 094c0263c..11be3b037 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,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.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 { @@ -21,7 +21,7 @@ public class HappyGaryTrack extends Track .addTier(new TrackTier( "☆゚°˖* ᕕ(ᐛ)ᕗ", null, - player -> _coreClientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TrackManager.HAPPY_GARY_PERMISSION)), + player -> _coreClientManager.Get(player).hasPermission(TrackManager.Perm.HAPPY_GARY), new TrackFormat(ChatColor.GOLD, ChatColor.GOLD) .animated(1, "☆゚°˖* ᕕ(ᐛ)ᕗ", 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 0d8f56ba5..552b96ef1 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.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,7 +21,7 @@ public class LeaderTrack extends Track .addTier(new TrackTier( "What's a Leader?", null, - player -> _coreClientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TrackManager.LEADER_PERMISSION)), + player -> _coreClientManager.Get(player).hasPermission(TrackManager.Perm.LEADER), new TrackFormat(ChatColor.DARK_RED, ChatColor.RED) )); } 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 ff5f732f4..20d123ee7 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.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.getPermissionManager().hasPermission(player, GroupPermission.of(TrackManager.TABLE_FLIP_PERMISSION)), + player -> _coreClientManager.Get(player).hasPermission(TrackManager.Perm.TABLE_FLIP), new TrackFormat(ChatColor.AQUA, ChatColor.AQUA) .animated(5, "(\\°-°)\\ ┬┬", 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 b177ffade..890e684a2 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,15 +1,15 @@ package mineplex.core.titles.tracks.staff; +import net.md_5.bungee.api.ChatColor; + import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -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; public class BuilderTrack extends ItemizedTrack { @@ -30,6 +30,6 @@ public class BuilderTrack extends ItemizedTrack @Override public boolean owns(Player player) { - return _clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TrackManager.BUILDER_PERMISSION)); + return _clientManager.Get(player).hasPermission(TrackManager.Perm.BUILDER); } } \ 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 f26f55afa..4e365a10f 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,15 +1,15 @@ package mineplex.core.titles.tracks.staff; +import net.md_5.bungee.api.ChatColor; + import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -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; public class ModeratorTrack extends ItemizedTrack { @@ -30,6 +30,6 @@ public class ModeratorTrack extends ItemizedTrack @Override public boolean owns(Player player) { - return _clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TrackManager.MOD_PERMISSION)); + return _clientManager.Get(player).hasPermission(TrackManager.Perm.MOD); } } \ 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 51ceef55f..2fc610c0a 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,15 +1,15 @@ package mineplex.core.titles.tracks.staff; +import net.md_5.bungee.api.ChatColor; + import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -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; public class SeniorModeratorTrack extends ItemizedTrack { @@ -30,6 +30,6 @@ public class SeniorModeratorTrack extends ItemizedTrack @Override public boolean owns(Player player) { - return _clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TrackManager.SR_MOD_PERMISSION)); + return _clientManager.Get(player).hasPermission(TrackManager.Perm.SR_MOD); } } \ 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 7dc87b46a..402bd665c 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,15 +1,15 @@ package mineplex.core.titles.tracks.staff; +import net.md_5.bungee.api.ChatColor; + import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -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; public class TraineeTrack extends ItemizedTrack { @@ -30,6 +30,6 @@ public class TraineeTrack extends ItemizedTrack @Override public boolean owns(Player player) { - return _clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(TrackManager.TRAINEE_PERMISSION)); + return _clientManager.Get(player).hasPermission(TrackManager.Perm.TRAINEE); } } \ 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 65338a99c..cccdbb440 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/tournament/DebugShopCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/tournament/DebugShopCommand.java @@ -8,7 +8,7 @@ public class DebugShopCommand extends CommandBase { public DebugShopCommand(TournamentManager plugin) { - super(plugin, TournamentManager.DEBUG_SHOP_COMMAND_PERMISSION, "ots"); + super(plugin, TournamentManager.Perm.DEBUG_SHOP_COMMAND, "ots"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java b/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java index 0726a6dce..8fa2b7e46 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/tournament/TournamentManager.java @@ -10,9 +10,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.donation.DonationManager; import mineplex.core.recharge.Recharge; @@ -25,8 +24,11 @@ import mineplex.core.tournament.ui.TournamentShop; public class TournamentManager extends MiniDbClientPlugin { - public static final String DEBUG_SHOP_COMMAND_PERMISSION = "mineplex.core.tournament.debugshop"; - + public enum Perm implements Permission + { + DEBUG_SHOP_COMMAND, + } + private TournamentRepository _repository; private TournamentShop _shop; private HashSet _tournaments = new HashSet<>(); @@ -45,9 +47,8 @@ public class TournamentManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(DEBUG_SHOP_COMMAND_PERMISSION), true, true); + + PermissionGroup.PLAYER.setPermission(Perm.DEBUG_SHOP_COMMAND, true, true); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java b/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java index 056d205ee..91e86f390 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java @@ -33,9 +33,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandBase; import mineplex.core.common.util.BukkitFuture; import mineplex.core.common.util.C; @@ -49,9 +48,12 @@ 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"; - + public enum Perm implements Permission + { + USE_2FA, + RESET_2FA, + } + private final Map setupData = new HashMap<>(); private final Set authenticating = new HashSet<>(); @@ -76,27 +78,25 @@ public class TwoFactorAuth extends MiniClientPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(USE_2FA_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RESET_2FA_PERMISSION), true, true); + + PermissionGroup.BUILDER.setPermission(Perm.USE_2FA, true, true); + PermissionGroup.ADMIN.setPermission(Perm.RESET_2FA, true, true); } @Override public void addCommands() { - addCommand(new CommandBase(this, USE_2FA_PERMISSION, "2fa", "tfa") + addCommand(new CommandBase(this, Perm.USE_2FA, "2fa", "tfa") { @Override public void Execute(Player caller, String[] args) { if (args.length < 1 || !args[0].toLowerCase().equals("reset")) { - if (_clientManager.getPermissionManager().hasPermission(caller, GroupPermission.of(RESET_2FA_PERMISSION))) + if (_clientManager.Get(caller).hasPermission(Perm.RESET_2FA)) { caller.sendMessage(F.main("2FA", "Usage: /2fa reset [player]")); - } - else + } else { caller.sendMessage(F.main("2FA", "Usage: /2fa reset")); } @@ -126,7 +126,7 @@ public class TwoFactorAuth extends MiniClientPlugin return; } - if (!_clientManager.getPermissionManager().hasPermission(caller, GroupPermission.of(RESET_2FA_PERMISSION))) + if (!_clientManager.Get(caller).hasPermission(Perm.RESET_2FA)) { UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that."); return; @@ -224,7 +224,7 @@ public class TwoFactorAuth extends MiniClientPlugin else { // 2FA not set up yet. - if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(USE_2FA_PERMISSION))) + if (_clientManager.Get(player).hasPermission(Perm.USE_2FA)) { runSync(() -> setup2FA(event.getPlayer())); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java index 502a978e9..90b9c8919 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java @@ -16,12 +16,9 @@ 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.Permission; 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.NautHashMap; @@ -38,9 +35,12 @@ 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"; - + public enum Perm implements Permission + { + RESTART_COMMAND, + BVERSION_COMMAND, + } + private Portal _portal; private NautHashMap _jarMd5Map = new NautHashMap(); @@ -77,11 +77,10 @@ public class FileUpdater extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(BVERSION_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RESTART_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.QAM, GroupPermission.of(RESTART_COMMAND_PERMISSION), false, true); + + PermissionGroup.MOD.setPermission(Perm.BVERSION_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.RESTART_COMMAND, true, true); + PermissionGroup.QAM.setPermission(Perm.RESTART_COMMAND, false, true); } @Override 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 ab36c62ed..cf64a45d4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/command/BuildVersionCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/command/BuildVersionCommand.java @@ -12,7 +12,7 @@ public class BuildVersionCommand extends CommandBase { public BuildVersionCommand(FileUpdater plugin) { - super(plugin, FileUpdater.BVERSION_COMMAND_PERMISSION, "bversion"); + super(plugin, FileUpdater.Perm.BVERSION_COMMAND, "bversion"); } @Override 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 4bd7da7d1..afe1072c1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/command/RestartServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/command/RestartServerCommand.java @@ -15,7 +15,7 @@ public class RestartServerCommand extends CommandBase { public RestartServerCommand(FileUpdater plugin) { - super(plugin, FileUpdater.RESTART_COMMAND_PERMISSION, "restart"); + super(plugin, FileUpdater.Perm.RESTART_COMMAND, "restart"); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/website/LinkCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/website/LinkCommand.java index 3051f57f0..c474f56a9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/website/LinkCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/LinkCommand.java @@ -10,7 +10,7 @@ public class LinkCommand extends CommandBase { public LinkCommand(WebsiteLinkManager plugin) { - super(plugin, WebsiteLinkManager.LINK_COMMAND_PERMISSION, "link"); + super(plugin, WebsiteLinkManager.Perm.LINK_COMMAND, "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 0245ce421..24dc7bcd8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/website/UnlinkCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/UnlinkCommand.java @@ -8,7 +8,7 @@ public class UnlinkCommand extends CommandBase { public UnlinkCommand(WebsiteLinkManager plugin) { - super(plugin, WebsiteLinkManager.UNLINK_COMMAND_PERMISSION, "unlink"); + super(plugin, WebsiteLinkManager.Perm.UNLINK_COMMAND, "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 930a2c46d..e78a3b557 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java @@ -41,9 +41,8 @@ import mineplex.core.account.CoreClientManager; 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.Permission; 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.common.util.UtilServer; @@ -54,9 +53,12 @@ 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"; - + public enum Perm implements Permission + { + LINK_COMMAND, + UNLINK_COMMAND, + } + 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"; @@ -77,10 +79,9 @@ public class WebsiteLinkManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(LINK_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(UNLINK_COMMAND_PERMISSION), true, true); + + PermissionGroup.PLAYER.setPermission(Perm.LINK_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.UNLINK_COMMAND, true, true); } public void unlink(Player sender, String target) diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java index ead50bbe4..ed83d08e7 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java @@ -14,6 +14,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.PermissionGroupHelper; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.Callback; import mineplex.core.donation.DonationManager; @@ -150,7 +151,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor return false; } - PermissionGroup c = PermissionGroup.getGroup(args[2]).orElse(_clientManager.getPermissionManager().getGroupFromLegacy(args[2])); + PermissionGroup c = PermissionGroup.getGroup(args[2]).orElse(PermissionGroupHelper.getGroupFromLegacy(args[2])); if (c == null) { return false; @@ -159,7 +160,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor _clientManager.loadClientByName(name, loadedClient -> { - if (rank == PermissionGroup.PLAYER || loadedClient.getPrimaryGroup() == PermissionGroup.PLAYER || !_clientManager.getPermissionManager().inheritsFully(loadedClient.getPrimaryGroup(), rank) || loadedClient.getPrimaryGroup().equals(rank)) + if (rank == PermissionGroup.PLAYER || loadedClient.getPrimaryGroup() == PermissionGroup.PLAYER || !loadedClient.getPrimaryGroup().inheritsFrom(rank)) { _clientManager.setPrimaryGroup(client.getAccountId(), rank, () -> _purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), rank.name() + "Permanent", 1, true)); 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 3fe3f2b1f..2a180e79a 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,11 +27,8 @@ 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.Permission; 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; @@ -72,8 +69,11 @@ 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"; - + public enum Perm implements Permission + { + COMPENSATION_COMMAND, + } + private final List _compensating = new ArrayList<>(); private boolean _debug; @@ -82,10 +82,7 @@ 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(PermissionGroup.PLAYER, GroupPermission.of(COMPENSATION_COMMAND_PERMISSION), true, true); - } + PermissionGroup.PLAYER.setPermission(Perm.COMPENSATION_COMMAND, 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 019daf5c5..831f24afb 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 @@ -2,6 +2,12 @@ package mineplex.game.clans.compensation; import java.util.Random; +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 net.md_5.bungee.api.chat.TextComponent; + import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; @@ -9,11 +15,6 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.ClansManager; -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 net.md_5.bungee.api.chat.TextComponent; public class CompensationCommand extends CommandBase { @@ -22,7 +23,7 @@ public class CompensationCommand extends CommandBase public CompensationCommand(ClansManager plugin, ClansCompensation main) { - super(plugin, ClansCompensation.COMPENSATION_COMMAND_PERMISSION, "compensation"); + super(plugin, ClansCompensation.Perm.COMPENSATION_COMMAND, "compensation"); _main = main; char[] characters = "abcdefghijklmnopqrstuvwxyz".toCharArray(); 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 9aea90546..cdc25cdf0 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 @@ -6,9 +6,8 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; 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; @@ -24,8 +23,11 @@ import mineplex.game.clans.core.war.ClanWarData; public class ClansAdmin { - public static final String USE_ADMIN_COMMANDS_PERMISSION = "mineplex.clans.management.command"; - + public enum Perm implements Permission + { + USE_ADMIN_COMMANDS, + } + private ClansManager Clans; public ClansAdmin(ClansManager clans) @@ -37,14 +39,13 @@ public class ClansAdmin private void generatePermissions() { - PermissionManager pm = Clans.getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(USE_ADMIN_COMMANDS_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.USE_ADMIN_COMMANDS, true, true); } public void command(Player caller, String[] args) { - if (!Clans.getClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(USE_ADMIN_COMMANDS_PERMISSION)) && !caller.isOp()) + if (!Clans.getClientManager().Get(caller).hasPermission(Perm.USE_ADMIN_COMMANDS) && !caller.isOp()) { UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that."); return; 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 658a31cf5..e3171d54c 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,9 +44,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestoreData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -72,8 +71,11 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class ClansGame extends MiniPlugin { - public static final String DUPE_ALERT_PERMISSION = "mineplex.clans.game.dupealert"; - + public enum Perm implements Permission + { + DUPE_ALERT, + } + private static final int CLICKS_TO_OPEN_TRAPPED = 10; private ClansManager _clans; @@ -88,9 +90,8 @@ public class ClansGame extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clans.getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(DUPE_ALERT_PERMISSION), true, true); + + PermissionGroup.TRAINEE.setPermission(Perm.DUPE_ALERT, true, true); } private void setupSafes() @@ -175,7 +176,7 @@ public class ClansGame extends MiniPlugin event.setCancelled(true); for (Player p : Bukkit.getOnlinePlayers()) { - if (ClansManager.getInstance().getClientManager().getPermissionManager().hasPermission(p, GroupPermission.of(DUPE_ALERT_PERMISSION))) + if (ClansManager.getInstance().getClientManager().Get(p).hasPermission(Perm.DUPE_ALERT)) { 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 bff71b1c7..24963f615 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,9 +42,8 @@ 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.Permission; 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.chat.Chat; @@ -160,17 +159,20 @@ import mineplex.serverdata.commands.ServerCommandManager; 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 enum Perm implements Permission + { + ALLY_CHAT_COMMAND, + CLAN_CHAT_COMMAND, + CLANS_COMMAND, + SUICIDE_COMMAND, + MAP_COMMAND, + REGION_CLEAR_COMMAND, + SPEED_COMMAND, + FORCE_JOIN_COMMAND, + AUTO_OP, + PREFIX_SHOWN, + JOIN_FULL, + } public static final int CLAIMABLE_RADIUS = 800; public static final int WORLD_RADIUS = 1200; @@ -494,29 +496,28 @@ public class ClansManager extends MiniClientPlugin implements IRelat private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.revokePermission(PermissionGroup.MOD, GroupPermission.of(Teleport.TELEPORT_COMMAND_PERMISSION), true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(Teleport.TELEPORT_COMMAND_PERMISSION), true, true); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(CLANS_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(ALLY_CHAT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(CLAN_CHAT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(MAP_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(SUICIDE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(REGION_CLEAR_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(SPEED_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SPEED_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FORCE_JOIN_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(AUTO_OP_PERMISSION), true, true); + + PermissionGroup.MOD.revokePermission(Teleport.Perm.TELEPORT_COMMAND); + PermissionGroup.ADMIN.setPermission(Teleport.Perm.TELEPORT_COMMAND, true, true); + + PermissionGroup.PLAYER.setPermission(Perm.CLANS_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.ALLY_CHAT_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.CLAN_CHAT_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.MAP_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.SUICIDE_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.REGION_CLEAR_COMMAND, true, true); + PermissionGroup.CMOD.setPermission(Perm.SPEED_COMMAND, false, true); + PermissionGroup.ADMIN.setPermission(Perm.SPEED_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.FORCE_JOIN_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.AUTO_OP, true, true); if (UtilServer.isTestServer()) { - pm.setPermission(PermissionGroup.QAM, GroupPermission.of(AUTO_OP_PERMISSION), false, true); + PermissionGroup.QAM.setPermission(Perm.AUTO_OP, false, true); } - pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(PREFIX_SHOWN_PERMISSION), true, true); - pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); - pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(PREFIX_SHOWN_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + PermissionGroup.CONTENT.setPermission(Perm.PREFIX_SHOWN, true, true); + PermissionGroup.CONTENT.setPermission(Perm.JOIN_FULL, true, true); + PermissionGroup.BUILDER.setPermission(Perm.PREFIX_SHOWN, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.JOIN_FULL, true, true); } @Override @@ -820,8 +821,8 @@ public class ClansManager extends MiniClientPlugin implements IRelat { clanInfo.playerOnline(player); } - - if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(AUTO_OP_PERMISSION))) + + if (_clientManager.Get(player).hasPermission(Perm.AUTO_OP)) { player.setOp(true); } @@ -1015,7 +1016,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat String rank = _clientManager.Get(event.getPlayer()).getPrimaryGroup().getDisplay(true, true, true, false) + " "; - if (!_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(PREFIX_SHOWN_PERMISSION))) + if (!_clientManager.Get(event.getPlayer()).hasPermission(Perm.PREFIX_SHOWN)) { rank = ""; } @@ -1069,7 +1070,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat { String rank = _clientManager.Get(caller).getPrimaryGroup().getDisplay(true, true, true, false) + " "; - if (!_clientManager.getPermissionManager().hasPermission(caller, GroupPermission.of(PREFIX_SHOWN_PERMISSION))) + if (!_clientManager.Get(caller).hasPermission(Perm.PREFIX_SHOWN)) { rank = ""; } @@ -1081,7 +1082,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat { String rank = _clientManager.Get(caller).getPrimaryGroup().getDisplay(true, true, true, false) + " "; - if (!_clientManager.getPermissionManager().hasPermission(caller, GroupPermission.of(PREFIX_SHOWN_PERMISSION))) + if (!_clientManager.Get(caller).hasPermission(Perm.PREFIX_SHOWN)) { rank = ""; } @@ -1306,7 +1307,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat for (Player player : UtilServer.getPlayers()) { - if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(JOIN_FULL_PERMISSION))) + if (_clientManager.Get(player).hasPermission(Perm.JOIN_FULL)) { continue; } @@ -1314,7 +1315,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat online++; } - if (online >= UtilServer.getServer().getMaxPlayers() && !_clientManager.getPermissionManager().hasPermission(_clientManager.Get(event.getPlayer()), GroupPermission.of(JOIN_FULL_PERMISSION)) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp()) + if (online >= UtilServer.getServer().getMaxPlayers() && !_clientManager.Get(event.getPlayer()).hasPermission(Perm.JOIN_FULL) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp()) { event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This Clans server is full! Try again soon"); } 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 08a65a809..b5e14d211 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 @@ -11,7 +11,7 @@ public class AmplifierCommand extends CommandBase { public AmplifierCommand(AmplifierManager plugin) { - super(plugin, AmplifierManager.AMPLIFIER_COMMAND_PERMISSION, "amplifier", "runeamplifier"); + super(plugin, AmplifierManager.Perm.AMPLIFIER_COMMAND, "amplifier", "runeamplifier"); } @Override 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 7774e6277..1f0bf8ee9 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 @@ -7,9 +7,8 @@ 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.Permission; 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; @@ -25,8 +24,11 @@ import mineplex.game.clans.clans.ClansManager; */ public class AmplifierManager extends MiniPlugin { - public static final String AMPLIFIER_COMMAND_PERMISSION = "mineplex.clans.amplifier.command"; - + public enum Perm implements Permission + { + AMPLIFIER_COMMAND, + } + public static final double AMPLIFIER_RUNE_DROP_MULTIPLIER = 2; private static final String AMPLIFIER_NAME = "Rune Amplifier"; private Amplifier _active; @@ -42,9 +44,7 @@ public class AmplifierManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(AMPLIFIER_COMMAND_PERMISSION), true, true); + PermissionGroup.PLAYER.setPermission(Perm.AMPLIFIER_COMMAND, 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 794a5e2da..c1920a2a2 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 @@ -26,9 +26,8 @@ import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilPlayer; @@ -43,9 +42,12 @@ import mineplex.game.clans.core.repository.ClanTerritory; */ 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 enum Perm implements Permission + { + BANNER_COMMAND, + 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; @@ -63,10 +65,8 @@ public class BannerManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(BANNER_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BANNER_ACCESS_PERMISSION), true, true); + PermissionGroup.PLAYER.setPermission(Perm.BANNER_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.BANNER_ACCESS, true, true); } /** @@ -85,7 +85,7 @@ public class BannerManager extends MiniPlugin { level = 2; } - if (ClansManager.getInstance().getClientManager().getPermissionManager().hasPermission(player, GroupPermission.of(BANNER_ACCESS_PERMISSION))) + if (ClansManager.getInstance().getClientManager().Get(player).hasPermission(Perm.BANNER_ACCESS)) { 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 05ff02e3e..10c117726 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 @@ -23,7 +23,7 @@ public class BannerCommand extends CommandBase { public BannerCommand(BannerManager plugin) { - super(plugin, BannerManager.BANNER_COMMAND_PERMISSION, "banner"); + super(plugin, BannerManager.Perm.BANNER_COMMAND, "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 09e09b6fa..daa2f3a52 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,20 +17,21 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandBase; 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"; - + public enum Perm implements Permission + { + BOX_COMMAND, + } + private BuilderBoxInventory _builderBox; public BoxManager(JavaPlugin plugin) @@ -41,7 +42,7 @@ public class BoxManager extends MiniPlugin _builderBox = new BuilderBoxInventory(); - addCommand(new CommandBase(this, BOX_COMMAND_PERMISSION, "boxes", "box") + addCommand(new CommandBase(this, Perm.BOX_COMMAND, "boxes", "box") { @Override public void Execute(Player caller, String[] args) @@ -55,9 +56,7 @@ public class BoxManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(BOX_COMMAND_PERMISSION), true, true); + PermissionGroup.PLAYER.setPermission(Perm.BOX_COMMAND, 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 88277b07c..8f347b8a6 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 @@ -18,9 +18,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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilBlock; @@ -42,8 +41,11 @@ import mineplex.game.clans.core.ClaimLocation; public class ClaimVisualizer extends MiniPlugin { - public static final String VISUALIZE_COMMAND_PERMISSION = "mineplex.clans.visualize.command"; - + public enum Perm implements Permission + { + VISUALIZE_COMMAND, + } + private ClansManager _clansManager; private List _visualizing; @@ -68,9 +70,8 @@ public class ClaimVisualizer extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(VISUALIZE_COMMAND_PERMISSION), true, true); + + PermissionGroup.PLAYER.setPermission(Perm.VISUALIZE_COMMAND, 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 b467fe504..15d60a154 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 @@ -9,7 +9,7 @@ public class ClaimVisualizeCommand extends CommandBase { public ClaimVisualizeCommand(ClaimVisualizer plugin) { - super(plugin, ClaimVisualizer.VISUALIZE_COMMAND_PERMISSION, "showclaims"); + super(plugin, ClaimVisualizer.Perm.VISUALIZE_COMMAND, "showclaims"); } @Override 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 ab714ccb6..e0cf31910 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 @@ -15,7 +15,7 @@ public class ClansAllyChatCommand extends CommandBase { public ClansAllyChatCommand(ClansManager plugin) { - super(plugin, ClansManager.ALLY_CHAT_COMMAND_PERMISSION, "ac"); + super(plugin, ClansManager.Perm.ALLY_CHAT_COMMAND, "ac"); } @Override 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 67eade7d6..29b3e5e82 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 @@ -15,7 +15,7 @@ public class ClansChatCommand extends CommandBase { public ClansChatCommand(ClansManager plugin) { - super(plugin, ClansManager.CLAN_CHAT_COMMAND_PERMISSION, "cc", "fc"); + super(plugin, ClansManager.Perm.CLAN_CHAT_COMMAND, "cc", "fc"); } @Override 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 76940f62a..aa15b6381 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 @@ -3,6 +3,8 @@ 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; @@ -13,7 +15,6 @@ 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.util.C; import mineplex.core.common.util.Callback; @@ -41,7 +42,6 @@ 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 { @@ -49,7 +49,7 @@ public class ClansCommand extends CommandBase public ClansCommand(ClansManager plugin) { - super(plugin, ClansManager.CLANS_COMMAND_PERMISSION, "c", "clan", "clans", "factions"); + super(plugin, ClansManager.Perm.CLANS_COMMAND, "c", "clan", "clans", "factions"); _clansManager = plugin; } @@ -148,7 +148,7 @@ public class ClansCommand extends CommandBase return; } - if (!Plugin.getClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(ClansManager.FORCE_JOIN_COMMAND_PERMISSION))) + if (!Plugin.getClientManager().Get(caller).hasPermission(ClansManager.Perm.FORCE_JOIN_COMMAND)) { UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that."); return; 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 7df4c360f..47bb1f9b4 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 @@ -14,7 +14,7 @@ public class KillCommand extends CommandBase { public KillCommand(ClansManager plugin) { - super(plugin, ClansManager.SUICIDE_COMMAND_PERMISSION, "suicide", "kill"); + super(plugin, ClansManager.Perm.SUICIDE_COMMAND, "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 3233e9229..a724dd133 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 @@ -9,7 +9,7 @@ public class MapCommand extends CommandBase { public MapCommand(ClansManager plugin) { - super(plugin, ClansManager.MAP_COMMAND_PERMISSION, "map", "clansmap"); + super(plugin, ClansManager.Perm.MAP_COMMAND, "map", "clansmap"); } @Override 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 4b7d33669..4b3bc2a43 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 @@ -13,7 +13,7 @@ public class RegionsCommand extends CommandBase public RegionsCommand(ClansManager plugin) { - super(plugin, ClansManager.REGION_CLEAR_COMMAND_PERMISSION, "region-reset"); + super(plugin, ClansManager.Perm.REGION_CLEAR_COMMAND, "region-reset"); _manager = plugin; } 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 8b6121148..4962db005 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 @@ -13,7 +13,7 @@ public class SpeedCommand extends CommandBase { public SpeedCommand(ClansManager plugin) { - super(plugin, ClansManager.SPEED_COMMAND_PERMISSION, "speed"); + super(plugin, ClansManager.Perm.SPEED_COMMAND, "speed"); } @Override 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 ebf95ab6e..4f91363ad 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,9 +20,8 @@ import org.bukkit.potion.PotionEffectType; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; 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.UtilMath; @@ -39,10 +38,13 @@ 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"; - + public enum Perm implements Permission + { + FREEZE_COMMAND, + UNFREEZE_COMMAND, + NOTIFY, + } + private static final long FREEZE_MESSAGE_INTERVAL = 10000; private final CoreClientManager _clientManager; private final Map _frozen = new HashMap<>(); @@ -58,17 +60,16 @@ public class ClansFreezeManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(FREEZE_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.CMA, GroupPermission.of(FREEZE_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FREEZE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(UNFREEZE_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.CMA, GroupPermission.of(UNFREEZE_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(UNFREEZE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(NOTIFY_PERMISSION), false, true); - pm.setPermission(PermissionGroup.CMA, GroupPermission.of(NOTIFY_PERMISSION), false, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(NOTIFY_PERMISSION), true, true); + + PermissionGroup.CMOD.setPermission(Perm.FREEZE_COMMAND, false, true); + PermissionGroup.CMA.setPermission(Perm.FREEZE_COMMAND, false, true); + PermissionGroup.ADMIN.setPermission(Perm.FREEZE_COMMAND, true, true); + PermissionGroup.CMOD.setPermission(Perm.UNFREEZE_COMMAND, false, true); + PermissionGroup.CMA.setPermission(Perm.UNFREEZE_COMMAND, false, true); + PermissionGroup.ADMIN.setPermission(Perm.UNFREEZE_COMMAND, true, true); + PermissionGroup.CMOD.setPermission(Perm.NOTIFY, false, true); + PermissionGroup.CMA.setPermission(Perm.NOTIFY, false, true); + PermissionGroup.ADMIN.setPermission(Perm.NOTIFY, true, true); } @Override @@ -88,7 +89,7 @@ public class ClansFreezeManager extends MiniPlugin event.getPlayer().removePotionEffect(PotionEffectType.JUMP); for (Player staff : UtilServer.GetPlayers()) { - if (_clientManager.getPermissionManager().hasPermission(staff, GroupPermission.of(NOTIFY_PERMISSION))) + if (_clientManager.Get(staff).hasPermission(Perm.NOTIFY)) { UtilPlayer.message(staff, F.main(getName(), F.elem(event.getPlayer().getName()) + " has logged out while frozen!")); } @@ -237,7 +238,7 @@ public class ClansFreezeManager extends MiniPlugin player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999, -10)); for (Player alert : UtilServer.GetPlayers()) { - if (_clientManager.getPermissionManager().hasPermission(alert, GroupPermission.of(NOTIFY_PERMISSION))) + if (_clientManager.Get(alert).hasPermission(Perm.NOTIFY)) { UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been frozen by " + F.elem(staff.getName()) + "!")); } @@ -258,7 +259,7 @@ public class ClansFreezeManager extends MiniPlugin player.removePotionEffect(PotionEffectType.JUMP); for (Player alert : UtilServer.GetPlayers()) { - if (_clientManager.getPermissionManager().hasPermission(alert, GroupPermission.of(NOTIFY_PERMISSION))) + if (_clientManager.Get(alert).hasPermission(Perm.NOTIFY)) { 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 a55e9ed6b..bc5f75d1e 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 @@ -15,7 +15,7 @@ public class FreezeCommand extends CommandBase { public FreezeCommand(ClansFreezeManager plugin) { - super(plugin, ClansFreezeManager.FREEZE_COMMAND_PERMISSION, "freeze"); + super(plugin, ClansFreezeManager.Perm.FREEZE_COMMAND, "freeze"); } @Override 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 4d385e5fe..a1de3c010 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 @@ -15,7 +15,7 @@ public class UnfreezeCommand extends CommandBase { public UnfreezeCommand(ClansFreezeManager plugin) { - super(plugin, ClansFreezeManager.UNFREEZE_COMMAND_PERMISSION, "unfreeze"); + super(plugin, ClansFreezeManager.Perm.UNFREEZE_COMMAND, "unfreeze"); } @Override 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 f8ead4820..59fbba87f 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 @@ -8,9 +8,8 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import mineplex.core.MiniPlugin; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -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; @@ -18,8 +17,11 @@ import mineplex.game.clans.clans.invsee.ui.InvseeInventory; public class InvseeManager extends MiniPlugin { - public static final String INVSEE_COMMAND_PERMISSION = "mineplex.clans.invsee.command"; - + public enum Perm implements Permission + { + INVSEE_COMMAND, + } + private final Map _viewing = new HashMap<>(); public InvseeManager(ClansManager manager) @@ -31,10 +33,9 @@ public class InvseeManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(INVSEE_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(INVSEE_COMMAND_PERMISSION), true, true); + + PermissionGroup.CMOD.setPermission(Perm.INVSEE_COMMAND, false, true); + PermissionGroup.ADMIN.setPermission(Perm.INVSEE_COMMAND, true, true); } @Override 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 c85271765..fb2e7d0ce 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 @@ -2,6 +2,10 @@ package mineplex.game.clans.clans.invsee.commands; import java.util.UUID; +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.ChatColor; import org.bukkit.OfflinePlayer; @@ -13,15 +17,12 @@ import mineplex.core.command.CommandBase; 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; public class InvseeCommand extends CommandBase { public InvseeCommand(InvseeManager plugin) { - super(plugin, InvseeManager.INVSEE_COMMAND_PERMISSION, "invsee"); + super(plugin, InvseeManager.Perm.INVSEE_COMMAND, "invsee"); } @Override 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 7ccfa6b68..11cada41b 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,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandBase; import mineplex.core.common.Pair; import mineplex.core.common.util.F; @@ -52,10 +51,13 @@ 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"; - + public enum Perm implements Permission + { + MOUNT_COMMAND, + GIVE_MOUNT_COMMAND, + MOUNT_SKIN_UNLOCK, + } + 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}; @@ -81,7 +83,7 @@ public class MountManager extends MiniDbClientPlugin final MountShop shop = new MountShop(this); - addCommand(new CommandBase(this, MOUNT_COMMAND_PERMISSION, "mounts", "mount") + addCommand(new CommandBase(this, Perm.MOUNT_COMMAND, "mounts", "mount") { @Override public void Execute(Player caller, String[] args) @@ -90,7 +92,7 @@ public class MountManager extends MiniDbClientPlugin } }); - addCommand(new CommandBase(this, GIVE_MOUNT_COMMAND_PERMISSION, "givemount") + addCommand(new CommandBase(this, Perm.GIVE_MOUNT_COMMAND, "givemount") { @Override public void Execute(Player caller, String[] args) @@ -155,11 +157,10 @@ public class MountManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(MOUNT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_MOUNT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(MOUNT_SKIN_UNLOCK_PERMISSION), true, true); + + PermissionGroup.PLAYER.setPermission(Perm.MOUNT_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.GIVE_MOUNT_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.MOUNT_SKIN_UNLOCK, 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 4ff28d999..ffddfd313 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,6 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -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 +46,7 @@ public class MountSkinPage extends ShopPageBase private boolean hasUnlocked(Player player, SkinType type) { - if (getClientManager().getPermissionManager().hasPermission(player, GroupPermission.of(MountManager.MOUNT_SKIN_UNLOCK_PERMISSION))) + if (getClientManager().Get(player).hasPermission(MountManager.Perm.MOUNT_SKIN_UNLOCK)) { 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 92c984ab0..72fad982b 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,19 +6,20 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -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"; - + public enum Perm implements Permission + { + BLACKLIST_COMMAND, + } + private List _blacklist; private ClanNameBlacklistRepository _repository; @@ -35,10 +36,9 @@ public class ClansBlacklist extends MiniPlugin private void generatePermissions() { - PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(BLACKLIST_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BLACKLIST_COMMAND_PERMISSION), true, true); + + PermissionGroup.CMOD.setPermission(Perm.BLACKLIST_COMMAND, false, true); + PermissionGroup.ADMIN.setPermission(Perm.BLACKLIST_COMMAND, true, true); } // Fetch new blacklisted clans every 16 seconds (in case someone blacklists a clan name on a different server) 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 8f2cfe840..80db31eab 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 @@ -12,7 +12,7 @@ public class AddBlacklistCommand extends CommandBase { public AddBlacklistCommand(ClansBlacklist plugin) { - super(plugin, ClansBlacklist.BLACKLIST_COMMAND_PERMISSION, "blacklistname"); + super(plugin, ClansBlacklist.Perm.BLACKLIST_COMMAND, "blacklistname"); } @Override 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 78850294e..d155b8642 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,9 +34,8 @@ import org.bukkit.potion.PotionEffectType; import com.google.common.collect.Lists; import mineplex.core.MiniPlugin; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.generator.VoidGenerator; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -63,13 +62,16 @@ 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"; + public enum Perm implements Permission + { + PORTAL_COMMAND, + PORTAL_CLOSE_COMMAND, + PORTAL_CREATE_COMMAND, + PORTAL_DELETE_COMMAND, + PORTAL_FORCE_COMMAND, + PORTAL_LIST_COMMAND, + PORTAL_OPEN_COMMAND, + } 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"; @@ -104,15 +106,14 @@ public class NetherManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PORTAL_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PORTAL_CLOSE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PORTAL_CREATE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PORTAL_DELETE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PORTAL_FORCE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PORTAL_LIST_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(PORTAL_OPEN_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.PORTAL_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.PORTAL_CLOSE_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.PORTAL_CREATE_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.PORTAL_DELETE_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.PORTAL_FORCE_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.PORTAL_LIST_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.PORTAL_OPEN_COMMAND, true, true); } private void begin() @@ -567,7 +568,7 @@ public class NetherManager extends MiniPlugin { return; } - if (!ClansManager.getInstance().getClientManager().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(PORTAL_CREATE_COMMAND_PERMISSION))) + if (!ClansManager.getInstance().getClientManager().Get(event.getPlayer()).hasPermission(Perm.PORTAL_CREATE_COMMAND)) { 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 def457994..f86df3db0 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 @@ -14,7 +14,7 @@ public class CloseCommand extends CommandBase { public CloseCommand(NetherManager plugin) { - super(plugin, NetherManager.PORTAL_CLOSE_COMMAND_PERMISSION, "close"); + super(plugin, NetherManager.Perm.PORTAL_CLOSE_COMMAND, "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 dc94f32b0..41ca33269 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 @@ -14,7 +14,7 @@ public class CreateCommand extends CommandBase { public CreateCommand(NetherManager plugin) { - super(plugin, NetherManager.PORTAL_CREATE_COMMAND_PERMISSION, "create"); + super(plugin, NetherManager.Perm.PORTAL_CREATE_COMMAND, "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 018b2993c..13f1ba346 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 @@ -15,7 +15,7 @@ public class DeleteCommand extends CommandBase { public DeleteCommand(NetherManager plugin) { - super(plugin, NetherManager.PORTAL_DELETE_COMMAND_PERMISSION, "delete", "remove"); + super(plugin, NetherManager.Perm.PORTAL_DELETE_COMMAND, "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 571c4d530..92e0a9726 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 @@ -20,7 +20,7 @@ public class ForceTeleportCommand extends CommandBase { public ForceTeleportCommand(NetherManager plugin) { - super(plugin, NetherManager.PORTAL_FORCE_COMMAND_PERMISSION, "forcePortal"); + super(plugin, NetherManager.Perm.PORTAL_FORCE_COMMAND, "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 c78dc028d..a62bbb124 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 @@ -12,7 +12,7 @@ public class ListCommand extends CommandBase { public ListCommand(NetherManager plugin) { - super(plugin, NetherManager.PORTAL_LIST_COMMAND_PERMISSION, "list"); + super(plugin, NetherManager.Perm.PORTAL_LIST_COMMAND, "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 c99b0b67d..d6b13bf6f 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 @@ -15,7 +15,7 @@ public class PortalCommand extends MultiCommandBase { public PortalCommand(NetherManager plugin) { - super(plugin, NetherManager.PORTAL_COMMAND_PERMISSION, "netherportal", "portal"); + super(plugin, NetherManager.Perm.PORTAL_COMMAND, "netherportal", "portal"); AddCommand(new CreateCommand(plugin)); AddCommand(new DeleteCommand(plugin)); 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 e75b00831..bc5db8bac 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 @@ -14,7 +14,7 @@ public class SpawnCommand extends CommandBase { public SpawnCommand(NetherManager plugin) { - super(plugin, NetherManager.PORTAL_OPEN_COMMAND_PERMISSION, "spawn"); + super(plugin, NetherManager.Perm.PORTAL_OPEN_COMMAND, "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 f9f01facf..537e25b63 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 @@ -12,7 +12,7 @@ public class WandCommand extends CommandBase { public WandCommand(NetherManager plugin) { - super(plugin, NetherManager.PORTAL_CREATE_COMMAND_PERMISSION, "wand"); + super(plugin, NetherManager.Perm.PORTAL_CREATE_COMMAND, "wand"); } @Override 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 159bb7d3c..444e10a34 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,9 +19,8 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; 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.game.clans.clans.ClansManager; @@ -30,8 +29,11 @@ import mineplex.minecraft.game.core.condition.ConditionManager; public class ObserverManager extends MiniPlugin { - public static final String OBSERVE_COMMAND_PERMISSION = "mineplex.clans.observe.command"; - + public enum Perm implements Permission + { + OBSERVE_COMMAND, + } + // Used to Cloak Players private ConditionManager _conditionManager; private ClansManager _clansManager; @@ -50,9 +52,7 @@ public class ObserverManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(OBSERVE_COMMAND_PERMISSION), false, true); + PermissionGroup.TRAINEE.setPermission(Perm.OBSERVE_COMMAND, false, true); } public void setObserver(Player player) 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 1d9a3a9e9..ed9e13fc3 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 @@ -11,7 +11,7 @@ public class ObserverCommand extends CommandBase { public ObserverCommand(ObserverManager plugin) { - super(plugin, ObserverManager.OBSERVE_COMMAND_PERMISSION, "observer", "o"); + super(plugin, ObserverManager.Perm.OBSERVE_COMMAND, "observer", "o"); } @Override 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 86cea47d7..544193db5 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 @@ -10,9 +10,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.stats.StatsManager; import mineplex.core.task.TaskManager; import mineplex.game.clans.clans.ClansManager; @@ -21,8 +20,11 @@ import mineplex.game.clans.clans.playtime.command.PlayTimeCommand; public class Playtime extends MiniClientPlugin { - public static final String CLANS_TIME_COMMAND_PERMISSION = "mineplex.clans.playtime.command"; - + public enum Perm implements Permission + { + CLANS_TIME_COMMAND, + } + private StatsManager _statsManager; public Playtime(ClansManager clans, StatsManager statsManager) @@ -38,9 +40,8 @@ public class Playtime extends MiniClientPlugin private void generatePermissions() { - PermissionManager pm = _statsManager.getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(CLANS_TIME_COMMAND_PERMISSION), true, true); + + PermissionGroup.MOD.setPermission(Perm.CLANS_TIME_COMMAND, true, true); } @Override 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 29ae7f027..0e121a688 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 @@ -16,7 +16,7 @@ public class PlayTimeCommand extends CommandBase public PlayTimeCommand(StatsManager plugin, Playtime tracker) { - super(plugin, Playtime.CLANS_TIME_COMMAND_PERMISSION, "clanstime"); + super(plugin, Playtime.Perm.CLANS_TIME_COMMAND, "clanstime"); _playTracker = tracker; } 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 de999075a..792f96cc2 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 @@ -15,9 +15,8 @@ import org.bukkit.event.block.BlockPlaceEvent; import com.google.gson.Gson; import mineplex.core.MiniPlugin; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilInv; @@ -41,8 +40,11 @@ import mineplex.game.clans.spawn.Spawn; public class SiegeManager extends MiniPlugin { - public static final String GIVE_CANNON_COMMAND_PERMISSION = "mineplex.clans.siege.givecannon"; - + public enum Perm implements Permission + { + GIVE_CANNON_COMMAND, + } + private ClansManager _clansManager; private OutpostManager _outpostManager; @@ -100,9 +102,8 @@ public class SiegeManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_CANNON_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.GIVE_CANNON_COMMAND, 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 8544c2a6d..98e58fdc9 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 @@ -13,7 +13,7 @@ public class GiveWeaponCommand extends CommandBase { public GiveWeaponCommand(SiegeManager plugin) { - super(plugin, SiegeManager.GIVE_CANNON_COMMAND_PERMISSION, "giveweapon", "siegeweapon", "givecannon"); + super(plugin, SiegeManager.Perm.GIVE_CANNON_COMMAND, "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 9814e04c7..a864ffaf1 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,6 @@ import org.bukkit.util.Vector; import com.google.common.collect.Lists; -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 +284,7 @@ public class Cannon extends SiegeWeapon event.setCancelled(true); for (Player p : Bukkit.getOnlinePlayers()) { - if (ClansManager.getInstance().getClientManager().getPermissionManager().hasPermission(p, GroupPermission.of(ClansGame.DUPE_ALERT_PERMISSION))) + if (ClansManager.getInstance().getClientManager().Get(p).hasPermission(ClansGame.Perm.DUPE_ALERT)) { 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 4896b68f5..86599c074 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 @@ -16,9 +16,8 @@ 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.Permission; 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; @@ -43,8 +42,11 @@ import mineplex.game.clans.core.war.ClanWarData; public class WarManager extends MiniPlugin implements ScoreboardElement { - public static final String WAR_POINT_COMMAND_PERMISSION = "mineplex.clans.war.command"; - + public enum Perm implements Permission + { + WAR_POINT_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 @@ -70,9 +72,8 @@ public class WarManager extends MiniPlugin implements ScoreboardElement private void generatePermissions() { - PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(WAR_POINT_COMMAND_PERMISSION), true, true); + + PermissionGroup.PLAYER.setPermission(Perm.WAR_POINT_COMMAND, 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 7fa506d3a..f9d6bbdc6 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 @@ -16,7 +16,7 @@ public class WarPointsCommand extends CommandBase { public WarPointsCommand(WarManager plugin) { - super(plugin, WarManager.WAR_POINT_COMMAND_PERMISSION, "warpoints", "wp", "dom"); + super(plugin, WarManager.Perm.WAR_POINT_COMMAND, "warpoints", "wp", "dom"); } @Override 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 e5a0de948..3a2c44f2e 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,9 +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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.common.util.C; @@ -40,10 +39,13 @@ 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"; - + public enum Perm implements Permission + { + WORLD_EVENT_COMMAND, + START_EVENT_COMMAND, + STOP_EVENT_COMMAND, + } + private final List _runningEvents; private Random _random; @@ -86,11 +88,9 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement private void generatePermissions() { - PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(WORLD_EVENT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(START_EVENT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(STOP_EVENT_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.WORLD_EVENT_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.START_EVENT_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.STOP_EVENT_COMMAND, 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 a7d0be727..9a2c19d93 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 @@ -11,7 +11,7 @@ public class ClearCommand extends CommandBase { public ClearCommand(WorldEventManager plugin) { - super(plugin, WorldEventManager.STOP_EVENT_COMMAND_PERMISSION, "clear"); + super(plugin, WorldEventManager.Perm.STOP_EVENT_COMMAND, "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 790d1133d..321a79321 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 @@ -15,7 +15,7 @@ public class RandomCommand extends CommandBase { public RandomCommand(WorldEventManager plugin) { - super(plugin, WorldEventManager.START_EVENT_COMMAND_PERMISSION, "random", "rand"); + super(plugin, WorldEventManager.Perm.START_EVENT_COMMAND, "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 c9b9d4e9f..e1cf0292c 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 @@ -14,7 +14,7 @@ public class StartCommand extends CommandBase { public StartCommand(WorldEventManager plugin) { - super(plugin, WorldEventManager.START_EVENT_COMMAND_PERMISSION, "start", "create"); + super(plugin, WorldEventManager.Perm.START_EVENT_COMMAND, "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 c9b4cbba5..c14a07fe2 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 @@ -12,7 +12,7 @@ public class WorldEventCommand extends MultiCommandBase { public WorldEventCommand(WorldEventManager plugin) { - super(plugin, WorldEventManager.WORLD_EVENT_COMMAND_PERMISSION, "worldevent", "we", "event"); + super(plugin, WorldEventManager.Perm.WORLD_EVENT_COMMAND, "worldevent", "we", "event"); AddCommand(new StartCommand(Plugin)); AddCommand(new ClearCommand(Plugin)); 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 38c7a1988..a1922f007 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,9 +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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -40,8 +39,11 @@ import mineplex.minecraft.game.core.damage.DamageManager; public class RaidManager extends MiniPlugin { - public static final String START_RAID_COMMAND_PERMISSION = "mineplex.clans.raids.startcommand"; - + public enum Perm implements Permission + { + START_RAID_COMMAND, + } + private static final int MAX_PARTICIPANTS = 10; private Set _raids = new HashSet<>(); @@ -65,9 +67,8 @@ public class RaidManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(START_RAID_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.START_RAID_COMMAND, 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 f8f7fe0dc..be755626b 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 @@ -13,7 +13,7 @@ public class StartRaidCommand extends CommandBase { public StartRaidCommand(RaidManager plugin) { - super(plugin, RaidManager.START_RAID_COMMAND_PERMISSION, "startraid"); + super(plugin, RaidManager.Perm.START_RAID_COMMAND, "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 b8ffdc98d..9bb748156 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 @@ -11,7 +11,7 @@ public class GoldCommand extends CommandBase { public GoldCommand(GoldManager plugin) { - super(plugin, GoldManager.GIVE_GOLD_COMMAND_PERMISSION, "givegold"); + super(plugin, GoldManager.Perm.GIVE_GOLD_COMMAND, "givegold"); } @Override 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 38147e024..753f4bac4 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,9 +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.Permission; 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; @@ -47,8 +46,11 @@ 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 enum Perm implements Permission + { + GIVE_GOLD_COMMAND, + SET_GOLD_COMMAND, + } 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 @@ -85,10 +87,9 @@ public class GoldManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_GOLD_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SET_GOLD_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.GIVE_GOLD_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.SET_GOLD_COMMAND, true, true); } @Override 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 d49d0039b..1dce0b575 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 @@ -11,7 +11,7 @@ public class SetGoldCommand extends CommandBase { public SetGoldCommand(GoldManager plugin) { - super(plugin, GoldManager.SET_GOLD_COMMAND_PERMISSION, "setgold"); + super(plugin, GoldManager.Perm.SET_GOLD_COMMAND, "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 d042a1bfc..6974bb078 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 @@ -19,9 +19,8 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -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; @@ -40,8 +39,11 @@ import mineplex.minecraft.game.core.condition.ConditionManager; public class FieldBlock extends MiniPlugin { - public static final String FIELD_BLOCK_COMMAND_PERMISSION = "mineplex.clans.field.block"; - + public enum Perm implements Permission + { + FIELD_BLOCK_COMMAND, + } + private ConditionFactory _conditionFactory; private Energy _energy; private FieldRepository _repository; @@ -79,9 +81,7 @@ public class FieldBlock extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clansManager.getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FIELD_BLOCK_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.FIELD_BLOCK_COMMAND, true, true); } @Override 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 210906ccf..32ac7803b 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 @@ -13,16 +13,14 @@ import org.bukkit.event.HandlerList; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -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; @@ -30,8 +28,11 @@ import mineplex.game.clans.fields.repository.FieldRepository; public class FieldMonster extends MiniPlugin { - public static final String FIELD_MONSTER_COMMAND_PERMISSION = "mineplex.clans.field.monster"; - + public enum Perm implements Permission + { + FIELD_MONSTER_COMMAND, + } + private Creature _creature; private FieldRepository _repository; private Set _pits; @@ -54,9 +55,7 @@ public class FieldMonster extends MiniPlugin private void generatePermissions() { - PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FIELD_MONSTER_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.FIELD_MONSTER_COMMAND, true, true); } @Override 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 4a71f0793..813f6c802 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 @@ -20,9 +20,8 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -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; @@ -33,15 +32,17 @@ 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"; - + public enum Perm implements Permission + { + FIELD_ORE_COMMAND, + } + private FieldRepository _repository; private Set _active = new HashSet(); @@ -68,9 +69,7 @@ public class FieldOre extends MiniPlugin private void generatePermissions() { - PermissionManager pm = ClansManager.getInstance().getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FIELD_ORE_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.FIELD_ORE_COMMAND, true, true); } @Override 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 8d374c75f..67cc167c1 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 @@ -12,7 +12,7 @@ public class FieldBlockCommand extends CommandBase { public FieldBlockCommand(FieldBlock plugin) { - super(plugin, FieldBlock.FIELD_BLOCK_COMMAND_PERMISSION, "fb"); + super(plugin, FieldBlock.Perm.FIELD_BLOCK_COMMAND, "fb"); } @Override 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 e1da01efc..ff8d64575 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 @@ -14,7 +14,7 @@ public class FieldMonsterCommand extends CommandBase { public FieldMonsterCommand(FieldMonster plugin) { - super(plugin, FieldMonster.FIELD_MONSTER_COMMAND_PERMISSION, "fm"); + super(plugin, FieldMonster.Perm.FIELD_MONSTER_COMMAND, "fm"); } @Override 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 752135886..5c78bd478 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 @@ -11,7 +11,7 @@ public class FieldOreCommand extends CommandBase { public FieldOreCommand(FieldOre plugin) { - super(plugin, FieldOre.FIELD_ORE_COMMAND_PERMISSION, "fo"); + super(plugin, FieldOre.Perm.FIELD_ORE_COMMAND, "fo"); } @Override 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 e65f48acf..53d093716 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 @@ -37,9 +37,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; @@ -94,9 +93,12 @@ import mineplex.serverdata.serialization.RuntimeTypeAdapterFactory; */ 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"; - + public enum Perm implements Permission + { + RUNE_COMMAND, + GEAR_COMMAND, + } + private static final String ITEM_SERIALIZATION_TAG = "-JSON-"; private static final Gson GSON; @@ -256,10 +258,9 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RUNE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GEAR_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.RUNE_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.GEAR_COMMAND, 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 85a561c58..fd08528ec 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 @@ -9,7 +9,7 @@ public class GearCommand extends CommandBase { public GearCommand(GearManager plugin) { - super(plugin, GearManager.GEAR_COMMAND_PERMISSION, "gear", "custom-gear"); + super(plugin, GearManager.Perm.GEAR_COMMAND, "gear", "custom-gear"); } @Override 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 a5ebe8538..e5fc48549 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 @@ -20,7 +20,7 @@ public class RuneCommand extends CommandBase public RuneCommand(GearManager plugin) { - super(plugin, GearManager.RUNE_COMMAND_PERMISSION, "rune", "giverune", "getrune"); + super(plugin, GearManager.Perm.RUNE_COMMAND, "rune", "giverune", "getrune"); } @Override 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 5c62376dd..69b3994c8 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 @@ -10,7 +10,7 @@ public class RestartCommand extends CommandBase { public RestartCommand(RestartManager plugin) { - super(plugin, RestartManager.RESTART_COMMAND_PERMISSION, "forceRestart"); + super(plugin, RestartManager.Perm.RESTART_COMMAND, "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 264af47d9..d7d2ac9bb 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 @@ -13,12 +13,9 @@ 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.Permission; 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.UtilServer; @@ -38,8 +35,11 @@ import mineplex.game.clans.gameplay.safelog.npc.NPCManager; public class RestartManager extends MiniPlugin { - public static final String RESTART_COMMAND_PERMISSION = "mineplex.clans.restart.command"; - + public enum Perm implements Permission + { + 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; @@ -82,11 +82,10 @@ public class RestartManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(RESTART_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.QAM, GroupPermission.of(RESTART_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RESTART_COMMAND_PERMISSION), true, true); + + PermissionGroup.CMOD.setPermission(Perm.RESTART_COMMAND, false, true); + PermissionGroup.QAM.setPermission(Perm.RESTART_COMMAND, false, true); + PermissionGroup.ADMIN.setPermission(Perm.RESTART_COMMAND, true, true); } private boolean inRestartZone(int hour) 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 a28d13a39..126ce0bfc 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 @@ -11,9 +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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.chat.Chat; import mineplex.core.chat.FilterPriority; import mineplex.core.common.events.PlayerRecieveBroadcastEvent; @@ -35,10 +34,13 @@ import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial; 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"; - + public enum Perm implements Permission + { + TUTORIAL_COMMAND, + START_TUTORIAL_COMMAND, + FINISH_TUTORIAL_COMMAND, + } + private CoreClientManager _clientManager; private DonationManager _donationManager; private ClansMessageManager _clansMessageManager; @@ -88,25 +90,22 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - + if (UtilServer.isTestServer()) { - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(TUTORIAL_COMMAND_PERMISSION), true, true); - } - else + PermissionGroup.PLAYER.setPermission(Perm.TUTORIAL_COMMAND, true, true); + } else { - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TUTORIAL_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.TUTORIAL_COMMAND, true, true); } if (UtilServer.isTestServer()) { - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(FINISH_TUTORIAL_COMMAND_PERMISSION), true, true); - } - else + PermissionGroup.PLAYER.setPermission(Perm.FINISH_TUTORIAL_COMMAND, true, true); + } else { - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FINISH_TUTORIAL_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.FINISH_TUTORIAL_COMMAND, true, true); } - pm.setPermission(PermissionGroup.DEV, GroupPermission.of(START_TUTORIAL_COMMAND_PERMISSION), true, true); + PermissionGroup.DEV.setPermission(Perm.START_TUTORIAL_COMMAND, true, true); } @EventHandler 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 a8b3a3a52..acb0fcb48 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 @@ -9,7 +9,7 @@ public class FinishCommand extends CommandBase { public FinishCommand(TutorialManager plugin) { - super(plugin, TutorialManager.FINISH_TUTORIAL_COMMAND_PERMISSION, "finish", "end"); + super(plugin, TutorialManager.Perm.FINISH_TUTORIAL_COMMAND, "finish", "end"); } @Override 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 a019dfec3..71ce8c3e0 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 @@ -12,7 +12,7 @@ public class StartCommand extends CommandBase { public StartCommand(TutorialManager plugin) { - super(plugin, TutorialManager.START_TUTORIAL_COMMAND_PERMISSION, "start"); + super(plugin, TutorialManager.Perm.START_TUTORIAL_COMMAND, "start"); } @Override 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 05de8d0dc..06979be37 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 @@ -11,7 +11,7 @@ public class TutorialCommand extends MultiCommandBase { public TutorialCommand(TutorialManager plugin) { - super(plugin, TutorialManager.TUTORIAL_COMMAND_PERMISSION, "tutorial", "tut"); + super(plugin, TutorialManager.Perm.TUTORIAL_COMMAND, "tutorial", "tut"); AddCommand(new StartCommand(plugin)); AddCommand(new FinishCommand(plugin)); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java index 97848929d..3288e0487 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansServerPage.java @@ -7,7 +7,6 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -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 +33,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"; - + public enum Perm implements Permission + { + STAFF_PAGE, + ALLOW_HARDCORE, + JOIN_FULL, + } + private static final long SERVER_RELOAD_INTERVAL = 5000; private PartyManager _party; private Portal _portal; @@ -75,11 +75,9 @@ public class ClansTransferManager extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.TRAINEE, of(STAFF_PAGE_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(ALLOW_HARDCORE_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + PermissionGroup.TRAINEE.setPermission(Perm.STAFF_PAGE, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.ALLOW_HARDCORE, true, true); + PermissionGroup.ULTRA.setPermission(Perm.JOIN_FULL, 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 cfa0be0c5..66b0077d6 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ForcefieldManager.java @@ -10,9 +10,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.MiniPlugin; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; @@ -29,9 +28,12 @@ import mineplex.core.updater.event.UpdateEvent; */ 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 enum Perm implements Permission + { + BYPASS_FORCEFIELD, + FORCEFIELD_RADIUS_COMMAND, + } + public HubManager Manager; private Map _radius = new HashMap<>(); @@ -47,11 +49,9 @@ public class ForcefieldManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Manager.GetClients().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), true, true); - pm.setPermission(PermissionGroup.EVENTMOD, GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), false, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(FORCEFIELD_RADIUS_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.BYPASS_FORCEFIELD, true, true); + PermissionGroup.EVENTMOD.setPermission(Perm.BYPASS_FORCEFIELD, false, true); + PermissionGroup.ADMIN.setPermission(Perm.FORCEFIELD_RADIUS_COMMAND, true, true); } @EventHandler @@ -62,7 +62,7 @@ public class ForcefieldManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { - if (Manager.getPreferences().get(player).isActive(Preference.FORCE_FIELD) && Manager.GetClients().getPermissionManager().hasPermission(player, Preference.FORCE_FIELD.getPermission())) + if (Manager.getPreferences().get(player).isActive(Preference.FORCE_FIELD) && Manager.GetClients().Get(player).hasPermission(Preference.FORCE_FIELD)) { for (Player other : UtilServer.getPlayers()) { @@ -76,7 +76,7 @@ public class ForcefieldManager extends MiniPlugin if (UtilMath.offset(other, player) > range) continue; - if (Manager.GetClients().getPermissionManager().hasPermission(other, GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION))) + if (Manager.GetClients().Get(other).hasPermission(Perm.BYPASS_FORCEFIELD)) 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 fdf2e173f..8262bede2 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -53,9 +53,8 @@ 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.Permission; 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; @@ -137,13 +136,16 @@ import mineplex.minecraft.game.core.condition.ConditionManager; */ 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"; - + public enum Perm implements Permission + { + GADGET_TOGGLE_COMMAND, + GAMEMODE_COMMAND, + AUTO_OP, + VANISH, + SPAWN_PM, + JOIN_FULL, + } + private BlockRestore _blockRestore; private CoreClientManager _clientManager; private ConditionManager _conditionManager; @@ -403,19 +405,17 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GADGET_TOGGLE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GAMEMODE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(AUTO_OP_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.GADGET_TOGGLE_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.GAMEMODE_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.AUTO_OP, true, true); if (UtilServer.isTestServer()) { - pm.setPermission(PermissionGroup.QAM, GroupPermission.of(AUTO_OP_PERMISSION), false, true); + PermissionGroup.QAM.setPermission(Perm.AUTO_OP, false, true); } - pm.setPermission(PermissionGroup.CMOD, GroupPermission.of(VANISH_PERMISSION), false, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(VANISH_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(SPAWN_PM_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + PermissionGroup.CMOD.setPermission(Perm.VANISH, false, true); + PermissionGroup.ADMIN.setPermission(Perm.VANISH, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.SPAWN_PM, true, true); + PermissionGroup.ULTRA.setPermission(Perm.JOIN_FULL, true, true); } @Override @@ -478,7 +478,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20) { - if (!_clientManager.getPermissionManager().hasPermission(client, GroupPermission.of(JOIN_FULL_PERMISSION))) + if (!client.hasPermission(Perm.JOIN_FULL)) { Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> { @@ -497,11 +497,10 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter @EventHandler(priority = EventPriority.LOW) public void handleOP(PlayerJoinEvent event) { - if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(AUTO_OP_PERMISSION))) + if (_clientManager.Get(event.getPlayer()).hasPermission(Perm.AUTO_OP)) { event.getPlayer().setOp(true); - } - else + } else { event.getPlayer().setOp(false); } @@ -550,7 +549,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.getPermissionManager().hasPermission(event.getSender(), GroupPermission.of(SPAWN_PM_PERMISSION))) + if (UtilMath.offset2d(GetSpawn(), event.getSender().getLocation()) == 0 && !_clientManager.Get(event.getSender()).hasPermission(Perm.SPAWN_PM)) { UtilPlayer.message(event.getSender(), F.main("Chat", "You must leave spawn before you can Private Message!")); event.setCancelled(true); @@ -560,7 +559,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter @EventHandler public void Incog(IncognitoHidePlayerEvent event) { - if (!_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(VANISH_PERMISSION))) + if (!_clientManager.Get(event.getPlayer()).hasPermission(Perm.VANISH)) { event.setCancelled(true); } @@ -573,7 +572,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter return; //Dont Let Chat Near Spawn! - if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(SPAWN_PM_PERMISSION))) + if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.Get(event.getPlayer()).hasPermission(Perm.SPAWN_PM)) { UtilPlayer.message(event.getPlayer(), F.main("Chat", "You must leave spawn before you can chat!")); event.setCancelled(true); @@ -929,7 +928,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter @EventHandler public void ignoreVelocity(PlayerVelocityEvent event) { - if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), Preference.IGNORE_VELOCITY.getPermission()) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY)) + if (_clientManager.Get(event.getPlayer()).hasPermission(Preference.IGNORE_VELOCITY) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY)) { event.setCancelled(true); } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java index cc862285f..33e33f7bb 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubVisibilityManager.java @@ -7,9 +7,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.MiniPlugin; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.preferences.Preference; @@ -22,8 +21,11 @@ import mineplex.core.visibility.VisibilityManager; */ public class HubVisibilityManager extends MiniPlugin { - public static final String BYPASS_INVISIBILITY_PERMISSION = "mineplex.clanshub.invisibility.bypass"; - + public enum Perm implements Permission + { + BYPASS_INVISIBILITY, + } + public HubManager Manager; private HashSet _hiddenPlayers = new HashSet(); @@ -39,9 +41,7 @@ public class HubVisibilityManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Manager.GetClients().getPermissionManager(); - - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(BYPASS_INVISIBILITY_PERMISSION), true, true); + PermissionGroup.MOD.setPermission(Perm.BYPASS_INVISIBILITY, true, true); } /** @@ -78,7 +78,7 @@ public class HubVisibilityManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { boolean hideMe = UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 || - (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && Manager.GetClients().getPermissionManager().hasPermission(player, Preference.INVISIBILITY.getPermission())) || + (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && Manager.GetClients().Get(player).hasPermission(Preference.INVISIBILITY)) || _hiddenPlayers.contains(player); for (Player other : UtilServer.getPlayers()) @@ -86,8 +86,8 @@ public class HubVisibilityManager extends MiniPlugin boolean localHideMe = hideMe; if (player.equals(other)) continue; - - if (Manager.GetClients().getPermissionManager().hasPermission(other, GroupPermission.of(BYPASS_INVISIBILITY_PERMISSION))) + + if (Manager.GetClients().Get(other).hasPermission(Perm.BYPASS_INVISIBILITY)) 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 1a6c1a4b5..2c15ae64d 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java @@ -3,7 +3,6 @@ package mineplex.clanshub; 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; @@ -41,7 +40,7 @@ public class JoinServerButton implements IButton System.out.println("Selecting server :" + serverInfo.Name); int slots = 1; - if (serverInfo.getAvailableSlots() < slots && !_page.getClientManager().getPermissionManager().hasPermission(player, GroupPermission.of(ClansTransferManager.JOIN_FULL_PERMISSION))) + if (serverInfo.getAvailableSlots() < slots && !_page.getClientManager().Get(player).hasPermission(ClansTransferManager.Perm.JOIN_FULL)) { _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 b8a1b9876..6d5b5b8ab 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/ForcefieldRadius.java @@ -12,7 +12,7 @@ public class ForcefieldRadius extends CommandBase { public ForcefieldRadius(ForcefieldManager plugin) { - super(plugin, ForcefieldManager.FORCEFIELD_RADIUS_COMMAND_PERMISSION, "radius", "forcefield"); + super(plugin, ForcefieldManager.Perm.FORCEFIELD_RADIUS_COMMAND, "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 bf962ea94..45c8e9da3 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GadgetToggle.java @@ -12,7 +12,7 @@ public class GadgetToggle extends CommandBase { public GadgetToggle(HubManager plugin) { - super(plugin, HubManager.GADGET_TOGGLE_COMMAND_PERMISSION, "gadget"); + super(plugin, HubManager.Perm.GADGET_TOGGLE_COMMAND, "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 70577de2d..74b03d46e 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/commands/GameModeCommand.java @@ -15,7 +15,7 @@ public class GameModeCommand extends CommandBase { public GameModeCommand(HubManager plugin) { - super(plugin, HubManager.GAMEMODE_COMMAND_PERMISSION, "gamemode", "gm"); + super(plugin, HubManager.Perm.GAMEMODE_COMMAND, "gamemode", "gm"); } @Override 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 0f847cbc4..ed0bc91ab 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementCommand.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementCommand.java @@ -10,7 +10,7 @@ public class SalesAnnouncementCommand extends CommandBase _data = new HashMap<>(); private final SalesAnnouncementRepository _repo; @@ -45,9 +47,7 @@ public class SalesAnnouncementManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SALES_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.SALES_COMMAND, true, true); } public Map getLoadedAnnouncements() 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 8a1046cb5..ea297e1b7 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/salesannouncements/SalesAnnouncementRepository.java @@ -7,10 +7,7 @@ import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; -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; @@ -30,14 +27,12 @@ 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) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 73a9eb0f2..533390e1b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -48,9 +48,8 @@ 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.Permission; 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; @@ -148,14 +147,17 @@ import mineplex.minecraft.game.core.condition.ConditionManager; 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"; - + public enum Perm implements Permission + { + GADGET_TOGGLE_COMMAND, + GAMEMODE_COMMAND, + AUTO_OP, + VANISH, + SPAWN_PM, + NEWS_COMMAND, + JOIN_FULL, + } + // ☃❅ Snowman! public HubType Type = HubType.Normal; @@ -444,23 +446,21 @@ public class HubManager extends MiniClientPlugin implements IChatMess private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GADGET_TOGGLE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GAMEMODE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(NEWS_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.GADGET_TOGGLE_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.GAMEMODE_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.NEWS_COMMAND, true, true); if (UtilServer.isDevServer() || UtilServer.isTestServer()) { - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(AUTO_OP_PERMISSION), true, true); - pm.setPermission(PermissionGroup.QAM, GroupPermission.of(AUTO_OP_PERMISSION), false, true); + PermissionGroup.ADMIN.setPermission(Perm.AUTO_OP, true, true); + PermissionGroup.QAM.setPermission(Perm.AUTO_OP, false, true); } else { - pm.setPermission(PermissionGroup.LT, GroupPermission.of(AUTO_OP_PERMISSION), true, true); + PermissionGroup.LT.setPermission(Perm.AUTO_OP, true, true); } - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(VANISH_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(SPAWN_PM_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.VANISH, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.SPAWN_PM, true, true); + PermissionGroup.ULTRA.setPermission(Perm.JOIN_FULL, true, true); } @Override @@ -546,7 +546,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20) { - if (!_clientManager.getPermissionManager().hasPermission(client, GroupPermission.of(JOIN_FULL_PERMISSION))) + if (!client.hasPermission(Perm.JOIN_FULL)) { Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> { @@ -565,7 +565,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess @EventHandler(priority = EventPriority.LOW) public void AdminOP(PlayerJoinEvent event) { - if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(AUTO_OP_PERMISSION))) + if (_clientManager.Get(event.getPlayer()).hasPermission(Perm.AUTO_OP)) event.getPlayer().setOp(true); else event.getPlayer().setOp(false); @@ -632,7 +632,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.getPermissionManager().hasPermission(event.getSender(), GroupPermission.of(SPAWN_PM_PERMISSION))) + if (UtilMath.offset2d(GetSpawn(), event.getSender().getLocation()) == 0 && !!_clientManager.Get(event.getSender()).hasPermission(Perm.SPAWN_PM)) { UtilPlayer.message(event.getSender(), F.main("Chat", "You must leave spawn before you can Private Message!")); event.setCancelled(true); @@ -642,7 +642,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess @EventHandler public void Incog(IncognitoHidePlayerEvent event) { - if (!_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(VANISH_PERMISSION))) + if (!_clientManager.Get(event.getPlayer()).hasPermission(Perm.VANISH)) { event.setCancelled(true); } @@ -655,7 +655,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess return; //Dont Let Chat Near Spawn! - if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(SPAWN_PM_PERMISSION))) + if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.Get(event.getPlayer()).hasPermission(Perm.SPAWN_PM)) { UtilPlayer.message(event.getPlayer(), F.main("Chat", "You must leave spawn before you can chat!")); event.setCancelled(true); @@ -961,7 +961,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess @EventHandler public void ignoreVelocity(PlayerVelocityEvent event) { - if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), Preference.IGNORE_VELOCITY.getPermission()) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY) && !getJumpManager().isDoubleJumping(event.getPlayer())) + if (_clientManager.Get(event.getPlayer()).hasPermission(Preference.IGNORE_VELOCITY) && _preferences.get(event.getPlayer()).isActive(Preference.IGNORE_VELOCITY) && !getJumpManager().isDoubleJumping(event.getPlayer())) { event.setCancelled(true); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/EggAddCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/EggAddCommand.java index d52c8c416..a7e015a96 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/EggAddCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/EggAddCommand.java @@ -11,7 +11,7 @@ public class EggAddCommand extends CommandBase { public EggAddCommand(EasterEggHunt plugin) { - super(plugin, EasterEggHunt.ADD_EGG_COMMAND_PERMISSION, "addegg"); + super(plugin, EasterEggHunt.Perm.ADD_EGG_COMMAND, "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 0962c1f7b..c4d96543f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/ForcefieldRadius.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/ForcefieldRadius.java @@ -9,7 +9,7 @@ public class ForcefieldRadius extends CommandBase { public ForcefieldRadius(ForcefieldManager plugin) { - super(plugin, ForcefieldManager.FORCEFIELD_RADIUS_COMMAND_PERMISSION, "radius"); + super(plugin, ForcefieldManager.Perm.FORCEFIELD_RADIUS_COMMAND, "radius"); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java index fb7f1f180..ab51becd5 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GadgetToggle.java @@ -9,7 +9,7 @@ public class GadgetToggle extends CommandBase { public GadgetToggle(HubManager plugin) { - super(plugin, HubManager.GADGET_TOGGLE_COMMAND_PERMISSION, "gadget"); + super(plugin, HubManager.Perm.GADGET_TOGGLE_COMMAND, "gadget"); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GameModeCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GameModeCommand.java index 282aed008..91122febb 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GameModeCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/GameModeCommand.java @@ -12,7 +12,7 @@ public class GameModeCommand extends CommandBase { public GameModeCommand(HubManager plugin) { - super(plugin, HubManager.GAMEMODE_COMMAND_PERMISSION, "gm"); + super(plugin, HubManager.Perm.GAMEMODE_COMMAND, "gm"); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HorseSpawn.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HorseSpawn.java index 7c7ea1382..223699324 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HorseSpawn.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HorseSpawn.java @@ -9,7 +9,7 @@ public class HorseSpawn extends CommandBase { public HorseSpawn(AdminMountManager plugin) { - super(plugin, AdminMountManager.HORSE_COMMAND_PERMISSION, "horse"); + super(plugin, AdminMountManager.Perm.HORSE_COMMAND, "horse"); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java index 5ecfe9f55..18c44b660 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewYearCommand.java @@ -16,7 +16,7 @@ public class NewYearCommand extends CommandBase { public NewYearCommand(NewYearCountdown plugin) { - super(plugin, NewYearCountdown.NEW_YEARS_COMMAND_PERMISSION, "newyear", "nycountdown", "nyc"); + super(plugin, NewYearCountdown.Perm.NEW_YEARS_COMMAND, "newyear", "nycountdown", "nyc"); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsAddCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsAddCommand.java index 493dffa88..a5ea32266 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsAddCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsAddCommand.java @@ -1,5 +1,7 @@ package mineplex.hub.commands; +import net.md_5.bungee.api.ChatColor; + import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; @@ -8,13 +10,12 @@ 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, HubManager.NEWS_COMMAND_PERMISSION, "add"); + super(plugin, HubManager.Perm.NEWS_COMMAND, "add"); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java index bb6d95d99..3109b2fb0 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsCommand.java @@ -9,7 +9,7 @@ public class NewsCommand extends MultiCommandBase { public NewsCommand(HubManager plugin) { - super(plugin, HubManager.NEWS_COMMAND_PERMISSION, "news"); + super(plugin, HubManager.Perm.NEWS_COMMAND, "news"); AddCommand(new NewsAddCommand(plugin)); AddCommand(new NewsDeleteCommand(plugin)); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsConfirmCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsConfirmCommand.java index a83c900e2..43eb186ac 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsConfirmCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsConfirmCommand.java @@ -13,7 +13,7 @@ public class NewsConfirmCommand extends CommandBase { public NewsConfirmCommand(HubManager plugin) { - super(plugin, HubManager.NEWS_COMMAND_PERMISSION, "¢¤₦₣¡₨₥"); + super(plugin, HubManager.Perm.NEWS_COMMAND, "¢¤₦₣¡₨₥"); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsDeleteCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsDeleteCommand.java index d4ce529b4..1e7084b77 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsDeleteCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsDeleteCommand.java @@ -13,7 +13,7 @@ public class NewsDeleteCommand extends CommandBase { public NewsDeleteCommand(HubManager plugin) { - super(plugin, HubManager.NEWS_COMMAND_PERMISSION, "delete"); + super(plugin, HubManager.Perm.NEWS_COMMAND, "delete"); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java index 974a08e40..29b50af26 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsListCommand.java @@ -16,7 +16,7 @@ public class NewsListCommand extends CommandBase { public NewsListCommand(HubManager plugin) { - super(plugin, HubManager.NEWS_COMMAND_PERMISSION, "list"); + super(plugin, HubManager.Perm.NEWS_COMMAND, "list"); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsSetCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsSetCommand.java index d5b6083b7..baa3e441e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsSetCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/NewsSetCommand.java @@ -14,7 +14,7 @@ public class NewsSetCommand extends CommandBase { public NewsSetCommand(HubManager plugin) { - super(plugin, HubManager.NEWS_COMMAND_PERMISSION, "set"); + super(plugin, HubManager.Perm.NEWS_COMMAND, "set"); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java index 5bd47f2a0..2e81a8fe5 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AdminMountManager.java @@ -16,9 +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.Permission; 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.utils.UtilVariant; @@ -27,8 +26,11 @@ import mineplex.hub.commands.HorseSpawn; public class AdminMountManager extends MiniPlugin { - public static final String HORSE_COMMAND_PERMISSION = "mineplex.hub.horse"; - + public enum Perm implements Permission + { + HORSE_COMMAND, + } + private HubManager Manager; private HashMap _mounts = new HashMap(); @@ -44,8 +46,7 @@ public class AdminMountManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Manager.GetClients().getPermissionManager(); - pm.setPermission(PermissionGroup.LT, GroupPermission.of(HORSE_COMMAND_PERMISSION), true, true); + PermissionGroup.LT.setPermission(Perm.HORSE_COMMAND, 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 009151aaf..0951ffd55 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AlienInvasion.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AlienInvasion.java @@ -28,10 +28,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.Achievement; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.command.CommandBase; @@ -58,8 +56,11 @@ import mineplex.hub.server.ServerManager; @ReflectivelyCreateMiniPlugin public class AlienInvasion extends MiniPlugin { - public static final String TOGGLE_ANIMATION_COMMAND_PERMISSION = "mineplex.hub.alieninvasion"; - + public enum Perm implements Permission + { + TOGGLE_ANIMATION_COMMAND, + } + private static final String SCHEMATIC_PATH = ".." + File.separator + ".." + File.separator + "update" + File.separator + "files" + File.separator + "UFO.schematic"; private static final int[][] UFO_SPAWNS = { @@ -144,7 +145,7 @@ public class AlienInvasion extends MiniPlugin _beaconBlocks = new HashSet<>(); _aliens = new HashSet<>(); - addCommand(new CommandBase(this, TOGGLE_ANIMATION_COMMAND_PERMISSION, "alien-animation-start") + addCommand(new CommandBase(this, Perm.TOGGLE_ANIMATION_COMMAND, "alien-animation-start") { @Override public void Execute(Player caller, String[] args) @@ -152,7 +153,7 @@ public class AlienInvasion extends MiniPlugin startAnimation(); } }); - addCommand(new CommandBase(this, TOGGLE_ANIMATION_COMMAND_PERMISSION, "alien-animation-stop") + addCommand(new CommandBase(this, Perm.TOGGLE_ANIMATION_COMMAND, "alien-animation-stop") { @Override public void Execute(Player caller, String[] args) @@ -168,9 +169,8 @@ public class AlienInvasion extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(TOGGLE_ANIMATION_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.TOGGLE_ANIMATION_COMMAND, true, true); } public void startAnimation() diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java index 417148aa6..d25c99196 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java @@ -27,9 +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.Permission; 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.F; @@ -49,8 +48,11 @@ import mineplex.serverdata.database.DBPool; public class EasterEggHunt extends MiniDbClientPlugin { - public static final String ADD_EGG_COMMAND_PERMISSION = "mineplex.hub.addeasteregg"; - + public enum Perm implements Permission + { + ADD_EGG_COMMAND, + } + private static final int SHARD_REWARD = 500; private static final String ITEM_REWARD = "Omega Chest"; private static final int EGGS_PER_DAY = 30; @@ -102,9 +104,8 @@ public class EasterEggHunt extends MiniDbClientPlugin private void generatePermissions() { - PermissionManager pm = getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(ADD_EGG_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.ADD_EGG_COMMAND, 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 05e8f124d..0317eb262 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ForcefieldManager.java @@ -9,9 +9,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.MiniPlugin; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; @@ -26,9 +25,12 @@ import mineplex.hub.HubManager; 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 enum Perm implements Permission + { + BYPASS_FORCEFIELD, + FORCEFIELD_RADIUS_COMMAND, + } + public HubManager Manager; private HashMap _radius = new HashMap(); @@ -44,11 +46,9 @@ public class ForcefieldManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Manager.GetClients().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), true, true); - pm.setPermission(PermissionGroup.EVENTMOD, GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION), false, true); - pm.setPermission(PermissionGroup.LT, GroupPermission.of(FORCEFIELD_RADIUS_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.BYPASS_FORCEFIELD, true, true); + PermissionGroup.EVENTMOD.setPermission(Perm.BYPASS_FORCEFIELD, false, true); + PermissionGroup.LT.setPermission(Perm.FORCEFIELD_RADIUS_COMMAND, true, true); } @EventHandler @@ -59,7 +59,7 @@ public class ForcefieldManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { - if (Manager.getPreferences().get(player).isActive(Preference.FORCE_FIELD) && Manager.GetClients().getPermissionManager().hasPermission(player, Preference.FORCE_FIELD.getPermission())) + if (Manager.getPreferences().get(player).isActive(Preference.FORCE_FIELD) && Manager.GetClients().Get(player).hasPermission(Preference.FORCE_FIELD)) { for (Player other : UtilServer.getPlayers()) { @@ -73,7 +73,7 @@ public class ForcefieldManager extends MiniPlugin if (UtilMath.offset(other, player) > range) continue; - if (Manager.GetClients().getPermissionManager().hasPermission(other, GroupPermission.of(BYPASS_FORCEFIELD_PERMISSION))) + if (Manager.GetClients().Get(other).hasPermission(Perm.BYPASS_FORCEFIELD)) continue; if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false)) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java index c6a1fc63a..b96bef681 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java @@ -142,7 +142,7 @@ public class HubVisibilityManager extends MiniPlugin // Close to spawn closeToSpawn(subject) || // Enabled Invisibility - (Manager.getPreferences().get(subject).isActive(Preference.INVISIBILITY) && Manager.GetClients().getPermissionManager().hasPermission(subject, Preference.INVISIBILITY.getPermission())) || + (Manager.getPreferences().get(subject).isActive(Preference.INVISIBILITY) && Manager.GetClients().Get(subject).hasPermission(Preference.INVISIBILITY)) || // OR Player has been explicitly hidden _hiddenPlayers.contains(subject); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java index 697d944ad..9486e9014 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java @@ -51,7 +51,7 @@ public class JumpManager extends MiniPlugin return; } - if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && Manager.GetClients().getPermissionManager().hasPermission(player, Preference.INVISIBILITY.getPermission())) + if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && Manager.GetClients().Get(event.getPlayer()).hasPermission(Preference.INVISIBILITY)) { return; } @@ -92,7 +92,7 @@ public class JumpManager extends MiniPlugin if (player.getGameMode() == GameMode.CREATIVE) continue; - if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && Manager.GetClients().getPermissionManager().hasPermission(player, Preference.INVISIBILITY.getPermission())) + if (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && Manager.GetClients().Get(player).hasPermission(Preference.INVISIBILITY)) { player.setAllowFlight(true); continue; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java index 9fb687c65..a332df20b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewYearCountdown.java @@ -21,12 +21,9 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.command.CommandCenter; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilFirework; @@ -49,8 +46,11 @@ import mineplex.serverdata.commands.ServerCommandManager; */ public class NewYearCountdown extends MiniPlugin { - public static final String NEW_YEARS_COMMAND_PERMISSION = "mineplex.hub.newyears"; - + public enum Perm implements Permission + { + NEW_YEARS_COMMAND, + } + private boolean _inProgress; private Location _center; private Location _spawn; @@ -74,8 +74,7 @@ public class NewYearCountdown extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(NEW_YEARS_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.NEW_YEARS_COMMAND, true, true); } @Override 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 8dd02cbd6..86e8b5260 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementCommand.java @@ -10,7 +10,7 @@ public class SalesAnnouncementCommand extends CommandBase _data = new HashMap<>(); private final SalesAnnouncementRepository _repo; @@ -45,9 +47,8 @@ public class SalesAnnouncementManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SALES_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.SALES_COMMAND, true, true); } public Map getLoadedAnnouncements() 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 3213c47ea..d66b024e2 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/salesannouncements/SalesAnnouncementRepository.java @@ -7,10 +7,7 @@ import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; -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; @@ -30,14 +27,12 @@ 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) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/notification/NotificationManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/notification/NotificationManager.java index 48c6583da..370a89ae9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/notification/NotificationManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/notification/NotificationManager.java @@ -12,9 +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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.ClickEvent; import mineplex.core.common.jsonchat.Color; import mineplex.core.common.jsonchat.JsonMessage; @@ -26,8 +25,11 @@ import mineplex.hub.notification.gui.NotificationShop; public class NotificationManager extends MiniPlugin { - public static final String NOTIFICATION_COMMAND_PERMISSION = "mineplex.hub.notification.command"; - + public enum Perm implements Permission + { + NOTIFICATION_COMMAND, + } + private static NotificationComparator COMPARATOR = new NotificationComparator(); private NotificationShop _shop; @@ -47,9 +49,8 @@ public class NotificationManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(NOTIFICATION_COMMAND_PERMISSION), true, true); + + PermissionGroup.PLAYER.setPermission(Perm.NOTIFICATION_COMMAND, true, true); } @EventHandler 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 1f1dc11a9..faa7011ed 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/notification/command/NotificationCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/notification/command/NotificationCommand.java @@ -9,7 +9,7 @@ public class NotificationCommand extends CommandBase { public NotificationCommand(NotificationManager plugin) { - super(plugin, NotificationManager.NOTIFICATION_COMMAND_PERMISSION, "notifications"); + super(plugin, NotificationManager.Perm.NOTIFICATION_COMMAND, "notifications"); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 31be69ab3..c5ca2737a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -27,9 +27,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.boosters.BoosterManager; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; @@ -64,9 +63,12 @@ import mineplex.serverdata.data.ServerGroup; public class ServerManager extends MiniPlugin { - public static final String JOIN_FULL_PERMISSION = "mineplex.hub.servermanager.joinfull"; - public static final String FEATURE_SERVER_PERMISSION = "mineplex.hub.servermanager.featureserver"; - + public enum Perm implements Permission + { + JOIN_FULL, + FEATURE_SERVER, + } + private static final Random random = new Random(); public final int TOP_SERVERS = 3; // The number of top contending servers for auto-joining games @@ -126,11 +128,10 @@ public class ServerManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); - pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(FEATURE_SERVER_PERMISSION), true, true); - pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(FEATURE_SERVER_PERMISSION), true, true); + + PermissionGroup.ULTRA.setPermission(Perm.JOIN_FULL, true, true); + PermissionGroup.CONTENT.setPermission(Perm.FEATURE_SERVER, true, true); + PermissionGroup.BUILDER.setPermission(Perm.FEATURE_SERVER, true, true); } @EventHandler(priority = EventPriority.LOW) @@ -663,7 +664,7 @@ public class ServerManager extends MiniPlugin { int slots = 0; - if (!_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(JOIN_FULL_PERMISSION)) && !_donationManager.Get(player).ownsUnknownSalesPackage(serverType + " ULTRA")) + if (!_clientManager.Get(player).hasPermission(Perm.JOIN_FULL) && !_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 c4de0ced1..0e79b5bd3 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java @@ -9,7 +9,6 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; -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 +67,7 @@ public class LobbyMenu extends ShopPageBase implements if (serverInfo.CurrentPlayers >= serverInfo.MaxPlayers) { - if (!getClientManager().getPermissionManager().hasPermission(getPlayer(), GroupPermission.of(ServerManager.JOIN_FULL_PERMISSION))) + if (!getClientManager().Get(getPlayer()).hasPermission(ServerManager.Perm.JOIN_FULL)) lore.add(openFull); else lore.add(openFullUltra); 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 bf53746c8..9f8b8f8cb 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,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; import mineplex.core.account.CoreClientManager; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; import mineplex.core.game.GameDisplay; @@ -92,7 +91,7 @@ public class ServerNpcPage extends ShopPageInventory lore = new ArrayList(); @@ -210,7 +209,7 @@ public class ServerNpcPage extends ShopPageInventory implements IClassFactory { - public static final String VIEW_OTHER_SKILLS = "mineplex.classcombat.skillunlock"; - + public enum Perm implements Permission + { + VIEW_OTHER_SKILLS, + } + private CoreClientManager _clientManager; private DonationManager _donationManager; private SkillFactory _skillFactory; @@ -96,9 +98,8 @@ public class ClassManager extends MiniClientPlugin implements IClas private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(VIEW_OTHER_SKILLS), true, true); + + PermissionGroup.MOD.setPermission(Perm.VIEW_OTHER_SKILLS, true, true); } @EventHandler @@ -362,7 +363,7 @@ public class ClassManager extends MiniClientPlugin implements IClas Player target = event.getPlayer(); //Target Other - if (args.length > 1 && _clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(VIEW_OTHER_SKILLS))) + if (args.length > 1 && _clientManager.Get(event.getPlayer()).hasPermission(Perm.VIEW_OTHER_SKILLS)) { target = UtilPlayer.searchOnline(event.getPlayer(), args[1], true); 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 bd559e5fe..1b2244c1a 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,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import mineplex.core.account.CoreClient; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -27,8 +26,8 @@ import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildTok import mineplex.minecraft.game.classcombat.Class.repository.token.SlotToken; import mineplex.minecraft.game.classcombat.Skill.ISkill; 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.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.item.ItemFactory; import mineplex.minecraft.game.classcombat.shop.ClassShopManager; @@ -578,7 +577,7 @@ public class ClientClass 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")))) + if (!skillName.isEmpty() && (skill == null || skill.GetSkillType() != expectedType || (!skill.IsFree() && !_donor.ownsUnknownSalesPackage("Champions " + skillName) && !_client.hasPermission(ClassShopManager.Perm.SKILL_UNLOCK_LEGACY) && !_donor.ownsUnknownSalesPackage("Competitive ULTRA")))) { return false; } 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 b882bfd25..015863ec5 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,9 +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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.achievement.Achievement; import mineplex.core.achievement.AchievementManager; import mineplex.minecraft.game.classcombat.Class.ClassManager; @@ -16,9 +15,12 @@ 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"; - + public enum Perm implements Permission + { + SKILL_UNLOCK, + SKILL_UNLOCK_LEGACY, + } + private ClassManager _classManager; private SkillFactory _skillFactory; private ItemFactory _itemFactory; @@ -40,10 +42,9 @@ public class ClassShopManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(SKILL_UNLOCK_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(SKILL_UNLOCK_LEGACY_PERMISSION), true, true); + + PermissionGroup.TRAINEE.setPermission(Perm.SKILL_UNLOCK, true, true); + PermissionGroup.ULTRA.setPermission(Perm.SKILL_UNLOCK_LEGACY, true, true); } public ClassManager GetClassManager() @@ -63,7 +64,7 @@ public class ClassShopManager extends MiniPlugin public boolean hasAchievements(Player player) { - if (_clientManager.getPermissionManager().hasPermission(player, GroupPermission.of(SKILL_UNLOCK_PERMISSION))) + if (_clientManager.Get(player).hasPermission(Perm.SKILL_UNLOCK)) return true; return _achievementManager.hasCategory(player, new Achievement[] 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 cb6916902..1e15aa094 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 @@ -10,7 +10,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import mineplex.core.account.CoreClientManager; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; @@ -399,7 +398,7 @@ public class SkillPage extends ShopPageBase private boolean isSkillLocked(ISkill skill) { - 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())) + if (skill.IsFree() || getClientManager().Get(getPlayer()).hasPermission(ClassShopManager.Perm.SKILL_UNLOCK) || getDonationManager().Get(getPlayer()).ownsUnknownSalesPackage("Champions ULTRA") || getDonationManager().Get(getPlayer()).ownsUnknownSalesPackage("Champions " + skill.GetName())) return false; return true; @@ -407,7 +406,7 @@ public class SkillPage extends ShopPageBase private boolean isItemLocked(Item item) { - 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())) + if (item.isFree() || getClientManager().Get(getPlayer()).hasPermission(ClassShopManager.Perm.SKILL_UNLOCK) || getDonationManager().Get(getPlayer()).ownsUnknownSalesPackage("Champions ULTRA") || getDonationManager().Get(getPlayer()).ownsUnknownSalesPackage("Champions " + item.GetName())) return false; return true; diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 6fa7bb982..33e6a59e7 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -29,9 +29,8 @@ 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.Permission; 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.F; @@ -49,11 +48,14 @@ 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"; + public enum Perm implements Permission + { + CHECK_BONUS_COMMAND, + CHECK_COMMAND, + CHECK_OWNS_PACKAGE_COMMAND, + LIST_PPC_COMMAND, + JOIN_SERVER, + } private CoreClientManager _clientManager; private DonationManager _donationManager; @@ -89,19 +91,18 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.SUPPORT, GroupPermission.of(CHECK_BONUS_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.SUPPORT, GroupPermission.of(CHECK_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.SUPPORT, GroupPermission.of(CHECK_OWNS_PACKAGE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.SUPPORT, GroupPermission.of(LIST_PPC_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.SUPPORT, GroupPermission.of(JOIN_SERVER_PERMISSION), true, true); + + PermissionGroup.SUPPORT.setPermission(Perm.CHECK_BONUS_COMMAND, true, true); + PermissionGroup.SUPPORT.setPermission(Perm.CHECK_COMMAND, true, true); + PermissionGroup.SUPPORT.setPermission(Perm.CHECK_OWNS_PACKAGE_COMMAND, true, true); + PermissionGroup.SUPPORT.setPermission(Perm.LIST_PPC_COMMAND, true, true); + PermissionGroup.SUPPORT.setPermission(Perm.JOIN_SERVER, true, true); } @EventHandler public void Join(PlayerJoinEvent event) { - if (!_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(JOIN_SERVER_PERMISSION))) + if (!_clientManager.Get(event.getPlayer()).hasPermission(Perm.JOIN_SERVER)) { event.getPlayer().kickPlayer("Only for support staff."); return; diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/ListPPCCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/ListPPCCommand.java index 1b109a4b0..e925c2f69 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/ListPPCCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/ListPPCCommand.java @@ -30,7 +30,7 @@ public class ListPPCCommand extends CommandBase public ListPPCCommand(CustomerSupport customerSupport, PowerPlayClubRepository powerPlayRepo) { - super(customerSupport, CustomerSupport.LIST_PPC_COMMAND_PERMISSION, "listppc", "checkppc"); + super(customerSupport, CustomerSupport.Perm.LIST_PPC_COMMAND, "listppc", "checkppc"); _powerPlayRepo = powerPlayRepo; } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java index da1df77b5..5626c2d3e 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkBonusCommand.java @@ -10,7 +10,7 @@ public class checkBonusCommand extends CommandBase { public checkBonusCommand(CustomerSupport plugin) { - super(plugin, CustomerSupport.CHECK_BONUS_COMMAND_PERMISSION, "checkbonus"); + super(plugin, CustomerSupport.Perm.CHECK_BONUS_COMMAND, "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 23c061b15..822a78a96 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java @@ -10,7 +10,7 @@ public class checkCommand extends CommandBase { public checkCommand(CustomerSupport plugin) { - super(plugin, CustomerSupport.CHECK_COMMAND_PERMISSION, "check", "c"); + super(plugin, CustomerSupport.Perm.CHECK_COMMAND, "check", "c"); } @Override diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkOwnsPackageCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkOwnsPackageCommand.java index 200b572e0..b6a702463 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkOwnsPackageCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkOwnsPackageCommand.java @@ -10,7 +10,7 @@ public class checkOwnsPackageCommand extends CommandBase { public checkOwnsPackageCommand(CustomerSupport plugin) { - super(plugin, CustomerSupport.CHECK_OWNS_PACKAGE_COMMAND_PERMISSION, "checkownspackage"); + super(plugin, CustomerSupport.Perm.CHECK_OWNS_PACKAGE_COMMAND, "checkownspackage"); } @Override diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index 376524a48..94adbd2e9 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -5,9 +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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.NautHashMap; import mineplex.core.donation.DonationManager; @@ -50,9 +49,12 @@ 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"; - + public enum Perm implements Permission + { + SALES_COMMAND, + DISPLAY_PACKAGE_COMMAND, + } + private CoreClientManager _clientManager; private DonationManager _donationManager; private InventoryManager _inventoryManager; @@ -126,10 +128,8 @@ public class SalesPackageManager extends MiniPlugin private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.SUPPORT, GroupPermission.of(SALES_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.SUPPORT, GroupPermission.of(DISPLAY_PACKAGE_COMMAND_PERMISSION), true, true); + PermissionGroup.SUPPORT.setPermission(Perm.SALES_COMMAND, true, true); + PermissionGroup.SUPPORT.setPermission(Perm.DISPLAY_PACKAGE_COMMAND, true, true); } private void addSalesPackage(SalesPackageBase salesPackage) 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 90f84e4c0..bac43ff9d 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/CoinCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/CoinCommand.java @@ -12,7 +12,7 @@ public class CoinCommand extends CommandBase { public CoinCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "coin", "shard", "shards"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "coin", "shard", "shards"); } @Override 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 189d98f38..dbf8fb4d5 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/DisplayPackageCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/DisplayPackageCommand.java @@ -9,7 +9,7 @@ public class DisplayPackageCommand extends CommandBase { public DisplayPackageCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.DISPLAY_PACKAGE_COMMAND_PERMISSION, "display"); + super(plugin, SalesPackageManager.Perm.DISPLAY_PACKAGE_COMMAND, "display"); } @Override 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 fdab3fc26..139225110 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java @@ -11,7 +11,7 @@ public class GemHunterCommand extends CommandBase { public GemHunterCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "gemhunter"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "gemhunter"); } @Override 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 8421d3ed8..c5632c914 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/HeroCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/HeroCommand.java @@ -11,7 +11,7 @@ public class HeroCommand extends CommandBase { public HeroCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "hero"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "hero"); } @Override 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 603bf39ec..94996fa0e 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/ItemCommand.java @@ -16,7 +16,7 @@ public class ItemCommand extends CommandBase { public ItemCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "item"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "item"); } @Override 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 5cbc405ca..df295a855 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/KitsCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/KitsCommand.java @@ -10,7 +10,7 @@ public class KitsCommand extends CommandBase { public KitsCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "kits"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "kits"); } @Override 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 690b03b34..f7e719020 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeEternalCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeEternalCommand.java @@ -11,7 +11,7 @@ public class LifetimeEternalCommand extends CommandBase { public LifetimeEternalCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "lifetimeeternal"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "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 14385201b..8e3d6a592 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeHeroCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeHeroCommand.java @@ -11,7 +11,7 @@ public class LifetimeHeroCommand extends CommandBase { public LifetimeHeroCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "lifetimehero"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "lifetimehero"); } @Override 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 64ec8d171..a3df06814 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeLegendCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeLegendCommand.java @@ -11,7 +11,7 @@ public class LifetimeLegendCommand extends CommandBase { public LifetimeLegendCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "lifetimelegend"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "lifetimelegend"); } @Override 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 95b106ec4..a76e93398 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeTitanCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeTitanCommand.java @@ -11,7 +11,7 @@ public class LifetimeTitanCommand extends CommandBase { public LifetimeTitanCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "lifetimetitan"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "lifetimetitan"); } @Override 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 4c3fba148..a91dff857 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeUltraCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/LifetimeUltraCommand.java @@ -11,7 +11,7 @@ public class LifetimeUltraCommand extends CommandBase { public LifetimeUltraCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "lifetimeultra"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "lifetimeultra"); } @Override 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 b74aa4952..666c9672e 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PetCommand.java @@ -19,7 +19,7 @@ public class PetCommand extends CommandBase { public PetCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "pet"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "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 167c1427b..580a4d39b 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PowerPlayCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/PowerPlayCommand.java @@ -13,7 +13,7 @@ public class PowerPlayCommand extends CommandBase { public PowerPlayCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "powerplay"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "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 9c41d9752..23f0d4afd 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/RankCommand.java @@ -19,7 +19,7 @@ public class RankCommand extends CommandBase public RankCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "rank"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "rank"); } @Override 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 c44a8a435..7f8c23308 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/Sales.java @@ -9,7 +9,7 @@ public class Sales extends MultiCommandBase { public Sales(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "sales"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "sales"); AddCommand(new RankCommand(plugin)); AddCommand(new CoinCommand(plugin)); 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 4c3b98e48..a177ca573 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/UltraCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/UltraCommand.java @@ -11,7 +11,7 @@ public class UltraCommand extends CommandBase { public UltraCommand(SalesPackageManager plugin) { - super(plugin, SalesPackageManager.SALES_COMMAND_PERMISSION, "ultra"); + super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "ultra"); } @Override 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 520fa7152..5366fd8f1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -39,9 +39,8 @@ 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.Permission; 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; @@ -171,22 +170,25 @@ import nautilus.game.arcade.shop.ArcadeShop; 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"; + public enum Perm implements Permission + { + USE_MENU_DURING_GAME, + NEXT_BEST_GAME, + KIT_UNLOCK_COMMAND, + TAUNT_COMMAND, + GAME_COMMAND, + SET_GAME_COMMAND, + START_GAME_COMMAND, + STOP_GAME_COMMAND, + AUTO_OP, + KIT_ACCESS, + FEATURED_SERVER, + INFORM_RANKED_MODERATION_POTENTIAL, + JOIN_FULL, + JOIN_FULL_STAFF, + BYPASS_WHITELIST, + BYPASS_MPS_WHITELIST, + } // Modules private BlockRestore _blockRestore; @@ -614,46 +616,44 @@ public class ArcadeManager extends MiniPlugin implements IRelation private void generatePermissions() { - PermissionManager pm = _clientManager.getPermissionManager(); - - pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(USE_MENU_DURING_GAME_PERMISSION), true, true); - pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(USE_MENU_DURING_GAME_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(NEXT_BEST_GAME_PERMISSION), true, true); - pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(KIT_UNLOCK_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(TAUNT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GAME_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SET_GAME_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(START_GAME_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(STOP_GAME_COMMAND_PERMISSION), true, true); + + PermissionGroup.CONTENT.setPermission(Perm.USE_MENU_DURING_GAME, true, true); + PermissionGroup.BUILDER.setPermission(Perm.USE_MENU_DURING_GAME, true, true); + PermissionGroup.PLAYER.setPermission(Perm.NEXT_BEST_GAME, true, true); + PermissionGroup.CONTENT.setPermission(Perm.KIT_UNLOCK_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.TAUNT_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.GAME_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.SET_GAME_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.START_GAME_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.STOP_GAME_COMMAND, true, true); if (UtilServer.isTestServer()) { - pm.setPermission(PermissionGroup.QA, GroupPermission.of(GAME_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.QA, GroupPermission.of(SET_GAME_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.QA, GroupPermission.of(START_GAME_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.QA, GroupPermission.of(STOP_GAME_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MAPLEAD, GroupPermission.of(GAME_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.MAPLEAD, GroupPermission.of(SET_GAME_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.MAPLEAD, GroupPermission.of(START_GAME_COMMAND_PERMISSION), false, true); - pm.setPermission(PermissionGroup.MAPLEAD, GroupPermission.of(STOP_GAME_COMMAND_PERMISSION), false, true); + PermissionGroup.QA.setPermission(Perm.GAME_COMMAND, true, true); + PermissionGroup.QA.setPermission(Perm.SET_GAME_COMMAND, true, true); + PermissionGroup.QA.setPermission(Perm.START_GAME_COMMAND, true, true); + PermissionGroup.QA.setPermission(Perm.STOP_GAME_COMMAND, true, true); + PermissionGroup.MAPLEAD.setPermission(Perm.GAME_COMMAND, false, true); + PermissionGroup.MAPLEAD.setPermission(Perm.SET_GAME_COMMAND, false, true); + PermissionGroup.MAPLEAD.setPermission(Perm.START_GAME_COMMAND, false, true); + PermissionGroup.MAPLEAD.setPermission(Perm.STOP_GAME_COMMAND, false, true); } if (UtilServer.isTestServer() || UtilServer.isDevServer()) { - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(AUTO_OP_PERMISSION), true, true); - pm.setPermission(PermissionGroup.QAM, GroupPermission.of(AUTO_OP_PERMISSION), false, true); - } - else + PermissionGroup.ADMIN.setPermission(Perm.AUTO_OP, true, true); + PermissionGroup.QAM.setPermission(Perm.AUTO_OP, false, true); + } else { - pm.setPermission(PermissionGroup.LT, GroupPermission.of(AUTO_OP_PERMISSION), true, true); + PermissionGroup.LT.setPermission(Perm.AUTO_OP, true, true); } - pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(KIT_ACCESS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(FEATURED_SERVER_PERMISSION), true, true); - pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(FEATURED_SERVER_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(INFORM_RANKED_MODERATION_POTENTIAL_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(JOIN_FULL_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(JOIN_FULL_STAFF_PERMISSION), true, true); - pm.setPermission(PermissionGroup.BUILDER, GroupPermission.of(BYPASS_WHITELIST_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(BYPASS_WHITELIST_PERMISSION), false, false); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(BYPASS_MPS_WHITELIST_PERMISSION), true, true); + PermissionGroup.BUILDER.setPermission(Perm.KIT_ACCESS, true, true); + PermissionGroup.BUILDER.setPermission(Perm.FEATURED_SERVER, true, true); + PermissionGroup.CONTENT.setPermission(Perm.FEATURED_SERVER, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.INFORM_RANKED_MODERATION_POTENTIAL, true, true); + PermissionGroup.ULTRA.setPermission(Perm.JOIN_FULL, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.JOIN_FULL_STAFF, true, true); + PermissionGroup.BUILDER.setPermission(Perm.BYPASS_WHITELIST, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.BYPASS_WHITELIST, false, false); + PermissionGroup.MOD.setPermission(Perm.BYPASS_MPS_WHITELIST, true, true); } @Override @@ -1000,7 +1000,7 @@ 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.hasPermission(GroupPermission.of(FEATURED_SERVER_PERMISSION))) + if (_gameHostManager.isPrivateServer() && _gameHostManager.hasPermission(Perm.FEATURED_SERVER)) { extrainformation += "|HostRank." + _gameHostManager.getHostRank().name(); } @@ -1134,7 +1134,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation { if (Bukkit.getServer().hasWhitelist()) { - if (_clientManager.getPermissionManager().hasPermission(_clientManager.Get(event.getPlayer().getUniqueId()), GroupPermission.of(BYPASS_WHITELIST_PERMISSION))) + if (_clientManager.Get(event.getPlayer().getUniqueId()).hasPermission(Perm.BYPASS_WHITELIST)) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); @@ -1165,13 +1165,13 @@ public class ArcadeManager extends MiniPlugin implements IRelation // Reserved Slot Check if (Bukkit.getOnlinePlayers().size() >= Bukkit.getServer().getMaxPlayers()) { - if (_clientManager.getPermissionManager().hasPermission(_clientManager.Get(event.getPlayer().getUniqueId()), GroupPermission.of(JOIN_FULL_STAFF_PERMISSION))) + if (_clientManager.Get(event.getPlayer().getUniqueId()).hasPermission(Perm.JOIN_FULL_STAFF)) { event.allow(); event.setResult(PlayerLoginEvent.Result.ALLOWED); return; } - else if (_clientManager.getPermissionManager().hasPermission(_clientManager.Get(event.getPlayer().getUniqueId()), GroupPermission.of(JOIN_FULL_PERMISSION)) + else if (_clientManager.Get(event.getPlayer().getUniqueId()).hasPermission(Perm.JOIN_FULL) || _donationManager.Get(event.getPlayer().getUniqueId()).ownsUnknownSalesPackage(_serverConfig.ServerType + " ULTRA")) { @@ -1204,11 +1204,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation @EventHandler(priority = EventPriority.LOW) public void AdminOP(PlayerJoinEvent event) { - if (_clientManager.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(AUTO_OP_PERMISSION))) + if (_clientManager.Get(event.getPlayer()).hasPermission(Perm.AUTO_OP)) { event.getPlayer().setOp(true); - } - else + } else { event.getPlayer().setOp(false); } 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 c08d4e4e3..2d04a089a 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 @@ -12,7 +12,7 @@ public class CancelNextGameCommand extends CommandBase { public CancelNextGameCommand(ArcadeManager plugin) { - super(plugin, ArcadeManager.NEXT_BEST_GAME_PERMISSION, "cancelsendingtonextbestgame"); + super(plugin, ArcadeManager.Perm.NEXT_BEST_GAME, "cancelsendingtonextbestgame"); } @Override 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 0d1256f2e..d1fde493e 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 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; +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; public class GameCommand extends MultiCommandBase { public GameCommand(ArcadeManager plugin) { - super(plugin, ArcadeManager.GAME_COMMAND_PERMISSION, "game"); + super(plugin, ArcadeManager.Perm.GAME_COMMAND, "game"); AddCommand(new StartCommand(Plugin)); AddCommand(new StopCommand(Plugin)); 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 894c0a605..f73e75762 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 @@ -12,7 +12,7 @@ public class GoToNextGameCommand extends CommandBase { public GoToNextGameCommand(ArcadeManager plugin) { - super(plugin, ArcadeManager.NEXT_BEST_GAME_PERMISSION, "gotonextbestgame"); + super(plugin, ArcadeManager.Perm.NEXT_BEST_GAME, "gotonextbestgame"); } @Override 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 21d8846bf..f24cfea6c 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 @@ -9,7 +9,7 @@ public class KitUnlockCommand extends CommandBase { public KitUnlockCommand(ArcadeManager plugin) { - super(plugin, ArcadeManager.KIT_UNLOCK_COMMAND_PERMISSION, new String[] {"youtube", "twitch", "kits"}); + super(plugin, ArcadeManager.Perm.KIT_UNLOCK_COMMAND, "youtube", "twitch", "kits"); } @Override 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 093cba16e..6d98156b4 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 @@ -14,7 +14,7 @@ public class OpenGameMechPrefsCommand extends CommandBase { public OpenGameMechPrefsCommand(ArcadeManager plugin) { - super(plugin, ArcadeManager.NEXT_BEST_GAME_PERMISSION, "opengamemechanicpreferences"); + super(plugin, ArcadeManager.Perm.NEXT_BEST_GAME, "opengamemechanicpreferences"); } @Override 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 3b8d8d446..7bc228eeb 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 @@ -26,7 +26,7 @@ public class SetCommand extends CommandBase public SetCommand(ArcadeManager plugin) { - super(plugin, ArcadeManager.SET_GAME_COMMAND_PERMISSION, "set"); + super(plugin, ArcadeManager.Perm.SET_GAME_COMMAND, "set"); } @Override @@ -340,7 +340,7 @@ public class SetCommand extends CommandBase @Override public List onTabComplete(CommandSender sender, String commandLabel, String[] args) { - if (!(sender instanceof Player) && !_commandCenter.GetClientManager().getPermissionManager().hasPermission((Player)sender, getPermission())) + if (!(sender instanceof Player) && !_commandCenter.GetClientManager().Get((Player) sender).hasPermission(getPermission())) { return null; } 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 a0569a288..9ae7feb17 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 @@ -13,7 +13,7 @@ public class StartCommand extends CommandBase { public StartCommand(ArcadeManager plugin) { - super(plugin, ArcadeManager.START_GAME_COMMAND_PERMISSION, "start"); + super(plugin, ArcadeManager.Perm.START_GAME_COMMAND, "start"); } @Override 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 bf72dfed4..333693168 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 @@ -14,7 +14,7 @@ public class StopCommand extends CommandBase { public StopCommand(ArcadeManager plugin) { - super(plugin, ArcadeManager.STOP_GAME_COMMAND_PERMISSION, "stop"); + super(plugin, ArcadeManager.Perm.STOP_GAME_COMMAND, "stop"); } @Override 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 1e1bfa70b..8cf8de13d 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 @@ -18,7 +18,7 @@ public class TauntCommand extends CommandBase public TauntCommand(ArcadeManager manager) { - super(manager, ArcadeManager.TAUNT_COMMAND_PERMISSION, "taunt"); + super(manager, ArcadeManager.Perm.TAUNT_COMMAND, "taunt"); _arcadeManager = manager; } 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 76cba4ca7..84d6aa518 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 @@ -3,25 +3,24 @@ package nautilus.game.arcade.game; import org.bukkit.entity.Player; import mineplex.core.Managers; -import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.Permission; import mineplex.core.command.CommandBase; + import nautilus.game.arcade.ArcadeManager; -public abstract class DebugCommand extends CommandBase +public class DebugCommand extends CommandBase { - private final PermissionGroup _defaultGroup; + private final DebugCommandExecutor _executor; - public DebugCommand(String commandName, String permission, PermissionGroup defaultGroup) + public DebugCommand(String commandName, Permission permission, DebugCommandExecutor executor) { super(Managers.get(ArcadeManager.class), permission, commandName); - _defaultGroup = defaultGroup; - } - - public PermissionGroup getDefaultGroup() - { - return _defaultGroup; + _executor = executor; } - public abstract void Execute(Player caller, String[] args); + public void Execute(Player caller, String[] args) + { + _executor.execute(caller, args); + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommandExecutor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommandExecutor.java new file mode 100644 index 000000000..cdc314883 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/DebugCommandExecutor.java @@ -0,0 +1,9 @@ +package nautilus.game.arcade.game; + +import org.bukkit.entity.Player; + +@FunctionalInterface +public interface DebugCommandExecutor +{ + void execute(Player player, String[] args); +} 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 000f9d739..b4c0aa265 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 @@ -49,8 +49,8 @@ import com.google.common.collect.Lists; import com.mojang.authlib.GameProfile; import mineplex.core.Managers; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.antihack.AntiHack; import mineplex.core.arcadeevents.CoreGameStartEvent; import mineplex.core.arcadeevents.CoreGameStopEvent; @@ -534,23 +534,22 @@ public abstract class Game extends ListenerComponent implements Lifetimed } } - public void registerDebugCommand(DebugCommand debugCommand) + public & Permission> void registerDebugCommand(String commandName, T permission, DebugCommandExecutor executor) { - PermissionManager pm = Manager.GetClients().getPermissionManager(); - pm.setPermission(debugCommand.getDefaultGroup(), debugCommand.getPermission(), true, true); + DebugCommand command = new DebugCommand(commandName, permission, executor); if (UtilServer.isTestServer()) { - pm.setPermission(PermissionGroup.QA, debugCommand.getPermission(), true, true); + PermissionGroup.QA.setPermission(permission, true, true); } - _debugCommands.add(debugCommand); - for (String string : debugCommand.Aliases()) + _debugCommands.add(command); + for (String string : command.Aliases()) { if (CommandCenter.getCommands().containsKey(string.toLowerCase())) { throw new IllegalArgumentException("Existing command: " + string.toLowerCase()); } } - CommandCenter.Instance.addCommand(debugCommand); + CommandCenter.Instance.addCommand(command); } public void setKits(Kit[] kits) 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 d75caa55d..54bfb0119 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 @@ -13,9 +13,9 @@ 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; @@ -101,7 +101,7 @@ public abstract class RankedTeamGame extends TeamGame return; } String message = ChatColor.RED + "This game has reached maximum capacity!"; - if (Manager.GetClients().getPermissionManager().hasPermission(Manager.GetClients().Get(event.getPlayer().getUniqueId()), GroupPermission.of(ArcadeManager.INFORM_RANKED_MODERATION_POTENTIAL_PERMISSION))) + if (Manager.GetClients().Get(event.getPlayer().getUniqueId()).hasPermission(ArcadeManager.Perm.INFORM_RANKED_MODERATION_POTENTIAL)) { if (InProgress()) { 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 ece542833..0defbd396 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 @@ -45,7 +45,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; -import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.Permission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -72,7 +72,6 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; @@ -101,6 +100,12 @@ import nautilus.game.arcade.stats.TntMinerStatTracker; public class Bridge extends TeamGame implements OreObsfucation { + public enum Perm implements Permission + { + DEBUG_BRIDGE_COMMAND, + DEBUG_BRIDGEINFO_COMMAND, + } + /** * When a block is broken of one of these materials, the item drop will be locked to the player that broke the block for 8 seconds. After that, anyone can pick up the item. */ @@ -269,31 +274,22 @@ public class Bridge extends TeamGame implements OreObsfucation } } - registerDebugCommand(new DebugCommand("bridge", "mineplex.arcade.bridge.bridge", PermissionGroup.ADMIN) + registerDebugCommand("bridge", Perm.DEBUG_BRIDGE_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) - { - caller.sendMessage(F.main("Debug", "Spawning the bridges.")); - _bridgeTime = 3000; - } + caller.sendMessage(F.main("Debug", "Spawning the bridges.")); + _bridgeTime = 3000; }); - registerDebugCommand(new DebugCommand("bridgeinfo", "mineplex.arcade.bridge.bridgeinfo", PermissionGroup.ADMIN) + registerDebugCommand("bridgeinfo", Perm.DEBUG_BRIDGEINFO_COMMAND, (caller, args) -> { - - @Override - public void Execute(Player caller, String[] args) + if (_animation == null || !(_animation instanceof CustomBridgeAnimation)) { - if (_animation == null || !(_animation instanceof CustomBridgeAnimation)) - { - caller.sendMessage(F.main("Debug", "The bridge animation for this map isn't a custom one.")); - return; - } - - caller.sendMessage(F.main("Debug", "Bridge Info:")); - caller.sendMessage(_animation.toString()); + caller.sendMessage(F.main("Debug", "The bridge animation for this map isn't a custom one.")); + return; } + + caller.sendMessage(F.main("Debug", "Bridge Info:")); + caller.sendMessage(_animation.toString()); }); } 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 b2db7e432..731cdd641 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 @@ -25,9 +25,8 @@ 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.Permission; 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.RadarData; @@ -62,8 +61,11 @@ import nautilus.game.arcade.kit.Kit; public class CaptureTheFlag extends TeamGame { - public static final String SUDDEN_DEATH_COMMAND_PERMISSION = "mineplex.arcade.ctf.suddendeath"; - + public enum Perm implements Permission + { + SUDDEN_DEATH_COMMAND, + } + //Map Data private Location _redFlag; private Location _blueFlag; @@ -119,12 +121,10 @@ public class CaptureTheFlag extends TeamGame private void generatePermissions() { - PermissionManager pm = Manager.GetClients().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SUDDEN_DEATH_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.SUDDEN_DEATH_COMMAND, true, true); if (UtilServer.isTestServer()) { - pm.setPermission(PermissionGroup.QA, GroupPermission.of(SUDDEN_DEATH_COMMAND_PERMISSION), true, true); + PermissionGroup.QA.setPermission(Perm.SUDDEN_DEATH_COMMAND, true, true); } } @@ -739,7 +739,7 @@ public class CaptureTheFlag extends TeamGame if (event.getMessage().contains("/suddendeath")) { - boolean authorized = Manager.GetClients().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(SUDDEN_DEATH_COMMAND_PERMISSION)); + boolean authorized = Manager.GetClients().Get(event.getPlayer()).hasPermission(Perm.SUDDEN_DEATH_COMMAND); if (Manager.GetGameHostManager().isPrivateServer()) if (Manager.GetGameHostManager().isAdmin(event.getPlayer(), false)) 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 bdc549651..053d7bdae 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,9 +39,8 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import mineplex.core.MiniPlugin; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; 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.NautHashMap; @@ -73,8 +72,11 @@ import nautilus.game.arcade.kit.Kit; public class EventModule extends MiniPlugin { - public static final String SET_HOST_COMMAND_PERMISSION = "mineplex.arcade.event.sethost"; - + public enum Perm implements Permission + { + SET_HOST_COMMAND, + } + private ArcadeManager Manager; private NautHashMap _potionEffectsDuration = new NautHashMap<>(); @@ -103,12 +105,10 @@ public class EventModule extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Manager.GetClients().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SET_HOST_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.SET_HOST_COMMAND, true, true); if (_plugin.getConfig().getString("serverstatus.name").equals("SMTestServer-1")) { - pm.setPermission(PermissionGroup.QA, GroupPermission.of(SET_HOST_COMMAND_PERMISSION), true, true); + PermissionGroup.QA.setPermission(Perm.SET_HOST_COMMAND, true, true); } } @@ -127,7 +127,7 @@ public class EventModule extends MiniPlugin if (!event.getMessage().toLowerCase().startsWith("/sethost ")) return; - if (!Manager.GetClients().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(SET_HOST_COMMAND_PERMISSION))) + if (!Manager.GetClients().Get(event.getPlayer()).hasPermission(Perm.SET_HOST_COMMAND)) { return; } 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 27aa0cfaf..0a280a292 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 @@ -21,7 +21,7 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; import mineplex.core.Managers; -import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.Permission; import mineplex.core.common.Pair; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -41,7 +41,6 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; -import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.moba.boss.BossManager; @@ -80,6 +79,11 @@ import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; public class Moba extends TeamGame { + public enum Perm implements Permission + { + DEBUG_KIT_COMMAND, + } + private static final String[] ITEM_IMAGES = { "Anath_the_Burnt.png", @@ -162,31 +166,27 @@ public class Moba extends TeamGame .setGiveCompassToAlive(false) .register(this); - registerDebugCommand(new DebugCommand("kit", "mineplex.arcade.moba.kit", PermissionGroup.ADMIN) + registerDebugCommand("kit", Perm.DEBUG_KIT_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) + StringBuilder builder = new StringBuilder(); + + for (String arg : args) { - StringBuilder builder = new StringBuilder(); - - for (String arg : args) - { - builder.append(arg).append(" "); - } - - String kit = builder.toString().trim(); - - for (Kit kits : _kits) - { - if (kit.equalsIgnoreCase(kits.GetName())) - { - SetKit(caller, kits, true); - return; - } - } - - caller.sendMessage(F.main("Kit", "Sorry that is not a kit!")); + builder.append(arg).append(" "); } + + String kit = builder.toString().trim(); + + for (Kit kits : _kits) + { + if (kit.equalsIgnoreCase(kits.GetName())) + { + SetKit(caller, kits, true); + return; + } + } + + caller.sendMessage(F.main("Kit", "Sorry that is not a kit!")); }); } 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 5c9e6370b..32de630a6 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 @@ -8,12 +8,12 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.Permission; 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; @@ -22,6 +22,10 @@ import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; public class GoldManager implements Listener { + public enum Perm implements Permission + { + DEBUG_GOLD_COMMAND, + } private static final int GOLD_PER_5 = 20; private static final int GOLD_PER_CAPTURE_5 = 5; @@ -40,28 +44,23 @@ public class GoldManager implements Listener _playerGold = new HashMap<>(); - host.registerDebugCommand(new DebugCommand("gold", "mineplex.arcade.moba.gold.give", PermissionGroup.ADMIN) + host.registerDebugCommand("gold", Perm.DEBUG_GOLD_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) + if (args.length < 1) { - if (args.length < 1) - { - caller.sendMessage(F.main("Debug", "/gold ")); - return; - } + caller.sendMessage(F.main("Debug", "/gold ")); + return; + } - try - { - int amount = Integer.parseInt(args[0]); + try + { + int amount = Integer.parseInt(args[0]); - addGold(caller, amount); - caller.sendMessage(F.main("Debug", "Gave yourself " + F.elem(args[0]) + " gold.")); - } - catch (NumberFormatException e) - { - caller.sendMessage(F.main("Debug", F.elem(args[0]) + " is not a number.")); - } + addGold(caller, amount); + caller.sendMessage(F.main("Debug", "Gave yourself " + F.elem(args[0]) + " gold.")); + } catch (NumberFormatException e) + { + caller.sendMessage(F.main("Debug", F.elem(args[0]) + " is not a number.")); } }); } 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 fc4fb3e4c..75217b8c1 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 @@ -10,19 +10,18 @@ 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.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.Permission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; 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.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; @@ -31,6 +30,11 @@ import nautilus.game.arcade.game.games.moba.util.MobaConstants; public class MinionManager implements Listener { + public enum Perm implements Permission + { + DEBUG_REMOVEMINIONS_COMMAND, + } + private static final long MINION_SPAWN_TIME = TimeUnit.SECONDS.toMillis(30); private final Moba _host; @@ -47,18 +51,14 @@ public class MinionManager implements Listener _waves = new HashSet<>(); _enabled = true; - host.registerDebugCommand(new DebugCommand("removeminions", "mineplex.arcade.moba.minion.remove", PermissionGroup.DEV) + host.registerDebugCommand("removeminions", Perm.DEBUG_REMOVEMINIONS_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) + for (MinionWave wave : _waves) { - for (MinionWave wave : _waves) - { - wave.cleanup(); - } - - caller.sendMessage(F.main("Debug", "Removed all minions.")); + wave.cleanup(); } + + caller.sendMessage(F.main("Debug", "Removed all minions.")); }); } 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 cf09056cc..66f7b2bd1 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 @@ -17,7 +17,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.Permission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -28,7 +28,6 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GemData; import nautilus.game.arcade.game.games.moba.Moba; @@ -68,29 +67,27 @@ public class MobaProgression implements Listener _roleViewers = new HashMap<>(); _roleShop = new MobaRoleShop(host.getArcadeManager()); - host.registerDebugCommand(new DebugCommand("fakeexp", "mineplex.arcade.moba.progression.fakeexp", PermissionGroup.DEV) + host.registerDebugCommand("fakeexp", Perm.DEBUG_FAKEEXP_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) - { - int exp = Integer.parseInt(args[0]); - _host.GetGems(caller).put("Fake Exp", new GemData(exp, false)); - caller.sendMessage(F.main("Debug", "Gave you " + F.elem(exp) + " fake exp.")); - } + int exp = Integer.parseInt(args[0]); + _host.GetGems(caller).put("Fake Exp", new GemData(exp, false)); + caller.sendMessage(F.main("Debug", "Gave you " + F.elem(exp) + " fake exp.")); }); - host.registerDebugCommand(new DebugCommand("setmobalevel", "mineplex.arcade.moba.progression.setlevel", PermissionGroup.DEV) + host.registerDebugCommand("setmobalevel", Perm.DEBUG_SETMOBALEVEL_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) - { - MobaRole role = MobaRole.valueOf(args[0].toUpperCase()); - int exp = getExpFor(Integer.parseInt(args[1]) - 1); - _host.getArcadeManager().GetStatsManager().setStat(caller, _host.GetName() + "." + role.getName() + ".ExpEarned", exp); - caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp) + 1) + ".")); - } + MobaRole role = MobaRole.valueOf(args[0].toUpperCase()); + int exp = getExpFor(Integer.parseInt(args[1]) - 1); + _host.getArcadeManager().GetStatsManager().setStat(caller, _host.GetName() + "." + role.getName() + ".ExpEarned", exp); + caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp) + 1) + ".")); }); } + public enum Perm implements Permission + { + DEBUG_FAKEEXP_COMMAND, + DEBUG_SETMOBALEVEL_COMMAND, + } + public void spawnRoleViewers(Map> lobbyLocations) { Location center = lobbyLocations.get("SPAWN").get(0); 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 0e28cbefd..7455fc567 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 @@ -24,7 +24,7 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; -import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.Permission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -36,10 +36,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.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.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaPlayer; @@ -51,6 +51,10 @@ import nautilus.game.arcade.scoreboard.GameScoreboard; public class MobaTraining extends Moba { + public enum Perm implements Permission + { + DEBUG_SKIP_COMMAND, + } private static final String[] DESCRIPTION = { "Heroes of GWEN", @@ -175,12 +179,10 @@ public class MobaTraining extends Moba if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam)) { suffix = C.cYellow + " Unknown"; - } - else if (mobaPlayer == null || mobaPlayer.getKit() == null) + } else if (mobaPlayer == null || mobaPlayer.getKit() == null) { suffix = C.cYellow + " Selecting"; - } - else + } else { suffix = mobaPlayer.getRole().getChatColor() + " [" + mobaPlayer.getKit().GetName() + "]"; } @@ -192,15 +194,11 @@ public class MobaTraining extends Moba (int) (Math.ceil(subject.getHealth() / 2D))) .register(this); - registerDebugCommand(new DebugCommand("skip", "mineplex.arcade.moba.training.skip", PermissionGroup.PLAYER) + registerDebugCommand("skip", Perm.DEBUG_SKIP_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) + if (!safeFunction.apply(caller)) { - if (!safeFunction.apply(caller)) - { - caller.teleport(GetTeam(ChatColor.YELLOW).GetSpawn()); - } + caller.teleport(GetTeam(ChatColor.YELLOW).GetSpawn()); } }); } 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 f2fd7a722..467ebdb99 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 @@ -32,7 +32,7 @@ import org.bukkit.scheduler.BukkitRunnable; import com.google.common.collect.Sets; -import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.Permission; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -57,7 +57,6 @@ import nautilus.game.arcade.ArcadeFormat; 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.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; @@ -90,6 +89,15 @@ import nautilus.game.arcade.managers.PerkSpreadsheetModule; public abstract class SuperSmash extends Game { + public enum Perm implements Permission + { + DEBUG_LIVES_COMMAND, + DEBUG_KIT_COMMAND, + DEBUG_SMASH_COMMAND, + DEBUG_NEXTSMASH_COMMAND, + DEBUG_COOLDOWN_COMMAND, + } + private static final int MAX_LIVES = 4; private static final int POWERUP_SPAWN_Y_INCREASE = 120; private static final int HUNGER_DELAY = 250; @@ -139,78 +147,58 @@ public abstract class SuperSmash extends Game new PerkSpreadsheetModule(this, "SMASH_KITS"); - registerDebugCommand(new DebugCommand("cooldown", "mineplex.arcade.smash.cooldown", PermissionGroup.ADMIN) + registerDebugCommand("cooldown", Perm.DEBUG_COOLDOWN_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) + for (Player other : UtilServer.getPlayers()) { - for (Player other : UtilServer.getPlayers()) - { - Recharge.Instance.Reset(other); - } - - Announce(C.cWhiteB + caller.getName() + C.cAquaB + " reset cooldowns!"); + Recharge.Instance.Reset(other); } + + Announce(C.cWhiteB + caller.getName() + C.cAquaB + " reset cooldowns!"); }); - registerDebugCommand(new DebugCommand("nextsmash", "mineplex.arcade.smash.nextsmash", PermissionGroup.ADMIN) + registerDebugCommand("nextsmash", Perm.DEBUG_NEXTSMASH_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) - { - _nextPowerup = System.currentTimeMillis() + 1000; - Announce(C.cWhiteB + caller.getName() + C.cAquaB + " spawned a smash crystal!"); - } + _nextPowerup = System.currentTimeMillis() + 1000; + Announce(C.cWhiteB + caller.getName() + C.cAquaB + " spawned a smash crystal!"); }); - registerDebugCommand(new DebugCommand("smash", "mineplex.arcade.smash.smash", PermissionGroup.ADMIN) + registerDebugCommand("smash", Perm.DEBUG_SMASH_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) - { - giveSmashItem(caller); - } + giveSmashItem(caller); }); - registerDebugCommand(new DebugCommand("kit", "mineplex.arcade.smash.kit", PermissionGroup.ADMIN) + registerDebugCommand("kit", Perm.DEBUG_KIT_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) + String kit = ""; + + for (int i = 0; i < args.length; i++) { - String kit = ""; - - for (int i = 0; i < args.length; i++) - { - kit += args[i] + " "; - } - - kit = kit.trim(); - - for (Kit kits : GetKits()) - { - if (kit.equalsIgnoreCase(kits.GetName())) - { - SetKit(caller, kits, true); - return; - } - } - - caller.sendMessage(F.main("Kit", "Sorry that is not a kit!")); + kit += args[i] + " "; } + + kit = kit.trim(); + + for (Kit gkit : GetKits()) + { + if (kit.equalsIgnoreCase(gkit.GetName())) + { + SetKit(caller, gkit, true); + return; + } + } + + caller.sendMessage(F.main("Kit", "Sorry that is not a kit!")); }); - registerDebugCommand(new DebugCommand("lives", "mineplex.arcade.smash.lives", PermissionGroup.ADMIN) + registerDebugCommand("lives", Perm.DEBUG_LIVES_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) + Announce(C.cWhiteB + caller.getName() + C.cAquaB + " reset their lives!"); + + if (!IsAlive(caller)) { - Announce(C.cWhiteB + caller.getName() + C.cAquaB + " reset their lives!"); - - if (!IsAlive(caller)) - { - SetPlayerState(caller, PlayerState.IN); - RespawnPlayer(caller); - caller.sendMessage(F.main("Revive", "You are back in the game!")); - } - - _lives.put(caller, MAX_LIVES); + SetPlayerState(caller, PlayerState.IN); + RespawnPlayer(caller); + caller.sendMessage(F.main("Revive", "You are back in the game!")); } + + _lives.put(caller, MAX_LIVES); }); } 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 35ba49e31..4183d54aa 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 @@ -55,7 +55,7 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; -import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.Permission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; @@ -80,7 +80,6 @@ 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; @@ -102,6 +101,11 @@ import nautilus.game.arcade.stats.BlockPlaceStatTracker; public class SpeedBuilders extends SoloGame { + public enum Perm implements Permission + { + DEBUG_SETNEXT_COMMAND, + } + private static final String GUARDIAN_NAME = "Gwen the Guardian"; //Build Size and some other values used commonly @@ -161,41 +165,41 @@ public class SpeedBuilders extends SoloGame public SpeedBuilders(ArcadeManager manager) { - super(manager, GameType.SpeedBuilders, - new Kit[] - { - new DefaultKit(manager) - }, - new String[] - { - "Recreate the build shown to you.", - "The least correct build is eliminated.", - "Last person left wins!" - }); - + super(manager, GameType.SpeedBuilders, + new Kit[] + { + new DefaultKit(manager) + }, + new String[] + { + "Recreate the build shown to you.", + "The least correct build is eliminated.", + "Last person left wins!" + }); + Damage = false; - + HungerSet = 20; HealthSet = 20; - + DontAllowOverfill = true; - + DeathMessages = false; - + FixSpawnFacing = false; - + AllowParticles = false; - + InventoryClick = true; - + registerStatTrackers( new DependableTracker(this), new FirstBuildTracker(this), new PerfectionistTracker(this), new SpeediestBuilderizerTracker(this), - new BlockPlaceStatTracker(this, new Material[] {}) + new BlockPlaceStatTracker(this, new Material[]{}) ); - + registerQuestTrackers(new PerfectBuildQuestTracker(this)); registerChatStats( @@ -208,51 +212,46 @@ public class SpeedBuilders extends SoloGame .setGiveCompassToSpecs(true) .setGiveCompassToAlive(false) .register(this); - - registerDebugCommand(new DebugCommand("setnext", "mineplex.arcade.speedbuilders.setnext", PermissionGroup.BUILDER) + + registerDebugCommand("setnext", Perm.DEBUG_SETNEXT_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) + if (!UtilServer.isTestServer()) { - 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())) { - 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))); + 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))); + } }); } 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 dc4fe8789..87e94105d 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,9 +6,8 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; 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.NautHashMap; @@ -20,8 +19,11 @@ import nautilus.game.arcade.game.games.typewars.TypeWars.KillType; public class StaffKillMonitorManager implements Listener { - public static final String MONITOR_KILLS_COMMAND_PERMISSION = "mineplex.arcade.typewars.monitorkills"; - + public enum Perm implements Permission + { + MONITOR_KILLS_COMMAND, + } + private TypeWars _host; private String _command = "/words"; @@ -38,9 +40,8 @@ public class StaffKillMonitorManager implements Listener private void generatePermissions() { - PermissionManager pm = _host.Manager.GetClients().getPermissionManager(); - - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(MONITOR_KILLS_COMMAND_PERMISSION), true, true); + + PermissionGroup.TRAINEE.setPermission(Perm.MONITOR_KILLS_COMMAND, true, true); } public TypeWars getHost() @@ -78,7 +79,7 @@ public class StaffKillMonitorManager implements Listener if (!_host.IsLive()) return; - if (!_host.Manager.GetClients().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(MONITOR_KILLS_COMMAND_PERMISSION))) + if (!_host.Manager.GetClients().Get(event.getPlayer()).hasPermission(Perm.MONITOR_KILLS_COMMAND)) return; event.setCancelled(true); 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 4a6b0f9a0..a1bc7f4c5 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 @@ -28,7 +28,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.util.Vector; -import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.Permission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -49,10 +49,10 @@ import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; -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; @@ -75,7 +75,13 @@ import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.world.WorldData; public class TypeWars extends TeamGame -{ +{ + public enum Perm implements Permission + { + DEBUG_MONEY_COMMAND, + DEBUG_BOSS_COMMAND, + } + private List _activeMinions; private List _deadMinions; private List _finishedMinions; @@ -105,21 +111,21 @@ public class TypeWars extends TeamGame public TypeWars(ArcadeManager manager) { super(manager, GameType.TypeWars, - new Kit[] - { - new KitTyper(manager), - }, - new String[] - { - "Protect your Giant from enemy minions.", - "Type minions names to kill them and get money.", - "Spend money on Spells and Minion Spawns.", - "You get ONE free Giant Smash per game.", - "Kill your enemies Giant before they kill yours!" - }); - + new Kit[] + { + new KitTyper(manager), + }, + new String[] + { + "Protect your Giant from enemy minions.", + "Type minions names to kill them and get money.", + "Spend money on Spells and Minion Spawns.", + "You get ONE free Giant Smash per game.", + "Kill your enemies Giant before they kill yours!" + }); + new StaffKillMonitorManager(this); - + this.DeathOut = false; this.DamageTeamSelf = false; this.DamageSelf = false; @@ -140,7 +146,7 @@ public class TypeWars extends TeamGame this.EnableTutorials = true; this.PrepareFreeze = true; this.AllowParticles = false; - + _activeMinions = new ArrayList<>(); _deadMinions = new ArrayList<>(); _finishedMinions = new ArrayList<>(); @@ -157,10 +163,10 @@ public class TypeWars extends TeamGame _giantsAttacked = new HashMap<>(); _playerTitles = new HashSet<>(); _giantLocs = new HashMap<>(); - + _animationTicks = 0; _nukeFrame = 0; - + registerStatTrackers( new DemonStatsTracker(this), new DumbledontStatTracker(this), @@ -169,12 +175,12 @@ public class TypeWars extends TeamGame new WaitForItStatTracker(this), new KillsStatTracker(this), new TimeInGameTracker(this) - ); + ); registerChatStats( new ChatStatData("MinionKills", "Kills", true) ); - + manager.GetCreature().SetDisableCustomDrops(true); new CompassModule() @@ -187,38 +193,31 @@ public class TypeWars extends TeamGame .giveTeamArmor() .giveHotbarItem() .register(this); - - registerDebugCommand(new DebugCommand("money", "mineplex.arcade.type.money", PermissionGroup.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", PermissionGroup.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")); - } + registerDebugCommand("money", Perm.DEBUG_MONEY_COMMAND, (caller, args) -> + { + _moneyMap.put(caller, 1000); + UtilPlayer.message(caller, F.main("Money", "You got some Money")); + }); + registerDebugCommand("boss", Perm.DEBUG_BOSS_COMMAND, (caller, 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")); } + ; }); } 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 81e617260..4c9568e64 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 @@ -70,7 +70,7 @@ import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.spigotmc.ActivationRange; -import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.Permission; import mineplex.core.boosters.event.BoosterItemGiveEvent; import mineplex.core.common.Pair; import mineplex.core.common.util.C; @@ -102,7 +102,6 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; -import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.AbsorptionFix; @@ -128,6 +127,19 @@ import nautilus.game.arcade.kit.Kit; public abstract class UHC extends Game { + public enum Perm implements Permission + { + DEBUG_ENTITIES_COMMAND, + DEBUG_CHUNK_COMMAND, + DEBUG_WORLDINFO_COMMAND, + DEBUG_STARTPVP_COMMAND, + DEBUG_UHCGAMES_COMMAND, + DEBUG_SETCOMBATLOGTIMEOUT_COMMAND, + DEBUG_DEATHMATCH_COMMAND, + DEBUG_CALLCHUNKS_COMMAND, + DEBUG_GC_COMMAND, + } + private static int _gamesRun = 0; public static final int VIEW_DISTANCE = 5; @@ -196,9 +208,9 @@ public abstract class UHC extends Game @SuppressWarnings("unchecked") public UHC(ArcadeManager manager, GameType type, boolean speedMode) { - super(manager, type, new Kit[] { new KitUHC(manager) }, + super(manager, type, new Kit[]{new KitUHC(manager)}, - new String[] { "10 minutes of no PvP", "Only Golden Apples restore health", "Ores can only be found in caves", "Borders shrink over time", "Last player/team alive wins!" }); + new String[]{"10 minutes of no PvP", "Only Golden Apples restore health", "Ores can only be found in caves", "Borders shrink over time", "Last player/team alive wins!"}); _gamesRun++; @@ -298,241 +310,239 @@ public abstract class UHC extends Game registerStatTrackers(new CollectFoodStat(this), new HoeCraftingStat(this), new LuckyMinerStat(this), new HalfHeartHealStat(this)); registerQuestTrackers(new TameQuestTracker(this)); - - registerDebugCommand(new DebugCommand("startpvp", "mineplex.arcade.uhc.startpvp", PermissionGroup.ADMIN) + + registerDebugCommand("startpvp", Perm.DEBUG_STARTPVP_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) + if (!IsLive()) { - if (!IsLive()) - { - UtilPlayer.message(caller, F.main("Debug", "You can't start the game right now!")); - return; - } - if (_state.isPVP()) - { - UtilPlayer.message(caller, F.main("Debug", "PvP has already been started!")); - return; - } - - MINING_TIME -= SAFE_TIME; - SAFE_TIME = 0; - - startPvp(); - UtilPlayer.message(caller, F.main("Debug", "Started PvP")); - } - }); - - registerDebugCommand(new DebugCommand("worldinfo", "mineplex.arcade.uhc.worldinfo", PermissionGroup.ADMIN) - { - @Override - public void Execute(Player caller, String[] args) - { - if (args == null || args.length == 0) - { - UtilPlayer.message(caller, F.main("Debug", "Loaded worlds:")); - UtilPlayer.message(caller, F.desc("Bukkit Worlds", Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.joining(", ")))); - UtilPlayer.message(caller, F.desc("NMS Worlds", MinecraftServer.getServer().worlds.stream().map(net.minecraft.server.v1_8_R3.WorldServer::getWorldData).map( - net.minecraft.server.v1_8_R3.WorldData::getName).collect(Collectors.joining(", ")))); - return; - } - if (args[0].equals("info")) - { - if (args.length > 1) - { - String worldName = args[1]; - World targetWorld = null; - - if (worldName.startsWith("b:")) - { - targetWorld = Bukkit.getWorlds().stream().filter(world -> world.getName().replace(" ", "").equals(worldName.substring(2))).findAny().orElse(null); - } - else if (worldName.startsWith("n:")) - { - WorldServer world = MinecraftServer.getServer().worlds.stream().filter(ws -> ws.getWorldData().getName().replace(" ", "").equals(worldName.substring(2))).findAny().orElse( - null); - if (world != null) - { - targetWorld = world.getWorld(); - } - } - else - { - UtilPlayer.message(caller, F.main("Debug", "No world type specified")); - return; - } - - if (targetWorld != null) - { - WorldServer nmsWorld = ((CraftWorld) targetWorld).getHandle(); - Chunk[] chunks = targetWorld.getLoadedChunks(); - UtilPlayer.message(caller, F.main("Debug", "World info for " + targetWorld.getName())); - UtilPlayer.message(caller, F.desc("Chunks", String.valueOf(chunks.length))); - UtilPlayer.message(caller, F.desc("Entities", String.valueOf(targetWorld.getEntities().size()))); - UtilPlayer.message(caller, F.desc("Tile Entities", String.valueOf(Arrays.stream(chunks).map(Chunk::getTileEntities).map(Arrays::asList).mapToLong(Collection::size).sum()))); - UtilPlayer.message(caller, F.desc("View Distance", String.valueOf(nmsWorld.spigotConfig.viewDistance))); - UtilPlayer.message(caller, F.desc("Unload queue size", String.valueOf(nmsWorld.chunkProviderServer.unloadQueue.size()))); - - try - { - Field f = nmsWorld.getClass().getDeclaredField("M"); - f.setAccessible(true); - HashTreeSet m = (HashTreeSet) f.get(nmsWorld); - - UtilPlayer.message(caller, F.desc("Pending tick", String.valueOf(m.size()))); - } - catch (ReflectiveOperationException e) - { - e.printStackTrace(); - } - } - else - { - UtilPlayer.message(caller, F.main("Debug", "That world was not found")); - } - } - else - { - UtilPlayer.message(caller, F.main("Debug", "No world specified")); - } - } - else if (args[0].equals("chunks")) - { - - if (args.length > 1) - { - String worldName = args[1]; - World targetWorld = null; - - if (worldName.startsWith("b:")) - { - targetWorld = Bukkit.getWorlds().stream().filter(world -> world.getName().replace(" ", "").equals(worldName.substring(2))).findAny().orElse(null); - } - else if (worldName.startsWith("n:")) - { - WorldServer world = MinecraftServer.getServer().worlds.stream().filter(ws -> ws.getWorldData().getName().replace(" ", "").equals(worldName.substring(2))).findAny().orElse( - null); - if (world != null) - { - targetWorld = world.getWorld(); - } - } - else - { - UtilPlayer.message(caller, F.main("Debug", "No world type specified")); - return; - } - - if (targetWorld != null) - { - String message = Arrays.stream(targetWorld.getLoadedChunks()).map(chunk -> "(" + chunk.getX() + "," + chunk.getZ() + ")").collect(Collectors.joining(",")); - System.out.println("Chunks: " + message); - if (message.getBytes(StandardCharsets.UTF_8).length < 32767) - { - caller.sendMessage(message); - } - } - else - { - UtilPlayer.message(caller, F.main("Debug", "That world was not found")); - } - } - else - { - UtilPlayer.message(caller, F.main("Debug", "No world specified")); - } - } + UtilPlayer.message(caller, F.main("Debug", "You can't start the game right now!")); return; } - }); - registerDebugCommand(new DebugCommand("uhcgames", "mineplex.arcade.uhc.uhcgames", PermissionGroup.ADMIN) - { - @Override - public void Execute(Player caller, String[] args) + if (_state.isPVP()) { - UtilPlayer.message(caller, F.main("Debug", "As of now, there have been " + _gamesRun + " games played")); + UtilPlayer.message(caller, F.main("Debug", "PvP has already been started!")); + return; } + + MINING_TIME -= SAFE_TIME; + SAFE_TIME = 0; + + startPvp(); + UtilPlayer.message(caller, F.main("Debug", "Started PvP")); }); - registerDebugCommand(new DebugCommand("uhcgc", "mineplex.arcade.uhc.gc", PermissionGroup.DEV) + + registerDebugCommand("worldinfo", Perm.DEBUG_WORLDINFO_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) + if (args == null || args.length == 0) { - System.gc(); - UtilPlayer.message(caller, F.main("Debug", "Cleaned up!")); + UtilPlayer.message(caller, F.main("Debug", "Loaded worlds:")); + UtilPlayer.message(caller, F.desc("Bukkit Worlds", Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.joining(", ")))); + UtilPlayer.message(caller, F.desc("NMS Worlds", MinecraftServer.getServer().worlds.stream().map(WorldServer::getWorldData).map( + net.minecraft.server.v1_8_R3.WorldData::getName).collect(Collectors.joining(", ")))); + return; } - }); - registerDebugCommand(new DebugCommand("setcombatlogtimeout", "mineplex.arcade.uhc.combatlogtimeout", PermissionGroup.DEV) - { - @Override - public void Execute(Player caller, String[] args) + if (args[0].equals("info")) { - CombatLogModule module = getModule(CombatLogModule.class); - if (module == null) + if (args.length > 1) { - UtilPlayer.message(caller, F.main("Debug", "The combat log module has not been loaded yet")); - return; - } + String worldName = args[1]; + World targetWorld = null; - if (args.length == 0) - { - UtilPlayer.message(caller, F.main("Debug", "No timeout specified")); - return; - } + if (worldName.startsWith("b:")) + { + targetWorld = Bukkit.getWorlds().stream().filter(world -> world.getName().replace(" ", "").equals(worldName.substring(2))).findAny().orElse(null); + } else if (worldName.startsWith("n:")) + { + WorldServer world = MinecraftServer.getServer().worlds.stream().filter(ws -> ws.getWorldData().getName().replace(" ", "").equals(worldName.substring(2))).findAny().orElse( + null); + if (world != null) + { + targetWorld = world.getWorld(); + } + } else + { + UtilPlayer.message(caller, F.main("Debug", "No world type specified")); + return; + } - try + if (targetWorld != null) + { + WorldServer nmsWorld = ((CraftWorld) targetWorld).getHandle(); + Chunk[] chunks = targetWorld.getLoadedChunks(); + UtilPlayer.message(caller, F.main("Debug", "World info for " + targetWorld.getName())); + UtilPlayer.message(caller, F.desc("Chunks", String.valueOf(chunks.length))); + UtilPlayer.message(caller, F.desc("Entities", String.valueOf(targetWorld.getEntities().size()))); + UtilPlayer.message(caller, F.desc("Tile Entities", String.valueOf(Arrays.stream(chunks).map(Chunk::getTileEntities).map(Arrays::asList).mapToLong(Collection::size).sum()))); + UtilPlayer.message(caller, F.desc("View Distance", String.valueOf(nmsWorld.spigotConfig.viewDistance))); + UtilPlayer.message(caller, F.desc("Unload queue size", String.valueOf(nmsWorld.chunkProviderServer.unloadQueue.size()))); + + try + { + Field f = nmsWorld.getClass().getDeclaredField("M"); + f.setAccessible(true); + HashTreeSet m = (HashTreeSet) f.get(nmsWorld); + + UtilPlayer.message(caller, F.desc("Pending tick", String.valueOf(m.size()))); + } catch (ReflectiveOperationException e) + { + e.printStackTrace(); + } + } else + { + UtilPlayer.message(caller, F.main("Debug", "That world was not found")); + } + } else { - int timeout = Integer.parseInt(args[0]); - module.setCombatLogTime(timeout); - getModule(RejoinModule.class).setRejoinTime(timeout); - UtilPlayer.message(caller, F.main("Debug", "Set the new timeout to " + timeout)); + UtilPlayer.message(caller, F.main("Debug", "No world specified")); } - catch (NumberFormatException ex) + } else if (args[0].equals("chunks")) + { + + if (args.length > 1) { - UtilPlayer.message(caller, F.main("Debug", "That's not a number!")); + String worldName = args[1]; + World targetWorld = null; + + if (worldName.startsWith("b:")) + { + targetWorld = Bukkit.getWorlds().stream().filter(world -> world.getName().replace(" ", "").equals(worldName.substring(2))).findAny().orElse(null); + } else if (worldName.startsWith("n:")) + { + WorldServer world = MinecraftServer.getServer().worlds.stream().filter(ws -> ws.getWorldData().getName().replace(" ", "").equals(worldName.substring(2))).findAny().orElse( + null); + if (world != null) + { + targetWorld = world.getWorld(); + } + } else + { + UtilPlayer.message(caller, F.main("Debug", "No world type specified")); + return; + } + + if (targetWorld != null) + { + String message = Arrays.stream(targetWorld.getLoadedChunks()).map(chunk -> "(" + chunk.getX() + "," + chunk.getZ() + ")").collect(Collectors.joining(",")); + System.out.println("Chunks: " + message); + if (message.getBytes(StandardCharsets.UTF_8).length < 32767) + { + caller.sendMessage(message); + } + } else + { + UtilPlayer.message(caller, F.main("Debug", "That world was not found")); + } + } else + { + UtilPlayer.message(caller, F.main("Debug", "No world specified")); } } + return; }); - registerDebugCommand(new DebugCommand("dm", "mineplex.arcade.uhc.deathmatch", PermissionGroup.ADMIN) + registerDebugCommand("uhcgames", Perm.DEBUG_UHCGAMES_COMMAND, (caller, args) -> { - - @Override - public void Execute(Player caller, String[] args) + UtilPlayer.message(caller, F.main("Debug", "As of now, there have been " + _gamesRun + " games played")); + }); + registerDebugCommand("uhcgc", Perm.DEBUG_GC_COMMAND, (caller, args) -> + { + System.gc(); + UtilPlayer.message(caller, F.main("Debug", "Cleaned up!")); + }); + registerDebugCommand("setcombatlogtimeout", Perm.DEBUG_SETCOMBATLOGTIMEOUT_COMMAND, (caller, args) -> + { + CombatLogModule module = getModule(CombatLogModule.class); + if (module == null) { - SAFE_TIME = 0; - MINING_TIME = 1000; - startPreDeathmatch(); - UtilPlayer.message(caller, F.main("Debug", "Starting deathmatch")); + UtilPlayer.message(caller, F.main("Debug", "The combat log module has not been loaded yet")); + return; + } + + if (args.length == 0) + { + UtilPlayer.message(caller, F.main("Debug", "No timeout specified")); + return; + } + + try + { + int timeout = Integer.parseInt(args[0]); + module.setCombatLogTime(timeout); + getModule(RejoinModule.class).setRejoinTime(timeout); + UtilPlayer.message(caller, F.main("Debug", "Set the new timeout to " + timeout)); + } catch (NumberFormatException ex) + { + UtilPlayer.message(caller, F.main("Debug", "That's not a number!")); } }); - registerDebugCommand(new DebugCommand("uhcentities", "mineplex.arcade.uhc.entities", PermissionGroup.DEV) + registerDebugCommand("dm", Perm.DEBUG_DEATHMATCH_COMMAND, (caller, args) -> { - - @Override - public void Execute(Player caller, String[] args) + SAFE_TIME = 0; + MINING_TIME = 1000; + startPreDeathmatch(); + UtilPlayer.message(caller, F.main("Debug", "Starting deathmatch")); + }); + registerDebugCommand("uhcentities", Perm.DEBUG_ENTITIES_COMMAND, (caller, args) -> + { + for (Entity entity : caller.getNearbyEntities(5.0, 5.0, 5.0)) { - for (Entity entity : caller.getNearbyEntities(5.0, 5.0, 5.0)) + net.minecraft.server.v1_8_R3.Entity nms = ((CraftEntity) entity).getHandle(); + String debug = "Entity: " + entity.getType() + " id:" + nms.getId() + " inac:" + ActivationRange.checkIfActive(nms); + debug += " at:" + nms.activatedTick + " dac:" + nms.defaultActivationState; + + int x = MathHelper.floor(nms.locX); + int z = MathHelper.floor(nms.locZ); + + net.minecraft.server.v1_8_R3.Chunk chunk = nms.world.getChunkIfLoaded(x >> 4, z >> 4); + debug += " c:" + chunk + " il:" + (chunk != null ? chunk.areNeighborsLoaded(1) : "null"); + caller.sendMessage(debug); + } + }); + registerDebugCommand("uhcchunk", Perm.DEBUG_CHUNK_COMMAND, (caller, args) -> + { + net.minecraft.server.v1_8_R3.Chunk chunk = ((CraftChunk) caller.getLocation().getChunk()).getHandle(); + try + { + Field neighbors = chunk.getClass().getDeclaredField("neighbors"); + neighbors.setAccessible(true); + int n = neighbors.getInt(chunk); + + for (int x = -1; x < 2; x++) { - net.minecraft.server.v1_8_R3.Entity nms = ((CraftEntity) entity).getHandle(); - String debug = "Entity: " + entity.getType() + " id:" + nms.getId() + " inac:" + ActivationRange.checkIfActive(nms); - debug += " at:" + nms.activatedTick + " dac:" + nms.defaultActivationState; + for (int z = -1; z < 2; z++) + { + if (x == 0 && z == 0) + { + continue; + } - int x = MathHelper.floor(nms.locX); - int z = MathHelper.floor(nms.locZ); + int mask = 0x1 << (x * 5 + z + 12); - net.minecraft.server.v1_8_R3.Chunk chunk = nms.world.getChunkIfLoaded(x >> 4, z >> 4); - debug += " c:" + chunk + " il:" + (chunk != null ? chunk.areNeighborsLoaded(1) : "null"); - caller.sendMessage(debug); + boolean should = chunk.world.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z) != null; + boolean is = (n & mask) == mask; + if (is && should) + { + caller.sendMessage(ChatColor.GREEN + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is a neighbor"); + } else if (is && !should) + { + caller.sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is a neighbor but should not be"); + } else if (!is && should) + { + caller.sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is not a neighbor but should be"); + } else if (!is && !should) + { + caller.sendMessage(ChatColor.GREEN + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is not a neighbor"); + } + } } + } catch (Throwable t) + { + t.printStackTrace(); } }); - registerDebugCommand(new DebugCommand("uhcchunk", "mineplex.arcade.uhc.chunk", PermissionGroup.DEV) + registerDebugCommand("uhcallchunks", Perm.DEBUG_CALLCHUNKS_COMMAND, (caller, args) -> { - - @Override - public void Execute(Player caller, String[] args) + for (net.minecraft.server.v1_8_R3.Chunk chunk : ((CraftWorld) caller.getWorld()).getHandle().chunkProviderServer.chunks.values()) { - net.minecraft.server.v1_8_R3.Chunk chunk = ((CraftChunk) caller.getLocation().getChunk()).getHandle(); try { Field neighbors = chunk.getClass().getDeclaredField("neighbors"); @@ -552,79 +562,24 @@ public abstract class UHC extends Game boolean should = chunk.world.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z) != null; boolean is = (n & mask) == mask; - if (is && should) + if (is && !should) { - caller.sendMessage(ChatColor.GREEN + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is a neighbor"); - } - else if (is && !should) + caller.sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") relative to " + (chunk.locX) + "," + chunk.locZ + + " is a neighbor but should not be"); + } else if (!is && should) { - caller.sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is a neighbor but should not be"); - } - else if (!is && should) - { - caller.sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is not a neighbor but should be"); - } - else if (!is && !should) - { - caller.sendMessage(ChatColor.GREEN + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") is not a neighbor"); + caller.sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") relative to " + (chunk.locX) + "," + chunk.locZ + + " is not a neighbor but should be"); } } } - } - catch (Throwable t) + } catch (Throwable t) { t.printStackTrace(); } } - }); - registerDebugCommand(new DebugCommand("uhcallchunks", "mineplex.arcade.uhc.callchunks", PermissionGroup.DEV) - { - @Override - public void Execute(Player caller, String[] args) - { - for (net.minecraft.server.v1_8_R3.Chunk chunk : ((CraftWorld) caller.getWorld()).getHandle().chunkProviderServer.chunks.values()) - { - try - { - Field neighbors = chunk.getClass().getDeclaredField("neighbors"); - neighbors.setAccessible(true); - int n = neighbors.getInt(chunk); - - for (int x = -1; x < 2; x++) - { - for (int z = -1; z < 2; z++) - { - if (x == 0 && z == 0) - { - continue; - } - - int mask = 0x1 << (x * 5 + z + 12); - - boolean should = chunk.world.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z) != null; - boolean is = (n & mask) == mask; - if (is && !should) - { - caller.sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") relative to " + (chunk.locX) + "," + chunk.locZ - + " is a neighbor but should not be"); - } - else if (!is && should) - { - caller.sendMessage(ChatColor.RED + "Chunk " + (chunk.locX + x) + "," + (chunk.locZ + z) + " (" + x + "," + z + ") relative to " + (chunk.locX) + "," + chunk.locZ - + " is not a neighbor but should be"); - } - } - } - } - catch (Throwable t) - { - t.printStackTrace(); - } - } - - caller.sendMessage("Done"); - } + caller.sendMessage("Done"); }); } 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 d14585e14..267590ac4 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,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.account.permissions.Permission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; @@ -22,12 +22,16 @@ 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 { + public enum Perm implements Permission + { + DEBUG_REJOIN_COMMAND, + } + private Set _data = new HashSet<>(); private int _rejoinTime = (int) TimeUnit.MINUTES.toMillis(2); @@ -35,35 +39,30 @@ public class RejoinModule extends Module @Override protected void setup() { - getGame().registerDebugCommand(new DebugCommand("rejoin", "mineplex.arcade.rejoin.command", PermissionGroup.ADMIN) + getGame().registerDebugCommand("rejoin", Perm.DEBUG_REJOIN_COMMAND, (caller, args) -> { - @Override - public void Execute(Player caller, String[] args) + if (args.length < 1) { - if (args.length < 1) - { - caller.sendMessage(F.main("Debug", "/rejoin ")); - return; - } - - String player = args[0]; - - RejoinPlayerData data = getRejoinPlayerData(player); - - // Player wasn't alive earlier or was too slow - if (data == null) - { - _data.add(new RejoinPlayerData(player, 20, null, null)); - } - else - { - caller.sendMessage(F.main("Debug", "That player is already allowed to rejoin!")); - return; - } - - caller.sendMessage(F.main("Debug", C.cYellow + player + C.cGray + " is now allowed to rejoin. If they are online tell them to relog.")); - caller.sendMessage(F.main("Debug", "There are issues with this and it should not be used outside of the testing environment!")); + caller.sendMessage(F.main("Debug", "/rejoin ")); + return; } + + String player = args[0]; + + RejoinPlayerData data = getRejoinPlayerData(player); + + // Player wasn't alive earlier or was too slow + if (data == null) + { + _data.add(new RejoinPlayerData(player, 20, null, null)); + } else + { + caller.sendMessage(F.main("Debug", "That player is already allowed to rejoin!")); + return; + } + + caller.sendMessage(F.main("Debug", C.cYellow + player + C.cGray + " is now allowed to rejoin. If they are online tell them to relog.")); + caller.sendMessage(F.main("Debug", "There are issues with this and it should not be used outside of the testing environment!")); }); } 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 2e9dd58ae..1d3c5c21a 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 @@ -9,11 +9,11 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.shop.item.ShopItem; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.gui.privateServer.PrivateServerShop; import nautilus.game.arcade.gui.privateServer.button.BanButton; @@ -44,7 +44,7 @@ public class MenuPage extends BasePage addButton(4, getOwnerHead(), new PlayerHeadButton(getPlugin(), this)); boolean host = _manager.isHost(getPlayer()); - boolean disableChangeButtons = !getClientManager().getPermissionManager().hasPermission(getPlayer(), GroupPermission.of(ArcadeManager.USE_MENU_DURING_GAME_PERMISSION)) && getPlugin().isGameInProgress(); + boolean disableChangeButtons = !getClientManager().Get(getPlayer()).hasPermission(ArcadeManager.Perm.USE_MENU_DURING_GAME) && getPlugin().isGameInProgress(); { // Change Buttons - If a game is in progress and user isn't Youtube+ rank, they cannot 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 114657691..e332af27d 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 @@ -5,6 +5,10 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import net.minecraft.server.v1_8_R3.EntityFireworks; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityStatus; +import net.minecraft.server.v1_8_R3.World; + import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -24,7 +28,6 @@ import org.bukkit.scheduler.BukkitRunnable; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -40,13 +43,11 @@ import mineplex.core.progression.math.Calculations; import mineplex.core.shop.confirmation.ConfirmationPage; import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.SalesPackageProcessor; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.games.evolution.Evolution; import nautilus.game.arcade.shop.KitPackage; -import net.minecraft.server.v1_8_R3.EntityFireworks; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityStatus; -import net.minecraft.server.v1_8_R3.World; /** * Kit wrapper for all new kits @@ -381,12 +382,12 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit { Donor donor = Manager.GetDonation().Get(player); - if (this.GetAvailability() == KitAvailability.Free || - 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().getPermissionManager().hasPermission(player, GroupPermission.of(ArcadeManager.KIT_ACCESS_PERMISSION)) || - donor.ownsUnknownSalesPackage(Manager.GetServerConfig().ServerType + " ULTRA") || Manager.GetServerConfig().Tournament) + if (this.GetAvailability() == KitAvailability.Free || + 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).hasPermission(ArcadeManager.Perm.KIT_ACCESS) || + donor.ownsUnknownSalesPackage(Manager.GetServerConfig().ServerType + " ULTRA") || Manager.GetServerConfig().Tournament) { return true; } 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 2b4016893..913432715 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 @@ -48,9 +48,8 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.util.Vector; import mineplex.core.Managers; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.antihack.AntiHack; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -86,8 +85,11 @@ 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"; - + public enum Perm implements Permission + { + BYPASS_TELEPORT_KICK, + } + ArcadeManager Manager; SecondaryDamageManager Secondary; private Map _respawnTimers = new HashMap<>(); @@ -104,13 +106,11 @@ public class GameFlagManager implements Listener private void generatePermissions() { - PermissionManager pm = Manager.GetClients().getPermissionManager(); - - pm.setPermission(PermissionGroup.DEV, GroupPermission.of(BYPASS_TELEPORT_KICK_PERMISSION), true, true); + PermissionGroup.DEV.setPermission(Perm.BYPASS_TELEPORT_KICK, true, true); if (UtilServer.isTestServer()) { - pm.setPermission(PermissionGroup.QA, GroupPermission.of(BYPASS_TELEPORT_KICK_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(BYPASS_TELEPORT_KICK_PERMISSION), true, true); + PermissionGroup.QA.setPermission(Perm.BYPASS_TELEPORT_KICK, true, true); + PermissionGroup.ADMIN.setPermission(Perm.BYPASS_TELEPORT_KICK, true, true); } } @@ -1031,8 +1031,8 @@ public class GameFlagManager implements Listener { if (event.isCancelled()) return; - - if (Manager.GetClients().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(BYPASS_TELEPORT_KICK_PERMISSION))) + + if (Manager.GetClients().Get(event.getPlayer()).hasPermission(Perm.BYPASS_TELEPORT_KICK)) return; Game game = Manager.GetGame(); 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 01045f9a9..455ef8c40 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 @@ -26,9 +26,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.antihack.AntiHack; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -47,6 +46,7 @@ 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; @@ -56,9 +56,13 @@ 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."; - + public enum Perm implements Permission + { + AUTO_ADMIN_ACCESS, + INCREASE_MAX_PLAYERS_60, + INCREASE_MAX_PLAYERS_100, + } + private final AntiHack _antiHack; private List _games = new ArrayList<>(); @@ -161,13 +165,11 @@ public class GameHostManager implements Listener private void generatePermissions() { - PermissionManager pm = Manager.GetClients().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(AUTO_ADMIN_ACCESS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.SRMOD, GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 2), true, true); - pm.setPermission(PermissionGroup.ETERNAL, GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 1), true, true); - pm.setPermission(PermissionGroup.CONTENT, GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 2), true, true); - pm.setPermission(PermissionGroup.YT, GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 2), false, false); + PermissionGroup.ADMIN.setPermission(Perm.AUTO_ADMIN_ACCESS, true, true); + PermissionGroup.SRMOD.setPermission(Perm.INCREASE_MAX_PLAYERS_100, true, true); + PermissionGroup.ETERNAL.setPermission(Perm.INCREASE_MAX_PLAYERS_60, true, true); + PermissionGroup.CONTENT.setPermission(Perm.INCREASE_MAX_PLAYERS_100, true, true); + PermissionGroup.YT.setPermission(Perm.INCREASE_MAX_PLAYERS_100, false, false); } public ArrayList hasWarning() @@ -248,7 +250,7 @@ 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)); + boolean alwaysAllow = Manager.GetClients().Get(p.getUniqueId()).hasPermission(ArcadeManager.Perm.BYPASS_MPS_WHITELIST); if (alwaysAllow) { @@ -575,9 +577,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().getPermissionManager().hasPermission(player, GroupPermission.of(AUTO_ADMIN_ACCESS_PERMISSION))); + return (getOwner().getMembers().containsKey(player.getUniqueId()) && getOwner().getMembers().get(player.getUniqueId()).Role.ordinal() <= CommunityRole.COLEADER.ordinal()) || (includeStaff && Manager.GetClients().Get(player).hasPermission(Perm.AUTO_ADMIN_ACCESS)); } - return player.equals(_host) || _adminList.contains(player.getName()) || (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).hasPermission(Perm.AUTO_ADMIN_ACCESS)); } public boolean isHost(Player player) @@ -634,19 +636,18 @@ public class GameHostManager implements Listener } } - public boolean hasPermission(GroupPermission permission) + public boolean hasPermission(Permission permission) { - PermissionManager pm = Manager.GetClients().getPermissionManager(); if (isCommunityServer()) { - return pm.hasPermission(PermissionGroup.ETERNAL, permission); + return PermissionGroup.ETERNAL.hasPermission(permission); } if (_hostRank == null) { return false; } - return pm.hasPermission(_hostRank, permission); + return _hostRank.hasPermission(permission); } public List getAvailableGames(Player player) @@ -778,11 +779,11 @@ public class GameHostManager implements Listener { return 20; } - if (hasPermission(GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 2))) + if (hasPermission(Perm.INCREASE_MAX_PLAYERS_100)) { return 100; } - else if (hasPermission(GroupPermission.of(INCREASE_MAX_PLAYERS_LEVEL_PERMISSION + 1))) + else if (hasPermission(Perm.INCREASE_MAX_PLAYERS_60)) { return 60; } 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 59f4d11f6..9dfbe132a 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.account.permissions.GroupPermission; +import mineplex.core.account.CoreClient; +import mineplex.core.account.permissions.Permission; 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.UtilAlg; @@ -38,8 +38,13 @@ 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."; - + public enum Perm implements Permission + { + LOOT_CHANCE_MULT_1_6, + LOOT_CHANCE_MULT_1_4, + LOOT_CHANCE_MULT_1_2, + } + private ArcadeManager Manager; private RewardManager _rewardManager; @@ -71,11 +76,10 @@ public class GameLootManager implements Listener private void generatePermissions() { - PermissionManager pm = Manager.GetClients().getPermissionManager(); - - pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 1), true, true); - pm.setPermission(PermissionGroup.HERO, GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 2), true, true); - pm.setPermission(PermissionGroup.LEGEND, GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 3), true, true); + + PermissionGroup.ULTRA.setPermission(Perm.LOOT_CHANCE_MULT_1_2, true, true); + PermissionGroup.HERO.setPermission(Perm.LOOT_CHANCE_MULT_1_4, true, true); + PermissionGroup.LEGEND.setPermission(Perm.LOOT_CHANCE_MULT_1_6, true, true); } @EventHandler @@ -145,26 +149,21 @@ public class GameLootManager implements Listener if (!force) { double chance = Math.min(0.5, 0.1 + (System.currentTimeMillis() - _startTime)/3600000d); - - if (Manager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 1))) + + CoreClient client = Manager.GetClients().Get(player); + if (client.hasPermission(Perm.LOOT_CHANCE_MULT_1_6)) { - if (Manager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 2))) - { - if (Manager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(LOOT_CHANCE_MULT_LEVEL_PERMISSION + 3))) - { - chance *= 1.6; - } - else - { - chance *= 1.4; - } - } - else - { - chance *= 1.2; - } + chance *= 1.6; } - + else if (client.hasPermission(Perm.LOOT_CHANCE_MULT_1_4)) + { + chance *= 1.4; + } + else if (client.hasPermission(Perm.LOOT_CHANCE_MULT_1_2)) + { + chance *= 1.2; + } + if (Math.random() > chance) { return false; 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 28959fe0f..225a22136 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 @@ -3,6 +3,8 @@ package nautilus.game.arcade.managers; import java.lang.reflect.Field; import java.util.HashMap; +import net.minecraft.server.v1_8_R3.EntityHuman; + import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; @@ -14,9 +16,8 @@ import org.bukkit.event.player.PlayerQuitEvent; import com.mojang.authlib.GameProfile; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; 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; @@ -29,6 +30,7 @@ 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; @@ -39,13 +41,20 @@ 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 enum Perm implements Permission + { + SHARD_MULT_1, + SHARD_MULT_2, + SHARD_MULT_3, + SHARD_MULT_4, + SHARD_MULT_5, + } public static final String SHARD_MULT_LEVEL_PERMISSION = "mineplex.arcade.reward."; ArcadeManager Manager; @@ -63,13 +72,12 @@ public class GameRewardManager implements Listener private void generatePermissions() { - PermissionManager pm = Manager.GetClients().getPermissionManager(); - - pm.setPermission(PermissionGroup.ULTRA, GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 1), true, true); - pm.setPermission(PermissionGroup.HERO, GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 2), true, true); - pm.setPermission(PermissionGroup.LEGEND, GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 3), true, true); - pm.setPermission(PermissionGroup.TITAN, GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 4), true, true); - pm.setPermission(PermissionGroup.ETERNAL, GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + 5), true, true); + + PermissionGroup.ULTRA.setPermission(Perm.SHARD_MULT_1, true, true); + PermissionGroup.HERO.setPermission(Perm.SHARD_MULT_2, true, true); + PermissionGroup.LEGEND.setPermission(Perm.SHARD_MULT_3, true, true); + PermissionGroup.TITAN.setPermission(Perm.SHARD_MULT_4, true, true); + PermissionGroup.ETERNAL.setPermission(Perm.SHARD_MULT_5, true, true); } @EventHandler @@ -240,15 +248,15 @@ public class GameRewardManager implements Listener int accountId = Manager.GetClients().getAccountId(player); double shardMult = 0; - - for (int i = 1; i < 6; i++) + + for (Perm shardMultPerm : Perm.values()) { - if (Manager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + i))) + if (Manager.GetClients().Get(player).hasPermission(shardMultPerm)) { shardMult += 0.5; } } - + if (shardMult > 0) { shardsToReward *= shardMult; @@ -401,10 +409,10 @@ public class GameRewardManager implements Listener double extraMult = 0; PermissionGroup group = Manager.GetClients().Get(player).getPrimaryGroup(); - - for (int i = 1; i < 6; i++) + + for (Perm shardMultPerm : Perm.values()) { - if (Manager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(SHARD_MULT_LEVEL_PERMISSION + i))) + if (Manager.GetClients().Get(player).hasPermission(shardMultPerm)) { extraMult += 0.5; } 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 46776694d..f9b20dc52 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,9 +12,8 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -27,8 +26,11 @@ import nautilus.game.arcade.stats.StatTracker; public class GameStatManager implements Listener { - public static final String STAT_BOOST_COMMAND_PERMISSION = "mineplex.arcade.stat.boost"; - + public enum Perm implements Permission + { + STAT_BOOST_COMMAND, + } + ArcadeManager Manager; private final HashMap _joinTimes = new HashMap<>(); @@ -44,9 +46,8 @@ public class GameStatManager implements Listener private void generatePermissions() { - PermissionManager pm = Manager.GetClients().getPermissionManager(); - - pm.setPermission(PermissionGroup.LT, GroupPermission.of(STAT_BOOST_COMMAND_PERMISSION), true, true); + + PermissionGroup.LT.setPermission(Perm.STAT_BOOST_COMMAND, true, true); } @EventHandler @@ -130,7 +131,7 @@ public class GameStatManager implements Listener @EventHandler public void statBoostCommand(PlayerCommandPreprocessEvent event) { - if (event.getMessage().startsWith("/statboost ") && Manager.GetClients().getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(STAT_BOOST_COMMAND_PERMISSION))) + if (event.getMessage().startsWith("/statboost ") && Manager.GetClients().Get(event.getPlayer()).hasPermission(Perm.STAT_BOOST_COMMAND)) { event.setCancelled(true); 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 a2a7ef8e8..f127f5de4 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,9 +14,8 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -31,8 +30,11 @@ import nautilus.game.arcade.game.Game.GameState; public class IdleManager implements Listener { - public static final String BYPASS_KICK_PERMISSION = "mineplex.arcade.idle.bypass"; - + public enum Perm implements Permission + { + BYPASS_KICK, + } + private final ArcadeManager _arcadeManager; private final Map _yaw = new HashMap<>(); private final Map _idle = new HashMap<>(); @@ -49,9 +51,8 @@ public class IdleManager implements Listener private void generatePermissions() { - PermissionManager pm = _arcadeManager.GetClients().getPermissionManager(); - - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(BYPASS_KICK_PERMISSION), true, true); + + PermissionGroup.MOD.setPermission(Perm.BYPASS_KICK, true, true); } @EventHandler @@ -123,7 +124,7 @@ public class IdleManager implements Listener if (_arcadeManager.GetGame().GetState() != GameState.Recruit && !_arcadeManager.GetGame().IsAlive(player)) continue; - if (_arcadeManager.GetClients().getPermissionManager().hasPermission(player, GroupPermission.of(BYPASS_KICK_PERMISSION))) + if (_arcadeManager.GetClients().Get(player).hasPermission(Perm.BYPASS_KICK)) continue; //Start Beeps 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 65268f9dc..ed8964748 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,6 +5,11 @@ 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; @@ -21,7 +26,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import mineplex.core.Managers; -import mineplex.core.account.permissions.GroupPermission; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; @@ -35,6 +39,7 @@ 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; @@ -44,10 +49,6 @@ 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. @@ -429,7 +430,7 @@ public class NextBestGameManager implements Listener } else { - MinecraftServer server = findBestGame(_partyManager.getClientManager().getPermissionManager().hasPermission(_partyManager.getClientManager().Get(player), GroupPermission.of(ArcadeManager.JOIN_FULL_PERMISSION)), party); + MinecraftServer server = findBestGame(_partyManager.getClientManager().Get(player.getUniqueId()).hasPermission(ArcadeManager.Perm.JOIN_FULL), party); if (server == null) { @@ -449,7 +450,7 @@ public class NextBestGameManager implements Listener } else { - MinecraftServer server = findBestGame(_partyManager.getClientManager().getPermissionManager().hasPermission(_partyManager.getClientManager().Get(player), GroupPermission.of(ArcadeManager.JOIN_FULL_PERMISSION)), null); + MinecraftServer server = findBestGame(_partyManager.getClientManager().Get(player.getUniqueId()).hasPermission(ArcadeManager.Perm.JOIN_FULL), null); player.getInventory().clear(); sendToServer(player, server); } @@ -711,7 +712,7 @@ public class NextBestGameManager implements Listener return; } - MinecraftServer server = findBestGame(_partyManager.getClientManager().getPermissionManager().hasPermission(_partyManager.getClientManager().Get(_player), GroupPermission.of(ArcadeManager.JOIN_FULL_PERMISSION)), null); + MinecraftServer server = findBestGame(_partyManager.getClientManager().Get(_player.getUniqueId()).hasPermission(ArcadeManager.Perm.JOIN_FULL), null); if (server == null) { 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 6aca653bb..ecf648424 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,14 +15,14 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.jooq.tools.json.JSONObject; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; 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; @@ -30,10 +30,13 @@ 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"; - + public enum Perm implements Permission + { + TEAM_SPY, + SPEC_ALWAYS_SPEAK, + SPEC_ALWAYS_HEAR, + } + private ArcadeManager _manager; private LinkedList _chatStats; @@ -55,11 +58,10 @@ public class GameChatManager implements Listener private void generatePermissions() { - PermissionManager pm = _manager.GetClients().getPermissionManager(); - - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(TEAM_SPY_PERMISSION), true, true); - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(SPEC_ALWAYS_SPEAK_PERMISSION), true, true); - pm.setPermission(PermissionGroup.MOD, GroupPermission.of(SPEC_ALWAYS_HEAR_PERMISSION), true, true); + + PermissionGroup.MOD.setPermission(Perm.TEAM_SPY, true, true); + PermissionGroup.TRAINEE.setPermission(Perm.SPEC_ALWAYS_SPEAK, true, true); + PermissionGroup.MOD.setPermission(Perm.SPEC_ALWAYS_HEAR, true, true); } @EventHandler @@ -241,12 +243,12 @@ public class GameChatManager implements Listener { Player receiver = recipientIterator.next(); - if (_manager.IsAlive(sender) || _manager.GetClients().getPermissionManager().hasPermission(sender, GroupPermission.of(SPEC_ALWAYS_SPEAK_PERMISSION))) + if (_manager.IsAlive(sender) || _manager.GetClients().Get(sender).hasPermission(Perm.SPEC_ALWAYS_SPEAK)) { continue; } - if (!_manager.IsAlive(receiver) || _manager.GetClients().getPermissionManager().hasPermission(receiver, GroupPermission.of(SPEC_ALWAYS_HEAR_PERMISSION))) + if (!_manager.IsAlive(receiver) || _manager.GetClients().Get(receiver).hasPermission(Perm.SPEC_ALWAYS_HEAR)) { continue; } @@ -269,7 +271,7 @@ public class GameChatManager implements Listener { Player receiver = recipientIterator.next(); - if (!_manager.GetServerConfig().Tournament && _manager.GetClients().getPermissionManager().hasPermission(receiver, GroupPermission.of(TEAM_SPY_PERMISSION))) + if (!_manager.GetServerConfig().Tournament && _manager.GetClients().Get(receiver).hasPermission(Perm.TEAM_SPY)) { if (TeamSpy) { 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 73e66caad..531b19963 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 @@ -31,7 +31,6 @@ 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; @@ -47,6 +46,7 @@ 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; @@ -528,13 +528,13 @@ public abstract class LobbyManager implements Listener } if (ent.GetKit().GetAvailability() == KitAvailability.Free || //Free - _manager.hasKitsUnlocked(player) || //YouTube - (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().getPermissionManager().hasPermission(player, GroupPermission.of(ArcadeManager.KIT_ACCESS_PERMISSION)) || //STAFF - donor.ownsUnknownSalesPackage(_manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old) - _manager.GetServerConfig().Tournament) //Tournament + _manager.hasKitsUnlocked(player) || //YouTube + (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).hasPermission(ArcadeManager.Perm.KIT_ACCESS) || //STAFF + donor.ownsUnknownSalesPackage(_manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old) + _manager.GetServerConfig().Tournament) //Tournament { entityName = ent.GetKit().GetAvailability().GetColor() + entityName; } 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 315927c9d..cd5e5ca08 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/CashOutModule.java @@ -20,13 +20,10 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; -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.Permission; 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.F; @@ -52,9 +49,12 @@ import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent; @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"; - + public enum Perm implements Permission + { + CASH_OUT_ITEM_COMMAND, + RESET_COOLDOWN_COMMAND, + } + 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(); @@ -83,10 +83,9 @@ public class CashOutModule extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(CASH_OUT_ITEM_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.DEV, GroupPermission.of(RESET_COOLDOWN_COMMAND_PERMISSION), true, true); + + PermissionGroup.PLAYER.setPermission(Perm.CASH_OUT_ITEM_COMMAND, true, true); + PermissionGroup.DEV.setPermission(Perm.RESET_COOLDOWN_COMMAND, true, true); } @Override 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 a5485a37e..ab8e2caf3 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/economy/EconomyModule.java @@ -9,9 +9,8 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; @@ -25,8 +24,11 @@ import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent; @ReflectivelyCreateMiniPlugin public class EconomyModule extends MiniClientPlugin { - public static final String GIVE_GEMS_COMMAND_PERMISSION = "mineplex.gemhunters.economy.givegems"; - + public enum Perm implements Permission + { + GIVE_GEMS_COMMAND, + } + public static final float GEM_KILL_FACTOR = 0.5F; public static final int GEM_START_COST = 100; @@ -46,9 +48,7 @@ public class EconomyModule extends MiniClientPlugin private void generatePermissions() { - PermissionManager pm = _donation.getClientManager().getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(GIVE_GEMS_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.GIVE_GEMS_COMMAND, true, true); } @Override 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 81724cdbf..ac11be529 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 @@ -10,7 +10,7 @@ public class CashOutItemCommand extends CommandBase { public CashOutItemCommand(CashOutModule plugin) { - super(plugin, CashOutModule.CASH_OUT_ITEM_COMMAND_PERMISSION, "cashout", "ct", "cashitem", "cashoutitem"); + super(plugin, CashOutModule.Perm.CASH_OUT_ITEM_COMMAND, "cashout", "ct", "cashitem", "cashoutitem"); } @Override 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 56a33a296..8dba4e6fa 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 @@ -12,7 +12,7 @@ public class GiveGemsCommand extends CommandBase { public GiveGemsCommand(EconomyModule plugin) { - super(plugin, EconomyModule.GIVE_GEMS_COMMAND_PERMISSION, "givegems"); + super(plugin, EconomyModule.Perm.GIVE_GEMS_COMMAND, "givegems"); } @Override 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 baa590794..004deb334 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 @@ -10,7 +10,7 @@ public class ResetCooldownCommand extends CommandBase { public ResetCooldownCommand(CashOutModule plugin) { - super(plugin, CashOutModule.RESET_COOLDOWN_COMMAND_PERMISSION, "resetcashout"); + super(plugin, CashOutModule.Perm.RESET_COOLDOWN_COMMAND, "resetcashout"); } @Override 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 71286e525..e75a11e41 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java @@ -29,13 +29,10 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; @@ -67,9 +64,12 @@ import mineplex.gemhunters.world.WorldDataModule; @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"; - + public enum Perm implements Permission + { + SPAWN_CHEST_COMMAND, + UPDATE_LOOT_COMMAND, + } + 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); @@ -133,10 +133,9 @@ public class LootModule extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SPAWN_CHEST_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(UPDATE_LOOT_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.SPAWN_CHEST_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.UPDATE_LOOT_COMMAND, 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 96301c1f1..0c7957114 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 @@ -13,7 +13,7 @@ public class SpawnChestCommand extends CommandBase { public SpawnChestCommand(LootModule plugin) { - super(plugin, LootModule.SPAWN_CHEST_COMMAND_PERMISSION, "spawnchest"); + super(plugin, LootModule.Perm.SPAWN_CHEST_COMMAND, "spawnchest"); } @Override 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 ea17046b2..ae6ae4b16 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 @@ -14,7 +14,7 @@ public class UpdateLootCommand extends CommandBase { public UpdateLootCommand(LootModule plugin) { - super(plugin, LootModule.UPDATE_LOOT_COMMAND_PERMISSION, "updateloot"); + super(plugin, LootModule.Perm.UPDATE_LOOT_COMMAND, "updateloot"); } @Override 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 edca846fa..52f948ef9 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/ItemMapModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/map/ItemMapModule.java @@ -51,13 +51,10 @@ 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.Permission; 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.UtilEvent; @@ -82,8 +79,11 @@ import mineplex.gemhunters.map.command.MapCommand; @ReflectivelyCreateMiniPlugin public class ItemMapModule extends MiniPlugin { - public static final String MAP_COMMAND_PERMISSION = "mineplex.gemhunters.map.command"; - + public enum Perm implements Permission + { + 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 @@ -307,9 +307,8 @@ public class ItemMapModule extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(MAP_COMMAND_PERMISSION), true, true); + + PermissionGroup.PLAYER.setPermission(Perm.MAP_COMMAND, 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 81af9692d..d529a7a90 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 @@ -10,7 +10,7 @@ public class MapCommand extends CommandBase { public MapCommand(ItemMapModule plugin) { - super(plugin, ItemMapModule.MAP_COMMAND_PERMISSION, "map", "getmap"); + super(plugin, ItemMapModule.Perm.MAP_COMMAND, "map", "getmap"); } @Override 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 c4e9a3a03..9afe397c3 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/moderation/ModerationModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/moderation/ModerationModule.java @@ -10,13 +10,11 @@ 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.CoreClientManager; -import mineplex.core.account.permissions.GroupPermission; +import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; import mineplex.core.incognito.IncognitoManager; @@ -29,10 +27,13 @@ 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"; - + public enum Perm implements Permission + { + MODERATOR_MODE_COMMAND, + MODERATOR_MODE_BYPASS, + AUTO_OP, + } + private final CoreClientManager _client; private final IncognitoManager _incognito; private final SpawnModule _spawn; @@ -54,14 +55,13 @@ public class ModerationModule extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.TRAINEE, GroupPermission.of(MODERATOR_MODE_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(MODERATOR_MODE_BYPASS_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(AUTO_OP_PERMISSION), true, true); + + PermissionGroup.TRAINEE.setPermission(Perm.MODERATOR_MODE_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.MODERATOR_MODE_BYPASS, true, true); + PermissionGroup.ADMIN.setPermission(Perm.AUTO_OP, true, true); if (UtilServer.isTestServer()) { - pm.setPermission(PermissionGroup.QAM, GroupPermission.of(AUTO_OP_PERMISSION), false, true); + PermissionGroup.QAM.setPermission(Perm.AUTO_OP, false, true); } } @@ -120,11 +120,10 @@ public class ModerationModule extends MiniPlugin @EventHandler public void autoOp(PlayerJoinEvent event) { - if (_client.getPermissionManager().hasPermission(event.getPlayer(), GroupPermission.of(AUTO_OP_PERMISSION))) + if (_client.Get(event.getPlayer()).hasPermission(Perm.AUTO_OP)) { event.getPlayer().setOp(true); - } - else + } else { event.getPlayer().setOp(false); } @@ -160,6 +159,6 @@ public class ModerationModule extends MiniPlugin public boolean isBypassing(Player player) { - return _client.getPermissionManager().hasPermission(player, GroupPermission.of(MODERATOR_MODE_BYPASS_PERMISSION)); + return _client.Get(player).hasPermission(Perm.MODERATOR_MODE_BYPASS); } } \ 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 3e9d8a0a2..668651b99 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 @@ -9,7 +9,7 @@ public class ModeratorModeCommand extends CommandBase { public ModeratorModeCommand(ModerationModule plugin) { - super(plugin, ModerationModule.MODERATOR_MODE_COMMAND_PERMISSION, "modmode", "staffmode", "mm", "o"); + super(plugin, ModerationModule.Perm.MODERATOR_MODE_COMMAND, "modmode", "staffmode", "mm", "o"); } @Override 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 0eb513d8e..1c00e2627 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java @@ -22,13 +22,10 @@ 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.Permission; 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.F; @@ -60,8 +57,11 @@ import mineplex.gemhunters.world.WorldDataModule; @ReflectivelyCreateMiniPlugin public class QuestModule extends MiniClientPlugin { - public static final String RESET_QUESTS_COMMAND_PERMISSION = "mineplex.gemhunters.quest.reset"; - + public enum Perm implements Permission + { + RESET_QUESTS_COMMAND, + } + 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; @@ -127,9 +127,8 @@ public class QuestModule extends MiniClientPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(RESET_QUESTS_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.RESET_QUESTS_COMMAND, true, true); } @Override 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 6c92c19e2..3449e1adf 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 @@ -12,7 +12,7 @@ public class ResetQuestsCommand extends CommandBase { public ResetQuestsCommand(QuestModule plugin) { - super(plugin, QuestModule.RESET_QUESTS_COMMAND_PERMISSION, "resetquest"); + super(plugin, QuestModule.Perm.RESET_QUESTS_COMMAND, "resetquest"); } @Override 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 a63eab737..44dfe74e0 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java @@ -15,13 +15,10 @@ 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.Permission; 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.UtilAlg; @@ -45,8 +42,11 @@ import mineplex.gemhunters.world.WorldDataModule; @ReflectivelyCreateMiniPlugin public class SpawnModule extends MiniPlugin { - public static final String HUB_COMMAND_PERMISSION = "mineplex.gemhunters.spawn.hub"; - + public enum Perm implements Permission + { + HUB_COMMAND, + } + 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; @@ -72,9 +72,8 @@ public class SpawnModule extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.PLAYER, GroupPermission.of(HUB_COMMAND_PERMISSION), true, true); + + PermissionGroup.PLAYER.setPermission(Perm.HUB_COMMAND, 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 990d3d62b..22d0bf68f 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 @@ -12,7 +12,7 @@ public class HubCommand extends CommandBase { public HubCommand(SpawnModule plugin) { - super(plugin, SpawnModule.HUB_COMMAND_PERMISSION, "hub", "lobby"); + super(plugin, SpawnModule.Perm.HUB_COMMAND, "hub", "lobby"); } @Override 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 76a7e62d8..33a58bff0 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/SupplyDropModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/supplydrop/SupplyDropModule.java @@ -16,13 +16,10 @@ 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.Pair; import mineplex.core.common.util.C; @@ -43,10 +40,13 @@ 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"; - + public enum Perm implements Permission + { + SUPPLY_DROP_COMMAND, + START_SUPPLY_DROP_COMMAND, + STOP_SUPPLY_DROP_COMMAND, + } + private static final long SEQUENCE_TIMER = TimeUnit.MINUTES.toMillis(20); private static final String CHEST_COLOUR = "RED"; @@ -80,11 +80,10 @@ public class SupplyDropModule extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(SUPPLY_DROP_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(START_SUPPLY_DROP_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(STOP_SUPPLY_DROP_COMMAND_PERMISSION), true, true); + + PermissionGroup.ADMIN.setPermission(Perm.SUPPLY_DROP_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.START_SUPPLY_DROP_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.STOP_SUPPLY_DROP_COMMAND, true, true); } @Override 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 078bfaa73..c3535edb1 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 @@ -10,7 +10,7 @@ public class EndCommand extends CommandBase { public EndCommand(SupplyDropModule plugin) { - super(plugin, SupplyDropModule.STOP_SUPPLY_DROP_COMMAND_PERMISSION, "stop"); + super(plugin, SupplyDropModule.Perm.STOP_SUPPLY_DROP_COMMAND, "stop"); } @Override 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 25a357906..d05ae90f6 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 @@ -11,7 +11,7 @@ public class StartCommand extends CommandBase { public StartCommand(SupplyDropModule plugin) { - super(plugin, SupplyDropModule.START_SUPPLY_DROP_COMMAND_PERMISSION, "start"); + super(plugin, SupplyDropModule.Perm.START_SUPPLY_DROP_COMMAND, "start"); } @Override 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 2b38bab40..328668419 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 @@ -11,7 +11,7 @@ public class SupplyDropCommand extends MultiCommandBase { public SupplyDropCommand(SupplyDropModule plugin) { - super(plugin, SupplyDropModule.SUPPLY_DROP_COMMAND_PERMISSION, "supplydrop", "supply", "sd"); + super(plugin, SupplyDropModule.Perm.SUPPLY_DROP_COMMAND, "supplydrop", "supply", "sd"); AddCommand(new StartCommand(plugin)); AddCommand(new EndCommand(plugin)); 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 ce53df05c..187391f60 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/worldevent/WorldEventModule.java @@ -10,13 +10,10 @@ import java.util.concurrent.TimeUnit; 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.Permission; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.permissions.PermissionManager; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; @@ -34,10 +31,13 @@ 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"; - + public enum Perm implements Permission + { + WORLD_EVENT_COMMAND, + START_WORLD_EVENT_COMMAND, + STOP_WORLD_EVENT_COMMAND, + } + 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); @@ -62,11 +62,9 @@ public class WorldEventModule extends MiniPlugin private void generatePermissions() { - PermissionManager pm = Managers.get(CoreClientManager.class).getPermissionManager(); - - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(WORLD_EVENT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(START_WORLD_EVENT_COMMAND_PERMISSION), true, true); - pm.setPermission(PermissionGroup.ADMIN, GroupPermission.of(STOP_WORLD_EVENT_COMMAND_PERMISSION), true, true); + PermissionGroup.ADMIN.setPermission(Perm.WORLD_EVENT_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.START_WORLD_EVENT_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.STOP_WORLD_EVENT_COMMAND, true, true); } @Override 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 d24b12995..83ce7b609 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 @@ -12,7 +12,7 @@ public class StartCommand extends CommandBase { public StartCommand(WorldEventModule plugin) { - super(plugin, WorldEventModule.START_WORLD_EVENT_COMMAND_PERMISSION, "start"); + super(plugin, WorldEventModule.Perm.START_WORLD_EVENT_COMMAND, "start"); } @Override 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 b245b5623..e095da6d3 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 @@ -13,7 +13,7 @@ public class StopCommand extends CommandBase { public StopCommand(WorldEventModule plugin) { - super(plugin, WorldEventModule.STOP_WORLD_EVENT_COMMAND_PERMISSION, "stop"); + super(plugin, WorldEventModule.Perm.STOP_WORLD_EVENT_COMMAND, "stop"); } @Override 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 13b11112c..568656f7d 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 @@ -11,7 +11,7 @@ public class WorldEventCommand extends MultiCommandBase { public WorldEventCommand(WorldEventModule plugin) { - super(plugin, WorldEventModule.WORLD_EVENT_COMMAND_PERMISSION, "worldevent", "we"); + super(plugin, WorldEventModule.Perm.WORLD_EVENT_COMMAND, "worldevent", "we"); AddCommand(new StartCommand(plugin)); AddCommand(new StopCommand(plugin));