mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-30 20:39:53 -05:00
Improve Placeholders
This commit is contained in:
1 parent
e948deba9a
commit
e55f4d3917
27 files changed
+263
-51
No files matched your search
@@ -4,6 +4,9 @@ import de.rayzs.pat.api.storage.blacklist.BlacklistCreator;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.*;
|
||||
import de.rayzs.pat.api.storage.placeholders.commands.general.*;
|
||||
import de.rayzs.pat.api.storage.placeholders.commands.group.*;
|
||||
import de.rayzs.pat.api.storage.placeholders.general.GeneralCurrentVersionPlaceholder;
|
||||
import de.rayzs.pat.api.storage.placeholders.general.GeneralNewestVersionPlaceholder;
|
||||
import de.rayzs.pat.api.storage.placeholders.general.GeneralUserPlaceholder;
|
||||
import de.rayzs.pat.api.storage.placeholders.groups.*;
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.api.storage.config.messages.*;
|
||||
@@ -14,6 +17,7 @@ import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.*;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -131,21 +135,28 @@ public class Storage {
|
||||
|
||||
public static class Placeholders {
|
||||
|
||||
public static GeneralUserPlaceholder USER = new GeneralUserPlaceholder();
|
||||
public static GeneralCurrentVersionPlaceholder CURRENT_VERSION = new GeneralCurrentVersionPlaceholder();
|
||||
public static GeneralNewestVersionPlaceholder NEWEST_VERSION = new GeneralNewestVersionPlaceholder();
|
||||
|
||||
public static ListGroupsPlaceholder LIST_GROUP = new ListGroupsPlaceholder();
|
||||
public static ListGroupsReversedPlaceholder LIST_GROUP_REVERSED = new ListGroupsReversedPlaceholder();
|
||||
public static ListGroupsSortedPlaceholder LIST_GROUP_SORTED = new ListGroupsSortedPlaceholder();
|
||||
public static ListSizeGroupsPlaceholder LIST_SIZE_GROUPS = new ListSizeGroupsPlaceholder();
|
||||
|
||||
public static ListGroupCommandsPlaceholder LIST_GROUP_COMMANDS = new ListGroupCommandsPlaceholder();
|
||||
public static ListGroupReversedCommandsPlaceholder LIST_GROUP_REVERSED_COMMANDS = new ListGroupReversedCommandsPlaceholder();
|
||||
public static ListGroupSortedCommandsPlaceholder LIST_GROUP_SORTED_COMMANDS = new ListGroupSortedCommandsPlaceholder();
|
||||
public static ListGroupSizeCommandsPlaceholder LIST_GROUP_SIZE_GROUP = new ListGroupSizeCommandsPlaceholder();
|
||||
|
||||
public static ListCommandsPlaceholder LIST_COMMANDS = new ListCommandsPlaceholder();
|
||||
public static ListReversedCommandsPlaceholder LIST_REVERSED_COMMANDS = new ListReversedCommandsPlaceholder();
|
||||
public static ListSortedCommandsPlaceholder LIST_SORTED_COMMANDS = new ListSortedCommandsPlaceholder();
|
||||
public static ListSizeCommandsPlaceholder LIST_SIZE_COMMANDS = new ListSizeCommandsPlaceholder();
|
||||
|
||||
public static void initialize() {}
|
||||
|
||||
public static String findAndReplace(String request) {
|
||||
public static String findAndReplace(Player player, String request) {
|
||||
String result = null, param = "";
|
||||
|
||||
if(USE_PLACEHOLDERAPI)
|
||||
@@ -155,7 +166,7 @@ public class Storage {
|
||||
if(storage.getRequest().endsWith("group_") && request.contains("group_"))
|
||||
param = request.split("group_")[1];
|
||||
|
||||
result = storage.onRequest(param);
|
||||
result = storage.onRequest(player, param);
|
||||
if(result == null) continue;
|
||||
else result = result.replace("\\n", "\n");
|
||||
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class ListCommandsPlaceholder extends PlaceholderStorage {
|
||||
public String COMMAND, SPLITTER;
|
||||
|
||||
@Override
|
||||
public String onRequest(String param) {
|
||||
public String onRequest(Player player, String param) {
|
||||
return StringUtils.buildStringList(
|
||||
Storage.Blacklist.getBlacklist().getCommands(),
|
||||
SPLITTER,
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListReversedCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class ListReversedCommandsPlaceholder extends PlaceholderStorage {
|
||||
public String COMMAND, SPLITTER;
|
||||
|
||||
@Override
|
||||
public String onRequest(String param) {
|
||||
public String onRequest(Player player, String param) {
|
||||
return StringUtils.buildSortedStringList(
|
||||
Storage.Blacklist.getBlacklist().getCommands(),
|
||||
SPLITTER,
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.commands.general;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListSizeCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public ListSizeCommandsPlaceholder() { super("list_size_commands"); }
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
return String.valueOf(Storage.Blacklist.getBlacklist().getCommands().size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -4,6 +4,7 @@ import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListSortedCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class ListSortedCommandsPlaceholder extends PlaceholderStorage {
|
||||
public String COMMAND, SPLITTER;
|
||||
|
||||
@Override
|
||||
public String onRequest(String param) {
|
||||
public String onRequest(Player player, String param) {
|
||||
return StringUtils.buildSortedStringList(
|
||||
Storage.Blacklist.getBlacklist().getCommands(),
|
||||
SPLITTER,
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
@@ -14,7 +15,7 @@ public class ListGroupCommandsPlaceholder extends PlaceholderStorage {
|
||||
public String COMMAND, SPLITTER;
|
||||
|
||||
@Override
|
||||
public String onRequest(String param) {
|
||||
public String onRequest(Player player, String param) {
|
||||
Group group = GroupManager.getGroupByName(param);
|
||||
if(group == null) return null;
|
||||
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupReversedCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
@@ -14,7 +15,7 @@ public class ListGroupReversedCommandsPlaceholder extends PlaceholderStorage {
|
||||
public String COMMAND, SPLITTER;
|
||||
|
||||
@Override
|
||||
public String onRequest(String param) {
|
||||
public String onRequest(Player player, String param) {
|
||||
Group group = GroupManager.getGroupByName(param);
|
||||
if(group == null) return null;
|
||||
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.commands.group;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupSizeCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public ListGroupSizeCommandsPlaceholder() { super("list_size_commands_group_"); }
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
Group group = GroupManager.getGroupByName(param);
|
||||
if(group == null) return null;
|
||||
return String.valueOf(group.getCommands().size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -6,6 +6,7 @@ import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupSortedCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
@@ -14,7 +15,7 @@ public class ListGroupSortedCommandsPlaceholder extends PlaceholderStorage {
|
||||
public String COMMAND, SPLITTER;
|
||||
|
||||
@Override
|
||||
public String onRequest(String param) {
|
||||
public String onRequest(Player player, String param) {
|
||||
Group group = GroupManager.getGroupByName(param);
|
||||
if(group == null) return null;
|
||||
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.general;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GeneralCurrentVersionPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public GeneralCurrentVersionPlaceholder() { super("general_version_current"); }
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
return Storage.CURRENT_VERSION;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.general;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GeneralNewestVersionPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public GeneralNewestVersionPlaceholder() { super("general_version_newest"); }
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
return Storage.NEWER_VERSION;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.general;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GeneralUserPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public GeneralUserPlaceholder() { super("general_user"); }
|
||||
|
||||
public String CONSOLE;
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
return player == null ? CONSOLE : player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
CONSOLE = new ConfigSectionHelper<String>(this, "console-name", "Server console").getOrSet();
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -4,6 +4,7 @@ import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class ListGroupsPlaceholder extends PlaceholderStorage {
|
||||
public String COMMAND, SPLITTER;
|
||||
|
||||
@Override
|
||||
public String onRequest(String param) {
|
||||
public String onRequest(Player player, String param) {
|
||||
Group group = GroupManager.getGroupByName(param);
|
||||
if(group == null) return null;
|
||||
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupsReversedPlaceholder extends PlaceholderStorage {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class ListGroupsReversedPlaceholder extends PlaceholderStorage {
|
||||
public String COMMAND, SPLITTER;
|
||||
|
||||
@Override
|
||||
public String onRequest(String param) {
|
||||
public String onRequest(Player player, String param) {
|
||||
Group group = GroupManager.getGroupByName(param);
|
||||
if(group == null) return null;
|
||||
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupsSortedPlaceholder extends PlaceholderStorage {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class ListGroupsSortedPlaceholder extends PlaceholderStorage {
|
||||
public String COMMAND, SPLITTER;
|
||||
|
||||
@Override
|
||||
public String onRequest(String param) {
|
||||
public String onRequest(Player player, String param) {
|
||||
Group group = GroupManager.getGroupByName(param);
|
||||
if(group == null) return null;
|
||||
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.groups;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListSizeGroupsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public ListSizeGroupsPlaceholder() { super("list_size_groups"); }
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
return String.valueOf(GroupManager.getGroups().size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BlockedCommandPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public BlockedCommandPlaceholder() { super("message_blocked"); }
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
return StringUtils.buildStringList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE.getLines());
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class UnknownCommandPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public UnknownCommandPlaceholder() { super("message_unknowncommand"); }
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
return StringUtils.buildStringList(Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.MESSAGE.getLines());
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package de.rayzs.pat.api.storage.storages;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.StorageTemplate;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class PlaceholderStorage extends StorageTemplate {
|
||||
|
||||
@@ -23,5 +24,5 @@ public abstract class PlaceholderStorage extends StorageTemplate {
|
||||
return request;
|
||||
}
|
||||
|
||||
public abstract String onRequest(String param);
|
||||
public abstract String onRequest(Player player, String param);
|
||||
}
|
||||
@@ -122,17 +122,26 @@ public class BukkitLoader extends JavaPlugin {
|
||||
updaterTaskId = Bukkit.getScheduler().scheduleAsyncRepeatingTask(this, () -> {
|
||||
String result = new ConnectionBuilder().setUrl("https://www.rayzs.de/proantitab/api/version.php")
|
||||
.setProperties("ProAntiTab", "4654").connect().getResponse();
|
||||
|
||||
if(result == null) result = "internet";
|
||||
Storage.NEWER_VERSION = result;
|
||||
|
||||
if (!Storage.NEWER_VERSION.equals(Storage.CURRENT_VERSION)) {
|
||||
Bukkit.getScheduler().cancelTask(updaterTaskId);
|
||||
if (result.equals("unknown")) {
|
||||
Logger.warning("Failed reaching web host! (firewall enabled? website down?)");
|
||||
} else if (result.equals("exception")) {
|
||||
Logger.warning("Failed creating web instance! (outdated java version?)");
|
||||
} else {
|
||||
Storage.OUTDATED = true;
|
||||
Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines().forEach(Logger::warning);
|
||||
switch (result) {
|
||||
case "internet":
|
||||
Logger.warning("Failed to build connection to website! (No internet?)");
|
||||
break;
|
||||
case "unknown":
|
||||
Logger.warning("Failed to build connection to website! (Firewall enabled or website down?)");
|
||||
break;
|
||||
case "exception":
|
||||
Logger.warning("Failed to build connection to website! (Outdated java version?)");
|
||||
break;
|
||||
default:
|
||||
Storage.OUTDATED = true;
|
||||
Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines().forEach(Logger::warning);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if(!checkUpdate) {
|
||||
|
||||
@@ -53,10 +53,14 @@ public class CommandSender {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object getSenderObject() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public void sendMessage(String text) {
|
||||
if(MessageTranslator.isSupported()) MessageTranslator.send(sender, text);
|
||||
else if(sender instanceof Player) ((Player) sender).sendMessage(text);
|
||||
else if(sender instanceof org.bukkit.command.CommandSender) ((org.bukkit.command.CommandSender) sender).sendMessage(text);
|
||||
else if(sender instanceof Player) ((Player) sender).sendMessage(MessageTranslator.replaceMessage(sender, text));
|
||||
else if(sender instanceof org.bukkit.command.CommandSender) ((org.bukkit.command.CommandSender) sender).sendMessage(MessageTranslator.replaceMessage(sender, text));
|
||||
}
|
||||
|
||||
public String getServerName() {
|
||||
|
||||
@@ -44,9 +44,7 @@ public class ConnectionBuilder {
|
||||
StringBuilder builder = new StringBuilder("\\");
|
||||
while (scanner.hasNextLine()) builder.append(" ").append(scanner.next());
|
||||
response = builder.toString().replace("\\ ", "");
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("§cFailed to built connection to website! [" + exception.getMessage() + "]");
|
||||
}
|
||||
} catch (Exception ignored) { }
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
package de.rayzs.pat.utils;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
@@ -83,4 +77,17 @@ public class StringUtils {
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static String buildStringList(List<String> list) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
boolean end;
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
end = i >= list.size() - 1;
|
||||
builder.append(list.get(i).replace("&", "§"));
|
||||
if (!end) builder.append("\n");
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.rayzs.pat.utils.configuration.helper;
|
||||
|
||||
import de.rayzs.pat.api.storage.StorageTemplate;
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.configuration.ConfigurationBuilder;
|
||||
@@ -10,13 +11,7 @@ public class ConfigSectionHelper<T> {
|
||||
private final String path;
|
||||
private final Object obj;
|
||||
|
||||
public ConfigSectionHelper(ConfigStorage config, String path, Object obj) {
|
||||
this.configuration = config.getConfig();
|
||||
this.path = config.getNavigatePath() + (path != null ? "." + path : ""); ;
|
||||
this.obj = obj;
|
||||
}
|
||||
|
||||
public ConfigSectionHelper(PlaceholderStorage config, String path, Object obj) {
|
||||
public ConfigSectionHelper(StorageTemplate config, String path, Object obj) {
|
||||
this.configuration = config.getConfig();
|
||||
this.path = config.getNavigatePath() + (path != null ? "." + path : ""); ;
|
||||
this.obj = obj;
|
||||
|
||||
@@ -42,6 +42,6 @@ public class PlaceholderHook extends PlaceholderExpansion {
|
||||
|
||||
@Override
|
||||
public @Nullable String onPlaceholderRequest(Player player, @NotNull String request) {
|
||||
return Storage.ConfigSections.Placeholders.findAndReplace(request.toLowerCase());
|
||||
return Storage.ConfigSections.Placeholders.findAndReplace(player, request.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,21 @@
|
||||
package de.rayzs.pat.utils.message.replacer;
|
||||
|
||||
import de.rayzs.pat.utils.CommandSender;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlaceholderReplacer {
|
||||
|
||||
public static String replace(Object player, String text) {
|
||||
return PlaceholderAPI.setPlaceholders((Player) player, text);
|
||||
public static String replace(Object playerObj, String text) {
|
||||
Player player = null;
|
||||
|
||||
if(playerObj != null)
|
||||
if(playerObj instanceof CommandSender) {
|
||||
CommandSender sender = (CommandSender) playerObj;
|
||||
player = sender.isPlayer() ? (Player) sender.getSenderObject() : null;
|
||||
} else if(playerObj instanceof Player)
|
||||
player = (Player) playerObj;
|
||||
|
||||
return PlaceholderAPI.setPlaceholders(player, text);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user