org.spongepowered.api.block.tileentity.Sign Java Examples

The following examples show how to use org.spongepowered.api.block.tileentity.Sign. 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: EconomyUtil.java    From GriefDefender with MIT License 6 votes vote down vote up
public void sellCancelConfirmation(CommandSource src, Claim claim, Sign sign) {
    final Player player = (Player) src;
    final GDClaim gdClaim = (GDClaim) claim;
    // check sell access
    if (gdClaim.allowEdit(player) != null) {
        GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().CLAIM_NOT_YOURS);
        return;
    }

    final Component sellCancelConfirmationText = TextComponent.builder()
            .append("\n[")
            .append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN))
            .append("]\n")
            .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(src, createSellCancelConfirmed(src, claim, sign), true)))
            .build();
    final Component message = TextComponent.builder()
            .append(MessageCache.getInstance().ECONOMY_CLAIM_SALE_CANCEL_CONFIRMATION)
            .append("\n")
            .append(sellCancelConfirmationText)
            .build();
    GriefDefenderPlugin.sendMessage(src, message);
}
 
Example #2
Source File: SignListener.java    From UltimateCore with MIT License 6 votes vote down vote up
@Listener
public void onSignClick(InteractBlockEvent.Secondary event, @Root Player p) {
    if (!event.getTargetBlock().getLocation().isPresent() || !event.getTargetBlock().getLocation().get().getTileEntity().isPresent()) {
        return;
    }
    if (!(event.getTargetBlock().getLocation().get().getTileEntity().get() instanceof Sign)) {
        return;
    }
    Sign sign = (Sign) event.getTargetBlock().getLocation().get().getTileEntity().get();
    for (UCSign usign : UltimateCore.get().getSignService().get().getRegisteredSigns()) {
        if (sign.getSignData().get(0).orElse(Text.of()).toPlain().equalsIgnoreCase("[" + usign.getIdentifier() + "]")) {
            if (!p.hasPermission(usign.getUsePermission().get())) {
                Messages.send(p, "core.nopermissions");
            }
            SignUseEvent cevent = new SignUseEvent(usign, sign.getLocation(), Cause.builder().append(UltimateCore.getContainer()).append(p).build(EventContext.builder().build()));
            Sponge.getEventManager().post(cevent);
            if (!cevent.isCancelled()) {
                usign.onExecute(p, sign);
            }
        }
    }
}
 
Example #3
Source File: SigneditCommand.java    From UltimateCore with MIT License 6 votes vote down vote up
@Override
public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException {
    checkIfPlayer(sender);
    Player p = (Player) sender;

    int line = args.<Integer>getOne("line").get();
    Text text = VariableUtil.replaceVariables(Messages.toText(args.<String>getOne("text").get()), sender);

    try {
        BlockSelectionTask task = new BlockSelectionTask();
        task.select(p,
                (loc) -> loc.getTileEntity().isPresent() && loc.getTileEntity().get() instanceof Sign,
                (loc) -> {
                    Sign sign = (Sign) loc.getTileEntity().get();
                    sign.offer(Keys.SIGN_LINES, sign.getSignData().lines().set(line - 1, text).get());
                    Messages.send(sender, "sign.command.signedit.success", "%line%", line, "%text%", text);
                });
        return CommandResult.success();
    } catch (Exception ex) {
        throw Messages.error(sender, "sign.command.signedit.nosign");
    }
}
 
