1.0.4
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
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 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.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Alias_CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
String Prefix;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Prefix = Main.prefix;
|
||||
|
||||
if (args.length == 0) {
|
||||
// Command
|
||||
if (sender.hasPermission("t2code.alias.command.info")) {
|
||||
Commands.info(sender);
|
||||
} else send.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-alias info")
|
||||
.replace("[perm]", "t2code.alias.command.info"));
|
||||
} else {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "reload":
|
||||
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")
|
||||
.replace("[perm]", "t2code.alias.command.reload"));
|
||||
break;
|
||||
case "info":
|
||||
case "plugin":
|
||||
case "veraion":
|
||||
if (sender.hasPermission("t2code.alias.command.info")) {
|
||||
Commands.info(sender);
|
||||
} else send.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-alias info")
|
||||
.replace("[perm]", "t2code.alias.command.info"));
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//TabCompleter
|
||||
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
|
||||
put("reload", "t2code.alias.command.reload");
|
||||
put("rl", "t2code.alias.command.reload");
|
||||
put("info", "t2code.alias.command.info");
|
||||
}};
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length == 1) {
|
||||
for (String command : arg1.keySet()) {
|
||||
Boolean passend = true;
|
||||
for (int i = 0; i < args[0].length(); i++) {
|
||||
if (args[0].length() >= command.length()) {
|
||||
passend = false;
|
||||
} else {
|
||||
if (args[0].charAt(i) != command.charAt(i)) {
|
||||
passend = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasPermission(p, arg1.get(command)) && passend) {
|
||||
list.add(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static boolean hasPermission(Player player, String permission) {
|
||||
if (player.isOp()) {
|
||||
return true;
|
||||
}
|
||||
String[] Permissions = permission.split(";");
|
||||
for (String perm : Permissions) {
|
||||
if (player.hasPermission(perm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,38 @@
|
||||
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.lib.Spigot.Lib.messages.T2CodeTemplate;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Commands {
|
||||
private static Plugin plugin = Main.plugin;
|
||||
private static String prefix = Main.prefix;
|
||||
private static List autor = Main.autor;
|
||||
private static String version = Main.version;
|
||||
private static String spigot = Main.spigot;
|
||||
private static String discord = Main.discord;
|
||||
|
||||
public static void info(CommandSender sender) {
|
||||
T2CodeTemplate.sendInfo(sender,prefix,spigot,discord,autor,version, UpdateAPI.PluginVersionen.get(plugin.getName()).publicVersion);
|
||||
}
|
||||
|
||||
public static void reload(CommandSender sender) {
|
||||
if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadStart);
|
||||
send.console(prefix + "§8-------------------------------");
|
||||
send.console(prefix + " §6Plugin reload...");
|
||||
send.console(prefix + "§8-------------------------------");
|
||||
Load.loadReload();
|
||||
if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadEnd);
|
||||
send.console(prefix + "§8-------------------------------");
|
||||
send.console(prefix + " §2Plugin successfully reloaded.");
|
||||
send.console(prefix + "§8-------------------------------");
|
||||
}
|
||||
}
|
@@ -0,0 +1,166 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user