mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-10-31 01:03:44 +01:00 
			
		
		
		
	endgame progression WIP
This commit is contained in:
		| @@ -5,7 +5,9 @@ import co.aikar.commands.BukkitCommandManager; | ||||
| import co.aikar.commands.ConditionFailedException; | ||||
| import com.gmail.nossr50.commands.chat.AdminChatCommand; | ||||
| import com.gmail.nossr50.commands.chat.PartyChatCommand; | ||||
| import com.gmail.nossr50.commands.skills.PowerLevelCommand; | ||||
| import com.gmail.nossr50.config.ChatConfig; | ||||
| import com.gmail.nossr50.config.Config; | ||||
| import com.gmail.nossr50.datatypes.chat.ChatChannel; | ||||
| import com.gmail.nossr50.datatypes.player.McMMOPlayer; | ||||
| import com.gmail.nossr50.locale.LocaleLoader; | ||||
| @@ -20,9 +22,14 @@ import org.jetbrains.annotations.NotNull; | ||||
|  * For now this class will only handle ACF converted commands, all other commands will be handled elsewhere | ||||
|  */ | ||||
| public class CommandManager { | ||||
|     public static final @NotNull String MMO_DATA_LOADED = "mmoDataLoaded"; | ||||
|  | ||||
|     //CHAT | ||||
|     public static final @NotNull String ADMIN_CONDITION = "adminCondition"; | ||||
|     public static final @NotNull String PARTY_CONDITION = "partyCondition"; | ||||
|     public static final @NotNull String MMO_DATA_LOADED = "mmoDataLoaded"; | ||||
|  | ||||
|     //SKILLS | ||||
|     public static final @NotNull String POWER_LEVEL_CONDITION = "powerLevelCondition"; | ||||
|  | ||||
|     private final @NotNull mcMMO pluginRef; | ||||
|     private final @NotNull BukkitCommandManager bukkitCommandManager; | ||||
| @@ -36,9 +43,16 @@ public class CommandManager { | ||||
|     } | ||||
|  | ||||
|     private void registerCommands() { | ||||
|         registerSkillCommands(); //TODO: Implement other skills not just power level | ||||
|         registerChatCommands(); | ||||
|     } | ||||
|  | ||||
|     private void registerSkillCommands() { | ||||
|         if(Config.getInstance().isMasterySystemEnabled()) { | ||||
|             bukkitCommandManager.registerCommand(new PowerLevelCommand(pluginRef)); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Registers chat commands if the chat system is enabled | ||||
|      */ | ||||
| @@ -54,6 +68,23 @@ public class CommandManager { | ||||
|     } | ||||
|  | ||||
|     public void registerConditions() { | ||||
|         registerChatCommandConditions(); //Chat Commands | ||||
|         registerSkillConditions(); | ||||
|     } | ||||
|  | ||||
|     private void registerSkillConditions() { | ||||
|         bukkitCommandManager.getCommandConditions().addCondition(POWER_LEVEL_CONDITION, (context) -> { | ||||
|             BukkitCommandIssuer issuer = context.getIssuer(); | ||||
|  | ||||
|             if(issuer.getIssuer() instanceof Player) { | ||||
|                 validateLoadedData(issuer.getPlayer()); | ||||
|             } else { | ||||
|                 throw new ConditionFailedException(LocaleLoader.getString("Commands.NoConsole")); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     private void registerChatCommandConditions() { | ||||
|         // Method or Class based - Can only be used on methods | ||||
|         bukkitCommandManager.getCommandConditions().addCondition(ADMIN_CONDITION, (context) -> { | ||||
|             BukkitCommandIssuer issuer = context.getIssuer(); | ||||
| @@ -78,6 +109,7 @@ public class CommandManager { | ||||
|             if(bukkitCommandIssuer.getIssuer() instanceof Player) { | ||||
|                 validateLoadedData(bukkitCommandIssuer.getPlayer()); | ||||
|                 validatePlayerParty(bukkitCommandIssuer.getPlayer()); | ||||
|                 //TODO: Is there even a point in validating permission? look into this later | ||||
|                 validatePermission("mcmmo.chat.partychat", bukkitCommandIssuer.getPlayer()); | ||||
|             } | ||||
|         }); | ||||
|   | ||||
| @@ -0,0 +1,31 @@ | ||||
| package com.gmail.nossr50.commands.skills; | ||||
|  | ||||
| import co.aikar.commands.BaseCommand; | ||||
| import co.aikar.commands.BukkitCommandIssuer; | ||||
| import co.aikar.commands.annotation.CommandAlias; | ||||
| import co.aikar.commands.annotation.CommandPermission; | ||||
| import co.aikar.commands.annotation.Conditions; | ||||
| import co.aikar.commands.annotation.Default; | ||||
| import com.gmail.nossr50.commands.CommandManager; | ||||
| import com.gmail.nossr50.mcMMO; | ||||
| import org.bukkit.entity.Player; | ||||
| import org.jetbrains.annotations.NotNull; | ||||
|  | ||||
| @CommandPermission("mcmmo.commands.mmopower") | ||||
| @CommandAlias("mmopowerlevel|powerlevel") //Kept for historical reasons | ||||
| public class PowerLevelCommand extends BaseCommand { | ||||
|     private final @NotNull mcMMO pluginRef; | ||||
|  | ||||
|     public PowerLevelCommand(@NotNull mcMMO pluginRef) { | ||||
|         this.pluginRef = pluginRef; | ||||
|     } | ||||
|  | ||||
|     @Default | ||||
|     @Conditions(CommandManager.ADMIN_CONDITION) | ||||
|     public void processCommand(String[] args) { | ||||
|         BukkitCommandIssuer bukkitCommandIssuer = (BukkitCommandIssuer) getCurrentCommandIssuer(); | ||||
|         Player player = bukkitCommandIssuer.getPlayer(); | ||||
|  | ||||
|         //TODO: impl | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 nossr50
					nossr50