geforkt von Mirrors/FastAsyncWorldEdit
Remove auto updater and minors
- Remove Changelog command - Remove Auto updater
Dieser Commit ist enthalten in:
Ursprung
699783ba72
Commit
cb482ccbd5
@ -84,7 +84,6 @@ public class Fawe {
|
|||||||
private final FaweTimer timer;
|
private final FaweTimer timer;
|
||||||
private FaweVersion version;
|
private FaweVersion version;
|
||||||
private VisualQueue visualQueue;
|
private VisualQueue visualQueue;
|
||||||
private Updater updater;
|
|
||||||
private TextureUtil textures;
|
private TextureUtil textures;
|
||||||
private DefaultTransformParser transformParser;
|
private DefaultTransformParser transformParser;
|
||||||
private ChatManager chatManager = new PlainChatManager();
|
private ChatManager chatManager = new PlainChatManager();
|
||||||
@ -212,13 +211,6 @@ public class Fawe {
|
|||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
TaskManager.IMP.repeat(timer, 1);
|
TaskManager.IMP.repeat(timer, 1);
|
||||||
|
|
||||||
if (!Settings.IMP.UPDATE.equalsIgnoreCase("false")) {
|
|
||||||
// Delayed updating
|
|
||||||
updater = new Updater();
|
|
||||||
TaskManager.IMP.async(this::update);
|
|
||||||
TaskManager.IMP.repeatAsync(this::update, 36000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
@ -227,14 +219,6 @@ public class Fawe {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean update() {
|
|
||||||
if (updater != null) {
|
|
||||||
updater.getUpdate(IMP.getPlatform(), getVersion());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CUI getCUI(Actor actor) {
|
public CUI getCUI(Actor actor) {
|
||||||
FawePlayer<Object> fp = FawePlayer.wrap(actor);
|
FawePlayer<Object> fp = FawePlayer.wrap(actor);
|
||||||
CUI cui = fp.getMeta("CUI");
|
CUI cui = fp.getMeta("CUI");
|
||||||
@ -272,16 +256,6 @@ public class Fawe {
|
|||||||
return transformParser;
|
return transformParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The FAWE updater class
|
|
||||||
* - Use to get basic update information (changelog/version etc)
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Updater getUpdater() {
|
|
||||||
return updater;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextureUtil getCachedTextureUtil(boolean randomize, int min, int max) {
|
public TextureUtil getCachedTextureUtil(boolean randomize, int min, int max) {
|
||||||
TextureUtil tu = getTextureUtil();
|
TextureUtil tu = getTextureUtil();
|
||||||
try {
|
try {
|
||||||
|
@ -124,10 +124,6 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
if (Settings.IMP.CLIPBOARD.USE_DISK) {
|
if (Settings.IMP.CLIPBOARD.USE_DISK) {
|
||||||
loadClipboardFromDisk();
|
loadClipboardFromDisk();
|
||||||
}
|
}
|
||||||
Updater updater = Fawe.get().getUpdater();
|
|
||||||
if (updater != null && updater.hasPending(this)) {
|
|
||||||
TaskManager.IMP.async(() -> updater.confirmUpdate(this));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int cancel(boolean close) {
|
public int cancel(boolean close) {
|
||||||
|
@ -1,128 +0,0 @@
|
|||||||
package com.boydti.fawe.util;
|
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
|
||||||
import com.boydti.fawe.FaweVersion;
|
|
||||||
import com.boydti.fawe.config.Settings;
|
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
|
||||||
import com.boydti.fawe.util.chat.Message;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.channels.Channels;
|
|
||||||
import java.nio.channels.ReadableByteChannel;
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
public class Updater {
|
|
||||||
private FaweVersion newVersion;
|
|
||||||
private String changes;
|
|
||||||
|
|
||||||
private volatile boolean pending;
|
|
||||||
private File pendingFile, destFile;
|
|
||||||
private String versionString;
|
|
||||||
|
|
||||||
public synchronized String getChanges() {
|
|
||||||
if (changes == null) {
|
|
||||||
try (Scanner scanner = new Scanner(new URL("https://empcraft.com/fawe/cl?" + Integer.toHexString(Fawe.get().getVersion().hash)).openStream(), "UTF-8")) {
|
|
||||||
changes = scanner.useDelimiter("\\A").next();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return changes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean isOutdated() {
|
|
||||||
return newVersion != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasPending(FawePlayer fp) {
|
|
||||||
return (pending && fp.hasPermission("fawe.admin"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void confirmUpdate(FawePlayer fp) {
|
|
||||||
if (pending && fp.hasPermission("fawe.admin")) {
|
|
||||||
Fawe.debug("Updated FAWE to " + versionString + " @ " + pendingFile);
|
|
||||||
String url = "https://empcraft.com/fawe/cl?" + Integer.toHexString(Fawe.get().getVersion().hash);
|
|
||||||
new Message().prefix().text("A FAWE update is available:")
|
|
||||||
.text("\n&8 - &a/fawe update &8 - &7Updates the plugin and restarts the server to apply the changes")
|
|
||||||
.cmdTip("fawe update")
|
|
||||||
.text("\n&8 - &a/fawe changelog")
|
|
||||||
.cmdTip("fawe changelog")
|
|
||||||
.text("&8 - &7( &9&o" + url + " &7)")
|
|
||||||
.link(url)
|
|
||||||
.send(fp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean installUpdate(FawePlayer fp) {
|
|
||||||
if (pending && (fp == null || fp.hasPermission("fawe.admin")) && pendingFile.exists()) {
|
|
||||||
pending = false;
|
|
||||||
File outFileParent = destFile.getParentFile();
|
|
||||||
if (!outFileParent.exists()) {
|
|
||||||
outFileParent.mkdirs();
|
|
||||||
}
|
|
||||||
pendingFile.renameTo(destFile);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void getUpdate(String platform, FaweVersion currentVersion) {
|
|
||||||
if (currentVersion == null || platform == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
String downloadUrl = "https://ci.athion.net/job/FastAsyncWorldEdit/lastSuccessfulBuild/artifact/target/FastAsyncWorldEdit-%platform%-%version%.jar";
|
|
||||||
String versionUrl = "https://empcraft.com/fawe/version.php?%platform%";
|
|
||||||
URL url = new URL(versionUrl.replace("%platform%", platform));
|
|
||||||
try (Scanner reader = new Scanner(url.openStream())) {
|
|
||||||
this.versionString = reader.next();
|
|
||||||
FaweVersion version = new FaweVersion(versionString);
|
|
||||||
if (version.isNewer(newVersion != null ? newVersion : currentVersion)) {
|
|
||||||
newVersion = version;
|
|
||||||
URL download = new URL(downloadUrl.replaceAll("%platform%", platform).replaceAll("%version%", versionString));
|
|
||||||
try (ReadableByteChannel rbc = Channels.newChannel(download.openStream())) {
|
|
||||||
File jarFile = MainUtil.getJarFile();
|
|
||||||
|
|
||||||
File finalFile = new File(jarFile.getParent(), "update-confirm" + File.separator + jarFile.getName());
|
|
||||||
File outFile = new File(jarFile.getParent(), "update-confirm" + File.separator + jarFile.getName().replace(".jar", ".part"));
|
|
||||||
boolean exists = outFile.exists();
|
|
||||||
if (exists) {
|
|
||||||
outFile.delete();
|
|
||||||
} else {
|
|
||||||
File outFileParent = outFile.getParentFile();
|
|
||||||
if (!outFileParent.exists()) {
|
|
||||||
outFileParent.mkdirs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try (FileOutputStream fos = new FileOutputStream(outFile)) {
|
|
||||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
|
||||||
}
|
|
||||||
outFile.renameTo(finalFile);
|
|
||||||
|
|
||||||
if (Settings.IMP.UPDATE.equalsIgnoreCase("true")) {
|
|
||||||
pending = true;
|
|
||||||
pendingFile = finalFile;
|
|
||||||
destFile = new File(jarFile.getParent(), "update" + File.separator + jarFile.getName());
|
|
||||||
|
|
||||||
installUpdate(null);
|
|
||||||
Fawe.debug("Updated FAWE to " + versionString + " @ " + pendingFile);
|
|
||||||
MainUtil.sendAdmin("&a/restart&7 to update FAWE with these changes: &c/fawe changelog &7or&c " + "https://empcraft.com/fawe/cl?" + Integer.toHexString(currentVersion.hash));
|
|
||||||
} else if (!Settings.IMP.UPDATE.equalsIgnoreCase("false")) {
|
|
||||||
pendingFile = finalFile;
|
|
||||||
destFile = new File(jarFile.getParent(), "update" + File.separator + jarFile.getName());
|
|
||||||
pending = true;
|
|
||||||
|
|
||||||
for (final FawePlayer<?> player : Fawe.get().getCachedPlayers()) {
|
|
||||||
confirmUpdate(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable ignore) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -84,14 +84,6 @@ public class WorldEditCommands {
|
|||||||
actor.printDebug(" - COMMIT: " + Integer.toHexString(version.hash));
|
actor.printDebug(" - COMMIT: " + Integer.toHexString(version.hash));
|
||||||
actor.printDebug(" - BUILD: #" + version.build);
|
actor.printDebug(" - BUILD: #" + version.build);
|
||||||
actor.printDebug(" - PLATFORM: " + Settings.IMP.PLATFORM);
|
actor.printDebug(" - PLATFORM: " + Settings.IMP.PLATFORM);
|
||||||
Updater updater = Fawe.get().getUpdater();
|
|
||||||
if (updater == null) {
|
|
||||||
actor.printDebug(" - UPDATES: DISABLED");
|
|
||||||
} else if (updater.isOutdated()) {
|
|
||||||
actor.printDebug(" - UPDATES: " + updater.getChanges().split("\n").length + " (see /fawe cl)");
|
|
||||||
} else {
|
|
||||||
actor.printDebug(" - UPDATES: Latest Version");
|
|
||||||
}
|
|
||||||
actor.printDebug("------------------------------------");
|
actor.printDebug("------------------------------------");
|
||||||
}
|
}
|
||||||
PlatformManager pm = we.getPlatformManager();
|
PlatformManager pm = we.getPlatformManager();
|
||||||
@ -124,72 +116,6 @@ public class WorldEditCommands {
|
|||||||
actor.print(BBC.getPrefix() + "Reloaded WorldEdit " + we.getVersion() + " and FAWE (" + Fawe.get().getVersion() + ")");
|
actor.print(BBC.getPrefix() + "Reloaded WorldEdit " + we.getVersion() + " and FAWE (" + Fawe.get().getVersion() + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = {"update"},
|
|
||||||
usage = "",
|
|
||||||
desc = "Update the plugin",
|
|
||||||
min = 0,
|
|
||||||
max = 0
|
|
||||||
)
|
|
||||||
public void update(FawePlayer fp) throws WorldEditException {
|
|
||||||
if (Fawe.get().getUpdater().installUpdate(fp)) {
|
|
||||||
TaskManager.IMP.sync(() -> {
|
|
||||||
fp.executeCommand("restart");
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
fp.sendMessage(BBC.getPrefix() + "Please restart to finish installing the update");
|
|
||||||
} else {
|
|
||||||
fp.sendMessage(BBC.getPrefix() + "No update is pending");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = {"changelog", "cl"},
|
|
||||||
usage = "",
|
|
||||||
desc = "View the FAWE changelog",
|
|
||||||
min = 0,
|
|
||||||
max = 0
|
|
||||||
)
|
|
||||||
@CommandPermissions("worldedit.changelog")
|
|
||||||
public void changelog(Actor actor) throws WorldEditException {
|
|
||||||
try {
|
|
||||||
Updater updater = Fawe.get().getUpdater();
|
|
||||||
String changes = updater != null ? updater.getChanges() : null;
|
|
||||||
|
|
||||||
String url = "https://empcraft.com/fawe/cl?" + Integer.toHexString(Fawe.get().getVersion().hash);
|
|
||||||
if (changes == null) {
|
|
||||||
try (Scanner scanner = new Scanner(new URL(url).openStream(), "UTF-8")) {
|
|
||||||
changes = scanner.useDelimiter("\\A").next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
changes = changes.replaceAll("#([0-9]+)", "github.com/boy0001/FastAsyncWorldedit/issues/$1");
|
|
||||||
|
|
||||||
String[] split = changes.substring(1).split("[\n](?! )");
|
|
||||||
if (changes.length() <= 1) actor.print(BBC.getPrefix() + "No description available");
|
|
||||||
else {
|
|
||||||
StringBuilder msg = new StringBuilder();
|
|
||||||
msg.append(BBC.getPrefix() + split.length + " commits:");
|
|
||||||
for (String change : split) {
|
|
||||||
String[] split2 = change.split("\n ");
|
|
||||||
msg.append("\n&a&l" + split2[0]);
|
|
||||||
if (split2.length != 0) {
|
|
||||||
for (int i = 1; i < split2.length; i++) {
|
|
||||||
msg.append('\n');
|
|
||||||
String[] split3 = split2[i].split("\n");
|
|
||||||
String subChange = "&8 - &7" + StringMan.join(split3, "\n&7 ");
|
|
||||||
msg.append(subChange);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
msg.append("\n&7More info: &9&o" + url);
|
|
||||||
msg.append("\n&7Discuss: &9&ohttps://discord.gg/ngZCzbU");
|
|
||||||
actor.print(BBC.color(msg.toString()));
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"debugpaste"},
|
aliases = {"debugpaste"},
|
||||||
usage = "",
|
usage = "",
|
||||||
@ -224,28 +150,6 @@ public class WorldEditCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Command(aliases = {"report"}, desc = "Writes a report on WorldEdit", flags = "p", max = 0)
|
|
||||||
// @CommandPermissions({"worldedit.report"})
|
|
||||||
// public void report(Actor actor, CommandContext args) throws WorldEditException {
|
|
||||||
// ReportList report = new ReportList("Report");
|
|
||||||
// report.add(new SystemInfoReport());
|
|
||||||
// report.add(new ConfigReport());
|
|
||||||
// String result = report.toString();
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// File dest = new File(we.getWorkingDirectoryFile(we.getConfiguration().saveDir), "report.txt");
|
|
||||||
// Files.write(result, dest, Charset.forName("UTF-8"));
|
|
||||||
// actor.print("WorldEdit report written to " + dest.getAbsolutePath());
|
|
||||||
// } catch (IOException e) {
|
|
||||||
// actor.printError("Failed to write report: " + e.getMessage());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (args.hasFlag('p')) {
|
|
||||||
// actor.checkPermission("worldedit.report.pastebin");
|
|
||||||
// ActorCallbackPaste.pastebin(we.getSupervisor(), actor, result, "WorldEdit report: %s.report");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"cui"},
|
aliases = {"cui"},
|
||||||
usage = "",
|
usage = "",
|
||||||
|
@ -2086,13 +2086,6 @@ WorldEditCommands:
|
|||||||
- tz
|
- tz
|
||||||
usage: '[tiempo de la zona]'
|
usage: '[tiempo de la zona]'
|
||||||
desc: Establecer tu zona horaria para snapshots
|
desc: Establecer tu zona horaria para snapshots
|
||||||
changelog:
|
|
||||||
help: ''
|
|
||||||
aliases:
|
|
||||||
- changelog
|
|
||||||
- cl
|
|
||||||
usage: ''
|
|
||||||
desc: Ver el registro de cambios de FAWE
|
|
||||||
debugpaste:
|
debugpaste:
|
||||||
help: ''
|
help: ''
|
||||||
aliases:
|
aliases:
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren