16.7_dev-19
This commit is contained in:
@@ -3,9 +3,9 @@ package net.t2code.t2codelib.SPIGOT.api.bungeePlayers;
|
||||
import lombok.Getter;
|
||||
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.T2C_Main;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import net.t2code.t2codelib.util.T2C_Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
@@ -23,15 +23,15 @@ public class T2C_BungeePlayers implements PluginMessageListener {
|
||||
@Override
|
||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, byte[] message) {
|
||||
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(message));
|
||||
T2C_Debug.debug(T2CodeLibMain.getPlugin(), "stream: " + stream.toString());
|
||||
T2C_Debug.debug(T2C_Main.getPlugin(), "stream: " + stream.toString());
|
||||
try {
|
||||
T2C_BngeePlayersEnum subChannel = T2C_BngeePlayersEnum.valueOf(stream.readUTF());
|
||||
String input = stream.readUTF();
|
||||
String uuid = stream.readUTF();
|
||||
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);
|
||||
T2C_Debug.debug(T2C_Main.getPlugin(), "PluginMessage received channel: " + channel);
|
||||
T2C_Debug.debug(T2C_Main.getPlugin(), "PluginMessage received subChannel: " + subChannel.name());
|
||||
T2C_Debug.debug(T2C_Main.getPlugin(), "PluginMessage received input: " + input);
|
||||
T2C_Debug.debug(T2C_Main.getPlugin(), "PluginMessage received input2/uuid: " + uuid);
|
||||
switch (subChannel) {
|
||||
case JOIN:
|
||||
bungeePlayers.add(input);
|
||||
@@ -52,13 +52,13 @@ public class T2C_BungeePlayers implements PluginMessageListener {
|
||||
break;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
T2C_Send.sendException(e, T2CodeLibMain.getPlugin().getLogger());
|
||||
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||
}
|
||||
}
|
||||
|
||||
public static void callAllBungeePlayers() {
|
||||
if (Bukkit.getOnlinePlayers().isEmpty()) {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(T2C_Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
callAllBungeePlayers();
|
||||
@@ -72,14 +72,14 @@ public class T2C_BungeePlayers implements PluginMessageListener {
|
||||
output.writeUTF(T2C_BngeePlayersEnum.GIVEALL.name());
|
||||
output.writeUTF(T2C_LibConfig.VALUES.serverUUID.getValue().toString());
|
||||
} catch (IOException e) {
|
||||
T2C_Send.sendException(e, T2CodeLibMain.getPlugin().getLogger());
|
||||
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||
}
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
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());
|
||||
player.sendPluginMessage(T2C_Main.getPlugin(), T2C_Util.getPluginChannel_ProxyOnlinePlayers(), stream.toByteArray());
|
||||
T2C_Debug.debug(T2C_Main.getPlugin(), "PluginMessage received channel: " + T2C_Util.getPluginChannel_ProxyOnlinePlayers());
|
||||
T2C_Debug.debug(T2C_Main.getPlugin(), "PluginMessage send subChannel: " + T2C_BngeePlayersEnum.GIVEALL.name());
|
||||
T2C_Debug.debug(T2C_Main.getPlugin(), "PluginMessage send output/uuid: " + T2C_LibConfig.VALUES.serverUUID.getValue().toString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package net.t2code.t2codelib.SPIGOT.api.commands;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.system.BungeeCommandSenderReceiver;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -13,7 +13,7 @@ public class T2C_Cmd {
|
||||
Map.Entry<String,Integer> map = delay(cmdInput);
|
||||
int delay = map.getValue();
|
||||
String cmd = map.getKey();
|
||||
Bukkit.getScheduler().runTaskLater(T2CodeLibMain.getPlugin(), new Runnable() {
|
||||
Bukkit.getScheduler().runTaskLater(T2C_Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (cmd.contains("!onBungee")) {
|
||||
@@ -27,7 +27,7 @@ public class T2C_Cmd {
|
||||
Map.Entry<String,Integer> map = delay(cmdInput);
|
||||
int delay = map.getValue();
|
||||
String cmd = map.getKey();
|
||||
Bukkit.getScheduler().runTaskLater(T2CodeLibMain.getPlugin(), new Runnable() {
|
||||
Bukkit.getScheduler().runTaskLater(T2C_Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (cmd.contains("!asConsole")) {
|
||||
|
@@ -3,7 +3,7 @@ package net.t2code.t2codelib.SPIGOT.api.eco;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
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.T2C_Main;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.languages.T2CLibLanguages;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -14,20 +14,20 @@ import org.bukkit.inventory.ItemStack;
|
||||
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();
|
||||
return T2C_Main.getEco().withdrawPlayer(player, price).transactionSuccess();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean moneyAdd(String prefix, Player player, Double price) {
|
||||
if (vault(prefix, player)) {
|
||||
return T2CodeLibMain.getEco().depositPlayer(player, price).transactionSuccess();
|
||||
return T2C_Main.getEco().depositPlayer(player, price).transactionSuccess();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean vault(String prefix, Player player) {
|
||||
if (T2CodeLibMain.getEco() == null) {
|
||||
if (T2C_Main.getEco() == null) {
|
||||
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
|
||||
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║ ");
|
||||
@@ -74,7 +74,7 @@ public class T2C_Eco {
|
||||
|
||||
public static boolean votePointsAdd(String prefix, Player player, Integer amount) {
|
||||
if (votePlugin(prefix, player)) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(T2C_Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
VotingPluginMain.getPlugin().getVotingPluginUserManager().getVotingPluginUser(player).addPoints(amount);
|
||||
|
@@ -4,7 +4,7 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
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 net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@@ -47,7 +47,7 @@ public class T2C_ItemBuilder {
|
||||
inventory.setItem(i, glass);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
T2C_Send.sendException(e, T2CodeLibMain.getPlugin().getLogger());
|
||||
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class T2C_ItemBuilder {
|
||||
profileField.setAccessible(true);
|
||||
profileField.set(itemMeta, profile);
|
||||
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
|
||||
T2C_Send.sendException(e, T2CodeLibMain.getPlugin().getLogger());
|
||||
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||
}
|
||||
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
|
@@ -1,145 +0,0 @@
|
||||
// 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, "");
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
package net.t2code.t2codelib.SPIGOT.api.messages;
|
||||
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -26,7 +26,7 @@ public class T2C_HoverModule {
|
||||
}
|
||||
|
||||
public static void moduleConsole(String msg) {
|
||||
if (T2CodeLibMain.getMmIsLoad()) {
|
||||
if (T2C_Main.getMmIsLoad()) {
|
||||
T2C_MiniMessage.sendConsoleMiniMessage(msg);
|
||||
return;
|
||||
}
|
||||
|
@@ -3,12 +3,12 @@ package net.t2code.t2codelib.SPIGOT.api.messages;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class T2C_MiniMessage {
|
||||
private static final BukkitAudiences bukkitAudiences = T2CodeLibMain.getPlugin().getAdventure();
|
||||
private static final BukkitAudiences bukkitAudiences = T2C_Main.getPlugin().getAdventure();
|
||||
|
||||
public static void sendSenderMiniMessage(String msg, CommandSender sender) {
|
||||
String string = "";
|
||||
@@ -30,4 +30,9 @@ public class T2C_MiniMessage {
|
||||
protected static Component replace(String text) {
|
||||
return MiniMessage.miniMessage().deserialize(T2C_Replace.convertColorCode(text));
|
||||
}
|
||||
|
||||
|
||||
public static String removeMiniMessageCodes(String text){
|
||||
return MiniMessage.miniMessage().stripTags(text);
|
||||
}
|
||||
}
|
||||
|
@@ -5,112 +5,226 @@ import net.t2code.t2codelib.SPIGOT.api.plugins.T2C_PluginCheck;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class T2C_Replace {
|
||||
|
||||
public static String replace(String prefix, String Text) {
|
||||
|
||||
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);
|
||||
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) {
|
||||
return replacePlaceholders(replaceLegacyColor(text), prefix, player, null);
|
||||
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 (T2C_PluginCheck.papi()) {
|
||||
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input));
|
||||
} else {
|
||||
return replaceLegacyColor(input);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
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 item : list) {
|
||||
output.add(item.replace(placeholder, replacement));
|
||||
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"));
|
||||
}
|
||||
return output;
|
||||
object = 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());
|
||||
public static Object replaceObject(String prefix, Player player, Object object) {
|
||||
if (object instanceof String) {
|
||||
|
||||
if (T2C_PluginCheck.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 (price != null) {
|
||||
text = text.replace("[price]", price);
|
||||
if (object instanceof List) {
|
||||
List<String> in = (List<String>) object;
|
||||
List<String> output = new ArrayList<>();
|
||||
for (String input : in) {
|
||||
if (T2C_PluginCheck.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;
|
||||
}
|
||||
if (player != null && T2C_PluginCheck.papi()) {
|
||||
text = PlaceholderAPI.setPlaceholders(player, text);
|
||||
}
|
||||
return text;
|
||||
return object;
|
||||
}
|
||||
|
||||
private static List<String> replacePlaceholdersInList(List<String> texts, String prefix, Player player, String price) {
|
||||
public static List<String> replace(String prefix, List<String> Text) {
|
||||
List<String> output = new ArrayList<>();
|
||||
for (String text : texts) {
|
||||
output.add(replacePlaceholders(replaceLegacyColor(text), prefix, player, price));
|
||||
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;
|
||||
}
|
||||
|
||||
private static Object replaceObjectPlaceholders(Object object, String prefix, Player player, String price) {
|
||||
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 (T2C_PluginCheck.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 (T2C_PluginCheck.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 (T2C_PluginCheck.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) {
|
||||
return replacePlaceholders(replaceLegacyColor((String) object), prefix, player, price);
|
||||
} else if (object instanceof List) {
|
||||
return replacePlaceholdersInList((List<String>) object, prefix, player, price);
|
||||
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;
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.t2code.t2codelib.SPIGOT.api.messages;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
|
||||
import net.t2code.t2codelib.util.T2C_GenerateFrame;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -13,31 +14,32 @@ import java.util.logging.Logger;
|
||||
|
||||
public class T2C_Send {
|
||||
|
||||
public static String sendStartTextCenter(String prefix, String text, boolean isReload) {
|
||||
public static void sendStartTextCenter(String prefix, String text, boolean isReload) {
|
||||
if (isReload) {
|
||||
return prefix + " " + text;
|
||||
console(prefix + " " + text);
|
||||
return;
|
||||
}
|
||||
return T2C_GernerateFrame.setCenterAligned(prefix,text);
|
||||
console(T2C_GenerateFrame.setCenterAligned(prefix, text));
|
||||
}
|
||||
|
||||
public static String sendStartTextLeft(String prefix, String text, boolean isReload) {
|
||||
public static void sendStartTextLeft(String prefix, String text, boolean isReload) {
|
||||
if (isReload) {
|
||||
return prefix + " " + text;
|
||||
|
||||
console(prefix + " " + text);
|
||||
return;
|
||||
}
|
||||
return T2C_GernerateFrame.setLeftAligned(prefix, text);
|
||||
console(T2C_GenerateFrame.setLeftAligned(prefix, text));
|
||||
}
|
||||
|
||||
public static String sendFrameCenter(String prefix, String... lines){
|
||||
return T2C_GernerateFrame.sendFrameCenter(prefix, lines);
|
||||
public static String getFrameCenter(String prefix, boolean console, String... lines) {
|
||||
return T2C_GenerateFrame.getFrameCenter(prefix, console, lines);
|
||||
}
|
||||
|
||||
public static String sendFrameLeft(String prefix, String... lines){
|
||||
return T2C_GernerateFrame.sendFrameLeft(prefix, lines);
|
||||
public static String getFrameLeft(String prefix, boolean console, String... lines) {
|
||||
return T2C_GenerateFrame.getFrameLeft(prefix, console, lines);
|
||||
}
|
||||
|
||||
public static void sendException(Exception e, Logger logger){
|
||||
logger.log(Level.SEVERE,"Interrupted exception occurred", e);
|
||||
public static void sendException(Exception e, Logger logger) {
|
||||
logger.log(Level.SEVERE, "Interrupted exception occurred", e);
|
||||
}
|
||||
|
||||
public static void console(String msg) {
|
||||
@@ -56,14 +58,14 @@ public class T2C_Send {
|
||||
}
|
||||
|
||||
public static void console(Object object) {
|
||||
for (String msg : list(object)){
|
||||
for (String msg : list(object)) {
|
||||
if (msg == null || msg.contains("[empty]")) continue;
|
||||
T2C_HoverModule.moduleConsole(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void player(Player player, Object object) {
|
||||
for (String msg : list(object)){
|
||||
for (String msg : list(object)) {
|
||||
if (msg == null || msg.contains("[empty]")) continue;
|
||||
T2C_HoverModule.modulePlayer(msg, player);
|
||||
}
|
||||
@@ -71,7 +73,7 @@ public class T2C_Send {
|
||||
|
||||
|
||||
public static void sender(CommandSender sender, Object object) {
|
||||
for (String msg : list(object)){
|
||||
for (String msg : list(object)) {
|
||||
if (msg == null || msg.contains("[empty]")) return;
|
||||
T2C_HoverModule.moduleSender(msg, sender);
|
||||
}
|
||||
@@ -87,7 +89,7 @@ public class T2C_Send {
|
||||
|
||||
/**
|
||||
* @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)}
|
||||
* Please use the new method {@link T2C_Debug#debug(Plugin, String)} or {@link T2C_Debug#debug(Plugin, String, Integer)}
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void debug(Plugin plugin, String msg) {
|
||||
@@ -96,7 +98,7 @@ public class T2C_Send {
|
||||
|
||||
/**
|
||||
* @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)}
|
||||
* Please use the new method {@link T2C_Debug#debug(Plugin, String)} or {@link T2C_Debug#debug(Plugin, String, Integer)}
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void debug(Plugin plugin, String msg, Integer stage) {
|
||||
@@ -106,7 +108,7 @@ public class T2C_Send {
|
||||
|
||||
/**
|
||||
* @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)}
|
||||
* Please use the new method {@link T2C_Debug#debugmsg(Plugin, String)}
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void debugmsg(Plugin plugin, String msg) {
|
||||
@@ -125,13 +127,13 @@ public class T2C_Send {
|
||||
plugin.getLogger().log(Level.SEVERE, msg);
|
||||
}
|
||||
|
||||
private static ArrayList<String> list(Object object){
|
||||
private static ArrayList<String> list(Object object) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
|
||||
if (object instanceof List){
|
||||
list= (ArrayList<String>) object;
|
||||
if (object instanceof List) {
|
||||
list = (ArrayList<String>) object;
|
||||
}
|
||||
if (object instanceof String){
|
||||
if (object instanceof String) {
|
||||
list.add((String) object);
|
||||
}
|
||||
return list;
|
||||
|
@@ -1,8 +1,9 @@
|
||||
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 net.t2code.t2codelib.util.T2C_GenerateFrame;
|
||||
import net.t2code.t2codelib.util.T2C_UpdateWebData;
|
||||
import net.t2code.t2codelib.util.T2C_Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -20,8 +21,8 @@ public class T2C_Template {
|
||||
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);
|
||||
for (String s : T2C_Util.getLoadLogo()) {
|
||||
T2C_Send.console(prefix + " "+ T2C_GenerateFrame.getCOLOR_CODE() + s);
|
||||
}
|
||||
T2C_Send.sendStartTextCenter(prefix, "§2Author §6" + String.valueOf(autor).replace("[", "").replace("]", ""), false);
|
||||
T2C_Send.sendStartTextCenter(prefix, "§2Version: §6" + version, false);
|
||||
@@ -61,17 +62,18 @@ public class T2C_Template {
|
||||
}
|
||||
|
||||
public static void onLoadSeparateStroke(String prefix) {
|
||||
T2C_Send.console(prefix + " §e╠═══════════════════════════════════════════════════════════════════════════╣");
|
||||
T2C_Send.console(prefix + " " + T2C_GenerateFrame.getCOLOR_CODE() + T2C_GenerateFrame.getSTROKE());
|
||||
}
|
||||
|
||||
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);
|
||||
T2C_Send.console(prefix + " " + T2C_GenerateFrame.getCOLOR_CODE() + T2C_GenerateFrame.getBOTTOM_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. ");
|
||||
T2C_Send.console(T2C_Send.getFrameCenter(prefix, true, " §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) {
|
||||
@@ -79,7 +81,7 @@ public class T2C_Template {
|
||||
String publicVersion = "";
|
||||
boolean update;
|
||||
String stNVersion;
|
||||
T2CupdateWebData webData;
|
||||
T2C_UpdateWebData webData;
|
||||
try {
|
||||
webData = T2C_UpdateAPI.pluginVersions.get(plugin.getName()).webData;
|
||||
} catch (Exception ex) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package net.t2code.t2codelib.SPIGOT.api.plugins;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class T2C_PluginCheck {
|
||||
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
||||
Bukkit.getConsoleSender().sendMessage(prefix + " §e" + pl + " §4could not be found. Please download it here: " +
|
||||
"§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin.");
|
||||
T2CodeLibMain.getPlugin().getPluginLoader().disablePlugin(T2CodeLibMain.getPlugin());
|
||||
T2C_Main.getPlugin().getPluginLoader().disablePlugin(T2C_Main.getPlugin());
|
||||
return true;
|
||||
} else return false;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package net.t2code.t2codelib.SPIGOT.api.plugins;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@@ -10,33 +10,33 @@ public class T2C_PluginManager {
|
||||
|
||||
public static void restart(String plugin) {
|
||||
if (Bukkit.getPluginManager().getPlugin(plugin) == null) return;
|
||||
T2CodeLibMain.getPlugin().getPluginLoader().disablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
|
||||
T2CodeLibMain.getPlugin().getPluginLoader().enablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
|
||||
T2C_Main.getPlugin().getPluginLoader().disablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
|
||||
T2C_Main.getPlugin().getPluginLoader().enablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
|
||||
}
|
||||
|
||||
public static void enable(String plugin) {
|
||||
if (Bukkit.getPluginManager().getPlugin(plugin) == null) return;
|
||||
T2CodeLibMain.getPlugin().getPluginLoader().enablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
|
||||
T2C_Main.getPlugin().getPluginLoader().enablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
|
||||
}
|
||||
|
||||
public static void disable(String plugin) {
|
||||
if (Bukkit.getPluginManager().getPlugin(plugin) == null) return;
|
||||
T2CodeLibMain.getPlugin().getPluginLoader().disablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
|
||||
T2C_Main.getPlugin().getPluginLoader().disablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
|
||||
}
|
||||
|
||||
public static void restart(Plugin plugin) {
|
||||
if (plugin == null) return;
|
||||
T2CodeLibMain.getPlugin().getPluginLoader().disablePlugin(plugin);
|
||||
T2CodeLibMain.getPlugin().getPluginLoader().enablePlugin(plugin);
|
||||
T2C_Main.getPlugin().getPluginLoader().disablePlugin(plugin);
|
||||
T2C_Main.getPlugin().getPluginLoader().enablePlugin(plugin);
|
||||
}
|
||||
|
||||
public static void enable(Plugin plugin) {
|
||||
if (plugin == null) return;
|
||||
T2CodeLibMain.getPlugin().getPluginLoader().enablePlugin(plugin);
|
||||
T2C_Main.getPlugin().getPluginLoader().enablePlugin(plugin);
|
||||
}
|
||||
|
||||
public static void disable(Plugin plugin) {
|
||||
if (plugin == null) return;
|
||||
T2CodeLibMain.getPlugin().getPluginLoader().disablePlugin(plugin);
|
||||
T2C_Main.getPlugin().getPluginLoader().disablePlugin(plugin);
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package net.t2code.t2codelib.SPIGOT.api.update;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
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;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import net.t2code.t2codelib.util.T2C_UpdateType;
|
||||
import net.t2code.t2codelib.util.T2C_UpdateObject;
|
||||
import net.t2code.t2codelib.util.T2C_UpdateWebData;
|
||||
import net.t2code.t2codelib.util.T2C_Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -16,16 +16,11 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class T2C_UpdateAPI {
|
||||
public static HashMap<String, T2CupdateObject> pluginVersions = new HashMap<>();
|
||||
public static HashMap<String, T2C_UpdateObject> pluginVersions = new HashMap<>();
|
||||
|
||||
public static void join(Plugin plugin, String prefix, String perm, Player player, Integer spigotID, String discord) {
|
||||
if (pluginVersions.get(plugin.getName()) == null) {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
join(plugin, prefix, perm, player, spigotID, discord);
|
||||
}
|
||||
}, 2 * 20L);
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(T2C_Main.getPlugin(), () -> join(plugin, prefix, perm, player, spigotID, discord), 2 * 20L);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,22 +39,23 @@ public class T2C_UpdateAPI {
|
||||
}.runTaskLaterAsynchronously(plugin, 20L);
|
||||
return;
|
||||
}
|
||||
T2CupdateWebData webData = pluginVersions.get(plugin.getName()).webData;
|
||||
T2C_UpdateWebData webData = pluginVersions.get(plugin.getName()).webData;
|
||||
if (!pluginVersions.get(plugin.getName()).updateAvailable) return;
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendUpdateMsg(prefix, webData, discord, plugin, player);
|
||||
}
|
||||
}.runTaskLaterAsynchronously(T2CodeLibMain.getPlugin(), 200L);
|
||||
}.runTaskLaterAsynchronously(T2C_Main.getPlugin(), 200L);
|
||||
}
|
||||
|
||||
public static void sendUpdateMsg(String prefix, T2CupdateWebData webData, String discord, Plugin plugin, Player player) {
|
||||
public static void sendUpdateMsg(String prefix, T2C_UpdateWebData webData, String discord, Plugin plugin, Player player) {
|
||||
String publicVersion = webData.getVersion();
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
if (!pluginVersions.get(plugin.getName()).updateAvailable) {
|
||||
return;
|
||||
}
|
||||
String updateStatusVersion = getUpdateType(webData);
|
||||
String st = "[prefix]<br>" +
|
||||
"<click:open_url:'[link]'><hover:show_text:'<color:#6e90ff>You can download it here: <yellow>[link]</yellow></color>'>[prefix] <color:#6e90ff>A new</color> [value] <color:#6e90ff>version was" +
|
||||
" found!</color></hover></click><br>" +
|
||||
@@ -69,81 +65,40 @@ public class T2C_UpdateAPI {
|
||||
"[prefix] <color:#ff9499><hover:show_text:'<red>Click for more information</red>'><click:run_command:'/t2c updateinfo " + plugin.getName() + "'>Update information</click></hover></color><br>" +
|
||||
"[prefix]";
|
||||
|
||||
String updateStatusVersion;
|
||||
|
||||
if (webData.isPreRelease()) {
|
||||
//todo if (!SelectLibConfig.getSeePreReleaseUpdates()) return;
|
||||
updateStatusVersion = UpdateType.PRERELEASE.text;
|
||||
if (publicVersion.toLowerCase().contains("dev")) {
|
||||
updateStatusVersion = UpdateType.DEVELOPMENT.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("beta")) {
|
||||
updateStatusVersion = UpdateType.BETA.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("snapshot")) {
|
||||
updateStatusVersion = UpdateType.SNAPSHOT.text;
|
||||
}
|
||||
} else updateStatusVersion = UpdateType.STABLE.text;
|
||||
|
||||
T2C_Send.player(player, st.replace("[prefix]", prefix).replace("[value]", updateStatusVersion).replace("[link]", webData.getUpdateUrl())
|
||||
.replace("[plv]", pluginVersion).replace("[puv]", publicVersion).replace("[dc]", discord));
|
||||
}
|
||||
|
||||
public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Plugin plugin) {
|
||||
public static void sendUpdateMsg(String prefix, String discord, T2C_UpdateWebData webData, Plugin plugin) {
|
||||
String publicVersion = webData.getVersion();
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
String updateStatusVersion;
|
||||
if (webData.isPreRelease()) {
|
||||
updateStatusVersion = UpdateType.PRERELEASE.text;
|
||||
if (publicVersion.toLowerCase().contains("dev")) {
|
||||
updateStatusVersion = UpdateType.DEVELOPMENT.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("beta")) {
|
||||
updateStatusVersion = UpdateType.BETA.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("snapshot")) {
|
||||
updateStatusVersion = UpdateType.SNAPSHOT.text;
|
||||
}
|
||||
} else updateStatusVersion = UpdateType.STABLE.text;
|
||||
String s1 = " <color:#6e90ff>A new [value] version was found!</color>".replace("[value]", updateStatusVersion);
|
||||
String s2 = " <color:#6e90ff>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</color> <green>" + webData.getVersion() + "</green>";
|
||||
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>";
|
||||
String updateStatusVersion = getUpdateType(webData);
|
||||
String s1 = "<color:#6e90ff>A new [value] version was found!</color>".replace("[value]", updateStatusVersion);
|
||||
String s2 = "<color:#6e90ff>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</color> <green>" + webData.getVersion() + "</green>";
|
||||
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>";
|
||||
|
||||
T2C_Send.sendFrameCenter(prefix,s1,s2,s3,s4);
|
||||
T2C_Send.console(T2C_Send.getFrameCenter(prefix, true, s1, s2, s3, s4));
|
||||
}
|
||||
|
||||
public static String updateInfo(String[] args, Boolean player) {
|
||||
T2CupdateObject object;
|
||||
T2C_UpdateObject object;
|
||||
try {
|
||||
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>";
|
||||
return T2C_Util.getPrefix() + " <red>The plugin <yellow>" + args[1] + "</yellow> is not registered in the update checker of T2Code!</red>";
|
||||
}
|
||||
if (object == null) return Util.getPrefix() + " <red>The plugin <yellow>" + args[1] + "</yellow> is not registered in the update checker of T2Code!</red>";
|
||||
T2CupdateWebData webData = object.webData;
|
||||
if (object == null) return T2C_Util.getPrefix() + " <red>The plugin <yellow>" + args[1] + "</yellow> is not registered in the update checker of T2Code!</red>";
|
||||
T2C_UpdateWebData webData = object.webData;
|
||||
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>";
|
||||
return T2C_Util.getPrefix() + " <b><dark_red>It could not be checked for updates with the plugin <yellow>" + args[1] + "</yellow>!</dark_red></b>";
|
||||
}
|
||||
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();
|
||||
String updateType;
|
||||
|
||||
if (webData.isPreRelease()) {
|
||||
updateType = UpdateType.PRERELEASE.text;
|
||||
if (updateVersion.toLowerCase().contains("dev")) {
|
||||
updateType = UpdateType.DEVELOPMENT.text;
|
||||
}
|
||||
if (updateVersion.toLowerCase().contains("beta")) {
|
||||
updateType = UpdateType.BETA.text;
|
||||
}
|
||||
if (updateVersion.toLowerCase().contains("snapshot")) {
|
||||
updateType = UpdateType.SNAPSHOT.text;
|
||||
}
|
||||
} else updateType = UpdateType.STABLE.text;
|
||||
String publicVersion = webData.getVersion();
|
||||
String updateType = getUpdateType(webData);
|
||||
|
||||
String updateAt = webData.getPublishedAt();
|
||||
String updateUpdate = webData.getUpdateUrl();
|
||||
@@ -153,7 +108,7 @@ public class T2C_UpdateAPI {
|
||||
String pluginVersionString = "<br><dark_red>║</dark_red> <color:#6e90ff>Your version:</color> <color:#5eff89>" + pluginVersion + "</color>";
|
||||
String updateInfoString = "<br><dark_red>║</dark_red> <color:#09ff00>[value]:</color>";
|
||||
String updateTitleString = "<br><dark_red>║</dark_red> <color:#6e90ff>Title:</color> <color:#5eff89>" + updateTitle + "</color>";
|
||||
String updateVersionString = "<br><dark_red>║</dark_red> <color:#6e90ff>Version:</color> <color:#5eff89>" + updateVersion + "</color>";
|
||||
String updateVersionString = "<br><dark_red>║</dark_red> <color:#6e90ff>Version:</color> <color:#5eff89>" + publicVersion + "</color>";
|
||||
String updateAtString = "<br><dark_red>║</dark_red> <color:#6e90ff>Published on:</color> <color:#5eff89>" + updateAt + "</color>";
|
||||
String updateTypeString = "<br><dark_red>║</dark_red> <color:#6e90ff>Version type:</color> <color:#5eff89>" + updateType + "</color>";
|
||||
|
||||
@@ -187,4 +142,22 @@ public class T2C_UpdateAPI {
|
||||
if ((boolean) T2C_LibConfig.VALUES.updateCheckFullDisable.getValue()) return;
|
||||
new T2C_UpdateCheckerGit((JavaPlugin) plugin, prefix, gitKey, spigotID, discord, updateCheckOnJoin, seePreReleaseUpdates, timeInterval);
|
||||
}
|
||||
|
||||
private static String getUpdateType(T2C_UpdateWebData webData) {
|
||||
String updateType;
|
||||
String publicVersion = webData.getVersion();
|
||||
if (webData.isPreRelease()) {
|
||||
updateType = T2C_UpdateType.PRERELEASE.text;
|
||||
if (publicVersion.toLowerCase().contains("dev")) {
|
||||
updateType = T2C_UpdateType.DEVELOPMENT.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("beta")) {
|
||||
updateType = T2C_UpdateType.BETA.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("snapshot")) {
|
||||
updateType = T2C_UpdateType.SNAPSHOT.text;
|
||||
}
|
||||
} else updateType = T2C_UpdateType.STABLE.text;
|
||||
return updateType;
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,11 @@
|
||||
package net.t2code.t2codelib.SPIGOT.api.update;
|
||||
|
||||
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.T2C_Main;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||
import net.t2code.t2codelib.T2CupdateObject;
|
||||
import net.t2code.t2codelib.T2CupdateWebData;
|
||||
import net.t2code.t2codelib.util.T2C_UpdateObject;
|
||||
import net.t2code.t2codelib.util.T2C_UpdateWebData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@@ -20,7 +21,7 @@ import java.util.function.Consumer;
|
||||
|
||||
public class T2C_UpdateCheckerGit {
|
||||
private final JavaPlugin plugin;
|
||||
private T2CupdateObject t2CupdateObject;
|
||||
private T2C_UpdateObject t2CupdateObject;
|
||||
|
||||
|
||||
public T2C_UpdateCheckerGit(JavaPlugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
|
||||
@@ -42,7 +43,7 @@ public class T2C_UpdateCheckerGit {
|
||||
public void run() {
|
||||
if ((boolean) T2C_LibConfig.VALUES.updateCheckFullDisable.getValue()) return;
|
||||
getVersion((webData) -> {
|
||||
T2CupdateObject update = new T2CupdateObject(
|
||||
T2C_UpdateObject update = new T2C_UpdateObject(
|
||||
plugin.getName(),
|
||||
plugin.getDescription().getVersion(),
|
||||
webData,
|
||||
@@ -53,7 +54,7 @@ public class T2C_UpdateCheckerGit {
|
||||
|
||||
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");
|
||||
T2C_Debug.debugmsg(T2C_Main.getPlugin(), "'" + plugin.getName() + "' UpdateAPI T2CupdateAPI.pluginVersions.get(plugin.getName()) == null");
|
||||
return;
|
||||
}
|
||||
if (T2C_UpdateAPI.pluginVersions.get(plugin.getName()).updateAvailable) {
|
||||
@@ -80,7 +81,7 @@ public class T2C_UpdateCheckerGit {
|
||||
}, 10L, finalInterval * 60 * 20L);
|
||||
}
|
||||
|
||||
public void getVersion(Consumer<T2CupdateWebData> consumer, String pluginVersion, Integer spigotID, String URL, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
|
||||
public void getVersion(Consumer<T2C_UpdateWebData> consumer, String pluginVersion, Integer spigotID, String URL, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
|
||||
if (!plugin.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
@@ -128,14 +129,14 @@ public class T2C_UpdateCheckerGit {
|
||||
updateUrl = "https://www.spigotmc.org/resources/" + spigotID;
|
||||
}
|
||||
|
||||
T2CupdateWebData webData = new T2CupdateWebData(updateTitle, version, updateDescription, updateUrl, publishedAt, downloadURL, gitURL, preRelease);
|
||||
T2C_UpdateWebData webData = new T2C_UpdateWebData(updateTitle, version, updateDescription, updateUrl, publishedAt, downloadURL, gitURL, preRelease);
|
||||
consumer.accept(webData);
|
||||
} catch (Exception exception) {
|
||||
Boolean load = false;
|
||||
if (T2C_UpdateAPI.pluginVersions.containsKey(plugin.getName())) {
|
||||
load = T2C_UpdateAPI.pluginVersions.get(plugin.getName()).load;
|
||||
}
|
||||
T2CupdateObject update = new T2CupdateObject(
|
||||
T2C_UpdateObject update = new T2C_UpdateObject(
|
||||
plugin.getName(),
|
||||
pluginVersion,
|
||||
null,
|
||||
|
@@ -3,7 +3,7 @@ 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 net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -17,7 +17,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void set(String path, String value, YamlConfiguration YamlConfiguration) {
|
||||
@@ -29,7 +29,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void set(String path, Object value, YamlConfiguration YamlConfiguration) {
|
||||
@@ -41,7 +41,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void set(String path, YamlConfiguration YamlConfiguration) {
|
||||
@@ -51,7 +51,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void set(String path, Integer value, YamlConfiguration YamlConfiguration) {
|
||||
@@ -63,7 +63,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void set(String path, Double value, YamlConfiguration YamlConfiguration) {
|
||||
@@ -75,7 +75,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void set(String path, Boolean value, YamlConfiguration YamlConfiguration) {
|
||||
@@ -87,7 +87,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void set(String path, List<String> value, YamlConfiguration YamlConfiguration) {
|
||||
@@ -99,7 +99,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void set(String path, ItemStack value, YamlConfiguration YamlConfiguration) {
|
||||
@@ -111,7 +111,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void setSound(String soundName, String sound1_8, String sound1_9, String sound1_13, YamlConfiguration yamlConfiguration) {
|
||||
@@ -128,7 +128,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void setSound(String soundName, String sound1_8, String sound1_13, YamlConfiguration yamlConfiguration) {
|
||||
@@ -143,7 +143,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void setSound(String soundName, String sound, YamlConfiguration yamlConfiguration) {
|
||||
@@ -154,7 +154,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static boolean selectSoundEnable(String soundName, YamlConfiguration yamlConfiguration) {
|
||||
@@ -164,7 +164,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static String selectSound(String prefix, String soundName, YamlConfiguration yamlConfiguration) {
|
||||
@@ -174,7 +174,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Sound checkSound(String sound1_8, String sound1_9, String sound1_13, String selectSoundFromConfig, String prefix) {
|
||||
@@ -184,7 +184,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Sound checkSound(String sound1_8, String sound1_13, String selectSoundFromConfig, String prefix) {
|
||||
@@ -194,7 +194,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Sound checkSound(String sound, String selectSoundFromConfig, String prefix) {
|
||||
@@ -205,7 +205,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static String select(String prefix, String path, YamlConfiguration yamlConfiguration) {
|
||||
@@ -215,7 +215,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Object selectObject(String prefix, String path, YamlConfiguration yamlConfiguration) {
|
||||
@@ -225,7 +225,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Integer selectInt(String path, YamlConfiguration yamlConfiguration) {
|
||||
@@ -235,7 +235,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Boolean selectBoolean(String path, YamlConfiguration yamlConfiguration) {
|
||||
@@ -245,7 +245,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Double selectDouble(String path, YamlConfiguration yamlConfiguration) {
|
||||
@@ -255,7 +255,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static List<String> selectList(String path, YamlConfiguration yamlConfiguration) {
|
||||
@@ -265,7 +265,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static ItemStack selectItemStack(String path, YamlConfiguration yamlConfiguration) {
|
||||
@@ -275,7 +275,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static List<String> selectList(String prefix, String path, YamlConfiguration yamlConfiguration) {
|
||||
@@ -290,7 +290,7 @@ 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...)}.
|
||||
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static void select(String prefix, List<String> value, String path, YamlConfiguration yamlConfiguration) {
|
||||
|
@@ -3,9 +3,9 @@
|
||||
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 net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@@ -19,14 +19,14 @@ public class T2C_ConfigWriter {
|
||||
|
||||
private static FileConfiguration config;
|
||||
|
||||
public static void createConfig(File configFile, T2CconfigItem[] values, String... header) {
|
||||
public static void createConfig(File configFile, T2C_ConfigItem[] values, String... header) {
|
||||
boolean exist = configFile.exists();
|
||||
if (!exist) {
|
||||
configFile.getParentFile().mkdirs();
|
||||
try {
|
||||
configFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
T2C_Send.sendException(e, T2CodeLibMain.getPlugin().getLogger());
|
||||
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||
return;
|
||||
}
|
||||
} else exist = true;
|
||||
@@ -34,13 +34,13 @@ public class T2C_ConfigWriter {
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
Map<String, List<String>> comments = new LinkedHashMap<>();
|
||||
|
||||
T2CLanguageEnum lang = T2CLanguageEnum.english;
|
||||
T2C_LanguageEnum lang = T2C_LanguageEnum.english;
|
||||
try {
|
||||
lang = T2CLanguageEnum.valueOf(config.getString(values[0].getLanguagePath().replace(".yml", "")));
|
||||
lang = T2C_LanguageEnum.valueOf(config.getString(values[0].getLanguagePath().replace(".yml", "")));
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
|
||||
for (T2CconfigItem item : values) {
|
||||
for (T2C_ConfigItem item : values) {
|
||||
if (item.getForceSet() || !exist) {
|
||||
config.addDefault(item.getPath(), item.getValue());
|
||||
|
||||
@@ -58,8 +58,8 @@ public class T2C_ConfigWriter {
|
||||
readConfig(config, values);
|
||||
}
|
||||
|
||||
private static void readConfig(FileConfiguration config, T2CconfigItem[] values) {
|
||||
for (T2CconfigItem value : values) {
|
||||
private static void readConfig(FileConfiguration config, T2C_ConfigItem[] values) {
|
||||
for (T2C_ConfigItem value : values) {
|
||||
value.setValue(config.get(value.getPath()));
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
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.T2CconfigItemLanguages;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||
import net.t2code.t2codelib.util.T2C_ConfigItemLanguages;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@@ -17,14 +17,14 @@ public class T2C_LanguageWriter {
|
||||
|
||||
private static FileConfiguration config;
|
||||
|
||||
public static void createConfig(String prefix, File path, T2CconfigItemLanguages[] values, String loadConfig, boolean isReload, String... header) {
|
||||
public static void createConfig(String prefix, File path, T2C_ConfigItemLanguages[] values, String loadConfig, boolean isReload, String... header) {
|
||||
|
||||
File f = new File(path + "/languages/");
|
||||
f.mkdirs();
|
||||
File[] fileArray = f.listFiles();
|
||||
if (fileArray.length == 0) {
|
||||
List<File> zw = new ArrayList<>();
|
||||
for (T2CLanguageEnum lan : T2CLanguageEnum.values()) {
|
||||
for (T2C_LanguageEnum lan : T2C_LanguageEnum.values()) {
|
||||
if (values[0].getLanguage().containsKey(lan)) {
|
||||
zw.add(new File(path + "/languages/" + lan.name() + ".yml"));
|
||||
}
|
||||
@@ -33,9 +33,9 @@ public class T2C_LanguageWriter {
|
||||
}
|
||||
for (File langFile : fileArray) {
|
||||
if (langFile.getName().endsWith(".yml")) {
|
||||
T2CLanguageEnum lang = T2CLanguageEnum.english;
|
||||
T2C_LanguageEnum lang = T2C_LanguageEnum.english;
|
||||
try {
|
||||
lang = T2CLanguageEnum.valueOf(langFile.getName().replace(".yml", ""));
|
||||
lang = T2C_LanguageEnum.valueOf(langFile.getName().replace(".yml", ""));
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class T2C_LanguageWriter {
|
||||
try {
|
||||
langFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
T2C_Send.sendException(e, T2CodeLibMain.getPlugin().getLogger());
|
||||
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class T2C_LanguageWriter {
|
||||
// Copy default values if they are missing
|
||||
config = YamlConfiguration.loadConfiguration(langFile);
|
||||
config.options().copyDefaults(true);
|
||||
for (T2CconfigItemLanguages item : values) {
|
||||
for (T2C_ConfigItemLanguages item : values) {
|
||||
config.addDefault(item.getPath(), item.getLanguage().get(lang));
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class T2C_LanguageWriter {
|
||||
readConfig(prefix, path, values, loadConfig, isReload);
|
||||
}
|
||||
|
||||
private static void readConfig(String prefix, File path, T2CconfigItemLanguages[] values, String loadConfig, boolean isReload) {
|
||||
private static void readConfig(String prefix, File path, T2C_ConfigItemLanguages[] values, String loadConfig, boolean isReload) {
|
||||
String selectMSG;
|
||||
File msg;
|
||||
msg = new File(path, "languages/" + loadConfig + ".yml");
|
||||
@@ -75,14 +75,14 @@ public class T2C_LanguageWriter {
|
||||
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, "§6The default language §e" + T2C_LanguageEnum.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();
|
||||
msg = new File(path, "languages/" + T2C_LanguageEnum.english.name() + ".yml");
|
||||
selectMSG = T2C_LanguageEnum.english.name();
|
||||
} else selectMSG = loadConfig;
|
||||
YamlConfiguration yml = YamlConfiguration.loadConfiguration(msg);
|
||||
for (T2CconfigItemLanguages value : values) {
|
||||
for (T2C_ConfigItemLanguages value : values) {
|
||||
value.setValue(yml.get(value.getPath()));
|
||||
}
|
||||
T2C_Send.sendStartTextCenter(prefix, "§2Language successfully selected to: §6" + selectMSG, isReload);
|
||||
|
Reference in New Issue
Block a user