From b526ff4b725b621775090938cca72ac15b64d870 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 30 Jun 2015 05:30:36 +1000 Subject: [PATCH] Fire protection, plot component setting Fixes #358 --- PlotSquared/pom.xml | 2 +- .../plot/commands/DebugExec.java | 13 ++- .../plot/commands/Set.java | 62 ++++++++--- .../intellectualcrafters/plot/config/C.java | 4 +- .../plot/config/Configuration.java | 101 +++++++----------- .../plot/flag/FlagManager.java | 4 +- .../plot/listeners/PlayerEvents.java | 5 +- .../plot/object/PlotWorld.java | 2 +- .../plot/util/BlockManager.java | 5 + .../plot/util/MainUtil.java | 1 - .../plot/util/StringComparison.java | 42 +++++--- .../plot/util/bukkit/BukkitUtil.java | 58 +++++++++- 12 files changed, 195 insertions(+), 104 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 620f46d46..fcf4b9978 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.11.24 + 2.11.25 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 340bdef4d..1b8e7d77d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -92,13 +92,18 @@ public class DebugExec extends SubCommand { ExpireManager.task = -1; return MainUtil.sendMessage(player, "Cancelled task."); } - case "reset-modified": { + case "remove-flag": { + if (args.length != 2) { + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot debugexec reset-flat "); + return false; + } + String flag = args[1]; for (Plot plot : PlotSquared.getPlots()) { - if (FlagManager.getPlotFlag(plot, "modified-blocks") != null) { - FlagManager.removePlotFlag(plot, "modified-blocks"); + if (FlagManager.getPlotFlag(plot, flag) != null) { + FlagManager.removePlotFlag(plot, flag); } } - return MainUtil.sendMessage(player, "Cleared modified flag!"); + return MainUtil.sendMessage(player, "Cleared flag: " + flag); } case "start-rgar": { if (args.length != 2) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java index 168f73572..36cc120e9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.AbstractFlag; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.flag.FlagValue.PlotBlockListValue; import com.intellectualcrafters.plot.listeners.APlotListener; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.Location; @@ -46,6 +47,7 @@ import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.SetBlockQueue; +import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -238,24 +240,50 @@ public class Set extends SubCommand { } PlotBlock[] blocks; try { - blocks = (PlotBlock[]) Configuration.BLOCKLIST.parseString(args[1]); - } catch (final Exception e) { - try { - if (args.length < 2) { - MainUtil.sendMessage(plr, C.NEED_BLOCK); - return true; - } - blocks = new PlotBlock[] { new PlotBlock((short) BlockManager.manager.getBlockIdFromString(args[1]), (byte) 0) }; - for (PlotBlock block : blocks) { - if (!BlockManager.manager.isBlockSolid(block)) { - MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK); - return false; - } - } - } catch (final Exception e2) { - MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK); - return false; + if (args.length < 2) { + MainUtil.sendMessage(plr, C.NEED_BLOCK); + return true; } +// if (!Configuration.BLOCKLIST.validateValue(args[1])) { +// MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, args[1]); +// return false; +// } + String[] split = args[1].split(","); + blocks = Configuration.BLOCKLIST.parseString(args[1]); + for (int i = 0; i < blocks.length; i++) { + PlotBlock block = blocks[i]; + if (block == null) { + MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, split[i]); + String name; + if (split[i].contains("%")) { + name = split[i].split("%")[1]; + } + else { + name = split[i]; + } + StringComparison.ComparisonResult match = BlockManager.manager.getClosestBlock(name); + if (match != null) { + name = BlockManager.manager.getClosestMatchingName(match.best); + if (name != null) { + MainUtil.sendMessage(plr, C.DID_YOU_MEAN, name.toLowerCase()); + } + } + return false; + } + else if (!BlockManager.manager.isBlockSolid(block)) { + MainUtil.sendMessage(plr, C.NOT_ALLOWED_BLOCK, block.toString()); + return false; + } + } + for (PlotBlock block : blocks) { + if (!BlockManager.manager.isBlockSolid(block)) { + MainUtil.sendMessage(plr, C.NOT_ALLOWED_BLOCK, block.toString()); + return false; + } + } + } catch (final Exception e2) { + MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, args[1]); + return false; } if (MainUtil.runners.containsKey(plot)) { MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index b2830d850..4a672e7c9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -293,7 +293,6 @@ public enum C { /* * Block List */ - NOT_VALID_BLOCK_LIST_HEADER("$2That's not a valid block. Valid blocks are:\\n", "Block List"), BLOCK_LIST_ITEM(" $1%mat%$2,", "Block List"), BLOCK_LIST_SEPARATER("$1,$2 ", "Block List"), /* @@ -322,7 +321,8 @@ public enum C { * Invalid */ NOT_VALID_DATA("$2That's not a valid data id.", "Invalid"), - NOT_VALID_BLOCK("$2That's not a valid block.", "Invalid"), + NOT_VALID_BLOCK("$2That's not a valid block: %s", "Invalid"), + NOT_ALLOWED_BLOCK("$2That block is not allowed: %s", "Invalid"), NOT_VALID_NUMBER("$2That's not a valid number within the range: %s", "Invalid"), NOT_VALID_PLOT_ID("$2That's not a valid plot id.", "Invalid"), PLOT_ID_FORM("$2The plot id must be in the form: $1X;Y $2e.g. $1-5;7", "Invalid"), diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java index 15cb48664..0f8a95abb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Configuration.java @@ -21,9 +21,11 @@ package com.intellectualcrafters.plot.config; import java.util.ArrayList; +import java.util.List; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.BlockManager; +import com.intellectualcrafters.plot.util.StringComparison; /** * Main Configuration Utility @@ -32,29 +34,29 @@ import com.intellectualcrafters.plot.util.BlockManager; */ @SuppressWarnings("unused") public class Configuration { - public static final SettingValue STRING = new SettingValue("STRING") { + public static final SettingValue STRING = new SettingValue("STRING") { @Override public boolean validateValue(final String string) { return true; } @Override - public Object parseString(final String string) { + public String parseString(final String string) { return string; } }; - public static final SettingValue STRINGLIST = new SettingValue("STRINGLIST") { + public static final SettingValue STRINGLIST = new SettingValue("STRINGLIST") { @Override public boolean validateValue(final String string) { return true; } @Override - public Object parseString(final String string) { + public String[] parseString(final String string) { return string.split(","); } }; - public static final SettingValue INTEGER = new SettingValue("INTEGER") { + public static final SettingValue INTEGER = new SettingValue("INTEGER") { @Override public boolean validateValue(final String string) { try { @@ -66,11 +68,11 @@ public class Configuration { } @Override - public Object parseString(final String string) { + public Integer parseString(final String string) { return Integer.parseInt(string); } }; - public static final SettingValue BOOLEAN = new SettingValue("BOOLEAN") { + public static final SettingValue BOOLEAN = new SettingValue("BOOLEAN") { @Override public boolean validateValue(final String string) { try { @@ -82,11 +84,11 @@ public class Configuration { } @Override - public Object parseString(final String string) { + public Boolean parseString(final String string) { return Boolean.parseBoolean(string); } }; - public static final SettingValue DOUBLE = new SettingValue("DOUBLE") { + public static final SettingValue DOUBLE = new SettingValue("DOUBLE") { @Override public boolean validateValue(final String string) { try { @@ -98,11 +100,11 @@ public class Configuration { } @Override - public Object parseString(final String string) { + public Double parseString(final String string) { return Double.parseDouble(string); } }; - public static final SettingValue BIOME = new SettingValue("BIOME") { + public static final SettingValue BIOME = new SettingValue("BIOME") { @Override public boolean validateValue(final String string) { try { @@ -117,19 +119,14 @@ public class Configuration { } @Override - public Object parseString(final String string) { + public String parseString(final String string) { if (validateValue(string)) { return string.toUpperCase(); } return "FOREST"; } - - @Override - public Object parseObject(final Object object) { - return object.toString(); - } }; - public static final SettingValue BLOCK = new SettingValue("BLOCK") { + public static final SettingValue BLOCK = new SettingValue("BLOCK") { @Override public boolean validateValue(final String string) { try { @@ -147,7 +144,7 @@ public class Configuration { } @Override - public Object parseString(final String string) { + public PlotBlock parseString(final String string) { if (string.contains(":")) { final String[] split = string.split(":"); return new PlotBlock(Short.parseShort(split[0]), Byte.parseByte(split[1])); @@ -155,13 +152,8 @@ public class Configuration { return new PlotBlock(Short.parseShort(string), (byte) 0); } } - - @Override - public Object parseObject(final Object object) { - return object; - } }; - public static final SettingValue BLOCKLIST = new SettingValue("BLOCKLIST") { + public static final SettingValue BLOCKLIST = new SettingValue("BLOCKLIST") { @Override public boolean validateValue(final String string) { try { @@ -171,12 +163,9 @@ public class Configuration { Integer.parseInt(split[0]); block = split[1]; } - if (block.contains(":")) { - final String[] split = block.split(":"); - Short.parseShort(split[0]); - Short.parseShort(split[1]); - } else { - Short.parseShort(block); + StringComparison.ComparisonResult value = BlockManager.manager.getClosestBlock(block); + if (value == null || value.match > 1) { + return false; } } return true; @@ -186,33 +175,34 @@ public class Configuration { } @Override - public Object parseString(final String string) { + public PlotBlock[] parseString(final String string) { final String[] blocks = string.split(","); final ArrayList parsedvalues = new ArrayList<>(); final PlotBlock[] values = new PlotBlock[blocks.length]; final int[] counts = new int[blocks.length]; int min = 100; for (int i = 0; i < blocks.length; i++) { - if (blocks[i].contains("%")) { - final String[] split = blocks[i].split("%"); - blocks[i] = split[1]; - final int value = Integer.parseInt(split[0]); - counts[i] = value; - if (value < min) { - min = value; + try { + if (blocks[i].contains("%")) { + final String[] split = blocks[i].split("%"); + blocks[i] = split[1]; + final int value = Integer.parseInt(split[0]); + counts[i] = value; + if (value < min) { + min = value; + } + } else { + counts[i] = 1; + if (1 < min) { + min = 1; + } } - } else { - counts[i] = 1; - if (1 < min) { - min = 1; + StringComparison.ComparisonResult result = BlockManager.manager.getClosestBlock(blocks[i]); + if (result != null && result.match < 2) { + values[i] = result.best; } } - if (blocks[i].contains(":")) { - final String[] split = blocks[i].split(":"); - values[i] = new PlotBlock(Short.parseShort(split[0]), Byte.parseByte(split[1])); - } else { - values[i] = new PlotBlock(Short.parseShort(blocks[i]), (byte) 0); - } + catch (Exception e) {} } final int gcd = gcd(counts); for (int i = 0; i < counts.length; i++) { @@ -223,11 +213,6 @@ public class Configuration { } return parsedvalues.toArray(new PlotBlock[parsedvalues.size()]); } - - @Override - public Object parseObject(final Object object) { - return object; - } }; public static int gcd(final int a, final int b) { @@ -248,7 +233,7 @@ public class Configuration { /** * Create your own SettingValue object to make the management of plotworld configuration easier */ - public static abstract class SettingValue { + public static abstract class SettingValue { private final String type; public SettingValue(final String type) { @@ -259,11 +244,7 @@ public class Configuration { return this.type; } - public Object parseObject(final Object object) { - return object; - } - - public abstract Object parseString(final String string); + public abstract T parseString(final String string); public abstract boolean validateValue(final String string); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index bfa0eb426..aee043850 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -102,7 +102,7 @@ public class FlagManager { public static boolean addFlag(AbstractFlag af, boolean reserved) { PlotSquared.log(C.PREFIX.s() + "&8 - Adding flag: &7" + af); for (PlotWorld plotworld : PlotSquared.getPlotWorldObjects()) { - Flag flag = plotworld.DEFAULT_FLAGS.get(af.getKey()); + Flag flag = ((HashMap) plotworld.DEFAULT_FLAGS.clone()).get(af.getKey()); if (flag != null) { flag.setKey(af); } @@ -129,7 +129,7 @@ public class FlagManager { if (plotworld == null) { return null; } - return plotworld.DEFAULT_FLAGS.get(id); + return ((HashMap) plotworld.DEFAULT_FLAGS.clone()).get(id); } return flag; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 3d641e7d0..36d75d120 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -831,10 +831,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } Material type = block.getType(); - if (true || type.isSolid() && type.isBlock() && type.isOccluding()) { + if (action == Action.RIGHT_CLICK_BLOCK && type.isSolid() && type.isBlock() && type.isOccluding() && !type.isBurnable()) { BlockState state = block.getState(); - MaterialData data = state.getData(); - if (data instanceof Tree || data instanceof Wool || state.getData().getClass().equals(MaterialData.class)) { + if (state.getData().getClass().equals(MaterialData.class)) { Class clazz = state.getClass(); if (clazz.getSimpleName().equals("CraftBlockState")) { return; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java index b9541c5e2..b81464456 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -239,7 +239,7 @@ public abstract class PlotWorld { * Saving generator specific settings */ for (final ConfigurationNode setting : settings) { - options.put(setting.getConstant(), setting.getType().parseObject(setting.getValue())); + options.put(setting.getConstant(), setting.getValue()); } for (final String option : options.keySet()) { if (!config.contains(option)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index ebaea69c7..0d4918580 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -3,11 +3,16 @@ package com.intellectualcrafters.plot.util; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.schematic.PlotItem; +import com.intellectualcrafters.plot.util.StringComparison.ComparisonResult; public abstract class BlockManager { public static BlockManager manager; public abstract boolean isBlockSolid(PlotBlock block); + + public abstract StringComparison.ComparisonResult getClosestBlock(String name); + + public abstract String getClosestMatchingName(PlotBlock block); public abstract String[] getBiomeList(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 90f15bec8..676837b5f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -1569,7 +1569,6 @@ public class MainUtil { for (Entry entry : rating.entrySet()) { val += entry.getValue(); } - System.out.print(val); return val / (double) rating.size(); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java index edbc17dd2..6086f8454 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java @@ -31,11 +31,11 @@ import org.apache.commons.lang.StringUtils; * @author Citymonstret */ @SuppressWarnings("unused") -public class StringComparison { +public class StringComparison { /** * Best Match */ - private String bestMatch; + private T bestMatch; /** * Match Value * @@ -45,7 +45,7 @@ public class StringComparison { /** * The actual object */ - private Object bestMatchObject; + private T bestMatchObject; /** * Constructor @@ -53,15 +53,24 @@ public class StringComparison { * @param input Input Base Value * @param objects Objects to compare */ - public StringComparison(String input, final Object[] objects) { + public StringComparison(String input, final T[] objects) { + init(input, objects); + } + + /** + * You should call init(...) when you are ready to get a String comparison value + */ + public StringComparison() {} + + public void init(String input, final T[] objects) { int c; - this.bestMatch = objects[0].toString(); + this.bestMatch = objects[0]; this.bestMatchObject = objects[0]; input = input.toLowerCase(); - for (final Object o : objects) { + for (final T o : objects) { if ((c = compare(input, o.toString().toLowerCase())) < this.match) { this.match = c; - this.bestMatch = o.toString(); + this.bestMatch = o; this.bestMatchObject = o; } } @@ -93,7 +102,7 @@ public class StringComparison { * * @return ArrayList */ - public static ArrayList wLetterPair(final String s) { + public static ArrayList wLetterPair(final String s) { final ArrayList aPairs = new ArrayList<>(); final String[] wo = s.split("\\s"); for (final String aWo : wo) { @@ -124,7 +133,7 @@ public class StringComparison { * * @return match object */ - public Object getMatchObject() { + public T getMatchObject() { return this.bestMatchObject; } @@ -134,7 +143,7 @@ public class StringComparison { * @return match value */ public String getBestMatch() { - return this.bestMatch; + return this.bestMatch.toString(); } /** @@ -142,7 +151,16 @@ public class StringComparison { * * @return object[] containing: double, String */ - public Object[] getBestMatchAdvanced() { - return new Object[] { this.match, this.bestMatch }; + public ComparisonResult getBestMatchAdvanced() { + return new ComparisonResult(this.match, this.bestMatch); + } + + public class ComparisonResult { + public T best; + public final double match; + public ComparisonResult(double match, T best) { + this.match = match; + this.best = best; + } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 842a32e8a..ffc66847e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; +import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Material; @@ -18,6 +19,11 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; +import org.bukkit.material.MaterialData; +import org.bukkit.material.Sandstone; +import org.bukkit.material.Step; +import org.bukkit.material.Tree; +import org.bukkit.material.Wool; import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.ChunkLoc; @@ -27,6 +33,8 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.schematic.PlotItem; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.StringComparison; +import com.intellectualcrafters.plot.util.StringComparison.ComparisonResult; public class BukkitUtil extends BlockManager { private static HashMap worlds = new HashMap<>(); @@ -317,10 +325,58 @@ public class BukkitUtil extends BlockManager { public boolean isBlockSolid(PlotBlock block) { try { Material material = Material.getMaterial(block.id); - return material.isBlock() && material.isSolid() && material.isOccluding() && !material.hasGravity(); + if (material.isBlock() && material.isSolid() && !material.hasGravity()) { + Class data = material.getData(); + if (data.equals(MaterialData.class) || data.equals(Tree.class) || data.equals(Sandstone.class) || data.equals(Wool.class) || data.equals(Step.class)) { + return true; + } + } + return false; } catch (Exception e) { return false; } } + + @Override + public String getClosestMatchingName(PlotBlock block) { + try { + return Material.getMaterial(block.id).name(); + } + catch (Exception e) { + return null; + } + } + + @Override + public StringComparison.ComparisonResult getClosestBlock(String name) { + try { + double match; + short id; + byte data; + String[] split = name.split(":"); + if (split.length == 2) { + data = Byte.parseByte(split[1]); + name = split[0]; + } + else { + data = 0; + } + if (StringUtils.isNumeric(split[0])) { + id = Short.parseShort(split[0]); + match = 0; + } + else { + StringComparison.ComparisonResult comparison = new StringComparison(name, Material.values()).getBestMatchAdvanced(); + match = comparison.match; + id = (short) comparison.best.getId(); + } + PlotBlock block = new PlotBlock(id, data); + StringComparison outer = new StringComparison(); + return outer.new ComparisonResult(match, block); + + } + catch (Exception e) {} + return null; + } }