mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Ensure not to parse null parameters into templates for titles
This commit is contained in:
parent
824f9d7ad0
commit
67683fbddb
@ -26,7 +26,6 @@
|
|||||||
package com.plotsquared.core.listener;
|
package com.plotsquared.core.listener;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.permissions.Permission;
|
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.configuration.caption.StaticCaption;
|
import com.plotsquared.core.configuration.caption.StaticCaption;
|
||||||
import com.plotsquared.core.configuration.caption.Templates;
|
import com.plotsquared.core.configuration.caption.Templates;
|
||||||
@ -34,6 +33,7 @@ import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
|||||||
import com.plotsquared.core.events.PlotFlagRemoveEvent;
|
import com.plotsquared.core.events.PlotFlagRemoveEvent;
|
||||||
import com.plotsquared.core.events.Result;
|
import com.plotsquared.core.events.Result;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
|
import com.plotsquared.core.permissions.Permission;
|
||||||
import com.plotsquared.core.player.ConsolePlayer;
|
import com.plotsquared.core.player.ConsolePlayer;
|
||||||
import com.plotsquared.core.player.MetaDataAccess;
|
import com.plotsquared.core.player.MetaDataAccess;
|
||||||
import com.plotsquared.core.player.PlayerMetaDataKeys;
|
import com.plotsquared.core.player.PlayerMetaDataKeys;
|
||||||
@ -74,8 +74,10 @@ import javax.annotation.Nullable;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class PlotListener {
|
public class PlotListener {
|
||||||
|
|
||||||
@ -275,34 +277,43 @@ public class PlotListener {
|
|||||||
if (!TranslatableCaption.of("titles.title_entered_plot").getComponent(ConsolePlayer.getConsole()).isEmpty()
|
if (!TranslatableCaption.of("titles.title_entered_plot").getComponent(ConsolePlayer.getConsole()).isEmpty()
|
||||||
|| !TranslatableCaption.of("titles.title_entered_plot_sub").getComponent(ConsolePlayer.getConsole()).isEmpty()) {
|
|| !TranslatableCaption.of("titles.title_entered_plot_sub").getComponent(ConsolePlayer.getConsole()).isEmpty()) {
|
||||||
TaskManager.runTaskLaterAsync(() -> {
|
TaskManager.runTaskLaterAsync(() -> {
|
||||||
Plot lastPlot = null;
|
Plot lastPlot;
|
||||||
try (final MetaDataAccess<Plot> lastPlotAccess =
|
try (final MetaDataAccess<Plot> lastPlotAccess =
|
||||||
player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) {
|
player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) {
|
||||||
lastPlot = lastPlotAccess.get().orElse(null);
|
lastPlot = lastPlotAccess.get().orElse(null);
|
||||||
}
|
}
|
||||||
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) {
|
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId()) && plot.hasOwner()) {
|
||||||
player.sendTitle(
|
final Consumer<String> userConsumer = user -> player
|
||||||
TranslatableCaption.of("titles.title_entered_plot"),
|
.sendTitle(TranslatableCaption.of("titles.title_entered_plot"),
|
||||||
TranslatableCaption.of("titles.title_entered_plot_sub"),
|
TranslatableCaption.of("titles.title_entered_plot_sub"),
|
||||||
Templates.of("x", lastPlot.getId().getX()),
|
Templates.of("x", lastPlot.getId().getX()), Templates.of("z", lastPlot.getId().getY()),
|
||||||
Templates.of("z", lastPlot.getId().getY()),
|
Templates.of("world", Objects.requireNonNull(plot.getWorldName(), "Unknown")),
|
||||||
Templates.of("world", plot.getArea()),
|
Templates.of("greeting", greeting), Templates.of("alias", plot.getAlias()),
|
||||||
Templates.of("greeting", greeting),
|
Templates.of("owner", user));
|
||||||
Templates.of("alias", plot.getAlias()),
|
UUID uuid = plot.getOwner();
|
||||||
Templates.of("owner", plot.getOwner())
|
if (uuid == null) {
|
||||||
);
|
userConsumer.accept("Unknown");
|
||||||
|
} else {
|
||||||
|
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(plot.getOwner(), (user, throwable) -> {
|
||||||
|
if (throwable == null) {
|
||||||
|
userConsumer.accept("Unknown");
|
||||||
|
} else {
|
||||||
|
userConsumer.accept(user);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, TaskTime.seconds(1L));
|
}, TaskTime.seconds(1L));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class);
|
TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class);
|
||||||
if (feed != null && feed.getInterval() != 0 && feed.getValue() != 0) {
|
if (feed.getInterval() != 0 && feed.getValue() != 0) {
|
||||||
feedRunnable
|
feedRunnable
|
||||||
.put(player.getUUID(), new Interval(feed.getInterval(), feed.getValue(), 20));
|
.put(player.getUUID(), new Interval(feed.getInterval(), feed.getValue(), 20));
|
||||||
}
|
}
|
||||||
TimedFlag.Timed<Integer> heal = plot.getFlag(HealFlag.class);
|
TimedFlag.Timed<Integer> heal = plot.getFlag(HealFlag.class);
|
||||||
if (heal != null && heal.getInterval() != 0 && heal.getValue() != 0) {
|
if (heal.getInterval() != 0 && heal.getValue() != 0) {
|
||||||
healRunnable
|
healRunnable
|
||||||
.put(player.getUUID(), new Interval(heal.getInterval(), heal.getValue(), 20));
|
.put(player.getUUID(), new Interval(heal.getInterval(), heal.getValue(), 20));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user