@EventHandler public void onSignChange(SignChangeEvent event) { Player player = event.getPlayer(); if (player.hasPermission("rankedgames.create.sign")) { Sign sign = (Sign) event.getBlock().getState(); if ((event.getLine(0).equalsIgnoreCase("[RG]")) && (!event.getLine(1).isEmpty())) { int type = 0; try { type = Integer.parseInt(event.getLine(1)); if ((type < 1) || (type > 3)) { player.sendMessage( ChatColor.RED + "Impossible de cr�er le panneau (Le type de pvp doit être égal à 1, 2 ou 3)"); event.getBlock().breakNaturally(); return; } event.setLine(0, ChatColor.GREEN + "[RankedGames]"); event.setLine(1, ChatColor.DARK_RED + "" + type + "vs" + type); sign.update(true); } catch (NumberFormatException ex) { event.getBlock().breakNaturally(); player.sendMessage( ChatColor.RED + "Impossible de créer le panneau (Valeur num�rique requise dans le type de pvp)"); } } } }
@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 = Tools.getEnchantmentByDisplayname(ench); if (ce == null) ce = Tools.getEnchantmentByOriginalname(ench); if (ce == null) for (CEnchantment ceT : Main.enchantments) if (Tools.checkForEnchantment(ench, ceT)) ce = ceT; if (ce == null) { e.getPlayer() .sendMessage(ChatColor.RED + "[CE] Could not find Custom Enchantment " + ench + "."); e.setCancelled(true); return; } try { Integer.parseInt(e.getLine(3).replaceAll("\\D+", "")); } catch (NumberFormatException ex) { e.getPlayer().sendMessage(ChatColor.RED + "[CE] The cost you entered is invalid."); e.setCancelled(true); return; } e.getPlayer() .sendMessage( ChatColor.GREEN + "[CE] Successfully created a sign shop for the enchantment " + ench + "."); } }
public void checkCreation(SignChangeEvent event) { if (!Parser.isInteger(event.getLine(2))) { SignUtils.cancelSignCreation(event, "Enter the delay in seconds in line 3."); } else { event.setLine(2, String.valueOf(Math.abs(Integer.valueOf(event.getLine(2)).intValue()))); event.setLine(3, ""); } }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerInteractEvent3(SignChangeEvent event) { Player p = event.getPlayer(); if ((event.getLine(0).contains("[Warp]")) && (p.hasPermission(new Permission("ELT.admin")))) { event.setLine(0, ChatColor.BLUE + "[Warp]"); p.sendMessage(ChatColor.BLUE + "[Warp] Criado"); } else if (event.getLine(0).contains("[Warp]")) { event.setLine(0, ChatColor.RED + "[INVALIDO]"); } }
public StringToggle(SignChangeEvent event) { super(event); this.gateName = "String Toggle"; this.gateID = "[StringToggle]"; this.addOutput("Value", "string"); this.gateStrData = event.getLine(1) + event.getLine(2) + event.getLine(3); this.gateDouData = 0.0; updateOutput(); event.setLine(1, (String) this.gateOutputs.get(0)); }
@EventHandler public void onSignChange(SignChangeEvent e) { String s; for (int i = 0; i <= 3; i++) { if (e.getPlayer().hasPermission("blockeffects.signcolors")) { s = e.getLine(i).replaceAll("(?i)&([a-fk-or0-9])", "\u00A7$1"); } else { s = e.getLine(i).replaceAll("(?i)&([a-fk-or0-9])", ""); } e.setLine(i, s); } }
@Override public void onSignChange(SignChangeEvent event) { if (event.isCancelled()) return; if (!event.getLine(0).equalsIgnoreCase("[ExpStone]")) return; // Get basics final Block block = event.getBlock(); final Player player = event.getPlayer(); // Get a certein block. final Block fieldBlock = BlockUtil.getFieldStone(block, true); // Chech if any surrounding blocks is a known fieldblock. if (fieldBlock == null) { player.sendMessage(ChatColor.YELLOW + "ExpensiveStones: No Expensive StoneType Found."); return; } // _____________________Test Adming_____________________________ if (event.getLine(2).equalsIgnoreCase("admin")) { // Check rights if (!player.hasPermission(ESPermissionManager.PERM_ADMIN)) { player.sendMessage( ChatColor.YELLOW + "ExpensiveStones: You don't have the permissions to make an adminField."); } else { fieldManager.setAdminField(fieldManager.getExpensiveField(block)); player.sendMessage( ChatColor.YELLOW + "ExpensiveStones: Admin-Field created, field is now handled by PreciousStones."); player.sendMessage(ChatColor.YELLOW + "You can now destroy this sign."); } return; } // _____________________Normal Player___________________________ final Block chestBlock = BlockUtil.getChest(block); // Chech chest if (chestBlock == null) { player.sendMessage(ChatColor.YELLOW + "ExpensiveStones: No chest found for register"); return; } final ExpensiveField expField = new ExpensiveField(block, chestBlock, stones.getForceFieldManager().getField(fieldBlock)); fieldManager.disableField(expField); event.setLine(1, expField.getField().getOwner()); event.setLine(2, expField.getSettings().getMaterial().toString()); event.setLine(3, "<DISABLED>"); player.sendMessage( ChatColor.YELLOW + "ExpensiveStones: Field Registered, click to enable field"); }
@Override public void onPlace(SignChangeEvent e) { e.getPlayer().sendMessage(I18N._("spleefSignCreated")); StringBuilder builder = new StringBuilder(); if (e.getLine(1).startsWith("[")) { builder.append(ChatColor.DARK_GRAY + "["); } builder.append(ChatColor.DARK_RED).append(ChatColor.BOLD).append("Leave"); if (e.getLine(1).endsWith("]")) { builder.append(ChatColor.DARK_GRAY + "]"); } e.setLine(1, builder.toString()); }
@Override public boolean signCreate(SignChangeEvent event) { if (plugin.mdata.hasMinigame(event.getLine(2))) { event.setLine(1, ChatColor.GREEN + "Bet"); event.setLine(2, plugin.mdata.getMinigame(event.getLine(2)).getName(false)); if (event.getLine(3).matches("[0-9]+")) { event.setLine(3, "$" + event.getLine(3)); } return true; } event .getPlayer() .sendMessage( ChatColor.RED + "[Minigames] " + ChatColor.WHITE + MinigameUtils.formStr("minigame.error.noMinigameName", event.getLine(2))); return false; }
@EventHandler(priority = EventPriority.NORMAL) public void onSignChange(SignChangeEvent event) { Player p = event.getPlayer(); for (int i = 0; i < event.getLines().length; i++) { if (event.getLine(i).toLowerCase().contains("[sortal]") || event.getLine(i).toLowerCase().contains(plugin.signContains)) { if (event.getPlayer().hasPermission("sortal.placesign")) { if (this.pay(p)) { plugin.log.info("Sign placed by " + p.getDisplayName() + ", AKA " + p.getName() + "!"); } else { event.setCancelled(true); } } else { p.sendMessage("You are not allowed to place a [Sortal] sign!"); event.setCancelled(true); } } } }
@Override public void onSignChange(SignChangeEvent event) { if (event.getLine(0).equalsIgnoreCase("[shop]")) { String paymentType = "Iron"; String paymentCode = "i"; int paymentId = 265; if (event.getLine(1).toLowerCase().endsWith("i")) { paymentCode = "i"; paymentType = "Iron"; paymentId = 265; } else if (event.getLine(1).toLowerCase().endsWith("g")) { paymentCode = "g"; paymentType = "Gold"; paymentId = 266; } else if (event.getLine(1).toLowerCase().endsWith("d")) { paymentCode = "d"; paymentType = "Diamonds"; paymentId = 264; } int paymentAmount = 10; try { paymentAmount = Integer.parseInt(event.getLine(1).replace(paymentCode, "")); } catch (Exception e) { event .getPlayer() .sendMessage( ChatColor.RED + "Please input only a number and the payment type(i for Iron,g for Gold, or d for Diamonds)"); event.getPlayer().sendMessage(ChatColor.RED + "For example: 10i"); } event.setLine(0, event.getPlayer().getName()); event.setLine(1, paymentAmount + " " + paymentType); event.setLine(2, "Right click me"); event.setLine(3, "with something"); plugin.AddShop( paymentId, paymentType, paymentAmount, event.getBlock().getLocation(), event.getPlayer().getName()); } }
// handle sign change @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onTNTRunSignCreate(SignChangeEvent e) { Player player = e.getPlayer(); if (e.getLine(0).equalsIgnoreCase("[TNTRun]")) { if (!player.hasPermission("tntrun.setup")) { Messages.sendMessage(player, Messages.nopermission); e.setCancelled(true); e.getBlock().breakNaturally(); return; } if (e.getLine(1).equalsIgnoreCase("[join]") && e.getLine(2) != null) { joinsign.handleCreation(e); } else if (e.getLine(1).equalsIgnoreCase("[leave]")) { leavesign.handleCreation(e); } else if (e.getLine(1).equalsIgnoreCase("[vote]")) { votesign.handleCreation(e); } } }
@EventHandler public void onSignChange(SignChangeEvent e) { Player p = e.getPlayer(); if (e.getLine(0).equalsIgnoreCase("[Rankup]")) if (p.hasPermission("rankup.sign")) { if (e.getLine(1).isEmpty() && e.getLine(2).isEmpty() && e.getLine(3).isEmpty()) { e.setLine(0, ChatColor.DARK_BLUE + "[Rankup]"); e.setLine(1, "Right click me"); e.setLine(2, "to rank up!"); Language.send(p, "&7Successfully created a rankup sign."); } } else { Language.send(p, "&cYou do not have permission to create a rankup sign."); e.setCancelled(true); } }
@EventHandler public void onSignChange(SignChangeEvent e) { if (e.getLines().length == 0) { } else if (e.getLine(0).equalsIgnoreCase("[TNTTag]") && e.getLine(1).equalsIgnoreCase("1") && e.getPlayer().hasPermission("TNTTag.Sign.Create")) { e.getPlayer().sendMessage("You created a TNTTag sign for arena: 1"); e.setLine(0, ChatColor.GREEN + "[Join]"); e.setLine(1, ChatColor.BLACK + "1"); e.setLine(2, ChatColor.BLACK + "0:10"); e.setLine(3, ChatColor.BLACK + "TntTag"); } else if (e.getLine(0).equalsIgnoreCase("[TNTTag]") && e.getPlayer().hasPermission("TNTTag.Sign.create")) { e.getPlayer().sendMessage("A TNTTag sign must a valid number for the arena on line 2! "); e.getBlock().breakNaturally(); } else if (e.getLine(0).equalsIgnoreCase("[TNTTag]") && e.getLine(1).equalsIgnoreCase("spectate 1") && e.getPlayer().hasPermission("TNTTag.Sign.Create")) { // same code lines as [Join] Sign, but changed to [Spectate] } else if (e.getLine(0).equalsIgnoreCase("[TNTTag]") && e.getPlayer().hasPermission("TNTTag.Sign.Create")) { // same code lines as Error } }
// sign setup @EventHandler public void onSignCreation(SignChangeEvent e) { Player player = (Player) e.getPlayer(); if (!player.hasPermission("freezetag.signplace")) { player.sendMessage("No permission"); return; } if (e.getLine(0).equals("/ftpap")) { e.setLine(0, ChatColor.BLUE + ChatColor.BOLD.toString() + "Pack"); e.setLine(1, ChatColor.YELLOW + ChatColor.BOLD.toString() + "a"); e.setLine(2, ChatColor.GREEN + ChatColor.BOLD.toString() + "Punch"); e.setLine(3, ChatColor.MAGIC.toString() + ChatColor.BOLD.toString() + "fresh fish"); } }
@EventHandler(priority = EventPriority.NORMAL) public void onSignChange(SignChangeEvent event) { if (event.isCancelled()) return; String line = event.getLine(1); Pair<String> data = idMap.get(line); if (data != null) { if (PermissionHandler.getInstance() .playerHasNode(event.getPlayer(), data.getSecond() + ".build")) { event.setLine(1, data.getFirst()); } else { event.setCancelled(true); } } }
/** Called when a sign is changed. */ @Override public void onSignChange(SignChangeEvent event) { Player player = event.getPlayer(); WorldConfiguration wcfg = getWorldConfig(player); if (wcfg.signChestProtection) { if (event.getLine(0).equalsIgnoreCase("[Lock]")) { if (event.getBlock().getType() != Material.SIGN_POST) { player.sendMessage( ChatColor.RED + "The [Lock] sign must be a sign post, not a wall sign."); dropSign(event.getBlock()); event.setCancelled(true); return; } else if (!event.getLine(1).equalsIgnoreCase(player.getName())) { player.sendMessage(ChatColor.RED + "The first owner line must be your name."); dropSign(event.getBlock()); event.setCancelled(true); return; } else { event.setLine(0, "[Lock]"); player.sendMessage(ChatColor.YELLOW + "A chest or double chest above is now protected."); } } } else { if (event.getLine(0).equalsIgnoreCase("[Lock]")) { player.sendMessage(ChatColor.RED + "WorldGuard's sign chest protection is disabled."); dropSign(event.getBlock()); event.setCancelled(true); return; } } }
public void a(Packet130UpdateSign packet130updatesign) { // CraftBukkit start if (this.player.dead) { return; } // CraftBukkit end // WorldServer worldserver = this.minecraftServer.a(this.player.dimension); if (worldserver.isLoaded(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z)) { TileEntity tileentity = worldserver.getTileEntity( packet130updatesign.x, packet130updatesign.y, packet130updatesign.z); if (tileentity instanceof TileEntitySign) { TileEntitySign tileentitysign = (TileEntitySign) tileentity; if (!tileentitysign.a()) { this.minecraftServer.c( "Player " + this.player.name + " just tried to change non-editable sign"); // CraftBukkit this.sendPacket( new Packet130UpdateSign( packet130updatesign.x, packet130updatesign.y, packet130updatesign.z, tileentitysign.lines)); return; } } int i; int j; for (j = 0; j < 4; ++j) { boolean flag = true; if (packet130updatesign.lines[j].length() > 15) { flag = false; } else { for (i = 0; i < packet130updatesign.lines[j].length(); ++i) { if (FontAllowedCharacters.a.indexOf(packet130updatesign.lines[j].charAt(i)) < 0) { flag = false; } } } if (!flag) { packet130updatesign.lines[j] = "!?"; } } if (tileentity instanceof TileEntitySign) { j = packet130updatesign.x; int k = packet130updatesign.y; i = packet130updatesign.z; TileEntitySign tileentitysign1 = (TileEntitySign) tileentity; // CraftBukkit start Player player = server.getPlayer(this.player); SignChangeEvent event = new SignChangeEvent( (CraftBlock) player.getWorld().getBlockAt(j, k, i), server.getPlayer(this.player), packet130updatesign.lines); server.getPluginManager().callEvent(event); if (!event.isCancelled()) { for (int l = 0; l < 4; ++l) { tileentitysign1.lines[l] = event.getLine(l); } tileentitysign1.setEditable(false); } // CraftBukkit end tileentitysign1.update(); worldserver.notify(j, k, i); } } }
@EventHandler public void onSignChange(SignChangeEvent sign) { Player player = sign.getPlayer(); if (player.hasPermission("ELT.placac")) { if ((sign.getLine(0).contains("&1")) || (sign.getLine(0).contains("&2")) || (sign.getLine(0).contains("&3")) || (sign.getLine(0).contains("&4")) || (sign.getLine(0).contains("&5")) || (sign.getLine(0).contains("&6")) || (sign.getLine(0).contains("&7")) || (sign.getLine(0).contains("&8")) || (sign.getLine(0).contains("&9")) || (sign.getLine(0).contains("&0")) || (sign.getLine(0).contains("&a")) || (sign.getLine(0).contains("&b")) || (sign.getLine(0).contains("&c")) || (sign.getLine(0).contains("&d")) || (sign.getLine(0).contains("&e")) || (sign.getLine(0).contains("&f")) || (sign.getLine(0).contains("&o")) || (sign.getLine(0).contains("&l")) || (sign.getLine(0).contains("&k")) || (sign.getLine(0).contains("&n")) || (sign.getLine(0).contains("&m")) || (sign.getLine(0).contains("&r"))) { sign.setLine(0, sign.getLine(0).replace("&", "§")); } if ((sign.getLine(1).contains("&1")) || (sign.getLine(1).contains("&2")) || (sign.getLine(1).contains("&3")) || (sign.getLine(1).contains("&4")) || (sign.getLine(1).contains("&5")) || (sign.getLine(1).contains("&6")) || (sign.getLine(1).contains("&7")) || (sign.getLine(1).contains("&8")) || (sign.getLine(1).contains("&9")) || (sign.getLine(1).contains("&0")) || (sign.getLine(1).contains("&a")) || (sign.getLine(1).contains("&b")) || (sign.getLine(1).contains("&c")) || (sign.getLine(1).contains("&d")) || (sign.getLine(1).contains("&e")) || (sign.getLine(1).contains("&f")) || (sign.getLine(1).contains("&o")) || (sign.getLine(1).contains("&l")) || (sign.getLine(1).contains("&k")) || (sign.getLine(1).contains("&n")) || (sign.getLine(1).contains("&m")) || (sign.getLine(1).contains("&r"))) { sign.setLine(1, sign.getLine(1).replace("&", "§")); } if ((sign.getLine(2).contains("&1")) || (sign.getLine(2).contains("&2")) || (sign.getLine(2).contains("&3")) || (sign.getLine(2).contains("&4")) || (sign.getLine(2).contains("&5")) || (sign.getLine(2).contains("&6")) || (sign.getLine(2).contains("&7")) || (sign.getLine(2).contains("&8")) || (sign.getLine(2).contains("&9")) || (sign.getLine(2).contains("&0")) || (sign.getLine(2).contains("&a")) || (sign.getLine(2).contains("&b")) || (sign.getLine(2).contains("&c")) || (sign.getLine(2).contains("&d")) || (sign.getLine(2).contains("&e")) || (sign.getLine(2).contains("&f")) || (sign.getLine(2).contains("&o")) || (sign.getLine(2).contains("&l")) || (sign.getLine(2).contains("&k")) || (sign.getLine(2).contains("&n")) || (sign.getLine(2).contains("&m")) || (sign.getLine(2).contains("&r"))) { sign.setLine(2, sign.getLine(2).replace("&", "§")); } if ((sign.getLine(3).contains("&1")) || (sign.getLine(3).contains("&2")) || (sign.getLine(3).contains("&3")) || (sign.getLine(3).contains("&4")) || (sign.getLine(3).contains("&5")) || (sign.getLine(3).contains("&6")) || (sign.getLine(3).contains("&7")) || (sign.getLine(3).contains("&8")) || (sign.getLine(3).contains("&9")) || (sign.getLine(3).contains("&0")) || (sign.getLine(3).contains("&a")) || (sign.getLine(3).contains("&b")) || (sign.getLine(3).contains("&c")) || (sign.getLine(3).contains("&d")) || (sign.getLine(3).contains("&e")) || (sign.getLine(3).contains("&f")) || (sign.getLine(3).contains("&o")) || (sign.getLine(3).contains("&l")) || (sign.getLine(3).contains("&k")) || (sign.getLine(3).contains("&n")) || (sign.getLine(3).contains("&m")) || (sign.getLine(3).contains("&r"))) { sign.setLine(3, sign.getLine(3).replace("&", "§")); } } }
public final String getLine(final int index) { return event.getLine(index); }
/** * Event handler for Sign Changes * * @param e */ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false) 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"))) { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorNoPerm); return; } // Check that the player is on their island if (!(plugin.getGrid().playerIsOnIsland(player))) { player.sendMessage( 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())) { player.sendMessage( 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 { player.sendMessage( 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(); player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpsdeactivate); removeWarp(player.getUniqueId()); } } } // Set up the warp if (addWarp(player.getUniqueId(), e.getBlock().getLocation())) { player.sendMessage( ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).warpssuccess); e.setLine(0, ChatColor.GREEN + plugin.myLocale().warpswelcomeLine); } else { player.sendMessage( ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorDuplicate); e.setLine(0, ChatColor.RED + plugin.myLocale().warpswelcomeLine); } } } } } }
/* * Called when a sign is changed. */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onSignChange(SignChangeEvent event) { Player player = event.getPlayer(); WorldConfiguration wcfg = getWorldConfig(player); if (wcfg.signChestProtection) { if (event.getLine(0).equalsIgnoreCase("[Lock]")) { if (wcfg.isChestProtectedPlacement(event.getBlock(), player)) { player.sendMessage(ChatColor.DARK_RED + "You do not own the adjacent chest."); event.getBlock().breakNaturally(); event.setCancelled(true); return; } if (event.getBlock().getTypeId() != BlockID.SIGN_POST) { player.sendMessage( ChatColor.RED + "The [Lock] sign must be a sign post, not a wall sign."); event.getBlock().breakNaturally(); event.setCancelled(true); return; } if (!event.getLine(1).equalsIgnoreCase(player.getName())) { player.sendMessage(ChatColor.RED + "The first owner line must be your name."); event.getBlock().breakNaturally(); event.setCancelled(true); return; } int below = event.getBlock().getRelative(0, -1, 0).getTypeId(); if (below == BlockID.TNT || below == BlockID.SAND || below == BlockID.GRAVEL || below == BlockID.SIGN_POST) { player.sendMessage( ChatColor.RED + "That is not a safe block that you're putting this sign on."); event.getBlock().breakNaturally(); event.setCancelled(true); return; } event.setLine(0, "[Lock]"); player.sendMessage(ChatColor.YELLOW + "A chest or double chest above is now protected."); } } else if (!wcfg.disableSignChestProtectionCheck) { if (event.getLine(0).equalsIgnoreCase("[Lock]")) { player.sendMessage(ChatColor.RED + "WorldGuard's sign chest protection is disabled."); event.getBlock().breakNaturally(); event.setCancelled(true); return; } } if (!plugin.getGlobalRegionManager().canBuild(player, event.getBlock())) { player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area."); event.setCancelled(true); return; } }
public static Portal createPortal(SignChangeEvent event, Player player) { SignPost id = new SignPost(new Blox(event.getBlock())); Block idParent = id.getParent(); if (idParent == null) { return null; } if (Gate.getGatesByControlBlock(idParent).length == 0) return null; if (Portal.getByBlock(idParent) != null) { Stargate.debug("createPortal", "idParent belongs to existing gate"); return null; } Blox parent = new Blox(player.getWorld(), idParent.getX(), idParent.getY(), idParent.getZ()); Blox topleft = null; String name = filterName(event.getLine(0)); String destName = filterName(event.getLine(1)); String network = filterName(event.getLine(2)); String options = filterName(event.getLine(3)); boolean hidden = (options.indexOf('h') != -1 || options.indexOf('H') != -1); boolean alwaysOn = (options.indexOf('a') != -1 || options.indexOf('A') != -1); boolean priv = (options.indexOf('p') != -1 || options.indexOf('P') != -1); boolean free = (options.indexOf('f') != -1 || options.indexOf('F') != -1); boolean backwards = (options.indexOf('b') != -1 || options.indexOf('B') != -1); boolean show = (options.indexOf('s') != -1 || options.indexOf('S') != -1); // Check permissions for options. if (hidden && !Stargate.canOption(player, "hidden")) hidden = false; if (alwaysOn && !Stargate.canOption(player, "alwayson")) alwaysOn = false; if (priv && !Stargate.canOption(player, "private")) priv = false; if (free && !Stargate.canOption(player, "free")) free = false; if (backwards && !Stargate.canOption(player, "backwards")) backwards = false; if (show && !Stargate.canOption(player, "show")) show = false; // Can not create a non-fixed always-on gate. if (alwaysOn && destName.length() == 0) { alwaysOn = false; } // Show isn't useful if A is false if (show && !alwaysOn) { show = false; } // Moved the layout check so as to avoid invalid messages when not making a gate int modX = 0; int modZ = 0; float rotX = 0f; int facing = 0; if (idParent.getX() > id.getBlock().getX()) { modZ -= 1; rotX = 90f; facing = 2; } else if (idParent.getX() < id.getBlock().getX()) { modZ += 1; rotX = 270f; facing = 1; } else if (idParent.getZ() > id.getBlock().getZ()) { modX += 1; rotX = 180f; facing = 4; } else if (idParent.getZ() < id.getBlock().getZ()) { modX -= 1; rotX = 0f; facing = 3; } Gate[] possibleGates = Gate.getGatesByControlBlock(idParent); Gate gate = null; RelativeBlockVector buttonVector = null; for (Gate possibility : possibleGates) { if ((gate == null) && (buttonVector == null)) { RelativeBlockVector[] vectors = possibility.getControls(); RelativeBlockVector otherControl = null; for (RelativeBlockVector vector : vectors) { Blox tl = parent.modRelative( -vector.getRight(), -vector.getDepth(), -vector.getDistance(), modX, 1, modZ); if (gate == null) { if (possibility.matches(tl, modX, modZ, true)) { gate = possibility; topleft = tl; if (otherControl != null) { buttonVector = otherControl; } } } else if (otherControl != null) { buttonVector = vector; } otherControl = vector; } } } if ((gate == null) || (buttonVector == null)) { Stargate.debug("createPortal", "Could not find matching gate layout"); return null; } // Debug Stargate.debug( "createPortal", "h = " + hidden + " a = " + alwaysOn + " p = " + priv + " f = " + free + " b = " + backwards + " s = " + show); if ((network.length() < 1) || (network.length() > 11)) { network = Stargate.getDefaultNetwork(); } // Check if the player can create gates on this network if (!Stargate.canCreate(player, network)) { Stargate.debug( "createPortal", "Player doesn't have create permissions on network. Trying personal"); if (Stargate.canCreatePersonal(player)) { network = player.getName(); if (network.length() > 11) network = network.substring(0, 11); Stargate.debug("createPortal", "Creating personal portal"); Stargate.sendMessage(player, Stargate.getString("createPersonal")); } else { Stargate.debug("createPortal", "Player does not have access to network"); Stargate.sendMessage(player, Stargate.getString("createNetDeny")); return null; } } // Check if the player can create this gate layout String gateName = gate.getFilename(); gateName = gateName.substring(0, gateName.indexOf('.')); if (!Stargate.canCreateGate(player, gateName)) { Stargate.debug("createPortal", "Player does not have access to gate layout"); Stargate.sendMessage(player, Stargate.getString("createGateDeny")); return null; } if (name.length() < 1 || name.length() > 11) { Stargate.debug("createPortal", "Name length error"); Stargate.sendMessage(player, Stargate.getString("createNameLength")); return null; } if (getByName(name, network) != null) { Stargate.debug("createPortal", "Name Error"); Stargate.sendMessage(player, Stargate.getString("createExists")); return null; } // Check if there are too many gates in this network ArrayList<String> netList = allPortalsNet.get(network.toLowerCase()); if (Stargate.maxGates > 0 && netList != null && netList.size() >= Stargate.maxGates) { Stargate.sendMessage(player, Stargate.getString("createFull")); return null; } // Check if the user can create gates to this world. if (destName.length() > 0) { Portal p = Portal.getByName(destName, network); if (p != null) { String world = p.getWorld().getName(); if (!Stargate.canAccessWorld(player, world)) { Stargate.debug("canCreate", "Player does not have access to destination world"); Stargate.sendMessage(player, Stargate.getString("createWorldDeny")); return null; } } } // Bleh, gotta check to make sure none of this gate belongs to another gate. Boo slow. for (RelativeBlockVector v : gate.getBorder()) { Blox b = topleft.modRelative(v.getRight(), v.getDepth(), v.getDistance(), modX, 1, modZ); if (Portal.getByBlock(b.getBlock()) != null) { Stargate.debug("createPortal", "Gate conflicts with existing gate"); Stargate.sendMessage(player, Stargate.getString("createConflict")); return null; } } int cost = Stargate.getCreateCost(player, gate); if (cost > 0) { if (!Stargate.chargePlayer(player, null, gate.getCreateCost())) { String inFundMsg = Stargate.getString("ecoInFunds"); inFundMsg = Stargate.replaceVars( inFundMsg, new String[] {"%cost%", "%portal%"}, new String[] {iConomyHandler.format(cost), name}); Stargate.sendMessage(player, inFundMsg); Stargate.debug("createPortal", "Insufficient Funds"); return null; } String deductMsg = Stargate.getString("ecoDeduct"); deductMsg = Stargate.replaceVars( deductMsg, new String[] {"%cost%", "%portal%"}, new String[] {iConomyHandler.format(cost), name}); Stargate.sendMessage(player, deductMsg, false); } Portal portal = null; Blox button = null; // No button on an always-open gate. if (!alwaysOn) { button = topleft.modRelative( buttonVector.getRight(), buttonVector.getDepth(), buttonVector.getDistance() + 1, modX, 1, modZ); button.setType(Material.STONE_BUTTON.getId()); button.setData(facing); } portal = new Portal( topleft, modX, modZ, rotX, id, button, destName, name, true, network, gate, player.getName(), hidden, alwaysOn, priv, free, backwards, show); // Open always on gate if (portal.isAlwaysOn()) { Portal dest = Portal.getByName(destName, portal.getNetwork()); if (dest != null) { portal.open(true); dest.drawSign(); } // Set the inside of the gate to its closed material } else { for (Blox inside : portal.getEntrances()) { inside.setType(portal.getGate().getPortalBlockClosed()); } } // Open any always on gate pointing at this gate for (String originName : allPortalsNet.get(portal.getNetwork().toLowerCase())) { Portal origin = Portal.getByName(originName, portal.getNetwork()); if (origin == null) continue; if (!origin.getDestinationName().equalsIgnoreCase(portal.getName())) continue; if (!origin.isVerified()) continue; if (origin.isFixed()) origin.drawSign(); if (origin.isAlwaysOn()) origin.open(true); } saveAllGates(portal.getWorld()); return portal; }