Skip to content

Commit

Permalink
Add config for color
Browse files Browse the repository at this point in the history
  • Loading branch information
pop4959 committed Dec 10, 2023
1 parent 4ab6774 commit 852c9e6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = "org.popcraft"
version = "1.1.0"
version = "1.1.1"

java {
toolchain {
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/org/popcraft/blueborder/BlueBorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@
public final class BlueBorder extends JavaPlugin {
private static final String MARKER_SET_ID = "worldborder";
private static final String LABEL = "World border";
private static final String DEFAULT_COLOR = "FF0000";
private Color color;

@Override
public void onEnable() {
getConfig().options().copyDefaults(true);
saveConfig();
reloadOptions();
BlueMapAPI.onEnable(this::addWorldBorders);
BlueMapAPI.onDisable(this::removeWorldBorders);
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
reloadOptions();
BlueMapAPI.getInstance().ifPresent(this::removeWorldBorders);
BlueMapAPI.getInstance().ifPresent(this::addWorldBorders);
return true;
Expand All @@ -38,6 +44,11 @@ public List<String> onTabComplete(CommandSender sender, Command command, String
return Collections.emptyList();
}

private void reloadOptions() {
reloadConfig();
color = new Color(Integer.parseInt(getConfig().getString("color", DEFAULT_COLOR).toLowerCase(), 16), 1f);
}

private void addWorldBorders(BlueMapAPI blueMapAPI) {
for (final World world : getServer().getWorlds()) {
final MarkerSet markerSet = MarkerSet.builder().label(LABEL).build();
Expand All @@ -51,7 +62,7 @@ private void addWorldBorders(BlueMapAPI blueMapAPI) {
final ShapeMarker marker = ShapeMarker.builder()
.label(LABEL)
.shape(border, world.getSeaLevel())
.lineColor(new Color(0xFF0000, 1f))
.lineColor(color)
.fillColor(new Color(0))
.lineWidth(3)
.depthTestEnabled(false)
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
color: FF0000

0 comments on commit 852c9e6

Please sign in to comment.