Optimizations

This commit is contained in:
mathiascode 2020-04-16 20:05:32 +03:00
parent 0a3c44db89
commit 2e70511748
6 changed files with 28 additions and 35 deletions

0
LICENSE Executable file → Normal file
View File

0
README.md Executable file → Normal file
View File

0
pom.xml Executable file → Normal file
View File

63
src/main/java/pw/kaboom/commandspy/Main.java Executable file → Normal file
View File

@ -30,21 +30,22 @@ public final class Main extends JavaPlugin implements CommandExecutor, Listener
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) { public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final 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 { return true;
final Player player = (Player) sender;
final JavaPlugin plugin = JavaPlugin.getPlugin(Main.class);
if (plugin.getConfig().contains(player.getUniqueId().toString())) {
plugin.getConfig().set(player.getUniqueId().toString(), null);
plugin.saveConfig();
player.sendMessage("Successfully disabled CommandSpy");
} else {
plugin.getConfig().set(player.getUniqueId().toString(), true);
plugin.saveConfig();
player.sendMessage("Successfully enabled CommandSpy");
}
config = plugin.getConfig();
} }
final Player player = (Player) sender;
final JavaPlugin plugin = JavaPlugin.getPlugin(Main.class);
if (plugin.getConfig().contains(player.getUniqueId().toString())) {
plugin.getConfig().set(player.getUniqueId().toString(), null);
plugin.saveConfig();
player.sendMessage("Successfully disabled CommandSpy");
} else {
plugin.getConfig().set(player.getUniqueId().toString(), true);
plugin.saveConfig();
player.sendMessage("Successfully enabled CommandSpy");
}
config = plugin.getConfig();
return true; return true;
} }
@ -54,16 +55,12 @@ public final class Main extends JavaPlugin implements CommandExecutor, Listener
UUID uuid = UUID.fromString(uuidString); UUID uuid = UUID.fromString(uuidString);
if (Bukkit.getPlayer(uuid) != null) { if (Bukkit.getPlayer(uuid) != null) {
final Player commandRunner = event.getPlayer(); Bukkit.getPlayer(uuid).sendMessage(
final ChatColor color; ChatColor.YELLOW + ""
+ event.getPlayer().getName() + ""
if (config.contains(commandRunner.getUniqueId().toString())) { + ChatColor.YELLOW + ": "
color = ChatColor.GREEN; + event.getMessage()
} else { );
color = ChatColor.RED;
}
Bukkit.getPlayer(uuid).sendMessage(color + "" + commandRunner.getName() + "" + color + ": " + event.getMessage());
} }
} }
} }
@ -74,18 +71,14 @@ public final class Main extends JavaPlugin implements CommandExecutor, Listener
UUID uuid = UUID.fromString(uuidString); UUID uuid = UUID.fromString(uuidString);
if (Bukkit.getPlayer(uuid) != null) { if (Bukkit.getPlayer(uuid) != null) {
final Player signPlacer = event.getPlayer(); Bukkit.getPlayer(uuid).sendMessage(
final ChatColor color; ChatColor.YELLOW + ""
+ event.getPlayer().getName() + ""
if (config.contains(signPlacer.getUniqueId().toString())) { + ChatColor.YELLOW
color = ChatColor.GREEN; + " created a sign with contents:"
} else { );
color = ChatColor.RED;
}
Bukkit.getPlayer(uuid).sendMessage(color + "" + signPlacer.getName() + "" + color + " created a sign with contents:");
for (String line: event.getLines()) { for (String line: event.getLines()) {
Bukkit.getPlayer(uuid).sendMessage(color + " " + line); Bukkit.getPlayer(uuid).sendMessage(ChatColor.YELLOW + " " + line);
} }
} }
} }

0
src/main/resources/plugin.yml Executable file → Normal file
View File

0
suppressions.xml Executable file → Normal file
View File