Zedd7 / ZHorse

Bukkit plugin providing an enhanced management of horses in Minecraft
https://www.spigotmc.org/resources/zhorse.3384/
Other
11 stars 12 forks source link

Can't give horses to offline players #153

Open oskarkk opened 3 years ago

oskarkk commented 3 years ago

Bug report (and in part a feature request)

What are you trying to do?

I'm using ZHorse 1.8.3 snapshot 1 on the newest Spigot for Minecraft 1.16.4.

When sitting on a horse I execute a command: /zh give <offline player>

What is the expected behavior?

I expected that the horse would just be given to the player.

What is the actual behavior?

<player>'s claims limit has been reached. When using admin mode it behaves as it should, because admin mode bypasses limits.

I've read the code and found that for the offline players the limit is always 0.

Proposed solution

Add config option to set the lower claims limit for all players (online, offline, with groups and without). The simplest implementation would be to replace (almost) all zeros in method:

    public int getClaimsLimit(UUID playerUUID) {
        int claimsLimit = 0;
        if (playerUUID != null) {
            String groupName = getGroupName(playerUUID);
            if (groupName != null) {
                claimsLimit = config.getInt(KeyWordEnum.GROUPS_PREFIX.getValue() + groupName + KeyWordEnum.CLAIMS_LIMIT_SUFFIX.getValue(), 0);
                if (claimsLimit < 0 && claimsLimit != -1) {
                    claimsLimit = 0;
                }
            }
        }
        return claimsLimit;
    }

... with some reference to my proposed config value. Then, you could give an offline player a horse if that player has less horses than this lower limit. Of course, if there's a player who is in group with e.g. no limit (-1), and has more horses than the lower limit, then you couldn't give that player more horses while he's offline.

It's simple enough that I could do it myself, but given that I never wrote anything in Java (and never compiled any plugins for Spigot), it would take me some time to "spin up", so I won't do it soon.

If that solution is unacceptable for some reason, it would be better to inform a player about the proper reason why the command didn't work, such as "Horses can't be given to offline players", instead of "Player's claims limit has been reached" (which is in most cases untrue).