Skip to content

%s being edited to % by PlaceholderAPI #771

@booksaw

Description

@booksaw

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions