16.7_dev-22
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package net.t2code.t2codelib.SPIGOT.api.commands;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.system.BungeeCommandSenderReceiver;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2C_ProxyCommandSenderReceiver;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -17,7 +17,7 @@ public class T2C_Cmd {
|
||||
@Override
|
||||
public void run() {
|
||||
if (cmd.contains("!onBungee")) {
|
||||
BungeeCommandSenderReceiver.sendToBungee(null, cmd.replace("!onBungee", ""), true);
|
||||
T2C_ProxyCommandSenderReceiver.sendToBungee(null, cmd.replace("!onBungee", ""), true);
|
||||
} else Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
|
||||
}
|
||||
}, delay);
|
||||
@@ -32,11 +32,11 @@ public class T2C_Cmd {
|
||||
public void run() {
|
||||
if (cmd.contains("!asConsole")) {
|
||||
if (cmd.contains("!onBungee")) {
|
||||
BungeeCommandSenderReceiver.sendToBungee(player, cmd.replace("!asConsole", "").replace("!onBungee", ""), true);
|
||||
T2C_ProxyCommandSenderReceiver.sendToBungee(player, cmd.replace("!asConsole", "").replace("!onBungee", ""), true);
|
||||
} else console(cmd.replace("!asConsole", ""));
|
||||
} else {
|
||||
if (cmd.contains("!onBungee")) {
|
||||
BungeeCommandSenderReceiver.sendToBungee(player, cmd.replace("!onBungee", ""), false);
|
||||
T2C_ProxyCommandSenderReceiver.sendToBungee(player, cmd.replace("!onBungee", ""), false);
|
||||
} else player.chat("/" + cmd);
|
||||
}
|
||||
}
|
||||
|
@@ -1,58 +0,0 @@
|
||||
package net.t2code.t2codelib.SPIGOT.api.messages;
|
||||
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class T2C_HoverModule {
|
||||
|
||||
public static void modulePlayer(String text, String hover, String action, String actionValue, Player player) {
|
||||
modulePlayer((text != null ? text : "null") + "/*/" + (hover != null ? hover : "null") + "/*/" + (action != null ? action : "null")
|
||||
+ "/*/" + (actionValue != null ? actionValue : "null"), player);
|
||||
}
|
||||
|
||||
public static void modulePlayer(String msg, Player player) {
|
||||
if (msg.contains("/*/")) {
|
||||
t2cmodule(msg, player);
|
||||
return;
|
||||
}
|
||||
T2C_MiniMessage.sendPlayerMiniMessage(msg, player);
|
||||
}
|
||||
|
||||
public static void moduleSender(String msg, CommandSender sender) {
|
||||
T2C_MiniMessage.sendSenderMiniMessage(msg, sender);
|
||||
}
|
||||
|
||||
public static void moduleConsole(String msg) {
|
||||
if (T2C_Main.getMmIsLoad()) {
|
||||
T2C_MiniMessage.sendConsoleMiniMessage(msg);
|
||||
return;
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage(msg);
|
||||
}
|
||||
|
||||
private static void t2cmodule(String msg, Player player) {
|
||||
String[] split = msg.split("/\\*/");
|
||||
int i = split.length;
|
||||
String text = null;
|
||||
String hover = null;
|
||||
String action = null;
|
||||
String actionValue = null;
|
||||
if (i > 0) text = split[0];
|
||||
if (i > 1) hover = split[1];
|
||||
if (i > 2) action = split[2];
|
||||
if (i > 3) actionValue = split[3];
|
||||
|
||||
T2C_TextBuilder textBuilder = new T2C_TextBuilder(text);
|
||||
if (hover != null && !hover.equals("null")) {
|
||||
textBuilder.addHover(hover);
|
||||
}
|
||||
|
||||
if (action != null && actionValue != null && !action.equals("null") && !actionValue.equals("null")) {
|
||||
textBuilder.addClickEvent(ClickEvent.Action.valueOf(action.toUpperCase()), actionValue);
|
||||
}
|
||||
player.spigot().sendMessage(textBuilder.build());
|
||||
}
|
||||
}
|
@@ -44,30 +44,30 @@ public class T2C_Send {
|
||||
|
||||
public static void console(String msg) {
|
||||
if (msg == null || msg.contains("[empty]")) return;
|
||||
T2C_HoverModule.moduleConsole(msg);
|
||||
T2C_MiniMessage.sendConsoleMiniMessage(msg);
|
||||
}
|
||||
|
||||
public static void player(Player player, String msg) {
|
||||
if (msg == null || msg.contains("[empty]")) return;
|
||||
T2C_HoverModule.modulePlayer(msg, player);
|
||||
T2C_MiniMessage.sendPlayerMiniMessage(msg, player);
|
||||
}
|
||||
|
||||
public static void sender(CommandSender sender, String msg) {
|
||||
if (msg == null || msg.contains("[empty]")) return;
|
||||
T2C_HoverModule.moduleSender(msg, sender);
|
||||
T2C_MiniMessage.sendSenderMiniMessage(msg, sender);
|
||||
}
|
||||
|
||||
public static void console(Object object) {
|
||||
for (String msg : list(object)) {
|
||||
if (msg == null || msg.contains("[empty]")) continue;
|
||||
T2C_HoverModule.moduleConsole(msg);
|
||||
T2C_MiniMessage.sendConsoleMiniMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void player(Player player, Object object) {
|
||||
for (String msg : list(object)) {
|
||||
if (msg == null || msg.contains("[empty]")) continue;
|
||||
T2C_HoverModule.modulePlayer(msg, player);
|
||||
T2C_MiniMessage.sendPlayerMiniMessage(msg, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class T2C_Send {
|
||||
public static void sender(CommandSender sender, Object object) {
|
||||
for (String msg : list(object)) {
|
||||
if (msg == null || msg.contains("[empty]")) return;
|
||||
T2C_HoverModule.moduleSender(msg, sender);
|
||||
T2C_MiniMessage.sendSenderMiniMessage(msg, sender);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,7 @@ import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2C_Main;
|
||||
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||
import net.t2code.t2codelib.util.T2C_Util;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@@ -19,7 +20,7 @@ public class T2C_ConfigWriter {
|
||||
|
||||
private static FileConfiguration config;
|
||||
|
||||
public static void createConfig(File configFile, T2C_ConfigItem[] values, String... header) {
|
||||
public static void createConfig(String prefix, File configFile, T2C_ConfigItem[] values, boolean isReload, String... header) {
|
||||
boolean exist = configFile.exists();
|
||||
if (!exist) {
|
||||
configFile.getParentFile().mkdirs();
|
||||
@@ -34,11 +35,20 @@ public class T2C_ConfigWriter {
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
Map<String, List<String>> comments = new LinkedHashMap<>();
|
||||
|
||||
T2C_LanguageEnum lang = T2C_LanguageEnum.english;
|
||||
T2C_LanguageEnum lang = null;
|
||||
String lp = values[0].getLanguagePath();
|
||||
|
||||
try {
|
||||
lang = T2C_LanguageEnum.valueOf(config.getString(values[0].getLanguagePath().replace(".yml", "")));
|
||||
lang = T2C_LanguageEnum.valueOf(lp);
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
if (lang == null) {
|
||||
try {
|
||||
lang = T2C_LanguageEnum.valueOf(config.getString(lp.replace(".yml", "")));
|
||||
} catch (Exception e) {
|
||||
lang = T2C_LanguageEnum.english;
|
||||
}
|
||||
}
|
||||
|
||||
for (T2C_ConfigItem item : values) {
|
||||
if (item.getForceSet() || !exist) {
|
||||
@@ -55,12 +65,16 @@ public class T2C_ConfigWriter {
|
||||
config.options().copyDefaults(true);
|
||||
|
||||
T2C_YmlWriter.saveConfigWithComments(configFile, config, comments, header);
|
||||
readConfig(config, values);
|
||||
readConfig(prefix, configFile, config, values, isReload);
|
||||
}
|
||||
|
||||
private static void readConfig(FileConfiguration config, T2C_ConfigItem[] values) {
|
||||
private static void readConfig(String prefix, File configFile, FileConfiguration config, T2C_ConfigItem[] values, boolean isReload) {
|
||||
for (T2C_ConfigItem value : values) {
|
||||
value.setValue(config.get(value.getPath()));
|
||||
}
|
||||
T2C_Send.sendStartTextCenter(prefix, "§2" + configFile.getName() + " were successfully created / updated.", isReload);
|
||||
//T2C_Send.sendStartTextCenter(Util.getPrefix(), "§2opWhitelist.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms",isReload);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -54,18 +54,23 @@ public class T2C_YmlWriter {
|
||||
// Add value with proper indentation
|
||||
// builder.append(indent).append(key).append(": ").append(value).append("\n");
|
||||
if (value instanceof List) {
|
||||
List<?> list = (List<?>) value;
|
||||
if (list.isEmpty()) {
|
||||
builder.append(indent).append(key).append(": []").append("\n");
|
||||
continue;
|
||||
}
|
||||
builder.append(indent).append(key).append(": ").append("\n");
|
||||
List<Object> zw = (List<Object>) value;
|
||||
for (Object s : zw) {
|
||||
for (Object s : list) {
|
||||
if (s instanceof String) {
|
||||
builder.append(indent).append("- \"").append(s).append("\"\n");
|
||||
} else builder.append(indent).append("- ").append(s).append("\n");
|
||||
}
|
||||
} else {
|
||||
if (value instanceof String) {
|
||||
builder.append(indent).append(key).append(": \"").append(value).append("\"\n");
|
||||
} else builder.append(indent).append(key).append(": ").append(value).append("\n");
|
||||
continue;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
builder.append(indent).append(key).append(": \"").append(value).append("\"\n");
|
||||
} else builder.append(indent).append(key).append(": ").append(value).append("\n");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user