38 lines
1.1 KiB
Java
38 lines
1.1 KiB
Java
package ee.lunasqu.redstoneoutput;
|
|
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandExecutor;
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
public class RemoteCommand implements CommandExecutor {
|
|
@Override
|
|
public boolean onCommand(CommandSender sender, Command arg1, String arg2, String[] arguments) {
|
|
switch (arguments[0]) {
|
|
case "status":
|
|
if (Main.plugin.getConnection() != null) {
|
|
sender.sendMessage("The connection is established.");
|
|
} else {
|
|
sender.sendMessage("The connection is closed.");
|
|
}
|
|
return true;
|
|
case "start":
|
|
if (Main.plugin.getConnection() != null) {
|
|
sender.sendMessage("The connection is already established!");
|
|
return false;
|
|
}
|
|
sender.sendMessage("Connection has been attempted!");
|
|
Main.plugin.connect();
|
|
return true;
|
|
case "stop":
|
|
if (Main.plugin.getConnection() == null) {
|
|
sender.sendMessage("The connection is already closed!");
|
|
return false;
|
|
}
|
|
sender.sendMessage("Connection has been closed!");
|
|
Main.plugin.getConnection().die();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|