mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Remove update and changelog commands
This commit is contained in:
parent
7302480728
commit
e47b4fef20
@ -73,7 +73,6 @@ import java.util.zip.ZipInputStream;
|
|||||||
// Implementation logger
|
// Implementation logger
|
||||||
@Setter @Getter private ILogger logger;
|
@Setter @Getter private ILogger logger;
|
||||||
// Platform / Version / Update URL
|
// Platform / Version / Update URL
|
||||||
@Getter private Updater updater;
|
|
||||||
private PlotVersion version;
|
private PlotVersion version;
|
||||||
// Files and configuration
|
// Files and configuration
|
||||||
@Getter private File jarFile = null; // This file
|
@Getter private File jarFile = null; // This file
|
||||||
|
@ -1,82 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
|
||||||
|
|
||||||
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 {
|
|
||||||
|
|
||||||
PlotVersion newVersion;
|
|
||||||
private String changes;
|
|
||||||
|
|
||||||
public String getChanges() {
|
|
||||||
if (changes == null) {
|
|
||||||
try (Scanner scanner = new Scanner(new URL("http://empcraft.com/plots/cl?" + Integer
|
|
||||||
.toHexString(PlotSquared.get().getVersion().hash)).openStream(), "UTF-8")) {
|
|
||||||
changes = scanner.useDelimiter("\\A").next();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return changes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOutdated() {
|
|
||||||
return newVersion != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*public void update(String platform, PlotVersion currentVersion) {
|
|
||||||
if (currentVersion == null || platform == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
String downloadUrl =
|
|
||||||
"https://ci.athion.net/job/PlotSquared/lastSuccessfulBuild/artifact/target/PlotSquared-%platform%-%version%.jar";
|
|
||||||
String versionUrl = "http://empcraft.com/plots/version.php?%platform%";
|
|
||||||
URL url = new URL(versionUrl.replace("%platform%", platform));
|
|
||||||
try (Scanner reader = new Scanner(url.openStream())) {
|
|
||||||
String versionString = reader.next();
|
|
||||||
PlotVersion version = new PlotVersion(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 = PlotSquared.get().getJarFile();
|
|
||||||
|
|
||||||
File finalFile = new File(jarFile.getParent(),
|
|
||||||
"update" + File.separator + jarFile.getName());
|
|
||||||
File outFile = new File(jarFile.getParent(),
|
|
||||||
"update" + 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);
|
|
||||||
PlotSquared.debug("Updated PlotSquared to " + versionString);
|
|
||||||
MainUtil.sendAdmin(
|
|
||||||
"&7Restart to update PlotSquared with these changes: &c/plot changelog &7or&c "
|
|
||||||
+ "http://empcraft.com/plots/cl?" + Integer
|
|
||||||
.toHexString(currentVersion.hash));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable ignore) {
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.Updater;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
@CommandDeclaration(command = "changelog", permission = "plots.admin.command.changelog",
|
|
||||||
description = "View the changelog", usage = "/plot changelog", requiredType = RequiredType.NONE,
|
|
||||||
aliases = {"cl"}, category = CommandCategory.ADMINISTRATION) public class Changelog
|
|
||||||
extends SubCommand {
|
|
||||||
|
|
||||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
|
||||||
try {
|
|
||||||
Updater updater = PlotSquared.get().getUpdater();
|
|
||||||
String changes = updater != null ? updater.getChanges() : null;
|
|
||||||
if (changes == null) {
|
|
||||||
try (Scanner scanner = new Scanner(new URL("http://empcraft.com/plots/cl?" + Integer
|
|
||||||
.toHexString(PlotSquared.get().getVersion().hash)).openStream(), "UTF-8")) {
|
|
||||||
changes = scanner.useDelimiter("\\A").next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
changes = changes
|
|
||||||
.replaceAll("#([0-9]+)", "github.com/IntellectualSites/PlotSquared/pulls/$1");
|
|
||||||
MainUtil.sendMessage(player, changes);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -36,7 +36,6 @@ public class MainCommand extends Command {
|
|||||||
new Confirm();
|
new Confirm();
|
||||||
new Template();
|
new Template();
|
||||||
new Download();
|
new Download();
|
||||||
new Changelog();
|
|
||||||
new Template();
|
new Template();
|
||||||
new Setup();
|
new Setup();
|
||||||
new Area();
|
new Area();
|
||||||
|
Loading…
Reference in New Issue
Block a user