- The option 'Plugin.UpdateCheck.OnJoin' activates / deactivates the UpdateCheck on join of all T2Code plugins using the T2CodeLib from now on
- minor code changes
This commit is contained in:
JaTiTV 2022-04-26 18:26:51 +02:00
parent f27ec3c985
commit df01efdfbd
12 changed files with 54 additions and 60 deletions

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT"> <library name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.13.1-R0.1-SNAPSHOT/bukkit-1.13.1-R0.1-20181022.190036-99.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.13.1-R0.1-SNAPSHOT/bukkit-1.13.1-R0.1-SNAPSHOT.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.13.1-R0.1-SNAPSHOT/bukkit-1.13.1-R0.1-20181022.190036-99-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.13.1-R0.1-SNAPSHOT/bukkit-1.13.1-R0.1-SNAPSHOT-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.13.1-R0.1-SNAPSHOT/bukkit-1.13.1-R0.1-20181022.190036-99-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.13.1-R0.1-SNAPSHOT/bukkit-1.13.1-R0.1-SNAPSHOT-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>

View File

@ -25,25 +25,24 @@
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: net.t2code:bungee:1615" level="project" />
<orderEntry type="library" name="Maven: net.t2code:LuckyBox-API:4.2.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.MilkBowl:VaultAPI:1.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: me.clip:placeholderapi:2.11.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:31.0.1-jre" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:31.0.1-jre" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.checkerframework:checker-qual:3.12.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.checkerframework:checker-qual:3.12.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.errorprone:error_prone_annotations:2.7.1" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.google.errorprone:error_prone_annotations:2.7.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.28" level="project" />
<orderEntry type="library" name="Maven: net.t2code:bungee:1615" level="project" />
<orderEntry type="library" name="Maven: net.t2code:LuckyBox-API:4.2.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.MilkBowl:VaultAPI:1.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: me.clip:placeholderapi:2.11.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains:annotations:19.0.0" level="project" />
</component> </component>
</module> </module>

View File

@ -11,7 +11,7 @@
<name>T2CodeLib</name> <name>T2CodeLib</name>
<description>Libarie from T2Code Plugins</description> <description>Library from T2Code Plugins</description>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -4,6 +4,7 @@ import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.t2code.lib.Spigot.Lib.replace.Replace; import net.t2code.lib.Spigot.Lib.replace.Replace;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import net.t2code.lib.Spigot.system.config.SelectLibConfig;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -46,6 +47,7 @@ public class T2CodeTemplate {
if (version.toLowerCase().contains("dev") || version.toLowerCase().contains("snapshot") || version.toLowerCase().contains("beta")) { 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 §4UpdateChecker & bStats may be disabled!"); 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-------------------"); send.console(prefix + " §4 §e-------------------");
if (SelectLibConfig.t2cTestDevelopment) return long_;
try { try {
Thread.sleep(5000); Thread.sleep(5000);
} catch (InterruptedException e) { } catch (InterruptedException e) {

View File

@ -25,9 +25,9 @@ public class UpdateAPI {
public static HashMap<String, UpdateObject> PluginVersionen = new HashMap<>(); public static HashMap<String, UpdateObject> PluginVersionen = new HashMap<>();
public static void join(Plugin plugin, String prefix, String perm, Player player, String spigot, String discord) { public static void join(Plugin plugin, String prefix, String perm, Player player, String spigot, String discord) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { if (!SelectLibConfig.UpdateCheckOnJoin) {
@Override return;
public void run() { }
String pluginVersion = plugin.getDescription().getVersion(); String pluginVersion = plugin.getDescription().getVersion();
if (!player.hasPermission(perm) && !player.isOp()) { if (!player.hasPermission(perm) && !player.isOp()) {
return; return;
@ -39,21 +39,21 @@ public class UpdateAPI {
join(plugin, prefix, perm, player, spigot, discord); join(plugin, prefix, perm, player, spigot, discord);
} }
}.runTaskLater(plugin, 20L); }.runTaskLater(plugin, 20L);
} else use(plugin, prefix, player, pluginVersion, UpdateAPI.PluginVersionen.get(plugin.getName()).publicVersion, spigot, discord); return;
} }
}); String publicVersion = UpdateAPI.PluginVersionen.get(plugin.getName()).publicVersion;
if (pluginVersion.equals(publicVersion)) {
return;
}
use(plugin, prefix, player, pluginVersion, publicVersion, spigot, discord);
} }
private static void use(Plugin plugin, String prefix, Player player, String pluginVersion, String publicVersion, String spigot, String discord) { private static void use(Plugin plugin, String prefix, Player player, String pluginVersion, String publicVersion, String spigot, String discord) {
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
if (!pluginVersion.equals(publicVersion)) {
if (SelectLibConfig.UpdateCheckOnJoin) {
UpdateAPI.sendUpdateMsg(prefix, spigot, discord, pluginVersion, publicVersion, player); UpdateAPI.sendUpdateMsg(prefix, spigot, discord, pluginVersion, publicVersion, player);
} }
}
}
}, 200L); }, 200L);
} }
@ -120,7 +120,7 @@ public class UpdateAPI {
} }
public static void onUpdateCheck(Plugin plugin, String Prefix, String Spigot, int SpigotID, String Discord, Integer timeInMin) { public static void onUpdateCheck(Plugin plugin, String Prefix, String Spigot, int SpigotID, String Discord, Integer timeInMin) {
int taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { int taskID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
public void run() { public void run() {
(new UpdateAPI((JavaPlugin) plugin, SpigotID)).getVersion((update_version) -> { (new UpdateAPI((JavaPlugin) plugin, SpigotID)).getVersion((update_version) -> {
UpdateObject update = new UpdateObject( UpdateObject update = new UpdateObject(

View File

@ -5,6 +5,7 @@ import net.milkbowl.vault.permission.Permission;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.system.Main; import net.t2code.lib.Spigot.system.Main;
import net.t2code.lib.Spigot.system.languages.SelectLibMsg; import net.t2code.lib.Spigot.system.languages.SelectLibMsg;
import net.t2code.lib.Util;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
@ -20,7 +21,7 @@ public class Vault {
send.console(prefix + " §4\n" + prefix + " §4Vault could not be found! §9Please download it here: " + send.console(prefix + " §4\n" + prefix + " §4Vault could not be found! §9Please download it here: " +
"§6https://www.spigotmc.org/resources/vault.34315/§4\n" + prefix); "§6https://www.spigotmc.org/resources/vault.34315/§4\n" + prefix);
} }
p.sendMessage(prefix + "\n" + SelectLibMsg.VaultNotSetUp + "\n" + prefix); p.sendMessage(prefix + "\n" + SelectLibMsg.vaultNotSetUp + "\n" + prefix);
} else { } else {
return Main.eco.withdrawPlayer(p,price).transactionSuccess(); return Main.eco.withdrawPlayer(p,price).transactionSuccess();
} }
@ -33,7 +34,7 @@ public class Vault {
send.console(prefix + " §4\n" + prefix + " §4Vault could not be found! §9Please download it here: " + send.console(prefix + " §4\n" + prefix + " §4Vault could not be found! §9Please download it here: " +
"§6https://www.spigotmc.org/resources/vault.34315/§4\n" + prefix); "§6https://www.spigotmc.org/resources/vault.34315/§4\n" + prefix);
} }
p.sendMessage(prefix + "\n" + SelectLibMsg.VaultNotSetUp + "\n" + prefix); p.sendMessage(prefix + "\n" + SelectLibMsg.vaultNotSetUp + "\n" + prefix);
} else { } else {
return Main.eco.depositPlayer(p,price).transactionSuccess(); return Main.eco.depositPlayer(p,price).transactionSuccess();
} }
@ -49,14 +50,14 @@ public class Vault {
Main.eco = eco.getProvider(); Main.eco = eco.getProvider();
if (Main.eco != null) { if (Main.eco != null) {
connected = true; connected = true;
send.console(Main.prefix + " §2Vault / Economy successfully connected!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); send.console(Util.getPrefix() + " §2Vault / Economy successfully connected!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} else { } else {
connected = false; connected = false;
send.console(Main.prefix + " §4Economy could not be connected / found! 1" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); send.console(Util.getPrefix() + " §4Economy could not be connected / found! 1" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} }
} else { } else {
connected = false; connected = false;
send.console(Main.prefix + " §4Economy could not be connected / found! 2" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); send.console(Util.getPrefix() + " §4Economy could not be connected / found! 2" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} }
RegisteredServiceProvider<Permission> perm = Main.plugin.getServer().getServicesManager().getRegistration(Permission.class); RegisteredServiceProvider<Permission> perm = Main.plugin.getServer().getServicesManager().getRegistration(Permission.class);
if (perm != null) { if (perm != null) {
@ -65,12 +66,12 @@ public class Vault {
} else { } else {
vaultEnable = false; vaultEnable = false;
connected = false; connected = false;
send.console(Main.prefix + " §4Vault could not be connected! 3" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); send.console(Util.getPrefix() + " §4Vault could not be connected! 3" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} }
} }
public static void vaultDisable() { public static void vaultDisable() {
connected = false; connected = false;
send.console(Main.prefix + " §4Vault / Economy successfully deactivated."); send.console(Util.getPrefix() + " §4Vault / Economy successfully deactivated.");
} }
} }

View File

@ -109,7 +109,7 @@ public class Config {
try { try {
return Sound.valueOf(selectSoundFromConfig); return Sound.valueOf(selectSoundFromConfig);
} catch (Exception e) { } catch (Exception e) {
send.console("§4\n§4\n§4\n" + SelectLibMsg.SoundNotFound.replace("[prefix]", prefix) send.console("§4\n§4\n§4\n" + SelectLibMsg.soundNotFound.replace("[prefix]", prefix)
.replace("[sound]", "§8Buy: §6" + selectSoundFromConfig) + "§4\n§4\n§4\n"); .replace("[sound]", "§8Buy: §6" + selectSoundFromConfig) + "§4\n§4\n§4\n");
return Sound.valueOf(sound); return Sound.valueOf(sound);
} }

View File

@ -9,6 +9,7 @@ public class SelectLibConfig {
public static Boolean UpdateCheckOnJoin; public static Boolean UpdateCheckOnJoin;
public static Boolean t2cTestDevelopment;
public static Integer UpdateCheckTimeInterval; public static Integer UpdateCheckTimeInterval;
public static Boolean Debug; public static Boolean Debug;
public static String language; public static String language;
@ -19,6 +20,7 @@ public class SelectLibConfig {
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheck.OnJoin"); UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheck.OnJoin");
t2cTestDevelopment = yamlConfiguration.getBoolean("t2cTestDevelopment");
UpdateCheckTimeInterval = yamlConfiguration.getInt("Plugin.UpdateCheck.TimeInterval"); UpdateCheckTimeInterval = yamlConfiguration.getInt("Plugin.UpdateCheck.TimeInterval");
Debug = yamlConfiguration.getBoolean("Plugin.Debug"); Debug = yamlConfiguration.getBoolean("Plugin.Debug");
language = yamlConfiguration.getString("Plugin.language"); language = yamlConfiguration.getString("Plugin.language");

View File

@ -15,8 +15,8 @@ public class SelectLibMsg {
public static String selectMSG; public static String selectMSG;
public static String VaultNotSetUp; public static String vaultNotSetUp;
public static String SoundNotFound; public static String soundNotFound;
public static void onSelect(String Prefix) { public static void onSelect(String Prefix) {
@ -38,8 +38,8 @@ public class SelectLibMsg {
} else selectMSG = SelectLibConfig.language; } else selectMSG = SelectLibConfig.language;
YamlConfiguration yamlConfiguration_msg = YamlConfiguration.loadConfiguration(msg); YamlConfiguration yamlConfiguration_msg = YamlConfiguration.loadConfiguration(msg);
VaultNotSetUp = Replace.replace(prefix, yamlConfiguration_msg.getString("Plugin.VaultNotSetUp")); vaultNotSetUp = Replace.replace(prefix, yamlConfiguration_msg.getString("Plugin.VaultNotSetUp"));
SoundNotFound = Replace.replace(prefix, yamlConfiguration_msg.getString("Plugin.SoundNotFound")); soundNotFound = Replace.replace(prefix, yamlConfiguration_msg.getString("Plugin.SoundNotFound"));
send.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); send.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
} }

View File

@ -2,4 +2,4 @@ name: T2CodeLib
version: ${project.version} version: ${project.version}
main: net.t2code.lib.Bungee.BMain main: net.t2code.lib.Bungee.BMain
author: JaTiTV, Jkobs author: JaTiTV, Jkobs
description: Libarie from T2Code Plugins description: Library from T2Code Plugins

View File

@ -4,7 +4,7 @@ main: net.t2code.lib.Spigot.system.Main
api-version: 1.13 api-version: 1.13
prefix: T2CodeLib prefix: T2CodeLib
authors: [ JaTiTV, Jkobs ] authors: [ JaTiTV, Jkobs ]
description: Libarie from T2Code Plugins description: Library from T2Code Plugins
website: T2Code.net website: T2Code.net
load: STARTUP load: STARTUP
softdepend: [ PlaceholderAPI, PlotSquared, CMI, CMILib, Vault, Economy, XConomy ] softdepend: [ PlaceholderAPI, PlotSquared, CMI, CMILib, Vault, Economy, XConomy ]