Search in sources :

Example 1 with Caption

use of com.plotsquared.core.configuration.caption.Caption in project PlotSquared by IntellectualSites.

the class PlotListener method plotExit.

public boolean plotExit(final PlotPlayer<?> player, Plot plot) {
    try (final MetaDataAccess<Plot> lastPlot = player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) {
        final Plot previous = lastPlot.remove();
        this.eventDispatcher.callLeave(player, plot);
        if (plot.hasOwner()) {
            PlotArea pw = plot.getArea();
            if (pw == null) {
                return true;
            }
            try (final MetaDataAccess<Boolean> kickAccess = player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_KICK)) {
                if (plot.getFlag(DenyExitFlag.class) && !Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_EXIT_DENIED) && !kickAccess.get().orElse(false)) {
                    if (previous != null) {
                        lastPlot.set(previous);
                    }
                    return false;
                }
            }
            if (!plot.getFlag(GamemodeFlag.class).equals(GamemodeFlag.DEFAULT) || !plot.getFlag(GuestGamemodeFlag.class).equals(GamemodeFlag.DEFAULT)) {
                if (player.getGameMode() != pw.getGameMode()) {
                    if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) {
                        player.setGameMode(pw.getGameMode());
                    } else {
                        player.sendMessage(TranslatableCaption.of("gamemode.gamemode_was_bypassed"), Template.of("gamemode", pw.getGameMode().getName().toLowerCase()), Template.of("plot", plot.toString()));
                    }
                }
            }
            String farewell = plot.getFlag(FarewellFlag.class);
            if (!farewell.isEmpty()) {
                if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
                    plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendMessage);
                } else {
                    plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendActionBar);
                }
            }
            if (plot.getFlag(NotifyLeaveFlag.class)) {
                if (!Permissions.hasPermission(player, "plots.flag.notify-leave.bypass")) {
                    for (UUID uuid : plot.getOwners()) {
                        final PlotPlayer<?> owner = PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
                        if ((owner != null) && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) {
                            Caption caption = TranslatableCaption.of("notification.notify_leave");
                            notifyPlotOwner(player, plot, owner, caption);
                        }
                    }
                }
            }
            final FlyFlag.FlyStatus flyStatus = plot.getFlag(FlyFlag.class);
            if (flyStatus != FlyFlag.FlyStatus.DEFAULT) {
                try (final MetaDataAccess<Boolean> metaDataAccess = player.accessPersistentMetaData(PlayerMetaDataKeys.PERSISTENT_FLIGHT)) {
                    final Optional<Boolean> value = metaDataAccess.get();
                    if (value.isPresent()) {
                        player.setFlight(value.get());
                        metaDataAccess.remove();
                    } else {
                        GameMode gameMode = player.getGameMode();
                        if (gameMode == GameModes.SURVIVAL || gameMode == GameModes.ADVENTURE) {
                            player.setFlight(false);
                        } else if (!player.getFlight()) {
                            player.setFlight(true);
                        }
                    }
                }
            }
            if (plot.getFlag(TimeFlag.class) != TimeFlag.TIME_DISABLED.getValue().longValue()) {
                player.setTime(Long.MAX_VALUE);
            }
            final PlotWeather plotWeather = plot.getFlag(WeatherFlag.class);
            if (plotWeather != PlotWeather.OFF) {
                player.setWeather(PlotWeather.WORLD);
            }
            try (final MetaDataAccess<Location> musicAccess = player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_MUSIC)) {
                musicAccess.get().ifPresent(lastLoc -> {
                    musicAccess.remove();
                    player.playMusic(lastLoc, ItemTypes.AIR);
                });
            }
            feedRunnable.remove(player.getUUID());
            healRunnable.remove(player.getUUID());
        }
    }
    return true;
}
Also used : PlotArea(com.plotsquared.core.plot.PlotArea) Plot(com.plotsquared.core.plot.Plot) GuestGamemodeFlag(com.plotsquared.core.plot.flag.implementations.GuestGamemodeFlag) StaticCaption(com.plotsquared.core.configuration.caption.StaticCaption) Caption(com.plotsquared.core.configuration.caption.Caption) TranslatableCaption(com.plotsquared.core.configuration.caption.TranslatableCaption) GameMode(com.sk89q.worldedit.world.gamemode.GameMode) FlyFlag(com.plotsquared.core.plot.flag.implementations.FlyFlag) TimeFlag(com.plotsquared.core.plot.flag.implementations.TimeFlag) GamemodeFlag(com.plotsquared.core.plot.flag.implementations.GamemodeFlag) GuestGamemodeFlag(com.plotsquared.core.plot.flag.implementations.GuestGamemodeFlag) UUID(java.util.UUID) PlotWeather(com.plotsquared.core.plot.PlotWeather) Location(com.plotsquared.core.location.Location)

