Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.alpsbte.plotsystem.core.menus;

import com.alpsbte.alpslib.utils.item.ItemBuilder;
import com.alpsbte.alpslib.utils.item.LoreBuilder;
import com.alpsbte.plotsystem.core.system.plot.Plot;
import com.alpsbte.plotsystem.utils.Utils;
import com.alpsbte.plotsystem.utils.io.LangPaths;
import com.alpsbte.plotsystem.utils.io.LangUtil;
import com.alpsbte.plotsystem.utils.items.BaseItems;
import org.bukkit.entity.Player;
import org.ipvp.canvas.mask.BinaryMask;
import org.ipvp.canvas.mask.Mask;

import static net.kyori.adventure.text.Component.text;
import static net.kyori.adventure.text.format.NamedTextColor.RED;
import static net.kyori.adventure.text.format.TextDecoration.BOLD;

public class AbandonConfirmMenu extends AbstractMenu {
private final Plot plot;

public AbandonConfirmMenu(Player player, Plot plot) {
super(3, LangUtil.getInstance().get(player, LangPaths.MenuTitle.ABANDON_CONFIRM, String.valueOf(plot.getId())), player);
this.plot = plot;
}

@Override
protected void setMenuItemsAsync() {
getMenu().getSlot(12)
.setItem(new ItemBuilder(BaseItems.PLOT_ABANDON.getItem())
.setName(text(LangUtil.getInstance().get(getMenuPlayer(), LangPaths.MenuTitle.ABANDON), RED).decoration(BOLD, true))
.setLore(new LoreBuilder()
.addLine(LangUtil.getInstance().get(getMenuPlayer(), LangPaths.MenuDescription.ABANDON), true)
.emptyLine()
.addLine(Utils.ItemUtils.getNoteFormat(LangUtil.getInstance().get(getMenuPlayer(), LangPaths.Note.WONT_BE_ABLE_CONTINUE_BUILDING)))
.build())
.build());

getMenu().getSlot(14)
.setItem(new ItemBuilder(BaseItems.MENU_BACK.getItem())
.setName(text(LangUtil.getInstance().get(getMenuPlayer(), LangPaths.MenuTitle.CANCEL), RED).decoration(BOLD, true))
.build());
}

@Override
protected void setItemClickEventsAsync() {
getMenu().getSlot(12).setClickHandler((clickPlayer, clickInformation) -> {
clickPlayer.closeInventory();
clickPlayer.performCommand("plot abandon " + plot.getId());
});

getMenu().getSlot(14).setClickHandler((clickPlayer, clickInformation) -> {
clickPlayer.closeInventory();
new PlotActionsMenu(clickPlayer, plot);
});
}

@Override
protected Mask getMask() {
return BinaryMask.builder(getMenu())
.item(Utils.DEFAULT_ITEM)
.pattern(Utils.FULL_MASK)
.pattern(Utils.EMPTY_MASK)
.pattern(Utils.FULL_MASK)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ protected void setItemClickEventsAsync() {

// Set click event for abandon plot item
getMenu().getSlot(hasReview ? 14 : 16).setClickHandler((clickPlayer, clickInformation) -> {
clickPlayer.closeInventory();
clickPlayer.performCommand("plot abandon " + plot.getId());
new AbandonConfirmMenu(clickPlayer, plot);
});

// Set click event for feedback menu button
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/alpsbte/plotsystem/utils/io/LangPaths.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private MenuTitle() {}
public static final String SUBMIT = MENU_TITLES + "submit";
public static final String TELEPORT = MENU_TITLES + "teleport";
public static final String ABANDON = MENU_TITLES + "abandon";
public static final String ABANDON_CONFIRM = MENU_TITLES + "abandon-confirm";
public static final String UNDO_SUBMIT = MENU_TITLES + "undo-submit";
public static final String MANAGE_MEMBERS = MENU_TITLES + "manage-members";
public static final String FEEDBACK = MENU_TITLES + "feedback";
Expand Down Expand Up @@ -406,4 +407,4 @@ private Database() {}
public static final String STATUS = DATABASE_PREFIX + "status";
public static final String TOGGLE_CRITERIA = DATABASE_PREFIX + "toggle-criteria";
}
}
}
5 changes: 1 addition & 4 deletions src/main/resources/items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ plot-undo-submit:
material: FIRE_CHARGE
modelId: ''
plot-abandon:
material: BARRIER
material: TNT
modelId: ''
plot-teleport:
material: COMPASS
Expand Down Expand Up @@ -112,9 +112,6 @@ review-point-five:
review-submit:
material: FIREWORK_ROCKET
modelId: ''
review-cancel:
material: RED_CONCRETE
modelId: ''
review-info:
material: head(46488)
modelId: ''
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/lang/de_DE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ menu-title:
submit: 'Einreichen'
teleport: 'Teleportieren'
abandon: 'Löschen'
abandon-confirm: 'Plot #{0} löschen?'
undo-submit: 'Einreichung Zurückziehen'
manage-members: 'Mitglieder Verwalten'
feedback: 'Feedback | Bewertung #{0}'
Expand Down Expand Up @@ -446,4 +447,4 @@ database:
correct_window_type: 'Richtige Verstrebungen'
windows_blacked_out: 'Alle Fenster verdunkelt'
#NOTE: Do not change
config-version: 2.5
config-version: 2.5
1 change: 1 addition & 0 deletions src/main/resources/lang/en_GB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ menu-title:
submit: 'Submit'
teleport: 'Teleport'
abandon: 'Abandon'
abandon-confirm: 'Abandon plot #{0}?'
undo-submit: 'Undo Submit'
manage-members: 'Manage Members'
feedback: 'Feedback | Review #{0}'
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang/fr_FR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ menu-title:
submit: 'Soumettre'
teleport: 'Téléport'
abandon: 'Abandonner'
abandon-confirm: 'Abandonner le Plot #{0} ?'
undo-submit: 'Annuler Soumission'
manage-members: 'Gérer Membres'
feedback: 'Retour | Review #{0}'
Expand Down
Loading