geforkt von Mirrors/FastAsyncWorldEdit
[Bukkit] Implement the new entity API.
Dieser Commit ist enthalten in:
Ursprung
505d45237d
Commit
e2082ee8a4
@ -113,6 +113,23 @@ final class BukkitAdapter {
|
|||||||
position.getX(), position.getY(), position.getZ());
|
position.getX(), position.getY(), position.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Bukkit location from a WorldEdit location with a Bukkit world.
|
||||||
|
*
|
||||||
|
* @param world the Bukkit world
|
||||||
|
* @param location the WorldEdit location
|
||||||
|
* @return a Bukkit location
|
||||||
|
*/
|
||||||
|
public static org.bukkit.Location adapt(org.bukkit.World world, Location location) {
|
||||||
|
checkNotNull(world);
|
||||||
|
checkNotNull(location);
|
||||||
|
return new org.bukkit.Location(
|
||||||
|
world,
|
||||||
|
location.getX(), location.getY(), location.getZ(),
|
||||||
|
(float) Math.toDegrees(location.getYaw()),
|
||||||
|
(float) Math.toDegrees(location.getPitch()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a WorldEdit entity from a Bukkit entity.
|
* Create a WorldEdit entity from a Bukkit entity.
|
||||||
*
|
*
|
||||||
|
@ -19,8 +19,10 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.entity.metadata.Tameable;
|
import com.sk89q.worldedit.entity.metadata.Tameable;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
@ -74,12 +76,22 @@ class BukkitEntity implements Entity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseEntity getState() {
|
public BaseEntity getState() {
|
||||||
return null;
|
if (entity instanceof Player) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
|
if (adapter != null) {
|
||||||
|
return adapter.getEntity(entity);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean remove() {
|
public boolean remove() {
|
||||||
return false;
|
entity.remove();
|
||||||
|
return entity.isDead();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,17 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public com.sk89q.worldedit.entity.Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) {
|
public com.sk89q.worldedit.entity.Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) {
|
||||||
throw new UnsupportedOperationException("Not implemented yet");
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
|
if (adapter != null) {
|
||||||
|
Entity createdEntity = adapter.createEntity(BukkitAdapter.adapt(getWorld(), location), entity);
|
||||||
|
if (createdEntity != null) {
|
||||||
|
return new BukkitEntity(createdEntity);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +20,11 @@
|
|||||||
package com.sk89q.worldedit.bukkit.adapter;
|
package com.sk89q.worldedit.bukkit.adapter;
|
||||||
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface for adapters of various Bukkit implementations.
|
* An interface for adapters of various Bukkit implementations.
|
||||||
@ -45,5 +49,24 @@ public interface BukkitImplAdapter {
|
|||||||
*/
|
*/
|
||||||
boolean setBlock(Location location, BaseBlock state, boolean notifyAndLight);
|
boolean setBlock(Location location, BaseBlock state, boolean notifyAndLight);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the state for the given entity.
|
||||||
|
*
|
||||||
|
* @param entity the entity
|
||||||
|
* @return the state, or null
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
BaseEntity getEntity(Entity entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the given entity.
|
||||||
|
*
|
||||||
|
* @param location the location
|
||||||
|
* @param state the state
|
||||||
|
* @return the created entity or null
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
Entity createEntity(Location location, BaseEntity state);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren