Merge pull request '1.0.6' (#1) from 1.0.6 into main

Reviewed-on: #1
This commit is contained in:
JaTiTV 2022-01-29 19:44:29 +01:00
commit f3f1769d41
18 changed files with 107 additions and 208 deletions

20
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>Alias</artifactId>
<version>1.0.5</version>
<version>1.0.6</version>
<packaging>jar</packaging>
<name>T2C-Alias</name>
@ -56,16 +56,21 @@
<repositories>
<repository>
<id>Builders-Paradise</id>
<url>https://dojagames.net:8081/repository/Builders-Paradise/</url>
<id>T2Code</id>
<url>https://repo.t2code.net/repository/T2Code/</url>
</repository>
<repository>
<id>T2Code</id>
<url>https://dojagames.net:8081/repository/T2Code/</url>
<id>Builders-Paradise</id>
<url>https://repo.t2code.net/repository/Builders-Paradise/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>11.0</version>
</dependency>
<dependency>
<groupId>net.t2code</groupId>
<artifactId>bungee</artifactId>
@ -76,11 +81,6 @@
<artifactId>PlugmanGUI</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>7.4</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_18.r1</groupId>
<artifactId>spigot</artifactId>

View File

@ -15,13 +15,6 @@ 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;
@Override
public void onEnable() {
// Plugin startup logic
@ -30,18 +23,18 @@ public final class BMain extends Plugin {
autor = plugin.getDescription().getAuthor();
if (ProxyServer.getInstance().getPluginManager().getPlugin("T2CodeLib") == null) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
ProxyServer.getInstance().getConsole().sendMessage(prefix + " §eT2CodeLib §4could not be found. Please download it here: " +
ProxyServer.getInstance().getConsole().sendMessage(Util.getPrefix() + " §eT2CodeLib §4could not be found. Please download it here: " +
"§6https://www.spigotmc.org/resources/t2codelib.96388/ §4to be able to use this plugin.");
getProxy().getPluginManager().getPlugin(plugin.getDescription().getName()).onDisable();
return;
}
BLoad.onLoad(plugin, prefix, autor, version, spigot, discord, spigotID, bstatsID);
BLoad.onLoad(plugin, Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID());
}
@Override
public void onDisable() {
// Plugin shutdown logic
if (ProxyServer.getInstance().getPluginManager().getPlugin("T2CodeLib") == null) return;
BT2CodeTemplate.onDisable(prefix, autor, version, spigot, discord);
BT2CodeTemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
}
}

View File

@ -11,6 +11,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.logging.Level;
public final class Main extends JavaPlugin {
@ -18,13 +19,6 @@ public final class Main extends JavaPlugin {
return plugin.getDataFolder();
}
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 version;
public static List<String> autor;
@ -39,14 +33,8 @@ public final class Main extends JavaPlugin {
plugin = this;
autor = plugin.getDescription().getAuthors();
version = plugin.getDescription().getVersion();
isPlugin("T2CodeLib",96388);
Load.onLoad(prefix, autor, version, spigot, spigotID, discord, bstatsID);
}
public void saveConfig() {
if (!new File(getPath(), "config.yml").exists())
plugin.saveResource("config.yml", false);
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
Load.onLoad(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getSpigotID(), Util.getDiscord(), Util.getBstatsID());
}
@Override
@ -55,16 +43,24 @@ public final class Main extends JavaPlugin {
aliasHashMap.clear();
allAliases.clear();
if (Bukkit.getPluginManager().getPlugin("T2CodeLib") == null) return;
T2CodeTemplate.onDisable(prefix, autor, version, spigot, discord);
T2CodeTemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
}
public static void isPlugin(String pl, Integer spigotID) {
public static Boolean pluginNotFound(String pl, Integer spigotID, double ver) {
if (Bukkit.getPluginManager().getPlugin(pl) == null) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(prefix + " §e" + pl + " §4could not be found. Please download it here: " +
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4could not be found. Please download it here: " +
"§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin.");
Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
return;
return true;
} else {
if (Double.parseDouble(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(pl)).getDescription().getVersion()) < ver) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires at least version §2" + ver + " §4of §6" + pl + " §4Please update it here: §6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to use this version of " + plugin.getDescription().getName() + ".");
Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
return true;
}
return false;
}
}
}

