167 lines
8.0 KiB
Java
167 lines
8.0 KiB
Java
|
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.Alias_Objekt;
|
||
|
import net.t2code.alias.Spigot.system.*;
|
||
|
import net.t2code.lib.Spigot.Lib.commands.Cmd;
|
||
|
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.entity.Player;
|
||
|
|
||
|
public class RegisterCommands extends Command {
|
||
|
private String alias;
|
||
|
private String prefix = Main.prefix;
|
||
|
|
||
|
public RegisterCommands(String alias) {
|
||
|
super(alias);
|
||
|
this.alias = alias;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||
|
Alias_Objekt Alias = Main.aliasHashMap.get(alias);
|
||
|
|
||
|
if (!Alias.AliasEnable) {
|
||
|
send.sender(sender, SelectMessages.AliasDisabled);
|
||
|
return true;
|
||
|
}
|
||
|
if (sender instanceof Player) {
|
||
|
Player player = (Player) sender;
|
||
|
|
||
|
if (Alias.AdminEnable) {
|
||
|
if (player.hasPermission(Alias.AdminPermission)) {
|
||
|
if (Alias.AdminCommandEnable) {
|
||
|
for (String cmd : Alias.AdminCommands) {
|
||
|
if (Alias.AdminBungeeCommand) {
|
||
|
if (SelectConfig.Bungee) {
|
||
|
if (Alias.AdminCommandAsConsole) {
|
||
|
BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), true);
|
||
|
} else BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), false);
|
||
|
|
||
|
} else {
|
||
|
send.console(Main.prefix + " §4To use bungee commands, enable the Bungee option in the config.");
|
||
|
send.player(player, Main.prefix + " §4To use bungee commands, enable the Bungee option in the config.");
|
||
|
}
|
||
|
} else {
|
||
|
if (Alias.AdminCommandAsConsole) {
|
||
|
Cmd.console(cmd.replace("[player]", player.getName()));
|
||
|
} else {
|
||
|
Cmd.player(player, cmd.replace("[player]", player.getName()));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (Alias.AdminMessageEnable) {
|
||
|
for (String msg : Alias.AdminMessages) {
|
||
|
String text;
|
||
|
String hover;
|
||
|
if (PluginCheck.papi()) {
|
||
|
text = Replace.replace(prefix, player, msg);
|
||
|
hover = Replace.replace(prefix, player, Alias.AdminHover);
|
||
|
} else {
|
||
|
text = Replace.replace(prefix, msg);
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (Alias.Perm_necessary) {
|
||
|
if (!(player.hasPermission("t2code.alias.use." + alias.toLowerCase()) || player.hasPermission("t2code.alias.admin"))) {
|
||
|
send.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/" + alias.toLowerCase())
|
||
|
.replace("[perm]", "t2code.alias.use." + alias.toLowerCase()));
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
if (Alias.Command_Enable) {
|
||
|
for (String cmd : Alias.Command) {
|
||
|
if (Alias.BungeeCommand) {
|
||
|
if (SelectConfig.Bungee) {
|
||
|
if (Alias.CommandAsConsole) {
|
||
|
BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), true);
|
||
|
} else BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), false);
|
||
|
|
||
|
} else {
|
||
|
send.console(Main.prefix + " §4To use bungee commands, enable the Bungee option in the config.");
|
||
|
send.player(player, Main.prefix + " §4To use bungee commands, enable the Bungee option in the config.");
|
||
|
}
|
||
|
} else {
|
||
|
if (Alias.CommandAsConsole) {
|
||
|
Cmd.console(cmd.replace("[player]", player.getName()));
|
||
|
} else {
|
||
|
Cmd.player(player, cmd.replace("[player]", player.getName()));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (Alias.Message_Enable) {
|
||
|
for (String msg : Alias.Messages) {
|
||
|
String text;
|
||
|
String hover;
|
||
|
if (PluginCheck.papi()) {
|
||
|
text = Replace.replace(prefix, player, msg);
|
||
|
hover = Replace.replace(prefix,player,Alias.Hover);
|
||
|
} else{
|
||
|
text = Replace.replace(prefix, msg);
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
if (Alias.ConsoleEnable) {
|
||
|
if (Alias.ConsoleCommandEnable) {
|
||
|
for (String cmd : Alias.ConsoleCommands) {
|
||
|
if (Alias.ConsoleBungeeCommand) {
|
||
|
if (SelectConfig.Bungee) {
|
||
|
BCommand_Sender_Reciver.sendToBungee(sender, cmd.replace("[player]", sender.getName()), true);
|
||
|
} else {
|
||
|
send.console(Main.prefix + " §4To use bungee commands, enable the Bungee option in the config.");
|
||
|
send.sender(sender, Main.prefix + " §4To use bungee commands, enable the Bungee option in the config.");
|
||
|
}
|
||
|
} else {
|
||
|
Cmd.console(cmd.replace("[player]", sender.getName()));
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
if (Alias.ConsoleMessageEnable) {
|
||
|
for (String msg : Alias.ConsoleMessages) {
|
||
|
send.console(Replace.replace(prefix, msg));
|
||
|
}
|
||
|
}
|
||
|
} else send.sender(sender, SelectMessages.OnlyForPlayer);
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|