From a3ab4f3fbd173b0ef6f85918caa5d66f7018ecb2 Mon Sep 17 00:00:00 2001 From: William Polansky Date: Thu, 1 Aug 2024 16:34:42 -0700 Subject: [PATCH] Add Bedrock Geyser Support --- src/main/java/me/codedred/playtimes/commands/Time.java | 4 +++- src/main/java/me/codedred/playtimes/data/CustomConfig.java | 1 + src/main/resources/config.yml | 5 +++++ src/main/resources/exampleConfig.yml | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/codedred/playtimes/commands/Time.java b/src/main/java/me/codedred/playtimes/commands/Time.java index 7f797b7..252c7eb 100644 --- a/src/main/java/me/codedred/playtimes/commands/Time.java +++ b/src/main/java/me/codedred/playtimes/commands/Time.java @@ -275,10 +275,12 @@ private void handleOtherPlayerCommand(CommandSender sender, String[] args) { ChatUtil.errno(sender, ChatUtil.ChatTypes.NO_PERMISSION); return; } + String userPrefixRegex = Pattern.quote(Objects.requireNonNull(data.getConfig().getString("floodgate-username-prefix"))); + String regex = "[^a-z0-9_" + userPrefixRegex + "]"; new BukkitRunnable() { @Override public void run() { - Pattern p = Pattern.compile("[^a-z0-9_]", Pattern.CASE_INSENSITIVE); + Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(args[0]); boolean b = m.find(); diff --git a/src/main/java/me/codedred/playtimes/data/CustomConfig.java b/src/main/java/me/codedred/playtimes/data/CustomConfig.java index 9b9127e..aa160ac 100644 --- a/src/main/java/me/codedred/playtimes/data/CustomConfig.java +++ b/src/main/java/me/codedred/playtimes/data/CustomConfig.java @@ -49,6 +49,7 @@ public void reloadConfig() { private void checkAndAddDefaults() { Map requiredKeys = new LinkedHashMap<>(); requiredKeys.put("prefix", "&7[&b&lPlayTimes&7]"); + requiredKeys.put("floodgate-username-prefix", "."); requiredKeys.put("use-papi-placeholders", false); requiredKeys.put( diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 0216626..635d33d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -4,6 +4,11 @@ # The 'prefix' configures the introductory text for 'player-not-found' and 'player-never-joined' notifications. prefix: "&7[&b&lPlayTimes&7]" +# Only for servers running Floodgate for Bedrock Geyser support. +# This should be the same username-prefix found in your Floodgate config.yml +# Use '' for an empty prefix +floodgate-username-prefix: "." + # Placeholder API Configuration # Activate this only if using PlaceholderAPI with PlayTimes. # To integrate PlayTimes placeholders into other plugins, simply install PlaceholderAPI; integration occurs seamlessly. diff --git a/src/main/resources/exampleConfig.yml b/src/main/resources/exampleConfig.yml index ae31dbd..8e28986 100644 --- a/src/main/resources/exampleConfig.yml +++ b/src/main/resources/exampleConfig.yml @@ -4,6 +4,11 @@ # The 'prefix' configures the introductory text for 'player-not-found' and 'player-never-joined' notifications. prefix: "&7[&b&lPlayTimes&7]" +# Only for servers running Floodgate for Bedrock Geyser support. +# This should be the same username-prefix found in your Floodgate config.yml +# Use '' for an empty prefix +floodgate-username-prefix: "." + # Placeholder API Configuration # Activate this only if using PlaceholderAPI with PlayTimes. # To integrate PlayTimes placeholders into other plugins, simply install PlaceholderAPI; integration occurs seamlessly.