/** * Disable god mode for a player. * * @param player The player to disable godmode for */ public void disableGodMode(Player player) { player.removeMetadata(METADATA_KEY, CommandBook.inst()); }
@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 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(); } }
@Override public void enable() { CommandBook.inst().createDefaultConfiguration("kits.txt"); // Setup kits kits = new FlatFileKitsManager(new File(CommandBook.inst().getDataFolder(), "kits.txt")); kits.load(); CommandBook.server().getScheduler().scheduleAsyncRepeatingTask( CommandBook.inst(), new GarbageCollector(this), GarbageCollector.CHECK_FREQUENCY, GarbageCollector.CHECK_FREQUENCY); registerCommands(Commands.class); CommandBook.registerEvents(this); }
@EventHandler public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); if (!player.hasPlayedBefore()) { for (Entry<String, Kit> map : kits.getKits().entrySet()) { if (CommandBook.inst().hasPermission(player, "commandbook.kits.onfirstlogin." + map.getKey())) { map.getValue().distribute(player); } } } }
/** * Enable god mode for a player. * * @param player The player to enable godmode for */ public void enableGodMode(Player player) { if (!hasGodMode(player)) { player.setMetadata(METADATA_KEY, new FixedMetadataValue(CommandBook.inst(), true)); } }
@Override public void enable() { spawns = new WrappedSpawnManager(new File(CommandBook.inst().getDataFolder(), "spawns.yml")); config = configure(new LocalConfiguration()); registerCommands(Commands.class); CommandBook.registerEvents(this); }
public void remove(String name, World world, CommandSender sender) throws CommandException { NamedLocation loc = getManager().get(world, name); if (loc == null) { throw new CommandException("No " + this.name.toLowerCase() + " by that name could be found in " + world.getName() + "."); } if (!(sender instanceof Player) || !((Player) sender).getUniqueId().equals(loc.getCreatorID())) { CommandBook.inst().checkPermission(sender, "commandbook." + this.name.toLowerCase() + ".remove.other"); } getManager().remove(world, name); sender.sendMessage(ChatColor.YELLOW + this.name + ": " + name.toUpperCase() + " removed."); }
@EventHandler public void playerChangedWorld(PlayerChangedWorldEvent event) { if (!CommandBook.inst().hasPermission(event.getPlayer(), "commandbook.god")) { disableGodMode(event.getPlayer()); } }
@Command(aliases = {"save"}, usage = "", desc = "Save CommandBook's settings", min = 0, max = 0) @CommandPermissions({"commandbook.save"}) public static void save(CommandContext args, CommandSender sender) throws CommandException { CommandBook.inst().getGlobalConfiguration().save(); sender.sendMessage(ChatColor.YELLOW + "CommandBook's configuration has been reloaded."); }
@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"); }
public synchronized void lock(World world) { long time = world.getFullTime(); unlock(world); int id = CommandBook.server().getScheduler().scheduleSyncRepeatingTask( CommandBook.inst(), new TimeLocker(world, time), 20, config.timeLockDelay); tasks.put(world.getName(), id); }
@Override public void enable() { registerCommands(Commands.class); CommandBook.registerEvents(this); CommandBook.server().getScheduler().scheduleSyncRepeatingTask(CommandBook.inst(), this, 20 * 2, 20 * 2); }
@Override public void run() { if (CommandBook.inst().hasPermission(player, "commandbook.flight.onjoin")) { FlightSession session = sessions.getSession(FlightSession.class, player); player.setAllowFlight(session.canFly = true); //noinspection deprecation if (!player.isOnGround()) { player.setFlying(true); } } } }, 1);
@Override public void enable() { LocalConfiguration config = configure(new LocalConfiguration()); LocationManagerFactory<LocationManager<NamedLocation>> warpsFactory = new FlatFileLocationsManager.LocationsFactory(CommandBook.inst().getDataFolder(), name + "s"); manager = new RootLocationManager<NamedLocation>(warpsFactory, config.perWorld); CommandBook.registerEvents(new WorldListener()); }
@EventHandler public void playerWhois(InfoComponent.PlayerWhoisEvent event) { if (event.getPlayer() instanceof Player) { if (CommandBook.inst().hasPermission(event.getSource(), "commandbook.god.check")) { event.addWhoisInformation(null, "Player " + (hasGodMode((Player) event.getPlayer()) ? "has" : "does not have") + " god mode"); } } }
@Override public void enable() { config = configure(new LocalConfiguration()); // Setup the ban database bans = new CSVBanDatabase(CommandBook.inst().getDataFolder()); bans.load(); CommandBook.registerEvents(this); registerCommands(Commands.class); }
@EventHandler public void playerWhois(InfoComponent.PlayerWhoisEvent event) { if (CommandBook.inst().hasPermission(event.getSource(), "commandbook.bans.isbanned")) { event.addWhoisInformation(null, "Player " + (getBanDatabase().isBanned(event.getPlayer().getUniqueId()) ? "is" : "is not") + " banned."); } }
@EventHandler public void onPlayerworldChange(PlayerChangedWorldEvent event) { Player player = event.getPlayer(); FlightSession session = sessions.getSession(FlightSession.class, player); if (config.checkWorldChange && player.getGameMode() != GameMode.CREATIVE && !CommandBook.inst().hasPermission(player, "commandbook.flight." + player.getWorld().getName())) { player.setAllowFlight(session.canFly = false); } } }