mirror of
https://github.com/kaboomserver/commandspy.git
synced 2025-07-31 10:11:34 +00:00
Cleanups
This commit is contained in:
parent
fd068e2682
commit
72a164ac3e
1 changed files with 7 additions and 11 deletions
|
@ -19,7 +19,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class Main extends JavaPlugin implements Listener {
|
public class Main extends JavaPlugin implements Listener {
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.getCommand("commandspy").setExecutor(new CommandCommandSpy(this));
|
this.getCommand("commandspy").setExecutor(new CommandCommandSpy());
|
||||||
this.getServer().getPluginManager().registerEvents(this, this);
|
this.getServer().getPluginManager().registerEvents(this, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,24 +66,20 @@ public class Main extends JavaPlugin implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
class CommandCommandSpy implements CommandExecutor {
|
class CommandCommandSpy implements CommandExecutor {
|
||||||
Main main;
|
|
||||||
CommandCommandSpy(Main main) {
|
|
||||||
this.main = main;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
sender.sendMessage("Command has to be run by a player");
|
sender.sendMessage("Command has to be run by a player");
|
||||||
} else {
|
} else {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
|
final JavaPlugin plugin = JavaPlugin.getPlugin(Main.class);
|
||||||
|
|
||||||
if (main.getConfig().contains(player.getUniqueId().toString())) {
|
if (plugin.getConfig().contains(player.getUniqueId().toString())) {
|
||||||
main.getConfig().set(player.getUniqueId().toString(), null);
|
plugin.getConfig().set(player.getUniqueId().toString(), null);
|
||||||
main.saveConfig();
|
plugin.saveConfig();
|
||||||
player.sendMessage("Successfully disabled CommandSpy");
|
player.sendMessage("Successfully disabled CommandSpy");
|
||||||
} else {
|
} else {
|
||||||
main.getConfig().set(player.getUniqueId().toString(), true);
|
plugin.getConfig().set(player.getUniqueId().toString(), true);
|
||||||
main.saveConfig();
|
plugin.saveConfig();
|
||||||
player.sendMessage("Successfully enabled CommandSpy");
|
player.sendMessage("Successfully enabled CommandSpy");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue