T2CodeLib update to API Version 13.0

Bugfix:
- Hardcode message inserted in language file
This commit is contained in:
2022-10-25 16:38:16 +02:00
parent dbe5f82030
commit bcfcc2e863
27 changed files with 239 additions and 1212 deletions

View File

@@ -1,8 +1,7 @@
package net.t2code.alias.Spigot.cmdManagement;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.config.languages.SelectMessages;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -10,7 +9,6 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -25,7 +23,7 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
// Command
if (sender.hasPermission("t2code.alias.command.info")) {
Commands.info(sender);
} else send.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias info")
} else T2Csend.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias info")
.replace("[perm]", "t2code.alias.command.info"));
} else {
switch (args[0].toLowerCase()) {
@@ -33,7 +31,7 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
case "rl":
if (sender.hasPermission("t2code.alias.command.reload") || sender.isOp()) {
Commands.reload(sender);
} else send.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias reload")
} else T2Csend.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias reload")
.replace("[perm]", "t2code.alias.command.reload"));
break;
case "info":
@@ -41,7 +39,7 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
case "version":
if (sender.hasPermission("t2code.alias.command.info")) {
Commands.info(sender);
} else send.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias info")
} else T2Csend.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias info")
.replace("[perm]", "t2code.alias.command.info"));
break;

View File

@@ -2,30 +2,26 @@ package net.t2code.alias.Spigot.cmdManagement;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.config.languages.SelectMessages;
import net.t2code.alias.Spigot.system.Load;
import net.t2code.alias.Util;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import org.bukkit.Bukkit;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands {
public static void info(CommandSender sender) {
T2CodeTemplate.sendInfo(sender, Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), Main.getAutor(), Main.getVersion(),
UpdateAPI.PluginVersionen.get(Main.getPlugin().getName()).publicVersion);
T2Ctemplate.sendInfo(sender,Main.getPlugin(),Util.getSpigotID(),Util.getDiscord(),Util.getInfoText());
}
public static void reload(CommandSender sender) {
if (sender instanceof Player) sender.sendMessage(SelectMessages.reloadStart);
send.console(Util.getPrefix() + "§8-------------------------------");
send.console(Util.getPrefix() + " §6Plugin reload...");
send.console(Util.getPrefix() + "§8-------------------------------");
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
T2Csend.console(Util.getPrefix() + " §6Plugin reload...");
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
Main.getPlugin().onEnable();
if (sender instanceof Player) sender.sendMessage(SelectMessages.reloadEnd);
send.console(Util.getPrefix() + "§8-------------------------------");
send.console(Util.getPrefix() + " §2Plugin successfully reloaded.");
send.console(Util.getPrefix() + "§8-------------------------------");
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
T2Csend.console(Util.getPrefix() + " §2Plugin successfully reloaded.");
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
}
}

View File

@@ -1,17 +1,16 @@
package net.t2code.alias.Spigot.cmdManagement;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.config.config.SelectConfig;
import net.t2code.alias.Spigot.config.languages.SelectMessages;
import net.t2code.alias.Spigot.objects.AliasObject;
import net.t2code.alias.Spigot.objects.SubAliasObject;
import net.t2code.alias.Spigot.system.BCommandSenderReciver;
import net.t2code.alias.Util;
import net.t2code.lib.Spigot.Lib.commands.Cmd;
import net.t2code.lib.Spigot.Lib.eco.Eco;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
import net.t2code.lib.Spigot.Lib.replace.Replace;
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ccmd;
import net.t2code.t2codelib.SPIGOT.api.eco.T2Ceco;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -43,18 +42,18 @@ public class ExecuteAlias {
if (aliasObject.permissionMSG == null || aliasObject.permissionMSG.equals("")) {
npmsg = SelectMessages.noPermissionForCommand;
} else npmsg = aliasObject.permissionMSG;
send.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase())
T2Csend.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase())
.replace("[perm]", aliasObject.permission.replace("<alias>", alias.toLowerCase())).replace("[alias]", alias));
return;
}
}
if (aliasObject.costEnable) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
if (!Eco.moneyRemove(prefix, player, aliasObject.costPrice)) {
send.player(player, SelectMessages.noMoney);
if (!T2Ceco.moneyRemove(prefix, player, aliasObject.costPrice)) {
T2Csend.player(player, SelectMessages.noMoney);
return;
}
if (SelectConfig.buyMessage) send.player(player, SelectMessages.buy.replace("[price]", aliasObject.costPrice.toString()));
if (SelectConfig.buyMessage) T2Csend.player(player, SelectMessages.buy.replace("[price]", aliasObject.costPrice.toString()));
}
}
if (aliasObject.commandEnable) {
@@ -67,7 +66,7 @@ public class ExecuteAlias {
protected static void subAliasPlayer(CommandSender sender, SubAliasObject aliasObject, String alias, String[] args) {
if (!aliasObject.subAliasEnable) {
send.sender(sender, SelectMessages.aliasDisabled);
T2Csend.sender(sender, SelectMessages.aliasDisabled);
return;
}
@@ -92,18 +91,18 @@ public class ExecuteAlias {
if (aliasObject.permissionMSG == null || aliasObject.permissionMSG.equals("")) {
npmsg = SelectMessages.noPermissionForCommand;
} else npmsg = aliasObject.permissionMSG;
send.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase())
T2Csend.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase())
.replace("[perm]", aliasObject.permission.replace("<alias>", alias.toLowerCase())).replace("[alias]", alias));
return;
}
}
if (aliasObject.costEnable) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
if (!Eco.moneyRemove(prefix, player, aliasObject.costPrice)) {
send.player(player, SelectMessages.noMoney);
if (!T2Ceco.moneyRemove(prefix, player, aliasObject.costPrice)) {
T2Csend.player(player, SelectMessages.noMoney);
return;
}
if (SelectConfig.buyMessage) send.player(player, SelectMessages.buy.replace("[price]", aliasObject.costPrice.toString()));
if (SelectConfig.buyMessage) T2Csend.player(player, SelectMessages.buy.replace("[price]", aliasObject.costPrice.toString()));
}
}
if (aliasObject.commandEnable) {
@@ -115,7 +114,7 @@ public class ExecuteAlias {
} else {
if (aliasObject.consoleEnable) {
subAliasConsole(aliasObject, sender, args);
} else send.sender(sender, SelectMessages.onlyForPlayer);
} else T2Csend.sender(sender, SelectMessages.onlyForPlayer);
}
}
@@ -126,17 +125,17 @@ public class ExecuteAlias {
if (SelectConfig.Bungee) {
BCommandSenderReciver.sendToBungee(sender, cmd, true);
} else {
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
send.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2Csend.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
Cmd.console(cmd);
T2Ccmd.console(cmd);
}
}
}
if (alias.consoleMessageEnable) {
for (String msg : alias.consoleMessages) {
send.console(Replace.replace(prefix, msg));
T2Csend.console(T2Creplace.replace(prefix, msg));
}
}
}
@@ -155,17 +154,17 @@ public class ExecuteAlias {
if (SelectConfig.Bungee) {
BCommandSenderReciver.sendToBungee(sender, cmd.replace("[target]", targetSt), true);
} else {
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
send.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2Csend.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
Cmd.console(cmd.replace("[target]", targetSt));
T2Ccmd.console(cmd.replace("[target]", targetSt));
}
}
}
if (alias.consoleMessageEnable) {
for (String msg : alias.consoleMessages) {
send.console(Replace.replace(prefix, msg));
T2Csend.console(T2Creplace.replace(prefix, msg));
}
}
}
@@ -184,14 +183,14 @@ public class ExecuteAlias {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.adminCommandAsConsole);
} else {
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2Csend.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
if (alias.adminCommandAsConsole) {
Cmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
} else {
Cmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
T2Ccmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
}
}
}
@@ -211,14 +210,14 @@ public class ExecuteAlias {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.adminCommandAsConsole);
} else {
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2Csend.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
if (alias.adminCommandAsConsole) {
Cmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
} else {
Cmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
T2Ccmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
}
}
}
@@ -234,12 +233,12 @@ public class ExecuteAlias {
}
for (String msg : aliasObject.adminMessages) {
String text;
if (PluginCheck.papi()) {
text = Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
if (T2CpluginCheck.papi()) {
text = T2Creplace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
} else {
text = Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
text = T2Creplace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
}
send.player(player, text);
T2Csend.player(player, text);
}
}
@@ -253,12 +252,12 @@ public class ExecuteAlias {
}
for (String msg : subAliasObject.adminMessages) {
String text;
if (PluginCheck.papi()) {
text = Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
if (T2CpluginCheck.papi()) {
text = T2Creplace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
} else {
text = Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
text = T2Creplace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
}
send.player(player, text);
T2Csend.player(player, text);
}
}
@@ -276,14 +275,14 @@ public class ExecuteAlias {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.commandAsConsole);
} else {
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2Csend.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
if (alias.commandAsConsole) {
Cmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
} else {
Cmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
T2Ccmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
}
}
}
@@ -303,14 +302,14 @@ public class ExecuteAlias {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.commandAsConsole);
} else {
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2Csend.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
if (alias.commandAsConsole) {
Cmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
} else {
Cmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
T2Ccmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
}
}
}
@@ -328,12 +327,12 @@ public class ExecuteAlias {
for (String msg : aliasObject.messages) {
String text;
if (PluginCheck.papi()) {
text = Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
if (T2CpluginCheck.papi()) {
text = T2Creplace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
} else {
text = Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
text = T2Creplace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
}
send.player(player, text);
T2Csend.player(player, text);
}
}
@@ -347,12 +346,12 @@ public class ExecuteAlias {
}
for (String msg : subAliasObject.messages) {
String text;
if (PluginCheck.papi()) {
text = Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
if (T2CpluginCheck.papi()) {
text = T2Creplace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
} else {
text = Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
text = T2Creplace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
}
send.player(player, text);
T2Csend.player(player, text);
}
}

View File

@@ -5,19 +5,17 @@ import net.t2code.alias.Spigot.config.languages.SelectMessages;
import net.t2code.alias.Spigot.objects.AliasObject;
import net.t2code.alias.Spigot.objects.SubAliasObject;
import net.t2code.alias.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class RegisterCommands extends Command implements TabCompleter {
public class RegisterCommands extends Command {
private String alias;
private String prefix = Util.getPrefix();
@@ -31,11 +29,11 @@ public class RegisterCommands extends Command implements TabCompleter {
AliasObject alias = Main.aliasHashMap.get(this.alias);
if (alias == null) {
send.error(Main.getPlugin(), "The alias " + this.alias + " does not exist.");
T2Csend.error(Main.getPlugin(), "The alias " + this.alias + " does not exist.");
return false;
}
if (!alias.aliasEnable) {
send.sender(sender, SelectMessages.aliasDisabled);
T2Csend.sender(sender, SelectMessages.aliasDisabled);
return true;
}
if (args.length == 0 || args.length == 1 && args[0].contains("-p:")) {
@@ -44,7 +42,7 @@ public class RegisterCommands extends Command implements TabCompleter {
} else {
if (alias.consoleEnable) {
ExecuteAlias.aliasConsole(alias, sender, prefix);
} else send.sender(sender, SelectMessages.onlyForPlayer);
} else T2Csend.sender(sender, SelectMessages.onlyForPlayer);
}
} else {
if (!Main.allForSubAliases.contains(this.alias)) {
@@ -61,15 +59,9 @@ public class RegisterCommands extends Command implements TabCompleter {
}
}
}
send.sender(sender, "<color:#ffbd17><hover:show_text:'<dark_red>TODO <blue>DEV</blue></dark_red>'>Diesen Befehl gibt es nicht</hover></color>");
//todo
T2Csend.sender(sender, SelectMessages.noSubCommand);
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {
return Collections.singletonList("hallodepp");
}
}

View File

@@ -2,7 +2,7 @@ package net.t2code.alias.Spigot.cmdManagement;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.objects.SubAliasObject;
import net.t2code.lib.Spigot.Lib.commands.Tab;
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ctab;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.TabCompleteEvent;
@@ -36,7 +36,7 @@ public class TabEvent implements Listener {
int arg = aliasObject.subAliasArg;
if (args.length - 1 == arg) {
for (String command : aliasObject.subAliasList) {
if (Tab.hasPermission(e.getSender(), arg1.get(command)) && Tab.passend(command, args[arg])) {
if (T2Ctab.hasPermission(e.getSender(), arg1.get(command)) && T2Ctab.passend(command, args[arg])) {
list.add(command);
}
}