Compare commits

...

4 Commits

Author SHA1 Message Date
78125ff1e2 build: Release 6.5.0 2022-02-10 12:32:02 +01:00
d7c8715b25 Don't open the component GUI if the actor has no permission for a specific preset (#3496)
* fix: Handle an empty component GUI gracefully

* Address comments
2022-02-10 12:19:35 +01:00
34f005c244 Restore ability to use PlaceholderAPI in greeting and farewell flag (#3489)
Fixes #3465
2022-02-10 12:11:39 +01:00
6fbd1376ca Don't enable presets with prices if economy is disabled (#3497) 2022-02-10 12:10:47 +01:00
9 changed files with 36 additions and 44 deletions

View File

@ -102,7 +102,7 @@ public enum CommandCategory implements Caption {
* *
* @param player The player to check against * @param player The player to check against
* @return {@code true} if at least one command of this category can be executed by the player, {@code false} otherwise * @return {@code true} if at least one command of this category can be executed by the player, {@code false} otherwise
* @since TODO * @since 6.5.0
*/ */
boolean canAccess(PlotPlayer<?> player) { boolean canAccess(PlotPlayer<?> player) {
return !MainCommand.getInstance().getCommands(this, player).isEmpty(); return !MainCommand.getInstance().getCommands(this, player).isEmpty();

View File

@ -128,7 +128,7 @@ public class ComponentPresetManager {
0, 0,
"", "",
"<rainbow:2>Disco Floor</rainbow>", "<rainbow:2>Disco Floor</rainbow>",
Arrays.asList("<gold>Spice up your plot floor</gold>"), List.of("<gold>Spice up your plot floor</gold>"),
ItemTypes.YELLOW_WOOL ItemTypes.YELLOW_WOOL
)); ));
yamlConfiguration.set("presets", defaultPreset.stream().map(ComponentPreset::serialize).collect(Collectors.toList())); yamlConfiguration.set("presets", defaultPreset.stream().map(ComponentPreset::serialize).collect(Collectors.toList()));
@ -181,6 +181,10 @@ public class ComponentPresetManager {
} }
allowedPresets.add(componentPreset); allowedPresets.add(componentPreset);
} }
if (allowedPresets.isEmpty()) {
player.sendMessage(TranslatableCaption.of("preset.empty"));
return null;
}
final int size = (int) Math.ceil((double) allowedPresets.size() / 9.0D); final int size = (int) Math.ceil((double) allowedPresets.size() / 9.0D);
final PlotInventory plotInventory = new PlotInventory(this.inventoryUtil, player, size, final PlotInventory plotInventory = new PlotInventory(this.inventoryUtil, player, size,
TranslatableCaption.of("preset.title").getComponent(player)) { TranslatableCaption.of("preset.title").getComponent(player)) {
@ -210,7 +214,13 @@ public class ComponentPresetManager {
return false; return false;
} }
if (componentPreset.getCost() > 0.0D && econHandler.isEnabled(plot.getArea())) { if (componentPreset.getCost() > 0.0D) {
if (!econHandler.isEnabled(plot.getArea())) {
getPlayer().sendMessage(
TranslatableCaption.of("preset.economy_disabled"),
Template.of("preset", componentPreset.getDisplayName()));
return false;
}
if (econHandler.getMoney(getPlayer()) < componentPreset.getCost()) { if (econHandler.getMoney(getPlayer()) < componentPreset.getCost()) {
getPlayer().sendMessage(TranslatableCaption.of("preset.preset_cannot_afford")); getPlayer().sendMessage(TranslatableCaption.of("preset.preset_cannot_afford"));
return false; return false;
@ -246,11 +256,16 @@ public class ComponentPresetManager {
for (int i = 0; i < allowedPresets.size(); i++) { for (int i = 0; i < allowedPresets.size(); i++) {
final ComponentPreset preset = allowedPresets.get(i); final ComponentPreset preset = allowedPresets.get(i);
final List<String> lore = new ArrayList<>(); final List<String> lore = new ArrayList<>();
if (preset.getCost() > 0 && this.econHandler.isEnabled(plot.getArea())) { if (preset.getCost() > 0) {
lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.parse( if (!this.econHandler.isEnabled(plot.getArea())) {
TranslatableCaption.of("preset.preset_lore_cost").getComponent(player), lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.parse(
Template.of("cost", String.format("%.2f", preset.getCost())) TranslatableCaption.of("preset.preset_lore_economy_disabled").getComponent(player))));
))); } else {
lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.parse(
TranslatableCaption.of("preset.preset_lore_cost").getComponent(player),
Template.of("cost", String.format("%.2f", preset.getCost()))
)));
}
} }
lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.parse( lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.parse(
TranslatableCaption.of("preset.preset_lore_component").getComponent(player), TranslatableCaption.of("preset.preset_lore_component").getComponent(player),

View File

@ -174,21 +174,9 @@ public class PlotListener {
String greeting = plot.getFlag(GreetingFlag.class); String greeting = plot.getFlag(GreetingFlag.class);
if (!greeting.isEmpty()) { if (!greeting.isEmpty()) {
if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) { if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
player.sendMessage( plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendMessage);
TranslatableCaption.of("flags.greeting_flag_format"),
Template.of("world", plot.getWorldName()),
Template.of("plot_id", plot.getId().toString()),
Template.of("alias", plot.getAlias()),
Template.of("greeting", greeting)
);
} else { } else {
player.sendActionBar( plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendActionBar);
TranslatableCaption.of("flags.greeting_flag_format"),
Template.of("world", plot.getWorldName()),
Template.of("plot_id", plot.getId().toString()),
Template.of("alias", plot.getAlias()),
Template.of("greeting", greeting)
);
} }
} }
@ -413,21 +401,9 @@ public class PlotListener {
String farewell = plot.getFlag(FarewellFlag.class); String farewell = plot.getFlag(FarewellFlag.class);
if (!farewell.isEmpty()) { if (!farewell.isEmpty()) {
if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) { if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
player.sendMessage( plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendMessage);
TranslatableCaption.of("flags.farewell_flag_format"),
Template.of("world", plot.getWorldName()),
Template.of("plot_id", plot.getId().toString()),
Template.of("alias", plot.getAlias()),
Template.of("farewell", farewell)
);
} else { } else {
player.sendActionBar( plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendActionBar);
TranslatableCaption.of("flags.farewell_flag_format"),
Template.of("world", plot.getWorldName()),
Template.of("plot_id", plot.getId().toString()),
Template.of("alias", plot.getAlias()),
Template.of("farewell", farewell)
);
} }
} }

