initial work for commands that execute on level up

This commit is contained in:
nossr50 2021-08-24 20:00:16 -07:00
parent e8fdae9597
commit efbacefdbf
5 changed files with 127 additions and 0 deletions

View File

@ -0,0 +1,43 @@
package com.gmail.nossr50.onlevel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface LevelUpCommand {
/**
* Raw command input, this is before any processing is done (regex etc)
*
* @return the raw command input from the config file
*/
@NotNull String getRawInput();
/**
* The command after regex operations etc
*
* @return the processed command
*/
@NotNull String getProcessedInput();
/**
* Who should execute this level up command
*
* @return who should execute this level up command
*/
@NotNull SkillDispatcher getSender();
/**
* Get the {@link LevelUpCommandTriggers}'s for this command
*
* @return the {@link LevelUpCommandTriggers} for this command
*/
@NotNull LevelUpCommandTriggers getCommandTriggers();
/**
* The permission node for this command
*
* @return the permission node for this command, null if not needed
*/
@Nullable String getPermissionNode();
}

View File

@ -0,0 +1,36 @@
package com.gmail.nossr50.onlevel;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
/**
* This class will handle execution of {@link LevelUpCommand}'s
* This class is invoked by our {@link com.gmail.nossr50.listeners.SelfListener}
*/
public class LevelUpCommandProcessor {
@NotNull private HashMap<TargetSkill, LevelUpCommand> commandMap;
public LevelUpCommandProcessor() {
commandMap = new HashMap<>();
loadPayloads();
}
/**
* Load the {@link LevelUpCommand} payloads to be executed as needed
*/
private void loadPayloads() {
//Load the payloads from the config file
}
/**
* Execute any relevant {@link LevelUpCommand}'s for this player
* @param mmoPlayer target player
* @param primarySkillType target skill type
*/
public void onLevel(@NotNull McMMOPlayer mmoPlayer, @NotNull PrimarySkillType primarySkillType) {
}
}

View File

@ -0,0 +1,21 @@
package com.gmail.nossr50.onlevel;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public interface LevelUpCommandTriggers {
/**
* The {@link TargetSkill}'s that can trigger a {@link LevelUpCommand}
*
* @return the relevant target skills
*/
@NotNull List<TargetSkill> getTargetSkills();
/**
* The levels at which this command will trigger
*
* @return the levels at which this command will trigger
*/
@NotNull List<Integer> getTargetLevels();
}

View File

@ -0,0 +1,6 @@
package com.gmail.nossr50.onlevel;
public enum SkillDispatcher {
CONSOLE,
PLAYER;
}

View File

@ -0,0 +1,21 @@
package com.gmail.nossr50.onlevel;
public enum TargetSkill {
POWER_LEVEL,
ANY,
ACROBATICS,
ALCHEMY,
ARCHERY,
AXES,
EXCAVATION,
FISHING,
HERBALISM,
MINING,
REPAIR,
SALVAGE,
SMELTING,
SWORDS,
TAMING,
UNARMED,
WOODCUTTING;
}