Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
Show a message with install instructions when running the jar file
Co-Authored-By: Matthew Miller <mnmiller1@me.com>
Dieser Commit ist enthalten in:
Ursprung
bc686a611d
Commit
0b65533294
@ -37,6 +37,7 @@ fun Project.applyPlatformAndCoreConfiguration() {
|
||||
//options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" })
|
||||
options.isDeprecation = false
|
||||
options.encoding = "UTF-8"
|
||||
options.compilerArgs.add("-parameters")
|
||||
}
|
||||
|
||||
// configure<CheckstyleExtension> {
|
||||
@ -126,3 +127,29 @@ val CLASSPATH = listOf("truezip", "truevfs", "js")
|
||||
.map { "$it.jar" }
|
||||
.flatMap { listOf(it, "WorldEdit/$it") }
|
||||
.joinToString(separator = " ")
|
||||
|
||||
sealed class WorldEditKind(
|
||||
val name: String,
|
||||
val mainClass: String = "com.sk89q.worldedit.internal.util.InfoEntryPoint"
|
||||
) {
|
||||
class Standalone(mainClass: String) : WorldEditKind("STANDALONE", mainClass)
|
||||
object Mod : WorldEditKind("MOD")
|
||||
object Plugin : WorldEditKind("PLUGIN")
|
||||
}
|
||||
|
||||
fun Project.addJarManifest(kind: WorldEditKind, includeClasspath: Boolean = false) {
|
||||
tasks.named<Jar>("jar") {
|
||||
val version = project(":worldedit-core").version
|
||||
inputs.property("version", version)
|
||||
val attributes = mutableMapOf(
|
||||
"Implementation-Version" to version,
|
||||
"WorldEdit-Version" to version,
|
||||
"WorldEdit-Kind" to kind.name,
|
||||
"Main-Class" to kind.mainClass
|
||||
)
|
||||
if (includeClasspath) {
|
||||
attributes["Class-Path"] = CLASSPATH
|
||||
}
|
||||
manifest.attributes(attributes)
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,13 @@ Checks based on Google Checks, modified for EngineHub.
|
||||
<message key="ws.notFollowed"
|
||||
value="WhitespaceAround: ''{0}'' is not followed by whitespace. (4.1.3)"/>
|
||||
</module>
|
||||
<module name="NoWhitespaceBefore"/>
|
||||
<module name="NoWhitespaceBefore">
|
||||
<property name="tokens" value="COMMA, POST_INC, POST_DEC, ELLIPSIS, LABELED_STAT"/>
|
||||
</module>
|
||||
<module name="NoWhitespaceBefore">
|
||||
<property name="tokens" value="SEMI"/>
|
||||
<property name="allowLineBreaks" value="true"/>
|
||||
</module>
|
||||
<module name="OneStatementPerLine"/>
|
||||
<module name="MultipleVariableDeclarations"/>
|
||||
<module name="ArrayTypeStyle"/>
|
||||
|
@ -147,6 +147,8 @@ tasks.named<Jar>("jar") {
|
||||
}
|
||||
}
|
||||
|
||||
addJarManifest(WorldEditKind.Plugin, includeClasspath = true)
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
from(zipTree("src/main/resources/worldedit-adapters.jar").matching {
|
||||
exclude("META-INF/")
|
||||
|
@ -249,7 +249,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
@Override
|
||||
public boolean clearContainerBlockContents(BlockVector3 pt) {
|
||||
checkNotNull(pt);
|
||||
if (getBlock(pt).getBlockType().getMaterial().hasContainer()) {
|
||||
if (!getBlock(pt).getBlockType().getMaterial().hasContainer()) {
|
||||
return false;
|
||||
}
|
||||
Block block = getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
|
@ -7,6 +7,8 @@ plugins {
|
||||
applyPlatformAndCoreConfiguration()
|
||||
applyShadowConfiguration()
|
||||
|
||||
addJarManifest(WorldEditKind.Standalone("com.sk89q.worldedit.cli.CLIWorldEdit"))
|
||||
|
||||
dependencies {
|
||||
"api"(project(":worldedit-core"))
|
||||
"implementation"(platform("org.apache.logging.log4j:log4j-bom:2.14.0"))
|
||||
@ -17,15 +19,6 @@ dependencies {
|
||||
"implementation"("com.google.code.gson:gson")
|
||||
}
|
||||
|
||||
tasks.named<Jar>("jar") {
|
||||
manifest {
|
||||
attributes(
|
||||
"Implementation-Version" to project.version,
|
||||
"Main-Class" to "com.sk89q.worldedit.cli.CLIWorldEdit"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
dependencies {
|
||||
include { true }
|
||||
|
@ -34,11 +34,32 @@ import javax.annotation.Nullable;
|
||||
public class WorldEditManifest {
|
||||
|
||||
public static final String WORLD_EDIT_VERSION = "WorldEdit-Version";
|
||||
public static final String WORLD_EDIT_KIND = "WorldEdit-Kind";
|
||||
|
||||
public enum Kind {
|
||||
MOD("mods"),
|
||||
PLUGIN("plugins"),
|
||||
UNKNOWN("mods/plugins"),
|
||||
;
|
||||
|
||||
public final String folderName;
|
||||
|
||||
Kind(String folderName) {
|
||||
this.folderName = folderName;
|
||||
}
|
||||
}
|
||||
|
||||
public static WorldEditManifest load() {
|
||||
Attributes attributes = readAttributes();
|
||||
Kind kind;
|
||||
try {
|
||||
kind = Kind.valueOf(readAttribute(attributes, WORLD_EDIT_KIND, () -> "UNKNOWN"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
kind = Kind.UNKNOWN;
|
||||
}
|
||||
return new WorldEditManifest(
|
||||
readAttribute(attributes, WORLD_EDIT_VERSION, () -> "(unknown)")
|
||||
readAttribute(attributes, WORLD_EDIT_VERSION, () -> "(unknown)"),
|
||||
kind
|
||||
);
|
||||
}
|
||||
|
||||
@ -71,12 +92,18 @@ public class WorldEditManifest {
|
||||
}
|
||||
|
||||
private final String worldEditVersion;
|
||||
private final Kind worldEditKind;
|
||||
|
||||
private WorldEditManifest(String worldEditVersion) {
|
||||
private WorldEditManifest(String worldEditVersion, Kind worldEditKind) {
|
||||
this.worldEditVersion = worldEditVersion;
|
||||
this.worldEditKind = worldEditKind;
|
||||
}
|
||||
|
||||
public String getWorldEditVersion() {
|
||||
return worldEditVersion;
|
||||
}
|
||||
|
||||
public Kind getWorldEditKind() {
|
||||
return worldEditKind;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.internal.util;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditManifest;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextPane;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.text.html.HTMLDocument;
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
|
||||
public class InfoEntryPoint {
|
||||
|
||||
private static final String INSTALL_URL = "https://wiki.intellectualsites.com/FastAsyncWorldEdit";
|
||||
private static final String SUPPORT_URL = "https://discord.gg/intellectualsites";
|
||||
|
||||
private static String getMessage(boolean html) {
|
||||
WorldEditManifest manifest = WorldEditManifest.load();
|
||||
|
||||
return "To install FastAsyncWorldEdit, place it in the "
|
||||
+ manifest.getWorldEditKind().folderName + " folder.\n"
|
||||
+ "For more detailed instructions, see " + formatLink(INSTALL_URL, html) + "\n"
|
||||
+ "For further help, check out our support Discord at "
|
||||
+ formatLink(SUPPORT_URL, html) + "\n"
|
||||
+ "\n"
|
||||
+ "Version: " + manifest.getWorldEditVersion() + "\n";
|
||||
}
|
||||
|
||||
private static String formatLink(String url, boolean html) {
|
||||
return html ? String.format("<a href=\"%1$s\">%1$s</a>", url) : url;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (System.console() != null) {
|
||||
System.err.println(getMessage(false));
|
||||
} else {
|
||||
System.setProperty("awt.useSystemAAFontSettings", "lcd");
|
||||
JOptionPane.showMessageDialog(
|
||||
null,
|
||||
new NavigableEditorPane(getMessage(true)),
|
||||
"FastAsyncWorldEdit",
|
||||
JOptionPane.INFORMATION_MESSAGE
|
||||
);
|
||||
}
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
private static class NavigableEditorPane extends JTextPane {
|
||||
public NavigableEditorPane(String htmlBody) {
|
||||
super(new HTMLDocument());
|
||||
setEditorKit(new HTMLEditorKit());
|
||||
setText(htmlBody.replace("\n", "<br>"));
|
||||
setBackground(UIManager.getColor("Panel.background"));
|
||||
|
||||
addHyperlinkListener(e -> {
|
||||
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(e.getURL().toURI());
|
||||
} catch (IOException | URISyntaxException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
setEditable(false);
|
||||
setBorder(null);
|
||||
}
|
||||
}
|
||||
}
|
@ -91,7 +91,7 @@ tasks.named<Copy>("processResources") {
|
||||
from(project(":worldedit-core").tasks.named("processResources"))
|
||||
}
|
||||
|
||||
addJarManifest(includeClasspath = false)
|
||||
addJarManifest(WorldEditKind.Mod, includeClasspath = false)
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
dependencies {
|
||||
|
@ -26,7 +26,7 @@ dependencies {
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
addJarManifest(includeClasspath = true)
|
||||
addJarManifest(WorldEditKind.Mod, includeClasspath = true)
|
||||
=======
|
||||
tasks.named<Jar>("jar") {
|
||||
manifest {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren