geforkt von Mirrors/FastAsyncWorldEdit
Update templates, address JEP deprecations and place a few TODOs
Dieser Commit ist enthalten in:
Ursprung
d3aaf7acff
Commit
1f975ac044
5
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
5
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -29,6 +29,7 @@ body:
|
||||
description: Which server version version you using? If your server version is not listed, it is not supported. Update to a supported version first.
|
||||
multiple: false
|
||||
options:
|
||||
- '1.18'
|
||||
- '1.17.1'
|
||||
- '1.16.5'
|
||||
- '1.15.2'
|
||||
@ -82,7 +83,7 @@ body:
|
||||
attributes:
|
||||
label: Fawe Version
|
||||
description: What version of Fawe are you running? (`/version FastAsyncWorldEdit`)
|
||||
placeholder: "For example: FastAsyncWorldEdit version 1.17-89;8c01959"
|
||||
placeholder: "For example: FastAsyncWorldEdit version 2.0.0-SNAPSHOT+1"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
@ -93,7 +94,7 @@ body:
|
||||
options:
|
||||
- label: I have included a Fawe debugpaste.
|
||||
required: true
|
||||
- label: I am using the newest build from https://ci.athion.net/job/FastAsyncWorldEdit-1.17/ and the issue still persists.
|
||||
- label: I am using the newest build from https://ci.athion.net/job/FastAsyncWorldEdit-1.18/ and the issue still persists.
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
|
@ -38,7 +38,7 @@ You will find:
|
||||
* FastAsyncWorldEdit for Bukkit in **worldedit-bukkit/build/libs**
|
||||
* the CLI version in **worldedit-cli/build/libs**
|
||||
|
||||
If you want to use FastAsyncWorldEdit, use the `FastAsyncWorldEdit-1.17-<commitHash>` version obtained in **worldedit-bukkit/build/libs**.
|
||||
If you want to use FastAsyncWorldEdit, use the `FastAsyncWorldEdit-<identifier>` version obtained in **worldedit-bukkit/build/libs**.
|
||||
|
||||
(The `-#` version includes FastAsyncWorldEdit + necessary libraries.)
|
||||
|
||||
|
@ -24,8 +24,8 @@ Java Edition required. FastAsyncWorldEdit is compatible with Bukkit, Spigot, Pap
|
||||
* [Wiki](https://github.com/IntellectualSites/FastAsyncWorldEdit-Documentation/wiki)
|
||||
* [Report Issue](https://github.com/IntellectualSites/FastAsyncWorldEdit/issues)
|
||||
* [Crowdin (Translations)](https://intellectualsites.crowdin.com/fastasyncworldedit)
|
||||
* [JavaDocs for the -bukkit module](https://ci.athion.net/job/FastAsyncWorldEdit-1.17-Bukkit-Javadocs/javadoc/)
|
||||
* [JavaDocs for the -core module](https://ci.athion.net/job/FastAsyncWorldEdit-1.17-Core-Javadocs/javadoc/)
|
||||
* [JavaDocs for the -bukkit module](https://javadoc.io/doc/com.fastasyncworldedit/FastAsyncWorldEdit-Bukkit/latest/index.html)
|
||||
* [JavaDocs for the -core module](https://javadoc.io/doc/com.fastasyncworldedit/FastAsyncWorldEdit-Core/latest/index.html)
|
||||
|
||||
## Edit The Code
|
||||
|
||||
|
@ -60,13 +60,13 @@ fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, banSlf4j: Boolean
|
||||
options.encoding = "UTF-8"
|
||||
links(
|
||||
"https://javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.2/",
|
||||
"https://jd.adventure.kyori.net/api/4.9.1/",
|
||||
"https://jd.adventure.kyori.net/api/4.9.3/",
|
||||
"https://javadoc.io/doc/org.apache.logging.log4j/log4j-api/2.14.1/",
|
||||
"https://javadoc.io/doc/com.google.guava/guava/21.0/",
|
||||
"https://javadoc.io/doc/com.google.guava/guava/31.0.1/",
|
||||
"https://www.antlr.org/api/Java/",
|
||||
"https://docs.enginehub.org/javadoc/org.enginehub.piston/core/0.5.7/",
|
||||
"https://docs.enginehub.org/javadoc/org.enginehub.piston/default-impl/0.5.7/",
|
||||
"https://papermc.io/javadocs/paper/1.17/",
|
||||
"https://papermc.io/javadocs/paper/1.18/",
|
||||
"https://ci.athion.net/job/FastAsyncWorldEdit-1.17-Core-Javadocs/javadoc/" // needed for other module linking
|
||||
)
|
||||
}
|
||||
|
@ -193,8 +193,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter {
|
||||
serverWorldsField = CraftServer.class.getDeclaredField("worlds");
|
||||
serverWorldsField.setAccessible(true);
|
||||
|
||||
getChunkFutureMethod = ServerChunkCache.class.getDeclaredMethod("getChunkFutureMainThread",
|
||||
int.class, int.class, ChunkStatus.class, boolean.class);
|
||||
getChunkFutureMethod = ServerChunkCache.class.getDeclaredMethod(
|
||||
Refraction.pickName("getChunkFutureMainThread", "c"),
|
||||
int.class, int.class, ChunkStatus.class, boolean.class
|
||||
);
|
||||
getChunkFutureMethod.setAccessible(true);
|
||||
|
||||
chunkProviderExecutorField = ServerChunkCache.class.getDeclaredField(
|
||||
|
@ -220,8 +220,6 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
// Enable metrics
|
||||
new Metrics(this, BSTATS_ID);
|
||||
|
||||
// Check whether the server runs on 11 or greater
|
||||
ServerLib.checkJavaLTS();
|
||||
// Check if we are in a safe environment
|
||||
ServerLib.checkUnsafeForks();
|
||||
// Check if a new build is available
|
||||
|
@ -305,6 +305,7 @@ public class Fawe {
|
||||
br.close();
|
||||
this.version = FaweVersion.tryParse(versionString, commitString, dateString);
|
||||
Settings.IMP.DATE = new Date(100 + version.year, version.month, version.day).toString();
|
||||
//TODO 1.18 revisit
|
||||
Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit-1.17/" + version.build;
|
||||
Settings.IMP.COMMIT = "https://github.com/IntellectualSites/FastAsyncWorldEdit/commit/" + Integer.toHexString(version.hash);
|
||||
} catch (Throwable ignored) {
|
||||
|
@ -3,6 +3,7 @@ package com.fastasyncworldedit.core;
|
||||
/**
|
||||
* An internal FAWE class not meant for public use.
|
||||
**/
|
||||
//TODO 18 update to semver
|
||||
public class FaweVersion {
|
||||
|
||||
public final int year;
|
||||
|
@ -34,7 +34,7 @@ public class Config {
|
||||
/**
|
||||
* Get the value for a node. Probably throws some error if you try to get a non-existent key.
|
||||
*/
|
||||
private <T> T get(String key, Class root) {
|
||||
private <T> T get(String key, Class<?> root) {
|
||||
String[] split = key.split("\\.");
|
||||
Object instance = getInstance(split, root);
|
||||
if (instance != null) {
|
||||
@ -57,7 +57,7 @@ public class Config {
|
||||
* @param key config node
|
||||
* @param value value
|
||||
*/
|
||||
private void set(String key, Object value, Class root) {
|
||||
private void set(String key, Object value, Class<?> root) {
|
||||
String[] split = key.split("\\.");
|
||||
Object instance = getInstance(split, root);
|
||||
if (instance != null) {
|
||||
@ -201,7 +201,7 @@ public class Config {
|
||||
/**
|
||||
* Get the static fields in a section.
|
||||
*/
|
||||
private Map<String, Object> getFields(Class clazz) {
|
||||
private Map<String, Object> getFields(Class<?> clazz) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
for (Field field : clazz.getFields()) {
|
||||
if (Modifier.isStatic(field.getModifiers())) {
|
||||
@ -223,12 +223,11 @@ public class Config {
|
||||
}
|
||||
StringBuilder m = new StringBuilder();
|
||||
for (Object obj : listValue) {
|
||||
m.append(System.lineSeparator() + spacing + "- " + toYamlString(obj, spacing));
|
||||
m.append(System.lineSeparator()).append(spacing).append("- ").append(toYamlString(obj, spacing));
|
||||
}
|
||||
return m.toString();
|
||||
}
|
||||
if (value instanceof String) {
|
||||
String stringValue = (String) value;
|
||||
if (value instanceof String stringValue) {
|
||||
if (stringValue.isEmpty()) {
|
||||
return "''";
|
||||
}
|
||||
@ -237,11 +236,11 @@ public class Config {
|
||||
return value != null ? value.toString() : "null";
|
||||
}
|
||||
|
||||
private void save(PrintWriter writer, Class clazz, final Object instance, int indent) {
|
||||
private void save(PrintWriter writer, Class<?> clazz, final Object instance, int indent) {
|
||||
try {
|
||||
String CTRF = System.lineSeparator();
|
||||
String spacing = StringMan.repeat(" ", indent);
|
||||
HashMap<Class, Object> instances = new HashMap<>();
|
||||
HashMap<Class<?>, Object> instances = new HashMap<>();
|
||||
for (Field field : clazz.getFields()) {
|
||||
if (field.getAnnotation(Ignore.class) != null) {
|
||||
continue;
|
||||
@ -272,7 +271,7 @@ public class Config {
|
||||
configBlock = new ConfigBlock();
|
||||
field.set(instance, configBlock);
|
||||
for (String blockName : blockNames.value()) {
|
||||
configBlock.put(blockName, current.newInstance());
|
||||
configBlock.put(blockName, current.getDeclaredConstructor().newInstance());
|
||||
}
|
||||
}
|
||||
// Save each instance
|
||||
@ -299,11 +298,10 @@ public class Config {
|
||||
}
|
||||
writer.write(spacing + toNodeName(current.getSimpleName()) + ":" + CTRF);
|
||||
if (value == null) {
|
||||
field.set(instance, value = current.newInstance());
|
||||
field.set(instance, value = current.getDeclaredConstructor().newInstance());
|
||||
instances.put(current, value);
|
||||
}
|
||||
save(writer, current, value, indent + 2);
|
||||
continue;
|
||||
} else {
|
||||
writer.write(spacing + toNodeName(field.getName() + ": ") + toYamlString(
|
||||
field.get(instance),
|
||||
@ -321,7 +319,7 @@ public class Config {
|
||||
*
|
||||
* @param split the node (split by period)
|
||||
*/
|
||||
private Field getField(String[] split, Class root) {
|
||||
private Field getField(String[] split, Class<?> root) {
|
||||
Object instance = getInstance(split, root);
|
||||
if (instance == null) {
|
||||
return null;
|
||||
@ -352,32 +350,23 @@ public class Config {
|
||||
}
|
||||
}
|
||||
|
||||
private Object getInstance(Object instance, Class clazz) throws IllegalAccessException, InstantiationException {
|
||||
try {
|
||||
Field instanceField = clazz.getDeclaredField(clazz.getSimpleName());
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
return clazz.newInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the instance for a specific config node.
|
||||
*
|
||||
* @param split the node (split by period)
|
||||
* @return The instance or null
|
||||
*/
|
||||
private Object getInstance(String[] split, Class root) {
|
||||
private Object getInstance(String[] split, Class<?> root) {
|
||||
try {
|
||||
Class<?> clazz = root == null ? MethodHandles.lookup().lookupClass() : root;
|
||||
Object instance = this;
|
||||
while (split.length > 0) {
|
||||
switch (split.length) {
|
||||
case 1:
|
||||
if (split.length == 1) {
|
||||
return instance;
|
||||
default:
|
||||
Class found = null;
|
||||
}
|
||||
Class<?> found = null;
|
||||
Class<?>[] classes = clazz.getDeclaredClasses();
|
||||
for (Class current : classes) {
|
||||
for (Class<?> current : classes) {
|
||||
if (StringMan.isEqual(current.getSimpleName(), toFieldName(split[0]))) {
|
||||
found = current;
|
||||
break;
|
||||
@ -389,7 +378,7 @@ public class Config {
|
||||
if (instanceField.getType() != ConfigBlock.class) {
|
||||
Object value = instanceField.get(instance);
|
||||
if (value == null) {
|
||||
value = found.newInstance();
|
||||
value = found.getDeclaredConstructor().newInstance();
|
||||
instanceField.set(instance, value);
|
||||
}
|
||||
clazz = found;
|
||||
@ -404,7 +393,7 @@ public class Config {
|
||||
}
|
||||
instance = value.get(split[1]);
|
||||
if (instance == null) {
|
||||
instance = found.newInstance();
|
||||
instance = found.getDeclaredConstructor().newInstance();
|
||||
value.put(split[1], instance);
|
||||
}
|
||||
clazz = found;
|
||||
@ -415,12 +404,11 @@ public class Config {
|
||||
if (found != null) {
|
||||
split = Arrays.copyOfRange(split, 1, split.length);
|
||||
clazz = found;
|
||||
instance = clazz.newInstance();
|
||||
instance = clazz.getDeclaredConstructor().newInstance();
|
||||
continue;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -354,10 +354,10 @@ public class TextureUtil implements TextureHolder {
|
||||
LOGGER.info("Downloading asset jar from Mojang, please wait...");
|
||||
new File(Fawe.imp().getDirectory() + "/" + Settings.IMP.PATHS.TEXTURES + "/").mkdirs();
|
||||
try (BufferedInputStream in = new BufferedInputStream(
|
||||
new URL("https://launcher.mojang.com/v1/objects/8d9b65467c7913fcf6f5b2e729d44a1e00fde150/client.jar")
|
||||
new URL("https://launcher.mojang.com/v1/objects/d49eb6caed53d23927648c97451503442f9e26fd/client.jar")
|
||||
.openStream());
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(
|
||||
Fawe.imp().getDirectory() + "/" + Settings.IMP.PATHS.TEXTURES + "/1.17.1.jar")) {
|
||||
Fawe.imp().getDirectory() + "/" + Settings.IMP.PATHS.TEXTURES + "/1.18.jar")) {
|
||||
byte[] dataBuffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
|
||||
@ -370,6 +370,7 @@ public class TextureUtil implements TextureHolder {
|
||||
"folder with a `.minecraft/versions` jar in it.");
|
||||
LOGGER.error("If the file exists, please make sure the server has read access to the directory.");
|
||||
}
|
||||
//TODO 1.18 AccessControlException is deprecated and scheduled for removal as of Java 17. Exchange on sight to be prepared for future releases
|
||||
} catch (AccessControlException e) {
|
||||
LOGGER.error(
|
||||
"Could not download asset jar. It's likely your file permission are setup improperly and do not allow fetching data from the Mojang servers.");
|
||||
@ -811,10 +812,10 @@ public class TextureUtil implements TextureHolder {
|
||||
new File(Fawe.imp().getDirectory() + "/" + Settings.IMP.PATHS.TEXTURES + "/")
|
||||
.mkdirs();
|
||||
try (BufferedInputStream in = new BufferedInputStream(
|
||||
new URL("https://launcher.mojang.com/v1/objects/8d9b65467c7913fcf6f5b2e729d44a1e00fde150/client.jar")
|
||||
new URL("https://launcher.mojang.com/v1/objects/d49eb6caed53d23927648c97451503442f9e26fd/client.jar")
|
||||
.openStream());
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(
|
||||
Fawe.imp().getDirectory() + "/" + Settings.IMP.PATHS.TEXTURES + "/1.17.1.jar")) {
|
||||
Fawe.imp().getDirectory() + "/" + Settings.IMP.PATHS.TEXTURES + "/1.18.jar")) {
|
||||
byte[] dataBuffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
|
||||
|
@ -30,6 +30,7 @@ public class UpdateNotification {
|
||||
try {
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
//TODO 1.18 revisit and update to semver parsing after updating FaweVersion.java
|
||||
Document doc = db.parse(new URL("https://ci.athion.net/job/FastAsyncWorldEdit-1.17/api/xml/").openStream());
|
||||
faweVersion = doc.getElementsByTagName("lastSuccessfulBuild").item(0).getFirstChild().getTextContent();
|
||||
FaweVersion faweVersion = Fawe.get().getVersion();
|
||||
@ -42,8 +43,10 @@ public class UpdateNotification {
|
||||
hasUpdate = true;
|
||||
int versionDifference = Integer.parseInt(UpdateNotification.faweVersion) - faweVersion.build;
|
||||
LOGGER.warn(
|
||||
"An update for FastAsyncWorldEdit is available. You are {} build(s) out of date.\nYou are running " +
|
||||
"version {}, the latest version is {}-{}.\nUpdate at https://www.spigotmc.org/resources/13932/",
|
||||
"""
|
||||
An update for FastAsyncWorldEdit is available. You are {} build(s) out of date.
|
||||
You are running version {}, the latest version is {}-{}.
|
||||
Update at https://www.spigotmc.org/resources/13932/""",
|
||||
versionDifference,
|
||||
faweVersion.toString(),
|
||||
faweVersion.getSimpleVersionName(),
|
||||
|
@ -72,4 +72,11 @@ public final class Constants {
|
||||
*/
|
||||
public static final int DATA_VERSION_MC_1_17 = 2724;
|
||||
|
||||
//FAWE start - add data version for 1.18
|
||||
/**
|
||||
* The DataVersion for Minecraft 1.18
|
||||
*/
|
||||
public static final int DATA_VERSION_MC_1_18 = 2860;
|
||||
//FAWE end
|
||||
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren