mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +01:00
fixed command verbose
This commit is contained in:
parent
00ca007ecc
commit
60038e08d7
@ -1,13 +1,14 @@
|
||||
package net.Indyuce.mmocore.command;
|
||||
|
||||
import io.lumine.mythic.lib.api.util.EnumUtils;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CommandVerbose {
|
||||
private final Map<CommandType, VerboseValue> values = new HashMap<>();
|
||||
@ -16,33 +17,28 @@ public class CommandVerbose {
|
||||
values.clear();
|
||||
|
||||
for (CommandType type : CommandType.values())
|
||||
values.put(type, EnumUtils.getIfPresent(VerboseValue.class, config.getString(type.name().toLowerCase(), "true")).orElse(VerboseValue.TRUE));
|
||||
try {
|
||||
values.put(type, VerboseValue.valueOf(config.getString(type.name().toLowerCase(), "TRUE").toUpperCase()));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
values.put(type, VerboseValue.TRUE);
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load command verbose action for " + type.name());
|
||||
}
|
||||
}
|
||||
|
||||
public enum CommandType {
|
||||
ATTRIBUTE, CLASS, EXPERIENCE, LEVEL,
|
||||
NOCD, POINTS, RESET, RESOURCE
|
||||
}
|
||||
|
||||
enum VerboseValue {
|
||||
TRUE, PLAYER,
|
||||
CONSOLE, FALSE
|
||||
}
|
||||
|
||||
public void handle(CommandSender sender, CommandType cmd, String verbose) {
|
||||
switch(values.getOrDefault(cmd, VerboseValue.FALSE)) {
|
||||
public void handle(CommandSender sender, CommandType type, String verbose) {
|
||||
switch (values.getOrDefault(type, VerboseValue.FALSE)) {
|
||||
case FALSE:
|
||||
return;
|
||||
case TRUE:
|
||||
//sender.sendMessage(verbose);
|
||||
sender.sendMessage(verbose);
|
||||
break;
|
||||
case PLAYER:
|
||||
if (sender instanceof Player)
|
||||
//sender.sendMessage(verbose);
|
||||
sender.sendMessage(verbose);
|
||||
break;
|
||||
case CONSOLE:
|
||||
if(!(sender instanceof Player))
|
||||
//sender.sendMessage(verbose);
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
sender.sendMessage(verbose);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -50,4 +46,22 @@ public class CommandVerbose {
|
||||
public static void verbose(CommandSender sender, CommandType cmd, String verbose) {
|
||||
MMOCore.plugin.configManager.commandVerbose.handle(sender, cmd, verbose);
|
||||
}
|
||||
|
||||
public enum CommandType {
|
||||
ATTRIBUTE,
|
||||
CLASS,
|
||||
EXPERIENCE,
|
||||
LEVEL,
|
||||
NOCD,
|
||||
POINTS,
|
||||
RESET,
|
||||
RESOURCE
|
||||
}
|
||||
|
||||
private enum VerboseValue {
|
||||
TRUE,
|
||||
PLAYER,
|
||||
CONSOLE,
|
||||
FALSE
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user