Example 2 with Caption

use of com.plotsquared.core.configuration.caption.Caption in project PlotSquared by IntellectualSites.

the class Plot method debug.

public void debug(@NonNull final String message) {
    try {
        final Collection<PlotPlayer<?>> players = PlotPlayer.getDebugModePlayersInPlot(this);
        if (players.isEmpty()) {
            return;
        }
        Caption caption = TranslatableCaption.of("debug.plot_debug");
        Template plotTemplate = Template.of("plot", this.toString());
        Template messageTemplate = Template.of("message", message);
        for (final PlotPlayer<?> player : players) {
            if (isOwner(player.getUUID()) || Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_DEBUG_OTHER)) {
                player.sendMessage(caption, plotTemplate, messageTemplate);
            }
        }
    } catch (final Exception ignored) {
    }
}
Also used : PlotPlayer(com.plotsquared.core.player.PlotPlayer) StaticCaption(com.plotsquared.core.configuration.caption.StaticCaption) Caption(com.plotsquared.core.configuration.caption.Caption) TranslatableCaption(com.plotsquared.core.configuration.caption.TranslatableCaption) Template(net.kyori.adventure.text.minimessage.Template)

Example 3 with Caption

use of com.plotsquared.core.configuration.caption.Caption in project PlotSquared by IntellectualSites.

the class Plot method format.

