mirror of
https://github.com/filoghost/ChestCommands.git
synced 2025-01-06 07:47:42 +01:00
Improve comment formatting
This commit is contained in:
parent
2eae19e2b3
commit
97af919551
@ -193,11 +193,11 @@ public class ChestCommands extends JavaPlugin {
|
||||
getLogger().warning("Unhandled error while reading the placeholders! Please inform the developer.");
|
||||
}
|
||||
|
||||
// Load the menus.
|
||||
// Load the menus
|
||||
File menusFolder = new File(getDataFolder(), "menu");
|
||||
|
||||
if (!menusFolder.isDirectory()) {
|
||||
// Create the directory with the default menu.
|
||||
// Create the directory with the default menu
|
||||
menusFolder.mkdirs();
|
||||
Utils.saveResourceSafe(this, "menu" + File.separator + "example.yml");
|
||||
}
|
||||
@ -250,7 +250,7 @@ public class ChestCommands extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
// Register the BungeeCord plugin channel.
|
||||
// Register the BungeeCord plugin channel
|
||||
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(this, "BungeeCord")) {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public final class SimpleUpdater {
|
||||
JSONArray filesArray = (JSONArray) readJson("https://api.curseforge.com/servermods/files?projectIds=" + projectId);
|
||||
|
||||
if (filesArray.size() == 0) {
|
||||
// The array cannot be empty, there must be at least one file. The project ID is not valid.
|
||||
// The array cannot be empty, there must be at least one file. The project ID is not valid
|
||||
plugin.getLogger().warning("The project ID (" + projectId + ") provided for updating is invalid or curse had a problem.");
|
||||
plugin.getLogger().warning("If the error persists, please inform the author.");
|
||||
return;
|
||||
@ -127,16 +127,16 @@ public final class SimpleUpdater {
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
|
||||
if (pluginVersion == null) {
|
||||
// Do not throw exceptions, just consider it as v0.
|
||||
// Do not throw exceptions, just consider it as v0
|
||||
pluginVersion = "0";
|
||||
}
|
||||
|
||||
if (!remoteVersion.matches("v?[0-9\\.]+")) {
|
||||
// Should always be checked before by this class.
|
||||
// Should always be checked before by this class
|
||||
throw new IllegalArgumentException("fetched version's format is incorrect");
|
||||
}
|
||||
|
||||
// Remove all the "v" from the versions, replace multiple full stops with a single full stop, and split them.
|
||||
// Remove all the "v" from the versions, replace multiple full stops with a single full stop, and split them
|
||||
String[] pluginVersionSplit = pluginVersion.replace("v", "").replaceAll("[\\.]{2,}", ".").split("\\.");
|
||||
String[] remoteVersionSplit = remoteVersion.replace("v", "").replaceAll("[\\.]{2,}", ".").split("\\.");
|
||||
|
||||
@ -161,7 +161,7 @@ public final class SimpleUpdater {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Continue the loop.
|
||||
// Continue the loop
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -56,7 +56,7 @@ public class Icon {
|
||||
|
||||
private Set<Variable> nameVariables;
|
||||
private Map<Integer, Set<Variable>> loreVariables;
|
||||
private ItemStack cachedItem; // When there are no variables, we don't recreate the item.
|
||||
private ItemStack cachedItem; // When there are no variables, we don't recreate the item
|
||||
|
||||
public Icon() {
|
||||
enchantments = new HashMap<Enchantment, Integer>();
|
||||
@ -236,7 +236,7 @@ public class Icon {
|
||||
}
|
||||
|
||||
if (name.isEmpty()) {
|
||||
// Add a color to display the name empty.
|
||||
// Add a color to display the name empty
|
||||
return ChatColor.WHITE.toString();
|
||||
} else {
|
||||
return name;
|
||||
@ -269,7 +269,7 @@ public class Icon {
|
||||
output.add(line);
|
||||
}
|
||||
} else {
|
||||
// Otherwise just copy the lines.
|
||||
// Otherwise just copy the lines
|
||||
output.addAll(lore);
|
||||
}
|
||||
}
|
||||
@ -280,7 +280,7 @@ public class Icon {
|
||||
output = Utils.newArrayList();
|
||||
}
|
||||
|
||||
// Add an error message.
|
||||
// Add an error message
|
||||
output.add(ChatColor.RED + "(Invalid material)");
|
||||
}
|
||||
|
||||
@ -291,17 +291,17 @@ public class Icon {
|
||||
public ItemStack createItemstack(Player pov) {
|
||||
|
||||
if (!this.hasVariables() && cachedItem != null) {
|
||||
// Performance.
|
||||
// Performance
|
||||
return cachedItem;
|
||||
}
|
||||
|
||||
// If the material is not set, display BEDROCK.
|
||||
// If the material is not set, display BEDROCK
|
||||
ItemStack itemStack = (material != null) ? new ItemStack(material, amount, dataValue) : new ItemStack(Material.BEDROCK, amount);
|
||||
|
||||
// First try to apply NBT data.
|
||||
// First try to apply NBT data
|
||||
if (nbtData != null) {
|
||||
try {
|
||||
// Note: this method should not throw any exception. It should log directly to the console.
|
||||
// Note: this method should not throw any exception. It should log directly to the console
|
||||
Bukkit.getUnsafe().modifyItemStack(itemStack, nbtData);
|
||||
} catch (Throwable t) {
|
||||
this.nbtData = null;
|
||||
@ -309,7 +309,7 @@ public class Icon {
|
||||
}
|
||||
}
|
||||
|
||||
// Then apply data from config nodes, overwriting NBT data if there are confliting values.
|
||||
// Then apply data from config nodes, overwriting NBT data if there are confliting values
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
if (hasName()) {
|
||||
@ -336,7 +336,7 @@ public class Icon {
|
||||
}
|
||||
|
||||
if (!this.hasVariables()) {
|
||||
// If there are no variables, cache the item.
|
||||
// If there are no variables, cache the item
|
||||
cachedItem = itemStack;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class BungeeCordUtils {
|
||||
DataOutputStream out = new DataOutputStream(byteArray);
|
||||
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(server); // Target Server.
|
||||
out.writeUTF(server); // Target Server
|
||||
|
||||
player.sendPluginMessage(ChestCommands.getInstance(), "BungeeCord", byteArray.toByteArray());
|
||||
|
||||
|
@ -62,7 +62,7 @@ public abstract class CommandFramework implements CommandExecutor {
|
||||
} catch (CommandException ex) {
|
||||
|
||||
if (ex.getMessage() != null && !ex.getMessage().isEmpty()) {
|
||||
// Use RED by default.
|
||||
// Use RED by default
|
||||
sender.sendMessage(ChatColor.RED + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class CommandHandler extends CommandFramework {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
// This info is accessible to anyone. Please don't remove it, remember that Chest Commands is developed for FREE.
|
||||
// This info is accessible to anyone. Please don't remove it, remember that Chest Commands is developed for free
|
||||
sender.sendMessage(ChestCommands.CHAT_PREFIX);
|
||||
sender.sendMessage(ChatColor.GREEN + "Version: " + ChatColor.GRAY + ChestCommands.getInstance().getDescription().getVersion());
|
||||
sender.sendMessage(ChatColor.GREEN + "Developer: " + ChatColor.GRAY + "filoghost");
|
||||
|
@ -46,7 +46,7 @@ public class AsciiPlaceholders {
|
||||
List<String> lines = Utils.readLines(file);
|
||||
for (String line : lines) {
|
||||
|
||||
// Comment or empty line.
|
||||
// Comment or empty line
|
||||
if (line.isEmpty() || line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
@ -100,7 +100,7 @@ public class AsciiPlaceholders {
|
||||
|
||||
private static String unquote(String input) {
|
||||
if (input.length() < 2) {
|
||||
// Cannot be quoted.
|
||||
// Cannot be quoted
|
||||
return input;
|
||||
}
|
||||
if (input.startsWith("'") && input.endsWith("'")) {
|
||||
|
@ -27,7 +27,7 @@ public class Lang extends SpecialConfig {
|
||||
public String menu_not_found = "&cMenu not found! Please inform the staff.";
|
||||
public String open_menu = "&aOpening the menu \"{menu}\".";
|
||||
public String open_menu_others = "&aOpening the menu \"{menu}\" to {player}.";
|
||||
public String any = "any"; // Used in no_required_item when data value is not restrictive.
|
||||
public String any = "any"; // Used in no_required_item when data value is not restrictive
|
||||
|
||||
public Lang(PluginConfig config) {
|
||||
super(config);
|
||||
|
@ -52,7 +52,7 @@ public class PluginConfig extends YamlConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
// To reset all the values when loading.
|
||||
// To reset all the values when loading
|
||||
for (String section : this.getKeys(false)) {
|
||||
set(section, null);
|
||||
}
|
||||
|
@ -45,11 +45,11 @@ public class SpecialConfig {
|
||||
|
||||
public void load() throws IOException, InvalidConfigurationException, Exception {
|
||||
|
||||
// Check if the configuration was initialized.
|
||||
// Check if the configuration was initialized
|
||||
if (defaultValuesMap == null) {
|
||||
defaultValuesMap = new HashMap<String, Object>();
|
||||
|
||||
// Put the values in the default values map.
|
||||
// Put the values in the default values map
|
||||
for (Field field : getClass().getDeclaredFields()) {
|
||||
if (!isValidField(field)) continue;
|
||||
|
||||
@ -70,10 +70,10 @@ public class SpecialConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// First of all, try to load the yaml file.
|
||||
// First of all, try to load the yaml file
|
||||
config.load();
|
||||
|
||||
// Save default values not set.
|
||||
// Save default values not set
|
||||
boolean needsSave = false;
|
||||
for (Entry<String, Object> entry : defaultValuesMap.entrySet()) {
|
||||
if (!config.isSet(entry.getKey())) {
|
||||
@ -87,7 +87,7 @@ public class SpecialConfig {
|
||||
config.save();
|
||||
}
|
||||
|
||||
// Now read change the fields.
|
||||
// Now read change the fields
|
||||
for (Field field : getClass().getDeclaredFields()) {
|
||||
|
||||
if (!isValidField(field)) continue;
|
||||
@ -110,7 +110,7 @@ public class SpecialConfig {
|
||||
field.set(this, config.getDouble(configKey));
|
||||
|
||||
} else if (type == String.class) {
|
||||
field.set(this, Utils.addColors(config.getString(configKey))); // Always add colors.
|
||||
field.set(this, Utils.addColors(config.getString(configKey))); // Always add colors
|
||||
|
||||
} else {
|
||||
config.getPlugin().getLogger().warning("Unknown field type: " + field.getType().getName() + " (" + field.getName() + "). Please inform the developer.");
|
||||
|
@ -36,7 +36,7 @@ public class BoundItem {
|
||||
this.menu = menu;
|
||||
this.material = material;
|
||||
this.clickType = clickType;
|
||||
data = -1; // -1 = any.
|
||||
data = -1; // -1 = any
|
||||
}
|
||||
|
||||
public void setRestrictiveData(short data) {
|
||||
@ -52,16 +52,16 @@ public class BoundItem {
|
||||
return false;
|
||||
}
|
||||
|
||||
// First, they must have the same material.
|
||||
// First, they must have the same material
|
||||
if (this.material != item.getType()) {
|
||||
return false;
|
||||
}
|
||||
// Check if the data value is valid (-1 = any data value).
|
||||
// Check if the data value is valid (-1 = any data value)
|
||||
if (this.data != -1 && this.data != item.getDurability()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Finally checks the action.
|
||||
// Finally checks the action
|
||||
return clickType.isValidInteract(action);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class CommandsClickHandler implements ClickHandler {
|
||||
if (commands != null && commands.size() > 0) {
|
||||
for (IconCommand command : commands) {
|
||||
if (command instanceof OpenIconCommand) {
|
||||
// Fix GUI closing if KEEP-OPEN is not set, and a command should open another GUI.
|
||||
// Fix GUI closing if KEEP-OPEN is not set, and a command should open another GUI
|
||||
this.closeOnClick = false;
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class ExtendedIconMenu extends IconMenu {
|
||||
ItemStack newItem = AttributeRemover.hideAttributes(extIcon.createItemstack(player));
|
||||
inventory.setItem(i, newItem);
|
||||
} else {
|
||||
// Performance, only update name and lore.
|
||||
// Performance, only update name and lore
|
||||
ItemStack oldItem = AttributeRemover.hideAttributes(inventory.getItem(i));
|
||||
ItemMeta meta = oldItem.getItemMeta();
|
||||
meta.setDisplayName(extIcon.calculateName(player));
|
||||
|
@ -23,11 +23,11 @@ import com.gmail.filoghost.chestcommands.util.ClickType;
|
||||
|
||||
public class MenuData {
|
||||
|
||||
// Required data.
|
||||
// Required data
|
||||
private String title;
|
||||
private int rows;
|
||||
|
||||
// Optional data.
|
||||
// Optional data
|
||||
private String[] commands;
|
||||
private Material boundMaterial;
|
||||
private short boundDataValue;
|
||||
@ -38,7 +38,7 @@ public class MenuData {
|
||||
public MenuData(String title, int rows) {
|
||||
this.title = title;
|
||||
this.rows = rows;
|
||||
boundDataValue = -1; // -1 = any.
|
||||
boundDataValue = -1; // -1 = any
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
|
@ -34,10 +34,12 @@ public class MenuInventoryHolder implements InventoryHolder {
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
// This inventory will not do anything.
|
||||
// I'm 90% sure that it doesn't break any other plugin,
|
||||
// because the only way you can get here is using InventoryClickEvent,
|
||||
// that is cancelled by ChestCommands, or using InventoryOpenEvent.
|
||||
/*
|
||||
* This inventory will not do anything.
|
||||
* I'm 90% sure that it doesn't break any other plugin,
|
||||
* because the only way you can get here is using InventoryClickEvent,
|
||||
* that is cancelled by ChestCommands, or using InventoryOpenEvent.
|
||||
*/
|
||||
return Bukkit.createInventory(null, iconMenu.getSize());
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ public class ExtendedIcon extends Icon {
|
||||
@Override
|
||||
public boolean onClick(Player player) {
|
||||
|
||||
// Check all the requirements.
|
||||
// Check all the requirements
|
||||
|
||||
if (!canClickIcon(player)) {
|
||||
if (permissionMessage != null) {
|
||||
@ -190,9 +190,9 @@ public class ExtendedIcon extends Icon {
|
||||
}
|
||||
}
|
||||
|
||||
// Take the money and the required item.
|
||||
// Take the money and the required item
|
||||
|
||||
boolean changedVariables = false; // To update the placeholders.
|
||||
boolean changedVariables = false; // To update the placeholders
|
||||
|
||||
if (moneyPrice > 0) {
|
||||
if (!EconomyBridge.takeMoney(player, moneyPrice)) {
|
||||
|
@ -31,7 +31,7 @@ public class DragonBarIconCommand extends IconCommand {
|
||||
seconds = 1;
|
||||
message = command;
|
||||
|
||||
String[] split = command.split("\\|", 2); // Max of 2 pieces.
|
||||
String[] split = command.split("\\|", 2); // Max of 2 pieces
|
||||
if (split.length > 1 && Utils.isValidPositiveInteger(split[0].trim())) {
|
||||
seconds = Integer.parseInt(split[0].trim());
|
||||
message = split[1].trim();
|
||||
|
@ -33,8 +33,10 @@ public class OpenIconCommand extends IconCommand {
|
||||
final ExtendedIconMenu menu = ChestCommands.getFileNameToMenuMap().get(command.toLowerCase());
|
||||
if (menu != null) {
|
||||
|
||||
// Delay the task, since this command is executed in ClickInventoryEvent
|
||||
// and opening another inventory in the same moment is not a good idea.
|
||||
/*
|
||||
* Delay the task, since this command is executed in ClickInventoryEvent
|
||||
* and opening another inventory in the same moment is not a good idea.
|
||||
*/
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ChestCommands.getInstance(), new Runnable() {
|
||||
public void run() {
|
||||
if (player.hasPermission(menu.getPermission())) {
|
||||
|
@ -32,7 +32,7 @@ public class CommandListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// Very fast method compared to split & substring.
|
||||
// Very fast method compared to split & substring
|
||||
String command = StringUtils.getCleanCommand(event.getMessage());
|
||||
|
||||
if (command.isEmpty()) {
|
||||
|
@ -57,7 +57,7 @@ public class InventoryListener implements Listener {
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (event.getInventory().getHolder() instanceof MenuInventoryHolder) {
|
||||
|
||||
event.setCancelled(true); // First thing to do, if an exception is thrown at least the player doesn't take the item.
|
||||
event.setCancelled(true); // First thing to do, if an exception is thrown at least the player doesn't take the item
|
||||
|
||||
IconMenu menu = ((MenuInventoryHolder) event.getInventory().getHolder()).getIconMenu();
|
||||
int slot = event.getRawSlot();
|
||||
@ -81,7 +81,7 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// Closes the inventory and executes commands AFTER the event.
|
||||
// Closes the inventory and executes commands AFTER the event
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ChestCommands.getInstance(), new ExecuteCommandsTask(clicker, icon));
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class SignListener implements Listener {
|
||||
|
||||
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onSignChangeMonitor(SignChangeEvent event) {
|
||||
// Prevent players with permissions for creating colored signs from creating menu signs.
|
||||
// Prevent players with permissions for creating colored signs from creating menu signs
|
||||
if (event.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE + "[menu]") && !event.getPlayer().hasPermission(Permissions.SIGN_CREATE)) {
|
||||
event.setLine(0, ChatColor.stripColor(event.getLine(0)));
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ public class AttributeRemover {
|
||||
private static Class<?> nbtTagCompoundClass;
|
||||
private static Class<?> nbtTagListClass;
|
||||
private static Class<?> nmsItemstackClass;
|
||||
private static Method asNmsCopyMethod; // static
|
||||
private static Method asCraftMirrorMethod; // static
|
||||
private static Method asNmsCopyMethod;
|
||||
private static Method asCraftMirrorMethod;
|
||||
private static Method hasTagMethod;
|
||||
private static Method getTagMethod;
|
||||
private static Method setTagMethod;
|
||||
@ -111,10 +111,12 @@ public class AttributeRemover {
|
||||
nbtSetMethod.invoke(nbtCompound, "AttributeModifiers", nbtList);
|
||||
return (ItemStack) asCraftMirrorMethod.invoke(null, nmsItemstack);
|
||||
|
||||
} catch (Exception e) { }
|
||||
} catch (Throwable t) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
// On failure
|
||||
// On failure just return the item
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class CommandSerializer {
|
||||
commandTypesMap.put(commandPattern("console:"), ConsoleIconCommand.class);
|
||||
commandTypesMap.put(commandPattern("op:"), OpIconCommand.class);
|
||||
commandTypesMap.put(commandPattern("(open|menu):"), OpenIconCommand.class);
|
||||
commandTypesMap.put(commandPattern("server:?"), ServerIconCommand.class); // The colon is optional.
|
||||
commandTypesMap.put(commandPattern("server:?"), ServerIconCommand.class); // The colon is optional
|
||||
commandTypesMap.put(commandPattern("tell:"), TellIconCommand.class);
|
||||
commandTypesMap.put(commandPattern("broadcast:"), BroadcastIconCommand.class);
|
||||
commandTypesMap.put(commandPattern("give:"), GiveIconCommand.class);
|
||||
@ -53,7 +53,7 @@ public class CommandSerializer {
|
||||
}
|
||||
|
||||
private static Pattern commandPattern(String regex) {
|
||||
return Pattern.compile("^(?i)" + regex); // Case insensitive and only at the beginning.
|
||||
return Pattern.compile("^(?i)" + regex); // Case insensitive and only at the beginning
|
||||
}
|
||||
|
||||
public static void checkClassConstructors(ErrorLogger errorLogger) {
|
||||
@ -93,18 +93,18 @@ public class CommandSerializer {
|
||||
for (Entry<Pattern, Class<? extends IconCommand>> entry : commandTypesMap.entrySet()) {
|
||||
Matcher matcher = entry.getKey().matcher(input);
|
||||
if (matcher.find()) {
|
||||
// Remove the command prefix and trim the spaces.
|
||||
// Remove the command prefix and trim the spaces
|
||||
String cleanCommand = matcher.replaceFirst("").trim();
|
||||
|
||||
try {
|
||||
return entry.getValue().getDeclaredConstructor(String.class).newInstance(cleanCommand);
|
||||
} catch (Exception e) {
|
||||
// Checked at startup.
|
||||
// Checked at startup
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new PlayerIconCommand(input); // Normal command, no match found.
|
||||
return new PlayerIconCommand(input); // Normal command, no match found
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class EnchantmentSerializer {
|
||||
|
||||
for (Enchantment enchant : Enchantment.values()) {
|
||||
if (enchant != null) {
|
||||
// Accepts the ugly default names too.
|
||||
// Accepts the ugly default names too
|
||||
enchantmentsMap.put(formatLowercase(enchant.getName()), enchant);
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public class IconSerializer {
|
||||
public static Icon loadIconFromSection(ConfigurationSection section, String iconName, String menuFileName, ErrorLogger errorLogger) {
|
||||
Validate.notNull(section, "ConfigurationSection cannot be null");
|
||||
|
||||
// The icon is valid even without a Material.
|
||||
// The icon is valid even without a Material
|
||||
ExtendedIcon icon = new ExtendedIcon();
|
||||
|
||||
if (section.isSet(Nodes.ID)) {
|
||||
@ -116,7 +116,7 @@ public class IconSerializer {
|
||||
if (section.isSet(Nodes.NBT_DATA)) {
|
||||
String nbtData = section.getString(Nodes.NBT_DATA);
|
||||
try {
|
||||
// Check that NBT has valid syntax before applying it to the icon.
|
||||
// Check that NBT has valid syntax before applying it to the icon
|
||||
MojangsonParser.parse(nbtData);
|
||||
icon.setNBTData(nbtData);
|
||||
} catch (MojangsonParseException e) {
|
||||
|
@ -99,7 +99,7 @@ public class MenuSerializer {
|
||||
}
|
||||
|
||||
} else {
|
||||
rows = 6; // Defaults to 6 rows.
|
||||
rows = 6; // Defaults to 6 rows
|
||||
errorLogger.addError("The menu \"" + config.getFileName() + "\" doesn't have a the number of rows set, it will have 6 rows by default.");
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ import com.gmail.filoghost.chestcommands.exception.FormatException;
|
||||
|
||||
public class ItemStackReader {
|
||||
|
||||
private Material material = Material.STONE; // In the worst case (bad exception handling) we just get stone.
|
||||
private Material material = Material.STONE; // In the worst case (bad exception handling) we just get stone
|
||||
private int amount = 1;
|
||||
private short dataValue = 0;
|
||||
private boolean explicitDataValue = false;
|
||||
@ -34,11 +34,11 @@ public class ItemStackReader {
|
||||
public ItemStackReader(String input, boolean parseAmount) throws FormatException {
|
||||
Validate.notNull(input, "input cannot be null");
|
||||
|
||||
// Remove spaces, they're not needed.
|
||||
// Remove spaces, they're not needed
|
||||
input = StringUtils.stripChars(input, " _-");
|
||||
|
||||
if (parseAmount) {
|
||||
// Read the optional amount.
|
||||
// Read the optional amount
|
||||
String[] splitAmount = input.split(",");
|
||||
|
||||
if (splitAmount.length > 1) {
|
||||
@ -51,13 +51,13 @@ public class ItemStackReader {
|
||||
if (amount <= 0) throw new FormatException("invalid amount \"" + splitAmount[1] + "\"");
|
||||
this.amount = amount;
|
||||
|
||||
// Only keep the first part as input.
|
||||
// Only keep the first part as input
|
||||
input = splitAmount[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Read the optional data value.
|
||||
// Read the optional data value
|
||||
String[] splitByColons = input.split(":");
|
||||
|
||||
if (splitByColons.length > 1) {
|
||||
@ -74,7 +74,7 @@ public class ItemStackReader {
|
||||
this.explicitDataValue = true;
|
||||
this.dataValue = dataValue;
|
||||
|
||||
// Only keep the first part as input.
|
||||
// Only keep the first part as input
|
||||
input = splitByColons[0];
|
||||
}
|
||||
|
||||
|
@ -24,19 +24,19 @@ import org.bukkit.Material;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MaterialsRegistry {
|
||||
|
||||
// Material names have been changed in 1.13, when dolphins were added.
|
||||
// Material names have been changed in 1.13, when dolphins were added
|
||||
private static final boolean USE_NEW_MATERIAL_NAMES = Utils.isClassLoaded("org.bukkit.entity.Dolphin");
|
||||
|
||||
// Characters to ignore when searching materials by name.
|
||||
// Characters to ignore when searching materials by name
|
||||
private static final char[] IGNORE_CHARS = {'-', '_', ' '};
|
||||
|
||||
// Default material names are ugly.
|
||||
// Default material names are ugly
|
||||
private static final Map<String, Material> MATERIALS_BY_ALIAS = new HashMap<String, Material>();
|
||||
|
||||
// Materials that are considered air (with 1.13+ compatibility).
|
||||
// Materials that are considered air (with 1.13+ compatibility)
|
||||
private static final Collection<Material> AIR_MATERIALS = getExistingMaterials("AIR", "CAVE_AIR", "VOID_AIR");
|
||||
|
||||
// Materials that have a "Sign" block state (with 1.13+ compatibility).
|
||||
// Materials that have a "Sign" block state (with 1.13+ compatibility)
|
||||
private static final Collection<Material> SIGN_MATERIALS = getExistingMaterials("SIGN", "SIGN_POST", "WALL_SIGN");
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ public class MaterialsRegistry {
|
||||
try {
|
||||
addMaterialAlias(name, Material.valueOf(materialEnumName));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Ignore, do not add a new alias.
|
||||
// Ignore, do not add a new alias
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ public class MaterialsRegistry {
|
||||
try {
|
||||
existingMaterials.add(Material.valueOf(materialEnumName));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Ignore, not existing.
|
||||
// Ignore, not existing
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,12 +95,12 @@ public class MaterialsRegistry {
|
||||
addMaterialAlias(material.toString(), material);
|
||||
|
||||
if (!useNewMaterialNames()) {
|
||||
// Add numerical IDs in versions before 1.13.
|
||||
// Add numerical IDs in versions before 1.13
|
||||
addMaterialAlias(String.valueOf(material.getId()), material);
|
||||
}
|
||||
}
|
||||
|
||||
// Add some default useful aliases (when present).
|
||||
// Add some default useful aliases (when present)
|
||||
tryAddMaterialAlias("iron bar", "IRON_FENCE");
|
||||
tryAddMaterialAlias("iron bars", "IRON_FENCE");
|
||||
tryAddMaterialAlias("glass pane", "THIN_GLASS");
|
||||
|
@ -24,7 +24,7 @@ public class StringUtils {
|
||||
return stripChars(input, removed.toCharArray());
|
||||
}
|
||||
|
||||
// Removes the first slash, and returns the all the chars until a space is encontered.
|
||||
// Removes the first slash, and returns the all the chars until a space is encontered
|
||||
public static String getCleanCommand(String message) {
|
||||
char[] chars = message.toCharArray();
|
||||
|
||||
|
@ -228,7 +228,7 @@ public class Utils {
|
||||
try {
|
||||
plugin.saveResource(name, false);
|
||||
} catch (Exception ex) {
|
||||
// Shhh...
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user