From 69e82b5746c1eba0c4ca836700ec0ebc07579090 Mon Sep 17 00:00:00 2001 From: ZeroEpoch1969 <13510767+ZeroEpoch1969@users.noreply.github.com> Date: Mon, 21 May 2018 19:32:28 -0700 Subject: [PATCH] Remove updater fully and revert /tfm properly. --- .../totalfreedommod/TotalFreedomMod.java | 2 - .../totalfreedom/totalfreedommod/Updater.java | 103 ------------------ .../command/Command_totalfreedommod.java | 44 ++++---- 3 files changed, 23 insertions(+), 126 deletions(-) delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/Updater.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java index a6a1fc38..cf0b6375 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java @@ -93,7 +93,6 @@ public class TotalFreedomMod extends AeroPlugin public EntityWiper ew; public FrontDoor fd; public ServerPing sp; - public Updater ud; public ItemFun it; public Landminer lm; public MP44 mp; @@ -206,7 +205,6 @@ public class TotalFreedomMod extends AeroPlugin ew = services.registerService(EntityWiper.class); fd = services.registerService(FrontDoor.class); sp = services.registerService(ServerPing.class); - ud = services.registerService(Updater.class); pv = services.registerService(PlayerVerification.class); // Fun diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Updater.java b/src/main/java/me/totalfreedom/totalfreedommod/Updater.java deleted file mode 100644 index 00df8b61..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/Updater.java +++ /dev/null @@ -1,103 +0,0 @@ -package me.totalfreedom.totalfreedommod; - -import me.totalfreedom.totalfreedommod.util.FLog; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.lang.reflect.Method; -import java.net.URL; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; -import java.util.Scanner; - -/* - This class exists primarily due to the fact that it takes too long to get new builds onto the official - TotalFreedom server. If you wish to delete this class you may do so. -*/ - -public class Updater extends FreedomService -{ - - private final String UPDATE_SERVER_URL = "https://tfm.zeroepoch1969.rip"; - private final TotalFreedomMod.BuildProperties build = TotalFreedomMod.build; - public boolean updateAvailable = false; - - public Updater(TotalFreedomMod plugin) - { - super(plugin); - } - - @Override - protected void onStart() - { - if (build.number != null) - { - checkForUpdates(); - } - } - - @Override - protected void onStop() - { - } - - private void checkForUpdates() - { - try - { - URL url = new URL(UPDATE_SERVER_URL + "/build"); - String webBuild = new Scanner(url.openStream()).useDelimiter("\\Z").next(); - if (!build.number.equals(webBuild)) - { - updateAvailable = true; - } - FLog.info((updateAvailable ? "A new update is a available!" : "TFM is up-to-date!")); - - } - catch (IOException ex) - { - FLog.warning("Failed to connect to the update server."); - } - } - - - public void update() - { - try - { - URL url = new URL(UPDATE_SERVER_URL + "/TotalFreedomMod.jar"); - ReadableByteChannel input = Channels.newChannel(url.openStream()); - FileOutputStream output = new FileOutputStream(getFilePath()); - FLog.info("Downloading latest version..."); - output.getChannel().transferFrom(input, 0, Long.MAX_VALUE); - input.close(); - output.close(); - FLog.info("The latest version has been installed! Restart the server for changes to take effect."); - - } - catch (IOException ex) - { - FLog.severe(ex); - } - } - public String getFilePath() - { - try - { - Method method = JavaPlugin.class.getDeclaredMethod("getFile"); - boolean wasAccessible = method.isAccessible(); - method.setAccessible(true); - File file = (File) method.invoke(plugin); - method.setAccessible(wasAccessible); - - return file.getPath(); - } - catch (Exception e) - { - return "plugins" + File.separator + plugin.getName(); - } - } -} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java index 37cc8f60..d3c721af 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java @@ -5,7 +5,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.MainConfig; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FLog; -import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -24,41 +23,44 @@ public class Command_totalfreedommod extends FreedomCommand { if (args.length == 1) { - if (args[0].equals("reload")) + if (!args[0].equals("reload")) { - if (!plugin.al.isAdmin(sender)) - { - noPerms(); - return true; - } + return false; + } - plugin.config.load(); - plugin.services.stop(); - plugin.services.start(); - - final String message = String.format("%s v%s reloaded.", - TotalFreedomMod.pluginName, - TotalFreedomMod.pluginVersion); - - msg(message); - FLog.info(message); + if (!plugin.al.isAdmin(sender)) + { + noPerms(); return true; } + plugin.config.load(); + plugin.services.stop(); + plugin.services.start(); + + final String message = String.format("%s v%s reloaded.", + TotalFreedomMod.pluginName, + TotalFreedomMod.pluginVersion); + + msg(message); + FLog.info(message); + return true; + } + TotalFreedomMod.BuildProperties build = TotalFreedomMod.build; msg("TotalFreedomMod for 'Total Freedom', the original all-op server.", ChatColor.GOLD); msg("Running on " + ConfigEntry.SERVER_NAME.getString() + ".", ChatColor.GOLD); msg("Created by Madgeek1450 and Prozza.", ChatColor.GOLD); msg(String.format("Version " - + ChatColor.BLUE + "%s %s.%s " + ChatColor.GOLD + "(" - + ChatColor.BLUE + "%s" + ChatColor.GOLD + ")", + + ChatColor.BLUE + "%s %s.%s " + ChatColor.GOLD + "(" + + ChatColor.BLUE + "%s" + ChatColor.GOLD + ")", build.codename, build.version, build.number, build.head), ChatColor.GOLD); msg(String.format("Compiled " - + ChatColor.BLUE + "%s" + ChatColor.GOLD + " by " - + ChatColor.BLUE + "%s", + + ChatColor.BLUE + "%s" + ChatColor.GOLD + " by " + + ChatColor.BLUE + "%s", build.date, build.author), ChatColor.GOLD); msg("Visit " + ChatColor.AQUA + "http://github.com/TotalFreedom/TotalFreedomMod"