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