Add methods for Creaking (#12094)
This commit is contained in:
@ -1,8 +1,43 @@
|
|||||||
package org.bukkit.entity;
|
package org.bukkit.entity;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.jspecify.annotations.NullMarked;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Creaking.
|
* Represents a Creaking.
|
||||||
*/
|
*/
|
||||||
|
@NullMarked
|
||||||
public interface Creaking extends Monster {
|
public interface Creaking extends Monster {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the home location for this creaking (where its {@link org.bukkit.block.CreakingHeart} could be found).
|
||||||
|
*
|
||||||
|
* @return the location of the home if available, null otherwise
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
Location getHome();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activates this creaking to target and follow a player.
|
||||||
|
*
|
||||||
|
* @param player the target
|
||||||
|
*/
|
||||||
|
void activate(final Player player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deactivates the creaking, clearing its current attack target and
|
||||||
|
* marking it as inactive.
|
||||||
|
*/
|
||||||
|
void deactivate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if this creaking is currently active and hunting.
|
||||||
|
*
|
||||||
|
* @see #activate(Player)
|
||||||
|
*
|
||||||
|
* @return true if active
|
||||||
|
*/
|
||||||
|
boolean isActive();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,19 @@
|
|||||||
package org.bukkit.craftbukkit.entity;
|
package org.bukkit.craftbukkit.entity;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import net.minecraft.Optionull;
|
||||||
import net.minecraft.world.entity.monster.creaking.Creaking;
|
import net.minecraft.world.entity.monster.creaking.Creaking;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.util.CraftLocation;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jspecify.annotations.NullMarked;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
|
@NullMarked
|
||||||
public class CraftCreaking extends CraftMonster implements org.bukkit.entity.Creaking {
|
public class CraftCreaking extends CraftMonster implements org.bukkit.entity.Creaking {
|
||||||
|
|
||||||
public CraftCreaking(CraftServer server, Creaking entity) {
|
public CraftCreaking(final CraftServer server, final Creaking entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,6 +22,28 @@ public class CraftCreaking extends CraftMonster implements org.bukkit.entity.Cre
|
|||||||
return (Creaking) this.entity;
|
return (Creaking) this.entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Location getHome() {
|
||||||
|
return Optionull.map(this.getHandle().getHomePos(), pos -> CraftLocation.toBukkit(pos, this.getHandle().level()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void activate(final Player player) {
|
||||||
|
Preconditions.checkArgument(player != null, "player cannot be null");
|
||||||
|
this.getHandle().activate(((CraftPlayer) player).getHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deactivate() {
|
||||||
|
this.getHandle().deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isActive() {
|
||||||
|
return this.getHandle().isActive();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CraftCreaking";
|
return "CraftCreaking";
|
||||||
|
|||||||
Reference in New Issue
Block a user