Compare commits

...

8 Commits

Author SHA1 Message Date
6cbae613a3 customizable time interval for the UpdateChecker 2021-12-31 02:36:03 +01:00
9d0902f611 Code changes 2021-12-31 02:17:24 +01:00
f1a5fa9423 Code changes 2021-12-31 01:35:31 +01:00
5e3a3d290c Update 1.18 Start warning to 1.19 warning 2021-12-31 01:35:09 +01:00
07145453b2 add Player.Inventories.CloseByServerStop Function to Config 2021-12-31 01:34:41 +01:00
f545068330 add 1.19 2021-12-31 01:34:10 +01:00
34e59872c0 Update DEV / Snapshot / Beta Version Startmessage 2021-12-31 01:33:59 +01:00
ed63004ebf Change Version to 9.0_Snapshot_1 2021-12-31 01:32:59 +01:00
28 changed files with 128 additions and 30 deletions

View File

@@ -1,7 +1,7 @@
<component name="ArtifactManager">
<artifact type="jar" name="T2CodeLib_8.1">
<artifact type="jar" name="T2CodeLib_9.0_Snapshot_1">
<output-path>$PROJECT_DIR$/../../Plugins/T2CodeLib/.jar</output-path>
<root id="archive" name="T2CodeLib_8.1.jar">
<root id="archive" name="T2CodeLib_9.0_Snapshot_1.jar">
<element id="module-output" name="T2CodeLib" />
</root>
</artifact>

View File

@@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>8.1</version>
<version>9.0</version>
<packaging>jar</packaging>
<name>T2CodeLib</name>

View File

