From 8d182abd3e19225c8e7278de98ab3747b3d388d5 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 19 Apr 2019 13:50:03 +0200 Subject: [PATCH] Minor FAVS cleanup --- favs/build.gradle | 4 - .../com/thevoxelbox/voxelsniper/Brushes.java | 38 ++---- .../com/thevoxelbox/voxelsniper/Message.java | 63 ++++------ .../voxelsniper/PaintingWrapper.java | 60 +++------- .../voxelsniper/RangeBlockHelper.java | 2 - .../thevoxelbox/voxelsniper/SnipeAction.java | 7 +- .../com/thevoxelbox/voxelsniper/Sniper.java | 15 +-- .../voxelsniper/SniperManager.java | 12 +- .../thevoxelbox/voxelsniper/VoxelSniper.java | 47 ++------ .../voxelsniper/VoxelSniperConfiguration.java | 30 ++--- .../voxelsniper/VoxelSniperListener.java | 55 +++------ .../command/VoxelBrushCommand.java | 45 +++---- .../command/VoxelBrushToolCommand.java | 56 +++------ .../command/VoxelCenterCommand.java | 16 +-- .../command/VoxelChunkCommand.java | 9 +- .../command/VoxelDefaultCommand.java | 9 +- .../voxelsniper/command/VoxelGoToCommand.java | 16 +-- .../command/VoxelHeightCommand.java | 16 +-- .../voxelsniper/command/VoxelInkCommand.java | 31 ++--- .../command/VoxelInkReplaceCommand.java | 31 ++--- .../voxelsniper/command/VoxelListCommand.java | 31 ++--- .../command/VoxelPaintCommand.java | 30 ++--- .../command/VoxelPerformerCommand.java | 41 ++----- .../command/VoxelSniperCommand.java | 61 +++------- .../voxelsniper/command/VoxelUndoCommand.java | 23 ++-- .../command/VoxelUndoUserCommand.java | 16 +-- .../event/SniperBrushSizeChangedEvent.java | 25 ++-- .../SniperReplaceMaterialChangedEvent.java | 13 +- .../voxelsniper/jsap/HelpJSAP.java | 111 ++++++------------ .../jsap/NullableIntegerStringParser.java | 36 ++---- 30 files changed, 292 insertions(+), 657 deletions(-) diff --git a/favs/build.gradle b/favs/build.gradle index 7aded4c06..023a2a6a0 100644 --- a/favs/build.gradle +++ b/favs/build.gradle @@ -1,10 +1,6 @@ apply plugin: 'eclipse' apply plugin: 'maven' -repositories { - maven {url "https://ci.athion.net/job/FAWE-WorldGuard-1.13/lastSuccessfulBuild/artifact/mvn"} -} - dependencies { compile project(':worldedit-bukkit') compile 'com.martiansoftware:jsap:2.1' diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/Brushes.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/Brushes.java index 3517a1d05..e1d2fb7ae 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/Brushes.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/Brushes.java @@ -13,21 +13,18 @@ import java.util.Set; /** * Brush registration manager. */ -public class Brushes -{ +public class Brushes { private Multimap, String> brushes = HashMultimap.create(); /** * Register a brush for VoxelSniper to be able to use. * - * @param clazz Brush implementing IBrush interface. - * @param handles Handles under which the brush can be accessed ingame. + * @param clazz Brush implementing IBrush interface. + * @param handles Handles under which the brush can be accessed ingame. */ - public void registerSniperBrush(Class clazz, String... handles) - { + public void registerSniperBrush(Class clazz, String... handles) { Preconditions.checkNotNull(clazz, "Cannot register null as a class."); - for (String handle : handles) - { + for (String handle : handles) { brushes.put(clazz, handle.toLowerCase()); } } @@ -38,18 +35,14 @@ public class Brushes * @param handle Case insensitive brush handle * @return Brush class */ - public Class getBrushForHandle(String handle) - { + public Class getBrushForHandle(String handle) { Preconditions.checkNotNull(handle, "Brushhandle can not be null."); - if (!brushes.containsValue(handle.toLowerCase())) - { + if (!brushes.containsValue(handle.toLowerCase())) { return null; } - for (Map.Entry, String> entry : brushes.entries()) - { - if (entry.getValue().equalsIgnoreCase(handle)) - { + for (Map.Entry, String> entry : brushes.entries()) { + if (entry.getValue().equalsIgnoreCase(handle)) { return entry.getKey(); } } @@ -59,34 +52,29 @@ public class Brushes /** * @return Amount of IBrush classes registered with the system under Sniper visibility. */ - public int registeredSniperBrushes() - { + public int registeredSniperBrushes() { return brushes.keySet().size(); } /** * @return Amount of handles registered with the system under Sniper visibility. */ - public int registeredSniperBrushHandles() - { + public int registeredSniperBrushHandles() { return brushes.size(); } /** - * * @param clazz Brush class * @return All Sniper registered handles for the brush. */ - public Set getSniperBrushHandles(Class clazz) - { + public Set getSniperBrushHandles(Class clazz) { return new HashSet<>(brushes.get(clazz)); } /** * @return Immutable Multimap copy of all the registered brushes */ - public Multimap, String> getRegisteredBrushesMultimap() - { + public Multimap, String> getRegisteredBrushesMultimap() { return ImmutableMultimap.copyOf(brushes); } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java index 34e991325..211103c80 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java @@ -1,23 +1,19 @@ package com.thevoxelbox.voxelsniper; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import org.bukkit.ChatColor; -import org.bukkit.Material; /** * */ -public class Message -{ +public class Message { private static final int BRUSH_SIZE_WARNING_THRESHOLD = 20; private final SnipeData snipeData; /** * @param snipeData */ - public Message(SnipeData snipeData) - { + public Message(SnipeData snipeData) { this.snipeData = snipeData; } @@ -26,8 +22,7 @@ public class Message * * @param brushMessage */ - public void brushMessage(String brushMessage) - { + public void brushMessage(String brushMessage) { snipeData.sendMessage(ChatColor.LIGHT_PURPLE + brushMessage); } @@ -36,16 +31,14 @@ public class Message * * @param brushName */ - public void brushName(String brushName) - { + public void brushName(String brushName) { snipeData.sendMessage(ChatColor.AQUA + "Brush Type: " + ChatColor.LIGHT_PURPLE + brushName); } /** * Display Center Parameter. */ - public void center() - { + public void center() { snipeData.sendMessage(ChatColor.DARK_BLUE + "Brush Center: " + ChatColor.DARK_RED + snipeData.getcCen()); } @@ -54,24 +47,21 @@ public class Message * * @param message */ - public void custom(String message) - { + public void custom(String message) { snipeData.sendMessage(message); } /** * Display data value. */ - public void data() - { + public void data() { snipeData.sendMessage(ChatColor.BLUE + "Data Variable: " + ChatColor.DARK_RED + snipeData.getPropertyId()); } /** * Display voxel height. */ - public void height() - { + public void height() { snipeData.sendMessage(ChatColor.DARK_AQUA + "Brush Height: " + ChatColor.DARK_RED + snipeData.getVoxelHeight()); } @@ -80,8 +70,7 @@ public class Message * * @param performerName */ - public void performerName(String performerName) - { + public void performerName(String performerName) { this.snipeData.sendMessage(ChatColor.DARK_PURPLE + "Performer: " + ChatColor.DARK_GREEN + performerName); } @@ -89,27 +78,23 @@ public class Message * Displaye replace material. */ @SuppressWarnings("deprecation") - public void replace() - { + public void replace() { snipeData.sendMessage(ChatColor.AQUA + "Replace Material: " + BlockTypes.get(snipeData.getReplaceId())); } /** * Display replace data value. */ - public void replaceData() - { + public void replaceData() { snipeData.sendMessage(ChatColor.DARK_GRAY + "Replace Data Variable: " + ChatColor.DARK_RED + snipeData.getReplaceData()); } /** * Display brush size. */ - public void size() - { + public void size() { snipeData.sendMessage(ChatColor.GREEN + "Brush Size: " + ChatColor.DARK_RED + snipeData.getBrushSize()); - if (snipeData.getBrushSize() >= BRUSH_SIZE_WARNING_THRESHOLD) - { + if (snipeData.getBrushSize() >= BRUSH_SIZE_WARNING_THRESHOLD) { snipeData.sendMessage(ChatColor.RED + "WARNING: Large brush size selected!"); } } @@ -117,24 +102,21 @@ public class Message /** * Display toggle lightning message. */ - public void toggleLightning() - { + public void toggleLightning() { snipeData.sendMessage(ChatColor.GOLD + "Lightning mode has been toggled " + ChatColor.DARK_RED + ((snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).isLightningEnabled()) ? "on" : "off")); } /** * Display toggle printout message. */ - public final void togglePrintout() - { + public final void togglePrintout() { snipeData.sendMessage(ChatColor.GOLD + "Brush info printout mode has been toggled " + ChatColor.DARK_RED + ((snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).isLightningEnabled()) ? "on" : "off")); } /** * Display toggle range message. */ - public void toggleRange() - { + public void toggleRange() { snipeData.sendMessage(ChatColor.GOLD + "Distance Restriction toggled " + ChatColor.DARK_RED + ((snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).isRanged()) ? "on" : "off") + ChatColor.GOLD + ". Range is " + ChatColor.LIGHT_PURPLE + (double) snipeData.owner().getSnipeData(snipeData.owner().getCurrentToolId()).getRange()); } @@ -142,22 +124,17 @@ public class Message * Display voxel type. */ @SuppressWarnings("deprecation") - public void voxel() - { + public void voxel() { snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + BlockTypes.get(snipeData.getVoxelId())); } /** * Display voxel list. */ - public void voxelList() - { - if (snipeData.getVoxelList().isEmpty()) - { + public void voxelList() { + if (snipeData.getVoxelList().isEmpty()) { snipeData.sendMessage(ChatColor.DARK_GREEN + "No blocks selected!"); - } - else - { + } else { String returnValueBuilder = ChatColor.DARK_GREEN + "Block Types Selected: " + ChatColor.AQUA + snipeData.getVoxelList(); snipeData.sendMessage(returnValueBuilder); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/PaintingWrapper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/PaintingWrapper.java index 78a75ef49..d20ee7e8d 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/PaintingWrapper.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/PaintingWrapper.java @@ -4,96 +4,72 @@ import org.bukkit.Art; import org.bukkit.ChatColor; import org.bukkit.Chunk; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Painting; import org.bukkit.entity.Player; -import java.util.Set; - /** * Painting state change handler. * * @author Piotr */ -public final class PaintingWrapper -{ +public final class PaintingWrapper { - private PaintingWrapper() - { + private PaintingWrapper() { } /** * The paint method used to scroll or set a painting to a specific type. * - * @param p - * The player executing the method - * @param auto - * Scroll automatically? If false will use 'choice' to try and set the painting - * @param back - * Scroll in reverse? - * @param choice - * Chosen index to set the painting to + * @param p The player executing the method + * @param auto Scroll automatically? If false will use 'choice' to try and set the painting + * @param back Scroll in reverse? + * @param choice Chosen index to set the painting to */ @SuppressWarnings("deprecation") - public static void paint(final Player p, final boolean auto, final boolean back, final int choice) - { + public static void paint(final Player p, final boolean auto, final boolean back, final int choice) { Location targetLocation = p.getTargetBlock(null, 4).getLocation(); Chunk paintingChunk = p.getTargetBlock(null, 4).getLocation().getChunk(); Double bestDistanceMatch = 50D; Painting bestMatch = null; - for (Entity entity : paintingChunk.getEntities()) - { - if (entity.getType() == EntityType.PAINTING) - { + for (Entity entity : paintingChunk.getEntities()) { + if (entity.getType() == EntityType.PAINTING) { Double distance = targetLocation.distanceSquared(entity.getLocation()); - if (distance <= 4 && distance < bestDistanceMatch) - { + if (distance <= 4 && distance < bestDistanceMatch) { bestDistanceMatch = distance; bestMatch = (Painting) entity; } } } - if (bestMatch != null) - { - if (auto) - { - try - { + if (bestMatch != null) { + if (auto) { + try { final int i = bestMatch.getArt().getId() + (back ? -1 : 1); Art art = Art.getById(i); - if (art == null) - { + if (art == null) { p.sendMessage(ChatColor.RED + "This is the final painting, try scrolling to the other direction."); return; } bestMatch.setArt(art); p.sendMessage(ChatColor.GREEN + "Painting set to ID: " + (i)); - } - catch (final Exception e) - { + } catch (final Exception e) { p.sendMessage(ChatColor.RED + "Oops. Something went wrong."); } - } - else - { - try - { + } else { + try { Art art = Art.getById(choice); bestMatch.setArt(art); p.sendMessage(ChatColor.GREEN + "Painting set to ID: " + choice); - } - catch (final Exception exception) - { + } catch (final Exception exception) { p.sendMessage(ChatColor.RED + "Your input was invalid somewhere."); } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java index 2d4a6d011..f4cfc718f 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/RangeBlockHelper.java @@ -30,8 +30,6 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.world.registry.LegacyMapper; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; import org.bukkit.entity.Player; public class RangeBlockHelper { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeAction.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeAction.java index 3102e0e82..9362ec448 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeAction.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/SnipeAction.java @@ -1,9 +1,8 @@ package com.thevoxelbox.voxelsniper; /** -* -*/ -public enum SnipeAction -{ + * + */ +public enum SnipeAction { ARROW, GUNPOWDER } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java index b0ec73c77..35c52cf11 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java @@ -44,25 +44,16 @@ import com.google.common.base.Preconditions; import com.google.common.collect.*; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.extent.MaskingExtent; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.request.Request; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import com.thevoxelbox.voxelsniper.brush.IBrush; import com.thevoxelbox.voxelsniper.brush.SnipeBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; import com.thevoxelbox.voxelsniper.brush.perform.Performer; -import com.thevoxelbox.voxelsniper.event.SniperMaterialChangedEvent; -import com.thevoxelbox.voxelsniper.event.SniperReplaceMaterialChangedEvent; - -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -72,9 +63,13 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.block.Action; -import org.bukkit.material.MaterialData; import org.bukkit.plugin.PluginManager; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + public class Sniper { private VoxelSniper plugin; private final UUID player; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/SniperManager.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/SniperManager.java index 7bc394e9c..e71d9ad26 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/SniperManager.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/SniperManager.java @@ -9,20 +9,16 @@ import java.util.UUID; /** * */ -public class SniperManager -{ +public class SniperManager { private Map sniperInstances = Maps.newHashMap(); private VoxelSniper plugin; - public SniperManager(VoxelSniper plugin) - { + public SniperManager(VoxelSniper plugin) { this.plugin = plugin; } - public Sniper getSniperForPlayer(Player player) - { - if (sniperInstances.get(player.getUniqueId()) == null) - { + public Sniper getSniperForPlayer(Player player) { + if (sniperInstances.get(player.getUniqueId()) == null) { sniperInstances.put(player.getUniqueId(), new Sniper(plugin, player)); } return sniperInstances.get(player.getUniqueId()); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java index 715d774fa..d518da511 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java @@ -1,34 +1,19 @@ package com.thevoxelbox.voxelsniper; -import com.boydti.fawe.Fawe; import com.boydti.fawe.bukkit.BukkitCommand; import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.object.FawePlayer; -import com.boydti.fawe.util.Jars; -import com.boydti.fawe.util.MainUtil; -import com.google.common.base.Preconditions; import com.thevoxelbox.voxelsniper.brush.*; -import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; -import com.thevoxelbox.voxelsniper.command.VoxelVoxelCommand; -import com.thevoxelbox.voxelsniper.event.SniperBrushChangedEvent; -import com.thevoxelbox.voxelsniper.event.SniperMaterialChangedEvent; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; -import java.io.File; -import java.io.FileOutputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; - /** * Bukkit extension point. */ -public class VoxelSniper extends JavaPlugin -{ +public class VoxelSniper extends JavaPlugin { private static VoxelSniper instance; private SniperManager sniperManager = new SniperManager(this); private final VoxelSniperListener voxelSniperListener = new VoxelSniperListener(this); @@ -39,8 +24,7 @@ public class VoxelSniper extends JavaPlugin * * @return Brush Manager for current instance. */ - public Brushes getBrushManager() - { + public Brushes getBrushManager() { return brushManager; } @@ -49,8 +33,7 @@ public class VoxelSniper extends JavaPlugin /** * @return {@link VoxelSniper} */ - public static VoxelSniper getInstance() - { + public static VoxelSniper getInstance() { return VoxelSniper.instance; } @@ -59,8 +42,7 @@ public class VoxelSniper extends JavaPlugin * * @return {@link VoxelSniperConfiguration} object for accessing global VoxelSniper options. */ - public VoxelSniperConfiguration getVoxelSniperConfiguration() - { + public VoxelSniperConfiguration getVoxelSniperConfiguration() { return voxelSniperConfiguration; } @@ -69,20 +51,16 @@ public class VoxelSniper extends JavaPlugin * * @return SniperManager */ - public SniperManager getSniperManager() - { + public SniperManager getSniperManager() { return sniperManager; } @Override - public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) - { - if (sender instanceof Player) - { + public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { + if (sender instanceof Player) { String[] arguments = args; - if (arguments == null) - { + if (arguments == null) { arguments = new String[0]; } @@ -94,8 +72,7 @@ public class VoxelSniper extends JavaPlugin } @Override - public void onEnable() - { + public void onEnable() { VoxelSniper.instance = this; registerBrushes(); @@ -134,14 +111,14 @@ public class VoxelSniper extends JavaPlugin } }); - } catch (Throwable ignore) {} + } catch (Throwable ignore) { + } } /** * Registers all brushes. */ - public void registerBrushes() - { + public void registerBrushes() { brushManager.registerSniperBrush(BallBrush.class, "b", "ball"); brushManager.registerSniperBrush(BiomeBrush.class, "bio", "biome"); brushManager.registerSniperBrush(BlendBallBrush.class, "bb", "blendball"); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperConfiguration.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperConfiguration.java index 3b226a414..0e2e28aac 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperConfiguration.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperConfiguration.java @@ -8,8 +8,7 @@ import java.util.List; /** * Configuration storage defining global configurations for VoxelSniper. */ -public class VoxelSniperConfiguration -{ +public class VoxelSniperConfiguration { public static final String CONFIG_IDENTIFIER_LITESNIPER_MAX_BRUSH_SIZE = "litesniper-max-brush-size"; public static final String CONFIG_IDENTIFIER_UNDO_CACHE_SIZE = "undo-cache-size"; public static final String CONFIG_IDENTIFIER_LITESNIPER_RESTRICTED_ITEMS = "litesniper-restricted-items"; @@ -22,8 +21,7 @@ public class VoxelSniperConfiguration /** * @param configuration Configuration that is going to be used. */ - public VoxelSniperConfiguration(FileConfiguration configuration) - { + public VoxelSniperConfiguration(FileConfiguration configuration) { this.configuration = configuration; } @@ -32,8 +30,7 @@ public class VoxelSniperConfiguration * * @return the maximum amount of snipes stored in the undo cache of snipers */ - public int getUndoCacheSize() - { + public int getUndoCacheSize() { return configuration.getInt(CONFIG_IDENTIFIER_UNDO_CACHE_SIZE, DEFAULT_UNDO_CACHE_SIZE); } @@ -42,8 +39,7 @@ public class VoxelSniperConfiguration * * @param size size of undo cache */ - public void setUndoCacheSize(int size) - { + public void setUndoCacheSize(int size) { configuration.set(CONFIG_IDENTIFIER_UNDO_CACHE_SIZE, size); } @@ -52,8 +48,7 @@ public class VoxelSniperConfiguration * * @return maximum size */ - public int getLiteSniperMaxBrushSize() - { + public int getLiteSniperMaxBrushSize() { return configuration.getInt(CONFIG_IDENTIFIER_LITESNIPER_MAX_BRUSH_SIZE, DEFAULT_LITESNIPER_MAX_BRUSH_SIZE); } @@ -62,8 +57,7 @@ public class VoxelSniperConfiguration * * @param size maximum size */ - public void setLiteSniperMaxBrushSize(int size) - { + public void setLiteSniperMaxBrushSize(int size) { configuration.set(CONFIG_IDENTIFIER_LITESNIPER_MAX_BRUSH_SIZE, size); } @@ -72,8 +66,7 @@ public class VoxelSniperConfiguration * * @return List of restricted Litesniper Items */ - public List getLiteSniperRestrictedItems() - { + public List getLiteSniperRestrictedItems() { return configuration.getIntegerList(CONFIG_IDENTIFIER_LITESNIPER_RESTRICTED_ITEMS); } @@ -82,8 +75,7 @@ public class VoxelSniperConfiguration * * @param restrictedItems List of restricted Litesniper Items */ - public void setLitesniperRestrictedItems(List restrictedItems) - { + public void setLitesniperRestrictedItems(List restrictedItems) { Preconditions.checkNotNull(restrictedItems, "Restricted items must be a list."); configuration.set(CONFIG_IDENTIFIER_LITESNIPER_RESTRICTED_ITEMS, restrictedItems); } @@ -93,8 +85,7 @@ public class VoxelSniperConfiguration * * @return true if message on login is enabled, false otherwise. */ - public boolean isMessageOnLoginEnabled() - { + public boolean isMessageOnLoginEnabled() { return configuration.getBoolean(CONFIG_IDENTIFIER_MESSAGE_ON_LOGIN_ENABLED, DEFAULT_MESSAGE_ON_LOGIN_ENABLED); } @@ -103,8 +94,7 @@ public class VoxelSniperConfiguration * * @param enabled Message on Login enabled */ - public void setMessageOnLoginEnabled(boolean enabled) - { + public void setMessageOnLoginEnabled(boolean enabled) { configuration.set(CONFIG_IDENTIFIER_MESSAGE_ON_LOGIN_ENABLED, enabled); } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java index ffa8189d5..ac8dc7eb7 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java @@ -16,13 +16,11 @@ import org.bukkit.event.player.PlayerJoinEvent; import java.util.HashMap; import java.util.Map; -import java.util.logging.Level; /** * @author Voxel */ -public class VoxelSniperListener implements Listener -{ +public class VoxelSniperListener implements Listener { private static final String SNIPER_PERMISSION = "voxelsniper.sniper"; private final VoxelSniper plugin; @@ -31,8 +29,7 @@ public class VoxelSniperListener implements Listener /** * @param plugin */ - public VoxelSniperListener(final VoxelSniper plugin) - { + public VoxelSniperListener(final VoxelSniper plugin) { this.plugin = plugin; addCommand(new VoxelBrushCommand(plugin)); addCommand(new VoxelBrushToolCommand(plugin)); @@ -53,8 +50,7 @@ public class VoxelSniperListener implements Listener addCommand(new VoxelVoxelCommand(plugin)); } - private void addCommand(final VoxelCommand command) - { + private void addCommand(final VoxelCommand command) { this.commands.put(command.getIdentifier().toLowerCase(), command); } @@ -64,16 +60,13 @@ public class VoxelSniperListener implements Listener * @param command * @return boolean Success. */ - public boolean onCommand(final Player player, final String[] split, final String command) - { + public boolean onCommand(final Player player, final String[] split, final String command) { VoxelCommand found = this.commands.get(command.toLowerCase()); - if (found == null) - { + if (found == null) { return false; } - if (!hasPermission(found, player)) - { + if (!hasPermission(found, player)) { player.sendMessage(ChatColor.RED + "Insufficient Permissions."); return true; } @@ -111,20 +104,14 @@ public class VoxelSniperListener implements Listener return true; } - private boolean hasPermission(final VoxelCommand command, final Player player) - { - if (command == null || player == null) - { + private boolean hasPermission(final VoxelCommand command, final Player player) { + if (command == null || player == null) { // Just a usual check for nulls return false; - } - else if (command.getPermission() == null || command.getPermission().isEmpty()) - { + } else if (command.getPermission() == null || command.getPermission().isEmpty()) { // This is for commands that do not require a permission node to be executed return true; - } - else - { + } else { // Should utilize Vault for permission checks if available return player.hasPermission(command.getPermission()); } @@ -134,25 +121,19 @@ public class VoxelSniperListener implements Listener * @param event */ @EventHandler(ignoreCancelled = false) - public final void onPlayerInteract(final PlayerInteractEvent event) - { + public final void onPlayerInteract(final PlayerInteractEvent event) { Player player = event.getPlayer(); - if (!player.hasPermission(SNIPER_PERMISSION)) - { + if (!player.hasPermission(SNIPER_PERMISSION)) { return; } - try - { + try { Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - if (sniper.isEnabled() && sniper.snipe(event.getAction(), event.getMaterial(), event.getClickedBlock(), event.getBlockFace())) - { + if (sniper.isEnabled() && sniper.snipe(event.getAction(), event.getMaterial(), event.getClickedBlock(), event.getBlockFace())) { event.setCancelled(true); } - } - catch (final Throwable ignored) - { + } catch (final Throwable ignored) { ignored.printStackTrace(); } } @@ -161,13 +142,11 @@ public class VoxelSniperListener implements Listener * @param event */ @EventHandler - public final void onPlayerJoin(final PlayerJoinEvent event) - { + public final void onPlayerJoin(final PlayerJoinEvent event) { Player player = event.getPlayer(); Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - if (player.hasPermission(SNIPER_PERMISSION) && plugin.getVoxelSniperConfiguration().isMessageOnLoginEnabled()) - { + if (player.hasPermission(SNIPER_PERMISSION) && plugin.getVoxelSniperConfiguration().isMessageOnLoginEnabled()) { sniper.displayInfo(); } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushCommand.java index 4697a3ee0..6762d723d 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushCommand.java @@ -3,9 +3,9 @@ package com.thevoxelbox.voxelsniper.command; import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Sniper; import com.thevoxelbox.voxelsniper.VoxelSniper; +import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; import com.thevoxelbox.voxelsniper.brush.IBrush; import com.thevoxelbox.voxelsniper.brush.perform.Performer; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; import com.thevoxelbox.voxelsniper.event.SniperBrushChangedEvent; import com.thevoxelbox.voxelsniper.event.SniperBrushSizeChangedEvent; import org.bukkit.Bukkit; @@ -13,35 +13,27 @@ import org.bukkit.entity.Player; import java.util.Arrays; -public class VoxelBrushCommand extends VoxelCommand -{ - public VoxelBrushCommand(final VoxelSniper plugin) - { +public class VoxelBrushCommand extends VoxelCommand { + public VoxelBrushCommand(final VoxelSniper plugin) { super("VoxelBrush", plugin); setIdentifier("b"); setPermission("voxelsniper.sniper"); } @Override - public boolean onCommand(Player player, String[] args) - { + public boolean onCommand(Player player, String[] args) { Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); String currentToolId = sniper.getCurrentToolId(); SnipeData snipeData = sniper.getSnipeData(currentToolId); - if (args == null || args.length == 0) - { + if (args == null || args.length == 0) { sniper.previousBrush(currentToolId); sniper.displayInfo(); return true; - } - else if (args.length > 0) - { - try - { + } else if (args.length > 0) { + try { int newBrushSize = Integer.parseInt(args[0]); - if (!player.hasPermission("voxelsniper.ignorelimitations") && newBrushSize > plugin.getVoxelSniperConfiguration().getLiteSniperMaxBrushSize()) - { + if (!player.hasPermission("voxelsniper.ignorelimitations") && newBrushSize > plugin.getVoxelSniperConfiguration().getLiteSniperMaxBrushSize()) { player.sendMessage("Size is restricted to " + plugin.getVoxelSniperConfiguration().getLiteSniperMaxBrushSize() + " for you."); newBrushSize = plugin.getVoxelSniperConfiguration().getLiteSniperMaxBrushSize(); } @@ -51,28 +43,21 @@ public class VoxelBrushCommand extends VoxelCommand Bukkit.getPluginManager().callEvent(event); snipeData.getVoxelMessage().size(); return true; - } - catch (NumberFormatException ingored) - { + } catch (NumberFormatException ingored) { } Class brush = plugin.getBrushManager().getBrushForHandle(args[0]); - if (brush != null) - { + if (brush != null) { IBrush orignalBrush = sniper.getBrush(currentToolId); sniper.setBrush(currentToolId, brush); - if (args.length > 1) - { + if (args.length > 1) { IBrush currentBrush = sniper.getBrush(currentToolId); - if (currentBrush instanceof Performer) - { + if (currentBrush instanceof Performer) { String[] parameters = Arrays.copyOfRange(args, 1, args.length); ((Performer) currentBrush).parse(parameters, snipeData); return true; - } - else - { + } else { String[] parameters = hackTheArray(Arrays.copyOfRange(args, 1, args.length)); currentBrush.parameters(parameters, snipeData); return true; @@ -81,9 +66,7 @@ public class VoxelBrushCommand extends VoxelCommand SniperBrushChangedEvent event = new SniperBrushChangedEvent(sniper, currentToolId, orignalBrush, sniper.getBrush(currentToolId)); sniper.displayInfo(); return true; - } - else - { + } else { player.sendMessage("Couldn't find Brush for brush handle \"" + args[0] + "\""); return true; } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushToolCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushToolCommand.java index b50a7106a..4a0e4140d 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushToolCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushToolCommand.java @@ -7,75 +7,53 @@ import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; import org.bukkit.Material; import org.bukkit.entity.Player; -public class VoxelBrushToolCommand extends VoxelCommand -{ - public VoxelBrushToolCommand(final VoxelSniper plugin) - { +public class VoxelBrushToolCommand extends VoxelCommand { + public VoxelBrushToolCommand(final VoxelSniper plugin) { super("VoxelBrushTool", plugin); setIdentifier("btool"); setPermission("voxelsniper.sniper"); } @Override - public boolean onCommand(Player player, String[] args) - { + public boolean onCommand(Player player, String[] args) { Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - if (args != null && args.length > 0) - { - if (args[0].equalsIgnoreCase("assign")) - { + if (args != null && args.length > 0) { + if (args[0].equalsIgnoreCase("assign")) { SnipeAction action; - if (args[1].equalsIgnoreCase("arrow")) - { + if (args[1].equalsIgnoreCase("arrow")) { action = SnipeAction.ARROW; - } - else if (args[1].equalsIgnoreCase("powder")) - { + } else if (args[1].equalsIgnoreCase("powder")) { action = SnipeAction.GUNPOWDER; - } - else - { + } else { player.sendMessage("/btool assign "); return true; } - if (args.length == 3 && args[2] != null && !args[2].isEmpty()) - { + if (args.length == 3 && args[2] != null && !args[2].isEmpty()) { Material itemInHand = (player.getItemInHand() != null) ? player.getItemInHand().getType() : null; - if (itemInHand == null) - { + if (itemInHand == null) { player.sendMessage("/btool assign "); return true; } - if (sniper.setTool(args[2], action, itemInHand)) - { + if (sniper.setTool(args[2], action, itemInHand)) { player.sendMessage(itemInHand.name() + " has been assigned to '" + args[2] + "' as action " + action.name() + "."); - } - else - { + } else { player.sendMessage("Couldn't assign tool."); } return true; } - } - else if (args[0].equalsIgnoreCase("remove")) - { - if (args.length == 2 && args[1] != null && !args[1].isEmpty()) - { + } else if (args[0].equalsIgnoreCase("remove")) { + if (args.length == 2 && args[1] != null && !args[1].isEmpty()) { sniper.removeTool(args[1]); return true; - } - else - { + } else { Material itemInHand = (player.getItemInHand() != null) ? player.getItemInHand().getType() : null; - if (itemInHand == null) - { + if (itemInHand == null) { player.sendMessage("Can't unassign empty hands."); return true; } - if (sniper.getCurrentToolId() == null) - { + if (sniper.getCurrentToolId() == null) { player.sendMessage("Can't unassign default tool."); return true; } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelCenterCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelCenterCommand.java index d5d6e6ff8..a4f0a114d 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelCenterCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelCenterCommand.java @@ -7,30 +7,24 @@ import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -public class VoxelCenterCommand extends VoxelCommand -{ - public VoxelCenterCommand(final VoxelSniper plugin) - { +public class VoxelCenterCommand extends VoxelCommand { + public VoxelCenterCommand(final VoxelSniper plugin) { super("VoxelCenter", plugin); setIdentifier("vc"); setPermission("voxelsniper.sniper"); } @Override - public boolean onCommand(Player player, String[] args) - { + public boolean onCommand(Player player, String[] args) { Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId()); - try - { + try { int center = Integer.parseInt(args[0]); snipeData.setcCen(center); snipeData.getVoxelMessage().center(); return true; - } - catch (final Exception exception) - { + } catch (final Exception exception) { player.sendMessage(ChatColor.RED + "Invalid input."); return true; } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelChunkCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelChunkCommand.java index 231a5fe9b..9fd3ce608 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelChunkCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelChunkCommand.java @@ -4,17 +4,14 @@ import com.thevoxelbox.voxelsniper.VoxelSniper; import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; import org.bukkit.entity.Player; -public class VoxelChunkCommand extends VoxelCommand -{ - public VoxelChunkCommand(final VoxelSniper plugin) - { +public class VoxelChunkCommand extends VoxelCommand { + public VoxelChunkCommand(final VoxelSniper plugin) { super("VoxelChunk", plugin); setIdentifier("vchunk"); } @Override - public boolean onCommand(Player player, String[] args) - { + public boolean onCommand(Player player, String[] args) { player.getWorld().refreshChunk(player.getLocation().getBlockX(), player.getLocation().getBlockZ()); return true; } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelDefaultCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelDefaultCommand.java index 507375629..f1f068a6d 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelDefaultCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelDefaultCommand.java @@ -6,18 +6,15 @@ import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -public class VoxelDefaultCommand extends VoxelCommand -{ - public VoxelDefaultCommand(final VoxelSniper plugin) - { +public class VoxelDefaultCommand extends VoxelCommand { + public VoxelDefaultCommand(final VoxelSniper plugin) { super("VoxelDefault", plugin); setIdentifier("d"); setPermission("voxelsniper.sniper"); } @Override - public boolean onCommand(Player player, String[] args) - { + public boolean onCommand(Player player, String[] args) { Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); sniper.reset(sniper.getCurrentToolId()); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelGoToCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelGoToCommand.java index 9fa440250..5ca8055dd 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelGoToCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelGoToCommand.java @@ -6,28 +6,22 @@ import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.Player; -public class VoxelGoToCommand extends VoxelCommand -{ - public VoxelGoToCommand(final VoxelSniper plugin) - { +public class VoxelGoToCommand extends VoxelCommand { + public VoxelGoToCommand(final VoxelSniper plugin) { super("VoxelGoTo", plugin); setIdentifier("goto"); setPermission("voxelsniper.sniper"); } @Override - public boolean onCommand(Player player, String[] args) - { - try - { + public boolean onCommand(Player player, String[] args) { + try { final int x = Integer.parseInt(args[0]); final int z = Integer.parseInt(args[1]); player.teleport(new Location(player.getWorld(), x, player.getWorld().getHighestBlockYAt(x, z), z)); player.sendMessage(ChatColor.GREEN + "Woosh!"); return true; - } - catch (final Exception exception) - { + } catch (final Exception exception) { player.sendMessage(ChatColor.RED + "Invalid syntax."); return true; } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelHeightCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelHeightCommand.java index 4785be95f..3b6977561 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelHeightCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelHeightCommand.java @@ -7,30 +7,24 @@ import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -public class VoxelHeightCommand extends VoxelCommand -{ - public VoxelHeightCommand(final VoxelSniper plugin) - { +public class VoxelHeightCommand extends VoxelCommand { + public VoxelHeightCommand(final VoxelSniper plugin) { super("VoxelHeight", plugin); setIdentifier("vh"); setPermission("voxelsniper.sniper"); } @Override - public boolean onCommand(Player player, String[] args) - { + public boolean onCommand(Player player, String[] args) { Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId()); - try - { + try { int height = Integer.parseInt(args[0]); snipeData.setVoxelHeight(height); snipeData.getVoxelMessage().height(); return true; - } - catch (final Exception exception) - { + } catch (final Exception exception) { player.sendMessage(ChatColor.RED + "Invalid input."); return true; } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkCommand.java index f55b11228..fabf429db 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkCommand.java @@ -7,45 +7,32 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Sniper; import com.thevoxelbox.voxelsniper.VoxelSniper; import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.block.Block; import org.bukkit.entity.Player; -public class VoxelInkCommand extends VoxelCommand -{ - public VoxelInkCommand(final VoxelSniper plugin) - { +public class VoxelInkCommand extends VoxelCommand { + public VoxelInkCommand(final VoxelSniper plugin) { super("VoxelInk", plugin); setIdentifier("vi"); setPermission("voxelsniper.sniper"); } @Override - public boolean onCommand(Player player, String[] args) - { + public boolean onCommand(Player player, String[] args) { Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); int dataValue; - if (args.length == 0) - { + if (args.length == 0) { AsyncBlock targetBlock = new RangeBlockHelper(player, sniper.getWorld()).getTargetBlock(); - if (targetBlock != null) - { + if (targetBlock != null) { dataValue = targetBlock.getPropertyId(); - } - else - { + } else { return true; } - } - else - { - try - { + } else { + try { dataValue = Integer.parseInt(args[0]); - } - catch (NumberFormatException exception) - { + } catch (NumberFormatException exception) { BlockState state = BlockState.get(args[0]); if (state == null) { player.sendMessage("Couldn't parse input."); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkReplaceCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkReplaceCommand.java index fe8f2f67a..de339bace 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkReplaceCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelInkReplaceCommand.java @@ -7,45 +7,32 @@ import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Sniper; import com.thevoxelbox.voxelsniper.VoxelSniper; import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.block.Block; import org.bukkit.entity.Player; -public class VoxelInkReplaceCommand extends VoxelCommand -{ - public VoxelInkReplaceCommand(final VoxelSniper plugin) - { +public class VoxelInkReplaceCommand extends VoxelCommand { + public VoxelInkReplaceCommand(final VoxelSniper plugin) { super("VoxelInkReplace", plugin); setIdentifier("vir"); setPermission("voxelsniper.sniper"); } @Override - public boolean onCommand(Player player, String[] args) - { + public boolean onCommand(Player player, String[] args) { Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); int dataValue; - if (args.length == 0) - { + if (args.length == 0) { AsyncBlock targetBlock = new RangeBlockHelper(player, sniper.getWorld()).getTargetBlock(); - if (targetBlock != null) - { + if (targetBlock != null) { dataValue = targetBlock.getPropertyId(); - } - else - { + } else { return true; } - } - else - { - try - { + } else { + try { dataValue = Integer.parseInt(args[0]); - } - catch (NumberFormatException exception) - { + } catch (NumberFormatException exception) { BlockState state = BlockState.get(args[0]); if (state == null) { player.sendMessage("Couldn't parse input."); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelListCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelListCommand.java index c003ba9e8..e9dec9c31 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelListCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelListCommand.java @@ -1,61 +1,44 @@ package com.thevoxelbox.voxelsniper.command; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; -import com.boydti.fawe.object.FawePlayer; -import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.extension.factory.MaskFactory; -import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.function.mask.BlockMask; import com.sk89q.worldedit.function.mask.BlockMaskBuilder; -import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockTypes; import com.thevoxelbox.voxelsniper.RangeBlockHelper; import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Sniper; import com.thevoxelbox.voxelsniper.VoxelSniper; import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import org.bukkit.Material; -import org.bukkit.block.Block; import org.bukkit.entity.Player; -public class VoxelListCommand extends VoxelCommand -{ - public VoxelListCommand(final VoxelSniper plugin) - { +public class VoxelListCommand extends VoxelCommand { + public VoxelListCommand(final VoxelSniper plugin) { super("VoxelList", plugin); setIdentifier("vl"); setPermission("voxelsniper.sniper"); } @Override - public boolean onCommand(Player player, String[] args) - { + public boolean onCommand(Player player, String[] args) { Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId()); - if (args.length == 0) - { + if (args.length == 0) { final RangeBlockHelper rangeBlockHelper = new RangeBlockHelper(player, sniper.getWorld()); final AsyncBlock targetBlock = rangeBlockHelper.getTargetBlock(); snipeData.getVoxelList().add(BukkitAdapter.adapt(targetBlock.getBlockData())); snipeData.getVoxelMessage().voxelList(); return true; - } - else - { - if (args[0].equalsIgnoreCase("clear")) - { + } else { + if (args[0].equalsIgnoreCase("clear")) { snipeData.getVoxelList().clear(); snipeData.getVoxelMessage().voxelList(); return true; } } - for (String string : args) - { + for (String string : args) { boolean remove = false; if (string.charAt(0) == '-') { string = string.substring(1); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPaintCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPaintCommand.java index 780a9a04c..8d073d808 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPaintCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPaintCommand.java @@ -6,41 +6,29 @@ import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -public class VoxelPaintCommand extends VoxelCommand -{ - public VoxelPaintCommand(final VoxelSniper plugin) - { +public class VoxelPaintCommand extends VoxelCommand { + public VoxelPaintCommand(final VoxelSniper plugin) { super("VoxelPaint", plugin); setIdentifier("paint"); setPermission("voxelsniper.paint"); } @Override - public boolean onCommand(Player player, String[] args) - { - if (args.length == 1) - { - if (args[0].equalsIgnoreCase("back")) - { + public boolean onCommand(Player player, String[] args) { + if (args.length == 1) { + if (args[0].equalsIgnoreCase("back")) { PaintingWrapper.paint(player, true, true, 0); return true; - } - else - { - try - { + } else { + try { PaintingWrapper.paint(player, false, false, Integer.parseInt(args[0])); return true; - } - catch (final Exception exception) - { + } catch (final Exception exception) { player.sendMessage(ChatColor.RED + "Invalid input."); return true; } } - } - else - { + } else { PaintingWrapper.paint(player, true, false, 0); return true; } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPerformerCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPerformerCommand.java index d9cf46fc4..a1c5d62eb 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPerformerCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelPerformerCommand.java @@ -3,58 +3,43 @@ package com.thevoxelbox.voxelsniper.command; import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Sniper; import com.thevoxelbox.voxelsniper.VoxelSniper; +import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; import com.thevoxelbox.voxelsniper.brush.IBrush; import com.thevoxelbox.voxelsniper.brush.perform.Performer; -import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; import org.bukkit.entity.Player; import java.util.logging.Level; -public class VoxelPerformerCommand extends VoxelCommand -{ - public VoxelPerformerCommand(final VoxelSniper plugin) - { +public class VoxelPerformerCommand extends VoxelCommand { + public VoxelPerformerCommand(final VoxelSniper plugin) { super("VoxelPerformer", plugin); setIdentifier("p"); setPermission("voxelsniper.sniper"); } @Override - public boolean onCommand(Player player, String[] args) - { + public boolean onCommand(Player player, String[] args) { Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId()); - try - { - if (args == null || args.length == 0) - { + try { + if (args == null || args.length == 0) { IBrush brush = sniper.getBrush(sniper.getCurrentToolId()); - if (brush instanceof Performer) - { - ((Performer) brush).parse(new String[]{ "m" }, snipeData); - } - else - { + if (brush instanceof Performer) { + ((Performer) brush).parse(new String[]{"m"}, snipeData); + } else { player.sendMessage("This brush is not a performer brush."); } - } - else - { + } else { IBrush brush = sniper.getBrush(sniper.getCurrentToolId()); - if (brush instanceof Performer) - { + if (brush instanceof Performer) { ((Performer) brush).parse(args, snipeData); - } - else - { + } else { player.sendMessage("This brush is not a performer brush."); } } return true; - } - catch (Exception exception) - { + } catch (Exception exception) { plugin.getLogger().log(Level.WARNING, "Command error from " + player.getName(), exception); return true; } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelSniperCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelSniperCommand.java index 14512a5b3..6c5aae8ee 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelSniperCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelSniperCommand.java @@ -6,19 +6,17 @@ import com.google.common.collect.Multimap; import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Sniper; import com.thevoxelbox.voxelsniper.VoxelSniper; -import com.thevoxelbox.voxelsniper.brush.IBrush; import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; +import com.thevoxelbox.voxelsniper.brush.IBrush; import com.thevoxelbox.voxelsniper.brush.perform.PerformerE; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import java.util.List; -public class VoxelSniperCommand extends VoxelCommand -{ +public class VoxelSniperCommand extends VoxelCommand { - public VoxelSniperCommand(final VoxelSniper plugin) - { + public VoxelSniperCommand(final VoxelSniper plugin) { super("VoxelSniper", plugin); setIdentifier("vs"); @@ -26,79 +24,56 @@ public class VoxelSniperCommand extends VoxelCommand } @Override - public boolean onCommand(Player player, String[] args) - { + public boolean onCommand(Player player, String[] args) { Sniper sniper = VoxelSniper.getInstance().getSniperManager().getSniperForPlayer(player); - if (args.length >= 1) - { - if (args[0].equalsIgnoreCase("brushes")) - { + if (args.length >= 1) { + if (args[0].equalsIgnoreCase("brushes")) { Multimap, String> registeredBrushesMultimap = VoxelSniper.getInstance().getBrushManager().getRegisteredBrushesMultimap(); List allHandles = Lists.newLinkedList(); - for (Class brushClass : registeredBrushesMultimap.keySet()) - { + for (Class brushClass : registeredBrushesMultimap.keySet()) { allHandles.addAll(registeredBrushesMultimap.get(brushClass)); } player.sendMessage(Joiner.on(", ").skipNulls().join(allHandles)); return true; - } - else if (args[0].equalsIgnoreCase("range")) - { + } else if (args[0].equalsIgnoreCase("range")) { SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId()); - if (args.length == 2) - { - try - { + if (args.length == 2) { + try { int range = Integer.parseInt(args[1]); - if (range < 0) - { + if (range < 0) { player.sendMessage("Negative values are not allowed."); } snipeData.setRange(range); snipeData.setRanged(true); snipeData.getVoxelMessage().toggleRange(); - } - catch (NumberFormatException exception) - { + } catch (NumberFormatException exception) { player.sendMessage("Can't parse number."); } return true; - } - else - { + } else { snipeData.setRanged(!snipeData.isRanged()); snipeData.getVoxelMessage().toggleRange(); return true; } - } - else if (args[0].equalsIgnoreCase("perf")) - { + } else if (args[0].equalsIgnoreCase("perf")) { player.sendMessage(ChatColor.AQUA + "Available performers (abbreviated):"); player.sendMessage(PerformerE.performer_list_short); return true; - } - else if (args[0].equalsIgnoreCase("perflong")) - { + } else if (args[0].equalsIgnoreCase("perflong")) { player.sendMessage(ChatColor.AQUA + "Available performers:"); player.sendMessage(PerformerE.performer_list_long); return true; - } - else if (args[0].equalsIgnoreCase("enable") && player.hasPermission("voxelsniper.command.vs.enable")) - { + } else if (args[0].equalsIgnoreCase("enable") && player.hasPermission("voxelsniper.command.vs.enable")) { sniper.setEnabled(true); player.sendMessage("VoxelSniper is " + (sniper.isEnabled() ? "enabled" : "disabled")); return true; - } - else if (args[0].equalsIgnoreCase("disable") && player.hasPermission("voxelsniper.command.vs.enable")) - { + } else if (args[0].equalsIgnoreCase("disable") && player.hasPermission("voxelsniper.command.vs.enable")) { sniper.setEnabled(false); player.sendMessage("VoxelSniper is " + (sniper.isEnabled() ? "enabled" : "disabled")); return true; - } - else if (args[0].equalsIgnoreCase("toggle") && player.hasPermission("voxelsniper.command.vs.enable")) - { + } else if (args[0].equalsIgnoreCase("toggle") && player.hasPermission("voxelsniper.command.vs.enable")) { sniper.setEnabled(!sniper.isEnabled()); player.sendMessage("VoxelSniper is " + (sniper.isEnabled() ? "enabled" : "disabled")); return true; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoCommand.java index c551b0dd8..6a71efa71 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoCommand.java @@ -5,34 +5,25 @@ import com.thevoxelbox.voxelsniper.VoxelSniper; import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; import org.bukkit.entity.Player; -public class VoxelUndoCommand extends VoxelCommand -{ - public VoxelUndoCommand(final VoxelSniper plugin) - { +public class VoxelUndoCommand extends VoxelCommand { + public VoxelUndoCommand(final VoxelSniper plugin) { super("VoxelUndo", plugin); setIdentifier("u"); setPermission("voxelsniper.sniper"); } @Override - public boolean onCommand(Player player, String[] args) - { + public boolean onCommand(Player player, String[] args) { Sniper sniper = plugin.getSniperManager().getSniperForPlayer(player); - if (args.length == 1) - { - try - { + if (args.length == 1) { + try { int amount = Integer.parseInt(args[0]); sniper.undo(amount); - } - catch (NumberFormatException exception) - { + } catch (NumberFormatException exception) { player.sendMessage("Error while parsing amount of undo. Number format exception."); } - } - else - { + } else { sniper.undo(); } plugin.getLogger().info("Player \"" + player.getName() + "\" used /u"); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoUserCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoUserCommand.java index e35619dc5..66904b681 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoUserCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelUndoUserCommand.java @@ -6,25 +6,19 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; -public class VoxelUndoUserCommand extends VoxelCommand -{ - public VoxelUndoUserCommand(final VoxelSniper plugin) - { +public class VoxelUndoUserCommand extends VoxelCommand { + public VoxelUndoUserCommand(final VoxelSniper plugin) { super("VoxelUndoUser", plugin); setIdentifier("uu"); setPermission("voxelsniper.command.uu"); } @Override - public boolean onCommand(Player player, String[] args) - { - try - { + public boolean onCommand(Player player, String[] args) { + try { plugin.getSniperManager().getSniperForPlayer(Bukkit.getPlayer(args[0])).undo(); return true; - } - catch (final Exception exception) - { + } catch (final Exception exception) { player.sendMessage(ChatColor.GREEN + "Player not found."); return true; } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushSizeChangedEvent.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushSizeChangedEvent.java index 4d373dc07..3980b4e92 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushSizeChangedEvent.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperBrushSizeChangedEvent.java @@ -1,57 +1,48 @@ package com.thevoxelbox.voxelsniper.event; import com.thevoxelbox.voxelsniper.Sniper; -import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; /** * */ -public class SniperBrushSizeChangedEvent extends Event -{ +public class SniperBrushSizeChangedEvent extends Event { private static final HandlerList handlers = new HandlerList(); private final Sniper sniper; private final int originalSize; private final int newSize; private final String toolId; - public SniperBrushSizeChangedEvent(Sniper sniper, String toolId, int originalSize, int newSize) - { + public SniperBrushSizeChangedEvent(Sniper sniper, String toolId, int originalSize, int newSize) { this.sniper = sniper; this.originalSize = originalSize; this.newSize = newSize; this.toolId = toolId; } - public static HandlerList getHandlerList() - { + public static HandlerList getHandlerList() { return handlers; } - public int getOriginalSize() - { + public int getOriginalSize() { return originalSize; } - public int getNewSize() - { + public int getNewSize() { return newSize; } - public Sniper getSniper() - { + public Sniper getSniper() { return sniper; } - public String getToolId() - { + public String getToolId() { return toolId; } @Override - public HandlerList getHandlers() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperReplaceMaterialChangedEvent.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperReplaceMaterialChangedEvent.java index 46bc22607..453bd4797 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperReplaceMaterialChangedEvent.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/event/SniperReplaceMaterialChangedEvent.java @@ -3,28 +3,23 @@ package com.thevoxelbox.voxelsniper.event; import com.thevoxelbox.voxelsniper.Sniper; import org.bukkit.block.data.BlockData; import org.bukkit.event.HandlerList; -import org.bukkit.material.MaterialData; /** * */ -public class SniperReplaceMaterialChangedEvent extends SniperMaterialChangedEvent -{ +public class SniperReplaceMaterialChangedEvent extends SniperMaterialChangedEvent { private static final HandlerList handlers = new HandlerList(); - public SniperReplaceMaterialChangedEvent(Sniper sniper, String toolId, BlockData originalMaterial, BlockData newMaterial) - { + public SniperReplaceMaterialChangedEvent(Sniper sniper, String toolId, BlockData originalMaterial, BlockData newMaterial) { super(sniper, toolId, originalMaterial, newMaterial); } - public static HandlerList getHandlerList() - { + public static HandlerList getHandlerList() { return handlers; } @Override - public HandlerList getHandlers() - { + public HandlerList getHandlers() { return handlers; } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/HelpJSAP.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/HelpJSAP.java index 89870aa21..b29975775 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/HelpJSAP.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/HelpJSAP.java @@ -1,5 +1,12 @@ package com.thevoxelbox.voxelsniper.jsap; +import com.martiansoftware.jsap.JSAP; +import com.martiansoftware.jsap.JSAPException; +import com.martiansoftware.jsap.JSAPResult; +import com.martiansoftware.jsap.Switch; +import com.martiansoftware.util.StringUtils; +import org.bukkit.ChatColor; + import java.io.IOException; import java.net.URL; import java.util.Collections; @@ -7,21 +14,12 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import com.martiansoftware.jsap.JSAP; -import com.martiansoftware.jsap.JSAPException; -import com.martiansoftware.jsap.JSAPResult; -import com.martiansoftware.jsap.Switch; -import com.martiansoftware.util.StringUtils; - -import org.bukkit.ChatColor; - /** * JSAP parser with help generating code. * * @author MikeMatrix */ -public class HelpJSAP extends JSAP -{ +public class HelpJSAP extends JSAP { private String name; private String explanation; @@ -32,20 +30,16 @@ public class HelpJSAP extends JSAP * @param explanation * @param screenWidth */ - public HelpJSAP(final String name, final String explanation, final int screenWidth) - { + public HelpJSAP(final String name, final String explanation, final int screenWidth) { super(); this.name = name; this.explanation = explanation; this.screenWidth = screenWidth; - try - { + try { this.registerParameter(new Switch("help", JSAP.NO_SHORTFLAG, "help", "Displays this help page.")); - } - catch (final JSAPException e) - { + } catch (final JSAPException e) { } } @@ -54,26 +48,19 @@ public class HelpJSAP extends JSAP * @param explanation * @param screenWidth * @param resourceName - * - * @throws java.io.IOException - * if an I/O error occurs - * @throws com.martiansoftware.jsap.JSAPException - * if the configuration is not valid + * @throws java.io.IOException if an I/O error occurs + * @throws com.martiansoftware.jsap.JSAPException if the configuration is not valid */ - public HelpJSAP(final String name, final String explanation, final int screenWidth, final String resourceName) throws IOException, JSAPException - { + public HelpJSAP(final String name, final String explanation, final int screenWidth, final String resourceName) throws IOException, JSAPException { super(resourceName); this.name = name; this.explanation = explanation; this.screenWidth = screenWidth; - try - { + try { this.registerParameter(new Switch("help", JSAP.NO_SHORTFLAG, "help", "Displays this help page.")); - } - catch (final JSAPException e) - { + } catch (final JSAPException e) { } } @@ -82,95 +69,74 @@ public class HelpJSAP extends JSAP * @param explanation * @param screenWidth * @param jsapXML - * - * @throws java.io.IOException - * if an I/O error occurs - * @throws com.martiansoftware.jsap.JSAPException - * if the configuration is not valid + * @throws java.io.IOException if an I/O error occurs + * @throws com.martiansoftware.jsap.JSAPException if the configuration is not valid */ - public HelpJSAP(final String name, final String explanation, final int screenWidth, final URL jsapXML) throws IOException, JSAPException - { + public HelpJSAP(final String name, final String explanation, final int screenWidth, final URL jsapXML) throws IOException, JSAPException { super(jsapXML); this.name = name; this.explanation = explanation; this.screenWidth = screenWidth; - try - { + try { this.registerParameter(new Switch("help", JSAP.NO_SHORTFLAG, "help", "Displays this help page.")); - } - catch (final JSAPException e) - { + } catch (final JSAPException e) { } } /** * @return the explanation */ - public final String getExplanation() - { + public final String getExplanation() { return this.explanation; } /** - * @param explanation - * the explanation to set + * @param explanation the explanation to set */ - public final void setExplanation(final String explanation) - { + public final void setExplanation(final String explanation) { this.explanation = explanation; } /** * @return the name */ - public final String getName() - { + public final String getName() { return this.name; } /** - * @param name - * the name to set + * @param name the name to set */ - public final void setName(final String name) - { + public final void setName(final String name) { this.name = name; } /** * @return the screenWidth */ - public final int getScreenWidth() - { + public final int getScreenWidth() { return this.screenWidth; } /** - * @param screenWidth - * the screenWidth to set + * @param screenWidth the screenWidth to set */ - public final void setScreenWidth(final int screenWidth) - { + public final void setScreenWidth(final int screenWidth) { this.screenWidth = screenWidth; } /** * @param jsapResult - * * @return if something has been written on writer. */ - public final List writeHelpOrErrorMessageIfRequired(final JSAPResult jsapResult) - { - if (!(jsapResult.success()) || jsapResult.getBoolean("help")) - { + public final List writeHelpOrErrorMessageIfRequired(final JSAPResult jsapResult) { + if (!(jsapResult.success()) || jsapResult.getBoolean("help")) { List returnValue = new LinkedList<>(); // To avoid spurious missing argument errors we never print errors if help is required. - if (!jsapResult.getBoolean("help")) - { - for (final Iterator err = jsapResult.getErrorMessageIterator(); err.hasNext(); ) - { + if (!jsapResult.getBoolean("help")) { + for (final Iterator err = jsapResult.getErrorMessageIterator(); err.hasNext(); ) { returnValue.add(ChatColor.RED + "Error: " + ChatColor.DARK_RED + err.next()); } @@ -179,17 +145,14 @@ public class HelpJSAP extends JSAP returnValue.add(ChatColor.GOLD + "Usage:"); List l = StringUtils.wrapToList(this.name + " " + this.getUsage(), this.screenWidth); - for (final Object aL : l) - { + for (final Object aL : l) { returnValue.add(" " + aL.toString()); } - if (this.explanation != null) - { + if (this.explanation != null) { returnValue.add(""); l = StringUtils.wrapToList(this.explanation, this.screenWidth); - for (final Object aL : l) - { + for (final Object aL : l) { final String next = (String) aL; returnValue.add(ChatColor.AQUA + next); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/NullableIntegerStringParser.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/NullableIntegerStringParser.java index 30d196bff..d01d51a1a 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/NullableIntegerStringParser.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/NullableIntegerStringParser.java @@ -10,22 +10,20 @@ import com.martiansoftware.jsap.StringParser; * @see com.martiansoftware.jsap.StringParser * @see Integer */ -public class NullableIntegerStringParser extends StringParser -{ +public class NullableIntegerStringParser extends StringParser { @SuppressWarnings("unused") - private static final NullableIntegerStringParser INSTANCE = new NullableIntegerStringParser(); + private static final NullableIntegerStringParser INSTANCE = new NullableIntegerStringParser(); /** * Returns a {@link com.thevoxelbox.voxelsniper.jsap.NullableIntegerStringParser}. - * - * + *

+ *

* Convenient access to the only instance returned by this method is available through {@link com.martiansoftware.jsap.JSAP#INTEGER_PARSER}. * * @return a {@link com.thevoxelbox.voxelsniper.jsap.NullableIntegerStringParser}. */ - public static NullableIntegerStringParser getParser() - { + public static NullableIntegerStringParser getParser() { return new NullableIntegerStringParser(); } @@ -34,8 +32,7 @@ public class NullableIntegerStringParser extends StringParser * * @deprecated Use {@link #getParser()} or, even better, {@link com.martiansoftware.jsap.JSAP#INTEGER_PARSER}. */ - public NullableIntegerStringParser() - { + public NullableIntegerStringParser() { super(); } @@ -43,31 +40,22 @@ public class NullableIntegerStringParser extends StringParser * Parses the specified argument into an Integer. This method delegates the parsing to Integer.decode(arg). If Integer.decode() * throws a NumberFormatException, it is encapsulated into a ParseException and re-thrown. * - * @param arg - * the argument to parse - * + * @param arg the argument to parse * @return an Integer object with the value contained in the specified argument. - * - * @throws com.martiansoftware.jsap.ParseException - * if Integer.decode(arg) throws a NumberFormatException. + * @throws com.martiansoftware.jsap.ParseException if Integer.decode(arg) throws a NumberFormatException. * @see Integer * @see com.martiansoftware.jsap.StringParser#parse(String) */ @Override - public final Object parse(final String arg) throws ParseException - { - if (arg == null) - { + public final Object parse(final String arg) throws ParseException { + if (arg == null) { return null; } Integer result; - try - { + try { result = Integer.decode(arg); - } - catch (NumberFormatException nfe) - { + } catch (NumberFormatException nfe) { throw (new ParseException("Unable to convert '" + arg + "' to an Integer.", nfe)); } return (result);