View File

@ -19,7 +19,6 @@ public class Alias_CmdExecuter implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Prefix = Main.prefix;
if (args.length == 0) {
// Command
@ -38,7 +37,7 @@ public class Alias_CmdExecuter implements CommandExecutor, TabCompleter {
break;
case "info":
case "plugin":
case "veraion":
case "version":
if (sender.hasPermission("t2code.alias.command.info")) {
Commands.info(sender);
} else send.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-alias info")

View File

@ -3,6 +3,7 @@ package net.t2code.alias.Spigot.cmdManagement;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.config.languages.SelectMessages;
import net.t2code.alias.Spigot.system.Load;
import net.t2code.alias.Util;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
@ -13,26 +14,19 @@ import org.bukkit.plugin.Plugin;
import java.util.List;
public class Commands {
private static Plugin plugin = Main.plugin;
private static String prefix = Main.prefix;
private static List autor = Main.autor;
private static String version = Main.version;
private static String spigot = Main.spigot;
private static String discord = Main.discord;
public static void info(CommandSender sender) {
T2CodeTemplate.sendInfo(sender,prefix,spigot,discord,autor,version, UpdateAPI.PluginVersionen.get(plugin.getName()).publicVersion);
T2CodeTemplate.sendInfo(sender, Util.getPrefix(),Util.getSpigot(),Util.getDiscord(),Main.autor,Main.version, UpdateAPI.PluginVersionen.get(Main.plugin.getName()).publicVersion);
}
public static void reload(CommandSender sender) {
if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadStart);
send.console(prefix + "§8-------------------------------");
send.console(prefix + " §6Plugin reload...");
send.console(prefix + "§8-------------------------------");
send.console(Util.getPrefix() + "§8-------------------------------");
send.console(Util.getPrefix() + " §6Plugin reload...");
send.console(Util.getPrefix() + "§8-------------------------------");
Load.loadReload();
if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadEnd);
send.console(prefix + "§8-------------------------------");
send.console(prefix + " §2Plugin successfully reloaded.");
send.console(prefix + "§8-------------------------------");
send.console(Util.getPrefix() + "§8-------------------------------");
send.console(Util.getPrefix() + " §2Plugin successfully reloaded.");
send.console(Util.getPrefix() + "§8-------------------------------");
}
}

View File

