forked from Upstream/mmocore
Verbose management in config.yml
You can now disable some of the command results from appearing in console, etc.
This commit is contained in:
parent
de059cbd17
commit
497f2e6f6b
@ -166,6 +166,13 @@ public class MMOCore extends JavaPlugin {
|
||||
new Metrics(this);
|
||||
saveDefaultConfig();
|
||||
|
||||
final int configVersion = getConfig().contains("config-version", true) ? getConfig().getInt("config-version") : -1;
|
||||
final int defConfigVersion = getConfig().getDefaults().getInt("config-version");
|
||||
if(configVersion != defConfigVersion) {
|
||||
getLogger().warning("You may be using an outdated config.yml!");
|
||||
getLogger().warning("(Your config version: '" + configVersion + "' | Expected config version: '" + defConfigVersion + "')");
|
||||
}
|
||||
|
||||
if (getConfig().isConfigurationSection("mysql") && getConfig().getBoolean("mysql.enabled"))
|
||||
dataProvider = new MySQLDataProvider(getConfig());
|
||||
|
||||
|
@ -0,0 +1,53 @@
|
||||
package net.Indyuce.mmocore.command;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.mmogroup.mmolib.api.util.EnumUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommandVerbose {
|
||||
private final Map<CommandType, VerboseValue> values = new HashMap<>();
|
||||
|
||||
public void reload(ConfigurationSection config) {
|
||||
values.clear();
|
||||
|
||||
for(CommandType type : CommandType.values())
|
||||
values.put(type, EnumUtils.getIfPresent(VerboseValue.class, config.getString(type.name().toLowerCase(), "true")).orElse(VerboseValue.TRUE));
|
||||
}
|
||||
|
||||
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.TRUE)) {
|
||||
case FALSE:
|
||||
return;
|
||||
case TRUE:
|
||||
sender.sendMessage(verbose);
|
||||
break;
|
||||
case PLAYER:
|
||||
if(sender instanceof Player)
|
||||
sender.sendMessage(verbose);
|
||||
break;
|
||||
case CONSOLE:
|
||||
if(!(sender instanceof Player))
|
||||
sender.sendMessage(verbose);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void verbose(CommandSender sender, CommandType cmd, String verbose) {
|
||||
MMOCore.plugin.configManager.commandVerbose.handle(sender, cmd, verbose);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmocore.command.rpg.admin;
|
||||
|
||||
import net.Indyuce.mmocore.command.CommandVerbose;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -62,8 +63,8 @@ public class AttributeCommandTreeNode extends CommandTreeNode {
|
||||
|
||||
AttributeInstance instance = PlayerData.get(player).getAttributes().getInstance(attribute);
|
||||
instance.setBase(Math.min(attribute.getMax(), instance.getBase() + c * amount));
|
||||
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD + instance.getBase()
|
||||
+ ChatColor.YELLOW + " " + attribute.getName() + ".");
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.ATTRIBUTE, ChatColor.GOLD + player.getName() + ChatColor.YELLOW
|
||||
+ " now has " + ChatColor.GOLD + instance.getBase() + ChatColor.YELLOW + " " + attribute.getName() + ".");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmocore.command.rpg.admin;
|
||||
|
||||
import net.Indyuce.mmocore.command.CommandVerbose;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
@ -59,8 +60,8 @@ public class ClassCommandTreeNode extends CommandTreeNode {
|
||||
data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.UI_TOAST_CHALLENGE_COMPLETE, 1, 1);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " is now a " + ChatColor.GOLD
|
||||
+ profess.getName() + ChatColor.YELLOW + ".");
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.CLASS, ChatColor.GOLD + player.getName()
|
||||
+ ChatColor.YELLOW + " is now a " + ChatColor.GOLD + profess.getName() + ChatColor.YELLOW + ".");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.Indyuce.mmocore.command.rpg.admin;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import net.Indyuce.mmocore.command.CommandVerbose;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -62,8 +63,8 @@ public class ExperienceCommandTreeNode extends CommandTreeNode {
|
||||
PlayerData data = PlayerData.get(player);
|
||||
if (args[4].equalsIgnoreCase("main")) {
|
||||
main.accept(data, amount);
|
||||
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD + data.getExperience()
|
||||
+ ChatColor.YELLOW + " EXP.");
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.EXPERIENCE, ChatColor.GOLD + player.getName()
|
||||
+ ChatColor.YELLOW + " now has " + ChatColor.GOLD + data.getExperience() + ChatColor.YELLOW + " EXP.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
@ -75,8 +76,8 @@ public class ExperienceCommandTreeNode extends CommandTreeNode {
|
||||
|
||||
Profession profession = MMOCore.plugin.professionManager.get(format);
|
||||
this.profession.accept(data.getCollectionSkills(), profession, amount);
|
||||
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD
|
||||
+ data.getCollectionSkills().getExperience(profession) + ChatColor.YELLOW + " EXP in " + profession.getName() + ".");
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.EXPERIENCE, ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has "
|
||||
+ ChatColor.GOLD + data.getCollectionSkills().getExperience(profession) + ChatColor.YELLOW + " EXP in " + profession.getName() + ".");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmocore.command.rpg.admin;
|
||||
|
||||
import net.Indyuce.mmocore.command.CommandVerbose;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -41,8 +42,8 @@ public class ForceClassCommandTreeNode extends CommandTreeNode {
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
data.setClass(profess);
|
||||
sender.sendMessage(
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " is now a " + ChatColor.GOLD + profess.getName() + ChatColor.YELLOW + ".");
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.CLASS, ChatColor.GOLD + player.getName()
|
||||
+ ChatColor.YELLOW + " is now a " + ChatColor.GOLD + profess.getName() + ChatColor.YELLOW + ".");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.Indyuce.mmocore.command.rpg.admin;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import net.Indyuce.mmocore.command.CommandVerbose;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -63,8 +64,9 @@ public class LevelCommandTreeNode extends CommandTreeNode {
|
||||
PlayerData data = PlayerData.get(player);
|
||||
if (args[4].equalsIgnoreCase("main")) {
|
||||
main.accept(data, amount);
|
||||
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " is now Lvl " + ChatColor.GOLD + data.getLevel()
|
||||
+ ChatColor.YELLOW + ".");
|
||||
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.LEVEL, ChatColor.GOLD + player.getName()
|
||||
+ ChatColor.YELLOW + " is now Lvl " + ChatColor.GOLD + data.getLevel() + ChatColor.YELLOW + ".");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
@ -76,7 +78,8 @@ public class LevelCommandTreeNode extends CommandTreeNode {
|
||||
|
||||
Profession profession = MMOCore.plugin.professionManager.get(format);
|
||||
this.profession.accept(data.getCollectionSkills(), profession, amount);
|
||||
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " is now Lvl " + ChatColor.GOLD
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.LEVEL,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " is now Lvl " + ChatColor.GOLD
|
||||
+ data.getCollectionSkills().getLevel(profession) + ChatColor.YELLOW + " in " + profession.getName() + ".");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmocore.command.rpg.admin;
|
||||
|
||||
import net.Indyuce.mmocore.command.CommandVerbose;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -29,7 +30,8 @@ public class NoCooldownCommandTreeNode extends CommandTreeNode {
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
data.nocd = !data.nocd;
|
||||
sender.sendMessage(ChatColor.YELLOW + "NoCD " + (data.nocd ? "enabled" : "disabled") + " for " + player.getName() + ".");
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.NOCD,
|
||||
ChatColor.YELLOW + "NoCD " + (data.nocd ? "enabled" : "disabled") + " for " + player.getName() + ".");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.Indyuce.mmocore.command.rpg.admin;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.Indyuce.mmocore.command.CommandVerbose;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -60,8 +61,8 @@ public class PointsCommandTreeNode extends CommandTreeNode {
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
action.accept(data, amount);
|
||||
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD + get.apply(data)
|
||||
+ ChatColor.YELLOW + " " + type + " points.");
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.POINTS, ChatColor.GOLD + player.getName()
|
||||
+ ChatColor.YELLOW + " now has " + ChatColor.GOLD + get.apply(data) + ChatColor.YELLOW + " " + type + " points.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmocore.command.rpg.admin;
|
||||
|
||||
import net.Indyuce.mmocore.command.CommandVerbose;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -66,7 +67,8 @@ public class ResetCommandTreeNode extends CommandTreeNode {
|
||||
data.unbindSkill(0);
|
||||
data.getQuestData().resetFinishedQuests();
|
||||
data.getQuestData().start(null);
|
||||
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s data was succesfully reset.");
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s data was succesfully reset.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -142,7 +144,8 @@ public class ResetCommandTreeNode extends CommandTreeNode {
|
||||
data.mapSkillLevels().forEach((skill, level) -> data.resetSkillLevel(skill));
|
||||
while (data.hasSkillBound(0))
|
||||
data.unbindSkill(0);
|
||||
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s skill data was succesfully reset.");
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s skill data was succesfully reset.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -180,12 +183,14 @@ public class ResetCommandTreeNode extends CommandTreeNode {
|
||||
}
|
||||
|
||||
data.giveAttributePoints(points);
|
||||
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s attribute points spendings were successfully reset.");
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s attribute points spendings were successfully reset.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
data.getAttributes().getInstances().forEach(ins -> ins.setBase(0));
|
||||
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s attributes were succesfully reset.");
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s attributes were succesfully reset.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -215,7 +220,8 @@ public class ResetCommandTreeNode extends CommandTreeNode {
|
||||
data.getCollectionSkills().setExperience(profession, 0);
|
||||
data.getCollectionSkills().setLevel(profession, 0);
|
||||
}
|
||||
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s levels were succesfully reset.");
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESET,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + "'s levels were succesfully reset.");
|
||||
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.Indyuce.mmocore.command.rpg.admin;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.Indyuce.mmocore.command.CommandVerbose;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -61,7 +62,8 @@ public class ResourceCommandTreeNode extends CommandTreeNode {
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
action.accept(data, amount);
|
||||
sender.sendMessage(ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD + get.apply(data)
|
||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.RESOURCE,
|
||||
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD + get.apply(data)
|
||||
+ ChatColor.YELLOW + " " + type + " points.");
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import net.Indyuce.mmocore.api.util.input.AnvilGUI;
|
||||
import net.Indyuce.mmocore.api.util.input.ChatInput;
|
||||
import net.Indyuce.mmocore.api.util.input.PlayerInput;
|
||||
import net.Indyuce.mmocore.api.util.input.PlayerInput.InputType;
|
||||
import net.Indyuce.mmocore.command.CommandVerbose;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -21,8 +22,8 @@ import java.text.DecimalFormatSymbols;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class ConfigManager {
|
||||
public final CommandVerbose commandVerbose = new CommandVerbose();
|
||||
|
||||
public boolean overrideVanillaExp, hotbarSwap;
|
||||
public double expPartyBuff, regenPartyBuff;
|
||||
@ -33,8 +34,8 @@ public class ConfigManager {
|
||||
public final DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols();
|
||||
public final DecimalFormat decimal = new DecimalFormat("0.#", formatSymbols), decimals = new DecimalFormat("0.##", formatSymbols);
|
||||
|
||||
private FileConfiguration messages;
|
||||
private boolean chatInput;
|
||||
private final FileConfiguration messages;
|
||||
private final boolean chatInput;
|
||||
|
||||
/*
|
||||
* the instance must be created after the other managers since all it does
|
||||
@ -42,7 +43,6 @@ public class ConfigManager {
|
||||
* already loaded based on the config
|
||||
*/
|
||||
public ConfigManager() {
|
||||
|
||||
// loadDefaultFile("recipes", "brewing.yml");
|
||||
// loadDefaultFile("recipes", "furnace.yml");
|
||||
|
||||
@ -91,10 +91,8 @@ public class ConfigManager {
|
||||
loadDefaultFile("commands.yml");
|
||||
loadDefaultFile("guilds.yml");
|
||||
|
||||
loadOptions();
|
||||
}
|
||||
commandVerbose.reload(MMOCore.plugin.getConfig().getConfigurationSection("command-verbose"));
|
||||
|
||||
public void loadOptions() {
|
||||
messages = new ConfigFile("messages").getConfig();
|
||||
hotbarSwap = MMOCore.plugin.getConfig().getBoolean("hotbar-swap");
|
||||
chatInput = MMOCore.plugin.getConfig().getBoolean("use-chat-input");
|
||||
|
@ -1,3 +1,15 @@
|
||||
#
|
||||
# ███ ███ ███ ███ ██████ ██████ ██████ ██████ ███████
|
||||
# ████ ████ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
# ██ ████ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██████ █████
|
||||
# ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
# ██ ██ ██ ██ ██████ ██████ ██████ ██ ██ ███████
|
||||
#
|
||||
# a Spigot Plugin by Team Requiem
|
||||
|
||||
# DO NOT TOUCH
|
||||
config-version: 2
|
||||
|
||||
# Auto-Save feature automatically saves playerdata
|
||||
# (class, level, etc.) and guild data
|
||||
# (guild names, members, etc.) at a set interval.
|
||||
@ -151,3 +163,21 @@ resource-bar-colors:
|
||||
stamina-whole: 'GREEN'
|
||||
stamina-half: 'DARK_GREEN'
|
||||
stamina-empty: 'WHITE'
|
||||
|
||||
# Whether or not the admin commands should display
|
||||
# the result of the command when ran.
|
||||
# For Example: "Players Level is now 10."
|
||||
# Accepted Values:
|
||||
# true - Always verbose
|
||||
# player - Only verbose when ran from a player
|
||||
# console - Only verbose when ran from console
|
||||
# false - Never verbose
|
||||
command-verbose:
|
||||
attribute: true
|
||||
class: true
|
||||
experience: true
|
||||
level: true
|
||||
nocd: true
|
||||
points: true
|
||||
reset: true
|
||||
resource: true
|
Loading…
Reference in New Issue
Block a user