16.7_dev-22

This commit is contained in:
JaTiTV 2024-07-05 09:35:57 +02:00
parent 83f4a3ef71
commit a350f9fb00
16 changed files with 89 additions and 139 deletions

28
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>16.7_dev-19</version>
<version>16.7_dev-22</version>
<!--version>VERSION_snapshot-0</version-->
<!--version>VERSION_beta-0</version-->
<!--version>VERSION_dev-0</version-->
@ -47,31 +47,7 @@
<relocations>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>net.t2code.libraries.kyori.adventure</shadedPattern>
</relocation>
<relocation>
<pattern>com.google.gson</pattern>
<shadedPattern>net.t2code.libraries.google</shadedPattern>
</relocation>
<relocation>
<pattern>mozilla</pattern>
<shadedPattern>net.t2code.libraries.mozilla</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache</pattern>
<shadedPattern>net.t2code.libraries.apache</shadedPattern>
</relocation>
<relocation>
<pattern>org.intellij</pattern>
<shadedPattern>net.t2code.libraries.intellij</shadedPattern>
</relocation>
<relocation>
<pattern>org.jetbrains</pattern>
<shadedPattern>net.t2code.libraries.jetbrains</shadedPattern>
</relocation>
<relocation>
<pattern>org.json</pattern>
<shadedPattern>net.t2code.libraries.json</shadedPattern>
<shadedPattern>net.t2code.t2codelib.shaded.adventure</shadedPattern>
</relocation>
</relocations>
</configuration>

View File

