Skip to content

Commit 5de015a

Browse files
committed
Fix minor code issues
1 parent 4301583 commit 5de015a

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/main/java/world/bentobox/aoneblock/AOneBlock.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class AOneBlock extends GameModeAddon {
6767
.defaultSetting(false)
6868
.build();
6969
private BossBarListener bossBar = new BossBarListener(this);
70-
public final Flag ONEBLOCK_BOSSBAR = new Flag.Builder("ONEBLOCK_BOSSBAR", Material.DRAGON_HEAD).mode(Mode.BASIC)
70+
public final Flag BOSSBAR = new Flag.Builder("BOSSBAR", Material.DRAGON_HEAD).mode(Mode.BASIC)
7171
.type(Type.SETTING).listener(bossBar).defaultSetting(true).build();
7272

7373
@Override
@@ -93,7 +93,7 @@ public void onLoad() {
9393
// Register protection flag with BentoBox
9494
getPlugin().getFlagsManager().registerFlag(this, START_SAFETY);
9595
// Bossbar
96-
getPlugin().getFlagsManager().registerFlag(this, this.ONEBLOCK_BOSSBAR);
96+
getPlugin().getFlagsManager().registerFlag(this, this.BOSSBAR);
9797
}
9898
}
9999

src/main/java/world/bentobox/aoneblock/commands/island/IslandBossBarCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void setup() {
2828
public boolean execute(User user, String label, List<String> args) {
2929
addon.getBossBar().toggleUser(user);
3030
getIslands().getIslandAt(user.getLocation()).ifPresent(i -> {
31-
if (!i.isAllowed(addon.ONEBLOCK_BOSSBAR)) {
31+
if (!i.isAllowed(addon.BOSSBAR)) {
3232
user.sendMessage("aoneblock.bossbar.not-active");
3333
}
3434
});

src/main/java/world/bentobox/aoneblock/listeners/BossBarListener.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
public class BossBarListener implements Listener {
3131

32+
private static final String AONEBLOCK_BOSSBAR = "aoneblock.bossbar";
33+
3234
public BossBarListener(AOneBlock addon) {
3335
super();
3436
this.addon = addon;
@@ -54,7 +56,7 @@ public void onEnterIsland(IslandEnterEvent event) {
5456

5557
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
5658
public void onFlagChange(FlagSettingChangeEvent e) {
57-
if (e.getEditedFlag() == addon.ONEBLOCK_BOSSBAR) {
59+
if (e.getEditedFlag() == addon.BOSSBAR) {
5860
// Show to players on island. If it isn't allowed then this will clean up the boss bar too
5961
e.getIsland().getPlayersOnIsland().stream().map(Player::getUniqueId)
6062
.forEach(uuid -> this.tryToShowBossBar(uuid, e.getIsland()));
@@ -70,7 +72,7 @@ private void tryToShowBossBar(UUID uuid, Island island) {
7072
User user = User.getInstance(uuid);
7173

7274
// Only show if enabled for island
73-
if (!island.isAllowed(addon.ONEBLOCK_BOSSBAR)) {
75+
if (!island.isAllowed(addon.BOSSBAR)) {
7476
BossBar removed = islandBossBars.remove(island);
7577
if (removed != null) {
7678
// Remove all players from the boss bar
@@ -79,7 +81,7 @@ private void tryToShowBossBar(UUID uuid, Island island) {
7981
return;
8082
}
8183
// Default to showing boss bar unless it is explicitly turned off
82-
if (!user.getMetaData("aoneblock.bossbar").map(MetaDataValue::asBoolean).orElse(true)) {
84+
if (!user.getMetaData(AONEBLOCK_BOSSBAR).map(MetaDataValue::asBoolean).orElse(true)) {
8385
// Remove any boss bar from user if they are in the world
8486
removeBar(user, island);
8587
// Do not show a boss bar
@@ -170,8 +172,8 @@ public void onQuit(PlayerQuitEvent e) {
170172
* @param user user to toggle
171173
*/
172174
public void toggleUser(User user) {
173-
boolean newState = !user.getMetaData("aoneblock.bossbar").map(MetaDataValue::asBoolean).orElse(true);
174-
user.putMetaData("aoneblock.bossbar", new MetaDataValue(newState));
175+
boolean newState = !user.getMetaData(AONEBLOCK_BOSSBAR).map(MetaDataValue::asBoolean).orElse(true);
176+
user.putMetaData(AONEBLOCK_BOSSBAR, new MetaDataValue(newState));
175177
if (newState) {
176178
// If the player is on an island then show the bar
177179
addon.getIslands().getIslandAt(user.getLocation()).filter(is -> addon.inWorld(is.getWorld()))

0 commit comments

Comments
 (0)