mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-04 09:10:17 +01:00
Allow PlotTitle to have a "null" mode (default plot title flag should be the configured values)
This commit is contained in:
parent
8a53b41b52
commit
4b26a7e300
@ -35,7 +35,6 @@ 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.permissions.Permission;
|
||||||
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;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
@ -297,16 +296,16 @@ public class PlotListener {
|
|||||||
String subtitle;
|
String subtitle;
|
||||||
PlotTitle titleFlag = plot.getFlag(PlotTitleFlag.class);
|
PlotTitle titleFlag = plot.getFlag(PlotTitleFlag.class);
|
||||||
boolean fromFlag;
|
boolean fromFlag;
|
||||||
if (!titleFlag.title().isEmpty() && !titleFlag.subtitle().isEmpty()) {
|
if (titleFlag.title() != null && titleFlag.subtitle() != null) {
|
||||||
title = titleFlag.title();
|
title = titleFlag.title();
|
||||||
subtitle = titleFlag.subtitle();
|
subtitle = titleFlag.subtitle();
|
||||||
fromFlag = true;
|
fromFlag = true;
|
||||||
} else {
|
} else {
|
||||||
title = TranslatableCaption.of("titles.title_entered_plot").getComponent(ConsolePlayer.getConsole());
|
title = "";
|
||||||
subtitle = TranslatableCaption.of("titles.title_entered_plot_sub").getComponent(ConsolePlayer.getConsole());
|
subtitle = "";
|
||||||
fromFlag = false;
|
fromFlag = false;
|
||||||
}
|
}
|
||||||
if (!title.isEmpty() && !subtitle.isEmpty()) {
|
// It's not actually possible for these to be null, but IntelliJ is dumb
|
||||||
TaskManager.runTaskLaterAsync(() -> {
|
TaskManager.runTaskLaterAsync(() -> {
|
||||||
Plot lastPlot;
|
Plot lastPlot;
|
||||||
try (final MetaDataAccess<Plot> lastPlotAccess =
|
try (final MetaDataAccess<Plot> lastPlotAccess =
|
||||||
@ -351,7 +350,6 @@ public class PlotListener {
|
|||||||
}
|
}
|
||||||
}, TaskTime.seconds(1L));
|
}, TaskTime.seconds(1L));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class);
|
TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class);
|
||||||
if (feed.getInterval() != 0 && feed.getValue() != 0) {
|
if (feed.getInterval() != 0 && feed.getValue() != 0) {
|
||||||
|
@ -25,13 +25,21 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot;
|
package com.plotsquared.core.plot;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class PlotTitle {
|
public class PlotTitle {
|
||||||
|
|
||||||
|
public static final PlotTitle CONFIGURED = new PlotTitle();
|
||||||
|
|
||||||
private final String title;
|
private final String title;
|
||||||
private final String subtitle;
|
private final String subtitle;
|
||||||
|
|
||||||
|
private PlotTitle() {
|
||||||
|
title = null;
|
||||||
|
subtitle = null;
|
||||||
|
}
|
||||||
|
|
||||||
public PlotTitle(String title, String subtitle) {
|
public PlotTitle(String title, String subtitle) {
|
||||||
Objects.requireNonNull(title);
|
Objects.requireNonNull(title);
|
||||||
Objects.requireNonNull(subtitle);
|
Objects.requireNonNull(subtitle);
|
||||||
@ -39,10 +47,12 @@ public class PlotTitle {
|
|||||||
this.subtitle = subtitle;
|
this.subtitle = subtitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String title() {
|
public String title() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String subtitle() {
|
public String subtitle() {
|
||||||
return subtitle;
|
return subtitle;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
|
|
||||||
public class PlotTitleFlag extends PlotFlag<PlotTitle, PlotTitleFlag> {
|
public class PlotTitleFlag extends PlotFlag<PlotTitle, PlotTitleFlag> {
|
||||||
|
|
||||||
public static final PlotTitleFlag TITLE_FLAG_EMPTY = new PlotTitleFlag(new PlotTitle("", ""));
|
public static final PlotTitleFlag TITLE_FLAG_EMPTY = new PlotTitleFlag(PlotTitle.CONFIGURED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new flag instance.
|
* Construct a new flag instance.
|
||||||
|
Loading…
Reference in New Issue
Block a user