Example #4
Source File: Region.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
private void updateSigns(String fname) {
    if (!RedProtect.get().config.configRoot().region_settings.enable_flag_sign) {
        return;
    }
    List<Location> locs = RedProtect.get().config.getSigns(this.getID());
    if (locs.size() > 0) {
        for (Location loc : locs) {
            if (loc.getTileEntity().isPresent() && loc.getTileEntity().get() instanceof Sign) {
                Sign s = (Sign) loc.getTileEntity().get();
                ListValue<Text> lines = s.lines();
                if (lines.get(0).toPlain().equalsIgnoreCase("[flag]")) {
                    if (lines.get(1).toPlain().equalsIgnoreCase(fname) && this.name.equalsIgnoreCase(lines.get(2).toPlain())) {
                        lines.set(3, RedProtect.get().getUtil().toText(RedProtect.get().lang.get("region.value") + " " + RedProtect.get().lang.translBool(getFlagString(fname))));
                        s.offer(lines);
                        RedProtect.get().config.putSign(this.getID(), loc);
                    }
                } else {
                    RedProtect.get().config.removeSign(this.getID(), loc);
                }
            } else {
                RedProtect.get().config.removeSign(this.getID(), loc);
            }
        }
    }
}
 
Example #5
Source File: SignUtil.java    From GriefDefender with MIT License 6 votes vote down vote up
public static void updateSignRentable(Claim claim, Sign sign) {
    if (!isRentSign(claim, sign)) {
        return;
    }


    final PaymentType paymentType = claim.getEconomyData().getPaymentType();
    final List<Text> lines = createRentSignLines(claim.getEconomyData().getRentRate(), paymentType);
    final SignData signData = sign.getOrCreate(SignData.class).orElse(null);
    if (signData != null) { 
        for (int i = 0; i < lines.size(); i++) {
            signData.addElement(i, lines.get(i));
        }
        sign.offer(signData);
    }
}
 
Example #6
Source File: SignUtil.java    From GriefDefender with MIT License 6 votes vote down vote up
private static Consumer<CommandSource> createSaleConfirmationConsumer(CommandSource src, Claim claim, Sign sign,  double price) {
    return confirm -> {
        claim.getEconomyData().setSalePrice(price);
        claim.getEconomyData().setForSale(true);
        claim.getEconomyData().setSaleSignPosition(sign.getLocation().getBlockPosition());
        claim.getData().save();
        final List<Text> lines = createSellSignLines(claim.getEconomyData().getSalePrice());
        final SignData signData = sign.getOrCreate(SignData.class).orElse(null);
        if (signData != null) { 
            for (int i = 0; i < lines.size(); i++) {
                signData.addElement(i, lines.get(i));
            }
            sign.offer(signData);
        }
        final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_CLAIM_SALE_CONFIRMED,
                ImmutableMap.of("amount", price));
        GriefDefenderPlugin.sendMessage(src, message);
    };
}
 
Example #7
Source File: SignUtil.java    From GriefDefender with MIT License 6 votes vote down vote up
public static void setClaimForSale(Claim claim, Player player, Sign sign, double price) {
    if (claim.isWilderness()) {
        GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().ECONOMY_CLAIM_NOT_FOR_SALE);
        return;
    }

    // if not owner of claim, validate perms
    if (((GDClaim) claim).allowEdit(player) != null || !player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_OTHERS)) {
        TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIM_NOT_YOURS);
        return;
    }

    final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_CLAIM_SALE_CONFIRMATION,
            ImmutableMap.of(
            "amount", price));
    GriefDefenderPlugin.sendMessage(player, message);

    final Component saleConfirmationText = TextComponent.builder("")
            .append("\n[")
            .append("Confirm", TextColor.GREEN)
            .append("]\n")
            .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createSaleConfirmationConsumer(player, claim, sign, price))))
            .build();
    GriefDefenderPlugin.sendMessage(player, saleConfirmationText);
}
 
Example #8
Source File: SignUtil.java    From GriefDefender with MIT License 6 votes vote down vote up
public static Sign getSign(Location<World> location) {
    if (location == null) {
        return null;
    }

    final TileEntity tileEntity = location.getTileEntity().orElse(null);
    if (tileEntity == null) {
        return null;
    }

    if (!(tileEntity instanceof Sign)) {
        return null;
    }

    return (Sign) tileEntity;
}
 
