#MCPets API rework
1 messages · Page 1 of 1 (latest)
Hi 👋 It's lacking a lot of features I agree, but that's a lot of work and I have no idea what people are using from MCPets >.<
On my case I’m using the ActivePet and seems that on 1.21 is broken
wdym it's broken?
I did a Boolean using the activePet on users and it’s always false
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
You can share the check you're doing on the activePet object here so we can look into a possible fix
Sure, give me a sec
public static Pet getRidingPet(Player p) throws NoClassDefFoundError {
Pet mount = MCPetsAPI.getActivePet(p.getUniqueId());
if (mount != null && mount.hasMount(p))
return mount;
return MCPetsAPI.getActivePets().values().stream().filter(pet -> pet.hasMount(p)).findFirst().orElse(null);
}```
So this worked on 1.20.4, idk why not on 1.21.4
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) {}```
Did you try overriding the API call through the usual Pet.getActivePets() which I believe is a HashMap? Then you can inspect the HashMap to see if it's always empty as you say. I'm pretty sure it should not be empty, otherwise the whole plugin would crumble down
Out of any specific usage, talking unitary function-wise, your code appears correct to me
The thing is that both are giving null
you mean your getRidingPet function returns null, right?
Yes
Not the ActivePets list
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
I'll check first what you said of activePets
and that's where the issue could lie? I'm not sure
It can be, let me see
I made a change that will print all the pets on the event, maybe will help
I would call for any debug within the getRidingPet function you made personally, that way it's easier to narrow down why it's not working in the specific instance
Shit
[21:48:05 INFO]: [PactoriaMiscellaneous] Active pets: {}
Weirdest thing, you got something spawned?
plugin.getLogger().info("Active pets: " + MCPetsAPI.getActivePets());```
Yes
A capybara
I'm trying to make sense of it but I'd need to dive in the code a bit
On mine or MCPets
MCPets
Okay
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 
Can you try Pet.fromOwner(UUID) function instead of the activepet list?
Sure
Maybe it's something that I was working on and forgot about it
that's impossible \o/ 😭
The whole plugin would not work without this function
we're doomed
doesn't it send you messages when you despawn a pet?
Yes
so you receive a message
All messages work on the plugin
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
That's why I'm here
Because this worked, and now it doesn't
And Pet.fromOwner doesn't help either .-.
what's the exact MCPets version you're running, as well as MythicMobs?
(spigot is 1.21.4)
Can you try updating MCPets to latest #🦦|mcpets-builds and MythicMobs to any version above 5.9.0?
MCPets i can, as for MythicMobs ig i have to wait the owner to give it to me
you can't have the latest MCPets running without MythicMobs above 5.9
Then we have to wait until the owner shows up, I'll let you know...
Funfact: Jar file is 4.1.6 and you say it's 4.1.5 at the beginning
@tawdry crescent With 4.1.5 seems to work
[22:15:51 INFO]: [PactoriaMiscellaneous] Active pets: {b374ad51-9db5-4b79-b855-e269d798b82a=AlmPet;Capybara_Mount}
Error happen along the way, that's what turns the journey into a real Odyssey
I'm glad you do! Check out the Patreon for monthly content :3
All servers I worked they had cool things of you
Cool!
have a nice day