mirror of
https://github.com/kaboomserver/commandspy.git
synced 2025-08-06 12:42:52 +00:00
Use spaces instead of tabs
This commit is contained in:
parent
849895747e
commit
7762bd56f5
2 changed files with 77 additions and 78 deletions
|
@ -19,94 +19,94 @@ import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public final class Main extends JavaPlugin implements CommandExecutor, Listener {
|
public final class Main extends JavaPlugin implements CommandExecutor, Listener {
|
||||||
private FileConfiguration config;
|
private FileConfiguration config;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
config = getConfig();
|
config = getConfig();
|
||||||
this.getCommand("commandspy").setExecutor(this);
|
this.getCommand("commandspy").setExecutor(this);
|
||||||
this.getServer().getPluginManager().registerEvents(this, this);
|
this.getServer().getPluginManager().registerEvents(this, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableCommandSpy(final Player player, final Plugin plugin) {
|
private void enableCommandSpy(final Player player, final Plugin plugin) {
|
||||||
plugin.getConfig().set(player.getUniqueId().toString(), true);
|
plugin.getConfig().set(player.getUniqueId().toString(), true);
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
player.sendMessage("Successfully enabled CommandSpy");
|
player.sendMessage("Successfully enabled CommandSpy");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableCommandSpy(final Player player, final Plugin plugin) {
|
private void disableCommandSpy(final Player player, final Plugin plugin) {
|
||||||
plugin.getConfig().set(player.getUniqueId().toString(), null);
|
plugin.getConfig().set(player.getUniqueId().toString(), null);
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
player.sendMessage("Successfully disabled CommandSpy");
|
player.sendMessage("Successfully disabled CommandSpy");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final JavaPlugin plugin = JavaPlugin.getPlugin(Main.class);
|
final JavaPlugin plugin = JavaPlugin.getPlugin(Main.class);
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
if (config.contains(player.getUniqueId().toString())) {
|
if (config.contains(player.getUniqueId().toString())) {
|
||||||
disableCommandSpy(player, plugin);
|
disableCommandSpy(player, plugin);
|
||||||
} else {
|
} else {
|
||||||
enableCommandSpy(player, plugin);
|
enableCommandSpy(player, plugin);
|
||||||
}
|
}
|
||||||
} else if ("on".equalsIgnoreCase(args[0])) {
|
} else if ("on".equalsIgnoreCase(args[0])) {
|
||||||
enableCommandSpy(player, plugin);
|
enableCommandSpy(player, plugin);
|
||||||
} else if ("off".equalsIgnoreCase(args[0])) {
|
} else if ("off".equalsIgnoreCase(args[0])) {
|
||||||
disableCommandSpy(player, plugin);
|
disableCommandSpy(player, plugin);
|
||||||
}
|
}
|
||||||
config = plugin.getConfig();
|
config = plugin.getConfig();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> uuids = config.getKeys(false);
|
Set<String> uuids = config.getKeys(false);
|
||||||
ChatColor color = (uuids.contains(event.getPlayer().getUniqueId().toString())) ? ChatColor.YELLOW : ChatColor.AQUA;
|
ChatColor color = (uuids.contains(event.getPlayer().getUniqueId().toString())) ? ChatColor.YELLOW : ChatColor.AQUA;
|
||||||
|
|
||||||
for (String uuidString : uuids) {
|
for (String uuidString : uuids) {
|
||||||
UUID uuid = UUID.fromString(uuidString);
|
UUID uuid = UUID.fromString(uuidString);
|
||||||
|
|
||||||
if (Bukkit.getPlayer(uuid) != null) {
|
if (Bukkit.getPlayer(uuid) != null) {
|
||||||
Bukkit.getPlayer(uuid).sendMessage(
|
Bukkit.getPlayer(uuid).sendMessage(
|
||||||
color + ""
|
color + ""
|
||||||
+ event.getPlayer().getName() + ""
|
+ event.getPlayer().getName() + ""
|
||||||
+ color + ": "
|
+ color + ": "
|
||||||
+ event.getMessage()
|
+ event.getMessage()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onSignChange(final SignChangeEvent event) {
|
void onSignChange(final SignChangeEvent event) {
|
||||||
Set<String> uuids = config.getKeys(false);
|
Set<String> uuids = config.getKeys(false);
|
||||||
ChatColor color = (uuids.contains(event.getPlayer().getUniqueId().toString())) ? ChatColor.YELLOW : ChatColor.AQUA;
|
ChatColor color = (uuids.contains(event.getPlayer().getUniqueId().toString())) ? ChatColor.YELLOW : ChatColor.AQUA;
|
||||||
|
|
||||||
for (String uuidString : uuids) {
|
for (String uuidString : uuids) {
|
||||||
UUID uuid = UUID.fromString(uuidString);
|
UUID uuid = UUID.fromString(uuidString);
|
||||||
|
|
||||||
if (Bukkit.getPlayer(uuid) != null) {
|
if (Bukkit.getPlayer(uuid) != null) {
|
||||||
Bukkit.getPlayer(uuid).sendMessage(
|
Bukkit.getPlayer(uuid).sendMessage(
|
||||||
color + ""
|
color + ""
|
||||||
+ event.getPlayer().getName() + ""
|
+ event.getPlayer().getName() + ""
|
||||||
+ color
|
+ color
|
||||||
+ " created a sign with contents:"
|
+ " 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(color + " " + line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
|
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
|
||||||
|
|
||||||
<suppressions>
|
<suppressions>
|
||||||
<suppress checks="FileTabCharacter" files="."/>
|
|
||||||
<suppress checks="Javadoc" files="."/>
|
<suppress checks="Javadoc" files="."/>
|
||||||
<suppress checks="LineLength" files="."/>
|
<suppress checks="LineLength" files="."/>
|
||||||
</suppressions>
|
</suppressions>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue