org.spongepowered.api.event.block.tileentity.ChangeSignEvent Java Examples
The following examples show how to use
org.spongepowered.api.event.block.tileentity.ChangeSignEvent.
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: BuildPermListener.java From Nations with MIT License | 6 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onSignChanged(ChangeSignEvent event, @First User player) { if (!ConfigHandler.getNode("worlds").getNode(event.getTargetTile().getLocation().getExtent().getName()).getNode("enabled").getBoolean()) { return; } if (player.hasPermission("nations.admin.bypass.perm.build")) { return; } if (!DataHandler.getPerm("build", player.getUniqueId(), event.getTargetTile().getLocation())) { event.setCancelled(true); } }
Example #2
Source File: SignListener.java From UltimateCore with MIT License | 6 votes |
@Listener(order = Order.EARLY) public void onSignCreate(ChangeSignEvent event, @Root Player p) { //Sign colors List<Text> lines = event.getText().lines().get(); lines.set(0, TextUtil.replaceColors(lines.get(0), p, "uc.sign")); lines.set(1, TextUtil.replaceColors(lines.get(1), p, "uc.sign")); lines.set(2, TextUtil.replaceColors(lines.get(2), p, "uc.sign")); lines.set(3, TextUtil.replaceColors(lines.get(3), p, "uc.sign")); event.getText().setElements(lines); //Registered signs for (UCSign sign : UltimateCore.get().getSignService().get().getRegisteredSigns()) { if (event.getText().get(0).orElse(Text.of()).toPlain().equalsIgnoreCase("[" + sign.getIdentifier() + "]")) { if (!p.hasPermission(sign.getCreatePermission().get())) { Messages.send(p, "core.nopermissions"); } SignCreateEvent cevent = new SignCreateEvent(sign, event.getTargetTile().getLocation(), Cause.builder().append(UltimateCore.getContainer()).append(p).build(EventContext.builder().build())); Sponge.getEventManager().post(cevent); if (!cevent.isCancelled() && sign.onCreate(p, event)) { //Color sign event.getTargetTile().offer(Keys.SIGN_LINES, event.getText().setElement(0, Text.of(TextColors.AQUA, "[" + StringUtil.firstUpperCase(sign.getIdentifier()) + "]")).asList()); Messages.send(p, "sign.create", "%sign%", sign.getIdentifier()); } } } }
Example #3
Source File: BlockEventHandler.java From GriefDefender with MIT License | 5 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onSignChanged(ChangeSignEvent event) { final User user = CauseContextHelper.getEventUser(event); if (user == null) { return; } if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(event.getTargetTile().getLocation().getExtent().getUniqueId())) { return; } GDTimings.SIGN_CHANGE_EVENT.startTimingIfSync(); Location<World> location = event.getTargetTile().getLocation(); // Prevent users exploiting signs GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(location); if (GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.INTERACT_BLOCK_SECONDARY, user, location.getBlock(), user, TrustTypes.ACCESSOR, true) == Tristate.FALSE) { if (user instanceof Player) { event.setCancelled(true); final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_ACCESS, ImmutableMap.of("player", claim.getOwnerName())); GriefDefenderPlugin.sendClaimDenyMessage(claim, (Player) user, message); return; } } GDTimings.SIGN_CHANGE_EVENT.stopTimingIfSync(); }
Example #4
Source File: SignChangeListener.java From EssentialCmds with MIT License | 5 votes |
@Listener public void onSignChange(ChangeSignEvent event, @First Player player) { SignData signData = event.getText(); if (signData.getValue(Keys.SIGN_LINES).isPresent()) { String line0 = signData.getValue(Keys.SIGN_LINES).get().get(0).toPlain(); String line1 = signData.getValue(Keys.SIGN_LINES).get().get(1).toPlain(); String line2 = signData.getValue(Keys.SIGN_LINES).get().get(2).toPlain(); String line3 = signData.getValue(Keys.SIGN_LINES).get().get(3).toPlain(); if (line0.equals("[Warp]")) { if (Utils.getWarps().contains(line1)) { signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(0, Text.of(TextColors.DARK_BLUE, "[Warp]"))); } else { signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(0, Text.of(TextColors.DARK_RED, "[Warp]"))); } } else if (player != null && player.hasPermission("essentialcmds.color.sign.use")) { signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(0, TextSerializers.formattingCode('&').deserialize(line0))); signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(1, TextSerializers.formattingCode('&').deserialize(line1))); signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(2, TextSerializers.formattingCode('&').deserialize(line2))); signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(3, TextSerializers.formattingCode('&').deserialize(line3))); } } }
Example #5
Source File: BlockEventHandler.java From GriefPrevention with MIT License | 4 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onSignChanged(ChangeSignEvent event) { final User user = CauseContextHelper.getEventUser(event); if (user == null) { return; } if (!GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getTargetTile().getLocation().getExtent().getProperties())) { return; } GPTimings.SIGN_CHANGE_EVENT.startTimingIfSync(); Location<World> location = event.getTargetTile().getLocation(); // Prevent users exploiting signs GPClaim claim = GriefPreventionPlugin.instance.dataStore.getClaimAt(location); if (GPPermissionHandler.getClaimPermission(event, location, claim, GPPermissions.INTERACT_BLOCK_SECONDARY, user, location.getBlock(), user, TrustType.ACCESSOR, true) == Tristate.FALSE) { if (user instanceof Player) { event.setCancelled(true); final Text message = GriefPreventionPlugin.instance.messageData.permissionAccess .apply(ImmutableMap.of( "player", Text.of(claim.getOwnerName()))).build(); GriefPreventionPlugin.sendClaimDenyMessage(claim, (Player) user, message); return; } } // send sign content to online administrators if (!GriefPreventionPlugin.getActiveConfig(location.getExtent().getProperties()) .getConfig().general.generalAdminSignNotifications) { GPTimings.SIGN_CHANGE_EVENT.stopTimingIfSync(); return; } World world = location.getExtent(); StringBuilder lines = new StringBuilder(" placed a sign @ " + GriefPreventionPlugin.getfriendlyLocationString(event.getTargetTile().getLocation())); boolean notEmpty = false; for (int i = 0; i < event.getText().lines().size(); i++) { String withoutSpaces = Text.of(event.getText().lines().get(i)).toPlain().replace(" ", ""); if (!withoutSpaces.isEmpty()) { notEmpty = true; lines.append("\n " + event.getText().lines().get(i)); } } String signMessage = lines.toString(); // prevent signs with blocked IP addresses if (!user.hasPermission(GPPermissions.OVERRIDE_SPAM) && GriefPreventionPlugin.instance.containsBlockedIP(signMessage)) { event.setCancelled(true); GPTimings.SIGN_CHANGE_EVENT.stopTimingIfSync(); return; } // if not empty and wasn't the same as the last sign, log it and remember it for later GPPlayerData playerData = this.dataStore.getOrCreatePlayerData(world, user.getUniqueId()); if (notEmpty && playerData.lastMessage != null && !playerData.lastMessage.equals(signMessage)) { GriefPreventionPlugin.addLogEntry(user.getName() + lines.toString().replace("\n ", ";"), null); //PlayerEventHandler.makeSocialLogEntry(player.get().getName(), signMessage); playerData.lastMessage = signMessage; if (!user.hasPermission(GPPermissions.EAVES_DROP_SIGNS)) { Collection<Player> players = (Collection<Player>) Sponge.getGame().getServer().getOnlinePlayers(); for (Player otherPlayer : players) { if (otherPlayer.hasPermission(GPPermissions.EAVES_DROP_SIGNS)) { otherPlayer.sendMessage(Text.of(TextColors.GRAY, user.getName(), signMessage)); } } } } GPTimings.SIGN_CHANGE_EVENT.stopTimingIfSync(); }
Example #6
Source File: RegionBuilder.java From RedProtect with GNU General Public License v3.0 | 4 votes |
protected void setErrorSign(ChangeSignEvent e, String error) { SignData sign = e.getText(); sign.set(sign.getValue(Keys.SIGN_LINES).get().set(0, RedProtect.get().getUtil().toText(RedProtect.get().lang.get("regionbuilder.signerror")))); this.setError(e.getCause().first(Player.class).get(), error); }
Example #7
Source File: BlockListener.java From RedProtect with GNU General Public License v3.0 | 4 votes |
void setErrorSign(ChangeSignEvent e, Player p, String error) { List<Text> lines = e.getTargetTile().get(Keys.SIGN_LINES).get(); lines.set(0, RedProtect.get().getUtil().toText(RedProtect.get().lang.get("regionbuilder.signerror"))); e.getTargetTile().offer(Keys.SIGN_LINES, lines); RedProtect.get().lang.sendMessage(p, RedProtect.get().lang.get("regionbuilder.signerror") + ": " + error); }
Example #8
Source File: WarpSign.java From UltimateCore with MIT License | 4 votes |
@Override public boolean onCreate(Player p, ChangeSignEvent event) { return true; }
Example #9
Source File: UCSign.java From UltimateCore with MIT License | 2 votes |
/** * Called when a player creates a new sign, normally by clicking the confirm button after typing a sign. * Permission checks and messages will be done by the implementation. * * @param p The player who created the sign * @param event The event which was thrown after creating the sign */ boolean onCreate(Player p, ChangeSignEvent event);