Merge pull request '12.5' (#6) from 12.4-DEV into main

Reviewed-on: #6
This commit is contained in:
JaTiTV 2022-07-14 21:58:00 +02:00
commit f35b4efe4f
18 changed files with 247 additions and 131 deletions

View File

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: junit:junit:4.10">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.10/junit-4.10.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.10/junit-4.10-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.10/junit-4.10-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: org.hamcrest:hamcrest-core:1.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -13,7 +13,7 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="16" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@ -44,7 +44,7 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: me.clip:placeholderapi:2.11.1" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: me.clip:placeholderapi:2.11.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains:annotations:19.0.0" level="project" /> <orderEntry type="library" name="Maven: org.jetbrains:annotations:19.0.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.bencodez:votingplugin:6.9.2" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: com.bencodez:votingplugin:6.9.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-velocity:2.2.1" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-velocity:2.2.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-base:2.2.1" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-base:2.2.1" level="project" />
@ -53,5 +53,19 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-simple:1.7.5" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-simple:1.7.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: xyz.upperlevel.spigot.book:spigot-book-api:1.6" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: xyz.upperlevel.spigot.book:spigot-book-api:1.6" level="project" />
<orderEntry type="library" name="Maven: net.kyori:adventure-text-minimessage:4.11.0" level="project" />
<orderEntry type="library" name="Maven: net.kyori:adventure-api:4.11.0" level="project" />
<orderEntry type="library" name="Maven: net.kyori:adventure-key:4.11.0" level="project" />
<orderEntry type="library" name="Maven: net.kyori:examination-api:1.3.0" level="project" />
<orderEntry type="library" name="Maven: net.kyori:examination-string:1.3.0" level="project" />
<orderEntry type="library" name="Maven: net.kyori:adventure-platform-bukkit:4.1.1" level="project" />
<orderEntry type="library" name="Maven: net.kyori:adventure-platform-api:4.1.1" level="project" />
<orderEntry type="library" name="Maven: net.kyori:adventure-text-serializer-bungeecord:4.1.1" level="project" />
<orderEntry type="library" name="Maven: net.kyori:adventure-text-serializer-legacy:4.11.0" level="project" />
<orderEntry type="library" name="Maven: net.kyori:adventure-nbt:4.11.0" level="project" />
<orderEntry type="library" name="Maven: net.kyori:adventure-text-serializer-gson:4.11.0" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: net.kyori:adventure-text-serializer-gson-legacy-impl:4.11.0" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: net.kyori:adventure-platform-facet:4.1.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: net.kyori:adventure-platform-viaversion:4.1.1" level="project" />
</component> </component>
</module> </module>

26
pom.xml
View File

@ -4,8 +4,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>12.3</version> <version>12.5</version>
<!-- <classifier>dev-#2</classifier> --> <!-- <classifier>dev-1</classifier> -->
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<packaging>jar</packaging> <packaging>jar</packaging>
@ -57,10 +57,12 @@
</build> </build>
<repositories> <repositories>
<!-- Mojang / Spigot -->
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository> </repository>
<!-- repo.t2code / T2Code -->
<repository> <repository>
<id>Builders-Paradise</id> <id>Builders-Paradise</id>
<url>https://repo.t2code.net/repository/Builders-Paradise/</url> <url>https://repo.t2code.net/repository/Builders-Paradise/</url>
@ -69,14 +71,17 @@
<id>T2Code</id> <id>T2Code</id>
<url>https://repo.t2code.net/repository/T2Code/</url> <url>https://repo.t2code.net/repository/T2Code/</url>
</repository> </repository>
<!-- Vault-->
<repository> <repository>
<id>jitpack.io</id> <id>jitpack.io</id>
<url>https://jitpack.io</url> <url>https://jitpack.io</url>
</repository> </repository>
<!-- placeholderapi -->
<repository> <repository>
<id>placeholderapi</id> <id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url> <url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository> </repository>
<!-- votingplugin -->
<repository> <repository>
<id>BenCodez Repo</id> <id>BenCodez Repo</id>
<url>https://nexus.bencodez.com/repository/maven-public/</url> <url>https://nexus.bencodez.com/repository/maven-public/</url>
@ -84,12 +89,15 @@
</repositories> </repositories>
<dependencies> <dependencies>
<!-- Mojang / Spigot-->
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version> <version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- repo.t2code / T2Code -->
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>bungee</artifactId> <artifactId>bungee</artifactId>
@ -100,23 +108,37 @@
<artifactId>LuckyBox-API</artifactId> <artifactId>LuckyBox-API</artifactId>
<version>4.2.7</version> <version>4.2.7</version>
</dependency> </dependency>
<!-- Vault-->
<dependency> <dependency>
<groupId>com.github.MilkBowl</groupId> <groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId> <artifactId>VaultAPI</artifactId>
<version>1.7</version> <version>1.7</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- placeholderapi -->
<dependency> <dependency>
<groupId>me.clip</groupId> <groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId> <artifactId>placeholderapi</artifactId>
<version>2.11.1</version> <version>2.11.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- votingplugin -->
<dependency> <dependency>
<groupId>com.bencodez</groupId> <groupId>com.bencodez</groupId>
<artifactId>votingplugin</artifactId> <artifactId>votingplugin</artifactId>
<version>LATEST</version> <version>LATEST</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!--Kyori MiniMessage-->
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.11.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.1.1</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -75,7 +75,7 @@ public class Tab {
} }
private static Boolean passend(String command, String arg) { public static Boolean passend(String command, String arg) {
for (int i = 0; i < arg.toUpperCase().length(); i++) { for (int i = 0; i < arg.toUpperCase().length(); i++) {
if (arg.toUpperCase().length() >= command.toUpperCase().length()) { if (arg.toUpperCase().length() >= command.toUpperCase().length()) {
return false; return false;

View File

@ -1,31 +1,54 @@
package net.t2code.lib.Spigot.Lib.messages; package net.t2code.lib.Spigot.Lib.messages;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.t2code.lib.Spigot.Lib.replace.Replace;
import net.t2code.lib.Spigot.system.T2CodeMain; import net.t2code.lib.Spigot.system.T2CodeMain;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class HoverModule { public class HoverModule {
public static void module(String text, String hover, String action, String actionValue, Player player) { public static void modulePlayer(String text, String hover, String action, String actionValue, Player player) {
module((text != null ? text : "null") + "/*/" + (hover != null ? hover : "null") + "/*/" + (action != null ? action : "null") modulePlayer((text != null ? text : "null") + "/*/" + (hover != null ? hover : "null") + "/*/" + (action != null ? action : "null")
+ "/*/" + (actionValue != null ? actionValue : "null"), player); + "/*/" + (actionValue != null ? actionValue : "null"), player);
} }
private static final MiniMessage mm = MiniMessage.miniMessage();
public static void module(String msg, Player player) { public static void modulePlayer(String msg, Player player) {
if (!msg.contains("/*/")) { if (msg.contains("/*/")) {
player.sendMessage(msg); t2cmodule(msg, player);
return; return;
} }
miniMessage(msg,player);
}
public static void moduleSender(String msg, CommandSender sender) {
miniMessage(msg,sender);
}
public static void miniMessage(String msg, Player player){
Component parsed = mm.deserialize(Replace.convertColorCode(msg));
T2CodeMain.adventure.player(player).sendMessage(parsed);
}
public static void miniMessage(String msg, CommandSender sender){
Component parsed = mm.deserialize(Replace.convertColorCode(msg));
T2CodeMain.adventure.sender(sender).sendMessage(parsed);
}
private static void t2cmodule(String msg, Player player) {
String[] split = msg.split("/\\*/"); String[] split = msg.split("/\\*/");
int i = split.length; int i = split.length;
String text = null; String text = null;
String hover = null; String hover = null;
String action = null; String action = null;
String actionValue = null; String actionValue = null;
if (i > 0) text= split[0]; if (i > 0) text = split[0];
if (i > 1) hover =split[1]; if (i > 1) hover = split[1];
if (i > 2)action = split[2]; if (i > 2) action = split[2];
if (i > 3)actionValue = split[3]; if (i > 3) actionValue = split[3];
TextBuilder textBuilder = new TextBuilder(text); TextBuilder textBuilder = new TextBuilder(text);
if (hover != null && !hover.equals("null")) { if (hover != null && !hover.equals("null")) {

View File

@ -20,7 +20,7 @@ public class send {
public static void player( Player player, String msg) { public static void player( Player player, String msg) {
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) return;
HoverModule.module(msg, player); HoverModule.modulePlayer(msg, player);
} }
public static void title( Player player, String msg, String msg2) { public static void title( Player player, String msg, String msg2) {
@ -37,7 +37,7 @@ public class send {
public static void sender( CommandSender sender, String msg) { public static void sender( CommandSender sender, String msg) {
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) return;
sender.sendMessage(msg); HoverModule.moduleSender(msg, sender);
} }
public static void debug( Plugin plugin, String msg) { public static void debug( Plugin plugin, String msg) {

View File

@ -40,6 +40,9 @@ public class PluginCheck {
public static Boolean cgui(){ public static Boolean cgui(){
return Bukkit.getPluginManager().getPlugin("CommandGUI") != null; return Bukkit.getPluginManager().getPlugin("CommandGUI") != null;
} }
public static Boolean functiongui(){
return Bukkit.getPluginManager().getPlugin("T2C-CommandGUI") != null;
}
public static Boolean plotSquaredGUI(){ public static Boolean plotSquaredGUI(){
return Bukkit.getPluginManager().getPlugin("PlotSquaredGUI") != null; return Bukkit.getPluginManager().getPlugin("PlotSquaredGUI") != null;
} }

View File

@ -0,0 +1,42 @@
package net.t2code.lib.Spigot.Lib.plugins;
import net.t2code.lib.Spigot.system.T2CodeMain;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import java.util.Objects;
public class T2CPluginManager {
public static void restart(String plugin) {
if (Bukkit.getPluginManager().getPlugin(plugin) == null) return;
T2CodeMain.getPlugin().getPluginLoader().disablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
T2CodeMain.getPlugin().getPluginLoader().enablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
}
public static void enable(String plugin) {
if (Bukkit.getPluginManager().getPlugin(plugin) == null) return;
T2CodeMain.getPlugin().getPluginLoader().enablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
}
public static void disable(String plugin) {
if (Bukkit.getPluginManager().getPlugin(plugin) == null) return;
T2CodeMain.getPlugin().getPluginLoader().disablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
}
public static void restart(Plugin plugin) {
if (plugin == null) return;
T2CodeMain.getPlugin().getPluginLoader().disablePlugin(plugin);
T2CodeMain.getPlugin().getPluginLoader().enablePlugin(plugin);
}
public static void enable(Plugin plugin) {
if (plugin == null) return;
T2CodeMain.getPlugin().getPluginLoader().enablePlugin(plugin);
}
public static void disable(Plugin plugin) {
if (plugin == null) return;
T2CodeMain.getPlugin().getPluginLoader().disablePlugin(plugin);
}
}

View File

@ -3,36 +3,32 @@ package net.t2code.lib.Spigot.Lib.replace;
import me.clip.placeholderapi.PlaceholderAPI; import me.clip.placeholderapi.PlaceholderAPI;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.system.T2CodeMain; import net.t2code.lib.Spigot.system.T2CodeMain;
import net.t2code.lib.Spigot.system.config.SelectLibConfig;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
public class Replace { public class Replace {
public static String replace(String prefix, String Text) { public static String replace(String prefix, String Text) {
return Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü")
return replaceLegacyColor(Text).replace("[prefix]", prefix).replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö") .replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n") .replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n");
;
} }
public static String replace(String prefix, Player player, String Text) { public static String replace(String prefix, Player player, String Text) {
return PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix).replace("&", "§") return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")); .replace("[nl]", "\n")));
} }
public static List<String> replace(String prefix, List<String> Text) { public static List<String> replace(String prefix, List<String> Text) {
List<String> output = new ArrayList<>(); List<String> output = new ArrayList<>();
for (String input : Text) { for (String input : Text) {
output.add(input.replace("[prefix]", prefix).replace("&", "§") output.add(replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")); .replace("[nl]", "\n"));
@ -49,7 +45,7 @@ public class Replace {
return Collections.singletonList("Text is null"); return Collections.singletonList("Text is null");
} }
for (String input : Text) { for (String input : Text) {
output.add(PlaceholderAPI.setPlaceholders(player, input.replace("[prefix]", prefix).replace("&", "§") output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n"))); .replace("[nl]", "\n")));
@ -60,7 +56,7 @@ public class Replace {
public static List<String> replacePrice(String prefix, List<String> Text, String price) { public static List<String> replacePrice(String prefix, List<String> Text, String price) {
List<String> rp = new ArrayList(); List<String> rp = new ArrayList();
for (String s : Text) { for (String s : Text) {
rp.add(s.replace("[prefix]", prefix).replace("&", "§") rp.add(replaceLegacyColor(s).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n").replace("[price]", String.valueOf(price))); .replace("[nl]", "\n").replace("[price]", String.valueOf(price)));
@ -69,40 +65,81 @@ public class Replace {
} }
public static String removeColorCode(String value) { public static String removeColorCode(String value) {
String text = value.replace("&", "§"); return value.replace("&0", "").replace("&1", "").replace("&2", "").replace("&3", "")
while (text.contains("§")) { .replace("&4", "").replace("&5", "").replace("&6", "").replace("&7", "")
int stelle = text.indexOf("§"); .replace("&8", "").replace("&9", "").replace("&a", "").replace("&b", "")
if (text.length() >= stelle + 2) { .replace("&c", "").replace("&d", "").replace("&e", "").replace("&f", "")
text = text.substring(0, stelle) + text.substring(stelle + 2); .replace("&k", "").replace("&l", "").replace("&m", "").replace("&n", "")
} else { .replace("&o", "").replace("&r", "");
text = text.substring(0, stelle) + text.substring(stelle + 1); // String text = value.replace("&", "§");
} // while (text.contains("§")) {
} // int stelle = text.indexOf("§");
return (text); // if (text.length() >= stelle + 2) {
// text = text.substring(0, stelle) + text.substring(stelle + 2);
// } else {
// text = text.substring(0, stelle) + text.substring(stelle + 1);
// }
// }
// return (text);
} }
public static List<String> replacePrice(String prefix, Player player, List<String> Text, String price) { public static List<String> replacePrice(String prefix, Player player, List<String> Text, String price) {
List<String> rp = new ArrayList(); List<String> rp = new ArrayList();
for (String s : Text) { for (String s : Text) {
rp.add(PlaceholderAPI.setPlaceholders(player, s.replace("[prefix]", prefix).replace("&", "§") rp.add(replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, s.replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n") .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n")
.replace("[price]", String.valueOf(price)))); .replace("[price]", String.valueOf(price)))));
} }
return rp; return rp;
} }
public static String replacePrice(String prefix, String Text, String price) { public static String replacePrice(String prefix, String Text, String price) {
return Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü") return replaceLegacyColor(Text).replace("[prefix]", prefix)
.replace("&o", "§o").replace("&r", "§r").replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö") .replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[price]", String.valueOf(price)) .replace("[ae]", "ä").replace("[AE]", "Ä").replace("[price]", String.valueOf(price))
.replace("[nl]", "\n"); .replace("[nl]", "\n");
} }
public static String replacePrice(String prefix, Player player, String Text, String price) { public static String replacePrice(String prefix, Player player, String Text, String price) {
return PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix).replace("&", "§") return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[price]", String.valueOf(price)).replace("[nl]", "\n")); .replace("[price]", String.valueOf(price)).replace("[nl]", "\n")));
}
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>");
} }
} }

View File

@ -21,7 +21,7 @@ public class UpdateAPI {
public static HashMap<String, UpdateObject> PluginVersionen = new HashMap<>(); public static HashMap<String, UpdateObject> PluginVersionen = new HashMap<>();
public static void join(Plugin plugin, String prefix, String perm, Player player, String spigot, String discord) { public static void join(Plugin plugin, String prefix, String perm, Player player, String spigot, String discord) {
if (!SelectLibConfig.UpdateCheckOnJoin) { if (!SelectLibConfig.getUpdateCheckOnJoin()) {
return; return;
} }
String pluginVersion = plugin.getDescription().getVersion(); String pluginVersion = plugin.getDescription().getVersion();
@ -81,19 +81,19 @@ public class UpdateAPI {
send.player(player, Prefix); send.player(player, Prefix);
if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")) { if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")) {
if (publicVersion.toLowerCase().contains("dev")) { if (publicVersion.toLowerCase().contains("dev")) {
HoverModule.module(Prefix + " §6A new §4DEV§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); HoverModule.modulePlayer(Prefix + " §6A new §4DEV§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player);
} }
if (publicVersion.toLowerCase().contains("beta")) { if (publicVersion.toLowerCase().contains("beta")) {
HoverModule.module(Prefix + " §6A new §2BETA§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); HoverModule.modulePlayer(Prefix + " §6A new §2BETA§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player);
} }
if (publicVersion.toLowerCase().contains("snapshot")) { if (publicVersion.toLowerCase().contains("snapshot")) {
HoverModule.module(Prefix + " §6A new §eSNAPSHOT§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); HoverModule.modulePlayer(Prefix + " §6A new §eSNAPSHOT§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player);
} }
} else { } else {
HoverModule.module(Prefix + " §6A new version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); HoverModule.modulePlayer(Prefix + " §6A new version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player);
} }
HoverModule.module(Prefix + " §c" + pluginVersion + " §7-> §a" + publicVersion, "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); HoverModule.modulePlayer(Prefix + " §c" + pluginVersion + " §7-> §a" + publicVersion, "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player);
HoverModule.module(Prefix + " §6You can find more information on Discord.", "§e" + Discord, "OPEN_URL", Discord, player); HoverModule.modulePlayer(Prefix + " §6You can find more information on Discord.", "§e" + Discord, "OPEN_URL", Discord, player);
send.player(player, Prefix); send.player(player, Prefix);
} }

View File

@ -3,6 +3,7 @@ package net.t2code.lib.Spigot.system;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import net.t2code.lib.Spigot.system.config.SelectLibConfig;
import net.t2code.lib.Util; import net.t2code.lib.Util;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -32,6 +33,9 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
case "ver": case "ver":
T2CodeTemplate.sendInfo(sender, Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), T2CodeMain.getAutor(), T2CodeMain.getVersion(), UpdateAPI.PluginVersionen.get(T2CodeMain.getPerm().getName()).publicVersion); T2CodeTemplate.sendInfo(sender, Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), T2CodeMain.getAutor(), T2CodeMain.getVersion(), UpdateAPI.PluginVersionen.get(T2CodeMain.getPerm().getName()).publicVersion);
return false; return false;
case "reloadconfig":
SelectLibConfig.onSelect();
return false;
case "debug": case "debug":
if (args.length != 2) { if (args.length != 2) {
send.sender(sender, "§4Use: §7/t2code debug createReportLog"); send.sender(sender, "§4Use: §7/t2code debug createReportLog");
@ -53,6 +57,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{ private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
put("debug", "t2code.admin"); put("debug", "t2code.admin");
put("info", "t2code.admin"); put("info", "t2code.admin");
put("reloadconfig", "t2code.admin");
}}; }};
@Override @Override

View File

@ -31,7 +31,7 @@ public class Metrics {
public static void Bstats(Plugin plugin, int bstatsID) { public static void Bstats(Plugin plugin, int bstatsID) {
int pluginId = bstatsID; // <-- Replace with the id of your plugin! int pluginId = bstatsID; // <-- Replace with the id of your plugin!
Metrics metrics = new Metrics((JavaPlugin) plugin, pluginId); Metrics metrics = new Metrics((JavaPlugin) plugin, pluginId);
metrics.addCustomChart(new SimplePie("updatecheckonjoin", () -> String.valueOf(SelectLibConfig.UpdateCheckOnJoin))); metrics.addCustomChart(new SimplePie("updatecheckonjoin", () -> String.valueOf(SelectLibConfig.getUpdateCheckOnJoin())));
} }
private final Plugin plugin; private final Plugin plugin;

View File

@ -1,7 +1,6 @@
package net.t2code.lib.Spigot.system; package net.t2code.lib.Spigot.system;
import com.bencodez.votingplugin.VotingPluginHooks; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import com.bencodez.votingplugin.user.UserManager;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
import net.t2code.lib.Spigot.Lib.items.ItemVersion; import net.t2code.lib.Spigot.Lib.items.ItemVersion;
@ -29,6 +28,9 @@ public final class T2CodeMain extends JavaPlugin {
return plugin.getDataFolder(); return plugin.getDataFolder();
} }
public static BukkitAudiences adventure;
private static T2CodeMain plugin; private static T2CodeMain plugin;
private static Economy eco = null; private static Economy eco = null;
private static Permission perm = null; private static Permission perm = null;
@ -101,17 +103,13 @@ public final class T2CodeMain extends JavaPlugin {
plugin = this; plugin = this;
autor = plugin.getDescription().getAuthors(); autor = plugin.getDescription().getAuthors();
version = plugin.getDescription().getVersion(); version = plugin.getDescription().getVersion();
this.adventure = BukkitAudiences.create(this);
long long_; long long_;
long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord); long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord);
if (Util.getSnapshot()) { if (Util.getSnapshot()) {
send.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! §4This is a trial version! §eSome features may not be working as expected." + send.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! §4This is a trial version! §eSome features may not be working as expected." +
" Please report all bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled!"); " Please report all bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled!");
send.console(prefix + " §4 §e-------------------"); send.console(prefix + " §4 §e-------------------");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
} }
try { try {
@ -124,7 +122,7 @@ public final class T2CodeMain extends JavaPlugin {
if (MCVersion.minecraft1_19) { if (MCVersion.minecraft1_19) {
send.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!"); send.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
send.console(prefix ); send.console(prefix );
send.warning(this, "The 1.19 is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net"); send.warning(this, "The 1.19.* is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net");
send.console(prefix); send.console(prefix);
send.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!"); send.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
try { try {
@ -168,16 +166,18 @@ public final class T2CodeMain extends JavaPlugin {
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin); Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
T2CodeTemplate.onLoadFooter(prefix, long_); T2CodeTemplate.onLoadFooter(prefix, long_);
} }
@Override @Override
public void onDisable() { public void onDisable() {
// Plugin shutdown logic // Plugin shutdown logic
if (SelectLibConfig.InventoriesCloseByServerStop) { if (SelectLibConfig.getInventoriesCloseByServerStop()) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
player.closeInventory(); player.closeInventory();
} }
} }
if(this.adventure != null) {
this.adventure.close();
this.adventure = null;
}
Vault.vaultDisable(); Vault.vaultDisable();
T2CodeTemplate.onDisable(prefix, autor, version, spigot, discord); T2CodeTemplate.onDisable(prefix, autor, version, spigot, discord);
} }

View File

@ -11,24 +11,6 @@ import java.io.IOException;
public class ConfigCreate { public class ConfigCreate {
private static Boolean UpdateCheckOnJoin = true;
private static Integer UpdateCheckTimeInterval = 60;
private static Boolean Debug = false;
private static String language = "english";
private static Boolean mySQL = false;
private static String Storage = "YML";
private static String ip = "localhost";
private static Integer port = 3306;
private static String database = "database";
private static String user = "root";
private static String password = "password";
private static Boolean SSL = false;
private static Boolean Bungee = false;
private static String thisServer = "server";
public static void configCreate() { public static void configCreate() {
Long long_ = Long.valueOf(System.currentTimeMillis()); Long long_ = Long.valueOf(System.currentTimeMillis());
if (new File(T2CodeMain.getPath(), "config.yml").exists()){ if (new File(T2CodeMain.getPath(), "config.yml").exists()){
@ -39,25 +21,14 @@ public class ConfigCreate {
File config = new File(T2CodeMain.getPath(), "config.yml"); File config = new File(T2CodeMain.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
Config.set("Plugin.UpdateCheck.OnJoin", UpdateCheckOnJoin, yamlConfiguration); Config.set("Plugin.UpdateCheck.OnJoin", true, yamlConfiguration);
Config.set("Plugin.UpdateCheck.TimeInterval", UpdateCheckTimeInterval, yamlConfiguration); Config.set("Plugin.UpdateCheck.TimeInterval", 60, yamlConfiguration);
Config.set("Plugin.language", language, yamlConfiguration); Config.set("Plugin.language", "english", yamlConfiguration);
Config.set("BungeeCord.Enable", Bungee, yamlConfiguration); Config.set("BungeeCord.Enable", false, yamlConfiguration);
Config.set("BungeeCord.ThisServer", thisServer, yamlConfiguration); Config.set("BungeeCord.ThisServer", "server", yamlConfiguration);
Config.set("Player.Inventories.CloseByServerStop", true, yamlConfiguration); Config.set("Player.Inventories.CloseByServerStop", true, yamlConfiguration);
// Config.set("Storage.MySQL.Enable", mySQL, yamlConfiguration);
// Config.set("Storage.Type", Storage, yamlConfiguration);
// Config.set("Storage.MySQL.IP", ip, yamlConfiguration);
// Config.set("Storage.MySQL.Port", port, yamlConfiguration);
// Config.set("Storage.MySQL.Database", database, yamlConfiguration);
// Config.set("Storage.MySQL.User", user, yamlConfiguration);
// Config.set("Storage.MySQL.Password", password, yamlConfiguration);
// Config.set("Storage.MySQL.SSL", SSL, yamlConfiguration);
try { try {
yamlConfiguration.save(config); yamlConfiguration.save(config);
} catch (IOException e) { } catch (IOException e) {

View File

@ -8,12 +8,12 @@ import java.io.File;
public class SelectLibConfig { public class SelectLibConfig {
public static Boolean UpdateCheckOnJoin; private static Boolean UpdateCheckOnJoin;
public static Boolean t2cTestDevelopment; private static Boolean t2cTestDevelopment;
public static Integer UpdateCheckTimeInterval; private static Integer UpdateCheckTimeInterval;
public static Boolean Debug; private static Boolean Debug;
public static String language; private static String language;
public static Boolean InventoriesCloseByServerStop; private static Boolean InventoriesCloseByServerStop;
public static void onSelect() { public static void onSelect() {
File config = new File(T2CodeMain.getPath(), "config.yml"); File config = new File(T2CodeMain.getPath(), "config.yml");
@ -26,4 +26,29 @@ public class SelectLibConfig {
language = yamlConfiguration.getString("Plugin.language"); language = yamlConfiguration.getString("Plugin.language");
InventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop"); InventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop");
} }
public static Boolean getUpdateCheckOnJoin() {
return UpdateCheckOnJoin;
}
public static Boolean getT2cTestDevelopment() {
return t2cTestDevelopment;
}
public static Integer getUpdateCheckTimeInterval() {
return UpdateCheckTimeInterval;
}
public static Boolean getDebug() {
return Debug;
}
public static String getLanguage() {
return language;
}
public static Boolean getInventoriesCloseByServerStop() {
return InventoriesCloseByServerStop;
}
} }

View File

@ -26,17 +26,17 @@ public class SelectLibMsg {
File msg; File msg;
msg = new File(T2CodeMain.getPath(), "languages/" + SelectLibConfig.language + "_messages.yml"); msg = new File(T2CodeMain.getPath(), "languages/" + SelectLibConfig.getLanguage() + "_messages.yml");
if (!msg.isFile()) { if (!msg.isFile()) {
send.console(Prefix); send.console(Prefix);
send.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); send.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
send.console(Prefix + " §4The selected §c" + SelectLibConfig.language + " §4language file was not found."); send.console(Prefix + " §4The selected §c" + SelectLibConfig.getLanguage() + " §4language file was not found.");
send.console(Prefix + " §6The default language §eEnglish §6is used!"); send.console(Prefix + " §6The default language §eEnglish §6is used!");
send.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); send.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
send.console(Prefix); send.console(Prefix);
msg = new File(T2CodeMain.getPath(), "languages/" + "english_messages.yml"); msg = new File(T2CodeMain.getPath(), "languages/" + "english_messages.yml");
selectMSG = "english"; selectMSG = "english";
} else selectMSG = SelectLibConfig.language; } else selectMSG = SelectLibConfig.getLanguage();
YamlConfiguration yamlConfiguration_msg = YamlConfiguration.loadConfiguration(msg); YamlConfiguration yamlConfiguration_msg = YamlConfiguration.loadConfiguration(msg);
vaultNotSetUp = Replace.replace(prefix, yamlConfiguration_msg.getString("Plugin.VaultNotSetUp")); vaultNotSetUp = Replace.replace(prefix, yamlConfiguration_msg.getString("Plugin.VaultNotSetUp"));