Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%s being edited to % by PlaceholderAPI #771

Closed
3 tasks done
booksaw opened this issue Dec 22, 2021 · 2 comments · Fixed by #772
Closed
3 tasks done

%s being edited to % by PlaceholderAPI #771

booksaw opened this issue Dec 22, 2021 · 2 comments · Fixed by #772
Assignees
Labels
Type: Issue (PlaceholderAPI) Issue caused by PlaceholderAPI not working properly.

Comments

@booksaw
Copy link

booksaw commented Dec 22, 2021

Confirmation

  • My issue isn't already found on the Issue tracker.
  • My issue is about PlaceholderAPI and not any expansion or external plugin
  • The issue isn't already fixed in a Spigot Release or Development Build.

Type

API Bug

What happens?

The method PlaceholderAPI.setPlaceholders(OfflinePlayer, String); is changing the input string %s to % , this is causing bugs further down the line in other plugins that use String.format(); for example.

This bug is specific to the latest version (2.11.0)

I found this bug from bug reports from users of betterteams, as BetterTeams supports placeholders in all messages the use of String.format across the plugin broke most plugin messages while placeholderAPI was installed.

Expected Behaviour

The string %s should remain uneffected.

How to Reproduce

The following single class plugin demonstrates the bug reliably

import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.java.JavaPlugin;

import me.clip.placeholderapi.PlaceholderAPI;

public class BugExample extends JavaPlugin implements Listener {

	@Override
	public void onEnable() {
		Bukkit.getPluginManager().registerEvents(this, this);
	}

	@EventHandler
	public void onChat(AsyncPlayerChatEvent e) {
		e.setMessage(PlaceholderAPI.setPlaceholders(e.getPlayer(), "(%s )"));
	}

}

Simply compile the plugin and type something in chat. Notice how your message will be (% ), the brackets are not needed for the bug to occur, they are simply there to demonstrate that the space remains.

/papi dump Output

https://paste.helpch.at/cupojeloka

Console Log

https://paste.helpch.at/vohidipomi.md

Errors

No response

Additional Info

code-examples provided in the reproduce box.

@booksaw booksaw added the Type: Issue (Unconfirmed) Issue is not reproducable and therefore not confirmed to exist. label Dec 22, 2021
@booksaw booksaw changed the title UnknownFormatConversionException %s being edited to % by PlaceholderAPI Dec 22, 2021
@Andre601
Copy link
Collaborator

I assume the issue is not present when you do the String.format before setting placeholders?
F.e. PlaceholderAPI.setPlaceholders(player, String.format("Some String %s %%player_name%%"))

@booksaw
Copy link
Author

booksaw commented Dec 22, 2021

Doing String.format before PlaceholderAPI.setPlaceholders() would not indicate the existence of the bug as the %s will have already been replaced with the new value before PlaceholderAPI.setPlaceholders() can remove the s.

@Andre601 Andre601 changed the title %s being edited to % by PlaceholderAPI %s being edited to % by PlaceholderAPI Dec 22, 2021
@PiggyPiglet PiggyPiglet self-assigned this Dec 23, 2021
@PiggyPiglet PiggyPiglet added Type: Issue (PlaceholderAPI) Issue caused by PlaceholderAPI not working properly. and removed Type: Issue (Unconfirmed) Issue is not reproducable and therefore not confirmed to exist. labels Dec 24, 2021
PiggyPiglet added a commit that referenced this issue Dec 24, 2021
@PiggyPiglet PiggyPiglet mentioned this issue Dec 24, 2021
@darbyjack darbyjack linked a pull request Dec 24, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Issue (PlaceholderAPI) Issue caused by PlaceholderAPI not working properly.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants