Remove update checker
This commit is contained in:
1 parent
4ffbd5e8b3
commit
1292debe80
7 files changed
+5
-95
No files matched your search
@@ -4,6 +4,7 @@ The [TrueOG Network](https://trueog.net) fork of [Duels](https://github.com/Real
|
||||
|
||||
Changes from Duels:
|
||||
|
||||
- Remove update checker by @NotAlexNoyle
|
||||
- Only start Duels from one world, configurable in config.yml by @NotAlexNoyle
|
||||
- Inventory loss bug fixes by @szumielxd
|
||||
- Essentials API NPE fix by @skbeh
|
||||
|
||||
@@ -50,7 +50,6 @@ import me.realized.duels.util.Loadable;
|
||||
import me.realized.duels.util.Log;
|
||||
import me.realized.duels.util.Log.LogSource;
|
||||
import me.realized.duels.util.Reloadable;
|
||||
import me.realized.duels.util.UpdateChecker;
|
||||
import me.realized.duels.util.command.AbstractCommand;
|
||||
import me.realized.duels.util.gui.GuiListener;
|
||||
import me.realized.duels.util.json.JsonUtil;
|
||||
@@ -65,7 +64,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class DuelsPlugin extends JavaPlugin implements Duels, LogSource {
|
||||
|
||||
private static final int BSTATS_ID = 2696;
|
||||
private static final int RESOURCE_ID = 20171;
|
||||
private static final String SPIGOT_INSTALLATION_URL = "https://www.spigotmc.org/wiki/spigot-installation/";
|
||||
|
||||
@Getter
|
||||
@@ -116,11 +114,6 @@ public class DuelsPlugin extends JavaPlugin implements Duels, LogSource {
|
||||
private final Map<String, AbstractCommand<DuelsPlugin>> commands = new HashMap<>();
|
||||
private final List<Listener> registeredListeners = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
private volatile boolean updateAvailable;
|
||||
@Getter
|
||||
private volatile String newVersion;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
@@ -187,25 +180,6 @@ public class DuelsPlugin extends JavaPlugin implements Duels, LogSource {
|
||||
new LingerPotionListener(this);
|
||||
|
||||
new Metrics(this, BSTATS_ID);
|
||||
|
||||
if (!configuration.isCheckForUpdates()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final UpdateChecker updateChecker = new UpdateChecker(this, RESOURCE_ID);
|
||||
updateChecker.check((hasUpdate, newVersion) -> {
|
||||
if (hasUpdate) {
|
||||
DuelsPlugin.this.updateAvailable = true;
|
||||
DuelsPlugin.this.newVersion = newVersion;
|
||||
Log.info("===============================================");
|
||||
Log.info("An update for " + getName() + " is available!");
|
||||
Log.info("Download " + getName() + " v" + newVersion + " here:");
|
||||
Log.info(getDescription().getWebsite());
|
||||
Log.info("===============================================");
|
||||
} else {
|
||||
Log.info("No updates were available. You are on the latest version!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,8 +18,6 @@ public class Config extends AbstractConfiguration<DuelsPlugin> {
|
||||
|
||||
@Getter
|
||||
private int version;
|
||||
@Getter
|
||||
private boolean checkForUpdates;
|
||||
|
||||
@Getter
|
||||
private boolean ctpPreventDuel;
|
||||
@@ -122,8 +120,6 @@ public class Config extends AbstractConfiguration<DuelsPlugin> {
|
||||
@Getter
|
||||
private boolean cancelIfMoved;
|
||||
@Getter
|
||||
private String enabledWorld;
|
||||
@Getter
|
||||
private List<String> blacklistedWorlds;
|
||||
@Getter
|
||||
private boolean teleportToLastLocation;
|
||||
@@ -266,7 +262,6 @@ public class Config extends AbstractConfiguration<DuelsPlugin> {
|
||||
}
|
||||
|
||||
version = configuration.getInt("config-version");
|
||||
checkForUpdates = configuration.getBoolean("check-for-updates", true);
|
||||
|
||||
ctpPreventDuel = configuration.getBoolean("supported-plugins.CombatTagPlus.prevent-duel-if-tagged", true);
|
||||
ctpPreventTag = configuration.getBoolean("supported-plugins.CombatTagPlus.prevent-tag-in-duel", true);
|
||||
@@ -319,10 +314,6 @@ public class Config extends AbstractConfiguration<DuelsPlugin> {
|
||||
preventTpToMatchPlayers = configuration.getBoolean("duel.prevent-teleport-to-match-players", true);
|
||||
forceAllowCombat = configuration.getBoolean("duel.force-allow-combat", true);
|
||||
cancelIfMoved = configuration.getBoolean("duel.cancel-if-moved", false);
|
||||
final String configuredEnabledWorld = configuration.getString("duel.enabled-world", "world");
|
||||
enabledWorld = configuredEnabledWorld != null && !configuredEnabledWorld.trim().isEmpty()
|
||||
? configuredEnabledWorld.trim()
|
||||
: "world";
|
||||
blacklistedWorlds = configuration.getStringList("duel.blacklisted-worlds");
|
||||
teleportToLastLocation = configuration.getBoolean("duel.teleport-to-last-location", false);
|
||||
teleportDelay = configuration.getInt("duel.teleport-delay", 5);
|
||||
@@ -422,7 +413,7 @@ public class Config extends AbstractConfiguration<DuelsPlugin> {
|
||||
|
||||
public boolean isDuelingWorld(final Player player) {
|
||||
return player != null && player.getWorld() != null
|
||||
&& enabledWorld.equalsIgnoreCase(player.getWorld().getName());
|
||||
&& "world".equals(player.getWorld().getName());
|
||||
}
|
||||
|
||||
public class MessageSound {
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.Getter;
|
||||
import me.realized.duels.DuelsPlugin;
|
||||
import me.realized.duels.Permissions;
|
||||
import me.realized.duels.api.event.user.UserCreateEvent;
|
||||
import me.realized.duels.api.kit.Kit;
|
||||
import me.realized.duels.api.user.User;
|
||||
@@ -28,7 +27,6 @@ import me.realized.duels.config.Lang;
|
||||
import me.realized.duels.util.DateUtil;
|
||||
import me.realized.duels.util.Loadable;
|
||||
import me.realized.duels.util.Log;
|
||||
import me.realized.duels.util.StringUtil;
|
||||
import me.realized.duels.util.UUIDUtil;
|
||||
import me.realized.duels.util.json.JsonUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -42,8 +40,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class UserManagerImpl implements Loadable, Listener, UserManager {
|
||||
|
||||
private static final String ADMIN_UPDATE_MESSAGE = "&9[Duels] &bDuels &fv%s &7is now available for download! Download at: &c%s";
|
||||
|
||||
private final DuelsPlugin plugin;
|
||||
private final Config config;
|
||||
private final Lang lang;
|
||||
@@ -292,12 +288,6 @@ public class UserManagerImpl implements Loadable, Listener, UserManager {
|
||||
public void on(final PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
plugin.doSyncAfter(() -> {
|
||||
if (plugin.isUpdateAvailable() && (player.isOp() || player.hasPermission(Permissions.ADMIN))) {
|
||||
player.sendMessage(StringUtil.color(String.format(ADMIN_UPDATE_MESSAGE, plugin.getNewVersion(), plugin.getDescription().getWebsite())));
|
||||
}
|
||||
}, 5L);
|
||||
|
||||
final UserData user = users.get(player.getUniqueId());
|
||||
|
||||
if (user != null) {
|
||||
|
||||
@@ -103,7 +103,7 @@ public class PlayerInfoManager implements Loadable {
|
||||
this.lobby = getFallbackLocation();
|
||||
final World world = this.lobby != null ? this.lobby.getWorld() : null;
|
||||
Log.warn(this,
|
||||
String.format(ERROR_LOBBY_DEFAULT, world != null ? world.getName() : config.getEnabledWorld()));
|
||||
String.format(ERROR_LOBBY_DEFAULT, world != null ? world.getName() : "world"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,11 +211,11 @@ public class PlayerInfoManager implements Loadable {
|
||||
|
||||
private boolean isEnabledWorld(final Location location) {
|
||||
return location != null && location.getWorld() != null
|
||||
&& config.getEnabledWorld().equalsIgnoreCase(location.getWorld().getName());
|
||||
&& "world".equals(location.getWorld().getName());
|
||||
}
|
||||
|
||||
private Location getFallbackLocation() {
|
||||
World world = Bukkit.getWorld(config.getEnabledWorld());
|
||||
World world = Bukkit.getWorld("world");
|
||||
|
||||
if (world == null && !Bukkit.getWorlds().isEmpty()) {
|
||||
world = Bukkit.getWorlds().get(0);
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package me.realized.duels.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.function.BiConsumer;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public final class UpdateChecker {
|
||||
|
||||
private static final String API_URL = "https://api.spigotmc.org/legacy/update.php?resource=%s";
|
||||
|
||||
private final Plugin plugin;
|
||||
private final int id;
|
||||
|
||||
public UpdateChecker(final Plugin plugin, final int id) {
|
||||
this.plugin = plugin;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void check(final BiConsumer<Boolean, String> callback) {
|
||||
final String currentVersion = plugin.getDescription().getVersion();
|
||||
|
||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(String.format(API_URL, id)).openStream()))) {
|
||||
final String latestVersion = reader.readLine();
|
||||
|
||||
if (latestVersion == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean updateAvailable = NumberUtil.isLower(currentVersion, latestVersion);
|
||||
callback.accept(updateAvailable, updateAvailable ? latestVersion : currentVersion);
|
||||
} catch (IOException ignored) {}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,6 @@
|
||||
# DO NOT EDIT THIS VALUE!
|
||||
config-version: 12
|
||||
|
||||
# If set to 'true', a notification and a download link will be printed on both console and in-game when a new update is available.
|
||||
# default: true
|
||||
check-for-updates: true
|
||||
|
||||
|
||||
# NOTE: The following options will only activate if the message '[Duels] Hooked into <plugin name>!' is displayed on console.
|
||||
# If the plugin in the following list is enabled on your server but Duels fails to hook into them,
|
||||
@@ -231,10 +227,6 @@ duel:
|
||||
# default: false
|
||||
cancel-if-moved: false
|
||||
|
||||
# Only allow duels to be started from this world.
|
||||
# default: world
|
||||
enabled-world: 'world'
|
||||
|
||||
# List of worlds to disable dueling.
|
||||
blacklisted-worlds:
|
||||
- 'world_name_here'
|
||||
|
||||
Reference in new issue
Block a user