Minor tweaks to work with build.js

This commit is contained in:
Jesse Boyd 2019-04-14 22:46:01 +10:00
parent f6b844e53c
commit a8b0fd21bb
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
3 changed files with 17 additions and 0 deletions

View File

@ -30,7 +30,9 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.CommandManager;
import com.sk89q.worldedit.scripting.CraftScriptContext;
import com.sk89q.worldedit.scripting.CraftScriptEngine;
import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
import com.sk89q.worldedit.session.request.Request;
@ -138,9 +140,15 @@ public class ScriptingCommands {
engine.setTimeLimit(worldEdit.getConfiguration().scriptTimeout);
Player player = actor instanceof Player ? (Player) actor : null;
CraftScriptContext scriptContext = new CraftScriptContext(worldEdit, WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.USER_COMMANDS),
WorldEdit.getInstance().getConfiguration(), session, player, args);
Map<String, Object> vars = new HashMap<>();
vars.put("argv", args);
vars.put("context", scriptContext);
vars.put("actor", actor);
vars.put("player", player);
try {
result = engine.evaluate(script, filename, vars);
@ -155,6 +163,7 @@ public class ScriptingCommands {
} catch (Throwable e) {
actor.printError(BBC.getPrefix() + "Failed to execute (see console):");
actor.printRaw(e.getClass().getCanonicalName());
e.printStackTrace();
}
if (result instanceof NativeJavaObject) {
return (T) ((NativeJavaObject) result).unwrap();

View File

@ -200,6 +200,10 @@ public class BaseBlock implements BlockStateHolder<BaseBlock> {
return blockState.getBlockType();
}
public BlockType getType() {
return getBlockType();
}
@Override
public int getOrdinal() {
return blockState.getOrdinal();

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.world.item;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.registry.RegistryItem;
import com.sk89q.worldedit.registry.NamespacedRegistry;
@ -105,6 +106,9 @@ public class ItemType implements RegistryItem {
}
public BaseItem getDefaultState() {
if (defaultState == null) {
this.defaultState = new BaseItemStack(this);
}
return this.defaultState;
}