forked from Upstream/mmocore
fixed command verbose
This commit is contained in:
parent
00ca007ecc
commit
60038e08d7
@ -1,53 +1,67 @@
|
|||||||
package net.Indyuce.mmocore.command;
|
package net.Indyuce.mmocore.command;
|
||||||
|
|
||||||
import io.lumine.mythic.lib.api.util.EnumUtils;
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class CommandVerbose {
|
public class CommandVerbose {
|
||||||
private final Map<CommandType, VerboseValue> values = new HashMap<>();
|
private final Map<CommandType, VerboseValue> values = new HashMap<>();
|
||||||
|
|
||||||
public void reload(ConfigurationSection config) {
|
public void reload(ConfigurationSection config) {
|
||||||
values.clear();
|
values.clear();
|
||||||
|
|
||||||
for(CommandType type : CommandType.values())
|
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 {
|
public void handle(CommandSender sender, CommandType type, String verbose) {
|
||||||
ATTRIBUTE, CLASS, EXPERIENCE, LEVEL,
|
switch (values.getOrDefault(type, VerboseValue.FALSE)) {
|
||||||
NOCD, POINTS, RESET, RESOURCE
|
case FALSE:
|
||||||
}
|
return;
|
||||||
|
case TRUE:
|
||||||
|
sender.sendMessage(verbose);
|
||||||
|
break;
|
||||||
|
case PLAYER:
|
||||||
|
if (sender instanceof Player)
|
||||||
|
sender.sendMessage(verbose);
|
||||||
|
break;
|
||||||
|
case CONSOLE:
|
||||||
|
if (sender instanceof ConsoleCommandSender)
|
||||||
|
sender.sendMessage(verbose);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum VerboseValue {
|
public static void verbose(CommandSender sender, CommandType cmd, String verbose) {
|
||||||
TRUE, PLAYER,
|
MMOCore.plugin.configManager.commandVerbose.handle(sender, cmd, verbose);
|
||||||
CONSOLE, FALSE
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(CommandSender sender, CommandType cmd, String verbose) {
|
public enum CommandType {
|
||||||
switch(values.getOrDefault(cmd, VerboseValue.FALSE)) {
|
ATTRIBUTE,
|
||||||
case FALSE:
|
CLASS,
|
||||||
return;
|
EXPERIENCE,
|
||||||
case TRUE:
|
LEVEL,
|
||||||
//sender.sendMessage(verbose);
|
NOCD,
|
||||||
break;
|
POINTS,
|
||||||
case PLAYER:
|
RESET,
|
||||||
if(sender instanceof Player)
|
RESOURCE
|
||||||
//sender.sendMessage(verbose);
|
}
|
||||||
break;
|
|
||||||
case CONSOLE:
|
|
||||||
if(!(sender instanceof Player))
|
|
||||||
//sender.sendMessage(verbose);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void verbose(CommandSender sender, CommandType cmd, String verbose) {
|
private enum VerboseValue {
|
||||||
MMOCore.plugin.configManager.commandVerbose.handle(sender, cmd, verbose);
|
TRUE,
|
||||||
}
|
PLAYER,
|
||||||
|
CONSOLE,
|
||||||
|
FALSE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user