Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-05 02:50:05 +01:00
Minor FAVS cleanup
Dieser Commit ist enthalten in:
Ursprung
a22ba45b1c
Commit
8d182abd3e
@ -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'
|
||||
|
@ -13,21 +13,18 @@ import java.util.Set;
|
||||
/**
|
||||
* Brush registration manager.
|
||||
*/
|
||||
public class Brushes
|
||||
{
|
||||
public class Brushes {
|
||||
private Multimap<Class<? extends IBrush>, 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<? extends IBrush> clazz, String... handles)
|
||||
{
|
||||
public void registerSniperBrush(Class<? extends IBrush> 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<? extends IBrush> getBrushForHandle(String handle)
|
||||
{
|
||||
public Class<? extends IBrush> 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<Class<? extends IBrush>, String> entry : brushes.entries())
|
||||
{
|
||||
if (entry.getValue().equalsIgnoreCase(handle))
|
||||
{
|
||||
for (Map.Entry<Class<? extends IBrush>, 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<String> getSniperBrushHandles(Class<? extends IBrush> clazz)
|
||||
{
|
||||
public Set<String> getSniperBrushHandles(Class<? extends IBrush> clazz) {
|
||||
return new HashSet<>(brushes.get(clazz));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Immutable Multimap copy of all the registered brushes
|
||||
*/
|
||||
public Multimap<Class<?extends IBrush>, String> getRegisteredBrushesMultimap()
|
||||
{
|
||||
public Multimap<Class<? extends IBrush>, String> getRegisteredBrushesMultimap() {
|
||||
return ImmutableMultimap.copyOf(brushes);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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.");
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -1,9 +1,8 @@
|
||||
package com.thevoxelbox.voxelsniper;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public enum SnipeAction
|
||||
{
|
||||
*
|
||||
*/
|
||||
public enum SnipeAction {
|
||||
ARROW, GUNPOWDER
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -9,20 +9,16 @@ import java.util.UUID;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class SniperManager
|
||||
{
|
||||
public class SniperManager {
|
||||
private Map<UUID, Sniper> 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());
|
||||
|
@ -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");
|
||||
|
@ -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<Integer> getLiteSniperRestrictedItems()
|
||||
{
|
||||
public List<Integer> 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<Integer> restrictedItems)
|
||||
{
|
||||
public void setLitesniperRestrictedItems(List<Integer> 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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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<? extends IBrush> 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;
|
||||
}
|
||||
|
@ -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 <arrow|powder> <toolid>");
|
||||
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 <arrow|powder> <toolid>");
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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.");
|
||||
|
@ -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.");
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<Class<? extends IBrush>, String> registeredBrushesMultimap = VoxelSniper.getInstance().getBrushManager().getRegisteredBrushesMultimap();
|
||||
List<String> allHandles = Lists.newLinkedList();
|
||||
for (Class<? extends IBrush> brushClass : registeredBrushesMultimap.keySet())
|
||||
{
|
||||
for (Class<? extends IBrush> 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;
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<String> writeHelpOrErrorMessageIfRequired(final JSAPResult jsapResult)
|
||||
{
|
||||
if (!(jsapResult.success()) || jsapResult.getBoolean("help"))
|
||||
{
|
||||
public final List<String> writeHelpOrErrorMessageIfRequired(final JSAPResult jsapResult) {
|
||||
if (!(jsapResult.success()) || jsapResult.getBoolean("help")) {
|
||||
List<String> 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);
|
||||
}
|
||||
|
@ -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}.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* <p>
|
||||
* 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 <code>Integer.decode(arg)</code>. If <code>Integer.decode()</code>
|
||||
* 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 <code>Integer.decode(arg)</code> throws a NumberFormatException.
|
||||
* @throws com.martiansoftware.jsap.ParseException if <code>Integer.decode(arg)</code> 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);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren