diff --git a/build.gradle.kts b/build.gradle.kts index 7d586a9..efc0ea7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ plugins { } group = "org.popcraft" -version = "1.1.0" +version = "1.1.1" java { toolchain { diff --git a/src/main/java/org/popcraft/blueborder/BlueBorder.java b/src/main/java/org/popcraft/blueborder/BlueBorder.java index aeeb8d5..b6e196c 100644 --- a/src/main/java/org/popcraft/blueborder/BlueBorder.java +++ b/src/main/java/org/popcraft/blueborder/BlueBorder.java @@ -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; @@ -38,6 +44,11 @@ public List 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(); @@ -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) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..d0f63a0 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1 @@ +color: FF0000