mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-21 16:47:39 +01:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
21601089f4
@ -457,7 +457,7 @@ protection:
|
|||||||
description: "Toggle access"
|
description: "Toggle access"
|
||||||
name: "Trap doors"
|
name: "Trap doors"
|
||||||
locked: "&cThis island is locked!"
|
locked: "&cThis island is locked!"
|
||||||
protected: "&cIsland protected!"
|
protected: "&cIsland protected: [description]"
|
||||||
|
|
||||||
panel:
|
panel:
|
||||||
title: "Island flags"
|
title: "Island flags"
|
||||||
|
@ -412,6 +412,9 @@ public class Settings implements DataObject, WorldSettings {
|
|||||||
@ConfigEntry(path = "island.require-confirmation.leave-wait")
|
@ConfigEntry(path = "island.require-confirmation.leave-wait")
|
||||||
private long leaveWait = 10L;
|
private long leaveWait = 10L;
|
||||||
|
|
||||||
|
@ConfigEntry(path = "panel.close-on-click-outside")
|
||||||
|
private boolean closePanelOnClickOutside = true;
|
||||||
|
|
||||||
private String uniqueId = "config";
|
private String uniqueId = "config";
|
||||||
|
|
||||||
// Getters and setters
|
// Getters and setters
|
||||||
@ -1482,4 +1485,12 @@ public class Settings implements DataObject, WorldSettings {
|
|||||||
this.worldFlags = worldFlags;
|
this.worldFlags = worldFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getClosePanelOnClickOutside() {
|
||||||
|
return closePanelOnClickOutside;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClosePanelOnClickOutside(boolean closePanelOnClickOutside) {
|
||||||
|
this.closePanelOnClickOutside = closePanelOnClickOutside;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -25,10 +25,6 @@ public class Flag implements Comparable<Flag> {
|
|||||||
WORLD_SETTING
|
WORLD_SETTING
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String PRO_FLAGS = "protection.flags.";
|
|
||||||
private static final String DOT_DESC = ".description";
|
|
||||||
private static final String DESC_PLACEHOLDER = "[description]";
|
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
private final Material icon;
|
private final Material icon;
|
||||||
private final Listener listener;
|
private final Listener listener;
|
||||||
@ -141,6 +137,14 @@ public class Flag implements Comparable<Flag> {
|
|||||||
return type == other.type;
|
return type == other.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getNameReference() {
|
||||||
|
return "protection.flags." + this.id + ".name";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescriptionReference() {
|
||||||
|
return "protection.flags." + this.id + ".description";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a flag to a panel item. The content of the flag will change depending on who the user is and where they are.
|
* Converts a flag to a panel item. The content of the flag will change depending on who the user is and where they are.
|
||||||
* @param plugin - plugin
|
* @param plugin - plugin
|
||||||
@ -151,17 +155,17 @@ public class Flag implements Comparable<Flag> {
|
|||||||
// Start the flag conversion
|
// Start the flag conversion
|
||||||
PanelItemBuilder pib = new PanelItemBuilder()
|
PanelItemBuilder pib = new PanelItemBuilder()
|
||||||
.icon(new ItemStack(icon))
|
.icon(new ItemStack(icon))
|
||||||
.name(user.getTranslation("protection.panel.flag-item.name-layout", TextVariables.NAME, user.getTranslation(PRO_FLAGS + id + ".name")))
|
.name(user.getTranslation("protection.panel.flag-item.name-layout", TextVariables.NAME, user.getTranslation(getNameReference())))
|
||||||
.clickHandler(clickHandler);
|
.clickHandler(clickHandler);
|
||||||
if (getType().equals(Type.MENU)) {
|
if (getType().equals(Type.MENU)) {
|
||||||
pib.description(user.getTranslation("protection.panel.flag-item.menu-layout", DESC_PLACEHOLDER, user.getTranslation(PRO_FLAGS + id + DOT_DESC)));
|
pib.description(user.getTranslation("protection.panel.flag-item.menu-layout", TextVariables.DESCRIPTION, user.getTranslation(getDescriptionReference())));
|
||||||
return pib.build();
|
return pib.build();
|
||||||
}
|
}
|
||||||
// Check if this is a setting or world setting
|
// Check if this is a setting or world setting
|
||||||
if (getType().equals(Type.WORLD_SETTING)) {
|
if (getType().equals(Type.WORLD_SETTING)) {
|
||||||
String worldDetting = this.isSetForWorld(user.getWorld()) ? user.getTranslation("protection.panel.flag-item.setting-active")
|
String worldDetting = this.isSetForWorld(user.getWorld()) ? user.getTranslation("protection.panel.flag-item.setting-active")
|
||||||
: user.getTranslation("protection.panel.flag-item.setting-disabled");
|
: user.getTranslation("protection.panel.flag-item.setting-disabled");
|
||||||
pib.description(user.getTranslation("protection.panel.flag-item.setting-layout", DESC_PLACEHOLDER, user.getTranslation(PRO_FLAGS + id + DOT_DESC)
|
pib.description(user.getTranslation("protection.panel.flag-item.setting-layout", TextVariables.DESCRIPTION, user.getTranslation(getDescriptionReference())
|
||||||
, "[setting]", worldDetting));
|
, "[setting]", worldDetting));
|
||||||
return pib.build();
|
return pib.build();
|
||||||
}
|
}
|
||||||
@ -172,7 +176,7 @@ public class Flag implements Comparable<Flag> {
|
|||||||
if (getType().equals(Type.SETTING)) {
|
if (getType().equals(Type.SETTING)) {
|
||||||
String islandSetting = island.isAllowed(this) ? user.getTranslation("protection.panel.flag-item.setting-active")
|
String islandSetting = island.isAllowed(this) ? user.getTranslation("protection.panel.flag-item.setting-active")
|
||||||
: user.getTranslation("protection.panel.flag-item.setting-disabled");
|
: user.getTranslation("protection.panel.flag-item.setting-disabled");
|
||||||
pib.description(user.getTranslation("protection.panel.flag-item.setting-layout", DESC_PLACEHOLDER, user.getTranslation(PRO_FLAGS + id + DOT_DESC)
|
pib.description(user.getTranslation("protection.panel.flag-item.setting-layout", TextVariables.DESCRIPTION, user.getTranslation(getDescriptionReference())
|
||||||
, "[setting]", islandSetting));
|
, "[setting]", islandSetting));
|
||||||
return pib.build();
|
return pib.build();
|
||||||
}
|
}
|
||||||
@ -180,8 +184,8 @@ public class Flag implements Comparable<Flag> {
|
|||||||
// Dynamic rank list
|
// Dynamic rank list
|
||||||
if (getType().equals(Type.PROTECTION)) {
|
if (getType().equals(Type.PROTECTION)) {
|
||||||
// Protection flag
|
// Protection flag
|
||||||
String d = user.getTranslation(PRO_FLAGS + id + DOT_DESC);
|
String d = user.getTranslation(getDescriptionReference());
|
||||||
d = user.getTranslation("protection.panel.flag-item.description-layout", DESC_PLACEHOLDER, d);
|
d = user.getTranslation("protection.panel.flag-item.description-layout", TextVariables.DESCRIPTION, d);
|
||||||
pib.description(d);
|
pib.description(d);
|
||||||
plugin.getRanksManager().getRanks().forEach((reference, score) -> {
|
plugin.getRanksManager().getRanks().forEach((reference, score) -> {
|
||||||
if (score > RanksManager.BANNED_RANK && score < island.getFlag(this)) {
|
if (score > RanksManager.BANNED_RANK && score < island.getFlag(this)) {
|
||||||
|
@ -7,6 +7,7 @@ package us.tastybento.bskyblock.api.localization;
|
|||||||
public class TextVariables {
|
public class TextVariables {
|
||||||
|
|
||||||
public static final String NAME = "[name]";
|
public static final String NAME = "[name]";
|
||||||
|
public static final String DESCRIPTION = "[description]";
|
||||||
public static final String NUMBER = "[number]";
|
public static final String NUMBER = "[number]";
|
||||||
public static final String RANK = "[rank]";
|
public static final String RANK = "[rank]";
|
||||||
public static final String LABEL = "[label]";
|
public static final String LABEL = "[label]";
|
||||||
|
@ -13,6 +13,7 @@ import org.bukkit.event.inventory.InventoryType.SlotType;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
|
import us.tastybento.bskyblock.BSkyBlock;
|
||||||
import us.tastybento.bskyblock.api.panels.Panel;
|
import us.tastybento.bskyblock.api.panels.Panel;
|
||||||
import us.tastybento.bskyblock.api.panels.PanelItem;
|
import us.tastybento.bskyblock.api.panels.PanelItem;
|
||||||
import us.tastybento.bskyblock.api.user.User;
|
import us.tastybento.bskyblock.api.user.User;
|
||||||
@ -23,13 +24,12 @@ public class PanelListenerManager implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
// Close inventory if clicked outside
|
// Close inventory if clicked outside and if setting is true
|
||||||
if (event.getSlotType().equals(SlotType.OUTSIDE)) {
|
if (BSkyBlock.getInstance().getSettings().getClosePanelOnClickOutside() && event.getSlotType().equals(SlotType.OUTSIDE)) {
|
||||||
event.getWhoClicked().closeInventory();
|
event.getWhoClicked().closeInventory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
User user = User.getInstance(event.getWhoClicked()); // The player that
|
User user = User.getInstance(event.getWhoClicked()); // The player that clicked the item
|
||||||
// clicked the item
|
|
||||||
Inventory inventory = event.getInventory(); // The inventory that was
|
Inventory inventory = event.getInventory(); // The inventory that was
|
||||||
// Open the inventory panel that this player has open (they can only ever have one)
|
// Open the inventory panel that this player has open (they can only ever have one)
|
||||||
if (openPanels.containsKey(user.getUniqueId())) {
|
if (openPanels.containsKey(user.getUniqueId())) {
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.event.Listener;
|
|||||||
import us.tastybento.bskyblock.BSkyBlock;
|
import us.tastybento.bskyblock.BSkyBlock;
|
||||||
import us.tastybento.bskyblock.api.flags.Flag;
|
import us.tastybento.bskyblock.api.flags.Flag;
|
||||||
import us.tastybento.bskyblock.api.flags.Flag.Type;
|
import us.tastybento.bskyblock.api.flags.Flag.Type;
|
||||||
|
import us.tastybento.bskyblock.api.localization.TextVariables;
|
||||||
import us.tastybento.bskyblock.api.user.User;
|
import us.tastybento.bskyblock.api.user.User;
|
||||||
import us.tastybento.bskyblock.database.objects.Island;
|
import us.tastybento.bskyblock.database.objects.Island;
|
||||||
import us.tastybento.bskyblock.managers.IslandWorldManager;
|
import us.tastybento.bskyblock.managers.IslandWorldManager;
|
||||||
@ -79,23 +80,25 @@ public abstract class AbstractFlagListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Cancels the event and sends the island public message to user
|
* Cancels the event and sends the island public message to user
|
||||||
* @param e - event
|
* @param e - event
|
||||||
|
* @param flag - the flag that has been checked
|
||||||
*/
|
*/
|
||||||
public void noGo(Event e) {
|
public void noGo(Event e, Flag flag) {
|
||||||
noGo(e, false);
|
noGo(e, flag,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels the event and sends the island protected message to user unless silent is true
|
* Cancels the event and sends the island protected message to user unless silent is true
|
||||||
* @param e - event
|
* @param e - event
|
||||||
|
* @param flag - the flag that has been checked
|
||||||
* @param silent - if true, message is not sent
|
* @param silent - if true, message is not sent
|
||||||
*/
|
*/
|
||||||
public void noGo(Event e, boolean silent) {
|
public void noGo(Event e, Flag flag, boolean silent) {
|
||||||
if (e instanceof Cancellable) {
|
if (e instanceof Cancellable) {
|
||||||
((Cancellable)e).setCancelled(true);
|
((Cancellable)e).setCancelled(true);
|
||||||
}
|
}
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
user.notify("protection.protected");
|
user.notify("protection.protected", TextVariables.DESCRIPTION, user.getTranslation(flag.getDescriptionReference()));
|
||||||
}
|
}
|
||||||
user.updateInventory();
|
user.updateInventory();
|
||||||
}
|
}
|
||||||
@ -148,7 +151,7 @@ public abstract class AbstractFlagListener implements Listener {
|
|||||||
|
|
||||||
if (island.isPresent()) {
|
if (island.isPresent()) {
|
||||||
if (!island.get().isAllowed(user, flag)) {
|
if (!island.get().isAllowed(user, flag)) {
|
||||||
noGo(e, silent);
|
noGo(e, flag, silent);
|
||||||
// Clear the user for the next time
|
// Clear the user for the next time
|
||||||
user = null;
|
user = null;
|
||||||
return false;
|
return false;
|
||||||
@ -159,7 +162,7 @@ public abstract class AbstractFlagListener implements Listener {
|
|||||||
}
|
}
|
||||||
// The player is in the world, but not on an island, so general world settings apply
|
// The player is in the world, but not on an island, so general world settings apply
|
||||||
if (!flag.isSetForWorld(loc.getWorld())) {
|
if (!flag.isSetForWorld(loc.getWorld())) {
|
||||||
noGo(e, silent);
|
noGo(e, flag, silent);
|
||||||
user = null;
|
user = null;
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user