aromaa / WorldGuardExtraFlags

Extension for the WorldGuard plugin.
https://www.spigotmc.org/resources/worldguard-extra-flags.4823
MIT License
90 stars 71 forks source link

No empty space after Chat prefix and suffix #178

Open pthoelken opened 3 years ago

pthoelken commented 3 years ago

Hello Guys,

I don't thinks this is a bug. More than a usability feature. Can you add a space in code of chat prefix and suffix?

Currently it looks not so good. Adding a empty space into the flags doesn't work.

image

After a quick view I think this will solve this FR?

    public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
    {
        Player player = event.getPlayer();

        ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());

        String prefix = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.CHAT_PREFIX);
        String suffix = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.CHAT_SUFFIX);

        if (prefix != null)
        {
            event.setFormat(prefix + " " + event.getFormat());
        }

        if (suffix != null)
        {
            event.setFormat(event.getFormat() + " " + suffix);
        }
    }

https://github.com/aromaa/WorldGuardExtraFlagsPlugin/blob/32e27117324e1d15ed70105cff0c36c4a889660d/Spigot/src/main/java/net/goldtreeservers/worldguardextraflags/listeners/PlayerListener.java#L79-L97