Java Code Examples for org.bukkit.event.block.SignChangeEvent#setLine()
The following examples show how to use
org.bukkit.event.block.SignChangeEvent#setLine() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Recipes.java From ProRecipes with GNU General Public License v2.0 | 6 votes |
@EventHandler public void onSignChangeEvent(SignChangeEvent event){ if(event.getLine(0).equalsIgnoreCase("mTable")){ Sign s = (Sign) event.getBlock().getState().getData(); if(event.getBlock().getRelative(s.getFacing().getOppositeFace()).getRelative(BlockFace.UP).getType().equals(Material.AIR)){ event.getPlayer().sendMessage("There must be a block above the sign!"); event.setCancelled(true); return; } if(event.getPlayer().hasPermission("prorecipes.createtable")){ event.setLine(1, ProRecipes.getPlugin().ms.getMessage("Multi_Craft", ChatColor.GOLD + "Multi-Craft")); event.setLine(0, ""); event.getPlayer().sendMessage(ChatColor.GREEN + "Successfully created Mutli-Craft Table!"); }else{ event.setCancelled(true); event.getPlayer().sendMessage(ChatColor.RED + "You do not have permission to create an multi-craft table"); } } }
Example 2
Source File: SignListener.java From ChestCommands with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onSignChange(SignChangeEvent event) { if (event.getLine(0).equalsIgnoreCase("[menu]") && event.getPlayer().hasPermission(Permissions.SIGN_CREATE)) { if (event.getLine(1).isEmpty()) { event.setLine(0, ChatColor.RED + event.getLine(0)); event.getPlayer().sendMessage(ChatColor.RED + "You must set a valid menu name in the second line."); return; } IconMenu iconMenu = ChestCommands.getFileNameToMenuMap().get(BukkitUtils.addYamlExtension(event.getLine(1))); if (iconMenu == null) { event.setLine(0, ChatColor.RED + event.getLine(0)); event.getPlayer().sendMessage(ChatColor.RED + "That menu was not found."); return; } event.setLine(0, ChatColor.DARK_BLUE + event.getLine(0)); event.getPlayer().sendMessage(ChatColor.GREEN + "Successfully created a sign for the menu " + BukkitUtils.addYamlExtension(event.getLine(1)) + "."); } }
Example 3
Source File: SignManager.java From factions-top with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void registerSign(SignChangeEvent event) { // Do nothing if the sign should not be registered. if (!event.getPlayer().hasPermission("factionstop.sign.create") || !signRegex.matcher(event.getLine(0).toLowerCase()).find()) { return; } // Attempt to parse the rank for this sign. int rank; try { rank = Integer.parseInt(event.getLine(1)); } catch (NumberFormatException e) { event.getPlayer().sendMessage(ChatColor.RED + "Invalid rank number on line 2!"); event.setLine(0, ChatColor.DARK_RED + "[FactionsTop]"); return; } event.setLine(0, ChatColor.DARK_BLUE + "[FactionsTop]"); event.setLine(1, "#" + Math.max(rank, 1)); rank = Math.max(rank - 1, 0); SplaySet<FactionWorth> factions = plugin.getWorthManager().getOrderedFactions(); if (factions.size() > rank) { FactionWorth worth = factions.byIndex(rank); event.setLine(2, worth.getName()); event.setLine(3, plugin.getSettings().getCurrencyFormat().format(worth.getTotalWorth())); } else { event.setLine(2, "-"); event.setLine(3, "$0.00"); } saveSign(BlockPos.of(event.getBlock()), rank); }
Example 4
Source File: SignChange.java From WildernessTp with MIT License | 5 votes |
@EventHandler public void onSignChange(SignChangeEvent e) { String noPermMsg = wild.getConfig().getString("No-Perm"); Checks check = new Checks(wild); if (e.getLine(1).equalsIgnoreCase("[wild]") && e.getLine(0).equalsIgnoreCase("wildtp")) { if (e.getPlayer().hasPermission("wild.wildtp.create.sign")) { if (check.world(e.getPlayer())) { if(e.getLine(2)!=null) e.setLine(3, e.getLine(2)); e.setLine(0, "§4===================="); e.setLine(1, "[§1Wild§0]"); e.setLine(2, "§4===================="); e.getPlayer().sendMessage(ChatColor.GREEN + "Successfully made a new WildTP sign"); } else { e.getPlayer().sendMessage(ChatColor.RED + "Signs cannot be placed in this world as the command isnt allowed in this world"); e.getBlock().breakNaturally(); e.setCancelled(true); } } else { e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes((char) '&', noPermMsg)); e.setCancelled(true); } } }
Example 5
Source File: SignEditListener.java From NyaaUtils with MIT License | 5 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onSignChange(SignChangeEvent event) { UUID uuid = event.getPlayer().getUniqueId(); if (signContents.containsKey(uuid)) { SignContent c = signContents.get(uuid); for (int i = 0; i < 4; i++) { event.setLine(i, c.getLine(i)); } signContents.remove(uuid); } }
Example 6
Source File: SignChangeListener.java From SaneEconomy with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onSignChange(SignChangeEvent evt) { if (!evt.getPlayer().hasPermission("saneeconomy.signshop.create.admin")) { return; } ParsedSignShop pss = this.parseSignShop(evt); if (pss.error != null) { this.plugin.getMessenger().sendMessage(evt.getPlayer(), "Cannot create shop: {1}", pss.error); return; } if (pss.shop == null) { return; } SignShop signShop = pss.shop; this.plugin.getSignShopManager().addSignShop(signShop); evt.setLine(0, ChatColor.translateAlternateColorCodes('&', this.plugin.getConfig().getString("admin-shop-title"))); this.plugin.getMessenger().sendMessage(evt.getPlayer(), "Sign shop created!"); this.plugin.getMessenger().sendMessage(evt.getPlayer(), "Item: {1} x {2}", signShop.getQuantity(), signShop.getItemStack()); if (signShop.canBuy()) { // The player be buying from the shop, not the other way around. this.plugin.getMessenger().sendMessage(evt.getPlayer(), "Will sell to players for {1}.", this.plugin.getSaneEconomy().getEconomyManager().getCurrency().formatAmount(signShop.getBuyPrice()) ); } if (signShop.canSell()) { // The player be selling to the shop, not the other way around. this.plugin.getMessenger().sendMessage(evt.getPlayer(), "Will buy from players for {1}.", this.plugin.getSaneEconomy().getEconomyManager().getCurrency().formatAmount(signShop.getSellPrice()) ); } }
Example 7
Source File: SignListener.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onSignChange(SignChangeEvent sce) { String firstLine = sce.getLine(0).trim(); if (!"[bw]".equals(firstLine)) { return; } Player player = sce.getPlayer(); if (!player.hasPermission("bw.setup")) { return; } String gameName = sce.getLine(1).trim(); Game game = BedwarsRel.getInstance().getGameManager().getGame(gameName); if (game == null) { String notfound = BedwarsRel._l("errors.gamenotfoundsimple"); if (notfound.length() > 16) { String[] splitted = notfound.split(" ", 4); for (int i = 0; i < splitted.length; i++) { sce.setLine(i, ChatColor.RED + splitted[i]); } } else { sce.setLine(0, ChatColor.RED + notfound); sce.setLine(1, ""); sce.setLine(2, ""); sce.setLine(3, ""); } return; } sce.setCancelled(true); game.addJoinSign(sce.getBlock().getLocation()); game.updateSigns(); }
Example 8
Source File: SignListener.java From ChestCommands with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onSignChangeMonitor(SignChangeEvent event) { // Prevent players with permissions for creating colored signs from creating menu signs if (event.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE + "[menu]") && !event.getPlayer().hasPermission(Permissions.SIGN_CREATE)) { event.setLine(0, ChatColor.stripColor(event.getLine(0))); } }
Example 9
Source File: WarpSigns.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Event handler for Sign Changes * * @param e - event */ @EventHandler(priority = EventPriority.NORMAL) public void onSignWarpCreate(SignChangeEvent e) { //plugin.getLogger().info("DEBUG: SignChangeEvent called"); String title = e.getLine(0); Player player = e.getPlayer(); if (player.getWorld().equals(ASkyBlock.getIslandWorld()) || player.getWorld().equals(ASkyBlock.getNetherWorld())) { //plugin.getLogger().info("DEBUG: Correct world"); if (e.getBlock().getType().equals(Material.SIGN_POST) || e.getBlock().getType().equals(Material.WALL_SIGN)) { //plugin.getLogger().info("DEBUG: The first line of the sign says " + title); // Check if someone is changing their own sign // This should never happen !! if (title.equalsIgnoreCase(plugin.myLocale().warpswelcomeLine)) { //plugin.getLogger().info("DEBUG: Welcome sign detected"); // Welcome sign detected - check permissions if (!(VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp"))) { Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorNoPerm); return; } if(Settings.warpLevelsRestriction > 0 && !(ASkyBlockAPI.getInstance().getLongIslandLevel(player.getUniqueId()) > Settings.warpLevelsRestriction)){ Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorNotEnoughLevel); return; } // Check that the player is on their island if (!(plugin.getGrid().playerIsOnIsland(player, Settings.coopsCanCreateWarps))) { Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorNoPlace); e.setLine(0, ChatColor.RED + plugin.myLocale().warpswelcomeLine); return; } // Check if the player already has a sign final Location oldSignLoc = getWarp(player.getUniqueId()); if (oldSignLoc == null) { //plugin.getLogger().info("DEBUG: Player does not have a sign already"); // First time the sign has been placed or this is a new // sign if (addWarp(player.getUniqueId(), e.getBlock().getLocation())) { Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).warpssuccess); e.setLine(0, ChatColor.GREEN + plugin.myLocale().warpswelcomeLine); for (int i = 1; i<4; i++) { e.setLine(i, ChatColor.translateAlternateColorCodes('&', e.getLine(i))); } } else { Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorDuplicate); e.setLine(0, ChatColor.RED + plugin.myLocale().warpswelcomeLine); for (int i = 1; i<4; i++) { e.setLine(i, ChatColor.translateAlternateColorCodes('&', e.getLine(i))); } } } else { //plugin.getLogger().info("DEBUG: Player already has a Sign"); // A sign already exists. Check if it still there and if // so, // deactivate it Block oldSignBlock = oldSignLoc.getBlock(); if (oldSignBlock.getType().equals(Material.SIGN_POST) || oldSignBlock.getType().equals(Material.WALL_SIGN)) { // The block is still a sign //plugin.getLogger().info("DEBUG: The block is still a sign"); Sign oldSign = (Sign) oldSignBlock.getState(); if (oldSign != null) { //plugin.getLogger().info("DEBUG: Sign block is a sign"); if (oldSign.getLine(0).equalsIgnoreCase(ChatColor.GREEN + plugin.myLocale().warpswelcomeLine)) { //plugin.getLogger().info("DEBUG: Old sign had a green welcome"); oldSign.setLine(0, ChatColor.RED + plugin.myLocale().warpswelcomeLine); oldSign.update(true, false); Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpsdeactivate); removeWarp(player.getUniqueId()); Bukkit.getPluginManager().callEvent(new WarpRemoveEvent(plugin, oldSign.getLocation(), player.getUniqueId())); } } } // Set up the warp if (addWarp(player.getUniqueId(), e.getBlock().getLocation())) { Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).warpssuccess); e.setLine(0, ChatColor.GREEN + plugin.myLocale().warpswelcomeLine); } else { Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorDuplicate); e.setLine(0, ChatColor.RED + plugin.myLocale().warpswelcomeLine); } } } } } }