View File

@ -121,7 +121,7 @@ public class PlotInventory {
* @param item the item to place * @param item the item to place
* @return {@code true} if the item could be placed, otherwise {@code false} * @return {@code true} if the item could be placed, otherwise {@code false}
* @see InventoryUtil#setItemChecked(PlotInventory, int, PlotItemStack) * @see InventoryUtil#setItemChecked(PlotInventory, int, PlotItemStack)
* @since TODO * @since 6.5.0
*/ */
public boolean setItemChecked(int index, PlotItemStack item) { public boolean setItemChecked(int index, PlotItemStack item) {
if (!this.inventoryUtil.setItemChecked(this, index, item)) { if (!this.inventoryUtil.setItemChecked(this, index, item)) {

View File

@ -54,7 +54,7 @@ public class PlotItemStack {
* @param amount Amount of items in the stack * @param amount Amount of items in the stack
* @param name The display name of the item stack * @param name The display name of the item stack
* @param lore The item stack lore * @param lore The item stack lore
* @since TODO * @since 6.5.0
*/ */
public PlotItemStack( public PlotItemStack(
final ItemType type, final int amount, final String name, final ItemType type, final int amount, final String name,

View File

@ -45,7 +45,7 @@ public abstract class InventoryUtil {
* @param index The index where to place the item * @param index The index where to place the item
* @param item The item to place into the inventory * @param item The item to place into the inventory
* @return {@code true} if the item could be placed, {@code false} otherwise (e.g. item not available in current version) * @return {@code true} if the item could be placed, {@code false} otherwise (e.g. item not available in current version)
* @since TODO * @since 6.5.0
*/ */
public abstract boolean setItemChecked( public abstract boolean setItemChecked(
final PlotInventory plotInventory, final int index, final PlotInventory plotInventory, final int index,

View File

@ -460,9 +460,12 @@
"backups.backup_automatic_failure": "<prefix><red>The automatic backup process failed. Your pending action has been canceled. Reason: </red><gray><reason></gray>", "backups.backup_automatic_failure": "<prefix><red>The automatic backup process failed. Your pending action has been canceled. Reason: </red><gray><reason></gray>",
"preset.preset_cannot_afford": "<prefix><red>You cannot afford that preset.</red>", "preset.preset_cannot_afford": "<prefix><red>You cannot afford that preset.</red>",
"preset.preset_invalid": "<prefix><red>Could not generate a pattern from that preset.</red>", "preset.preset_invalid": "<prefix><red>Could not generate a pattern from that preset.</red>",
"preset.preset_lore_cost": "<prefix><gray>Cost: </gray><gold><cost></gold>", "preset.preset_lore_cost": "<gray>Cost: </gray><gold><cost></gold>",
"preset.preset_lore_economy_disabled": "<gray>Cost: </gray><red>Economy is disabled</red>",
"preset.preset_lore_component": "<gray>Component: </gray><gold><component></gold>", "preset.preset_lore_component": "<gray>Component: </gray><gold><component></gold>",
"preset.title": "Plot Components", "preset.title": "Plot Components",
"preset.empty": "<prefix><red>No plot component presets available.</red>",
"preset.economy_disabled": "<prefix><red>The component preset '<preset>' has a price set but economy is disabled.</red>",
"generic.generic_other": "<gray>other</gray>", "generic.generic_other": "<gray>other</gray>",
"generic.generic_merged": "<gray>merged</gray>", "generic.generic_merged": "<gray>merged</gray>",
"generic.generic_unowned": "<gray>unowned</gray>", "generic.generic_unowned": "<gray>unowned</gray>",
@ -620,8 +623,6 @@
"flags.flag_error_title": "Flag value must be in the format </red><grey>\"A title\" \"The subtitle\"</grey><red>.", "flags.flag_error_title": "Flag value must be in the format </red><grey>\"A title\" \"The subtitle\"</grey><red>.",
"flags.area_flags": "<prefix><gray>Area flags: </gray><dark_aqua><flags></dark_aqua>", "flags.area_flags": "<prefix><gray>Area flags: </gray><dark_aqua><flags></dark_aqua>",
"flags.road_flags": "<prefix><gray>Road flags: </gray><dark_aqua><flags></dark_aqua>", "flags.road_flags": "<prefix><gray>Road flags: </gray><dark_aqua><flags></dark_aqua>",
"flags.greeting_flag_format": "<prefix><gold>[<world>;<plot_id>]:</gold> <greeting>",
"flags.farewell_flag_format": "<prefix><gold>[<world>;<plot_id>]:</gold> <farewell>",
"commands.description.add": "<gray>Allow a user to build in a plot while the plot owner is online.</gray>", "commands.description.add": "<gray>Allow a user to build in a plot while the plot owner is online.</gray>",
"commands.description.alias": "<gray>Set the plot alias.</gray>", "commands.description.alias": "<gray>Set the plot alias.</gray>",
"commands.description.area": "<gray>Create a new plot area.</gray>", "commands.description.area": "<gray>Create a new plot area.</gray>",

View File

@ -18,7 +18,7 @@ plugins {
idea idea
} }
version = "6.4.1-SNAPSHOT" version = "6.5.0"
allprojects { allprojects {
group = "com.plotsquared" group = "com.plotsquared"

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists