Compare commits
11 Commits
velocity-d
...
f3bc2e3d4f
Author | SHA1 | Date | |
---|---|---|---|
f3bc2e3d4f | |||
d8f0752ea7 | |||
90f899cb16 | |||
7c3ffc80c3 | |||
d5a82e6005 | |||
eb237aaa89 | |||
1397656bf2 | |||
bbe8fbce49 | |||
9413f0f7c8 | |||
a05223333c | |||
2ac9c890f6 |
1
.idea/encodings.xml
generated
1
.idea/encodings.xml
generated
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
|
32
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
32
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,32 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<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>
|
10
.idea/jarRepositories.xml
generated
10
.idea/jarRepositories.xml
generated
@@ -26,6 +26,11 @@
|
||||
<option name="name" value="sonatype-oss-snapshots1" />
|
||||
<option name="url" value="https://s01.oss.sonatype.org/content/repositories/snapshots/" />
|
||||
</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>
|
||||
<option name="id" value="placeholderapi" />
|
||||
<option name="name" value="placeholderapi" />
|
||||
@@ -56,10 +61,5 @@
|
||||
<option name="name" value="BenCodez Repo" />
|
||||
<option name="url" value="https://nexus.bencodez.com/repository/maven-public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="papermc" />
|
||||
<option name="name" value="papermc" />
|
||||
<option name="url" value="https://repo.papermc.io/repository/maven-public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -5,9 +5,6 @@
|
||||
<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" />
|
||||
</list>
|
||||
<writeAnnotations>
|
||||
<writeAnnotation name="lombok.Getter" />
|
||||
</writeAnnotations>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
|
57
pom.xml
57
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2CodeLib</artifactId>
|
||||
<version>16.7_dev-19</version>
|
||||
<version>16.7_dev-1</version>
|
||||
<!--version>VERSION_snapshot-0</version-->
|
||||
<!--version>VERSION_beta-0</version-->
|
||||
<!--version>VERSION_dev-0</version-->
|
||||
@@ -15,7 +15,7 @@
|
||||
<name>T2CodeLib</name>
|
||||
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@@ -45,8 +45,32 @@
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>net.kyori.adventure</pattern>
|
||||
<shadedPattern>net.t2code.t2codelib.shaded.adventure</shadedPattern>
|
||||
<pattern>net.kyori</pattern>
|
||||
<shadedPattern>net.t2code.libraries.kyori.adventure</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google.gson</pattern>
|
||||
<shadedPattern>net.t2code.libraries.google</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>mozilla</pattern>
|
||||
<shadedPattern>net.t2code.libraries.mozilla</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.apache</pattern>
|
||||
<shadedPattern>net.t2code.libraries.apache</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.intellij</pattern>
|
||||
<shadedPattern>net.t2code.libraries.intellij</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.jetbrains</pattern>
|
||||
<shadedPattern>net.t2code.libraries.jetbrains</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.json</pattern>
|
||||
<shadedPattern>net.t2code.libraries.json</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
@@ -63,10 +87,6 @@
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<!-- Spigot -->
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
@@ -85,6 +105,12 @@
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
|
||||
<!-- Velocity / Paper-->
|
||||
<repository>
|
||||
<id>papermc-repo</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
|
||||
<!-- repo.t2code / T2Code -->
|
||||
<repository>
|
||||
<id>T2Code</id>
|
||||
@@ -154,7 +180,7 @@
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>3.2.0-SNAPSHOT</version>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -214,7 +240,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
<version>1.18.24</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -239,7 +265,12 @@
|
||||
<version>20230227</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@@ -6,6 +6,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class T2CBtab {
|
||||
|
@@ -48,14 +48,12 @@ public class T2CBupdateAPI {
|
||||
private static String pluginVersion;
|
||||
|
||||
public static void onUpdateCheckTimer(Plugin plugin, String prefix, String discord, Integer spigotID, String url) {
|
||||
Integer finalInterval;
|
||||
if (T2CBlibConfig.getUpdateTimer() < 1){
|
||||
finalInterval = 1;
|
||||
} else finalInterval = T2CBlibConfig.getUpdateTimer();
|
||||
if ((int) T2CBlibConfig.VALUES.updateTimer.getValue() < 1) {
|
||||
T2CBlibConfig.VALUES.updateTimer.setValue(1);
|
||||
}
|
||||
ProxyServer.getInstance().getScheduler().schedule(plugin, new Runnable() {
|
||||
public void run() {
|
||||
if (T2CBlibConfig.getUpdateCheckFullDisable()) return;
|
||||
(new T2CBupdateCheckerGit(plugin, spigotID)).getVersion((webData) -> {
|
||||
(new T2CBupdateCheckerGit(plugin)).getVersion((webData) -> {
|
||||
pluginVersion = plugin.getDescription().getVersion();
|
||||
T2CupdateObject update = new T2CupdateObject(
|
||||
plugin.getDescription().getName(),
|
||||
@@ -77,6 +75,6 @@ public class T2CBupdateAPI {
|
||||
}
|
||||
}, pluginVersion, spigotID, url);
|
||||
}
|
||||
}, 0, finalInterval * 60 * 20L, TimeUnit.SECONDS);
|
||||
}, 0, (int) T2CBlibConfig.VALUES.updateTimer.getValue() * 60 * 20L, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
@@ -18,17 +18,16 @@ import java.util.function.Consumer;
|
||||
|
||||
public class T2CBupdateCheckerGit {
|
||||
private Plugin plugin;
|
||||
private int resourceId;
|
||||
|
||||
public T2CBupdateCheckerGit(Plugin plugin, int resourceId) {
|
||||
|
||||
public T2CBupdateCheckerGit(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.resourceId = resourceId;
|
||||
|
||||
}
|
||||
|
||||
public void getVersion(Consumer<T2CupdateWebData> consumer, String pluginVersion, Integer spigotID, String gitKey) {
|
||||
if (T2CBlibConfig.getUpdateCheckFullDisable()) return;
|
||||
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1";
|
||||
if (!T2CBlibConfig.getSeePreReleaseUpdates()) {
|
||||
if (!(boolean)T2CBlibConfig.VALUES.seePreReleaseUpdates.getValue() ) {
|
||||
RepoURL = RepoURL + "&pre-release=false";
|
||||
}
|
||||
String finalRepoURL = RepoURL;
|
||||
|
@@ -0,0 +1,100 @@
|
||||
// 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.T2CconfigItem;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
|
||||
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 T2CBconfigWriter {
|
||||
|
||||
private static Configuration config;
|
||||
|
||||
|
||||
public static void createConfig(File configFile, T2CconfigItem[] values, String... header) {
|
||||
if (!configFile.exists()) {
|
||||
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<>();
|
||||
|
||||
for(T2CconfigItem item : values){
|
||||
if(!config.contains(item.getPath())){
|
||||
config.set(item.getPath(), item.getValue());
|
||||
}
|
||||
comments.put(item.getPath(), item.getComments());
|
||||
}
|
||||
saveConfigWithComments(configFile, comments, header);
|
||||
readConfig(config,values);
|
||||
}
|
||||
|
||||
private static void readConfig(Configuration config, T2CconfigItem[] values) {
|
||||
for(T2CconfigItem 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){
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,35 +4,24 @@ 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.api.pluginMessaging.T2CplmsgBcmd;
|
||||
import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.autoResponse.T2CapiAutoResponse;
|
||||
import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.commandgui.T2CapiCGUI;
|
||||
import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.opSecurity.T2CapiOpSecurity;
|
||||
|
||||
import java.io.IOException;
|
||||
import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig;
|
||||
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;
|
||||
|
||||
public class T2CBload {
|
||||
public static void onLoad(Plugin plugin, String prefix, String author, String version, String spigot, String discord, Integer spigotID, Integer bstatsID, String url) {
|
||||
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 + " §2Author: §6" + String.valueOf(author).replace("[", "").replace("]", ""));
|
||||
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);
|
||||
}
|
||||
T2CBmetrics.bStats(plugin, bstatsID);
|
||||
T2CBlibConfig.set();
|
||||
|
||||
T2CBupdateAPI.onUpdateCheckTimer(plugin, prefix, discord, spigotID, url);
|
||||
|
||||
@@ -44,16 +33,16 @@ public class T2CBload {
|
||||
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CBbungeePlayers());
|
||||
T2CBbungeePlayers.sendToSpigotDeleteAll();
|
||||
|
||||
if (T2CBlibConfig.getApiCommandGUIEnable()) {
|
||||
if ((boolean) T2CBlibConfig.VALUES.apiCommandGUIEnable.getValue()) {
|
||||
plugin.getProxy().registerChannel("t2c:cguiopl");
|
||||
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiCGUI());
|
||||
T2CapiCGUI.sendToSpigotDeleteAll();
|
||||
}
|
||||
if (T2CBlibConfig.getApiAutoResponse()) {
|
||||
if ( (boolean)T2CBlibConfig.VALUES.apiAutoResponse.getValue() ) {
|
||||
plugin.getProxy().registerChannel("t2c:aresp");
|
||||
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiAutoResponse());
|
||||
}
|
||||
if (T2CBlibConfig.getApiOpSecurity()) {
|
||||
if ((boolean)T2CBlibConfig.VALUES.apiOpSecurity.getValue()) {
|
||||
plugin.getProxy().registerChannel("t2c:t2c:opsec");
|
||||
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiOpSecurity());
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
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.T2CBsend;
|
||||
@@ -9,12 +8,16 @@ import net.t2code.t2codelib.Util;
|
||||
|
||||
public class T2CodeBMain extends Plugin {
|
||||
|
||||
@Getter
|
||||
private static Plugin plugin;
|
||||
|
||||
private static String version;
|
||||
public static Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private static String version;
|
||||
private static String orgVersion;
|
||||
private static String autor;
|
||||
|
||||
@Getter
|
||||
private static Boolean mmIsLoad = true;
|
||||
private static BungeeAudiences adventure;
|
||||
|
||||
@@ -30,8 +33,8 @@ public class T2CodeBMain extends Plugin {
|
||||
public void onEnable() {
|
||||
// Plugin startup logic
|
||||
plugin = this;
|
||||
String orgVersion = plugin.getDescription().getVersion();
|
||||
String author = plugin.getDescription().getAuthor();
|
||||
orgVersion = plugin.getDescription().getVersion();
|
||||
autor = plugin.getDescription().getAuthor();
|
||||
try {
|
||||
adventure = BungeeAudiences.create(this);
|
||||
T2CBsend.info(this,"Adventure load!");
|
||||
@@ -39,7 +42,7 @@ public class T2CodeBMain extends Plugin {
|
||||
T2CBsend.error(this,"Adventure can not be load!");
|
||||
mmIsLoad = false;
|
||||
}
|
||||
T2CBload.onLoad(plugin, Util.getPrefix(), author, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID(),Util.getGit());
|
||||
T2CBload.onLoad(plugin, Util.getPrefix(), autor, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID(),Util.getGit());
|
||||
version = plugin.getDescription().getVersion();
|
||||
}
|
||||
|
||||
@@ -61,4 +64,7 @@ public class T2CodeBMain extends Plugin {
|
||||
T2CBsend.console(Util.getPrefix() + " §4Plugin successfully disabled.");
|
||||
T2CBsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4=============================");
|
||||
}
|
||||
public static Boolean getMmIsLoad() {
|
||||
return mmIsLoad;
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class T2CBmetrics {
|
||||
|
||||
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!
|
||||
T2CBmetrics metrics = new T2CBmetrics(plugin, pluginId);
|
||||
}
|
||||
|
@@ -0,0 +1,37 @@
|
||||
package net.t2code.t2codelib.BUNGEE.system.config;
|
||||
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
import net.t2code.t2codelib.T2CconfigItem;
|
||||
|
||||
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(T2CodeBMain.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",T2CBlibConfig.VALUES.updateTimer);
|
||||
set("UpdateCheck.SeePreReleaseUpdates",T2CBlibConfig.VALUES.seePreReleaseUpdates);
|
||||
set("API.CommandGUI.Enable",T2CBlibConfig.VALUES.apiCommandGUIEnable);
|
||||
set("API.AutoResponse.Enable",T2CBlibConfig.VALUES.apiAutoResponse);
|
||||
set("API.OPSecurity.Enable",T2CBlibConfig.VALUES.apiOpSecurity);
|
||||
|
||||
config.delete();
|
||||
}
|
||||
|
||||
private static void set(String path, T2CconfigItem item){
|
||||
if (configuration.contains(path)){
|
||||
item.setValue(configuration.get(path));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,63 +1,65 @@
|
||||
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.api.yaml.T2CBconfigWriter;
|
||||
import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain;
|
||||
import net.t2code.t2codelib.T2CconfigItem;
|
||||
import net.t2code.t2codelib.Util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
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();
|
||||
public enum VALUES implements T2CconfigItem{
|
||||
updateTimer("updateCheck.timerInMin", 60,"In this option you can set the time interval in minutes in which updates should be checked."),
|
||||
seePreReleaseUpdates("updateCheck.seePreReleaseUpdates", true,"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, "With this option you activate the api interface for the T2C-CommandGUI plugin."),
|
||||
apiAutoResponse("api.autoResponse.enable", false,"With this option you activate the api interface for the T2C-AutoResponse plugin."),
|
||||
apiOpSecurity("api.opSecurity.enable", false,"With this option you activate the api interface for the T2C-OPSecurity plugin."),
|
||||
;
|
||||
|
||||
private final String path;
|
||||
private Object value;
|
||||
private final List<String> comments;
|
||||
|
||||
VALUES(String path, Object value, String... comments) {
|
||||
this.path = path;
|
||||
this.value = value;
|
||||
this.comments = new ArrayList<>(Arrays.asList(comments));
|
||||
}
|
||||
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);
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, config);
|
||||
T2CBsend.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
public static void set(){
|
||||
try {
|
||||
ConvertT2CBlibConfig.convert();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
T2CBconfigWriter.createConfig(new File(T2CodeBMain.getPlugin().getDataFolder(), "config.yml"), VALUES.values(), Util.getConfigLogo());
|
||||
}
|
||||
|
||||
@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,4 +1,4 @@
|
||||
package net.t2code.t2codelib.BUNGEE.api.pluginMessaging;
|
||||
package net.t2code.t2codelib.BUNGEE.system.pluginMessaging;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@@ -6,6 +6,7 @@ import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
@@ -1,4 +1,4 @@
|
||||
package net.t2code.t2codelib.BUNGEE.api.pluginMessaging.autoResponse;
|
||||
package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.autoResponse;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
@@ -1,4 +1,4 @@
|
||||
package net.t2code.t2codelib.BUNGEE.api.pluginMessaging.commandgui;
|
||||
package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.commandgui;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
@@ -1,4 +1,4 @@
|
||||
package net.t2code.t2codelib.BUNGEE.api.pluginMessaging.opSecurity;
|
||||
package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.opSecurity;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
@@ -3,6 +3,7 @@ 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.SPIGOT.system.config.config.T2CLibConfig;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -37,7 +38,7 @@ public class T2CbungeePlayers implements PluginMessageListener {
|
||||
bungeePlayers.remove(input);
|
||||
break;
|
||||
case GIVEALL:
|
||||
if (!Util.getServerUUID().toString().equals(uuid)) {
|
||||
if (!T2CLibConfig.VALUES.serverUUID.getValue().equals(uuid)) {
|
||||
return;
|
||||
}
|
||||
bungeePlayers.clear();
|
||||
@@ -67,7 +68,7 @@ public class T2CbungeePlayers implements PluginMessageListener {
|
||||
DataOutputStream output = new DataOutputStream(stream);
|
||||
try {
|
||||
output.writeUTF(T2CbungeePlayersEnum.GIVEALL.name());
|
||||
output.writeUTF(Util.getServerUUID().toString());
|
||||
output.writeUTF(T2CLibConfig.VALUES.serverUUID.getValue().toString());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -76,7 +77,7 @@ public class T2CbungeePlayers implements PluginMessageListener {
|
||||
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());
|
||||
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage send output/uuid: " + T2CLibConfig.VALUES.serverUUID.getValue().toString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,14 @@
|
||||
package net.t2code.t2codelib.SPIGOT.api.commands;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.rmi.MarshalledObject;
|
||||
import java.util.Map;
|
||||
|
||||
public class T2Ccmd {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
|
@@ -1,60 +1,73 @@
|
||||
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.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.T2CupdateWebData;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginLogger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class T2Ctemplate {
|
||||
public static Long onLoadHeader(String prefix, List<String> author, String version, String spigot, String discord) {
|
||||
return onLoadHeader(prefix, author, version, spigot, discord, null, null);
|
||||
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> author, String version, String spigot, String discord, Boolean isPremium) {
|
||||
return onLoadHeader(prefix, author, version, spigot, discord, isPremium, 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> author, String version, String spigot, String discord, Boolean isPremium, Boolean isVerify) {
|
||||
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║ §2Author: §6" + String.valueOf(author).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);
|
||||
|
||||
/**
|
||||
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 + " §e╔════════════════════════════════════");
|
||||
onStartMsg(prefix,"");
|
||||
for (String s : Util.getLoadLogo()) {
|
||||
onStartMsg(prefix, s);
|
||||
}
|
||||
onStartMsg(prefix,"");
|
||||
onStartMsg(prefix,"§2Author §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
|
||||
onStartMsg(prefix,"§2Version: §6" + version);
|
||||
onStartMsg(prefix,"§2Spigot: §6" + spigot);
|
||||
onStartMsg(prefix,"§2Discord: §6" + discord);
|
||||
if (isPremium != null) {
|
||||
if (isPremium) {
|
||||
T2Csend.console(prefix + " §4 §e║ §6Premium: §2true");
|
||||
} else T2Csend.console(prefix + " §4 §e║ §6Premium: §4false");
|
||||
onStartMsg(prefix,"§6Premium: §2true");
|
||||
} else onStartMsg(prefix,"§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");
|
||||
onStartMsg(prefix,"§6Verify: §2true");
|
||||
} else onStartMsg(prefix,"§6Verify: §4false");
|
||||
} else onStartMsg(prefix,"§6Verify: §4false");
|
||||
}
|
||||
|
||||
T2Csend.console(prefix + " §4 §e╚══════════════════════════");
|
||||
onLoadSeparateStroke(prefix);
|
||||
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();
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return long_;
|
||||
@@ -67,7 +80,11 @@ public class T2Ctemplate {
|
||||
}
|
||||
|
||||
public static void onLoadSeparateStroke(String prefix) {
|
||||
T2Csend.console(prefix + " §8-------------------------------");
|
||||
onStartMsg(prefix,"§8-------------------------------");
|
||||
}
|
||||
|
||||
public static void onStartMsg(String prefix, String msg) {
|
||||
T2Csend.console(prefix + " §e║ " + msg);
|
||||
}
|
||||
|
||||
public static void onLoadFooter(String prefix, Long long_, String v) {
|
||||
@@ -76,12 +93,13 @@ public class T2Ctemplate {
|
||||
|
||||
public static void onLoadFooter(String prefix, Long long_) {
|
||||
onLoadSeparateStroke(prefix);
|
||||
T2Csend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
onStartMsg(prefix, "§2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
T2Csend.console(prefix + " §e╚════════════════════════════════════");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param prefix
|
||||
* @param author
|
||||
* @param autor
|
||||
* @param spigot
|
||||
* @param discord
|
||||
* @deprecated reason this method is deprecated <br/>
|
||||
@@ -94,7 +112,7 @@ public class T2Ctemplate {
|
||||
* </pre></blockquote>
|
||||
*/
|
||||
@Deprecated
|
||||
public static void onDisable(String prefix, List<String> author, String version, String spigot, String discord) {
|
||||
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.");
|
||||
}
|
||||
@@ -102,7 +120,7 @@ public class T2Ctemplate {
|
||||
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║ §2Authors: §6" + plugin.getDescription().getAuthors());
|
||||
T2Csend.console(prefix + " §4 §e║ §2Autors: §6" + plugin.getDescription().getAuthors());
|
||||
T2Csend.console(prefix + " §4 §e║ §4Plugin successfully disabled.");
|
||||
T2Csend.console(prefix + " §4 §e╚══════════════════════════");
|
||||
}
|
||||
@@ -130,29 +148,11 @@ public class T2Ctemplate {
|
||||
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 stAuthor = "<dark_red>║</dark_red> <yellow>Author(s):</yellow> <gold>[author]</gold>".replace("[author]", plugin.getDescription().getAuthors().toString());
|
||||
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 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;
|
||||
T2Csend.sender(sender, "<br><dark_red>╔════════════════════════════════</dark_red>"
|
||||
+ "<br>" + stPlugin
|
||||
+ "<br>" + stVersion
|
||||
+ stMSG
|
||||
+ "<br>" + stAuthor
|
||||
+ "<br>" + stUpdate
|
||||
+ stNVersion
|
||||
+ "<br>" + stLink
|
||||
+ pr
|
||||
+ "<br><dark_red>╚════════════════════════════════</dark_red>");
|
||||
}
|
||||
|
||||
private static @NotNull String getString(int spigotID, String discord, boolean player) {
|
||||
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>"
|
||||
@@ -160,7 +160,20 @@ public class T2Ctemplate {
|
||||
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;
|
||||
return stLink;
|
||||
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) {
|
||||
|
@@ -1,5 +1,7 @@
|
||||
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;
|
||||
|
||||
|
||||
|
@@ -1,6 +1,8 @@
|
||||
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 {
|
||||
|
@@ -2,7 +2,7 @@ package net.t2code.t2codelib.SPIGOT.api.update;
|
||||
|
||||
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.SPIGOT.system.config.config.T2CLibConfig;
|
||||
import net.t2code.t2codelib.UpdateType;
|
||||
import net.t2code.t2codelib.T2CupdateObject;
|
||||
import net.t2code.t2codelib.T2CupdateWebData;
|
||||
@@ -186,7 +186,7 @@ public class T2CupdateAPI {
|
||||
}
|
||||
|
||||
public static void onUpdateCheck(Plugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
|
||||
if (SelectLibConfig.getUpdateCheckFullDisable()) return;
|
||||
if ((boolean) T2CLibConfig.VALUES.updateCheckFullDisable.getValue()) return;
|
||||
new T2CupdateCheckerGit((JavaPlugin) plugin, prefix, gitKey, spigotID, discord, updateCheckOnJoin, seePreReleaseUpdates, timeInterval);
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package net.t2code.t2codelib.SPIGOT.api.update;
|
||||
|
||||
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.SPIGOT.system.config.config.T2CLibConfig;
|
||||
import net.t2code.t2codelib.T2CupdateObject;
|
||||
import net.t2code.t2codelib.T2CupdateWebData;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -40,7 +40,7 @@ public class T2CupdateCheckerGit {
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (SelectLibConfig.getUpdateCheckFullDisable()) return;
|
||||
if ((boolean) T2CLibConfig.VALUES.updateCheckFullDisable.getValue()) return;
|
||||
getVersion((webData) -> {
|
||||
T2CupdateObject update = new T2CupdateObject(
|
||||
plugin.getName(),
|
||||
@@ -52,8 +52,8 @@ public class T2CupdateCheckerGit {
|
||||
);
|
||||
|
||||
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
|
||||
if (T2CupdateAPI.pluginVersions.get(plugin.getName()) == null){
|
||||
T2Csend.debugmsg(T2CodeLibMain.getPlugin(),"'"+plugin.getName() + "' UpdateAPI T2CupdateAPI.pluginVersions.get(plugin.getName()) == null");
|
||||
if (T2CupdateAPI.pluginVersions.get(plugin.getName()) == null) {
|
||||
T2Csend.debugmsg(T2CodeLibMain.getPlugin(), "'" + plugin.getName() + "' UpdateAPI T2CupdateAPI.pluginVersions.get(plugin.getName()) == null");
|
||||
return;
|
||||
}
|
||||
if (T2CupdateAPI.pluginVersions.get(plugin.getName()).updateAvailable) {
|
||||
@@ -145,7 +145,7 @@ public class T2CupdateCheckerGit {
|
||||
);
|
||||
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
|
||||
|
||||
T2Csend.error(this.plugin,"§4 Cannot look for updates: " + exception.getMessage());
|
||||
T2Csend.error(this.plugin, "§4 Cannot look for updates: " + exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
@@ -1,37 +1,60 @@
|
||||
package net.t2code.t2codelib.SPIGOT.api.yaml;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
|
||||
public class T2CLibConfig {
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, use the method from the return!
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Boolean getUpdateCheckOnJoin() {
|
||||
return SelectLibConfig.getUpdateCheckOnJoin();
|
||||
}
|
||||
|
||||
public static Boolean getT2cTestDevelopment() {
|
||||
return SelectLibConfig.getT2cTestDevelopment();
|
||||
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.updateCheckOnJoin.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, use the method from the return!
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Integer getUpdateCheckTimeInterval() {
|
||||
return SelectLibConfig.getUpdateCheckTimeInterval();
|
||||
return (Integer) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.updateCheckTimeInterval.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, use the method from the return!
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Boolean getSeePreReleaseUpdates() {
|
||||
return SelectLibConfig.getSeePreReleaseUpdates();
|
||||
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.seePreReleaseUpdates.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, use the method from the return!
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Boolean getDebug() {
|
||||
return SelectLibConfig.getDebug();
|
||||
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.debug.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, use the method from the return!
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static String getLanguage() {
|
||||
return SelectLibConfig.getLanguage();
|
||||
return (String) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.language.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, use the method from the return!
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Boolean getBungee() {
|
||||
return SelectLibConfig.getBungee();
|
||||
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.proxy.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, use the method from the return!
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Boolean getInventoriesCloseByServerStop() {
|
||||
return SelectLibConfig.getInventoriesCloseByServerStop();
|
||||
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.inventoriesCloseByServerStop.getValue();
|
||||
}
|
||||
}
|
||||
|
@@ -12,51 +12,80 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class T2Cconfig {
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static void set(String path, String value, YamlConfiguration YamlConfiguration) {
|
||||
if (!YamlConfiguration.contains(path)) {
|
||||
YamlConfiguration.set(path, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static void set(String path, Object value, YamlConfiguration YamlConfiguration) {
|
||||
if (!YamlConfiguration.contains(path)) {
|
||||
YamlConfiguration.set(path, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static void set(String path, YamlConfiguration YamlConfiguration) {
|
||||
YamlConfiguration.set(path, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static void set(String path, Integer value, YamlConfiguration YamlConfiguration) {
|
||||
if (!YamlConfiguration.contains(path)) {
|
||||
YamlConfiguration.set(path, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static void set(String path, Double value, YamlConfiguration YamlConfiguration) {
|
||||
if (!YamlConfiguration.contains(path)) {
|
||||
YamlConfiguration.set(path, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static void set(String path, Boolean value, YamlConfiguration YamlConfiguration) {
|
||||
if (!YamlConfiguration.contains(path)) {
|
||||
YamlConfiguration.set(path, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static void set(String path, List<String> value, YamlConfiguration YamlConfiguration) {
|
||||
if (!YamlConfiguration.contains(path)) {
|
||||
YamlConfiguration.set(path, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static void set(String path, ItemStack value, YamlConfiguration YamlConfiguration) {
|
||||
if (!YamlConfiguration.contains(path)) {
|
||||
YamlConfiguration.set(path, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static void setSound(String soundName, String sound1_8, String sound1_9, String sound1_13, YamlConfiguration yamlConfiguration) {
|
||||
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
|
||||
String sound;
|
||||
@@ -68,6 +97,9 @@ public class T2Cconfig {
|
||||
set("Sound." + soundName + ".Sound", sound, yamlConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static void setSound(String soundName, String sound1_8, String sound1_13, YamlConfiguration yamlConfiguration) {
|
||||
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
|
||||
String sound;
|
||||
@@ -77,19 +109,31 @@ public class T2Cconfig {
|
||||
set("Sound." + soundName + ".Sound", sound, yamlConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static void setSound(String soundName, String sound, YamlConfiguration yamlConfiguration) {
|
||||
set("Sound." + soundName + ".Enable", true, yamlConfiguration);
|
||||
set("Sound." + soundName + ".Sound", sound.toString(), yamlConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static boolean selectSoundEnable(String soundName, YamlConfiguration yamlConfiguration) {
|
||||
return selectBoolean("Sound." + soundName + ".Enable", yamlConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static String selectSound(String prefix, String soundName, YamlConfiguration yamlConfiguration) {
|
||||
return select(prefix, "Sound." + soundName + ".Sound", yamlConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static Sound checkSound(String sound1_8, String sound1_9, String sound1_13, String selectSoundFromConfig, String prefix) {
|
||||
String SOUND;
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
@@ -101,6 +145,9 @@ public class T2Cconfig {
|
||||
return checkSound(SOUND, selectSoundFromConfig, prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static Sound checkSound(String sound1_8, String sound1_13, String selectSoundFromConfig, String prefix) {
|
||||
String SOUND;
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
@@ -110,6 +157,9 @@ public class T2Cconfig {
|
||||
return checkSound(SOUND, selectSoundFromConfig, prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static Sound checkSound(String sound, String selectSoundFromConfig, String prefix) {
|
||||
try {
|
||||
return Sound.valueOf(selectSoundFromConfig);
|
||||
@@ -120,34 +170,58 @@ public class T2Cconfig {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static String select(String prefix, String path, YamlConfiguration yamlConfiguration) {
|
||||
return T2Creplace.replace(prefix, yamlConfiguration.getString(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static Object selectObject(String prefix, String path, YamlConfiguration yamlConfiguration) {
|
||||
return T2Creplace.replaceObject(prefix, yamlConfiguration.get(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static Integer selectInt(String path, YamlConfiguration yamlConfiguration) {
|
||||
return (yamlConfiguration.getInt(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static Boolean selectBoolean(String path, YamlConfiguration yamlConfiguration) {
|
||||
return (yamlConfiguration.getBoolean(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static Double selectDouble(String path, YamlConfiguration yamlConfiguration) {
|
||||
return (yamlConfiguration.getDouble(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static List<String> selectList(String path, YamlConfiguration yamlConfiguration) {
|
||||
return (yamlConfiguration.getStringList(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static ItemStack selectItemStack(String path, YamlConfiguration yamlConfiguration) {
|
||||
return (yamlConfiguration.getItemStack(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static List<String> selectList(String prefix, String path, YamlConfiguration yamlConfiguration) {
|
||||
List<String> output = new ArrayList<>();
|
||||
List<String> input = yamlConfiguration.getStringList(path);
|
||||
@@ -157,6 +231,9 @@ public class T2Cconfig {
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, please use the new T2CconfigWriter.
|
||||
*/
|
||||
public static void select(String prefix, List<String> value, String path, YamlConfiguration yamlConfiguration) {
|
||||
List<String> output = new ArrayList<>();
|
||||
List<String> input = yamlConfiguration.getStringList(path);
|
||||
|
@@ -0,0 +1,100 @@
|
||||
// This class was created by JaTiTV.
|
||||
|
||||
package net.t2code.t2codelib.SPIGOT.api.yaml;
|
||||
|
||||
import net.t2code.t2codelib.T2CconfigItem;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
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 T2CconfigWriter {
|
||||
|
||||
private static FileConfiguration config;
|
||||
|
||||
|
||||
public static void createConfig(File configFile, T2CconfigItem[] values, String... header) {
|
||||
boolean exist = false;
|
||||
if (!configFile.exists()) {
|
||||
configFile.getParentFile().mkdirs();
|
||||
try {
|
||||
configFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
} else exist = true;
|
||||
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
Map<String, List<String>> comments = new LinkedHashMap<>();
|
||||
|
||||
for (T2CconfigItem value : values) {
|
||||
if ((value.getForceSet() && exist)||!exist && !value.getForceSet()){
|
||||
config.addDefault(value.getPath(), value.getValue());
|
||||
comments.put(value.getPath(), value.getComments());
|
||||
}
|
||||
}
|
||||
|
||||
// Copy default values if they are missing
|
||||
config.options().copyDefaults(true);
|
||||
|
||||
saveConfigWithComments(configFile, comments, header);
|
||||
readConfig(config, values);
|
||||
}
|
||||
|
||||
private static void readConfig(FileConfiguration config, T2CconfigItem[] values) {
|
||||
for (T2CconfigItem value : values) {
|
||||
value.setValue(config.get(value.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(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(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) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
package net.t2code.t2codelib.SPIGOT.system;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -27,7 +28,7 @@ public class T2CbungeeCommandSenderReciver {
|
||||
}
|
||||
}
|
||||
output.writeUTF(information);
|
||||
output.writeUTF(String.valueOf(Util.getServerUUID()));
|
||||
output.writeUTF(String.valueOf(T2CLibConfig.VALUES.serverUUID.getValue()));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@@ -17,10 +17,10 @@ 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.config.T2CLibConfig;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.languages.LanguagesCreate;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg;
|
||||
import net.t2code.t2codelib.T2CplatformDetector;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -41,19 +41,25 @@ public final class T2CodeLibMain extends JavaPlugin {
|
||||
@Getter
|
||||
private static Boolean mmIsLoad = true;
|
||||
private static Boolean load = false;
|
||||
@Getter
|
||||
private static T2CplatformDetector.PlatformType plattform;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// 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;
|
||||
}
|
||||
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
plattform = T2CplatformDetector.detectPlatform();
|
||||
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord(), null, null);
|
||||
|
||||
checkIsBungee();
|
||||
String prefix = Util.getPrefix();
|
||||
|
||||
@@ -65,78 +71,81 @@ public final class T2CodeLibMain extends JavaPlugin {
|
||||
T2CmcVersion.onCheck();
|
||||
|
||||
if (T2CnmsVersions.getT2CnmsEnum() == T2CnmsEnum.not_support) {
|
||||
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.console(prefix);
|
||||
T2Ctemplate.onStartMsg(prefix, "§4!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Ctemplate.onStartMsg(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();
|
||||
}
|
||||
T2Ctemplate.onStartMsg(prefix, "");
|
||||
T2Ctemplate.onStartMsg(prefix, "§4!!!!!!!!!!!!!!!!!!!!");
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
if (T2CmcVersion.isMc1_21()) {
|
||||
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.console(prefix);
|
||||
T2Ctemplate.onStartMsg(prefix, "§4!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Ctemplate.onStartMsg(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.onStartMsg(prefix, "");
|
||||
T2Ctemplate.onStartMsg(prefix, "§4!!!!!!!!!!!!!!!!!!!!");
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} 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.onStartMsg(prefix, "§2Server run on:");
|
||||
T2Ctemplate.onStartMsg(prefix, "§3Platform: §6" + plattform.name());
|
||||
T2Ctemplate.onStartMsg(prefix, "§3mcVersion: §6" + T2CmcVersion.getMcVersion());
|
||||
T2Ctemplate.onStartMsg(prefix, "§3bukkitVersion: §6" + T2CmcVersion.getBukkitVersion());
|
||||
T2Ctemplate.onStartMsg(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" +
|
||||
T2Ctemplate.onStartMsg(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");
|
||||
T2Ctemplate.onStartMsg(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");
|
||||
T2Ctemplate.onStartMsg(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()
|
||||
T2Ctemplate.onStartMsg(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");
|
||||
T2Ctemplate.onStartMsg(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");
|
||||
T2Ctemplate.onStartMsg(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");
|
||||
T2Ctemplate.onStartMsg(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");
|
||||
T2Ctemplate.onStartMsg(prefix, "§3Kyori MiniMessage Support: " + (getMmIsLoad() ? "§2load" : "§4not load") + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
|
||||
|
||||
plugin.getCommand("t2code").setExecutor(new CmdExecuter());
|
||||
ConfigCreate.configCreate();
|
||||
T2CLibConfig.set();
|
||||
T2Ctemplate.onLoadSeparateStroke(prefix);
|
||||
T2Ctemplate.onStartMsg(prefix, "§3Use Proxy: §6" + (boolean)T2CLibConfig.VALUES.proxy.getValue());
|
||||
T2Ctemplate.onStartMsg(prefix, "§3serverUUID: §6" + T2CLibConfig.VALUES.serverUUID.getValue());
|
||||
T2Ctemplate.onLoadSeparateStroke(prefix);
|
||||
T2CitemVersion.scan();
|
||||
LanguagesCreate.langCreate();
|
||||
SelectLibConfig.onSelect();
|
||||
SelectLibMsg.onSelect();
|
||||
|
||||
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), Util.getSpigotID(), Util.getDiscord(), SelectLibConfig.getUpdateCheckOnJoin(), SelectLibConfig.getSeePreReleaseUpdates(),
|
||||
SelectLibConfig.getUpdateCheckTimeInterval());
|
||||
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), Util.getSpigotID(), Util.getDiscord(),
|
||||
(boolean) T2CLibConfig.VALUES.updateCheckOnJoin.getValue(),
|
||||
(boolean) T2CLibConfig.VALUES.seePreReleaseUpdates.getValue(),
|
||||
(int) T2CLibConfig.VALUES.updateCheckTimeInterval.getValue());
|
||||
Metrics.Bstats(plugin, Util.getBstatsID());
|
||||
if (SelectLibConfig.getBungee()) {
|
||||
if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
|
||||
T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:bcmd");
|
||||
|
||||
@@ -160,7 +169,7 @@ public final class T2CodeLibMain extends JavaPlugin {
|
||||
// Plugin shutdown logic
|
||||
if (!load) return;
|
||||
ReportLogStorage.save();
|
||||
if (SelectLibConfig.getInventoriesCloseByServerStop()) {
|
||||
if ((boolean) T2CLibConfig.VALUES.inventoriesCloseByServerStop.getValue()) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.closeInventory();
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package net.t2code.t2codelib.SPIGOT.system;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
@@ -22,14 +23,15 @@ public class Vault {
|
||||
T2CodeLibMain.setEco(eco.getProvider());
|
||||
if (T2CodeLibMain.getEco() != null) {
|
||||
connected = true;
|
||||
T2Csend.console(Util.getPrefix() + " §2Vault / Economy successfully connected!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(), " §2Vault / Economy successfully connected!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
} else {
|
||||
connected = false;
|
||||
T2Csend.console(Util.getPrefix() + " §4Economy could not be connected / found! [1]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(), " §4Economy could not be connected / found! [1]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
} else {
|
||||
connected = false;
|
||||
T2Csend.console(Util.getPrefix() + " §4Economy could not be connected / found! [2]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(), " §4Economy could not be connected / found! [2]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
RegisteredServiceProvider<Permission> perm = T2CodeLibMain.getPlugin().getServer().getServicesManager().getRegistration(Permission.class);
|
||||
if (perm != null) {
|
||||
@@ -38,13 +40,13 @@ public class Vault {
|
||||
} else {
|
||||
vaultEnable = false;
|
||||
connected = false;
|
||||
T2Csend.console(Util.getPrefix() + " §4Vault could not be connected! [3]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix()," §4Vault could not be connected! [3]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
}
|
||||
|
||||
public static void vaultDisable() {
|
||||
if (!connected) return;
|
||||
connected = false;
|
||||
T2Csend.console(Util.getPrefix() + " §4Vault / Economy successfully deactivated.");
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(), " §4Vault / Economy successfully deactivated.");
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
package net.t2code.t2codelib.SPIGOT.system.bstats;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -31,7 +31,7 @@ public class Metrics {
|
||||
public static void Bstats(Plugin plugin, int bstatsID) {
|
||||
int pluginId = bstatsID; // <-- Replace with the id of your plugin!
|
||||
Metrics metrics = new Metrics((JavaPlugin) plugin, pluginId);
|
||||
metrics.addCustomChart(new SimplePie("updatecheckonjoin", () -> String.valueOf(SelectLibConfig.getUpdateCheckOnJoin())));
|
||||
metrics.addCustomChart(new SimplePie("updatecheckonjoin", () -> String.valueOf(T2CLibConfig.VALUES.updateCheckOnJoin.getValue())));
|
||||
}
|
||||
|
||||
private final Plugin plugin;
|
||||
|
@@ -5,8 +5,8 @@ import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
|
||||
import net.t2code.t2codelib.T2CupdateObject;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -69,7 +69,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
|
||||
return false;
|
||||
}
|
||||
SelectLibConfig.onSelect();
|
||||
T2CLibConfig.set();
|
||||
T2Csend.sender(sender, Util.getPrefix() + " §2Config successfully reloaded");
|
||||
return false;
|
||||
case "debug":
|
||||
@@ -92,7 +92,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
return false;
|
||||
}
|
||||
T2Csend.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]", Util.getPrefix()).replace("[id]", String.valueOf(T2CLibConfig.VALUES.serverUUID.getValue())));
|
||||
return false;
|
||||
case "bcmd":
|
||||
if (!sender.hasPermission("t2code.admin")) {
|
||||
|
@@ -5,7 +5,7 @@ import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -93,10 +93,10 @@ public class Commands {
|
||||
String permission = args[2];
|
||||
|
||||
if (player.hasPermission(permission)) {
|
||||
T2Ccmd.console(SelectLibConfig.getCommandPermToggleCommand().replace("[player]",player.getName()).replace("[perm]",permission).replace("[value]", "false"));
|
||||
T2Ccmd.console(String.valueOf(T2CLibConfig.VALUES.commandPermToggleCommand.getValue()).replace("[player]",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.");
|
||||
} else {
|
||||
T2Ccmd.console(SelectLibConfig.getCommandPermToggleCommand().replace("[player]",player.getName()).replace("[perm]",permission).replace("[value]", "true"));
|
||||
T2Ccmd.console(String.valueOf(T2CLibConfig.VALUES.commandPermToggleCommand.getValue()).replace("[player]",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.");
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,7 @@ import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
@@ -2,7 +2,7 @@ package net.t2code.t2codelib.SPIGOT.system.cmd;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -27,7 +27,7 @@ public class Development implements Listener {
|
||||
if (!args[0].equals("_t2code_")) {
|
||||
return;
|
||||
}
|
||||
if (!SelectLibConfig.getDeveloperTool()) {
|
||||
if (!(boolean) T2CLibConfig.VALUES.developerTool.getValue()) {
|
||||
T2Csend.player(e.getPlayer(), Util.getPrefix() + " The Development Tool is disabled.");
|
||||
}
|
||||
e.setCancelled(true);
|
||||
|
@@ -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.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.T2CconfigItem;
|
||||
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(T2CodeLibMain.getPath(), "config.yml");
|
||||
yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
if (!config.exists()) return;
|
||||
if (yamlConfiguration.contains("plugin.updateCheck.onJoin")) return;
|
||||
|
||||
set("Plugin.UpdateCheck.OnJoin",T2CLibConfig.VALUES.updateCheckOnJoin);
|
||||
set("Plugin.UpdateCheck.TimeInterval",T2CLibConfig.VALUES.updateCheckTimeInterval);
|
||||
set("Plugin.UpdateCheck.SeePreReleaseUpdates",T2CLibConfig.VALUES.seePreReleaseUpdates);
|
||||
set("Plugin.UpdateCheck.AllPlugins.FullDisable",T2CLibConfig.VALUES.updateCheckFullDisable);
|
||||
set("Plugin.Debug",T2CLibConfig.VALUES.debug);
|
||||
set("Plugin.language",T2CLibConfig.VALUES.language);
|
||||
set("Plugin.Not recommended to disable.developerTool",T2CLibConfig.VALUES.developerTool);
|
||||
set("BungeeCord.Enable",T2CLibConfig.VALUES.proxy);
|
||||
set("Player.Inventories.CloseByServerStop",T2CLibConfig.VALUES.inventoriesCloseByServerStop);
|
||||
set("Command.PermToggle.PermissionSetCommand",T2CLibConfig.VALUES.updateCheckOnJoin);
|
||||
|
||||
config.delete();
|
||||
}
|
||||
|
||||
private static void set(String path, T2CconfigItem 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,97 @@
|
||||
package net.t2code.t2codelib.SPIGOT.system.config.config;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.T2CconfigItem;
|
||||
import net.t2code.t2codelib.Util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class T2CLibConfig {
|
||||
|
||||
public enum VALUES implements T2CconfigItem {
|
||||
|
||||
updateCheckOnJoin("plugin.updateCheck.onJoin", true, true,"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,"In this option you can set the time interval in minutes in which updates should be checked."),
|
||||
|
||||
seePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true, true,"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,"This option deactivates all update checks for plugins that use the T2CodeLib."),
|
||||
|
||||
debug("plugin.debug.debugModus", false,true, "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,"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,"In this option you can set the language of the plugin."),
|
||||
|
||||
space_proxy("proxy", null, true,""),
|
||||
|
||||
proxy("proxy.enable", T2CodeLibMain.getIsBungee(), true,"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, "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,""),
|
||||
|
||||
inventoriesCloseByServerStop("player.inventories.closeByServerStop", true, true,"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),", "the inventory / GUIs are closed if players have them open when the server is shut down or restarted."),
|
||||
|
||||
space_command("command", null, true,""),
|
||||
|
||||
commandPermToggleCommand("command.permToggle.permissionSetCommand", "lp user [player] permission set [perm] [value]",
|
||||
true,"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 List<String> comments;
|
||||
|
||||
VALUES(String path, Object value,boolean forceSet, String... comments) {
|
||||
this.path = path;
|
||||
this.value = value;
|
||||
this.forceSet = forceSet;
|
||||
this.comments = new ArrayList<>(Arrays.asList(comments));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getForceSet() {
|
||||
return forceSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static void set() {
|
||||
long long_ = System.currentTimeMillis();
|
||||
ConvertT2ClibConfig.convert();
|
||||
T2CconfigWriter.createConfig(new File(T2CodeLibMain.getPath(), "config.yml"), VALUES.values(), Util.getConfigLogo());
|
||||
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(), "§2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
package net.t2code.t2codelib.SPIGOT.system.config.languages;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.Util;
|
||||
@@ -24,7 +25,7 @@ public class LanguagesCreate {
|
||||
|
||||
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");
|
||||
T2Ctemplate.onStartMsg(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) {
|
||||
|
@@ -2,8 +2,9 @@ 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.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -27,23 +28,23 @@ public class SelectLibMsg {
|
||||
|
||||
File msg;
|
||||
|
||||
msg = new File(T2CodeLibMain.getPath(), "languages/" + SelectLibConfig.getLanguage() + ".yml");
|
||||
msg = new File(T2CodeLibMain.getPath(), "languages/" + T2CLibConfig.VALUES.language.getValue() + ".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);
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(),"");
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(), "§4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(), "§4The selected §c" + T2CLibConfig.VALUES.language.getValue() + " §4language file was not found.");
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(), "§6The default language §eEnglish §6is used!");
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(), "§4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(),"");
|
||||
msg = new File(T2CodeLibMain.getPath(), "languages/" + "english.yml");
|
||||
selectMSG = "english";
|
||||
} else selectMSG = SelectLibConfig.getLanguage();
|
||||
} else selectMSG = (String) T2CLibConfig.VALUES.language.getValue();
|
||||
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");
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(), "§2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
}
|
||||
|
@@ -1,28 +0,0 @@
|
||||
package net.t2code.t2codelib;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class T2CVupdateObject {
|
||||
|
||||
public Optional<String> pluginName;
|
||||
public Optional<String> pluginVersion;
|
||||
public T2CupdateWebData webData;
|
||||
public Boolean load;
|
||||
public Boolean updateAvailable;
|
||||
public Boolean updateCheckOnJoin;
|
||||
|
||||
public T2CVupdateObject(Optional<String> pluginName,
|
||||
Optional<String> pluginVersion,
|
||||
T2CupdateWebData webData,
|
||||
Boolean load,
|
||||
Boolean updateAvailable,
|
||||
Boolean updateCheckOnJoin) {
|
||||
this.pluginName = pluginName;
|
||||
this.pluginVersion = pluginVersion;
|
||||
this.webData = webData;
|
||||
this.load = load;
|
||||
this.updateAvailable = updateAvailable;
|
||||
this.updateCheckOnJoin = updateCheckOnJoin;
|
||||
}
|
||||
}
|
35
src/main/java/net/t2code/t2codelib/T2CconfigItem.java
Normal file
35
src/main/java/net/t2code/t2codelib/T2CconfigItem.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package net.t2code.t2codelib;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface T2CconfigItem {
|
||||
/**
|
||||
* Returns the path of the option for the config
|
||||
* @return Config path of the option
|
||||
*/
|
||||
String getPath();
|
||||
|
||||
/**
|
||||
* Returns the default value of the option and, after reading the config, the value from the config
|
||||
* @return Value of the option
|
||||
*/
|
||||
Object getValue();
|
||||
|
||||
/**
|
||||
* Here you determine whether the value should always be set (true) or only when the config is first created (false)
|
||||
*/
|
||||
boolean getForceSet();
|
||||
|
||||
/**
|
||||
* Set the description of the option here, the '# ' is automatically set in front of it
|
||||
*/
|
||||
List<String> getComments();
|
||||
|
||||
/**
|
||||
* This @void is used to reset the value of @getValue()
|
||||
*/
|
||||
default void setValue(Object newValue){
|
||||
|
||||
}
|
||||
}
|
47
src/main/java/net/t2code/t2codelib/T2CplatformDetector.java
Normal file
47
src/main/java/net/t2code/t2codelib/T2CplatformDetector.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package net.t2code.t2codelib;// This class was created by JaTiTV.
|
||||
|
||||
public class T2CplatformDetector {
|
||||
|
||||
public static PlatformType detectPlatform;
|
||||
|
||||
public enum PlatformType {
|
||||
SPIGOT,
|
||||
PAPER,
|
||||
BUNGEECORD,
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
public static PlatformType detectPlatform() {
|
||||
// Check for Bukkit/Spigot/Paper
|
||||
try {
|
||||
Class.forName("org.bukkit.Bukkit");
|
||||
if (isPaper()) {
|
||||
return PlatformType.PAPER;
|
||||
} else {
|
||||
return PlatformType.SPIGOT;
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Not a Bukkit/Spigot/Paper server
|
||||
}
|
||||
|
||||
// Check for BungeeCord
|
||||
try {
|
||||
Class.forName("net.md_5.bungee.api.ProxyServer");
|
||||
return PlatformType.BUNGEECORD;
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Not a BungeeCord server
|
||||
}
|
||||
|
||||
return PlatformType.UNKNOWN;
|
||||
}
|
||||
|
||||
private static boolean isPaper() {
|
||||
// Paper has the PaperConfig class, which Spigot and Bukkit do not have
|
||||
try {
|
||||
Class.forName("com.destroystokyo.paper.PaperConfig");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,8 +1,6 @@
|
||||
package net.t2code.t2codelib;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class T2CupdateObject {
|
||||
|
||||
public String pluginName;
|
||||
|
@@ -5,7 +5,13 @@ public enum UpdateType {
|
||||
DEVELOPMENT("<dark_red>DEV</dark_red>"),
|
||||
BETA("<gold>BETA</gold>"),
|
||||
SNAPSHOT("<yellow>SNAPSHOT</yellow>"),
|
||||
STABLE("<dark_green>STABLE</dark_green>");
|
||||
STABLE("<dark_green>STABLE</dark_green>"),
|
||||
|
||||
PRERELEASE_("Pre-Release"),
|
||||
DEVELOPMENT_("DEV"),
|
||||
BETA_("BETA"),
|
||||
SNAPSHOT_("SNAPSHOT"),
|
||||
STABLE_("STABLE");
|
||||
|
||||
public String text;
|
||||
|
||||
|
@@ -5,21 +5,23 @@ import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Util {
|
||||
@Getter
|
||||
private static final UUID serverUUID = UUID.randomUUID();
|
||||
|
||||
//@Getter
|
||||
// private static final UUID serverUUID = UUID.randomUUID();
|
||||
|
||||
|
||||
public static String getInfoText() {
|
||||
return "<yellow>Description:</yellow> <gold>"+T2CodeLibMain.getPlugin().getDescription().getDescription()+"</gold>" ;
|
||||
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>";
|
||||
}
|
||||
@Getter
|
||||
private static String vPrefix = "[T2CodeLib]";
|
||||
|
||||
public static Integer getSpigotID() {
|
||||
return 96388;
|
||||
@@ -59,4 +61,38 @@ public class Util {
|
||||
"T2C-LoginPermissionAuth"
|
||||
);
|
||||
}
|
||||
|
||||
@Getter
|
||||
private static final String[] configLogo = new String[]{
|
||||
"####################################################################################################################",
|
||||
"## ##",
|
||||
"## /$$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ ##",
|
||||
"## |__ $$__//$$__ $$ /$$__ $$ | $$ | $$ ##",
|
||||
"## | $$ |__/ \\ $$| $$ \\__/ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ ##",
|
||||
"## | $$ /$$$$$$/| $$ /$$__ $$ /$$__ $$ /$$__ $$ | $$__ $$ /$$__ $$|_ $$_/ ##",
|
||||
"## | $$ /$$____/ | $$ | $$ \\ $$| $$ | $$| $$$$$$$$ | $$ \\ $$| $$$$$$$$ | $$ ##",
|
||||
"## | $$ | $$ | $$ $$| $$ | $$| $$ | $$| $$_____/ | $$ | $$| $$_____/ | $$ /$$ ##",
|
||||
"## | $$ | $$$$$$$$| $$$$$$/| $$$$$$/| $$$$$$$| $$$$$$$ /$$| $$ | $$| $$$$$$$ | $$$$/ ##",
|
||||
"## |__/ |________/ \\______/ \\______/ \\_______/ \\_______/|__/|__/ |__/ \\_______/ \\___/ ##",
|
||||
"## ##",
|
||||
"## T2CodeLib from JaTiTV / T2Code.net. In case of problems please contact the Discord: https://dc.t2code.net ##",
|
||||
"## ##",
|
||||
"####################################################################################################################"
|
||||
};
|
||||
@Getter
|
||||
public static String[] loadLogo = new String[]{
|
||||
"################################################################################",
|
||||
"## ##",
|
||||
"## _______ ___ _____ _ _ ##",
|
||||
"## |__ __| |__ \\ / ____| | | | | ##",
|
||||
"## | | ) | | | ___ __| | ___ _ __ ___ | |_ ##",
|
||||
"## | | / / | | / _ \\ / _` | / _ \\ | '_ \\ / _ \\ | __| ##",
|
||||
"## | | / /_ | |____ | (_) | | (_| | | __/ _ | | | | | __/ | |_ ##",
|
||||
"## |_| |____| \\_____| \\___/ \\__,_| \\___| (_) |_| |_| \\___| \\__| ##",
|
||||
"## ##",
|
||||
"## T2CodeLib from JaTiTV / T2Code.net. ##",
|
||||
"## In case of problems please contact the Discord: https://dc.t2code.net ##",
|
||||
"## ##",
|
||||
"################################################################################"
|
||||
};
|
||||
}
|
||||
|
@@ -1,101 +0,0 @@
|
||||
package net.t2code.t2codelib.VELOCITY;
|
||||
|
||||
|
||||
//@Plugin(id = "t2codelib", name = "T2CodeLib", version = "16.7_dev-01", authors = {"JaTiTV"})
|
||||
public class VelocityMain {
|
||||
//
|
||||
// String prefix = "[T2CodeLib]";
|
||||
//
|
||||
// protected final ProxyServer server;
|
||||
// protected final Logger logger;
|
||||
// public static final MinecraftChannelIdentifier IDENTIFIER = MinecraftChannelIdentifier.from("t2c:bcmd");
|
||||
// // public static final MinecraftChannelIdentifier IDENTIFIER2 = MinecraftChannelIdentifier.from("booster:activate");
|
||||
//
|
||||
// @Inject
|
||||
// public VelocityMain(ProxyServer server, Logger logger) {
|
||||
// long long_ = System.currentTimeMillis();
|
||||
// this.server = server;
|
||||
// this.logger = logger;
|
||||
//
|
||||
// logger.info("============================= {} =============================", prefix);
|
||||
// logger.info("Autor: JaTiTV");
|
||||
// logger.info("Version: 16.7_dev-01");
|
||||
// logger.info("Plugin loaded successfully. - {}ms", System.currentTimeMillis() - long_);
|
||||
// logger.info("============================= {} =============================", prefix);
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Subscribe
|
||||
// public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
// server.getChannelRegistrar().register(IDENTIFIER);
|
||||
// // server.getChannelRegistrar().register(IDENTIFIER2);
|
||||
// }
|
||||
//
|
||||
// @Subscribe
|
||||
// public void onPluginMessageFromPlayer(PluginMessageEvent event) {
|
||||
// if (event.getIdentifier() != IDENTIFIER) {
|
||||
// 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: {}", prefix, serverID, input);
|
||||
// dispatchCommand(input);
|
||||
// } else {
|
||||
// Player player = server.getPlayer(channel).orElse(null);
|
||||
// if (player != null) {
|
||||
// logger.info("{} [{}] T2C BCMD Command {}: {}", prefix, serverID, player, input);
|
||||
// executeCommand(player, input);
|
||||
// }
|
||||
// }
|
||||
// event.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||
// }
|
||||
//
|
||||
//// public void sendToSpigot(String sender, String boostertype, String step, String starter, String starttime, String starteruuid) {
|
||||
//// ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
//// DataOutputStream output = new DataOutputStream(stream);
|
||||
//// try {
|
||||
//// output.writeUTF(boostertype);
|
||||
//// output.writeUTF(step);
|
||||
//// output.writeUTF(starter);
|
||||
//// output.writeUTF(starttime);
|
||||
//// output.writeUTF(starteruuid);
|
||||
//// } catch (IOException e) {
|
||||
//// java.util.logging.Logger.getLogger(e.getMessage());
|
||||
//// }
|
||||
//// Optional<Player> player = server.getPlayer(sender);
|
||||
//// if (!player.isPresent()) {
|
||||
//// return;
|
||||
//// }
|
||||
//// server.getAllServers().forEach((server) -> {
|
||||
//// if (server != player.get().getCurrentServer().get().getServer()) {
|
||||
//// server.sendPluginMessage(IDENTIFIER2, stream.toByteArray());
|
||||
//// }
|
||||
//// });
|
||||
//// }
|
||||
//
|
||||
// public void dispatchCommand(String input) {
|
||||
// // Get the console command source
|
||||
// ConsoleCommandSource console = server.getConsoleCommandSource();
|
||||
//
|
||||
// // Dispatch the command
|
||||
// server.getCommandManager().executeAsync(console, input).join();
|
||||
// }
|
||||
//
|
||||
// public void executeCommand(Player player, String input) {
|
||||
// CommandManager commandManager = server.getCommandManager();
|
||||
//
|
||||
// // Dispatch the command
|
||||
// commandManager.executeImmediatelyAsync(player, input);
|
||||
// }
|
||||
|
||||
}
|
@@ -1,3 +1,5 @@
|
||||
// This class was created by JaTiTV.
|
||||
|
||||
package net.t2code.t2codelib.VELOCITY.api.commands;
|
||||
|
||||
import com.velocitypowered.api.command.CommandManager;
|
||||
@@ -9,8 +11,8 @@ import org.slf4j.Logger;
|
||||
|
||||
public class T2CVcmd {
|
||||
|
||||
public static ProxyServer server = T2CodeVMain.server;
|
||||
public static Logger logger = T2CodeVMain.logger;
|
||||
private static final ProxyServer server = T2CodeVMain.getServer();
|
||||
private static final Logger logger = T2CodeVMain.getLogger();
|
||||
|
||||
public static void Console(String cmd) {
|
||||
// Get the console command source
|
||||
@@ -27,4 +29,4 @@ public class T2CVcmd {
|
||||
commandManager.executeImmediatelyAsync(player, cmd);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
package net.t2code.t2codelib.VELOCITY.api.commands;
|
||||
//
|
||||
//import net.md_5.bungee.api.CommandSender;
|
||||
//import net.md_5.bungee.api.ProxyServer;
|
||||
//import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.HashMap;
|
||||
//import java.util.List;
|
||||
//
|
||||
public class T2CVtab {
|
||||
//
|
||||
//
|
||||
// public static void tab(List<String> matches, CommandSender sender, int arg, String[] args, String perm, Boolean onlinePlayer) {
|
||||
// if (args.length != arg + 1) return;
|
||||
// for (ProxiedPlayer player1 : ProxyServer.getInstance().getPlayers()) {
|
||||
// if (passend(player1.getName(), args[arg]) && hasPermission(sender, perm)) {
|
||||
// matches.add(player1.getName());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static void tab(List<String> matches, CommandSender sender, int argEquals, String equalsValue, int arg, String[] args, String perm, Boolean onlinePlayer) {
|
||||
// if (args.length != arg + 1) return;
|
||||
// if (!args[argEquals].toLowerCase().equals(equalsValue)) return;
|
||||
// for (ProxiedPlayer player1 : ProxyServer.getInstance().getPlayers()) {
|
||||
// if (passend(player1.getName(), args[arg]) && hasPermission(sender, perm)) {
|
||||
// matches.add(player1.getName());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static void tab(List<String> matches, CommandSender sender, int arg, String[] args, HashMap<String, String> permMap, Boolean onlinePlayer, String permForPlayer) {
|
||||
// if (args.length != arg + 1) return;
|
||||
// for (String command : permMap.keySet()) {
|
||||
// if (hasPermission(sender, permMap.get(command)) && passend(command, args[arg])) {
|
||||
// matches.add(command);
|
||||
// } else if (onlinePlayer != null && permForPlayer != null) {
|
||||
// tab(matches, sender, arg, args, permForPlayer, onlinePlayer);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static void tab(List<String> matches, CommandSender sender, int arg, String[] args, HashMap<String, String> permMap) {
|
||||
// tab(matches, sender, arg, args, permMap, null, null);
|
||||
// }
|
||||
//
|
||||
// public static void tab(List<String> matches, CommandSender sender, int argEquals, String equalsValue, int arg, String[] args, HashMap<String, String> permMap) {
|
||||
// if (args.length != arg + 1) return;
|
||||
// if (!args[argEquals].toLowerCase().equals(equalsValue)) return;
|
||||
// for (String command : permMap.keySet()) {
|
||||
// if (hasPermission(sender, permMap.get(command)) && passend(command, args[arg])) {
|
||||
// matches.add(command);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static List<String> tab(CommandSender sender, int arg, String[] args, String perm, String command) {
|
||||
// List<String> matches = new ArrayList<>();
|
||||
// if (hasPermission(sender, perm) && passend(command, args[arg])) {
|
||||
// matches.add(command);
|
||||
// }
|
||||
// return matches;
|
||||
// }
|
||||
//
|
||||
// public static Boolean passend(String command, String arg) {
|
||||
// for (int i = 0; i < arg.toUpperCase().length(); i++) {
|
||||
// if (arg.toUpperCase().length() >= command.toUpperCase().length()) {
|
||||
// return false;
|
||||
// } else {
|
||||
// if (arg.toUpperCase().charAt(i) != command.toUpperCase().charAt(i)) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// public static boolean hasPermission(CommandSender sender, String permission) {
|
||||
// String[] Permissions = permission.split(";");
|
||||
// for (String perm : Permissions) {
|
||||
// if (sender.hasPermission(perm)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
package net.t2code.t2codelib.VELOCITY.api.messages;
|
||||
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import net.t2code.t2codelib.T2CupdateWebData;
|
||||
import net.t2code.t2codelib.VELOCITY.api.update.T2CVupdateAPI;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class T2CBtemplate {
|
||||
|
||||
|
||||
public static Long onLoadHeader(String prefix, String autor, String version, String spigot, String discord) {
|
||||
Long long_ = Long.valueOf(System.currentTimeMillis());
|
||||
T2CVsend.console(prefix + "§4============================= " + prefix + " §4=============================");
|
||||
T2CVsend.console(prefix + " §2Autor: §6" + autor.replace("[", "").replace("]", ""));
|
||||
T2CVsend.console(prefix + " §2Version: §6" + version);
|
||||
T2CVsend.console(prefix + " §2Spigot: §6" + spigot);
|
||||
T2CVsend.console(prefix + " §2Discord: §6" + discord);
|
||||
T2CVsend.console(prefix + " §8-------------------------------");
|
||||
return long_;
|
||||
}
|
||||
|
||||
public static void onLoadSeparateStroke(String prefix) {
|
||||
T2CVsend.console(prefix + " §8-------------------------------");
|
||||
}
|
||||
|
||||
public static void onLoadFooter(String prefix, Long long_) {
|
||||
T2CVsend.console(prefix + " §8-------------------------------");
|
||||
T2CVsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
||||
T2CVsend.console(prefix + "§4============================= " + prefix + " §4=============================");
|
||||
}
|
||||
|
||||
public static void onDisable(String prefix, String autor, String version, String spigot, String discord) {
|
||||
T2CVsend.console(prefix + "§4============================= " + prefix + " §4=============================");
|
||||
T2CVsend.console(prefix + " §2Autor: §6" + autor.replace("[", "").replace("]", ""));
|
||||
T2CVsend.console(prefix + " §2Version: §6" + version);
|
||||
T2CVsend.console(prefix + " §2Spigot: §6" + spigot);
|
||||
T2CVsend.console(prefix + " §2Discord: §6" + discord);
|
||||
T2CVsend.console(prefix + " §4Plugin successfully disabled.");
|
||||
T2CVsend.console(prefix + "§4============================= " + prefix + " §4=============================");
|
||||
}
|
||||
|
||||
public static void sendInfo(CommandSource sender, PluginContainer plugin, String prefix, String spigot, String discord, String autor) {
|
||||
T2CupdateWebData webData = T2CVupdateAPI.bungeePluginVersins.get(plugin.getDescription().getName()).webData;
|
||||
String pluginVersion = String.valueOf(plugin.getDescription().getVersion());
|
||||
T2CVsend.sender(sender, prefix + "§4======= " + prefix + " §4=======");
|
||||
T2CVsend.sender(sender, prefix + " §2Autor: §6" + autor);
|
||||
if (webData.getVersion().equalsIgnoreCase(pluginVersion)) {
|
||||
T2CVsend.sender(sender, prefix + " §2Version: §6" + pluginVersion);
|
||||
} else {
|
||||
T2CVupdateAPI.sendUpdateMsg(prefix, discord, webData, Optional.of(plugin), sender);
|
||||
}
|
||||
T2CVsend.sender(sender, prefix + " §2Spigot: §6" + spigot);
|
||||
T2CVsend.sender(sender, prefix + " §2Discord: §6" + discord);
|
||||
T2CVsend.sender(sender, prefix + "§4======= " + prefix + " §4=======");
|
||||
}
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
package net.t2code.t2codelib.VELOCITY.api.messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class T2CVreplace {
|
||||
|
||||
public static String replace(String prefix, String Text) {
|
||||
return Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü")
|
||||
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
|
||||
.replace("[ae]", "ä").replace("[AE]", "Ä");
|
||||
}
|
||||
|
||||
public static List<String> replace(String prefix, List<String> Text) {
|
||||
List<String> output = new ArrayList<>();
|
||||
for (String input : Text) {
|
||||
output.add(input.replace("[prefix]", prefix).replace("&", "§")
|
||||
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
|
||||
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä"));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public static List replacePrice(String prefix,List<String> Text, String price) {
|
||||
List rp = new ArrayList();
|
||||
for (String s : Text) {
|
||||
rp.add(s.replace("[prefix]", prefix).replace("&", "§")
|
||||
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
|
||||
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
|
||||
.replace("[price]", String.valueOf(price)));
|
||||
}
|
||||
return rp;
|
||||
}
|
||||
}
|
@@ -1,67 +1,97 @@
|
||||
package net.t2code.t2codelib.VELOCITY.api.messages;
|
||||
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
|
||||
import net.t2code.t2codelib.VELOCITY.system.config.T2CVlibConfig;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class T2CVsend {
|
||||
public static ProxyServer server = T2CodeVMain.server;
|
||||
public static Logger logger = T2CodeVMain.logger;
|
||||
|
||||
public static void console(String msg) {
|
||||
logger.info(msg);
|
||||
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 title(Player player, Title msg) {
|
||||
player.showTitle(msg);
|
||||
}
|
||||
|
||||
public static void sender(CommandSource sender, String msg) {
|
||||
sender.sendMessage(Component.text( msg));
|
||||
if (msg == null || msg.contains("[empty]")) return;
|
||||
sender.sendMessage(Component.text(msg));
|
||||
}
|
||||
|
||||
public static void debug(Optional<PluginContainer> plugin, String msg) {
|
||||
debug(plugin, msg, null);
|
||||
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 debug(Optional<PluginContainer> plugin, String msg, Integer stage) {
|
||||
// if (!new File(Main.getPath(), "config.yml").exists()) return;
|
||||
// if (stage == null) {
|
||||
// if (plugin.getConfig().getBoolean("Plugin.Debug")) {
|
||||
// ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg);
|
||||
// }
|
||||
// return;
|
||||
//}
|
||||
//if (plugin.getConfig().getInt("Plugin.Debug") >= stage) {
|
||||
// ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + 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 debugmsg(PluginContainer plugin, String msg) {
|
||||
logger.info("{} §5DEBUG-MSG: §6{}", plugin.getDescription().getName(), 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 info(PluginContainer plugin, String msg) {
|
||||
logger.info("{} {}", plugin.getDescription().getName(), 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 warning(PluginContainer plugin, String msg) {
|
||||
logger.warn("{} {}", plugin.getDescription().getName(), msg);
|
||||
|
||||
public static void debugmsg(Logger logger, String msg) {
|
||||
logger.warn(msg);
|
||||
}
|
||||
|
||||
public static void error(PluginContainer plugin, String msg) {
|
||||
logger.error("{} {}", plugin.getDescription().getName(), msg);
|
||||
public static void debug(Logger logger, String msg) {
|
||||
if (!(boolean)T2CVlibConfig.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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,27 +1,28 @@
|
||||
package net.t2code.t2codelib.VELOCITY.api.pluginMessaging;
|
||||
// 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.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import net.t2code.t2codelib.VELOCITY.api.commands.T2CVcmd;
|
||||
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class T2CplmsgBcmd {
|
||||
public class T2CVplmsgCmd {
|
||||
|
||||
public static ProxyServer server = T2CodeVMain.server;
|
||||
public static Logger logger = T2CodeVMain.logger;
|
||||
private final ProxyServer server;
|
||||
private final Logger logger;
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
server.getChannelRegistrar().register(T2CodeVMain.bcmd);
|
||||
// server.getChannelRegistrar().register(IDENTIFIER2);
|
||||
public T2CVplmsgCmd(ProxyServer server, Logger logger) {
|
||||
this.server = server;
|
||||
this.logger = logger;
|
||||
server.getChannelRegistrar().register(T2CodeVMain.bcmd);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -40,16 +41,16 @@ public class T2CplmsgBcmd {
|
||||
}
|
||||
|
||||
if (channel.equals("T2Code-Console")) {
|
||||
logger.info("{} [{}] T2C BCMD Command Console: {}", T2CodeVMain.prefix, serverID, input);
|
||||
T2CVcmd.Console(input);
|
||||
logger.info("{} [{}] T2C BCMD Command Console: {}", Util.getVPrefix(), serverID, input);
|
||||
T2CVcmd.Console(input);
|
||||
} else {
|
||||
Player player = server.getPlayer(channel).orElse(null);
|
||||
if (player != null) {
|
||||
logger.info("{} [{}] T2C BCMD Command {}: {}", T2CodeVMain.prefix, serverID, player, input);
|
||||
logger.info("{} [{}] T2C BCMD Command {}: {}", Util.getVPrefix(), serverID, player, input);
|
||||
T2CVcmd.Player(player, input);
|
||||
}
|
||||
}
|
||||
event.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
package net.t2code.t2codelib.VELOCITY.api.pluginMessaging.autoResponse;
|
||||
// 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;
|
||||
@@ -14,9 +15,15 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class T2CapiAutoResponse {
|
||||
public static ProxyServer server = T2CodeVMain.server;
|
||||
public static Logger logger = T2CodeVMain.logger;
|
||||
public class T2CVapiAutoResponse {
|
||||
private final ProxyServer server;
|
||||
private final Logger logger;
|
||||
|
||||
public T2CVapiAutoResponse(ProxyServer server, Logger logger) {
|
||||
this.server = server;
|
||||
this.logger = logger;
|
||||
server.getChannelRegistrar().register(T2CodeVMain.aresp);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPluginmessage(PluginMessageEvent event) {
|
@@ -1,5 +1,6 @@
|
||||
package net.t2code.t2codelib.VELOCITY.api.pluginMessaging.commandgui;
|
||||
// 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;
|
||||
@@ -16,8 +17,14 @@ import java.io.IOException;
|
||||
|
||||
public class T2CVapiCGUI {
|
||||
|
||||
public static ProxyServer server = T2CodeVMain.server;
|
||||
public static Logger logger = T2CodeVMain.logger;
|
||||
private static ProxyServer server;
|
||||
private static Logger logger;
|
||||
|
||||
public T2CVapiCGUI(ProxyServer server, Logger logger) {
|
||||
T2CVapiCGUI.server = server;
|
||||
T2CVapiCGUI.logger = logger;
|
||||
server.getChannelRegistrar().register(T2CodeVMain.cguiopl);
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
@@ -65,4 +72,4 @@ public class T2CVapiCGUI {
|
||||
server.sendPluginMessage(T2CodeVMain.cguiopl, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,17 +1,25 @@
|
||||
package net.t2code.t2codelib.VELOCITY.api.pluginMessaging.opSecurity;
|
||||
// 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.T2CodeVMain;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class T2CapiOpSecurity {
|
||||
public static ProxyServer server = T2CodeVMain.server;
|
||||
public class T2CVapiOpSecurity {
|
||||
private static ProxyServer server ;
|
||||
private static Logger logger ;
|
||||
|
||||
public T2CVapiOpSecurity(ProxyServer server, Logger logger) {
|
||||
T2CVapiOpSecurity.server = server;
|
||||
T2CVapiOpSecurity.logger = logger;
|
||||
server.getChannelRegistrar().register(T2CodeVMain.opsec);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPluginmessage(PluginMessageEvent event) {
|
||||
@@ -19,17 +27,17 @@ public class T2CapiOpSecurity {
|
||||
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();
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,10 +49,10 @@ public class T2CapiOpSecurity {
|
||||
output.writeUTF(mode);
|
||||
output.writeUTF(information);
|
||||
} catch (IOException e) {
|
||||
Logger.getLogger(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
for (RegisteredServer server : server.getAllServers()) {
|
||||
server.sendPluginMessage(T2CodeVMain.opsec, stream.toByteArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,9 @@
|
||||
// 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;
|
||||
@@ -11,14 +14,15 @@ import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayersEnum;
|
||||
import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend;
|
||||
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public class T2CVPlayers {
|
||||
|
||||
public static ProxyServer server = T2CodeVMain.server;
|
||||
public static org.slf4j.Logger logger = T2CodeVMain.logger;
|
||||
public static ProxyServer server = T2CodeVMain.getServer();
|
||||
public static Logger logger = T2CodeVMain.getLogger();
|
||||
|
||||
@Subscribe
|
||||
public void onJoin(PostLoginEvent e) {
|
||||
@@ -54,12 +58,12 @@ public class T2CVPlayers {
|
||||
output.writeUTF(name);
|
||||
output.writeUTF(uuid);
|
||||
} catch (IOException e) {
|
||||
Logger.getLogger(e.getMessage());
|
||||
logger.error (e.getMessage());
|
||||
}
|
||||
T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received channel: t2c:bonlp");
|
||||
T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received subChannel: " + value.name());
|
||||
T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received input: " + name);
|
||||
T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received input2/uuid: " + uuid);
|
||||
T2CVsend.debug(logger, "PluginMessage received channel: t2c:bonlp");
|
||||
T2CVsend.debug(logger, "PluginMessage received subChannel: " + value.name());
|
||||
T2CVsend.debug(logger, "PluginMessage received input: " + name);
|
||||
T2CVsend.debug(logger, "PluginMessage received input2/uuid: " + uuid);
|
||||
byte[] data = stream.toByteArray();
|
||||
for (RegisteredServer server : server.getAllServers()) {
|
||||
server.sendPluginMessage(T2CodeVMain.bonlp, data);
|
||||
@@ -75,7 +79,7 @@ public class T2CVPlayers {
|
||||
output.writeUTF("");
|
||||
output.writeUTF("");
|
||||
} catch (IOException e) {
|
||||
Logger.getLogger(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
byte[] data = stream.toByteArray();
|
||||
for (RegisteredServer server : server.getAllServers()) {
|
||||
@@ -94,9 +98,9 @@ public class T2CVPlayers {
|
||||
T2CbungeePlayersEnum subChannel = T2CbungeePlayersEnum.valueOf(stream.readUTF());
|
||||
String input = stream.readUTF();
|
||||
|
||||
T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received channel: " + T2CodeVMain.bonlp);
|
||||
T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received subChannel: " + subChannel.name());
|
||||
T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received input/uuid: " + input);
|
||||
T2CVsend.debug(logger, "PluginMessage received channel: " + T2CodeVMain.bonlp);
|
||||
T2CVsend.debug(logger, "PluginMessage received subChannel: " + subChannel.name());
|
||||
T2CVsend.debug(logger, "PluginMessage received input/uuid: " + input);
|
||||
|
||||
sendToSpigotPlayer("", subChannel, input);
|
||||
} catch (IOException e) {
|
||||
@@ -104,4 +108,4 @@ public class T2CVPlayers {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,79 +1,77 @@
|
||||
package net.t2code.t2codelib.VELOCITY.api.update;
|
||||
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.t2code.t2codelib.T2CVupdateObject;
|
||||
import net.t2code.t2codelib.T2CupdateObject;
|
||||
import net.t2code.t2codelib.T2CupdateWebData;
|
||||
import net.t2code.t2codelib.UpdateType;
|
||||
import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend;
|
||||
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
|
||||
import net.t2code.t2codelib.VELOCITY.system.config.T2CVlibConfig;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
|
||||
public class T2CVupdateAPI {
|
||||
public static HashMap<Optional<String>, T2CVupdateObject> bungeePluginVersins = new HashMap<>();
|
||||
public static ProxyServer server = T2CodeVMain.server;
|
||||
public static HashMap<String, T2CupdateObject> bungeePluginVersins = new HashMap<>();
|
||||
|
||||
|
||||
public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Optional<PluginContainer> plugin, CommandSource sender) {
|
||||
public static void sendUpdateMsg(Logger logger, String prefix, String discord, T2CupdateWebData webData, PluginContainer plugin) {
|
||||
String publicVersion = webData.getVersion();
|
||||
String pluginVersion = String.valueOf(plugin.get().getDescription().getVersion());
|
||||
String pluginVersion = plugin.getDescription().getVersion().orElse("unknown");
|
||||
String value;
|
||||
if (webData.isPreRelease()) {
|
||||
value = UpdateType.PRERELEASE.text;
|
||||
value = UpdateType.PRERELEASE_.text;
|
||||
if (publicVersion.toLowerCase().contains("dev")) {
|
||||
value = UpdateType.DEVELOPMENT.text;
|
||||
value = UpdateType.DEVELOPMENT_.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("beta")) {
|
||||
value = UpdateType.BETA.text;
|
||||
value = UpdateType.BETA_.text;
|
||||
}
|
||||
if (publicVersion.toLowerCase().contains("snapshot")) {
|
||||
value = UpdateType.SNAPSHOT.text;
|
||||
value = UpdateType.SNAPSHOT_.text;
|
||||
}
|
||||
} else value = UpdateType.STABLE.text;
|
||||
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 s2 = "<br><dark_red>║</dark_red> <gold>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</gold> <green>" + webData.getVersion() + "</green>";
|
||||
String s3 = "<br><dark_red>║</dark_red> <gold>You can download it here:</gold> <yellow>" + webData.getUpdateUrl() + "</yellow>";
|
||||
String s4 = "<br><dark_red>║</dark_red> <gold>You can find more information on Discord:</gold> <yellow>" + discord + "</yellow>";
|
||||
String f = "<br><dark_red>╚══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
|
||||
String text = h + s1 + s2 + s3 + s4 + f;
|
||||
if (sender == null) {
|
||||
T2CVsend.console(text);
|
||||
} else T2CVsend.sender(sender, text);
|
||||
|
||||
} else value = UpdateType.STABLE_.text;
|
||||
T2CVsend.console(logger, "╔══════════════" + prefix + "══════════════");
|
||||
T2CVsend.console(logger, "║ A new [value] version was found!".replace("[value]", value));
|
||||
T2CVsend.console(logger, "║ Your version: " + pluginVersion + " - Current version: " + webData.getVersion());
|
||||
T2CVsend.console(logger, "║ You can download it here: " + webData.getUpdateUrl());
|
||||
T2CVsend.console(logger, "║ You can find more information on Discord: " + discord);
|
||||
T2CVsend.console(logger, "╚══════════════" + prefix + "══════════════");
|
||||
}
|
||||
|
||||
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) T2CVlibConfig.VALUES.updateTimer.getValue() < 1) {
|
||||
T2CVlibConfig.VALUES.updateTimer.setValue(1);
|
||||
}
|
||||
|
||||
public static void checkForUpdates(Optional<PluginContainer> plugin, String prefix, String discord, Integer spigotID, String url) {
|
||||
server.getScheduler().buildTask(plugin, () -> {
|
||||
(new T2CVupdateCheckerGit(plugin,logger)).getVersion((webData) -> {
|
||||
pluginVersion = plugin.getDescription().getVersion().toString();
|
||||
T2CupdateObject update = new T2CupdateObject(
|
||||
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) {
|
||||
T2CVsend.console(logger, " No update found.");
|
||||
noUpdate = false;
|
||||
}
|
||||
}
|
||||
}, pluginVersion, spigotID, url);
|
||||
|
||||
// if (T2CVlibConfig.getUpdateCheckFullDisable()) return;
|
||||
(new T2CVupdateCheckerGit(plugin, spigotID)).getVersion((webData) -> {
|
||||
pluginVersion = T2CodeVMain.version;
|
||||
T2CVupdateObject update = new T2CVupdateObject(
|
||||
plugin.get().getDescription().getName(),
|
||||
plugin.get().getDescription().getVersion(),
|
||||
webData,
|
||||
false,
|
||||
!plugin.get().getDescription().getVersion().equals(webData.getVersion()),
|
||||
true
|
||||
);
|
||||
bungeePluginVersins.put(plugin.get().getDescription().getName(), update);
|
||||
if (!pluginVersion.replace("_Bungee", "").equalsIgnoreCase(webData.getVersion())) {
|
||||
sendUpdateMsg(prefix, discord, webData, plugin, null);
|
||||
noUpdate = true;
|
||||
} else {
|
||||
if (noUpdate) {
|
||||
T2CVsend.console(prefix + " §2No update found.");
|
||||
noUpdate = false;
|
||||
}
|
||||
}
|
||||
}, pluginVersion, spigotID, url);
|
||||
}).repeat(Duration.ofMinutes((int) T2CVlibConfig.VALUES.updateTimer.getValue())).schedule();
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,9 @@
|
||||
package net.t2code.t2codelib.VELOCITY.api.update;
|
||||
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.t2code.t2codelib.T2CVupdateObject;
|
||||
import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig;
|
||||
import net.t2code.t2codelib.T2CupdateObject;
|
||||
import net.t2code.t2codelib.T2CupdateWebData;
|
||||
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
@@ -15,88 +14,88 @@ import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class T2CVupdateCheckerGit {
|
||||
private Optional<PluginContainer> plugin;
|
||||
private int resourceId;
|
||||
public static ProxyServer server = T2CodeVMain.server;
|
||||
public static Logger logger = T2CodeVMain.logger;
|
||||
|
||||
public T2CVupdateCheckerGit(Optional<PluginContainer> plugin, int resourceId) {
|
||||
public class T2CVupdateCheckerGit {
|
||||
private PluginContainer plugin;
|
||||
private Logger logger;
|
||||
|
||||
|
||||
public T2CVupdateCheckerGit(PluginContainer plugin, Logger logger) {
|
||||
this.plugin = plugin;
|
||||
this.resourceId = resourceId;
|
||||
this.logger=logger;
|
||||
|
||||
}
|
||||
|
||||
public void getVersion(Consumer<T2CupdateWebData> consumer, String pluginVersion, Integer spigotID, String gitKey) {
|
||||
// if (T2CVlibConfig.getUpdateCheckFullDisable()) return;
|
||||
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1";
|
||||
// if (!T2CVlibConfig.getSeePreReleaseUpdates()) {
|
||||
if (!(boolean)T2CBlibConfig.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;
|
||||
}
|
||||
|
||||
T2CupdateWebData webData = new T2CupdateWebData(updateTitle, version, updateDescription, updateUrl, publishedAt, downloadURL, gitURL, preRelease);
|
||||
consumer.accept(webData);
|
||||
} catch (Exception var10) {
|
||||
Boolean load = false;
|
||||
if (T2CVupdateAPI.bungeePluginVersins.containsKey(plugin.get().getDescription().getName())) {
|
||||
load = T2CVupdateAPI.bungeePluginVersins.get(plugin.get().getDescription().getName()).load;
|
||||
}
|
||||
T2CVupdateObject update = new T2CVupdateObject(
|
||||
plugin.get().getDescription().getName(),
|
||||
Optional.ofNullable(pluginVersion),
|
||||
null,
|
||||
load,
|
||||
false,
|
||||
true
|
||||
);
|
||||
T2CVupdateAPI.bungeePluginVersins.put(plugin.get().getDescription().getName(), update);
|
||||
logger.info("§4 Cannot look for updates: {}", var10.getMessage());
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
T2CupdateWebData webData = new T2CupdateWebData(updateTitle, version, updateDescription, updateUrl, publishedAt, downloadURL, gitURL, preRelease);
|
||||
consumer.accept(webData);
|
||||
} catch (Exception var10) {
|
||||
Boolean load = false;
|
||||
if (T2CVupdateAPI.bungeePluginVersins.containsKey(plugin.getDescription().getName().toString())) {
|
||||
load = T2CVupdateAPI.bungeePluginVersins.get(plugin.getDescription().getName().toString()).load;
|
||||
}
|
||||
T2CupdateObject update = new T2CupdateObject(
|
||||
plugin.getDescription().getName().toString(),
|
||||
pluginVersion,
|
||||
null,
|
||||
load,
|
||||
false,
|
||||
true
|
||||
);
|
||||
T2CVupdateAPI.bungeePluginVersins.put(plugin.getDescription().getName().toString(), update);
|
||||
logger.error("Cannot look for updates: {}", var10.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,86 +0,0 @@
|
||||
package net.t2code.t2codelib.VELOCITY.api.yaml;
|
||||
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
|
||||
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class T2CVconfig {
|
||||
private final Path configPath;
|
||||
private final @NonNull YAMLConfigurationLoader loader;
|
||||
private CommentedConfigurationNode configNode;
|
||||
|
||||
public T2CVconfig(Path configPath, ProxyServer proxy, PluginContainer pluginContainer, Logger logger) {
|
||||
this.configPath = configPath;
|
||||
loader = YAMLConfigurationLoader.builder().setPath(configPath).build();
|
||||
try {
|
||||
this.configNode = (CommentedConfigurationNode) loader.load();
|
||||
} catch (IOException e) {
|
||||
logger.error("Error loading configuration file {}", configPath.getFileName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveConfig() {
|
||||
try {
|
||||
loader.save(configNode);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Error saving configuration file " + configPath.getFileName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public void set(String path, Object value) {
|
||||
configNode.getNode((Object[]) path.split("\\.")).setValue(value);
|
||||
}
|
||||
|
||||
public String select(String path) {
|
||||
return configNode.getNode((Object[]) path.split("\\.")).getString();
|
||||
}
|
||||
|
||||
public int selectInt(String path) {
|
||||
return configNode.getNode((Object[]) path.split("\\.")).getInt();
|
||||
}
|
||||
|
||||
public boolean selectBoolean(String path) {
|
||||
return configNode.getNode((Object[]) path.split("\\.")).getBoolean();
|
||||
}
|
||||
|
||||
public double selectDouble(String path) {
|
||||
return configNode.getNode((Object[]) path.split("\\.")).getDouble();
|
||||
}
|
||||
|
||||
public List<String> selectList(String path) {
|
||||
List<String> list = new ArrayList<>();
|
||||
ConfigurationNode node = configNode.getNode((Object[]) path.split("\\."));
|
||||
if (node.hasListChildren()) {
|
||||
for (ConfigurationNode child : node.getChildrenList()) {
|
||||
list.add(child.getString(""));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<String> selectList(String prefix, String path) {
|
||||
List<String> output = new ArrayList<>();
|
||||
ConfigurationNode node = configNode.getNode((Object[]) path.split("\\."));
|
||||
if (node.hasListChildren()) {
|
||||
for (ConfigurationNode child : node.getChildrenList()) {
|
||||
output.add(prefix + child.getString());
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
public void setList(List<String> value, String path) {
|
||||
configNode.getNode((Object[]) path.split("\\.")).setValue(value);
|
||||
}
|
||||
}
|
@@ -0,0 +1,143 @@
|
||||
package net.t2code.t2codelib.VELOCITY.api.yml;// This class was created by JaTiTV.
|
||||
|
||||
|
||||
import net.t2code.t2codelib.T2CconfigItem;
|
||||
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 T2CVconfigWriter {
|
||||
|
||||
|
||||
|
||||
public static void createConfig(Logger logger, File configFile, T2CconfigItem[] manager, String... header) throws IOException {
|
||||
|
||||
if (!configFile.exists()) {
|
||||
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<>();
|
||||
}
|
||||
for(T2CconfigItem value : manager){
|
||||
readValue(config,value.getPath(), value);
|
||||
addValue(config, value.getPath(), value.getValue());
|
||||
comments.put(value.getPath(), value.getComments());
|
||||
}
|
||||
saveConfigWithComments(configFile, comments,config, header);
|
||||
}
|
||||
|
||||
private static void readValue(Map<String, Object> config, String path, T2CconfigItem 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){
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
package net.t2code.t2codelib.VELOCITY.system;
|
||||
|
||||
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.t2code.t2codelib.VELOCITY.api.proxyPlayers.T2CVPlayers;
|
||||
import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend;
|
||||
import net.t2code.t2codelib.VELOCITY.system.config.VelocityConfig;
|
||||
import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.commandgui.T2CVapiCGUI;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class T2CVload {
|
||||
public static ProxyServer server = T2CodeVMain.server;
|
||||
public static Logger logger = T2CodeVMain.logger;
|
||||
|
||||
|
||||
|
||||
public static void onLoad(Optional<PluginContainer> plugin, String prefix, String version, String spigot, String discord, Integer spigotID, Integer bstatsID, String url) {
|
||||
long long_ = System.currentTimeMillis();
|
||||
T2CVsend.console(prefix + "§4============================= " + prefix + " §4=============================");
|
||||
// T2CVsend.console(prefix + " §2Autor: §6" + String.valueOf(plugin.get().getDescription().getAuthors()).replace("[", "").replace("]", ""));
|
||||
T2CVsend.console(prefix + " §2Version: §6" + version);
|
||||
T2CVsend.console(prefix + " §2Spigot: §6" + spigot);
|
||||
T2CVsend.console(prefix + " §2Discord: §6" + discord);
|
||||
|
||||
|
||||
|
||||
//T2CVlibConfig.create();
|
||||
VelocityConfig.main();
|
||||
// try {
|
||||
// T2CVlibConfig.select();
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//API
|
||||
server.getChannelRegistrar().register(T2CodeVMain.bcmd);
|
||||
|
||||
server.getChannelRegistrar().register(T2CodeVMain.bonlp);
|
||||
T2CVPlayers.sendToSpigotDeleteAll();
|
||||
|
||||
// if (T2CVlibConfig.getApiCommandGUIEnable()) {
|
||||
server.getChannelRegistrar().register(T2CodeVMain.cguiopl);
|
||||
T2CVapiCGUI.sendToSpigotDeleteAll();
|
||||
// }
|
||||
|
||||
// if (T2CVlibConfig.getApiAutoResponse()) {
|
||||
server.getChannelRegistrar().register(T2CodeVMain.aresp);
|
||||
// }
|
||||
|
||||
// if (T2CVlibConfig.getApiOpSecurity()) {
|
||||
server.getChannelRegistrar().register(T2CodeVMain.opsec);
|
||||
//}
|
||||
|
||||
|
||||
T2CVsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
T2CVsend.console(prefix + "§4============================= " + prefix + " §4=============================");
|
||||
}
|
||||
}
|
@@ -1,33 +1,46 @@
|
||||
// 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.event.proxy.ProxyShutdownEvent;
|
||||
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 com.velocitypowered.api.scheduler.Scheduler;
|
||||
import lombok.Getter;
|
||||
|
||||
import net.t2code.t2codelib.Util;
|
||||
import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.T2CVplmsgCmd;
|
||||
import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.autoResponse.T2CVapiAutoResponse;
|
||||
import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.commandgui.T2CVapiCGUI;
|
||||
import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.opSecurity.T2CVapiOpSecurity;
|
||||
import net.t2code.t2codelib.VELOCITY.api.proxyPlayers.T2CVPlayers;
|
||||
import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend;
|
||||
import net.t2code.t2codelib.VELOCITY.api.update.T2CVupdateAPI;
|
||||
import net.t2code.t2codelib.VELOCITY.system.bstats.Metrics;
|
||||
import net.t2code.t2codelib.VELOCITY.system.config.T2CVlibConfig;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class T2CodeVMain {
|
||||
public class T2CodeVMain {
|
||||
|
||||
@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 Metrics.Factory metricsFactory;
|
||||
|
||||
|
||||
public static Optional<PluginContainer> pluginContainer;
|
||||
|
||||
|
||||
|
||||
public static final String prefix = "[T2CodeLib]";
|
||||
public static ProxyServer server;
|
||||
public static Logger logger;
|
||||
public static final MinecraftChannelIdentifier bcmd = MinecraftChannelIdentifier.from("t2c:bcmd");
|
||||
public static final MinecraftChannelIdentifier bonlp = MinecraftChannelIdentifier.from("t2c:bonlp");
|
||||
public static final MinecraftChannelIdentifier cguiopl = MinecraftChannelIdentifier.from("t2c:cguiopl");
|
||||
@@ -36,46 +49,76 @@ public class T2CodeVMain {
|
||||
|
||||
|
||||
@Inject
|
||||
public T2CodeVMain(ProxyServer server, Logger logger) throws IOException {
|
||||
// Plugin startup logic
|
||||
public T2CodeVMain(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory, Metrics.Factory metricsFactory) {
|
||||
starttime = System.currentTimeMillis();
|
||||
T2CodeVMain.server = server;
|
||||
T2CodeVMain.logger = logger;
|
||||
pluginContainer = server.getPluginManager().getPlugin("t2codelib");
|
||||
|
||||
// orgVersion = plugin.getDescription().getVersion();
|
||||
// autor = plugin.getDescription().getAuthor();
|
||||
|
||||
int pluginId = Util.getBstatsID();
|
||||
// T2CVmetrics metrics = metricsFactory.make(this, pluginId);
|
||||
T2CodeVMain.dataDirectory = dataDirectory;
|
||||
this.metricsFactory = metricsFactory;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyShutdown(ProxyShutdownEvent event) {
|
||||
// Plugin shutdown logic
|
||||
public void onLoad(ProxyInitializeEvent e) {
|
||||
new pl(this, server);
|
||||
logger.info("╔════════════════════════════════════");
|
||||
// logger.info("║");
|
||||
for (String s : Util.getLoadLogo()) {
|
||||
logger.info("║ {}", s);
|
||||
}
|
||||
logger.info("║");
|
||||
// Thread.sleep(5000);
|
||||
logger.info("║ Author: {}", String.valueOf(plugin.getDescription().getAuthors()).replace("[", "").replace("]", ""));
|
||||
logger.info("║ Version: {}", plugin.getDescription().getVersion().orElse("unknown"));
|
||||
logger.info("║ Spigot: {}", Util.getSpigot());
|
||||
logger.info("║ Discord: {}", Util.getDiscord());
|
||||
|
||||
try {
|
||||
T2CVlibConfig.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 T2CVplmsgCmd(server, logger));
|
||||
|
||||
|
||||
server.getChannelRegistrar().register(T2CodeVMain.bonlp);
|
||||
T2CVPlayers.sendToSpigotDeleteAll();
|
||||
|
||||
T2CVsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4=============================");
|
||||
T2CVsend.console(Util.getPrefix() + " §2Autor: §6" + String.valueOf(pluginContainer.get().getDescription().getAuthors()).replace("[", "").replace("]", ""));
|
||||
|
||||
T2CVsend.console(Util.getPrefix() + " §2Spigot: §6" + Util.getSpigot());
|
||||
T2CVsend.console(Util.getPrefix() + " §2Discord: §6" + Util.getDiscord());
|
||||
T2CVsend.console(Util.getPrefix() + " §4Plugin successfully disabled.");
|
||||
T2CVsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4=============================");
|
||||
if ((boolean) T2CVlibConfig.VALUES.apiCommandGUIEnable.getValue()) {
|
||||
server.getEventManager().register(this, new T2CVapiCGUI(server, logger));
|
||||
T2CVapiCGUI.sendToSpigotDeleteAll();
|
||||
}
|
||||
|
||||
if ((boolean) T2CVlibConfig.VALUES.apiAutoResponse.getValue()) {
|
||||
server.getEventManager().register(this, new T2CVapiAutoResponse(server, logger));
|
||||
}
|
||||
|
||||
if ((boolean) T2CVlibConfig.VALUES.apiOpSecurity.getValue()) {
|
||||
server.getEventManager().register(this, new T2CVapiOpSecurity(server, logger));
|
||||
}
|
||||
|
||||
|
||||
Metrics.bStats(this, Util.getBstatsID(), metricsFactory);
|
||||
T2CVupdateAPI.onUpdateCheckTimer(logger, plugin, server, Util.getVPrefix(), Util.getDiscord(), Util.getSpigotID(), Util.getGit());
|
||||
logger.info("║");
|
||||
logger.info("║ Plugin loaded successfully - {}ms", System.currentTimeMillis() - starttime);
|
||||
logger.info("╚════════════════════════════════════");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onProxyInitialize(ProxyInitializeEvent event) {
|
||||
// Schedule the task to check for updates every 60 minutes
|
||||
Scheduler scheduler = server.getScheduler();
|
||||
|
||||
scheduler.buildTask(this, this:: checkForUpdates)
|
||||
.repeat(60, TimeUnit.MINUTES)
|
||||
.schedule();
|
||||
}
|
||||
private void checkForUpdates() {
|
||||
T2CVupdateAPI.checkForUpdates(pluginContainer, prefix, Util.getDiscord(), Util.getSpigotID(), Util.getGit());
|
||||
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
@@ -1,134 +0,0 @@
|
||||
package net.t2code.t2codelib.VELOCITY.system.bstats;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.plugin.PluginDescription;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import org.bstats.MetricsBase;
|
||||
import org.bstats.charts.CustomChart;
|
||||
import org.bstats.config.MetricsConfig;
|
||||
import org.bstats.json.JsonObjectBuilder;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class T2CVmetrics {
|
||||
|
||||
/**
|
||||
* A factory to create new Metrics classes.
|
||||
*/
|
||||
public static class Factory {
|
||||
|
||||
private final ProxyServer server;
|
||||
private final Logger logger;
|
||||
private final Path dataDirectory;
|
||||
|
||||
// The constructor is not meant to be called by the user.
|
||||
// The instance is created using Dependency Injection
|
||||
@Inject
|
||||
private Factory(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
|
||||
this.server = server;
|
||||
this.logger = logger;
|
||||
this.dataDirectory = dataDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Metrics class.
|
||||
*
|
||||
* @param plugin The plugin instance.
|
||||
* @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>
|
||||
* <p>Not to be confused with Velocity's {@link PluginDescription#getId()} method!
|
||||
* @return A Metrics instance that can be used to register custom charts.
|
||||
* <p>The return value can be ignored, when you do not want to register custom charts.
|
||||
*/
|
||||
public T2CVmetrics make(Object plugin, int serviceId) {
|
||||
return new T2CVmetrics(plugin, server, logger, dataDirectory, serviceId);
|
||||
}
|
||||
}
|
||||
|
||||
private final PluginContainer pluginContainer;
|
||||
private final ProxyServer server;
|
||||
private MetricsBase metricsBase;
|
||||
|
||||
private T2CVmetrics(Object plugin, ProxyServer server, Logger logger, Path dataDirectory, int serviceId) {
|
||||
pluginContainer = server.getPluginManager().fromInstance(plugin)
|
||||
.orElseThrow(() -> new IllegalArgumentException("The provided instance is not a plugin"));
|
||||
this.server = server;
|
||||
|
||||
File configFile = dataDirectory.getParent().resolve("bStats").resolve("config.txt").toFile();
|
||||
MetricsConfig config;
|
||||
try {
|
||||
config = new MetricsConfig(configFile, true);
|
||||
} catch (IOException e) {
|
||||
logger.error("Failed to create bStats config", e);
|
||||
return;
|
||||
}
|
||||
|
||||
metricsBase = new MetricsBase(
|
||||
"velocity",
|
||||
config.getServerUUID(),
|
||||
serviceId,
|
||||
config.isEnabled(),
|
||||
this::appendPlatformData,
|
||||
this::appendServiceData,
|
||||
task -> server.getScheduler().buildTask(plugin, task).schedule(),
|
||||
() -> true,
|
||||
logger::warn,
|
||||
logger::info,
|
||||
config.isLogErrorsEnabled(),
|
||||
config.isLogSentDataEnabled(),
|
||||
config.isLogResponseStatusTextEnabled()
|
||||
);
|
||||
|
||||
if (!config.didExistBefore()) {
|
||||
// Send an info message when the bStats config file gets created for the first time
|
||||
logger.info("Velocity and some of its plugins collect metrics and send them to bStats (https://bStats.org).");
|
||||
logger.info("bStats collects some basic information for plugin authors, like how many people use");
|
||||
logger.info("their plugin and their total player count. It's recommend to keep bStats enabled, but");
|
||||
logger.info("if you're not comfortable with this, you can opt-out by editing the config.txt file in");
|
||||
logger.info("the '/plugins/bStats/' folder and setting enabled to false.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down the underlying scheduler service.
|
||||
*/
|
||||
public void shutdown() {
|
||||
metricsBase.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom chart.
|
||||
*
|
||||
* @param chart The chart to add.
|
||||
*/
|
||||
public void addCustomChart(CustomChart chart) {
|
||||
if (metricsBase != null) {
|
||||
metricsBase.addCustomChart(chart);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendPlatformData(JsonObjectBuilder builder) {
|
||||
builder.appendField("playerAmount", server.getPlayerCount());
|
||||
builder.appendField("managedServers", server.getAllServers().size());
|
||||
builder.appendField("onlineMode", server.getConfiguration().isOnlineMode() ? 1 : 0);
|
||||
builder.appendField("velocityVersionVersion", server.getVersion().getVersion());
|
||||
builder.appendField("velocityVersionName", server.getVersion().getName());
|
||||
builder.appendField("velocityVersionVendor", server.getVersion().getVendor());
|
||||
|
||||
builder.appendField("javaVersion", System.getProperty("java.version"));
|
||||
builder.appendField("osName", System.getProperty("os.name"));
|
||||
builder.appendField("osArch", System.getProperty("os.arch"));
|
||||
builder.appendField("osVersion", System.getProperty("os.version"));
|
||||
builder.appendField("coreCount", Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
private void appendServiceData(JsonObjectBuilder builder) {
|
||||
builder.appendField("pluginVersion", pluginContainer.getDescription().getVersion().orElse("unknown"));
|
||||
}
|
||||
|
||||
}
|
@@ -1,60 +1,67 @@
|
||||
package net.t2code.t2codelib.VELOCITY.system.config;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.T2CconfigItem;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend;
|
||||
import net.t2code.t2codelib.VELOCITY.api.yml.T2CVconfigWriter;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class T2CVlibConfig {
|
||||
|
||||
// public static void create() throws IOException {
|
||||
// long startTime = System.currentTimeMillis();
|
||||
// Path configFile = Paths.get("config.yml");
|
||||
//
|
||||
// if (!T2CodeVMain.getPlugin().getDataFolder().exists()) {
|
||||
// T2CodeVMain.getPlugin().getDataFolder().mkdir();
|
||||
// }
|
||||
//
|
||||
// if (!configFile.exists()) {
|
||||
// configFile.createNewFile();
|
||||
// }
|
||||
//
|
||||
// Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||
//
|
||||
// configuration.set("UpdateCheck.TimerInMin", 60);
|
||||
// configuration.set("UpdateCheck.SeePreReleaseUpdates", true);
|
||||
// configuration.set("Plugin.UpdateCheck.AllPlugins.FullDisable", false);
|
||||
//
|
||||
// configuration.set("API.CommandGUI.Enable", false);
|
||||
// configuration.set("API.AutoResponse.Enable", false);
|
||||
// configuration.set("API.OPSecurity.Enable", false);
|
||||
//
|
||||
// ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, configFile);
|
||||
//
|
||||
// long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
// T2CVsend.console(Util.getPrefix() + " §2config.yml was successfully created / updated. §7- §e" + elapsedTime + "ms");
|
||||
// }
|
||||
//
|
||||
// public static void select() throws IOException {
|
||||
// File configFile = new File(T2CodeVMain.getPlugin().getDataFolder(), "config.yml");
|
||||
// Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
public enum VALUES implements T2CconfigItem {
|
||||
updateTimer("updateCheck.timerInMin", 60, "In this option you can set the time interval in minutes in which updates should be checked."),
|
||||
seePreReleaseUpdates("updateCheck.seePreReleaseUpdates", true, "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, "The debug mode sends more detailed debug information to the console."),
|
||||
|
||||
apiCommandGUIEnable("api.commandGUI.enable", false, "With this option you activate the api interface for the T2C-CommandGUI plugin."),
|
||||
apiAutoResponse("api.autoResponse.enable", false, "With this option you activate the api interface for the T2C-AutoResponse plugin."),
|
||||
apiOpSecurity("api.opSecurity.enable", false, "With this option you activate the api interface for the T2C-OPSecurity plugin."),
|
||||
;
|
||||
|
||||
|
||||
private final String path;
|
||||
private Object value;
|
||||
private final List<String> comments;
|
||||
|
||||
VALUES(String path, Object value, String... comments) {
|
||||
this.path = path;
|
||||
this.value = value;
|
||||
this.comments = new ArrayList<>(Arrays.asList(comments));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static void set(Path dataDirectory, Logger logger) throws IOException {
|
||||
long long_ = System.currentTimeMillis();
|
||||
T2CVconfigWriter.createConfig(logger, new File(dataDirectory.getParent() + "/T2CodeLib", "config.yml"), VALUES.values(), Util.getConfigLogo());
|
||||
T2CVsend.info(logger, "║ The config.yml were successfully created / updated." + " - " + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
}
|
||||
|
@@ -1,131 +0,0 @@
|
||||
package net.t2code.t2codelib.VELOCITY.system.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class VelocityConfig {
|
||||
|
||||
private static final String CONFIG_FILE = "plugin_config.yml";
|
||||
|
||||
private String pluginName;
|
||||
private int maxConnections;
|
||||
private boolean isEnabled;
|
||||
private boolean debugMode;
|
||||
private int timeoutSeconds;
|
||||
|
||||
public VelocityConfig(String pluginName, int maxConnections, boolean isEnabled, boolean debugMode, int timeoutSeconds) {
|
||||
this.pluginName = pluginName;
|
||||
this.maxConnections = maxConnections;
|
||||
this.isEnabled = isEnabled;
|
||||
this.debugMode = debugMode;
|
||||
this.timeoutSeconds = timeoutSeconds;
|
||||
}
|
||||
|
||||
public static VelocityConfig loadConfig() {
|
||||
Path configFile = Paths.get(CONFIG_FILE);
|
||||
if (!Files.exists(configFile)) {
|
||||
// Default configuration if file doesn't exist
|
||||
return new VelocityConfig("MyPlugin", 100, true, false, 30);
|
||||
}
|
||||
|
||||
try {
|
||||
// Read configuration from file
|
||||
String content = Files.readString(configFile);
|
||||
String[] lines = content.split("\\r?\\n");
|
||||
|
||||
// Parse the configuration
|
||||
String pluginName = lines[0].split(":")[1].trim();
|
||||
int maxConnections = Integer.parseInt(lines[1].split(":")[1].trim());
|
||||
boolean isEnabled = Boolean.parseBoolean(lines[2].split(":")[1].trim());
|
||||
boolean debugMode = Boolean.parseBoolean(lines[3].split(":")[1].trim());
|
||||
int timeoutSeconds = Integer.parseInt(lines[4].split(":")[1].trim());
|
||||
|
||||
return new VelocityConfig(pluginName, maxConnections, isEnabled, debugMode, timeoutSeconds);
|
||||
} catch (IOException | ArrayIndexOutOfBoundsException | NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
// Handle exception: default configuration or logging
|
||||
return new VelocityConfig("MyPlugin", 100, true, false, 30);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveConfig() {
|
||||
Path configFile = Paths.get(CONFIG_FILE);
|
||||
try {
|
||||
// Write configuration to file
|
||||
String configContent = "pluginName: " + pluginName + "\n"
|
||||
+ "maxConnections: " + maxConnections + "\n"
|
||||
+ "isEnabled: " + isEnabled + "\n"
|
||||
+ "debugMode: " + debugMode + "\n"
|
||||
+ "timeoutSeconds: " + timeoutSeconds + "\n";
|
||||
Files.writeString(configFile, configContent);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
// Handle exception: logging or alerting
|
||||
}
|
||||
}
|
||||
|
||||
// Getters and setters
|
||||
public String getPluginName() {
|
||||
return pluginName;
|
||||
}
|
||||
|
||||
public void setPluginName(String pluginName) {
|
||||
this.pluginName = pluginName;
|
||||
}
|
||||
|
||||
public int getMaxConnections() {
|
||||
return maxConnections;
|
||||
}
|
||||
|
||||
public void setMaxConnections(int maxConnections) {
|
||||
this.maxConnections = maxConnections;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return isEnabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
isEnabled = enabled;
|
||||
}
|
||||
|
||||
public boolean isDebugMode() {
|
||||
return debugMode;
|
||||
}
|
||||
|
||||
public void setDebugMode(boolean debugMode) {
|
||||
this.debugMode = debugMode;
|
||||
}
|
||||
|
||||
public int getTimeoutSeconds() {
|
||||
return timeoutSeconds;
|
||||
}
|
||||
|
||||
public void setTimeoutSeconds(int timeoutSeconds) {
|
||||
this.timeoutSeconds = timeoutSeconds;
|
||||
}
|
||||
|
||||
public static void main() {
|
||||
// Example usage:
|
||||
VelocityConfig config = VelocityConfig.loadConfig();
|
||||
System.out.println("Loaded Configuration:");
|
||||
System.out.println("Plugin Name: " + config.getPluginName());
|
||||
System.out.println("Max Connections: " + config.getMaxConnections());
|
||||
System.out.println("Is Enabled: " + config.isEnabled());
|
||||
System.out.println("Debug Mode: " + config.isDebugMode());
|
||||
System.out.println("Timeout Seconds: " + config.getTimeoutSeconds());
|
||||
|
||||
// Modify configuration
|
||||
config.setMaxConnections(150);
|
||||
config.setEnabled(false);
|
||||
config.setDebugMode(true);
|
||||
config.setTimeoutSeconds(60);
|
||||
|
||||
// Save configuration
|
||||
config.saveConfig();
|
||||
System.out.println("Configuration saved.");
|
||||
}
|
||||
}
|
@@ -1,18 +1,5 @@
|
||||
name: T2CodeLib
|
||||
version: ${project.version}
|
||||
main: net.t2code.t2codelib.bungee.system.T2CodeBMain
|
||||
main: net.t2code.t2codelib.BUNGEE.system.T2CodeBMain
|
||||
author: JaTiTV, Jkobs
|
||||
description: Library from T2Code Plugins
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
_______ ___ _____ _ _
|
||||
|__ __|__ \ / ____| | | | |
|
||||
| | ) | | ___ __| | ___ _ __ ___| |_
|
||||
| | / /| | / _ \ / _` |/ _ \ | '_ \ / _ \ __|
|
||||
| | / /_| |___| (_) | (_| | __/_| | | | __/ |_
|
||||
|_| |____|\_____\___/ \__,_|\___(_)_| |_|\___|\__|
|
||||
|
||||
|
||||
description: Library from T2Code Plugins
|
@@ -1,6 +1,6 @@
|
||||
name: T2CodeLib
|
||||
version: '${project.version}'
|
||||
main: net.t2code.t2codelib.spigot.system.T2CodeLibMain
|
||||
main: net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain
|
||||
api-version: 1.13
|
||||
prefix: T2CodeLib
|
||||
authors: [ JaTiTV ]
|
||||
@@ -31,5 +31,8 @@ permissions:
|
||||
default: op
|
||||
children:
|
||||
t2code.permtoggle.use: true
|
||||
t2code.lib.updatemsg: true
|
||||
t2code.permtoggle.use:
|
||||
default: op
|
||||
t2code.lib.updatemsg:
|
||||
default: op
|
||||
|
Reference in New Issue
Block a user