@ -105,12 +105,20 @@ public class T2CB_ConfigWriter {
// Add value with proper indentation
// builder.append(indent).append(key).append(": ").append(value).append("\n");
if (value instanceof List) {
builder.append(indent).append(key).append(": ").append("\n");
List<Object> zw = (List<Object>) value;
for (Object s : zw) {
if (s instanceof String) {
builder.append(indent).append("- \"").append(s).append("\"\n");
} else builder.append(indent).append("- ").append(s).append("\n");
List<?> list = (List<?>) value;
if (list.size() == 1){
for (Object s : list) {
if (s instanceof String) {
builder.append(indent).append(key).append(": \"").append(value).append("\"\n");
} else builder.append(indent).append(key).append(": ").append(value).append("\n");
}
} else {
builder.append(indent).append(key).append(": ").append("\n");
for (Object s : list) {
if (s instanceof String) {
builder.append(indent).append("- \"").append(s).append("\"\n");
} else builder.append(indent).append("- ").append(s).append("\n");
}
}
} else {
if (value instanceof String) {

View File

@ -1,6 +1,6 @@
package net.t2code.t2codelib.SPIGOT.api.commands;
import net.t2code.t2codelib.SPIGOT.system.BungeeCommandSenderReceiver;
import net.t2code.t2codelib.SPIGOT.system.T2C_ProxyCommandSenderReceiver;
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -17,7 +17,7 @@ public class T2C_Cmd {
@Override
public void run() {
if (cmd.contains("!onBungee")) {
BungeeCommandSenderReceiver.sendToBungee(null, cmd.replace("!onBungee", ""), true);
T2C_ProxyCommandSenderReceiver.sendToBungee(null, cmd.replace("!onBungee", ""), true);
} else Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
}
}, delay);
@ -32,11 +32,11 @@ public class T2C_Cmd {
public void run() {
if (cmd.contains("!asConsole")) {
if (cmd.contains("!onBungee")) {
BungeeCommandSenderReceiver.sendToBungee(player, cmd.replace("!asConsole", "").replace("!onBungee", ""), true);
T2C_ProxyCommandSenderReceiver.sendToBungee(player, cmd.replace("!asConsole", "").replace("!onBungee", ""), true);
} else console(cmd.replace("!asConsole", ""));
} else {
if (cmd.contains("!onBungee")) {
BungeeCommandSenderReceiver.sendToBungee(player, cmd.replace("!onBungee", ""), false);
T2C_ProxyCommandSenderReceiver.sendToBungee(player, cmd.replace("!onBungee", ""), false);
} else player.chat("/" + cmd);
}
}

View File

@ -1,58 +0,0 @@
package net.t2code.t2codelib.SPIGOT.api.messages;
import net.md_5.bungee.api.chat.ClickEvent;
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class T2C_HoverModule {
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")
+ "/*/" + (actionValue != null ? actionValue : "null"), player);
}
public static void modulePlayer(String msg, Player player) {
if (msg.contains("/*/")) {
t2cmodule(msg, player);
return;
}
T2C_MiniMessage.sendPlayerMiniMessage(msg, player);
}
public static void moduleSender(String msg, CommandSender sender) {
T2C_MiniMessage.sendSenderMiniMessage(msg, sender);
}
public static void moduleConsole(String msg) {
if (T2C_Main.getMmIsLoad()) {
T2C_MiniMessage.sendConsoleMiniMessage(msg);
return;
}
Bukkit.getConsoleSender().sendMessage(msg);
}
private static void t2cmodule(String msg, Player player) {
String[] split = msg.split("/\\*/");
int i = split.length;
String text = null;
String hover = null;
String action = null;
String actionValue = null;
if (i > 0) text = split[0];
if (i > 1) hover = split[1];
if (i > 2) action = split[2];
if (i > 3) actionValue = split[3];
T2C_TextBuilder textBuilder = new T2C_TextBuilder(text);
if (hover != null && !hover.equals("null")) {
textBuilder.addHover(hover);
}
if (action != null && actionValue != null && !action.equals("null") && !actionValue.equals("null")) {
textBuilder.addClickEvent(ClickEvent.Action.valueOf(action.toUpperCase()), actionValue);
}
player.spigot().sendMessage(textBuilder.build());
}
}

View File

@ -44,30 +44,30 @@ public class T2C_Send {
public static void console(String msg) {
if (msg == null || msg.contains("[empty]")) return;
T2C_HoverModule.moduleConsole(msg);
T2C_MiniMessage.sendConsoleMiniMessage(msg);
}
public static void player(Player player, String msg) {
if (msg == null || msg.contains("[empty]")) return;
T2C_HoverModule.modulePlayer(msg, player);
T2C_MiniMessage.sendPlayerMiniMessage(msg, player);
}
public static void sender(CommandSender sender, String msg) {
if (msg == null || msg.contains("[empty]")) return;
T2C_HoverModule.moduleSender(msg, sender);
T2C_MiniMessage.sendSenderMiniMessage(msg, sender);
}
public static void console(Object object) {
for (String msg : list(object)) {
if (msg == null || msg.contains("[empty]")) continue;
T2C_HoverModule.moduleConsole(msg);
T2C_MiniMessage.sendConsoleMiniMessage(msg);
}
}
public static void player(Player player, Object object) {
for (String msg : list(object)) {
if (msg == null || msg.contains("[empty]")) continue;
T2C_HoverModule.modulePlayer(msg, player);
T2C_MiniMessage.sendPlayerMiniMessage(msg, player);
}
}
@ -75,7 +75,7 @@ public class T2C_Send {
public static void sender(CommandSender sender, Object object) {
for (String msg : list(object)) {
if (msg == null || msg.contains("[empty]")) return;
T2C_HoverModule.moduleSender(msg, sender);
T2C_MiniMessage.sendSenderMiniMessage(msg, sender);
}
}

View File

@ -6,6 +6,7 @@ import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
import net.t2code.t2codelib.util.T2C_LanguageEnum;
import net.t2code.t2codelib.util.T2C_ConfigItem;
import net.t2code.t2codelib.util.T2C_Util;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
@ -19,7 +20,7 @@ public class T2C_ConfigWriter {
private static FileConfiguration config;
public static void createConfig(File configFile, T2C_ConfigItem[] values, String... header) {
public static void createConfig(String prefix, File configFile, T2C_ConfigItem[] values, boolean isReload, String... header) {
boolean exist = configFile.exists();
if (!exist) {
configFile.getParentFile().mkdirs();
@ -34,11 +35,20 @@ public class T2C_ConfigWriter {
config = YamlConfiguration.loadConfiguration(configFile);
Map<String, List<String>> comments = new LinkedHashMap<>();
T2C_LanguageEnum lang = T2C_LanguageEnum.english;
T2C_LanguageEnum lang = null;
String lp = values[0].getLanguagePath();
try {
lang = T2C_LanguageEnum.valueOf(config.getString(values[0].getLanguagePath().replace(".yml", "")));
lang = T2C_LanguageEnum.valueOf(lp);
} catch (Exception ignore) {
}
if (lang == null) {
try {
lang = T2C_LanguageEnum.valueOf(config.getString(lp.replace(".yml", "")));
} catch (Exception e) {
lang = T2C_LanguageEnum.english;
}
}
for (T2C_ConfigItem item : values) {
if (item.getForceSet() || !exist) {
@ -55,12 +65,16 @@ public class T2C_ConfigWriter {
config.options().copyDefaults(true);
T2C_YmlWriter.saveConfigWithComments(configFile, config, comments, header);
readConfig(config, values);
readConfig(prefix, configFile, config, values, isReload);
}
private static void readConfig(FileConfiguration config, T2C_ConfigItem[] values) {
private static void readConfig(String prefix, File configFile, FileConfiguration config, T2C_ConfigItem[] values, boolean isReload) {
for (T2C_ConfigItem value : values) {
value.setValue(config.get(value.getPath()));
}
T2C_Send.sendStartTextCenter(prefix, "§2" + configFile.getName() + " were successfully created / updated.", isReload);
//T2C_Send.sendStartTextCenter(Util.getPrefix(), "§2opWhitelist.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms",isReload);
}
}

View File

@ -54,18 +54,23 @@ public class T2C_YmlWriter {
// Add value with proper indentation
// builder.append(indent).append(key).append(": ").append(value).append("\n");
if (value instanceof List) {
List<?> list = (List<?>) value;
if (list.isEmpty()) {
builder.append(indent).append(key).append(": []").append("\n");
continue;
}
builder.append(indent).append(key).append(": ").append("\n");
List<Object> zw = (List<Object>) value;
for (Object s : zw) {
for (Object s : list) {
if (s instanceof String) {
builder.append(indent).append("- \"").append(s).append("\"\n");
} else builder.append(indent).append("- ").append(s).append("\n");
}
} else {
if (value instanceof String) {
builder.append(indent).append(key).append(": \"").append(value).append("\"\n");
} else builder.append(indent).append(key).append(": ").append(value).append("\n");
continue;
}
if (value instanceof String) {
builder.append(indent).append(key).append(": \"").append(value).append("\"\n");
} else builder.append(indent).append(key).append(": ").append(value).append("\n");
}
}
}

View File

@ -13,7 +13,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Arrays;
public class BungeeCommandSenderReceiver {
public class T2C_ProxyCommandSenderReceiver {
public static void sendToBungee(CommandSender sender, String information, Boolean console) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();

View File

@ -3,7 +3,7 @@ package net.t2code.t2codelib.SPIGOT.system.cmd;
import net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
import net.t2code.t2codelib.SPIGOT.system.BungeeCommandSenderReceiver;
import net.t2code.t2codelib.SPIGOT.system.T2C_ProxyCommandSenderReceiver;
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
import net.t2code.t2codelib.SPIGOT.system.config.languages.T2CLibLanguages;
@ -106,7 +106,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
cmd = cmd + s + " ";
}
cmd = cmd.replace("bcmd ", "");
BungeeCommandSenderReceiver.sendToBungee(null, cmd, true);
T2C_ProxyCommandSenderReceiver.sendToBungee(null, cmd, true);
T2C_Debug.debug(T2C_Main.getPlugin(), "PluginMessage BCMD: " + cmd);
return false;

View File

@ -63,6 +63,7 @@ public class Development implements Listener {
msg = msg + "<dark_red>" + plSt + "</dark_red>, ";
} else msg = msg + "<red>" + plSt + "</red>, ";
}
T2C_Send.player(player, removeLastChar(msg, 2));
}

View File

@ -61,7 +61,7 @@ public class T2C_LibConfig {
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
proxy("proxy.enable", T2C_Main.getIsBungee(), true,
proxy("For this option, the option proxy.enable in the config.yml of the T2CodeLib must be set to true and the T2CodeLib must also be present on the proxy in order to function as a bridge.", T2C_Main.getIsBungee(), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Diese Option muss aktiviert werden, wenn du die T2CodeLib auf einem BungeeCord, Waterfall oder Velocity Proxy als Bridge verwenden möchtest."
, "Bitte beachte, dass die einzelnen APIs der Plugins, die eine Bridge auf einem Proxy verwenden, in der config.yml der T2CodeLib auf dem Proxy aktiviert werden müssen!"));
@ -149,9 +149,7 @@ public class T2C_LibConfig {
public static void set(boolean isReload) {
long long_ = System.currentTimeMillis();
ConvertT2ClibConfig.convert();
T2C_ConfigWriter.createConfig(new File(T2C_Main.getPath(), "config.yml"), VALUES.values(), T2C_Util.getConfigLogo());
T2C_Send.sendStartTextCenter(T2C_Util.getPrefix(), "§2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", isReload);
T2C_ConfigWriter.createConfig(T2C_Util.getPrefix(), new File(T2C_Main.getPath(), "config.yml"), VALUES.values(), isReload, T2C_Util.getConfigLogo());
}
}

View File

@ -29,8 +29,8 @@ public class T2CLibLanguages {
vaultNotSetUp("plugin.vaultNotSetUp",
null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, "[prefix] &4Vault / Economy nicht eingerichtet!");
put(T2C_LanguageEnum.english, "[prefix] &4Vault / Economy not set up!");
put(T2C_LanguageEnum.german, List.of("[prefix] &4Vault / Economy nicht eingerichtet!"));
put(T2C_LanguageEnum.english,List.of( "[prefix] &4Vault / Economy not set up!"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Diese Meldung wird angezeigt, wenn ein Plugin auf die Vault Schnittstelle von T2CodeLib zugreift und Vault oder kein Economy System vorhanden ist."));
@ -40,8 +40,8 @@ public class T2CLibLanguages {
votingPluginNotSetUp("plugin.votingPluginNotSetUp",
null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, "[prefix] &4VotingPlugin ist auf dem Server nicht vorhanden!");
put(T2C_LanguageEnum.english, "[prefix] &4VotingPlugin is not present on the server!");
put(T2C_LanguageEnum.german, List.of("[prefix] &4VotingPlugin ist auf dem Server nicht vorhanden!"));
put(T2C_LanguageEnum.english, List.of("[prefix] &4VotingPlugin is not present on the server!"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Diese Meldung wird angezeigt, wenn ein Plugin auf die VotingPlugin Schnittstelle von T2CodeLib zugreift und VotingPlugin nicht vorhanden ist.", "VotingPlugin: https://spigotmc.org/resources/votingplugin.15358/"));
@ -50,22 +50,22 @@ public class T2CLibLanguages {
soundNotFound("plugin.soundNotFound",
null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, "[prefix] &4Der Sound &6[sound] &4wurde nicht gefunden! Bitte überprüfe die Einstellungen.");
put(T2C_LanguageEnum.english, "[prefix] &4The sound &6[sound] &4was not found! Please check the settings.");
put(T2C_LanguageEnum.german, List.of("[prefix] &4Der Sound &6[sound] &4wurde nicht gefunden! Bitte überprüfe die Einstellungen."));
put(T2C_LanguageEnum.english, List.of("[prefix] &4The sound &6[sound] &4was not found! Please check the settings."));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Diese Meldung wird angezeigt, wenn ein Sound über die T2CodeLib abgespielt werden soll, den es nicht gibt"));
put(T2C_LanguageEnum.english, List.of());
put(T2C_LanguageEnum.german, List.of("Diese Meldung wird angezeigt, wenn ein Sound über die T2CodeLib abgespielt werden soll, den es nicht gibt."));
put(T2C_LanguageEnum.english, List.of("This message is displayed if a sound is to be played via the T2CodeLib that does not exist."));
}}),
;
private final String path;
private Object value;
private final HashMap<T2C_LanguageEnum, String> lang;
private final HashMap<T2C_LanguageEnum, List<String>> lang;
private final HashMap<T2C_LanguageEnum, List<String>> comments;
VALUES(String path, Object value, @NonNull HashMap<T2C_LanguageEnum, String> lang, HashMap<T2C_LanguageEnum, List<String>> comments) {
VALUES(String path, Object value, @NonNull HashMap<T2C_LanguageEnum, List<String>> lang, HashMap<T2C_LanguageEnum, List<String>> comments) {
this.path = path;
this.value = value;
this.lang = lang;
@ -86,7 +86,7 @@ public class T2CLibLanguages {
}
@Override
public HashMap<T2C_LanguageEnum, String> getLanguage() {
public HashMap<T2C_LanguageEnum, List<String>> getLanguage() {
return lang;
}

View File

@ -147,12 +147,20 @@ public class T2CV_ConfigWriter {
// Add value with proper indentation
// builder.append(indent).append(key.getKey()).append(": ").append(value).append("\n");
if (value instanceof List) {
builder.append(indent).append(key.getKey()).append(": ").append("\n");
List<Object> zw = (List<Object>) value;
for (Object s : zw) {
if (s instanceof String) {
builder.append(indent).append("- \"").append(s).append("\"\n");
} else builder.append(indent).append("- ").append(s).append("\n");
List<?> list = (List<?>) value;
if (list.size() == 1){
for (Object s : list) {
if (s instanceof String) {
builder.append(indent).append(key.getKey()).append(": \"").append(value).append("\"\n");
} else builder.append(indent).append(key.getKey()).append(": ").append(value).append("\n");
}
}else {
builder.append(indent).append(key.getKey()).append(": ").append("\n");
for (Object s : list) {
if (s instanceof String) {
builder.append(indent).append("- \"").append(s).append("\"\n");
} else builder.append(indent).append("- ").append(s).append("\n");
}
}
} else {
if (value instanceof String) {

View File

@ -19,7 +19,7 @@ public interface T2C_ConfigItemLanguages {
*/
Object getValue();
HashMap<T2C_LanguageEnum, String> getLanguage();
HashMap<T2C_LanguageEnum, List<String>> getLanguage();
/**

View File

@ -131,7 +131,6 @@ public class T2C_GenerateFrame {
if (console && T2C_PlatformDetector.detectPlatform == T2C_PlatformDetector.PlatformType.VELOCITY) {
System.out.println("conole & velo");
colorCode = "";
nextLine = "\n";
}
@ -185,7 +184,6 @@ public class T2C_GenerateFrame {
// String miniMessageRegex = "<(?!br)(color:#([A-Fa-f0-9]{6})|[a-zA-Z_]+)(:[a-zA-Z0-9_]+)?>|</[a-zA-Z_]+>";
// return text.replaceAll("§[a-f0-9k-oK-O]", "").replaceAll(miniMessageRegex, "");
String s = MiniMessage.miniMessage().stripTags(text).replaceAll("§[a-f0-9k-oK-O]", "");
System.out.println(s);
return s;
}
}

View File

@ -27,7 +27,7 @@ public class T2C_Util {
private static Integer bstatsID = 12518;
@Getter
private static String spigot = "https://www.spigotmc.org/resources/" + getSpigotID();
private static String spigot = "https://spigotmc.org/resources/" + getSpigotID();
@Getter
private static String discord = "http://dc.t2code.net";