Java Code Examples for org.bukkit.event.block.SignChangeEvent#setCancelled()
The following examples show how to use
org.bukkit.event.block.SignChangeEvent#setCancelled() .
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: SignListener.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
@EventHandler public void onChangeSign(SignChangeEvent event) { if (event.isCancelled()) { return; } if (event.getBlock().getState() instanceof Sign) { Location loc = event.getBlock().getLocation(); if (SIGN_PREFIX.contains(event.getLine(0).toLowerCase())) { if (event.getPlayer().hasPermission(owner.getSignCreationPermission())) { if (manager.registerSign(loc, event.getLine(1))) { event.getPlayer().sendMessage(owner.returnTranslate("sign_successfully_created")); } else { event.getPlayer().sendMessage(owner.returnTranslate("sign_can_not_been_created")); event.setCancelled(true); event.getBlock().breakNaturally(); } } } } }
Example 2
Source File: SignListener.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
@EventHandler public void onChangeSign(SignChangeEvent event) { if (event.isCancelled()) { return; } if (event.getBlock().getState() instanceof Sign) { Location loc = event.getBlock().getLocation(); if (SIGN_PREFIX.contains(event.getLine(0).toLowerCase())) { if (event.getPlayer().hasPermission(owner.getSignCreationPermission())) { if (manager.registerSign(loc, event.getLine(1))) { event.getPlayer().sendMessage(owner.returnTranslate("sign_successfully_created")); } else { event.getPlayer().sendMessage(owner.returnTranslate("sign_can_not_been_created")); event.setCancelled(true); event.getBlock().breakNaturally(); } } } } }
Example 3
Source File: LWCBlockListener.java From Modern-LWC with MIT License | 6 votes |
@EventHandler public void onSignChange(SignChangeEvent event) { if (!LWC.ENABLED || event.isCancelled()) { return; } LWC lwc = plugin.getLWC(); Block block = event.getBlock(); Player player = event.getPlayer(); if (block == null) { return; } Protection protection = lwc.findProtection(block.getLocation()); if (protection == null) { return; } boolean canAccess = lwc.canAccessProtection(player, protection); if (!canAccess) { event.setCancelled(true); } }
Example 4
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 5
Source File: SignListener.java From SkyWarsReloaded with GNU General Public License v3.0 | 6 votes |
@EventHandler public void signPlaced(SignChangeEvent event) { String[] lines = event.getLines(); if (lines[0].equalsIgnoreCase("[sw]") && lines.length >= 2) { if (event.getPlayer().hasPermission("sw.signs")) { Location signLocation = event.getBlock().getLocation(); World w = signLocation.getWorld(); Block b = w.getBlockAt(signLocation); if(b.getType() == Material.WALL_SIGN || b.getType() == SkyWarsReloaded.getNMS().getMaterial("SIGN_POST").getType()) { event.setCancelled(true); String serverName = lines[1]; SWRServer server = SWRServer.getServer(serverName); if (server != null) { server.addSign(signLocation); event.getPlayer().sendMessage(new Messaging.MessageFormatter().format("signs.added")); } else { event.getPlayer().sendMessage(new Messaging.MessageFormatter().format("signs.no-map")); } } } else { event.getPlayer().sendMessage(new Messaging.MessageFormatter().format("error.signs-no-perm")); event.setCancelled(true); } } }
Example 6
Source File: ClaimSignListener.java From Guilds with MIT License | 5 votes |
@EventHandler public void onSignChange(SignChangeEvent event) { Player player = event.getPlayer(); if (!event.getLine(0).equalsIgnoreCase("[Guild Claim]")) return; if (!player.hasPermission("guilds.claimsigns.place") && !player.hasPermission("worldguard.region.redefine.*")) { guilds.getCommandManager().getCommandIssuer(player).sendInfo(Messages.CLAIM__SIGN_NO_PERMISSION); event.setCancelled(true); return; } if (!settingsManager.getProperty(ClaimSettings.CLAIM_SIGNS)) { guilds.getCommandManager().getCommandIssuer(player).sendInfo(Messages.CLAIM__SIGN_NOT_ENABLED); event.setCancelled(true); return; } if (event.getLine(1).isEmpty() || event.getLine(2).isEmpty()) { guilds.getCommandManager().getCommandIssuer(player).sendInfo(Messages.CLAIM__SIGN_INVALID_FORMAT); event.setCancelled(true); return; } if (!ClaimUtils.checkAlreadyExist(wrapper, player, event.getLine(1))) { guilds.getCommandManager().getCommandIssuer(player).sendInfo(Messages.CLAIM__SIGN_INVALID_REGION); event.setCancelled(true); return; } guilds.getCommandManager().getCommandIssuer(player).sendInfo(Messages.CLAIM__SIGN_PLACED, "{region}", event.getLine(1), "{price}", event.getLine(2)); }
Example 7
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 8
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 9
Source File: GlobalProtectionListener.java From DungeonsXL with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onSignChange(SignChangeEvent event) { Player player = event.getPlayer(); Block block = event.getBlock(); BlockState state = block.getState(); if (!(state instanceof Sign)) { return; } String[] lines = event.getLines(); // Group Signs if (plugin.getEditWorld(player.getWorld()) == null) { if (!DPermission.hasPermission(player, DPermission.SIGN)) { return; } if (!lines[0].equalsIgnoreCase(GlobalProtection.SIGN_TAG)) { return; } if (lines[1].equalsIgnoreCase(GroupSign.GROUP_SIGN_TAG)) { if (GroupSign.tryToCreate(plugin, event) != null) { event.setCancelled(true); } } else if (lines[1].equalsIgnoreCase(GameSign.GAME_SIGN_TAG)) { if (GameSign.tryToCreate(plugin, event) != null) { event.setCancelled(true); } } else if (lines[1].equalsIgnoreCase(LeaveSign.LEAVE_SIGN_TAG)) { Sign sign = (Sign) state; new LeaveSign(plugin, plugin.getGlobalProtectionCache().generateId(LeaveSign.class, sign.getWorld()), sign); event.setCancelled(true); } } }
Example 10
Source File: BukkitPlotListener.java From PlotMe-Core with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onSignEdit(SignChangeEvent event) { IPlayer player = plugin.wrapPlayer(event.getPlayer()); Location location = BukkitUtil.adapt(event.getBlock().getLocation()); if (manager.isPlotWorld(location)) { if (event.getPlayer().hasPermission(PermissionNames.ADMIN_BUILDANYWHERE)) { return; } Plot plot = manager.getPlot(location); if (plot == null) { player.sendMessage(api.C("CannotBuild")); event.setCancelled(true); } else { Optional<Plot.AccessLevel> member = plot.isMember(event.getPlayer().getUniqueId()); if (plot.getOwnerId().equals(event.getPlayer().getUniqueId())) { return; } if (member.isPresent()) { if (member.get().equals(Plot.AccessLevel.TRUSTED) && !api.getServerBridge().getOfflinePlayer(plot.getOwnerId()).isOnline()) { player.sendMessage(api.C("CannotBuild")); event.setCancelled(true); } else if (api.isPlotLocked(plot.getId())) { player.sendMessage(api.C("PlotLocked")); event.setCancelled(true); } } else { player.sendMessage(api.C("CannotBuild")); event.setCancelled(true); } } } }
Example 11
Source File: CEListener.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void SignChangeEvent(SignChangeEvent e) { if (e.getLine(0).equals("[CustomEnchant]")) if (!e.getPlayer().isOp()) e.setCancelled(true); else { String ench = e.getLine(1); CEnchantment ce = EnchantManager.getEnchantment(ench); if (ce == null) for (CEnchantment ceT : EnchantManager.getEnchantments()) if (EnchantManager.containsEnchantment(ench, ceT)) ce = ceT; if (ce == null) { e.getPlayer().sendMessage(ChatColor.RED + "Could not find Custom Enchantment " + ench + "."); e.setCancelled(true); return; } if (Main.hasEconomy) try { Integer.parseInt(e.getLine(3).replaceAll("\\D+", "")); } catch (NumberFormatException ex) { e.getPlayer().sendMessage(ChatColor.RED + "The cost you entered is invalid."); e.setCancelled(true); return; } else e.getPlayer().sendMessage(ChatColor.GRAY + "You are not using a compatible economy plugin, so the cost will not be used."); e.getPlayer().sendMessage(ChatColor.GREEN + "Successfully created a sign shop for the enchantment " + ench + "."); } }
Example 12
Source File: PlayerListener.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onSignChange(SignChangeEvent event) { Player player = event.getPlayer(); if (listenerService.shouldCancelEvent(player)) { event.setCancelled(true); } }
Example 13
Source File: DSignListener.java From DungeonsXL with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onSignChange(SignChangeEvent event) { String[] lines = event.getLines(); if (lines.length < 3 || !lines[0].startsWith("[")) { return; } Player player = event.getPlayer(); Block block = event.getBlock(); BlockState state = block.getState(); if (!(state instanceof Sign)) { return; } Sign sign = (Sign) state; EditWorld editWorld = api.getEditWorld(sign.getWorld()); if (editWorld == null) { return; } if (sign == null) { return; } // Override sign plugins color codes etc. sign.setLine(0, lines[0]); sign.setLine(1, lines[1]); sign.setLine(2, lines[2]); sign.setLine(3, lines[3]); if (DungeonsXL.LEGACY_SIGNS.containsKey(lines[0].substring(1, lines[0].length() - 1).toUpperCase())) { MessageUtil.sendMessage(player, ChatColor.RED + "https://erethon.de/resources/dxl-signs/deprecated.gif"); MessageUtil.sendMessage(player, ChatColor.LIGHT_PURPLE + "https://github.com/DRE2N/DungeonsXL/wiki/Legacy-support#updating"); event.setCancelled(true); event.getBlock().setType(VanillaItem.AIR.getMaterial()); return; } DungeonSign dsign = editWorld.createDungeonSign(sign, sign.getLines()); if (dsign == null) { return; } if (!DPermission.hasPermission(player, dsign.getBuildPermission())) { MessageUtil.sendMessage(player, DMessage.ERROR_NO_PERMISSIONS.getMessage()); return; } if (dsign.validate()) { editWorld.registerSign(block); MessageUtil.sendMessage(player, DMessage.PLAYER_SIGN_CREATED.getMessage()); } else { editWorld.removeDungeonSign(block); MessageUtil.sendMessage(player, DMessage.ERROR_SIGN_WRONG_FORMAT.getMessage()); } }
Example 14
Source File: MainListener.java From ArmorStandTools with MIT License | 4 votes |
@EventHandler public void onSignChange(final SignChangeEvent event) { if(event.getBlock().hasMetadata("armorStand")) { final Block b = event.getBlock(); final ArmorStand as = getArmorStand(b); if (as != null) { StringBuilder sb = new StringBuilder(); for (String line : event.getLines()) { if (line != null && line.length() > 0) { sb.append(ChatColor.translateAlternateColorCodes('&', line)); } } String input = sb.toString(); if(b.hasMetadata("setName")) { if (input.length() > 0) { as.setCustomName(input); as.setCustomNameVisible(true); } else { as.setCustomName(""); as.setCustomNameVisible(false); as.setCustomNameVisible(false); } } else if(b.hasMetadata("setSkull")) { if(MC_USERNAME_PATTERN.matcher(input).matches()) { b.setMetadata("protected", new FixedMetadataValue(plugin, true)); event.getPlayer().sendMessage(ChatColor.GOLD + Config.pleaseWait); String cmd = "minecraft:give " + event.getPlayer().getName() + " minecraft:player_head{SkullOwner:\"" + input + "\"} 1"; String current = b.getWorld().getGameRuleValue("sendCommandFeedback"); b.getWorld().setGameRuleValue("sendCommandFeedback", "false"); Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd); b.getWorld().setGameRuleValue("sendCommandFeedback", current); boolean found = false; for(int slot : event.getPlayer().getInventory().all(Material.PLAYER_HEAD).keySet()) { ItemStack skull = event.getPlayer().getInventory().getItem(slot); SkullMeta sm = (SkullMeta) skull.getItemMeta(); if(sm.hasOwner() && input.equalsIgnoreCase(sm.getOwningPlayer().getName())) { as.setHelmet(skull); event.getPlayer().sendMessage(ChatColor.GREEN + Config.appliedHead + ChatColor.GOLD + " " + input); event.getPlayer().getInventory().setItem(slot, null); found = true; break; } } if(!found) { event.getPlayer().sendMessage(ChatColor.GOLD + Config.headFailed); } } else { event.getPlayer().sendMessage(ChatColor.RED + input + " " + Config.invalidName); } } } event.setCancelled(true); b.removeMetadata("armorStand", plugin); b.removeMetadata("setName", plugin); b.removeMetadata("setSkull", plugin); b.setType(Material.AIR); } }