mirror of
https://github.com/JamesPeters98/ChestsPlusPlus.git
synced 2025-02-13 19:12:07 +01:00
Update Checker Periodic
This commit is contained in:
parent
94547d6bc4
commit
dd99b8d854
@ -4,6 +4,9 @@ import com.jamesdpeters.minecraft.chests.commands.RemoteChestCommand;
|
|||||||
import com.jamesdpeters.minecraft.chests.listeners.ChestLinkListener;
|
import com.jamesdpeters.minecraft.chests.listeners.ChestLinkListener;
|
||||||
import com.jamesdpeters.minecraft.chests.listeners.HopperListener;
|
import com.jamesdpeters.minecraft.chests.listeners.HopperListener;
|
||||||
import com.jamesdpeters.minecraft.chests.listeners.InventoryListener;
|
import com.jamesdpeters.minecraft.chests.listeners.InventoryListener;
|
||||||
|
import com.jamesdpeters.minecraft.chests.misc.Config;
|
||||||
|
import com.jamesdpeters.minecraft.chests.misc.Settings;
|
||||||
|
import com.jamesdpeters.minecraft.chests.misc.Stats;
|
||||||
import com.jamesdpeters.minecraft.chests.serialize.InventoryStorage;
|
import com.jamesdpeters.minecraft.chests.serialize.InventoryStorage;
|
||||||
import com.jamesdpeters.minecraft.chests.serialize.LinkedChest;
|
import com.jamesdpeters.minecraft.chests.serialize.LinkedChest;
|
||||||
import com.jamesdpeters.minecraft.chests.versionchecker.UpdateCheck;
|
import com.jamesdpeters.minecraft.chests.versionchecker.UpdateCheck;
|
||||||
@ -13,13 +16,13 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class ChestsPlusPlus extends JavaPlugin {
|
public class ChestsPlusPlus extends JavaPlugin {
|
||||||
|
|
||||||
public static JavaPlugin PLUGIN;
|
public static JavaPlugin PLUGIN;
|
||||||
public static InventoryManager INVENTORY_MANAGER;
|
public static InventoryManager INVENTORY_MANAGER;
|
||||||
|
private static boolean boot = false;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ConfigurationSerialization.registerClass(LinkedChest.class, "LinkedChest");
|
ConfigurationSerialization.registerClass(LinkedChest.class, "LinkedChest");
|
||||||
@ -30,6 +33,7 @@ public class ChestsPlusPlus extends JavaPlugin {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
int pluginId = 7166;
|
int pluginId = 7166;
|
||||||
Metrics metrics = new Metrics(this, pluginId);
|
Metrics metrics = new Metrics(this, pluginId);
|
||||||
|
Stats.addCharts(metrics);
|
||||||
|
|
||||||
Settings.initConfig(this);
|
Settings.initConfig(this);
|
||||||
|
|
||||||
@ -46,10 +50,10 @@ public class ChestsPlusPlus extends JavaPlugin {
|
|||||||
|
|
||||||
if(Settings.isUpdateCheckEnabled()) {
|
if(Settings.isUpdateCheckEnabled()) {
|
||||||
String SPIGOT_URL = "https://www.spigotmc.org/resources/chests-chest-linking-hopper-filtering-remote-chests-menus.71355/";
|
String SPIGOT_URL = "https://www.spigotmc.org/resources/chests-chest-linking-hopper-filtering-remote-chests-menus.71355/";
|
||||||
UpdateCheck
|
UpdateCheck updateChecker = UpdateCheck
|
||||||
.of(this)
|
.of(this)
|
||||||
.resourceId(71355)
|
.resourceId(71355)
|
||||||
.currentVersion("1.15 v1.2.2")
|
.currentVersion(getDescription().getVersion())
|
||||||
.handleResponse((versionResponse, version) -> {
|
.handleResponse((versionResponse, version) -> {
|
||||||
switch (versionResponse) {
|
switch (versionResponse) {
|
||||||
case FOUND_NEW:
|
case FOUND_NEW:
|
||||||
@ -58,13 +62,14 @@ public class ChestsPlusPlus extends JavaPlugin {
|
|||||||
Bukkit.broadcastMessage(ChatColor.RED + "[Chests++] New version of the plugin was found: " + version);
|
Bukkit.broadcastMessage(ChatColor.RED + "[Chests++] New version of the plugin was found: " + version);
|
||||||
break;
|
break;
|
||||||
case LATEST:
|
case LATEST:
|
||||||
getLogger().info("Plugin is up to date! Thank you for supporting Chests++!");
|
if(!boot) getLogger().info("Plugin is up to date! Thank you for supporting Chests++!");
|
||||||
break;
|
break;
|
||||||
case UNAVAILABLE:
|
case UNAVAILABLE:
|
||||||
Bukkit.broadcastMessage("Unable to perform an update check.");
|
Bukkit.broadcastMessage("Unable to perform an update check.");
|
||||||
}
|
}
|
||||||
})
|
boot = true;
|
||||||
.check();
|
});
|
||||||
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, updateChecker::check,0,Settings.getUpdateCheckerPeriodTicks());
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger().info("Chests++ enabled!");
|
getLogger().info("Chests++ enabled!");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: ChestsPlusPlus
|
name: ChestsPlusPlus
|
||||||
version: 1.15.2-v1
|
version: 1.15 v1.2.3
|
||||||
main: com.jamesdpeters.minecraft.chests.ChestsPlusPlus
|
main: com.jamesdpeters.minecraft.chests.ChestsPlusPlus
|
||||||
api-version: "1.15"
|
api-version: "1.15"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user