The command system works! Kinda...
This commit is contained in:
parent
47315bbdaf
commit
718f43e303
24 changed files with 189 additions and 173 deletions
|
@ -4,30 +4,23 @@ version: 4.0
|
||||||
commands:
|
commands:
|
||||||
u:
|
u:
|
||||||
description: Auto-flair system. Accept or ignore flair.
|
description: Auto-flair system. Accept or ignore flair.
|
||||||
usage: "&cUsage: /u accept|ignore|opme&r"
|
|
||||||
ooc:
|
ooc:
|
||||||
description: Send message in Out-of-Character.
|
description: Send message in Out-of-Character.
|
||||||
usage: "&cUsage: /ooc <message>&r"
|
|
||||||
alias: nrp
|
alias: nrp
|
||||||
unlol:
|
unlol:
|
||||||
description: Unlaugh the last laugh.
|
description: Unlaugh the last laugh.
|
||||||
alias: unlaugh
|
alias: unlaugh
|
||||||
mwiki:
|
mwiki:
|
||||||
description: Search the wiki.
|
description: Search the wiki.
|
||||||
usage: "&cUsage: /mwiki [query]&r"
|
|
||||||
dontrunthiscmd:
|
dontrunthiscmd:
|
||||||
tableflip:
|
tableflip:
|
||||||
description: Flip a table.
|
description: Flip a table.
|
||||||
usage: "&cUsage: /tableflip [message]&r"
|
|
||||||
unflip:
|
unflip:
|
||||||
description: Unflip a flip.
|
description: Unflip a flip.
|
||||||
usage: "&cUsage: /unflip [message]&r"
|
|
||||||
chatonly:
|
chatonly:
|
||||||
description: Enable chat only mode. Useful for chat clients.
|
description: Enable chat only mode. Useful for chat clients.
|
||||||
usage: "&cUsage: /chatonly&r"
|
|
||||||
shrug:
|
shrug:
|
||||||
description: Shrug.
|
description: Shrug.
|
||||||
usage: "&cUsage: /shrug [message]&r"
|
|
||||||
author: NorbiPeti
|
author: NorbiPeti
|
||||||
depend: [Essentials, Towny, Minigames, Votifier, WorldGuard, WorldEdit, ProtocolLib, FastLogin, Vault, AuthMe]
|
depend: [Essentials, Towny, Minigames, Votifier, WorldGuard, WorldEdit, ProtocolLib, FastLogin, Vault, AuthMe]
|
||||||
permissions:
|
permissions:
|
||||||
|
|
6
pom.xml
6
pom.xml
|
@ -45,6 +45,11 @@
|
||||||
<exclude>log4j:log4j:jar:</exclude>
|
<exclude>log4j:log4j:jar:</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
|
<pluginExecution>
|
||||||
|
<action>
|
||||||
|
<execute />
|
||||||
|
</action>
|
||||||
|
</pluginExecution>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
@ -63,6 +68,7 @@
|
||||||
<groupId>org.reflections</groupId>
|
<groupId>org.reflections</groupId>
|
||||||
<artifactId>reflections</artifactId>
|
<artifactId>reflections</artifactId>
|
||||||
<version>0.9.10</version>
|
<version>0.9.10</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -25,8 +25,7 @@ import com.palmergames.bukkit.towny.object.Nation;
|
||||||
import com.palmergames.bukkit.towny.object.Town;
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||||
|
|
||||||
import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase;
|
import io.github.norbipeti.thebuttonmcchat.commands.CommandCaller;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.String;
|
import java.lang.String;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -57,8 +56,10 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
try {
|
try {
|
||||||
System.out.println("Extracting necessary libraries...");
|
System.out.println("Extracting necessary libraries...");
|
||||||
final File[] libs = new File[] { new File(getDataFolder(),
|
final File[] libs = new File[] {
|
||||||
"htmlcleaner-2.16.jar") };
|
new File(getDataFolder(), "htmlcleaner-2.16.jar"),
|
||||||
|
new File(getDataFolder(), "reflections-0.9.10.jar"),
|
||||||
|
new File(getDataFolder(), "javassist-3.19.0-GA.jar") };
|
||||||
for (final File lib : libs) {
|
for (final File lib : libs) {
|
||||||
if (!lib.exists()) {
|
if (!lib.exists()) {
|
||||||
JarUtils.extractFromJar(lib.getName(),
|
JarUtils.extractFromJar(lib.getName(),
|
||||||
|
@ -81,7 +82,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvents(new PlayerListener(),
|
getServer().getPluginManager().registerEvents(new PlayerListener(),
|
||||||
this);
|
this);
|
||||||
TBMCCommandBase.RegisterCommands(this);
|
CommandCaller.RegisterCommands(this);
|
||||||
Instance = this;
|
Instance = this;
|
||||||
Console = this.getServer().getConsoleSender();
|
Console = this.getServer().getConsoleSender();
|
||||||
LoadFiles(false);
|
LoadFiles(false);
|
||||||
|
@ -305,12 +306,11 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
|
|
||||||
public static void LoadFiles(boolean reload) {
|
public static void LoadFiles(boolean reload) {
|
||||||
if (reload) {
|
if (reload) {
|
||||||
System.out
|
System.out.println("TBMC chat plugin cleanup for reloading...");
|
||||||
.println("The Button Minecraft plugin cleanup for reloading...");
|
|
||||||
MaybeOfflinePlayer.AllPlayers.clear();
|
MaybeOfflinePlayer.AllPlayers.clear();
|
||||||
AnnounceMessages.clear();
|
AnnounceMessages.clear();
|
||||||
}
|
}
|
||||||
System.out.println("Loading files for The Button Minecraft plugin...");
|
System.out.println("Loading files for TBMC chat plugin...");
|
||||||
try {
|
try {
|
||||||
File file = new File("thebuttonmc.yml");
|
File file = new File("thebuttonmc.yml");
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
|
@ -325,7 +325,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
AnnounceMessages.addAll(yc.getStringList("announcements"));
|
AnnounceMessages.addAll(yc.getStringList("announcements"));
|
||||||
PlayerListener.AlphaDeaths = yc.getInt("alphadeaths");
|
PlayerListener.AlphaDeaths = yc.getInt("alphadeaths");
|
||||||
}
|
}
|
||||||
System.out.println("The Button Minecraft plugin loaded files!");
|
System.out.println("TBMC plugin loaded files!");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Error!\n" + e);
|
System.out.println("Error!\n" + e);
|
||||||
LastException = e;
|
LastException = e;
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.github.norbipeti.thebuttonmcchat.commands;
|
||||||
|
|
||||||
import io.github.norbipeti.thebuttonmcchat.PluginMain;
|
import io.github.norbipeti.thebuttonmcchat.PluginMain;
|
||||||
|
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -10,23 +11,62 @@ import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
|
import org.reflections.scanners.SubTypesScanner;
|
||||||
|
import org.reflections.util.ClasspathHelper;
|
||||||
|
import org.reflections.util.ConfigurationBuilder;
|
||||||
|
|
||||||
public class CommandCaller implements CommandExecutor {
|
public class CommandCaller implements CommandExecutor {
|
||||||
|
|
||||||
|
private CommandCaller() {
|
||||||
|
}
|
||||||
|
|
||||||
private static HashMap<String, TBMCCommandBase> commands = new HashMap<String, TBMCCommandBase>();
|
private static HashMap<String, TBMCCommandBase> commands = new HashMap<String, TBMCCommandBase>();
|
||||||
|
|
||||||
public void RegisterCommands(PluginMain plugin) {
|
public static HashMap<String, TBMCCommandBase> GetCommands() {
|
||||||
|
return commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CommandCaller instance;
|
||||||
|
|
||||||
|
public static void RegisterCommands(PluginMain plugin) {
|
||||||
|
if (instance != null) {
|
||||||
|
new Exception("Only one instance of CommandCaller is allowed")
|
||||||
|
.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
System.out.println("Registering commands...");
|
System.out.println("Registering commands...");
|
||||||
|
|
||||||
|
CommandCaller cc = new CommandCaller();
|
||||||
|
instance = cc;
|
||||||
Reflections rf = new Reflections(
|
Reflections rf = new Reflections(
|
||||||
"io.github.norbipeti.thebuttonmcchat.commands");
|
new ConfigurationBuilder()
|
||||||
|
.setUrls(
|
||||||
|
ClasspathHelper.forClassLoader(plugin
|
||||||
|
.getClass().getClassLoader()))
|
||||||
|
.addClassLoader(plugin.getClass().getClassLoader())
|
||||||
|
.addScanners(new SubTypesScanner())
|
||||||
|
.filterInputsBy(
|
||||||
|
(String pkg) -> pkg
|
||||||
|
.contains("io.github.norbipeti.thebuttonmcchat.commands")));
|
||||||
Set<Class<? extends TBMCCommandBase>> cmds = rf
|
Set<Class<? extends TBMCCommandBase>> cmds = rf
|
||||||
.getSubTypesOf(TBMCCommandBase.class);
|
.getSubTypesOf(TBMCCommandBase.class);
|
||||||
for (Class<? extends TBMCCommandBase> cmd : cmds) {
|
for (Class<? extends TBMCCommandBase> cmd : cmds) {
|
||||||
try {
|
try {
|
||||||
|
if (Modifier.isAbstract(cmd.getModifiers()))
|
||||||
|
continue;
|
||||||
TBMCCommandBase c = cmd.newInstance();
|
TBMCCommandBase c = cmd.newInstance();
|
||||||
commands.put(c.GetCommandPath(), c);
|
commands.put(c.GetCommandPath(), c);
|
||||||
plugin.getCommand(c.GetCommandPath()).setExecutor(this);
|
if (!c.GetCommandPath().contains("/")) // Top-level command
|
||||||
|
{
|
||||||
|
PluginCommand pc = plugin.getCommand(c.GetCommandPath());
|
||||||
|
if (pc == null)
|
||||||
|
System.out.println("Can't find top-level command: "
|
||||||
|
+ c.GetCommandPath());
|
||||||
|
else
|
||||||
|
pc.setExecutor(cc);
|
||||||
|
}
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
|
@ -50,6 +90,7 @@ public class CommandCaller implements CommandExecutor {
|
||||||
path = path.substring(0, path.indexOf('/'));
|
path = path.substring(0, path.indexOf('/'));
|
||||||
argc++;
|
argc++;
|
||||||
cmd = commands.get(path);
|
cmd = commands.get(path);
|
||||||
|
System.out.println(path);
|
||||||
}
|
}
|
||||||
if (cmd == null) {
|
if (cmd == null) {
|
||||||
sender.sendMessage("§cInternal error: Command not registered to CommandCaller");
|
sender.sendMessage("§cInternal error: Command not registered to CommandCaller");
|
||||||
|
@ -59,8 +100,12 @@ public class CommandCaller implements CommandExecutor {
|
||||||
"§cInternal error: Command not registered to CommandCaller");
|
"§cInternal error: Command not registered to CommandCaller");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
cmd.OnCommand(sender, alias,
|
if (!cmd.OnCommand(
|
||||||
Arrays.copyOfRange(args, argc, args.length - 1));
|
sender,
|
||||||
|
alias,
|
||||||
|
(args.length > 0 ? Arrays.copyOfRange(args, argc,
|
||||||
|
args.length - 1) : args)))
|
||||||
|
sender.sendMessage(cmd.GetHelpText(alias));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,6 @@
|
||||||
package io.github.norbipeti.thebuttonmcchat.commands;
|
package io.github.norbipeti.thebuttonmcchat.commands;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import io.github.norbipeti.thebuttonmcchat.PluginMain;
|
|
||||||
import io.github.norbipeti.thebuttonmcchat.commands.appendtext.ShrugCommand;
|
|
||||||
import io.github.norbipeti.thebuttonmcchat.commands.appendtext.TableflipCommand;
|
|
||||||
import io.github.norbipeti.thebuttonmcchat.commands.appendtext.UnflipCommand;
|
|
||||||
import io.github.norbipeti.thebuttonmcchat.commands.ucmds.UCommand;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public abstract class TBMCCommandBase {
|
public abstract class TBMCCommandBase {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package io.github.norbipeti.thebuttonmcchat.commands.ucmds;
|
package io.github.norbipeti.thebuttonmcchat.commands.ucmds;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import io.github.norbipeti.thebuttonmcchat.commands.CommandCaller;
|
||||||
import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase;
|
import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -17,9 +20,9 @@ public final class HelpCommand extends UCommandBase {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
sender.sendMessage(new String[] {
|
sender.sendMessage(new String[] {
|
||||||
"§6---- TBMC Help ----",
|
"§6---- TBMC Help ----",
|
||||||
"Do /u help <subcommand> for more info",
|
"Do /u help <topic> for more info",
|
||||||
"Alternatively, you can do /u help <commandname> for more info about a command",
|
"Alternatively, you can do /u help <commandname> [subcommands] for more info about a command",
|
||||||
"Subcommands:",
|
"Topics:",
|
||||||
"flairs: The flairs are the numbers near your name",
|
"flairs: The flairs are the numbers near your name",
|
||||||
"commands: See all the commands from this plugin",
|
"commands: See all the commands from this plugin",
|
||||||
"login: If you or someone else has any problems with logins, lost inventory/location, etc." });
|
"login: If you or someone else has any problems with logins, lost inventory/location, etc." });
|
||||||
|
@ -28,18 +31,22 @@ public final class HelpCommand extends UCommandBase {
|
||||||
if (args[0].equalsIgnoreCase("flairs"))
|
if (args[0].equalsIgnoreCase("flairs"))
|
||||||
sender.sendMessage(new String[] { "§6---- About flairs ----", "" }); // TODO
|
sender.sendMessage(new String[] { "§6---- About flairs ----", "" }); // TODO
|
||||||
else if (args[0].equalsIgnoreCase("commands")) {
|
else if (args[0].equalsIgnoreCase("commands")) {
|
||||||
String[] text = new String[TBMCCommandBase.GetCommands().size() + 1];
|
ArrayList<String> text = new ArrayList<String>();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
text[i++] = "§6---- Command list ----";
|
text.set(i++, "§6---- Command list ----");
|
||||||
for (TBMCCommandBase cmd : TBMCCommandBase.GetCommands().values())
|
for (TBMCCommandBase cmd : CommandCaller.GetCommands().values())
|
||||||
text[i++] = "/" + cmd.GetCommandName();
|
if (!cmd.GetCommandPath().contains("/"))
|
||||||
sender.sendMessage(text);
|
text.set(i++, "/" + cmd.GetCommandPath());
|
||||||
|
sender.sendMessage((String[]) text.toArray());
|
||||||
} else {
|
} else {
|
||||||
TBMCCommandBase cmd = TBMCCommandBase.GetCommands().get(args[0]);
|
String path = args[0];
|
||||||
|
for (int i = 1; i < args.length; i++)
|
||||||
|
path += "/" + args[i];
|
||||||
|
TBMCCommandBase cmd = CommandCaller.GetCommands().get(path);
|
||||||
if (cmd == null)
|
if (cmd == null)
|
||||||
sender.sendMessage(new String[] {
|
sender.sendMessage(new String[] {
|
||||||
"§cError: Command not found: " + args[0],
|
"§cError: Command not found: " + path.replace('/', ' '),
|
||||||
"Use either a command of this plugin or a subcommand (for example: /u accept --> /u help accept" });
|
"Usage example: /u accept --> /u help u accept" });
|
||||||
else
|
else
|
||||||
sender.sendMessage(cmd.GetHelpText(args[0]));
|
sender.sendMessage(cmd.GetHelpText(args[0]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,12 @@ import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public final class UCommand extends UCommandBase {
|
public final class UCommand extends TBMCCommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] GetHelpText(String alias) {
|
public String[] GetHelpText(String alias) {
|
||||||
return new String[] { "§6---- U commands ----",
|
return new String[] { "§6---- U commands ----",
|
||||||
"Subcommands: help, accept, ignore, admin" }; //TODO
|
"Subcommands: help, accept, ignore, admin" }; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,8 +18,8 @@ public final class UCommand extends UCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetUCommandPath() {
|
public String GetCommandPath() {
|
||||||
return "u"; // TODO: Same as at AdminCommand
|
return "u";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package io.github.norbipeti.thebuttonmcchat.commands.ucmds;
|
package io.github.norbipeti.thebuttonmcchat.commands.ucmds;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase;
|
import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase;
|
||||||
|
|
||||||
public abstract class UCommandBase extends TBMCCommandBase {
|
public abstract class UCommandBase extends TBMCCommandBase {
|
||||||
|
@ -12,8 +8,6 @@ public abstract class UCommandBase extends TBMCCommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetCommandPath() {
|
public String GetCommandPath() {
|
||||||
if (GetUCommandPath().equals("u"))
|
|
||||||
return "u";
|
|
||||||
return "u/" + GetUCommandPath(); //TODO: This for others
|
return "u/" + GetUCommandPath(); //TODO: This for others
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin;
|
package io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin;
|
||||||
|
|
||||||
|
import io.github.norbipeti.thebuttonmcchat.commands.ucmds.UCommandBase;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public final class AdminCommand extends AdminCommandBase {
|
public final class AdminCommand extends UCommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] GetHelpText(String alias) {
|
public String[] GetHelpText(String alias) {
|
||||||
|
@ -17,7 +19,7 @@ public final class AdminCommand extends AdminCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetAdminCommandName() {
|
public String GetUCommandPath() {
|
||||||
return "admin"; //TODO: Call this by default (so /u admin invalidcmd should point here)
|
return "admin";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin;
|
package io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import io.github.norbipeti.thebuttonmcchat.commands.ucmds.UCommandBase;
|
import io.github.norbipeti.thebuttonmcchat.commands.ucmds.UCommandBase;
|
||||||
|
|
||||||
public abstract class AdminCommandBase extends UCommandBase {
|
public abstract class AdminCommandBase extends UCommandBase {
|
||||||
|
@ -12,9 +8,7 @@ public abstract class AdminCommandBase extends UCommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetUCommandPath() {
|
public String GetUCommandPath() {
|
||||||
if (GetAdminCommandName().equals("admin"))
|
return "admin/" + GetAdminCommandPath();
|
||||||
return "admin";
|
|
||||||
return "admin/" + GetAdminCommandName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,6 +16,6 @@ public abstract class AdminCommandBase extends UCommandBase {
|
||||||
return false; // Allow admin commands in console
|
return false; // Allow admin commands in console
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String GetAdminCommandName();
|
public abstract String GetAdminCommandPath();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class ConfirmCommand extends AdminCommandBase {
|
||||||
System.out.println("Error!\n" + e);
|
System.out.println("Error!\n" + e);
|
||||||
if (sender != PluginMain.Console)
|
if (sender != PluginMain.Console)
|
||||||
sender.sendMessage("§cAn error occured. See console for details.§r");
|
sender.sendMessage("§cAn error occured. See console for details.§r");
|
||||||
PluginMain.LastException = e; // 2015.08.09.
|
PluginMain.LastException = e;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
sender.sendMessage("§cYou need to do /u admin reload first.§r");
|
sender.sendMessage("§cYou need to do /u admin reload first.§r");
|
||||||
|
@ -36,7 +36,7 @@ public class ConfirmCommand extends AdminCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetAdminCommandName() {
|
public String GetAdminCommandPath() {
|
||||||
return "confirm";
|
return "confirm";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class GetLastErrorCommand extends AdminCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnAdminCommand(CommandSender sender, String alias,
|
public boolean OnCommand(CommandSender sender, String alias,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
if (PluginMain.LastException != null) {
|
if (PluginMain.LastException != null) {
|
||||||
sender.sendMessage("Last error:");
|
sender.sendMessage("Last error:");
|
||||||
|
@ -26,7 +26,7 @@ public class GetLastErrorCommand extends AdminCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetAdminCommandName() {
|
public String GetAdminCommandPath() {
|
||||||
return "getlasterror";
|
return "getlasterror";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class PlayerInfoCommand extends AdminCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnAdminCommand(CommandSender sender, String alias,
|
public boolean OnCommand(CommandSender sender, String alias,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -38,7 +38,7 @@ public class PlayerInfoCommand extends AdminCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetAdminCommandName() {
|
public String GetAdminCommandPath() {
|
||||||
return "playerinfo";
|
return "playerinfo";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ public final class ReloadCommand extends AdminCommandBase {
|
||||||
public static CommandSender Reloader;
|
public static CommandSender Reloader;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnAdminCommand(CommandSender sender, String alias,
|
public boolean OnCommand(CommandSender sender, String alias,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
Reloader = sender;
|
Reloader = sender;
|
||||||
sender.sendMessage("§bMake sure to save the current settings before you modify and reload them! Type /u admin confirm when done.§r");
|
sender.sendMessage("§bMake sure to save the current settings before you modify and reload them! Type /u admin confirm when done.§r");
|
||||||
|
@ -25,7 +25,7 @@ public final class ReloadCommand extends AdminCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetAdminCommandName() {
|
public String GetAdminCommandPath() {
|
||||||
return "reload";
|
return "reload";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class SaveCommand extends AdminCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnAdminCommand(CommandSender sender, String alias,
|
public boolean OnCommand(CommandSender sender, String alias,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
PluginMain.SaveFiles(); // 2015.08.09.
|
PluginMain.SaveFiles(); // 2015.08.09.
|
||||||
sender.sendMessage("§bSaved files. Now you can edit them and reload if you want.§r");
|
sender.sendMessage("§bSaved files. Now you can edit them and reload if you want.§r");
|
||||||
|
@ -21,7 +21,7 @@ public class SaveCommand extends AdminCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetAdminCommandName() {
|
public String GetAdminCommandPath() {
|
||||||
return "save";
|
return "save";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class SetFlairCommand extends AdminCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnAdminCommand(CommandSender sender, String alias,
|
public boolean OnCommand(CommandSender sender, String alias,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -71,7 +71,7 @@ public class SetFlairCommand extends AdminCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetAdminCommandName() {
|
public String GetAdminCommandPath() {
|
||||||
return "setflair";
|
return "setflair";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class UpdatePlugin extends AdminCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnAdminCommand(CommandSender sender, String alias,
|
public boolean OnCommand(CommandSender sender, String alias,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
sender.sendMessage("Updating Auto-Flair plugin...");
|
sender.sendMessage("Updating Auto-Flair plugin...");
|
||||||
System.out.println("Forced updating of Auto-Flair plugin.");
|
System.out.println("Forced updating of Auto-Flair plugin.");
|
||||||
|
@ -41,7 +41,7 @@ public class UpdatePlugin extends AdminCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetAdminCommandName() {
|
public String GetAdminCommandPath() {
|
||||||
return "updateplugin";
|
return "updateplugin";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class AddCommand extends AnnounceCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnAnnounceCommand(CommandSender sender, String alias,
|
public boolean OnCommand(CommandSender sender, String alias,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -35,7 +35,7 @@ public class AddCommand extends AnnounceCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetAnnounceCommandName() {
|
public String GetAnnounceCommandPath() {
|
||||||
return "add";
|
return "add";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package io.github.norbipeti.thebuttonmcchat.commands.ucmds.announce;
|
package io.github.norbipeti.thebuttonmcchat.commands.ucmds.announce;
|
||||||
|
|
||||||
|
import io.github.norbipeti.thebuttonmcchat.commands.ucmds.UCommandBase;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class AnnounceCommand extends AnnounceCommandBase {
|
public class AnnounceCommand extends UCommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] GetHelpText(String alias) {
|
public String[] GetHelpText(String alias) {
|
||||||
|
@ -11,13 +13,12 @@ public class AnnounceCommand extends AnnounceCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnAnnounceCommand(CommandSender sender, String alias,
|
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||||
String[] args) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetAnnounceCommandName() {
|
public String GetUCommandPath() {
|
||||||
return "announce";
|
return "announce";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package io.github.norbipeti.thebuttonmcchat.commands.ucmds.announce;
|
package io.github.norbipeti.thebuttonmcchat.commands.ucmds.announce;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import io.github.norbipeti.thebuttonmcchat.commands.ucmds.UCommandBase;
|
import io.github.norbipeti.thebuttonmcchat.commands.ucmds.UCommandBase;
|
||||||
|
|
||||||
public abstract class AnnounceCommandBase extends UCommandBase {
|
public abstract class AnnounceCommandBase extends UCommandBase {
|
||||||
|
@ -11,21 +7,10 @@ public abstract class AnnounceCommandBase extends UCommandBase {
|
||||||
public abstract String[] GetHelpText(String alias);
|
public abstract String[] GetHelpText(String alias);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnUCommand(CommandSender sender, String alias, String[] args) {
|
public String GetUCommandPath() {
|
||||||
if (args.length == 0)
|
|
||||||
return false;
|
|
||||||
return OnAnnounceCommand(sender, alias,
|
|
||||||
Arrays.copyOfRange(args, 1, args.length)); //TODO: Only allow OPs and mods to use it
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract boolean OnAnnounceCommand(CommandSender sender,
|
|
||||||
String alias, String[] args);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String GetUCommandName() {
|
|
||||||
return "announce";
|
return "announce";
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String GetAnnounceCommandName();
|
public abstract String GetAnnounceCommandPath();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class EditCommand extends AnnounceCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnAnnounceCommand(CommandSender sender, String alias,
|
public boolean OnCommand(CommandSender sender, String alias,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
if (!(sender instanceof BlockCommandSender)) {
|
if (!(sender instanceof BlockCommandSender)) {
|
||||||
sender.sendMessage("§cError: This command can only be used from a command block. You can use add and remove, though it's not recommended.");
|
sender.sendMessage("§cError: This command can only be used from a command block. You can use add and remove, though it's not recommended.");
|
||||||
|
@ -43,7 +43,7 @@ public class EditCommand extends AnnounceCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetAnnounceCommandName() {
|
public String GetAnnounceCommandPath() {
|
||||||
return "edit";
|
return "edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class ListCommand extends AnnounceCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnAnnounceCommand(CommandSender sender, String alias,
|
public boolean OnCommand(CommandSender sender, String alias,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
sender.sendMessage("§bList of announce messages:§r");
|
sender.sendMessage("§bList of announce messages:§r");
|
||||||
sender.sendMessage("§bFormat: [index] message§r");
|
sender.sendMessage("§bFormat: [index] message§r");
|
||||||
|
@ -26,7 +26,7 @@ public class ListCommand extends AnnounceCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetAnnounceCommandName() {
|
public String GetAnnounceCommandPath() {
|
||||||
return "list";
|
return "list";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class RemoveCommand extends AnnounceCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnAnnounceCommand(CommandSender sender, String alias,
|
public boolean OnCommand(CommandSender sender, String alias,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
sender.sendMessage("§cUsage: /u announce remove <index>");
|
sender.sendMessage("§cUsage: /u announce remove <index>");
|
||||||
|
@ -28,7 +28,7 @@ public class RemoveCommand extends AnnounceCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetAnnounceCommandName() {
|
public String GetAnnounceCommandPath() {
|
||||||
return "remove";
|
return "remove";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class SetTimeCommand extends AnnounceCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean OnAnnounceCommand(CommandSender sender, String alias,
|
public boolean OnCommand(CommandSender sender, String alias,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -31,7 +31,7 @@ public class SetTimeCommand extends AnnounceCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetAnnounceCommandName() {
|
public String GetAnnounceCommandPath() {
|
||||||
return "settime";
|
return "settime";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue