Skip to content

Commit

Permalink
Make config properties private with public getters
Browse files Browse the repository at this point in the history
  • Loading branch information
TechnicJelle committed Feb 20, 2024
1 parent 14a2ab9 commit 55818b0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void onEnable() {

@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChat(AsyncPlayerChatEvent event) {
if (event.isCancelled() && !config.forceful) return;
if (event.isCancelled() && !config.getForceful()) return;
BlueMapAPI api = BlueMapAPI.getInstance().orElse(null);
if (api == null) return; //BlueMap not loaded, ignore

Expand All @@ -79,9 +79,9 @@ public void onPlayerChat(AsyncPlayerChatEvent event) {
bmWorld.getMaps().forEach(map -> {
// get marker-set of map (or create new marker set if none found)
MarkerSet markerSet = map.getMarkerSets().computeIfAbsent(Config.MARKER_SET_ID, id -> MarkerSet.builder()
.label(config.markerSetName)
.toggleable(config.toggleable)
.defaultHidden(config.defaultHidden)
.label(config.getMarkerSetName())
.toggleable(config.isToggleable())
.defaultHidden(config.isDefaultHidden())
.build());

String key = "chat-marker_" + event.hashCode();
Expand All @@ -92,7 +92,7 @@ public void onPlayerChat(AsyncPlayerChatEvent event) {
//wait Seconds and remove the Marker
Bukkit.getScheduler().runTaskLater(this,
() -> markerSet.remove(key),
config.markerDuration * 20L);
config.getMarkerDuration() * 20L);
});
}

Expand Down
30 changes: 25 additions & 5 deletions src/main/java/com/technicjelle/bluemapchatmarkers/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ public class Config {

private final BlueMapChatMarkers plugin;

public String markerSetName;
public boolean toggleable;
public boolean defaultHidden;
public boolean forceful;
public long markerDuration;
private final String markerSetName;
private final boolean toggleable;
private final boolean defaultHidden;
private final long markerDuration;
private final boolean forceful;

public Config(BlueMapChatMarkers plugin) {
this.plugin = plugin;
Expand All @@ -39,4 +39,24 @@ public Config(BlueMapChatMarkers plugin) {
private FileConfiguration configFile() {
return plugin.getConfig();
}

public String getMarkerSetName() {
return markerSetName;
}

public boolean isToggleable() {
return toggleable;
}

public boolean isDefaultHidden() {
return defaultHidden;
}

public long getMarkerDuration() {
return markerDuration;
}

public boolean getForceful() {
return forceful;
}
}

0 comments on commit 55818b0

Please sign in to comment.