diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java index e08dd718e..301a05efa 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java @@ -73,7 +73,6 @@ import java.util.zip.ZipInputStream; // Implementation logger @Setter @Getter private ILogger logger; // Platform / Version / Update URL - @Getter private Updater updater; private PlotVersion version; // Files and configuration @Getter private File jarFile = null; // This file diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/Updater.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/Updater.java deleted file mode 100644 index 4132508a0..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/Updater.java +++ /dev/null @@ -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) { - } - }*/ -} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Changelog.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Changelog.java deleted file mode 100644 index 829e34380..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Changelog.java +++ /dev/null @@ -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; - } - -} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java index a68681d7a..0e1630e76 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java @@ -36,7 +36,6 @@ public class MainCommand extends Command { new Confirm(); new Template(); new Download(); - new Changelog(); new Template(); new Setup(); new Area();