Example #9
Source File: SignUtil.java    From GriefDefender with MIT License 6 votes vote down vote up
public static Sign getRentSign(Location<World> location) {
    if (location == null) {
        return null;
    }

    final Sign sign = getSign(location);
    if (sign == null) {
        return null;
    }

    final String header = sign.lines().get(0).toPlain();
    if (header.equalsIgnoreCase(RENT_SIGN)) {
        return sign;
    }

    return null;
}
 
Example #10
Source File: SignUtil.java    From GriefDefender with MIT License 6 votes vote down vote up
public static Sign getSellSign(Location<World> location) {
    if (location == null) {
        return null;
    }

    final Sign sign = getSign(location);
    if (sign == null) {
        return null;
    }

    final String header = sign.lines().get(0).toPlain();
    if (header.equalsIgnoreCase(SELL_SIGN)) {
        return sign;
    }

    return null;
}
 
Example #11
Source File: EconomyUtil.java    From GriefDefender with MIT License 6 votes vote down vote up
private Consumer<CommandSource> createSellCancelConfirmed(CommandSource src, Claim claim, Sign sign) {
    return confirm -> {
        if (!claim.getEconomyData().isForSale()) {
            return;
        }
        Location<World> location = null;
        if (sign != null) {
            location = sign.getLocation();
        } else {
            final Sign saleSign = SignUtil.getSign(((GDClaim) claim).getWorld(), claim.getEconomyData().getSaleSignPosition());
            if (saleSign != null) {
                location = saleSign.getLocation();
            }
        }
        if (location != null && location.getBlockType() != BlockTypes.AIR) {
            location.setBlockType(BlockTypes.AIR);
            SignUtil.resetSellData(claim);
            claim.getData().save();
            GriefDefenderPlugin.sendMessage(src, MessageCache.getInstance().ECONOMY_CLAIM_SALE_CANCELLED);
        }
    };
}
 
Example #12
Source File: SignUtil.java    From GriefDefender with MIT License 5 votes vote down vote up
public static Sign getSign(World world, Vector3i pos) {
    if (pos == null) {
        return null;
    }

    // Don't load chunks to update signs
    if (BlockUtil.getInstance().getLoadedChunkWithoutMarkingActive(world, pos.getX() >> 4, pos.getZ() >> 4) == null) {
        return null;
    }

    return getSign(new Location<>(world, pos));
}
 
Example #13
Source File: SignUtil.java    From GriefDefender with MIT License 5 votes vote down vote up
public static boolean isSellSign(Sign sign) {
    if (sign == null) {
        return false;
    }

    final String header = sign.lines().get(0).toPlain();
    if (header.equalsIgnoreCase(SELL_SIGN)) {
        return true;
    }

    return false;
}
 
Example #14
Source File: SignUtil.java    From GriefDefender with MIT License 5 votes vote down vote up
public static boolean isRentSign(Sign sign) {
    if (sign == null) {
        return false;
    }

    final String header = sign.lines().get(0).toPlain();
    if (header.equalsIgnoreCase(RENT_SIGN)) {
        return true;
    }

    return false;
}
 
Example #15
Source File: SignUtil.java    From GriefDefender with MIT License 5 votes vote down vote up
public static boolean isRentSign(Claim claim, Sign sign) {
    if (sign == null) {
        return false;
    }

    if (claim.getEconomyData() == null) {
        return false;
    }

    if (claim.getEconomyData().getRentSignPosition() == null) {
        return isRentSign(sign);
    }

    return claim.getEconomyData().getRentSignPosition().equals(sign.getLocation().getBlockPosition());
}
 
Example #16
Source File: PlayerListener.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
private void changeFlag(Region r, String flag, Player p, Sign s) {
    if (r.setFlag(RedProtect.get().getVersionHelper().getCause(p), flag, !r.getFlagBool(flag))) {
        RedProtect.get().lang.sendMessage(p, RedProtect.get().lang.get("cmdmanager.region.flag.set").replace("{flag}", "'" + flag + "'") + " " + r.getFlagBool(flag));
        RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET FLAG " + flag + " of region " + r.getName() + " to " + RedProtect.get().lang.translBool(r.getFlagString(flag)));
        s.lines().set(3, RedProtect.get().getUtil().toText(RedProtect.get().lang.get("region.value") + " " + RedProtect.get().lang.translBool(r.getFlagString(flag))));
        if (!RedProtect.get().config.getSigns(r.getID()).contains(s.getLocation())) {
            RedProtect.get().config.putSign(r.getID(), s.getLocation());
        }
    }
}
 
Example #17
Source File: BlockListener.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Listener(order = Order.FIRST, beforeModifications = true)
public void onBlockBreak(ChangeBlockEvent.Break e, @First Player p) {
    RedProtect.get().logger.debug(LogLevel.BLOCKS, "BlockListener - Is ChangeBlockEvent.Break event!");

    BlockSnapshot b = e.getTransactions().get(0).getOriginal();
    Location<World> bloc = b.getLocation().get();

    boolean antih = RedProtect.get().config.configRoot().region_settings.anti_hopper;
    Region r = RedProtect.get().rm.getTopRegion(bloc, this.getClass().getName());

    if (!RedProtect.get().ph.hasPerm(p, "redprotect.bypass")) {
        BlockSnapshot ib = bloc.getBlockRelative(Direction.UP).createSnapshot();
        if ((antih && !cont.canBreak(p, ib)) || !cont.canBreak(p, b)) {
            RedProtect.get().lang.sendMessage(p, "blocklistener.container.breakinside");
            e.setCancelled(true);
            return;
        }
    }

    if (r == null && canBreakList(p.getWorld(), b.getState().getType().getName())) {
        return;
    }

    if (r != null && b.getState().getType().equals(BlockTypes.MOB_SPAWNER) && r.allowSpawner(p)) {
        return;
    }

    if (r != null && r.canBuild(p) && b.getState().getType().getName().equalsIgnoreCase("sign")) {
        Sign s = (Sign) b.getLocation().get().getTileEntity().get();
        if (s.lines().get(0).toPlain().equalsIgnoreCase("[flag]")) {
            RedProtect.get().config.removeSign(r.getID(), b.getLocation().get());
            return;
        }
    }

    if (r != null && !r.canBuild(p) && !r.canTree(b) && !r.canMining(b) && !r.canCrops(b) && !r.canBreak(b)) {
        RedProtect.get().lang.sendMessage(p, "blocklistener.region.cantbuild");
        e.setCancelled(true);
    }
}
 
Example #18
Source File: SignUtil.java    From GriefDefender with MIT License 4 votes vote down vote up
private static Consumer<CommandSource> createRentConfirmationConsumer(CommandSource src, Claim claim, Sign sign, double rate, int min, int max, PaymentType paymentType) {
    return confirm -> {
        resetRentData(claim);
        claim.getEconomyData().setRentRate(rate);
        claim.getEconomyData().setPaymentType(paymentType);
        if (min > 0) {
            if (min > max) {
                claim.getEconomyData().setRentMinTime(max);
            } else {
                claim.getEconomyData().setRentMinTime(min);
            }
        }
        if (max > 0) {
            final int rentMaxLimit = GriefDefenderPlugin.getActiveConfig(((GDClaim) claim).getWorld().getUniqueId()).getConfig().economy.rentMaxTimeLimit;
            if (max > rentMaxLimit) {
                claim.getEconomyData().setRentMaxTime(rentMaxLimit);
            } else {
                claim.getEconomyData().setRentMaxTime(max);
            }

            claim.getEconomyData().setRentEndDate(Instant.now().plus(max, paymentType == PaymentType.DAILY ? ChronoUnit.DAYS : ChronoUnit.HOURS));
        }
        claim.getEconomyData().setForRent(true);
        Sign rentSign = sign;
        if (rentSign == null) {
            rentSign = SignUtil.getSign(((GDClaim) claim).getWorld(), claim.getEconomyData().getRentSignPosition());
        }

        if (rentSign != null) {
            claim.getEconomyData().setRentSignPosition(rentSign.getLocation().getBlockPosition());
            claim.getData().save();
            final List<Text> lines = createRentSignLines(rate, paymentType);
            final SignData signData = rentSign.getOrCreate(SignData.class).orElse(null);
            if (signData != null) { 
                for (int i = 0; i < lines.size(); i++) {
                    signData.addElement(i, lines.get(i));
                }
                sign.offer(signData);
            }
        }

        final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_CLAIM_RENT_CONFIRMED,
                ImmutableMap.of(
                        "amount", "$" + rate,
                        "type", paymentType == PaymentType.DAILY ? MessageCache.getInstance().LABEL_DAY : MessageCache.getInstance().LABEL_HOUR));
        GriefDefenderPlugin.sendMessage(src, message);
    };
}
 
