geforkt von Mirrors/Paper
SPIGOT-5413: Add TrustedPlayer API for foxes
Dieser Commit ist enthalten in:
Ursprung
062680a826
Commit
817116de01
@ -1,5 +1,16 @@
|
|||||||
--- a/net/minecraft/server/EntityFox.java
|
--- a/net/minecraft/server/EntityFox.java
|
||||||
+++ b/net/minecraft/server/EntityFox.java
|
+++ b/net/minecraft/server/EntityFox.java
|
||||||
|
@@ -17,8 +17,8 @@
|
||||||
|
|
||||||
|
private static final DataWatcherObject<Integer> bw = DataWatcher.a(EntityFox.class, DataWatcherRegistry.b);
|
||||||
|
private static final DataWatcherObject<Byte> bx = DataWatcher.a(EntityFox.class, DataWatcherRegistry.a);
|
||||||
|
- private static final DataWatcherObject<Optional<UUID>> by = DataWatcher.a(EntityFox.class, DataWatcherRegistry.o);
|
||||||
|
- private static final DataWatcherObject<Optional<UUID>> bz = DataWatcher.a(EntityFox.class, DataWatcherRegistry.o);
|
||||||
|
+ public static final DataWatcherObject<Optional<UUID>> by = DataWatcher.a(EntityFox.class, DataWatcherRegistry.o);
|
||||||
|
+ public static final DataWatcherObject<Optional<UUID>> bz = DataWatcher.a(EntityFox.class, DataWatcherRegistry.o);
|
||||||
|
private static final Predicate<EntityItem> bA = (entityitem) -> {
|
||||||
|
return !entityitem.p() && entityitem.isAlive();
|
||||||
|
};
|
||||||
@@ -263,8 +263,8 @@
|
@@ -263,8 +263,8 @@
|
||||||
private List<UUID> eE() {
|
private List<UUID> eE() {
|
||||||
List<UUID> list = Lists.newArrayList();
|
List<UUID> list = Lists.newArrayList();
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package org.bukkit.craftbukkit.entity;
|
package org.bukkit.craftbukkit.entity;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
import net.minecraft.server.EntityFox;
|
import net.minecraft.server.EntityFox;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.entity.AnimalTamer;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Fox;
|
import org.bukkit.entity.Fox;
|
||||||
|
|
||||||
@ -63,4 +66,52 @@ public class CraftFox extends CraftAnimals implements Fox {
|
|||||||
public void setSleeping(boolean sleeping) {
|
public void setSleeping(boolean sleeping) {
|
||||||
getHandle().setSleeping(sleeping);
|
getHandle().setSleeping(sleeping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AnimalTamer getFirstTrustedPlayer() {
|
||||||
|
UUID uuid = getHandle().getDataWatcher().get(EntityFox.by).orElse(null);
|
||||||
|
if (uuid == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimalTamer player = getServer().getPlayer(uuid);
|
||||||
|
if (player == null) {
|
||||||
|
player = getServer().getOfflinePlayer(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFirstTrustedPlayer(AnimalTamer player) {
|
||||||
|
if (player == null && getHandle().getDataWatcher().get(EntityFox.bz).isPresent()) {
|
||||||
|
throw new IllegalStateException("Must remove second trusted player first");
|
||||||
|
}
|
||||||
|
|
||||||
|
getHandle().getDataWatcher().set(EntityFox.by, player == null ? Optional.empty() : Optional.of(player.getUniqueId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AnimalTamer getSecondTrustedPlayer() {
|
||||||
|
UUID uuid = getHandle().getDataWatcher().get(EntityFox.bz).orElse(null);
|
||||||
|
if (uuid == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimalTamer player = getServer().getPlayer(uuid);
|
||||||
|
if (player == null) {
|
||||||
|
player = getServer().getOfflinePlayer(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSecondTrustedPlayer(AnimalTamer player) {
|
||||||
|
if (player != null && !getHandle().getDataWatcher().get(EntityFox.by).isPresent()) {
|
||||||
|
throw new IllegalStateException("Must add first trusted player first");
|
||||||
|
}
|
||||||
|
|
||||||
|
getHandle().getDataWatcher().set(EntityFox.bz, player == null ? Optional.empty() : Optional.of(player.getUniqueId()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren