Fixes some minor warnings and spacing
This commit is contained in:
@@ -21,9 +21,9 @@ public class StargateCommand extends JavaPlugin {
|
|||||||
RegisteredServiceProvider<StargateAPI> stargateProvider = servicesManager.getRegistration(StargateAPI.class);
|
RegisteredServiceProvider<StargateAPI> stargateProvider = servicesManager.getRegistration(StargateAPI.class);
|
||||||
if (stargateProvider != null) {
|
if (stargateProvider != null) {
|
||||||
StargateAPI stargateAPI = stargateProvider.getProvider();
|
StargateAPI stargateAPI = stargateProvider.getProvider();
|
||||||
|
|
||||||
//Register commands
|
//Register commands
|
||||||
PluginCommand stargateCommand = this.getCommand("stargatecommand");
|
PluginCommand stargateCommand = this.getCommand("stargateCommand");
|
||||||
if (stargateCommand != null) {
|
if (stargateCommand != null) {
|
||||||
stargateCommand.setExecutor(new CommandStarGateCommand(stargateAPI));
|
stargateCommand.setExecutor(new CommandStarGateCommand(stargateAPI));
|
||||||
stargateCommand.setTabCompleter(new StargateCommandTabCompleter());
|
stargateCommand.setTabCompleter(new StargateCommandTabCompleter());
|
||||||
@@ -38,5 +38,5 @@ public class StargateCommand extends JavaPlugin {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
//Currently, nothing needs to be disabled
|
//Currently, nothing needs to be disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,17 +17,17 @@ import java.util.Arrays;
|
|||||||
* This command represents the config command for changing config values
|
* This command represents the config command for changing config values
|
||||||
*/
|
*/
|
||||||
public class CommandConfig implements CommandExecutor {
|
public class CommandConfig implements CommandExecutor {
|
||||||
|
|
||||||
private final ConfigurationAPI configurationAPI;
|
private final ConfigurationAPI configurationAPI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new instance of the config command
|
* Instantiates a new instance of the config command
|
||||||
*
|
*
|
||||||
* @param configurationAPI <p>A reference to the Stargate API</p>
|
* @param configurationAPI <p>A reference to the Stargate API</p>
|
||||||
*/
|
*/
|
||||||
public CommandConfig(ConfigurationAPI configurationAPI) {
|
public CommandConfig(ConfigurationAPI configurationAPI) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.configurationAPI = configurationAPI;
|
this.configurationAPI = configurationAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,10 +95,10 @@ public class CommandConfig implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test any option data type with a defined set of values.
|
/* Test any option data type with a defined set of values.
|
||||||
* Color is excluded as it has a near-infinite number of valid values. */
|
* Color is excluded as it has a near-infinite number of valid values. */
|
||||||
if (optionDataType != OptionDataType.COLOR && optionDataType.getValues() != null &&
|
if (optionDataType != OptionDataType.COLOR && optionDataType.getValues() != null &&
|
||||||
optionDataType.getValues().length > 0) {
|
optionDataType.getValues().length > 0) {
|
||||||
if (!checkIfValueMatchesDatatype(optionDataType, value, commandSender)) {
|
if (!checkIfValueMatchesDatatype(optionDataType, value, commandSender)) {
|
||||||
return;
|
return;
|
||||||
@@ -111,15 +111,15 @@ public class CommandConfig implements CommandExecutor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given value is valid for the given option data type and warns if it isn't
|
* Checks if the given value is valid for the given option data type and warns if it isn't
|
||||||
*
|
*
|
||||||
* @param dataType <p>The expected type for the value</p>
|
* @param dataType <p>The expected type for the value</p>
|
||||||
* @param value <p>The value to check</p>
|
* @param value <p>The value to check</p>
|
||||||
* @param commandSender <p>The command sender to warn about invalid values</p>
|
* @param commandSender <p>The command sender to warn about invalid values</p>
|
||||||
* @return <p>True if the given value is valid for the option data type</p>
|
* @return <p>True if the given value is valid for the option data type</p>
|
||||||
*/
|
*/
|
||||||
private boolean checkIfValueMatchesDatatype(OptionDataType dataType, String value, CommandSender commandSender) {
|
private boolean checkIfValueMatchesDatatype(OptionDataType dataType, String value, CommandSender commandSender) {
|
||||||
if (!matchesOptionDataType(dataType, value)) {
|
if (!matchesOptionDataType(dataType, value)) {
|
||||||
commandSender.sendMessage(String.format("Invalid %s given",
|
commandSender.sendMessage(String.format("Invalid %s given",
|
||||||
dataType.name().toLowerCase().replace('_', ' ')));
|
dataType.name().toLowerCase().replace('_', ' ')));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -129,9 +129,9 @@ public class CommandConfig implements CommandExecutor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given value is valid for the given option data type
|
* Checks if the given value is valid for the given option data type
|
||||||
*
|
*
|
||||||
* @param dataType <p>The expected type for the value</p>
|
* @param dataType <p>The expected type for the value</p>
|
||||||
* @param value <p>The value to check</p>
|
* @param value <p>The value to check</p>
|
||||||
* @return <p>True if the given value is valid for the option data type</p>
|
* @return <p>True if the given value is valid for the option data type</p>
|
||||||
*/
|
*/
|
||||||
private boolean matchesOptionDataType(OptionDataType dataType, String value) {
|
private boolean matchesOptionDataType(OptionDataType dataType, String value) {
|
||||||
@@ -141,7 +141,7 @@ public class CommandConfig implements CommandExecutor {
|
|||||||
/**
|
/**
|
||||||
* Saves the configuration file and reloads
|
* Saves the configuration file and reloads
|
||||||
*
|
*
|
||||||
* @param commandSender <p>The command sender that executed the config command</p>
|
* @param commandSender <p>The command sender that executed the config command</p>
|
||||||
*/
|
*/
|
||||||
private void saveAndReload(CommandSender commandSender) {
|
private void saveAndReload(CommandSender commandSender) {
|
||||||
configurationAPI.saveConfiguration();
|
configurationAPI.saveConfiguration();
|
||||||
@@ -216,7 +216,7 @@ public class CommandConfig implements CommandExecutor {
|
|||||||
*/
|
*/
|
||||||
private void displayConfigValues(CommandSender sender) {
|
private void displayConfigValues(CommandSender sender) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Stargate" + ChatColor.GOLD + "Config values:");
|
sender.sendMessage(ChatColor.GREEN + "Stargate" + ChatColor.GOLD + "Config values:");
|
||||||
|
|
||||||
for (ConfigurationOption option : ConfigurationOption.values()) {
|
for (ConfigurationOption option : ConfigurationOption.values()) {
|
||||||
sender.sendMessage(getOptionDescription(option));
|
sender.sendMessage(getOptionDescription(option));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* This command represents any command which starts with stargate-command (sgc)
|
* This command represents any command which starts with stargate-command (sgc)
|
||||||
*/
|
*/
|
||||||
public class CommandStarGateCommand implements CommandExecutor {
|
public class CommandStarGateCommand implements CommandExecutor {
|
||||||
|
|
||||||
private StargateAPI stargateAPI;
|
private final StargateAPI stargateAPI;
|
||||||
|
|
||||||
public CommandStarGateCommand(StargateAPI stargateAPI) {
|
public CommandStarGateCommand(StargateAPI stargateAPI) {
|
||||||
this.stargateAPI = stargateAPI;
|
this.stargateAPI = stargateAPI;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class ConfigTabCompleter implements TabCompleter {
|
|||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedOption.getDataType() == OptionDataType.COLOR) {
|
if (selectedOption.getDataType() == OptionDataType.COLOR) {
|
||||||
return filterMatching(chatColors, typedText);
|
return filterMatching(chatColors, typedText);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,5 +46,5 @@ public class StargateCommandTabCompleter implements TabCompleter {
|
|||||||
}
|
}
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user