Compare commits
22 Commits
16.6
...
83f4a3ef71
Author | SHA1 | Date | |
---|---|---|---|
83f4a3ef71 | |||
8678eee675 | |||
a74710ed9a | |||
d0c683b73c | |||
a533d2211b | |||
44c35bd185 | |||
5a49cc625a | |||
e9a43889cb | |||
2f168197fe | |||
3c85c440c9 | |||
f3bc2e3d4f | |||
d8f0752ea7 | |||
90f899cb16 | |||
7c3ffc80c3 | |||
d5a82e6005 | |||
eb237aaa89 | |||
1397656bf2 | |||
bbe8fbce49 | |||
9413f0f7c8 | |||
a05223333c | |||
2ac9c890f6 | |||
b8c65cb537 |
2
.idea/discord.xml
generated
2
.idea/discord.xml
generated
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="DiscordProjectSettings">
|
<component name="DiscordProjectSettings">
|
||||||
<option name="show" value="ASK" />
|
<option name="show" value="PROJECT_FILES" />
|
||||||
<option name="description" value="" />
|
<option name="description" value="" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
35
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
35
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ADDITIONAL_TAGS" value="Deprecated" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="VulnerableLibrariesLocal" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="isIgnoringEnabled" value="true" />
|
||||||
|
<option name="ignoredModules">
|
||||||
|
<list>
|
||||||
|
<option value="T2CodeLib" />
|
||||||
|
<option value="T2CodeLib" />
|
||||||
|
<option value="T2CodeLib" />
|
||||||
|
<option value="T2CodeLib" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
<option name="ignoredPackages">
|
||||||
|
<list>
|
||||||
|
<option value="junit:junit:4.10" />
|
||||||
|
<option value="commons-codec:commons-codec:1.9" />
|
||||||
|
<option value="commons-io:commons-io:2.4" />
|
||||||
|
<option value="org.apache.logging.log4j:log4j-core:2.0-beta9" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
<option name="ignoredReasons">
|
||||||
|
<list>
|
||||||
|
<option value="Not exploitable" />
|
||||||
|
<option value="Not exploitable" />
|
||||||
|
<option value="Not exploitable" />
|
||||||
|
<option value="Not exploitable" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@@ -26,6 +26,11 @@
|
|||||||
<option name="name" value="sonatype-oss-snapshots1" />
|
<option name="name" value="sonatype-oss-snapshots1" />
|
||||||
<option name="url" value="https://s01.oss.sonatype.org/content/repositories/snapshots/" />
|
<option name="url" value="https://s01.oss.sonatype.org/content/repositories/snapshots/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="papermc-repo" />
|
||||||
|
<option name="name" value="papermc-repo" />
|
||||||
|
<option name="url" value="https://repo.papermc.io/repository/maven-public/" />
|
||||||
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="placeholderapi" />
|
<option name="id" value="placeholderapi" />
|
||||||
<option name="name" value="placeholderapi" />
|
<option name="name" value="placeholderapi" />
|
||||||
|
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -5,6 +5,9 @@
|
|||||||
<item index="0" class="java.lang.String" itemvalue="net.md_5.bungee.event.EventHandler" />
|
<item index="0" class="java.lang.String" itemvalue="net.md_5.bungee.event.EventHandler" />
|
||||||
<item index="1" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
<item index="1" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||||
</list>
|
</list>
|
||||||
|
<writeAnnotations>
|
||||||
|
<writeAnnotation name="lombok.Getter" />
|
||||||
|
</writeAnnotations>
|
||||||
</component>
|
</component>
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="MavenProjectsManager">
|
<component name="MavenProjectsManager">
|
||||||
|
65
pom.xml
65
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>T2CodeLib</artifactId>
|
<artifactId>T2CodeLib</artifactId>
|
||||||
<version>16.6</version>
|
<version>16.7_dev-19</version>
|
||||||
<!--version>VERSION_snapshot-0</version-->
|
<!--version>VERSION_snapshot-0</version-->
|
||||||
<!--version>VERSION_beta-0</version-->
|
<!--version>VERSION_beta-0</version-->
|
||||||
<!--version>VERSION_dev-0</version-->
|
<!--version>VERSION_dev-0</version-->
|
||||||
@@ -27,8 +27,9 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>9</source>
|
<source>11</source>
|
||||||
<target>9</target>
|
<target>11</target>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -45,8 +46,32 @@
|
|||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>net.kyori.adventure</pattern>
|
<pattern>net.kyori</pattern>
|
||||||
<shadedPattern>net.t2code.t2codelib.shaded.adventure</shadedPattern>
|
<shadedPattern>net.t2code.libraries.kyori.adventure</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>com.google.gson</pattern>
|
||||||
|
<shadedPattern>net.t2code.libraries.google</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>mozilla</pattern>
|
||||||
|
<shadedPattern>net.t2code.libraries.mozilla</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.apache</pattern>
|
||||||
|
<shadedPattern>net.t2code.libraries.apache</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.intellij</pattern>
|
||||||
|
<shadedPattern>net.t2code.libraries.intellij</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.jetbrains</pattern>
|
||||||
|
<shadedPattern>net.t2code.libraries.jetbrains</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.json</pattern>
|
||||||
|
<shadedPattern>net.t2code.libraries.json</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -81,6 +106,12 @@
|
|||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<!-- Velocity / Paper-->
|
||||||
|
<repository>
|
||||||
|
<id>papermc-repo</id>
|
||||||
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
<!-- repo.t2code / T2Code -->
|
<!-- repo.t2code / T2Code -->
|
||||||
<repository>
|
<repository>
|
||||||
<id>T2Code</id>
|
<id>T2Code</id>
|
||||||
@@ -146,6 +177,14 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Velocity -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.velocitypowered</groupId>
|
||||||
|
<artifactId>velocity-api</artifactId>
|
||||||
|
<version>3.3.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- repo.t2code / T2Code -->
|
<!-- repo.t2code / T2Code -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
@@ -206,14 +245,6 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.json/json -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.json</groupId>
|
|
||||||
<artifactId>json</artifactId>
|
|
||||||
<version>20220924</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime -->
|
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
@@ -224,9 +255,15 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.json</groupId>
|
<groupId>org.json</groupId>
|
||||||
<artifactId>json</artifactId>
|
<artifactId>json</artifactId>
|
||||||
<version>20230227</version>
|
<version>20231013</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.yaml</groupId>
|
||||||
|
<artifactId>snakeyaml</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@@ -8,26 +8,27 @@ import net.md_5.bungee.api.event.PluginMessageEvent;
|
|||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend;
|
import net.t2code.t2codelib.BUNGEE.api.messages.T2CB_Send;
|
||||||
import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain;
|
import net.t2code.t2codelib.BUNGEE.system.T2CB_Main;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayersEnum;
|
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2C_BngeePlayersEnum;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class T2CBbungeePlayers implements Listener {
|
public class T2CB_BungeePlayers implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PostLoginEvent e) {
|
public void onJoin(PostLoginEvent e) {
|
||||||
sendToSpigotPlayer(e.getPlayer().getName(), T2CbungeePlayersEnum.JOIN, "");
|
sendToSpigotPlayer(e.getPlayer().getName(), T2C_BngeePlayersEnum.JOIN, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDisconnect(PlayerDisconnectEvent e) {
|
public void onDisconnect(PlayerDisconnectEvent e) {
|
||||||
sendToSpigotPlayer(e.getPlayer().getName(), T2CbungeePlayersEnum.QUIT, "");
|
sendToSpigotPlayer(e.getPlayer().getName(), T2C_BngeePlayersEnum.QUIT, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendToSpigotPlayer(String name, T2CbungeePlayersEnum value, String uuid) {
|
public static void sendToSpigotPlayer(String name, T2C_BngeePlayersEnum value, String uuid) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case JOIN:
|
case JOIN:
|
||||||
case QUIT:
|
case QUIT:
|
||||||
@@ -38,12 +39,12 @@ public class T2CBbungeePlayers implements Listener {
|
|||||||
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
|
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
|
||||||
input.append(player.getName()).append(";");
|
input.append(player.getName()).append(";");
|
||||||
}
|
}
|
||||||
sendToSpigotPlayerExecute(input.toString(), T2CbungeePlayersEnum.GIVEALL, uuid);
|
sendToSpigotPlayerExecute(input.toString(), T2C_BngeePlayersEnum.GIVEALL, uuid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendToSpigotPlayerExecute(String name, T2CbungeePlayersEnum value, String uuid) {
|
private static void sendToSpigotPlayerExecute(String name, T2C_BngeePlayersEnum value, String uuid) {
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
DataOutputStream output = new DataOutputStream(stream);
|
DataOutputStream output = new DataOutputStream(stream);
|
||||||
try {
|
try {
|
||||||
@@ -53,12 +54,12 @@ public class T2CBbungeePlayers implements Listener {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logger.getLogger(e.getMessage());
|
Logger.getLogger(e.getMessage());
|
||||||
}
|
}
|
||||||
T2CBsend.debug(T2CodeBMain.getPlugin(), "PluginMessage received channel: t2c:bonlp");
|
T2CB_Send.debug(T2CB_Main.getPlugin(), "PluginMessage received channel: "+ T2C_Util.getPluginChannel_ProxyOnlinePlayers());
|
||||||
T2CBsend.debug(T2CodeBMain.getPlugin(), "PluginMessage received subChannel: " + value.name());
|
T2CB_Send.debug(T2CB_Main.getPlugin(), "PluginMessage received subChannel: " + value.name());
|
||||||
T2CBsend.debug(T2CodeBMain.getPlugin(), "PluginMessage received input: " + name);
|
T2CB_Send.debug(T2CB_Main.getPlugin(), "PluginMessage received input: " + name);
|
||||||
T2CBsend.debug(T2CodeBMain.getPlugin(), "PluginMessage received input2/uuid: " + uuid);
|
T2CB_Send.debug(T2CB_Main.getPlugin(), "PluginMessage received input2/uuid: " + uuid);
|
||||||
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
|
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
|
||||||
server.sendData("t2c:bonlp", stream.toByteArray());
|
server.sendData(T2C_Util.getPluginChannel_ProxyOnlinePlayers(), stream.toByteArray());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,29 +67,29 @@ public class T2CBbungeePlayers implements Listener {
|
|||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
DataOutputStream output = new DataOutputStream(stream);
|
DataOutputStream output = new DataOutputStream(stream);
|
||||||
try {
|
try {
|
||||||
output.writeUTF(T2CbungeePlayersEnum.CLEAR.name());
|
output.writeUTF(T2C_BngeePlayersEnum.CLEAR.name());
|
||||||
output.writeUTF("");
|
output.writeUTF("");
|
||||||
output.writeUTF("");
|
output.writeUTF("");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logger.getLogger(e.getMessage());
|
Logger.getLogger(e.getMessage());
|
||||||
}
|
}
|
||||||
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
|
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
|
||||||
server.sendData("t2c:bonlp", stream.toByteArray());
|
server.sendData(T2C_Util.getPluginChannel_ProxyOnlinePlayers(), stream.toByteArray());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPluginMessage(PluginMessageEvent event) {
|
public void onPluginMessage(PluginMessageEvent event) {
|
||||||
if (event.getTag().equalsIgnoreCase("t2c:bonlp")) {
|
if (event.getTag().equalsIgnoreCase(T2C_Util.getPluginChannel_ProxyOnlinePlayers())) {
|
||||||
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
try {
|
try {
|
||||||
T2CbungeePlayersEnum subChannel = T2CbungeePlayersEnum.valueOf(stream.readUTF());
|
T2C_BngeePlayersEnum subChannel = T2C_BngeePlayersEnum.valueOf(stream.readUTF());
|
||||||
String input = stream.readUTF();
|
String input = stream.readUTF();
|
||||||
|
|
||||||
T2CBsend.debug(T2CodeBMain.getPlugin(), "PluginMessage received channel: " + event.getTag());
|
T2CB_Send.debug(T2CB_Main.getPlugin(), "PluginMessage received channel: " + event.getTag());
|
||||||
T2CBsend.debug(T2CodeBMain.getPlugin(), "PluginMessage received subChannel: " + subChannel.name());
|
T2CB_Send.debug(T2CB_Main.getPlugin(), "PluginMessage received subChannel: " + subChannel.name());
|
||||||
T2CBsend.debug(T2CodeBMain.getPlugin(), "PluginMessage received input/uuid: " + input);
|
T2CB_Send.debug(T2CB_Main.getPlugin(), "PluginMessage received input/uuid: " + input);
|
||||||
|
|
||||||
sendToSpigotPlayer("", subChannel, input);
|
sendToSpigotPlayer("", subChannel, input);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
@@ -3,7 +3,7 @@ package net.t2code.t2codelib.BUNGEE.api.commands;
|
|||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
public class T2CBcmd {
|
public class T2CB_Cmd {
|
||||||
public static void Console(String cmd){
|
public static void Console(String cmd){
|
||||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), cmd);
|
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), cmd);
|
||||||
}
|
}
|
@@ -6,10 +6,9 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class T2CBtab {
|
public class T2CB_Tab {
|
||||||
|
|
||||||
|
|
||||||
public static void tab(List<String> matches, CommandSender sender, int arg, String[] args, String perm, Boolean onlinePlayer) {
|
public static void tab(List<String> matches, CommandSender sender, int arg, String[] args, String perm, Boolean onlinePlayer) {
|
@@ -6,11 +6,11 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain;
|
import net.t2code.t2codelib.BUNGEE.system.T2CB_Main;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Replace;
|
||||||
|
|
||||||
public class T2CBminiMessage {
|
public class T2CB_MiniMessage {
|
||||||
private static final BungeeAudiences bungeeAudiences = T2CodeBMain.getAdventure();
|
private static final BungeeAudiences bungeeAudiences = T2CB_Main.getAdventure();
|
||||||
|
|
||||||
public static void sendSenderMiniMessage(String msg, CommandSender sender) {
|
public static void sendSenderMiniMessage(String msg, CommandSender sender) {
|
||||||
bungeeAudiences.sender(sender).sendMessage(replace(msg));
|
bungeeAudiences.sender(sender).sendMessage(replace(msg));
|
||||||
@@ -25,6 +25,10 @@ public class T2CBminiMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static Component replace(String text) {
|
protected static Component replace(String text) {
|
||||||
return MiniMessage.miniMessage().deserialize(T2Creplace.convertColorCode(text));
|
return MiniMessage.miniMessage().deserialize(T2C_Replace.convertColorCode(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String removeMiniMessageCodes(String text){
|
||||||
|
return MiniMessage.miniMessage().stripTags(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -3,7 +3,7 @@ package net.t2code.t2codelib.BUNGEE.api.messages;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class T2CBreplace {
|
public class T2CB_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 Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü")
|
@@ -5,20 +5,20 @@ import net.md_5.bungee.api.ProxyServer;
|
|||||||
import net.md_5.bungee.api.Title;
|
import net.md_5.bungee.api.Title;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain;
|
import net.t2code.t2codelib.BUNGEE.system.T2CB_Main;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class T2CBsend {
|
public class T2CB_Send {
|
||||||
public static void console(String msg) {
|
public static void console(String msg) {
|
||||||
if (T2CodeBMain.getMmIsLoad() && T2CodeBMain.getMmIsLoad()) {
|
if (T2CB_Main.getMmIsLoad() && T2CB_Main.getMmIsLoad()) {
|
||||||
T2CBminiMessage.sendConsoleMiniMessage(msg);
|
T2CB_MiniMessage.sendConsoleMiniMessage(msg);
|
||||||
} else ProxyServer.getInstance().getConsole().sendMessage(msg);
|
} else ProxyServer.getInstance().getConsole().sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void player(ProxiedPlayer player, String msg) {
|
public static void player(ProxiedPlayer player, String msg) {
|
||||||
if (T2CodeBMain.getMmIsLoad()&& T2CodeBMain.getMmIsLoad()) {
|
if (T2CB_Main.getMmIsLoad()&& T2CB_Main.getMmIsLoad()) {
|
||||||
T2CBminiMessage.sendPlayerMiniMessage(msg, player);
|
T2CB_MiniMessage.sendPlayerMiniMessage(msg, player);
|
||||||
} else player.sendMessage(msg);
|
} else player.sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,8 +27,8 @@ public class T2CBsend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void sender(CommandSender sender, String msg) {
|
public static void sender(CommandSender sender, String msg) {
|
||||||
if (T2CodeBMain.getMmIsLoad()&& T2CodeBMain.getMmIsLoad()) {
|
if (T2CB_Main.getMmIsLoad()&& T2CB_Main.getMmIsLoad()) {
|
||||||
T2CBminiMessage.sendSenderMiniMessage(msg, sender);
|
T2CB_MiniMessage.sendSenderMiniMessage(msg, sender);
|
||||||
} else sender.sendMessage(msg);
|
} else sender.sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
@@ -0,0 +1,56 @@
|
|||||||
|
package net.t2code.t2codelib.BUNGEE.api.messages;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
import net.t2code.t2codelib.BUNGEE.api.update.T2CB_UpdateAPI;
|
||||||
|
import net.t2code.t2codelib.util.T2C_UpdateWebData;
|
||||||
|
|
||||||
|
public class T2CB_Template {
|
||||||
|
|
||||||
|
|
||||||
|
public static Long onLoadHeader(String prefix, String autor, String version, String spigot, String discord) {
|
||||||
|
Long long_ = Long.valueOf(System.currentTimeMillis());
|
||||||
|
T2CB_Send.console(prefix + "§4============================= " + prefix + " §4=============================");
|
||||||
|
T2CB_Send.console(prefix + " §2Autor: §6" + autor.replace("[", "").replace("]", ""));
|
||||||
|
T2CB_Send.console(prefix + " §2Version: §6" + version);
|
||||||
|
T2CB_Send.console(prefix + " §2Spigot: §6" + spigot);
|
||||||
|
T2CB_Send.console(prefix + " §2Discord: §6" + discord);
|
||||||
|
T2CB_Send.console(prefix + " §8-------------------------------");
|
||||||
|
return long_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onLoadSeparateStroke(String prefix) {
|
||||||
|
T2CB_Send.console(prefix + " §8-------------------------------");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onLoadFooter(String prefix, Long long_) {
|
||||||
|
T2CB_Send.console(prefix + " §8-------------------------------");
|
||||||
|
T2CB_Send.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
||||||
|
T2CB_Send.console(prefix + "§4============================= " + prefix + " §4=============================");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onDisable(String prefix, String autor, String version, String spigot, String discord) {
|
||||||
|
T2CB_Send.console(prefix + "§4============================= " + prefix + " §4=============================");
|
||||||
|
T2CB_Send.console(prefix + " §2Autor: §6" + autor.replace("[", "").replace("]", ""));
|
||||||
|
T2CB_Send.console(prefix + " §2Version: §6" + version);
|
||||||
|
T2CB_Send.console(prefix + " §2Spigot: §6" + spigot);
|
||||||
|
T2CB_Send.console(prefix + " §2Discord: §6" + discord);
|
||||||
|
T2CB_Send.console(prefix + " §4Plugin successfully disabled.");
|
||||||
|
T2CB_Send.console(prefix + "§4============================= " + prefix + " §4=============================");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendInfo(CommandSender sender, Plugin plugin, String prefix, String spigot, String discord, String autor) {
|
||||||
|
T2C_UpdateWebData webData = T2CB_UpdateAPI.bungeePluginVersins.get(plugin.getDescription().getName()).webData;
|
||||||
|
String pluginVersion = plugin.getDescription().getVersion();
|
||||||
|
T2CB_Send.sender(sender, prefix + "§4======= " + prefix + " §4=======");
|
||||||
|
T2CB_Send.sender(sender, prefix + " §2Autor: §6" + autor);
|
||||||
|
if (webData.getVersion().equalsIgnoreCase(pluginVersion)) {
|
||||||
|
T2CB_Send.sender(sender, prefix + " §2Version: §6" + pluginVersion);
|
||||||
|
} else {
|
||||||
|
T2CB_UpdateAPI.sendUpdateMsg(prefix, discord, webData, plugin, sender);
|
||||||
|
}
|
||||||
|
T2CB_Send.sender(sender, prefix + " §2Spigot: §6" + spigot);
|
||||||
|
T2CB_Send.sender(sender, prefix + " §2Discord: §6" + discord);
|
||||||
|
T2CB_Send.sender(sender, prefix + "§4======= " + prefix + " §4=======");
|
||||||
|
}
|
||||||
|
}
|
@@ -1,56 +0,0 @@
|
|||||||
package net.t2code.t2codelib.BUNGEE.api.messages;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.api.update.T2CBupdateAPI;
|
|
||||||
import net.t2code.t2codelib.T2CupdateWebData;
|
|
||||||
|
|
||||||
public class T2CBtemplate {
|
|
||||||
|
|
||||||
|
|
||||||
public static Long onLoadHeader(String prefix, String autor, String version, String spigot, String discord) {
|
|
||||||
Long long_ = Long.valueOf(System.currentTimeMillis());
|
|
||||||
T2CBsend.console(prefix + "§4============================= " + prefix + " §4=============================");
|
|
||||||
T2CBsend.console(prefix + " §2Autor: §6" + autor.replace("[", "").replace("]", ""));
|
|
||||||
T2CBsend.console(prefix + " §2Version: §6" + version);
|
|
||||||
T2CBsend.console(prefix + " §2Spigot: §6" + spigot);
|
|
||||||
T2CBsend.console(prefix + " §2Discord: §6" + discord);
|
|
||||||
T2CBsend.console(prefix + " §8-------------------------------");
|
|
||||||
return long_;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onLoadSeparateStroke(String prefix) {
|
|
||||||
T2CBsend.console(prefix + " §8-------------------------------");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onLoadFooter(String prefix, Long long_) {
|
|
||||||
T2CBsend.console(prefix + " §8-------------------------------");
|
|
||||||
T2CBsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
|
||||||
T2CBsend.console(prefix + "§4============================= " + prefix + " §4=============================");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onDisable(String prefix, String autor, String version, String spigot, String discord) {
|
|
||||||
T2CBsend.console(prefix + "§4============================= " + prefix + " §4=============================");
|
|
||||||
T2CBsend.console(prefix + " §2Autor: §6" + autor.replace("[", "").replace("]", ""));
|
|
||||||
T2CBsend.console(prefix + " §2Version: §6" + version);
|
|
||||||
T2CBsend.console(prefix + " §2Spigot: §6" + spigot);
|
|
||||||
T2CBsend.console(prefix + " §2Discord: §6" + discord);
|
|
||||||
T2CBsend.console(prefix + " §4Plugin successfully disabled.");
|
|
||||||
T2CBsend.console(prefix + "§4============================= " + prefix + " §4=============================");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendInfo(CommandSender sender, Plugin plugin, String prefix, String spigot, String discord, String autor) {
|
|
||||||
T2CupdateWebData webData = T2CBupdateAPI.bungeePluginVersins.get(plugin.getDescription().getName()).webData;
|
|
||||||
String pluginVersion = plugin.getDescription().getVersion();
|
|
||||||
T2CBsend.sender(sender, prefix + "§4======= " + prefix + " §4=======");
|
|
||||||
T2CBsend.sender(sender, prefix + " §2Autor: §6" + autor);
|
|
||||||
if (webData.getVersion().equalsIgnoreCase(pluginVersion)) {
|
|
||||||
T2CBsend.sender(sender, prefix + " §2Version: §6" + pluginVersion);
|
|
||||||
} else {
|
|
||||||
T2CBupdateAPI.sendUpdateMsg(prefix, discord, webData, plugin, sender);
|
|
||||||
}
|
|
||||||
T2CBsend.sender(sender, prefix + " §2Spigot: §6" + spigot);
|
|
||||||
T2CBsend.sender(sender, prefix + " §2Discord: §6" + discord);
|
|
||||||
T2CBsend.sender(sender, prefix + "§4======= " + prefix + " §4=======");
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,21 +1,20 @@
|
|||||||
package net.t2code.t2codelib.BUNGEE.system.pluginMessaging;
|
package net.t2code.t2codelib.BUNGEE.api.pluginMessaging;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
import net.t2code.t2codelib.Util;
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
import org.junit.Ignore;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class T2CplmsgBcmd implements Listener {
|
public class T2CB_PluginMessageProxyCommand implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPluginmessage(PluginMessageEvent event) {
|
public void onPluginmessage(PluginMessageEvent event) {
|
||||||
if (event.getTag().equalsIgnoreCase("t2c:bcmd")) {
|
if (event.getTag().equalsIgnoreCase(T2C_Util.getPluginChannel_ProxyCommand())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
||||||
try {
|
try {
|
||||||
@@ -29,12 +28,12 @@ public class T2CplmsgBcmd implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (channel.equals("T2Code-Console")) {
|
if (channel.equals("T2Code-Console")) {
|
||||||
ProxyServer.getInstance().getConsole().sendMessage(Util.getPrefix()+" [§6"+serverID+"§r] §cT2C BCMD Command Console: §r"+ input);
|
ProxyServer.getInstance().getConsole().sendMessage(T2C_Util.getPrefix()+" [§6"+serverID+"§r] §cT2C BCMD Command Console: §r"+ input);
|
||||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), input);
|
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), input);
|
||||||
} else {
|
} else {
|
||||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(channel);
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(channel);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
ProxyServer.getInstance().getConsole().sendMessage(Util.getPrefix()+" [§6"+serverID+"§r] §cT2C BCMD Command §r" + player +": "+ input);
|
ProxyServer.getInstance().getConsole().sendMessage(T2C_Util.getPrefix()+" [§6"+serverID+"§r] §cT2C BCMD Command §r" + player +": "+ input);
|
||||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(player, input);
|
ProxyServer.getInstance().getPluginManager().dispatchCommand(player, input);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,21 +1,22 @@
|
|||||||
package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.autoResponse;
|
package net.t2code.t2codelib.BUNGEE.api.pluginMessaging.autoResponse;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend;
|
import net.t2code.t2codelib.BUNGEE.api.messages.T2CB_Send;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class T2CapiAutoResponse implements Listener {
|
public class T2CB_API_AutoResponse implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPluginmessage(PluginMessageEvent event) {
|
public void onPluginmessage(PluginMessageEvent event) {
|
||||||
if (event.getTag().equalsIgnoreCase("t2c:aresp")) {
|
if (event.getTag().equalsIgnoreCase(T2C_Util.getPluginChannel_AutoResponse())) {
|
||||||
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
try {
|
try {
|
||||||
@@ -29,7 +30,7 @@ public class T2CapiAutoResponse implements Listener {
|
|||||||
break;
|
break;
|
||||||
case "ALLPMSG":
|
case "ALLPMSG":
|
||||||
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
|
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
|
||||||
T2CBsend.player(player, input);
|
T2CB_Send.player(player, input);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
@@ -1,4 +1,4 @@
|
|||||||
package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.commandgui;
|
package net.t2code.t2codelib.BUNGEE.api.pluginMessaging.commandgui;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@@ -6,11 +6,12 @@ import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
|||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class T2CapiCGUI implements Listener {
|
public class T2CB_API_CGUI implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PostLoginEvent e) {
|
public void onJoin(PostLoginEvent e) {
|
||||||
@@ -38,7 +39,7 @@ public class T2CapiCGUI implements Listener {
|
|||||||
Logger.getLogger(e.getMessage());
|
Logger.getLogger(e.getMessage());
|
||||||
}
|
}
|
||||||
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
|
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
|
||||||
server.sendData("t2c:cguiopl", stream.toByteArray());
|
server.sendData(T2C_Util.getPluginChannel_CGUIOnlinePlayers(), stream.toByteArray());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ public class T2CapiCGUI implements Listener {
|
|||||||
Logger.getLogger(e.getMessage());
|
Logger.getLogger(e.getMessage());
|
||||||
}
|
}
|
||||||
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
|
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
|
||||||
server.sendData("t2c:cguiopl", stream.toByteArray());
|
server.sendData(T2C_Util.getPluginChannel_CGUIOnlinePlayers(), stream.toByteArray());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,18 +1,19 @@
|
|||||||
package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.opSecurity;
|
package net.t2code.t2codelib.BUNGEE.api.pluginMessaging.opSecurity;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class T2CapiOpSecurity implements Listener {
|
public class T2CB_API_OpSecurity implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPluginmessage(PluginMessageEvent event) {
|
public void onPluginmessage(PluginMessageEvent event) {
|
||||||
if (event.getTag().equalsIgnoreCase("t2c:opsec")) {
|
if (event.getTag().equalsIgnoreCase(T2C_Util.getPluginChannel_OPSecurity())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
||||||
try {
|
try {
|
||||||
@@ -39,7 +40,7 @@ public class T2CapiOpSecurity implements Listener {
|
|||||||
Logger.getLogger(e.getMessage());
|
Logger.getLogger(e.getMessage());
|
||||||
}
|
}
|
||||||
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
|
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
|
||||||
server.sendData("t2c:opsec", stream.toByteArray());
|
server.sendData(T2C_Util.getPluginChannel_OPSecurity(), stream.toByteArray());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,11 +2,11 @@ package net.t2code.t2codelib.BUNGEE.api.plugins;
|
|||||||
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain;
|
import net.t2code.t2codelib.BUNGEE.system.T2CB_Main;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class T2CBpluginCheck {
|
public class T2CB_PluginCheck {
|
||||||
public static Boolean pluginCheck(String pluginName){
|
public static Boolean pluginCheck(String pluginName){
|
||||||
return (ProxyServer.getInstance().getPluginManager().getPlugin(pluginName) != null);
|
return (ProxyServer.getInstance().getPluginManager().getPlugin(pluginName) != null);
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ public class T2CBpluginCheck {
|
|||||||
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
||||||
ProxyServer.getInstance().getConsole().sendMessage(prefix + " §e" + pl + " §4could not be found. Please download it here: " +
|
ProxyServer.getInstance().getConsole().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.");
|
"§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin.");
|
||||||
T2CodeBMain.getPlugin().getProxy().getPluginManager().getPlugin(plugin.getDescription().getName()).onDisable();
|
T2CB_Main.getPlugin().getProxy().getPluginManager().getPlugin(plugin.getDescription().getName()).onDisable();
|
||||||
return true;
|
return true;
|
||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
@@ -3,34 +3,34 @@ package net.t2code.t2codelib.BUNGEE.api.update;
|
|||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend;
|
import net.t2code.t2codelib.BUNGEE.api.messages.T2CB_Send;
|
||||||
import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig;
|
import net.t2code.t2codelib.BUNGEE.system.config.T2CB_LibConfig;
|
||||||
import net.t2code.t2codelib.T2CupdateObject;
|
import net.t2code.t2codelib.util.T2C_UpdateObject;
|
||||||
import net.t2code.t2codelib.T2CupdateWebData;
|
import net.t2code.t2codelib.util.T2C_UpdateWebData;
|
||||||
import net.t2code.t2codelib.UpdateType;
|
import net.t2code.t2codelib.util.T2C_UpdateType;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class T2CBupdateAPI {
|
public class T2CB_UpdateAPI {
|
||||||
public static HashMap<String, T2CupdateObject> bungeePluginVersins = new HashMap<>();
|
public static HashMap<String, T2C_UpdateObject> bungeePluginVersins = new HashMap<>();
|
||||||
|
|
||||||
public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Plugin plugin, CommandSender sender) {
|
public static void sendUpdateMsg(String prefix, String discord, T2C_UpdateWebData webData, Plugin plugin, CommandSender sender) {
|
||||||
String publicVersion = webData.getVersion();
|
String publicVersion = webData.getVersion();
|
||||||
String pluginVersion = plugin.getDescription().getVersion();
|
String pluginVersion = plugin.getDescription().getVersion();
|
||||||
String value;
|
String value;
|
||||||
if (webData.isPreRelease()) {
|
if (webData.isPreRelease()) {
|
||||||
value = UpdateType.PRERELEASE.text;
|
value = T2C_UpdateType.PRERELEASE.text;
|
||||||
if (publicVersion.toLowerCase().contains("dev")) {
|
if (publicVersion.toLowerCase().contains("dev")) {
|
||||||
value = UpdateType.DEVELOPMENT.text;
|
value = T2C_UpdateType.DEVELOPMENT.text;
|
||||||
}
|
}
|
||||||
if (publicVersion.toLowerCase().contains("beta")) {
|
if (publicVersion.toLowerCase().contains("beta")) {
|
||||||
value = UpdateType.BETA.text;
|
value = T2C_UpdateType.BETA.text;
|
||||||
}
|
}
|
||||||
if (publicVersion.toLowerCase().contains("snapshot")) {
|
if (publicVersion.toLowerCase().contains("snapshot")) {
|
||||||
value = UpdateType.SNAPSHOT.text;
|
value = T2C_UpdateType.SNAPSHOT.text;
|
||||||
}
|
}
|
||||||
} else value = UpdateType.STABLE.text;
|
} else value = T2C_UpdateType.STABLE.text;
|
||||||
String h = "<br><dark_red>╔══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
|
String h = "<br><dark_red>╔══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
|
||||||
String s1 = "<br><dark_red>║</dark_red> <gold>A new [value] version was found!</gold>".replace("[value]", value);
|
String s1 = "<br><dark_red>║</dark_red> <gold>A new [value] version was found!</gold>".replace("[value]", value);
|
||||||
String s2 = "<br><dark_red>║</dark_red> <gold>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</gold> <green>" + webData.getVersion() + "</green>";
|
String s2 = "<br><dark_red>║</dark_red> <gold>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</gold> <green>" + webData.getVersion() + "</green>";
|
||||||
@@ -39,8 +39,8 @@ public class T2CBupdateAPI {
|
|||||||
String f = "<br><dark_red>╚══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
|
String f = "<br><dark_red>╚══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
|
||||||
String text = h + s1 + s2 + s3 + s4 + f;
|
String text = h + s1 + s2 + s3 + s4 + f;
|
||||||
if (sender == null) {
|
if (sender == null) {
|
||||||
T2CBsend.console(text);
|
T2CB_Send.console(text);
|
||||||
} else T2CBsend.sender(sender, text);
|
} else T2CB_Send.sender(sender, text);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,16 +48,14 @@ public class T2CBupdateAPI {
|
|||||||
private static String pluginVersion;
|
private static String pluginVersion;
|
||||||
|
|
||||||
public static void onUpdateCheckTimer(Plugin plugin, String prefix, String discord, Integer spigotID, String url) {
|
public static void onUpdateCheckTimer(Plugin plugin, String prefix, String discord, Integer spigotID, String url) {
|
||||||
Integer finalInterval;
|
if ((int) T2CB_LibConfig.VALUES.updateTimer.getValue() < 1) {
|
||||||
if (T2CBlibConfig.getUpdateTimer() < 1){
|
T2CB_LibConfig.VALUES.updateTimer.setValue(1);
|
||||||
finalInterval = 1;
|
}
|
||||||
} else finalInterval = T2CBlibConfig.getUpdateTimer();
|
|
||||||
ProxyServer.getInstance().getScheduler().schedule(plugin, new Runnable() {
|
ProxyServer.getInstance().getScheduler().schedule(plugin, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (T2CBlibConfig.getUpdateCheckFullDisable()) return;
|
(new T2CB_UpdateCheckerGit(plugin)).getVersion((webData) -> {
|
||||||
(new T2CBupdateCheckerGit(plugin, spigotID)).getVersion((webData) -> {
|
|
||||||
pluginVersion = plugin.getDescription().getVersion();
|
pluginVersion = plugin.getDescription().getVersion();
|
||||||
T2CupdateObject update = new T2CupdateObject(
|
T2C_UpdateObject update = new T2C_UpdateObject(
|
||||||
plugin.getDescription().getName(),
|
plugin.getDescription().getName(),
|
||||||
plugin.getDescription().getVersion(),
|
plugin.getDescription().getVersion(),
|
||||||
webData,
|
webData,
|
||||||
@@ -71,12 +69,12 @@ public class T2CBupdateAPI {
|
|||||||
noUpdate = true;
|
noUpdate = true;
|
||||||
} else {
|
} else {
|
||||||
if (noUpdate) {
|
if (noUpdate) {
|
||||||
T2CBsend.console(prefix + " §2No update found.");
|
T2CB_Send.console(prefix + " §2No update found.");
|
||||||
noUpdate = false;
|
noUpdate = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, pluginVersion, spigotID, url);
|
}, pluginVersion, spigotID, url);
|
||||||
}
|
}
|
||||||
}, 0, finalInterval * 60 * 20L, TimeUnit.SECONDS);
|
}, 0, (int) T2CB_LibConfig.VALUES.updateTimer.getValue() * 60 * 20L, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,9 +2,9 @@ package net.t2code.t2codelib.BUNGEE.api.update;
|
|||||||
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig;
|
import net.t2code.t2codelib.BUNGEE.system.config.T2CB_LibConfig;
|
||||||
import net.t2code.t2codelib.T2CupdateObject;
|
import net.t2code.t2codelib.util.T2C_UpdateObject;
|
||||||
import net.t2code.t2codelib.T2CupdateWebData;
|
import net.t2code.t2codelib.util.T2C_UpdateWebData;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@@ -16,19 +16,18 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class T2CBupdateCheckerGit {
|
public class T2CB_UpdateCheckerGit {
|
||||||
private Plugin plugin;
|
private Plugin plugin;
|
||||||
private int resourceId;
|
|
||||||
|
|
||||||
public T2CBupdateCheckerGit(Plugin plugin, int resourceId) {
|
|
||||||
|
public T2CB_UpdateCheckerGit(Plugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.resourceId = resourceId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getVersion(Consumer<T2CupdateWebData> consumer, String pluginVersion, Integer spigotID, String gitKey) {
|
public void getVersion(Consumer<T2C_UpdateWebData> consumer, String pluginVersion, Integer spigotID, String gitKey) {
|
||||||
if (T2CBlibConfig.getUpdateCheckFullDisable()) return;
|
|
||||||
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1";
|
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1";
|
||||||
if (!T2CBlibConfig.getSeePreReleaseUpdates()) {
|
if (!(boolean) T2CB_LibConfig.VALUES.seePreReleaseUpdates.getValue() ) {
|
||||||
RepoURL = RepoURL + "&pre-release=false";
|
RepoURL = RepoURL + "&pre-release=false";
|
||||||
}
|
}
|
||||||
String finalRepoURL = RepoURL;
|
String finalRepoURL = RepoURL;
|
||||||
@@ -76,14 +75,14 @@ public class T2CBupdateCheckerGit {
|
|||||||
updateUrl = "https://www.spigotmc.org/resources/" + spigotID;
|
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);
|
consumer.accept(webData);
|
||||||
} catch (Exception var10) {
|
} catch (Exception var10) {
|
||||||
Boolean load = false;
|
Boolean load = false;
|
||||||
if (T2CBupdateAPI.bungeePluginVersins.containsKey(plugin.getDescription().getName())) {
|
if (T2CB_UpdateAPI.bungeePluginVersins.containsKey(plugin.getDescription().getName())) {
|
||||||
load = T2CBupdateAPI.bungeePluginVersins.get(plugin.getDescription().getName()).load;
|
load = T2CB_UpdateAPI.bungeePluginVersins.get(plugin.getDescription().getName()).load;
|
||||||
}
|
}
|
||||||
T2CupdateObject update = new T2CupdateObject(
|
T2C_UpdateObject update = new T2C_UpdateObject(
|
||||||
plugin.getDescription().getName(),
|
plugin.getDescription().getName(),
|
||||||
pluginVersion,
|
pluginVersion,
|
||||||
null,
|
null,
|
||||||
@@ -91,7 +90,7 @@ public class T2CBupdateCheckerGit {
|
|||||||
false,
|
false,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
T2CBupdateAPI.bungeePluginVersins.put(plugin.getDescription().getName(), update);
|
T2CB_UpdateAPI.bungeePluginVersins.put(plugin.getDescription().getName(), update);
|
||||||
this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage());
|
this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
@@ -1,12 +1,12 @@
|
|||||||
package net.t2code.t2codelib.BUNGEE.api.yaml;
|
package net.t2code.t2codelib.BUNGEE.api.yaml;
|
||||||
|
|
||||||
import net.md_5.bungee.config.Configuration;
|
import net.md_5.bungee.config.Configuration;
|
||||||
import net.t2code.t2codelib.BUNGEE.api.messages.T2CBreplace;
|
import net.t2code.t2codelib.BUNGEE.api.messages.T2CB_Replace;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class T2CBconfig {
|
public class T2CB_Config {
|
||||||
public static void set(String path, String value, Configuration configuration) {
|
public static void set(String path, String value, Configuration configuration) {
|
||||||
if (!configuration.contains(path)) {
|
if (!configuration.contains(path)) {
|
||||||
configuration.set(path, value);
|
configuration.set(path, value);
|
||||||
@@ -43,7 +43,7 @@ public class T2CBconfig {
|
|||||||
|
|
||||||
|
|
||||||
public static String select(String prefix, String path, Configuration configuration) {
|
public static String select(String prefix, String path, Configuration configuration) {
|
||||||
return T2CBreplace.replace(prefix, configuration.getString(path));
|
return T2CB_Replace.replace(prefix, configuration.getString(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ public class T2CBconfig {
|
|||||||
List<String> output = new ArrayList<>();
|
List<String> output = new ArrayList<>();
|
||||||
List<String> input = configuration.getStringList(path);
|
List<String> input = configuration.getStringList(path);
|
||||||
for (String st : input) {
|
for (String st : input) {
|
||||||
output.add(T2CBreplace.replace(prefix, st));
|
output.add(T2CB_Replace.replace(prefix, st));
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ public class T2CBconfig {
|
|||||||
List<String> output = new ArrayList<>();
|
List<String> output = new ArrayList<>();
|
||||||
List<String> input = configuration.getStringList(path);
|
List<String> input = configuration.getStringList(path);
|
||||||
for (String st : input) {
|
for (String st : input) {
|
||||||
output.add(T2CBreplace.replace(prefix, st));
|
output.add(T2CB_Replace.replace(prefix, st));
|
||||||
}
|
}
|
||||||
value = output;
|
value = output;
|
||||||
}
|
}
|
@@ -0,0 +1,124 @@
|
|||||||
|
// This class was created by JaTiTV.
|
||||||
|
|
||||||
|
package net.t2code.t2codelib.BUNGEE.api.yaml;
|
||||||
|
|
||||||
|
import net.md_5.bungee.config.ConfigurationProvider;
|
||||||
|
import net.md_5.bungee.config.YamlConfiguration;
|
||||||
|
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||||
|
import net.md_5.bungee.config.Configuration;
|
||||||
|
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class T2CB_ConfigWriter {
|
||||||
|
|
||||||
|
private static Configuration config;
|
||||||
|
|
||||||
|
|
||||||
|
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) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
Map<String, List<String>> comments = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
T2C_LanguageEnum lang = T2C_LanguageEnum.english;
|
||||||
|
|
||||||
|
for (T2C_ConfigItem item : values) {
|
||||||
|
if (item.getForceSet() || !exist) {
|
||||||
|
if (!config.contains(item.getPath())) {
|
||||||
|
config.set(item.getPath(), item.getValue());
|
||||||
|
}
|
||||||
|
List<String> commandList = item.getComments().get(lang);
|
||||||
|
if (commandList != null) {
|
||||||
|
comments.put(item.getPath(), commandList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
saveConfigWithComments(configFile, comments, header);
|
||||||
|
readConfig(config, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void readConfig(Configuration config, T2C_ConfigItem[] values) {
|
||||||
|
for (T2C_ConfigItem item : values) {
|
||||||
|
item.setValue(config.get(item.getPath()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void saveConfigWithComments(File file, Map<String, List<String>> comments, String... headers) {
|
||||||
|
try {
|
||||||
|
StringBuilder configContent = new StringBuilder();
|
||||||
|
for (String h : headers) {
|
||||||
|
configContent.append("# ").append(h).append("\n");
|
||||||
|
}
|
||||||
|
configContent.append("\n");
|
||||||
|
addSection(config, comments, configContent, "", 0);
|
||||||
|
|
||||||
|
// Write the content to the file
|
||||||
|
Files.write(file.toPath(), configContent.toString().getBytes());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addSection(Configuration section, Map<String, List<String>> comments, StringBuilder builder, String prefix, int indentLevel) {
|
||||||
|
String indent = " ".repeat(indentLevel);
|
||||||
|
|
||||||
|
for (String key : section.getKeys()) {
|
||||||
|
String fullKey = prefix.isEmpty() ? key : prefix + "." + key;
|
||||||
|
Object value = section.get(key);
|
||||||
|
|
||||||
|
// Add comment if it exists for this key
|
||||||
|
List<String> commentList = comments.get(fullKey);
|
||||||
|
if (commentList != null) {
|
||||||
|
for (String c : commentList) {
|
||||||
|
if (c.isEmpty()) {
|
||||||
|
builder.append(indent).append(c).append("\n");
|
||||||
|
} else builder.append(indent).append("# ").append(c).append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the value is a section (nested map)
|
||||||
|
|
||||||
|
if (value instanceof Configuration) {
|
||||||
|
// Correctly add the section
|
||||||
|
builder.append(indent).append(key).append(":\n");
|
||||||
|
addSection((Configuration) value, comments, builder, fullKey, indentLevel + 1);
|
||||||
|
} else {
|
||||||
|
// Add value with proper indentation
|
||||||
|
// builder.append(indent).append(key).append(": ").append(value).append("\n");
|
||||||
|
if (value instanceof List) {
|
||||||
|
builder.append(indent).append(key).append(": ").append("\n");
|
||||||
|
List<Object> zw = (List<Object>) value;
|
||||||
|
for (Object s : zw) {
|
||||||
|
if (s instanceof String) {
|
||||||
|
builder.append(indent).append("- \"").append(s).append("\"\n");
|
||||||
|
} else builder.append(indent).append("- ").append(s).append("\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (value instanceof String) {
|
||||||
|
builder.append(indent).append(key).append(": \"").append(value).append("\"\n");
|
||||||
|
} else builder.append(indent).append(key).append(": ").append(value).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
117
src/main/java/net/t2code/t2codelib/BUNGEE/system/T2CB_Main.java
Normal file
117
src/main/java/net/t2code/t2codelib/BUNGEE/system/T2CB_Main.java
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
package net.t2code.t2codelib.BUNGEE.system;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
|
||||||
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
import net.t2code.t2codelib.BUNGEE.api.messages.T2CB_Send;
|
||||||
|
import net.t2code.t2codelib.BUNGEE.api.bungeePlayers.T2CB_BungeePlayers;
|
||||||
|
import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.T2CB_PluginMessageProxyCommand;
|
||||||
|
import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.autoResponse.T2CB_API_AutoResponse;
|
||||||
|
import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.commandgui.T2CB_API_CGUI;
|
||||||
|
import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.opSecurity.T2CB_API_OpSecurity;
|
||||||
|
import net.t2code.t2codelib.BUNGEE.api.update.T2CB_UpdateAPI;
|
||||||
|
import net.t2code.t2codelib.BUNGEE.system.bstats.T2CB_Metrics;
|
||||||
|
import net.t2code.t2codelib.BUNGEE.system.config.T2CB_LibConfig;
|
||||||
|
import net.t2code.t2codelib.util.T2C_PlatformDetector;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
|
||||||
|
public class T2CB_Main extends Plugin {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static Plugin plugin;
|
||||||
|
|
||||||
|
private static String version;
|
||||||
|
private static String orgVersion;
|
||||||
|
private static String autor;
|
||||||
|
|
||||||
|
private static Boolean mmIsLoad = true;
|
||||||
|
private static BungeeAudiences adventure;
|
||||||
|
|
||||||
|
public static BungeeAudiences getAdventure() {
|
||||||
|
T2C_PlatformDetector.scan();
|
||||||
|
if (adventure == null) {
|
||||||
|
throw new IllegalStateException("Cannot retrieve audience provider while plugin is not enabled");
|
||||||
|
}
|
||||||
|
return adventure;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
// Plugin startup logic
|
||||||
|
plugin = this;
|
||||||
|
orgVersion = plugin.getDescription().getVersion();
|
||||||
|
autor = plugin.getDescription().getAuthor();
|
||||||
|
try {
|
||||||
|
adventure = BungeeAudiences.create(this);
|
||||||
|
T2CB_Send.info(this, "Adventure load!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
T2CB_Send.error(this, "Adventure can not be load!");
|
||||||
|
mmIsLoad = false;
|
||||||
|
}
|
||||||
|
onLoad(T2C_Util.getPrefix(), autor, orgVersion, T2C_Util.getSpigot(), T2C_Util.getDiscord(), T2C_Util.getSpigotID(), T2C_Util.getBstatsID(), T2C_Util.getGit());
|
||||||
|
version = plugin.getDescription().getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
// Plugin shutdown logic
|
||||||
|
T2CB_BungeePlayers.sendToSpigotDeleteAll();
|
||||||
|
if (mmIsLoad) {
|
||||||
|
if (adventure != null) {
|
||||||
|
adventure.close();
|
||||||
|
adventure = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
T2CB_Send.console(T2C_Util.getPrefix() + "§4============================= " + T2C_Util.getPrefix() + " §4=============================");
|
||||||
|
T2CB_Send.console(T2C_Util.getPrefix() + " §2Autor: §6" + String.valueOf(plugin.getDescription().getAuthor()).replace("[", "").replace("]", ""));
|
||||||
|
T2CB_Send.console(T2C_Util.getPrefix() + " §2Version: §6" + version);
|
||||||
|
T2CB_Send.console(T2C_Util.getPrefix() + " §2Spigot: §6" + T2C_Util.getSpigot());
|
||||||
|
T2CB_Send.console(T2C_Util.getPrefix() + " §2Discord: §6" + T2C_Util.getDiscord());
|
||||||
|
T2CB_Send.console(T2C_Util.getPrefix() + " §4Plugin successfully disabled.");
|
||||||
|
T2CB_Send.console(T2C_Util.getPrefix() + "§4============================= " + T2C_Util.getPrefix() + " §4=============================");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean getMmIsLoad() {
|
||||||
|
return mmIsLoad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onLoad(String prefix, String autor, String version, String spigot, String discord, Integer spigotID, Integer bstatsID, String url) {
|
||||||
|
long long_ = System.currentTimeMillis();
|
||||||
|
T2CB_Send.console(prefix + "§4============================= " + prefix + " §4=============================");
|
||||||
|
T2CB_Send.console(prefix + " §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
|
||||||
|
T2CB_Send.console(prefix + " §2Version: §6" + version);
|
||||||
|
T2CB_Send.console(prefix + " §2Spigot: §6" + spigot);
|
||||||
|
T2CB_Send.console(prefix + " §2Discord: §6" + discord);
|
||||||
|
|
||||||
|
T2CB_Metrics.bStats(plugin, bstatsID);
|
||||||
|
T2CB_LibConfig.set();
|
||||||
|
|
||||||
|
T2CB_UpdateAPI.onUpdateCheckTimer(plugin, prefix, discord, spigotID, url);
|
||||||
|
|
||||||
|
//API
|
||||||
|
plugin.getProxy().registerChannel(T2C_Util.getPluginChannel_ProxyCommand());
|
||||||
|
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CB_PluginMessageProxyCommand());
|
||||||
|
|
||||||
|
plugin.getProxy().registerChannel(T2C_Util.getPluginChannel_ProxyOnlinePlayers());
|
||||||
|
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CB_BungeePlayers());
|
||||||
|
T2CB_BungeePlayers.sendToSpigotDeleteAll();
|
||||||
|
|
||||||
|
if ((boolean) T2CB_LibConfig.VALUES.apiCommandGUIEnable.getValue()) {
|
||||||
|
plugin.getProxy().registerChannel(T2C_Util.getPluginChannel_CGUIOnlinePlayers());
|
||||||
|
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CB_API_CGUI());
|
||||||
|
T2CB_API_CGUI.sendToSpigotDeleteAll();
|
||||||
|
}
|
||||||
|
if ((boolean) T2CB_LibConfig.VALUES.apiAutoResponse.getValue()) {
|
||||||
|
plugin.getProxy().registerChannel(T2C_Util.getPluginChannel_AutoResponse());
|
||||||
|
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CB_API_AutoResponse());
|
||||||
|
}
|
||||||
|
if ((boolean) T2CB_LibConfig.VALUES.apiOpSecurity.getValue()) {
|
||||||
|
plugin.getProxy().registerChannel(T2C_Util.getPluginChannel_OPSecurity());
|
||||||
|
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CB_API_OpSecurity());
|
||||||
|
}
|
||||||
|
|
||||||
|
T2CB_Send.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||||
|
T2CB_Send.console(prefix + "§4============================= " + prefix + " §4=============================");
|
||||||
|
}
|
||||||
|
}
|
@@ -1,65 +0,0 @@
|
|||||||
package net.t2code.t2codelib.BUNGEE.system;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.api.update.T2CBupdateAPI;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.system.bstats.T2CBmetrics;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.api.bungeePlayers.T2CBbungeePlayers;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.T2CplmsgBcmd;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.autoResponse.T2CapiAutoResponse;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.commandgui.T2CapiCGUI;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.opSecurity.T2CapiOpSecurity;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class T2CBload {
|
|
||||||
public static void onLoad(Plugin plugin, String prefix, String autor, String version, String spigot, String discord, Integer spigotID, Integer bstatsID, String url) {
|
|
||||||
long long_ = System.currentTimeMillis();
|
|
||||||
T2CBsend.console(prefix + "§4============================= " + prefix + " §4=============================");
|
|
||||||
T2CBsend.console(prefix + " §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
|
|
||||||
T2CBsend.console(prefix + " §2Version: §6" + version);
|
|
||||||
T2CBsend.console(prefix + " §2Spigot: §6" + spigot);
|
|
||||||
T2CBsend.console(prefix + " §2Discord: §6" + discord);
|
|
||||||
|
|
||||||
T2CBmetrics.Bstats(plugin, bstatsID);
|
|
||||||
try {
|
|
||||||
T2CBlibConfig.create();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
T2CBlibConfig.select();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
T2CBupdateAPI.onUpdateCheckTimer(plugin, prefix, discord, spigotID, url);
|
|
||||||
|
|
||||||
//API
|
|
||||||
plugin.getProxy().registerChannel("t2c:bcmd");
|
|
||||||
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CplmsgBcmd());
|
|
||||||
|
|
||||||
plugin.getProxy().registerChannel("t2c:bonlp");
|
|
||||||
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CBbungeePlayers());
|
|
||||||
T2CBbungeePlayers.sendToSpigotDeleteAll();
|
|
||||||
|
|
||||||
if (T2CBlibConfig.getApiCommandGUIEnable()) {
|
|
||||||
plugin.getProxy().registerChannel("t2c:cguiopl");
|
|
||||||
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiCGUI());
|
|
||||||
T2CapiCGUI.sendToSpigotDeleteAll();
|
|
||||||
}
|
|
||||||
if (T2CBlibConfig.getApiAutoResponse()) {
|
|
||||||
plugin.getProxy().registerChannel("t2c:aresp");
|
|
||||||
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiAutoResponse());
|
|
||||||
}
|
|
||||||
if (T2CBlibConfig.getApiOpSecurity()) {
|
|
||||||
plugin.getProxy().registerChannel("t2c:t2c:opsec");
|
|
||||||
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiOpSecurity());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
T2CBsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
T2CBsend.console(prefix + "§4============================= " + prefix + " §4=============================");
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,70 +0,0 @@
|
|||||||
package net.t2code.t2codelib.BUNGEE.system;
|
|
||||||
|
|
||||||
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
|
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.api.bungeePlayers.T2CBbungeePlayers;
|
|
||||||
import net.t2code.t2codelib.Util;
|
|
||||||
|
|
||||||
public class T2CodeBMain extends Plugin {
|
|
||||||
|
|
||||||
private static Plugin plugin;
|
|
||||||
|
|
||||||
public static Plugin getPlugin() {
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String version;
|
|
||||||
private static String orgVersion;
|
|
||||||
private static String autor;
|
|
||||||
|
|
||||||
private static Boolean mmIsLoad = true;
|
|
||||||
private static BungeeAudiences adventure;
|
|
||||||
|
|
||||||
public static BungeeAudiences getAdventure() {
|
|
||||||
if(adventure == null) {
|
|
||||||
throw new IllegalStateException("Cannot retrieve audience provider while plugin is not enabled");
|
|
||||||
}
|
|
||||||
return adventure;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
// Plugin startup logic
|
|
||||||
plugin = this;
|
|
||||||
orgVersion = plugin.getDescription().getVersion();
|
|
||||||
autor = plugin.getDescription().getAuthor();
|
|
||||||
try {
|
|
||||||
adventure = BungeeAudiences.create(this);
|
|
||||||
T2CBsend.info(this,"Adventure load!");
|
|
||||||
} catch (Exception e){
|
|
||||||
T2CBsend.error(this,"Adventure can not be load!");
|
|
||||||
mmIsLoad = false;
|
|
||||||
}
|
|
||||||
T2CBload.onLoad(plugin, Util.getPrefix(), autor, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID(),Util.getGit());
|
|
||||||
version = plugin.getDescription().getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
// Plugin shutdown logic
|
|
||||||
T2CBbungeePlayers.sendToSpigotDeleteAll();
|
|
||||||
if (mmIsLoad){
|
|
||||||
if(adventure != null) {
|
|
||||||
adventure.close();
|
|
||||||
adventure = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
T2CBsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4=============================");
|
|
||||||
T2CBsend.console(Util.getPrefix() + " §2Autor: §6" + String.valueOf(plugin.getDescription().getAuthor()).replace("[", "").replace("]", ""));
|
|
||||||
T2CBsend.console(Util.getPrefix() + " §2Version: §6" + version);
|
|
||||||
T2CBsend.console(Util.getPrefix() + " §2Spigot: §6" + Util.getSpigot());
|
|
||||||
T2CBsend.console(Util.getPrefix() + " §2Discord: §6" + Util.getDiscord());
|
|
||||||
T2CBsend.console(Util.getPrefix() + " §4Plugin successfully disabled.");
|
|
||||||
T2CBsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4=============================");
|
|
||||||
}
|
|
||||||
public static Boolean getMmIsLoad() {
|
|
||||||
return mmIsLoad;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -21,11 +21,11 @@ import java.util.logging.Level;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
public class T2CBmetrics {
|
public class T2CB_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!
|
||||||
T2CBmetrics metrics = new T2CBmetrics(plugin, pluginId);
|
T2CB_Metrics metrics = new T2CB_Metrics(plugin, pluginId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
@@ -49,7 +49,7 @@ public class T2CBmetrics {
|
|||||||
* @param serviceId The id of the service. It can be found at <a
|
* @param serviceId The id of the service. It can be found at <a
|
||||||
* href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
|
* href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
|
||||||
*/
|
*/
|
||||||
public T2CBmetrics(Plugin plugin, int serviceId) {
|
public T2CB_Metrics(Plugin plugin, int serviceId) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
try {
|
try {
|
||||||
loadConfig();
|
loadConfig();
|
@@ -0,0 +1,37 @@
|
|||||||
|
package net.t2code.t2codelib.BUNGEE.system.config;
|
||||||
|
|
||||||
|
import net.md_5.bungee.config.ConfigurationProvider;
|
||||||
|
import net.t2code.t2codelib.BUNGEE.system.T2CB_Main;
|
||||||
|
import net.md_5.bungee.config.Configuration;
|
||||||
|
import net.md_5.bungee.config.YamlConfiguration;
|
||||||
|
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ConvertT2CBlibConfig {
|
||||||
|
|
||||||
|
public static Configuration configuration;
|
||||||
|
|
||||||
|
public static void convert() throws IOException {
|
||||||
|
File config = new File(T2CB_Main.getPlugin().getDataFolder(), "config.yml");
|
||||||
|
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config);
|
||||||
|
|
||||||
|
if (!config.exists()) return;
|
||||||
|
if (configuration.contains("plugin.updateCheck.onJoin")) return;
|
||||||
|
|
||||||
|
set("UpdateCheck.TimerInMin", T2CB_LibConfig.VALUES.updateTimer);
|
||||||
|
set("UpdateCheck.SeePreReleaseUpdates", T2CB_LibConfig.VALUES.seePreReleaseUpdates);
|
||||||
|
set("API.CommandGUI.Enable", T2CB_LibConfig.VALUES.apiCommandGUIEnable);
|
||||||
|
set("API.AutoResponse.Enable", T2CB_LibConfig.VALUES.apiAutoResponse);
|
||||||
|
set("API.OPSecurity.Enable", T2CB_LibConfig.VALUES.apiOpSecurity);
|
||||||
|
|
||||||
|
config.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void set(String path, T2C_ConfigItem item){
|
||||||
|
if (configuration.contains(path)){
|
||||||
|
item.setValue(configuration.get(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,92 @@
|
|||||||
|
package net.t2code.t2codelib.BUNGEE.system.config;
|
||||||
|
|
||||||
|
import net.t2code.t2codelib.BUNGEE.api.yaml.T2CB_ConfigWriter;
|
||||||
|
import net.t2code.t2codelib.BUNGEE.system.T2CB_Main;
|
||||||
|
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||||
|
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class T2CB_LibConfig {
|
||||||
|
|
||||||
|
public enum VALUES implements T2C_ConfigItem {
|
||||||
|
updateTimer("updateCheck.timerInMin", 60, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.english, List.of("In this option you can set the time interval in minutes in which updates should be checked."));
|
||||||
|
}}),
|
||||||
|
seePreReleaseUpdates("updateCheck.seePreReleaseUpdates", true, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.english, List.of("In this option you can set whether you want to receive and display beta and snapshot versions in the update check."));
|
||||||
|
}}),
|
||||||
|
|
||||||
|
apiCommandGUIEnable("api.commandGUI.enable", false, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.english, List.of("With this option you activate the api interface for the T2C-CommandGUI plugin."));
|
||||||
|
}}),
|
||||||
|
apiAutoResponse("api.autoResponse.enable", false, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.english, List.of("With this option you activate the api interface for the T2C-AutoResponse plugin."));
|
||||||
|
}}),
|
||||||
|
apiOpSecurity("api.opSecurity.enable", false, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.english, List.of("With this option you activate the api interface for the T2C-OPSecurity plugin."));
|
||||||
|
}}),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String path;
|
||||||
|
private Object value;
|
||||||
|
private final boolean forceSet;
|
||||||
|
private final HashMap<T2C_LanguageEnum, List<String>> comments;
|
||||||
|
|
||||||
|
VALUES(String path, Object value, boolean forceSet, HashMap<T2C_LanguageEnum, List<String>> comments) {
|
||||||
|
this.path = path;
|
||||||
|
this.value = value;
|
||||||
|
this.forceSet = forceSet;
|
||||||
|
this.comments = comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getForceSet() {
|
||||||
|
return forceSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<T2C_LanguageEnum, List<String>> getComments() {
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLanguagePath() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValue(Object newValue) {
|
||||||
|
value = newValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void set() {
|
||||||
|
try {
|
||||||
|
ConvertT2CBlibConfig.convert();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
T2CB_ConfigWriter.createConfig(new File(T2CB_Main.getPlugin().getDataFolder(), "config.yml"), VALUES.values(), T2C_Util.getConfigLogo());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,63 +0,0 @@
|
|||||||
package net.t2code.t2codelib.BUNGEE.system.config;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.md_5.bungee.config.Configuration;
|
|
||||||
import net.md_5.bungee.config.ConfigurationProvider;
|
|
||||||
import net.md_5.bungee.config.YamlConfiguration;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.api.yaml.T2CBconfig;
|
|
||||||
import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain;
|
|
||||||
import net.t2code.t2codelib.Util;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class T2CBlibConfig {
|
|
||||||
|
|
||||||
public static void create() throws IOException {
|
|
||||||
long long_ = System.currentTimeMillis();
|
|
||||||
File config = new File(T2CodeBMain.getPlugin().getDataFolder(), "config.yml");
|
|
||||||
if (!T2CodeBMain.getPlugin().getDataFolder().exists()) T2CodeBMain.getPlugin().getDataFolder().mkdir();
|
|
||||||
if (!config.exists()) {
|
|
||||||
config.createNewFile();
|
|
||||||
}
|
|
||||||
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config);
|
|
||||||
T2CBconfig.set("UpdateCheck.TimerInMin", 60, configuration);
|
|
||||||
T2CBconfig.set("UpdateCheck.SeePreReleaseUpdates", true, configuration);
|
|
||||||
T2CBconfig.set("Plugin.UpdateCheck.AllPlugins.FullDisable", false, configuration);
|
|
||||||
|
|
||||||
T2CBconfig.set("API.CommandGUI.Enable", false, configuration);
|
|
||||||
T2CBconfig.set("API.AutoResponse.Enable", false, configuration);
|
|
||||||
T2CBconfig.set("API.OPSecurity.Enable", false, configuration);
|
|
||||||
|
|
||||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, config);
|
|
||||||
T2CBsend.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void select() throws IOException {
|
|
||||||
File config = new File(T2CodeBMain.getPlugin().getDataFolder(), "config.yml");
|
|
||||||
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config);
|
|
||||||
|
|
||||||
updateTimer = configuration.getInt("UpdateCheck.TimerInMin");
|
|
||||||
seePreReleaseUpdates = configuration.getBoolean("UpdateCheck.SeePreReleaseUpdates");
|
|
||||||
updateCheckFullDisable = configuration.getBoolean("Plugin.UpdateCheck.AllPlugins.FullDisable");
|
|
||||||
|
|
||||||
apiCommandGUIEnable = configuration.getBoolean("API.CommandGUI.Enable");
|
|
||||||
apiAutoResponse = configuration.getBoolean("API.AutoResponse.Enable");
|
|
||||||
apiOpSecurity = configuration.getBoolean("API.OPSecurity.Enable");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private static Integer updateTimer;
|
|
||||||
@Getter
|
|
||||||
private static Boolean seePreReleaseUpdates;
|
|
||||||
@Getter
|
|
||||||
private static Boolean updateCheckFullDisable;
|
|
||||||
@Getter
|
|
||||||
private static Boolean apiCommandGUIEnable;
|
|
||||||
@Getter
|
|
||||||
private static Boolean apiAutoResponse;
|
|
||||||
@Getter
|
|
||||||
private static Boolean apiOpSecurity;
|
|
||||||
|
|
||||||
}
|
|
@@ -1,6 +1,6 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.bungeePlayers;
|
package net.t2code.t2codelib.SPIGOT.api.bungeePlayers;
|
||||||
|
|
||||||
public enum T2CbungeePlayersEnum {
|
public enum T2C_BngeePlayersEnum {
|
||||||
JOIN,
|
JOIN,
|
||||||
QUIT,
|
QUIT,
|
||||||
GIVEALL,
|
GIVEALL,
|
@@ -0,0 +1,86 @@
|
|||||||
|
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.T2C_Main;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class T2C_BungeePlayers implements PluginMessageListener {
|
||||||
|
@Getter
|
||||||
|
private static List<String> bungeePlayers = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, byte[] message) {
|
||||||
|
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(message));
|
||||||
|
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(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);
|
||||||
|
break;
|
||||||
|
case QUIT:
|
||||||
|
bungeePlayers.remove(input);
|
||||||
|
break;
|
||||||
|
case GIVEALL:
|
||||||
|
if (!T2C_LibConfig.VALUES.serverUUID.getValue().equals(uuid)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bungeePlayers.clear();
|
||||||
|
String[] in = input.split(";");
|
||||||
|
bungeePlayers.addAll(Arrays.asList(in));
|
||||||
|
break;
|
||||||
|
case CLEAR:
|
||||||
|
bungeePlayers.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void callAllBungeePlayers() {
|
||||||
|
if (Bukkit.getOnlinePlayers().isEmpty()) {
|
||||||
|
Bukkit.getScheduler().runTaskLaterAsynchronously(T2C_Main.getPlugin(), new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
callAllBungeePlayers();
|
||||||
|
}
|
||||||
|
}, 20L);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream output = new DataOutputStream(stream);
|
||||||
|
try {
|
||||||
|
output.writeUTF(T2C_BngeePlayersEnum.GIVEALL.name());
|
||||||
|
output.writeUTF(T2C_LibConfig.VALUES.serverUUID.getValue().toString());
|
||||||
|
} catch (IOException e) {
|
||||||
|
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
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,83 +0,0 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.bungeePlayers;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
|
||||||
import net.t2code.t2codelib.Util;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class T2CbungeePlayers implements PluginMessageListener {
|
|
||||||
@Getter
|
|
||||||
private static List<String> bungeePlayers = new ArrayList<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
|
||||||
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(message));
|
|
||||||
T2Csend.debug(T2CodeLibMain.getPlugin(), "stream: " + stream.toString());
|
|
||||||
try {
|
|
||||||
T2CbungeePlayersEnum subChannel = T2CbungeePlayersEnum.valueOf(stream.readUTF());
|
|
||||||
String input = stream.readUTF();
|
|
||||||
String uuid = stream.readUTF();
|
|
||||||
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage received channel: " + channel);
|
|
||||||
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage received subChannel: " + subChannel.name());
|
|
||||||
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage received input: " + input);
|
|
||||||
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage received input2/uuid: " + uuid);
|
|
||||||
switch (subChannel) {
|
|
||||||
case JOIN:
|
|
||||||
bungeePlayers.add(input);
|
|
||||||
break;
|
|
||||||
case QUIT:
|
|
||||||
bungeePlayers.remove(input);
|
|
||||||
break;
|
|
||||||
case GIVEALL:
|
|
||||||
if (!Util.getServerUUID().toString().equals(uuid)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
bungeePlayers.clear();
|
|
||||||
String[] in = input.split(";");
|
|
||||||
bungeePlayers.addAll(Arrays.asList(in));
|
|
||||||
break;
|
|
||||||
case CLEAR:
|
|
||||||
bungeePlayers.clear();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void callAllBungeePlayers() {
|
|
||||||
if (Bukkit.getOnlinePlayers().isEmpty()) {
|
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
callAllBungeePlayers();
|
|
||||||
}
|
|
||||||
}, 20L);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream output = new DataOutputStream(stream);
|
|
||||||
try {
|
|
||||||
output.writeUTF(T2CbungeePlayersEnum.GIVEALL.name());
|
|
||||||
output.writeUTF(Util.getServerUUID().toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
||||||
player.sendPluginMessage(T2CodeLibMain.getPlugin(), "t2c:bonlp", stream.toByteArray());
|
|
||||||
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage received channel: t2c:bonlp");
|
|
||||||
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage send subChannel: " + T2CbungeePlayersEnum.GIVEALL.name());
|
|
||||||
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage send output/uuid: " + Util.getServerUUID().toString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,26 +1,23 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.commands;
|
package net.t2code.t2codelib.SPIGOT.api.commands;
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
import net.t2code.t2codelib.SPIGOT.system.BungeeCommandSenderReceiver;
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
|
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
|
||||||
|
|
||||||
import java.rmi.MarshalledObject;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class T2Ccmd {
|
public class T2C_Cmd {
|
||||||
public static void console(String cmdInput) {
|
public static void console(String cmdInput) {
|
||||||
Map.Entry<String,Integer> map = delay(cmdInput);
|
Map.Entry<String,Integer> map = delay(cmdInput);
|
||||||
int delay = map.getValue();
|
int delay = map.getValue();
|
||||||
String cmd = map.getKey();
|
String cmd = map.getKey();
|
||||||
Bukkit.getScheduler().runTaskLater(T2CodeLibMain.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().runTaskLater(T2C_Main.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (cmd.contains("!onBungee")) {
|
if (cmd.contains("!onBungee")) {
|
||||||
T2CbungeeCommandSenderReciver.sendToBungee(null, cmd.replace("!onBungee", ""), true);
|
BungeeCommandSenderReceiver.sendToBungee(null, cmd.replace("!onBungee", ""), true);
|
||||||
} else Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
|
} else Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
|
||||||
}
|
}
|
||||||
}, delay);
|
}, delay);
|
||||||
@@ -30,16 +27,16 @@ public class T2Ccmd {
|
|||||||
Map.Entry<String,Integer> map = delay(cmdInput);
|
Map.Entry<String,Integer> map = delay(cmdInput);
|
||||||
int delay = map.getValue();
|
int delay = map.getValue();
|
||||||
String cmd = map.getKey();
|
String cmd = map.getKey();
|
||||||
Bukkit.getScheduler().runTaskLater(T2CodeLibMain.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().runTaskLater(T2C_Main.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (cmd.contains("!asConsole")) {
|
if (cmd.contains("!asConsole")) {
|
||||||
if (cmd.contains("!onBungee")) {
|
if (cmd.contains("!onBungee")) {
|
||||||
T2CbungeeCommandSenderReciver.sendToBungee(player, cmd.replace("!asConsole", "").replace("!onBungee", ""), true);
|
BungeeCommandSenderReceiver.sendToBungee(player, cmd.replace("!asConsole", "").replace("!onBungee", ""), true);
|
||||||
} else console(cmd.replace("!asConsole", ""));
|
} else console(cmd.replace("!asConsole", ""));
|
||||||
} else {
|
} else {
|
||||||
if (cmd.contains("!onBungee")) {
|
if (cmd.contains("!onBungee")) {
|
||||||
T2CbungeeCommandSenderReciver.sendToBungee(player, cmd.replace("!onBungee", ""), false);
|
BungeeCommandSenderReceiver.sendToBungee(player, cmd.replace("!onBungee", ""), false);
|
||||||
} else player.chat("/" + cmd);
|
} else player.chat("/" + cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -8,7 +8,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class T2Ctab {
|
public class T2C_Tab {
|
||||||
public static void tab(List<String> matches, CommandSender sender, int arg, String[] args, String perm, Boolean onlinePlayer) {
|
public static void tab(List<String> matches, CommandSender sender, int arg, String[] args, String perm, Boolean onlinePlayer) {
|
||||||
if (args.length != arg + 1) return;
|
if (args.length != arg + 1) return;
|
||||||
for (Player player1 : Bukkit.getOnlinePlayers()) {
|
for (Player player1 : Bukkit.getOnlinePlayers()) {
|
@@ -1,12 +1,12 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.debug;
|
package net.t2code.t2codelib.SPIGOT.api.debug;
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class T2Cdebug {
|
public class T2C_Debug {
|
||||||
public static void debug(Plugin plugin, String msg) {
|
public static void debug(Plugin plugin, String msg) {
|
||||||
debug(plugin, msg, null);
|
debug(plugin, msg, null);
|
||||||
}
|
}
|
||||||
@@ -15,19 +15,19 @@ public class T2Cdebug {
|
|||||||
// if (!new File(Main.getPath(), "config.yml").exists()) return;
|
// if (!new File(Main.getPath(), "config.yml").exists()) return;
|
||||||
if (stage == null) {
|
if (stage == null) {
|
||||||
if (plugin.getConfig().getBoolean("Plugin.Debug") || plugin.getConfig().getBoolean("plugin.debug") || plugin.getConfig().getBoolean("Debug") || plugin.getConfig().getBoolean("debug")){
|
if (plugin.getConfig().getBoolean("Plugin.Debug") || plugin.getConfig().getBoolean("plugin.debug") || plugin.getConfig().getBoolean("Debug") || plugin.getConfig().getBoolean("debug")){
|
||||||
T2Csend.info(plugin, "");
|
T2C_Send.info(plugin, "");
|
||||||
Bukkit.getConsoleSender().sendMessage(plugin.getDescription().getPrefix() + " §5DEBUG: §6" + msg);
|
Bukkit.getConsoleSender().sendMessage(plugin.getDescription().getPrefix() + " §5DEBUG: §6" + msg);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plugin.getConfig().getInt("Plugin.Debug") >= stage || plugin.getConfig().getInt("plugin.debug") >= stage || plugin.getConfig().getInt("Debug") >= stage || plugin.getConfig().getInt("debug") >= stage) {
|
if (plugin.getConfig().getInt("Plugin.Debug") >= stage || plugin.getConfig().getInt("plugin.debug") >= stage || plugin.getConfig().getInt("Debug") >= stage || plugin.getConfig().getInt("debug") >= stage) {
|
||||||
T2Csend.info(plugin, "");
|
T2C_Send.info(plugin, "");
|
||||||
Bukkit.getConsoleSender().sendMessage(plugin.getDescription().getPrefix() + " §5DEBUG: §6" + msg);
|
Bukkit.getConsoleSender().sendMessage(plugin.getDescription().getPrefix() + " §5DEBUG: §6" + msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debugmsg(Plugin plugin, String msg) {
|
public static void debugmsg(Plugin plugin, String msg) {
|
||||||
T2Csend.warning(plugin, "");
|
T2C_Send.warning(plugin, "");
|
||||||
Bukkit.getConsoleSender().sendMessage("§e[" + plugin.getDescription().getPrefix() + "] §5DEBUG-MSG: §6" + msg);
|
Bukkit.getConsoleSender().sendMessage("§e[" + plugin.getDescription().getPrefix() + "] §5DEBUG-MSG: §6" + msg);
|
||||||
}
|
}
|
||||||
|
|
@@ -1,6 +1,6 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.dev;
|
package net.t2code.t2codelib.SPIGOT.api.dev;
|
||||||
|
|
||||||
public class T2CdevelopmentTool {
|
public class T2C_DevelopmentTool {
|
||||||
public static String removeLastChar(String s, int amount) {
|
public static String removeLastChar(String s, int amount) {
|
||||||
return (s == null || s.length() == 0)
|
return (s == null || s.length() == 0)
|
||||||
? null
|
? null
|
@@ -1,37 +1,38 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.eco;
|
package net.t2code.t2codelib.SPIGOT.api.eco;
|
||||||
|
|
||||||
import com.bencodez.votingplugin.VotingPluginMain;
|
import com.bencodez.votingplugin.VotingPluginMain;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
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.SelectLibMsg;
|
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.config.languages.T2CLibLanguages;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class T2Ceco {
|
public class T2C_Eco {
|
||||||
public static boolean moneyRemove(String prefix, Player player, Double price) {
|
public static boolean moneyRemove(String prefix, Player player, Double price) {
|
||||||
if (vault(prefix, player)) {
|
if (vault(prefix, player)) {
|
||||||
return T2CodeLibMain.getEco().withdrawPlayer(player, price).transactionSuccess();
|
return T2C_Main.getEco().withdrawPlayer(player, price).transactionSuccess();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean moneyAdd(String prefix, Player player, Double price) {
|
public static boolean moneyAdd(String prefix, Player player, Double price) {
|
||||||
if (vault(prefix, player)) {
|
if (vault(prefix, player)) {
|
||||||
return T2CodeLibMain.getEco().depositPlayer(player, price).transactionSuccess();
|
return T2C_Main.getEco().depositPlayer(player, price).transactionSuccess();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean vault(String prefix, Player player) {
|
private static boolean vault(String prefix, Player player) {
|
||||||
if (T2CodeLibMain.getEco() == null) {
|
if (T2C_Main.getEco() == null) {
|
||||||
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
|
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
|
||||||
T2Csend.console(prefix + " §4\n" + prefix + " §4Vault could not be found! §9Please download it here: " +
|
T2C_Send.console(prefix + " §e║ "+ "§4\n" + prefix + " §e║ " + "§4Vault could not be found! §9Please download it here: " +
|
||||||
"§6https://www.spigotmc.org/resources/vault.34315/§4\n" + prefix);
|
"§6https://www.spigotmc.org/resources/vault.34315/§4\n" + prefix + " §e║ ");
|
||||||
}
|
}
|
||||||
player.sendMessage(prefix + "\n" + SelectLibMsg.vaultNotSetUp + "\n" + prefix);
|
player.sendMessage(prefix + "\n" + T2CLibLanguages.VALUES.vaultNotSetUp.getValue().toString() + "\n" + prefix);
|
||||||
return false;
|
return false;
|
||||||
} else return true;
|
} else return true;
|
||||||
}
|
}
|
||||||
@@ -73,7 +74,7 @@ public class T2Ceco {
|
|||||||
|
|
||||||
public static boolean votePointsAdd(String prefix, Player player, Integer amount) {
|
public static boolean votePointsAdd(String prefix, Player player, Integer amount) {
|
||||||
if (votePlugin(prefix, player)) {
|
if (votePlugin(prefix, player)) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(T2C_Main.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
VotingPluginMain.getPlugin().getVotingPluginUserManager().getVotingPluginUser(player).addPoints(amount);
|
VotingPluginMain.getPlugin().getVotingPluginUserManager().getVotingPluginUser(player).addPoints(amount);
|
||||||
@@ -84,10 +85,10 @@ public class T2Ceco {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean votePlugin(String prefix, Player player) {
|
private static boolean votePlugin(String prefix, Player player) {
|
||||||
if (T2CpluginCheck.votingPlugin()) return true;
|
if (T2C_PluginCheck.votingPlugin()) return true;
|
||||||
T2Csend.console(prefix + " §4\n" + prefix + " §4VotingPlugin could not be found! §9Please download it here: " +
|
T2C_Send.console(prefix + " §e║ " + "§4\n" + prefix + " §e║ " + "§4VotingPlugin could not be found! §9Please download it here: " +
|
||||||
"§6https://www.spigotmc.org/resources/votingplugin.15358/§4\n" + prefix);
|
"§6https://www.spigotmc.org/resources/votingplugin.15358/§4\n" + prefix + " §e║ ");
|
||||||
player.sendMessage(prefix + "\n" + SelectLibMsg.votingPluginNotSetUp + "\n" + prefix);
|
player.sendMessage(prefix + "\n" + T2CLibLanguages.VALUES.votingPluginNotSetUp.getValue().toString() + "\n" + prefix);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,7 +2,9 @@ package net.t2code.t2codelib.SPIGOT.api.items;
|
|||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@@ -22,8 +24,8 @@ import org.json.JSONObject;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class T2CitemBuilder {
|
public class T2C_ItemBuilder {
|
||||||
public static final boolean getLegacy = T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12();
|
public static final boolean getLegacy = T2C_McVersion.isMc1_8() || T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12();
|
||||||
|
|
||||||
public static void fillItem(boolean enable, String item, Integer lines, Inventory inventory) {
|
public static void fillItem(boolean enable, String item, Integer lines, Inventory inventory) {
|
||||||
if (!enable) return;
|
if (!enable) return;
|
||||||
@@ -45,7 +47,7 @@ public class T2CitemBuilder {
|
|||||||
inventory.setItem(i, glass);
|
inventory.setItem(i, glass);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,13 +78,13 @@ public class T2CitemBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack base64(String base64Value) {
|
public static ItemStack base64(String base64Value) {
|
||||||
if (!T2CmcVersion.minMc1_20() || T2CmcVersion.isNms1_20_R1()|| T2CmcVersion.isNms1_20_R2()|| T2CmcVersion.isNms1_20_R3()) {
|
if (!T2C_McVersion.minMc1_20() || T2C_McVersion.isNms1_20_R1()|| T2C_McVersion.isNms1_20_R2()|| T2C_McVersion.isNms1_20_R3()) {
|
||||||
return base64Old(base64Value);
|
return base64Old(base64Value);
|
||||||
} else return base64New(base64Value);
|
} else return base64New(base64Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ItemStack base64Old(String base64Value) {
|
private static ItemStack base64Old(String base64Value) {
|
||||||
ItemStack itemStack = new ItemStack(T2CitemVersion.getHead());
|
ItemStack itemStack = new ItemStack(T2C_ItemVersion.getHead());
|
||||||
SkullMeta itemMeta = (SkullMeta) itemStack.getItemMeta();
|
SkullMeta itemMeta = (SkullMeta) itemStack.getItemMeta();
|
||||||
|
|
||||||
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
|
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
|
||||||
@@ -93,7 +95,7 @@ public class T2CitemBuilder {
|
|||||||
profileField.setAccessible(true);
|
profileField.setAccessible(true);
|
||||||
profileField.set(itemMeta, profile);
|
profileField.set(itemMeta, profile);
|
||||||
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
|
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
|
||||||
e.printStackTrace();
|
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||||
}
|
}
|
||||||
|
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
@@ -101,7 +103,7 @@ public class T2CitemBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static ItemStack base64New(String base64Value) {
|
private static ItemStack base64New(String base64Value) {
|
||||||
ItemStack itemStack = new ItemStack(T2CitemVersion.getHead());
|
ItemStack itemStack = new ItemStack(T2C_ItemVersion.getHead());
|
||||||
SkullMeta itemMeta = (SkullMeta) itemStack.getItemMeta();
|
SkullMeta itemMeta = (SkullMeta) itemStack.getItemMeta();
|
||||||
|
|
||||||
PlayerProfile profile = Bukkit.createPlayerProfile(UUID.randomUUID());
|
PlayerProfile profile = Bukkit.createPlayerProfile(UUID.randomUUID());
|
@@ -1,11 +1,11 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.items;
|
package net.t2code.t2codelib.SPIGOT.api.items;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class T2CitemVersion {
|
public class T2C_ItemVersion {
|
||||||
@Getter
|
@Getter
|
||||||
private static Material Head;
|
private static Material Head;
|
||||||
@Getter
|
@Getter
|
||||||
@@ -28,7 +28,7 @@ public class T2CitemVersion {
|
|||||||
private static ItemStack BlackStainedGlassPane;
|
private static ItemStack BlackStainedGlassPane;
|
||||||
|
|
||||||
public static void scan() {
|
public static void scan() {
|
||||||
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
if (T2C_McVersion.isMc1_8() || T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) {
|
||||||
Head = Material.valueOf("SKULL_ITEM");
|
Head = Material.valueOf("SKULL_ITEM");
|
||||||
YellowWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 4);
|
YellowWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 4);
|
||||||
OrangeWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 1);
|
OrangeWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 1);
|
@@ -1,12 +1,12 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.messages;
|
package net.t2code.t2codelib.SPIGOT.api.messages;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
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.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class T2ChoverModule {
|
public class T2C_HoverModule {
|
||||||
|
|
||||||
public static void modulePlayer(String text, String hover, String action, String actionValue, Player player) {
|
public static void modulePlayer(String text, String hover, String action, String actionValue, Player player) {
|
||||||
modulePlayer((text != null ? text : "null") + "/*/" + (hover != null ? hover : "null") + "/*/" + (action != null ? action : "null")
|
modulePlayer((text != null ? text : "null") + "/*/" + (hover != null ? hover : "null") + "/*/" + (action != null ? action : "null")
|
||||||
@@ -18,16 +18,16 @@ public class T2ChoverModule {
|
|||||||
t2cmodule(msg, player);
|
t2cmodule(msg, player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
T2CminiMessage.sendPlayerMiniMessage(msg, player);
|
T2C_MiniMessage.sendPlayerMiniMessage(msg, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void moduleSender(String msg, CommandSender sender) {
|
public static void moduleSender(String msg, CommandSender sender) {
|
||||||
T2CminiMessage.sendSenderMiniMessage(msg, sender);
|
T2C_MiniMessage.sendSenderMiniMessage(msg, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void moduleConsole(String msg) {
|
public static void moduleConsole(String msg) {
|
||||||
if (T2CodeLibMain.getMmIsLoad()) {
|
if (T2C_Main.getMmIsLoad()) {
|
||||||
T2CminiMessage.sendConsoleMiniMessage(msg);
|
T2C_MiniMessage.sendConsoleMiniMessage(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bukkit.getConsoleSender().sendMessage(msg);
|
Bukkit.getConsoleSender().sendMessage(msg);
|
||||||
@@ -45,7 +45,7 @@ public class T2ChoverModule {
|
|||||||
if (i > 2) action = split[2];
|
if (i > 2) action = split[2];
|
||||||
if (i > 3) actionValue = split[3];
|
if (i > 3) actionValue = split[3];
|
||||||
|
|
||||||
T2CtextBuilder textBuilder = new T2CtextBuilder(text);
|
T2C_TextBuilder textBuilder = new T2C_TextBuilder(text);
|
||||||
if (hover != null && !hover.equals("null")) {
|
if (hover != null && !hover.equals("null")) {
|
||||||
textBuilder.addHover(hover);
|
textBuilder.addHover(hover);
|
||||||
}
|
}
|
@@ -3,18 +3,18 @@ package net.t2code.t2codelib.SPIGOT.api.messages;
|
|||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
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.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class T2CminiMessage {
|
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) {
|
public static void sendSenderMiniMessage(String msg, CommandSender sender) {
|
||||||
String string = "";
|
String string = "";
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
string =T2Creplace.replace("",player,msg);
|
string = T2C_Replace.replace("",player,msg);
|
||||||
} else string = msg;
|
} else string = msg;
|
||||||
bukkitAudiences.sender(sender).sendMessage(replace(string));
|
bukkitAudiences.sender(sender).sendMessage(replace(string));
|
||||||
}
|
}
|
||||||
@@ -24,10 +24,15 @@ public class T2CminiMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPlayerMiniMessage(String msg, Player player) {
|
public static void sendPlayerMiniMessage(String msg, Player player) {
|
||||||
bukkitAudiences.player(player).sendMessage(replace(T2Creplace.replace("", player, msg)));
|
bukkitAudiences.player(player).sendMessage(replace(T2C_Replace.replace("", player, msg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Component replace(String text) {
|
protected static Component replace(String text) {
|
||||||
return MiniMessage.miniMessage().deserialize(T2Creplace.convertColorCode(text));
|
return MiniMessage.miniMessage().deserialize(T2C_Replace.convertColorCode(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String removeMiniMessageCodes(String text){
|
||||||
|
return MiniMessage.miniMessage().stripTags(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,14 +1,15 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.messages;
|
package net.t2code.t2codelib.SPIGOT.api.messages;
|
||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
import net.t2code.t2codelib.SPIGOT.api.plugins.T2C_PluginCheck;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class T2Creplace {
|
public class T2C_Replace {
|
||||||
|
|
||||||
public static String replace(String prefix, String Text) {
|
public static String replace(String prefix, String Text) {
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ public class T2Creplace {
|
|||||||
.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");
|
||||||
if (T2CpluginCheck.papi()) {
|
if (T2C_PluginCheck.papi()) {
|
||||||
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input));
|
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input));
|
||||||
} else {
|
} else {
|
||||||
return replaceLegacyColor(input);
|
return replaceLegacyColor(input);
|
||||||
@@ -54,7 +55,7 @@ public class T2Creplace {
|
|||||||
public static Object replaceObject(String prefix, Player player, Object object) {
|
public static Object replaceObject(String prefix, Player player, Object object) {
|
||||||
if (object instanceof String) {
|
if (object instanceof String) {
|
||||||
|
|
||||||
if (T2CpluginCheck.papi()) {
|
if (T2C_PluginCheck.papi()) {
|
||||||
object = PlaceholderAPI.setPlaceholders(player, replaceLegacyColor((String) object).replace("[prefix]", prefix).replace("[ue]", "ü")
|
object = PlaceholderAPI.setPlaceholders(player, replaceLegacyColor((String) object).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"));
|
||||||
@@ -69,7 +70,7 @@ public class T2Creplace {
|
|||||||
List<String> in = (List<String>) object;
|
List<String> in = (List<String>) object;
|
||||||
List<String> output = new ArrayList<>();
|
List<String> output = new ArrayList<>();
|
||||||
for (String input : in) {
|
for (String input : in) {
|
||||||
if (T2CpluginCheck.papi()) {
|
if (T2C_PluginCheck.papi()) {
|
||||||
output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix)
|
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]", "Ä")
|
||||||
@@ -106,7 +107,7 @@ public class T2Creplace {
|
|||||||
return Collections.singletonList("Text is null");
|
return Collections.singletonList("Text is null");
|
||||||
}
|
}
|
||||||
for (String input : Text) {
|
for (String input : Text) {
|
||||||
if (T2CpluginCheck.papi()) {
|
if (T2C_PluginCheck.papi()) {
|
||||||
output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix)
|
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]", "Ä")
|
||||||
@@ -149,7 +150,7 @@ public class T2Creplace {
|
|||||||
.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));
|
||||||
if (T2CpluginCheck.papi()) {
|
if (T2C_PluginCheck.papi()) {
|
||||||
rp.add(replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input)));
|
rp.add(replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input)));
|
||||||
} else {
|
} else {
|
||||||
rp.add(replaceLegacyColor(input));
|
rp.add(replaceLegacyColor(input));
|
||||||
@@ -171,7 +172,7 @@ public class T2Creplace {
|
|||||||
.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");
|
||||||
if (T2CpluginCheck.papi()) {
|
if (T2C_PluginCheck.papi()) {
|
||||||
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input));
|
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input));
|
||||||
} else {
|
} else {
|
||||||
return replaceLegacyColor(input);
|
return replaceLegacyColor(input);
|
@@ -0,0 +1,141 @@
|
|||||||
|
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;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class T2C_Send {
|
||||||
|
|
||||||
|
public static void sendStartTextCenter(String prefix, String text, boolean isReload) {
|
||||||
|
if (isReload) {
|
||||||
|
console(prefix + " " + text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console(T2C_GenerateFrame.setCenterAligned(prefix, text));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendStartTextLeft(String prefix, String text, boolean isReload) {
|
||||||
|
if (isReload) {
|
||||||
|
console(prefix + " " + text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console(T2C_GenerateFrame.setLeftAligned(prefix, text));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getFrameCenter(String prefix, boolean console, String... lines) {
|
||||||
|
return T2C_GenerateFrame.getFrameCenter(prefix, console, 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 console(String msg) {
|
||||||
|
if (msg == null || msg.contains("[empty]")) return;
|
||||||
|
T2C_HoverModule.moduleConsole(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void player(Player player, String msg) {
|
||||||
|
if (msg == null || msg.contains("[empty]")) return;
|
||||||
|
T2C_HoverModule.modulePlayer(msg, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sender(CommandSender sender, String msg) {
|
||||||
|
if (msg == null || msg.contains("[empty]")) return;
|
||||||
|
T2C_HoverModule.moduleSender(msg, sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void console(Object 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)) {
|
||||||
|
if (msg == null || msg.contains("[empty]")) continue;
|
||||||
|
T2C_HoverModule.modulePlayer(msg, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void sender(CommandSender sender, Object object) {
|
||||||
|
for (String msg : list(object)) {
|
||||||
|
if (msg == null || msg.contains("[empty]")) return;
|
||||||
|
T2C_HoverModule.moduleSender(msg, sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void title(Player player, @Nullable String title, @Nullable String subtitle) {
|
||||||
|
player.sendTitle(title, subtitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void title(Player player, @Nullable String title, @Nullable String subtitle, int fadeIn, int stay, int fadeOut) {
|
||||||
|
player.sendTitle(title, subtitle, fadeIn, stay, fadeOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This method will be removed soon, as the debug messages have been moved to a separate class.
|
||||||
|
* Please use the new method {@link T2C_Debug#debug(Plugin, String)} or {@link T2C_Debug#debug(Plugin, String, Integer)}
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static void debug(Plugin plugin, String msg) {
|
||||||
|
debug(plugin, msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This method will be removed soon, as the debug messages have been moved to a separate class.
|
||||||
|
* Please use the new method {@link T2C_Debug#debug(Plugin, String)} or {@link T2C_Debug#debug(Plugin, String, Integer)}
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static void debug(Plugin plugin, String msg, Integer stage) {
|
||||||
|
// if (!new File(Main.getPath(), "config.yml").exists()) return;
|
||||||
|
T2C_Debug.debug(plugin, msg, stage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This method will be removed soon, as the debug messages have been moved to a separate class.
|
||||||
|
* Please use the new method {@link T2C_Debug#debugmsg(Plugin, String)}
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static void debugmsg(Plugin plugin, String msg) {
|
||||||
|
T2C_Debug.debugmsg(plugin, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void info(Plugin plugin, String msg) {
|
||||||
|
plugin.getLogger().log(Level.INFO, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void warning(Plugin plugin, String msg) {
|
||||||
|
plugin.getLogger().log(Level.WARNING, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void error(Plugin plugin, String msg) {
|
||||||
|
plugin.getLogger().log(Level.SEVERE, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ArrayList<String> list(Object object) {
|
||||||
|
ArrayList<String> list = new ArrayList<>();
|
||||||
|
|
||||||
|
if (object instanceof List) {
|
||||||
|
list = (ArrayList<String>) object;
|
||||||
|
}
|
||||||
|
if (object instanceof String) {
|
||||||
|
list.add((String) object);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,137 @@
|
|||||||
|
package net.t2code.t2codelib.SPIGOT.api.messages;
|
||||||
|
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
|
||||||
|
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;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class T2C_Template {
|
||||||
|
|
||||||
|
|
||||||
|
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord) {
|
||||||
|
return onLoadHeader(prefix, autor, version, spigot, discord, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium, Boolean isVerify) {
|
||||||
|
Long long_ = System.currentTimeMillis();
|
||||||
|
|
||||||
|
for (String s : 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);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§2Spigot: §6" + spigot, false);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§2Discord: §6" + discord, false);
|
||||||
|
if (isPremium != null) {
|
||||||
|
if (isPremium) {
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§6Premium: §2true", false);
|
||||||
|
} else T2C_Send.sendStartTextCenter(prefix, "§6Premium: §4false", false);
|
||||||
|
if (isVerify != null) {
|
||||||
|
if (isVerify) {
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§6Verify: §2true", false);
|
||||||
|
} else T2C_Send.sendStartTextCenter(prefix, "§6Verify: §4false", false);
|
||||||
|
} else T2C_Send.sendStartTextCenter(prefix, "§6Verify: §4false", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoadSeparateStroke(prefix);
|
||||||
|
if (version.toLowerCase().contains("dev") || version.toLowerCase().contains("snapshot") || version.toLowerCase().contains("beta")) {
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", false);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", false);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§eYou are running §4" + version + " §eof §4" + prefix + "§e!", false);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§eSome features may not be working as expected.", false);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§ePlease report all bugs here: http://dc.t2code.net", false);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§4UpdateChecker & bStats may be disabled!", false);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", false);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", false);
|
||||||
|
onLoadSeparateStroke(prefix);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(2000);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return long_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onLoadSeparateStroke(String prefix) {
|
||||||
|
T2C_Send.console(prefix + " " + 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 + " " + T2C_GenerateFrame.getCOLOR_CODE() + T2C_GenerateFrame.getBOTTOM_BORDER());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onDisable(String prefix, Plugin plugin) {
|
||||||
|
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) {
|
||||||
|
String pluginVersion = plugin.getDescription().getVersion();
|
||||||
|
String publicVersion = "";
|
||||||
|
boolean update;
|
||||||
|
String stNVersion;
|
||||||
|
T2C_UpdateWebData webData;
|
||||||
|
try {
|
||||||
|
webData = T2C_UpdateAPI.pluginVersions.get(plugin.getName()).webData;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
webData = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (webData != null) {
|
||||||
|
publicVersion = T2C_UpdateAPI.pluginVersions.get(plugin.getName()).webData.getVersion();
|
||||||
|
update = !publicVersion.equalsIgnoreCase(pluginVersion);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
update = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean player = sender instanceof Player;
|
||||||
|
String stPlugin = "<dark_red>║</dark_red> <yellow>Plugin:</yellow> <gold>[pl]</gold>".replace("[pl]", plugin.getName());
|
||||||
|
String stVersion = "<dark_red>║</dark_red> <yellow>Version:</yellow> <gold>[ver]</gold>".replace("[ver]", pluginVersion);
|
||||||
|
String stAutor = "<dark_red>║</dark_red> <yellow>Autor(s):</yellow> <gold>[autor]</gold>".replace("[autor]", plugin.getDescription().getAuthors().toString());
|
||||||
|
|
||||||
|
String stUpdate = "<dark_red>║</dark_red> <yellow>New version available:</yellow> [up]".replace("[up]", webData != null ? update ?
|
||||||
|
"<dark_green>YES</dark_green>" : "<red>no</red>" : "<b><dark_red>It could not be checked for updates!</dark_red></b>");
|
||||||
|
stNVersion = update ? "<br><dark_red>║</dark_red> <yellow>Newest Version:</yellow> <gold>[newVersion]</gold>".replace("[newVersion]", player ? "<hover:show_text:'<yellow>Click for the update information</yellow>'><click:run_command:'/t2code updateinfo " + plugin.getName() + "'>" + publicVersion + "</click></hover>" : publicVersion) : "";
|
||||||
|
String stLink = getString(spigotID, discord, player);
|
||||||
|
String pr = premiumVerified != null ? "<br><dark_red>║</dark_red> <yellow>Premium verified:</yellow> [pr]".replace("[pr]",
|
||||||
|
premiumVerified ? "<dark_green>YES</dark_green>" : "<red>NO</red>") : "";
|
||||||
|
|
||||||
|
String stMSG = text == null || text.isEmpty() ? "" : "<br><dark_red>║</dark_red> " + text;
|
||||||
|
T2C_Send.sender(sender, "<br><dark_red>╔════════════════════════════════</dark_red>"
|
||||||
|
+ "<br>" + stPlugin
|
||||||
|
+ "<br>" + stVersion
|
||||||
|
+ stMSG
|
||||||
|
+ "<br>" + stAutor
|
||||||
|
+ "<br>" + stUpdate
|
||||||
|
+ stNVersion
|
||||||
|
+ "<br>" + stLink
|
||||||
|
+ pr
|
||||||
|
+ "<br><dark_red>╚════════════════════════════════</dark_red>");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @NotNull String getString(int spigotID, String discord, boolean player) {
|
||||||
|
String stLinkPlayer = "<dark_red>║</dark_red> <yellow><hover:show_text:'<green>Go to the Spigot page</green>'><click:open_url:'[slink]'>Spigot</click></hover></yellow> "
|
||||||
|
.replace("[slink]", "https://www.spigotmc.org/resources/" + spigotID)
|
||||||
|
+ "<dark_red>-</dark_red> <dark_purple><hover:show_text:'<green>Go to the T2Code Support Discord</green>'><click:open_url:'[dlink]'>Discord</click></hover></dark_purple>"
|
||||||
|
.replace("[dlink]", discord);
|
||||||
|
String stLinkConsole = "<dark_red>║</dark_red> <yellow>Spigot:</yellow> <gold>https://www.spigotmc.org/resources/" + spigotID + "</gold>"
|
||||||
|
+ "<br><dark_red>║</dark_red> <yellow>Discord:</yellow> <gold>" + discord + "</gold>";
|
||||||
|
return player ? stLinkPlayer : stLinkConsole;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, String text) {
|
||||||
|
sendInfo(sender, plugin, spigotID, discord, null, text);
|
||||||
|
}
|
||||||
|
}
|
@@ -5,23 +5,23 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
|
|||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
|
||||||
public class T2CtextBuilder {
|
public class T2C_TextBuilder {
|
||||||
|
|
||||||
private final String text;
|
private final String text;
|
||||||
private String hover;
|
private String hover;
|
||||||
private String click;
|
private String click;
|
||||||
private ClickEvent.Action action;
|
private ClickEvent.Action action;
|
||||||
|
|
||||||
public T2CtextBuilder(String text) {
|
public T2C_TextBuilder(String text) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T2CtextBuilder addHover(String hover) {
|
public T2C_TextBuilder addHover(String hover) {
|
||||||
this.hover = hover;
|
this.hover = hover;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T2CtextBuilder addClickEvent(ClickEvent.Action clickEventAction, String value) {
|
public T2C_TextBuilder addClickEvent(ClickEvent.Action clickEventAction, String value) {
|
||||||
this.action = clickEventAction;
|
this.action = clickEventAction;
|
||||||
this.click = value;
|
this.click = value;
|
||||||
return this;
|
return this;
|
@@ -1,97 +0,0 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.messages;
|
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class T2Csend {
|
|
||||||
|
|
||||||
public static void console(String msg) {
|
|
||||||
if (msg == null || msg.contains("[empty]")) return;
|
|
||||||
T2ChoverModule.moduleConsole(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void player(Player player, String msg) {
|
|
||||||
if (msg == null || msg.contains("[empty]")) return;
|
|
||||||
T2ChoverModule.modulePlayer(msg, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sender(CommandSender sender, String msg) {
|
|
||||||
if (msg == null || msg.contains("[empty]")) return;
|
|
||||||
T2ChoverModule.moduleSender(msg, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void console(Object object) {
|
|
||||||
for (String msg : list(object)){
|
|
||||||
if (msg == null || msg.contains("[empty]")) continue;
|
|
||||||
T2ChoverModule.moduleConsole(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void player(Player player, Object object) {
|
|
||||||
for (String msg : list(object)){
|
|
||||||
if (msg == null || msg.contains("[empty]")) continue;
|
|
||||||
T2ChoverModule.modulePlayer(msg, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void sender(CommandSender sender, Object object) {
|
|
||||||
for (String msg : list(object)){
|
|
||||||
if (msg == null || msg.contains("[empty]")) return;
|
|
||||||
T2ChoverModule.moduleSender(msg, sender);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void title(Player player, @Nullable String title, @Nullable String subtitle) {
|
|
||||||
player.sendTitle(title, subtitle);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void title(Player player, @Nullable String title, @Nullable String subtitle, int fadeIn, int stay, int fadeOut) {
|
|
||||||
player.sendTitle(title, subtitle, fadeIn, stay, fadeOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void debug(Plugin plugin, String msg) {
|
|
||||||
debug(plugin, msg, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void debug(Plugin plugin, String msg, Integer stage) {
|
|
||||||
// if (!new File(Main.getPath(), "config.yml").exists()) return;
|
|
||||||
T2Cdebug.debug(plugin, msg, stage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void debugmsg(Plugin plugin, String msg) {
|
|
||||||
T2Cdebug.debugmsg(plugin, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void info(Plugin plugin, String msg) {
|
|
||||||
plugin.getLogger().log(Level.INFO, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void warning(Plugin plugin, String msg) {
|
|
||||||
plugin.getLogger().log(Level.WARNING, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void error(Plugin plugin, String msg) {
|
|
||||||
plugin.getLogger().log(Level.SEVERE, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ArrayList<String> list(Object object){
|
|
||||||
ArrayList<String> list = new ArrayList<>();
|
|
||||||
|
|
||||||
if (object instanceof List){
|
|
||||||
list= (ArrayList<String>) object;
|
|
||||||
}
|
|
||||||
if (object instanceof String){
|
|
||||||
list.add((String) object);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,164 +0,0 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.messages;
|
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
|
||||||
import net.t2code.t2codelib.T2CupdateWebData;
|
|
||||||
import net.t2code.t2codelib.UpdateType;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class T2Ctemplate {
|
|
||||||
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord) {
|
|
||||||
return onLoadHeader(prefix, autor, version, spigot, discord, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium) {
|
|
||||||
return onLoadHeader(prefix, autor, version, spigot, discord, isPremium, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium, Boolean isVerify) {
|
|
||||||
Long long_ = System.currentTimeMillis();
|
|
||||||
T2Csend.console(prefix + " <dark_red> _______ </dark_red><gray>___ </gray><dark_red>_____ </dark_red>");
|
|
||||||
T2Csend.console(prefix + " <dark_red> |__ __|</dark_red><gray>__ \\ </gray><dark_red>/ ____|</dark_red>");
|
|
||||||
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray> ) </gray><dark_red>| | </dark_red>");
|
|
||||||
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray> / /</gray><dark_red>| | </dark_red>");
|
|
||||||
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray>/ /_</gray><dark_red>| |____ </dark_red>");
|
|
||||||
T2Csend.console(prefix + " <dark_red> |_| </dark_red><gray>|____|</gray><dark_red>\\_____|</dark_red>");
|
|
||||||
T2Csend.console(prefix + " §4 §e╔══════════════════════════");
|
|
||||||
T2Csend.console(prefix + " §4 §e║ §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
|
|
||||||
T2Csend.console(prefix + " §4 §e║ §2Version: §6" + version);
|
|
||||||
T2Csend.console(prefix + " §4 §e║ §2Spigot: §6" + spigot);
|
|
||||||
T2Csend.console(prefix + " §4 §e║ §2Discord: §6" + discord);
|
|
||||||
if (isPremium != null) {
|
|
||||||
if (isPremium) {
|
|
||||||
T2Csend.console(prefix + " §4 §e║ §6Premium: §2true");
|
|
||||||
} else T2Csend.console(prefix + " §4 §e║ §6Premium: §4false");
|
|
||||||
if (isVerify != null) {
|
|
||||||
if (isVerify) {
|
|
||||||
T2Csend.console(prefix + " §4 §e║ §6Verify: §2true");
|
|
||||||
} else T2Csend.console(prefix + " §4 §e║ §6Verify: §4false");
|
|
||||||
} else T2Csend.console(prefix + " §4 §e║ §6Verify: §4false");
|
|
||||||
}
|
|
||||||
|
|
||||||
T2Csend.console(prefix + " §4 §e╚══════════════════════════");
|
|
||||||
if (version.toLowerCase().contains("dev") || version.toLowerCase().contains("snapshot") || version.toLowerCase().contains("beta")) {
|
|
||||||
T2Csend.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! Some features may not be working as expected. Please report all" +
|
|
||||||
" bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled!");
|
|
||||||
onLoadSeparateStroke(prefix);
|
|
||||||
if (!SelectLibConfig.getT2cTestDevelopment()) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(5000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return long_;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Long onLoadHeader(String prefix) {
|
|
||||||
Long long_ = System.currentTimeMillis();
|
|
||||||
T2Csend.console(prefix + "§4===================== " + prefix + " §4=====================");
|
|
||||||
return long_;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onLoadSeparateStroke(String prefix) {
|
|
||||||
T2Csend.console(prefix + " §8-------------------------------");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onLoadFooter(String prefix, Long long_, String v) {
|
|
||||||
onLoadFooter(prefix, long_);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onLoadFooter(String prefix, Long long_) {
|
|
||||||
onLoadSeparateStroke(prefix);
|
|
||||||
T2Csend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param prefix
|
|
||||||
* @param autor
|
|
||||||
* @param spigot
|
|
||||||
* @param discord
|
|
||||||
* @deprecated reason this method is deprecated <br/>
|
|
||||||
* {will be removed in next version} <br/>
|
|
||||||
* use {@link #onDisable(String, Plugin)} instead like this:
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* <blockquote><pre>
|
|
||||||
* onDisable(getPlugin())
|
|
||||||
* </pre></blockquote>
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static void onDisable(String prefix, List<String> autor, String version, String spigot, String discord) {
|
|
||||||
T2Csend.console(prefix + " §2Version: §6" + version);
|
|
||||||
T2Csend.console(prefix + " §4Plugin successfully disabled.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onDisable(String prefix, Plugin plugin) {
|
|
||||||
T2Csend.console(prefix + " §4 §e╔══════════════════════════");
|
|
||||||
T2Csend.console(prefix + " §4 §e║ §2Version: §6" + plugin.getDescription().getVersion());
|
|
||||||
T2Csend.console(prefix + " §4 §e║ §2Autors: §6" + plugin.getDescription().getAuthors());
|
|
||||||
T2Csend.console(prefix + " §4 §e║ §4Plugin successfully disabled.");
|
|
||||||
T2Csend.console(prefix + " §4 §e╚══════════════════════════");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, Boolean premiumVerified, String text) {
|
|
||||||
String pluginVersion = plugin.getDescription().getVersion();
|
|
||||||
String publicVersion = "";
|
|
||||||
boolean update;
|
|
||||||
String stNVersion;
|
|
||||||
T2CupdateWebData webData;
|
|
||||||
try {
|
|
||||||
webData = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData;
|
|
||||||
} catch (Exception ex) {
|
|
||||||
webData = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (webData != null) {
|
|
||||||
publicVersion = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData.getVersion();
|
|
||||||
update = !publicVersion.equalsIgnoreCase(pluginVersion);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
update = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean player = sender instanceof Player;
|
|
||||||
String stPlugin = "<dark_red>║</dark_red> <yellow>Plugin:</yellow> <gold>[pl]</gold>".replace("[pl]", plugin.getName());
|
|
||||||
String stVersion = "<dark_red>║</dark_red> <yellow>Version:</yellow> <gold>[ver]</gold>".replace("[ver]", pluginVersion);
|
|
||||||
String stAutor = "<dark_red>║</dark_red> <yellow>Autor(s):</yellow> <gold>[autor]</gold>".replace("[autor]", plugin.getDescription().getAuthors().toString());
|
|
||||||
|
|
||||||
String stUpdate = "<dark_red>║</dark_red> <yellow>New version available:</yellow> [up]".replace("[up]", webData != null ? update ?
|
|
||||||
"<dark_green>YES</dark_green>" : "<red>no</red>" : "<b><dark_red>It could not be checked for updates!</dark_red></b>");
|
|
||||||
stNVersion = update ? "<br><dark_red>║</dark_red> <yellow>Newest Version:</yellow> <gold>[nver]</gold>".replace("[nver]",player ? "<hover:show_text:'<yellow>Click for the update information</yellow>'><click:run_command:'/t2code updateinfo "+plugin.getName()+"'>"+publicVersion+"</click></hover>":publicVersion) : "";
|
|
||||||
String stLinkPlayer = "<dark_red>║</dark_red> <yellow><hover:show_text:'<green>Go to the Spigot page</green>'><click:open_url:'[slink]'>Spigot</click></hover></yellow> "
|
|
||||||
.replace("[slink]", "https://www.spigotmc.org/resources/" + spigotID)
|
|
||||||
+ "<dark_red>-</dark_red> <dark_purple><hover:show_text:'<green>Go to the T2Code Support Discord</green>'><click:open_url:'[dlink]'>Discord</click></hover></dark_purple>"
|
|
||||||
.replace("[dlink]", discord);
|
|
||||||
String stLinkConsole = "<dark_red>║</dark_red> <yellow>Spigot:</yellow> <gold>https://www.spigotmc.org/resources/" + spigotID + "</gold>"
|
|
||||||
+ "<br><dark_red>║</dark_red> <yellow>Discord:</yellow> <gold>" + discord + "</gold>";
|
|
||||||
String stLink = player ? stLinkPlayer : stLinkConsole;
|
|
||||||
String pr = premiumVerified != null ? "<br><dark_red>║</dark_red> <yellow>Premium verified:</yellow> [pr]".replace("[pr]",
|
|
||||||
premiumVerified ? "<dark_green>YES</dark_green>" : "<red>NO</red>") : "";
|
|
||||||
|
|
||||||
String stMSG = text == null || text.equals("") ? "" : "<br><dark_red>║</dark_red> " + text;
|
|
||||||
T2Csend.sender(sender, "<br><dark_red>╔════════════════════════════════</dark_red>"
|
|
||||||
+ "<br>" + stPlugin
|
|
||||||
+ "<br>" + stVersion
|
|
||||||
+ stMSG
|
|
||||||
+ "<br>" + stAutor
|
|
||||||
+ "<br>" + stUpdate
|
|
||||||
+ stNVersion
|
|
||||||
+ "<br>" + stLink
|
|
||||||
+ pr
|
|
||||||
+ "<br><dark_red>╚════════════════════════════════</dark_red>");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, String text) {
|
|
||||||
sendInfo(sender, plugin, spigotID, discord, null, text);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,21 +1,19 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
|
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
|
||||||
public class T2CmcVersion {
|
public class T2C_McVersion {
|
||||||
|
|
||||||
|
|
||||||
public static void onCheck() {
|
public static void onCheck() {
|
||||||
mcVersion = Bukkit.getServer().getVersion();
|
mcVersion = Bukkit.getServer().getVersion();
|
||||||
bukkitVersion = Bukkit.getServer().getBukkitVersion();
|
bukkitVersion = Bukkit.getServer().getBukkitVersion();
|
||||||
T2CnmsVersions.init();
|
T2C_NmsVersions.init();
|
||||||
nms = String.valueOf(T2CnmsVersions.getT2CnmsEnum());
|
nms = String.valueOf(T2C_NmsVersions.getT2CnmsEnum());
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "mcVersion: " + mcVersion);
|
// T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "mcVersion: " + mcVersion);
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "bukkitVersion: " + bukkitVersion);
|
// T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "bukkitVersion: " + bukkitVersion);
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "nms: " + nms);
|
// T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "nms: " + nms);
|
||||||
|
|
||||||
mc1_8 = mcVersion.contains("MC: 1.8");
|
mc1_8 = mcVersion.contains("MC: 1.8");
|
||||||
mc1_9 = mcVersion.contains("MC: 1.9");
|
mc1_9 = mcVersion.contains("MC: 1.9");
|
||||||
@@ -31,6 +29,7 @@ public class T2CmcVersion {
|
|||||||
mc1_19 = mcVersion.contains("MC: 1.19");
|
mc1_19 = mcVersion.contains("MC: 1.19");
|
||||||
mc1_20 = mcVersion.contains("MC: 1.20");
|
mc1_20 = mcVersion.contains("MC: 1.20");
|
||||||
mc1_21 = mcVersion.contains("MC: 1.21");
|
mc1_21 = mcVersion.contains("MC: 1.21");
|
||||||
|
mc1_22 = mcVersion.contains("MC: 1.22");
|
||||||
|
|
||||||
nms1_8_R1 = nms.contains("1_8_R1");
|
nms1_8_R1 = nms.contains("1_8_R1");
|
||||||
nms1_8_R2 = nms.contains("1_8_R2");
|
nms1_8_R2 = nms.contains("1_8_R2");
|
||||||
@@ -57,6 +56,7 @@ public class T2CmcVersion {
|
|||||||
nms1_20_R3 = nms.contains("1_20_R3");
|
nms1_20_R3 = nms.contains("1_20_R3");
|
||||||
nms1_20_R4 = nms.contains("1_20_R4");
|
nms1_20_R4 = nms.contains("1_20_R4");
|
||||||
nms1_21_R1 = nms.contains("1_21_R1");
|
nms1_21_R1 = nms.contains("1_21_R1");
|
||||||
|
nms1_21_R2 = nms.contains("1_21_R2");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String mcVersion;
|
private static String mcVersion;
|
||||||
@@ -75,6 +75,7 @@ public class T2CmcVersion {
|
|||||||
private static boolean mc1_19;
|
private static boolean mc1_19;
|
||||||
private static boolean mc1_20;
|
private static boolean mc1_20;
|
||||||
private static boolean mc1_21;
|
private static boolean mc1_21;
|
||||||
|
private static boolean mc1_22;
|
||||||
|
|
||||||
private static String nms;
|
private static String nms;
|
||||||
private static boolean nms1_8_R1;
|
private static boolean nms1_8_R1;
|
||||||
@@ -102,6 +103,7 @@ public class T2CmcVersion {
|
|||||||
private static boolean nms1_20_R3;
|
private static boolean nms1_20_R3;
|
||||||
private static boolean nms1_20_R4;
|
private static boolean nms1_20_R4;
|
||||||
private static boolean nms1_21_R1;
|
private static boolean nms1_21_R1;
|
||||||
|
private static boolean nms1_21_R2;
|
||||||
|
|
||||||
public static String getMcVersion() {
|
public static String getMcVersion() {
|
||||||
return mcVersion;
|
return mcVersion;
|
||||||
@@ -167,6 +169,10 @@ public class T2CmcVersion {
|
|||||||
return mc1_21;
|
return mc1_21;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isMc1_22() {
|
||||||
|
return mc1_22;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getNms() {
|
public static String getNms() {
|
||||||
return nms;
|
return nms;
|
||||||
}
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
|
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
|
||||||
|
|
||||||
public enum T2CnmsEnum {
|
public enum T2C_NmsEnum {
|
||||||
not_support,
|
not_support,
|
||||||
v1_8_R1,
|
v1_8_R1,
|
||||||
v1_8_R2,
|
v1_8_R2,
|
||||||
@@ -28,4 +28,5 @@ public enum T2CnmsEnum {
|
|||||||
v1_20_R3,
|
v1_20_R3,
|
||||||
v1_20_R4,
|
v1_20_R4,
|
||||||
v1_21_R1,
|
v1_21_R1,
|
||||||
|
v1_21_R2,
|
||||||
}
|
}
|
@@ -0,0 +1,100 @@
|
|||||||
|
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
|
||||||
|
public class T2C_NmsVersions {
|
||||||
|
|
||||||
|
public static Class minecraftServerClass;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static T2C_NmsEnum t2CnmsEnum;
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
String mc = T2C_McVersion.getMcVersion();
|
||||||
|
|
||||||
|
if (mc.contains("(MC: 1.8)") || mc.contains("(MC: 1.8.1)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_8_R1;
|
||||||
|
} else if (mc.contains("(MC: 1.8.3)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_8_R2;
|
||||||
|
} else if (mc.contains("(MC: 1.8.4)") || mc.contains("(MC: 1.8.5)") || mc.contains("(MC: 1.8.6)") || mc.contains("(MC: 1.8.7)") || mc.contains("(MC: 1.8.8)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_8_R3;
|
||||||
|
} else if (mc.contains("(MC: 1.9)") || mc.contains("(MC: 1.9.2)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_9_R1;
|
||||||
|
} else if (mc.contains("(MC: 1.9.3)") || mc.contains("(MC: 1.9.4)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_9_R2;
|
||||||
|
} else if (mc.contains("(MC: 1.10")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_10_R1;
|
||||||
|
} else if (mc.contains("(MC: 1.11")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_11_R1;
|
||||||
|
} else if (mc.contains("(MC: 1.12")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_12_R1;
|
||||||
|
} else if (mc.contains("(MC: 1.13)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_13_R1;
|
||||||
|
} else if (mc.contains("(MC: 1.13.1)") || mc.contains("(MC: 1.13.2)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_13_R2;
|
||||||
|
} else if (mc.contains("(MC: 1.14")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_14_R1;
|
||||||
|
} else if (mc.contains("(MC: 1.15")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_15_R1;
|
||||||
|
} else if (mc.contains("(MC: 1.16)") || mc.contains("(MC: 1.16.1)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_16_R1;
|
||||||
|
} else if (mc.contains("(MC: 1.16.2)") || mc.contains("(MC: 1.16.3)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_16_R2;
|
||||||
|
} else if (mc.contains("(MC: 1.16.4)") || mc.contains("(MC: 1.16.5)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_16_R3;
|
||||||
|
} else if (mc.contains("(MC: 1.17")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_17_R1;
|
||||||
|
} else if (mc.contains("(MC: 1.18)") || mc.contains("(MC: 1.18.1)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_18_R1;
|
||||||
|
} else if (mc.contains("(MC: 1.18.2)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_18_R2;
|
||||||
|
} else if (mc.contains("(MC: 1.19)") || mc.contains("(MC: 1.19.1)") || mc.contains("(MC: 1.19.2)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_19_R1;
|
||||||
|
} else if (mc.contains("(MC: 1.19.3)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_19_R2;
|
||||||
|
} else if (mc.contains("(MC: 1.19.4)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_19_R3;
|
||||||
|
} else if (mc.contains("(MC: 1.20)") || mc.contains("(MC: 1.20.1)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_20_R1;
|
||||||
|
} else if (mc.contains("(MC: 1.20.2)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_20_R2;
|
||||||
|
} else if (mc.contains("(MC: 1.20.3)") || mc.contains("(MC: 1.20.4)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_20_R3;
|
||||||
|
} else if (mc.contains("(MC: 1.20.6)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_20_R4;
|
||||||
|
} else if (mc.contains("(MC: 1.21)")) {
|
||||||
|
t2CnmsEnum = T2C_NmsEnum.v1_21_R1;
|
||||||
|
} else t2CnmsEnum = T2C_NmsEnum.not_support;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// public static void init() {
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// // List<String> list= Arrays.stream(Class .getPackages()).map(Package::getName).filter(n -> n.startsWith("net.minecraft.server")).collect(Collectors.toList());
|
||||||
|
//
|
||||||
|
// // for (String s : list){
|
||||||
|
// // T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(),s);
|
||||||
|
// //}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// for (T2CnmsEnum nmsEnum : T2CnmsEnum.values()) {
|
||||||
|
// try {
|
||||||
|
// minecraftServerClass = Class.forName("net.minecraft.server." + nmsEnum + ".MinecraftServer");
|
||||||
|
// } catch (ClassNotFoundException ignored) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (minecraftServerClass != null) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// // todo nicht kompatiebel
|
||||||
|
// T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "nicht kompa");
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
}
|
@@ -1,129 +0,0 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
|
||||||
|
|
||||||
|
|
||||||
public class T2CnmsVersions {
|
|
||||||
|
|
||||||
public static Class minecraftServerClass;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private static T2CnmsEnum t2CnmsEnum;
|
|
||||||
|
|
||||||
public static void init() {
|
|
||||||
String mc = T2CmcVersion.getMcVersion();
|
|
||||||
|
|
||||||
if (mc.contains("(MC: 1.8)") || mc.contains("(MC: 1.8.1)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_8_R1;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.8.3)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_8_R2;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.8.4)") || mc.contains("(MC: 1.8.5)") || mc.contains("(MC: 1.8.6)") || mc.contains("(MC: 1.8.7)") || mc.contains("(MC: 1.8.8)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_8_R3;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.9)") || mc.contains("(MC: 1.9.2)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_9_R1;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.9.3)") || mc.contains("(MC: 1.9.4)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_9_R2;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.10")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_10_R1;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.11")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_11_R1;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.12")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_12_R1;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.13)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_13_R1;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.13.1)") || mc.contains("(MC: 1.13.2)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_13_R2;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.14")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_14_R1;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.15")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_15_R1;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.16)") || mc.contains("(MC: 1.16.1)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_16_R1;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.16.2)") || mc.contains("(MC: 1.16.3)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_16_R2;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.16.4)") || mc.contains("(MC: 1.16.5)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_16_R3;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.17")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_17_R1;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.18)") || mc.contains("(MC: 1.18.1)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_18_R1;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.18.2)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_18_R2;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.19)") || mc.contains("(MC: 1.19.1)") || mc.contains("(MC: 1.19.2)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_19_R1;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.19.3)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_19_R2;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.19.4)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_19_R3;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.20)") || mc.contains("(MC: 1.20.1)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_20_R1;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.20.2)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_20_R2;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.20.3)") || mc.contains("(MC: 1.20.4)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_20_R3;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.20.6)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_20_R4;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else if (mc.contains("(MC: 1.21)")) {
|
|
||||||
t2CnmsEnum = T2CnmsEnum.v1_21_R1;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
} else t2CnmsEnum = T2CnmsEnum.not_support;
|
|
||||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// public static void init() {
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// // List<String> list= Arrays.stream(Class .getPackages()).map(Package::getName).filter(n -> n.startsWith("net.minecraft.server")).collect(Collectors.toList());
|
|
||||||
//
|
|
||||||
// // for (String s : list){
|
|
||||||
// // T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(),s);
|
|
||||||
// //}
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// for (T2CnmsEnum nmsEnum : T2CnmsEnum.values()) {
|
|
||||||
// try {
|
|
||||||
// minecraftServerClass = Class.forName("net.minecraft.server." + nmsEnum + ".MinecraftServer");
|
|
||||||
// } catch (ClassNotFoundException ignored) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (minecraftServerClass != null) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// // todo nicht kompatiebel
|
|
||||||
// T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "nicht kompa");
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
}
|
|
@@ -14,7 +14,7 @@ import java.util.Date;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class T2CnameHistory {
|
public class T2C_NameHistory {
|
||||||
public static class NameLookup {
|
public static class NameLookup {
|
||||||
|
|
||||||
/**
|
/**
|
@@ -1,12 +1,12 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.plugins;
|
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.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class T2CpluginCheck {
|
public class T2C_PluginCheck {
|
||||||
public static Boolean pluginCheck(String pluginName){
|
public static Boolean pluginCheck(String pluginName){
|
||||||
return Bukkit.getPluginManager().getPlugin(pluginName) != null;
|
return Bukkit.getPluginManager().getPlugin(pluginName) != null;
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ public class T2CpluginCheck {
|
|||||||
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
||||||
Bukkit.getConsoleSender().sendMessage(prefix + " §e" + pl + " §4could not be found. Please download it here: " +
|
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.");
|
"§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;
|
return true;
|
||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
@@ -0,0 +1,42 @@
|
|||||||
|
package net.t2code.t2codelib.SPIGOT.api.plugins;
|
||||||
|
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class T2C_PluginManager {
|
||||||
|
|
||||||
|
public static void restart(String plugin) {
|
||||||
|
if (Bukkit.getPluginManager().getPlugin(plugin) == null) return;
|
||||||
|
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;
|
||||||
|
T2C_Main.getPlugin().getPluginLoader().enablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void disable(String plugin) {
|
||||||
|
if (Bukkit.getPluginManager().getPlugin(plugin) == null) return;
|
||||||
|
T2C_Main.getPlugin().getPluginLoader().disablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void restart(Plugin plugin) {
|
||||||
|
if (plugin == null) return;
|
||||||
|
T2C_Main.getPlugin().getPluginLoader().disablePlugin(plugin);
|
||||||
|
T2C_Main.getPlugin().getPluginLoader().enablePlugin(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void enable(Plugin plugin) {
|
||||||
|
if (plugin == null) return;
|
||||||
|
T2C_Main.getPlugin().getPluginLoader().enablePlugin(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void disable(Plugin plugin) {
|
||||||
|
if (plugin == null) return;
|
||||||
|
T2C_Main.getPlugin().getPluginLoader().disablePlugin(plugin);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,42 +0,0 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.plugins;
|
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
|
||||||
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;
|
|
||||||
T2CodeLibMain.getPlugin().getPluginLoader().disablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)));
|
|
||||||
T2CodeLibMain.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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void disable(String plugin) {
|
|
||||||
if (Bukkit.getPluginManager().getPlugin(plugin) == null) return;
|
|
||||||
T2CodeLibMain.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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void enable(Plugin plugin) {
|
|
||||||
if (plugin == null) return;
|
|
||||||
T2CodeLibMain.getPlugin().getPluginLoader().enablePlugin(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void disable(Plugin plugin) {
|
|
||||||
if (plugin == null) return;
|
|
||||||
T2CodeLibMain.getPlugin().getPluginLoader().disablePlugin(plugin);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -6,7 +6,7 @@ import org.bukkit.permissions.Permission;
|
|||||||
import org.bukkit.permissions.PermissionDefault;
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class T2Cregister {
|
public class T2C_Register {
|
||||||
public static void listener(Listener listener, Plugin plugin) {
|
public static void listener(Listener listener, Plugin plugin) {
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(listener, plugin);
|
Bukkit.getServer().getPluginManager().registerEvents(listener, plugin);
|
||||||
}
|
}
|
@@ -0,0 +1,53 @@
|
|||||||
|
// This class was created by JaTiTV.
|
||||||
|
|
||||||
|
package net.t2code.t2codelib.SPIGOT.api.sound;
|
||||||
|
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.config.languages.T2CLibLanguages;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class T2C_Sound {
|
||||||
|
public static void playSound(Player player, String sound, int v, int v1) {
|
||||||
|
playSound(player, Sound.valueOf(sound), v, v1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void playSound(Player player, Sound sound, int v, int v1) {
|
||||||
|
player.playSound(player.getLocation(), sound, v, v1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Sound checkSound(String sound1_8, String sound1_9, String sound1_13, String selectSoundFromConfig, String prefix) {
|
||||||
|
String SOUND;
|
||||||
|
if (T2C_McVersion.isMc1_8()) {
|
||||||
|
SOUND = sound1_8;
|
||||||
|
} else if (T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) {
|
||||||
|
SOUND = sound1_9;
|
||||||
|
} else SOUND = sound1_13;
|
||||||
|
|
||||||
|
return checkSound(SOUND, selectSoundFromConfig, prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Sound checkSound(String sound1_8, String sound1_13, String selectSoundFromConfig, String prefix) {
|
||||||
|
String SOUND;
|
||||||
|
if (T2C_McVersion.isMc1_8()) {
|
||||||
|
SOUND = sound1_8;
|
||||||
|
} else SOUND = sound1_13;
|
||||||
|
|
||||||
|
return checkSound(SOUND, selectSoundFromConfig, prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Sound checkSound(String sound, String selectSoundFromConfig, String prefix) {
|
||||||
|
try {
|
||||||
|
return Sound.valueOf(selectSoundFromConfig);
|
||||||
|
} catch (Exception e) {
|
||||||
|
T2C_Send.console("§4\n§4\n§4\n" + T2CLibLanguages.VALUES.soundNotFound.getValue().toString().replace("[prefix]", prefix)
|
||||||
|
.replace("[sound]", "§8Buy: §6" + selectSoundFromConfig) + "§4\n§4\n§4\n");
|
||||||
|
return Sound.valueOf(sound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,12 +1,12 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.update;
|
package net.t2code.t2codelib.SPIGOT.api.update;
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||||
import net.t2code.t2codelib.UpdateType;
|
import net.t2code.t2codelib.util.T2C_UpdateType;
|
||||||
import net.t2code.t2codelib.T2CupdateObject;
|
import net.t2code.t2codelib.util.T2C_UpdateObject;
|
||||||
import net.t2code.t2codelib.T2CupdateWebData;
|
import net.t2code.t2codelib.util.T2C_UpdateWebData;
|
||||||
import net.t2code.t2codelib.Util;
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@@ -15,17 +15,12 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class T2CupdateAPI {
|
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) {
|
public static void join(Plugin plugin, String prefix, String perm, Player player, Integer spigotID, String discord) {
|
||||||
if (pluginVersions.get(plugin.getName()) == null) {
|
if (pluginVersions.get(plugin.getName()) == null) {
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().runTaskLaterAsynchronously(T2C_Main.getPlugin(), () -> join(plugin, prefix, perm, player, spigotID, discord), 2 * 20L);
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
join(plugin, prefix, perm, player, spigotID, discord);
|
|
||||||
}
|
|
||||||
}, 2 * 20L);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,22 +39,23 @@ public class T2CupdateAPI {
|
|||||||
}.runTaskLaterAsynchronously(plugin, 20L);
|
}.runTaskLaterAsynchronously(plugin, 20L);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
T2CupdateWebData webData = pluginVersions.get(plugin.getName()).webData;
|
T2C_UpdateWebData webData = pluginVersions.get(plugin.getName()).webData;
|
||||||
if (!pluginVersions.get(plugin.getName()).updateAvailable) return;
|
if (!pluginVersions.get(plugin.getName()).updateAvailable) return;
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
sendUpdateMsg(prefix, webData, discord, plugin, player);
|
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 publicVersion = webData.getVersion();
|
||||||
String pluginVersion = plugin.getDescription().getVersion();
|
String pluginVersion = plugin.getDescription().getVersion();
|
||||||
if (!pluginVersions.get(plugin.getName()).updateAvailable) {
|
if (!pluginVersions.get(plugin.getName()).updateAvailable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
String updateStatusVersion = getUpdateType(webData);
|
||||||
String st = "[prefix]<br>" +
|
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" +
|
"<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>" +
|
" found!</color></hover></click><br>" +
|
||||||
@@ -69,83 +65,40 @@ public class T2CupdateAPI {
|
|||||||
"[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] <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]";
|
"[prefix]";
|
||||||
|
|
||||||
String updateStatusVersion;
|
T2C_Send.player(player, st.replace("[prefix]", prefix).replace("[value]", updateStatusVersion).replace("[link]", webData.getUpdateUrl())
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
T2Csend.player(player, st.replace("[prefix]", prefix).replace("[value]", updateStatusVersion).replace("[link]", webData.getUpdateUrl())
|
|
||||||
.replace("[plv]", pluginVersion).replace("[puv]", publicVersion).replace("[dc]", discord));
|
.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 publicVersion = webData.getVersion();
|
||||||
String pluginVersion = plugin.getDescription().getVersion();
|
String pluginVersion = plugin.getDescription().getVersion();
|
||||||
String updateStatusVersion;
|
String updateStatusVersion = getUpdateType(webData);
|
||||||
if (webData.isPreRelease()) {
|
String s1 = "<color:#6e90ff>A new [value] version was found!</color>".replace("[value]", updateStatusVersion);
|
||||||
updateStatusVersion = UpdateType.PRERELEASE.text;
|
String s2 = "<color:#6e90ff>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</color> <green>" + webData.getVersion() + "</green>";
|
||||||
if (publicVersion.toLowerCase().contains("dev")) {
|
String s3 = "<color:#6e90ff>You can download it here:</color> <yellow>" + webData.getUpdateUrl() + "</yellow>";
|
||||||
updateStatusVersion = UpdateType.DEVELOPMENT.text;
|
String s4 = "<color:#6e90ff>You can find more information on Discord:</color> <yellow>" + discord + "</yellow>";
|
||||||
}
|
|
||||||
if (publicVersion.toLowerCase().contains("beta")) {
|
T2C_Send.console(T2C_Send.getFrameCenter(prefix, true, s1, s2, s3, s4));
|
||||||
updateStatusVersion = UpdateType.BETA.text;
|
|
||||||
}
|
|
||||||
if (publicVersion.toLowerCase().contains("snapshot")) {
|
|
||||||
updateStatusVersion = UpdateType.SNAPSHOT.text;
|
|
||||||
}
|
|
||||||
} else updateStatusVersion = UpdateType.STABLE.text;
|
|
||||||
String h = "<br><dark_red>╔══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
|
|
||||||
String s1 = "<br><dark_red>║</dark_red> <color:#6e90ff>A new [value] version was found!</color>".replace("[value]", updateStatusVersion);
|
|
||||||
String s2 = "<br><dark_red>║</dark_red> <color:#6e90ff>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</color> <green>" + webData.getVersion() + "</green>";
|
|
||||||
String s3 = "<br><dark_red>║</dark_red> <color:#6e90ff>You can download it here:</color> <yellow>" + webData.getUpdateUrl() + "</yellow>";
|
|
||||||
String s4 = "<br><dark_red>║</dark_red> <color:#6e90ff>You can find more information on Discord:</color> <yellow>" + discord + "</yellow>";
|
|
||||||
String f = "<br><dark_red>╚══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
|
|
||||||
String text = h + s1 + s2 + s3 + s4 + f;
|
|
||||||
T2Csend.console(text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String updateInfo(String[] args, Boolean player) {
|
public static String updateInfo(String[] args, Boolean player) {
|
||||||
T2CupdateObject object;
|
T2C_UpdateObject object;
|
||||||
try {
|
try {
|
||||||
object = T2CupdateAPI.pluginVersions.get(args[1]);
|
object = T2C_UpdateAPI.pluginVersions.get(args[1]);
|
||||||
} catch (Exception e) {
|
} 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>";
|
if (object == null) return T2C_Util.getPrefix() + " <red>The plugin <yellow>" + args[1] + "</yellow> is not registered in the update checker of T2Code!</red>";
|
||||||
T2CupdateWebData webData = object.webData;
|
T2C_UpdateWebData webData = object.webData;
|
||||||
if (webData == null) {
|
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 = T2CupdateAPI.pluginVersions.get(args[1]).pluginName;
|
String pluginName = T2C_UpdateAPI.pluginVersions.get(args[1]).pluginName;
|
||||||
String pluginVersion = T2CupdateAPI.pluginVersions.get(args[1]).pluginVersion;
|
String pluginVersion = T2C_UpdateAPI.pluginVersions.get(args[1]).pluginVersion;
|
||||||
|
|
||||||
String updateTitle = webData.getUpdateTitle();
|
String updateTitle = webData.getUpdateTitle();
|
||||||
String updateVersion = webData.getVersion();
|
String publicVersion = webData.getVersion();
|
||||||
String updateType;
|
String updateType = getUpdateType(webData);
|
||||||
|
|
||||||
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 updateAt = webData.getPublishedAt();
|
String updateAt = webData.getPublishedAt();
|
||||||
String updateUpdate = webData.getUpdateUrl();
|
String updateUpdate = webData.getUpdateUrl();
|
||||||
@@ -155,7 +108,7 @@ public class T2CupdateAPI {
|
|||||||
String pluginVersionString = "<br><dark_red>║</dark_red> <color:#6e90ff>Your version:</color> <color:#5eff89>" + pluginVersion + "</color>";
|
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 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 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 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>";
|
String updateTypeString = "<br><dark_red>║</dark_red> <color:#6e90ff>Version type:</color> <color:#5eff89>" + updateType + "</color>";
|
||||||
|
|
||||||
@@ -186,7 +139,25 @@ public class T2CupdateAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void onUpdateCheck(Plugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
|
public static void onUpdateCheck(Plugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
|
||||||
if (SelectLibConfig.getUpdateCheckFullDisable()) return;
|
if ((boolean) T2C_LibConfig.VALUES.updateCheckFullDisable.getValue()) return;
|
||||||
new T2CupdateCheckerGit((JavaPlugin) plugin, prefix, gitKey, spigotID, discord, updateCheckOnJoin, seePreReleaseUpdates, timeInterval);
|
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;
|
package net.t2code.t2codelib.SPIGOT.api.update;
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
import net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||||
import net.t2code.t2codelib.T2CupdateObject;
|
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||||
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.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@@ -15,16 +16,15 @@ import java.io.*;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class T2CupdateCheckerGit {
|
public class T2C_UpdateCheckerGit {
|
||||||
private final JavaPlugin plugin;
|
private final JavaPlugin plugin;
|
||||||
private T2CupdateObject t2CupdateObject;
|
private T2C_UpdateObject t2CupdateObject;
|
||||||
|
|
||||||
|
|
||||||
public T2CupdateCheckerGit(JavaPlugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
|
public T2C_UpdateCheckerGit(JavaPlugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1";
|
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1";
|
||||||
@@ -41,9 +41,9 @@ public class T2CupdateCheckerGit {
|
|||||||
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (SelectLibConfig.getUpdateCheckFullDisable()) return;
|
if ((boolean) T2C_LibConfig.VALUES.updateCheckFullDisable.getValue()) return;
|
||||||
getVersion((webData) -> {
|
getVersion((webData) -> {
|
||||||
T2CupdateObject update = new T2CupdateObject(
|
T2C_UpdateObject update = new T2C_UpdateObject(
|
||||||
plugin.getName(),
|
plugin.getName(),
|
||||||
plugin.getDescription().getVersion(),
|
plugin.getDescription().getVersion(),
|
||||||
webData,
|
webData,
|
||||||
@@ -52,24 +52,24 @@ public class T2CupdateCheckerGit {
|
|||||||
updateCheckOnJoin
|
updateCheckOnJoin
|
||||||
);
|
);
|
||||||
|
|
||||||
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
|
T2C_UpdateAPI.pluginVersions.put(plugin.getName(), update);
|
||||||
if (T2CupdateAPI.pluginVersions.get(plugin.getName()) == null){
|
if (T2C_UpdateAPI.pluginVersions.get(plugin.getName()) == null) {
|
||||||
T2Csend.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;
|
return;
|
||||||
}
|
}
|
||||||
if (T2CupdateAPI.pluginVersions.get(plugin.getName()).updateAvailable) {
|
if (T2C_UpdateAPI.pluginVersions.get(plugin.getName()).updateAvailable) {
|
||||||
if (!update.load) {
|
if (!update.load) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
update.load = true;
|
update.load = true;
|
||||||
T2CupdateAPI.sendUpdateMsg(prefix, discord, webData, plugin);
|
T2C_UpdateAPI.sendUpdateMsg(prefix, discord, webData, plugin);
|
||||||
}
|
}
|
||||||
}.runTaskLaterAsynchronously(plugin, 600L);
|
}.runTaskLaterAsynchronously(plugin, 600L);
|
||||||
} else T2CupdateAPI.sendUpdateMsg(prefix, discord, webData, plugin);
|
} else T2C_UpdateAPI.sendUpdateMsg(prefix, discord, webData, plugin);
|
||||||
} else {
|
} else {
|
||||||
if (!update.load) {
|
if (!update.load) {
|
||||||
T2Csend.console(prefix + " §2No update found.");
|
T2C_Send.console(prefix + " §e║ " + "§2No update found.");
|
||||||
update.load = true;
|
update.load = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ public class T2CupdateCheckerGit {
|
|||||||
}, 10L, finalInterval * 60 * 20L);
|
}, 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()) {
|
if (!plugin.isEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -129,14 +129,14 @@ public class T2CupdateCheckerGit {
|
|||||||
updateUrl = "https://www.spigotmc.org/resources/" + spigotID;
|
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);
|
consumer.accept(webData);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
Boolean load = false;
|
Boolean load = false;
|
||||||
if (T2CupdateAPI.pluginVersions.containsKey(plugin.getName())) {
|
if (T2C_UpdateAPI.pluginVersions.containsKey(plugin.getName())) {
|
||||||
load = T2CupdateAPI.pluginVersions.get(plugin.getName()).load;
|
load = T2C_UpdateAPI.pluginVersions.get(plugin.getName()).load;
|
||||||
}
|
}
|
||||||
T2CupdateObject update = new T2CupdateObject(
|
T2C_UpdateObject update = new T2C_UpdateObject(
|
||||||
plugin.getName(),
|
plugin.getName(),
|
||||||
pluginVersion,
|
pluginVersion,
|
||||||
null,
|
null,
|
||||||
@@ -144,9 +144,9 @@ public class T2CupdateCheckerGit {
|
|||||||
false,
|
false,
|
||||||
updateCheckOnJoin
|
updateCheckOnJoin
|
||||||
);
|
);
|
||||||
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
|
T2C_UpdateAPI.pluginVersions.put(plugin.getName(), update);
|
||||||
|
|
||||||
T2Csend.error(this.plugin,"§4 Cannot look for updates: " + exception.getMessage());
|
T2C_Send.error(this.plugin, "§4 Cannot look for updates: " + exception.getMessage());
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
@@ -1,37 +0,0 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.yaml;
|
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
|
||||||
|
|
||||||
public class T2CLibConfig {
|
|
||||||
public static Boolean getUpdateCheckOnJoin() {
|
|
||||||
return SelectLibConfig.getUpdateCheckOnJoin();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean getT2cTestDevelopment() {
|
|
||||||
return SelectLibConfig.getT2cTestDevelopment();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Integer getUpdateCheckTimeInterval() {
|
|
||||||
return SelectLibConfig.getUpdateCheckTimeInterval();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean getSeePreReleaseUpdates() {
|
|
||||||
return SelectLibConfig.getSeePreReleaseUpdates();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean getDebug() {
|
|
||||||
return SelectLibConfig.getDebug();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getLanguage() {
|
|
||||||
return SelectLibConfig.getLanguage();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean getBungee() {
|
|
||||||
return SelectLibConfig.getBungee();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean getInventoriesCloseByServerStop() {
|
|
||||||
return SelectLibConfig.getInventoriesCloseByServerStop();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,304 @@
|
|||||||
|
package net.t2code.t2codelib.SPIGOT.api.yaml;
|
||||||
|
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Replace;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.sound.T2C_Sound;
|
||||||
|
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class T2C_Config {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static void set(String path, String value, YamlConfiguration YamlConfiguration) {
|
||||||
|
if (!YamlConfiguration.contains(path)) {
|
||||||
|
YamlConfiguration.set(path, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static void set(String path, Object value, YamlConfiguration YamlConfiguration) {
|
||||||
|
if (!YamlConfiguration.contains(path)) {
|
||||||
|
YamlConfiguration.set(path, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static void set(String path, YamlConfiguration YamlConfiguration) {
|
||||||
|
YamlConfiguration.set(path, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static void set(String path, Integer value, YamlConfiguration YamlConfiguration) {
|
||||||
|
if (!YamlConfiguration.contains(path)) {
|
||||||
|
YamlConfiguration.set(path, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static void set(String path, Double value, YamlConfiguration YamlConfiguration) {
|
||||||
|
if (!YamlConfiguration.contains(path)) {
|
||||||
|
YamlConfiguration.set(path, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static void set(String path, Boolean value, YamlConfiguration YamlConfiguration) {
|
||||||
|
if (!YamlConfiguration.contains(path)) {
|
||||||
|
YamlConfiguration.set(path, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static void set(String path, List<String> value, YamlConfiguration YamlConfiguration) {
|
||||||
|
if (!YamlConfiguration.contains(path)) {
|
||||||
|
YamlConfiguration.set(path, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static void set(String path, ItemStack value, YamlConfiguration YamlConfiguration) {
|
||||||
|
if (!YamlConfiguration.contains(path)) {
|
||||||
|
YamlConfiguration.set(path, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, 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) {
|
||||||
|
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
|
||||||
|
String sound;
|
||||||
|
if (T2C_McVersion.isMc1_8()) {
|
||||||
|
sound = sound1_8.toString();
|
||||||
|
} else if (T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) {
|
||||||
|
sound = sound1_9.toString();
|
||||||
|
} else sound = sound1_13.toString();
|
||||||
|
set("Sound." + soundName + ".Sound", sound, yamlConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static void setSound(String soundName, String sound1_8, String sound1_13, YamlConfiguration yamlConfiguration) {
|
||||||
|
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
|
||||||
|
String sound;
|
||||||
|
if (T2C_McVersion.isMc1_8()) {
|
||||||
|
sound = sound1_8.toString();
|
||||||
|
} else sound = sound1_13.toString();
|
||||||
|
set("Sound." + soundName + ".Sound", sound, yamlConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static void setSound(String soundName, String sound, YamlConfiguration yamlConfiguration) {
|
||||||
|
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
|
||||||
|
set("Sound." + soundName + ".Sound", sound.toString(), yamlConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static boolean selectSoundEnable(String soundName, YamlConfiguration yamlConfiguration) {
|
||||||
|
return selectBoolean("Sound." + soundName + ".Enable", yamlConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static String selectSound(String prefix, String soundName, YamlConfiguration yamlConfiguration) {
|
||||||
|
return select(prefix, "Sound." + soundName + ".Sound", yamlConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, 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) {
|
||||||
|
return T2C_Sound.checkSound(sound1_8, sound1_9, sound1_13, selectSoundFromConfig, prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static Sound checkSound(String sound1_8, String sound1_13, String selectSoundFromConfig, String prefix) {
|
||||||
|
return T2C_Sound.checkSound(sound1_8, sound1_13, selectSoundFromConfig, prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static Sound checkSound(String sound, String selectSoundFromConfig, String prefix) {
|
||||||
|
return T2C_Sound.checkSound(sound, selectSoundFromConfig, prefix);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static String select(String prefix, String path, YamlConfiguration yamlConfiguration) {
|
||||||
|
return T2C_Replace.replace(prefix, yamlConfiguration.getString(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static Object selectObject(String prefix, String path, YamlConfiguration yamlConfiguration) {
|
||||||
|
return T2C_Replace.replaceObject(prefix, yamlConfiguration.get(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static Integer selectInt(String path, YamlConfiguration yamlConfiguration) {
|
||||||
|
return (yamlConfiguration.getInt(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static Boolean selectBoolean(String path, YamlConfiguration yamlConfiguration) {
|
||||||
|
return (yamlConfiguration.getBoolean(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static Double selectDouble(String path, YamlConfiguration yamlConfiguration) {
|
||||||
|
return (yamlConfiguration.getDouble(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static List<String> selectList(String path, YamlConfiguration yamlConfiguration) {
|
||||||
|
return (yamlConfiguration.getStringList(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static ItemStack selectItemStack(String path, YamlConfiguration yamlConfiguration) {
|
||||||
|
return (yamlConfiguration.getItemStack(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static List<String> selectList(String prefix, String path, YamlConfiguration yamlConfiguration) {
|
||||||
|
List<String> output = new ArrayList<>();
|
||||||
|
List<String> input = yamlConfiguration.getStringList(path);
|
||||||
|
for (String st : input) {
|
||||||
|
output.add(T2C_Replace.replace(prefix, st));
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 16.7
|
||||||
|
* This method will be removed soon!
|
||||||
|
* Please use the new {@link T2C_ConfigWriter#createConfig(File, T2C_ConfigItem[], String...)}.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "16.7", forRemoval = true)
|
||||||
|
public static void select(String prefix, List<String> value, String path, YamlConfiguration yamlConfiguration) {
|
||||||
|
List<String> output = new ArrayList<>();
|
||||||
|
List<String> input = yamlConfiguration.getStringList(path);
|
||||||
|
for (String st : input) {
|
||||||
|
output.add(T2C_Replace.replace(prefix, st));
|
||||||
|
}
|
||||||
|
value = output;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,66 @@
|
|||||||
|
// This class was created by JaTiTV.
|
||||||
|
|
||||||
|
package net.t2code.t2codelib.SPIGOT.api.yaml;
|
||||||
|
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||||
|
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||||
|
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class T2C_ConfigWriter {
|
||||||
|
|
||||||
|
private static FileConfiguration config;
|
||||||
|
|
||||||
|
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, T2C_Main.getPlugin().getLogger());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else exist = true;
|
||||||
|
|
||||||
|
config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
|
Map<String, List<String>> comments = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
T2C_LanguageEnum lang = T2C_LanguageEnum.english;
|
||||||
|
try {
|
||||||
|
lang = T2C_LanguageEnum.valueOf(config.getString(values[0].getLanguagePath().replace(".yml", "")));
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
}
|
||||||
|
|
||||||
|
for (T2C_ConfigItem item : values) {
|
||||||
|
if (item.getForceSet() || !exist) {
|
||||||
|
config.addDefault(item.getPath(), item.getValue());
|
||||||
|
|
||||||
|
List<String> commandList = item.getComments().get(lang);
|
||||||
|
if (commandList != null) {
|
||||||
|
comments.put(item.getPath(), commandList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy default values if they are missing
|
||||||
|
config.options().copyDefaults(true);
|
||||||
|
|
||||||
|
T2C_YmlWriter.saveConfigWithComments(configFile, config, comments, header);
|
||||||
|
readConfig(config, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void readConfig(FileConfiguration config, T2C_ConfigItem[] values) {
|
||||||
|
for (T2C_ConfigItem value : values) {
|
||||||
|
value.setValue(config.get(value.getPath()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,90 @@
|
|||||||
|
// This class was created by JaTiTV.
|
||||||
|
|
||||||
|
package net.t2code.t2codelib.SPIGOT.api.yaml;
|
||||||
|
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||||
|
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||||
|
import net.t2code.t2codelib.util.T2C_ConfigItemLanguages;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class T2C_LanguageWriter {
|
||||||
|
|
||||||
|
private static FileConfiguration config;
|
||||||
|
|
||||||
|
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 (T2C_LanguageEnum lan : T2C_LanguageEnum.values()) {
|
||||||
|
if (values[0].getLanguage().containsKey(lan)) {
|
||||||
|
zw.add(new File(path + "/languages/" + lan.name() + ".yml"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fileArray = zw.toArray(new File[0]);
|
||||||
|
}
|
||||||
|
for (File langFile : fileArray) {
|
||||||
|
if (langFile.getName().endsWith(".yml")) {
|
||||||
|
T2C_LanguageEnum lang = T2C_LanguageEnum.english;
|
||||||
|
try {
|
||||||
|
lang = T2C_LanguageEnum.valueOf(langFile.getName().replace(".yml", ""));
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!langFile.exists()) {
|
||||||
|
langFile.getParentFile().mkdirs();
|
||||||
|
try {
|
||||||
|
langFile.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, List<String>> comments = new LinkedHashMap<>();
|
||||||
|
// Copy default values if they are missing
|
||||||
|
config = YamlConfiguration.loadConfiguration(langFile);
|
||||||
|
config.options().copyDefaults(true);
|
||||||
|
for (T2C_ConfigItemLanguages item : values) {
|
||||||
|
config.addDefault(item.getPath(), item.getLanguage().get(lang));
|
||||||
|
|
||||||
|
|
||||||
|
List<String> commandList = item.getComments().get(lang);
|
||||||
|
if (commandList != null) {
|
||||||
|
comments.put(item.getPath(), commandList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
T2C_YmlWriter.saveConfigWithComments(langFile, config, comments, header);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
readConfig(prefix, path, values, loadConfig, 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");
|
||||||
|
if (!msg.isFile()) {
|
||||||
|
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" + T2C_LanguageEnum.english.name() + " §6is used!", isReload);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", isReload);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", isReload);
|
||||||
|
msg = new File(path, "languages/" + T2C_LanguageEnum.english.name() + ".yml");
|
||||||
|
selectMSG = T2C_LanguageEnum.english.name();
|
||||||
|
} else selectMSG = loadConfig;
|
||||||
|
YamlConfiguration yml = YamlConfiguration.loadConfiguration(msg);
|
||||||
|
for (T2C_ConfigItemLanguages value : values) {
|
||||||
|
value.setValue(yml.get(value.getPath()));
|
||||||
|
}
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§2Language successfully selected to: §6" + selectMSG, isReload);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,72 @@
|
|||||||
|
// This class was created by JaTiTV.
|
||||||
|
|
||||||
|
package net.t2code.t2codelib.SPIGOT.api.yaml;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class T2C_YmlWriter {
|
||||||
|
protected static void saveConfigWithComments(File file, FileConfiguration config, Map<String, List<String>> comments, String... headers) {
|
||||||
|
try {
|
||||||
|
StringBuilder configContent = new StringBuilder();
|
||||||
|
for (String h : headers) {
|
||||||
|
configContent.append(h).append("\n");
|
||||||
|
}
|
||||||
|
configContent.append("\n");
|
||||||
|
addSection(config, comments, configContent, "", 0);
|
||||||
|
|
||||||
|
// Write the content to the file
|
||||||
|
Files.write(file.toPath(), configContent.toString().getBytes());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void addSection(ConfigurationSection section, Map<String, List<String>> comments, StringBuilder builder, String prefix, int indentLevel) {
|
||||||
|
String indent = " ".repeat(indentLevel);
|
||||||
|
|
||||||
|
for (String key : section.getKeys(false)) {
|
||||||
|
String fullKey = prefix.isEmpty() ? key : prefix + "." + key;
|
||||||
|
Object value = section.get(key);
|
||||||
|
|
||||||
|
// Add comment if it exists for this key
|
||||||
|
List<String> commentList = comments.get(fullKey);
|
||||||
|
if (commentList != null) {
|
||||||
|
for (String c : commentList) {
|
||||||
|
if (c.isEmpty()) {
|
||||||
|
builder.append(indent).append(c).append("\n");
|
||||||
|
} else builder.append(indent).append("# ").append(c).append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the value is a section (nested map)
|
||||||
|
if (value instanceof ConfigurationSection) {
|
||||||
|
// Correctly add the section
|
||||||
|
builder.append(indent).append(key).append(":\n");
|
||||||
|
addSection((ConfigurationSection) value, comments, builder, fullKey, indentLevel + 1);
|
||||||
|
} else {
|
||||||
|
// Add value with proper indentation
|
||||||
|
// builder.append(indent).append(key).append(": ").append(value).append("\n");
|
||||||
|
if (value instanceof List) {
|
||||||
|
builder.append(indent).append(key).append(": ").append("\n");
|
||||||
|
List<Object> zw = (List<Object>) value;
|
||||||
|
for (Object s : zw) {
|
||||||
|
if (s instanceof String) {
|
||||||
|
builder.append(indent).append("- \"").append(s).append("\"\n");
|
||||||
|
} else builder.append(indent).append("- ").append(s).append("\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (value instanceof String) {
|
||||||
|
builder.append(indent).append(key).append(": \"").append(value).append("\"\n");
|
||||||
|
} else builder.append(indent).append(key).append(": ").append(value).append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,168 +0,0 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.api.yaml;
|
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class T2Cconfig {
|
|
||||||
public static void set(String path, String value, YamlConfiguration YamlConfiguration) {
|
|
||||||
if (!YamlConfiguration.contains(path)) {
|
|
||||||
YamlConfiguration.set(path, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static void set(String path, Object value, YamlConfiguration YamlConfiguration) {
|
|
||||||
if (!YamlConfiguration.contains(path)) {
|
|
||||||
YamlConfiguration.set(path, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void set(String path, YamlConfiguration YamlConfiguration) {
|
|
||||||
YamlConfiguration.set(path, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void set(String path, Integer value, YamlConfiguration YamlConfiguration) {
|
|
||||||
if (!YamlConfiguration.contains(path)) {
|
|
||||||
YamlConfiguration.set(path, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void set(String path, Double value, YamlConfiguration YamlConfiguration) {
|
|
||||||
if (!YamlConfiguration.contains(path)) {
|
|
||||||
YamlConfiguration.set(path, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void set(String path, Boolean value, YamlConfiguration YamlConfiguration) {
|
|
||||||
if (!YamlConfiguration.contains(path)) {
|
|
||||||
YamlConfiguration.set(path, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void set(String path, List<String> value, YamlConfiguration YamlConfiguration) {
|
|
||||||
if (!YamlConfiguration.contains(path)) {
|
|
||||||
YamlConfiguration.set(path, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void set(String path, ItemStack value, YamlConfiguration YamlConfiguration) {
|
|
||||||
if (!YamlConfiguration.contains(path)) {
|
|
||||||
YamlConfiguration.set(path, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setSound(String soundName, String sound1_8, String sound1_9, String sound1_13, YamlConfiguration yamlConfiguration) {
|
|
||||||
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
|
|
||||||
String sound;
|
|
||||||
if (T2CmcVersion.isMc1_8()) {
|
|
||||||
sound = sound1_8.toString();
|
|
||||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
|
||||||
sound = sound1_9.toString();
|
|
||||||
} else sound = sound1_13.toString();
|
|
||||||
set("Sound." + soundName + ".Sound", sound, yamlConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setSound(String soundName, String sound1_8, String sound1_13, YamlConfiguration yamlConfiguration) {
|
|
||||||
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
|
|
||||||
String sound;
|
|
||||||
if (T2CmcVersion.isMc1_8()) {
|
|
||||||
sound = sound1_8.toString();
|
|
||||||
} else sound = sound1_13.toString();
|
|
||||||
set("Sound." + soundName + ".Sound", sound, yamlConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setSound(String soundName, String sound, YamlConfiguration yamlConfiguration) {
|
|
||||||
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
|
|
||||||
set("Sound." + soundName + ".Sound", sound.toString(), yamlConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean selectSoundEnable(String soundName, YamlConfiguration yamlConfiguration) {
|
|
||||||
return selectBoolean("Sound." + soundName + ".Enable", yamlConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String selectSound(String prefix, String soundName, YamlConfiguration yamlConfiguration) {
|
|
||||||
return select(prefix, "Sound." + soundName + ".Sound", yamlConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Sound checkSound(String sound1_8, String sound1_9, String sound1_13, String selectSoundFromConfig, String prefix) {
|
|
||||||
String SOUND;
|
|
||||||
if (T2CmcVersion.isMc1_8()) {
|
|
||||||
SOUND = sound1_8;
|
|
||||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
|
||||||
SOUND = sound1_9;
|
|
||||||
} else SOUND = sound1_13;
|
|
||||||
|
|
||||||
return checkSound(SOUND, selectSoundFromConfig, prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Sound checkSound(String sound1_8, String sound1_13, String selectSoundFromConfig, String prefix) {
|
|
||||||
String SOUND;
|
|
||||||
if (T2CmcVersion.isMc1_8()) {
|
|
||||||
SOUND = sound1_8;
|
|
||||||
} else SOUND = sound1_13;
|
|
||||||
|
|
||||||
return checkSound(SOUND, selectSoundFromConfig, prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Sound checkSound(String sound, String selectSoundFromConfig, String prefix) {
|
|
||||||
try {
|
|
||||||
return Sound.valueOf(selectSoundFromConfig);
|
|
||||||
} catch (Exception e) {
|
|
||||||
T2Csend.console("§4\n§4\n§4\n" + SelectLibMsg.soundNotFound.replace("[prefix]", prefix)
|
|
||||||
.replace("[sound]", "§8Buy: §6" + selectSoundFromConfig) + "§4\n§4\n§4\n");
|
|
||||||
return Sound.valueOf(sound);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String select(String prefix, String path, YamlConfiguration yamlConfiguration) {
|
|
||||||
return T2Creplace.replace(prefix, yamlConfiguration.getString(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object selectObject(String prefix, String path, YamlConfiguration yamlConfiguration) {
|
|
||||||
return T2Creplace.replaceObject(prefix, yamlConfiguration.get(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Integer selectInt(String path, YamlConfiguration yamlConfiguration) {
|
|
||||||
return (yamlConfiguration.getInt(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean selectBoolean(String path, YamlConfiguration yamlConfiguration) {
|
|
||||||
return (yamlConfiguration.getBoolean(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Double selectDouble(String path, YamlConfiguration yamlConfiguration) {
|
|
||||||
return (yamlConfiguration.getDouble(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> selectList(String path, YamlConfiguration yamlConfiguration) {
|
|
||||||
return (yamlConfiguration.getStringList(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack selectItemStack(String path, YamlConfiguration yamlConfiguration) {
|
|
||||||
return (yamlConfiguration.getItemStack(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> selectList(String prefix, String path, YamlConfiguration yamlConfiguration) {
|
|
||||||
List<String> output = new ArrayList<>();
|
|
||||||
List<String> input = yamlConfiguration.getStringList(path);
|
|
||||||
for (String st : input) {
|
|
||||||
output.add(T2Creplace.replace(prefix, st));
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void select(String prefix, List<String> value, String path, YamlConfiguration yamlConfiguration) {
|
|
||||||
List<String> output = new ArrayList<>();
|
|
||||||
List<String> input = yamlConfiguration.getStringList(path);
|
|
||||||
for (String st : input) {
|
|
||||||
output.add(T2Creplace.replace(prefix, st));
|
|
||||||
}
|
|
||||||
value = output;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,48 @@
|
|||||||
|
package net.t2code.t2codelib.SPIGOT.system;
|
||||||
|
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class BungeeCommandSenderReceiver {
|
||||||
|
|
||||||
|
public static void sendToBungee(CommandSender sender, String information, Boolean console) {
|
||||||
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream output = new DataOutputStream(stream);
|
||||||
|
try {
|
||||||
|
if (console) {
|
||||||
|
output.writeUTF("T2Code-Console");
|
||||||
|
} else {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
output.writeUTF(sender.getName());
|
||||||
|
} else {
|
||||||
|
output.writeUTF("T2Code-Console");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
output.writeUTF(information);
|
||||||
|
output.writeUTF(String.valueOf(T2C_LibConfig.VALUES.serverUUID.getValue()));
|
||||||
|
} catch (IOException e) {
|
||||||
|
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||||
|
}
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
player.sendPluginMessage(T2C_Main.getPlugin(), T2C_Util.getPluginChannel_ProxyCommand(), stream.toByteArray());
|
||||||
|
T2C_Debug.debug(T2C_Main.getPlugin(), "PluginMessage received T2CbungeeCommandSenderReciver: "+ T2C_Util.getPluginChannel_ProxyCommand()+" - " + Arrays.toString(stream.toByteArray()) + " Player: " + player.getName());
|
||||||
|
} else {
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
player.sendPluginMessage(T2C_Main.getPlugin(), T2C_Util.getPluginChannel_ProxyCommand(), stream.toByteArray());
|
||||||
|
T2C_Debug.debug(T2C_Main.getPlugin(), "PluginMessage received T2CbungeeCommandSenderReciver: "+ T2C_Util.getPluginChannel_ProxyCommand()+" - " + Arrays.toString(stream.toByteArray()) + " Player: " + player.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
package net.t2code.t2codelib.SPIGOT.system;
|
package net.t2code.t2codelib.SPIGOT.system;
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
|
||||||
import net.t2code.t2codelib.Util;
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
@@ -12,6 +12,6 @@ public class JoinEvent implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoinEvent(PlayerLoginEvent event) {
|
public void onJoinEvent(PlayerLoginEvent event) {
|
||||||
T2CupdateAPI.join(T2CodeLibMain.getPlugin(), Util.getPrefix(),"t2code.lib.updatemsg",event.getPlayer(),Util.getSpigotID(),Util.getDiscord());
|
T2C_UpdateAPI.join(T2C_Main.getPlugin(), T2C_Util.getPrefix(),"t2code.lib.updatemsg",event.getPlayer(), T2C_Util.getSpigotID(), T2C_Util.getDiscord());
|
||||||
}
|
}
|
||||||
}
|
}
|
242
src/main/java/net/t2code/t2codelib/SPIGOT/system/T2C_Main.java
Normal file
242
src/main/java/net/t2code/t2codelib/SPIGOT/system/T2C_Main.java
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
package net.t2code.t2codelib.SPIGOT.system;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2C_BungeePlayers;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.items.T2C_ItemVersion;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_NmsEnum;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_NmsVersions;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.plugins.T2C_PluginCheck;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.bstats.Metrics;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.cmd.CmdExecuter;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.cmd.Development;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.cmd.ReportLogStorage;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.config.languages.T2CLibLanguages;
|
||||||
|
import net.t2code.t2codelib.util.T2C_PlatformDetector;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public final class T2C_Main extends JavaPlugin {
|
||||||
|
@Getter
|
||||||
|
private static T2C_Main plugin;
|
||||||
|
@Getter
|
||||||
|
private static Economy eco = null;
|
||||||
|
@Getter
|
||||||
|
private static Permission perm = null;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static List<String> autor;
|
||||||
|
@Getter
|
||||||
|
private static String version;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static Boolean mmIsLoad = true;
|
||||||
|
@Getter
|
||||||
|
private static Boolean load = false;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
T2C_PlatformDetector.scan();
|
||||||
|
// Plugin startup logic
|
||||||
|
plugin = this;
|
||||||
|
autor = plugin.getDescription().getAuthors();
|
||||||
|
// logger = getLogger();
|
||||||
|
version = plugin.getDescription().getVersion();
|
||||||
|
|
||||||
|
try {
|
||||||
|
adventure = BukkitAudiences.create(this);
|
||||||
|
} catch (Exception e) {
|
||||||
|
mmIsLoad = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void load() {
|
||||||
|
long long_ = T2C_Template.onLoadHeader(T2C_Util.getPrefix(), autor, version, T2C_Util.getSpigot(), T2C_Util.getDiscord());
|
||||||
|
|
||||||
|
checkIsBungee();
|
||||||
|
String prefix = T2C_Util.getPrefix();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Vault.loadVault();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
T2C_Send.sendException(e, getLogger());
|
||||||
|
}
|
||||||
|
T2C_McVersion.onCheck();
|
||||||
|
|
||||||
|
if (T2C_NmsVersions.getT2CnmsEnum() == T2C_NmsEnum.not_support) {
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§4!!!!!!!!!!!!!!!!!!!!", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "The " + T2C_McVersion.getMcVersion() + " is a very fresh / new version.", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "The plugin may not yet be supported on this server!", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "If there are any bugs in our plugins,", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "please report them to us via our Discord: http://dc.t2code.net", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§4!!!!!!!!!!!!!!!!!!!!", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", true);
|
||||||
|
try {
|
||||||
|
Thread.sleep(5000);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (T2C_McVersion.isMc1_22()) {
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§4!!!!!!!!!!!!!!!!!!!!", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "The 1.22 is a very fresh / new version.", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "If there are any bugs in our plugins,", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "please report them to us via our Discord: http://dc.t2code.net", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§4!!!!!!!!!!!!!!!!!!!!", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", true);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "", true);
|
||||||
|
try {
|
||||||
|
Thread.sleep(2000);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
T2C_Template.onLoadSeparateStroke(prefix);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§2Server run on:", false);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§3NMS: §6" + T2C_McVersion.getNms(), false);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§3Platform: §6" + T2C_PlatformDetector.detectPlatform, false);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§3Bukkit Version: §6" + T2C_McVersion.getBukkitVersion(), false);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§3Server Version: §6" + T2C_McVersion.getMcVersion(), false);
|
||||||
|
|
||||||
|
T2C_Template.onLoadSeparateStroke(prefix);
|
||||||
|
if (eco != null) {
|
||||||
|
String st = eco.getName();
|
||||||
|
if (eco.getName().equals("CMIEconomy")) st = "CMI";
|
||||||
|
if (Bukkit.getPluginManager().getPlugin(st) != null) {
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§3Economy: §6" + eco.getName() + " - " + Bukkit.getPluginManager().getPlugin(st).getDescription().getVersion() + " §7- §e" +
|
||||||
|
(System.currentTimeMillis() - long_) + "ms", false);
|
||||||
|
} else
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§3Economy: §6" + eco.getName() + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
||||||
|
} else
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§3Economy: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
||||||
|
|
||||||
|
if (perm != null) {
|
||||||
|
if (Bukkit.getPluginManager().getPlugin(perm.getName()) != null) {
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§3Permission plugin: §6" + perm.getName() + " - " + Bukkit.getPluginManager().getPlugin(perm.getName()).getDescription().getVersion()
|
||||||
|
+ " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
||||||
|
} else
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§3Permission plugin: §6" + perm.getName() + " - §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
||||||
|
} else
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§3Permission plugin: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
||||||
|
|
||||||
|
if (T2C_PluginCheck.papi()) {
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§3PlaceholderAPI: §6connected" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§3Kyori MiniMessage Support: " + (getMmIsLoad() ? "§2load" : "§4not load") + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
||||||
|
|
||||||
|
|
||||||
|
plugin.getCommand("t2code").setExecutor(new CmdExecuter());
|
||||||
|
|
||||||
|
T2C_Template.onLoadSeparateStroke(prefix);
|
||||||
|
T2C_LibConfig.set(false);
|
||||||
|
|
||||||
|
T2C_ItemVersion.scan();
|
||||||
|
T2CLibLanguages.set(false);
|
||||||
|
|
||||||
|
T2C_Template.onLoadSeparateStroke(prefix);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§3Use Proxy: §6" + (boolean) T2C_LibConfig.VALUES.proxy.getValue(), false);
|
||||||
|
T2C_Send.sendStartTextCenter(prefix, "§3serverUUID: §6" + T2C_LibConfig.VALUES.serverUUID.getValue(), false);
|
||||||
|
|
||||||
|
T2C_UpdateAPI.onUpdateCheck(plugin, prefix, T2C_Util.getGit(), T2C_Util.getSpigotID(), T2C_Util.getDiscord(),
|
||||||
|
(boolean) T2C_LibConfig.VALUES.updateCheckOnJoin.getValue(),
|
||||||
|
(boolean) T2C_LibConfig.VALUES.seePreReleaseUpdates.getValue(),
|
||||||
|
(int) T2C_LibConfig.VALUES.updateCheckTimeInterval.getValue());
|
||||||
|
Metrics.Bstats(plugin, T2C_Util.getBstatsID());
|
||||||
|
if ((boolean) T2C_LibConfig.VALUES.proxy.getValue()) {
|
||||||
|
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, T2C_Util.getPluginChannel_ProxyCommand());
|
||||||
|
T2C_Debug.debug(plugin, "registerIncomingPluginChannel §e" + T2C_Util.getPluginChannel_ProxyCommand());
|
||||||
|
|
||||||
|
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, T2C_Util.getPluginChannel_ProxyOnlinePlayers());
|
||||||
|
if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin, T2C_Util.getPluginChannel_ProxyOnlinePlayers())) {
|
||||||
|
T2C_Debug.debug(plugin, "registerIncomingPluginChannel §e" + T2C_Util.getPluginChannel_ProxyOnlinePlayers());
|
||||||
|
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, T2C_Util.getPluginChannel_ProxyOnlinePlayers(), new T2C_BungeePlayers());
|
||||||
|
T2C_BungeePlayers.callAllBungeePlayers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ReportLogStorage.load();
|
||||||
|
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
|
||||||
|
Bukkit.getServer().getPluginManager().registerEvents(new Development(), plugin);
|
||||||
|
T2C_Template.onLoadFooter(prefix, long_);
|
||||||
|
load = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
// Plugin shutdown logic
|
||||||
|
if (!load) return;
|
||||||
|
ReportLogStorage.save();
|
||||||
|
if ((boolean) T2C_LibConfig.VALUES.inventoriesCloseByServerStop.getValue()) {
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
player.closeInventory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Vault.vaultDisable();
|
||||||
|
T2C_Template.onDisable(T2C_Util.getPrefix(), this);
|
||||||
|
if (mmIsLoad) {
|
||||||
|
if (this.adventure != null) {
|
||||||
|
this.adventure.close();
|
||||||
|
this.adventure = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File getPath() {
|
||||||
|
return plugin.getDataFolder();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setEco(Economy eco) {
|
||||||
|
T2C_Main.eco = eco;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setPerm(Permission perm) {
|
||||||
|
T2C_Main.perm = perm;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BukkitAudiences adventure;
|
||||||
|
|
||||||
|
public BukkitAudiences getAdventure() {
|
||||||
|
if (adventure == null) {
|
||||||
|
throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!");
|
||||||
|
}
|
||||||
|
return adventure;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkIsBungee() {
|
||||||
|
File config = new File("spigot.yml");
|
||||||
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
|
isBungee = yamlConfiguration.getBoolean("settings.bungeecord");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static Boolean isBungee;
|
||||||
|
|
||||||
|
}
|
@@ -1,48 +0,0 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.system;
|
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
|
||||||
import net.t2code.t2codelib.Util;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class T2CbungeeCommandSenderReciver {
|
|
||||||
|
|
||||||
public static void sendToBungee(CommandSender sender, String information, Boolean console) {
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream output = new DataOutputStream(stream);
|
|
||||||
try {
|
|
||||||
if (console) {
|
|
||||||
output.writeUTF("T2Code-Console");
|
|
||||||
} else {
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
output.writeUTF(sender.getName());
|
|
||||||
} else {
|
|
||||||
output.writeUTF("T2Code-Console");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
output.writeUTF(information);
|
|
||||||
output.writeUTF(String.valueOf(Util.getServerUUID()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
player.sendPluginMessage(T2CodeLibMain.getPlugin(), "t2c:bcmd", stream.toByteArray());
|
|
||||||
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received T2CbungeeCommandSenderReciver: t2c:bcmd - " + Arrays.toString(stream.toByteArray()) + " Player: " + player.getName());
|
|
||||||
} else {
|
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
||||||
player.sendPluginMessage(T2CodeLibMain.getPlugin(), "t2c:bcmd", stream.toByteArray());
|
|
||||||
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received T2CbungeeCommandSenderReciver: t2c:bcmd - " + Arrays.toString(stream.toByteArray()) + " Player: " + player.getName());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//todo
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,236 +0,0 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.system;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
|
||||||
import net.milkbowl.vault.permission.Permission;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayers;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CnmsEnum;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CnmsVersions;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.bstats.Metrics;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.cmd.CmdExecuter;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.cmd.Development;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.cmd.ReportLogStorage;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.config.ConfigCreate;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.languages.LanguagesCreate;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg;
|
|
||||||
import net.t2code.t2codelib.Util;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public final class T2CodeLibMain extends JavaPlugin {
|
|
||||||
private static T2CodeLibMain plugin;
|
|
||||||
private static Economy eco = null;
|
|
||||||
private static Permission perm = null;
|
|
||||||
|
|
||||||
private static List<String> autor;
|
|
||||||
private static String version;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private static Boolean mmIsLoad = true;
|
|
||||||
private static Boolean load = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
// Plugin startup logic
|
|
||||||
plugin = this;
|
|
||||||
autor = plugin.getDescription().getAuthors();
|
|
||||||
version = plugin.getDescription().getVersion();
|
|
||||||
try {
|
|
||||||
adventure = BukkitAudiences.create(this);
|
|
||||||
} catch (Exception e) {
|
|
||||||
mmIsLoad = false;
|
|
||||||
}
|
|
||||||
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
|
||||||
checkIsBungee();
|
|
||||||
String prefix = Util.getPrefix();
|
|
||||||
|
|
||||||
try {
|
|
||||||
Vault.loadVault();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
T2CmcVersion.onCheck();
|
|
||||||
|
|
||||||
if (T2CnmsVersions.getT2CnmsEnum() == T2CnmsEnum.not_support) {
|
|
||||||
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
|
|
||||||
T2Csend.console(prefix);
|
|
||||||
T2Csend.warning(plugin, "The " + T2CmcVersion.getMcVersion() + " is a very fresh / new version.");
|
|
||||||
T2Csend.warning(plugin, "The plugin may not yet be supported on this server! If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net");
|
|
||||||
T2Csend.console(prefix);
|
|
||||||
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
|
|
||||||
if (!SelectLibConfig.getT2cTestDevelopment()) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(5000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (T2CmcVersion.isMc1_21()) {
|
|
||||||
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
|
|
||||||
T2Csend.console(prefix);
|
|
||||||
T2Csend.warning(plugin, "The 1.21 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");
|
|
||||||
T2Csend.console(prefix);
|
|
||||||
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
|
|
||||||
if (!SelectLibConfig.getT2cTestDevelopment()) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(5000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
T2Ctemplate.onLoadSeparateStroke(prefix);
|
|
||||||
T2Csend.console(prefix + " §2Server run on:");
|
|
||||||
T2Csend.console(prefix + " §3mcVersion: §6" + T2CmcVersion.getMcVersion());
|
|
||||||
T2Csend.console(prefix + " §3bukkitVersion: §6" + T2CmcVersion.getBukkitVersion());
|
|
||||||
T2Csend.console(prefix + " §3nms: §6" + T2CmcVersion.getNms());
|
|
||||||
T2Ctemplate.onLoadSeparateStroke(prefix);
|
|
||||||
if (eco != null) {
|
|
||||||
String st = eco.getName();
|
|
||||||
if (eco.getName().equals("CMIEconomy")) st = "CMI";
|
|
||||||
if (Bukkit.getPluginManager().getPlugin(st) != null) {
|
|
||||||
T2Csend.console(prefix + " §3Economy: §6" + eco.getName() + " - " + Bukkit.getPluginManager().getPlugin(st).getDescription().getVersion() + " §7- §e" +
|
|
||||||
(System.currentTimeMillis() - long_) + "ms");
|
|
||||||
} else
|
|
||||||
T2Csend.console(prefix + " §3Economy: §6" + eco.getName() + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
} else
|
|
||||||
T2Csend.console(prefix + " §3Economy: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
|
|
||||||
if (perm != null) {
|
|
||||||
if (Bukkit.getPluginManager().getPlugin(perm.getName()) != null) {
|
|
||||||
T2Csend.console(prefix + " §3Permission plugin: §6" + perm.getName() + " - " + Bukkit.getPluginManager().getPlugin(perm.getName()).getDescription().getVersion()
|
|
||||||
+ " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
} else
|
|
||||||
T2Csend.console(prefix + " §3Permission plugin: §6" + perm.getName() + " - §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
} else
|
|
||||||
T2Csend.console(prefix + " §3Permission plugin: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
|
|
||||||
if (T2CpluginCheck.papi()) {
|
|
||||||
T2Csend.console(prefix + " §3PlaceholderAPI: §6connected" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
}
|
|
||||||
|
|
||||||
T2Csend.console(prefix + " §3Kyori MiniMessage Support: " + (getMmIsLoad() ? "§2load" : "§4not load") + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
|
|
||||||
|
|
||||||
plugin.getCommand("t2code").setExecutor(new CmdExecuter());
|
|
||||||
ConfigCreate.configCreate();
|
|
||||||
T2CitemVersion.scan();
|
|
||||||
LanguagesCreate.langCreate();
|
|
||||||
SelectLibConfig.onSelect();
|
|
||||||
SelectLibMsg.onSelect();
|
|
||||||
|
|
||||||
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), Util.getSpigotID(), Util.getDiscord(), SelectLibConfig.getUpdateCheckOnJoin(), SelectLibConfig.getSeePreReleaseUpdates(),
|
|
||||||
SelectLibConfig.getUpdateCheckTimeInterval());
|
|
||||||
Metrics.Bstats(plugin, Util.getBstatsID());
|
|
||||||
if (SelectLibConfig.getBungee()) {
|
|
||||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
|
|
||||||
T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:bcmd");
|
|
||||||
|
|
||||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bonlp");
|
|
||||||
if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin, "t2c:bonlp")) {
|
|
||||||
T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:bonlp");
|
|
||||||
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "t2c:bonlp", new T2CbungeePlayers());
|
|
||||||
T2CbungeePlayers.callAllBungeePlayers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ReportLogStorage.load();
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new Development(), plugin);
|
|
||||||
T2Ctemplate.onLoadFooter(prefix, long_);
|
|
||||||
load = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
// Plugin shutdown logic
|
|
||||||
if (!load) return;
|
|
||||||
ReportLogStorage.save();
|
|
||||||
if (SelectLibConfig.getInventoriesCloseByServerStop()) {
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
||||||
player.closeInventory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Vault.vaultDisable();
|
|
||||||
T2Ctemplate.onDisable(Util.getPrefix(), this);
|
|
||||||
if (mmIsLoad) {
|
|
||||||
if (this.adventure != null) {
|
|
||||||
this.adventure.close();
|
|
||||||
this.adventure = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getPath() {
|
|
||||||
return plugin.getDataFolder();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setEco(Economy eco) {
|
|
||||||
T2CodeLibMain.eco = eco;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setPerm(Permission perm) {
|
|
||||||
T2CodeLibMain.perm = perm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T2CodeLibMain getPlugin() {
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Economy getEco() {
|
|
||||||
return eco;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Permission getPerm() {
|
|
||||||
return perm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getAutor() {
|
|
||||||
return autor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static BukkitAudiences adventure;
|
|
||||||
|
|
||||||
public BukkitAudiences getAdventure() {
|
|
||||||
if (adventure == null) {
|
|
||||||
throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!");
|
|
||||||
}
|
|
||||||
return adventure;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void checkIsBungee() {
|
|
||||||
File config = new File("spigot.yml");
|
|
||||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
|
||||||
|
|
||||||
isBungee = yamlConfiguration.getBoolean("settings.bungeecord");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Boolean isBungee;
|
|
||||||
|
|
||||||
public static Boolean getIsBungee() {
|
|
||||||
return isBungee;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean getMmIsLoad() {
|
|
||||||
return mmIsLoad;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -2,8 +2,8 @@ package net.t2code.t2codelib.SPIGOT.system;
|
|||||||
|
|
||||||
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.t2codelib.SPIGOT.api.messages.T2Csend;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
import net.t2code.t2codelib.Util;
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -15,36 +15,37 @@ public class Vault {
|
|||||||
|
|
||||||
public static void loadVault() throws InterruptedException {
|
public static void loadVault() throws InterruptedException {
|
||||||
long long_ = System.currentTimeMillis();
|
long long_ = System.currentTimeMillis();
|
||||||
if (T2CodeLibMain.getPlugin().getServer().getPluginManager().getPlugin("Vault") != null && Objects.requireNonNull(T2CodeLibMain.getPlugin().getServer().getPluginManager().getPlugin("Vault")).isEnabled()) {
|
if (T2C_Main.getPlugin().getServer().getPluginManager().getPlugin("Vault") != null && Objects.requireNonNull(T2C_Main.getPlugin().getServer().getPluginManager().getPlugin("Vault")).isEnabled()) {
|
||||||
vaultEnable = true;
|
vaultEnable = true;
|
||||||
RegisteredServiceProvider<Economy> eco = T2CodeLibMain.getPlugin().getServer().getServicesManager().getRegistration(Economy.class);
|
RegisteredServiceProvider<Economy> eco = T2C_Main.getPlugin().getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
if (eco != null) {
|
if (eco != null) {
|
||||||
T2CodeLibMain.setEco(eco.getProvider());
|
T2C_Main.setEco(eco.getProvider());
|
||||||
if (T2CodeLibMain.getEco() != null) {
|
if (T2C_Main.getEco() != null) {
|
||||||
connected = true;
|
connected = true;
|
||||||
T2Csend.console(Util.getPrefix() + " §2Vault / Economy successfully connected!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
|
T2C_Send.sendStartTextCenter(T2C_Util.getPrefix(), " §2Vault / Economy successfully connected!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
||||||
} else {
|
} else {
|
||||||
connected = false;
|
connected = false;
|
||||||
T2Csend.console(Util.getPrefix() + " §4Economy could not be connected / found! [1]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
T2C_Send.sendStartTextCenter(T2C_Util.getPrefix(), " §4Economy could not be connected / found! [1]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
connected = false;
|
connected = false;
|
||||||
T2Csend.console(Util.getPrefix() + " §4Economy could not be connected / found! [2]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
T2C_Send.sendStartTextCenter(T2C_Util.getPrefix(), " §4Economy could not be connected / found! [2]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
||||||
}
|
}
|
||||||
RegisteredServiceProvider<Permission> perm = T2CodeLibMain.getPlugin().getServer().getServicesManager().getRegistration(Permission.class);
|
RegisteredServiceProvider<Permission> perm = T2C_Main.getPlugin().getServer().getServicesManager().getRegistration(Permission.class);
|
||||||
if (perm != null) {
|
if (perm != null) {
|
||||||
T2CodeLibMain.setPerm(perm.getProvider());
|
T2C_Main.setPerm(perm.getProvider());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
vaultEnable = false;
|
vaultEnable = false;
|
||||||
connected = false;
|
connected = false;
|
||||||
T2Csend.console(Util.getPrefix() + " §4Vault could not be connected! [3]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
T2C_Send.sendStartTextCenter(T2C_Util.getPrefix()," §4Vault could not be connected! [3]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void vaultDisable() {
|
public static void vaultDisable() {
|
||||||
if (!connected) return;
|
if (!connected) return;
|
||||||
connected = false;
|
connected = false;
|
||||||
T2Csend.console(Util.getPrefix() + " §4Vault / Economy successfully deactivated.");
|
T2C_Send.sendStartTextCenter(T2C_Util.getPrefix(), " §4Vault / Economy successfully deactivated.", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
|
|
||||||
package net.t2code.t2codelib.SPIGOT.system.bstats;
|
package net.t2code.t2codelib.SPIGOT.system.bstats;
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -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.getUpdateCheckOnJoin())));
|
metrics.addCustomChart(new SimplePie("updatecheckonjoin", () -> String.valueOf(T2C_LibConfig.VALUES.updateCheckOnJoin.getValue())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
|
@@ -1,15 +1,14 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
import net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
import net.t2code.t2codelib.SPIGOT.system.BungeeCommandSenderReceiver;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayers;
|
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
|
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
import net.t2code.t2codelib.SPIGOT.system.config.languages.T2CLibLanguages;
|
||||||
import net.t2code.t2codelib.T2CupdateObject;
|
import net.t2code.t2codelib.util.T2C_UpdateObject;
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
import net.t2code.t2codelib.Util;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -27,7 +26,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
if (!sender.hasPermission("t2code.admin")) {
|
if (!sender.hasPermission("t2code.admin")) {
|
||||||
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
T2C_Send.sender(sender, "§4No Permission §8t2code.admin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Commands.info(sender);
|
Commands.info(sender);
|
||||||
@@ -40,21 +39,21 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
|||||||
case "version":
|
case "version":
|
||||||
case "ver":
|
case "ver":
|
||||||
if (!sender.hasPermission("t2code.admin")) {
|
if (!sender.hasPermission("t2code.admin")) {
|
||||||
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
T2C_Send.sender(sender, "§4No Permission §8t2code.admin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Commands.info(sender);
|
Commands.info(sender);
|
||||||
return false;
|
return false;
|
||||||
case "permtoggle":
|
case "permtoggle":
|
||||||
if (!sender.hasPermission("t2code.permtoggle.use")) {
|
if (!sender.hasPermission("t2code.permtoggle.use")) {
|
||||||
T2Csend.sender(sender, "§4No Permission §8t2code.permtoggle.use");
|
T2C_Send.sender(sender, "§4No Permission §8t2code.permtoggle.use");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Commands.permtoggle(sender, args);
|
Commands.permtoggle(sender, args);
|
||||||
return false;
|
return false;
|
||||||
case "updateinfo":
|
case "updateinfo":
|
||||||
if (!sender.hasPermission("t2code.admin")) {
|
if (!sender.hasPermission("t2code.admin")) {
|
||||||
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
T2C_Send.sender(sender, "§4No Permission §8t2code.admin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Commands.updateInfo(sender, args);
|
Commands.updateInfo(sender, args);
|
||||||
@@ -68,37 +67,38 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
|||||||
// return false;
|
// return false;
|
||||||
case "reloadconfig":
|
case "reloadconfig":
|
||||||
if (!sender.hasPermission("t2code.admin")) {
|
if (!sender.hasPermission("t2code.admin")) {
|
||||||
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
T2C_Send.sender(sender, "§4No Permission §8t2code.admin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SelectLibConfig.onSelect();
|
T2C_LibConfig.set(true);
|
||||||
T2Csend.sender(sender, Util.getPrefix() + " §2Config successfully reloaded");
|
T2CLibLanguages.set(true);
|
||||||
|
T2C_Send.sender(sender, T2C_Util.getPrefix() + " §2Config successfully reloaded");
|
||||||
return false;
|
return false;
|
||||||
case "debug":
|
case "debug":
|
||||||
if (!sender.hasPermission("t2code.admin")) {
|
if (!sender.hasPermission("t2code.admin")) {
|
||||||
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
T2C_Send.sender(sender, "§4No Permission §8t2code.admin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Commands.debug(sender, args);
|
Commands.debug(sender, args);
|
||||||
return false;
|
return false;
|
||||||
case "test":
|
case "test":
|
||||||
if (!sender.hasPermission("t2code.admin")) {
|
if (!sender.hasPermission("t2code.admin")) {
|
||||||
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
T2C_Send.sender(sender, "§4No Permission §8t2code.admin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Commands.test(sender, args);
|
Commands.test(sender, args);
|
||||||
return false;
|
return false;
|
||||||
case "serverid":
|
case "serverid":
|
||||||
if (!sender.hasPermission("t2code.admin")) {
|
if (!sender.hasPermission("t2code.admin")) {
|
||||||
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
T2C_Send.sender(sender, "§4No Permission §8t2code.admin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
T2Csend.sender(sender, ("[prefix] <red>T2C ServerID:</red> <gold><hover:show_text:'<yellow>copy</yellow>'>" +
|
T2C_Send.sender(sender, ("[prefix] <red>T2C ServerID:</red> <gold><hover:show_text:'<yellow>copy</yellow>'>" +
|
||||||
"<click:copy_to_clipboard:[id]>[id]</click></hover></gold>").replace("[prefix]", Util.getPrefix()).replace("[id]", String.valueOf(Util.getServerUUID())));
|
"<click:copy_to_clipboard:[id]>[id]</click></hover></gold>").replace("[prefix]", T2C_Util.getPrefix()).replace("[id]", String.valueOf(T2C_LibConfig.VALUES.serverUUID.getValue())));
|
||||||
return false;
|
return false;
|
||||||
case "bcmd":
|
case "bcmd":
|
||||||
if (!sender.hasPermission("t2code.admin")) {
|
if (!sender.hasPermission("t2code.admin")) {
|
||||||
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
T2C_Send.sender(sender, "§4No Permission §8t2code.admin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String cmd = "";
|
String cmd = "";
|
||||||
@@ -106,16 +106,16 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
|||||||
cmd = cmd + s + " ";
|
cmd = cmd + s + " ";
|
||||||
}
|
}
|
||||||
cmd = cmd.replace("bcmd ", "");
|
cmd = cmd.replace("bcmd ", "");
|
||||||
T2CbungeeCommandSenderReciver.sendToBungee(null, cmd, true);
|
BungeeCommandSenderReceiver.sendToBungee(null, cmd, true);
|
||||||
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage BCMD: " + cmd);
|
T2C_Debug.debug(T2C_Main.getPlugin(), "PluginMessage BCMD: " + cmd);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (!sender.hasPermission("t2code.admin")) {
|
if (!sender.hasPermission("t2code.admin")) {
|
||||||
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
T2C_Send.sender(sender, "§4No Permission §8t2code.admin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
|
T2C_Send.sender(sender, "§4Use: §7/t2code debug createReportLog");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
|||||||
if (args.length == 2 && args[0].equalsIgnoreCase("updateinfo")) {
|
if (args.length == 2 && args[0].equalsIgnoreCase("updateinfo")) {
|
||||||
if (sender.hasPermission("t2code.admin")) {
|
if (sender.hasPermission("t2code.admin")) {
|
||||||
if (hasPermission(p, arg1.get("updateinfo"))) {
|
if (hasPermission(p, arg1.get("updateinfo"))) {
|
||||||
for (Map.Entry<String, T2CupdateObject> pl : T2CupdateAPI.pluginVersions.entrySet()) {
|
for (Map.Entry<String, T2C_UpdateObject> pl : T2C_UpdateAPI.pluginVersions.entrySet()) {
|
||||||
if (passend(pl.getValue().pluginName, args[1])) list.add(pl.getValue().pluginName);
|
if (passend(pl.getValue().pluginName, args[1])) list.add(pl.getValue().pluginName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,32 +1,31 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ccmd;
|
import net.t2code.t2codelib.SPIGOT.api.commands.T2C_Cmd;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
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.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class Commands {
|
public class Commands {
|
||||||
protected static void info(CommandSender sender) {
|
protected static void info(CommandSender sender) {
|
||||||
T2Ctemplate.sendInfo(sender, T2CodeLibMain.getPlugin(), Util.getSpigotID(), Util.getDiscord(), null, Util.getInfoText());
|
assert T2C_Main.getPlugin().getDescription().getDescription() != null;
|
||||||
|
T2C_Template.sendInfo(sender, T2C_Main.getPlugin(), T2C_Util.getSpigotID(), T2C_Util.getDiscord(), null, T2C_Util.getInfoText().replace("[getDescription()]",T2C_Main.getPlugin().getDescription().getDescription()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void test(CommandSender sender, String[] args) {
|
protected static void test(CommandSender sender, String[] args) {
|
||||||
T2Csend.sender(sender, Util.getPrefix() + " &4Currently there is no development test command");
|
T2C_Send.sender(sender, T2C_Util.getPrefix() + " &4Currently there is no development test command");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void debug(CommandSender sender, String[] args) {
|
protected static void debug(CommandSender sender, String[] args) {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
|
T2C_Send.sender(sender, "§4Use: §7/t2code debug createReportLog");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (args[1].toLowerCase()) {
|
switch (args[1].toLowerCase()) {
|
||||||
@@ -34,11 +33,11 @@ public class Commands {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
T2Csend.sender(sender, "<dark_red>The debug zip file is <red>automatically uploaded</red> to T2Code's servers<br>and <red>automatically deleted</red> " +
|
T2C_Send.sender(sender, "<dark_red>The debug zip file is <red>automatically uploaded</red> to T2Code's servers<br>and <red>automatically deleted</red> " +
|
||||||
"after <red>14</red> days!<br>The file can also be deleted manually by you via command!</dark_red><br><dark_green><hover:show_text:'<yellow>Confirm the" +
|
"after <red>14</red> days!<br>The file can also be deleted manually by you via command!</dark_red><br><dark_green><hover:show_text:'<yellow>Confirm the" +
|
||||||
" upload</yellow>'><click:run_command:'/t2c debug createReportLog confirmupload'>upload</click></hover></dark_green> <dark_gray>|</dark_gray> " +
|
" upload</yellow>'><click:run_command:'/t2c debug createReportLog confirmupload'>upload</click></hover></dark_green> <dark_gray>|</dark_gray> " +
|
||||||
"<gold><hover:show_text:'<red>Do not upload</red>'><click:run_command:'/t2c debug createReportLog noupload'>keep the file on your server</click></hover></gold>");
|
"<gold><hover:show_text:'<red>Do not upload</red>'><click:run_command:'/t2c debug createReportLog noupload'>keep the file on your server</click></hover></gold>");
|
||||||
} else T2Csend.sender(sender, "<dark_red>The debug zip file is <red>automatically uploaded</red> to T2Code's servers</dark_red>" +
|
} else T2C_Send.sender(sender, "<dark_red>The debug zip file is <red>automatically uploaded</red> to T2Code's servers</dark_red>" +
|
||||||
"<br><dark_red>and <red>automatically deleted</red> after <red>14</red> days!</dark_red>" +
|
"<br><dark_red>and <red>automatically deleted</red> after <red>14</red> days!</dark_red>" +
|
||||||
"<br><dark_red>The file can also be deleted manually by you via command!</dark_red>" +
|
"<br><dark_red>The file can also be deleted manually by you via command!</dark_red>" +
|
||||||
"<br><green>Confirm the upload with the command:</green>" +
|
"<br><green>Confirm the upload with the command:</green>" +
|
||||||
@@ -48,26 +47,26 @@ public class Commands {
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
Boolean upload = args[2].equalsIgnoreCase("confirmupload");
|
Boolean upload = args[2].equalsIgnoreCase("confirmupload");
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(T2C_Main.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
CreateReportLog.create(sender, upload);
|
CreateReportLog.create(sender, upload);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
T2Csend.sender(sender, Util.getPrefix() + " <red>An error occurred while creating a report log! Please look in the console!</red>");
|
T2C_Send.sender(sender, T2C_Util.getPrefix() + " <red>An error occurred while creating a report log! Please look in the console!</red>");
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
|
T2C_Send.sender(sender, "§4Use: §7/t2code debug createReportLog");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "deletereportlog":
|
case "deletereportlog":
|
||||||
if (args.length != 3) {
|
if (args.length != 3) {
|
||||||
T2Csend.sender(sender, "§4Use: §7/t2code debug deleteReportLog [id]");
|
T2C_Send.sender(sender, "§4Use: §7/t2code debug deleteReportLog [id]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -77,29 +76,29 @@ public class Commands {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog/deleteReportLog");
|
T2C_Send.sender(sender, "§4Use: §7/t2code debug createReportLog/deleteReportLog");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void updateInfo(CommandSender sender, String[] args) {
|
protected static void updateInfo(CommandSender sender, String[] args) {
|
||||||
T2Csend.sender(sender, T2CupdateAPI.updateInfo(args, sender instanceof Player));
|
T2C_Send.sender(sender, T2C_UpdateAPI.updateInfo(args, sender instanceof Player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void permtoggle(CommandSender sender, String[] args) {
|
public static void permtoggle(CommandSender sender, String[] args) {
|
||||||
Player player = (Player) Bukkit.getOfflinePlayer(args[1]);
|
Player player = (Player) Bukkit.getOfflinePlayer(args[1]);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
T2Csend.sender(sender, "§4Player §6" + args[1] + " §4not exist!");
|
T2C_Send.sender(sender, "§4Player §6" + args[1] + " §4not exist!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String permission = args[2];
|
String permission = args[2];
|
||||||
|
|
||||||
if (player.hasPermission(permission)) {
|
if (player.hasPermission(permission)) {
|
||||||
T2Ccmd.console(SelectLibConfig.getCommandPermToggleCommand().replace("[player]",player.getName()).replace("[perm]",permission).replace("[value]", "false"));
|
T2C_Cmd.console(String.valueOf(T2C_LibConfig.VALUES.commandPermToggleCommand.getValue()).replace("[player]",player.getName()).replace("%player_name%",player.getName()).replace("[perm]",permission).replace("[value]", "false"));
|
||||||
T2Csend.sender(sender, "§2Permission §8'§6" + permission + "§8' §2was set to §6false §2for the player §6" + player.getName() + "§2.");
|
T2C_Send.sender(sender, "§2Permission §8'§6" + permission + "§8' §2was set to §6false §2for the player §6" + player.getName() + "§2.");
|
||||||
} else {
|
} else {
|
||||||
T2Ccmd.console(SelectLibConfig.getCommandPermToggleCommand().replace("[player]",player.getName()).replace("[perm]",permission).replace("[value]", "true"));
|
T2C_Cmd.console(String.valueOf(T2C_LibConfig.VALUES.commandPermToggleCommand.getValue()).replace("[player]",player.getName()).replace("%player_name%",player.getName()).replace("[perm]",permission).replace("[value]", "true"));
|
||||||
T2Csend.sender(sender, "§2Permission §8'§6" + permission + "§8' §2was set to §6true §2for the player §6" + player.getName() + "§2.");
|
T2C_Send.sender(sender, "§2Permission §8'§6" + permission + "§8' §2was set to §6true §2for the player §6" + player.getName() + "§2.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
||||||
|
|
||||||
import net.t2code.luckyBox.api.LuckyBoxAPI;
|
import net.t2code.luckyBox.api.LuckyBoxAPI;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
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.Vault;
|
import net.t2code.t2codelib.SPIGOT.system.Vault;
|
||||||
import net.t2code.t2codelib.Util;
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.client.HttpClient;
|
import org.apache.http.client.HttpClient;
|
||||||
@@ -17,7 +17,6 @@ import org.apache.http.impl.client.DefaultHttpClient;
|
|||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@@ -38,10 +37,10 @@ import java.util.zip.ZipOutputStream;
|
|||||||
|
|
||||||
public class CreateReportLog {
|
public class CreateReportLog {
|
||||||
protected static void create(CommandSender sender, Boolean confirmUpload) throws IOException {
|
protected static void create(CommandSender sender, Boolean confirmUpload) throws IOException {
|
||||||
T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog is created...");
|
T2C_Send.sender(sender, T2C_Util.getPrefix() + " §6A DebugLog is created...");
|
||||||
String timeStampFile = new SimpleDateFormat("HH_mm_ss-dd_MM_yyyy").format(Calendar.getInstance().getTime());
|
String timeStampFile = new SimpleDateFormat("HH_mm_ss-dd_MM_yyyy").format(Calendar.getInstance().getTime());
|
||||||
|
|
||||||
File directory = new File(T2CodeLibMain.getPath() + "/DebugLogs");
|
File directory = new File(T2C_Main.getPath() + "/DebugLogs");
|
||||||
File directoryTemp = new File("T2CDebugLogsTemp");
|
File directoryTemp = new File("T2CDebugLogsTemp");
|
||||||
if (!directory.exists()) {
|
if (!directory.exists()) {
|
||||||
directory.mkdir();
|
directory.mkdir();
|
||||||
@@ -57,11 +56,11 @@ public class CreateReportLog {
|
|||||||
String timeStamp = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy").format(Calendar.getInstance().getTime());
|
String timeStamp = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy").format(Calendar.getInstance().getTime());
|
||||||
pWriter.println("Created on: " + timeStamp + " - from: " + sender.getName());
|
pWriter.println("Created on: " + timeStamp + " - from: " + sender.getName());
|
||||||
pWriter.println();
|
pWriter.println();
|
||||||
pWriter.println("Server Bukkit version: " + T2CmcVersion.getBukkitVersion());
|
pWriter.println("Server Bukkit version: " + T2C_McVersion.getBukkitVersion());
|
||||||
pWriter.println("Server run on: " + T2CmcVersion.getMcVersion());
|
pWriter.println("Server run on: " + T2C_McVersion.getMcVersion());
|
||||||
pWriter.println("Server NMS: " + T2CmcVersion.getNms());
|
pWriter.println("Server NMS: " + T2C_McVersion.getNms());
|
||||||
pWriter.println("Online Mode: " + Bukkit.getOnlineMode());
|
pWriter.println("Online Mode: " + Bukkit.getOnlineMode());
|
||||||
pWriter.println("Bungee Mode: " + T2CodeLibMain.getIsBungee());
|
pWriter.println("Bungee Mode: " + T2C_Main.getIsBungee());
|
||||||
pWriter.println("Server Port: " + Bukkit.getServer().getPort());
|
pWriter.println("Server Port: " + Bukkit.getServer().getPort());
|
||||||
pWriter.println();
|
pWriter.println();
|
||||||
pWriter.println("Worlds: " + Bukkit.getWorlds());
|
pWriter.println("Worlds: " + Bukkit.getWorlds());
|
||||||
@@ -74,18 +73,18 @@ public class CreateReportLog {
|
|||||||
pWriter.println("Vault: " + Bukkit.getPluginManager().getPlugin("Vault").getName() + " - " + Bukkit.getPluginManager().getPlugin("Vault")
|
pWriter.println("Vault: " + Bukkit.getPluginManager().getPlugin("Vault").getName() + " - " + Bukkit.getPluginManager().getPlugin("Vault")
|
||||||
.getDescription().getVersion());
|
.getDescription().getVersion());
|
||||||
} else pWriter.println("Vault: not connected");
|
} else pWriter.println("Vault: not connected");
|
||||||
if (T2CodeLibMain.getEco() != null) {
|
if (T2C_Main.getEco() != null) {
|
||||||
String st = T2CodeLibMain.getEco().getName();
|
String st = T2C_Main.getEco().getName();
|
||||||
if (T2CodeLibMain.getEco().getName().equals("CMIEconomy")) st = "CMI";
|
if (T2C_Main.getEco().getName().equals("CMIEconomy")) st = "CMI";
|
||||||
if (Bukkit.getPluginManager().getPlugin(st) != null) {
|
if (Bukkit.getPluginManager().getPlugin(st) != null) {
|
||||||
pWriter.println("Economy: " + T2CodeLibMain.getEco().isEnabled() + " - " + st + " - " + Bukkit.getPluginManager().getPlugin(st).getDescription().getVersion());
|
pWriter.println("Economy: " + T2C_Main.getEco().isEnabled() + " - " + st + " - " + Bukkit.getPluginManager().getPlugin(st).getDescription().getVersion());
|
||||||
} else pWriter.println("Economy: " + T2CodeLibMain.getEco().isEnabled() + " - " + st);
|
} else pWriter.println("Economy: " + T2C_Main.getEco().isEnabled() + " - " + st);
|
||||||
} else pWriter.println("Economy: not connected via vault");
|
} else pWriter.println("Economy: not connected via vault");
|
||||||
if (T2CodeLibMain.getPerm() != null) {
|
if (T2C_Main.getPerm() != null) {
|
||||||
if (Bukkit.getPluginManager().getPlugin(T2CodeLibMain.getPerm().getName()) != null) {
|
if (Bukkit.getPluginManager().getPlugin(T2C_Main.getPerm().getName()) != null) {
|
||||||
pWriter.println("Permission: " + T2CodeLibMain.getPerm().isEnabled() + " - " + T2CodeLibMain.getPerm().getName() + " - " + Bukkit.getPluginManager()
|
pWriter.println("Permission: " + T2C_Main.getPerm().isEnabled() + " - " + T2C_Main.getPerm().getName() + " - " + Bukkit.getPluginManager()
|
||||||
.getPlugin(T2CodeLibMain.getPerm().getName()).getDescription().getVersion());
|
.getPlugin(T2C_Main.getPerm().getName()).getDescription().getVersion());
|
||||||
} else pWriter.println("Permission: " + T2CodeLibMain.getPerm().isEnabled() + " - " + T2CodeLibMain.getPerm().getName());
|
} else pWriter.println("Permission: " + T2C_Main.getPerm().isEnabled() + " - " + T2C_Main.getPerm().getName());
|
||||||
} else pWriter.println("Permission: not connected via vault");
|
} else pWriter.println("Permission: not connected via vault");
|
||||||
pWriter.println();
|
pWriter.println();
|
||||||
pWriter.println("Java: " + System.getProperty("java.version"));
|
pWriter.println("Java: " + System.getProperty("java.version"));
|
||||||
@@ -93,9 +92,9 @@ public class CreateReportLog {
|
|||||||
pWriter.println("System: " + System.getProperty("os.version"));
|
pWriter.println("System: " + System.getProperty("os.version"));
|
||||||
pWriter.println("User Home: " + System.getProperty("user.home"));
|
pWriter.println("User Home: " + System.getProperty("user.home"));
|
||||||
pWriter.println();
|
pWriter.println();
|
||||||
pWriter.println("T2CodeLib: " + T2CodeLibMain.getPlugin().getDescription().getVersion());
|
pWriter.println("T2CodeLib: " + T2C_Main.getPlugin().getDescription().getVersion());
|
||||||
pWriter.println();
|
pWriter.println();
|
||||||
if (T2CpluginCheck.luckyBox()) {
|
if (T2C_PluginCheck.luckyBox()) {
|
||||||
pWriter.println("T2C-PremiumPlugins: ");
|
pWriter.println("T2C-PremiumPlugins: ");
|
||||||
pWriter.println("T2C-LuckyBox UID: " + LuckyBoxAPI.getUID());
|
pWriter.println("T2C-LuckyBox UID: " + LuckyBoxAPI.getUID());
|
||||||
pWriter.println("T2C-LuckyBox RID: " + LuckyBoxAPI.getRID());
|
pWriter.println("T2C-LuckyBox RID: " + LuckyBoxAPI.getRID());
|
||||||
@@ -133,8 +132,8 @@ public class CreateReportLog {
|
|||||||
" - Website: " + pl.getDescription().getWebsite());
|
" - Website: " + pl.getDescription().getWebsite());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException e) {
|
||||||
ioe.printStackTrace();
|
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||||
} finally {
|
} finally {
|
||||||
if (pWriter != null) {
|
if (pWriter != null) {
|
||||||
pWriter.flush();
|
pWriter.flush();
|
||||||
@@ -160,7 +159,7 @@ public class CreateReportLog {
|
|||||||
zip.closeEntry();
|
zip.closeEntry();
|
||||||
zip.close();
|
zip.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||||
}
|
}
|
||||||
file.delete();
|
file.delete();
|
||||||
File zipFile = new File(zipPath);
|
File zipFile = new File(zipPath);
|
||||||
@@ -170,9 +169,9 @@ public class CreateReportLog {
|
|||||||
zipFile.delete();
|
zipFile.delete();
|
||||||
directoryTemp.delete();
|
directoryTemp.delete();
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + directory + "/" + zipFile.getName());
|
T2C_Send.sender(sender, T2C_Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + directory + "/" + zipFile.getName());
|
||||||
}
|
}
|
||||||
T2Csend.console(Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + directory + "/" + zipFile.getName());
|
T2C_Send.console(T2C_Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + directory + "/" + zipFile.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,15 +193,15 @@ public class CreateReportLog {
|
|||||||
zipFile.delete();
|
zipFile.delete();
|
||||||
directoryTemp.delete();
|
directoryTemp.delete();
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
T2Csend.sender(sender, ("[prefix] <green>A DebugLog zip has been created." +
|
T2C_Send.sender(sender, ("[prefix] <green>A DebugLog zip has been created." +
|
||||||
"<br>[prefix] <green>You can download it <click:open_url:'[url]'><gold><hover:show_text:'<yellow>Download the debug file</yellow>'>here</hover></gold></click>." +
|
"<br>[prefix] <green>You can download it <click:open_url:'[url]'><gold><hover:show_text:'<yellow>Download the debug file</yellow>'>here</hover></gold></click>." +
|
||||||
"<br>[prefix] <green>Please enter the following key in the ticket: <gold><click:copy_to_clipboard:[key]><hover:show_text:'<yellow>Copy to clipboard</yellow>'>[key]</hover></click></gold></green>" +
|
"<br>[prefix] <green>Please enter the following key in the ticket: <gold><click:copy_to_clipboard:[key]><hover:show_text:'<yellow>Copy to clipboard</yellow>'>[key]</hover></click></gold></green>" +
|
||||||
"<br>[prefix] <dark_red>Do not share the download URL with anyone!</dark_red>" +
|
"<br>[prefix] <dark_red>Do not share the download URL with anyone!</dark_red>" +
|
||||||
"<br>[prefix] <click:run_command:'/t2code debug deleteReportLog [key]'><hover:show_text:'<yellow>Click to delete</yellow>'><green>You can <b>delete</b> your Debug-File by clicking me.</green>" +
|
"<br>[prefix] <click:run_command:'/t2code debug deleteReportLog [key]'><hover:show_text:'<yellow>Click to delete</yellow>'><green>You can <b>delete</b> your Debug-File by clicking me.</green>" +
|
||||||
"<br>[prefix] <color:#910d06>(If you do not delete the debug file, it will be deleted automatically after <red>14</red> days!)</color></click></hover>")
|
"<br>[prefix] <color:#910d06>(If you do not delete the debug file, it will be deleted automatically after <red>14</red> days!)</color></click></hover>")
|
||||||
.replace("[key]", fileID).replace("[url]", downloadURL).replace("[prefix]", Util.getPrefix()));
|
.replace("[key]", fileID).replace("[url]", downloadURL).replace("[prefix]", T2C_Util.getPrefix()));
|
||||||
}
|
}
|
||||||
T2Csend.console(Util.getPrefix() + (" <gold>A DebugLog zip has been created. You can download it here:</gold> <yellow>[url]</yellow>" +
|
T2C_Send.console(T2C_Util.getPrefix() + (" <gold>A DebugLog zip has been created. You can download it here:</gold> <yellow>[url]</yellow>" +
|
||||||
"<br><gold>Please enter the following key in the ticket:</gold> <yellow>[key]</yellow>." +
|
"<br><gold>Please enter the following key in the ticket:</gold> <yellow>[key]</yellow>." +
|
||||||
"<br><dark_red>Do not share the download URL with anyone!</dark_red>" +
|
"<br><dark_red>Do not share the download URL with anyone!</dark_red>" +
|
||||||
"<br><color:#910d06>(If you do not delete the debug file, it will be deleted automatically after <red>14</red> days!)</color>" +
|
"<br><color:#910d06>(If you do not delete the debug file, it will be deleted automatically after <red>14</red> days!)</color>" +
|
||||||
@@ -212,7 +211,7 @@ public class CreateReportLog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void pluginToDebug(String pluginName, ZipOutputStream zip) throws IOException {
|
private static void pluginToDebug(String pluginName, ZipOutputStream zip) throws IOException {
|
||||||
if (T2CpluginCheck.pluginCheck(pluginName)) {
|
if (T2C_PluginCheck.pluginCheck(pluginName)) {
|
||||||
Plugin plugin = Bukkit.getPluginManager().getPlugin(pluginName);
|
Plugin plugin = Bukkit.getPluginManager().getPlugin(pluginName);
|
||||||
File plConfigs = new File(plugin.getDataFolder().getPath());
|
File plConfigs = new File(plugin.getDataFolder().getPath());
|
||||||
if (plConfigs.exists()) {
|
if (plConfigs.exists()) {
|
||||||
@@ -232,7 +231,7 @@ public class CreateReportLog {
|
|||||||
private static void pluginToDebug(ZipOutputStream zip) throws IOException {
|
private static void pluginToDebug(ZipOutputStream zip) throws IOException {
|
||||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||||
String plName = plugin.getDescription().getName();
|
String plName = plugin.getDescription().getName();
|
||||||
if (plName.contains("T2C-") || Util.getT2cPlugins().contains(plName) || plugin.getDescription().getAuthors().contains("JaTiTV")) {
|
if (plName.contains("T2C-") || T2C_Util.getT2cPlugins().contains(plName) || plugin.getDescription().getAuthors().contains("JaTiTV")) {
|
||||||
File plConfigs = new File(plugin.getDataFolder().getPath());
|
File plConfigs = new File(plugin.getDataFolder().getPath());
|
||||||
if (plConfigs.exists()) {
|
if (plConfigs.exists()) {
|
||||||
addFolderToZip("T2Code-Plugins", plugin.getDataFolder().getPath(), zip);
|
addFolderToZip("T2Code-Plugins", plugin.getDataFolder().getPath(), zip);
|
||||||
@@ -296,9 +295,9 @@ public class CreateReportLog {
|
|||||||
int response = con.getResponseCode();
|
int response = con.getResponseCode();
|
||||||
if (response == 200) {
|
if (response == 200) {
|
||||||
ReportLogStorage.remove(arg);
|
ReportLogStorage.remove(arg);
|
||||||
T2Csend.sender(sender, "<green>Deleted report: <yellow>" + arg);
|
T2C_Send.sender(sender, "<green>Deleted report: <yellow>" + arg);
|
||||||
} else {
|
} else {
|
||||||
T2Csend.sender(sender, "<green>Error while deleting report: <yellow>" + arg);
|
T2C_Send.sender(sender, "<green>Error while deleting report: <yellow>" + arg);
|
||||||
}
|
}
|
||||||
con.disconnect();
|
con.disconnect();
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion;
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
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.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -16,7 +15,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
import static net.t2code.t2codelib.SPIGOT.api.dev.T2CdevelopmentTool.removeLastChar;
|
import static net.t2code.t2codelib.SPIGOT.api.dev.T2C_DevelopmentTool.removeLastChar;
|
||||||
|
|
||||||
public class Development implements Listener {
|
public class Development implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -28,8 +27,8 @@ public class Development implements Listener {
|
|||||||
if (!args[0].equals("_t2code_")) {
|
if (!args[0].equals("_t2code_")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!SelectLibConfig.getDeveloperTool()) {
|
if (!(boolean) T2C_LibConfig.VALUES.developerTool.getValue()) {
|
||||||
T2Csend.player(e.getPlayer(), Util.getPrefix() + " The Development Tool is disabled.");
|
T2C_Send.player(e.getPlayer(), T2C_Util.getPrefix() + " The Development Tool is disabled.");
|
||||||
}
|
}
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
t2cPls(e.getPlayer());
|
t2cPls(e.getPlayer());
|
||||||
@@ -37,7 +36,7 @@ public class Development implements Listener {
|
|||||||
|
|
||||||
protected static void t2cPls(Player player) {
|
protected static void t2cPls(Player player) {
|
||||||
String msg = "<red>T<gray>2</gray>Code</red> <dark_purple>Development</dark_purple><br>"
|
String msg = "<red>T<gray>2</gray>Code</red> <dark_purple>Development</dark_purple><br>"
|
||||||
+ T2CmcVersion.getMcVersion() + "<br>(" + Bukkit.getPluginManager().getPlugins().length + ") ";
|
+ T2C_McVersion.getMcVersion() + "<br>(" + Bukkit.getPluginManager().getPlugins().length + ") ";
|
||||||
ArrayList<Plugin> plugins = new ArrayList<>();
|
ArrayList<Plugin> plugins = new ArrayList<>();
|
||||||
Collections.addAll(plugins, Bukkit.getPluginManager().getPlugins());
|
Collections.addAll(plugins, Bukkit.getPluginManager().getPlugins());
|
||||||
plugins.sort(Comparator.comparing(Plugin::getName));
|
plugins.sort(Comparator.comparing(Plugin::getName));
|
||||||
@@ -57,14 +56,14 @@ public class Development implements Listener {
|
|||||||
plSt = "<click:open_url:'" + plugin.getDescription().getWebsite() + "'>" + plSt + "</click>";
|
plSt = "<click:open_url:'" + plugin.getDescription().getWebsite() + "'>" + plSt + "</click>";
|
||||||
}
|
}
|
||||||
if (plugin.isEnabled()) {
|
if (plugin.isEnabled()) {
|
||||||
if (plName.contains("T2C-") || Util.getT2cPlugins().contains(plName)) {
|
if (plName.contains("T2C-") || T2C_Util.getT2cPlugins().contains(plName)) {
|
||||||
msg = msg + "<dark_green>" + plSt + "</dark_green>, ";
|
msg = msg + "<dark_green>" + plSt + "</dark_green>, ";
|
||||||
} else msg = msg + "<green>" + plSt + "</green>, ";
|
} else msg = msg + "<green>" + plSt + "</green>, ";
|
||||||
} else if (plName.contains("T2C-") || Util.getT2cPlugins().contains(plName)) {
|
} else if (plName.contains("T2C-") || T2C_Util.getT2cPlugins().contains(plName)) {
|
||||||
msg = msg + "<dark_red>" + plSt + "</dark_red>, ";
|
msg = msg + "<dark_red>" + plSt + "</dark_red>, ";
|
||||||
} else msg = msg + "<red>" + plSt + "</red>, ";
|
} else msg = msg + "<red>" + plSt + "</red>, ";
|
||||||
}
|
}
|
||||||
T2Csend.player(player, removeLastChar(msg, 2));
|
T2C_Send.player(player, removeLastChar(msg, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
package net.t2code.t2codelib.SPIGOT.system.cmd;
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -11,7 +12,7 @@ import java.util.List;
|
|||||||
public class ReportLogStorage {
|
public class ReportLogStorage {
|
||||||
public static List<String> list = new ArrayList<>();
|
public static List<String> list = new ArrayList<>();
|
||||||
|
|
||||||
protected static File config = new File(T2CodeLibMain.getPath(), "/DebugLogs/T2CodeReportKeys.yml");
|
protected static File config = new File(T2C_Main.getPath(), "/DebugLogs/T2CodeReportKeys.yml");
|
||||||
protected static YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
protected static YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
public static void add(String key) {
|
public static void add(String key) {
|
||||||
@@ -31,7 +32,7 @@ public class ReportLogStorage {
|
|||||||
try {
|
try {
|
||||||
yamlConfiguration.save(config);
|
yamlConfiguration.save(config);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
T2C_Send.sendException(e, T2C_Main.getPlugin().getLogger());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,46 +0,0 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.system.config.config;
|
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
|
||||||
import net.t2code.t2codelib.Util;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
|
|
||||||
public class ConfigCreate {
|
|
||||||
|
|
||||||
public static void configCreate() {
|
|
||||||
long long_ = System.currentTimeMillis();
|
|
||||||
if (new File(T2CodeLibMain.getPath(), "config.yml").exists()){
|
|
||||||
if (T2CodeLibMain.getPlugin().getConfig().getBoolean("Plugin.Debug")) T2Csend.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated...");
|
|
||||||
} else T2Csend.console(Util.getPrefix() + " §4config.yml are created...");
|
|
||||||
|
|
||||||
|
|
||||||
File config = new File(T2CodeLibMain.getPath(), "config.yml");
|
|
||||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
|
||||||
|
|
||||||
|
|
||||||
T2Cconfig.set("Plugin.UpdateCheck.OnJoin", true, yamlConfiguration);
|
|
||||||
T2Cconfig.set("Plugin.UpdateCheck.TimeInterval", 60, yamlConfiguration);
|
|
||||||
T2Cconfig.set("Plugin.UpdateCheck.SeePreReleaseUpdates", true, yamlConfiguration);
|
|
||||||
T2Cconfig.set("Plugin.UpdateCheck.AllPlugins.FullDisable", false, yamlConfiguration);
|
|
||||||
T2Cconfig.set("Plugin.language", "english", yamlConfiguration);
|
|
||||||
T2Cconfig.set("Plugin.Not recommended to disable.developerTool", true, yamlConfiguration);
|
|
||||||
|
|
||||||
T2Cconfig.set("BungeeCord.Enable", T2CodeLibMain.getIsBungee(), yamlConfiguration);
|
|
||||||
T2Cconfig.set("Player.Inventories.CloseByServerStop", true, yamlConfiguration);
|
|
||||||
|
|
||||||
T2Cconfig.set("Command.PermToggle.PermissionSetCommand","lp user [player] permission set [perm] [value]",yamlConfiguration);
|
|
||||||
|
|
||||||
try {
|
|
||||||
yamlConfiguration.save(config);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
T2Csend.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,40 @@
|
|||||||
|
package net.t2code.t2codelib.SPIGOT.system.config.config;
|
||||||
|
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||||
|
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class ConvertT2ClibConfig {
|
||||||
|
|
||||||
|
public static YamlConfiguration yamlConfiguration;
|
||||||
|
|
||||||
|
|
||||||
|
public static void convert() {
|
||||||
|
File config = new File(T2C_Main.getPath(), "config.yml");
|
||||||
|
yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
|
if (!config.exists()) return;
|
||||||
|
if (yamlConfiguration.contains("plugin.updateCheck.onJoin")) return;
|
||||||
|
|
||||||
|
set("Plugin.UpdateCheck.OnJoin", T2C_LibConfig.VALUES.updateCheckOnJoin);
|
||||||
|
set("Plugin.UpdateCheck.TimeInterval", T2C_LibConfig.VALUES.updateCheckTimeInterval);
|
||||||
|
set("Plugin.UpdateCheck.SeePreReleaseUpdates", T2C_LibConfig.VALUES.seePreReleaseUpdates);
|
||||||
|
set("Plugin.UpdateCheck.AllPlugins.FullDisable", T2C_LibConfig.VALUES.updateCheckFullDisable);
|
||||||
|
set("Plugin.Debug", T2C_LibConfig.VALUES.debug);
|
||||||
|
set("Plugin.language", T2C_LibConfig.VALUES.language);
|
||||||
|
set("Plugin.Not recommended to disable.developerTool", T2C_LibConfig.VALUES.developerTool);
|
||||||
|
set("BungeeCord.Enable", T2C_LibConfig.VALUES.proxy);
|
||||||
|
set("Player.Inventories.CloseByServerStop", T2C_LibConfig.VALUES.inventoriesCloseByServerStop);
|
||||||
|
set("Command.PermToggle.PermissionSetCommand", T2C_LibConfig.VALUES.updateCheckOnJoin);
|
||||||
|
|
||||||
|
config.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void set(String path, T2C_ConfigItem item){
|
||||||
|
if (yamlConfiguration.contains(path)){
|
||||||
|
item.setValue(yamlConfiguration.get(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,53 +0,0 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.system.config.config;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class SelectLibConfig {
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private static Boolean updateCheckOnJoin;
|
|
||||||
@Getter
|
|
||||||
private static Boolean t2cTestDevelopment = false;
|
|
||||||
@Getter
|
|
||||||
private static Integer updateCheckTimeInterval;
|
|
||||||
@Getter
|
|
||||||
private static Boolean seePreReleaseUpdates;
|
|
||||||
@Getter
|
|
||||||
private static Boolean updateCheckFullDisable;
|
|
||||||
@Getter
|
|
||||||
private static Boolean debug;
|
|
||||||
@Getter
|
|
||||||
private static String language;
|
|
||||||
@Getter
|
|
||||||
private static Boolean developerTool;
|
|
||||||
@Getter
|
|
||||||
private static Boolean bungee;
|
|
||||||
@Getter
|
|
||||||
private static Boolean inventoriesCloseByServerStop;
|
|
||||||
@Getter
|
|
||||||
private static String commandPermToggleCommand;
|
|
||||||
|
|
||||||
public static void onSelect() {
|
|
||||||
File config = new File(T2CodeLibMain.getPath(), "config.yml");
|
|
||||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
|
||||||
|
|
||||||
if (yamlConfiguration.contains("t2cTestDevelopment")) {
|
|
||||||
t2cTestDevelopment = yamlConfiguration.getBoolean("t2cTestDevelopment");
|
|
||||||
}
|
|
||||||
|
|
||||||
updateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheck.OnJoin");
|
|
||||||
updateCheckTimeInterval = yamlConfiguration.getInt("Plugin.UpdateCheck.TimeInterval");
|
|
||||||
seePreReleaseUpdates = yamlConfiguration.getBoolean("Plugin.UpdateCheck.SeePreReleaseUpdates");
|
|
||||||
updateCheckFullDisable = yamlConfiguration.getBoolean("Plugin.UpdateCheck.AllPlugins.FullDisable");
|
|
||||||
debug = yamlConfiguration.getBoolean("Plugin.Debug");
|
|
||||||
language = yamlConfiguration.getString("Plugin.language");
|
|
||||||
developerTool = yamlConfiguration.getBoolean("Plugin.Not recommended to disable.developerTool");
|
|
||||||
bungee = yamlConfiguration.getBoolean("BungeeCord.Enable");
|
|
||||||
inventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop");
|
|
||||||
commandPermToggleCommand = yamlConfiguration.getString("Command.PermToggle.PermissionSetCommand");
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,157 @@
|
|||||||
|
package net.t2code.t2codelib.SPIGOT.system.config.config;
|
||||||
|
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter;
|
||||||
|
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||||
|
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class T2C_LibConfig {
|
||||||
|
|
||||||
|
public enum VALUES implements T2C_ConfigItem {
|
||||||
|
|
||||||
|
updateCheckOnJoin("plugin.updateCheck.onJoin", true, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("Mit dieser Option kannst du festlegen, ob Spieler mit der Berechtigung 't2code.lib.updatemsg' beim Join eine Update-Nachricht erhalten, wenn ein Update für das Plugin verfügbar ist."));
|
||||||
|
put(T2C_LanguageEnum.english, List.of("In this option you can set if players with the permission 't2code.lib.updatemsg' will get an update message on join when an update for the plugin is available."));
|
||||||
|
}}),
|
||||||
|
|
||||||
|
updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("Mit dieser Option kannst du das Zeitintervall in Minuten festlegen, in dem Aktualisierungen überprüft werden sollen."));
|
||||||
|
put(T2C_LanguageEnum.english, List.of("In this option you can set the time interval in minutes in which updates should be checked."));
|
||||||
|
}}),
|
||||||
|
|
||||||
|
seePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("In dieser Option kannst du einstellen, ob du Beta- und Snapshot-Versionen in der Update-Prüfung erhalten und anzeigen möchten."));
|
||||||
|
put(T2C_LanguageEnum.english, List.of("In this option you can set whether you want to receive and display beta and snapshot versions in the update check."));
|
||||||
|
}}),
|
||||||
|
|
||||||
|
updateCheckFullDisable("plugin.updateCheck.allPlugins.fullDisable", false, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("Diese Option deaktiviert alle Aktualisierungsprüfungen für Plugins, die die T2CodeLib verwenden."));
|
||||||
|
put(T2C_LanguageEnum.english, List.of("This option deactivates all update checks for plugins that use the T2CodeLib."));
|
||||||
|
}}),
|
||||||
|
|
||||||
|
debug("plugin.debug.debugModus", false, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("Der Debug-Modus sendet ausführlichere Debug-Informationen an die Konsole.", "In dieser Version des Plugins sind keine Debug-Meldungen eingebaut!"));
|
||||||
|
put(T2C_LanguageEnum.english, List.of("The debug mode sends more detailed debug information to the console.", "In this version of the plugin no debug messages are built in!"));
|
||||||
|
}}),
|
||||||
|
|
||||||
|
developerTool("plugin.debug.developerTool", false, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("Diese Option aktiviert erweiterte Werkzeuge für die Entwickler von Plugins, die die T2CodeLib verwenden.", "Wenn du nicht genau weist, wozu das gut ist, solltest du es deaktiviert lassen!"));
|
||||||
|
put(T2C_LanguageEnum.english, List.of("This option activates advanced tools for the developers of plugins that use the T2CodeLib.", "If you don't know exactly what this is for, you should leave it deactivated!"));
|
||||||
|
}}),
|
||||||
|
|
||||||
|
language("plugin.language", "english", true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("In dieser Option kannst du die Sprache des Plugins einstellen."));
|
||||||
|
put(T2C_LanguageEnum.english, List.of("In this option you can set the language of the plugin."));
|
||||||
|
}}),
|
||||||
|
|
||||||
|
space_proxy("proxy", null, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of());
|
||||||
|
put(T2C_LanguageEnum.english, List.of());
|
||||||
|
}}),
|
||||||
|
proxy("proxy.enable", T2C_Main.getIsBungee(), true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("Diese Option muss aktiviert werden, wenn du die T2CodeLib auf einem BungeeCord, Waterfall oder Velocity Proxy als Bridge verwenden möchtest."
|
||||||
|
, "Bitte beachte, dass die einzelnen APIs der Plugins, die eine Bridge auf einem Proxy verwenden, in der config.yml der T2CodeLib auf dem Proxy aktiviert werden müssen!"));
|
||||||
|
put(T2C_LanguageEnum.english, List.of("This option must be activated if you use the T2CodeLib on a BungeeCord, Waterfall or Velocity Proxy as a bridge."
|
||||||
|
, "Please note that the individual APIs of the plugins that use a bridge on a proxy must be activated in the config.yml of the T2CodeLib on the proxy!"));
|
||||||
|
}}),
|
||||||
|
|
||||||
|
serverUUID("proxy.serverUUID", UUID.randomUUID(), true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("Diese UUID wird für die Kommunikation der Plugins in einem Netzwerk mit mehreren Servern verwendet.", "Diese UUID darf nur einmal in einem Netz vorkommen!"));
|
||||||
|
put(T2C_LanguageEnum.english, List.of("This UUID is used for the communication of the plugins in a network with several servers.", "This UUID may only occur once in a network!"));
|
||||||
|
}}),
|
||||||
|
|
||||||
|
space_player("player", null, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of());
|
||||||
|
put(T2C_LanguageEnum.english, List.of());
|
||||||
|
}}),
|
||||||
|
|
||||||
|
inventoriesCloseByServerStop("player.inventories.closeByServerStop", true, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("Wenn diese Option aktiviert ist, werden bei allen Spielern auf dem Server (Spigot, Papier, etc.) das Inventar / GUIs geschlossen, wenn der Server heruntergefahren oder neu gestartet wird.",
|
||||||
|
"(Damit ist nicht das gesamte Netz gemeint, wenn ein Proxy verwendet wird)"));
|
||||||
|
put(T2C_LanguageEnum.english, List.of("If this option is enabled, all players on the server (spigot, paper, etc.) will have their inventory / GUIs closed when the server is shut down or restarted.",
|
||||||
|
"(This does not mean the entire network if a proxy is used)"));
|
||||||
|
|
||||||
|
}}),
|
||||||
|
|
||||||
|
space_command("command", null, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of());
|
||||||
|
put(T2C_LanguageEnum.english, List.of());
|
||||||
|
}}),
|
||||||
|
|
||||||
|
commandPermToggleCommand("command.permToggle.permissionSetCommand", "lp user [player] permission set [perm] [value]", true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("Diese Option gibt an, welcher Befehl für den T2CodeLib-Befehl '/t2code permtoggle <player> <permission>' verwendet werden soll."));
|
||||||
|
put(T2C_LanguageEnum.english, List.of("This option specifies which command is to be used for the T2CodeLib command '/t2code permtoggle <player> <permission>'."));
|
||||||
|
}}),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String path;
|
||||||
|
private Object value;
|
||||||
|
private final boolean forceSet;
|
||||||
|
private final HashMap<T2C_LanguageEnum, List<String>> comments;
|
||||||
|
|
||||||
|
VALUES(String path, Object value, boolean forceSet, HashMap<T2C_LanguageEnum, List<String>> comments) {
|
||||||
|
this.path = path;
|
||||||
|
this.value = value;
|
||||||
|
this.forceSet = forceSet;
|
||||||
|
this.comments = comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getForceSet() {
|
||||||
|
return forceSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<T2C_LanguageEnum, List<String>> getComments() {
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLanguagePath() {
|
||||||
|
return language.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValue(Object newValue) {
|
||||||
|
value = newValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void set(boolean isReload) {
|
||||||
|
long long_ = System.currentTimeMillis();
|
||||||
|
ConvertT2ClibConfig.convert();
|
||||||
|
T2C_ConfigWriter.createConfig(new File(T2C_Main.getPath(), "config.yml"), VALUES.values(), T2C_Util.getConfigLogo());
|
||||||
|
|
||||||
|
T2C_Send.sendStartTextCenter(T2C_Util.getPrefix(), "§2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", isReload);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,45 +0,0 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.system.config.languages;
|
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
|
||||||
import net.t2code.t2codelib.Util;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class LanguagesCreate {
|
|
||||||
static Plugin plugin = T2CodeLibMain.getPlugin();
|
|
||||||
|
|
||||||
public static void langCreate() {
|
|
||||||
T2Csend.debug(plugin, "§4Language files are created / updated...");
|
|
||||||
long long_ = System.currentTimeMillis();
|
|
||||||
|
|
||||||
|
|
||||||
setFile("english", MSG.EN_VaultNotSetUp, MSG.EN_VotingPluginNotSetUp, MSG.EN_SoundNotFound);
|
|
||||||
|
|
||||||
setFile("german", MSG.DE_VaultNotSetUp, MSG.DE_VotingPluginNotSetUp, MSG.DE_SoundNotFound);
|
|
||||||
|
|
||||||
setFile("norwegian", MSG.NO_VaultNotSetUp, MSG.NO_VotingPluginNotSetUp, MSG.NO_SoundNotFound);
|
|
||||||
|
|
||||||
T2Csend.console(Util.getPrefix() + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setFile(String language, String vaultNotSetUp, String votingPluginNotSetUp, String soundNotFound) {
|
|
||||||
File messages = new File(T2CodeLibMain.getPath(), "languages/" + language + ".yml");
|
|
||||||
YamlConfiguration yamlConfigurationNO = YamlConfiguration.loadConfiguration(messages);
|
|
||||||
|
|
||||||
T2Cconfig.set("Plugin.VaultNotSetUp", vaultNotSetUp, yamlConfigurationNO);
|
|
||||||
T2Cconfig.set("Plugin.VotingPluginNotSetUp", votingPluginNotSetUp, yamlConfigurationNO);
|
|
||||||
T2Cconfig.set("Plugin.SoundNotFound", soundNotFound, yamlConfigurationNO);
|
|
||||||
|
|
||||||
try {
|
|
||||||
yamlConfigurationNO.save(messages);
|
|
||||||
} catch (IOException e) {
|
|
||||||
T2Csend.warning(plugin, e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,25 +0,0 @@
|
|||||||
// This claas was created by JaTiTV
|
|
||||||
|
|
||||||
package net.t2code.t2codelib.SPIGOT.system.config.languages;
|
|
||||||
|
|
||||||
public class MSG {
|
|
||||||
|
|
||||||
// EN
|
|
||||||
public static String EN_VaultNotSetUp = "[prefix] &4Vault / Economy not set up!";
|
|
||||||
public static String EN_VotingPluginNotSetUp = "[prefix] &4VotingPlugin is not present on the server!";
|
|
||||||
public static String EN_SoundNotFound = "[prefix] &4The sound &6[sound] &4was not found! Please check the settings.";
|
|
||||||
|
|
||||||
|
|
||||||
// DE
|
|
||||||
public static String DE_VaultNotSetUp = "[prefix] &4Vault / Economy nicht eingerichtet!";
|
|
||||||
public static String DE_VotingPluginNotSetUp = "[prefix] &4VotingPlugin ist auf dem Server nicht vorhanden!";
|
|
||||||
public static String DE_SoundNotFound = "[prefix] &4Der Sound &6[sound] &4wurde nicht gefunden! Bitte [ue]berpr[ue]fe die Einstellungen.";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// NO
|
|
||||||
public static String NO_VaultNotSetUp = "[prefix] &4Vault / Økonomi har ikke blitt satt opp!";
|
|
||||||
public static String NO_VotingPluginNotSetUp = "[prefix] &4VotingPlugin er ikke til stede på serveren!";
|
|
||||||
public static String NO_SoundNotFound = "[prefix] &4Lyden &6[sound] &4ble ikke bli funnet! Vennligst sjekk innstillingene.";
|
|
||||||
|
|
||||||
}
|
|
@@ -1,49 +0,0 @@
|
|||||||
package net.t2code.t2codelib.SPIGOT.system.config.languages;
|
|
||||||
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
|
||||||
import net.t2code.t2codelib.Util;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class SelectLibMsg {
|
|
||||||
private static Plugin plugin = T2CodeLibMain.getPlugin();
|
|
||||||
|
|
||||||
public static String selectMSG;
|
|
||||||
|
|
||||||
public static String vaultNotSetUp;
|
|
||||||
public static String votingPluginNotSetUp;
|
|
||||||
public static String soundNotFound;
|
|
||||||
|
|
||||||
public static void onSelect() {
|
|
||||||
String prefix = Util.getPrefix();
|
|
||||||
|
|
||||||
T2Csend.debug(plugin, "§4Select language...");
|
|
||||||
long long_ = System.currentTimeMillis();
|
|
||||||
|
|
||||||
File msg;
|
|
||||||
|
|
||||||
msg = new File(T2CodeLibMain.getPath(), "languages/" + SelectLibConfig.getLanguage() + ".yml");
|
|
||||||
if (!msg.isFile()) {
|
|
||||||
T2Csend.console(prefix);
|
|
||||||
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
|
||||||
T2Csend.console(prefix + " §4The selected §c" + SelectLibConfig.getLanguage() + " §4language file was not found.");
|
|
||||||
T2Csend.console(prefix + " §6The default language §eEnglish §6is used!");
|
|
||||||
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
|
||||||
T2Csend.console(prefix);
|
|
||||||
msg = new File(T2CodeLibMain.getPath(), "languages/" + "english.yml");
|
|
||||||
selectMSG = "english";
|
|
||||||
} else selectMSG = SelectLibConfig.getLanguage();
|
|
||||||
YamlConfiguration yamlConfiguration_msg = YamlConfiguration.loadConfiguration(msg);
|
|
||||||
|
|
||||||
vaultNotSetUp = T2Creplace.replace(prefix, yamlConfiguration_msg.getString("Plugin.VaultNotSetUp"));
|
|
||||||
votingPluginNotSetUp = T2Creplace.replace(prefix, yamlConfiguration_msg.getString("Plugin.VotingPluginNotSetUp"));
|
|
||||||
soundNotFound = T2Creplace.replace(prefix, yamlConfiguration_msg.getString("Plugin.SoundNotFound"));
|
|
||||||
|
|
||||||
T2Csend.console(prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,108 @@
|
|||||||
|
// This class was created by JaTiTV.
|
||||||
|
|
||||||
|
package net.t2code.t2codelib.SPIGOT.system.config.languages;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.NonNull;
|
||||||
|
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||||
|
import net.t2code.t2codelib.util.T2C_ConfigItemLanguages;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_LanguageWriter;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class T2CLibLanguages {
|
||||||
|
|
||||||
|
public enum VALUES implements T2C_ConfigItemLanguages {
|
||||||
|
otherLang("plugin", null,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, null);
|
||||||
|
put(T2C_LanguageEnum.english, null);
|
||||||
|
}},
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("Wenn du eine Eigene Sprache hinzufügen magst, dann kopiere einfach eine Sprachdatei und benenne sie in deine Sprache, dies kannst du dann in der config.yml einstellen.", ""));
|
||||||
|
put(T2C_LanguageEnum.english, List.of("If you want to add your own language, simply copy a language file and rename it to your language, you can then set this in config.yml.", ""));
|
||||||
|
}}),
|
||||||
|
|
||||||
|
vaultNotSetUp("plugin.vaultNotSetUp",
|
||||||
|
null,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, "[prefix] &4Vault / Economy nicht eingerichtet!");
|
||||||
|
put(T2C_LanguageEnum.english, "[prefix] &4Vault / Economy not set up!");
|
||||||
|
}},
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("Diese Meldung wird angezeigt, wenn ein Plugin auf die Vault Schnittstelle von T2CodeLib zugreift und Vault oder kein Economy System vorhanden ist."));
|
||||||
|
put(T2C_LanguageEnum.english, List.of("This message is displayed if a plugin accesses the Vault interface of T2CodeLib and Vault or no Economy System is available."));
|
||||||
|
}}),
|
||||||
|
|
||||||
|
votingPluginNotSetUp("plugin.votingPluginNotSetUp",
|
||||||
|
null,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, "[prefix] &4VotingPlugin ist auf dem Server nicht vorhanden!");
|
||||||
|
put(T2C_LanguageEnum.english, "[prefix] &4VotingPlugin is not present on the server!");
|
||||||
|
}},
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("Diese Meldung wird angezeigt, wenn ein Plugin auf die VotingPlugin Schnittstelle von T2CodeLib zugreift und VotingPlugin nicht vorhanden ist.", "VotingPlugin: https://spigotmc.org/resources/votingplugin.15358/"));
|
||||||
|
put(T2C_LanguageEnum.english, List.of("This message is displayed if a plugin accesses the VotingPlugin interface of T2CodeLib and VotingPlugin is not available.", "VotingPlugin: https://spigotmc.org/resources/votingplugin.15358/"));
|
||||||
|
}}),
|
||||||
|
soundNotFound("plugin.soundNotFound",
|
||||||
|
null,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, "[prefix] &4Der Sound &6[sound] &4wurde nicht gefunden! Bitte überprüfe die Einstellungen.");
|
||||||
|
put(T2C_LanguageEnum.english, "[prefix] &4The sound &6[sound] &4was not found! Please check the settings.");
|
||||||
|
}},
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.german, List.of("Diese Meldung wird angezeigt, wenn ein Sound über die T2CodeLib abgespielt werden soll, den es nicht gibt"));
|
||||||
|
put(T2C_LanguageEnum.english, List.of());
|
||||||
|
}}),
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String path;
|
||||||
|
private Object value;
|
||||||
|
private final HashMap<T2C_LanguageEnum, String> lang;
|
||||||
|
private final HashMap<T2C_LanguageEnum, List<String>> comments;
|
||||||
|
|
||||||
|
VALUES(String path, Object value, @NonNull HashMap<T2C_LanguageEnum, String> lang, HashMap<T2C_LanguageEnum, List<String>> comments) {
|
||||||
|
this.path = path;
|
||||||
|
this.value = value;
|
||||||
|
this.lang = lang;
|
||||||
|
this.comments = comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getValue() {
|
||||||
|
if (value == null) {
|
||||||
|
return lang.get(T2C_LanguageEnum.english);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<T2C_LanguageEnum, String> getLanguage() {
|
||||||
|
return lang;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<T2C_LanguageEnum, List<String>> getComments() {
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValue(Object newValue) {
|
||||||
|
value = newValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void set(boolean isReload) {
|
||||||
|
T2C_LanguageWriter.createConfig(T2C_Util.getPrefix(), T2C_Main.getPath(), VALUES.values(), T2C_LibConfig.VALUES.language.getValue().toString(), isReload, T2C_Util.getConfigLogo());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -1,15 +0,0 @@
|
|||||||
package net.t2code.t2codelib;
|
|
||||||
|
|
||||||
public enum UpdateType {
|
|
||||||
PRERELEASE("<light_purple>Pre-Release</light_purple>"),
|
|
||||||
DEVELOPMENT("<dark_red>DEV</dark_red>"),
|
|
||||||
BETA("<gold>BETA</gold>"),
|
|
||||||
SNAPSHOT("<yellow>SNAPSHOT</yellow>"),
|
|
||||||
STABLE("<dark_green>STABLE</dark_green>");
|
|
||||||
|
|
||||||
public String text;
|
|
||||||
|
|
||||||
UpdateType(String text) {
|
|
||||||
this.text = text;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,62 +0,0 @@
|
|||||||
package net.t2code.t2codelib;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class Util {
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private static final UUID serverUUID = UUID.randomUUID();
|
|
||||||
|
|
||||||
|
|
||||||
public static String getInfoText() {
|
|
||||||
return "<yellow>Description:</yellow> <gold>"+T2CodeLibMain.getPlugin().getDescription().getDescription()+"</gold>" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getPrefix() {
|
|
||||||
return "<dark_gray>[<dark_red>T2Code</dark_red><dark_purple>Lib</dark_purple>]</dark_gray>";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Integer getSpigotID() {
|
|
||||||
return 96388;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getGit() {
|
|
||||||
return "JaTiTV/T2CodeLib";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Integer getBstatsID() {
|
|
||||||
return 12518;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getSpigot() {
|
|
||||||
return "https://www.spigotmc.org/resources/" + getSpigotID();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getDiscord() {
|
|
||||||
return "http://dc.t2code.net";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getT2cPlugins() {
|
|
||||||
return Arrays.asList(
|
|
||||||
"T2CodeLib",
|
|
||||||
"T2C-LuckyBox",
|
|
||||||
"WonderBagShop",
|
|
||||||
"CommandGUI",
|
|
||||||
// "T2C-OPSecurity",
|
|
||||||
"OPSecurity",
|
|
||||||
"PaPiTest",
|
|
||||||
"T2C-Alias",
|
|
||||||
"T2C-AutoResponse",
|
|
||||||
"LoreEditor",
|
|
||||||
"Booster",
|
|
||||||
"AntiMapCopy",
|
|
||||||
"AntiCopy",
|
|
||||||
"T2C-LoginPermissionAuth"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,32 @@
|
|||||||
|
// This class was created by JaTiTV.
|
||||||
|
|
||||||
|
package net.t2code.t2codelib.VELOCITY.api.commands;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.command.CommandManager;
|
||||||
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
|
import com.velocitypowered.api.proxy.ConsoleCommandSource;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.system.T2CV_Main;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
public class T2CV_Cmd {
|
||||||
|
|
||||||
|
private static final ProxyServer server = T2CV_Main.getServer();
|
||||||
|
private static final Logger logger = T2CV_Main.getLogger();
|
||||||
|
|
||||||
|
public static void Console(String cmd) {
|
||||||
|
// Get the console command source
|
||||||
|
ConsoleCommandSource console = server.getConsoleCommandSource();
|
||||||
|
|
||||||
|
// Dispatch the command
|
||||||
|
server.getCommandManager().executeAsync(console, cmd).join();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Player(CommandSource player, String cmd) {
|
||||||
|
CommandManager commandManager = server.getCommandManager();
|
||||||
|
|
||||||
|
// Dispatch the command
|
||||||
|
commandManager.executeImmediatelyAsync(player, cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,97 @@
|
|||||||
|
package net.t2code.t2codelib.VELOCITY.api.messages;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.title.Title;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.system.config.T2CV_LibConfig;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class T2CV_Send {
|
||||||
|
|
||||||
|
public static void console(Logger logger, String msg) {
|
||||||
|
if (msg == null || msg.contains("[empty]")) return;
|
||||||
|
logger.info(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void player(Player player, String msg) {
|
||||||
|
if (msg == null || msg.contains("[empty]")) return;
|
||||||
|
player.sendMessage(Component.text(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sender(CommandSource sender, String msg) {
|
||||||
|
if (msg == null || msg.contains("[empty]")) return;
|
||||||
|
sender.sendMessage(Component.text(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void console(Logger logger, Object object) {
|
||||||
|
for (String msg : list(object)) {
|
||||||
|
if (msg == null || msg.contains("[empty]")) continue;
|
||||||
|
logger.info(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void player(Player player, Object object) {
|
||||||
|
for (String msg : list(object)) {
|
||||||
|
if (msg == null || msg.contains("[empty]")) continue;
|
||||||
|
player.sendMessage(Component.text(msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void sender(CommandSource sender, Object object) {
|
||||||
|
for (String msg : list(object)) {
|
||||||
|
if (msg == null || msg.contains("[empty]")) return;
|
||||||
|
sender.sendMessage(Component.text(msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void title(Player player, @Nullable String title, @Nullable String subtitle, Integer fadeIn, Integer stay, Integer fadeOut) {
|
||||||
|
Component titleComponent = title != null ? Component.text(title) : Component.empty();
|
||||||
|
Component subtitleComponent = subtitle != null ? Component.text(subtitle) : Component.empty();
|
||||||
|
|
||||||
|
Title.Times times = Title.Times.times(Duration.ofSeconds(fadeIn == null ? 1 : fadeIn), Duration.ofSeconds(stay == null ? 3 : stay), Duration.ofSeconds(fadeOut == null ? 1 : fadeOut));
|
||||||
|
Title playerTitle = Title.title(titleComponent, subtitleComponent, times);
|
||||||
|
|
||||||
|
player.showTitle(playerTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void debugmsg(Logger logger, String msg) {
|
||||||
|
logger.warn(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void debug(Logger logger, String msg) {
|
||||||
|
if (!(boolean) T2CV_LibConfig.VALUES.debug.getValue()) return;
|
||||||
|
logger.warn(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void info(Logger logger, String msg) {
|
||||||
|
logger.info(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void warning(Logger logger, String msg) {
|
||||||
|
logger.warn(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void error(Logger logger, String msg) {
|
||||||
|
logger.error(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ArrayList<String> list(Object object) {
|
||||||
|
ArrayList<String> list = new ArrayList<>();
|
||||||
|
|
||||||
|
if (object instanceof List) {
|
||||||
|
list = (ArrayList<String>) object;
|
||||||
|
}
|
||||||
|
if (object instanceof String) {
|
||||||
|
list.add((String) object);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,56 @@
|
|||||||
|
// This class was created by JaTiTV.
|
||||||
|
|
||||||
|
package net.t2code.t2codelib.VELOCITY.api.pluginMessaging;
|
||||||
|
|
||||||
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
import com.google.common.io.ByteStreams;
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.api.commands.T2CV_Cmd;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.system.T2CV_Main;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
public class T2CV_PluginMessageProxyCommand {
|
||||||
|
|
||||||
|
private final ProxyServer server;
|
||||||
|
private final Logger logger;
|
||||||
|
|
||||||
|
|
||||||
|
public T2CV_PluginMessageProxyCommand(ProxyServer server, Logger logger) {
|
||||||
|
this.server = server;
|
||||||
|
this.logger = logger;
|
||||||
|
server.getChannelRegistrar().register(T2CV_Main.bcmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onPluginMessageFromPlayer(PluginMessageEvent event) {
|
||||||
|
if (event.getIdentifier() != T2CV_Main.bcmd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ByteArrayDataInput stream = ByteStreams.newDataInput(event.getData());
|
||||||
|
String channel = stream.readUTF();
|
||||||
|
String input = stream.readUTF();
|
||||||
|
String serverID;
|
||||||
|
try {
|
||||||
|
serverID = stream.readUTF();
|
||||||
|
} catch (Exception i) {
|
||||||
|
serverID = "not Found";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (channel.equals("T2Code-Console")) {
|
||||||
|
logger.info("{} [{}] T2C BCMD Command Console: {}", T2C_Util.getVPrefix(), serverID, input);
|
||||||
|
T2CV_Cmd.Console(input);
|
||||||
|
} else {
|
||||||
|
Player player = server.getPlayer(channel).orElse(null);
|
||||||
|
if (player != null) {
|
||||||
|
logger.info("{} [{}] T2C BCMD Command {}: {}", T2C_Util.getVPrefix(), serverID, player, input);
|
||||||
|
T2CV_Cmd.Player(player, input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
event.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,62 @@
|
|||||||
|
// This class was created by JaTiTV.
|
||||||
|
|
||||||
|
package net.t2code.t2codelib.VELOCITY.api.pluginMessaging.autoResponse;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.api.commands.T2CV_Cmd;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.api.messages.T2CV_Send;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.system.T2CV_Main;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class T2CV_API_AutoResponse {
|
||||||
|
private final ProxyServer server;
|
||||||
|
private final Logger logger;
|
||||||
|
|
||||||
|
public T2CV_API_AutoResponse(ProxyServer server, Logger logger) {
|
||||||
|
this.server = server;
|
||||||
|
this.logger = logger;
|
||||||
|
server.getChannelRegistrar().register(T2CV_Main.aresp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onPluginmessage(PluginMessageEvent event) {
|
||||||
|
if (event.getIdentifier() != T2CV_Main.aresp) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
||||||
|
|
||||||
|
try {
|
||||||
|
String channel = stream.readUTF();
|
||||||
|
String input = stream.readUTF();
|
||||||
|
|
||||||
|
switch (channel) {
|
||||||
|
case "ConC":
|
||||||
|
logger.info("Command Console: {}", input);
|
||||||
|
T2CV_Cmd.Console(input);
|
||||||
|
break;
|
||||||
|
case "ALLPMSG":
|
||||||
|
for (Player player : server.getAllPlayers()) {
|
||||||
|
T2CV_Send.player(player, input);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Player player = server.getPlayer(channel).orElse(null);
|
||||||
|
if (player != null) {
|
||||||
|
logger.info("Command Console: {}", input);
|
||||||
|
T2CV_Cmd.Player(player, input);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,75 @@
|
|||||||
|
// This class was created by JaTiTV.
|
||||||
|
|
||||||
|
package net.t2code.t2codelib.VELOCITY.api.pluginMessaging.commandgui;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||||
|
import com.velocitypowered.api.event.connection.PostLoginEvent;
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.system.T2CV_Main;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class T2CV_API_CGUI {
|
||||||
|
|
||||||
|
private static ProxyServer server;
|
||||||
|
private static Logger logger;
|
||||||
|
|
||||||
|
public T2CV_API_CGUI(ProxyServer server, Logger logger) {
|
||||||
|
T2CV_API_CGUI.server = server;
|
||||||
|
T2CV_API_CGUI.logger = logger;
|
||||||
|
server.getChannelRegistrar().register(T2CV_Main.cguiopl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onJoin(PostLoginEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
sendToSpigotPlayer(player.getUsername(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onDisconnect(DisconnectEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
sendToSpigotPlayer(player.getUsername(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendToSpigotPlayer(String name, Boolean join) {
|
||||||
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream output = new DataOutputStream(stream);
|
||||||
|
try {
|
||||||
|
if (join) {
|
||||||
|
output.writeUTF("join");
|
||||||
|
} else {
|
||||||
|
output.writeUTF("left");
|
||||||
|
}
|
||||||
|
output.writeUTF(name);
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.warn(e.getMessage());
|
||||||
|
}
|
||||||
|
byte[] data = stream.toByteArray();
|
||||||
|
for (RegisteredServer server : server.getAllServers()) {
|
||||||
|
server.sendPluginMessage(T2CV_Main.cguiopl, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendToSpigotDeleteAll() {
|
||||||
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream output = new DataOutputStream(stream);
|
||||||
|
try {
|
||||||
|
output.writeUTF("clear");
|
||||||
|
output.writeUTF("");
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.warn(e.getMessage());
|
||||||
|
}
|
||||||
|
byte[] data = stream.toByteArray();
|
||||||
|
for (RegisteredServer server : server.getAllServers()) {
|
||||||
|
server.sendPluginMessage(T2CV_Main.cguiopl, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,58 @@
|
|||||||
|
// This class was created by JaTiTV.
|
||||||
|
|
||||||
|
package net.t2code.t2codelib.VELOCITY.api.pluginMessaging.opSecurity;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.system.T2CV_Main;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class T2CV_API_OpSecurity {
|
||||||
|
private static ProxyServer server ;
|
||||||
|
private static Logger logger ;
|
||||||
|
|
||||||
|
public T2CV_API_OpSecurity(ProxyServer server, Logger logger) {
|
||||||
|
T2CV_API_OpSecurity.server = server;
|
||||||
|
T2CV_API_OpSecurity.logger = logger;
|
||||||
|
server.getChannelRegistrar().register(T2CV_Main.opsec);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onPluginmessage(PluginMessageEvent event) {
|
||||||
|
if (event.getIdentifier() != T2CV_Main.opsec) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
||||||
|
try {
|
||||||
|
String channel = stream.readUTF();
|
||||||
|
String mode = stream.readUTF();
|
||||||
|
String information = stream.readUTF();
|
||||||
|
if (channel.equals("T2Cconsole")) {
|
||||||
|
sendToSpigotPlayer(channel,mode,information);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sendToSpigotPlayer(String channel,String mode,String information) {
|
||||||
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream output = new DataOutputStream(stream);
|
||||||
|
try {
|
||||||
|
output.writeUTF(channel);
|
||||||
|
output.writeUTF(mode);
|
||||||
|
output.writeUTF(information);
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
}
|
||||||
|
for (RegisteredServer server : server.getAllServers()) {
|
||||||
|
server.sendPluginMessage(T2CV_Main.opsec, stream.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,112 @@
|
|||||||
|
// This class was created by JaTiTV.
|
||||||
|
|
||||||
|
package net.t2code.t2codelib.VELOCITY.api.proxyPlayers;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||||
|
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||||
|
import com.velocitypowered.api.event.connection.PostLoginEvent;
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2C_BngeePlayersEnum;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.api.messages.T2CV_Send;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.system.T2CV_Main;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
|
||||||
|
public class T2CV_Players {
|
||||||
|
|
||||||
|
public static ProxyServer server = T2CV_Main.getServer();
|
||||||
|
public static Logger logger = T2CV_Main.getLogger();
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onJoin(PostLoginEvent e) {
|
||||||
|
sendToSpigotPlayer(e.getPlayer().getUsername(), T2C_BngeePlayersEnum.JOIN, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onDisconnect(DisconnectEvent e) {
|
||||||
|
sendToSpigotPlayer(e.getPlayer().getUsername(), T2C_BngeePlayersEnum.QUIT, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendToSpigotPlayer(String name, T2C_BngeePlayersEnum value, String uuid) {
|
||||||
|
switch (value) {
|
||||||
|
case JOIN:
|
||||||
|
case QUIT:
|
||||||
|
sendToSpigotPlayerExecute(name, value, uuid);
|
||||||
|
break;
|
||||||
|
case GIVEALL:
|
||||||
|
StringBuilder input = new StringBuilder();
|
||||||
|
for (Player player : server.getAllPlayers()) {
|
||||||
|
input.append(player.getUsername()).append(";");
|
||||||
|
}
|
||||||
|
sendToSpigotPlayerExecute(input.toString(), T2C_BngeePlayersEnum.GIVEALL, uuid);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendToSpigotPlayerExecute(String name, T2C_BngeePlayersEnum value, String uuid) {
|
||||||
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream output = new DataOutputStream(stream);
|
||||||
|
try {
|
||||||
|
output.writeUTF(value.name());
|
||||||
|
output.writeUTF(name);
|
||||||
|
output.writeUTF(uuid);
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error (e.getMessage());
|
||||||
|
}
|
||||||
|
T2CV_Send.debug(logger, "PluginMessage received channel: "+ T2C_Util.getPluginChannel_ProxyOnlinePlayers());
|
||||||
|
T2CV_Send.debug(logger, "PluginMessage received subChannel: " + value.name());
|
||||||
|
T2CV_Send.debug(logger, "PluginMessage received input: " + name);
|
||||||
|
T2CV_Send.debug(logger, "PluginMessage received input2/uuid: " + uuid);
|
||||||
|
byte[] data = stream.toByteArray();
|
||||||
|
for (RegisteredServer server : server.getAllServers()) {
|
||||||
|
server.sendPluginMessage(T2CV_Main.bonlp, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendToSpigotDeleteAll() {
|
||||||
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream output = new DataOutputStream(stream);
|
||||||
|
try {
|
||||||
|
output.writeUTF(T2C_BngeePlayersEnum.CLEAR.name());
|
||||||
|
output.writeUTF("");
|
||||||
|
output.writeUTF("");
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
}
|
||||||
|
byte[] data = stream.toByteArray();
|
||||||
|
for (RegisteredServer server : server.getAllServers()) {
|
||||||
|
server.sendPluginMessage(T2CV_Main.bonlp, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onPluginMessage(PluginMessageEvent event) {
|
||||||
|
if (event.getIdentifier() != T2CV_Main.bonlp) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
||||||
|
|
||||||
|
try {
|
||||||
|
T2C_BngeePlayersEnum subChannel = T2C_BngeePlayersEnum.valueOf(stream.readUTF());
|
||||||
|
String input = stream.readUTF();
|
||||||
|
|
||||||
|
T2CV_Send.debug(logger, "PluginMessage received channel: " + T2CV_Main.bonlp);
|
||||||
|
T2CV_Send.debug(logger, "PluginMessage received subChannel: " + subChannel.name());
|
||||||
|
T2CV_Send.debug(logger, "PluginMessage received input/uuid: " + input);
|
||||||
|
|
||||||
|
sendToSpigotPlayer("", subChannel, input);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,77 @@
|
|||||||
|
package net.t2code.t2codelib.VELOCITY.api.update;
|
||||||
|
|
||||||
|
|
||||||
|
import com.velocitypowered.api.plugin.PluginContainer;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import net.t2code.t2codelib.util.T2C_GenerateFrame;
|
||||||
|
import net.t2code.t2codelib.util.T2C_UpdateObject;
|
||||||
|
import net.t2code.t2codelib.util.T2C_UpdateWebData;
|
||||||
|
import net.t2code.t2codelib.util.T2C_UpdateType;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.api.messages.T2CV_Send;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.system.config.T2CV_LibConfig;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class T2CV_UpdateAPI {
|
||||||
|
public static HashMap<String, T2C_UpdateObject> bungeePluginVersins = new HashMap<>();
|
||||||
|
|
||||||
|
public static void sendUpdateMsg(Logger logger, String prefix, String discord, T2C_UpdateWebData webData, PluginContainer plugin) {
|
||||||
|
String publicVersion = webData.getVersion();
|
||||||
|
String pluginVersion = plugin.getDescription().getVersion().orElse("unknown");
|
||||||
|
String value;
|
||||||
|
if (webData.isPreRelease()) {
|
||||||
|
value = T2C_UpdateType.PRERELEASE_.text;
|
||||||
|
if (publicVersion.toLowerCase().contains("dev")) {
|
||||||
|
value = T2C_UpdateType.DEVELOPMENT_.text;
|
||||||
|
}
|
||||||
|
if (publicVersion.toLowerCase().contains("beta")) {
|
||||||
|
value = T2C_UpdateType.BETA_.text;
|
||||||
|
}
|
||||||
|
if (publicVersion.toLowerCase().contains("snapshot")) {
|
||||||
|
value = T2C_UpdateType.SNAPSHOT_.text;
|
||||||
|
}
|
||||||
|
} else value = T2C_UpdateType.STABLE_.text;
|
||||||
|
String s1 = "A new [value] version was found!".replace("[value]", value);
|
||||||
|
String s2 = "Your version: " + pluginVersion + " - Current version: " + webData.getVersion();
|
||||||
|
String s3 = "You can download it here: " + webData.getUpdateUrl();
|
||||||
|
String s4 = "You can find more information on Discord: " + discord;
|
||||||
|
|
||||||
|
T2CV_Send.console(logger, T2C_GenerateFrame.getFrameCenter("[t2codelib]", true, s1, s2, s3, s4));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Boolean noUpdate = true;
|
||||||
|
private static String pluginVersion;
|
||||||
|
|
||||||
|
public static void onUpdateCheckTimer(Logger logger, PluginContainer plugin, ProxyServer server, String prefix, String discord, Integer spigotID, String url) {
|
||||||
|
if ((int) T2CV_LibConfig.VALUES.updateTimer.getValue() < 1) {
|
||||||
|
T2CV_LibConfig.VALUES.updateTimer.setValue(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
server.getScheduler().buildTask(plugin, () -> {
|
||||||
|
(new T2CV_UpdateCheckerGit(plugin, logger)).getVersion((webData) -> {
|
||||||
|
pluginVersion = plugin.getDescription().getVersion().toString();
|
||||||
|
T2C_UpdateObject update = new T2C_UpdateObject(
|
||||||
|
plugin.getDescription().getName().toString(),
|
||||||
|
plugin.getDescription().getVersion().toString(),
|
||||||
|
webData,
|
||||||
|
false,
|
||||||
|
!plugin.getDescription().getVersion().equals(webData.getVersion()),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
bungeePluginVersins.put(plugin.getDescription().getName().toString(), update);
|
||||||
|
if (!pluginVersion.replace("_Velocity", "").equalsIgnoreCase(webData.getVersion())) {
|
||||||
|
sendUpdateMsg(logger, prefix, discord, webData, plugin);
|
||||||
|
noUpdate = true;
|
||||||
|
} else {
|
||||||
|
if (noUpdate) {
|
||||||
|
T2CV_Send.console(logger, " No update found.");
|
||||||
|
noUpdate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, pluginVersion, spigotID, url);
|
||||||
|
|
||||||
|
}).repeat(Duration.ofMinutes((int) T2CV_LibConfig.VALUES.updateTimer.getValue())).schedule();
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,101 @@
|
|||||||
|
package net.t2code.t2codelib.VELOCITY.api.update;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.plugin.PluginContainer;
|
||||||
|
import net.t2code.t2codelib.BUNGEE.system.config.T2CB_LibConfig;
|
||||||
|
import net.t2code.t2codelib.util.T2C_UpdateObject;
|
||||||
|
import net.t2code.t2codelib.util.T2C_UpdateWebData;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
||||||
|
public class T2CV_UpdateCheckerGit {
|
||||||
|
private PluginContainer plugin;
|
||||||
|
private Logger logger;
|
||||||
|
|
||||||
|
|
||||||
|
public T2CV_UpdateCheckerGit(PluginContainer plugin, Logger logger) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.logger=logger;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getVersion(Consumer<T2C_UpdateWebData> consumer, String pluginVersion, Integer spigotID, String gitKey) {
|
||||||
|
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1";
|
||||||
|
if (!(boolean) T2CB_LibConfig.VALUES.seePreReleaseUpdates.getValue() ) {
|
||||||
|
RepoURL = RepoURL + "&pre-release=false";
|
||||||
|
}
|
||||||
|
String finalRepoURL = RepoURL;
|
||||||
|
|
||||||
|
try {
|
||||||
|
URL url = new URL(finalRepoURL);
|
||||||
|
URLConnection yc = url.openConnection();
|
||||||
|
BufferedReader in = new BufferedReader(
|
||||||
|
new InputStreamReader(
|
||||||
|
yc.getInputStream()));
|
||||||
|
String inputLine;
|
||||||
|
String data = "";
|
||||||
|
while ((inputLine = in.readLine()) != null)
|
||||||
|
data = inputLine;
|
||||||
|
in.close();
|
||||||
|
data = data.substring(1, data.length() - 1);
|
||||||
|
if (data.isEmpty()) {
|
||||||
|
consumer.accept(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JSONObject obj = new JSONObject(data);
|
||||||
|
String updateTitle = obj.getString("name");
|
||||||
|
String version = obj.getString("tag_name");
|
||||||
|
String updateDescription = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''");
|
||||||
|
String updateUrl = obj.getString("html_url");
|
||||||
|
boolean preRelease = obj.getBoolean("prerelease");
|
||||||
|
|
||||||
|
String date = obj.getString("published_at");
|
||||||
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||||
|
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
|
||||||
|
Date parsedDate = inputFormat.parse(date);
|
||||||
|
String publishedAt = outputFormat.format(parsedDate);
|
||||||
|
|
||||||
|
JSONArray downloadArray = obj.getJSONArray("assets");
|
||||||
|
String gitURL = updateUrl;
|
||||||
|
String downloadURL;
|
||||||
|
if (downloadArray.isEmpty()) {
|
||||||
|
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
|
||||||
|
} else {
|
||||||
|
downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!preRelease) {
|
||||||
|
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
|
||||||
|
updateUrl = "https://www.spigotmc.org/resources/" + spigotID;
|
||||||
|
}
|
||||||
|
|
||||||
|
T2C_UpdateWebData webData = new T2C_UpdateWebData(updateTitle, version, updateDescription, updateUrl, publishedAt, downloadURL, gitURL, preRelease);
|
||||||
|
consumer.accept(webData);
|
||||||
|
} catch (Exception var10) {
|
||||||
|
Boolean load = false;
|
||||||
|
if (T2CV_UpdateAPI.bungeePluginVersins.containsKey(plugin.getDescription().getName().toString())) {
|
||||||
|
load = T2CV_UpdateAPI.bungeePluginVersins.get(plugin.getDescription().getName().toString()).load;
|
||||||
|
}
|
||||||
|
T2C_UpdateObject update = new T2C_UpdateObject(
|
||||||
|
plugin.getDescription().getName().toString(),
|
||||||
|
pluginVersion,
|
||||||
|
null,
|
||||||
|
load,
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
T2CV_UpdateAPI.bungeePluginVersins.put(plugin.getDescription().getName().toString(), update);
|
||||||
|
logger.error("Cannot look for updates: {}", var10.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,165 @@
|
|||||||
|
package net.t2code.t2codelib.VELOCITY.api.yml;// This class was created by JaTiTV.
|
||||||
|
|
||||||
|
|
||||||
|
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||||
|
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class T2CV_ConfigWriter {
|
||||||
|
|
||||||
|
public static void createConfig(Logger logger, File configFile, T2C_ConfigItem[] manager, String... header) throws IOException {
|
||||||
|
boolean exist = configFile.exists();
|
||||||
|
if (!exist) {
|
||||||
|
configFile.getParentFile().mkdirs();
|
||||||
|
try {
|
||||||
|
configFile.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Yaml yaml = new Yaml();
|
||||||
|
Map<String, Object> config = yaml.load(Files.newInputStream(configFile.toPath()));
|
||||||
|
Map<String, List<String>> comments = new LinkedHashMap<>();
|
||||||
|
if (config == null) {
|
||||||
|
config = new LinkedHashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
T2C_LanguageEnum lang = T2C_LanguageEnum.english;
|
||||||
|
|
||||||
|
for (T2C_ConfigItem item : manager) {
|
||||||
|
if (item.getForceSet() || !exist) {
|
||||||
|
readValue(config, item.getPath(), item);
|
||||||
|
addValue(config, item.getPath(), item.getValue());
|
||||||
|
List<String> commandList = item.getComments().get(lang);
|
||||||
|
if (commandList != null) {
|
||||||
|
comments.put(item.getPath(), commandList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
saveConfigWithComments(configFile, comments, config, header);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void readValue(Map<String, Object> config, String path, T2C_ConfigItem value) {
|
||||||
|
if (path.contains(".")) {
|
||||||
|
String[] pathsplit = path.split("\\.");
|
||||||
|
String key = pathsplit[0];
|
||||||
|
if (config.containsKey(key)) {
|
||||||
|
StringBuilder zw = new StringBuilder();
|
||||||
|
for (int i = 1; i < pathsplit.length; i++) {
|
||||||
|
zw.append(pathsplit[i]);
|
||||||
|
if (i != (pathsplit.length - 1)) {
|
||||||
|
zw.append(".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
readValue((Map<String, Object>) config.get(key), zw.toString(), value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Object vl = config.get(path);
|
||||||
|
if (vl != null) {
|
||||||
|
value.setValue(vl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addValue(Map<String, Object> config, String path, Object value) {
|
||||||
|
if (path.contains(".")) {
|
||||||
|
String[] pathsplit = path.split("\\.");
|
||||||
|
String key = pathsplit[0];
|
||||||
|
if (config.containsKey(key)) {
|
||||||
|
StringBuilder zw = new StringBuilder();
|
||||||
|
for (int i = 1; i < pathsplit.length; i++) {
|
||||||
|
zw.append(pathsplit[i]);
|
||||||
|
if (i != (pathsplit.length - 1)) {
|
||||||
|
zw.append(".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addValue((Map<String, Object>) config.get(key), zw.toString(), value);
|
||||||
|
} else {
|
||||||
|
Map<String, Object> newMap = new LinkedHashMap<>();
|
||||||
|
StringBuilder zw = new StringBuilder();
|
||||||
|
for (int i = 1; i < pathsplit.length; i++) {
|
||||||
|
zw.append(pathsplit[i]);
|
||||||
|
if (i != (pathsplit.length - 1)) {
|
||||||
|
zw.append(".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addValue(newMap, zw.toString(), value);
|
||||||
|
config.put(key, newMap);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!config.containsKey(path)) {
|
||||||
|
config.put(path, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void saveConfigWithComments(File file, Map<String, List<String>> comments, Map<String, Object> config, String... headers) {
|
||||||
|
try {
|
||||||
|
StringBuilder configContent = new StringBuilder();
|
||||||
|
for (String h : headers) {
|
||||||
|
configContent.append(h).append("\n");
|
||||||
|
}
|
||||||
|
configContent.append("\n");
|
||||||
|
addSection(config, comments, configContent, "", 0);
|
||||||
|
|
||||||
|
// Write the content to the file
|
||||||
|
Files.write(file.toPath(), configContent.toString().getBytes());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addSection(Map<String, Object> config, Map<String, List<String>> comments, StringBuilder builder, String prefix, int indentLevel) {
|
||||||
|
String indent = " ".repeat(indentLevel);
|
||||||
|
|
||||||
|
|
||||||
|
for (Map.Entry<String, Object> key : config.entrySet()) {
|
||||||
|
String fullKey = prefix.isEmpty() ? key.getKey() : prefix + "." + key.getKey();
|
||||||
|
Object value = key.getValue();
|
||||||
|
|
||||||
|
// Add comment if it exists for this key
|
||||||
|
List<String> commentList = comments.get(fullKey);
|
||||||
|
if (commentList != null) {
|
||||||
|
for (String c : commentList) {
|
||||||
|
if (c.isEmpty()) {
|
||||||
|
builder.append(indent).append(c).append("\n");
|
||||||
|
} else builder.append(indent).append("# ").append(c).append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check if the value is a section (nested map)
|
||||||
|
if (value instanceof Map) {
|
||||||
|
// Correctly add the section
|
||||||
|
builder.append(indent).append(key.getKey()).append(":\n");
|
||||||
|
addSection((Map<String, Object>) value, comments, builder, fullKey, indentLevel + 1);
|
||||||
|
} else {
|
||||||
|
// Add value with proper indentation
|
||||||
|
// builder.append(indent).append(key.getKey()).append(": ").append(value).append("\n");
|
||||||
|
if (value instanceof List) {
|
||||||
|
builder.append(indent).append(key.getKey()).append(": ").append("\n");
|
||||||
|
List<Object> zw = (List<Object>) value;
|
||||||
|
for (Object s : zw) {
|
||||||
|
if (s instanceof String) {
|
||||||
|
builder.append(indent).append("- \"").append(s).append("\"\n");
|
||||||
|
} else builder.append(indent).append("- ").append(s).append("\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (value instanceof String) {
|
||||||
|
builder.append(indent).append(key.getKey()).append(": \"").append(value).append("\"\n");
|
||||||
|
} else builder.append(indent).append(key.getKey()).append(": ").append(value).append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,122 @@
|
|||||||
|
// This class was created by JaTiTV.
|
||||||
|
|
||||||
|
package net.t2code.t2codelib.VELOCITY.system;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||||
|
import com.velocitypowered.api.plugin.PluginContainer;
|
||||||
|
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||||
|
import net.t2code.t2codelib.util.T2C_GenerateFrame;
|
||||||
|
import net.t2code.t2codelib.util.T2C_PlatformDetector;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.T2CV_PluginMessageProxyCommand;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.autoResponse.T2CV_API_AutoResponse;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.commandgui.T2CV_API_CGUI;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.opSecurity.T2CV_API_OpSecurity;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.api.proxyPlayers.T2CV_Players;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.api.update.T2CV_UpdateAPI;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.system.bstats.T2CV_Metrics;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.system.config.T2CV_LibConfig;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public class T2CV_Main {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static ProxyServer server;
|
||||||
|
@Getter
|
||||||
|
private static Logger logger;
|
||||||
|
@Getter
|
||||||
|
private PluginContainer plugin;
|
||||||
|
@Getter
|
||||||
|
private final long starttime;
|
||||||
|
@Getter
|
||||||
|
private static Path dataDirectory;
|
||||||
|
|
||||||
|
private final T2CV_Metrics.Factory metricsFactory;
|
||||||
|
|
||||||
|
public static final MinecraftChannelIdentifier bcmd = MinecraftChannelIdentifier.from(T2C_Util.getPluginChannel_ProxyCommand());
|
||||||
|
public static final MinecraftChannelIdentifier bonlp = MinecraftChannelIdentifier.from(T2C_Util.getPluginChannel_ProxyOnlinePlayers());
|
||||||
|
public static final MinecraftChannelIdentifier cguiopl = MinecraftChannelIdentifier.from(T2C_Util.getPluginChannel_CGUIOnlinePlayers());
|
||||||
|
public static final MinecraftChannelIdentifier aresp = MinecraftChannelIdentifier.from(T2C_Util.getPluginChannel_AutoResponse());
|
||||||
|
public static final MinecraftChannelIdentifier opsec = MinecraftChannelIdentifier.from(T2C_Util.getPluginChannel_OPSecurity());
|
||||||
|
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public T2CV_Main(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory, T2CV_Metrics.Factory metricsFactory) {
|
||||||
|
T2C_PlatformDetector.scan();
|
||||||
|
starttime = System.currentTimeMillis();
|
||||||
|
T2CV_Main.server = server;
|
||||||
|
T2CV_Main.logger = logger;
|
||||||
|
T2CV_Main.dataDirectory = dataDirectory;
|
||||||
|
this.metricsFactory = metricsFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onLoad(ProxyInitializeEvent e) {
|
||||||
|
new pl(this, server);
|
||||||
|
// logger.info("║");
|
||||||
|
for (String s : T2C_Util.getLoadLogo()) {
|
||||||
|
logger.info(T2C_GenerateFrame.removeColorCodes(s));
|
||||||
|
}
|
||||||
|
// Thread.sleep(5000);
|
||||||
|
logger.info(T2C_GenerateFrame.setCenterAligned("", "Author: " + String.valueOf(plugin.getDescription().getAuthors()).replace("[", "").replace("]", "")));
|
||||||
|
logger.info(T2C_GenerateFrame.setCenterAligned("", "Version: " + plugin.getDescription().getVersion().orElse("unknown")));
|
||||||
|
logger.info(T2C_GenerateFrame.setCenterAligned("", "Spigot: " + T2C_Util.getSpigot()));
|
||||||
|
logger.info(T2C_GenerateFrame.setCenterAligned("", "Discord: " + T2C_Util.getDiscord()));
|
||||||
|
|
||||||
|
try {
|
||||||
|
T2CV_LibConfig.set(dataDirectory, logger);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// new T2CVcmd(server, logger);
|
||||||
|
// server.getEventManager().register(this, new T2CVpluginMessagingCmd(server, logger));
|
||||||
|
|
||||||
|
//API
|
||||||
|
|
||||||
|
server.getEventManager().register(this, new T2CV_PluginMessageProxyCommand(server, logger));
|
||||||
|
|
||||||
|
|
||||||
|
server.getChannelRegistrar().register(T2CV_Main.bonlp);
|
||||||
|
T2CV_Players.sendToSpigotDeleteAll();
|
||||||
|
|
||||||
|
if ((boolean) T2CV_LibConfig.VALUES.apiCommandGUIEnable.getValue()) {
|
||||||
|
server.getEventManager().register(this, new T2CV_API_CGUI(server, logger));
|
||||||
|
T2CV_API_CGUI.sendToSpigotDeleteAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((boolean) T2CV_LibConfig.VALUES.apiAutoResponse.getValue()) {
|
||||||
|
server.getEventManager().register(this, new T2CV_API_AutoResponse(server, logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((boolean) T2CV_LibConfig.VALUES.apiOpSecurity.getValue()) {
|
||||||
|
server.getEventManager().register(this, new T2CV_API_OpSecurity(server, logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
T2CV_Metrics.bStats(this, T2C_Util.getBstatsID(), metricsFactory);
|
||||||
|
T2CV_UpdateAPI.onUpdateCheckTimer(logger, plugin, server, T2C_Util.getVPrefix(), T2C_Util.getDiscord(), T2C_Util.getSpigotID(), T2C_Util.getGit());
|
||||||
|
logger.info(T2C_GenerateFrame.setCenterAligned("", ""));
|
||||||
|
logger.info(T2C_GenerateFrame.setCenterAligned("", "Plugin loaded successfully - " + (System.currentTimeMillis() - starttime) + "ms"));
|
||||||
|
|
||||||
|
logger.info(T2C_GenerateFrame.getBOTTOM_BORDER());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class pl {
|
||||||
|
public pl(Object pl, ProxyServer server) {
|
||||||
|
plugin = server.getPluginManager().fromInstance(pl)
|
||||||
|
.orElseThrow(() -> new IllegalArgumentException("The provided instance is not a plugin"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,96 @@
|
|||||||
|
package net.t2code.t2codelib.VELOCITY.system.config;
|
||||||
|
|
||||||
|
import net.t2code.t2codelib.util.T2C_GenerateFrame;
|
||||||
|
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||||
|
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||||
|
import net.t2code.t2codelib.util.T2C_Util;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.api.messages.T2CV_Send;
|
||||||
|
import net.t2code.t2codelib.VELOCITY.api.yml.T2CV_ConfigWriter;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class T2CV_LibConfig {
|
||||||
|
|
||||||
|
public enum VALUES implements T2C_ConfigItem {
|
||||||
|
updateTimer("updateCheck.timerInMin", 60, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.english, List.of("In this option you can set the time interval in minutes in which updates should be checked."));
|
||||||
|
}}),
|
||||||
|
seePreReleaseUpdates("updateCheck.seePreReleaseUpdates", true, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.english, List.of("In this option you can set whether you want to receive and display beta and snapshot versions in the update check."));
|
||||||
|
}}),
|
||||||
|
|
||||||
|
debug("plugin.debug.debugModus", false, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.english, List.of("The debug mode sends more detailed debug information to the console."));
|
||||||
|
}}),
|
||||||
|
|
||||||
|
apiCommandGUIEnable("api.commandGUI.enable", false, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.english, List.of("With this option you activate the api interface for the T2C-CommandGUI plugin."));
|
||||||
|
}}),
|
||||||
|
apiAutoResponse("api.autoResponse.enable", false, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.english, List.of("With this option you activate the api interface for the T2C-AutoResponse plugin."));
|
||||||
|
}}),
|
||||||
|
apiOpSecurity("api.opSecurity.enable", false, true,
|
||||||
|
new HashMap<>() {{
|
||||||
|
put(T2C_LanguageEnum.english, List.of("With this option you activate the api interface for the T2C-OPSecurity plugin."));
|
||||||
|
}}),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String path;
|
||||||
|
private Object value;
|
||||||
|
private final boolean forceSet;
|
||||||
|
private final HashMap<T2C_LanguageEnum, List<String>> comments;
|
||||||
|
|
||||||
|
VALUES(String path, Object value, boolean forceSet, HashMap<T2C_LanguageEnum, List<String>> comments) {
|
||||||
|
this.path = path;
|
||||||
|
this.value = value;
|
||||||
|
this.forceSet = forceSet;
|
||||||
|
this.comments = comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getForceSet() {
|
||||||
|
return forceSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<T2C_LanguageEnum, List<String>> getComments() {
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLanguagePath() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValue(Object newValue) {
|
||||||
|
value = newValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void set(Path dataDirectory, Logger logger) throws IOException {
|
||||||
|
long long_ = System.currentTimeMillis();
|
||||||
|
T2CV_ConfigWriter.createConfig(logger, new File(dataDirectory.getParent() + "/T2CodeLib", "config.yml"), VALUES.values(), T2C_Util.getConfigLogo());
|
||||||
|
T2CV_Send.info(logger, T2C_GenerateFrame.setCenterAligned("", "The config.yml were successfully created / updated." + " - " + (System.currentTimeMillis() - long_) + "ms"));
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user