Code reordered and methods rebat / removal announced via @Deprecated

This commit is contained in:
JaTiTV 2023-06-30 17:59:29 +02:00
parent 2e1ef9c46d
commit c2adf6957d
7 changed files with 148 additions and 38 deletions

View File

@ -8,11 +8,25 @@ import org.bukkit.entity.Player;
public class T2ChoverModule { public class T2ChoverModule {
/**
* @deprecated reason this method is deprecated <br/>
* The T2Code Hover Module will be removed soon,<br/>
* please use 'T2CminiMessage.sendPlayerMiniMessage(msg, player);'<br/>
* and the Kyori MiniMessage format!
*/
@Deprecated
public static void modulePlayer(String text, String hover, String action, String actionValue, Player player) { public static void modulePlayer(String text, String hover, String action, String actionValue, Player player) {
modulePlayer((text != null ? text : "null") + "/*/" + (hover != null ? hover : "null") + "/*/" + (action != null ? action : "null") modulePlayer((text != null ? text : "null") + "/*/" + (hover != null ? hover : "null") + "/*/" + (action != null ? action : "null")
+ "/*/" + (actionValue != null ? actionValue : "null"), player); + "/*/" + (actionValue != null ? actionValue : "null"), player);
} }
/**
* @deprecated reason this method is deprecated <br/>
* The T2Code Hover Module will be removed soon,<br/>
* please use 'T2CminiMessage.sendPlayerMiniMessage(msg, player);'<br/>
* and the Kyori MiniMessage format!
*/
@Deprecated
public static void modulePlayer(String msg, Player player) { public static void modulePlayer(String msg, Player player) {
if (msg.contains("/*/")) { if (msg.contains("/*/")) {
t2cmodule(msg, player); t2cmodule(msg, player);
@ -21,10 +35,24 @@ public class T2ChoverModule {
T2CminiMessage.sendPlayerMiniMessage(msg, player); T2CminiMessage.sendPlayerMiniMessage(msg, player);
} }
/**
* @deprecated reason this method is deprecated <br/>
* The T2Code Hover Module will be removed soon,<br/>
* please use 'T2CminiMessage.sendSenderMiniMessage(msg, sender);'<br/>
* and the Kyori MiniMessage format!
*/
@Deprecated
public static void moduleSender(String msg, CommandSender sender) { public static void moduleSender(String msg, CommandSender sender) {
T2CminiMessage.sendSenderMiniMessage(msg, sender); T2CminiMessage.sendSenderMiniMessage(msg, sender);
} }
/**
* @deprecated reason this method is deprecated <br/>
* The T2Code Hover Module will be removed soon,<br/>
* please use 'T2CminiMessage.sendPlayerMiniMessage(msg, player);'<br/>
* and the Kyori MiniMessage format!
*/
@Deprecated
public static void moduleConsole(String msg) { public static void moduleConsole(String msg) {
if (T2CodeLibMain.getMmIsLoad()) { if (T2CodeLibMain.getMmIsLoad()) {
T2CminiMessage.sendConsoleMiniMessage(msg); T2CminiMessage.sendConsoleMiniMessage(msg);
@ -33,6 +61,13 @@ public class T2ChoverModule {
Bukkit.getConsoleSender().sendMessage(msg); Bukkit.getConsoleSender().sendMessage(msg);
} }
/**
* @deprecated reason this method is deprecated <br/>
* The T2Code Hover Module will be removed soon,<br/>
* please use 'T2CminiMessage.sendPlayerMiniMessage(msg, player);'<br/>
* and the Kyori MiniMessage format!
*/
@Deprecated
private static void t2cmodule(String msg, Player player) { private static void t2cmodule(String msg, Player player) {
String[] split = msg.split("/\\*/"); String[] split = msg.split("/\\*/");
int i = split.length; int i = split.length;

View File

@ -110,16 +110,6 @@ public class T2Creplace {
.replace("&c", "").replace("&d", "").replace("&e", "").replace("&f", "") .replace("&c", "").replace("&d", "").replace("&e", "").replace("&f", "")
.replace("&k", "").replace("&l", "").replace("&m", "").replace("&n", "") .replace("&k", "").replace("&l", "").replace("&m", "").replace("&n", "")
.replace("&o", "").replace("&r", ""); .replace("&o", "").replace("&r", "");
// String text = value.replace("&", "§");
// while (text.contains("§")) {
// int stelle = text.indexOf("§");
// if (text.length() >= stelle + 2) {
// text = text.substring(0, stelle) + text.substring(stelle + 2);
// } else {
// text = text.substring(0, stelle) + text.substring(stelle + 1);
// }
// }
// return (text);
} }
public static List<String> replacePrice(String prefix, Player player, List<String> Text, String price) { public static List<String> replacePrice(String prefix, Player player, List<String> Text, String price) {

View File

@ -12,36 +12,62 @@ import java.util.logging.Level;
public class T2Csend { public class T2Csend {
/** /**
* Spigot * @deprecated reason this method is deprecated <br/>
* Please note that these methods will be rebuilt to MiniMessage in the future and from then on the T2Code Hover Module will be removed!
*/ */
@Deprecated
public static void console(String msg) { public static void console(String msg) {
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleConsole(msg); T2ChoverModule.moduleConsole(msg);
} }
/**
* @deprecated reason this method is deprecated <br/>
* Please note that these methods will be rebuilt to MiniMessage in the future and from then on the T2Code Hover Module will be removed!
*/
@Deprecated
public static void player(Player player, String msg) { public static void player(Player player, String msg) {
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.modulePlayer(msg, player); T2ChoverModule.modulePlayer(msg, player);
} }
/**
* @deprecated reason this method is deprecated <br/>
* Please note that these methods will be rebuilt to MiniMessage in the future and from then on the T2Code Hover Module will be removed!
*/
@Deprecated
public static void sender(CommandSender sender, String msg) { public static void sender(CommandSender sender, String msg) {
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleSender(msg, sender); T2ChoverModule.moduleSender(msg, sender);
} }
/**
* @deprecated reason this method is deprecated <br/>
* Please note that these methods will be rebuilt to MiniMessage in the future and from then on the T2Code Hover Module will be removed!
*/
@Deprecated
public static void console(Object object) { public static void console(Object object) {
String msg = String.valueOf(object); String msg = String.valueOf(object);
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleConsole(msg); T2ChoverModule.moduleConsole(msg);
} }
/**
* @deprecated reason this method is deprecated <br/>
* Please note that these methods will be rebuilt to MiniMessage in the future and from then on the T2Code Hover Module will be removed!
*/
@Deprecated
public static void player(Player player, Object object) { public static void player(Player player, Object object) {
String msg = String.valueOf(object); String msg = String.valueOf(object);
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.modulePlayer(msg, player); T2ChoverModule.modulePlayer(msg, player);
} }
/**
* @deprecated reason this method is deprecated <br/>
* Please note that these methods will be rebuilt to MiniMessage in the future and from then on the T2Code Hover Module will be removed!
*/
@Deprecated
public static void sender(CommandSender sender, Object object) { public static void sender(CommandSender sender, Object object) {
String msg = String.valueOf(object); String msg = String.valueOf(object);
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) return;

View File

@ -68,21 +68,41 @@ public class T2Ctemplate {
T2Csend.console(prefix + " §8-------------------------------"); T2Csend.console(prefix + " §8-------------------------------");
} }
public static void onLoadFooter(String prefix, Long long_, String version) {
onLoadSeparateStroke(prefix);
T2Csend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
public static void onLoadFooter(String prefix, Long long_) { public static void onLoadFooter(String prefix, Long long_) {
onLoadSeparateStroke(prefix); onLoadSeparateStroke(prefix);
T2Csend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); T2Csend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} }
/**
* @param prefix
* @param autor
* @param spigot
* @param discord
*
* @deprecated reason this method is deprecated <br/>
* {will be removed in next version} <br/>
* use {@link #onDisable(Plugin)} instead like this:
*
*
* <blockquote><pre>
* onDisable(getPlugin())
* </pre></blockquote>
*
*/
@Deprecated
public static void onDisable(String prefix, List<String> autor, String version, String spigot, String discord) { public static void onDisable(String prefix, List<String> autor, String version, String spigot, String discord) {
T2Csend.console(prefix + " §2Version: §6" + version); T2Csend.console(prefix + " §2Version: §6" + version);
T2Csend.console(prefix + " §4Plugin successfully disabled."); T2Csend.console(prefix + " §4Plugin successfully disabled.");
} }
public static void onDisable(String prefix, Plugin plugin) {
T2Csend.console(prefix + " §4 §e╔══════════════════════════");
T2Csend.console(prefix + " §4 §e║ §2Version: §6" + plugin.getDescription().getVersion());
T2Csend.console(prefix + " §4 §e║ §2Autors: §6" + plugin.getDescription().getAuthors());
T2Csend.console(prefix + " §4 §e║ §4Plugin successfully disabled.");
T2Csend.console(prefix + " §4 §e╚══════════════════════════");
}
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, Boolean premiumVerified, String text) { public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, Boolean premiumVerified, String text) {
String pluginVersion = plugin.getDescription().getVersion(); String pluginVersion = plugin.getDescription().getVersion();
String publicVersion = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData.getVersion(); String publicVersion = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData.getVersion();

View File

@ -25,11 +25,11 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
if (args.length == 0) { if (args.length == 0) {
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
Commands.info(sender); Commands.info(sender);
return false; return false;
} }
@ -39,26 +39,53 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
case "pl": case "pl":
case "version": case "version":
case "ver": case "ver":
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
Commands.info(sender); Commands.info(sender);
return false; return false;
case "updateinfo": case "updateinfo":
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
Commands.updateInfo(sender, args); Commands.updateInfo(sender, args);
return false; return false;
case "reloadconfig": case "reloadconfig":
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
SelectLibConfig.onSelect(); SelectLibConfig.onSelect();
T2Csend.sender(sender, Util.getPrefix() + " §2Config successfully reloaded"); T2Csend.sender(sender, Util.getPrefix() + " §2Config successfully reloaded");
return false; return false;
case "debug": case "debug":
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
Commands.debug(sender, args); Commands.debug(sender, args);
return false; return false;
case "test": case "test":
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
Commands.test(sender, args); Commands.test(sender, args);
return false; return false;
case "serverid": case "serverid":if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
T2Csend.sender(sender, ("[prefix] <red>T2C ServerID:</red> <gold><hover:show_text:'<yellow>copy</yellow>'>" + T2Csend.sender(sender, ("[prefix] <red>T2C ServerID:</red> <gold><hover:show_text:'<yellow>copy</yellow>'>" +
"<click:copy_to_clipboard:[id]>[id]</click></hover></gold>").replace("[prefix]", Util.getPrefix()).replace("[id]", String.valueOf(Util.getServerUUID()))); "<click:copy_to_clipboard:[id]>[id]</click></hover></gold>").replace("[prefix]", Util.getPrefix()).replace("[id]", String.valueOf(Util.getServerUUID())));
return false; return false;
case "bcmd": case "bcmd":
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
String cmd = ""; String cmd = "";
for (String s : args) { for (String s : args) {
cmd = cmd + s + " "; cmd = cmd + s + " ";
@ -69,6 +96,10 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
return false; return false;
default: default:
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog"); T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
return false; return false;
} }

View File

@ -3,31 +3,33 @@ package net.t2code.t2codelib.SPIGOT.system.cmd;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI; import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.Util; import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.IOException; import java.io.IOException;
public class Commands { public class Commands {
public static void info(CommandSender sender) { protected static void info(CommandSender sender) {
T2Ctemplate.sendInfo(sender, T2CodeLibMain.getPlugin(), Util.getSpigotID(), Util.getDiscord(), null, Util.getInfoText()); T2Ctemplate.sendInfo(sender, T2CodeLibMain.getPlugin(), Util.getSpigotID(), Util.getDiscord(), null, Util.getInfoText());
} }
public static void test(CommandSender sender, String[] args) {
T2Csend.sender(sender,Util.getPrefix()+" &4Currently there is no development test command"); protected static void test(CommandSender sender, String[] args) {
T2Csend.sender(sender, Util.getPrefix() + " &4Currently there is no development test command");
} }
public static void debug(CommandSender sender, String[] args) { protected static void debug(CommandSender sender, String[] args) {
if (args.length < 2) { if (args.length < 2) {
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog"); T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
return; return;
} }
switch (args[1].toLowerCase()) { switch (args[1].toLowerCase()) {
case "createreportlog": case "createreportlog":
switch (args.length){ switch (args.length) {
case 2: case 2:
if (sender instanceof Player) { if (sender instanceof Player) {
T2Csend.sender(sender, "<dark_red>The debug zip file is <red>automatically uploaded</red> to T2Code's servers<br>and <red>automatically deleted</red> " + T2Csend.sender(sender, "<dark_red>The debug zip file is <red>automatically uploaded</red> to T2Code's servers<br>and <red>automatically deleted</red> " +
@ -78,7 +80,7 @@ public class Commands {
} }
} }
public static void updateInfo(CommandSender sender, String[] args) { protected static void updateInfo(CommandSender sender, String[] args) {
T2Csend.sender(sender, T2CupdateAPI.updateInfo(args, sender instanceof Player)); T2Csend.sender(sender, T2CupdateAPI.updateInfo(args, sender instanceof Player));
} }
} }

View File

@ -123,9 +123,14 @@ public class CreateReportLog {
Collections.addAll(plugins, Bukkit.getPluginManager().getPlugins()); Collections.addAll(plugins, Bukkit.getPluginManager().getPlugins());
plugins.sort(Comparator.comparing(Plugin::getName)); plugins.sort(Comparator.comparing(Plugin::getName));
for (Plugin pl : plugins) { for (Plugin pl : plugins) {
pWriter.println(" - " + pl.getName() + " - " + pl.getDescription().getVersion() + " - Enabled: " + pl.isEnabled() + " - Autors: " pWriter.println(" - " + pl.getName() +
+ pl.getDescription().getAuthors() + " - SoftDepend: " + pl.getDescription().getSoftDepend() + " - Depend: " + pl.getDescription().getDepend() " - " + pl.getDescription().getVersion() +
+ " LoadBefore: " + pl.getDescription().getLoadBefore() + " - Website: " + pl.getDescription().getWebsite()); " - Enabled: " + pl.isEnabled() +
" - Autors: " + pl.getDescription().getAuthors() +
" - SoftDepend: " + pl.getDescription().getSoftDepend() +
" - Depend: " + pl.getDescription().getDepend() +
" - LoadBefore: " + pl.getDescription().getLoadBefore() +
" - Website: " + pl.getDescription().getWebsite());
} }
} catch (IOException ioe) { } catch (IOException ioe) {
@ -147,9 +152,9 @@ public class CreateReportLog {
addFileToZip("", "logs/latest.log", zip, false); addFileToZip("", "logs/latest.log", zip, false);
// for (String pl : Util.getT2cPlugins()) { // for (String pl : Util.getT2cPlugins()) {
// pluginToDebug(pl, zip); // pluginToDebug(pl, zip);
// } // }
pluginToDebug(zip); //todo überprüfen pluginToDebug(zip); //todo überprüfen
zip.closeEntry(); zip.closeEntry();
@ -223,16 +228,17 @@ public class CreateReportLog {
} }
} }
} }
private static void pluginToDebug(ZipOutputStream zip) throws IOException { private static void pluginToDebug(ZipOutputStream zip) throws IOException {
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()){ for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
String plName = plugin.getDescription().getName(); String plName = plugin.getDescription().getName();
if (plName.contains("T2C-") || Util.getT2cPlugins().contains(plName)){ if (plName.contains("T2C-") || Util.getT2cPlugins().contains(plName) || plugin.getDescription().getAuthors().contains("JaTiTV")) {
File plConfigs = new File(plugin.getDataFolder().getPath()); File plConfigs = new File(plugin.getDataFolder().getPath());
if (plConfigs.exists()) { if (plConfigs.exists()) {
addFolderToZip("T2Code-Plugins", plugin.getDataFolder().getPath(), zip); addFolderToZip("T2Code-Plugins", plugin.getDataFolder().getPath(), zip);
} }
File f = new File(plugin.getClass().getProtectionDomain().getCodeSource().getLocation().getPath()); File f = new File(plugin.getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
addFileToZip("T2Code-Plugins", f.getPath(), zip, false); addFileToZip("T2Code-Plugins", f.getPath(), zip, false);
} }
} }
} }