@@ -12,11 +12,11 @@ public final class BMain extends Plugin {
public static String Version;
public static String Autor;
public static String Prefix = Util.Prefix;
public static Integer SpigotID = Util.SpigotID;
public static Integer BstatsID = Util.BstatsID;
public static String Spigot = Util.Spigot;
public static String Discord = Util.Discord;
public static String Prefix = Util.getPrefix();
public static Integer SpigotID = Util.getSpigotID();
public static Integer BstatsID = Util.getBstatsID();
public static String Spigot = Util.getSpigot();
public static String Discord = Util.getDiscord();
@Override

View File

@@ -29,8 +29,13 @@ public class T2CodeTemplate {
send.console(prefix + " §4 §e| §2Discord: §6" + discord);
send.console(prefix + " §4 §e-------------------");
if (version.toLowerCase().contains("dev") || version.toLowerCase().contains("snapshot") || version.toLowerCase().contains("beta")) {
send.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! Some features may not be working as expected. Please report all bugs here: http://dc.t2code.net");
send.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! Some features may not be working as expected. Please report all bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled!");
send.console(prefix + " §4 §e-------------------");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
//onLoadSeparateStroke(prefix);
return long_;

View File

@@ -16,6 +16,7 @@ public class MCVersion {
public static boolean minecraft1_16;
public static boolean minecraft1_17;
public static boolean minecraft1_18;
public static boolean minecraft1_19;
public static void onCheck(){
isVersion = Bukkit.getServer().getVersion();
isBuckitVersion = Bukkit.getServer().getBukkitVersion();
@@ -30,5 +31,6 @@ public class MCVersion {
minecraft1_16 = Bukkit.getServer().getClass().getPackage().getName().contains("1_16");
minecraft1_17 = Bukkit.getServer().getClass().getPackage().getName().contains("1_17");
minecraft1_18 = Bukkit.getServer().getClass().getPackage().getName().contains("1_18");
minecraft1_19 = Bukkit.getServer().getClass().getPackage().getName().contains("1_19");
}
}

View File

@@ -6,6 +6,7 @@ import net.md_5.bungee.api.chat.TextComponent;
import net.t2code.lib.Spigot.Lib.messages.TextBuilder;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.system.Main;
import net.t2code.lib.Spigot.system.config.SelectLibConfig;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -81,9 +82,12 @@ public class UpdateAPI {
private static Boolean noUpdate = true;
public static void onUpdateCheck(Plugin plugin, String Prefix, String Spigot, int SpigotID, String Discord) {
onUpdateCheck(plugin, Prefix, Spigot, SpigotID, Discord, 60);
}
public static void onUpdateCheck(Plugin plugin, String Prefix, String Spigot, int SpigotID, String Discord, Integer timeInMin) {
int taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
public void run() {
(new UpdateAPI((JavaPlugin) plugin, SpigotID)).getVersion((update_version) -> {
UpdateObject update = new UpdateObject(
plugin.getName(),
@@ -91,7 +95,6 @@ public class UpdateAPI {
update_version
);
UpdateAPI.PluginVersionen.put(plugin.getName(), update);
if (!plugin.getDescription().getVersion().equalsIgnoreCase(update_version)) {
noUpdate = true;
new BukkitRunnable() {
@@ -101,7 +104,6 @@ public class UpdateAPI {
}
}.runTaskLater(plugin, 600L);
} else {
if (noUpdate) {
send.console(Prefix + " §2No update found.");
noUpdate = false;
@@ -109,7 +111,7 @@ public class UpdateAPI {
}
}, Prefix, plugin.getDescription().getVersion());
}
}, 0L, 20 * 60 * 60L);
}, 0L, timeInMin * 60 * 20L);
}
private JavaPlugin plugin;

View File

@@ -14,6 +14,6 @@ public class JoinEvent implements Listener {
@EventHandler
public void onJoinEvent(PlayerLoginEvent event) {
Player player = event.getPlayer();
UpdateAPI.join(Main.plugin, Util.Prefix, "t2code.lib.updatemsg", event.getPlayer(), Main.spigot, Main.discord);
UpdateAPI.join(Main.plugin, Util.getPrefix(), "t2code.lib.updatemsg", event.getPlayer(), Main.spigot, Main.discord);
}
}

View File

@@ -16,10 +16,12 @@ import net.t2code.lib.Util;
import net.t2code.lib.Spigot.system.config.SelectLibConfig;
import net.t2code.lib.Spigot.system.languages.SelectLibMsg;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.List;
import java.util.Objects;
public final class Main extends JavaPlugin {
@@ -34,11 +36,11 @@ public final class Main extends JavaPlugin {
public static List<String> autor;
public static String version;
public static String prefix = Util.Prefix;
public static Integer spigotID = Util.SpigotID;
public static Integer bstatsID = Util.BstatsID;
public static String spigot = Util.Spigot;
public static String discord = Util.Discord;
public static String prefix = Util.getPrefix();
public static Integer spigotID = Util.getSpigotID();
public static Integer bstatsID = Util.getBstatsID();
public static String spigot = Util.getSpigot();
public static String discord = Util.getDiscord();
@Override
public void onEnable() {
@@ -48,6 +50,16 @@ public final class Main extends JavaPlugin {
version = plugin.getDescription().getVersion();
Long long_;
long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord);
if (Util.getSnapshot()){
send.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! §4This is a trial version! §eSome features may not be working as expected. Please report all bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled!");
send.console(prefix + " §4 §e-------------------");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
//send.console("§4 _|_|_|_|_| _|_| _|_|_| _| ");
//send.console("§4 _| _| _| _| _|_| _|_|_| _|_| ");
//send.console("§4 _| _| _| _| _| _| _| _|_|_|_| ");
@@ -61,8 +73,13 @@ public final class Main extends JavaPlugin {
}
NMSVersion.onCheck();
MCVersion.onCheck();
if (MCVersion.minecraft1_18){
send.warning(this, "The 1.18 is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net");
if (MCVersion.minecraft1_19){
send.warning(this, "The 1.19 is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
ItemVersion.scan();
send.console(Main.prefix + " §3Server run on: §6" + MCVersion.isVersion + " / " + NMSVersion.isNMS);
@@ -92,6 +109,7 @@ public final class Main extends JavaPlugin {
SelectLibConfig.onSelect();
SelectLibMsg.onSelect(prefix);
UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord);
Metrics.Bstats(plugin, bstatsID);
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
T2CodeTemplate.onLoadFooter(prefix, long_);
@@ -100,6 +118,11 @@ public final class Main extends JavaPlugin {
@Override
public void onDisable() {
// Plugin shutdown logic
if (SelectLibConfig.InventoriesCloseByServerStop){
for (Player player : Bukkit.getOnlinePlayers()){
player.closeInventory();
}
}
Vault.vaultDisable();
T2CodeTemplate.onDisable(prefix, autor, version, spigot, discord);
}

View File

@@ -0,0 +1,33 @@
package net.t2code.lib.Spigot.system;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Scanner;
import java.util.function.Consumer;
public class UpdateChecker {
private final JavaPlugin plugin;
private final int resourceId;
public UpdateChecker(JavaPlugin plugin, int resourceId) {
this.plugin = plugin;
this.resourceId = resourceId;
}
public void getVersion(final Consumer<String> consumer) {
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
try (InputStream inputStream = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId).openStream(); Scanner scanner = new Scanner(inputStream)) {
if (scanner.hasNext()) {
consumer.accept(scanner.next());
}
} catch (IOException exception) {
plugin.getLogger().info("Unable to check for updates: " + exception.getMessage());
}
});
}
}

View File

@@ -12,6 +12,7 @@ import java.io.IOException;
public class ConfigCreate {
private static Boolean UpdateCheckOnJoin = true;
private static Integer UpdateCheckTimeInterval = 60;
private static Boolean Debug = false;
private static String language = "english";
@@ -38,11 +39,13 @@ public class ConfigCreate {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
Config.set("Plugin.UpdateCheckOnJoin", UpdateCheckOnJoin, yamlConfiguration);
Config.set("Plugin.UpdateCheck.OnJoin", UpdateCheckOnJoin, yamlConfiguration);
Config.set("Plugin.UpdateCheck.TimeInterval", UpdateCheckTimeInterval, yamlConfiguration);
Config.set("Plugin.language", language, yamlConfiguration);
Config.set("BungeeCord.Enable", Bungee, yamlConfiguration);
Config.set("BungeeCord.ThisServer", thisServer, yamlConfiguration);
Config.set("Player.Inventories.CloseByServerStop", true, yamlConfiguration);
// Config.set("Storage.MySQL.Enable", mySQL, yamlConfiguration);
// Config.set("Storage.Type", Storage, yamlConfiguration);

View File

@@ -9,16 +9,20 @@ public class SelectLibConfig {
public static Boolean UpdateCheckOnJoin;
public static Integer UpdateCheckTimeInterval;
public static Boolean Debug;
public static String language;
public static Boolean InventoriesCloseByServerStop;
public static void onSelect() {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheckOnJoin");
UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheck.OnJoin");
UpdateCheckTimeInterval = yamlConfiguration.getInt("Plugin.UpdateCheck.TimeInterval");
Debug = yamlConfiguration.getBoolean("Plugin.Debug");
language = yamlConfiguration.getString("Plugin.language");
InventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop");
}
}

View File

@@ -1,9 +1,35 @@
package net.t2code.lib;
public class Util {
public static String Prefix = "§8[§4T2Code§5Lib§8]";
public static Integer SpigotID = 96388;
public static Integer BstatsID = 12518;
public static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID;
public static String Discord = "http://dc.t2code.net";
private static Boolean Snapshot = true;
private static String Prefix = "§8[§4T2Code§5Lib§8]";
private static Integer SpigotID = 96388;
private static Integer BstatsID = 12518;
private static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID;
private static String Discord = "http://dc.t2code.net";
public static String getPrefix() {
return Prefix;
}
public static Integer getSpigotID() {
return SpigotID;
}
public static Integer getBstatsID() {
return BstatsID;
}
public static String getSpigot() {
return Spigot;
}
public static String getDiscord() {
return Discord;
}
public static Boolean getSnapshot(){
return Snapshot;
}
}

View File

@@ -1,5 +1,5 @@
name: T2CodeLib
version: 8.1
version: 9.0
main: net.t2code.lib.Bungee.BMain
author: JaTiTV, Jkobs
description: Libarie from T2Code Plugins

View File

@@ -1,5 +1,5 @@
name: T2CodeLib
version: 8.1
version: 9.0
main: net.t2code.lib.Spigot.system.Main
api-version: 1.13
prefix: T2CodeLib