@ -6,6 +6,7 @@ import net.t2code.alias.Spigot.config.config.SelectConfig;
import net.t2code.alias.Spigot.config.languages.SelectMessages;
import net.t2code.alias.Spigot.objects.Alias_Objekt;
import net.t2code.alias.Spigot.system.*;
import net.t2code.alias.Util;
import net.t2code.lib.Spigot.Lib.commands.Cmd;
import net.t2code.lib.Spigot.Lib.messages.TextBuilder;
import net.t2code.lib.Spigot.Lib.messages.send;
@ -17,7 +18,7 @@ import org.bukkit.entity.Player;
public class RegisterCommands extends Command {
private String alias;
private String prefix = Main.prefix;
private String prefix = Util.getPrefix();
public RegisterCommands(String alias) {
super(alias);
@ -46,8 +47,8 @@ public class RegisterCommands extends Command {
} else BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), false);
} else {
send.console(Main.prefix + " §4To use bungee commands, enable the Bungee option in the config.");
send.player(player, Main.prefix + " §4To use bungee commands, enable the Bungee option in the config.");
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
if (Alias.AdminCommandAsConsole) {
@ -101,8 +102,8 @@ public class RegisterCommands extends Command {
} else BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), false);
} else {
send.console(Main.prefix + " §4To use bungee commands, enable the Bungee option in the config.");
send.player(player, Main.prefix + " §4To use bungee commands, enable the Bungee option in the config.");
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
if (Alias.CommandAsConsole) {
@ -144,8 +145,8 @@ public class RegisterCommands extends Command {
if (SelectConfig.Bungee) {
BCommand_Sender_Reciver.sendToBungee(sender, cmd.replace("[player]", sender.getName()), true);
} else {
send.console(Main.prefix + " §4To use bungee commands, enable the Bungee option in the config.");
send.sender(sender, Main.prefix + " §4To use bungee commands, enable the Bungee option in the config.");
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
send.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
Cmd.console(cmd.replace("[player]", sender.getName()));

View File

@ -1,6 +1,7 @@
package net.t2code.alias.Spigot.config.config;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
import org.bukkit.configuration.file.YamlConfiguration;
@ -19,8 +20,8 @@ public class CreateConfig {
public static void configCreate() {
Long long_ = Long.valueOf(System.currentTimeMillis());
if (new File(Main.getPath(), "config.yml").exists()) {
if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Main.prefix + " §5DEBUG: §6" + " §4config.yml are created / updated...");
} else send.console(Main.prefix + " §4config.yml are created...");
if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated...");
} else send.console(Util.getPrefix() + " §4config.yml are created...");
File config = new File(Main.getPath(), "config.yml");
@ -40,6 +41,6 @@ public class CreateConfig {
} catch (IOException e) {
e.printStackTrace();
}
send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
send.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
}
}

View File

@ -1,6 +1,7 @@
package net.t2code.alias.Spigot.config.config;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
import org.bukkit.configuration.file.YamlConfiguration;
@ -54,8 +55,8 @@ public class CreateExampleAliasConfig {
public static void configCreate() {
Long long_ = Long.valueOf(System.currentTimeMillis());
if (new File(Main.getPath(), "config.yml").exists()) {
if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Main.prefix + " §5DEBUG: §6" + " §4config.yml are created / updated...");
} else send.console(Main.prefix + " §4config.yml are created...");
if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated...");
} else send.console(Util.getPrefix() + " §4config.yml are created...");
File config = new File(Main.getPath(), "Alias/aliasexample.yml");
@ -106,6 +107,6 @@ public class CreateExampleAliasConfig {
} catch (IOException e) {
e.printStackTrace();
}
send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
send.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
}
}

View File

@ -3,23 +3,23 @@ package net.t2code.alias.Spigot.config.config;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.system.AliasRegister;
import net.t2code.alias.Spigot.objects.Alias_Objekt;
import net.t2code.alias.Util;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
public class SelectAlias {
private static String Prefix = Main.prefix;
private static String Prefix = Util.getPrefix();
public static void onSelect() {
Main.aliasHashMap.clear();
Main.allAliases.clear();
File f = new File(Main.getPath() + "/Alias/");
File[] fileArray = f.listFiles();
for (File config_gui : fileArray) {
Main.allAliases.add(config_gui.getName().replace(".yml", ""));
String sub = config_gui.getName().substring(config_gui.getName().length() - 4);
if (sub.equals(".yml")) {
Main.allAliases.add(config_gui.getName().replace(".yml", ""));
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config_gui);
Alias_Objekt alias = new Alias_Objekt(

View File

@ -1,6 +1,7 @@
package net.t2code.alias.Spigot.config.languages;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
import org.bukkit.configuration.file.YamlConfiguration;
@ -86,7 +87,7 @@ public class LanguagesCreate {
}
send.console(Main.prefix + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
send.console(Util.getPrefix() + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
}
}

View File

@ -2,6 +2,7 @@ package net.t2code.alias.Spigot.config.languages;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.config.config.SelectConfig;
import net.t2code.alias.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
import org.bukkit.configuration.file.YamlConfiguration;
@ -9,7 +10,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
public class SelectMessages {
private static String prefix = Main.prefix;
private static String prefix = Util.getPrefix();
public static String selectMSG;

View File

@ -98,7 +98,7 @@ public class AliasRegister {
craftServer.getCommandMap().register(alias, new RegisterCommands(alias));
}
}
} else send.warning(plugin, " §4AliasHashmap is null!");
} else send.warning(plugin, " §4AliasHashmap is null! - " + alias);
}
}
}

View File

@ -12,10 +12,6 @@ public class Alias_RegisterPermissions {
if (Bukkit.getPluginManager().getPermission("t2code.alias.use." + alias.toLowerCase()) == null) {
Register.permission("t2code.alias.use." + alias.toLowerCase(), Main.plugin);
}
//if (Bukkit.getPluginManager().getPermission(Main.aliasHashMap.get(alias).AdminPermission) == null){
// Bukkit.getPluginManager().addPermission(new Permission(Main.aliasHashMap.get(alias).AdminPermission));
//}
}
}
}

View File

@ -29,7 +29,15 @@ public class BCommand_Sender_Reciver {
} catch (IOException e) {
e.printStackTrace();
}
Bukkit.getServer().sendPluginMessage(Main.plugin, "t2codealias:bungee", stream.toByteArray());
if (sender instanceof Player) {
Player player = (Player) sender;
player.sendPluginMessage(Main.plugin, "t2codealias:bungee", stream.toByteArray());
}else {
for(Player player : Bukkit.getOnlinePlayers()){
player.sendPluginMessage(Main.plugin, "t2codealias:bungee", stream.toByteArray());
return;
}
}
}
}

View File

@ -3,6 +3,7 @@
package net.t2code.alias.Spigot.system;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import net.t2code.lib.Spigot.system.config.SelectLibConfig;
@ -24,7 +25,7 @@ public class JoinEvent implements Listener {
if (player.hasPermission("alias.updatemsg") || player.isOp()) {
if (!Main.version.equals(publicVersion)) {
if (SelectLibConfig.UpdateCheckOnJoin) {
UpdateAPI.sendUpdateMsg(Main.prefix, Main.spigot, Main.discord, Main.version, publicVersion, player);
UpdateAPI.sendUpdateMsg(Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), Main.version, publicVersion, player);
}
}
}

View File

@ -8,6 +8,7 @@ import net.t2code.alias.Spigot.config.config.SelectAlias;
import net.t2code.alias.Spigot.config.config.SelectConfig;
import net.t2code.alias.Spigot.config.languages.LanguagesCreate;
import net.t2code.alias.Spigot.config.languages.SelectMessages;
import net.t2code.alias.Util;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import org.bukkit.Bukkit;
@ -21,7 +22,7 @@ public class Load {
static Plugin plugin = Main.plugin;
public static void onLoad(String prefix, List autor, String version, String spigot, int spigotID, String discord, int bstatsID) {
Long long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord);
Main.plugin.getCommand("alias").setExecutor(new Alias_CmdExecuter());
Main.plugin.getCommand("t2code-alias").setExecutor(new Alias_CmdExecuter());
loadReload();
UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord);
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
@ -43,7 +44,7 @@ public class Load {
CreateConfig.configCreate();
LanguagesCreate.langCreate();
SelectConfig.onSelect();
SelectMessages.onSelect(Main.prefix);
SelectMessages.onSelect(Util.getPrefix());
SelectAlias.onSelect();
if (SelectConfig.Bungee) {
@ -51,8 +52,5 @@ public class Load {
Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "t2codealias:bungee");
}
Alias_RegisterPermissions.onPermRegister();
}
}

View File

