mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-04 14:04:49 +01:00
Add Override annotations where appropriate
This commit is contained in:
parent
3331dade5e
commit
e3df3d5cda
140 changed files with 1021 additions and 0 deletions
|
@ -44,6 +44,7 @@ public class CraftChunk implements Chunk {
|
|||
z = getHandle().getPos().z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return worldServer.getWorld();
|
||||
}
|
||||
|
@ -68,10 +69,12 @@ public class CraftChunk implements Chunk {
|
|||
weakChunk.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
@ -81,12 +84,14 @@ public class CraftChunk implements Chunk {
|
|||
return "CraftChunk{" + "x=" + getX() + "z=" + getZ() + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock(int x, int y, int z) {
|
||||
validateChunkCoordinates(x, y, z);
|
||||
|
||||
return new CraftBlock(worldServer, new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity[] getEntities() {
|
||||
int count = 0, index = 0;
|
||||
net.minecraft.server.Chunk chunk = getHandle();
|
||||
|
@ -111,6 +116,7 @@ public class CraftChunk implements Chunk {
|
|||
return entities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState[] getTileEntities() {
|
||||
int index = 0;
|
||||
net.minecraft.server.Chunk chunk = getHandle();
|
||||
|
@ -129,18 +135,22 @@ public class CraftChunk implements Chunk {
|
|||
return entities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return getWorld().isChunkLoaded(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean load() {
|
||||
return getWorld().loadChunk(getX(), getZ(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean load(boolean generate) {
|
||||
return getWorld().loadChunk(getX(), getZ(), generate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unload() {
|
||||
return getWorld().unloadChunk(getX(), getZ());
|
||||
}
|
||||
|
@ -151,6 +161,7 @@ public class CraftChunk implements Chunk {
|
|||
return SeededRandom.a(getX(), getZ(), getWorld().getSeed(), 987234911L).nextInt(10) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unload(boolean save) {
|
||||
return getWorld().unloadChunk(getX(), getZ(), save);
|
||||
}
|
||||
|
@ -165,10 +176,12 @@ public class CraftChunk implements Chunk {
|
|||
getWorld().setChunkForceLoaded(getX(), getZ(), forced);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkSnapshot getChunkSnapshot() {
|
||||
return getChunkSnapshot(true, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkSnapshot getChunkSnapshot(boolean includeMaxBlockY, boolean includeBiome, boolean includeBiomeTempRain) {
|
||||
net.minecraft.server.Chunk chunk = getHandle();
|
||||
|
||||
|
|
|
@ -42,14 +42,17 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
|
|||
this.biomeTemp = biomeTemp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorldName() {
|
||||
return worldname;
|
||||
}
|
||||
|
@ -75,6 +78,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
|
|||
return CraftMagicNumbers.toLegacyData(blockids[y >> 4].a(x, y & 0xF, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getBlockSkyLight(int x, int y, int z) {
|
||||
CraftChunk.validateChunkCoordinates(x, y, z);
|
||||
|
||||
|
@ -82,6 +86,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
|
|||
return (skylight[y >> 4][off] >> ((x & 1) << 2)) & 0xF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getBlockEmittedLight(int x, int y, int z) {
|
||||
CraftChunk.validateChunkCoordinates(x, y, z);
|
||||
|
||||
|
@ -89,28 +94,33 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
|
|||
return (emitlight[y >> 4][off] >> ((x & 1) << 2)) & 0xF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getHighestBlockYAt(int x, int z) {
|
||||
CraftChunk.validateChunkCoordinates(x, 0, z);
|
||||
|
||||
return hmap.a(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Biome getBiome(int x, int z) {
|
||||
CraftChunk.validateChunkCoordinates(x, 0, z);
|
||||
|
||||
return CraftBlock.biomeBaseToBiome(biome[z << 4 | x]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final double getRawBiomeTemperature(int x, int z) {
|
||||
CraftChunk.validateChunkCoordinates(x, 0, z);
|
||||
|
||||
return biomeTemp[z << 4 | x];
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long getCaptureFullTime() {
|
||||
return captureFulltime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isSectionEmpty(int sy) {
|
||||
return empty[sy];
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||
|
||||
public class CraftCrashReport implements CrashReportCallable<Object> {
|
||||
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
StringWriter value = new StringWriter();
|
||||
try {
|
||||
|
|
|
@ -38,10 +38,12 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||
return profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return getPlayer() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
Player player = getPlayer();
|
||||
if (player != null) {
|
||||
|
@ -64,6 +66,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return profile.getId();
|
||||
}
|
||||
|
@ -72,10 +75,12 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return server.getHandle().isOp(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOp(boolean value) {
|
||||
if (value == isOp()) {
|
||||
return;
|
||||
|
@ -88,6 +93,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned() {
|
||||
if (getName() == null) {
|
||||
return false;
|
||||
|
@ -108,10 +114,12 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted() {
|
||||
return server.getHandle().getWhitelist().isWhitelisted(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelisted(boolean value) {
|
||||
if (value) {
|
||||
server.getHandle().getWhitelist().add(new WhiteListEntry(profile));
|
||||
|
@ -120,6 +128,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
Map<String, Object> result = new LinkedHashMap<String, Object>();
|
||||
|
||||
|
@ -142,6 +151,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||
return getClass().getSimpleName() + "[UUID=" + profile.getId() + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return server.getPlayer(getUniqueId());
|
||||
}
|
||||
|
@ -188,6 +198,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||
return new File(storage.getPlayerDir(), getUniqueId() + ".dat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFirstPlayed() {
|
||||
Player player = getPlayer();
|
||||
if (player != null) return player.getFirstPlayed();
|
||||
|
@ -206,6 +217,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastPlayed() {
|
||||
Player player = getPlayer();
|
||||
if (player != null) return player.getLastPlayed();
|
||||
|
@ -224,10 +236,12 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPlayedBefore() {
|
||||
return getData() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation() {
|
||||
NBTTagCompound data = getData();
|
||||
if (data == null) return null;
|
||||
|
|
|
@ -1847,6 +1847,7 @@ public final class CraftServer implements Server {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTable getLootTable(NamespacedKey key) {
|
||||
Validate.notNull(key, "NamespacedKey cannot be null");
|
||||
|
||||
|
|
|
@ -273,10 +273,12 @@ public class CraftWorld implements World {
|
|||
environment = env;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlockAt(int x, int y, int z) {
|
||||
return CraftBlock.at(world, new BlockPosition(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighestBlockYAt(int x, int z) {
|
||||
if (!isChunkLoaded(x >> 4, z >> 4)) {
|
||||
getChunkAt(x >> 4, z >> 4); // Transient load for this tick
|
||||
|
@ -285,6 +287,7 @@ public class CraftWorld implements World {
|
|||
return world.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, new BlockPosition(x, 0, z)).getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getSpawnLocation() {
|
||||
BlockPosition spawn = world.getSpawn();
|
||||
return new Location(this, spawn.getX(), spawn.getY(), spawn.getZ());
|
||||
|
@ -297,6 +300,7 @@ public class CraftWorld implements World {
|
|||
return equals(location.getWorld()) ? setSpawnLocation(location.getBlockX(), location.getBlockY(), location.getBlockZ()) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setSpawnLocation(int x, int y, int z) {
|
||||
try {
|
||||
Location previousLocation = getSpawnLocation();
|
||||
|
@ -312,14 +316,17 @@ public class CraftWorld implements World {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getChunkAt(int x, int z) {
|
||||
return this.world.getChunkProvider().getChunkAt(x, z, true).bukkitChunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getChunkAt(Block block) {
|
||||
return getChunkAt(block.getX() >> 4, block.getZ() >> 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkLoaded(int x, int z) {
|
||||
net.minecraft.server.Chunk chunk = world.getChunkProvider().getChunkAt(x, z, false);
|
||||
return chunk != null && chunk.loaded;
|
||||
|
@ -334,28 +341,34 @@ public class CraftWorld implements World {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk[] getLoadedChunks() {
|
||||
Long2ObjectLinkedOpenHashMap<PlayerChunk> chunks = world.getChunkProvider().playerChunkMap.visibleChunks;
|
||||
|
||||
return chunks.values().stream().map(PlayerChunk::getChunk).filter(Objects::nonNull).filter((chunk) -> chunk.loaded).map(net.minecraft.server.Chunk::getBukkitChunk).toArray(Chunk[]::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadChunk(int x, int z) {
|
||||
loadChunk(x, z, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadChunk(Chunk chunk) {
|
||||
return unloadChunk(chunk.getX(), chunk.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadChunk(int x, int z) {
|
||||
return unloadChunk(x, z, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadChunk(int x, int z, boolean save) {
|
||||
return unloadChunk0(x, z, save);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadChunkRequest(int x, int z) {
|
||||
net.minecraft.server.IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, false);
|
||||
if (chunk != null) {
|
||||
|
@ -378,6 +391,7 @@ public class CraftWorld implements World {
|
|||
return !isChunkLoaded(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean regenerateChunk(int x, int z) {
|
||||
throw new UnsupportedOperationException("Not supported in this Minecraft version! Unless you can fix it, this is not a bug :)");
|
||||
/*
|
||||
|
@ -402,6 +416,7 @@ public class CraftWorld implements World {
|
|||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean refreshChunk(int x, int z) {
|
||||
if (!isChunkLoaded(x, z)) {
|
||||
return false;
|
||||
|
@ -422,10 +437,12 @@ public class CraftWorld implements World {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkInUse(int x, int z) {
|
||||
return isChunkLoaded(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadChunk(int x, int z, boolean generate) {
|
||||
IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, generate ? ChunkStatus.FULL : ChunkStatus.EMPTY, true);
|
||||
|
||||
|
@ -443,10 +460,12 @@ public class CraftWorld implements World {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkLoaded(Chunk chunk) {
|
||||
return isChunkLoaded(chunk.getX(), chunk.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadChunk(Chunk chunk) {
|
||||
loadChunk(chunk.getX(), chunk.getZ());
|
||||
((CraftChunk) getChunkAt(chunk.getX(), chunk.getZ())).getHandle().bukkitChunk = chunk;
|
||||
|
@ -477,6 +496,7 @@ public class CraftWorld implements World {
|
|||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Item dropItem(Location loc, ItemStack item) {
|
||||
Validate.notNull(item, "Cannot drop a Null item.");
|
||||
EntityItem entity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), CraftItemStack.asNMSCopy(item));
|
||||
|
@ -487,6 +507,7 @@ public class CraftWorld implements World {
|
|||
return new CraftItem(world.getServer(), entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Item dropItemNaturally(Location loc, ItemStack item) {
|
||||
double xs = (world.random.nextFloat() * 0.5F) + 0.25D;
|
||||
double ys = (world.random.nextFloat() * 0.5F) + 0.25D;
|
||||
|
@ -498,10 +519,12 @@ public class CraftWorld implements World {
|
|||
return dropItem(loc, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Arrow spawnArrow(Location loc, Vector velocity, float speed, float spread) {
|
||||
return spawnArrow(loc, velocity, speed, spread, Arrow.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Arrow> T spawnArrow(Location loc, Vector velocity, float speed, float spread, Class<T> clazz) {
|
||||
Validate.notNull(loc, "Can not spawn arrow with a null location");
|
||||
Validate.notNull(velocity, "Can not spawn arrow with a null velocity");
|
||||
|
@ -525,22 +548,26 @@ public class CraftWorld implements World {
|
|||
return (T) arrow.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Location loc, EntityType entityType) {
|
||||
return spawn(loc, entityType.getEntityClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LightningStrike strikeLightning(Location loc) {
|
||||
EntityLightning lightning = new EntityLightning(world, loc.getX(), loc.getY(), loc.getZ(), false);
|
||||
world.strikeLightning(lightning);
|
||||
return new CraftLightningStrike(server, lightning);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LightningStrike strikeLightningEffect(Location loc) {
|
||||
EntityLightning lightning = new EntityLightning(world, loc.getX(), loc.getY(), loc.getZ(), true);
|
||||
world.strikeLightning(lightning);
|
||||
return new CraftLightningStrike(server, lightning);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(Location loc, TreeType type) {
|
||||
BlockPosition pos = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
|
||||
|
@ -603,6 +630,7 @@ public class CraftWorld implements World {
|
|||
return gen.generate(world, world.worldProvider.getChunkGenerator(), rand, pos, new WorldGenFeatureEmptyConfiguration());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
|
||||
world.captureTreeGeneration = true;
|
||||
world.captureBlockStates = true;
|
||||
|
@ -626,6 +654,7 @@ public class CraftWorld implements World {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return world.worldData.getName();
|
||||
}
|
||||
|
@ -635,6 +664,7 @@ public class CraftWorld implements World {
|
|||
return world.worldData.getSeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUID() {
|
||||
return world.getDataManager().getUUID();
|
||||
}
|
||||
|
@ -644,22 +674,26 @@ public class CraftWorld implements World {
|
|||
return "CraftWorld{name=" + getName() + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTime() {
|
||||
long time = getFullTime() % 24000;
|
||||
if (time < 0) time += 24000;
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTime(long time) {
|
||||
long margin = (time - getFullTime()) % 24000;
|
||||
if (margin < 0) margin += 24000;
|
||||
setFullTime(getFullTime() + margin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFullTime() {
|
||||
return world.getDayTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFullTime(long time) {
|
||||
world.setDayTime(time);
|
||||
|
||||
|
@ -672,26 +706,32 @@ public class CraftWorld implements World {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createExplosion(double x, double y, double z, float power) {
|
||||
return createExplosion(x, y, z, power, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createExplosion(double x, double y, double z, float power, boolean setFire) {
|
||||
return createExplosion(x, y, z, power, setFire, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks) {
|
||||
return !world.createExplosion(null, x, y, z, power, setFire, breakBlocks ? Explosion.Effect.BREAK : Explosion.Effect.NONE).wasCanceled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createExplosion(Location loc, float power) {
|
||||
return createExplosion(loc, power, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createExplosion(Location loc, float power, boolean setFire) {
|
||||
return createExplosion(loc.getX(), loc.getY(), loc.getZ(), power, setFire);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Environment getEnvironment() {
|
||||
return environment;
|
||||
}
|
||||
|
@ -713,38 +753,47 @@ public class CraftWorld implements World {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlockAt(Location location) {
|
||||
return getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighestBlockYAt(Location location) {
|
||||
return getHighestBlockYAt(location.getBlockX(), location.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getChunkAt(Location location) {
|
||||
return getChunkAt(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getGenerator() {
|
||||
return generator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPopulator> getPopulators() {
|
||||
return populators;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getHighestBlockAt(int x, int z) {
|
||||
return getBlockAt(x, getHighestBlockYAt(x, z), z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getHighestBlockAt(Location location) {
|
||||
return getHighestBlockAt(location.getBlockX(), location.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int x, int z) {
|
||||
return CraftBlock.biomeBaseToBiome(this.world.getBiome(new BlockPosition(x, 0, z)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, Biome bio) {
|
||||
BiomeBase bb = CraftBlock.biomeToBiomeBase(bio);
|
||||
if (this.world.isLoaded(new BlockPosition(x, 0, z))) {
|
||||
|
@ -759,14 +808,17 @@ public class CraftWorld implements World {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTemperature(int x, int z) {
|
||||
return this.world.getBiome(new BlockPosition(x, 0, z)).getTemperature();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHumidity(int x, int z) {
|
||||
return this.world.getBiome(new BlockPosition(x, 0, z)).getHumidity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Entity> getEntities() {
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
|
||||
|
@ -785,6 +837,7 @@ public class CraftWorld implements World {
|
|||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LivingEntity> getLivingEntities() {
|
||||
List<LivingEntity> list = new ArrayList<LivingEntity>();
|
||||
|
||||
|
@ -803,12 +856,14 @@ public class CraftWorld implements World {
|
|||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@Deprecated
|
||||
public <T extends Entity> Collection<T> getEntitiesByClass(Class<T>... classes) {
|
||||
return (Collection<T>)getEntitiesByClasses(classes);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Entity> Collection<T> getEntitiesByClass(Class<T> clazz) {
|
||||
Collection<T> list = new ArrayList<T>();
|
||||
|
@ -832,6 +887,7 @@ public class CraftWorld implements World {
|
|||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Entity> getEntitiesByClasses(Class<?>... classes) {
|
||||
Collection<Entity> list = new ArrayList<Entity>();
|
||||
|
||||
|
@ -1015,6 +1071,7 @@ public class CraftWorld implements World {
|
|||
return blockHit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> getPlayers() {
|
||||
List<Player> list = new ArrayList<Player>(world.getPlayers().size());
|
||||
|
||||
|
@ -1029,6 +1086,7 @@ public class CraftWorld implements World {
|
|||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
this.server.checkSaveState();
|
||||
try {
|
||||
|
@ -1043,18 +1101,22 @@ public class CraftWorld implements World {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoSave() {
|
||||
return !world.savingDisabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoSave(boolean value) {
|
||||
world.savingDisabled = !value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDifficulty(Difficulty difficulty) {
|
||||
this.getHandle().worldData.setDifficulty(EnumDifficulty.getById(difficulty.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Difficulty getDifficulty() {
|
||||
return Difficulty.getByValue(this.getHandle().getDifficulty().ordinal());
|
||||
}
|
||||
|
@ -1063,48 +1125,59 @@ public class CraftWorld implements World {
|
|||
return blockMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasStorm() {
|
||||
return world.worldData.hasStorm();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStorm(boolean hasStorm) {
|
||||
world.worldData.setStorm(hasStorm);
|
||||
setWeatherDuration(0); // Reset weather duration (legacy behaviour)
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeatherDuration() {
|
||||
return world.worldData.getWeatherDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeatherDuration(int duration) {
|
||||
world.worldData.setWeatherDuration(duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isThundering() {
|
||||
return world.worldData.isThundering();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThundering(boolean thundering) {
|
||||
world.worldData.setThundering(thundering);
|
||||
setThunderDuration(0); // Reset weather duration (legacy behaviour)
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getThunderDuration() {
|
||||
return world.worldData.getThunderDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThunderDuration(int duration) {
|
||||
world.worldData.setThunderDuration(duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSeed() {
|
||||
return world.worldData.getSeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPVP() {
|
||||
return world.pvpMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPVP(boolean pvp) {
|
||||
world.pvpMode = pvp;
|
||||
}
|
||||
|
@ -1113,14 +1186,17 @@ public class CraftWorld implements World {
|
|||
playEffect(player.getLocation(), effect, data, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playEffect(Location location, Effect effect, int data) {
|
||||
playEffect(location, effect, data, 64);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void playEffect(Location loc, Effect effect, T data) {
|
||||
playEffect(loc, effect, data, 64);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void playEffect(Location loc, Effect effect, T data, int radius) {
|
||||
if (data != null) {
|
||||
Validate.isTrue(effect.getData() != null && effect.getData().isAssignableFrom(data.getClass()), "Wrong kind of data for this effect!");
|
||||
|
@ -1132,6 +1208,7 @@ public class CraftWorld implements World {
|
|||
playEffect(loc, effect, datavalue, radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playEffect(Location location, Effect effect, int data, int radius) {
|
||||
Validate.notNull(location, "Location cannot be null");
|
||||
Validate.notNull(effect, "Effect cannot be null");
|
||||
|
@ -1152,6 +1229,7 @@ public class CraftWorld implements World {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> T spawn(Location location, Class<T> clazz) throws IllegalArgumentException {
|
||||
return spawn(location, clazz, null, SpawnReason.CUSTOM);
|
||||
}
|
||||
|
@ -1167,6 +1245,7 @@ public class CraftWorld implements World {
|
|||
return spawnFallingBlock(location, data.getItemType(), data.getData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public FallingBlock spawnFallingBlock(Location location, org.bukkit.Material material, byte data) throws IllegalArgumentException {
|
||||
Validate.notNull(location, "Location cannot be null");
|
||||
Validate.notNull(material, "Material cannot be null");
|
||||
|
@ -1558,34 +1637,42 @@ public class CraftWorld implements World {
|
|||
return addEntity(entity, reason, function);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkSnapshot getEmptyChunkSnapshot(int x, int z, boolean includeBiome, boolean includeBiomeTempRain) {
|
||||
return CraftChunk.getEmptyChunkSnapshot(x, z, this, includeBiome, includeBiomeTempRain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpawnFlags(boolean allowMonsters, boolean allowAnimals) {
|
||||
world.setSpawnFlags(allowMonsters, allowAnimals);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAllowAnimals() {
|
||||
return world.getChunkProvider().allowAnimals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAllowMonsters() {
|
||||
return world.getChunkProvider().allowMonsters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHeight() {
|
||||
return world.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSeaLevel() {
|
||||
return world.getSeaLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getKeepSpawnInMemory() {
|
||||
return world.keepSpawnInMemory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeepSpawnInMemory(boolean keepLoaded) {
|
||||
world.keepSpawnInMemory = keepLoaded;
|
||||
// Grab the worlds spawn chunk
|
||||
|
@ -1625,10 +1712,12 @@ public class CraftWorld implements World {
|
|||
return this.getUID() == other.getUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWorldFolder() {
|
||||
return ((WorldNBTStorage) world.getDataManager()).getDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPluginMessage(Plugin source, String channel, byte[] message) {
|
||||
StandardMessenger.validatePluginMessage(server.getMessenger(), source, channel, message);
|
||||
|
||||
|
@ -1637,6 +1726,7 @@ public class CraftWorld implements World {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getListeningPluginChannels() {
|
||||
Set<String> result = new HashSet<String>();
|
||||
|
||||
|
@ -1647,46 +1737,57 @@ public class CraftWorld implements World {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.WorldType getWorldType() {
|
||||
return org.bukkit.WorldType.getByName(world.getWorldData().getType().name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGenerateStructures() {
|
||||
return world.getWorldData().shouldGenerateMapFeatures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTicksPerAnimalSpawns() {
|
||||
return world.ticksPerAnimalSpawns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns) {
|
||||
world.ticksPerAnimalSpawns = ticksPerAnimalSpawns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTicksPerMonsterSpawns() {
|
||||
return world.ticksPerMonsterSpawns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns) {
|
||||
world.ticksPerMonsterSpawns = ticksPerMonsterSpawns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
|
||||
server.getWorldMetadata().setMetadata(this, metadataKey, newMetadataValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetadataValue> getMetadata(String metadataKey) {
|
||||
return server.getWorldMetadata().getMetadata(this, metadataKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMetadata(String metadataKey) {
|
||||
return server.getWorldMetadata().hasMetadata(this, metadataKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
|
||||
server.getWorldMetadata().removeMetadata(this, metadataKey, owningPlugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMonsterSpawnLimit() {
|
||||
if (monsterSpawn < 0) {
|
||||
return server.getMonsterSpawnLimit();
|
||||
|
@ -1695,10 +1796,12 @@ public class CraftWorld implements World {
|
|||
return monsterSpawn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMonsterSpawnLimit(int limit) {
|
||||
monsterSpawn = limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAnimalSpawnLimit() {
|
||||
if (animalSpawn < 0) {
|
||||
return server.getAnimalSpawnLimit();
|
||||
|
@ -1707,10 +1810,12 @@ public class CraftWorld implements World {
|
|||
return animalSpawn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnimalSpawnLimit(int limit) {
|
||||
animalSpawn = limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaterAnimalSpawnLimit() {
|
||||
if (waterAnimalSpawn < 0) {
|
||||
return server.getWaterAnimalSpawnLimit();
|
||||
|
@ -1719,10 +1824,12 @@ public class CraftWorld implements World {
|
|||
return waterAnimalSpawn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWaterAnimalSpawnLimit(int limit) {
|
||||
waterAnimalSpawn = limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmbientSpawnLimit() {
|
||||
if (ambientSpawn < 0) {
|
||||
return server.getAmbientSpawnLimit();
|
||||
|
@ -1731,14 +1838,17 @@ public class CraftWorld implements World {
|
|||
return ambientSpawn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAmbientSpawnLimit(int limit) {
|
||||
ambientSpawn = limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Location loc, Sound sound, float volume, float pitch) {
|
||||
playSound(loc, sound, org.bukkit.SoundCategory.MASTER, volume, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Location loc, String sound, float volume, float pitch) {
|
||||
playSound(loc, sound, org.bukkit.SoundCategory.MASTER, volume, pitch);
|
||||
}
|
||||
|
@ -1766,6 +1876,7 @@ public class CraftWorld implements World {
|
|||
world.getMinecraftServer().getPlayerList().sendPacketNearby(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension, packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameRuleValue(String rule) {
|
||||
// In method contract for some reason
|
||||
if (rule == null) {
|
||||
|
@ -1776,6 +1887,7 @@ public class CraftWorld implements World {
|
|||
return value != null ? value.getValue() : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setGameRuleValue(String rule, String value) {
|
||||
// No null values allowed
|
||||
if (rule == null || value == null) return false;
|
||||
|
@ -1786,10 +1898,12 @@ public class CraftWorld implements World {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGameRules() {
|
||||
return GameRules.getGameRules().keySet().toArray(new String[GameRules.getGameRules().size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGameRule(String rule) {
|
||||
Validate.isTrue(rule != null && !rule.isEmpty(), "Rule cannot be null nor empty");
|
||||
return GameRules.getGameRules().containsKey(rule);
|
||||
|
|
|
@ -73,6 +73,7 @@ public class CraftBlock implements Block {
|
|||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return world.getMinecraftWorld().getWorld();
|
||||
}
|
||||
|
@ -81,10 +82,12 @@ public class CraftBlock implements Block {
|
|||
return (CraftWorld) getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return new Location(getWorld(), position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation(Location loc) {
|
||||
if (loc != null) {
|
||||
loc.setWorld(getWorld());
|
||||
|
@ -102,18 +105,22 @@ public class CraftBlock implements Block {
|
|||
return new BlockVector(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return position.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return position.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return position.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getChunk() {
|
||||
return getWorld().getChunkAt(this);
|
||||
}
|
||||
|
@ -138,6 +145,7 @@ public class CraftBlock implements Block {
|
|||
return world.getType(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getData() {
|
||||
IBlockData blockData = world.getType(position);
|
||||
return CraftMagicNumbers.toLegacyData(blockData);
|
||||
|
@ -148,6 +156,7 @@ public class CraftBlock implements Block {
|
|||
return CraftBlockData.fromData(getData0());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(final Material type) {
|
||||
setType(type, true);
|
||||
}
|
||||
|
@ -197,18 +206,22 @@ public class CraftBlock implements Block {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getType() {
|
||||
return CraftMagicNumbers.getMaterial(world.getType(position).getBlock());
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getLightLevel() {
|
||||
return (byte) world.getMinecraftWorld().getLightLevel(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getLightFromSky() {
|
||||
return (byte) world.getBrightness(EnumSkyBlock.SKY, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getLightFromBlocks() {
|
||||
return (byte) world.getBrightness(EnumSkyBlock.BLOCK, position);
|
||||
}
|
||||
|
@ -222,18 +235,22 @@ public class CraftBlock implements Block {
|
|||
return getRelative(face, distance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getRelative(final int modX, final int modY, final int modZ) {
|
||||
return getWorld().getBlockAt(getX() + modX, getY() + modY, getZ() + modZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getRelative(BlockFace face) {
|
||||
return getRelative(face, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getRelative(BlockFace face, int distance) {
|
||||
return getRelative(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFace getFace(final Block block) {
|
||||
BlockFace[] values = BlockFace.values();
|
||||
|
||||
|
@ -293,6 +310,7 @@ public class CraftBlock implements Block {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getState() {
|
||||
Material material = getType();
|
||||
|
||||
|
@ -456,10 +474,12 @@ public class CraftBlock implements Block {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome() {
|
||||
return getWorld().getBiome(getX(), getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(Biome bio) {
|
||||
getWorld().setBiome(getX(), getZ(), bio);
|
||||
}
|
||||
|
@ -480,18 +500,22 @@ public class CraftBlock implements Block {
|
|||
return IRegistry.BIOME.get(new MinecraftKey(bio.name().toLowerCase(java.util.Locale.ENGLISH)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTemperature() {
|
||||
return world.getBiome(position).getAdjustedTemperature(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHumidity() {
|
||||
return getWorld().getHumidity(getX(), getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockPowered() {
|
||||
return world.getMinecraftWorld().getBlockPower(position) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockIndirectlyPowered() {
|
||||
return world.getMinecraftWorld().isBlockIndirectlyPowered(position);
|
||||
}
|
||||
|
@ -510,10 +534,12 @@ public class CraftBlock implements Block {
|
|||
return this.position.hashCode() ^ this.getWorld().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockFacePowered(BlockFace face) {
|
||||
return world.getMinecraftWorld().isBlockFacePowered(position, blockFaceToNotch(face));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockFaceIndirectlyPowered(BlockFace face) {
|
||||
int power = world.getMinecraftWorld().getBlockFacePower(position, blockFaceToNotch(face));
|
||||
|
||||
|
@ -525,6 +551,7 @@ public class CraftBlock implements Block {
|
|||
return power > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(BlockFace face) {
|
||||
int power = 0;
|
||||
BlockRedstoneWire wire = (BlockRedstoneWire) Blocks.REDSTONE_WIRE;
|
||||
|
@ -541,26 +568,32 @@ public class CraftBlock implements Block {
|
|||
return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower() {
|
||||
return getBlockPower(BlockFace.SELF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return getNMS().isAir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLiquid() {
|
||||
return (getType() == Material.WATER) || (getType() == Material.LAVA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PistonMoveReaction getPistonMoveReaction() {
|
||||
return PistonMoveReaction.getById(getNMS().getPushReaction().ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean breakNaturally() {
|
||||
return breakNaturally(new ItemStack(Material.AIR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean breakNaturally(ItemStack item) {
|
||||
// Order matters here, need to drop before setting to air so skulls can get their data
|
||||
net.minecraft.server.Block block = this.getNMSBlock();
|
||||
|
@ -574,27 +607,33 @@ public class CraftBlock implements Block {
|
|||
return setTypeAndData(Blocks.AIR.getBlockData(), true) && result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getDrops() {
|
||||
return getDrops(new ItemStack(Material.AIR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getDrops(ItemStack item) {
|
||||
return net.minecraft.server.Block.getDrops(getNMS(), (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), null, CraftItemStack.asNMSCopy(item))
|
||||
.stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
|
||||
getCraftWorld().getBlockMetadata().setMetadata(this, metadataKey, newMetadataValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetadataValue> getMetadata(String metadataKey) {
|
||||
return getCraftWorld().getBlockMetadata().getMetadata(this, metadataKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMetadata(String metadataKey) {
|
||||
return getCraftWorld().getBlockMetadata().hasMetadata(this, metadataKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
|
||||
getCraftWorld().getBlockMetadata().removeMetadata(this, metadataKey, owningPlugin);
|
||||
}
|
||||
|
|
|
@ -56,23 +56,28 @@ public class CraftBlockState implements BlockState {
|
|||
return new CraftBlockState(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
requirePlaced();
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return position.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return position.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return position.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getChunk() {
|
||||
requirePlaced();
|
||||
return chunk;
|
||||
|
@ -101,6 +106,7 @@ public class CraftBlockState implements BlockState {
|
|||
this.data = ((CraftBlockData) data).getState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(final MaterialData data) {
|
||||
Material mat = CraftMagicNumbers.getMaterial(this.data).getItemType();
|
||||
|
||||
|
@ -116,10 +122,12 @@ public class CraftBlockState implements BlockState {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialData getData() {
|
||||
return CraftMagicNumbers.getMaterial(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(final Material type) {
|
||||
Preconditions.checkArgument(type != null, "Material cannot be null");
|
||||
Preconditions.checkArgument(type.isBlock(), "Material must be a block!");
|
||||
|
@ -129,6 +137,7 @@ public class CraftBlockState implements BlockState {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getType() {
|
||||
return CraftMagicNumbers.getMaterial(data.getBlock());
|
||||
}
|
||||
|
@ -141,23 +150,28 @@ public class CraftBlockState implements BlockState {
|
|||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getLightLevel() {
|
||||
return getBlock().getLightLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftBlock getBlock() {
|
||||
requirePlaced();
|
||||
return CraftBlock.at(world.getHandle(), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update() {
|
||||
return update(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(boolean force) {
|
||||
return update(force, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(boolean force, boolean applyPhysics) {
|
||||
if (!isPlaced()) {
|
||||
return true;
|
||||
|
@ -187,14 +201,17 @@ public class CraftBlockState implements BlockState {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getRawData() {
|
||||
return CraftMagicNumbers.toLegacyData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return new Location(world, getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation(Location loc) {
|
||||
if (loc != null) {
|
||||
loc.setWorld(world);
|
||||
|
@ -208,6 +225,7 @@ public class CraftBlockState implements BlockState {
|
|||
return loc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRawData(byte data) {
|
||||
this.data = CraftMagicNumbers.getBlock(getType(), data);
|
||||
}
|
||||
|
@ -242,21 +260,25 @@ public class CraftBlockState implements BlockState {
|
|||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
|
||||
requirePlaced();
|
||||
chunk.getCraftWorld().getBlockMetadata().setMetadata(getBlock(), metadataKey, newMetadataValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetadataValue> getMetadata(String metadataKey) {
|
||||
requirePlaced();
|
||||
return chunk.getCraftWorld().getBlockMetadata().getMetadata(getBlock(), metadataKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMetadata(String metadataKey) {
|
||||
requirePlaced();
|
||||
return chunk.getCraftWorld().getBlockMetadata().hasMetadata(getBlock(), metadataKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
|
||||
requirePlaced();
|
||||
chunk.getCraftWorld().getBlockMetadata().removeMetadata(getBlock(), metadataKey, owningPlugin);
|
||||
|
|
|
@ -16,6 +16,7 @@ public class ConsoleCommandCompleter implements Completer {
|
|||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int complete(final String buffer, final int cursor, final List<CharSequence> candidates) {
|
||||
Waitable<List<String>> waitable = new Waitable<List<String>>() {
|
||||
@Override
|
||||
|
|
|
@ -21,30 +21,36 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc
|
|||
this.tile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return CraftBlock.at(tile.getWorld(), tile.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
for (IChatBaseComponent component : CraftChatMessage.fromString(message)) {
|
||||
block.base.sendMessage(component);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String[] messages) {
|
||||
for (String message : messages) {
|
||||
sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return block.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOp(boolean value) {
|
||||
throw new UnsupportedOperationException("Cannot change operator status of a block");
|
||||
}
|
||||
|
|
|
@ -18,48 +18,59 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co
|
|||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
sendRawMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String message) {
|
||||
System.out.println(ChatColor.stripColor(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String[] messages) {
|
||||
for (String message : messages) {
|
||||
sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CONSOLE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOp(boolean value) {
|
||||
throw new UnsupportedOperationException("Cannot change operator status of server console");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean beginConversation(Conversation conversation) {
|
||||
return conversationTracker.beginConversation(conversation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abandonConversation(Conversation conversation) {
|
||||
conversationTracker.abandonConversation(conversation, new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
|
||||
conversationTracker.abandonConversation(conversation, details);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptConversationInput(String input) {
|
||||
conversationTracker.acceptConversationInput(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConversing() {
|
||||
return conversationTracker.isConversing();
|
||||
}
|
||||
|
|
|
@ -16,46 +16,57 @@ public abstract class ServerCommandSender implements CommandSender {
|
|||
public ServerCommandSender() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String name) {
|
||||
return perm.isPermissionSet(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(Permission perm) {
|
||||
return this.perm.isPermissionSet(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String name) {
|
||||
return perm.hasPermission(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Permission perm) {
|
||||
return this.perm.hasPermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
|
||||
return perm.addAttachment(plugin, name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin) {
|
||||
return perm.addAttachment(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
|
||||
return perm.addAttachment(plugin, name, value, ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, int ticks) {
|
||||
return perm.addAttachment(plugin, ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttachment(PermissionAttachment attachment) {
|
||||
perm.removeAttachment(attachment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculatePermissions() {
|
||||
perm.recalculatePermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
||||
return perm.getEffectivePermissions();
|
||||
}
|
||||
|
@ -64,6 +75,7 @@ public abstract class ServerCommandSender implements CommandSender {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server getServer() {
|
||||
return Bukkit.getServer();
|
||||
}
|
||||
|
|
|
@ -12,10 +12,12 @@ public abstract class AbstractProjectile extends CraftEntity implements Projecti
|
|||
doesBounce = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesBounce() {
|
||||
return doesBounce;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBounce(boolean doesBounce) {
|
||||
this.doesBounce = doesBounce;
|
||||
}
|
||||
|
|
|
@ -22,33 +22,40 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac
|
|||
return (EntityHorseAbstract) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVariant(Horse.Variant variant) {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDomestication() {
|
||||
return getHandle().getTemper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomestication(int value) {
|
||||
Validate.isTrue(value >= 0, "Domestication cannot be less than zero");
|
||||
Validate.isTrue(value <= getMaxDomestication(), "Domestication cannot be greater than the max domestication");
|
||||
getHandle().setTemper(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDomestication() {
|
||||
return getHandle().getMaxDomestication();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxDomestication(int value) {
|
||||
Validate.isTrue(value > 0, "Max domestication cannot be zero or less");
|
||||
getHandle().maxDomestication = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getJumpStrength() {
|
||||
return getHandle().getJumpStrength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJumpStrength(double strength) {
|
||||
Validate.isTrue(strength >= 0, "Jump strength cannot be less than zero");
|
||||
getHandle().getAttributeInstance(EntityHorse.attributeJumpStrength).setValue(strength);
|
||||
|
|
|
@ -9,43 +9,52 @@ public class CraftAgeable extends CraftCreature implements Ageable {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAge() {
|
||||
return getHandle().getAge();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(int age) {
|
||||
getHandle().setAgeRaw(age);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAgeLock(boolean lock) {
|
||||
getHandle().ageLocked = lock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAgeLock() {
|
||||
return getHandle().ageLocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBaby() {
|
||||
if (isAdult()) {
|
||||
setAge(-24000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAdult() {
|
||||
if (!isAdult()) {
|
||||
setAge(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAdult() {
|
||||
return getAge() >= 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canBreed() {
|
||||
return getAge() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBreed(boolean breed) {
|
||||
if (breed) {
|
||||
setAge(0);
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CraftAmbient extends CraftMob implements Ambient {
|
|||
return "CraftAmbient";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -214,11 +214,13 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud
|
|||
return CraftPotionUtil.toBukkit(getHandle().getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectileSource getSource() {
|
||||
EntityLiving source = getHandle().getSource();
|
||||
return (source == null) ? null : (LivingEntity) source.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSource(ProjectileSource shooter) {
|
||||
if (shooter instanceof CraftLivingEntity) {
|
||||
getHandle().setSource((EntityLiving) ((CraftLivingEntity) shooter).getHandle());
|
||||
|
|
|
@ -17,11 +17,13 @@ public class CraftArrow extends AbstractProjectile implements Arrow {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKnockbackStrength(int knockbackStrength) {
|
||||
Validate.isTrue(knockbackStrength >= 0, "Knockback cannot be negative");
|
||||
getHandle().setKnockbackStrength(knockbackStrength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getKnockbackStrength() {
|
||||
return getHandle().knockbackStrength;
|
||||
}
|
||||
|
@ -37,18 +39,22 @@ public class CraftArrow extends AbstractProjectile implements Arrow {
|
|||
getHandle().setDamage(damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCritical() {
|
||||
return getHandle().isCritical();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCritical(boolean critical) {
|
||||
getHandle().setCritical(critical);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectileSource getShooter() {
|
||||
return getHandle().projectileSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShooter(ProjectileSource shooter) {
|
||||
if (shooter instanceof Entity) {
|
||||
getHandle().setShooter(((CraftEntity) shooter).getHandle());
|
||||
|
@ -102,6 +108,7 @@ public class CraftArrow extends AbstractProjectile implements Arrow {
|
|||
return "CraftArrow";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CraftBat extends CraftAmbient implements Bat {
|
|||
return "CraftBat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.BAT;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CraftBlaze extends CraftMonster implements Blaze {
|
|||
return "CraftBlaze";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.BLAZE;
|
||||
}
|
||||
|
|
|
@ -22,38 +22,46 @@ public class CraftBoat extends CraftVehicle implements Boat {
|
|||
getHandle().setType(getBoatType(species));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxSpeed() {
|
||||
return getHandle().maxSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxSpeed(double speed) {
|
||||
if (speed >= 0D) {
|
||||
getHandle().maxSpeed = speed;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getOccupiedDeceleration() {
|
||||
return getHandle().occupiedDeceleration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOccupiedDeceleration(double speed) {
|
||||
if (speed >= 0D) {
|
||||
getHandle().occupiedDeceleration = speed;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getUnoccupiedDeceleration() {
|
||||
return getHandle().unoccupiedDeceleration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnoccupiedDeceleration(double speed) {
|
||||
getHandle().unoccupiedDeceleration = speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getWorkOnLand() {
|
||||
return getHandle().landBoats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorkOnLand(boolean workOnLand) {
|
||||
getHandle().landBoats = workOnLand;
|
||||
}
|
||||
|
@ -68,6 +76,7 @@ public class CraftBoat extends CraftVehicle implements Boat {
|
|||
return "CraftBoat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.BOAT;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CraftCaveSpider extends CraftSpider implements CaveSpider {
|
|||
return "CraftCaveSpider";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.CAVE_SPIDER;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public class CraftChicken extends CraftAnimals implements Chicken {
|
|||
return "CraftChicken";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.CHICKEN;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ public class CraftComplexPart extends CraftEntity implements ComplexEntityPart {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComplexLivingEntity getParent() {
|
||||
return (ComplexLivingEntity) ((EntityEnderDragon) getHandle().owner).getBukkitEntity();
|
||||
}
|
||||
|
@ -42,6 +43,7 @@ public class CraftComplexPart extends CraftEntity implements ComplexEntityPart {
|
|||
return "CraftComplexPart";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public class CraftCow extends CraftAnimals implements Cow {
|
|||
return "CraftCow";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.COW;
|
||||
}
|
||||
|
|
|
@ -13,10 +13,12 @@ public class CraftCreeper extends CraftMonster implements Creeper {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowered() {
|
||||
return getHandle().isPowered();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPowered(boolean powered) {
|
||||
CraftServer server = this.server;
|
||||
Creeper entity = (Creeper) this.getHandle().getBukkitEntity();
|
||||
|
@ -72,6 +74,7 @@ public class CraftCreeper extends CraftMonster implements Creeper {
|
|||
return "CraftCreeper";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.CREEPER;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CraftEgg extends CraftProjectile implements Egg {
|
|||
return "CraftEgg";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.EGG;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ public class CraftEnderCrystal extends CraftEntity implements EnderCrystal {
|
|||
return "CraftEnderCrystal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.ENDER_CRYSTAL;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderD
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ComplexEntityPart> getParts() {
|
||||
Builder<ComplexEntityPart> builder = ImmutableSet.builder();
|
||||
|
||||
|
@ -45,6 +46,7 @@ public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderD
|
|||
return "CraftEnderDragon";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.ENDER_DRAGON;
|
||||
}
|
||||
|
|
|
@ -26,30 +26,37 @@ public class CraftEnderDragonPart extends CraftComplexPart implements EnderDrago
|
|||
return "CraftEnderDragonPart";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damage(double amount) {
|
||||
getParent().damage(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damage(double amount, Entity source) {
|
||||
getParent().damage(amount, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealth() {
|
||||
return getParent().getHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealth(double health) {
|
||||
getParent().setHealth(health);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return getParent().getMaxHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxHealth(double health) {
|
||||
getParent().setMaxHealth(health);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetMaxHealth() {
|
||||
getParent().resetMaxHealth();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CraftEnderPearl extends CraftProjectile implements EnderPearl {
|
|||
return "CraftEnderPearl";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.ENDER_PEARL;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ public class CraftEnderman extends CraftMonster implements Enderman {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialData getCarriedMaterial() {
|
||||
IBlockData blockData = getHandle().getCarried();
|
||||
return (blockData == null) ? Material.AIR.getNewData((byte) 0) : CraftMagicNumbers.getMaterial(blockData);
|
||||
|
@ -27,6 +28,7 @@ public class CraftEnderman extends CraftMonster implements Enderman {
|
|||
return (blockData == null) ? null : CraftBlockData.fromData(blockData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCarriedMaterial(MaterialData data) {
|
||||
getHandle().setCarried(CraftMagicNumbers.getBlock(data));
|
||||
}
|
||||
|
@ -46,6 +48,7 @@ public class CraftEnderman extends CraftMonster implements Enderman {
|
|||
return "CraftEnderman";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.ENDERMAN;
|
||||
}
|
||||
|
|
|
@ -370,10 +370,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
throw new AssertionError("Unknown entity " + (entity == null ? null : entity.getClass()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return new Location(getWorld(), entity.locX, entity.locY, entity.locZ, entity.getBukkitYaw(), entity.pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation(Location loc) {
|
||||
if (loc != null) {
|
||||
loc.setWorld(getWorld());
|
||||
|
@ -387,10 +389,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
return loc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getVelocity() {
|
||||
return CraftVector.toBukkit(entity.getMot());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVelocity(Vector velocity) {
|
||||
Preconditions.checkArgument(velocity != null, "velocity");
|
||||
velocity.checkFinite();
|
||||
|
@ -414,6 +418,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
return new BoundingBox(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnGround() {
|
||||
if (entity instanceof EntityArrow) {
|
||||
return ((EntityArrow) entity).inGround;
|
||||
|
@ -421,6 +426,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
return entity.onGround;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return entity.world.getWorld();
|
||||
}
|
||||
|
@ -440,10 +446,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
entity.setHeadRotation(yaw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(Location location) {
|
||||
return teleport(location, TeleportCause.PLUGIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(Location location, TeleportCause cause) {
|
||||
Preconditions.checkArgument(location != null, "location");
|
||||
location.checkFinite();
|
||||
|
@ -469,14 +477,17 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(org.bukkit.entity.Entity destination) {
|
||||
return teleport(destination.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(org.bukkit.entity.Entity destination, TeleportCause cause) {
|
||||
return teleport(destination.getLocation(), cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z) {
|
||||
List<Entity> notchEntityList = entity.world.getEntities(entity, entity.getBoundingBox().grow(x, y, z), null);
|
||||
List<org.bukkit.entity.Entity> bukkitEntityList = new java.util.ArrayList<org.bukkit.entity.Entity>(notchEntityList.size());
|
||||
|
@ -487,34 +498,42 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
return bukkitEntityList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEntityId() {
|
||||
return entity.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireTicks() {
|
||||
return entity.fireTicks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFireTicks() {
|
||||
return entity.getMaxFireTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFireTicks(int ticks) {
|
||||
entity.fireTicks = ticks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
entity.die();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDead() {
|
||||
return !entity.isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return entity.isAlive() && entity.valid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server getServer() {
|
||||
return server;
|
||||
}
|
||||
|
@ -537,10 +556,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
setVelocity(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getPassenger() {
|
||||
return isEmpty() ? null : getHandle().passengers.get(0).getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPassenger(org.bukkit.entity.Entity passenger) {
|
||||
Preconditions.checkArgument(!this.equals(passenger), "Entity cannot ride itself.");
|
||||
if (passenger instanceof CraftEntity) {
|
||||
|
@ -576,10 +597,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return !getHandle().isVehicle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eject() {
|
||||
if (isEmpty()) {
|
||||
return false;
|
||||
|
@ -589,30 +612,37 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFallDistance() {
|
||||
return getHandle().fallDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFallDistance(float distance) {
|
||||
getHandle().fallDistance = distance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastDamageCause(EntityDamageEvent event) {
|
||||
lastDamageEvent = event;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDamageEvent getLastDamageCause() {
|
||||
return lastDamageEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return getHandle().getUniqueID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTicksLived() {
|
||||
return getHandle().ticksLived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTicksLived(int value) {
|
||||
if (value <= 0) {
|
||||
throw new IllegalArgumentException("Age must be at least 1 tick");
|
||||
|
@ -661,26 +691,32 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
|
||||
server.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetadataValue> getMetadata(String metadataKey) {
|
||||
return server.getEntityMetadata().getMetadata(this, metadataKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMetadata(String metadataKey) {
|
||||
return server.getEntityMetadata().hasMetadata(this, metadataKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
|
||||
server.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInsideVehicle() {
|
||||
return getHandle().isPassenger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean leaveVehicle() {
|
||||
if (!isInsideVehicle()) {
|
||||
return false;
|
||||
|
@ -690,6 +726,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getVehicle() {
|
||||
if (!isInsideVehicle()) {
|
||||
return null;
|
||||
|
|
|
@ -10,10 +10,12 @@ public class CraftExperienceOrb extends CraftEntity implements ExperienceOrb {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExperience() {
|
||||
return getHandle().value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExperience(int value) {
|
||||
getHandle().value = value;
|
||||
}
|
||||
|
@ -28,6 +30,7 @@ public class CraftExperienceOrb extends CraftEntity implements ExperienceOrb {
|
|||
return "CraftExperienceOrb";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.EXPERIENCE_ORB;
|
||||
}
|
||||
|
|
|
@ -25,22 +25,27 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock {
|
|||
return "CraftFallingBlock";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.FALLING_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial() {
|
||||
return CraftMagicNumbers.getMaterial(getHandle().getBlock()).getItemType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData() {
|
||||
return CraftBlockData.fromData(getHandle().getBlock());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDropItem() {
|
||||
return getHandle().dropItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDropItem(boolean drop) {
|
||||
getHandle().dropItem = drop;
|
||||
}
|
||||
|
|
|
@ -14,26 +14,32 @@ public class CraftFireball extends AbstractProjectile implements Fireball {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getYield() {
|
||||
return getHandle().bukkitYield;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIncendiary() {
|
||||
return getHandle().isIncendiary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsIncendiary(boolean isIncendiary) {
|
||||
getHandle().isIncendiary = isIncendiary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setYield(float yield) {
|
||||
getHandle().bukkitYield = yield;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectileSource getShooter() {
|
||||
return getHandle().projectileSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShooter(ProjectileSource shooter) {
|
||||
if (shooter instanceof CraftLivingEntity) {
|
||||
getHandle().shooter = ((CraftLivingEntity) shooter).getHandle();
|
||||
|
@ -43,10 +49,12 @@ public class CraftFireball extends AbstractProjectile implements Fireball {
|
|||
getHandle().projectileSource = shooter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getDirection() {
|
||||
return new Vector(getHandle().dirX, getHandle().dirY, getHandle().dirZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection(Vector direction) {
|
||||
Validate.notNull(direction, "Direction can not be null");
|
||||
double x = direction.getX();
|
||||
|
@ -68,6 +76,7 @@ public class CraftFireball extends AbstractProjectile implements Fireball {
|
|||
return "CraftFireball";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ public class CraftFishHook extends AbstractProjectile implements FishHook {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectileSource getShooter() {
|
||||
if (getHandle().owner != null) {
|
||||
return getHandle().owner.getBukkitEntity();
|
||||
|
@ -25,6 +26,7 @@ public class CraftFishHook extends AbstractProjectile implements FishHook {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShooter(ProjectileSource shooter) {
|
||||
if (shooter instanceof CraftHumanEntity) {
|
||||
getHandle().owner = (EntityHuman) ((CraftHumanEntity) shooter).entity;
|
||||
|
@ -41,10 +43,12 @@ public class CraftFishHook extends AbstractProjectile implements FishHook {
|
|||
return "CraftFishingHook";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.FISHING_HOOK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBiteChance() {
|
||||
EntityFishingHook hook = getHandle();
|
||||
|
||||
|
@ -57,6 +61,7 @@ public class CraftFishHook extends AbstractProjectile implements FishHook {
|
|||
return this.biteChance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiteChance(double chance) {
|
||||
Validate.isTrue(chance >= 0 && chance <= 1, "The bite chance must be between 0 and 1.");
|
||||
this.biteChance = chance;
|
||||
|
|
|
@ -21,6 +21,7 @@ public class CraftGhast extends CraftFlying implements Ghast {
|
|||
return "CraftGhast";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.GHAST;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public class CraftGiant extends CraftMonster implements Giant {
|
|||
return "CraftGiant";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.GIANT;
|
||||
}
|
||||
|
|
|
@ -13,14 +13,17 @@ public class CraftHanging extends CraftEntity implements Hanging {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFace getAttachedFace() {
|
||||
return getFacing().getOppositeFace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacingDirection(BlockFace face) {
|
||||
setFacingDirection(face, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setFacingDirection(BlockFace face, boolean force) {
|
||||
EntityHanging hanging = getHandle();
|
||||
EnumDirection dir = hanging.direction;
|
||||
|
@ -47,6 +50,7 @@ public class CraftHanging extends CraftEntity implements Hanging {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFace getFacing() {
|
||||
EnumDirection direction = this.getHandle().direction;
|
||||
if (direction == null) return BlockFace.SELF;
|
||||
|
@ -63,6 +67,7 @@ public class CraftHanging extends CraftEntity implements Hanging {
|
|||
return "CraftHanging";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -91,34 +91,42 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
enderChest = new CraftInventory(entity.getEnderChest());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerInventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityEquipment getEquipment() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getEnderChest() {
|
||||
return enderChest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MainHand getMainHand() {
|
||||
return getHandle().getMainHand()== EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInHand() {
|
||||
return getInventory().getItemInHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInHand(ItemStack item) {
|
||||
getInventory().setItemInHand(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemOnCursor() {
|
||||
return CraftItemStack.asCraftMirror(getHandle().inventory.getCarried());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemOnCursor(ItemStack item) {
|
||||
net.minecraft.server.ItemStack stack = CraftItemStack.asNMSCopy(item);
|
||||
getHandle().inventory.setCarried(stack);
|
||||
|
@ -127,10 +135,12 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSleeping() {
|
||||
return getHandle().isSleeping();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSleepTicks() {
|
||||
return getHandle().sleepTicks;
|
||||
}
|
||||
|
@ -207,63 +217,78 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
return getHandle().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return op;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String name) {
|
||||
return perm.isPermissionSet(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(Permission perm) {
|
||||
return this.perm.isPermissionSet(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String name) {
|
||||
return perm.hasPermission(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Permission perm) {
|
||||
return this.perm.hasPermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
|
||||
return perm.addAttachment(plugin, name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin) {
|
||||
return perm.addAttachment(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
|
||||
return perm.addAttachment(plugin, name, value, ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, int ticks) {
|
||||
return perm.addAttachment(plugin, ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttachment(PermissionAttachment attachment) {
|
||||
perm.removeAttachment(attachment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculatePermissions() {
|
||||
perm.recalculatePermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOp(boolean value) {
|
||||
this.op = value;
|
||||
perm.recalculatePermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
||||
return perm.getEffectivePermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getGameMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGameMode(GameMode mode) {
|
||||
if (mode == null) {
|
||||
throw new IllegalArgumentException("Mode cannot be null");
|
||||
|
@ -287,10 +312,12 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
return "CraftHumanEntity{" + "id=" + getEntityId() + "name=" + getName() + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView getOpenInventory() {
|
||||
return getHandle().activeContainer.getBukkitView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openInventory(Inventory inventory) {
|
||||
if(!(getHandle() instanceof EntityPlayer)) return null;
|
||||
EntityPlayer player = (EntityPlayer) getHandle();
|
||||
|
@ -463,6 +490,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
getHandle().activeContainer.addSlotListener(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openWorkbench(Location location, boolean force) {
|
||||
if (!force) {
|
||||
Block block = location.getBlock();
|
||||
|
@ -480,6 +508,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
return getHandle().activeContainer.getBukkitView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openEnchanting(Location location, boolean force) {
|
||||
if (!force) {
|
||||
Block block = location.getBlock();
|
||||
|
@ -501,6 +530,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
return getHandle().activeContainer.getBukkitView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(InventoryView inventory) {
|
||||
if (!(getHandle() instanceof EntityPlayer)) return; // TODO: NPC support?
|
||||
if (((EntityPlayer) getHandle()).playerConnection == null) return;
|
||||
|
@ -567,10 +597,12 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
return this.getHandle().activeContainer.getBukkitView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
getHandle().closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlocking() {
|
||||
return getHandle().isBlocking();
|
||||
}
|
||||
|
@ -580,10 +612,12 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
return getHandle().isHandRaised();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setWindowProperty(InventoryView.Property prop, int value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExpToLevel() {
|
||||
return getHandle().getExpToLevel();
|
||||
}
|
||||
|
|
|
@ -20,10 +20,12 @@ public class CraftIronGolem extends CraftGolem implements IronGolem {
|
|||
return "CraftIronGolem";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerCreated() {
|
||||
return getHandle().isPlayerCreated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerCreated(boolean playerCreated) {
|
||||
getHandle().setPlayerCreated(playerCreated);
|
||||
}
|
||||
|
|
|
@ -20,18 +20,22 @@ public class CraftItem extends CraftEntity implements Item {
|
|||
this(server, entity, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return CraftItemStack.asCraftMirror(item.getItemStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStack(ItemStack stack) {
|
||||
item.setItemStack(CraftItemStack.asNMSCopy(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPickupDelay() {
|
||||
return item.pickupDelay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPickupDelay(int delay) {
|
||||
item.pickupDelay = Math.min(delay, Short.MAX_VALUE);
|
||||
}
|
||||
|
@ -49,6 +53,7 @@ public class CraftItem extends CraftEntity implements Item {
|
|||
return "CraftItem";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.DROPPED_ITEM;
|
||||
}
|
||||
|
|
|
@ -54,18 +54,22 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame {
|
|||
this.entity = frame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(org.bukkit.inventory.ItemStack item) {
|
||||
setItem(item, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(org.bukkit.inventory.ItemStack item, boolean playSound) {
|
||||
getHandle().setItem(CraftItemStack.asNMSCopy(item), true, playSound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getItem() {
|
||||
return CraftItemStack.asBukkitCopy(getHandle().getItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rotation getRotation() {
|
||||
return toBukkitRotation(getHandle().getRotation());
|
||||
}
|
||||
|
@ -94,6 +98,7 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotation(Rotation rotation) {
|
||||
Validate.notNull(rotation, "Rotation cannot be null");
|
||||
getHandle().setRotation(toInteger(rotation));
|
||||
|
@ -133,6 +138,7 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame {
|
|||
return "CraftItemFrame{item=" + getItem() + ", rotation=" + getRotation() + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.ITEM_FRAME;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ public class CraftLargeFireball extends CraftFireball implements LargeFireball {
|
|||
return "CraftLargeFireball";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.FIREBALL;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CraftLeash extends CraftHanging implements LeashHitch {
|
|||
return "CraftLeash";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.LEASH_HITCH;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEffect() {
|
||||
return ((EntityLightning) super.getHandle()).isEffect;
|
||||
}
|
||||
|
@ -24,6 +25,7 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike
|
|||
return "CraftLightningStrike";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.LIGHTNING;
|
||||
}
|
||||
|
|
|
@ -92,10 +92,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealth() {
|
||||
return Math.min(Math.max(0, getHandle().getHealth()), getMaxHealth());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealth(double health) {
|
||||
health = (float) health;
|
||||
if ((health < 0) || (health > getMaxHealth())) {
|
||||
|
@ -109,10 +111,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return getHandle().getMaxHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxHealth(double amount) {
|
||||
Validate.isTrue(amount > 0, "Max health must be greater than 0");
|
||||
|
||||
|
@ -123,14 +127,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetMaxHealth() {
|
||||
setMaxHealth(getHandle().getAttributeInstance(GenericAttributes.MAX_HEALTH).getAttribute().getDefault());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEyeHeight() {
|
||||
return getHandle().getHeadHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEyeHeight(boolean ignorePose) {
|
||||
return getEyeHeight();
|
||||
}
|
||||
|
@ -158,15 +165,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Block> getLineOfSight(Set<Material> transparent, int maxDistance) {
|
||||
return getLineOfSight(transparent, maxDistance, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getTargetBlock(Set<Material> transparent, int maxDistance) {
|
||||
List<Block> blocks = getLineOfSight(transparent, maxDistance, 1);
|
||||
return blocks.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Block> getLastTwoTargetBlocks(Set<Material> transparent, int maxDistance) {
|
||||
return getLineOfSight(transparent, maxDistance, 2);
|
||||
}
|
||||
|
@ -194,26 +204,32 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
return this.getWorld().rayTraceBlocks(eyeLocation, direction, maxDistance, fluidCollisionMode, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemainingAir() {
|
||||
return getHandle().getAirTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemainingAir(int ticks) {
|
||||
getHandle().setAirTicks(ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumAir() {
|
||||
return getHandle().maxAirTicks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaximumAir(int ticks) {
|
||||
getHandle().maxAirTicks = ticks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damage(double amount) {
|
||||
damage(amount, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damage(double amount, org.bukkit.entity.Entity source) {
|
||||
DamageSource reason = DamageSource.GENERIC;
|
||||
|
||||
|
@ -226,32 +242,39 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
entity.damageEntity(reason, (float) amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getEyeLocation() {
|
||||
Location loc = getLocation();
|
||||
loc.setY(loc.getY() + getEyeHeight());
|
||||
return loc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumNoDamageTicks() {
|
||||
return getHandle().maxNoDamageTicks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaximumNoDamageTicks(int ticks) {
|
||||
getHandle().maxNoDamageTicks = ticks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getLastDamage() {
|
||||
return getHandle().lastDamage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastDamage(double damage) {
|
||||
getHandle().lastDamage = (float) damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNoDamageTicks() {
|
||||
return getHandle().noDamageTicks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoDamageTicks(int ticks) {
|
||||
getHandle().noDamageTicks = ticks;
|
||||
}
|
||||
|
@ -270,14 +293,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
return "CraftLivingEntity{" + "id=" + getEntityId() + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getKiller() {
|
||||
return getHandle().killer == null ? null : (Player) getHandle().killer.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPotionEffect(PotionEffect effect) {
|
||||
return addPotionEffect(effect, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPotionEffect(PotionEffect effect, boolean force) {
|
||||
if (hasPotionEffect(effect.getType())) {
|
||||
if (!force) {
|
||||
|
@ -289,6 +315,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPotionEffects(Collection<PotionEffect> effects) {
|
||||
boolean success = true;
|
||||
for (PotionEffect effect : effects) {
|
||||
|
@ -297,6 +324,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPotionEffect(PotionEffectType type) {
|
||||
return getHandle().hasEffect(MobEffectList.fromId(type.getId()));
|
||||
}
|
||||
|
@ -307,10 +335,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
return (handle == null) ? null : new PotionEffect(PotionEffectType.getById(MobEffectList.getId(handle.getMobEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isShowParticles());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePotionEffect(PotionEffectType type) {
|
||||
getHandle().removeEffect(MobEffectList.fromId(type.getId()), EntityPotionEffectEvent.Cause.PLUGIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PotionEffect> getActivePotionEffects() {
|
||||
List<PotionEffect> effects = new ArrayList<PotionEffect>();
|
||||
for (MobEffect handle : getHandle().effects.values()) {
|
||||
|
@ -319,10 +349,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
return effects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile) {
|
||||
return launchProjectile(projectile, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
|
||||
net.minecraft.server.World world = ((CraftWorld) getWorld()).getHandle();
|
||||
|
@ -405,32 +437,39 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
return (T) launch.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLineOfSight(Entity other) {
|
||||
return getHandle().hasLineOfSight(((CraftEntity) other).getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRemoveWhenFarAway() {
|
||||
return getHandle() instanceof EntityInsentient && !((EntityInsentient) getHandle()).persistent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemoveWhenFarAway(boolean remove) {
|
||||
if (getHandle() instanceof EntityInsentient) {
|
||||
((EntityInsentient) getHandle()).persistent = !remove;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityEquipment getEquipment() {
|
||||
return equipment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanPickupItems(boolean pickup) {
|
||||
getHandle().canPickUpLoot = pickup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getCanPickupItems() {
|
||||
return getHandle().canPickUpLoot;
|
||||
}
|
||||
|
@ -444,6 +483,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
return super.teleport(location, cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (!(getHandle() instanceof EntityInsentient)) {
|
||||
return false;
|
||||
|
@ -451,6 +491,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
return ((EntityInsentient) getHandle()).getLeashHolder() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getLeashHolder() throws IllegalStateException {
|
||||
if (!isLeashed()) {
|
||||
throw new IllegalStateException("Entity not leashed");
|
||||
|
@ -466,6 +507,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setLeashHolder(Entity holder) {
|
||||
if ((getHandle() instanceof EntityWither) || !(getHandle() instanceof EntityInsentient)) {
|
||||
return false;
|
||||
|
|
|
@ -11,6 +11,7 @@ public class CraftMagmaCube extends CraftSlime implements MagmaCube {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityMagmaCube getHandle() {
|
||||
return (EntityMagmaCube) entity;
|
||||
}
|
||||
|
@ -20,6 +21,7 @@ public class CraftMagmaCube extends CraftSlime implements MagmaCube {
|
|||
return "CraftMagmaCube";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.MAGMA_CUBE;
|
||||
}
|
||||
|
|
|
@ -16,44 +16,54 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDamage(double damage) {
|
||||
getHandle().setDamage((float) damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDamage() {
|
||||
return getHandle().getDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxSpeed() {
|
||||
return getHandle().maxSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxSpeed(double speed) {
|
||||
if (speed >= 0D) {
|
||||
getHandle().maxSpeed = speed;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlowWhenEmpty() {
|
||||
return getHandle().slowWhenEmpty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlowWhenEmpty(boolean slow) {
|
||||
getHandle().slowWhenEmpty = slow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getFlyingVelocityMod() {
|
||||
return getHandle().getFlyingVelocityMod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlyingVelocityMod(Vector flying) {
|
||||
getHandle().setFlyingVelocityMod(flying);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getDerailedVelocityMod() {
|
||||
return getHandle().getDerailedVelocityMod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDerailedVelocityMod(Vector derailed) {
|
||||
getHandle().setDerailedVelocityMod(derailed);
|
||||
}
|
||||
|
@ -63,6 +73,7 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
|||
return (EntityMinecartAbstract) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayBlock(MaterialData material) {
|
||||
if(material != null) {
|
||||
IBlockData block = CraftMagicNumbers.getBlock(material);
|
||||
|
@ -86,6 +97,7 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialData getDisplayBlock() {
|
||||
IBlockData blockData = getHandle().getDisplayBlock();
|
||||
return CraftMagicNumbers.getMaterial(blockData);
|
||||
|
@ -97,10 +109,12 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
|||
return CraftBlockData.fromData(blockData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayBlockOffset(int offset) {
|
||||
getHandle().setDisplayBlockOffset(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayBlockOffset() {
|
||||
return getHandle().getDisplayBlockOffset();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ public class CraftMinecartChest extends CraftMinecartContainer implements Storag
|
|||
inventory = new CraftInventory(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
@ -25,6 +26,7 @@ public class CraftMinecartChest extends CraftMinecartContainer implements Storag
|
|||
return "CraftMinecartChest{" + "inventory=" + inventory + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.MINECART_CHEST;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ public class CraftMinecartFurnace extends CraftMinecart implements PoweredMineca
|
|||
return "CraftMinecartFurnace";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.MINECART_FURNACE;
|
||||
}
|
||||
|
|
|
@ -20,10 +20,12 @@ public final class CraftMinecartHopper extends CraftMinecartContainer implements
|
|||
return "CraftMinecartHopper{" + "inventory=" + inventory + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.MINECART_HOPPER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ final class CraftMinecartMobSpawner extends CraftMinecart implements SpawnerMine
|
|||
return "CraftMinecartMobSpawner";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.MINECART_MOB_SPAWNER;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ public class CraftMinecartRideable extends CraftMinecart implements RideableMine
|
|||
return "CraftMinecartRideable";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.MINECART;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMinecart
|
|||
return "CraftMinecartTNT";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.MINECART_TNT;
|
||||
}
|
||||
|
|
|
@ -15,10 +15,12 @@ public class CraftOcelot extends CraftAnimals implements Ocelot {
|
|||
return (EntityOcelot) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getCatType() {
|
||||
return Type.WILD_OCELOT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCatType(Type type) {
|
||||
throw new UnsupportedOperationException("Cats are now a different entity!");
|
||||
}
|
||||
|
|
|
@ -18,15 +18,18 @@ public class CraftPainting extends CraftHanging implements Painting {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Art getArt() {
|
||||
Paintings art = getHandle().art;
|
||||
return CraftArt.NotchToBukkit(art);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setArt(Art art) {
|
||||
return setArt(art, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setArt(Art art, boolean force) {
|
||||
EntityPainting painting = this.getHandle();
|
||||
Paintings oldArt = painting.art;
|
||||
|
@ -42,6 +45,7 @@ public class CraftPainting extends CraftHanging implements Painting {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setFacingDirection(BlockFace face, boolean force) {
|
||||
if (super.setFacingDirection(face, force)) {
|
||||
update();
|
||||
|
@ -73,6 +77,7 @@ public class CraftPainting extends CraftHanging implements Painting {
|
|||
return "CraftPainting{art=" + getArt() + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.PAINTING;
|
||||
}
|
||||
|
|
|
@ -10,14 +10,17 @@ public class CraftPig extends CraftAnimals implements Pig {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSaddle() {
|
||||
return getHandle().hasSaddle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaddle(boolean saddled) {
|
||||
getHandle().setSaddle(saddled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPig getHandle() {
|
||||
return (EntityPig) entity;
|
||||
}
|
||||
|
@ -27,6 +30,7 @@ public class CraftPig extends CraftAnimals implements Pig {
|
|||
return "CraftPig";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.PIG;
|
||||
}
|
||||
|
|
|
@ -11,18 +11,22 @@ public class CraftPigZombie extends CraftZombie implements PigZombie {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAnger() {
|
||||
return getHandle().angerLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnger(int level) {
|
||||
getHandle().angerLevel = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAngry(boolean angry) {
|
||||
setAnger(angry ? 400 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAngry() {
|
||||
return getAnger() > 0;
|
||||
}
|
||||
|
@ -37,6 +41,7 @@ public class CraftPigZombie extends CraftZombie implements PigZombie {
|
|||
return "CraftPigZombie";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.PIG_ZOMBIE;
|
||||
}
|
||||
|
|
|
@ -157,10 +157,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
perm.recalculatePermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return server.getPlayer(getUniqueId()) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getAddress() {
|
||||
if (getHandle().playerConnection == null) return null;
|
||||
|
||||
|
|
|
@ -11,10 +11,12 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectileSource getShooter() {
|
||||
return getHandle().projectileSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShooter(ProjectileSource shooter) {
|
||||
if (shooter instanceof CraftLivingEntity) {
|
||||
getHandle().shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity;
|
||||
|
|
|
@ -12,18 +12,22 @@ public class CraftSheep extends CraftAnimals implements Sheep {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DyeColor getColor() {
|
||||
return DyeColor.getByWoolData((byte) getHandle().getColor().getColorIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(DyeColor color) {
|
||||
getHandle().setColor(EnumColor.fromColorIndex(color.getWoolData()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSheared() {
|
||||
return getHandle().isSheared();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSheared(boolean flag) {
|
||||
getHandle().setSheared(flag);
|
||||
}
|
||||
|
@ -38,6 +42,7 @@ public class CraftSheep extends CraftAnimals implements Sheep {
|
|||
return "CraftSheep";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.SHEEP;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CraftSilverfish extends CraftMonster implements Silverfish {
|
|||
return "CraftSilverfish";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.SILVERFISH;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public class CraftSkeleton extends CraftMonster implements Skeleton {
|
|||
return "CraftSkeleton";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.SKELETON;
|
||||
}
|
||||
|
|
|
@ -11,10 +11,12 @@ public class CraftSlime extends CraftMob implements Slime {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return getHandle().getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(int size) {
|
||||
getHandle().setSize(size, true);
|
||||
}
|
||||
|
@ -29,6 +31,7 @@ public class CraftSlime extends CraftMob implements Slime {
|
|||
return "CraftSlime";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.SLIME;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CraftSmallFireball extends CraftFireball implements SmallFireball {
|
|||
return "CraftSmallFireball";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.SMALL_FIREBALL;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CraftSnowball extends CraftProjectile implements Snowball {
|
|||
return "CraftSnowball";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.SNOWBALL;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ public class CraftSnowman extends CraftGolem implements Snowman {
|
|||
return "CraftSnowman";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.SNOWMAN;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public class CraftSpider extends CraftMonster implements Spider {
|
|||
return "CraftSpider";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.SPIDER;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public class CraftSquid extends CraftWaterMob implements Squid {
|
|||
return "CraftSquid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.SQUID;
|
||||
}
|
||||
|
|
|
@ -13,26 +13,32 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getYield() {
|
||||
return getHandle().yield;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIncendiary() {
|
||||
return getHandle().isIncendiary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsIncendiary(boolean isIncendiary) {
|
||||
getHandle().isIncendiary = isIncendiary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setYield(float yield) {
|
||||
getHandle().yield = yield;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFuseTicks() {
|
||||
return getHandle().getFuseTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuseTicks(int fuseTicks) {
|
||||
getHandle().setFuseTicks(fuseTicks);
|
||||
}
|
||||
|
@ -47,10 +53,12 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed {
|
|||
return "CraftTNTPrimed";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.PRIMED_TNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getSource() {
|
||||
EntityLiving source = getHandle().getSource();
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat
|
|||
getHandle().setOwnerUUID(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnimalTamer getOwner() {
|
||||
if (getOwnerUUID() == null) {
|
||||
return null;
|
||||
|
@ -42,10 +43,12 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat
|
|||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTamed() {
|
||||
return getHandle().isTamed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwner(AnimalTamer tamer) {
|
||||
if (tamer != null) {
|
||||
setTamed(true);
|
||||
|
@ -57,6 +60,7 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTamed(boolean tame) {
|
||||
getHandle().setTamed(tame);
|
||||
if (!tame) {
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CraftThrownExpBottle extends CraftProjectile implements ThrownExpBo
|
|||
return "EntityThrownExpBottle";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.THROWN_EXP_BOTTLE;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CraftThrownPotion extends CraftProjectile implements ThrownPotion {
|
|||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PotionEffect> getEffects() {
|
||||
ImmutableList.Builder<PotionEffect> builder = ImmutableList.builder();
|
||||
for (MobEffect effect : PotionUtil.getEffects(getHandle().getItem())) {
|
||||
|
@ -28,6 +29,7 @@ public class CraftThrownPotion extends CraftProjectile implements ThrownPotion {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return CraftItemStack.asBukkitCopy(getHandle().getItem());
|
||||
}
|
||||
|
|
|
@ -25,14 +25,17 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
|
|||
return "CraftVillager";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.VILLAGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profession getProfession() {
|
||||
return Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(getHandle().getVillagerData().getProfession()).getKey().toUpperCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProfession(Profession profession) {
|
||||
Validate.notNull(profession);
|
||||
getHandle().setVillagerData(getHandle().getVillagerData().withProfession(IRegistry.VILLAGER_PROFESSION.get(new MinecraftKey(profession.name().toLowerCase(Locale.ROOT)))));
|
||||
|
|
|
@ -20,6 +20,7 @@ public class CraftWitch extends CraftRaider implements Witch {
|
|||
return "CraftWitch";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.WITCH;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public class CraftWither extends CraftMonster implements Wither {
|
|||
return "CraftWither";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.WITHER;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ public class CraftWitherSkull extends CraftFireball implements WitherSkull {
|
|||
return "CraftWitherSkull";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.WITHER_SKULL;
|
||||
}
|
||||
|
|
|
@ -12,10 +12,12 @@ public class CraftWolf extends CraftTameableAnimal implements Wolf {
|
|||
super(server, wolf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAngry() {
|
||||
return getHandle().isAngry();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAngry(boolean angry) {
|
||||
getHandle().setAngry(angry);
|
||||
}
|
||||
|
@ -30,10 +32,12 @@ public class CraftWolf extends CraftTameableAnimal implements Wolf {
|
|||
return EntityType.WOLF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DyeColor getCollarColor() {
|
||||
return DyeColor.getByWoolData((byte) getHandle().getCollarColor().getColorIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollarColor(DyeColor color) {
|
||||
getHandle().setCollarColor(EnumColor.fromColorIndex(color.getWoolData()));
|
||||
}
|
||||
|
|
|
@ -24,18 +24,22 @@ public class CraftZombie extends CraftMonster implements Zombie {
|
|||
return "CraftZombie";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.ZOMBIE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaby() {
|
||||
return getHandle().isBaby();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBaby(boolean flag) {
|
||||
getHandle().setBaby(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVillager() {
|
||||
return getHandle() instanceof EntityZombieVillager;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ public class CustomHelpTopic extends HelpTopic {
|
|||
this.fullText = shortText + "\n" + fullText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSee(CommandSender sender) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
return true;
|
||||
|
|
|
@ -34,6 +34,7 @@ public class MultipleCommandAliasHelpTopic extends HelpTopic {
|
|||
fullText = ChatColor.GOLD + "Alias for: " + ChatColor.WHITE + getShortText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSee(CommandSender sender) {
|
||||
if (amendedPermission == null) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.bukkit.help.HelpTopicFactory;
|
|||
*/
|
||||
public class MultipleCommandAliasHelpTopicFactory implements HelpTopicFactory<MultipleCommandAlias> {
|
||||
|
||||
@Override
|
||||
public HelpTopic createTopic(MultipleCommandAlias multipleCommandAlias) {
|
||||
return new MultipleCommandAliasHelpTopic(multipleCommandAlias);
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ public class SimpleHelpMap implements HelpMap {
|
|||
registerHelpTopicFactory(MultipleCommandAlias.class, new MultipleCommandAliasHelpTopicFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized HelpTopic getHelpTopic(String topicName) {
|
||||
if (topicName.equals("")) {
|
||||
return defaultTopic;
|
||||
|
@ -66,10 +67,12 @@ public class SimpleHelpMap implements HelpMap {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<HelpTopic> getHelpTopics() {
|
||||
return helpTopics.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addTopic(HelpTopic topic) {
|
||||
// Existing topics take priority
|
||||
if (!helpTopics.containsKey(topic.getName())) {
|
||||
|
@ -77,10 +80,12 @@ public class SimpleHelpMap implements HelpMap {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void clear() {
|
||||
helpTopics.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getIgnoredPlugins() {
|
||||
return yaml.getIgnoredPlugins();
|
||||
}
|
||||
|
@ -216,6 +221,7 @@ public class SimpleHelpMap implements HelpMap {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHelpTopicFactory(Class commandClass, HelpTopicFactory factory) {
|
||||
if (!Command.class.isAssignableFrom(commandClass) && !CommandExecutor.class.isAssignableFrom(commandClass)) {
|
||||
throw new IllegalArgumentException("commandClass must implement either Command or CommandExecutor!");
|
||||
|
@ -225,6 +231,7 @@ public class SimpleHelpMap implements HelpMap {
|
|||
|
||||
private class IsCommandTopicPredicate implements Predicate<HelpTopic> {
|
||||
|
||||
@Override
|
||||
public boolean apply(HelpTopic topic) {
|
||||
return topic.getName().charAt(0) == '/';
|
||||
}
|
||||
|
|
|
@ -45,38 +45,47 @@ public class CraftEntityEquipment implements EntityEquipment {
|
|||
setItemInMainHand(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getHelmet() {
|
||||
return getEquipment(EnumItemSlot.HEAD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHelmet(ItemStack helmet) {
|
||||
setEquipment(EnumItemSlot.HEAD, helmet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getChestplate() {
|
||||
return getEquipment(EnumItemSlot.CHEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChestplate(ItemStack chestplate) {
|
||||
setEquipment(EnumItemSlot.CHEST, chestplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getLeggings() {
|
||||
return getEquipment(EnumItemSlot.LEGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeggings(ItemStack leggings) {
|
||||
setEquipment(EnumItemSlot.LEGS, leggings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getBoots() {
|
||||
return getEquipment(EnumItemSlot.FEET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoots(ItemStack boots) {
|
||||
setEquipment(EnumItemSlot.FEET, boots);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getArmorContents() {
|
||||
ItemStack[] armor = new ItemStack[]{
|
||||
getEquipment(EnumItemSlot.FEET),
|
||||
|
@ -87,6 +96,7 @@ public class CraftEntityEquipment implements EntityEquipment {
|
|||
return armor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setArmorContents(ItemStack[] items) {
|
||||
setEquipment(EnumItemSlot.FEET, items.length >= 1 ? items[0] : null);
|
||||
setEquipment(EnumItemSlot.LEGS, items.length >= 2 ? items[1] : null);
|
||||
|
@ -102,12 +112,14 @@ public class CraftEntityEquipment implements EntityEquipment {
|
|||
entity.getHandle().setSlot(slot, CraftItemStack.asNMSCopy(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
||||
setEquipment(slot, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getHolder() {
|
||||
return entity;
|
||||
}
|
||||
|
@ -142,34 +154,42 @@ public class CraftEntityEquipment implements EntityEquipment {
|
|||
setDropChance(EnumItemSlot.OFFHAND, chance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHelmetDropChance() {
|
||||
return getDropChance(EnumItemSlot.HEAD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHelmetDropChance(float chance) {
|
||||
setDropChance(EnumItemSlot.HEAD, chance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChestplateDropChance() {
|
||||
return getDropChance(EnumItemSlot.CHEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChestplateDropChance(float chance) {
|
||||
setDropChance(EnumItemSlot.CHEST, chance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLeggingsDropChance() {
|
||||
return getDropChance(EnumItemSlot.LEGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeggingsDropChance(float chance) {
|
||||
setDropChance(EnumItemSlot.LEGS, chance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBootsDropChance() {
|
||||
return getDropChance(EnumItemSlot.FEET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBootsDropChance(float chance) {
|
||||
setDropChance(EnumItemSlot.FEET, chance);
|
||||
}
|
||||
|
|
|
@ -40,10 +40,12 @@ public class CraftInventory implements Inventory {
|
|||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return getInventory().getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(int index) {
|
||||
net.minecraft.server.ItemStack item = getInventory().getItem(index);
|
||||
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
|
||||
|
@ -71,12 +73,14 @@ public class CraftInventory implements Inventory {
|
|||
setContents(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getContents() {
|
||||
List<net.minecraft.server.ItemStack> mcItems = getInventory().getContents();
|
||||
|
||||
return asCraftMirror(mcItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContents(ItemStack[] items) {
|
||||
if (getSize() < items.length) {
|
||||
throw new IllegalArgumentException("Invalid inventory size; expected " + getSize() + " or less");
|
||||
|
@ -91,10 +95,12 @@ public class CraftInventory implements Inventory {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(int index, ItemStack item) {
|
||||
getInventory().setItem(index, CraftItemStack.asNMSCopy(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Material material) {
|
||||
Validate.notNull(material, "Material cannot be null");
|
||||
material = CraftLegacy.fromLegacy(material);
|
||||
|
@ -106,6 +112,7 @@ public class CraftInventory implements Inventory {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ItemStack item) {
|
||||
if (item == null) {
|
||||
return false;
|
||||
|
@ -118,6 +125,7 @@ public class CraftInventory implements Inventory {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Material material, int amount) {
|
||||
Validate.notNull(material, "Material cannot be null");
|
||||
material = CraftLegacy.fromLegacy(material);
|
||||
|
@ -134,6 +142,7 @@ public class CraftInventory implements Inventory {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ItemStack item, int amount) {
|
||||
if (item == null) {
|
||||
return false;
|
||||
|
@ -149,6 +158,7 @@ public class CraftInventory implements Inventory {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAtLeast(ItemStack item, int amount) {
|
||||
if (item == null) {
|
||||
return false;
|
||||
|
@ -164,6 +174,7 @@ public class CraftInventory implements Inventory {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ItemStack> all(Material material) {
|
||||
Validate.notNull(material, "Material cannot be null");
|
||||
material = CraftLegacy.fromLegacy(material);
|
||||
|
@ -179,6 +190,7 @@ public class CraftInventory implements Inventory {
|
|||
return slots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ItemStack> all(ItemStack item) {
|
||||
HashMap<Integer, ItemStack> slots = new HashMap<Integer, ItemStack>();
|
||||
if (item != null) {
|
||||
|
@ -192,6 +204,7 @@ public class CraftInventory implements Inventory {
|
|||
return slots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int first(Material material) {
|
||||
Validate.notNull(material, "Material cannot be null");
|
||||
material = CraftLegacy.fromLegacy(material);
|
||||
|
@ -205,6 +218,7 @@ public class CraftInventory implements Inventory {
|
|||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int first(ItemStack item) {
|
||||
return first(item, true);
|
||||
}
|
||||
|
@ -224,6 +238,7 @@ public class CraftInventory implements Inventory {
|
|||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int firstEmpty() {
|
||||
ItemStack[] inventory = getStorageContents();
|
||||
for (int i = 0; i < inventory.length; i++) {
|
||||
|
@ -262,6 +277,7 @@ public class CraftInventory implements Inventory {
|
|||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ItemStack> addItem(ItemStack... items) {
|
||||
Validate.noNullElements(items, "Item cannot be null");
|
||||
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
|
@ -327,6 +343,7 @@ public class CraftInventory implements Inventory {
|
|||
return leftover;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ItemStack> removeItem(ItemStack... items) {
|
||||
Validate.notNull(items, "Items cannot be null");
|
||||
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
|
@ -374,6 +391,7 @@ public class CraftInventory implements Inventory {
|
|||
return getInventory().getMaxStackSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Material material) {
|
||||
Validate.notNull(material, "Material cannot be null");
|
||||
material = CraftLegacy.fromLegacy(material);
|
||||
|
@ -385,6 +403,7 @@ public class CraftInventory implements Inventory {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(ItemStack item) {
|
||||
ItemStack[] items = getStorageContents();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
|
@ -394,20 +413,24 @@ public class CraftInventory implements Inventory {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(int index) {
|
||||
setItem(index, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
for (int i = 0; i < getSize(); i++) {
|
||||
clear(i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<ItemStack> iterator() {
|
||||
return new InventoryIterator(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<ItemStack> iterator(int index) {
|
||||
if (index < 0) {
|
||||
index += getSize() + 1; // ie, with -1, previous() will return the last element
|
||||
|
@ -415,10 +438,12 @@ public class CraftInventory implements Inventory {
|
|||
return new InventoryIterator(this, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HumanEntity> getViewers() {
|
||||
return this.inventory.getViewers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryType getType() {
|
||||
// Thanks to Droppers extending Dispensers, Blast Furnaces & Smokers extending Furnace, order is important.
|
||||
if (inventory instanceof InventoryCrafting) {
|
||||
|
@ -470,14 +495,17 @@ public class CraftInventory implements Inventory {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryHolder getHolder() {
|
||||
return inventory.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
return inventory.getMaxStackSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxStackSize(int size) {
|
||||
inventory.setMaxStackSize(size);
|
||||
}
|
||||
|
|
|
@ -9,10 +9,12 @@ public class CraftInventoryBeacon extends CraftInventory implements BeaconInvent
|
|||
super(beacon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(ItemStack item) {
|
||||
setItem(0, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return getItem(0);
|
||||
}
|
||||
|
|
|
@ -10,10 +10,12 @@ public class CraftInventoryBrewer extends CraftInventory implements BrewerInvent
|
|||
super(inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIngredient() {
|
||||
return getItem(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredient(ItemStack ingredient) {
|
||||
setItem(3, ingredient);
|
||||
}
|
||||
|
|
|
@ -81,18 +81,21 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getMatrix() {
|
||||
List<net.minecraft.server.ItemStack> matrix = getMatrixInventory().getContents();
|
||||
|
||||
return asCraftMirror(matrix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getResult() {
|
||||
net.minecraft.server.ItemStack item = getResultInventory().getItem(0);
|
||||
if (!item.isEmpty()) return CraftItemStack.asCraftMirror(item);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMatrix(ItemStack[] contents) {
|
||||
if (getMatrixInventory().getSize() > contents.length) {
|
||||
throw new IllegalArgumentException("Invalid inventory size; expected " + getMatrixInventory().getSize() + " or less");
|
||||
|
@ -107,11 +110,13 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResult(ItemStack item) {
|
||||
List<net.minecraft.server.ItemStack> contents = getResultInventory().getContents();
|
||||
contents.set(0, CraftItemStack.asNMSCopy(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Recipe getRecipe() {
|
||||
IRecipe recipe = getInventory().getCurrentRecipe();
|
||||
return recipe == null ? null : recipe.toBukkitRecipe();
|
||||
|
|
|
@ -62,14 +62,17 @@ public class CraftInventoryCustom extends CraftInventory {
|
|||
this.type = InventoryType.CHEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(int i) {
|
||||
return items.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack splitStack(int i, int j) {
|
||||
ItemStack stack = this.getItem(i);
|
||||
ItemStack result;
|
||||
|
@ -85,6 +88,7 @@ public class CraftInventoryCustom extends CraftInventory {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack splitWithoutUpdate(int i) {
|
||||
ItemStack stack = this.getItem(i);
|
||||
ItemStack result;
|
||||
|
@ -99,6 +103,7 @@ public class CraftInventoryCustom extends CraftInventory {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(int i, ItemStack itemstack) {
|
||||
items.set(i, itemstack);
|
||||
if (itemstack != ItemStack.a && this.getMaxStackSize() > 0 && itemstack.getCount() > this.getMaxStackSize()) {
|
||||
|
@ -106,32 +111,40 @@ public class CraftInventoryCustom extends CraftInventory {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
return maxStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxStackSize(int size) {
|
||||
maxStack = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {}
|
||||
|
||||
@Override
|
||||
public boolean a(EntityHuman entityhuman) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getContents() {
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen(CraftHumanEntity who) {
|
||||
viewers.add(who);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(CraftHumanEntity who) {
|
||||
viewers.remove(who);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HumanEntity> getViewers() {
|
||||
return viewers;
|
||||
}
|
||||
|
@ -140,10 +153,12 @@ public class CraftInventoryCustom extends CraftInventory {
|
|||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryHolder getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean b(int i, ItemStack itemstack) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -31,10 +31,12 @@ public class CraftInventoryDoubleChest extends CraftInventory implements DoubleC
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getLeftSide() {
|
||||
return left;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getRightSide() {
|
||||
return right;
|
||||
}
|
||||
|
|
|
@ -10,26 +10,32 @@ public class CraftInventoryFurnace extends CraftInventory implements FurnaceInve
|
|||
super(inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getResult() {
|
||||
return getItem(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getFuel() {
|
||||
return getItem(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSmelting() {
|
||||
return getItem(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuel(ItemStack stack) {
|
||||
setItem(1,stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResult(ItemStack stack) {
|
||||
setItem(2,stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSmelting(ItemStack stack) {
|
||||
setItem(0,stack);
|
||||
}
|
||||
|
|
|
@ -10,10 +10,12 @@ public class CraftInventoryHorse extends CraftInventoryAbstractHorse implements
|
|||
super(inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getArmor() {
|
||||
return getItem(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setArmor(ItemStack stack) {
|
||||
setItem(1, stack);
|
||||
}
|
||||
|
|
|
@ -102,48 +102,59 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i
|
|||
player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.defaultContainer.windowId, index, CraftItemStack.asNMSCopy(item)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeldItemSlot() {
|
||||
return getInventory().itemInHandIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeldItemSlot(int slot) {
|
||||
Validate.isTrue(slot >= 0 && slot < PlayerInventory.getHotbarSize(), "Slot is not between 0 and 8 inclusive");
|
||||
this.getInventory().itemInHandIndex = slot;
|
||||
((CraftPlayer) this.getHolder()).getHandle().playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(slot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getHelmet() {
|
||||
return getItem(getSize() - 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getChestplate() {
|
||||
return getItem(getSize() - 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getLeggings() {
|
||||
return getItem(getSize() - 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getBoots() {
|
||||
return getItem(getSize() - 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHelmet(ItemStack helmet) {
|
||||
setItem(getSize() - 2, helmet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChestplate(ItemStack chestplate) {
|
||||
setItem(getSize() - 3, chestplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeggings(ItemStack leggings) {
|
||||
setItem(getSize() - 4, leggings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoots(ItemStack boots) {
|
||||
setItem(getSize() - 5, boots);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getArmorContents() {
|
||||
return asCraftMirror(getInventory().armor);
|
||||
}
|
||||
|
@ -218,34 +229,42 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i
|
|||
throw new UnsupportedOperationException("Cannot set drop chance for PlayerInventory");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHelmetDropChance() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHelmetDropChance(float chance) {
|
||||
throw new UnsupportedOperationException("Cannot set drop chance for PlayerInventory");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChestplateDropChance() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChestplateDropChance(float chance) {
|
||||
throw new UnsupportedOperationException("Cannot set drop chance for PlayerInventory");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLeggingsDropChance() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeggingsDropChance(float chance) {
|
||||
throw new UnsupportedOperationException("Cannot set drop chance for PlayerInventory");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBootsDropChance() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBootsDropChance(float chance) {
|
||||
throw new UnsupportedOperationException("Cannot set drop chance for PlayerInventory");
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ public final class CraftItemFactory implements ItemFactory {
|
|||
private CraftItemFactory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(ItemMeta meta, ItemStack itemstack) {
|
||||
if (itemstack == null) {
|
||||
return false;
|
||||
|
@ -46,6 +47,7 @@ public final class CraftItemFactory implements ItemFactory {
|
|||
return isApplicable(meta, itemstack.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(ItemMeta meta, Material type) {
|
||||
type = CraftLegacy.fromLegacy(type); // This may be called from legacy item stacks, try to get the right material
|
||||
if (type == null || meta == null) {
|
||||
|
@ -58,6 +60,7 @@ public final class CraftItemFactory implements ItemFactory {
|
|||
return ((CraftMetaItem) meta).applicableTo(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemMeta getItemMeta(Material material) {
|
||||
Validate.notNull(material, "Material cannot be null");
|
||||
return getItemMeta(material, null);
|
||||
|
@ -254,6 +257,7 @@ public final class CraftItemFactory implements ItemFactory {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(ItemMeta meta1, ItemMeta meta2) {
|
||||
if (meta1 == meta2) {
|
||||
return true;
|
||||
|
@ -291,11 +295,13 @@ public final class CraftItemFactory implements ItemFactory {
|
|||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemMeta asMetaFor(ItemMeta meta, ItemStack stack) {
|
||||
Validate.notNull(stack, "Stack cannot be null");
|
||||
return asMetaFor(meta, stack.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemMeta asMetaFor(ItemMeta meta, Material material) {
|
||||
Validate.notNull(material, "Material cannot be null");
|
||||
if (!(meta instanceof CraftMetaItem)) {
|
||||
|
@ -304,6 +310,7 @@ public final class CraftItemFactory implements ItemFactory {
|
|||
return getItemMeta(material, (CraftMetaItem) meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getDefaultLeatherColor() {
|
||||
return DEFAULT_LEATHER_COLOR;
|
||||
}
|
||||
|
|
|
@ -161,26 +161,32 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAuthor() {
|
||||
return !Strings.isNullOrEmpty(author);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTitle() {
|
||||
return !Strings.isNullOrEmpty(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPages() {
|
||||
return !pages.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGeneration() {
|
||||
return generation != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setTitle(final String title) {
|
||||
if (title == null) {
|
||||
this.title = null;
|
||||
|
@ -193,10 +199,12 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
return this.author;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAuthor(final String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
@ -211,11 +219,13 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|||
this.generation = (generation == null) ? null : generation.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPage(final int page) {
|
||||
Validate.isTrue(isValidPage(page), "Invalid page number");
|
||||
return CraftChatMessage.fromComponent(pages.get(page - 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPage(final int page, final String text) {
|
||||
if (!isValidPage(page)) {
|
||||
throw new IllegalArgumentException("Invalid page number " + page + "/" + pages.size());
|
||||
|
@ -225,12 +235,14 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|||
pages.set(page - 1, CraftChatMessage.fromString(newText, true)[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPages(final String... pages) {
|
||||
this.pages.clear();
|
||||
|
||||
addPage(pages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPage(final String... pages) {
|
||||
for (String page : pages) {
|
||||
if (this.pages.size() >= MAX_PAGES) {
|
||||
|
@ -247,14 +259,17 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPageCount() {
|
||||
return pages.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPages() {
|
||||
return pages.stream().map(CraftChatMessage::fromComponent).collect(ImmutableList.toImmutableList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPages(List<String> pages) {
|
||||
this.pages.clear();
|
||||
for (String page : pages) {
|
||||
|
|
|
@ -123,10 +123,12 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage
|
|||
return !hasStoredEnchants();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasStoredEnchant(Enchantment ench) {
|
||||
return hasStoredEnchants() && enchantments.containsKey(ench);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredEnchantLevel(Enchantment ench) {
|
||||
Integer level = hasStoredEnchants() ? enchantments.get(ench) : null;
|
||||
if (level == null) {
|
||||
|
@ -135,10 +137,12 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage
|
|||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Enchantment, Integer> getStoredEnchants() {
|
||||
return hasStoredEnchants() ? ImmutableMap.copyOf(enchantments) : ImmutableMap.<Enchantment, Integer>of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addStoredEnchant(Enchantment ench, int level, boolean ignoreRestrictions) {
|
||||
if (enchantments == null) {
|
||||
enchantments = new HashMap<Enchantment, Integer>(4);
|
||||
|
@ -151,14 +155,17 @@ class CraftMetaEnchantedBook extends CraftMetaItem implements EnchantmentStorage
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeStoredEnchant(Enchantment ench) {
|
||||
return hasStoredEnchants() && enchantments.remove(ench) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasStoredEnchants() {
|
||||
return !(enchantments == null || enchantments.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConflictingStoredEnchant(Enchantment ench) {
|
||||
return checkConflictingEnchants(enchantments, ench);
|
||||
}
|
||||
|
|
|
@ -184,6 +184,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta {
|
|||
safelyAddEffects(effects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffects() {
|
||||
return !(effects == null || effects.isEmpty());
|
||||
}
|
||||
|
@ -330,6 +331,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta {
|
|||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEffect(FireworkEffect effect) {
|
||||
Validate.notNull(effect, "Effect cannot be null");
|
||||
if (this.effects == null) {
|
||||
|
@ -338,6 +340,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta {
|
|||
this.effects.add(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEffects(FireworkEffect...effects) {
|
||||
Validate.notNull(effects, "Effects cannot be null");
|
||||
if (effects.length == 0) {
|
||||
|
@ -355,19 +358,23 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEffects(Iterable<FireworkEffect> effects) {
|
||||
Validate.notNull(effects, "Effects cannot be null");
|
||||
safelyAddEffects(effects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FireworkEffect> getEffects() {
|
||||
return this.effects == null ? ImmutableList.<FireworkEffect>of() : ImmutableList.copyOf(this.effects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEffectsSize() {
|
||||
return this.effects == null ? 0 : this.effects.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEffect(int index) {
|
||||
if (this.effects == null) {
|
||||
throw new IndexOutOfBoundsException("Index: " + index + ", Size: 0");
|
||||
|
@ -376,14 +383,17 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearEffects() {
|
||||
this.effects = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPower() {
|
||||
return this.power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(int power) {
|
||||
Validate.isTrue(power >= 0, "Power cannot be less than zero: ", power);
|
||||
Validate.isTrue(power < 0x80, "Power cannot be more than 127: ", power);
|
||||
|
|
|
@ -191,6 +191,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
@ -747,14 +748,17 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|||
return !(hasDisplayName() || hasLocalizedName() || hasEnchants() || hasLore() || hasCustomModelData() || hasBlockData() || hasRepairCost() || !unhandledTags.isEmpty() || !persistentDataContainer.isEmpty() || hideFlag != 0 || isUnbreakable() || hasDamage() || hasAttributeModifiers());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return CraftChatMessage.fromComponent(displayName, EnumChatFormat.WHITE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setDisplayName(String name) {
|
||||
this.displayName = CraftChatMessage.wrapOrNull(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDisplayName() {
|
||||
return displayName != null;
|
||||
}
|
||||
|
@ -774,19 +778,23 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|||
return locName != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLore() {
|
||||
return this.lore != null && !this.lore.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRepairCost() {
|
||||
return repairCost > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEnchant(Enchantment ench) {
|
||||
Validate.notNull(ench, "Enchantment cannot be null");
|
||||
return hasEnchants() && enchantments.containsKey(ench);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantLevel(Enchantment ench) {
|
||||
Validate.notNull(ench, "Enchantment cannot be null");
|
||||
Integer level = hasEnchants() ? enchantments.get(ench) : null;
|
||||
|
@ -796,10 +804,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Enchantment, Integer> getEnchants() {
|
||||
return hasEnchants() ? ImmutableMap.copyOf(enchantments) : ImmutableMap.<Enchantment, Integer>of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addEnchant(Enchantment ench, int level, boolean ignoreRestrictions) {
|
||||
Validate.notNull(ench, "Enchantment cannot be null");
|
||||
if (enchantments == null) {
|
||||
|
@ -813,15 +823,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeEnchant(Enchantment ench) {
|
||||
Validate.notNull(ench, "Enchantment cannot be null");
|
||||
return hasEnchants() && enchantments.remove(ench) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEnchants() {
|
||||
return !(enchantments == null || enchantments.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConflictingEnchant(Enchantment ench) {
|
||||
return checkConflictingEnchants(enchantments, ench);
|
||||
}
|
||||
|
@ -863,10 +876,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|||
return (byte) (1 << hideFlag.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return this.lore == null ? null : new ArrayList<String>(Lists.transform(this.lore, (line) -> CraftChatMessage.fromComponent(line, EnumChatFormat.DARK_PURPLE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLore(List<String> lore) { // too tired to think if .clone is better
|
||||
if (lore == null) {
|
||||
this.lore = null;
|
||||
|
@ -911,10 +926,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|||
this.blockData = (blockData == null) ? null : ((CraftBlockData) blockData).toStates();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRepairCost() {
|
||||
return repairCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRepairCost(int cost) { // TODO: Does this have limits?
|
||||
repairCost = cost;
|
||||
}
|
||||
|
@ -1182,6 +1199,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Map<String, Object> serialize() {
|
||||
ImmutableMap.Builder<String, Object> map = ImmutableMap.builder();
|
||||
map.put(SerializableMeta.TYPE_FIELD, SerializableMeta.classMap.get(getClass()));
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue