mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-26 09:11:39 +01:00
Fixed usage of deprecated methods in CycleClicks and fixed a probable NPE
This commit is contained in:
parent
113335e60a
commit
819096eba9
@ -23,7 +23,7 @@ public class CycleClick implements PanelItem.ClickHandler {
|
||||
protected BentoBox plugin = BentoBox.getInstance();
|
||||
protected Island island;
|
||||
protected User user;
|
||||
protected boolean changeOccured;
|
||||
protected boolean changeOccurred;
|
||||
private final String id;
|
||||
private int minRank = RanksManager.VISITOR_RANK;
|
||||
private int maxRank = RanksManager.OWNER_RANK;
|
||||
@ -52,7 +52,7 @@ public class CycleClick implements PanelItem.ClickHandler {
|
||||
@Override
|
||||
public boolean onClick(Panel panel, User user, ClickType click, int slot) {
|
||||
this.user = user;
|
||||
changeOccured = false;
|
||||
changeOccurred = false;
|
||||
// Get the world
|
||||
if (!plugin.getIWM().inWorld(user.getLocation())) {
|
||||
user.sendMessage("general.errors.wrong-world");
|
||||
@ -69,10 +69,10 @@ public class CycleClick implements PanelItem.ClickHandler {
|
||||
// Right clicking decreases the rank required
|
||||
// Get the user's island
|
||||
island = plugin.getIslands().getIsland(user.getWorld(), user.getUniqueId());
|
||||
if (island != null && island.getOwner().equals(user.getUniqueId())) {
|
||||
changeOccured = true;
|
||||
if (island != null && user.getUniqueId().equals(island.getOwner())) {
|
||||
changeOccurred = true;
|
||||
RanksManager rm = plugin.getRanksManager();
|
||||
Flag flag = plugin.getFlagsManager().getFlagByID(id);
|
||||
Flag flag = plugin.getFlagsManager().getFlag(id).orElse(null);
|
||||
int currentRank = island.getFlag(flag);
|
||||
if (click.equals(ClickType.LEFT)) {
|
||||
if (currentRank >= maxRank) {
|
||||
|
@ -26,7 +26,7 @@ public class IslandLockClick extends CycleClick {
|
||||
*/
|
||||
public IslandLockClick(String id, int minRank, int maxRank) {
|
||||
super(id, minRank, maxRank);
|
||||
if (island != null && changeOccured) {
|
||||
if (island != null && changeOccurred) {
|
||||
// Fire lock event
|
||||
new IslandEvent.IslandEventBuilder()
|
||||
.island(island)
|
||||
|
@ -44,8 +44,8 @@ public class IslandToggleClick implements ClickHandler {
|
||||
}
|
||||
// Get the user's island
|
||||
Island island = plugin.getIslands().getIsland(user.getWorld(), user);
|
||||
if (island != null && island.getOwner().equals(user.getUniqueId())) {
|
||||
Flag flag = plugin.getFlagsManager().getFlagByID(id);
|
||||
if (island != null && user.getUniqueId().equals(island.getOwner())) {
|
||||
Flag flag = plugin.getFlagsManager().getFlag(id).orElse(null);
|
||||
// Toggle flag
|
||||
island.toggleFlag(flag);
|
||||
user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1F, 1F);
|
||||
|
@ -42,7 +42,7 @@ public class WorldToggleClick implements ClickHandler {
|
||||
return true;
|
||||
}
|
||||
// Get flag
|
||||
Flag flag = plugin.getFlagsManager().getFlagByID(id);
|
||||
Flag flag = plugin.getFlagsManager().getFlag(id).orElse(null);
|
||||
// Toggle flag
|
||||
flag.setSetting(user.getWorld(), !flag.isSetForWorld(user.getWorld()));
|
||||
user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1F, 1F);
|
||||
|
Loading…
Reference in New Issue
Block a user