public CompletableFuture<Caption> format(final Caption iInfo, PlotPlayer<?> player, final boolean full) {
    final CompletableFuture<Caption> future = new CompletableFuture<>();
    int num = this.getConnectedPlots().size();
    String alias = !this.getAlias().isEmpty() ? this.getAlias() : TranslatableCaption.of("info.none").getComponent(player);
    Location bot = this.getCorners()[0];
    PlotSquared.platform().worldUtil().getBiome(Objects.requireNonNull(this.getWorldName()), bot.getX(), bot.getZ(), biome -> {
        Component trusted = PlayerManager.getPlayerList(this.getTrusted(), player);
        Component members = PlayerManager.getPlayerList(this.getMembers(), player);
        Component denied = PlayerManager.getPlayerList(this.getDenied(), player);
        String seen;
        if (Settings.Enabled_Components.PLOT_EXPIRY && ExpireManager.IMP != null) {
            if (this.isOnline()) {
                seen = TranslatableCaption.of("info.now").getComponent(player);
            } else {
                int time = (int) (ExpireManager.IMP.getAge(this, false) / 1000);
                if (time != 0) {
                    seen = TimeUtil.secToTime(time);
                } else {
                    seen = TranslatableCaption.of("info.unknown").getComponent(player);
                }
            }
        } else {
            seen = TranslatableCaption.of("info.never").getComponent(player);
        }
        String description = this.getFlag(DescriptionFlag.class);
        if (description.isEmpty()) {
            description = TranslatableCaption.of("info.plot_no_description").getComponent(player);
        }
        Component flags;
        Collection<PlotFlag<?, ?>> flagCollection = this.getApplicableFlags(true);
        if (flagCollection.isEmpty()) {
            flags = MINI_MESSAGE.parse(TranslatableCaption.of("info.none").getComponent(player));
        } else {
            TextComponent.Builder flagBuilder = Component.text();
            String prefix = "";
            for (final PlotFlag<?, ?> flag : flagCollection) {
                Object value;
                if (flag instanceof DoubleFlag && !Settings.General.SCIENTIFIC) {
                    value = FLAG_DECIMAL_FORMAT.format(flag.getValue());
                } else {
                    value = flag.toString();
                }
                Component snip = MINI_MESSAGE.parse(prefix + CaptionUtility.format(player, TranslatableCaption.of("info.plot_flag_list").getComponent(player)), Template.of("flag", flag.getName()), Template.of("value", CaptionUtility.formatRaw(player, value.toString())));
                flagBuilder.append(snip);
                prefix = ", ";
            }
            flags = flagBuilder.build();
        }
        boolean build = this.isAdded(player.getUUID());
        Component owner;
        if (this.getOwner() == null) {
            owner = Component.text("unowned");
        } else if (this.getOwner().equals(DBFunc.SERVER)) {
            owner = Component.text(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.server").getComponent(player)));
        } else {
            owner = PlayerManager.getPlayerList(this.getOwners(), player);
        }
        Template headerTemplate = Template.of("header", TranslatableCaption.of("info.plot_info_header").getComponent(player));
        Template footerTemplate = Template.of("footer", TranslatableCaption.of("info.plot_info_footer").getComponent(player));
        Template areaTemplate;
        if (this.getArea() != null) {
            areaTemplate = Template.of("area", this.getArea().getWorldName() + (this.getArea().getId() == null ? "" : "(" + this.getArea().getId() + ")"));
        } else {
            areaTemplate = Template.of("area", TranslatableCaption.of("info.none").getComponent(player));
        }
        long creationDate = Long.parseLong(String.valueOf(timestamp));
        SimpleDateFormat sdf = new SimpleDateFormat(Settings.Timeformat.DATE_FORMAT);
        sdf.setTimeZone(TimeZone.getTimeZone(Settings.Timeformat.TIME_ZONE));
        String newDate = sdf.format(creationDate);
        Template idTemplate = Template.of("id", this.getId().toString());
        Template aliasTemplate = Template.of("alias", alias);
        Template numTemplate = Template.of("num", String.valueOf(num));
        Template descTemplate = Template.of("desc", description);
        Template biomeTemplate = Template.of("biome", biome.toString().toLowerCase());
        Template ownerTemplate = Template.of("owner", owner);
        Template membersTemplate = Template.of("members", members);
        Template playerTemplate = Template.of("player", player.getName());
        Template trustedTemplate = Template.of("trusted", trusted);
        Template helpersTemplate = Template.of("helpers", members);
        Template deniedTemplate = Template.of("denied", denied);
        Template seenTemplate = Template.of("seen", seen);
        Template flagsTemplate = Template.of("flags", flags);
        Template creationTemplate = Template.of("creationdate", newDate);
        Template buildTemplate = Template.of("build", String.valueOf(build));
        Template sizeTemplate = Template.of("size", String.valueOf(getConnectedPlots().size()));
        String component = iInfo.getComponent(player);
        if (component.contains("<rating>") || component.contains("<likes>")) {
            TaskManager.runTaskAsync(() -> {
                Template ratingTemplate;
                Template likesTemplate;
                if (Settings.Ratings.USE_LIKES) {
                    ratingTemplate = Template.of("rating", String.format("%.0f%%", Like.getLikesPercentage(this) * 100D));
                    likesTemplate = Template.of("likes", String.format("%.0f%%", Like.getLikesPercentage(this) * 100D));
                } else {
                    int max = 10;
                    if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES.isEmpty()) {
                        max = 8;
                    }
                    if (full && Settings.Ratings.CATEGORIES != null && Settings.Ratings.CATEGORIES.size() > 1) {
                        double[] ratings = this.getAverageRatings();
                        StringBuilder rating = new StringBuilder();
                        String prefix = "";
                        for (int i = 0; i < ratings.length; i++) {
                            rating.append(prefix).append(Settings.Ratings.CATEGORIES.get(i)).append('=').append(String.format("%.1f", ratings[i]));
                            prefix = ",";
                        }
                        ratingTemplate = Template.of("rating", rating.toString());
                    } else {
                        double rating = this.getAverageRating();
                        if (Double.isFinite(rating)) {
                            ratingTemplate = Template.of("rating", String.format("%.1f", rating) + '/' + max);
                        } else {
                            ratingTemplate = Template.of("rating", TranslatableCaption.of("info.none").getComponent(player));
                        }
                    }
                    likesTemplate = Template.of("likes", "N/A");
                }
                future.complete(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE.parse(iInfo.getComponent(player), headerTemplate, areaTemplate, idTemplate, aliasTemplate, numTemplate, descTemplate, biomeTemplate, ownerTemplate, membersTemplate, playerTemplate, trustedTemplate, helpersTemplate, deniedTemplate, seenTemplate, flagsTemplate, buildTemplate, ratingTemplate, creationTemplate, sizeTemplate, likesTemplate, footerTemplate))));
            });
            return;
        }
        future.complete(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE.parse(iInfo.getComponent(player), headerTemplate, areaTemplate, idTemplate, aliasTemplate, numTemplate, descTemplate, biomeTemplate, ownerTemplate, membersTemplate, playerTemplate, trustedTemplate, helpersTemplate, deniedTemplate, seenTemplate, flagsTemplate, buildTemplate, creationTemplate, sizeTemplate, footerTemplate))));
    });
    return future;
}
Also used : ServerPlotFlag(com.plotsquared.core.plot.flag.implementations.ServerPlotFlag) PlotFlag(com.plotsquared.core.plot.flag.PlotFlag) TextComponent(net.kyori.adventure.text.TextComponent) DoubleFlag(com.plotsquared.core.plot.flag.types.DoubleFlag) StaticCaption(com.plotsquared.core.configuration.caption.StaticCaption) Caption(com.plotsquared.core.configuration.caption.Caption) TranslatableCaption(com.plotsquared.core.configuration.caption.TranslatableCaption) Template(net.kyori.adventure.text.minimessage.Template) CompletableFuture(java.util.concurrent.CompletableFuture) TextComponent(net.kyori.adventure.text.TextComponent) Component(net.kyori.adventure.text.Component) SimpleDateFormat(java.text.SimpleDateFormat) Location(com.plotsquared.core.location.Location)

Example 4 with Caption

use of com.plotsquared.core.configuration.caption.Caption in project PlotSquared by IntellectualSites.

the class PlotModificationManager method setSign.

/**
 * Sets the sign for a plot to a specific name
 *
 * @param name name
 */
public void setSign(@NonNull final String name) {
    if (!this.plot.isLoaded()) {
        return;
    }
    PlotManager manager = this.plot.getArea().getPlotManager();
    if (this.plot.getArea().allowSigns()) {
        Location location = manager.getSignLoc(this.plot);
        String id = this.plot.getId().toString();
        Caption[] lines = new Caption[] { TranslatableCaption.of("signs.owner_sign_line_1"), TranslatableCaption.of("signs.owner_sign_line_2"), TranslatableCaption.of("signs.owner_sign_line_3"), TranslatableCaption.of("signs.owner_sign_line_4") };
        PlotSquared.platform().worldUtil().setSign(location, lines, Template.of("id", id), Template.of("owner", name));
    }
}
Also used : Caption(com.plotsquared.core.configuration.caption.Caption) TranslatableCaption(com.plotsquared.core.configuration.caption.TranslatableCaption) Location(com.plotsquared.core.location.Location)

Example 5 with Caption

use of com.plotsquared.core.configuration.caption.Caption in project PlotSquared by IntellectualSites.

the class PlotListener method plotEntry.

public boolean plotEntry(final PlotPlayer<?> player, final Plot plot) {
    if (plot.isDenied(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.entry.denied")) {
        player.sendMessage(TranslatableCaption.of("deny.no_enter"), Template.of("plot", plot.toString()));
        return false;
    }
    try (final MetaDataAccess<Plot> lastPlot = player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) {
        Plot last = lastPlot.get().orElse(null);
        if ((last != null) && !last.getId().equals(plot.getId())) {
            plotExit(player, last);
        }
        if (ExpireManager.IMP != null) {
            ExpireManager.IMP.handleEntry(player, plot);
        }
        lastPlot.set(plot);
    }
    this.eventDispatcher.callEntry(player, plot);
    if (plot.hasOwner()) {
        // This will inherit values from PlotArea
        final TitlesFlag.TitlesFlagValue titlesFlag = plot.getFlag(TitlesFlag.class);
        final boolean titles;
        if (titlesFlag == TitlesFlag.TitlesFlagValue.NONE) {
            titles = Settings.Titles.DISPLAY_TITLES;
        } else {
            titles = titlesFlag == TitlesFlag.TitlesFlagValue.TRUE;
        }
        String greeting = plot.getFlag(GreetingFlag.class);
        if (!greeting.isEmpty()) {
            if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
                plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendMessage);
            } else {
                plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendActionBar);
            }
        }
        if (plot.getFlag(NotifyEnterFlag.class)) {
            if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) {
                for (UUID uuid : plot.getOwners()) {
                    final PlotPlayer<?> owner = PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
                    if (owner != null && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) {
                        Caption caption = TranslatableCaption.of("notification.notify_enter");
                        notifyPlotOwner(player, plot, owner, caption);
                    }
                }
            }
        }
        final FlyFlag.FlyStatus flyStatus = plot.getFlag(FlyFlag.class);
        if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_FLIGHT)) {
            if (flyStatus != FlyFlag.FlyStatus.DEFAULT) {
                boolean flight = player.getFlight();
                GameMode gamemode = player.getGameMode();
                if (flight != (gamemode == GameModes.CREATIVE || gamemode == GameModes.SPECTATOR)) {
                    try (final MetaDataAccess<Boolean> metaDataAccess = player.accessPersistentMetaData(PlayerMetaDataKeys.PERSISTENT_FLIGHT)) {
                        metaDataAccess.set(player.getFlight());
                    }
                }
                player.setFlight(flyStatus == FlyFlag.FlyStatus.ENABLED);
            }
        }
        final GameMode gameMode = plot.getFlag(GamemodeFlag.class);
        if (!gameMode.equals(GamemodeFlag.DEFAULT)) {
            if (player.getGameMode() != gameMode) {
                if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) {
                    player.setGameMode(gameMode);
                } else {
                    player.sendMessage(TranslatableCaption.of("gamemode.gamemode_was_bypassed"), Template.of("gamemode", String.valueOf(gameMode)), Template.of("plot", plot.getId().toString()));
                }
            }
        }
        final GameMode guestGameMode = plot.getFlag(GuestGamemodeFlag.class);
        if (!guestGameMode.equals(GamemodeFlag.DEFAULT)) {
            if (player.getGameMode() != guestGameMode && !plot.isAdded(player.getUUID())) {
                if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) {
                    player.setGameMode(guestGameMode);
                } else {
                    player.sendMessage(TranslatableCaption.of("gamemode.gamemode_was_bypassed"), Template.of("gamemode", String.valueOf(guestGameMode)), Template.of("plot", plot.getId().toString()));
                }
            }
        }
        long time = plot.getFlag(TimeFlag.class);
        if (time != TimeFlag.TIME_DISABLED.getValue() && !player.getAttribute("disabletime")) {
            try {
                player.setTime(time);
            } catch (Exception ignored) {
                PlotFlag<?, ?> plotFlag = GlobalFlagContainer.getInstance().getFlag(TimeFlag.class);
                PlotFlagRemoveEvent event = this.eventDispatcher.callFlagRemove(plotFlag, plot);
                if (event.getEventResult() != Result.DENY) {
                    plot.removeFlag(event.getFlag());
                }
            }
        }
        player.setWeather(plot.getFlag(WeatherFlag.class));
        ItemType musicFlag = plot.getFlag(MusicFlag.class);
        try (final MetaDataAccess<Location> musicMeta = player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_MUSIC)) {
            if (musicFlag != null) {
                final String rawId = musicFlag.getId();
                if (rawId.contains("disc") || musicFlag == ItemTypes.AIR) {
                    Location location = player.getLocation();
                    Location lastLocation = musicMeta.get().orElse(null);
                    if (lastLocation != null) {
                        plot.getCenter(center -> player.playMusic(center.add(0, Short.MAX_VALUE, 0), musicFlag));
                        if (musicFlag == ItemTypes.AIR) {
                            musicMeta.remove();
                        }
                    }
                    if (musicFlag != ItemTypes.AIR) {
                        try {
                            musicMeta.set(location);
                            plot.getCenter(center -> player.playMusic(center.add(0, Short.MAX_VALUE, 0), musicFlag));
                        } catch (Exception ignored) {
                        }
                    }
                }
            } else {
                musicMeta.get().ifPresent(lastLoc -> {
                    musicMeta.remove();
                    player.playMusic(lastLoc, ItemTypes.AIR);
                });
            }
        }
        CommentManager.sendTitle(player, plot);
        if (titles && !player.getAttribute("disabletitles")) {
            String title;
            String subtitle;
            PlotTitle titleFlag = plot.getFlag(PlotTitleFlag.class);
            boolean fromFlag;
            if (titleFlag.title() != null && titleFlag.subtitle() != null) {
                title = titleFlag.title();
                subtitle = titleFlag.subtitle();
                fromFlag = true;
            } else {
                title = "";
                subtitle = "";
                fromFlag = false;
            }
            if (fromFlag || !plot.getFlag(ServerPlotFlag.class) || Settings.Titles.DISPLAY_DEFAULT_ON_SERVER_PLOT) {
                TaskManager.runTaskLaterAsync(() -> {
                    Plot lastPlot;
                    try (final MetaDataAccess<Plot> lastPlotAccess = player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) {
                        lastPlot = lastPlotAccess.get().orElse(null);
                    }
                    if ((lastPlot != null) && plot.getId().equals(lastPlot.getId()) && plot.hasOwner()) {
                        final UUID plotOwner = plot.getOwnerAbs();
                        String owner = PlayerManager.resolveName(plotOwner, true).getComponent(player);
                        Caption header = fromFlag ? StaticCaption.of(title) : TranslatableCaption.of("titles" + ".title_entered_plot");
                        Caption subHeader = fromFlag ? StaticCaption.of(subtitle) : TranslatableCaption.of("titles" + ".title_entered_plot_sub");
                        Template plotTemplate = Template.of("plot", lastPlot.getId().toString());
                        Template worldTemplate = Template.of("world", player.getLocation().getWorldName());
                        Template ownerTemplate = Template.of("owner", owner);
                        Template aliasTemplate = Template.of("alias", plot.getAlias());
                        final Consumer<String> userConsumer = user -> {
                            if (Settings.Titles.TITLES_AS_ACTIONBAR) {
                                player.sendActionBar(header, aliasTemplate, plotTemplate, worldTemplate, ownerTemplate);
                            } else {
                                player.sendTitle(header, subHeader, aliasTemplate, plotTemplate, worldTemplate, ownerTemplate);
                            }
                        };
                        UUID uuid = plot.getOwner();
                        if (uuid == null) {
                            userConsumer.accept("Unknown");
                        } else if (uuid.equals(DBFunc.SERVER)) {
                            userConsumer.accept(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.server").getComponent(player)));
                        } else {
                            PlotSquared.get().getImpromptuUUIDPipeline().getSingle(plot.getOwner(), (user, throwable) -> {
                                if (throwable != null) {
                                    userConsumer.accept("Unknown");
                                } else {
                                    userConsumer.accept(user);
                                }
                            });
                        }
                    }
                }, TaskTime.seconds(1L));
            }
        }
        TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class);
        if (feed.getInterval() != 0 && feed.getValue() != 0) {
            feedRunnable.put(player.getUUID(), new Interval(feed.getInterval(), feed.getValue(), 20));
        }
        TimedFlag.Timed<Integer> heal = plot.getFlag(HealFlag.class);
        if (heal.getInterval() != 0 && heal.getValue() != 0) {
            healRunnable.put(player.getUUID(), new Interval(heal.getInterval(), heal.getValue(), 20));
        }
        return true;
    }
    return true;
}
Also used : NotifyEnterFlag(com.plotsquared.core.plot.flag.implementations.NotifyEnterFlag) FeedFlag(com.plotsquared.core.plot.flag.implementations.FeedFlag) Permission(com.plotsquared.core.permissions.Permission) StaticCaption(com.plotsquared.core.configuration.caption.StaticCaption) TimedFlag(com.plotsquared.core.plot.flag.types.TimedFlag) Map(java.util.Map) DenyExitFlag(com.plotsquared.core.plot.flag.implementations.DenyExitFlag) Template(net.kyori.adventure.text.minimessage.Template) EventDispatcher(com.plotsquared.core.util.EventDispatcher) FlyFlag(com.plotsquared.core.plot.flag.implementations.FlyFlag) Caption(com.plotsquared.core.configuration.caption.Caption) DBFunc(com.plotsquared.core.database.DBFunc) ServerPlotFlag(com.plotsquared.core.plot.flag.implementations.ServerPlotFlag) MiniMessage(net.kyori.adventure.text.minimessage.MiniMessage) TimeFlag(com.plotsquared.core.plot.flag.implementations.TimeFlag) UUID(java.util.UUID) Result(com.plotsquared.core.events.Result) HealFlag(com.plotsquared.core.plot.flag.implementations.HealFlag) GameModes(com.sk89q.worldedit.world.gamemode.GameModes) TranslatableCaption(com.plotsquared.core.configuration.caption.TranslatableCaption) GreetingFlag(com.plotsquared.core.plot.flag.implementations.GreetingFlag) GamemodeFlag(com.plotsquared.core.plot.flag.implementations.GamemodeFlag) Optional(java.util.Optional) PlayerMetaDataKeys(com.plotsquared.core.player.PlayerMetaDataKeys) FarewellFlag(com.plotsquared.core.plot.flag.implementations.FarewellFlag) PlotTitleFlag(com.plotsquared.core.plot.flag.implementations.PlotTitleFlag) WeatherFlag(com.plotsquared.core.plot.flag.implementations.WeatherFlag) TaskTime(com.plotsquared.core.util.task.TaskTime) MetaDataAccess(com.plotsquared.core.player.MetaDataAccess) HashMap(java.util.HashMap) PlotFlag(com.plotsquared.core.plot.flag.PlotFlag) PlotWeather(com.plotsquared.core.plot.PlotWeather) CommentManager(com.plotsquared.core.plot.comment.CommentManager) ExpireManager(com.plotsquared.core.plot.expiration.ExpireManager) GuestGamemodeFlag(com.plotsquared.core.plot.flag.implementations.GuestGamemodeFlag) Nullable(org.checkerframework.checker.nullness.qual.Nullable) Location(com.plotsquared.core.location.Location) GlobalFlagContainer(com.plotsquared.core.plot.flag.GlobalFlagContainer) TitlesFlag(com.plotsquared.core.plot.flag.implementations.TitlesFlag) PlotFlagRemoveEvent(com.plotsquared.core.events.PlotFlagRemoveEvent) Permissions(com.plotsquared.core.util.Permissions) Plot(com.plotsquared.core.plot.Plot) Iterator(java.util.Iterator) TaskManager(com.plotsquared.core.util.task.TaskManager) ItemTypes(com.sk89q.worldedit.world.item.ItemTypes) GameMode(com.sk89q.worldedit.world.gamemode.GameMode) Consumer(java.util.function.Consumer) PlotSquared(com.plotsquared.core.PlotSquared) PlayerManager(com.plotsquared.core.util.PlayerManager) PlotPlayer(com.plotsquared.core.player.PlotPlayer) NotifyLeaveFlag(com.plotsquared.core.plot.flag.implementations.NotifyLeaveFlag) PlotTitle(com.plotsquared.core.plot.PlotTitle) Settings(com.plotsquared.core.configuration.Settings) PlotArea(com.plotsquared.core.plot.PlotArea) ItemType(com.sk89q.worldedit.world.item.ItemType) MusicFlag(com.plotsquared.core.plot.flag.implementations.MusicFlag) ItemType(com.sk89q.worldedit.world.item.ItemType) Template(net.kyori.adventure.text.minimessage.Template) WeatherFlag(com.plotsquared.core.plot.flag.implementations.WeatherFlag) FlyFlag(com.plotsquared.core.plot.flag.implementations.FlyFlag) UUID(java.util.UUID) PlotFlagRemoveEvent(com.plotsquared.core.events.PlotFlagRemoveEvent) ServerPlotFlag(com.plotsquared.core.plot.flag.implementations.ServerPlotFlag) PlotFlag(com.plotsquared.core.plot.flag.PlotFlag) TitlesFlag(com.plotsquared.core.plot.flag.implementations.TitlesFlag) Plot(com.plotsquared.core.plot.Plot) StaticCaption(com.plotsquared.core.configuration.caption.StaticCaption) Caption(com.plotsquared.core.configuration.caption.Caption) TranslatableCaption(com.plotsquared.core.configuration.caption.TranslatableCaption) PlotTitle(com.plotsquared.core.plot.PlotTitle) ServerPlotFlag(com.plotsquared.core.plot.flag.implementations.ServerPlotFlag) TimedFlag(com.plotsquared.core.plot.flag.types.TimedFlag) GameMode(com.sk89q.worldedit.world.gamemode.GameMode) TimeFlag(com.plotsquared.core.plot.flag.implementations.TimeFlag) Location(com.plotsquared.core.location.Location)

