mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 03:35:11 +01:00
Refactored toPanelItem to make it easier to understand
This commit is contained in:
parent
af25bba60c
commit
7a7ca42383
@ -299,32 +299,42 @@ public class Flag implements Comparable<Flag> {
|
|||||||
pib.description(user.getTranslation("protection.panel.flag-item.menu-layout", TextVariables.DESCRIPTION, user.getTranslation(getDescriptionReference())));
|
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
|
Island island = plugin.getIslands().getIslandAt(user.getLocation()).orElse(plugin.getIslands().getIsland(user.getWorld(), user.getUniqueId()));
|
||||||
if (getType().equals(Type.WORLD_SETTING)) {
|
switch(getType()) {
|
||||||
String worldDetting = this.isSetForWorld(user.getWorld()) ? user.getTranslation("protection.panel.flag-item.setting-active")
|
case PROTECTION:
|
||||||
: user.getTranslation("protection.panel.flag-item.setting-disabled");
|
return createProtectionFlag(plugin, user, island, pib).build();
|
||||||
pib.description(user.getTranslation("protection.panel.flag-item.setting-layout", TextVariables.DESCRIPTION, user.getTranslation(getDescriptionReference())
|
case SETTING:
|
||||||
, "[setting]", worldDetting));
|
return createSettingFlag(plugin, user, island, pib).build();
|
||||||
|
case WORLD_SETTING:
|
||||||
|
return createWorldSettingFlag(plugin, user, pib).build();
|
||||||
|
default:
|
||||||
return pib.build();
|
return pib.build();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get the island this user is on or their own
|
private PanelItemBuilder createWorldSettingFlag(BentoBox plugin, User user, PanelItemBuilder pib) {
|
||||||
Island island = plugin.getIslands().getIslandAt(user.getLocation()).orElse(plugin.getIslands().getIsland(user.getWorld(), user.getUniqueId()));
|
String worldSetting = this.isSetForWorld(user.getWorld()) ? user.getTranslation("protection.panel.flag-item.setting-active")
|
||||||
|
: user.getTranslation("protection.panel.flag-item.setting-disabled");
|
||||||
|
pib.description(user.getTranslation("protection.panel.flag-item.setting-layout", TextVariables.DESCRIPTION, user.getTranslation(getDescriptionReference())
|
||||||
|
, "[setting]", worldSetting));
|
||||||
|
return pib;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PanelItemBuilder createSettingFlag(BentoBox plugin, User user, Island island, PanelItemBuilder pib) {
|
||||||
if (island != null) {
|
if (island != null) {
|
||||||
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", TextVariables.DESCRIPTION, user.getTranslation(getDescriptionReference())
|
pib.description(user.getTranslation("protection.panel.flag-item.setting-layout", TextVariables.DESCRIPTION, user.getTranslation(getDescriptionReference())
|
||||||
, "[setting]", islandSetting));
|
, "[setting]", islandSetting));
|
||||||
return pib.build();
|
|
||||||
}
|
}
|
||||||
// TODO: Get the world settings - the player has no island and is not in an island location
|
return pib;
|
||||||
// Dynamic rank list
|
}
|
||||||
if (getType().equals(Type.PROTECTION)) {
|
|
||||||
|
private PanelItemBuilder createProtectionFlag(BentoBox plugin, User user, Island island, PanelItemBuilder pib) {
|
||||||
|
if (island != null) {
|
||||||
// Protection flag
|
// Protection flag
|
||||||
String d = user.getTranslation(getDescriptionReference());
|
pib.description(user.getTranslation("protection.panel.flag-item.description-layout",
|
||||||
d = user.getTranslation("protection.panel.flag-item.description-layout", TextVariables.DESCRIPTION, d);
|
TextVariables.DESCRIPTION, user.getTranslation(getDescriptionReference())));
|
||||||
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)) {
|
||||||
pib.description(user.getTranslation("protection.panel.flag-item.blocked-rank") + user.getTranslation(reference));
|
pib.description(user.getTranslation("protection.panel.flag-item.blocked-rank") + user.getTranslation(reference));
|
||||||
@ -335,10 +345,8 @@ public class Flag implements Comparable<Flag> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
return pib;
|
||||||
}
|
}
|
||||||
return pib.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see java.lang.Object#toString()
|
* @see java.lang.Object#toString()
|
||||||
|
Loading…
Reference in New Issue
Block a user