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:
|
||||
u:
|
||||
description: Auto-flair system. Accept or ignore flair.
|
||||
usage: "&cUsage: /u accept|ignore|opme&r"
|
||||
ooc:
|
||||
description: Send message in Out-of-Character.
|
||||
usage: "&cUsage: /ooc <message>&r"
|
||||
alias: nrp
|
||||
unlol:
|
||||
description: Unlaugh the last laugh.
|
||||
alias: unlaugh
|
||||
mwiki:
|
||||
description: Search the wiki.
|
||||
usage: "&cUsage: /mwiki [query]&r"
|
||||
dontrunthiscmd:
|
||||
tableflip:
|
||||
description: Flip a table.
|
||||
usage: "&cUsage: /tableflip [message]&r"
|
||||
unflip:
|
||||
description: Unflip a flip.
|
||||
usage: "&cUsage: /unflip [message]&r"
|
||||
chatonly:
|
||||
description: Enable chat only mode. Useful for chat clients.
|
||||
usage: "&cUsage: /chatonly&r"
|
||||
shrug:
|
||||
description: Shrug.
|
||||
usage: "&cUsage: /shrug [message]&r"
|
||||
author: NorbiPeti
|
||||
depend: [Essentials, Towny, Minigames, Votifier, WorldGuard, WorldEdit, ProtocolLib, FastLogin, Vault, AuthMe]
|
||||
permissions:
|
||||
|
|
134
pom.xml
134
pom.xml
|
@ -1,68 +1,74 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>TheButtonMCPlugin</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>The Button Minecraft Plugin</name>
|
||||
<description>The Button Minecraft Plugin</description>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.4.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<excludes>
|
||||
<exclude>classworlds:classworlds</exclude>
|
||||
<exclude>junit:junit</exclude>
|
||||
<exclude>jmock:*</exclude>
|
||||
<exclude>*:xml-apis</exclude>
|
||||
<exclude>org.apache.maven:lib:tests</exclude>
|
||||
<exclude>log4j:log4j:jar:</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<groupId>tk.sznp</groupId>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.10</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<artifactId>TheButtonMCPlugin</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>The Button Minecraft Plugin</name>
|
||||
<description>The Button Minecraft Plugin</description>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.4.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<excludes>
|
||||
<exclude>classworlds:classworlds</exclude>
|
||||
<exclude>junit:junit</exclude>
|
||||
<exclude>jmock:*</exclude>
|
||||
<exclude>*:xml-apis</exclude>
|
||||
<exclude>org.apache.maven:lib:tests</exclude>
|
||||
<exclude>log4j:log4j:jar:</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
<pluginExecution>
|
||||
<action>
|
||||
<execute />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<groupId>tk.sznp</groupId>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.10</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</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.TownyUniverse;
|
||||
|
||||
import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase;
|
||||
|
||||
import io.github.norbipeti.thebuttonmcchat.commands.CommandCaller;
|
||||
import java.io.*;
|
||||
import java.lang.String;
|
||||
import java.lang.reflect.Method;
|
||||
|
@ -57,8 +56,10 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
|||
public void onEnable() {
|
||||
try {
|
||||
System.out.println("Extracting necessary libraries...");
|
||||
final File[] libs = new File[] { new File(getDataFolder(),
|
||||
"htmlcleaner-2.16.jar") };
|
||||
final File[] libs = new File[] {
|
||||
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) {
|
||||
if (!lib.exists()) {
|
||||
JarUtils.extractFromJar(lib.getName(),
|
||||
|
@ -81,7 +82,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
|||
|
||||
getServer().getPluginManager().registerEvents(new PlayerListener(),
|
||||
this);
|
||||
TBMCCommandBase.RegisterCommands(this);
|
||||
CommandCaller.RegisterCommands(this);
|
||||
Instance = this;
|
||||
Console = this.getServer().getConsoleSender();
|
||||
LoadFiles(false);
|
||||
|
@ -305,12 +306,11 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
|||
|
||||
public static void LoadFiles(boolean reload) {
|
||||
if (reload) {
|
||||
System.out
|
||||
.println("The Button Minecraft plugin cleanup for reloading...");
|
||||
System.out.println("TBMC chat plugin cleanup for reloading...");
|
||||
MaybeOfflinePlayer.AllPlayers.clear();
|
||||
AnnounceMessages.clear();
|
||||
}
|
||||
System.out.println("Loading files for The Button Minecraft plugin...");
|
||||
System.out.println("Loading files for TBMC chat plugin...");
|
||||
try {
|
||||
File file = new File("thebuttonmc.yml");
|
||||
if (file.exists()) {
|
||||
|
@ -325,7 +325,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
|||
AnnounceMessages.addAll(yc.getStringList("announcements"));
|
||||
PlayerListener.AlphaDeaths = yc.getInt("alphadeaths");
|
||||
}
|
||||
System.out.println("The Button Minecraft plugin loaded files!");
|
||||
System.out.println("TBMC plugin loaded files!");
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error!\n" + e);
|
||||
LastException = e;
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.github.norbipeti.thebuttonmcchat.commands;
|
|||
|
||||
import io.github.norbipeti.thebuttonmcchat.PluginMain;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
@ -10,23 +11,62 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.SubTypesScanner;
|
||||
import org.reflections.util.ClasspathHelper;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
|
||||
public class CommandCaller implements CommandExecutor {
|
||||
|
||||
private CommandCaller() {
|
||||
}
|
||||
|
||||
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...");
|
||||
|
||||
CommandCaller cc = new CommandCaller();
|
||||
instance = cc;
|
||||
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
|
||||
.getSubTypesOf(TBMCCommandBase.class);
|
||||
for (Class<? extends TBMCCommandBase> cmd : cmds) {
|
||||
try {
|
||||
if (Modifier.isAbstract(cmd.getModifiers()))
|
||||
continue;
|
||||
TBMCCommandBase c = cmd.newInstance();
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
|
@ -50,6 +90,7 @@ public class CommandCaller implements CommandExecutor {
|
|||
path = path.substring(0, path.indexOf('/'));
|
||||
argc++;
|
||||
cmd = commands.get(path);
|
||||
System.out.println(path);
|
||||
}
|
||||
if (cmd == null) {
|
||||
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");
|
||||
return true;
|
||||
}
|
||||
cmd.OnCommand(sender, alias,
|
||||
Arrays.copyOfRange(args, argc, args.length - 1));
|
||||
if (!cmd.OnCommand(
|
||||
sender,
|
||||
alias,
|
||||
(args.length > 0 ? Arrays.copyOfRange(args, argc,
|
||||
args.length - 1) : args)))
|
||||
sender.sendMessage(cmd.GetHelpText(alias));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,6 @@
|
|||
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.entity.Player;
|
||||
|
||||
public abstract class TBMCCommandBase {
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
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 org.bukkit.command.CommandSender;
|
||||
|
@ -17,9 +20,9 @@ public final class HelpCommand extends UCommandBase {
|
|||
if (args.length == 0) {
|
||||
sender.sendMessage(new String[] {
|
||||
"§6---- TBMC Help ----",
|
||||
"Do /u help <subcommand> for more info",
|
||||
"Alternatively, you can do /u help <commandname> for more info about a command",
|
||||
"Subcommands:",
|
||||
"Do /u help <topic> for more info",
|
||||
"Alternatively, you can do /u help <commandname> [subcommands] for more info about a command",
|
||||
"Topics:",
|
||||
"flairs: The flairs are the numbers near your name",
|
||||
"commands: See all the commands from this plugin",
|
||||
"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"))
|
||||
sender.sendMessage(new String[] { "§6---- About flairs ----", "" }); // TODO
|
||||
else if (args[0].equalsIgnoreCase("commands")) {
|
||||
String[] text = new String[TBMCCommandBase.GetCommands().size() + 1];
|
||||
ArrayList<String> text = new ArrayList<String>();
|
||||
int i = 0;
|
||||
text[i++] = "§6---- Command list ----";
|
||||
for (TBMCCommandBase cmd : TBMCCommandBase.GetCommands().values())
|
||||
text[i++] = "/" + cmd.GetCommandName();
|
||||
sender.sendMessage(text);
|
||||
text.set(i++, "§6---- Command list ----");
|
||||
for (TBMCCommandBase cmd : CommandCaller.GetCommands().values())
|
||||
if (!cmd.GetCommandPath().contains("/"))
|
||||
text.set(i++, "/" + cmd.GetCommandPath());
|
||||
sender.sendMessage((String[]) text.toArray());
|
||||
} 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)
|
||||
sender.sendMessage(new String[] {
|
||||
"§cError: Command not found: " + args[0],
|
||||
"Use either a command of this plugin or a subcommand (for example: /u accept --> /u help accept" });
|
||||
"§cError: Command not found: " + path.replace('/', ' '),
|
||||
"Usage example: /u accept --> /u help u accept" });
|
||||
else
|
||||
sender.sendMessage(cmd.GetHelpText(args[0]));
|
||||
}
|
||||
|
|
|
@ -4,12 +4,12 @@ import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase;
|
|||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public final class UCommand extends UCommandBase {
|
||||
public final class UCommand extends TBMCCommandBase {
|
||||
|
||||
@Override
|
||||
public String[] GetHelpText(String alias) {
|
||||
return new String[] { "§6---- U commands ----",
|
||||
"Subcommands: help, accept, ignore, admin" }; //TODO
|
||||
"Subcommands: help, accept, ignore, admin" }; // TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,8 +18,8 @@ public final class UCommand extends UCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String GetUCommandPath() {
|
||||
return "u"; // TODO: Same as at AdminCommand
|
||||
public String GetCommandPath() {
|
||||
return "u";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package io.github.norbipeti.thebuttonmcchat.commands.ucmds;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase;
|
||||
|
||||
public abstract class UCommandBase extends TBMCCommandBase {
|
||||
|
@ -12,8 +8,6 @@ public abstract class UCommandBase extends TBMCCommandBase {
|
|||
|
||||
@Override
|
||||
public String GetCommandPath() {
|
||||
if (GetUCommandPath().equals("u"))
|
||||
return "u";
|
||||
return "u/" + GetUCommandPath(); //TODO: This for others
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin;
|
||||
|
||||
import io.github.norbipeti.thebuttonmcchat.commands.ucmds.UCommandBase;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public final class AdminCommand extends AdminCommandBase {
|
||||
public final class AdminCommand extends UCommandBase {
|
||||
|
||||
@Override
|
||||
public String[] GetHelpText(String alias) {
|
||||
|
@ -17,7 +19,7 @@ public final class AdminCommand extends AdminCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String GetAdminCommandName() {
|
||||
return "admin"; //TODO: Call this by default (so /u admin invalidcmd should point here)
|
||||
public String GetUCommandPath() {
|
||||
return "admin";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
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;
|
||||
|
||||
public abstract class AdminCommandBase extends UCommandBase {
|
||||
|
@ -12,9 +8,7 @@ public abstract class AdminCommandBase extends UCommandBase {
|
|||
|
||||
@Override
|
||||
public String GetUCommandPath() {
|
||||
if (GetAdminCommandName().equals("admin"))
|
||||
return "admin";
|
||||
return "admin/" + GetAdminCommandName();
|
||||
return "admin/" + GetAdminCommandPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,6 +16,6 @@ public abstract class AdminCommandBase extends UCommandBase {
|
|||
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);
|
||||
if (sender != PluginMain.Console)
|
||||
sender.sendMessage("§cAn error occured. See console for details.§r");
|
||||
PluginMain.LastException = e; // 2015.08.09.
|
||||
PluginMain.LastException = e;
|
||||
}
|
||||
} else
|
||||
sender.sendMessage("§cYou need to do /u admin reload first.§r");
|
||||
|
@ -36,7 +36,7 @@ public class ConfirmCommand extends AdminCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String GetAdminCommandName() {
|
||||
public String GetAdminCommandPath() {
|
||||
return "confirm";
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ public class GetLastErrorCommand extends AdminCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean OnAdminCommand(CommandSender sender, String alias,
|
||||
public boolean OnCommand(CommandSender sender, String alias,
|
||||
String[] args) {
|
||||
if (PluginMain.LastException != null) {
|
||||
sender.sendMessage("Last error:");
|
||||
|
@ -26,7 +26,7 @@ public class GetLastErrorCommand extends AdminCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String GetAdminCommandName() {
|
||||
public String GetAdminCommandPath() {
|
||||
return "getlasterror";
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ public class PlayerInfoCommand extends AdminCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean OnAdminCommand(CommandSender sender, String alias,
|
||||
public boolean OnCommand(CommandSender sender, String alias,
|
||||
String[] args) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
|
@ -38,7 +38,7 @@ public class PlayerInfoCommand extends AdminCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String GetAdminCommandName() {
|
||||
public String GetAdminCommandPath() {
|
||||
return "playerinfo";
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public final class ReloadCommand extends AdminCommandBase {
|
|||
public static CommandSender Reloader;
|
||||
|
||||
@Override
|
||||
public boolean OnAdminCommand(CommandSender sender, String alias,
|
||||
public boolean OnCommand(CommandSender sender, String alias,
|
||||
String[] args) {
|
||||
Reloader = sender;
|
||||
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
|
||||
public String GetAdminCommandName() {
|
||||
public String GetAdminCommandPath() {
|
||||
return "reload";
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ public class SaveCommand extends AdminCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean OnAdminCommand(CommandSender sender, String alias,
|
||||
public boolean OnCommand(CommandSender sender, String alias,
|
||||
String[] args) {
|
||||
PluginMain.SaveFiles(); // 2015.08.09.
|
||||
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
|
||||
public String GetAdminCommandName() {
|
||||
public String GetAdminCommandPath() {
|
||||
return "save";
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ public class SetFlairCommand extends AdminCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean OnAdminCommand(CommandSender sender, String alias,
|
||||
public boolean OnCommand(CommandSender sender, String alias,
|
||||
String[] args) {
|
||||
if (args.length < 3) {
|
||||
return false;
|
||||
|
@ -71,7 +71,7 @@ public class SetFlairCommand extends AdminCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String GetAdminCommandName() {
|
||||
public String GetAdminCommandPath() {
|
||||
return "setflair";
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public class UpdatePlugin extends AdminCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean OnAdminCommand(CommandSender sender, String alias,
|
||||
public boolean OnCommand(CommandSender sender, String alias,
|
||||
String[] args) {
|
||||
sender.sendMessage("Updating Auto-Flair plugin...");
|
||||
System.out.println("Forced updating of Auto-Flair plugin.");
|
||||
|
@ -41,7 +41,7 @@ public class UpdatePlugin extends AdminCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String GetAdminCommandName() {
|
||||
public String GetAdminCommandPath() {
|
||||
return "updateplugin";
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public class AddCommand extends AnnounceCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean OnAnnounceCommand(CommandSender sender, String alias,
|
||||
public boolean OnCommand(CommandSender sender, String alias,
|
||||
String[] args) {
|
||||
if (args.length < 1) {
|
||||
return false;
|
||||
|
@ -35,7 +35,7 @@ public class AddCommand extends AnnounceCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String GetAnnounceCommandName() {
|
||||
public String GetAnnounceCommandPath() {
|
||||
return "add";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package io.github.norbipeti.thebuttonmcchat.commands.ucmds.announce;
|
||||
|
||||
import io.github.norbipeti.thebuttonmcchat.commands.ucmds.UCommandBase;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class AnnounceCommand extends AnnounceCommandBase {
|
||||
public class AnnounceCommand extends UCommandBase {
|
||||
|
||||
@Override
|
||||
public String[] GetHelpText(String alias) {
|
||||
|
@ -11,13 +13,12 @@ public class AnnounceCommand extends AnnounceCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean OnAnnounceCommand(CommandSender sender, String alias,
|
||||
String[] args) {
|
||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetAnnounceCommandName() {
|
||||
public String GetUCommandPath() {
|
||||
return "announce";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
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;
|
||||
|
||||
public abstract class AnnounceCommandBase extends UCommandBase {
|
||||
|
@ -11,21 +7,10 @@ public abstract class AnnounceCommandBase extends UCommandBase {
|
|||
public abstract String[] GetHelpText(String alias);
|
||||
|
||||
@Override
|
||||
public boolean OnUCommand(CommandSender sender, String alias, String[] args) {
|
||||
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() {
|
||||
public String GetUCommandPath() {
|
||||
return "announce";
|
||||
}
|
||||
|
||||
public abstract String GetAnnounceCommandName();
|
||||
public abstract String GetAnnounceCommandPath();
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public class EditCommand extends AnnounceCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean OnAnnounceCommand(CommandSender sender, String alias,
|
||||
public boolean OnCommand(CommandSender sender, String alias,
|
||||
String[] args) {
|
||||
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.");
|
||||
|
@ -43,7 +43,7 @@ public class EditCommand extends AnnounceCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String GetAnnounceCommandName() {
|
||||
public String GetAnnounceCommandPath() {
|
||||
return "edit";
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ public class ListCommand extends AnnounceCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean OnAnnounceCommand(CommandSender sender, String alias,
|
||||
public boolean OnCommand(CommandSender sender, String alias,
|
||||
String[] args) {
|
||||
sender.sendMessage("§bList of announce messages:§r");
|
||||
sender.sendMessage("§bFormat: [index] message§r");
|
||||
|
@ -26,7 +26,7 @@ public class ListCommand extends AnnounceCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String GetAnnounceCommandName() {
|
||||
public String GetAnnounceCommandPath() {
|
||||
return "list";
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public class RemoveCommand extends AnnounceCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean OnAnnounceCommand(CommandSender sender, String alias,
|
||||
public boolean OnCommand(CommandSender sender, String alias,
|
||||
String[] args) {
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage("§cUsage: /u announce remove <index>");
|
||||
|
@ -28,7 +28,7 @@ public class RemoveCommand extends AnnounceCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String GetAnnounceCommandName() {
|
||||
public String GetAnnounceCommandPath() {
|
||||
return "remove";
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ public class SetTimeCommand extends AnnounceCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean OnAnnounceCommand(CommandSender sender, String alias,
|
||||
public boolean OnCommand(CommandSender sender, String alias,
|
||||
String[] args) {
|
||||
if (args.length < 3) {
|
||||
return false;
|
||||
|
@ -31,7 +31,7 @@ public class SetTimeCommand extends AnnounceCommandBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String GetAnnounceCommandName() {
|
||||
public String GetAnnounceCommandPath() {
|
||||
return "settime";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue