Recode Class Names

This commit is contained in:
2024-07-04 22:03:13 +02:00
parent a74710ed9a
commit 8678eee675
86 changed files with 1560 additions and 1676 deletions

View File

@@ -1,6 +1,6 @@
package net.t2code.t2codelib.SPIGOT.api.bungeePlayers;
public enum T2CbungeePlayersEnum {
public enum T2C_BngeePlayersEnum {
JOIN,
QUIT,
GIVEALL,

View File

@@ -1,36 +1,37 @@
package net.t2code.t2codelib.SPIGOT.api.bungeePlayers;
import lombok.Getter;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class T2CbungeePlayers implements PluginMessageListener {
public class T2C_BungeePlayers implements PluginMessageListener {
@Getter
private static List<String> bungeePlayers = new ArrayList<>();
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, byte[] message) {
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(message));
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "stream: " + stream.toString());
T2C_Debug.debug(T2CodeLibMain.getPlugin(), "stream: " + stream.toString());
try {
T2CbungeePlayersEnum subChannel = T2CbungeePlayersEnum.valueOf(stream.readUTF());
T2C_BngeePlayersEnum subChannel = T2C_BngeePlayersEnum.valueOf(stream.readUTF());
String input = stream.readUTF();
String uuid = stream.readUTF();
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received channel: " + channel);
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received subChannel: " + subChannel.name());
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received input: " + input);
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received input2/uuid: " + uuid);
T2C_Debug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received channel: " + channel);
T2C_Debug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received subChannel: " + subChannel.name());
T2C_Debug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received input: " + input);
T2C_Debug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received input2/uuid: " + uuid);
switch (subChannel) {
case JOIN:
bungeePlayers.add(input);
@@ -39,7 +40,7 @@ public class T2CbungeePlayers implements PluginMessageListener {
bungeePlayers.remove(input);
break;
case GIVEALL:
if (!T2CLibConfig.VALUES.serverUUID.getValue().equals(uuid)) {
if (!T2C_LibConfig.VALUES.serverUUID.getValue().equals(uuid)) {
return;
}
bungeePlayers.clear();
@@ -51,7 +52,7 @@ public class T2CbungeePlayers implements PluginMessageListener {
break;
}
} catch (IOException e) {
e.printStackTrace();
T2C_Send.sendException(e, T2CodeLibMain.getPlugin().getLogger());
}
}
@@ -68,17 +69,17 @@ public class T2CbungeePlayers implements PluginMessageListener {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream);
try {
output.writeUTF(T2CbungeePlayersEnum.GIVEALL.name());
output.writeUTF(T2CLibConfig.VALUES.serverUUID.getValue().toString());
output.writeUTF(T2C_BngeePlayersEnum.GIVEALL.name());
output.writeUTF(T2C_LibConfig.VALUES.serverUUID.getValue().toString());
} catch (IOException e) {
e.printStackTrace();
T2C_Send.sendException(e, T2CodeLibMain.getPlugin().getLogger());
}
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendPluginMessage(T2CodeLibMain.getPlugin(), "t2c:bonlp", stream.toByteArray());
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received channel: t2c:bonlp");
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage send subChannel: " + T2CbungeePlayersEnum.GIVEALL.name());
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage send output/uuid: " + T2CLibConfig.VALUES.serverUUID.getValue().toString());
player.sendPluginMessage(T2CodeLibMain.getPlugin(), Util.getPluginChannel_ProxyOnlinePlayers(), stream.toByteArray());
T2C_Debug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received channel: " + Util.getPluginChannel_ProxyOnlinePlayers());
T2C_Debug.debug(T2CodeLibMain.getPlugin(), "PluginMessage send subChannel: " + T2C_BngeePlayersEnum.GIVEALL.name());
T2C_Debug.debug(T2CodeLibMain.getPlugin(), "PluginMessage send output/uuid: " + T2C_LibConfig.VALUES.serverUUID.getValue().toString());
return;
}
}

View File

@@ -1,17 +1,14 @@
package net.t2code.t2codelib.SPIGOT.api.commands;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
import net.t2code.t2codelib.SPIGOT.system.BungeeCommandSenderReceiver;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.rmi.MarshalledObject;
import java.util.Map;
public class T2Ccmd {
public class T2C_Cmd {
public static void console(String cmdInput) {
Map.Entry<String,Integer> map = delay(cmdInput);
int delay = map.getValue();
@@ -20,7 +17,7 @@ public class T2Ccmd {
@Override
public void run() {
if (cmd.contains("!onBungee")) {
T2CbungeeCommandSenderReciver.sendToBungee(null, cmd.replace("!onBungee", ""), true);
BungeeCommandSenderReceiver.sendToBungee(null, cmd.replace("!onBungee", ""), true);
} else Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
}
}, delay);
@@ -35,11 +32,11 @@ public class T2Ccmd {
public void run() {
if (cmd.contains("!asConsole")) {
if (cmd.contains("!onBungee")) {
T2CbungeeCommandSenderReciver.sendToBungee(player, cmd.replace("!asConsole", "").replace("!onBungee", ""), true);
BungeeCommandSenderReceiver.sendToBungee(player, cmd.replace("!asConsole", "").replace("!onBungee", ""), true);
} else console(cmd.replace("!asConsole", ""));
} else {
if (cmd.contains("!onBungee")) {
T2CbungeeCommandSenderReciver.sendToBungee(player, cmd.replace("!onBungee", ""), false);
BungeeCommandSenderReceiver.sendToBungee(player, cmd.replace("!onBungee", ""), false);
} else player.chat("/" + cmd);
}
}

View File

@@ -8,7 +8,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class T2Ctab {
public class T2C_Tab {
public static void tab(List<String> matches, CommandSender sender, int arg, String[] args, String perm, Boolean onlinePlayer) {
if (args.length != arg + 1) return;
for (Player player1 : Bukkit.getOnlinePlayers()) {

View File

@@ -1,12 +1,12 @@
package net.t2code.t2codelib.SPIGOT.api.debug;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import java.util.UUID;
public class T2Cdebug {
public class T2C_Debug {
public static void debug(Plugin plugin, String msg) {
debug(plugin, msg, null);
}
@@ -15,19 +15,19 @@ public class T2Cdebug {
// if (!new File(Main.getPath(), "config.yml").exists()) return;
if (stage == null) {
if (plugin.getConfig().getBoolean("Plugin.Debug") || plugin.getConfig().getBoolean("plugin.debug") || plugin.getConfig().getBoolean("Debug") || plugin.getConfig().getBoolean("debug")){
T2Csend.info(plugin, "");
T2C_Send.info(plugin, "");
Bukkit.getConsoleSender().sendMessage(plugin.getDescription().getPrefix() + " §5DEBUG: §6" + msg);
}
return;
}
if (plugin.getConfig().getInt("Plugin.Debug") >= stage || plugin.getConfig().getInt("plugin.debug") >= stage || plugin.getConfig().getInt("Debug") >= stage || plugin.getConfig().getInt("debug") >= stage) {
T2Csend.info(plugin, "");
T2C_Send.info(plugin, "");
Bukkit.getConsoleSender().sendMessage(plugin.getDescription().getPrefix() + " §5DEBUG: §6" + msg);
}
}
public static void debugmsg(Plugin plugin, String msg) {
T2Csend.warning(plugin, "");
T2C_Send.warning(plugin, "");
Bukkit.getConsoleSender().sendMessage("§e[" + plugin.getDescription().getPrefix() + "] §5DEBUG-MSG: §6" + msg);
}

View File

@@ -1,6 +1,6 @@
package net.t2code.t2codelib.SPIGOT.api.dev;
public class T2CdevelopmentTool {
public class T2C_DevelopmentTool {
public static String removeLastChar(String s, int amount) {
return (s == null || s.length() == 0)
? null

View File

@@ -1,8 +1,8 @@
package net.t2code.t2codelib.SPIGOT.api.eco;
import com.bencodez.votingplugin.VotingPluginMain;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2C_PluginCheck;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.SPIGOT.system.config.languages.T2CLibLanguages;
@@ -11,7 +11,7 @@ import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class T2Ceco {
public class T2C_Eco {
public static boolean moneyRemove(String prefix, Player player, Double price) {
if (vault(prefix, player)) {
return T2CodeLibMain.getEco().withdrawPlayer(player, price).transactionSuccess();
@@ -29,7 +29,7 @@ public class T2Ceco {
private static boolean vault(String prefix, Player player) {
if (T2CodeLibMain.getEco() == null) {
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
T2Csend.console(prefix + " §e║ "+ "§4\n" + prefix + " §e║ " + "§4Vault could not be found! §9Please download it here: " +
T2C_Send.console(prefix + " §e║ "+ "§4\n" + prefix + " §e║ " + "§4Vault could not be found! §9Please download it here: " +
"§6https://www.spigotmc.org/resources/vault.34315/§4\n" + prefix + " §e║ ");
}
player.sendMessage(prefix + "\n" + T2CLibLanguages.VALUES.vaultNotSetUp.getValue().toString() + "\n" + prefix);
@@ -85,8 +85,8 @@ public class T2Ceco {
}
private static boolean votePlugin(String prefix, Player player) {
if (T2CpluginCheck.votingPlugin()) return true;
T2Csend.console(prefix + " §e║ " + "§4\n" + prefix + " §e║ " + "§4VotingPlugin could not be found! §9Please download it here: " +
if (T2C_PluginCheck.votingPlugin()) return true;
T2C_Send.console(prefix + " §e║ " + "§4\n" + prefix + " §e║ " + "§4VotingPlugin could not be found! §9Please download it here: " +
"§6https://www.spigotmc.org/resources/votingplugin.15358/§4\n" + prefix + " §e║ ");
player.sendMessage(prefix + "\n" + T2CLibLanguages.VALUES.votingPluginNotSetUp.getValue().toString() + "\n" + prefix);
return false;

View File

@@ -2,7 +2,9 @@ package net.t2code.t2codelib.SPIGOT.api.items;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
@@ -22,8 +24,8 @@ import org.json.JSONObject;
import java.util.List;
import java.util.UUID;
public class T2CitemBuilder {
public static final boolean getLegacy = T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12();
public class T2C_ItemBuilder {
public static final boolean getLegacy = T2C_McVersion.isMc1_8() || T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12();
public static void fillItem(boolean enable, String item, Integer lines, Inventory inventory) {
if (!enable) return;
@@ -45,7 +47,7 @@ public class T2CitemBuilder {
inventory.setItem(i, glass);
}
} catch (Exception e) {
e.printStackTrace();
T2C_Send.sendException(e, T2CodeLibMain.getPlugin().getLogger());
}
}
@@ -76,13 +78,13 @@ public class T2CitemBuilder {
}
public static ItemStack base64(String base64Value) {
if (!T2CmcVersion.minMc1_20() || T2CmcVersion.isNms1_20_R1()|| T2CmcVersion.isNms1_20_R2()|| T2CmcVersion.isNms1_20_R3()) {
if (!T2C_McVersion.minMc1_20() || T2C_McVersion.isNms1_20_R1()|| T2C_McVersion.isNms1_20_R2()|| T2C_McVersion.isNms1_20_R3()) {
return base64Old(base64Value);
} else return base64New(base64Value);
}
private static ItemStack base64Old(String base64Value) {
ItemStack itemStack = new ItemStack(T2CitemVersion.getHead());
ItemStack itemStack = new ItemStack(T2C_ItemVersion.getHead());
SkullMeta itemMeta = (SkullMeta) itemStack.getItemMeta();
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
@@ -93,7 +95,7 @@ public class T2CitemBuilder {
profileField.setAccessible(true);
profileField.set(itemMeta, profile);
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
e.printStackTrace();
T2C_Send.sendException(e, T2CodeLibMain.getPlugin().getLogger());
}
itemStack.setItemMeta(itemMeta);
@@ -101,7 +103,7 @@ public class T2CitemBuilder {
}
private static ItemStack base64New(String base64Value) {
ItemStack itemStack = new ItemStack(T2CitemVersion.getHead());
ItemStack itemStack = new ItemStack(T2C_ItemVersion.getHead());
SkullMeta itemMeta = (SkullMeta) itemStack.getItemMeta();
PlayerProfile profile = Bukkit.createPlayerProfile(UUID.randomUUID());

View File

@@ -1,11 +1,11 @@
package net.t2code.t2codelib.SPIGOT.api.items;
import lombok.Getter;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public class T2CitemVersion {
public class T2C_ItemVersion {
@Getter
private static Material Head;
@Getter
@@ -28,7 +28,7 @@ public class T2CitemVersion {
private static ItemStack BlackStainedGlassPane;
public static void scan() {
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
if (T2C_McVersion.isMc1_8() || T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) {
Head = Material.valueOf("SKULL_ITEM");
YellowWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 4);
OrangeWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 1);

View File

@@ -0,0 +1,145 @@
// This class was created by JaTiTV.
package net.t2code.t2codelib.SPIGOT.api.messages;
public class T2C_GernerateFrame {
protected static final String BOTTOM_BORDER = "╚═══════════════════════════════════════════════════════════════════════════╝";
private static final int FIXED_WIDTH = BOTTOM_BORDER.length() - 2; // Länge ohne die Randzeichen
private static final String COLOR_CODE = "§e";
private static final String BORDER_CHAR = "";
private static final String TOP_LEFT = "";
private static final String TOP_RIGHT = "";
private static final String BOTTOM_LEFT = "";
private static final String BOTTOM_RIGHT = "";
private static final String SIDE_BORDER = "";
public static String setCenterAligned(String prefix, String text) {
// Entfernen von Farbcodes aus der Berechnungslänge
String textWithoutColor = removeColorCodes(text);
int textLengthWithoutColor = textWithoutColor.length();
int totalPaddingSize = FIXED_WIDTH - textLengthWithoutColor;
// Sicherstellen, dass das Padding nicht negativ wird
if (totalPaddingSize < 0) totalPaddingSize = 0;
// Berechnung des Abstands vor und nach dem Text
int paddingLeft = totalPaddingSize / 2;
int paddingRight = totalPaddingSize - paddingLeft;
// Formatierung der Zeile: Text zentrieren
String formattedValue = "§e║" + " ".repeat(paddingLeft) + text + " ".repeat(paddingRight) + "§e║";
//T2Csend.console(prefix + " " + formattedValue);
return prefix + " " + formattedValue;
}
public static String setLeftAligned(String prefix, String text) {
// Entfernen von Farbcodes aus der Berechnungslänge
String textWithoutColor = removeColorCodes(text);
int textLengthWithoutColor = textWithoutColor.length();
int totalPaddingSize = FIXED_WIDTH - textLengthWithoutColor;
// Sicherstellen, dass das Padding nicht negativ wird
if (totalPaddingSize < 0) totalPaddingSize = 0;
// Berechnung des Abstands nach dem Text und vor dem Rand
int paddingRight = totalPaddingSize; // Alles Padding geht nach rechts
// Formatierung der Zeile: Text am Anfang und dynamischer Abstand zum Ende
String formattedValue = "§e║ " + text + " ".repeat((paddingRight - 1)) + "";
System.out.println(formattedValue);
T2C_Send.console(prefix + " " + formattedValue);
return prefix + " " + formattedValue;
}
// Methode für mehrere Zeilen Text mit dynamischem Rahmen
public static String sendFrameLeft(String prefix, String... lines) {
// Entfernen von Farbcodes und Berechnung der maximalen Länge
int maxLength = 0;
for (String line : lines) {
String lineWithoutColor = removeColorCodes(line);
maxLength = Math.max(maxLength, lineWithoutColor.length());
}
// Berechnung der Rahmenbreite
int frameWidth = maxLength + 2; // +2 für die Ränder '║'
String topBorder = COLOR_CODE + TOP_LEFT + BORDER_CHAR.repeat(frameWidth) + COLOR_CODE + TOP_RIGHT;
String bottomBorder = COLOR_CODE + BOTTOM_LEFT + BORDER_CHAR.repeat(frameWidth) + COLOR_CODE + BOTTOM_RIGHT;
// Gehe durch jede Zeile und formatiere sie
StringBuilder builder = new StringBuilder();
// Ausgabe der oberen Linie
builder.append("<br>").append(prefix).append(" ").append(topBorder).append("<br>");
for (String line : lines) {
// Entfernen von Farbcodes aus der Berechnungslänge
String lineWithoutColor = removeColorCodes(line);
int lineLengthWithoutColor = lineWithoutColor.length();
int totalPaddingSize = frameWidth - lineLengthWithoutColor; // -2 für die Ränder '║'
// Sicherstellen, dass das Padding nicht negativ wird
if (totalPaddingSize < 0) totalPaddingSize = 0;
// Berechnung des Abstands nach dem Text und vor dem Rand
int paddingLeft = 0; // Kein zusätzlicher Abstand vor dem Text
int paddingRight = totalPaddingSize; // Alles Padding geht nach rechts
// Formatierung der Zeile: Text am Anfang und dynamischer Abstand zum Ende
String formattedValue = COLOR_CODE + SIDE_BORDER + line + " ".repeat(paddingRight) + COLOR_CODE + SIDE_BORDER;
builder.append(prefix).append(" ").append(formattedValue).append("<br>");
}
// Ausgabe der unteren Linie
builder.append(prefix).append(" ").append(bottomBorder);
// T2Csend.console(builder.toString());
return builder.toString();
}
public static String sendFrameCenter(String prefix, String... lines) {
// Entfernen von Farbcodes und Berechnung der maximalen Länge
int maxLength = 0;
for (String line : lines) {
String lineWithoutColor = removeColorCodes(line);
maxLength = Math.max(maxLength, lineWithoutColor.length());
}
// Berechnung der Rahmenbreite
int frameWidth = maxLength + 2; // +2 für die Ränder '║'
String topBorder = COLOR_CODE + TOP_LEFT + BORDER_CHAR.repeat(frameWidth) + COLOR_CODE + TOP_RIGHT;
String bottomBorder = COLOR_CODE + BOTTOM_LEFT + BORDER_CHAR.repeat(frameWidth) + COLOR_CODE + BOTTOM_RIGHT;
// Gehe durch jede Zeile und formatiere sie
StringBuilder builder = new StringBuilder();
// Ausgabe der oberen Linie
builder.append("<br>").append(prefix).append(" ").append(topBorder).append("<br>");
for (String line : lines) {
// Entfernen von Farbcodes aus der Berechnungslänge
String lineWithoutColor = removeColorCodes(line);
int lineLengthWithoutColor = lineWithoutColor.length();
int totalPaddingSize = frameWidth - lineLengthWithoutColor; // -2 für die Ränder '║'
// Sicherstellen, dass das Padding nicht negativ wird
if (totalPaddingSize < 0) totalPaddingSize = 0;
// Berechnung des Abstands vor und nach dem Text
int paddingLeft = totalPaddingSize / 2;
int paddingRight = totalPaddingSize - paddingLeft;
// Formatierung der Zeile: Text zentrieren
String formattedValue = COLOR_CODE + SIDE_BORDER + " ".repeat(paddingLeft) + line + " ".repeat(paddingRight) + COLOR_CODE + SIDE_BORDER;
builder.append(prefix).append(" ").append(formattedValue).append("<br>");
}
// Ausgabe der unteren Linie
builder.append(prefix).append(" ").append(bottomBorder);
// T2Csend.console(builder.toString());
return builder.toString();
}
// Methode zum Entfernen von Farbcodes und MiniMessage-Farbcodes aus dem Text, außer <br>
private static String removeColorCodes(String text) {
// Regex für alle Farbcodes und MiniMessage-Codes außer <br>
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, "");
}
}

View File

@@ -6,7 +6,7 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class T2ChoverModule {
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")
@@ -18,16 +18,16 @@ public class T2ChoverModule {
t2cmodule(msg, player);
return;
}
T2CminiMessage.sendPlayerMiniMessage(msg, player);
T2C_MiniMessage.sendPlayerMiniMessage(msg, player);
}
public static void moduleSender(String msg, CommandSender sender) {
T2CminiMessage.sendSenderMiniMessage(msg, sender);
T2C_MiniMessage.sendSenderMiniMessage(msg, sender);
}
public static void moduleConsole(String msg) {
if (T2CodeLibMain.getMmIsLoad()) {
T2CminiMessage.sendConsoleMiniMessage(msg);
T2C_MiniMessage.sendConsoleMiniMessage(msg);
return;
}
Bukkit.getConsoleSender().sendMessage(msg);
@@ -45,7 +45,7 @@ public class T2ChoverModule {
if (i > 2) action = split[2];
if (i > 3) actionValue = split[3];
T2CtextBuilder textBuilder = new T2CtextBuilder(text);
T2C_TextBuilder textBuilder = new T2C_TextBuilder(text);
if (hover != null && !hover.equals("null")) {
textBuilder.addHover(hover);
}

View File

@@ -7,14 +7,14 @@ import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class T2CminiMessage {
public class T2C_MiniMessage {
private static final BukkitAudiences bukkitAudiences = T2CodeLibMain.getPlugin().getAdventure();
public static void sendSenderMiniMessage(String msg, CommandSender sender) {
String string = "";
if (sender instanceof Player) {
Player player = (Player) sender;
string =T2Creplace.replace("",player,msg);
string = T2C_Replace.replace("",player,msg);
} else string = msg;
bukkitAudiences.sender(sender).sendMessage(replace(string));
}
@@ -24,10 +24,10 @@ public class T2CminiMessage {
}
public static void sendPlayerMiniMessage(String msg, Player player) {
bukkitAudiences.player(player).sendMessage(replace(T2Creplace.replace("", player, msg)));
bukkitAudiences.player(player).sendMessage(replace(T2C_Replace.replace("", player, msg)));
}
protected static Component replace(String text) {
return MiniMessage.miniMessage().deserialize(T2Creplace.convertColorCode(text));
return MiniMessage.miniMessage().deserialize(T2C_Replace.convertColorCode(text));
}
}

View File

@@ -0,0 +1,117 @@
package net.t2code.t2codelib.SPIGOT.api.messages;
import me.clip.placeholderapi.PlaceholderAPI;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2C_PluginCheck;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class T2C_Replace {
private static final Map<String, String> REPLACEMENTS = Map.of(
"[ue]", "ü", "[UE]", "Ü",
"[oe]", "ö", "[OE]", "Ö",
"[ae]", "ä", "[AE]", "Ä",
"[nl]", "\n"
);
public static String replace(String prefix, String text) {
return replacePlaceholders(replaceLegacyColor(text), prefix, null, null);
}
public static String replace(String prefix, Player player, String text) {
return replacePlaceholders(replaceLegacyColor(text), prefix, player, null);
}
public static Object replaceObject(String prefix, Object object) {
return replaceObjectPlaceholders(object, prefix, null, null);
}
public static Object replaceObject(String prefix, Player player, Object object) {
return replaceObjectPlaceholders(object, prefix, player, null);
}
public static List<String> replace(String prefix, List<String> texts) {
return replacePlaceholdersInList(texts, prefix, null, null);
}
public static List<String> replace(String prefix, Player player, List<String> texts) {
return replacePlaceholdersInList(texts, prefix, player, null);
}
public static List<String> replacePrice(String prefix, List<String> texts, String price) {
return replacePlaceholdersInList(texts, prefix, null, price);
}
public static List<String> replacePrice(String prefix, Player player, List<String> texts, String price) {
return replacePlaceholdersInList(texts, prefix, player, price);
}
public static String replacePrice(String prefix, String text, String price) {
return replacePlaceholders(replaceLegacyColor(text), prefix, null, price);
}
public static String replacePrice(String prefix, Player player, String text, String price) {
return replacePlaceholders(replaceLegacyColor(text), prefix, player, price);
}
public static String removeColorCode(String value) {
return value.replaceAll("&[0-9a-fk-or]", "");
}
public static String replaceLegacyColor(String text) {
return text.replaceAll("&([0-9a-fk-or])", "§$1");
}
public static String convertColorCode(String text) {
return text.replaceAll("&([0-9a-fk-or])", "<$1>").replaceAll("§([0-9a-fk-or])", "<$1>");
}
public static Object replace(Object object, String placeholder, String replacement) {
if (object instanceof String) {
return ((String) object).replace(placeholder, replacement);
} else if (object instanceof List) {
List<String> list = (List<String>) object;
List<String> output = new ArrayList<>();
for (String item : list) {
output.add(item.replace(placeholder, replacement));
}
return output;
}
return object;
}
private static String replacePlaceholders(String text, String prefix, Player player, String price) {
text = text.replace("[prefix]", prefix);
for (Map.Entry<String, String> entry : REPLACEMENTS.entrySet()) {
text = text.replace(entry.getKey(), entry.getValue());
}
if (price != null) {
text = text.replace("[price]", price);
}
if (player != null && T2C_PluginCheck.papi()) {
text = PlaceholderAPI.setPlaceholders(player, text);
}
return text;
}
private static List<String> replacePlaceholdersInList(List<String> texts, String prefix, Player player, String price) {
List<String> output = new ArrayList<>();
for (String text : texts) {
output.add(replacePlaceholders(replaceLegacyColor(text), prefix, player, price));
}
return output;
}
private static Object replaceObjectPlaceholders(Object object, String prefix, Player player, String price) {
if (object instanceof String) {
return replacePlaceholders(replaceLegacyColor((String) object), prefix, player, price);
} else if (object instanceof List) {
return replacePlaceholdersInList((List<String>) object, prefix, player, price);
}
return object;
}
}

View File

@@ -1,7 +1,6 @@
package net.t2code.t2codelib.SPIGOT.api.messages;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import org.bukkit.Bukkit;
import net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@@ -10,35 +9,63 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
public class T2Csend {
public class T2C_Send {
public static String sendStartTextCenter(String prefix, String text, boolean isReload) {
if (isReload) {
return prefix + " " + text;
}
return T2C_GernerateFrame.setCenterAligned(prefix,text);
}
public static String sendStartTextLeft(String prefix, String text, boolean isReload) {
if (isReload) {
return prefix + " " + text;
}
return T2C_GernerateFrame.setLeftAligned(prefix, text);
}
public static String sendFrameCenter(String prefix, String... lines){
return T2C_GernerateFrame.sendFrameCenter(prefix, lines);
}
public static String sendFrameLeft(String prefix, String... lines){
return T2C_GernerateFrame.sendFrameLeft(prefix, lines);
}
public static void sendException(Exception e, Logger logger){
logger.log(Level.SEVERE,"Interrupted exception occurred", e);
}
public static void console(String msg) {
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleConsole(msg);
T2C_HoverModule.moduleConsole(msg);
}
public static void player(Player player, String msg) {
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.modulePlayer(msg, player);
T2C_HoverModule.modulePlayer(msg, player);
}
public static void sender(CommandSender sender, String msg) {
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleSender(msg, sender);
T2C_HoverModule.moduleSender(msg, sender);
}
public static void console(Object object) {
for (String msg : list(object)){
if (msg == null || msg.contains("[empty]")) continue;
T2ChoverModule.moduleConsole(msg);
T2C_HoverModule.moduleConsole(msg);
}
}
public static void player(Player player, Object object) {
for (String msg : list(object)){
if (msg == null || msg.contains("[empty]")) continue;
T2ChoverModule.modulePlayer(msg, player);
T2C_HoverModule.modulePlayer(msg, player);
}
}
@@ -46,7 +73,7 @@ public class T2Csend {
public static void sender(CommandSender sender, Object object) {
for (String msg : list(object)){
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleSender(msg, sender);
T2C_HoverModule.moduleSender(msg, sender);
}
}
@@ -59,29 +86,31 @@ public class T2Csend {
}
/**
* @Deprecated Use: T2Cdebug.debug(Plugin plugin, String msg) or T2Cdebug.debug(Plugin plugin, String msg, Integer stage)
* @deprecated This method will be removed soon, as the debug messages have been moved to a separate class.
* Please use the new method {@link T2C_Debug#debug(Plugin, String)} or {@link T2C_Debug#debug(Plugin, String, Integer)}
*/
@Deprecated
@Deprecated(since = "16.7", forRemoval = true)
public static void debug(Plugin plugin, String msg) {
debug(plugin, msg, null);
}
/**
* @Deprecated Use: T2Cdebug.debug(Plugin plugin, String msg) or T2Cdebug.debug(Plugin plugin, String msg, Integer stage)
* @deprecated This method will be removed soon, as the debug messages have been moved to a separate class.
* Please use the new method {@link T2C_Debug#debug(Plugin, String)} or {@link T2C_Debug#debug(Plugin, String, Integer)}
*/
@Deprecated
@Deprecated(since = "16.7", forRemoval = true)
public static void debug(Plugin plugin, String msg, Integer stage) {
// if (!new File(Main.getPath(), "config.yml").exists()) return;
T2Cdebug.debug(plugin, msg, stage);
T2C_Debug.debug(plugin, msg, stage);
}
/**
*
* Use: T2Cdebug.debugmsg(plugin, msg)
* @deprecated This method will be removed soon, as the debug messages have been moved to a separate class.
* Please use the new method {@link T2C_Debug#debugmsg(Plugin, String)}
*/
@Deprecated
@Deprecated(since = "16.7", forRemoval = true)
public static void debugmsg(Plugin plugin, String msg) {
T2Cdebug.debugmsg(plugin, msg);
T2C_Debug.debugmsg(plugin, msg);
}
public static void info(Plugin plugin, String msg) {

View File

@@ -0,0 +1,135 @@
package net.t2code.t2codelib.SPIGOT.api.messages;
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.Util;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class T2C_Template {
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord) {
return onLoadHeader(prefix, autor, version, spigot, discord, null, null);
}
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium, Boolean isVerify) {
Long long_ = System.currentTimeMillis();
for (String s : Util.getLoadLogo()) {
T2C_Send.console(prefix + " §e" + s);
}
T2C_Send.sendStartTextCenter(prefix, "§2Author §6" + String.valueOf(autor).replace("[", "").replace("]", ""), false);
T2C_Send.sendStartTextCenter(prefix, "§2Version: §6" + version, false);
T2C_Send.sendStartTextCenter(prefix, "§2Spigot: §6" + spigot, false);
T2C_Send.sendStartTextCenter(prefix, "§2Discord: §6" + discord, false);
if (isPremium != null) {
if (isPremium) {
T2C_Send.sendStartTextCenter(prefix, "§6Premium: §2true", false);
} else T2C_Send.sendStartTextCenter(prefix, "§6Premium: §4false", false);
if (isVerify != null) {
if (isVerify) {
T2C_Send.sendStartTextCenter(prefix, "§6Verify: §2true", false);
} else T2C_Send.sendStartTextCenter(prefix, "§6Verify: §4false", false);
} else T2C_Send.sendStartTextCenter(prefix, "§6Verify: §4false", false);
}
onLoadSeparateStroke(prefix);
if (version.toLowerCase().contains("dev") || version.toLowerCase().contains("snapshot") || version.toLowerCase().contains("beta")) {
T2C_Send.sendStartTextCenter(prefix, "", false);
T2C_Send.sendStartTextCenter(prefix, "", false);
T2C_Send.sendStartTextCenter(prefix, "§eYou are running §4" + version + " §eof §4" + prefix + "§e!", false);
T2C_Send.sendStartTextCenter(prefix, "§eSome features may not be working as expected.", false);
T2C_Send.sendStartTextCenter(prefix, "§ePlease report all bugs here: http://dc.t2code.net", false);
T2C_Send.sendStartTextCenter(prefix, "§4UpdateChecker & bStats may be disabled!", false);
T2C_Send.sendStartTextCenter(prefix, "", false);
T2C_Send.sendStartTextCenter(prefix, "", false);
onLoadSeparateStroke(prefix);
try {
Thread.sleep(2000);
} catch (Exception ignored) {
}
}
return long_;
}
public static void onLoadSeparateStroke(String prefix) {
T2C_Send.console(prefix + " §e╠═══════════════════════════════════════════════════════════════════════════╣");
}
public static void onLoadFooter(String prefix, Long long_) {
onLoadSeparateStroke(prefix);
T2C_Send.sendStartTextCenter(prefix, "§2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
T2C_Send.console(prefix + " §e" + T2C_GernerateFrame.BOTTOM_BORDER);
}
public static void onDisable(String prefix, Plugin plugin) {
T2C_Send.sendFrameCenter(prefix, " §2Version: §6" + plugin.getDescription().getVersion(), "§2Autors: §6" + String.valueOf(plugin.getDescription().getAuthors()).replace("[", "").replace("]", ""), " §4Plugin successfully disabled. ");
}
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, Boolean premiumVerified, String text) {
String pluginVersion = plugin.getDescription().getVersion();
String publicVersion = "";
boolean update;
String stNVersion;
T2CupdateWebData webData;
try {
webData = T2C_UpdateAPI.pluginVersions.get(plugin.getName()).webData;
} catch (Exception ex) {
webData = null;
}
if (webData != null) {
publicVersion = T2C_UpdateAPI.pluginVersions.get(plugin.getName()).webData.getVersion();
update = !publicVersion.equalsIgnoreCase(pluginVersion);
} else {
update = false;
}
boolean player = sender instanceof Player;
String stPlugin = "<dark_red>║</dark_red> <yellow>Plugin:</yellow> <gold>[pl]</gold>".replace("[pl]", plugin.getName());
String stVersion = "<dark_red>║</dark_red> <yellow>Version:</yellow> <gold>[ver]</gold>".replace("[ver]", pluginVersion);
String stAutor = "<dark_red>║</dark_red> <yellow>Autor(s):</yellow> <gold>[autor]</gold>".replace("[autor]", plugin.getDescription().getAuthors().toString());
String stUpdate = "<dark_red>║</dark_red> <yellow>New version available:</yellow> [up]".replace("[up]", webData != null ? update ?
"<dark_green>YES</dark_green>" : "<red>no</red>" : "<b><dark_red>It could not be checked for updates!</dark_red></b>");
stNVersion = update ? "<br><dark_red>║</dark_red> <yellow>Newest Version:</yellow> <gold>[newVersion]</gold>".replace("[newVersion]", player ? "<hover:show_text:'<yellow>Click for the update information</yellow>'><click:run_command:'/t2code updateinfo " + plugin.getName() + "'>" + publicVersion + "</click></hover>" : publicVersion) : "";
String stLink = getString(spigotID, discord, player);
String pr = premiumVerified != null ? "<br><dark_red>║</dark_red> <yellow>Premium verified:</yellow> [pr]".replace("[pr]",
premiumVerified ? "<dark_green>YES</dark_green>" : "<red>NO</red>") : "";
String stMSG = text == null || text.isEmpty() ? "" : "<br><dark_red>║</dark_red> " + text;
T2C_Send.sender(sender, "<br><dark_red>╔════════════════════════════════</dark_red>"
+ "<br>" + stPlugin
+ "<br>" + stVersion
+ stMSG
+ "<br>" + stAutor
+ "<br>" + stUpdate
+ stNVersion
+ "<br>" + stLink
+ pr
+ "<br><dark_red>╚════════════════════════════════</dark_red>");
}
private static @NotNull String getString(int spigotID, String discord, boolean player) {
String stLinkPlayer = "<dark_red>║</dark_red> <yellow><hover:show_text:'<green>Go to the Spigot page</green>'><click:open_url:'[slink]'>Spigot</click></hover></yellow> "
.replace("[slink]", "https://www.spigotmc.org/resources/" + spigotID)
+ "<dark_red>-</dark_red> <dark_purple><hover:show_text:'<green>Go to the T2Code Support Discord</green>'><click:open_url:'[dlink]'>Discord</click></hover></dark_purple>"
.replace("[dlink]", discord);
String stLinkConsole = "<dark_red>║</dark_red> <yellow>Spigot:</yellow> <gold>https://www.spigotmc.org/resources/" + spigotID + "</gold>"
+ "<br><dark_red>║</dark_red> <yellow>Discord:</yellow> <gold>" + discord + "</gold>";
return player ? stLinkPlayer : stLinkConsole;
}
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, String text) {
sendInfo(sender, plugin, spigotID, discord, null, text);
}
}

View File

@@ -5,23 +5,23 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
public class T2CtextBuilder {
public class T2C_TextBuilder {
private final String text;
private String hover;
private String click;
private ClickEvent.Action action;
public T2CtextBuilder(String text) {
public T2C_TextBuilder(String text) {
this.text = text;
}
public T2CtextBuilder addHover(String hover) {
public T2C_TextBuilder addHover(String hover) {
this.hover = hover;
return this;
}
public T2CtextBuilder addClickEvent(ClickEvent.Action clickEventAction, String value) {
public T2C_TextBuilder addClickEvent(ClickEvent.Action clickEventAction, String value) {
this.action = clickEventAction;
this.click = value;
return this;

View File

@@ -1,230 +0,0 @@
package net.t2code.t2codelib.SPIGOT.api.messages;
import me.clip.placeholderapi.PlaceholderAPI;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class T2Creplace {
public static String replace(String prefix, String Text) {
return replaceLegacyColor(Text).replace("[prefix]", prefix).replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n");
}
public static String replace(String prefix, Player player, String Text) {
String input = Text.replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n");
if (T2CpluginCheck.papi()) {
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input));
} else {
return replaceLegacyColor(input);
}
}
public static Object replaceObject(String prefix, Object object) {
if (object instanceof String) {
object = replaceLegacyColor((String) object).replace("[prefix]", prefix).replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n");
}
if ((object instanceof List) || (object instanceof ArrayList)) {
List<String> in = (List<String>) object;
List<String> output = new ArrayList<>();
for (String input : in) {
output.add(replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n"));
}
object = output;
}
return object;
}
public static Object replaceObject(String prefix, Player player, Object object) {
if (object instanceof String) {
if (T2CpluginCheck.papi()) {
object = PlaceholderAPI.setPlaceholders(player, replaceLegacyColor((String) object).replace("[prefix]", prefix).replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n"));
} else {
object = replaceLegacyColor((String) object).replace("[prefix]", prefix).replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n");
}
}
if (object instanceof List) {
List<String> in = (List<String>) object;
List<String> output = new ArrayList<>();
for (String input : in) {
if (T2CpluginCheck.papi()) {
output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")));
} else {
output.add(replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n"));
}
}
object = output;
}
return object;
}
public static List<String> replace(String prefix, List<String> Text) {
List<String> output = new ArrayList<>();
for (String input : Text) {
output.add(replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n"));
}
return output;
}
public static List<String> replace(String prefix, Player player, List<String> Text) {
List<String> output = new ArrayList<>();
if (player == null) {
return Collections.singletonList("player is null");
}
if (Text == null) {
return Collections.singletonList("Text is null");
}
for (String input : Text) {
if (T2CpluginCheck.papi()) {
output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")));
} else {
output.add(replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n"));
}
}
return output;
}
public static List<String> replacePrice(String prefix, List<String> Text, String price) {
List<String> rp = new ArrayList<>();
for (String s : Text) {
rp.add(replaceLegacyColor(s).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n").replace("[price]", String.valueOf(price)));
}
return rp;
}
public static String removeColorCode(String value) {
return value.replace("&0", "").replace("&1", "").replace("&2", "").replace("&3", "")
.replace("&4", "").replace("&5", "").replace("&6", "").replace("&7", "")
.replace("&8", "").replace("&9", "").replace("&a", "").replace("&b", "")
.replace("&c", "").replace("&d", "").replace("&e", "").replace("&f", "")
.replace("&k", "").replace("&l", "").replace("&m", "").replace("&n", "")
.replace("&o", "").replace("&r", "");
}
public static List<String> replacePrice(String prefix, Player player, List<String> Text, String price) {
List<String> rp = new ArrayList<>();
for (String s : Text) {
String input = s.replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n")
.replace("[price]", String.valueOf(price));
if (T2CpluginCheck.papi()) {
rp.add(replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input)));
} else {
rp.add(replaceLegacyColor(input));
}
}
return rp;
}
public static String replacePrice(String prefix, String Text, String price) {
return replaceLegacyColor(Text).replace("[prefix]", prefix)
.replace("&o", "§o").replace("&r", "§r").replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[price]", String.valueOf(price))
.replace("[nl]", "\n");
}
public static String replacePrice(String prefix, Player player, String Text, String price) {
String input = Text.replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[price]", String.valueOf(price)).replace("[nl]", "\n");
if (T2CpluginCheck.papi()) {
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input));
} else {
return replaceLegacyColor(input);
}
}
public static String replaceLegacyColor(String text) {
return text.replace("&0", "§0").replace("&1", "§1").replace("&2", "§2").replace("&3", "§3")
.replace("&4", "§4").replace("&5", "§5").replace("&6", "§6").replace("&7", "§7")
.replace("&8", "§8").replace("&9", "§9").replace("&a", "§a").replace("&b", "§b")
.replace("&c", "§c").replace("&d", "§d").replace("&e", "§e").replace("&f", "§f")
.replace("&k", "§k").replace("&l", "§l").replace("&m", "§m").replace("&n", "§n")
.replace("&o", "§o").replace("&r", "§r");
}
public static String convertColorCode(String text) {
return text.replace("&0", "<black>").replace("§0", "<black>")
.replace("&1", "<dark_blue>").replace("§1", "<dark_blue>")
.replace("&2", "<dark_green>").replace("§2", "<dark_green>")
.replace("&3", "<dark_aqua>").replace("§3", "<dark_aqua>")
.replace("&4", "<dark_red>").replace("§4", "<dark_red>")
.replace("&5", "<dark_purple>").replace("§5", "<dark_purple>")
.replace("&6", "<gold>").replace("§6", "<gold>")
.replace("&7", "<gray>").replace("§7", "<gray>")
.replace("&8", "<dark_gray>").replace("§8", "<dark_gray>")
.replace("&9", "<blue>").replace("§9", "<blue>")
.replace("&a", "<green>").replace("§a", "<green>")
.replace("&b", "<aqua>").replace("§b", "<aqua>")
.replace("&c", "<red>").replace("§c", "<red>")
.replace("&d", "<light_purple>").replace("§d", "<light_purple>")
.replace("&e", "<yellow>").replace("§e", "<yellow>")
.replace("&f", "<white>").replace("§f", "<white>")
.replace("&k", "<obfuscated>").replace("§k", "<obfuscated>")
.replace("&l", "<bold>").replace("§l", "<bold>")
.replace("&m", "<strikethrough>").replace("§m", "<strikethrough>")
.replace("&n", "<underlined>").replace("§n", "<underlined>")
.replace("&o", "<italic>").replace("§o", "<italic>")
.replace("&r", "<reset>").replace("§r", "<reset>");
}
public static Object replace(Object object, String placeholder, String replacement) {
if (object instanceof String) {
object = ((String) object).replace(placeholder, replacement);
}
if ((object instanceof List) || (object instanceof ArrayList)) {
List<String> in = (List<String>) object;
List<String> output = new ArrayList<>();
for (String input : in) {
output.add(input.replace(placeholder, replacement));
}
object = output;
}
return object;
}
}

View File

@@ -1,325 +0,0 @@
package net.t2code.t2codelib.SPIGOT.api.messages;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.Util;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.util.List;
public class T2Ctemplate {
public static Long onLoadHeader( String prefix, List<String> autor, String version, String spigot, String discord) {
return onLoadHeader( prefix, autor, version, spigot, discord, null, null);
}
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium, Boolean isVerify) {
Long long_ = System.currentTimeMillis();
/**
T2Csend.console(prefix + " <dark_red> _______ </dark_red><gray>___ </gray><dark_red>_____ </dark_red>");
T2Csend.console(prefix + " <dark_red> |__ __|</dark_red><gray>__ \\ </gray><dark_red>/ ____|</dark_red>");
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray> ) </gray><dark_red>| | </dark_red>");
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray> / /</gray><dark_red>| | </dark_red>");
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray>/ /_</gray><dark_red>| |____ </dark_red>");
T2Csend.console(prefix + " <dark_red> |_| </dark_red><gray>|____|</gray><dark_red>\\_____|</dark_red>");
*/
for (String s : Util.getLoadLogo()) {
T2Csend.console(prefix + " §e" + s);
}
setCenterAligned(prefix, "§2Author §6" + String.valueOf(autor).replace("[", "").replace("]", ""), true);
setCenterAligned(prefix, "§2Version: §6" + version, true);
setCenterAligned(prefix, "§2Spigot: §6" + spigot, true);
setCenterAligned(prefix, "§2Discord: §6" + discord, true);
if (isPremium != null) {
if (isPremium) {
setCenterAligned(prefix, "§6Premium: §2true", true);
} else setCenterAligned(prefix, "§6Premium: §4false", true);
if (isVerify != null) {
if (isVerify) {
setCenterAligned(prefix, "§6Verify: §2true", true);
} else setCenterAligned(prefix, "§6Verify: §4false", true);
} else setCenterAligned(prefix, "§6Verify: §4false", true);
}
onLoadSeparateStroke(prefix);
if (version.toLowerCase().contains("dev") || version.toLowerCase().contains("snapshot") || version.toLowerCase().contains("beta")) {
setCenterAligned(prefix, "", true);
setCenterAligned(prefix, "", true);
setCenterAligned(prefix, "§eYou are running §4" + version + " §eof §4" + prefix + "§e!", true);
setCenterAligned(prefix, "§eSome features may not be working as expected.", true);
setCenterAligned(prefix, "§ePlease report all bugs here: http://dc.t2code.net", true);
setCenterAligned(prefix, "§4UpdateChecker & bStats may be disabled!", true);
setCenterAligned(prefix, "", true);
setCenterAligned(prefix, "", true);
onLoadSeparateStroke(prefix);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return long_;
}
public static Long onLoadHeader(String prefix) {
Long long_ = System.currentTimeMillis();
T2Csend.console(prefix + "§4===================== " + prefix + " §4=====================");
return long_;
}
public static void onLoadSeparateStroke(String prefix) {
T2Csend.console(prefix + " §e╠═══════════════════════════════════════════════════════════════════════════╣");
}
public static void onLoadFooter(String prefix, Long long_, String v) {
onLoadFooter(prefix, long_);
}
public static void onLoadFooter(String prefix, Long long_) {
onLoadSeparateStroke(prefix);
setCenterAligned(prefix, "§2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", true);
T2Csend.console(prefix + " §e" + BOTTOM_BORDER);
}
public static void onDisable(String prefix, Plugin plugin) {
sendFrameCenter(prefix, " §2Version: §6" + plugin.getDescription().getVersion(), "§2Autors: §6" + String.valueOf(plugin.getDescription().getAuthors()).replace("[", "").replace("]", ""), " §4Plugin successfully disabled. ");
}
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, Boolean premiumVerified, String text) {
String pluginVersion = plugin.getDescription().getVersion();
String publicVersion = "";
boolean update;
String stNVersion;
T2CupdateWebData webData;
try {
webData = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData;
} catch (Exception ex) {
webData = null;
}
if (webData != null) {
publicVersion = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData.getVersion();
update = !publicVersion.equalsIgnoreCase(pluginVersion);
} else {
update = false;
}
boolean player = sender instanceof Player;
String stPlugin = "<dark_red>║</dark_red> <yellow>Plugin:</yellow> <gold>[pl]</gold>".replace("[pl]", plugin.getName());
String stVersion = "<dark_red>║</dark_red> <yellow>Version:</yellow> <gold>[ver]</gold>".replace("[ver]", pluginVersion);
String stAutor = "<dark_red>║</dark_red> <yellow>Autor(s):</yellow> <gold>[autor]</gold>".replace("[autor]", plugin.getDescription().getAuthors().toString());
String stUpdate = "<dark_red>║</dark_red> <yellow>New version available:</yellow> [up]".replace("[up]", webData != null ? update ?
"<dark_green>YES</dark_green>" : "<red>no</red>" : "<b><dark_red>It could not be checked for updates!</dark_red></b>");
stNVersion = update ? "<br><dark_red>║</dark_red> <yellow>Newest Version:</yellow> <gold>[nver]</gold>".replace("[nver]", player ? "<hover:show_text:'<yellow>Click for the update information</yellow>'><click:run_command:'/t2code updateinfo " + plugin.getName() + "'>" + publicVersion + "</click></hover>" : publicVersion) : "";
String stLinkPlayer = "<dark_red>║</dark_red> <yellow><hover:show_text:'<green>Go to the Spigot page</green>'><click:open_url:'[slink]'>Spigot</click></hover></yellow> "
.replace("[slink]", "https://www.spigotmc.org/resources/" + spigotID)
+ "<dark_red>-</dark_red> <dark_purple><hover:show_text:'<green>Go to the T2Code Support Discord</green>'><click:open_url:'[dlink]'>Discord</click></hover></dark_purple>"
.replace("[dlink]", discord);
String stLinkConsole = "<dark_red>║</dark_red> <yellow>Spigot:</yellow> <gold>https://www.spigotmc.org/resources/" + spigotID + "</gold>"
+ "<br><dark_red>║</dark_red> <yellow>Discord:</yellow> <gold>" + discord + "</gold>";
String stLink = player ? stLinkPlayer : stLinkConsole;
String pr = premiumVerified != null ? "<br><dark_red>║</dark_red> <yellow>Premium verified:</yellow> [pr]".replace("[pr]",
premiumVerified ? "<dark_green>YES</dark_green>" : "<red>NO</red>") : "";
String stMSG = text == null || text.equals("") ? "" : "<br><dark_red>║</dark_red> " + text;
T2Csend.sender(sender, "<br><dark_red>╔════════════════════════════════</dark_red>"
+ "<br>" + stPlugin
+ "<br>" + stVersion
+ stMSG
+ "<br>" + stAutor
+ "<br>" + stUpdate
+ stNVersion
+ "<br>" + stLink
+ pr
+ "<br><dark_red>╚════════════════════════════════</dark_red>");
}
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, String text) {
sendInfo(sender, plugin, spigotID, discord, null, text);
}
// Frame in Console
//todo Frame Builder als replace String Builder um es überall nutzen zu können
protected static final String BOTTOM_BORDER = "╚═══════════════════════════════════════════════════════════════════════════╝";
protected static final int FIXED_WIDTH = BOTTOM_BORDER.length() - 2; // Länge ohne die Randzeichen
public static void setCenterAligned(String prefix, String text, boolean setStartFrame) {
if (!setStartFrame) {
T2Csend.console(prefix + " " + text);
return;
}
// Entfernen von Farbcodes aus der Berechnungslänge
String textWithoutColor = removeColorCodes(text);
int textLengthWithoutColor = textWithoutColor.length();
int totalPaddingSize = FIXED_WIDTH - textLengthWithoutColor;
// Sicherstellen, dass das Padding nicht negativ wird
if (totalPaddingSize < 0) totalPaddingSize = 0;
// Berechnung des Abstands vor und nach dem Text
int paddingLeft = totalPaddingSize / 2;
int paddingRight = totalPaddingSize - paddingLeft;
// Formatierung der Zeile: Text zentrieren
String formattedValue = "§e║" + " ".repeat(paddingLeft) + text + " ".repeat(paddingRight) + "§e║";
T2Csend.console(prefix + " " + formattedValue);
}
public static void setLeftAligned(String prefix, String text, boolean setStartFrame) {
T2Csend.error(T2CodeLibMain.getPlugin(), text);
if (!setStartFrame) {
T2Csend.console(prefix + " " + text);
return;
}
// Entfernen von Farbcodes aus der Berechnungslänge
String textWithoutColor = removeColorCodes(text);
int textLengthWithoutColor = textWithoutColor.length();
int totalPaddingSize = FIXED_WIDTH - textLengthWithoutColor;
// Sicherstellen, dass das Padding nicht negativ wird
if (totalPaddingSize < 0) totalPaddingSize = 0;
// Berechnung des Abstands nach dem Text und vor dem Rand
int paddingLeft = 0; // Kein zusätzlicher Abstand vor dem Text
int paddingRight = totalPaddingSize; // Alles Padding geht nach rechts
// Formatierung der Zeile: Text am Anfang und dynamischer Abstand zum Ende
String formattedValue = "§e║" + text + " ".repeat(paddingRight) + "";
T2Csend.console(prefix + " " + formattedValue);
}
// Methode für mehrere Zeilen Text mit dynamischem Rahmen
public static void sendFrameLeft(String prefix, String... lines) {
String COLOR_CODE = "§e";
String BORDER_CHAR = "";
String TOP_LEFT = "";
String TOP_RIGHT = "";
String BOTTOM_LEFT = "";
String BOTTOM_RIGHT = "";
String SIDE_BORDER = "";
// Entfernen von Farbcodes und Berechnung der maximalen Länge
int maxLength = 0;
for (String line : lines) {
String lineWithoutColor = removeColorCodes(line);
maxLength = Math.max(maxLength, lineWithoutColor.length());
}
// Berechnung der Rahmenbreite
int frameWidth = maxLength + 2; // +2 für die Ränder '║'
String topBorder = COLOR_CODE + TOP_LEFT + BORDER_CHAR.repeat(frameWidth) + COLOR_CODE + TOP_RIGHT;
String bottomBorder = COLOR_CODE + BOTTOM_LEFT + BORDER_CHAR.repeat(frameWidth) + COLOR_CODE + BOTTOM_RIGHT;
// Gehe durch jede Zeile und formatiere sie
StringBuilder builder = new StringBuilder();
// Ausgabe der oberen Linie
builder.append("<br>").append(prefix).append(" ").append(topBorder).append("<br>");
for (String line : lines) {
// Entfernen von Farbcodes aus der Berechnungslänge
String lineWithoutColor = removeColorCodes(line);
int lineLengthWithoutColor = lineWithoutColor.length();
int totalPaddingSize = frameWidth - lineLengthWithoutColor; // -2 für die Ränder '║'
// Sicherstellen, dass das Padding nicht negativ wird
if (totalPaddingSize < 0) totalPaddingSize = 0;
// Berechnung des Abstands nach dem Text und vor dem Rand
int paddingLeft = 0; // Kein zusätzlicher Abstand vor dem Text
int paddingRight = totalPaddingSize; // Alles Padding geht nach rechts
// Formatierung der Zeile: Text am Anfang und dynamischer Abstand zum Ende
String formattedValue = COLOR_CODE + SIDE_BORDER + line + " ".repeat(paddingRight) + COLOR_CODE + SIDE_BORDER;
builder.append(prefix).append(" ").append(formattedValue).append("<br>");
}
// Ausgabe der unteren Linie
builder.append(prefix).append(" ").append(bottomBorder);
T2Csend.console(builder.toString());
}
public static void sendFrameCenter(String prefix, String... lines) {
String COLOR_CODE = "§e";
String BORDER_CHAR = "";
String TOP_LEFT = "";
String TOP_RIGHT = "";
String BOTTOM_LEFT = "";
String BOTTOM_RIGHT = "";
String SIDE_BORDER = "";
// Entfernen von Farbcodes und Berechnung der maximalen Länge
int maxLength = 0;
for (String line : lines) {
String lineWithoutColor = removeColorCodes(line);
maxLength = Math.max(maxLength, lineWithoutColor.length());
}
// Berechnung der Rahmenbreite
int frameWidth = maxLength + 2; // +2 für die Ränder '║'
String topBorder = COLOR_CODE + TOP_LEFT + BORDER_CHAR.repeat(frameWidth) + COLOR_CODE + TOP_RIGHT;
String bottomBorder = COLOR_CODE + BOTTOM_LEFT + BORDER_CHAR.repeat(frameWidth) + COLOR_CODE + BOTTOM_RIGHT;
// Gehe durch jede Zeile und formatiere sie
StringBuilder builder = new StringBuilder();
// Ausgabe der oberen Linie
builder.append("<br>").append(prefix).append(" ").append(topBorder).append("<br>");
for (String line : lines) {
// Entfernen von Farbcodes aus der Berechnungslänge
String lineWithoutColor = removeColorCodes(line);
int lineLengthWithoutColor = lineWithoutColor.length();
int totalPaddingSize = frameWidth - lineLengthWithoutColor; // -2 für die Ränder '║'
// Sicherstellen, dass das Padding nicht negativ wird
if (totalPaddingSize < 0) totalPaddingSize = 0;
// Berechnung des Abstands vor und nach dem Text
int paddingLeft = totalPaddingSize / 2;
int paddingRight = totalPaddingSize - paddingLeft;
// Formatierung der Zeile: Text zentrieren
String formattedValue = COLOR_CODE + SIDE_BORDER + " ".repeat(paddingLeft) + line + " ".repeat(paddingRight) + COLOR_CODE + SIDE_BORDER;
builder.append(prefix).append(" ").append(formattedValue).append("<br>");
}
// Ausgabe der unteren Linie
builder.append(prefix).append(" ").append(bottomBorder);
T2Csend.console(builder.toString());
}
// Methode zum Entfernen von Farbcodes und MiniMessage-Farbcodes aus dem Text, außer <br>
private static String removeColorCodes(String text) {
// Regex für alle Farbcodes und MiniMessage-Codes außer <br>
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, "");
}
}

View File

@@ -1,18 +1,16 @@
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import org.bukkit.Bukkit;
public class T2CmcVersion {
public class T2C_McVersion {
public static void onCheck() {
mcVersion = Bukkit.getServer().getVersion();
bukkitVersion = Bukkit.getServer().getBukkitVersion();
T2CnmsVersions.init();
nms = String.valueOf(T2CnmsVersions.getT2CnmsEnum());
T2C_NmsVersions.init();
nms = String.valueOf(T2C_NmsVersions.getT2CnmsEnum());
// T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "mcVersion: " + mcVersion);
// T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "bukkitVersion: " + bukkitVersion);
// T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "nms: " + nms);

View File

@@ -1,6 +1,6 @@
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
public enum T2CnmsEnum {
public enum T2C_NmsEnum {
not_support,
v1_8_R1,
v1_8_R2,

View File

@@ -1,73 +1,71 @@
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
import lombok.Getter;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
public class T2CnmsVersions {
public class T2C_NmsVersions {
public static Class minecraftServerClass;
@Getter
private static T2CnmsEnum t2CnmsEnum;
private static T2C_NmsEnum t2CnmsEnum;
public static void init() {
String mc = T2CmcVersion.getMcVersion();
String mc = T2C_McVersion.getMcVersion();
if (mc.contains("(MC: 1.8)") || mc.contains("(MC: 1.8.1)")) {
t2CnmsEnum = T2CnmsEnum.v1_8_R1;
t2CnmsEnum = T2C_NmsEnum.v1_8_R1;
} else if (mc.contains("(MC: 1.8.3)")) {
t2CnmsEnum = T2CnmsEnum.v1_8_R2;
t2CnmsEnum = T2C_NmsEnum.v1_8_R2;
} else if (mc.contains("(MC: 1.8.4)") || mc.contains("(MC: 1.8.5)") || mc.contains("(MC: 1.8.6)") || mc.contains("(MC: 1.8.7)") || mc.contains("(MC: 1.8.8)")) {
t2CnmsEnum = T2CnmsEnum.v1_8_R3;
t2CnmsEnum = T2C_NmsEnum.v1_8_R3;
} else if (mc.contains("(MC: 1.9)") || mc.contains("(MC: 1.9.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_9_R1;
t2CnmsEnum = T2C_NmsEnum.v1_9_R1;
} else if (mc.contains("(MC: 1.9.3)") || mc.contains("(MC: 1.9.4)")) {
t2CnmsEnum = T2CnmsEnum.v1_9_R2;
t2CnmsEnum = T2C_NmsEnum.v1_9_R2;
} else if (mc.contains("(MC: 1.10")) {
t2CnmsEnum = T2CnmsEnum.v1_10_R1;
t2CnmsEnum = T2C_NmsEnum.v1_10_R1;
} else if (mc.contains("(MC: 1.11")) {
t2CnmsEnum = T2CnmsEnum.v1_11_R1;
t2CnmsEnum = T2C_NmsEnum.v1_11_R1;
} else if (mc.contains("(MC: 1.12")) {
t2CnmsEnum = T2CnmsEnum.v1_12_R1;
t2CnmsEnum = T2C_NmsEnum.v1_12_R1;
} else if (mc.contains("(MC: 1.13)")) {
t2CnmsEnum = T2CnmsEnum.v1_13_R1;
t2CnmsEnum = T2C_NmsEnum.v1_13_R1;
} else if (mc.contains("(MC: 1.13.1)") || mc.contains("(MC: 1.13.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_13_R2;
t2CnmsEnum = T2C_NmsEnum.v1_13_R2;
} else if (mc.contains("(MC: 1.14")) {
t2CnmsEnum = T2CnmsEnum.v1_14_R1;
t2CnmsEnum = T2C_NmsEnum.v1_14_R1;
} else if (mc.contains("(MC: 1.15")) {
t2CnmsEnum = T2CnmsEnum.v1_15_R1;
t2CnmsEnum = T2C_NmsEnum.v1_15_R1;
} else if (mc.contains("(MC: 1.16)") || mc.contains("(MC: 1.16.1)")) {
t2CnmsEnum = T2CnmsEnum.v1_16_R1;
t2CnmsEnum = T2C_NmsEnum.v1_16_R1;
} else if (mc.contains("(MC: 1.16.2)") || mc.contains("(MC: 1.16.3)")) {
t2CnmsEnum = T2CnmsEnum.v1_16_R2;
t2CnmsEnum = T2C_NmsEnum.v1_16_R2;
} else if (mc.contains("(MC: 1.16.4)") || mc.contains("(MC: 1.16.5)")) {
t2CnmsEnum = T2CnmsEnum.v1_16_R3;
t2CnmsEnum = T2C_NmsEnum.v1_16_R3;
} else if (mc.contains("(MC: 1.17")) {
t2CnmsEnum = T2CnmsEnum.v1_17_R1;
t2CnmsEnum = T2C_NmsEnum.v1_17_R1;
} else if (mc.contains("(MC: 1.18)") || mc.contains("(MC: 1.18.1)")) {
t2CnmsEnum = T2CnmsEnum.v1_18_R1;
t2CnmsEnum = T2C_NmsEnum.v1_18_R1;
} else if (mc.contains("(MC: 1.18.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_18_R2;
t2CnmsEnum = T2C_NmsEnum.v1_18_R2;
} else if (mc.contains("(MC: 1.19)") || mc.contains("(MC: 1.19.1)") || mc.contains("(MC: 1.19.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_19_R1;
t2CnmsEnum = T2C_NmsEnum.v1_19_R1;
} else if (mc.contains("(MC: 1.19.3)")) {
t2CnmsEnum = T2CnmsEnum.v1_19_R2;
t2CnmsEnum = T2C_NmsEnum.v1_19_R2;
} else if (mc.contains("(MC: 1.19.4)")) {
t2CnmsEnum = T2CnmsEnum.v1_19_R3;
t2CnmsEnum = T2C_NmsEnum.v1_19_R3;
} else if (mc.contains("(MC: 1.20)") || mc.contains("(MC: 1.20.1)")) {
t2CnmsEnum = T2CnmsEnum.v1_20_R1;
t2CnmsEnum = T2C_NmsEnum.v1_20_R1;
} else if (mc.contains("(MC: 1.20.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_20_R2;
t2CnmsEnum = T2C_NmsEnum.v1_20_R2;
} else if (mc.contains("(MC: 1.20.3)") || mc.contains("(MC: 1.20.4)")) {
t2CnmsEnum = T2CnmsEnum.v1_20_R3;
t2CnmsEnum = T2C_NmsEnum.v1_20_R3;
} else if (mc.contains("(MC: 1.20.6)")) {
t2CnmsEnum = T2CnmsEnum.v1_20_R4;
t2CnmsEnum = T2C_NmsEnum.v1_20_R4;
} else if (mc.contains("(MC: 1.21)")) {
t2CnmsEnum = T2CnmsEnum.v1_21_R1;
} else t2CnmsEnum = T2CnmsEnum.not_support;
t2CnmsEnum = T2C_NmsEnum.v1_21_R1;
} else t2CnmsEnum = T2C_NmsEnum.not_support;
}

View File

@@ -14,7 +14,7 @@ import java.util.Date;
import java.util.UUID;
import java.util.stream.Collectors;
public class T2CnameHistory {
public class T2C_NameHistory {
public static class NameLookup {
/**

View File

@@ -6,7 +6,7 @@ import org.bukkit.plugin.Plugin;
import java.util.logging.Level;
public class T2CpluginCheck {
public class T2C_PluginCheck {
public static Boolean pluginCheck(String pluginName){
return Bukkit.getPluginManager().getPlugin(pluginName) != null;
}

View File

@@ -6,7 +6,7 @@ import org.bukkit.plugin.Plugin;
import java.util.Objects;
public class T2CpluginManager {
public class T2C_PluginManager {
public static void restart(String plugin) {
if (Bukkit.getPluginManager().getPlugin(plugin) == null) return;

View File

@@ -6,7 +6,7 @@ import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin;
public class T2Cregister {
public class T2C_Register {
public static void listener(Listener listener, Plugin plugin) {
Bukkit.getServer().getPluginManager().registerEvents(listener, plugin);
}

View File

@@ -2,13 +2,13 @@
package net.t2code.t2codelib.SPIGOT.api.sound;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion;
import net.t2code.t2codelib.SPIGOT.system.config.languages.T2CLibLanguages;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
public class T2Csound {
public class T2C_Sound {
public static void playSound(Player player, String sound, int v, int v1) {
playSound(player, Sound.valueOf(sound), v, v1);
}
@@ -20,9 +20,9 @@ public class T2Csound {
public static Sound checkSound(String sound1_8, String sound1_9, String sound1_13, String selectSoundFromConfig, String prefix) {
String SOUND;
if (T2CmcVersion.isMc1_8()) {
if (T2C_McVersion.isMc1_8()) {
SOUND = sound1_8;
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
} else if (T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) {
SOUND = sound1_9;
} else SOUND = sound1_13;
@@ -32,7 +32,7 @@ public class T2Csound {
public static Sound checkSound(String sound1_8, String sound1_13, String selectSoundFromConfig, String prefix) {
String SOUND;
if (T2CmcVersion.isMc1_8()) {
if (T2C_McVersion.isMc1_8()) {
SOUND = sound1_8;
} else SOUND = sound1_13;
@@ -44,7 +44,7 @@ public class T2Csound {
try {
return Sound.valueOf(selectSoundFromConfig);
} catch (Exception e) {
T2Csend.console("§4\n§4\n§4\n" + T2CLibLanguages.VALUES.soundNotFound.getValue().toString().replace("[prefix]", prefix)
T2C_Send.console("§4\n§4\n§4\n" + T2CLibLanguages.VALUES.soundNotFound.getValue().toString().replace("[prefix]", prefix)
.replace("[sound]", "§8Buy: §6" + selectSoundFromConfig) + "§4\n§4\n§4\n");
return Sound.valueOf(sound);
}

View File

@@ -1,9 +1,8 @@
package net.t2code.t2codelib.SPIGOT.api.update;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
import net.t2code.t2codelib.UpdateType;
import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.T2CupdateWebData;
@@ -16,7 +15,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.util.HashMap;
public class T2CupdateAPI {
public class T2C_UpdateAPI {
public static HashMap<String, T2CupdateObject> pluginVersions = new HashMap<>();
public static void join(Plugin plugin, String prefix, String perm, Player player, Integer spigotID, String discord) {
@@ -86,7 +85,7 @@ public class T2CupdateAPI {
}
} else updateStatusVersion = UpdateType.STABLE.text;
T2Csend.player(player, st.replace("[prefix]", prefix).replace("[value]", updateStatusVersion).replace("[link]", webData.getUpdateUrl())
T2C_Send.player(player, st.replace("[prefix]", prefix).replace("[value]", updateStatusVersion).replace("[link]", webData.getUpdateUrl())
.replace("[plv]", pluginVersion).replace("[puv]", publicVersion).replace("[dc]", discord));
}
@@ -111,13 +110,13 @@ public class T2CupdateAPI {
String s3 = " <color:#6e90ff>You can download it here:</color> <yellow>" + webData.getUpdateUrl() + "</yellow>";
String s4 = " <color:#6e90ff>You can find more information on Discord:</color> <yellow>" + discord + "</yellow>";
T2Ctemplate.sendFrameCenter(prefix,s1,s2,s3,s4);
T2C_Send.sendFrameCenter(prefix,s1,s2,s3,s4);
}
public static String updateInfo(String[] args, Boolean player) {
T2CupdateObject object;
try {
object = T2CupdateAPI.pluginVersions.get(args[1]);
object = T2C_UpdateAPI.pluginVersions.get(args[1]);
} catch (Exception e) {
return Util.getPrefix() + " <red>The plugin <yellow>" + args[1] + "</yellow> is not registered in the update checker of T2Code!</red>";
}
@@ -126,8 +125,8 @@ public class T2CupdateAPI {
if (webData == null) {
return Util.getPrefix() + " <b><dark_red>It could not be checked for updates with the plugin <yellow>" + args[1] + "</yellow>!</dark_red></b>";
}
String pluginName = T2CupdateAPI.pluginVersions.get(args[1]).pluginName;
String pluginVersion = T2CupdateAPI.pluginVersions.get(args[1]).pluginVersion;
String pluginName = T2C_UpdateAPI.pluginVersions.get(args[1]).pluginName;
String pluginVersion = T2C_UpdateAPI.pluginVersions.get(args[1]).pluginVersion;
String updateTitle = webData.getUpdateTitle();
String updateVersion = webData.getVersion();
@@ -185,7 +184,7 @@ public class T2CupdateAPI {
}
public static void onUpdateCheck(Plugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
if ((boolean) T2CLibConfig.VALUES.updateCheckFullDisable.getValue()) return;
new T2CupdateCheckerGit((JavaPlugin) plugin, prefix, gitKey, spigotID, discord, updateCheckOnJoin, seePreReleaseUpdates, timeInterval);
if ((boolean) T2C_LibConfig.VALUES.updateCheckFullDisable.getValue()) return;
new T2C_UpdateCheckerGit((JavaPlugin) plugin, prefix, gitKey, spigotID, discord, updateCheckOnJoin, seePreReleaseUpdates, timeInterval);
}
}

View File

@@ -1,8 +1,8 @@
package net.t2code.t2codelib.SPIGOT.api.update;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.T2CupdateWebData;
import org.bukkit.Bukkit;
@@ -18,12 +18,12 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.function.Consumer;
public class T2CupdateCheckerGit {
public class T2C_UpdateCheckerGit {
private final JavaPlugin plugin;
private T2CupdateObject t2CupdateObject;
public T2CupdateCheckerGit(JavaPlugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
public T2C_UpdateCheckerGit(JavaPlugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
this.plugin = plugin;
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1";
@@ -40,7 +40,7 @@ public class T2CupdateCheckerGit {
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
@Override
public void run() {
if ((boolean) T2CLibConfig.VALUES.updateCheckFullDisable.getValue()) return;
if ((boolean) T2C_LibConfig.VALUES.updateCheckFullDisable.getValue()) return;
getVersion((webData) -> {
T2CupdateObject update = new T2CupdateObject(
plugin.getName(),
@@ -51,24 +51,24 @@ public class T2CupdateCheckerGit {
updateCheckOnJoin
);
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
if (T2CupdateAPI.pluginVersions.get(plugin.getName()) == null) {
T2Csend.debugmsg(T2CodeLibMain.getPlugin(), "'" + plugin.getName() + "' UpdateAPI T2CupdateAPI.pluginVersions.get(plugin.getName()) == null");
T2C_UpdateAPI.pluginVersions.put(plugin.getName(), update);
if (T2C_UpdateAPI.pluginVersions.get(plugin.getName()) == null) {
T2C_Send.debugmsg(T2CodeLibMain.getPlugin(), "'" + plugin.getName() + "' UpdateAPI T2CupdateAPI.pluginVersions.get(plugin.getName()) == null");
return;
}
if (T2CupdateAPI.pluginVersions.get(plugin.getName()).updateAvailable) {
if (T2C_UpdateAPI.pluginVersions.get(plugin.getName()).updateAvailable) {
if (!update.load) {
new BukkitRunnable() {
@Override
public void run() {
update.load = true;
T2CupdateAPI.sendUpdateMsg(prefix, discord, webData, plugin);
T2C_UpdateAPI.sendUpdateMsg(prefix, discord, webData, plugin);
}
}.runTaskLaterAsynchronously(plugin, 600L);
} else T2CupdateAPI.sendUpdateMsg(prefix, discord, webData, plugin);
} else T2C_UpdateAPI.sendUpdateMsg(prefix, discord, webData, plugin);
} else {
if (!update.load) {
T2Csend.console(prefix + " §e║ " + "§2No update found.");
T2C_Send.console(prefix + " §e║ " + "§2No update found.");
update.load = true;
}
}
@@ -132,8 +132,8 @@ public class T2CupdateCheckerGit {
consumer.accept(webData);
} catch (Exception exception) {
Boolean load = false;
if (T2CupdateAPI.pluginVersions.containsKey(plugin.getName())) {
load = T2CupdateAPI.pluginVersions.get(plugin.getName()).load;
if (T2C_UpdateAPI.pluginVersions.containsKey(plugin.getName())) {
load = T2C_UpdateAPI.pluginVersions.get(plugin.getName()).load;
}
T2CupdateObject update = new T2CupdateObject(
plugin.getName(),
@@ -143,9 +143,9 @@ public class T2CupdateCheckerGit {
false,
updateCheckOnJoin
);
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
T2C_UpdateAPI.pluginVersions.put(plugin.getName(), update);
T2Csend.error(this.plugin, "§4 Cannot look for updates: " + exception.getMessage());
T2C_Send.error(this.plugin, "§4 Cannot look for updates: " + exception.getMessage());
exception.printStackTrace();
}
});

View File

@@ -1,60 +0,0 @@
package net.t2code.t2codelib.SPIGOT.api.yaml;
public class T2CLibConfig {
/**
* @deprecated since version 16.7, use the method from the return!
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Boolean getUpdateCheckOnJoin() {
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.updateCheckOnJoin.getValue();
}
/**
* @deprecated since version 16.7, use the method from the return!
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Integer getUpdateCheckTimeInterval() {
return (Integer) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.updateCheckTimeInterval.getValue();
}
/**
* @deprecated since version 16.7, use the method from the return!
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Boolean getSeePreReleaseUpdates() {
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.seePreReleaseUpdates.getValue();
}
/**
* @deprecated since version 16.7, use the method from the return!
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Boolean getDebug() {
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.debug.getValue();
}
/**
* @deprecated since version 16.7, use the method from the return!
*/
@Deprecated(since = "16.7", forRemoval = true)
public static String getLanguage() {
return (String) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.language.getValue();
}
/**
* @deprecated since version 16.7, use the method from the return!
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Boolean getBungee() {
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.proxy.getValue();
}
/**
* @deprecated since version 16.7, use the method from the return!
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Boolean getInventoriesCloseByServerStop() {
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.inventoriesCloseByServerStop.getValue();
}
}

View File

@@ -0,0 +1,304 @@
package net.t2code.t2codelib.SPIGOT.api.yaml;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Replace;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion;
import net.t2code.t2codelib.SPIGOT.api.sound.T2C_Sound;
import net.t2code.t2codelib.T2CconfigItem;
import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class T2C_Config {
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static void set(String path, String value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static void set(String path, Object value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static void set(String path, YamlConfiguration YamlConfiguration) {
YamlConfiguration.set(path, null);
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static void set(String path, Integer value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static void set(String path, Double value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static void set(String path, Boolean value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static void set(String path, List<String> value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static void set(String path, ItemStack value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static void setSound(String soundName, String sound1_8, String sound1_9, String sound1_13, YamlConfiguration yamlConfiguration) {
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
String sound;
if (T2C_McVersion.isMc1_8()) {
sound = sound1_8.toString();
} else if (T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) {
sound = sound1_9.toString();
} else sound = sound1_13.toString();
set("Sound." + soundName + ".Sound", sound, yamlConfiguration);
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static void setSound(String soundName, String sound1_8, String sound1_13, YamlConfiguration yamlConfiguration) {
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
String sound;
if (T2C_McVersion.isMc1_8()) {
sound = sound1_8.toString();
} else sound = sound1_13.toString();
set("Sound." + soundName + ".Sound", sound, yamlConfiguration);
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static void setSound(String soundName, String sound, YamlConfiguration yamlConfiguration) {
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
set("Sound." + soundName + ".Sound", sound.toString(), yamlConfiguration);
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static boolean selectSoundEnable(String soundName, YamlConfiguration yamlConfiguration) {
return selectBoolean("Sound." + soundName + ".Enable", yamlConfiguration);
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static String selectSound(String prefix, String soundName, YamlConfiguration yamlConfiguration) {
return select(prefix, "Sound." + soundName + ".Sound", yamlConfiguration);
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Sound checkSound(String sound1_8, String sound1_9, String sound1_13, String selectSoundFromConfig, String prefix) {
return T2C_Sound.checkSound(sound1_8, sound1_9, sound1_13, selectSoundFromConfig, prefix);
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Sound checkSound(String sound1_8, String sound1_13, String selectSoundFromConfig, String prefix) {
return T2C_Sound.checkSound(sound1_8, sound1_13, selectSoundFromConfig, prefix);
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Sound checkSound(String sound, String selectSoundFromConfig, String prefix) {
return T2C_Sound.checkSound(sound, selectSoundFromConfig, prefix);
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static String select(String prefix, String path, YamlConfiguration yamlConfiguration) {
return T2C_Replace.replace(prefix, yamlConfiguration.getString(path));
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Object selectObject(String prefix, String path, YamlConfiguration yamlConfiguration) {
return T2C_Replace.replaceObject(prefix, yamlConfiguration.get(path));
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Integer selectInt(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getInt(path));
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Boolean selectBoolean(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getBoolean(path));
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Double selectDouble(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getDouble(path));
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static List<String> selectList(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getStringList(path));
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static ItemStack selectItemStack(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getItemStack(path));
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static List<String> selectList(String prefix, String path, YamlConfiguration yamlConfiguration) {
List<String> output = new ArrayList<>();
List<String> input = yamlConfiguration.getStringList(path);
for (String st : input) {
output.add(T2C_Replace.replace(prefix, st));
}
return output;
}
/**
* @deprecated since version 16.7
* This method will be removed soon!
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2CconfigItem[], String...)}.
*/
@Deprecated(since = "16.7", forRemoval = true)
public static void select(String prefix, List<String> value, String path, YamlConfiguration yamlConfiguration) {
List<String> output = new ArrayList<>();
List<String> input = yamlConfiguration.getStringList(path);
for (String st : input) {
output.add(T2C_Replace.replace(prefix, st));
}
value = output;
}
}

View File

@@ -2,6 +2,8 @@
package net.t2code.t2codelib.SPIGOT.api.yaml;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.T2CLanguageEnum;
import net.t2code.t2codelib.T2CconfigItem;
import org.bukkit.configuration.file.FileConfiguration;
@@ -13,7 +15,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class T2CconfigWriter {
public class T2C_ConfigWriter {
private static FileConfiguration config;
@@ -24,7 +26,7 @@ public class T2CconfigWriter {
try {
configFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
T2C_Send.sendException(e, T2CodeLibMain.getPlugin().getLogger());
return;
}
} else exist = true;
@@ -52,7 +54,7 @@ public class T2CconfigWriter {
// Copy default values if they are missing
config.options().copyDefaults(true);
T2CymlWriter.saveConfigWithComments(configFile, config, comments, header);
T2C_YmlWriter.saveConfigWithComments(configFile, config, comments, header);
readConfig(config, values);
}

View File

@@ -2,7 +2,8 @@
package net.t2code.t2codelib.SPIGOT.api.yaml;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.T2CLanguageEnum;
import net.t2code.t2codelib.T2CconfigItemLanguages;
import org.bukkit.configuration.file.FileConfiguration;
@@ -12,19 +13,19 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
public class T2CconfigWriterLanguage {
public class T2C_LanguageWriter {
private static FileConfiguration config;
public static void createConfig(String prefix,File path, T2CconfigItemLanguages[] values, String loadConfig,boolean pluginStart, String... header) {
public static void createConfig(String prefix, File path, T2CconfigItemLanguages[] values, String loadConfig, boolean isReload, String... header) {
File f = new File(path + "/languages/");
f.mkdirs();
File[] fileArray = f.listFiles();
if(fileArray.length == 0){
if (fileArray.length == 0) {
List<File> zw = new ArrayList<>();
for(T2CLanguageEnum lan : T2CLanguageEnum.values()){
if(values[0].getLanguage().containsKey(lan)){
for (T2CLanguageEnum lan : T2CLanguageEnum.values()) {
if (values[0].getLanguage().containsKey(lan)) {
zw.add(new File(path + "/languages/" + lan.name() + ".yml"));
}
}
@@ -43,7 +44,7 @@ public class T2CconfigWriterLanguage {
try {
langFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
T2C_Send.sendException(e, T2CodeLibMain.getPlugin().getLogger());
return;
}
}
@@ -60,23 +61,23 @@ public class T2CconfigWriterLanguage {
comments.put(item.getPath(), commandList);
}
}
T2CymlWriter.saveConfigWithComments(langFile, config, comments, header);
T2C_YmlWriter.saveConfigWithComments(langFile, config, comments, header);
}
}
readConfig(prefix,path,values, loadConfig, pluginStart);
readConfig(prefix, path, values, loadConfig, isReload);
}
private static void readConfig(String prefix, File path, T2CconfigItemLanguages[] values, String loadConfig, boolean pluginStart) {
private static void readConfig(String prefix, File path, T2CconfigItemLanguages[] values, String loadConfig, boolean isReload) {
String selectMSG;
File msg;
msg = new File(path, "languages/" + loadConfig + ".yml");
if (!msg.isFile()) {
T2Ctemplate.setCenterAligned(prefix, "", pluginStart);
T2Ctemplate.setCenterAligned(prefix, "§4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", pluginStart);
T2Ctemplate.setCenterAligned(prefix, "§4The selected §c" + loadConfig + " §4language file was not found.", pluginStart);
T2Ctemplate.setCenterAligned(prefix, "§6The default language §e" + T2CLanguageEnum.english.name() + " §6is used!", pluginStart);
T2Ctemplate.setCenterAligned(prefix, "§4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", pluginStart);
T2Ctemplate.setCenterAligned(prefix, "", pluginStart);
T2C_Send.sendStartTextCenter(prefix, "", isReload);
T2C_Send.sendStartTextCenter(prefix, "§4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", isReload);
T2C_Send.sendStartTextCenter(prefix, "§4The selected §c" + loadConfig + " §4language file was not found.", isReload);
T2C_Send.sendStartTextCenter(prefix, "§6The default language §e" + T2CLanguageEnum.english.name() + " §6is used!", isReload);
T2C_Send.sendStartTextCenter(prefix, "§4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", isReload);
T2C_Send.sendStartTextCenter(prefix, "", isReload);
msg = new File(path, "languages/" + T2CLanguageEnum.english.name() + ".yml");
selectMSG = T2CLanguageEnum.english.name();
} else selectMSG = loadConfig;
@@ -84,6 +85,6 @@ public class T2CconfigWriterLanguage {
for (T2CconfigItemLanguages value : values) {
value.setValue(yml.get(value.getPath()));
}
T2Ctemplate.setCenterAligned(prefix, "§2Language successfully selected to: §6" + selectMSG, pluginStart);
T2C_Send.sendStartTextCenter(prefix, "§2Language successfully selected to: §6" + selectMSG, isReload);
}
}

View File

@@ -11,7 +11,7 @@ import java.nio.file.Files;
import java.util.List;
import java.util.Map;
public class T2CymlWriter {
public class T2C_YmlWriter {
protected static void saveConfigWithComments(File file, FileConfiguration config, Map<String, List<String>> comments, String... headers) {
try {
StringBuilder configContent = new StringBuilder();

View File

@@ -1,227 +0,0 @@
package net.t2code.t2codelib.SPIGOT.api.yaml;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.api.sound.T2Csound;
import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
public class T2Cconfig {
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static void set(String path, String value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static void set(String path, Object value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static void set(String path, YamlConfiguration YamlConfiguration) {
YamlConfiguration.set(path, null);
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static void set(String path, Integer value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static void set(String path, Double value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static void set(String path, Boolean value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static void set(String path, List<String> value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static void set(String path, ItemStack value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static void setSound(String soundName, String sound1_8, String sound1_9, String sound1_13, YamlConfiguration yamlConfiguration) {
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
String sound;
if (T2CmcVersion.isMc1_8()) {
sound = sound1_8.toString();
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
sound = sound1_9.toString();
} else sound = sound1_13.toString();
set("Sound." + soundName + ".Sound", sound, yamlConfiguration);
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static void setSound(String soundName, String sound1_8, String sound1_13, YamlConfiguration yamlConfiguration) {
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
String sound;
if (T2CmcVersion.isMc1_8()) {
sound = sound1_8.toString();
} else sound = sound1_13.toString();
set("Sound." + soundName + ".Sound", sound, yamlConfiguration);
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static void setSound(String soundName, String sound, YamlConfiguration yamlConfiguration) {
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
set("Sound." + soundName + ".Sound", sound.toString(), yamlConfiguration);
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static boolean selectSoundEnable(String soundName, YamlConfiguration yamlConfiguration) {
return selectBoolean("Sound." + soundName + ".Enable", yamlConfiguration);
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static String selectSound(String prefix, String soundName, YamlConfiguration yamlConfiguration) {
return select(prefix, "Sound." + soundName + ".Sound", yamlConfiguration);
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static Sound checkSound(String sound1_8, String sound1_9, String sound1_13, String selectSoundFromConfig, String prefix) {
return T2Csound.checkSound(sound1_8, sound1_9, sound1_13, selectSoundFromConfig, prefix);
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static Sound checkSound(String sound1_8, String sound1_13, String selectSoundFromConfig, String prefix) {
return T2Csound.checkSound(sound1_8, sound1_13, selectSoundFromConfig, prefix);
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static Sound checkSound(String sound, String selectSoundFromConfig, String prefix) {
return T2Csound.checkSound(sound, selectSoundFromConfig, prefix);
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static String select(String prefix, String path, YamlConfiguration yamlConfiguration) {
return T2Creplace.replace(prefix, yamlConfiguration.getString(path));
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static Object selectObject(String prefix, String path, YamlConfiguration yamlConfiguration) {
return T2Creplace.replaceObject(prefix, yamlConfiguration.get(path));
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static Integer selectInt(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getInt(path));
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static Boolean selectBoolean(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getBoolean(path));
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static Double selectDouble(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getDouble(path));
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static List<String> selectList(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getStringList(path));
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static ItemStack selectItemStack(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getItemStack(path));
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static List<String> selectList(String prefix, String path, YamlConfiguration yamlConfiguration) {
List<String> output = new ArrayList<>();
List<String> input = yamlConfiguration.getStringList(path);
for (String st : input) {
output.add(T2Creplace.replace(prefix, st));
}
return output;
}
/**
* @deprecated since version 16.7, please use the new T2CconfigWriter.
*/
public static void select(String prefix, List<String> value, String path, YamlConfiguration yamlConfiguration) {
List<String> output = new ArrayList<>();
List<String> input = yamlConfiguration.getStringList(path);
for (String st : input) {
output.add(T2Creplace.replace(prefix, st));
}
value = output;
}
}