Skip to content

Commit

Permalink
Minor fixes for craftscripts in Forge
Browse files Browse the repository at this point in the history
  • Loading branch information
octylFractal committed Jul 11, 2019
1 parent dd134d3 commit 5ba2c7f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 289 deletions.
2 changes: 1 addition & 1 deletion worldedit-core/build.gradle.kts
Expand Up @@ -15,7 +15,7 @@ configurations.all {
dependencies {
"compile"(project(":worldedit-libs:core"))
"compile"("de.schlichtherle:truezip:6.8.3")
"compile"("org.mozilla:rhino:1.7R5")
"compile"("org.mozilla:rhino:1.7.11")
"compile"("org.yaml:snakeyaml:1.9")
"compile"("com.google.guava:guava:21.0")
"compile"("com.google.code.findbugs:jsr305:1.3.9")
Expand Down
@@ -0,0 +1,41 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.scripting;

import org.mozilla.javascript.ClassShutter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Hides Minecraft's obfuscated & de-obfuscated names from scripts.
*/
class MinecraftHidingClassShutter implements ClassShutter {

private static final Logger LOGGER = LoggerFactory.getLogger(MinecraftHidingClassShutter.class);

@Override
public boolean visibleToScripts(String fullClassName) {
if (!fullClassName.contains(".")) {
// Default package -- probably Minecraft
return false;
}
return !fullClassName.startsWith("net.minecraft");
}
}
Expand Up @@ -50,6 +50,7 @@ public Object evaluate(String script, String filename, Map<String, Object> args)
throws ScriptException, Throwable {
RhinoContextFactory factory = new RhinoContextFactory(timeLimit);
Context cx = factory.enterContext();
cx.setClassShutter(new MinecraftHidingClassShutter());
ScriptableObject scriptable = new ImporterTopLevel(cx);
Scriptable scope = cx.initStandardObjects(scriptable);

Expand Down

This file was deleted.

This file was deleted.

4 changes: 3 additions & 1 deletion worldedit-forge/build.gradle.kts
Expand Up @@ -91,7 +91,9 @@ tasks.named<ShadowJar>("shadowJar") {
include(dependency("org.apache.logging.log4j:log4j-slf4j-impl"))
include(dependency("de.schlichtherle:truezip"))
include(dependency("org.mozilla:rhino"))

}
minimize {
exclude(dependency("org.mozilla:rhino"))
}
}

Expand Down

0 comments on commit 5ba2c7f

Please sign in to comment.