Unable to use JavaAdapter in CraftScripts
Snownee opened this issue ยท 11 comments
WorldEdit Version
7.2.5
Platform Version
Forge
Confirmations
- I am using the most recent Minecraft release.
- I am using a version of WorldEdit compatible with my Minecraft version.
- I am using the latest or recommended version of my platform software.
- I am NOT using a hybrid server, e.g. a server that combines Bukkit and Forge. Examples include Arclight, Mohist, and Cardboard.
- I am NOT using a fork of WorldEdit, such as FastAsyncWorldEdit (FAWE) or AsyncWorldEdit (AWE)
Bug Description
Due to the current implementation of MinecraftHidingClassShutter
, run the script below will show Access to Java class "adapter1" is prohibited
Which means you can't extend any class by CraftScripts
Expected Behavior
ability to use JavaAdapter in CraftScripts
Reproduction Steps
Use this script:
// $Id$
/*
* Test CraftScript for WorldEdit
* Copyright (C) 2021 Snownee
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
let we = com.sk89q.worldedit.WorldEdit.getInstance()
let factory = we.getBlockFactory()
let parser = new JavaAdapter(com.sk89q.worldedit.extension.factory.parser.DefaultBlockParser, {
parseFromInput: function(input, context) {
return null
}
}, we)
Anything Else?
No response
you should be making a custom SimpleInputParser (or any InputParser), not extending DefaultBlockParser
and i'm like 95% sure you can just do that with java's "anonymous class syntax", e.g.
parser = new SimpleInputParser(we) { getMatchedAliases: function() { return ImmutableList.of("#mypattern")} parseFromSimpleInput: function(input, context) { return MyPattern(...) }; } we.getPatternFactory().register(parser)
I thought that was a very simple need. So I don't want to import GPL codes or writing a dedicated mod for it. Also I am having some trouble extending abstract class in Rhino.
What do you mean by "GPL codes"? All of worldedit is GPL, you can't not use it.
Why do you need to extend DefaultBlockParser
? That's not really an intended usage of the API, if you need to parse stuff there are helpers to do that already [ref].
you should be making a custom SimpleInputParser (or any InputParser), not extending DefaultBlockParser
and i'm like 95% sure you can just do that with java's "anonymous class syntax", e.g.
parser = new SimpleInputParser(we) {
getMatchedAliases: function() { return ImmutableList.of("#mypattern")}
parseFromSimpleInput: function(input, context) { return MyPattern(...) };
}
we.getPatternFactory().register(parser)
Why a different block parser? Are you sure you're not looking to add a pattern parser and add it to the existing pattern factory?
What do you mean by "GPL codes"? All of worldedit is GPL, you can't not use it.
I don't want my entire project to become under GPL.
Unfortunately using CraftScripts won't let you avoid that. You must still use a GPL-compatible license even if you write a CraftScript, as that is still linking against WorldEdit.
Not being able to use JavaAdapter may be a bug, I'm looking in to it. However, you do not need it to implement a single interface as you need here, so this isn't a blocker.
Fixes by 6008fe7.