Use spaces instead of tabs
This commit is contained in:
parent
849895747e
commit
7762bd56f5
|
@ -19,94 +19,94 @@ import org.bukkit.plugin.Plugin;
|
|||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public final class Main extends JavaPlugin implements CommandExecutor, Listener {
|
||||
private FileConfiguration config;
|
||||
private FileConfiguration config;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
config = getConfig();
|
||||
this.getCommand("commandspy").setExecutor(this);
|
||||
this.getServer().getPluginManager().registerEvents(this, this);
|
||||
}
|
||||
@Override
|
||||
public void onEnable() {
|
||||
config = getConfig();
|
||||
this.getCommand("commandspy").setExecutor(this);
|
||||
this.getServer().getPluginManager().registerEvents(this, this);
|
||||
}
|
||||
|
||||
private void enableCommandSpy(final Player player, final Plugin plugin) {
|
||||
plugin.getConfig().set(player.getUniqueId().toString(), true);
|
||||
plugin.saveConfig();
|
||||
player.sendMessage("Successfully enabled CommandSpy");
|
||||
}
|
||||
private void enableCommandSpy(final Player player, final Plugin plugin) {
|
||||
plugin.getConfig().set(player.getUniqueId().toString(), true);
|
||||
plugin.saveConfig();
|
||||
player.sendMessage("Successfully enabled CommandSpy");
|
||||
}
|
||||
|
||||
private void disableCommandSpy(final Player player, final Plugin plugin) {
|
||||
plugin.getConfig().set(player.getUniqueId().toString(), null);
|
||||
plugin.saveConfig();
|
||||
player.sendMessage("Successfully disabled CommandSpy");
|
||||
}
|
||||
private void disableCommandSpy(final Player player, final Plugin plugin) {
|
||||
plugin.getConfig().set(player.getUniqueId().toString(), null);
|
||||
plugin.saveConfig();
|
||||
player.sendMessage("Successfully disabled CommandSpy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
return true;
|
||||
}
|
||||
|
||||
final Player player = (Player) sender;
|
||||
final JavaPlugin plugin = JavaPlugin.getPlugin(Main.class);
|
||||
final Player player = (Player) sender;
|
||||
final JavaPlugin plugin = JavaPlugin.getPlugin(Main.class);
|
||||
|
||||
if (args.length == 0) {
|
||||
if (config.contains(player.getUniqueId().toString())) {
|
||||
disableCommandSpy(player, plugin);
|
||||
} else {
|
||||
enableCommandSpy(player, plugin);
|
||||
}
|
||||
} else if ("on".equalsIgnoreCase(args[0])) {
|
||||
enableCommandSpy(player, plugin);
|
||||
} else if ("off".equalsIgnoreCase(args[0])) {
|
||||
disableCommandSpy(player, plugin);
|
||||
}
|
||||
config = plugin.getConfig();
|
||||
return true;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
if (config.contains(player.getUniqueId().toString())) {
|
||||
disableCommandSpy(player, plugin);
|
||||
} else {
|
||||
enableCommandSpy(player, plugin);
|
||||
}
|
||||
} else if ("on".equalsIgnoreCase(args[0])) {
|
||||
enableCommandSpy(player, plugin);
|
||||
} else if ("off".equalsIgnoreCase(args[0])) {
|
||||
disableCommandSpy(player, plugin);
|
||||
}
|
||||
config = plugin.getConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
@EventHandler
|
||||
void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> uuids = config.getKeys(false);
|
||||
ChatColor color = (uuids.contains(event.getPlayer().getUniqueId().toString())) ? ChatColor.YELLOW : ChatColor.AQUA;
|
||||
Set<String> uuids = config.getKeys(false);
|
||||
ChatColor color = (uuids.contains(event.getPlayer().getUniqueId().toString())) ? ChatColor.YELLOW : ChatColor.AQUA;
|
||||
|
||||
for (String uuidString : uuids) {
|
||||
UUID uuid = UUID.fromString(uuidString);
|
||||
for (String uuidString : uuids) {
|
||||
UUID uuid = UUID.fromString(uuidString);
|
||||
|
||||
if (Bukkit.getPlayer(uuid) != null) {
|
||||
Bukkit.getPlayer(uuid).sendMessage(
|
||||
color + ""
|
||||
+ event.getPlayer().getName() + ""
|
||||
+ color + ": "
|
||||
+ event.getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Bukkit.getPlayer(uuid) != null) {
|
||||
Bukkit.getPlayer(uuid).sendMessage(
|
||||
color + ""
|
||||
+ event.getPlayer().getName() + ""
|
||||
+ color + ": "
|
||||
+ event.getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onSignChange(final SignChangeEvent event) {
|
||||
Set<String> uuids = config.getKeys(false);
|
||||
ChatColor color = (uuids.contains(event.getPlayer().getUniqueId().toString())) ? ChatColor.YELLOW : ChatColor.AQUA;
|
||||
@EventHandler
|
||||
void onSignChange(final SignChangeEvent event) {
|
||||
Set<String> uuids = config.getKeys(false);
|
||||
ChatColor color = (uuids.contains(event.getPlayer().getUniqueId().toString())) ? ChatColor.YELLOW : ChatColor.AQUA;
|
||||
|
||||
for (String uuidString : uuids) {
|
||||
UUID uuid = UUID.fromString(uuidString);
|
||||
for (String uuidString : uuids) {
|
||||
UUID uuid = UUID.fromString(uuidString);
|
||||
|
||||
if (Bukkit.getPlayer(uuid) != null) {
|
||||
Bukkit.getPlayer(uuid).sendMessage(
|
||||
color + ""
|
||||
+ event.getPlayer().getName() + ""
|
||||
+ color
|
||||
+ " created a sign with contents:"
|
||||
);
|
||||
for (String line: event.getLines()) {
|
||||
Bukkit.getPlayer(uuid).sendMessage(color + " " + line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Bukkit.getPlayer(uuid) != null) {
|
||||
Bukkit.getPlayer(uuid).sendMessage(
|
||||
color + ""
|
||||
+ event.getPlayer().getName() + ""
|
||||
+ color
|
||||
+ " created a sign with contents:"
|
||||
);
|
||||
for (String line: event.getLines()) {
|
||||
Bukkit.getPlayer(uuid).sendMessage(color + " " + line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
|
||||
|
||||
<suppressions>
|
||||
<suppress checks="FileTabCharacter" files="."/>
|
||||
<suppress checks="Javadoc" files="."/>
|
||||
<suppress checks="LineLength" files="."/>
|
||||
</suppressions>
|
||||
|
|
Loading…
Reference in New Issue