Makes visualizer icons configurable #2
This commit is contained in:
@@ -6,7 +6,10 @@ import net.knarcraft.stargatecommand.command.CommandStarGateCommand;
|
||||
import net.knarcraft.stargatecommand.command.StargateCommandTabCompleter;
|
||||
import net.knarcraft.stargatecommand.formatting.Translator;
|
||||
import net.knarcraft.stargatecommand.listener.StargateListener;
|
||||
import net.knarcraft.stargatecommand.manager.IconManager;
|
||||
import net.knarcraft.stargatecommand.property.Icon;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicesManager;
|
||||
@@ -31,6 +34,12 @@ public class StargateCommand extends JavaPlugin {
|
||||
initializeBannedConfigOptions();
|
||||
}
|
||||
instance = this;
|
||||
|
||||
FileConfiguration configuration = this.getConfig();
|
||||
this.saveDefaultConfig();
|
||||
configuration.options().copyDefaults(true);
|
||||
loadConfiguration(configuration);
|
||||
|
||||
Translator.loadLanguages("en");
|
||||
//Get the Stargate API
|
||||
ServicesManager servicesManager = this.getServer().getServicesManager();
|
||||
@@ -66,6 +75,21 @@ public class StargateCommand extends JavaPlugin {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all configuration values from the given configuration
|
||||
*
|
||||
* @param fileConfiguration <p>The configuration to load</p>
|
||||
*/
|
||||
private void loadConfiguration(FileConfiguration fileConfiguration) {
|
||||
//Load all icons from config
|
||||
for (Icon icon : Icon.values()) {
|
||||
String iconString = fileConfiguration.getString(icon.getConfigNode());
|
||||
if (iconString != null) {
|
||||
IconManager.registerIconString(icon, iconString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the list of banned configuration options
|
||||
*
|
||||
|
||||
@@ -8,54 +8,58 @@ public enum Icon {
|
||||
/**
|
||||
* The icon used to mark a Stargate as hidden
|
||||
*/
|
||||
HIDDEN("⇒", "{icon_h}"),
|
||||
HIDDEN("⇒", "{icon_h}", "icon.hiddenIcon"),
|
||||
|
||||
/**
|
||||
* The icon used to mark a Stargate as not hidden
|
||||
*/
|
||||
NOT_HIDDEN("⇄", "{icon_nh}"),
|
||||
NOT_HIDDEN("⇄", "{icon_nh}", "icon.notHiddenIcon"),
|
||||
|
||||
/**
|
||||
* The icon used to mark a Stargate as always on/open
|
||||
*/
|
||||
ALWAYS_ON("⬛", "{icon_a}"),
|
||||
ALWAYS_ON("⬛", "{icon_a}", "icon.alwaysOpenIcon"),
|
||||
|
||||
/**
|
||||
* The icon used to mark a Stargate as not always on/open
|
||||
*/
|
||||
NOT_ALWAYS_ON("⬜", "{icon_na}"),
|
||||
NOT_ALWAYS_ON("⬜", "{icon_na}", "icon.notAlwaysOpenIcon"),
|
||||
|
||||
/**
|
||||
* The icon used to mark a Stargate as random
|
||||
*/
|
||||
RANDOM("↯", "{icon_r}"),
|
||||
RANDOM("↯", "{icon_r}", "icon.randomIcon"),
|
||||
|
||||
/**
|
||||
* The icon used to mark a Stargate as not random
|
||||
*/
|
||||
NOT_RANDOM("↠", "{icon_nr}"),
|
||||
NOT_RANDOM("↠", "{icon_nr}", "icon.notRandomIcon"),
|
||||
|
||||
/**
|
||||
* The icon used as a rightwards arrow between two items
|
||||
*/
|
||||
ARROW_RIGHT("->", "{icon_arrow_right}"),
|
||||
ARROW_RIGHT("->", "{icon_arrow_right}", "icon.arrowRightIcon"),
|
||||
|
||||
/**
|
||||
* The icon used to replace the space character for any names with spaces
|
||||
*/
|
||||
SPACE_REPLACEMENT("⚊", "{icon_space}");
|
||||
SPACE_REPLACEMENT("⚊", "{icon_space}", "icon.spaceReplacementIcon");
|
||||
|
||||
private final String defaultIcon;
|
||||
private final String placeholder;
|
||||
private final String configNode;
|
||||
|
||||
/**
|
||||
* Instantiates a new icon
|
||||
*
|
||||
* @param defaultIcon <p>The default value used unless another is specified</p>
|
||||
* @param placeholder <p>The placeholder this icon should replace</p>
|
||||
* @param configNode <p>The config node used to specify this icon</p>
|
||||
*/
|
||||
Icon(String defaultIcon, String placeholder) {
|
||||
Icon(String defaultIcon, String placeholder, String configNode) {
|
||||
this.defaultIcon = defaultIcon;
|
||||
this.placeholder = placeholder;
|
||||
this.configNode = configNode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,4 +80,13 @@ public enum Icon {
|
||||
return this.placeholder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the config node used to specify this icon
|
||||
*
|
||||
* @return <p>The config node used to specify this icon</p>
|
||||
*/
|
||||
public String getConfigNode() {
|
||||
return this.configNode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user