Example #19
Source File: SignUpdateTask.java    From GriefDefender with MIT License 4 votes vote down vote up
@Override
public void run() {
    for (World world : Sponge.getServer().getWorlds()) {
        final GDClaimManager claimManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(world.getUniqueId());
        Set<Claim> claimList = claimManager.getWorldClaims();
        if (claimList.size() == 0) {
            continue;
        }

        final Iterator<Claim> iterator = new HashSet<>(claimList).iterator();
        while (iterator.hasNext()) {
            final GDClaim claim = (GDClaim) iterator.next();
            final Vector3i pos = claim.getEconomyData().getRentSignPosition();
            if (pos == null || claim.getEconomyData() == null || claim.getEconomyData().getRentEndDate() == null) {
                continue;
            }

            final Sign sign = SignUtil.getSign(world, pos);
            if (SignUtil.isRentSign(claim, sign)) {
                final List<Text> lines = sign.getSignData().asList();
                final String header = lines.get(0).toPlain();
                if (header == null) {
                    // Should not happen but just in case
                    continue;
                }

                final Duration duration = Duration.between(Instant.now(), claim.getEconomyData().getRentEndDate());
                final long seconds = duration.getSeconds();
                if (seconds <= 0) {
                    if (claim.getEconomyData().isRented()) {
                        final UUID renterUniqueId = claim.getEconomyData().getRenters().get(0);
                        final GDPermissionUser renter = PermissionHolderCache.getInstance().getOrCreateUser(renterUniqueId);
                        if (renter != null && renter.getOnlinePlayer() != null) {
                            GriefDefenderPlugin.sendMessage(renter.getOnlinePlayer(), MessageCache.getInstance().ECONOMY_CLAIM_RENT_CANCELLED);
                        }
                    }
                    sign.getLocation().setBlockType(BlockTypes.AIR);
                    SignUtil.resetRentData(claim);
                    claim.getData().save();
                    continue;
                }

                final String remainingTime = String.format("%02d:%02d:%02d", duration.toDays(), (seconds % 86400 ) / 3600, (seconds % 3600) / 60);
                final SignData signData = sign.getOrCreate(SignData.class).orElse(null);
                if (signData != null) { 
                    signData.addElement(3, Text.of(TextColors.DARK_AQUA, remainingTime));
                    sign.offer(signData);
                }
            }
        }
    }
}
 