@ -1,116 +0,0 @@
// This claas was created by JaTiTV
package net.t2code.alias.Spigot.system;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.t2code.alias.Spigot.Main;
import net.t2code.lib.Spigot.Lib.messages.TextBuilder;
import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Scanner;
import java.util.function.Consumer;
public class UpdateChecker {
public static void sendUpdateMsg(String Prefix, String foundVersion, String update_version) {
send.console("§4=========== " + Prefix + " §4===========");
send.console("§6A new version was found!");
send.console("§6Your version: §c" + foundVersion + " §7- §6Current version: §a" + update_version);
send.console("§6You can download it here: §e" + Main.spigot);
send.console("§6You can find more information on Discord: §e" + Main.discord);
send.console("§4=========== " + Prefix + " §4===========");
}
public static void sendUpdateMsg(String Prefix, String foundVersion, String update_version, Player player) {
TextComponent comp = new TextBuilder(Prefix + " §6A new version was found!")
.addHover("§6You can download it here: §e" + Main.spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Main.spigot).build();
player.spigot().sendMessage(comp);
TextComponent comp1 = new TextBuilder(Prefix + " §c" + foundVersion + " §7-> §a" + update_version)
.addHover("§6You can download it here: §e" + Main.spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Main.spigot).build();
player.spigot().sendMessage(comp1);
TextComponent comp2 = new TextBuilder(Prefix + " §6You can find more information on Discord.")
.addHover("§e" + Main.discord).addClickEvent(ClickEvent.Action.OPEN_URL, Main.discord).build();
player.spigot().sendMessage(comp2);
}
private static Boolean noUpdate = true;
public static void onUpdateCheck() {
int taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.plugin, new Runnable() {
public void run() {
(new UpdateChecker(Main.plugin, Main.spigotID)).getVersion((update_version) -> {
String foundVersion = Main.plugin.getDescription().getVersion();
// Main.update_version = update_version;
if (!foundVersion.equalsIgnoreCase(update_version)) {
new BukkitRunnable() {
@Override
public void run() {
sendUpdateMsg(Main.prefix, foundVersion, update_version);
}
}.runTaskLater(Main.plugin, 600L);
}else {
if (noUpdate) {
send.console(Main.prefix + " §2No update found.");
noUpdate = false;
}
}
});
}
}, 0L, 20 * 60 * 60L);
}
private JavaPlugin plugin;
private int resourceId;
public UpdateChecker(JavaPlugin plugin, int resourceId) {
this.plugin = plugin;
this.resourceId = resourceId;
}
public void getVersion(Consumer<String> consumer) {
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
try {
InputStream inputStream = (new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId)).openStream();
try {
Scanner scanner = new Scanner(inputStream);
try {
if (scanner.hasNext()) {
consumer.accept(scanner.next());
}
} catch (Throwable var8) {
try {
scanner.close();
} catch (Throwable var7) {
var8.addSuppressed(var7);
}
throw var8;
}
scanner.close();
} catch (Throwable var9) {
if (inputStream != null) {
try {
inputStream.close();
} catch (Throwable var6) {
var9.addSuppressed(var6);
}
}
throw var9;
}
if (inputStream != null) {
inputStream.close();
}
} catch (IOException var10) {
// Main.update_version = " §4No public version found!";
this.plugin.getLogger().severe(Main.prefix + "§4 Cannot look for updates: " + var10.getMessage());
}
});
}
}

View File

@ -1,9 +1,34 @@
package net.t2code.alias;
public class Util {
public static String Prefix = "§8[§4T2Code§7-§aAlias§8]";
public static Integer SpigotID = 96389;
public static Integer BstatsID = 12517;
public static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID;
public static String Discord = "http://dc.t2code.net";
private static double requiredT2CodeLibVersion = 11.0;
private static String Prefix = "§8[§4T2Code§7-§aAlias§8]";
private static Integer SpigotID = 96389;
private static Integer BstatsID = 12517;
private static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID;
private static String Discord = "http://dc.t2code.net";
public static double getRequiredT2CodeLibVersion() {
return requiredT2CodeLibVersion;
}
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;
}
}