#MCPets API rework

1 messages · Page 1 of 1 (latest)

mild socket
#

The API for the plugin doesn't have any documentation, also would be nice to have a little more control on some things.

tawdry crescent
mild socket
tawdry crescent
mild socket
#

On 1.20 I had a code that avoided people mounting boats if they were on pets

#

Because the problem is that if they hop on a boat meanwhile on a pet

#

Mcpets doesn’t detect it and both pet and boat move

#

And when the player leaves the boat teleports to the pet

#

On 1.21 same code should work, instead always returns false

tawdry crescent
#

You can share the check you're doing on the activePet object here so we can look into a possible fix

mild socket
#

I did this with onVehicleEnter to avoid people hoping on boats when they are mounted, instead, it's never being used as getRidingPet returns null

    @EventHandler(ignoreCancelled = true)
    public void onVehicleEnter(VehicleEnterEvent event) {
        if(!(event.getEntered() instanceof Player player)) return;
        try {
            if(PetUtil.getRidingPet(player) != null) {
                player.sendActionBar(Component.text("You can't enter a vehicle while riding a pet!", NamedTextColor.RED));
                event.setCancelled(true);
            }
        }
        catch(Exception ignored) {}```
tawdry crescent
#

Out of any specific usage, talking unitary function-wise, your code appears correct to me

mild socket
tawdry crescent
mild socket
#

Yes

tawdry crescent
#

Not the ActivePets list

mild socket
#

I can assume it can be null, as it should return a value

#

On 1.20.4 it did

tawdry crescent
#

So what I would do first is check that the ActivePets hashmap is indeed functional, and if it's not a it's a problem with MCPets

#

so just checking that it's not empty while someone has a pet spawned

#

then I would do a specific check on the getRidingPet function you made, checking that the player is not null first (which should probably output an error so I don't think it is atm), then check their UUID as a string and see if it's in the ActivePets hashmap

#

maybe they formatted UUID differently going into 1.21.4

mild socket
#

I'll check first what you said of activePets

tawdry crescent
#

and that's where the issue could lie? I'm not sure

mild socket
#

It can be, let me see

#

I made a change that will print all the pets on the event, maybe will help

tawdry crescent
mild socket
tawdry crescent
mild socket
#
plugin.getLogger().info("Active pets: " + MCPetsAPI.getActivePets());```
#

Yes

#

A capybara

tawdry crescent
mild socket
#

So yea, seems that MCPets is broken

tawdry crescent
#

I'm trying to make sense of it but I'd need to dive in the code a bit

tawdry crescent
#

MCPets

mild socket
#

I'll go continue adapting to 1.21.4, mention me if you need me

#

And sorry for showing that your plugin is broken on 1.21.4 BennettSorry_DalasQuil

tawdry crescent
mild socket
#

Sure

tawdry crescent
#

Maybe it's something that I was working on and forgot about it

mild socket
#

Nope

#

On 1.20 works

#

So it was completed

tawdry crescent
#

that's impossible \o/ 😭

#

The whole plugin would not work without this function

#

we're doomed

mild socket
#

Nope

#

It's not working either

tawdry crescent
#

doesn't it send you messages when you despawn a pet?

mild socket
#

Yes

tawdry crescent
#

so you receive a message

mild socket
#

All messages work on the plugin

tawdry crescent
#

and yet when you ask the plugin who is the owner you can not fetch it

#

that makes 0 sense to me

#

that's the same call

mild socket
#

That's why I'm here

#

Because this worked, and now it doesn't

#

And Pet.fromOwner doesn't help either .-.

tawdry crescent
#

what's the exact MCPets version you're running, as well as MythicMobs?

#

(spigot is 1.21.4)

mild socket
#

MCPets 4.1.4-1.21
MythicMobs-5.8.2

#

MythicMobs works correctly without issues

tawdry crescent
mild socket
tawdry crescent
mild socket
mild socket
#

@tawdry crescent With 4.1.5 seems to work

#

[22:15:51 INFO]: [PactoriaMiscellaneous] Active pets: {b374ad51-9db5-4b79-b855-e269d798b82a=AlmPet;Capybara_Mount}

mild socket
#

Yup, fixed

#

Sorry for bothering you

tawdry crescent
mild socket
#

Thanks Nocsy

#

Before closing

#

Love your work on models

tawdry crescent
mild socket
#

All servers I worked they had cool things of you

mild socket
#

have a nice day