Skip to content

Commit

Permalink
Added placeholder settings (#26).
Browse files Browse the repository at this point in the history
  • Loading branch information
imDMK committed Feb 23, 2024
1 parent fc6e1ac commit 42da56b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ public DoubleJump(Plugin plugin) {

Stream.of(
new JumpPlayerDelayPlaceholder(pluginDescriptionFile, this.jumpPlayerManager),
new JumpPlayerIsDelayPlaceholder(pluginDescriptionFile, this.jumpPlayerManager),
new JumpPlayerIsDelayPlaceholder(pluginDescriptionFile, this.pluginConfiguration.placeholderSettings, this.jumpPlayerManager),
new JumpPlayerRegenerationDelayPlaceholder(pluginDescriptionFile, this.jumpPlayerManager),
new JumpPlayerHasJumpsPlaceholder(pluginDescriptionFile, this.jumpPlayerManager),
new JumpPlayerHasJumpsPlaceholder(pluginDescriptionFile, this.pluginConfiguration.placeholderSettings, this.jumpPlayerManager),
new JumpPlayerJumpsLimitPlaceholder(pluginDescriptionFile, this.jumpPlayerManager),
new JumpPlayerJumpsPlaceholder(pluginDescriptionFile, this.jumpPlayerManager),
new JumpPlayerStreakPlaceholder(pluginDescriptionFile, this.jumpPlayerManager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.imdmk.doublejump.command.CommandSettings;
import com.github.imdmk.doublejump.jump.JumpSettings;
import com.github.imdmk.doublejump.notification.configuration.NotificationSettings;
import com.github.imdmk.doublejump.placeholder.PlaceholderSettings;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import eu.okaeri.configs.annotation.Header;
Expand Down Expand Up @@ -37,4 +38,7 @@ public class PluginConfiguration extends OkaeriConfig {

@Comment({"# ", "# Notification settings", "# "})
public NotificationSettings notificationSettings = new NotificationSettings();

@Comment({"# ", "# Placeholder settings", "# "})
public PlaceholderSettings placeholderSettings = new PlaceholderSettings();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.imdmk.doublejump.jump.JumpPlayer;
import com.github.imdmk.doublejump.jump.JumpPlayerManager;
import com.github.imdmk.doublejump.placeholder.PlaceholderSettings;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.PluginDescriptionFile;
Expand All @@ -13,10 +14,12 @@
public class JumpPlayerIsDelayPlaceholder extends PlaceholderExpansion {

private final PluginDescriptionFile pluginDescriptionFile;
private final PlaceholderSettings placeholderSettings;
private final JumpPlayerManager jumpPlayerManager;

public JumpPlayerIsDelayPlaceholder(PluginDescriptionFile pluginDescriptionFile, JumpPlayerManager jumpPlayerManager) {
public JumpPlayerIsDelayPlaceholder(PluginDescriptionFile pluginDescriptionFile, PlaceholderSettings placeholderSettings, JumpPlayerManager jumpPlayerManager) {
this.pluginDescriptionFile = pluginDescriptionFile;
this.placeholderSettings = placeholderSettings;
this.jumpPlayerManager = jumpPlayerManager;
}

Expand Down Expand Up @@ -45,7 +48,7 @@ public JumpPlayerIsDelayPlaceholder(PluginDescriptionFile pluginDescriptionFile,

return jumpPlayerOptional
.map(JumpPlayer::isDelay)
.map(aBoolean -> aBoolean ? "yes" : "no")
.map(aBoolean -> aBoolean ? this.placeholderSettings.whenTrueMessage : this.placeholderSettings.whenFalseMessage)
.orElse(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.imdmk.doublejump.jump.JumpPlayer;
import com.github.imdmk.doublejump.jump.JumpPlayerManager;
import com.github.imdmk.doublejump.placeholder.PlaceholderSettings;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.PluginDescriptionFile;
Expand All @@ -13,10 +14,12 @@
public class JumpPlayerHasJumpsPlaceholder extends PlaceholderExpansion {

private final PluginDescriptionFile pluginDescriptionFile;
private final PlaceholderSettings placeholderSettings;
private final JumpPlayerManager jumpPlayerManager;

public JumpPlayerHasJumpsPlaceholder(PluginDescriptionFile pluginDescriptionFile, JumpPlayerManager jumpPlayerManager) {
public JumpPlayerHasJumpsPlaceholder(PluginDescriptionFile pluginDescriptionFile, PlaceholderSettings placeholderSettings, JumpPlayerManager jumpPlayerManager) {
this.pluginDescriptionFile = pluginDescriptionFile;
this.placeholderSettings = placeholderSettings;
this.jumpPlayerManager = jumpPlayerManager;
}

Expand Down Expand Up @@ -45,7 +48,7 @@ public JumpPlayerHasJumpsPlaceholder(PluginDescriptionFile pluginDescriptionFile

return jumpPlayerOptional
.map(JumpPlayer::hasJumps)
.map(aBoolean -> aBoolean ? "yes" : "no")
.map(aBoolean -> aBoolean ? this.placeholderSettings.whenTrueMessage : this.placeholderSettings.whenFalseMessage)
.orElse(null);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.github.imdmk.doublejump.jump.sound;

import com.github.imdmk.doublejump.configuration.implementation.PluginConfiguration;
import com.github.imdmk.doublejump.jump.JumpSettings;
import com.github.imdmk.doublejump.placeholder.PlaceholderRegistry;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.github.imdmk.doublejump.placeholder;

import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;

public class PlaceholderSettings extends OkaeriConfig {

@Comment({
"# Message shown after using the placeholder if it returns true.",
"# Example:",
"# whenTrueMessage: 'Available'",
"# Placeholder 'jump-player-is-delay' will return 'Available' when player doesn't have delay"
})
public String whenTrueMessage = "yes";

@Comment({
"# Message shown after using the placeholder if it returns false.",
"# Example:",
"# whenFalseMessage: 'Cooldown'",
"# Placeholder 'jump-player-is-delay' will return 'Cooldown' when player have delay"
})
public String whenFalseMessage = "no";
}

0 comments on commit 42da56b

Please sign in to comment.