small changes

This commit is contained in:
JaTiTV 2024-07-08 00:53:26 +02:00
parent c7e392a0f0
commit 56080e1eb8
4 changed files with 57 additions and 19 deletions

View File

@ -29,6 +29,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.List;
import java.util.Objects;
public final class T2C_Main extends JavaPlugin {
@Getter
@ -52,6 +53,7 @@ public final class T2C_Main extends JavaPlugin {
@Override
public void onEnable() {
T2C_PlatformDetector.scan();
checkIsProxy();
// Plugin startup logic
plugin = this;
autor = plugin.getDescription().getAuthors();
@ -70,7 +72,7 @@ public final class T2C_Main extends JavaPlugin {
private void load() {
long long_ = T2C_Template.onLoadHeader(T2C_Util.getPrefix(), autor, version, T2C_Util.getSpigot(), T2C_Util.getDiscord());
checkIsBungee();
String prefix = T2C_Util.getPrefix();
try {
@ -122,13 +124,18 @@ public final class T2C_Main extends JavaPlugin {
T2C_Send.sendStartTextCenter(prefix, "§3Platform: §6" + T2C_PlatformDetector.detectPlatform, false);
T2C_Send.sendStartTextCenter(prefix, "§3Bukkit Version: §6" + T2C_McVersion.getBukkitVersion(), false);
T2C_Send.sendStartTextCenter(prefix, "§3Server Version: §6" + T2C_McVersion.getMcVersion(), false);
T2C_Send.sendStartTextCenter(prefix, "§3OnlineMode: §6" + isOnlineMode, false);
if (isProxy) {
if (isBungee) T2C_Send.sendStartTextCenter(prefix, "§3Proxy: §6BungeeCord", false);
if (isVelocity) T2C_Send.sendStartTextCenter(prefix, "§3Proxy: §6Velocity", false);
}
T2C_Template.onLoadSeparateStroke(prefix);
if (eco != null) {
String st = eco.getName();
if (eco.getName().equals("CMIEconomy")) st = "CMI";
if (Bukkit.getPluginManager().getPlugin(st) != null) {
T2C_Send.sendStartTextCenter(prefix, "§3Economy: §6" + eco.getName() + " - " + Bukkit.getPluginManager().getPlugin(st).getDescription().getVersion() + " §7- §e" +
T2C_Send.sendStartTextCenter(prefix, "§3Economy: §6" + eco.getName() + " - " + Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(st)).getDescription().getVersion() + " §7- §e" +
(System.currentTimeMillis() - long_) + "ms", false);
} else
T2C_Send.sendStartTextCenter(prefix, "§3Economy: §6" + eco.getName() + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
@ -137,7 +144,7 @@ public final class T2C_Main extends JavaPlugin {
if (perm != null) {
if (Bukkit.getPluginManager().getPlugin(perm.getName()) != null) {
T2C_Send.sendStartTextCenter(prefix, "§3Permission plugin: §6" + perm.getName() + " - " + Bukkit.getPluginManager().getPlugin(perm.getName()).getDescription().getVersion()
T2C_Send.sendStartTextCenter(prefix, "§3Permission plugin: §6" + perm.getName() + " - " + Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(perm.getName())).getDescription().getVersion()
+ " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
} else
T2C_Send.sendStartTextCenter(prefix, "§3Permission plugin: §6" + perm.getName() + " - §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
@ -151,7 +158,7 @@ public final class T2C_Main extends JavaPlugin {
T2C_Send.sendStartTextCenter(prefix, "§3Kyori MiniMessage Support: " + (getMmIsLoad() ? "§2load" : "§4not load") + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
plugin.getCommand("t2code").setExecutor(new CmdExecuter());
Objects.requireNonNull(plugin.getCommand("t2code")).setExecutor(new CmdExecuter());
T2C_Template.onLoadSeparateStroke(prefix);
T2C_LibConfig.set(false);
@ -201,9 +208,9 @@ public final class T2C_Main extends JavaPlugin {
Vault.vaultDisable();
T2C_Template.onDisable(T2C_Util.getPrefix(), this);
if (mmIsLoad) {
if (this.adventure != null) {
this.adventure.close();
this.adventure = null;
if (adventure != null) {
adventure.close();
adventure = null;
}
}
}
@ -229,14 +236,47 @@ public final class T2C_Main extends JavaPlugin {
return adventure;
}
private static void checkIsBungee() {
private static void checkIsProxy() {
isOnlineMode = Bukkit.getServer().getOnlineMode();
File config = new File("spigot.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
isBungee = yamlConfiguration.getBoolean("settings.bungeecord");
if (yamlConfiguration.getBoolean("settings.bungeecord")) {
isProxy = true;
isBungee = true;
File paper = new File("config/paper-global.yml");
YamlConfiguration yamlPaper = YamlConfiguration.loadConfiguration(paper);
isOnlineMode = yamlPaper.isBoolean("proxies.bungee-cord.online-mode");
return;
}
if (T2C_PlatformDetector.detectPlatform == T2C_PlatformDetector.PlatformType.PAPER) {
File paperOld = new File("paper.yml");
if (paperOld.exists()) {
YamlConfiguration yamlPaperOld = YamlConfiguration.loadConfiguration(paperOld);
isVelocity = yamlPaperOld.getBoolean("settings.velocity-support.enabled");
isOnlineMode = yamlPaperOld.isBoolean("settings.velocity-support.online-mode");
}
File paper = new File("config/paper-global.yml");
YamlConfiguration yamlPaper = YamlConfiguration.loadConfiguration(paper);
isVelocity = yamlPaper.isBoolean("proxies.velocity.enabled");
isOnlineMode = yamlPaper.isBoolean("proxies.velocity.online-mode");
isProxy = isVelocity;
}
}
@Getter
private static Boolean isBungee;
private static boolean isProxy = false;
@Getter
private static boolean isBungee = false;
@Getter
private static boolean isVelocity = false;
@Getter
private static boolean isOnlineMode;
}

View File

@ -46,6 +46,6 @@ public class Vault {
public static void vaultDisable() {
if (!connected) return;
connected = false;
T2C_Send.sendStartTextCenter(T2C_Util.getPrefix(), " §4Vault / Economy successfully deactivated.", false);
T2C_Send.console(T2C_Util.getPrefix()+ " §4Vault / Economy successfully deactivated.");
}
}

View File

@ -28,10 +28,7 @@ import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@ -60,7 +57,9 @@ public class CreateReportLog {
pWriter.println("Server run on: " + T2C_McVersion.getMcVersion());
pWriter.println("Server NMS: " + T2C_McVersion.getNms());
pWriter.println("Online Mode: " + Bukkit.getOnlineMode());
pWriter.println("Bungee Mode: " + T2C_Main.getIsBungee());
pWriter.println("Proxy Mode: " + T2C_Main.isBungee());
pWriter.println("BungeeCord: " + T2C_Main.isBungee());
pWriter.println("Velocity: " + T2C_Main.isVelocity());
pWriter.println("Server Port: " + Bukkit.getServer().getPort());
pWriter.println();
pWriter.println("Worlds: " + Bukkit.getWorlds());
@ -77,7 +76,7 @@ public class CreateReportLog {
String st = T2C_Main.getEco().getName();
if (T2C_Main.getEco().getName().equals("CMIEconomy")) st = "CMI";
if (Bukkit.getPluginManager().getPlugin(st) != null) {
pWriter.println("Economy: " + T2C_Main.getEco().isEnabled() + " - " + st + " - " + Bukkit.getPluginManager().getPlugin(st).getDescription().getVersion());
pWriter.println("Economy: " + T2C_Main.getEco().isEnabled() + " - " + st + " - " + Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(st)).getDescription().getVersion());
} else pWriter.println("Economy: " + T2C_Main.getEco().isEnabled() + " - " + st);
} else pWriter.println("Economy: not connected via vault");
if (T2C_Main.getPerm() != null) {

View File

@ -1,6 +1,5 @@
package net.t2code.t2codelib.SPIGOT.system.config.config;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter;
import net.t2code.t2codelib.util.T2C_LanguageEnum;
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
@ -61,7 +60,7 @@ public class T2C_LibConfig {
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of("For this option, the option proxy.enable in the config.yml of the T2CodeLib must be set to true and the T2CodeLib must also be present on the proxy in order to function as a bridge."));
}}),
proxy("proxy.enable", T2C_Main.getIsBungee(), true,
proxy("proxy.enable", T2C_Main.isProxy(), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Diese Option muss aktiviert werden, wenn du die T2CodeLib auf einem BungeeCord, Waterfall oder Velocity Proxy als Bridge verwenden möchtest."
, "Bitte beachte, dass die einzelnen APIs der Plugins, die eine Bridge auf einem Proxy verwenden, in der config.yml der T2CodeLib auf dem Proxy aktiviert werden müssen!"));