Aggregations

Caption (com.plotsquared.core.configuration.caption.Caption)7 TranslatableCaption (com.plotsquared.core.configuration.caption.TranslatableCaption)7 Location (com.plotsquared.core.location.Location)5 Template (net.kyori.adventure.text.minimessage.Template)5 StaticCaption (com.plotsquared.core.configuration.caption.StaticCaption)4 Plot (com.plotsquared.core.plot.Plot)4 PlotPlayer (com.plotsquared.core.player.PlotPlayer)3 PlotArea (com.plotsquared.core.plot.PlotArea)3 UUID (java.util.UUID)3 PlotSquared (com.plotsquared.core.PlotSquared)2 Settings (com.plotsquared.core.configuration.Settings)2 DBFunc (com.plotsquared.core.database.DBFunc)2 Permission (com.plotsquared.core.permissions.Permission)2 PlotWeather (com.plotsquared.core.plot.PlotWeather)2 PlotFlag (com.plotsquared.core.plot.flag.PlotFlag)2 FlyFlag (com.plotsquared.core.plot.flag.implementations.FlyFlag)2 GamemodeFlag (com.plotsquared.core.plot.flag.implementations.GamemodeFlag)2 GuestGamemodeFlag (com.plotsquared.core.plot.flag.implementations.GuestGamemodeFlag)2 Permissions (com.plotsquared.core.util.Permissions)2 PlotFlagRemoveEvent (com.plotsquared.core.events.PlotFlagRemoveEvent)1