Skip to content

Commit 975b8bc

Browse files
committed
Fixes #460 where the action bar command was missing. Also adds #463
1 parent d2e20c2 commit 975b8bc

File tree

8 files changed

+174
-107
lines changed

8 files changed

+174
-107
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ public void onLoad() {
130130
// Register protection flag with BentoBox
131131
getPlugin().getFlagsManager().registerFlag(this, START_SAFETY);
132132
// Bossbar
133-
getPlugin().getFlagsManager().registerFlag(this, this.ONEBLOCK_BOSSBAR);
133+
if (getSettings().isBossBar()) {
134+
getPlugin().getFlagsManager().registerFlag(this, this.ONEBLOCK_BOSSBAR);
135+
}
136+
// Actionbar
137+
if (getSettings().isActionBar()) {
138+
getPlugin().getFlagsManager().registerFlag(this, this.ONEBLOCK_ACTIONBAR);
139+
}
134140
// Magic Block protection
135141
getPlugin().getFlagsManager().registerFlag(this, this.MAGIC_BLOCK);
136142
}
@@ -171,7 +177,9 @@ public void onEnable() {
171177
registerListener(new BlockProtect(this));
172178
registerListener(new JoinLeaveListener(this));
173179
registerListener(new InfoListener(this));
174-
registerListener(bossBar);
180+
if (getSettings().isBossBar() && getSettings().isActionBar()) {
181+
registerListener(bossBar);
182+
}
175183
// Register placeholders
176184
phManager = new AOneBlockPlaceholders(this, getPlugin().getPlaceholdersManager());
177185

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

Lines changed: 96 additions & 41 deletions
Large diffs are not rendered by default.

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import java.util.List;
44

55
import world.bentobox.aoneblock.AOneBlock;
6+
import world.bentobox.aoneblock.listeners.BossBarListener;
67
import world.bentobox.bentobox.api.commands.CompositeCommand;
8+
import world.bentobox.bentobox.api.metadata.MetaDataValue;
79
import world.bentobox.bentobox.api.user.User;
810

911
public class IslandActionBarCommand extends CompositeCommand {
@@ -26,12 +28,19 @@ public void setup() {
2628

2729
@Override
2830
public boolean execute(User user, String label, List<String> args) {
29-
addon.getBossBar().toggleUser(user);
3031
getIslands().getIslandAt(user.getLocation()).ifPresent(i -> {
3132
if (!i.isAllowed(addon.ONEBLOCK_ACTIONBAR)) {
3233
user.sendMessage("aoneblock.actionbar.not-active");
3334
}
3435
});
36+
// Toggle state
37+
boolean newState = !user.getMetaData(BossBarListener.AONEBLOCK_ACTIONBAR).map(MetaDataValue::asBoolean).orElse(true);
38+
user.putMetaData(BossBarListener.AONEBLOCK_ACTIONBAR, new MetaDataValue(newState));
39+
if (newState) {
40+
user.sendMessage("aoneblock.commands.island.actionbar.status_on");
41+
} else {
42+
user.sendMessage("aoneblock.commands.island.actionbar.status_off");
43+
}
3544
return true;
3645
}
3746
}

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,31 @@ public void setup() {
2121

2222
// Count
2323
new IslandCountCommand(this,
24-
settings.getCountCommand().split(" ")[0],
25-
settings.getCountCommand().split(" "));
24+
settings.getCountCommand().split(" ")[0],
25+
settings.getCountCommand().split(" "));
2626
// Phase list
2727
new IslandPhasesCommand(this,
28-
settings.getPhasesCommand().split(" ")[0],
29-
settings.getPhasesCommand().split(" "));
28+
settings.getPhasesCommand().split(" ")[0],
29+
settings.getPhasesCommand().split(" "));
3030
// Set Count
3131
new IslandSetCountCommand(this,
32-
settings.getSetCountCommand().split(" ")[0],
33-
settings.getSetCountCommand().split(" "));
32+
settings.getSetCountCommand().split(" ")[0],
33+
settings.getSetCountCommand().split(" "));
3434
// Force block respawn
3535
new IslandRespawnBlockCommand(this,
36-
settings.getRespawnBlockCommand().split(" ")[0],
37-
settings.getRespawnBlockCommand().split(" "));
36+
settings.getRespawnBlockCommand().split(" ")[0],
37+
settings.getRespawnBlockCommand().split(" "));
38+
39+
// Action bar
40+
if (settings.isActionBar()) {
41+
new IslandActionBarCommand(this, settings.getActionBarCommand().split(" ")[0],
42+
settings.getActionBarCommand().split(" "));
43+
}
44+
3845
// Boss bar
39-
new IslandBossBarCommand(this, settings.getBossBarCommand().split(" ")[0],
40-
settings.getBossBarCommand().split(" "));
46+
if (settings.isBossBar()) {
47+
new IslandBossBarCommand(this, settings.getBossBarCommand().split(" ")[0],
48+
settings.getBossBarCommand().split(" "));
49+
}
4150
}
4251
}

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import org.eclipse.jdt.annotation.NonNull;
1919

2020
import net.kyori.adventure.text.Component;
21-
import net.kyori.adventure.text.format.NamedTextColor;
2221
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
2322
import world.bentobox.aoneblock.AOneBlock;
2423
import world.bentobox.aoneblock.dataobjects.OneBlockIslands;
@@ -33,7 +32,7 @@
3332
public class BossBarListener implements Listener {
3433

3534
private static final String AONEBLOCK_BOSSBAR = "aoneblock.bossbar";
36-
private static final String AONEBLOCK_ACTIONBAR = "aoneblock.actionbar";
35+
public static final String AONEBLOCK_ACTIONBAR = "aoneblock.actionbar";
3736

3837
private static final LegacyComponentSerializer LEGACY_SERIALIZER = LegacyComponentSerializer.builder()
3938
.character('&')
@@ -98,11 +97,9 @@ private void tryToShowActionBar(UUID uuid, Island island) {
9897
if (!island.isAllowed(addon.ONEBLOCK_ACTIONBAR)) {
9998
return;
10099
}
101-
// Default to showing boss bar unless it is explicitly turned off
100+
// Default to showing action bar unless it is explicitly turned off
102101
if (!user.getMetaData(AONEBLOCK_ACTIONBAR).map(MetaDataValue::asBoolean).orElse(true)) {
103-
// Remove any boss bar from user if they are in the world
104-
removeBar(user, island);
105-
// Do not show a boss bar
102+
// Do not show a action bar
106103
return;
107104
}
108105
// Get the progress

src/main/resources/addon.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ permissions:
5050
aoneblock.island:
5151
description: Allow use of '/ob' command - the main island command
5252
default: TRUE
53+
aoneblock.island.actionbar:
54+
description: Allow use of '/ob actionbar' command - toggle the actionbar
55+
default: TRUE
5356
aoneblock.island.bossbar:
54-
description: Allow use of '/ob bossbar' command - toggle the bossbar
55-
default: FALSE
57+
description: Allow use of '/ob bossbar' command - toggle the bossbar
58+
default: TRUE
5659
aoneblock.island.home:
5760
description: Allow use of '/ob go' command - teleport you to your island
5861
default: TRUE

0 commit comments

Comments
 (0)