Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>1.21.1</build.version>
<build.version>1.21.2</build.version>
<!-- SonarCloud -->
<sonar.projectKey>BentoBoxWorld_AOneBlock</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/world/bentobox/aoneblock/AOneBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ public void onLoad() {
// Register protection flag with BentoBox
getPlugin().getFlagsManager().registerFlag(this, START_SAFETY);
// Bossbar
getPlugin().getFlagsManager().registerFlag(this, this.ONEBLOCK_BOSSBAR);
if (getSettings().isBossBar()) {
getPlugin().getFlagsManager().registerFlag(this, this.ONEBLOCK_BOSSBAR);
}
// Actionbar
if (getSettings().isActionBar()) {
getPlugin().getFlagsManager().registerFlag(this, this.ONEBLOCK_ACTIONBAR);
}
// Magic Block protection
getPlugin().getFlagsManager().registerFlag(this, this.MAGIC_BLOCK);
}
Expand Down Expand Up @@ -171,7 +177,9 @@ public void onEnable() {
registerListener(new BlockProtect(this));
registerListener(new JoinLeaveListener(this));
registerListener(new InfoListener(this));
registerListener(bossBar);
if (getSettings().isBossBar() && getSettings().isActionBar()) {
registerListener(bossBar);
}
// Register placeholders
phManager = new AOneBlockPlaceholders(this, getPlugin().getPlaceholdersManager());

Expand Down
137 changes: 96 additions & 41 deletions src/main/java/world/bentobox/aoneblock/Settings.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import java.util.List;

import world.bentobox.aoneblock.AOneBlock;
import world.bentobox.aoneblock.listeners.BossBarListener;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.metadata.MetaDataValue;
import world.bentobox.bentobox.api.user.User;

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

@Override
public boolean execute(User user, String label, List<String> args) {
addon.getBossBar().toggleUser(user);
getIslands().getIslandAt(user.getLocation()).ifPresent(i -> {
if (!i.isAllowed(addon.ONEBLOCK_ACTIONBAR)) {
user.sendMessage("aoneblock.actionbar.not-active");
}
});
// Toggle state
boolean newState = !user.getMetaData(BossBarListener.AONEBLOCK_ACTIONBAR).map(MetaDataValue::asBoolean).orElse(true);
user.putMetaData(BossBarListener.AONEBLOCK_ACTIONBAR, new MetaDataValue(newState));
if (newState) {
user.sendMessage("aoneblock.commands.island.actionbar.status_on");
} else {
user.sendMessage("aoneblock.commands.island.actionbar.status_off");
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,31 @@ public void setup() {

// Count
new IslandCountCommand(this,
settings.getCountCommand().split(" ")[0],
settings.getCountCommand().split(" "));
settings.getCountCommand().split(" ")[0],
settings.getCountCommand().split(" "));
// Phase list
new IslandPhasesCommand(this,
settings.getPhasesCommand().split(" ")[0],
settings.getPhasesCommand().split(" "));
settings.getPhasesCommand().split(" ")[0],
settings.getPhasesCommand().split(" "));
// Set Count
new IslandSetCountCommand(this,
settings.getSetCountCommand().split(" ")[0],
settings.getSetCountCommand().split(" "));
settings.getSetCountCommand().split(" ")[0],
settings.getSetCountCommand().split(" "));
// Force block respawn
new IslandRespawnBlockCommand(this,
settings.getRespawnBlockCommand().split(" ")[0],
settings.getRespawnBlockCommand().split(" "));
settings.getRespawnBlockCommand().split(" ")[0],
settings.getRespawnBlockCommand().split(" "));

// Action bar
if (settings.isActionBar()) {
new IslandActionBarCommand(this, settings.getActionBarCommand().split(" ")[0],
settings.getActionBarCommand().split(" "));
}

// Boss bar
new IslandBossBarCommand(this, settings.getBossBarCommand().split(" ")[0],
settings.getBossBarCommand().split(" "));
if (settings.isBossBar()) {
new IslandBossBarCommand(this, settings.getBossBarCommand().split(" ")[0],
settings.getBossBarCommand().split(" "));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.eclipse.jdt.annotation.NonNull;

import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import world.bentobox.aoneblock.AOneBlock;
import world.bentobox.aoneblock.dataobjects.OneBlockIslands;
Expand All @@ -33,7 +32,7 @@
public class BossBarListener implements Listener {

private static final String AONEBLOCK_BOSSBAR = "aoneblock.bossbar";
private static final String AONEBLOCK_ACTIONBAR = "aoneblock.actionbar";
public static final String AONEBLOCK_ACTIONBAR = "aoneblock.actionbar";

private static final LegacyComponentSerializer LEGACY_SERIALIZER = LegacyComponentSerializer.builder()
.character('&')
Expand Down Expand Up @@ -98,11 +97,9 @@ private void tryToShowActionBar(UUID uuid, Island island) {
if (!island.isAllowed(addon.ONEBLOCK_ACTIONBAR)) {
return;
}
// Default to showing boss bar unless it is explicitly turned off
// Default to showing action bar unless it is explicitly turned off
if (!user.getMetaData(AONEBLOCK_ACTIONBAR).map(MetaDataValue::asBoolean).orElse(true)) {
// Remove any boss bar from user if they are in the world
removeBar(user, island);
// Do not show a boss bar
// Do not show a action bar
return;
}
// Get the progress
Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/addon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ permissions:
aoneblock.island:
description: Allow use of '/ob' command - the main island command
default: TRUE
aoneblock.island.actionbar:
description: Allow use of '/ob actionbar' command - toggle the actionbar
default: TRUE
aoneblock.island.bossbar:
description: Allow use of '/ob bossbar' command - toggle the bossbar
default: FALSE
description: Allow use of '/ob bossbar' command - toggle the bossbar
default: TRUE
aoneblock.island.home:
description: Allow use of '/ob go' command - teleport you to your island
default: TRUE
Expand Down
Loading