org.bukkit.event.block.SignChangeEvent Java Examples
The following examples show how to use
org.bukkit.event.block.SignChangeEvent.
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: 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 #3
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 #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: GameSign.java From DungeonsXL with GNU General Public License v3.0 | 6 votes |
public static GameSign tryToCreate(DungeonsXL plugin, SignChangeEvent event) { if (!event.getLine(0).equalsIgnoreCase(SIGN_TAG)) { return null; } if (!event.getLine(1).equalsIgnoreCase(GAME_SIGN_TAG)) { return null; } String identifier = event.getLine(2); String[] data = event.getLine(3).split(","); int maxGroupsPerGame = NumberUtil.parseInt(data[0], 1); int startIfElementsAtLeast = -1; if (data.length > 1) { startIfElementsAtLeast = NumberUtil.parseInt(data[1], -1); } return tryToCreate(plugin, event.getBlock(), identifier, maxGroupsPerGame, startIfElementsAtLeast); }
Example #6
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 #7
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 #8
Source File: GroupSign.java From DungeonsXL with GNU General Public License v3.0 | 6 votes |
public static GroupSign tryToCreate(DungeonsXL plugin, SignChangeEvent event) { if (!event.getLine(0).equalsIgnoreCase(SIGN_TAG)) { return null; } if (!event.getLine(1).equalsIgnoreCase(GROUP_SIGN_TAG)) { return null; } String identifier = event.getLine(2); String[] data = event.getLine(3).split(","); int maxPlayersPerGroup = 1; String groupName = null; int startIfElementsAtLeast = -1; if (data.length >= 1) { maxPlayersPerGroup = NumberUtil.parseInt(data[0], 1); } if (data.length >= 2) { groupName = data[1]; } if (data.length == 3) { startIfElementsAtLeast = NumberUtil.parseInt(data[2], -1); } return tryToCreate(plugin, event.getBlock(), identifier, maxPlayersPerGroup, startIfElementsAtLeast, groupName); }
Example #9
Source File: SignEvents.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onSignChanged(SignChangeEvent e) { if (e.isCancelled() || e.getPlayer() == null || !plugin.getWorldManager().isSkyAssociatedWorld(e.getPlayer().getWorld()) || !e.getLines()[0].equalsIgnoreCase("[usb]") || e.getLines()[1].trim().isEmpty() || !e.getPlayer().hasPermission("usb.island.signs.place") || !(e.getBlock().getType() == SkyBlockMenu.WALL_SIGN_MATERIAL) || !(e.getBlock().getState() instanceof Sign) ) { return; } Sign sign = (Sign) e.getBlock().getState(); if(sign.getBlock().getState().getBlockData() instanceof WallSign) { WallSign data = (WallSign) sign.getBlock().getState().getBlockData(); BlockFace attached = data.getFacing().getOppositeFace(); Block wallBlock = sign.getBlock().getRelative(attached); if (isChest(wallBlock)) { logic.addSign(sign, e.getLines(), (Chest) wallBlock.getState()); } } }
Example #10
Source File: ATM.java From TimeIsMoney with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onSignChange(final SignChangeEvent e) { final Block b = e.getBlock(); if (b.getState() instanceof Sign) { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { if (b.getState() instanceof Sign) { Sign sign = (Sign) e.getBlock().getState(); if (sign.getLine(0).equalsIgnoreCase("[atm]")) { if (!e.getPlayer().hasPermission("tim.atm.place")) { e.getPlayer().sendMessage(CC("&cYou dont have permissions to build ATM's!")); sign.setLine(0, ""); } else { sign.setLine(0, CC("&cATM")); sign.update(); e.getPlayer().sendMessage(CC("&2ATM created! (You can also write something in the Lines 2-4)")); } } } }, 10L); } }
Example #11
Source File: SignListener.java From RandomTeleport with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true) public void onSignCreate(SignChangeEvent event) { if (plugin.matchesSignVariable(event.getLine(1))) { if (!event.getPlayer().hasPermission("randomteleport.sign.create")) { event.getBlock().breakNaturally(); plugin.sendMessage(event.getPlayer(), "sign.no-permission.create", "perm", "randomteleport.sign.create"); } else { String preset = event.getLine(2); if (preset != null) { plugin.sendMessage(event.getPlayer(), "sign.created", "preset", preset); if (plugin.getConfig().getString("presets." + preset.toLowerCase()) == null) { plugin.sendMessage(event.getPlayer(), "error.preset-doesnt-exist", "preset", preset); } } } } }
Example #12
Source File: RegionBuilder.java From RedProtect with GNU General Public License v3.0 | 5 votes |
protected void setErrorSign(SignChangeEvent e, String error) { Bukkit.getScheduler().callSyncMethod(RedProtect.get(), () -> { Sign sign = (Sign) e.getBlock().getState(); sign.setLine(0, RedProtect.get().lang.get("regionbuilder.signerror")); sign.update(); setError(e.getPlayer(), error); return true; }); }
Example #13
Source File: PlayerListenerTest.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
@Test public void shouldCancelSignChangeEvent() { // given SignChangeEvent event = mock(SignChangeEvent.class); Player player = mock(Player.class); given(event.getPlayer()).willReturn(player); given(listenerService.shouldCancelEvent(player)).willReturn(true); // when listener.onSignChange(event); // then verify(event).setCancelled(true); }
Example #14
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 #15
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 #16
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 #17
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 #18
Source File: PlayerListenerTest.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
@Test public void shouldAllowSignChangeEvent() { // given SignChangeEvent event = mock(SignChangeEvent.class); Player player = mock(Player.class); given(event.getPlayer()).willReturn(player); given(listenerService.shouldCancelEvent(player)).willReturn(false); // when listener.onSignChange(event); // then verify(event, only()).getPlayer(); }
Example #19
Source File: DEditPlayer.java From DungeonsXL with GNU General Public License v3.0 | 5 votes |
public void poke(Block block) { if (block.getState() instanceof Sign) { Sign sign = (Sign) block.getState(); String[] lines = sign.getLines(); if (lines[0].isEmpty() && lines[1].isEmpty() && lines[2].isEmpty() && lines[3].isEmpty()) { if (linesCopy != null) { SignChangeEvent event = new SignChangeEvent(block, getPlayer(), linesCopy); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { sign.setLine(0, event.getLine(0)); sign.setLine(1, event.getLine(1)); sign.setLine(2, event.getLine(2)); sign.setLine(3, event.getLine(3)); sign.update(); } } } else { linesCopy = lines; MessageUtil.sendMessage(getPlayer(), DMessage.PLAYER_SIGN_COPIED.getMessage()); } } else { String info = "" + block.getType(); if (block.getData() != 0) { info = info + "," + block.getData(); } MessageUtil.sendMessage(getPlayer(), DMessage.PLAYER_BLOCK_INFO.getMessage(info)); } }
Example #20
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 #21
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 #22
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 #23
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 #24
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 #25
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 #26
Source File: CivilianListener.java From Civs with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onAdvertisementPlace(SignChangeEvent event) { Town town = TownManager.getInstance().getTownAt(event.getBlock().getLocation()); if (town == null) { return; } Government government = GovernmentManager.getInstance().getGovernment(town.getGovernmentType()); if (government.getGovernmentType() != GovernmentType.IDIOCRACY) { return; } changeAdvertising(event.getBlock(), town, false); changeAdvertising(event.getLines(), town, true); Util.checkNoise(town, event.getPlayer()); }
Example #27
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 #28
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); } }
Example #29
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 #30
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); } } } } } }