Example #20
Source File: EconomyUtil.java    From GriefDefender with MIT License 4 votes vote down vote up
private Consumer<CommandSource> createRentCancelConfirmed(CommandSource src, Claim claim, Sign sign, boolean addDelinquent) {
    return confirm -> {
        if (!claim.getEconomyData().isForRent() && !claim.getEconomyData().isRented()) {
            return;
        }
        final Player player = (Player) src;
        boolean isRenter = false;
        for (UUID uuid : claim.getEconomyData().getRenters()) {
            if (player.getUniqueId().equals(uuid)) {
                isRenter = true;
                break;
            }
        }
        if (player.getUniqueId().equals(claim.getOwnerUniqueId()) || (claim.isAdminClaim() && !isRenter)) {
                Location<World> location = null;
            if (sign != null) {
                location = sign.getLocation();
            } else {
                final Sign rentSign = SignUtil.getSign(((GDClaim) claim).getWorld(), claim.getEconomyData().getRentSignPosition());
                if (rentSign != null) {
                    location = rentSign.getLocation();
                }
            }
            if (location != null) {
                location.setBlockType(BlockTypes.AIR);
            }
            SignUtil.resetRentData(claim);
            claim.getData().save();
            GriefDefenderPlugin.sendMessage(src, MessageCache.getInstance().ECONOMY_CLAIM_RENT_CANCELLED);
        } else if (claim.getEconomyData().isRented()) {
            // reset sign
            claim.getEconomyData().setForRent(true);
            SignUtil.updateSignRentable(claim, sign);
            claim.getEconomyData().setRentSignPosition(null);
            claim.getEconomyData().getRenters().clear();
            claim.getEconomyData().setRentStartDate(null);
            if (addDelinquent) {
                claim.getEconomyData().getDelinquentRenters().add(player.getUniqueId());
            }
            claim.removeUserTrust(player.getUniqueId(), TrustTypes.NONE);
            claim.getData().save();
            final GDPermissionUser owner = PermissionHolderCache.getInstance().getOrCreateUser(claim.getOwnerUniqueId());
            boolean rentRestore = false;
            if (claim.isAdminClaim()) {
                rentRestore = GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentSchematicRestoreAdmin;
            } else {
                rentRestore = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Boolean.class), owner == null ? GriefDefenderPlugin.DEFAULT_HOLDER : owner, Options.RENT_RESTORE, claim).booleanValue();
            }
            if (rentRestore) {
                // expiration days keep is up
                // restore schematic and remove renter rights
                final ClaimSchematic schematic = claim.getSchematics().get("__rent__");
                if (schematic != null) {
                    if (schematic.apply()) {
                        if (owner != null && owner.getOnlinePlayer() != null) {
                            owner.getOnlinePlayer().sendMessage(Text.of("Claim '" + ((GDClaim) claim).getFriendlyName() + "' has been restored."));
                        }
                    }
                }
            }
            GriefDefenderPlugin.sendMessage(src, MessageCache.getInstance().ECONOMY_CLAIM_RENT_CANCELLED);
        }
    };
}
 
Example #21
Source File: PlayerEventHandler.java    From GriefDefender with MIT License 4 votes vote down vote up
@Listener(order = Order.FIRST, beforeModifications = true)
public void onPlayerInteractBlockPrimary(InteractBlockEvent.Primary.MainHand event) {
    final Location<World> location = event.getTargetBlock().getLocation().orElse(null);
    if (location == null) {
        return;
    }

    User user = CauseContextHelper.getEventUser(event);
    final Object source = CauseContextHelper.getEventFakePlayerSource(event);
    final Player player = source instanceof Player ? (Player) source : null;
    if (player == null || NMSUtil.getInstance().isFakePlayer(player)) {
        if (user == null) {
            user = player;
        }

        this.handleFakePlayerInteractBlockPrimary(event, user, source);
        return;
    }

    final HandType handType = event.getHandType();
    final ItemStack itemInHand = player.getItemInHand(handType).orElse(ItemStack.empty());
    if (handleItemInteract(event, player, player.getWorld(), itemInHand).isCancelled()) {
        event.setCancelled(true);
        return;
    }

    final BlockSnapshot clickedBlock = event.getTargetBlock();
    final String id = GDPermissionManager.getInstance().getPermissionIdentifier(clickedBlock);
    final GDPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
    final GDClaim claim = this.dataStore.getClaimAt(location);
    // Handle rent/buy signs
    if (!playerData.claimMode) {
        final GriefDefenderConfig<?> activeConfig = GriefDefenderPlugin.getActiveConfig(location.getExtent().getUniqueId());
        if (activeConfig.getConfig().economy.isSellSignEnabled() ||  activeConfig.getConfig().economy.isRentSignEnabled()) {
            final Sign sign = SignUtil.getSign(location);
            if (sign != null) {
                if (activeConfig.getConfig().economy.isSellSignEnabled() && SignUtil.isSellSign(sign)) {
                    if (claim.getEconomyData() != null && claim.getEconomyData().isForSale()) {
                        event.setCancelled(true);
                        EconomyUtil.getInstance().sellCancelConfirmation(player, claim, sign);
                        return;
                    }
                } else if (GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentSystem  && activeConfig.getConfig().economy.isRentSignEnabled() && SignUtil.isRentSign(claim, sign)) {
                    if ((claim.getEconomyData() != null && claim.getEconomyData().isForRent()) || claim.getEconomyData().isRented() ) {
                        event.setCancelled(true);
                        EconomyUtil.getInstance().rentCancelConfirmation(player, claim, sign);
                        return;
                    }
                }
            }
        }
    }

    if (playerData.claimMode) {
        return;
    }
    // check give pet
    if (playerData.petRecipientUniqueId != null) {
        playerData.petRecipientUniqueId = null;
        GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().COMMAND_PET_TRANSFER_CANCEL);
        event.setCancelled(true);
        return;
    }
    if (!GDFlags.INTERACT_BLOCK_PRIMARY || !GriefDefenderPlugin.getInstance().claimsEnabledForWorld(player.getWorld().getUniqueId())) {
        return;
    }
    if (GriefDefenderPlugin.isTargetIdBlacklisted(Flags.INTERACT_BLOCK_PRIMARY.getName(), event.getTargetBlock().getState(), player.getWorld().getProperties())) {
        return;
    }

    GDTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.startTimingIfSync();
    final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.INTERACT_BLOCK_PRIMARY, source, clickedBlock.getState(), player, TrustTypes.BUILDER, true);
    if (result == Tristate.FALSE) {
        if (GriefDefenderPlugin.isTargetIdBlacklisted(Flags.BLOCK_BREAK.getName(), clickedBlock.getState(), player.getWorld().getProperties())) {
            GDTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.stopTimingIfSync();
            return;
        }
        if (GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.BLOCK_BREAK, source, clickedBlock.getState(), player, TrustTypes.BUILDER, true) == Tristate.TRUE) {
            GDTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.stopTimingIfSync();
            return;
        }

        // Don't send a deny message if the player is holding an investigation tool
        if (Sponge.getServer().getRunningTimeTicks() != lastInteractItemPrimaryTick || lastInteractItemCancelled != true) {
            if (!PlayerUtil.getInstance().hasItemInOneHand(player, GriefDefenderPlugin.getInstance().investigationTool.getType())) {
                this.sendInteractBlockDenyMessage(itemInHand, clickedBlock, claim, player, playerData, handType);
            }
        }
        event.setCancelled(true);
        GDTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.stopTimingIfSync();
        return;
    }
    GDTimings.PLAYER_INTERACT_BLOCK_PRIMARY_EVENT.stopTimingIfSync();
}
 
Example #22
Source File: WarpSign.java    From UltimateCore with MIT License 4 votes vote down vote up
@Override
public boolean onExecute(Player p, Sign sign) {
    return true;
}
 
Example #23
Source File: UCSign.java    From UltimateCore with MIT License 2 votes vote down vote up
/**
 * Called when a player executes the sign, normally by clicking it.
 * Permission checks will be done by the implementation.
 *
 * @param p    The player who executed the sign
 * @param sign The sign which has been executed
 */
boolean onExecute(Player p, Sign sign);