This commit is contained in:
Jesse Boyd
2018-08-24 01:22:30 +10:00
parent 963d1192c2
commit dbd31ea347
14 changed files with 54 additions and 19 deletions

View File

@ -91,7 +91,7 @@ public class Message
@SuppressWarnings("deprecation")
public void replace()
{
snipeData.sendMessage(ChatColor.AQUA + "Replace Material: " + ChatColor.RED + snipeData.getReplaceId() + ChatColor.GRAY + " (" + BlockTypes.get(snipeData.getReplaceId()).toString() + ")");
snipeData.sendMessage(ChatColor.AQUA + "Replace Material: " + BlockTypes.getFromStateId(snipeData.getReplaceId()));
}
/**
@ -144,7 +144,7 @@ public class Message
@SuppressWarnings("deprecation")
public void voxel()
{
snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + snipeData.getVoxelId() + ChatColor.GRAY + " (" + BlockTypes.get(snipeData.getVoxelId()).toString() + ")");
snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + BlockTypes.getFromStateId(snipeData.getVoxelId()));
}
/**

View File

@ -112,7 +112,7 @@ public class VoxelSniper extends JavaPlugin
@Override
public boolean execute(FawePlayer fp, String... args) {
Player player = (Player) fp.parent;
return (Bukkit.getPluginManager().getPlugin("VoxelSniper")).onCommand(player, new Command("p") {
return onCommand(player, new Command("p") {
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
return false;
@ -125,7 +125,7 @@ public class VoxelSniper extends JavaPlugin
@Override
public boolean execute(FawePlayer fp, String... args) {
Player player = (Player) fp.parent;
return (Bukkit.getPluginManager().getPlugin("VoxelSniper")).onCommand(player, new Command("d") {
return onCommand(player, new Command("d") {
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
return false;

View File

@ -1,5 +1,9 @@
package com.thevoxelbox.voxelsniper;
import com.boydti.fawe.object.FawePlayer;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.worldedit.extension.platform.CommandManager;
import com.sk89q.worldedit.util.command.parametric.ExceptionConverter;
import com.thevoxelbox.voxelsniper.api.command.VoxelCommand;
import com.thevoxelbox.voxelsniper.command.*;
import org.bukkit.ChatColor;
@ -11,6 +15,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
/**
* @author Voxel
@ -72,7 +77,32 @@ public class VoxelSniperListener implements Listener
return true;
}
return found.onCommand(player, split);
FawePlayer fp = FawePlayer.wrap(player);
ExceptionConverter exceptionConverter = CommandManager.getInstance().getExceptionConverter();
try {
try {
return found.onCommand(player, split);
} catch (Throwable t) {
Throwable next = t;
exceptionConverter.convert(next);
while (next.getCause() != null) {
next = next.getCause();
exceptionConverter.convert(next);
}
throw next;
}
} catch (CommandException e) {
String message = e.getMessage();
if (message != null) {
fp.sendMessage(e.getMessage());
return true;
}
e.printStackTrace();
} catch (Throwable e) {
e.printStackTrace();
}
fp.sendMessage("An unknown FAWE error has occurred! Please see console.");
return true;
}
private boolean hasPermission(final VoxelCommand command, final Player player)

View File

@ -149,7 +149,7 @@ public class ScannerBrush extends Brush
@Override
protected final void arrow(final SnipeData v)
{
this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId()));
this.checkFor = BukkitAdapter.adapt(BlockTypes.getFromStateId(v.getVoxelId()));
this.scan(v, this.getTargetBlock().getFace(this.getLastBlock()));
}
@ -157,7 +157,7 @@ public class ScannerBrush extends Brush
@Override
protected final void powder(final SnipeData v)
{
this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId()));
this.checkFor = BukkitAdapter.adapt(BlockTypes.getFromStateId(v.getVoxelId()));
this.scan(v, this.getTargetBlock().getFace(this.getLastBlock()));
}

View File

@ -19,7 +19,7 @@ import java.util.List;
public class VoxelList
{
private BlockMask mask = new BlockMask(NullExtent.INSTANCE);
private BlockMask mask = new BlockMask();
/**
* Adds the specified id, data value pair to the VoxelList. A data value of -1 will operate on all data values of that id.