mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-03 13:05:30 +02:00
more unit tests
This commit is contained in:
@@ -5,6 +5,21 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Represents a command to be executed on a level up
|
||||
*/
|
||||
public interface LevelUpCommand {
|
||||
void apply(McMMOPlayer player, PrimarySkillType primarySkillType, Set<Integer> levelsGained);
|
||||
/**
|
||||
* Process the command
|
||||
*
|
||||
* @param player the player
|
||||
* @param primarySkillType the skill type
|
||||
* @param levelsGained the levels gained
|
||||
*/
|
||||
void process(McMMOPlayer player, PrimarySkillType primarySkillType, Set<Integer> levelsGained);
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*/
|
||||
void executeCommand();
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ public class LevelUpCommandImpl implements LevelUpCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(McMMOPlayer player, PrimarySkillType primarySkillType, Set<Integer> levelsGained) {
|
||||
public void process(McMMOPlayer player, PrimarySkillType primarySkillType, Set<Integer> levelsGained) {
|
||||
if(!skills.contains(primarySkillType)) {
|
||||
return;
|
||||
}
|
||||
@@ -39,11 +39,15 @@ public class LevelUpCommandImpl implements LevelUpCommand {
|
||||
} else {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Executing command: " + commandStr);
|
||||
}
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), commandStr);
|
||||
executeCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void executeCommand() {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), commandStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@@ -28,7 +28,7 @@ public class LevelUpCommandManager {
|
||||
}
|
||||
|
||||
for (LevelUpCommand command : commands) {
|
||||
command.apply(mmoPlayer, primarySkillType, levelsGained);
|
||||
command.process(mmoPlayer, primarySkillType, levelsGained);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -62,9 +62,9 @@ public class SelfListener implements Listener {
|
||||
}
|
||||
|
||||
final Set<Integer> levelsAchieved = new LinkedHashSet<>();
|
||||
for(int i = 0; i < event.getLevelsGained(); i++)
|
||||
for(int i = 1; i <= event.getLevelsGained(); i++)
|
||||
{
|
||||
levelsAchieved.add(event.getSkillLevel());
|
||||
levelsAchieved.add(event.getSkillLevel() + i);
|
||||
}
|
||||
plugin.getLevelUpCommandManager().apply(mcMMOPlayer, skill, levelsAchieved);
|
||||
}
|
||||
|
Reference in New Issue
Block a user