public void deleteRegion(Player player, String[] args) { if (args.length != 2) { player.sendMessage(ChatColor.RED + "Wrong usage. /pr help"); return; } String id = "icp_" + player.getName() + "_" + args[1]; World world = player.getWorld(); LocalPlayer localPlayer = plugin.wrapPlayer(player); RegionManager mgr = plugin.getGlobalRegionManager().get(world); ProtectedRegion region = mgr.getRegion(id); if (region == null) { player.sendMessage(ChatColor.RED + "Could not find a region by that name."); return; } if (region.isOwner(localPlayer)) { mgr.removeRegion(id); player.sendMessage(ChatColor.YELLOW + "Region " + args[1] + " removed."); try { mgr.save(); } catch (IOException e) { player.sendMessage( ChatColor.RED + "(shouldn't happen) Failed to write regions file: " + e.getMessage()); } } }
public static void enchantValidate(Player p, String e, int rlvl) { // shut up for now :P HashMap<Enchantment, Integer> fen = new HashMap<Enchantment, Integer>(); ItemStack i = null; int lvl = 0; Enchantment en = Enchantment.getById(getEnchantId(e)); if (p.getItemInHand().getTypeId() == ((ItemStack) item.get(p.getName())).getTypeId()) { i = p.getItemInHand(); if (i.getAmount() == 1) { if (i.containsEnchantment(en)) { int plvl = i.getEnchantmentLevel(en); lvl = plvl + rlvl; } else { lvl = rlvl; } fen.put(en, lvl); enchants.put(p.getName(), fen); ChatListener.add(p, 2); p.sendMessage( "The enchant will cost you: " + getEnchantCost(p, e.toLowerCase(), rlvl) + "! Should I continue? Please type \"yes\" or \"no\"!"); } else { p.sendMessage( ChatColor.RED + "You have more then one item in your slot, please try again!"); } } }
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { Player player = null; if (sender instanceof Player) { player = (Player) sender; } if (player == null) { sender.sendMessage("Sorry, only Players can use such commands!"); return true; } else if (cmd.getName().equalsIgnoreCase("tk")) { if (args.length < 2 || !hasAdminAccess(sender)) { return false; } Player target = Bukkit.getPlayer(args[0]); String message = args[1]; for (Player players : getServer().getOnlinePlayers()) { if (target.isOnline()) { String s; if (target.isOp()) { String pname = ChatColor.DARK_RED + target.getDisplayName(); s = "[" + target.getWorld().getName() + "]<" + pname + ChatColor.WHITE + "> " + message; players.sendMessage(s); } else { s = "[" + target.getWorld().getName() + "]<" + target.getDisplayName() + "> " + message; players.sendMessage(s); } return true; } else { players.sendMessage("[world]<" + args[0] + "> " + message); return true; } } } return false; }
@Command( aliases = {"wp", "waypoint"}, usage = "modifier [type]", desc = "add a modifier", modifiers = {"modifier", "mod"}, min = 2, max = 2) public static void modifier(CommandContext args, Player player, HumanNPC npc) { if (!NPCDataManager.pathEditors.containsKey(player.getName())) { player.sendMessage(ChatColor.GRAY + "You must be editing your NPC's path."); return; } WaypointModifierType modifier = WaypointModifierType.value(args.getString(1).toUpperCase()); if (modifier == null) { player.sendMessage(ChatColor.GRAY + "Invalid modifier type."); return; } if (!PermissionManager.generic( player, "citizens.waypoints.modifier" + modifier.name().toLowerCase())) { player.sendMessage(MessageUtils.noPermissionsMessage); return; } player.sendMessage( ChatColor.AQUA + StringUtils.listify( StringUtils.wrap(StringUtils.capitalise(modifier.name().toLowerCase())) + " chat editor" + ChatColor.AQUA)); Waypoint waypoint = npc.getWaypoints().getLast(); ConversationUtils.addConverser(player, modifier.create(waypoint)); }
@Override public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args) { if (!(sender instanceof Player)) { plugin.getLogger().info("You can not execute this command while not in game."); return false; } Player player = (Player) sender; if (plugin.getGm().isInGame()) { player.sendMessage(ChatColor.RED + "You can not use this command while in game."); } if (CommandLabel.equalsIgnoreCase("vote")) { if (args.length == 0) { plugin.getVh().listMap(player); } else if (args.length == 1) { plugin.getVh().vote(player, args[0]); } else if (args.length == 2) { plugin.getVh().vote(player, args[0], args[1]); } else { player.sendMessage("Too many arguments."); } } return false; }
public void setHalted(boolean halted) { this.isHalted = halted; if (halted) { player.setOp(false); player.setGameMode(GameMode.SURVIVAL); TFM_Util.setFlying(player, false); TFM_EssentialsBridge.setNickname(player.getName(), player.getName()); player.closeInventory(); player.setTotalExperience(0); stopOrbiting(); setFrozen(true); setMuted(true); player.sendMessage(ChatColor.GRAY + "You have been halted, don't move!"); } else { player.setOp(true); player.setGameMode(GameMode.CREATIVE); setFrozen(false); setMuted(false); player.sendMessage(ChatColor.GRAY + "You are no longer halted."); } }
/** Removes chests when they're destroyed. */ @EventHandler(priority = EventPriority.HIGHEST) public void onBreak(final BlockBreakEvent e) { if (e.isCancelled()) return; Block b = e.getBlock(); Player p = e.getPlayer(); // If the chest was a chest if (b.getType() == Material.CHEST) { Shop shop = plugin.getShopManager().getShop(b.getLocation()); // If it was a shop if (shop != null) { if (plugin.lock) { // If they owned it or have bypass perms, they can destroy it if (!shop.getOwner().equalsIgnoreCase(p.getName()) && !p.hasPermission("quickshop.other.destroy")) { e.setCancelled(true); p.sendMessage(MsgUtil.getMessage("no-permission")); return; } } // If they're either survival or the owner, they can break it if (p.getGameMode() == GameMode.CREATIVE && !p.getName().equalsIgnoreCase(shop.getOwner())) { e.setCancelled(true); p.sendMessage(MsgUtil.getMessage("no-creative-break")); return; } // Cancel their current menu... Doesnt cancel other's menu's. Info action = plugin.getShopManager().getActions().get(p.getName()); if (action != null) { action.setAction(ShopAction.CANCELLED); } shop.delete(); p.sendMessage(MsgUtil.getMessage("success-removed-shop")); } } else if (b.getType() == Material.WALL_SIGN) { Shop shop = getShopNextTo(e.getBlock().getLocation()); if (shop != null) { // It is a shop sign we're dealing with. if (plugin.lock) { // If they're the shop owner or have bypass perms, they can destroy it. if (!shop.getOwner().equalsIgnoreCase(p.getName()) && !e.getPlayer().hasPermission("quickshop.other.destroy")) { e.setCancelled(true); p.sendMessage(MsgUtil.getMessage("no-permission")); return; } } // If they're in creative and not the owner, don't let them (accidents happen) if (p.getGameMode() == GameMode.CREATIVE && !p.getName().equalsIgnoreCase(shop.getOwner())) { e.setCancelled(true); p.sendMessage(MsgUtil.getMessage("no-creative-break")); return; } } } }
/* (non-Javadoc) * @see org.bukkit.event.player.PlayerListener#onPlayerInteract(org.bukkit.event.player.PlayerInteractEvent) */ @Override public void onPlayerInteract(PlayerInteractEvent event) { Block clicked = event.getClickedBlock(); Player player = event.getPlayer(); if (clicked != null && (clicked.getType() == Material.STONE_BUTTON || clicked.getType() == Material.LEVER)) { if (!this.ButtonLeverHit(player, clicked, null)) { event.setCancelled(true); } } else if (clicked != null && clicked.getType() == Material.WALL_SIGN) { Stargate stargate = StargateManager.getGateFromBlock(clicked); if (stargate != null) { if (WXPermissions.checkWXPermissions(player, stargate, PermissionType.SIGN)) { if (stargate.TryClickTeleportSign(clicked)) { String target = ""; if (stargate.SignTarget != null) { target = stargate.SignTarget.Name; } player.sendMessage("Dialer set to: " + target); } } else { player.sendMessage(ConfigManager.output_strings.get(StringTypes.PERMISSION_NO)); event.setCancelled(true); } } } }
/** * Toggles stealth login/logoff mode * * @param player */ public void stealth(Player player) { String playerName = player.getName(); // Check permissions to use the command if (AdminPermissions.has(player, Perms.STEALTH)) { // If the player is already stealthed, disable and send them a message if (AdminHandler.isStealthed(playerName)) { AdminHandler.setStealthed(playerName, false); AdminHandler.fakeLog(playerName, true); player.sendMessage( ChatColor.RED + "Stealth-Mode " + ChatColor.WHITE + "is now " + ChatColor.RED + "disabled."); } else { // Check if this player is in the admin map - add if necessary if (!AdminHandler.contains(playerName)) AdminHandler.add(playerName); // Now enable stealth mode and send the messages AdminHandler.setStealthed(playerName, true); AdminHandler.fakeLog(playerName, false); player.sendMessage( ChatColor.GREEN + "Stealth-Mode " + ChatColor.WHITE + "is now " + ChatColor.GREEN + "enabled."); } AdminHandler.savePlayer(playerName); } else { // If they don't have permissions let them know AdminPermissions.noPermsMessage(player); } }
public void listRegionBackups(Region r, String region, Player p) { if (r == null) { p.sendMessage( ChatColor.RED + "[Regios] The region to inherit : " + ChatColor.BLUE + region + ChatColor.RED + " does not exist!"); return; } File f = r.getBackupsDirectory(); if (f.listFiles().length < 1) { p.sendMessage( ChatColor.RED + "[Regios] The region " + ChatColor.BLUE + region + ChatColor.RED + " has no backups!"); } else { StringBuilder sb = new StringBuilder(); for (File backup : f.listFiles()) { sb.append(ChatColor.WHITE) .append(backup.getName().substring(0, backup.getName().lastIndexOf("."))) .append(ChatColor.BLUE) .append(", "); } p.sendMessage(sb.toString()); return; } }
public void setOwner(Region r, String name, String owner, Player p) { if (r == null) { p.sendMessage( ChatColor.RED + "[Regios] The region to inherit : " + ChatColor.BLUE + name + ChatColor.RED + " does not exist!"); return; } if (!r.canModify(p)) { p.sendMessage(ChatColor.RED + "[Regios] You are not permitted to modify this region!"); return; } mutable.setOwner(r, owner); p.sendMessage( ChatColor.GREEN + "[Regios] Owner for region " + ChatColor.BLUE + name + ChatColor.GREEN + " changed to " + ChatColor.BLUE + owner); }
@EventHandler public static void onPlayerMove(PlayerMoveEvent e) { Player player = e.getPlayer(); Location locTo = e.getTo(); Location locFrom = e.getFrom(); if (PBMethods.WGSupportEnabled) { if (PBMethods.getWorldGuard() != null) { ApplicableRegionSet set = WGBukkit.getRegionManager(locTo.getWorld()).getApplicableRegions(locTo); for (ProtectedRegion region : set) { if (region != null) { // Checks if the player can enter the field during a Probending Match if (region.getId().equalsIgnoreCase(PBMethods.ProbendingField)) { if (PBMethods.matchStarted) { String teamName = PBMethods.getPlayerTeam(player.getUniqueId()); if (teamName != null) { if (!PBMethods.playingTeams.contains(teamName.toLowerCase())) { player.sendMessage(Strings.Prefix + Strings.CantEnterField); player.teleport(locFrom); e.setCancelled(true); } } if (teamName == null) { player.sendMessage(Strings.Prefix + Strings.CantEnterField); player.teleport(locFrom); e.setCancelled(true); } } } } } } } }
public ListGames( Player player, String label, String[] args, FileConfiguration fileConfiguration) { if (GetGames.getGameNames(fileConfiguration) != null) { String[] games = GetGames.getGameNames(fileConfiguration); int i = 0; int imax = games.length; player.sendMessage( ConstantHolder.RAGEMODE_PREFIX + "Listing all available ragemode games..."); while (i < imax) { if (PlayerList.isGameRunning(games[i])) { player.sendMessage( i + 1 + ".) " + games[i] + ChatColor.GOLD.toString() + ChatColor.ITALIC.toString() + " running"); } else { player.sendMessage(i + 1 + ".) " + games[i] + ChatColor.GRAY + " idle"); } i++; } } else { player.sendMessage( ConstantHolder.RAGEMODE_PREFIX + "There are currently no RageMode maps on this server."); } }
public void regionPrice(Player player, String[] args) { Selection sel = worldEdit.getSelection(player); if (sel == null) { player.sendMessage(ChatColor.RED + "Select a region with a wooden axe first."); return; } ProtectedRegion region = null; String id = "icp__tempregion"; if (sel instanceof Polygonal2DSelection) { Polygonal2DSelection polySel = (Polygonal2DSelection) sel; int minY = polySel.getNativeMinimumPoint().getBlockY(); int maxY = polySel.getNativeMaximumPoint().getBlockY(); region = new ProtectedPolygonalRegion(id, polySel.getNativePoints(), minY, maxY); } else if (sel instanceof CuboidSelection) { BlockVector min = sel.getNativeMinimumPoint().toBlockVector(); BlockVector max = sel.getNativeMaximumPoint().toBlockVector(); region = new ProtectedCuboidRegion(id, min, max); } else { player.sendMessage( ChatColor.RED + "(shouldn't happen) Something went wrong. The type of region selected is unsupported!"); return; } double cost = (int) Math.ceil(econ.getCost(region.volume())); player.sendMessage(ChatColor.AQUA + "That region will cost you $" + cost + "."); }
@Command( aliases = {"dispenser"}, usage = "<nom_distributeur>", desc = "Information sur un distributeur.", min = 1, max = 1) @CommandPermissions({"mho.donjon.admin"}) public void dispenser(CommandContext args, CommandSender sender) { Player player = null; if (sender instanceof Player) { player = (Player) sender; } else { return; } String donjon = Manager.getDonjon().getDonjon(player.getName()); String dispenser = args.getString(0).toLowerCase(); if (Manager.getDonjon().existDonjon(donjon)) { if (Manager.getDonjon().existDispenser(donjon, dispenser)) { player.sendMessage( "Information du Distributeur: " + ChatColor.GREEN + dispenser + ChatColor.RESET); player.sendMessage(Manager.getDonjon().infoLocationDispenser(donjon, dispenser)); String[] items = Manager.getDonjon().infoItemsDispenser(donjon, dispenser); for (String item : items) { player.sendMessage("Item: " + item); } } else { player.sendMessage(ChatColor.RED + "Le distributeur n'existe pas." + ChatColor.RESET); } } else { player.sendMessage(ChatColor.RED + "Le donjon n'existe pas." + ChatColor.RESET); } }
private void heal(Player player, String[] args) { if (!AdminPermissions.has(player, Perms.ADMINHEAL) && !AdminPermissions.has(player, Perms.ANYHEAL)) { player.sendMessage("You don't have permission to use that command."); return; } else if (!AdminHandler.isAdminMode(player.getName()) && !AdminPermissions.has(player, Perms.ANYHEAL)) { player.sendMessage("You must be in admin mode to heal players."); return; } else if (args.length == 0) { heal(player, player, true); return; } if (args[0].equalsIgnoreCase("all")) { for (Player target : plugin.getServer().getOnlinePlayers()) heal(player, target, false); player.sendMessage("You have healed all online players."); return; } List<String> players = new ArrayList<String>(); for (Player target : plugin.getServer().getOnlinePlayers()) { if (target.getName().contains(args[0])) { heal(player, target, false); players.add(target.getName()); } } if (players.isEmpty()) player.sendMessage("Could not find any players named " + args[0] + "."); else { String message = "You have healed:"; for (String pName : players) message += " " + pName; player.sendMessage(message); } }
private void displayCommand(Command c, Player p) { p.sendMessage("-------------Command Arguments---------------"); p.sendMessage("--------------------------------------------"); for (Argument arg : c.listArguments()) { p.sendMessage(arg.toString()); } }
@EventHandler public void onPlayerDeath(PlayerDeathEvent e) { Player p = e.getEntity(); Player k = p.getKiller(); if (k instanceof Player && p instanceof Player) { if (FileUtils.hasBounty(p.getName())) { p.sendMessage( config .getString("bountyVictim") .replace("%prefix", config.getString("Prefix")) .replace("%target", k.getName()) .replace("&", "¤")); k.sendMessage( config .getString("bountyMurderer") .replace("%prefix", config.getString("Prefix")) .replace("%target", p.getName()) .replace("&", "¤")); Bountys.economy.depositPlayer(k, FileUtils.getBounty(p.getName())); FileUtils.removeBounty(p.getName()); } } }
/** * Process the Shroom Thumb ability. * * @param blockState The {@link BlockState} to check ability activation for * @return true if the ability was successful, false otherwise */ public boolean processShroomThumb(BlockState blockState) { Player player = getPlayer(); PlayerInventory playerInventory = player.getInventory(); if (!playerInventory.contains(Material.BROWN_MUSHROOM)) { player.sendMessage( LocaleLoader.getString( "Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM))); return false; } if (!playerInventory.contains(Material.RED_MUSHROOM)) { player.sendMessage( LocaleLoader.getString( "Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM))); return false; } playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM)); playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM)); player.updateInventory(); if (!SkillUtils.activationSuccessful( SecondaryAbility.SHROOM_THUMB, getPlayer(), getSkillLevel(), activationChance)) { player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail")); return false; } return Herbalism.convertShroomThumb(blockState); }
public static boolean goCMD(Player player, String[] args) { if (args.length == 1) { int id; try { id = Integer.parseInt(args[0]); } catch (NumberFormatException e) { player.sendMessage(RED + "That value is not an ID number."); return true; } Report report = WorldReport.reports.get(id); if (report == null) { player.sendMessage(RED + "Specified report doesn't exist."); } else { player.teleport(report.getLocation()); if (player.getLocation().equals(report.getLocation())) { player.sendMessage( WorldReport.colorString( "&eYou have been teleported to the report number &6" + id + "&e location.")); } } } else { player.sendMessage(RED + "Wrong command syntaxis, go <report id>"); } return true; }
@EventHandler public void onHit(EntityDamageByEntityEvent e) { if (e.getEntity() instanceof Player) { Player p = (Player) e.getEntity(); if (e.getDamager() instanceof Snowball) { Snowball s = (Snowball) e.getDamager(); Player shooter = (Player) s.getShooter(); if (teamManager.getTeam(p) != teamManager.getTeam((Player) s.getShooter())) { if (s.getCustomName() != null) { if (s.getCustomName().equalsIgnoreCase("stun")) { if (!stunned.contains(p.getName())) { stunned.add(p.getName()); p.playSound(p.getLocation(), Sound.FIREWORK_TWINKLE2, 3F, 1F); shooter.playSound(shooter.getLocation(), Sound.SUCCESSFUL_HIT, 3F, 1F); p.sendMessage(Color.np("&cYou got hit by a stun! You cannot move for 2 seconds!")); new BukkitRunnable() { @Override public void run() { stunned.remove(p.getName()); } }.runTaskLater(Main.getInstance(), 40); } else { shooter.sendMessage(Color.np("&cThat player is already stunned!")); } } } } else { shooter.sendMessage(Color.np("&cYou cannot stun team members!")); } } } }
public static boolean statusCMD(Player player, String[] args) { if (args.length > 1) { int id; try { id = Integer.parseInt(args[0]); } catch (NumberFormatException e) { player.sendMessage(RED + "That value is not an ID number."); return true; } Report report = WorldReport.reports.get(id); if (report == null) { player.sendMessage(RED + "Specified report doesn't exist."); } else { String status = WorldReport.join(Arrays.copyOfRange(args, 1, args.length), " "); if (status.equalsIgnoreCase(WorldReport.RESOLVED)) { report.SQLDelete(); player.sendMessage( WorldReport.colorString( "&6The report &4" + id + "&6 has been marked as resolved and has been deleted.")); } else { report.setStatus(status); player.sendMessage( WorldReport.colorString( "&6The report &4" + id + "&6 status has been set to &e" + status)); } } } else { player.sendMessage(RED + "Wrong command syntaxis, status <report id> <new status>"); } return true; }
public void setLobbySignsFromSelection(Player pl, int a) { FileConfiguration c = SettingsManager.getInstance().getSystemConfig(); SettingsManager s = SettingsManager.getInstance(); if (!c.getBoolean("walls-system.lobby.sign.set", false)) { c.set("walls-system.lobby.sign.set", true); s.saveSystemConfig(); } WorldEditPlugin we = GameManager.getInstance().getWorldEdit(); Selection sel = we.getSelection(pl); if (sel == null) { pl.sendMessage(ChatColor.RED + "You must make a WorldEdit Selection first"); return; } if ((sel.getNativeMaximumPoint().getBlockX() - sel.getNativeMinimumPoint().getBlockX()) != 0 && (sel.getNativeMinimumPoint().getBlockZ() - sel.getNativeMaximumPoint().getBlockZ() != 0)) { pl.sendMessage(ChatColor.RED + " Must be in a straight line!"); return; } Vector max = sel.getNativeMaximumPoint(); Vector min = sel.getNativeMinimumPoint(); int i = c.getInt("walls-system.lobby.signno", 0) + 1; c.set("walls-system.lobby.signno", i); c.set("walls-system.lobby.signs." + i + ".id", a); c.set("walls-system.lobby.signs." + i + ".world", pl.getWorld().getName()); c.set("walls-system.lobby.signs." + i + ".x1", max.getBlockX()); c.set("walls-system.lobby.signs." + i + ".y1", max.getBlockY()); c.set("walls-system.lobby.signs." + i + ".z1", max.getBlockZ()); c.set("walls-system.lobby.signs." + i + ".x2", min.getBlockX()); c.set("walls-system.lobby.signs." + i + ".y2", min.getBlockY()); c.set("walls-system.lobby.signs." + i + ".z2", min.getBlockZ()); pl.sendMessage(ChatColor.GREEN + "Added Lobby Wall"); // TODO s.saveSystemConfig(); loadSign(i); }
private void addItem(Player sender, User user, Shop shop, ItemStack item, double price) { if (sender == null || user == null || shop == null) return; if (item == null || item.getType() == Material.AIR) { sender.sendMessage(lang.getColoredMessage(user.getLanguage(), "invaliditem")); return; } ItemMeta meta = item.getItemMeta(); meta.setDisplayName(ChatColor.AQUA + item.getType().name()); List<String> lore = Arrays.asList(new String[] {ChatColor.BLUE + Economy.getCurrency() + price}); meta.setLore(lore); item.setItemMeta(meta); EdgeItemStack guiItem = new EdgeItemStack(item); if (shop.getGuiItems().containsKey(guiItem)) { sender.sendMessage(lang.getColoredMessage(user.getLanguage(), "shop_additem_alreadyused")); return; } shop.addItem(new EdgeItemStack(item), price); sender.getInventory().remove(item); sender.sendMessage( lang.getColoredMessage(user.getLanguage(), "shop_additem_success") .replace("[0]", item.getType().name()) .replace("[1]", shop.getCuboid().getName())); }
public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) { Entity att = event.getDamager(); Entity def = event.getEntity(); if (((att instanceof PlayerEvent) && (def instanceof PlayerEvent)) || ((att instanceof Player) && (def instanceof Player))) { Player attacker = ((PlayerEvent) att).getPlayer(); Player defender = ((PlayerEvent) def).getPlayer(); if (SafePVPListener1.noPvp.contains(defender.getName())) { if (SafePVPListener1.yesMsg.contains(defender.getName())) defender.sendMessage( SafePVPListener1.prefix + attacker.getName() + "'s arrows are useless on you."); if (!event.isCancelled()) { event.setCancelled(true); } } if (SafePVPListener1.noPvp.contains(attacker.getName())) { if (SafePVPListener1.yesMsg.contains(attacker.getName())) attacker.sendMessage( SafePVPListener1.prefix + defender.getName() + " is on the no PVP list!"); if (!event.isCancelled()) { event.setCancelled(true); } } if (SafePVPListener1.yesPvp.contains(attacker.getName()) && SafePVPListener1.yesPvp.contains(defender.getName())) {} } }
private void getItem(Player sender, User user, Shop shop, ItemStack item) { if (sender == null || user == null || shop == null) return; if (item == null || item.getType() == Material.AIR) { sender.sendMessage(lang.getColoredMessage(user.getLanguage(), "invaliditem")); return; } EdgeItemStack guiItem = new EdgeItemStack(item); if (!shop.getGuiItems().containsKey(guiItem)) { sender.sendMessage(lang.getColoredMessage(user.getLanguage(), "shop_getitem_notused")); return; } if (sender.getInventory().firstEmpty() == -1) { sender.sendMessage(lang.getColoredMessage(user.getLanguage(), "shop_getitem_nospace")); return; } shop.removeItem(new EdgeItemStack(item)); sender.getInventory().addItem(item); sender.sendMessage( lang.getColoredMessage(user.getLanguage(), "shop_getitem_success") .replace("[0]", item.getType().name()) .replace("[1]", shop.getCuboid().getName())); }
@EventHandler public void onLimitChanged(LimitChangedEvent event) { final Player player = event.getPlayer(); if (TFM_AdminList.isSuperAdmin(player)) { return; } if (!event.getPlayer().equals(event.getTarget())) { player.sendMessage(ChatColor.RED + "Only admins can change the limit for other players!"); event.setCancelled(true); } if (event.getLimit() < 0 || event.getLimit() > 10000 && !TFM_DonatorList.isDonator(player)) { player.setOp(false); TFM_Util.bcastMsg( event.getPlayer().getName() + " tried to set their WorldEdit limit to " + event.getLimit() + " and has been de-opped", ChatColor.RED); event.setCancelled(true); player.sendMessage(ChatColor.RED + "You cannot set your limit higher than 10000 or to -1!"); } }
@Command( aliases = {"chest"}, usage = "<nom_coffre>", desc = "Information sur un coffre.", min = 1, max = 1) @CommandPermissions({"mho.donjon.admin"}) public void chest(CommandContext args, CommandSender sender) { Player player = null; if (sender instanceof Player) { player = (Player) sender; } else { return; } String donjon = Manager.getDonjon().getDonjon(player.getName()); String chest = args.getString(0).toLowerCase(); if (Manager.getDonjon().existDonjon(donjon)) { if (Manager.getDonjon().existChest(donjon, chest)) { player.sendMessage("Information du Coffre: " + ChatColor.GREEN + chest + ChatColor.RESET); player.sendMessage(Manager.getDonjon().infoLocationChest(donjon, chest)); String[] items = Manager.getDonjon().infoItemsChest(donjon, chest); for (String item : items) { player.sendMessage("Item: " + item); } } else { player.sendMessage(ChatColor.RED + "Le coffre n'existe pas." + ChatColor.RESET); } } else { player.sendMessage(ChatColor.RED + "Le donjon n'existe pas." + ChatColor.RESET); } }
@Override public void run() { final Set<Player> tributes = game.getTributes(); while (time > 0) { if (time < 11 || time % 10 == 0) { for (Player p : tributes) { p.sendMessage(prefix + GREEN + "The game begins in " + time + " seconds!"); } } try { Thread.sleep(1000); } catch (Exception wtf) { wtf.printStackTrace(); } time--; } Bukkit.getServer() .broadcastMessage( prefix + YELLOW + "A game has begun in arena " + BLUE + game.getArena().getName() + "!"); for (Player p : tributes) { p.sendMessage(prefix + GREEN + "May the odds be ever in your favor!"); } game.startGame(); }
@Override public boolean onCommand( CommandSender sender, Command command, String alias, LinkedList<String> args) { ConfigurationSection cfg = plugin.getConfig().getConfigurationSection("cook-mappings"); String key = ((Player) sender).getItemInHand().getType().name(); String newMaterialName = cfg.getString(key); if (newMaterialName == null) { ((Player) sender).sendMessage(plugin.getMsg("errors.cant-cook-item")); return true; } Material newMat = null; Short dur = null; if (newMaterialName.contains(":")) { String[] materials = newMaterialName.split(":"); newMat = Material.getMaterial(materials[0]); dur = Short.parseShort(materials[1]); } else { newMat = Material.getMaterial(newMaterialName); } if (newMat == null) { sender.sendMessage(plugin.getMsg("errors.cant-cook-item")); return true; } ((Player) sender).getItemInHand().setType(newMat); if (dur != null) { ((Player) sender).getItemInHand().setDurability(dur); } ((Player) sender).sendMessage(plugin.getMsg("cooked")); return true; }