public void Load() { IgnorePlayer player = null; try (FileReader fr = new FileReader(igFile); JsonReader reader = new JsonReader(fr)) { reader.beginArray(); // begin players array while (reader.hasNext()) { reader.beginObject(); // begin player object while (reader.hasNext()) { String name = reader.nextName(); if (name.equalsIgnoreCase("uuid")) { UUID uuid = UUID.fromString(reader.nextString()); player = new IgnorePlayer(this, uuid); } else if (name.equalsIgnoreCase("ignoreall")) { if (reader.nextBoolean()) { player.toggleAllIgnore(false); } } else if (name.equalsIgnoreCase("ignores")) { reader.beginArray(); // begin ignores array while (reader.hasNext()) { reader.beginObject(); // begin ignored player object String n = reader.nextName(); if (n.equalsIgnoreCase("uuid")) { UUID ignoredUuid = UUID.fromString(reader.nextString()); if (ignoredUuid != null) { player.ignorePlayer(ignoredUuid, false); } } reader.endObject(); // end ignored player object } reader.endArray(); // end ignores array } } reader.endObject(); // end player object playerIgnoreList.add(player); } reader.endArray(); // end players array } catch (EOFException optional) { // Ignore. } catch (IOException e) { PickleCraftPlugin.log.warning(e.getMessage()); } }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Player player = null; if (sender instanceof Player) { player = (Player) sender; } /* * ignore command. */ if (command.getName().equalsIgnoreCase("ignore")) { if (player != null) { if (PickleCraftPlugin.hasPerm(player, command.getPermission())) { if (args.length >= 1) { if (args.length >= 2) { /* * flags */ if (args[0].equalsIgnoreCase("-r")) { // remove ignore flag Object[] playerAndbool = PickleCraftPlugin.getPlayer(args[1]); Player p = (Player) playerAndbool[0]; if (p != null) { if ((Boolean) playerAndbool[1] == false) { IgnorePlayer igP = getIgnorePlayer(player); if (igP != null) { igP.unignorePlayer(p.getUniqueId(), true); } else { player.sendMessage( plugin.getStringFromConfig( "ignorecraft.messages.errors.isnotignored", p.getName())); } } else { player.sendMessage( plugin.getStringFromConfig( "common.messages.errors.tomanyplayers", args[1])); } return true; } else { player.sendMessage( plugin.getStringFromConfig( "common.messages.errors.playerdontexist", args[1])); } } } else { Object[] playerAndbool = PickleCraftPlugin.getPlayer(args[0]); Player p = (Player) playerAndbool[0]; if (p != null) { if ((Boolean) playerAndbool[1] == false) { IgnorePlayer igP = getIgnorePlayer(player); if (igP != null) { igP.ignorePlayer(p.getUniqueId(), true); } else { igP = new IgnorePlayer(this, player.getUniqueId()); igP.ignorePlayer(p.getUniqueId(), true); playerIgnoreList.add(igP); } } else { player.sendMessage( plugin.getStringFromConfig("common.messages.errors.tomanyplayers", args[0])); } } else { player.sendMessage( plugin.getStringFromConfig("common.messages.errors.playerdontexist", args[0])); } return true; } } } else { player.sendMessage(plugin.getStringFromConfig("common.messages.errors.donthaveperm")); return true; } } else { sender.sendMessage("This is a player only command."); return true; } } /* * ignoreall command */ else if (command.getName().equalsIgnoreCase("ignoreall")) { // all ignore if (player != null) { if (PickleCraftPlugin.hasPerm(player, command.getPermission())) { IgnorePlayer igP = getIgnorePlayer(player); if (igP != null) { igP.toggleAllIgnore(true); } else { igP = new IgnorePlayer(this, player.getUniqueId()); igP.toggleAllIgnore(true); playerIgnoreList.add(igP); } } else { player.sendMessage(plugin.getStringFromConfig("common.messages.errors.donthaveperm")); } } else { sender.sendMessage("This is a player only command."); } return true; } /* * display ignore list */ else if (command.getName().equalsIgnoreCase("ignorelist")) { // displays ignore list if (player != null) { IgnorePlayer igP = getIgnorePlayer(player); if (igP != null) { listIgnores(igP); } } else { sender.sendMessage("This is a player only command."); } return true; } return false; }