@Command(aliases = {"reload"}, usage = "", desc = "Reload CommandBook's settings", min = 0, max = 0) @CommandPermissions({"commandbook.reload"}) public static void reload(CommandContext args, CommandSender sender) throws CommandException { try { CommandBook.inst().getGlobalConfiguration().load(); } catch (IOException e) { sender.sendMessage(ChatColor.RED + "Error reolading configuration: " + e.getMessage()); sender.sendMessage(ChatColor.RED + "See console for details!"); CommandBook.logger().log(Level.WARNING, "Error reloading configuration: " + e, e); } CommandBook.inst().loadConfiguration(); CommandBook.inst().getComponentManager().reloadComponents(); sender.sendMessage(ChatColor.YELLOW + "CommandBook's configuration has been reloaded."); }
public static Iterable<Player> detectTargets(CommandSender sender, CommandContext args, String perm) throws CommandException { List<Player> targets; // Detect targets based on the number of arguments provided if (args.argsLength() == 0) { targets = Lists.newArrayList(PlayerUtil.checkPlayer(sender)); } else { targets = InputUtil.PlayerParser.matchPlayers(sender, args.getString(0)); } InputUtil.PlayerParser.checkPlayerMatch(targets); // Check permissions! for (Player player : targets) { if (player.equals(sender)) { CommandBook.inst().checkPermission(sender, perm); } else { CommandBook.inst().checkPermission(sender, perm + ".other"); break; } } return targets; }
private boolean checkAutoEnable(Player player) { if (config.autoEnable && (CommandBook.inst().getPermissionsResolver() .inGroup(player, "cb-invincible") || CommandBook.inst().hasPermission(player, "commandbook.god.auto-invincible"))) { enableGodMode(player); return true; } return false; }
@Override public void enable() { CommandBook.server().getScheduler().scheduleSyncRepeatingTask(CommandBook.inst(), this, CHECK_FREQUENCY, CHECK_FREQUENCY); CommandBook.registerEvents(this); registerCommands(Commands.class); sessionsDir = new File(CommandBook.inst().getDataFolder(), "sessions"); if (!sessionsDir.exists()) { sessionsDir.mkdirs(); } }
CommandBook.inst().checkPermission(sender, "commandbook.kit.list"); if (!CommandBook.inst().hasPermission(sender, "commandbook.kit.kits." + id.replace(".", ""))) { continue; if (player != sender) { CommandBook.inst().checkPermission(sender, "commandbook.kit.other"); CommandBook.inst().checkPermission(sender, "commandbook.kit.kits." + id.replace(".", ""));
&& CommandBook.inst().hasPermission(sender, "commandbook.bans.exempt.override"); Player player; banID = CommandBook.server().getOfflinePlayer(playerName).getUniqueId(); banID = player.getUniqueId(); if (CommandBook.inst().hasPermission(player, "commandbook.bans.exempt") && !hasExemptOverride) { throw new CommandException("This player is exempt from being banned! " + "(use -o flag to override if you have commandbook.bans.exempt.override)"); CommandBook.inst().checkPermission(sender, "commandbook.bans.ban.ip"); banAddress = player.getAddress().getAddress(); for (Player aPlayer : CommandBook.server().getOnlinePlayers()) { if (aPlayer.getAddress().getAddress().equals(banAddress)) { player.kickPlayer(message == null ? "Banned!" : message); CommandBook.server().broadcastMessage(ChatColor.YELLOW + ChatUtil.toColoredName(sender, ChatColor.YELLOW) + " has banned " + playerName + (message == null ? "" : " - " + message));
if (CommandBook.server().getOnlinePlayers().isEmpty()) { throw new CommandException("No players matched query."); CommandBook.inst().checkPermission(source, "commandbook.targets.everyone"); return checkPlayerMatch(Lists.newArrayList(CommandBook.server().getOnlinePlayers())); CommandBook.inst().checkPermission(source, "commandbook.targets.world." + sourceWorld.getName()); return checkPlayerMatch(sourceWorld.getPlayers()); CommandBook.inst().checkPermission(source, "commandbook.targets.near"); List<Player> players = new ArrayList<Player>(); Player sourcePlayer = checkPlayer(source); for (Player player : CommandBook.server().getOnlinePlayers()) { if (!player.getWorld().equals(sourceWorld)) continue; if (player.getLocation(k).distanceSquared(sourceLocation) < targetDistance) {
@Override public void enable() { spawns = new WrappedSpawnManager(new File(CommandBook.inst().getDataFolder(), "spawns.yml")); config = configure(new LocalConfiguration()); registerCommands(Commands.class); CommandBook.registerEvents(this); }
CommandBook.inst().checkPermission(source, "commandbook.locations.coords"); CommandBook.inst().checkPermission(source, "commandbook.spawn"); if (args.length > 1) { return Lists.newArrayList(matchWorld(source, args[1]).getSpawnLocation()); CommandBook.inst().checkPermission(source, "commandbook.locations.target"); Player player = checkPlayer(source); Location playerLoc = player.getLocation(); || args[0].equalsIgnoreCase("#warp")) { String type = args[0].substring(1); CommandBook.inst().checkPermission(source, "commandbook.locations." + type); LocationsComponent component = type.equalsIgnoreCase("warp") ? CommandBook.inst().getComponentManager().getComponent(WarpsComponent.class) : CommandBook.inst().getComponentManager().getComponent(HomesComponent.class); if (component == null) { throw new CommandException("This type of location is not enabled!"); NamedLocation loc = manager.get(player.getWorld(), args[1]); if (loc != null && !(loc.getCreatorName().equalsIgnoreCase(player.getName()))) { CommandBook.inst().checkPermission(source, "commandbook.locations." + type + ".other"); NamedLocation loc = manager.get(matchWorld(source, args[2]), args[1]); if (loc != null && !(loc.getCreatorName().equalsIgnoreCase(player.getName()))) { CommandBook.inst().checkPermission(source, "commandbook.locations." + type + ".other");
CommandBook.inst().checkPermission(sender, "commandbook.midi.other"); break; CommandBook.inst().checkPermission(sender, "commandbook.midi"); new File(CommandBook.inst().getDataFolder(), "midi/" + filename), new File(CommandBook.inst().getDataFolder(), "midi/" + filename + ".mid"), new File(CommandBook.inst().getDataFolder(), "midi/" + filename + ".midi"), new File("midi", filename), new File("midi", filename + ".mid"),
@EventHandler public void onJoin(PlayerJoinEvent event) { MidiJingleSequencer sequencer; try { File file = new File(CommandBook.inst().getDataFolder(), "intro.mid"); if (file.exists()) { sequencer = new MidiJingleSequencer(file, false); getJingleNoteManager().play(event.getPlayer().getName(), sequencer); } } catch (MidiUnavailableException e) { CommandBook.logger().log(Level.WARNING, "Failed to access MIDI: " + e.getMessage()); } catch (InvalidMidiDataException e) { CommandBook.logger().log(Level.WARNING, "Failed to read intro MIDI file: " + e.getMessage()); } catch (FileNotFoundException ignored) { } catch (IOException e) { CommandBook.logger().log(Level.WARNING, "Failed to read intro MIDI file: " + e.getMessage()); } }
/** * Loads the configuration. */ @Override public YAMLProcessor createConfiguration() { final File configFile = new File(getDataFolder(), "config.yml"); YAMLProcessor config = new YAMLProcessor(configFile, true, YAMLFormat.EXTENDED); YAMLProcessor comments = new DefaultsFileYAMLProcessor("config-comments.yml", false); try { if (!configFile.exists()) { configFile.getParentFile().mkdirs(); configFile.createNewFile(); } config.load(); comments.load(); } catch (Exception e) { getLogger().log(Level.WARNING, "Error loading configuration: ", e); } for (Map.Entry<String, Object> e : comments.getMap().entrySet()) { if (e.getValue() != null) { config.setComment(e.getKey(), e.getValue().toString()); } } // Migrate the old configuration, if we need to final String result = new LegacyCommandBookConfigurationMigrator(configFile, config).migrate(); if (result != null) { logger().severe("Error migrating CommandBook configuration: " + result); } return config; }
if (config.playersListMaxPlayers) { out.append("/"); out.append(CommandBook.server().getMaxPlayers()); String[] playerGroups = CommandBook.inst().getPermissionsResolver().getGroups( player.getName()); String group = playerGroups.length > 0 ? playerGroups[0] : "Default"; if (CommandBook.inst().useDisplayNames) { out.append(player.getDisplayName()).append(ChatColor.WHITE); } else { if (CommandBook.inst().useDisplayNames) { out.append(player.getDisplayName()).append(ChatColor.WHITE); } else {
@CommandPermissions({"commandbook.who"}) public void who(CommandContext args, CommandSender sender) throws CommandException { Collection<? extends Player> online = CommandBook.server().getOnlinePlayers(); if (!(sender instanceof Player) && CommandBook.inst().crappyWrapperCompat) { StringBuilder out = new StringBuilder(); out.append(CommandBook.inst().useDisplayNames ? player.getDisplayName() : player.getName()); out.append(ChatColor.WHITE); CommandBook.callEvent(new OnlineListSendEvent(sender)); CommandBook.server().getOnlinePlayers(), sender); return;
return entry.getInformation().friendlyName() + " - " + entry.getInformation().desc(); }.display(sender, CommandBook.inst().getComponentManager().getComponents(), args.getFlagInteger('p', 1)); AbstractComponent component = CommandBook.inst().getComponentManager().getComponent(componentName); if (component == null) { throw new CommandException("No such component: " + componentName);
@Override public void enable() { config = configure(new LocalConfiguration()); File helpFile = new File(CommandBook.inst().getDataFolder(), config.helpFile); if (!helpFile.getParentFile().exists() || !helpFile.getParentFile().isDirectory()) helpFile.getParentFile().mkdirs(); if (!helpFile.exists() || !helpFile.isFile()) try { helpFile.createNewFile(); } catch (IOException ignored) {} help = new YAMLProcessor(helpFile, true, YAMLFormat.EXTENDED); reloadMessages(); registerCommands(HelpCommands.class); }
@Override public void populateConfiguration(YAMLProcessor config) { loadItemList(config); useDisplayNames = config.getBoolean("use-display-names", true); lookupWithDisplayNames = config.getBoolean("lookup-with-display-names", true); broadcastChanges = config.getBoolean("broadcast-changes", true); crappyWrapperCompat = config.getBoolean("crappy-wrapper-compat", true); if (crappyWrapperCompat) { getLogger().info("Maximum wrapper compatibility is enabled. " + "Some features have been disabled to be compatible with " + "poorly written server wrappers."); } }
@Command(aliases = {"version"}, usage = "", desc = "CommandBook version information", min = 0, max = 0) public static void version(CommandContext args, CommandSender sender) throws CommandException { sender.sendMessage(ChatColor.YELLOW + "CommandBook " + CommandBook.inst().getDescription().getVersion()); sender.sendMessage(ChatColor.YELLOW + "http://www.sk89q.com"); }