remove textBuilder and other changes
This commit is contained in:
parent
cf300acff1
commit
f8b86086db
@ -1,6 +1,7 @@
|
||||
package net.t2code.alias.Spigot;
|
||||
|
||||
import net.t2code.alias.Spigot.objects.AliasObjekt;
|
||||
import net.t2code.alias.Spigot.objects.SubAliasObjekt;
|
||||
import net.t2code.alias.Spigot.system.Load;
|
||||
import net.t2code.alias.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
|
||||
@ -23,7 +24,9 @@ public final class Main extends JavaPlugin {
|
||||
public static List<String> autor;
|
||||
public static Main plugin;
|
||||
public static HashMap<String, AliasObjekt> aliasHashMap = new HashMap<>();
|
||||
public static HashMap<String, SubAliasObjekt> subAliasHashMap = new HashMap<>();
|
||||
public static ArrayList<String> allAliases = new ArrayList<>();
|
||||
public static ArrayList<String> allSubAliases = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
@ -1,23 +1,28 @@
|
||||
package net.t2code.alias.Spigot.cmdManagement;
|
||||
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
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.AliasObjekt;
|
||||
import net.t2code.alias.Spigot.objects.SubAliasObjekt;
|
||||
import net.t2code.alias.Spigot.system.*;
|
||||
import net.t2code.alias.Util;
|
||||
import net.t2code.lib.Spigot.Lib.commands.Cmd;
|
||||
import net.t2code.lib.Spigot.Lib.commands.Tab;
|
||||
import net.t2code.lib.Spigot.Lib.eco.Eco;
|
||||
import net.t2code.lib.Spigot.Lib.messages.TextBuilder;
|
||||
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 org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class RegisterCommands extends Command {
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class RegisterCommands extends Command implements TabCompleter {
|
||||
private String alias;
|
||||
private String prefix = Util.getPrefix();
|
||||
|
||||
@ -34,7 +39,30 @@ public class RegisterCommands extends Command {
|
||||
send.sender(sender, SelectMessages.aliasDisabled);
|
||||
return true;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
if (sender instanceof Player) {
|
||||
exPlayer(sender, alias);
|
||||
} else {
|
||||
if (alias.consoleEnable) {
|
||||
console(alias, sender, prefix);
|
||||
} else send.sender(sender, SelectMessages.onlyForPlayer);
|
||||
}
|
||||
} else {
|
||||
for (String sals : Main.allSubAliases) {
|
||||
SubAliasObjekt sal = Main.subAliasHashMap.get(sals);
|
||||
if (args.length == sal.subAliasArg) {
|
||||
for (String al : sal.subAliasList) {
|
||||
if (args[sal.subAliasArg].toLowerCase().equals(al)) {
|
||||
RegisterSubAliasCommands.execute(sender, sal, al);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void exPlayer(CommandSender sender, AliasObjekt alias) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (alias.adminEnable) {
|
||||
@ -45,7 +73,7 @@ public class RegisterCommands extends Command {
|
||||
if (alias.adminMessageEnable) {
|
||||
adminMessage(alias, player, prefix);
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,14 +81,14 @@ public class RegisterCommands extends Command {
|
||||
if (!(player.hasPermission("t2code.alias.use." + this.alias.toLowerCase()) || player.hasPermission("t2code.alias.admin"))) {
|
||||
send.player(player, SelectMessages.noPermissionForCommand.replace("[cmd]", "/" + this.alias.toLowerCase())
|
||||
.replace("[perm]", "t2code.alias.use." + this.alias.toLowerCase()));
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (alias.costEnable) {
|
||||
if (!(alias.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
|
||||
if (!Eco.moneyRemove(prefix, player, alias.costPrice)) {
|
||||
send.player(player, SelectMessages.noMoney);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
if (SelectConfig.buyMessage) send.player(player, SelectMessages.buy.replace("[price]", alias.costPrice.toString()));
|
||||
}
|
||||
@ -71,12 +99,6 @@ public class RegisterCommands extends Command {
|
||||
if (alias.messageEnable) {
|
||||
message(alias, player, prefix);
|
||||
}
|
||||
} else {
|
||||
if (alias.consoleEnable) {
|
||||
console(alias, sender, prefix);
|
||||
} else send.sender(sender, SelectMessages.onlyForPlayer);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void adminCommand(AliasObjekt alias, Player player) {
|
||||
@ -107,23 +129,12 @@ public class RegisterCommands extends Command {
|
||||
String hover;
|
||||
if (PluginCheck.papi()) {
|
||||
text = Replace.replace(prefix, player, replacePlayer(msg, player));
|
||||
hover = Replace.replace(prefix, player, alias.adminHover);
|
||||
} else {
|
||||
text = Replace.replace(prefix, replacePlayer(msg, player));
|
||||
hover = Replace.replace(prefix, alias.adminHover);
|
||||
}
|
||||
if (alias.adminTextBuilder) {
|
||||
TextBuilder textBuilder = new TextBuilder(text);
|
||||
textBuilder.addHover(hover);
|
||||
if (alias.adminClickEvent) {
|
||||
textBuilder.addClickEvent(ClickEvent.Action.valueOf(alias.adminAction), alias.adminActionValue);
|
||||
}
|
||||
player.spigot().sendMessage(textBuilder.build());
|
||||
} else {
|
||||
send.player(player, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void command(AliasObjekt alias, Player player) {
|
||||
for (String cmd : alias.command) {
|
||||
@ -153,23 +164,12 @@ public class RegisterCommands extends Command {
|
||||
String hover;
|
||||
if (PluginCheck.papi()) {
|
||||
text = Replace.replace(prefix, player, replacePlayer(msg, player));
|
||||
hover = Replace.replace(prefix, player, alias.hover);
|
||||
} else {
|
||||
text = Replace.replace(prefix, replacePlayer(msg, player));
|
||||
hover = Replace.replace(prefix, alias.hover);
|
||||
}
|
||||
if (alias.textBuilder) {
|
||||
TextBuilder textBuilder = new TextBuilder(text);
|
||||
textBuilder.addHover(hover);
|
||||
if (alias.clickEvent) {
|
||||
textBuilder.addClickEvent(ClickEvent.Action.valueOf(alias.action), alias.actionValue);
|
||||
}
|
||||
player.spigot().sendMessage(textBuilder.build());
|
||||
} else {
|
||||
send.player(player, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void console(AliasObjekt alias, CommandSender sender, String prefix) {
|
||||
if (alias.consoleCommandEnable) {
|
||||
@ -196,5 +196,21 @@ public class RegisterCommands extends Command {
|
||||
private static String replacePlayer(String s, Player player) {
|
||||
return s.replace("[player]", player.getName());
|
||||
}
|
||||
|
||||
private static HashMap<String, String> arg1 = new HashMap<String, String>();
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
arg1.clear();
|
||||
for (String sals : Main.allSubAliases) {
|
||||
SubAliasObjekt sal = Main.subAliasHashMap.get(sals);
|
||||
for (String al : sal.subAliasList) {
|
||||
arg1.put(al, "t2code.alias.use.subalias." + al.toLowerCase());
|
||||
}
|
||||
Tab.tab(list, sender, sal.subAliasArg, args, arg1);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,23 +4,21 @@ import java.util.List;
|
||||
|
||||
public class AliasObjekt {
|
||||
public Boolean aliasEnable;
|
||||
public Boolean commandEnable;
|
||||
public List<String> aliasList;
|
||||
|
||||
public Boolean permNecessary;
|
||||
|
||||
public Boolean costEnable;
|
||||
public Double costPrice;
|
||||
public Boolean costAllowBypass;
|
||||
|
||||
public Boolean commandEnable;
|
||||
public Boolean commandAsConsole;
|
||||
public Boolean bungeeCommand;
|
||||
public List<String> command;
|
||||
public Boolean messageEnable;
|
||||
public List<String> messages;
|
||||
public Boolean textBuilder;
|
||||
public String hover;
|
||||
public Boolean clickEvent;
|
||||
public String action;
|
||||
public String actionValue;
|
||||
|
||||
|
||||
public Boolean adminEnable;
|
||||
public String adminPermission;
|
||||
@ -30,11 +28,6 @@ public class AliasObjekt {
|
||||
public List<String> adminCommands;
|
||||
public Boolean adminMessageEnable;
|
||||
public List<String> adminMessages;
|
||||
public Boolean adminTextBuilder;
|
||||
public String adminHover;
|
||||
public Boolean adminClickEvent;
|
||||
public String adminAction;
|
||||
public String adminActionValue;
|
||||
public Boolean consoleEnable;
|
||||
public Boolean consoleCommandEnable;
|
||||
public Boolean consoleBungeeCommand;
|
||||
@ -43,6 +36,7 @@ public class AliasObjekt {
|
||||
public List<String> consoleMessages;
|
||||
|
||||
public AliasObjekt(Boolean aliasEnable,
|
||||
List<String> aliasList,
|
||||
Boolean permNecessary,
|
||||
|
||||
Boolean costEnable,
|
||||
@ -55,11 +49,6 @@ public class AliasObjekt {
|
||||
List<String> command,
|
||||
Boolean messageEnable,
|
||||
List<String> messages,
|
||||
Boolean textBuilder,
|
||||
String hover,
|
||||
Boolean clickEvent,
|
||||
String action,
|
||||
String actionValue,
|
||||
|
||||
Boolean adminEnable,
|
||||
String adminPermission,
|
||||
@ -69,11 +58,6 @@ public class AliasObjekt {
|
||||
List<String> adminCommands,
|
||||
Boolean adminMessageEnable,
|
||||
List<String> adminMessages,
|
||||
Boolean adminTextBuilder,
|
||||
String adminHover,
|
||||
Boolean adminClickEvent,
|
||||
String adminAction,
|
||||
String adminActionValue,
|
||||
|
||||
Boolean consoleEnable,
|
||||
Boolean consoleCommandEnable,
|
||||
@ -82,6 +66,7 @@ public class AliasObjekt {
|
||||
Boolean consoleMessageEnable,
|
||||
List<String> consoleMessages) {
|
||||
this.aliasEnable = aliasEnable;
|
||||
this.aliasList=aliasList;
|
||||
this.permNecessary = permNecessary;
|
||||
|
||||
this.costEnable = costEnable;
|
||||
@ -94,11 +79,6 @@ public class AliasObjekt {
|
||||
this.command = command;
|
||||
this.messageEnable = messageEnable;
|
||||
this.messages = messages;
|
||||
this.textBuilder = textBuilder;
|
||||
this.hover = hover;
|
||||
this.clickEvent = clickEvent;
|
||||
this.action = action;
|
||||
this.actionValue = actionValue;
|
||||
this.adminEnable = adminEnable;
|
||||
this.adminPermission = adminPermission;
|
||||
this.adminCommandEnable = adminCommandEnable;
|
||||
@ -107,11 +87,7 @@ public class AliasObjekt {
|
||||
this.adminCommands = adminCommands;
|
||||
this.adminMessageEnable = adminMessageEnable;
|
||||
this.adminMessages = adminMessages;
|
||||
this.adminTextBuilder = adminTextBuilder;
|
||||
this.adminHover = adminHover;
|
||||
this.adminClickEvent = adminClickEvent;
|
||||
this.adminAction = adminAction;
|
||||
this.adminActionValue = adminActionValue;
|
||||
|
||||
|
||||
this.consoleEnable = consoleEnable;
|
||||
this.consoleCommandEnable = consoleCommandEnable;
|
||||
|
@ -2,14 +2,12 @@ package net.t2code.alias.Spigot.system;
|
||||
|
||||
import net.t2code.alias.Spigot.Main;
|
||||
import net.t2code.alias.Spigot.cmdManagement.AliasCmdExecuter;
|
||||
import net.t2code.alias.Spigot.config.config.CreateConfig;
|
||||
import net.t2code.alias.Spigot.config.config.CreateExampleAliasConfig;
|
||||
import net.t2code.alias.Spigot.config.config.SelectAlias;
|
||||
import net.t2code.alias.Spigot.config.config.SelectConfig;
|
||||
import net.t2code.alias.Spigot.config.config.*;
|
||||
import net.t2code.alias.Spigot.config.languages.LanguagesCreate;
|
||||
import net.t2code.alias.Spigot.config.languages.SelectMessages;
|
||||
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 org.bukkit.plugin.Plugin;
|
||||
@ -37,24 +35,39 @@ public class Load {
|
||||
CreateExampleAliasConfig.configCreate();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}try {
|
||||
CreateExampleSubAliasConfig.configCreate();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
plugin.saveResource("Alias/X_aliasDeclaration_X.yml",true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}try {
|
||||
plugin.saveResource("SubAlias/X_subaliasDeclaration_X.yml",true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
CreateConfig.configCreate();
|
||||
LanguagesCreate.langCreate();
|
||||
SelectConfig.onSelect();
|
||||
SelectMessages.onSelect(Util.getPrefix());
|
||||
SelectAlias.onSelect();
|
||||
SelectSubAlias.onSelect();
|
||||
|
||||
if (SelectConfig.Bungee) {
|
||||
Main.plugin.getServer().getMessenger().registerOutgoingPluginChannel(Main.plugin, "BungeeCord");
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "t2codealias:bungee");
|
||||
}
|
||||
AliasRegisterPermissions.onPermRegister();
|
||||
|
||||
send.debugmsg(plugin,Main.aliasHashMap.toString());
|
||||
send.debugmsg(plugin,Main.allAliases.toString());
|
||||
send.debugmsg(plugin,Main.subAliasHashMap.toString());
|
||||
|
||||
send.debugmsg(plugin,Main.allSubAliases.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user