Few changes, WorldEdit Change Event should now be cancellable.
This commit is contained in:
parent
ba08d4bde2
commit
addb99a1f2
@ -5,12 +5,12 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
|
||||
@ -65,7 +65,7 @@ import me.TheBukor.SkStuff.util.ReflectionUtils;
|
||||
public class SkStuff extends JavaPlugin {
|
||||
private int condAmount = 0;
|
||||
private int effAmount = 0;
|
||||
private boolean evtWE = false;
|
||||
private int evtAmount = 0;
|
||||
private int exprAmount = 0;
|
||||
private int typeAmount = 0;
|
||||
|
||||
@ -116,7 +116,7 @@ public class SkStuff extends JavaPlugin {
|
||||
NBT1 = nbtParserClass.getMethod("parse", String.class).invoke(NBT1, newTags);
|
||||
} catch (Exception ex) {
|
||||
if (ex instanceof InvocationTargetException && ex.getCause().getClass().getName().contains("MojangsonParseException")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[SkStuff] " + ChatColor.RED + "Error when parsing NBT - " + ex.getCause().getMessage());
|
||||
getLogger().warning(Ansi.ansi().fgBright(Ansi.Color.RED) + "Error when parsing NBT - " + ex.getCause().getMessage() + Ansi.ansi().fgBright(Ansi.Color.DEFAULT));
|
||||
return;
|
||||
}
|
||||
ex.printStackTrace();
|
||||
@ -214,7 +214,7 @@ public class SkStuff extends JavaPlugin {
|
||||
return EvtWorldEditChange.getBlock();
|
||||
}
|
||||
}, 0);
|
||||
evtWE = true;
|
||||
evtAmount += 1;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
Skript.error("Unable to register \"On WorldEdit block change\" event! You will need to upgrade to WorldEdit 6.0");
|
||||
return;
|
||||
@ -231,7 +231,7 @@ public class SkStuff extends JavaPlugin {
|
||||
effAmount += 1;
|
||||
exprAmount += 1;
|
||||
}
|
||||
getLogger().info("Everything ready! Loaded a total of " + condAmount + (condAmount == 1 ? " condition, " : " conditions, ") + effAmount + (effAmount == 1 ? " effect, " : " effects, ") + (evtWE ? "1 event, " : "") + exprAmount + (exprAmount == 1 ? " expression" : " expressions and ") + typeAmount + (typeAmount == 1 ? " type!" : " types!"));
|
||||
getLogger().info("Everything ready! Loaded a total of " + condAmount + " conditions, " + effAmount + " effects, " + evtAmount + "events, " + exprAmount + " expressions and " + typeAmount + " types!");
|
||||
} else {
|
||||
getLogger().info("Unable to find Skript or Skript isn't accepting registrations, disabling SkStuff...");
|
||||
Bukkit.getPluginManager().disablePlugin(this);;
|
||||
|
@ -2,16 +2,20 @@ package me.TheBukor.SkStuff.events;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class EvtWorldEditChange extends Event {
|
||||
static Player player;
|
||||
static Block block;
|
||||
public class EvtWorldEditChange extends Event implements Cancellable {
|
||||
private static Player player;
|
||||
private static Block block;
|
||||
private boolean cancelled;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public EvtWorldEditChange(Player player, Block block) {
|
||||
EvtWorldEditChange.player = player;
|
||||
EvtWorldEditChange.block = block;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
public static Player getPlayer() {
|
||||
@ -22,8 +26,6 @@ public class EvtWorldEditChange extends Event {
|
||||
return block;
|
||||
}
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
@ -31,4 +33,14 @@ public class EvtWorldEditChange extends Event {
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean bool) {
|
||||
this.cancelled = bool;
|
||||
}
|
||||
}
|
@ -12,10 +12,10 @@ import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.Event;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
|
||||
import ch.njol.skript.Skript;
|
||||
import ch.njol.skript.classes.Changer.ChangeMode;
|
||||
import ch.njol.skript.lang.Expression;
|
||||
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
||||
@ -104,7 +104,7 @@ public class ExprFileNBT extends SimpleExpression<Object> {
|
||||
os.close();
|
||||
} catch (Exception ex) {
|
||||
if (ex instanceof InvocationTargetException && ex.getCause().getClass().getName().contains("MojangsonParseException")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[SkStuff] " + ChatColor.RED + "Error when parsing NBT - " + ex.getCause().getMessage());
|
||||
Skript.warning(Ansi.ansi().fgBright(Ansi.Color.RED) + "Error when parsing NBT - " + ex.getCause().getMessage() + Ansi.ansi().fgBright(Ansi.Color.DEFAULT));
|
||||
return;
|
||||
}
|
||||
ex.printStackTrace();
|
||||
|
@ -4,12 +4,12 @@ import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
|
||||
import ch.njol.skript.Skript;
|
||||
import ch.njol.skript.lang.Expression;
|
||||
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
||||
import ch.njol.skript.lang.util.SimpleExpression;
|
||||
@ -72,7 +72,7 @@ public class ExprItemNBT extends SimpleExpression<ItemStack> {
|
||||
nmsItem.getClass().getMethod("setTag", nbtClass).invoke(nmsItem, NBT);
|
||||
} catch (Exception ex) {
|
||||
if (ex instanceof InvocationTargetException && ex.getCause().getClass().getName().contains("MojangsonParseException")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[SkStuff] " + ChatColor.RED + "Error when parsing NBT - " + ex.getCause().getMessage());
|
||||
Skript.warning(Ansi.ansi().fgBright(Ansi.Color.RED) + "Error when parsing NBT - " + ex.getCause().getMessage() + Ansi.ansi().fgBright(Ansi.Color.DEFAULT));
|
||||
return null;
|
||||
}
|
||||
ex.printStackTrace();
|
||||
|
@ -4,14 +4,14 @@ import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
|
||||
import ch.njol.skript.Skript;
|
||||
import ch.njol.skript.classes.Changer.ChangeMode;
|
||||
import ch.njol.skript.lang.Expression;
|
||||
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
||||
@ -141,7 +141,7 @@ public class ExprNBTOf extends SimpleExpression<Object> {
|
||||
nmsEnt.getClass().getMethod("f", nbtClass).invoke(nmsEnt, NBT);
|
||||
} catch (Exception ex) {
|
||||
if (ex instanceof InvocationTargetException && ex.getCause().getClass().getName().contains("MojangsonParseException")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[SkStuff] " + ChatColor.RED + "Error when parsing NBT - " + ex.getCause().getMessage());
|
||||
Skript.warning(Ansi.ansi().fgBright(Ansi.Color.RED) + "Error when parsing NBT - " + ex.getCause().getMessage() + Ansi.ansi().fgBright(Ansi.Color.DEFAULT));
|
||||
return;
|
||||
}
|
||||
ex.printStackTrace();
|
||||
@ -193,7 +193,7 @@ public class ExprNBTOf extends SimpleExpression<Object> {
|
||||
nmsWorld.getClass().getMethod("notify", nmsPosClass).invoke(nmsWorld, tileEntity.getClass().getMethod("getPosition").invoke(tileEntity));
|
||||
} catch (Exception ex) {
|
||||
if (ex instanceof InvocationTargetException && ex.getCause().getClass().getName().contains("MojangsonParseException")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[SkStuff] " + ChatColor.RED + "Error when parsing NBT - " + ex.getCause().getMessage());
|
||||
Skript.warning(Ansi.ansi().fgBright(Ansi.Color.RED) + "Error when parsing NBT - " + ex.getCause().getMessage() + Ansi.ansi().fgBright(Ansi.Color.DEFAULT));
|
||||
return;
|
||||
}
|
||||
ex.printStackTrace();
|
||||
@ -253,7 +253,7 @@ public class ExprNBTOf extends SimpleExpression<Object> {
|
||||
((Slot) slot[0]).setItem((ItemStack) newItem);
|
||||
} catch (Exception ex) {
|
||||
if (ex instanceof InvocationTargetException && ex.getCause().getClass().getName().contains("MojangsonParseException")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[SkStuff] " + ChatColor.RED + "Error when parsing NBT - " + ex.getCause().getMessage());
|
||||
Skript.warning(Ansi.ansi().fgBright(Ansi.Color.RED) + "Error when parsing NBT - " + ex.getCause().getMessage() + Ansi.ansi().fgBright(Ansi.Color.DEFAULT));
|
||||
return;
|
||||
}
|
||||
ex.printStackTrace();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.TheBukor.SkStuff.util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
|
||||
public class ReflectionUtils {
|
||||
|
||||
@ -11,7 +12,7 @@ public class ReflectionUtils {
|
||||
try {
|
||||
nmsClass = Class.forName(name);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
Bukkit.getLogger().warning("Unable to get NMS class! You are probably running an unsupported version");
|
||||
Bukkit.getLogger().warning(Ansi.ansi().fgBright(Ansi.Color.RED) + "Unable to get NMS class! You are probably running an unsupported version!" + Ansi.ansi().fgBright(Ansi.Color.DEFAULT));
|
||||
return null;
|
||||
}
|
||||
return nmsClass;
|
||||
@ -24,7 +25,7 @@ public class ReflectionUtils {
|
||||
try {
|
||||
obcClass = Class.forName(name);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
Bukkit.getLogger().warning("Unable to get OBC class! You are probably running an unsupported version");
|
||||
Bukkit.getLogger().warning(Ansi.ansi().fgBright(Ansi.Color.RED) + "Unable to get OBC class! You are probably running an unsupported version!" + Ansi.ansi().fgBright(Ansi.Color.DEFAULT));
|
||||
return null;
|
||||
}
|
||||
return obcClass;
|
||||
|
Loading…
Reference in New Issue
Block a user