mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-10 09:34:43 +02:00
Major code reformatting
This commit is contained in:
@ -1,40 +1,39 @@
|
||||
package com.plotsquared.bukkit.object;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import com.intellectualcrafters.plot.object.LazyBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public class BukkitLazyBlock extends LazyBlock {
|
||||
|
||||
|
||||
private int id;
|
||||
private Block block;
|
||||
private PlotBlock pb;
|
||||
|
||||
public BukkitLazyBlock(final int id, final Block block) {
|
||||
|
||||
public BukkitLazyBlock(int id, Block block) {
|
||||
this.id = id;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public BukkitLazyBlock(final PlotBlock pb) {
|
||||
id = pb.id;
|
||||
|
||||
public BukkitLazyBlock(PlotBlock pb) {
|
||||
this.id = pb.id;
|
||||
this.pb = pb;
|
||||
}
|
||||
|
||||
public BukkitLazyBlock(final Block block) {
|
||||
|
||||
public BukkitLazyBlock(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PlotBlock getPlotBlock() {
|
||||
if (pb != null) {
|
||||
return pb;
|
||||
if (this.pb != null) {
|
||||
return this.pb;
|
||||
}
|
||||
if (id == 0) {
|
||||
id = block.getTypeId();
|
||||
if (this.id == 0) {
|
||||
this.id = this.block.getTypeId();
|
||||
}
|
||||
byte data;
|
||||
switch (id) {
|
||||
switch (this.id) {
|
||||
case 0:
|
||||
case 2:
|
||||
case 4:
|
||||
@ -120,20 +119,20 @@ public class BukkitLazyBlock extends LazyBlock {
|
||||
data = 0;
|
||||
break;
|
||||
default:
|
||||
data = block.getData();
|
||||
data = this.block.getData();
|
||||
break;
|
||||
}
|
||||
pb = new PlotBlock((short) id, data);
|
||||
return pb;
|
||||
|
||||
this.pb = new PlotBlock((short) this.id, data);
|
||||
return this.pb;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
if (id == 0) {
|
||||
id = block.getTypeId();
|
||||
if (this.id == 0) {
|
||||
this.id = this.block.getTypeId();
|
||||
}
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
package com.plotsquared.bukkit.object;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitOfflinePlayer implements OfflinePlotPlayer {
|
||||
|
||||
@ -14,27 +13,27 @@ public class BukkitOfflinePlayer implements OfflinePlotPlayer {
|
||||
* Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects.
|
||||
* @param player
|
||||
*/
|
||||
public BukkitOfflinePlayer(final OfflinePlayer player) {
|
||||
public BukkitOfflinePlayer(OfflinePlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return player.getUniqueId();
|
||||
return this.player.getUniqueId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastPlayed() {
|
||||
return player.getLastPlayed();
|
||||
return this.player.getLastPlayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return player.isOnline();
|
||||
return this.player.isOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return player.getName();
|
||||
return this.player.getName();
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.PlotGamemode;
|
||||
import com.intellectualcrafters.plot.util.PlotGameMode;
|
||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
@ -31,12 +31,12 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
* Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects.
|
||||
* @param player
|
||||
*/
|
||||
public BukkitPlayer(final Player player) {
|
||||
public BukkitPlayer(Player player) {
|
||||
this.player = player;
|
||||
super.populatePersistentMetaMap();
|
||||
}
|
||||
|
||||
public BukkitPlayer(final Player player, final boolean offline) {
|
||||
|
||||
public BukkitPlayer(Player player, boolean offline) {
|
||||
this.player = player;
|
||||
this.offline = offline;
|
||||
super.populatePersistentMetaMap();
|
||||
@ -44,45 +44,45 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
|
||||
@Override
|
||||
public long getPreviousLogin() {
|
||||
if (last == 0) {
|
||||
last = player.getLastPlayed();
|
||||
if (this.last == 0) {
|
||||
this.last = this.player.getLastPlayed();
|
||||
}
|
||||
return last;
|
||||
return this.last;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
final Location loc = super.getLocation();
|
||||
return loc == null ? BukkitUtil.getLocation(player) : loc;
|
||||
Location location = super.getLocation();
|
||||
return location == null ? BukkitUtil.getLocation(this.player) : location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
if (uuid == null) {
|
||||
uuid = UUIDHandler.getUUID(this);
|
||||
if (this.uuid == null) {
|
||||
this.uuid = UUIDHandler.getUUID(this);
|
||||
}
|
||||
return uuid;
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String node) {
|
||||
if (offline && EconHandler.manager != null) {
|
||||
return EconHandler.manager.hasPermission(getName(), node);
|
||||
public boolean hasPermission(String permission) {
|
||||
if (this.offline && EconHandler.manager != null) {
|
||||
return EconHandler.manager.hasPermission(getName(), permission);
|
||||
}
|
||||
return player.hasPermission(node);
|
||||
return this.player.hasPermission(permission);
|
||||
}
|
||||
|
||||
public Permission getPermission(final String node) {
|
||||
final PluginManager manager = Bukkit.getPluginManager();
|
||||
|
||||
public Permission getPermission(String node) {
|
||||
PluginManager manager = Bukkit.getPluginManager();
|
||||
Permission perm = manager.getPermission(node);
|
||||
if (perm == null) {
|
||||
final String[] nodes = node.split("\\.");
|
||||
String[] nodes = node.split("\\.");
|
||||
perm = new Permission(node);
|
||||
final StringBuilder n = new StringBuilder();
|
||||
StringBuilder n = new StringBuilder();
|
||||
for (int i = 0; i < nodes.length - 1; i++) {
|
||||
n.append(nodes[i]).append(".");
|
||||
if (!node.equals(n + C.PERMISSION_STAR.s())) {
|
||||
final Permission parent = getPermission(n + C.PERMISSION_STAR.s());
|
||||
Permission parent = getPermission(n + C.PERMISSION_STAR.s());
|
||||
if (parent != null) {
|
||||
perm.addParent(parent, true);
|
||||
}
|
||||
@ -96,134 +96,125 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(final String message) {
|
||||
player.sendMessage(message);
|
||||
public void sendMessage(String message) {
|
||||
this.player.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(final Location loc) {
|
||||
if (Math.abs(loc.getX()) >= 30000000 || Math.abs(loc.getZ()) >= 30000000) {
|
||||
public void teleport(Location location) {
|
||||
if (Math.abs(location.getX()) >= 30000000 || Math.abs(location.getZ()) >= 30000000) {
|
||||
return;
|
||||
}
|
||||
player.teleport(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX() + 0.5, loc.getY(), loc.getZ() + 0.5, loc.getYaw(), loc.getPitch()), TeleportCause.COMMAND);
|
||||
this.player.teleport(
|
||||
new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX() + 0.5, location.getY(), location.getZ() + 0.5,
|
||||
location.getYaw(), location.getPitch()), TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (name == null) {
|
||||
name = player.getName();
|
||||
if (this.name == null) {
|
||||
this.name = this.player.getName();
|
||||
}
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return !offline && player.isOnline();
|
||||
return !this.offline && this.player.isOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompassTarget(final Location loc) {
|
||||
player.setCompassTarget(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ()));
|
||||
public void setCompassTarget(Location location) {
|
||||
this.player.setCompassTarget(
|
||||
new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocationFull() {
|
||||
return BukkitUtil.getLocationFull(player);
|
||||
return BukkitUtil.getLocationFull(this.player);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void loadData() {
|
||||
if (!player.isOnline()) {
|
||||
player.loadData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveData() {
|
||||
player.saveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeather(final PlotWeather weather) {
|
||||
public void setWeather(PlotWeather weather) {
|
||||
switch (weather) {
|
||||
case CLEAR:
|
||||
player.setPlayerWeather(WeatherType.CLEAR);
|
||||
this.player.setPlayerWeather(WeatherType.CLEAR);
|
||||
return;
|
||||
case RAIN:
|
||||
player.setPlayerWeather(WeatherType.DOWNFALL);
|
||||
this.player.setPlayerWeather(WeatherType.DOWNFALL);
|
||||
return;
|
||||
case RESET:
|
||||
player.resetPlayerWeather();
|
||||
this.player.resetPlayerWeather();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotGamemode getGamemode() {
|
||||
switch (player.getGameMode()) {
|
||||
public PlotGameMode getGameMode() {
|
||||
switch (this.player.getGameMode()) {
|
||||
case ADVENTURE:
|
||||
return PlotGamemode.ADVENTURE;
|
||||
return PlotGameMode.ADVENTURE;
|
||||
case CREATIVE:
|
||||
return PlotGamemode.CREATIVE;
|
||||
return PlotGameMode.CREATIVE;
|
||||
case SPECTATOR:
|
||||
return PlotGamemode.SPECTATOR;
|
||||
return PlotGameMode.SPECTATOR;
|
||||
case SURVIVAL:
|
||||
return PlotGamemode.SURVIVAL;
|
||||
return PlotGameMode.SURVIVAL;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGamemode(final PlotGamemode gamemode) {
|
||||
switch (gamemode) {
|
||||
public void setGameMode(PlotGameMode gameMode) {
|
||||
switch (gameMode) {
|
||||
case ADVENTURE:
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
this.player.setGameMode(GameMode.ADVENTURE);
|
||||
return;
|
||||
case CREATIVE:
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
this.player.setGameMode(GameMode.CREATIVE);
|
||||
return;
|
||||
case SPECTATOR:
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
this.player.setGameMode(GameMode.SPECTATOR);
|
||||
return;
|
||||
case SURVIVAL:
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
this.player.setGameMode(GameMode.SURVIVAL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTime(final long time) {
|
||||
public void setTime(long time) {
|
||||
if (time != Long.MAX_VALUE) {
|
||||
player.setPlayerTime(time, false);
|
||||
this.player.setPlayerTime(time, false);
|
||||
} else {
|
||||
player.resetPlayerTime();
|
||||
this.player.resetPlayerTime();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlight(final boolean fly) {
|
||||
player.setAllowFlight(fly);
|
||||
public void setFlight(boolean fly) {
|
||||
this.player.setAllowFlight(fly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playMusic(final Location loc, final int id) {
|
||||
player.playEffect(BukkitUtil.getLocation(loc), Effect.RECORD_PLAY, id);
|
||||
public void playMusic(Location location, int id) {
|
||||
this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kick(final String message) {
|
||||
player.kickPlayer(message);
|
||||
public void kick(String message) {
|
||||
this.player.kickPlayer(message);
|
||||
}
|
||||
|
||||
@Override public void stopSpectating() {
|
||||
if (getGamemode() == PlotGamemode.SPECTATOR) {
|
||||
player.setSpectatorTarget(null);
|
||||
if (getGameMode() == PlotGameMode.SPECTATOR) {
|
||||
this.player.setSpectatorTarget(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned() {
|
||||
return player.isBanned();
|
||||
return this.player.isBanned();
|
||||
}
|
||||
}
|
||||
|
@ -56,31 +56,31 @@ public class EntityWrapper {
|
||||
private ArmorStandStats stand;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public EntityWrapper(final org.bukkit.entity.Entity entity, final short depth) {
|
||||
hash = entity.getEntityId();
|
||||
public EntityWrapper(org.bukkit.entity.Entity entity, short depth) {
|
||||
this.hash = entity.getEntityId();
|
||||
this.depth = depth;
|
||||
final Location loc = entity.getLocation();
|
||||
yaw = loc.getYaw();
|
||||
pitch = loc.getPitch();
|
||||
x = loc.getX();
|
||||
y = loc.getY();
|
||||
z = loc.getZ();
|
||||
type = entity.getType();
|
||||
Location loc = entity.getLocation();
|
||||
this.yaw = loc.getYaw();
|
||||
this.pitch = loc.getPitch();
|
||||
this.x = loc.getX();
|
||||
this.y = loc.getY();
|
||||
this.z = loc.getZ();
|
||||
this.type = entity.getType();
|
||||
if (depth == 0) {
|
||||
return;
|
||||
}
|
||||
base = new EntityBaseStats();
|
||||
final Entity p = entity.getPassenger();
|
||||
this.base = new EntityBaseStats();
|
||||
Entity p = entity.getPassenger();
|
||||
if (p != null) {
|
||||
base.passenger = new EntityWrapper(p, depth);
|
||||
this.base.passenger = new EntityWrapper(p, depth);
|
||||
}
|
||||
base.fall = entity.getFallDistance();
|
||||
base.fire = (short) entity.getFireTicks();
|
||||
base.age = entity.getTicksLived();
|
||||
final Vector velocity = entity.getVelocity();
|
||||
base.v_x = velocity.getX();
|
||||
base.v_y = velocity.getY();
|
||||
base.v_z = velocity.getZ();
|
||||
this.base.fall = entity.getFallDistance();
|
||||
this.base.fire = (short) entity.getFireTicks();
|
||||
this.base.age = entity.getTicksLived();
|
||||
Vector velocity = entity.getVelocity();
|
||||
this.base.v_x = velocity.getX();
|
||||
this.base.v_y = velocity.getY();
|
||||
this.base.v_z = velocity.getZ();
|
||||
if (depth == 1) {
|
||||
return;
|
||||
}
|
||||
@ -123,31 +123,31 @@ public class EntityWrapper {
|
||||
}
|
||||
// MISC //
|
||||
case DROPPED_ITEM: {
|
||||
final Item item = (Item) entity;
|
||||
stack = item.getItemStack();
|
||||
Item item = (Item) entity;
|
||||
this.stack = item.getItemStack();
|
||||
return;
|
||||
}
|
||||
case ITEM_FRAME: {
|
||||
final ItemFrame itemframe = (ItemFrame) entity;
|
||||
x = Math.floor(x);
|
||||
y = Math.floor(y);
|
||||
z = Math.floor(z);
|
||||
dataByte = getOrdinal(Rotation.values(), itemframe.getRotation());
|
||||
stack = itemframe.getItem().clone();
|
||||
ItemFrame itemframe = (ItemFrame) entity;
|
||||
this.x = Math.floor(this.x);
|
||||
this.y = Math.floor(this.y);
|
||||
this.z = Math.floor(this.z);
|
||||
this.dataByte = getOrdinal(Rotation.values(), itemframe.getRotation());
|
||||
this.stack = itemframe.getItem().clone();
|
||||
return;
|
||||
}
|
||||
case PAINTING: {
|
||||
final Painting painting = (Painting) entity;
|
||||
x = Math.floor(x);
|
||||
y = Math.floor(y);
|
||||
z = Math.floor(z);
|
||||
final Art a = painting.getArt();
|
||||
dataByte = getOrdinal(BlockFace.values(), painting.getFacing());
|
||||
final int h = a.getBlockHeight();
|
||||
Painting painting = (Painting) entity;
|
||||
this.x = Math.floor(this.x);
|
||||
this.y = Math.floor(this.y);
|
||||
this.z = Math.floor(this.z);
|
||||
Art a = painting.getArt();
|
||||
this.dataByte = getOrdinal(BlockFace.values(), painting.getFacing());
|
||||
int h = a.getBlockHeight();
|
||||
if ((h % 2) == 0) {
|
||||
y -= 1;
|
||||
this.y -= 1;
|
||||
}
|
||||
dataString = a.name();
|
||||
this.dataString = a.name();
|
||||
return;
|
||||
}
|
||||
// END MISC //
|
||||
@ -161,7 +161,7 @@ public class EntityWrapper {
|
||||
// START AGEABLE //
|
||||
// START TAMEABLE //
|
||||
case HORSE: {
|
||||
final Horse horse = (Horse) entity;
|
||||
Horse horse = (Horse) entity;
|
||||
this.horse = new HorseStats();
|
||||
this.horse.jump = horse.getJumpStrength();
|
||||
this.horse.chest = horse.isCarryingChest();
|
||||
@ -184,9 +184,9 @@ public class EntityWrapper {
|
||||
}
|
||||
// END AMEABLE //
|
||||
case SHEEP: {
|
||||
final Sheep sheep = (Sheep) entity;
|
||||
dataByte = (byte) ((sheep).isSheared() ? 1 : 0);
|
||||
dataByte2 = sheep.getColor().getDyeData();
|
||||
Sheep sheep = (Sheep) entity;
|
||||
this.dataByte = (byte) (sheep.isSheared() ? 1 : 0);
|
||||
this.dataByte2 = sheep.getColor().getDyeData();
|
||||
storeAgeable((Ageable) entity);
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
@ -202,54 +202,55 @@ public class EntityWrapper {
|
||||
}
|
||||
// END AGEABLE //
|
||||
case RABBIT: { // NEW
|
||||
dataByte = getOrdinal(Type.values(), ((Rabbit) entity).getRabbitType());
|
||||
this.dataByte = getOrdinal(Type.values(), ((Rabbit) entity).getRabbitType());
|
||||
storeAgeable((Ageable) entity);
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
}
|
||||
case GUARDIAN: { // NEW
|
||||
dataByte = (byte) (((Guardian) entity).isElder() ? 1 : 0);
|
||||
this.dataByte = (byte) (((Guardian) entity).isElder() ? 1 : 0);
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
}
|
||||
case SKELETON: { // NEW
|
||||
dataByte = (byte) ((Skeleton) entity).getSkeletonType().getId();
|
||||
this.dataByte = (byte) ((Skeleton) entity).getSkeletonType().getId();
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
}
|
||||
case ARMOR_STAND: { // NEW
|
||||
// CHECK positions
|
||||
final ArmorStand stand = (ArmorStand) entity;
|
||||
inventory = new ItemStack[] { stand.getItemInHand().clone(), stand.getHelmet().clone(), stand.getChestplate().clone(), stand.getLeggings().clone(), stand.getBoots().clone() };
|
||||
ArmorStand stand = (ArmorStand) entity;
|
||||
this.inventory = new ItemStack[]{stand.getItemInHand().clone(), stand.getHelmet().clone(), stand.getChestplate().clone(),
|
||||
stand.getLeggings().clone(), stand.getBoots().clone()};
|
||||
storeLiving((LivingEntity) entity);
|
||||
this.stand = new ArmorStandStats();
|
||||
|
||||
final EulerAngle head = stand.getHeadPose();
|
||||
EulerAngle head = stand.getHeadPose();
|
||||
this.stand.head[0] = (float) head.getX();
|
||||
this.stand.head[1] = (float) head.getY();
|
||||
this.stand.head[2] = (float) head.getZ();
|
||||
|
||||
final EulerAngle body = stand.getBodyPose();
|
||||
EulerAngle body = stand.getBodyPose();
|
||||
this.stand.body[0] = (float) body.getX();
|
||||
this.stand.body[1] = (float) body.getY();
|
||||
this.stand.body[2] = (float) body.getZ();
|
||||
|
||||
final EulerAngle leftLeg = stand.getLeftLegPose();
|
||||
EulerAngle leftLeg = stand.getLeftLegPose();
|
||||
this.stand.leftLeg[0] = (float) leftLeg.getX();
|
||||
this.stand.leftLeg[1] = (float) leftLeg.getY();
|
||||
this.stand.leftLeg[2] = (float) leftLeg.getZ();
|
||||
|
||||
final EulerAngle rightLeg = stand.getRightLegPose();
|
||||
EulerAngle rightLeg = stand.getRightLegPose();
|
||||
this.stand.rightLeg[0] = (float) rightLeg.getX();
|
||||
this.stand.rightLeg[1] = (float) rightLeg.getY();
|
||||
this.stand.rightLeg[2] = (float) rightLeg.getZ();
|
||||
|
||||
final EulerAngle leftArm = stand.getLeftArmPose();
|
||||
EulerAngle leftArm = stand.getLeftArmPose();
|
||||
this.stand.leftArm[0] = (float) leftArm.getX();
|
||||
this.stand.leftArm[1] = (float) leftArm.getY();
|
||||
this.stand.leftArm[2] = (float) leftArm.getZ();
|
||||
|
||||
final EulerAngle rightArm = stand.getRightArmPose();
|
||||
EulerAngle rightArm = stand.getRightArmPose();
|
||||
this.stand.rightArm[0] = (float) rightArm.getX();
|
||||
this.stand.rightArm[1] = (float) rightArm.getY();
|
||||
this.stand.rightArm[2] = (float) rightArm.getZ();
|
||||
@ -298,39 +299,39 @@ public class EntityWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
return hash == obj.hashCode();
|
||||
public boolean equals(Object obj) {
|
||||
return this.hash == obj.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hash;
|
||||
return this.hash;
|
||||
}
|
||||
|
||||
public void storeInventory(final InventoryHolder held) {
|
||||
inventory = held.getInventory().getContents().clone();
|
||||
public void storeInventory(InventoryHolder held) {
|
||||
this.inventory = held.getInventory().getContents().clone();
|
||||
}
|
||||
|
||||
private void restoreLiving(final LivingEntity entity) {
|
||||
entity.setCanPickupItems(lived.loot);
|
||||
if (lived.name != null) {
|
||||
entity.setCustomName(lived.name);
|
||||
entity.setCustomNameVisible(lived.visible);
|
||||
private void restoreLiving(LivingEntity entity) {
|
||||
entity.setCanPickupItems(this.lived.loot);
|
||||
if (this.lived.name != null) {
|
||||
entity.setCustomName(this.lived.name);
|
||||
entity.setCustomNameVisible(this.lived.visible);
|
||||
}
|
||||
if ((lived.potions != null) && (!lived.potions.isEmpty())) {
|
||||
entity.addPotionEffects(lived.potions);
|
||||
if ((this.lived.potions != null) && !this.lived.potions.isEmpty()) {
|
||||
entity.addPotionEffects(this.lived.potions);
|
||||
}
|
||||
entity.setRemainingAir(lived.air);
|
||||
entity.setRemoveWhenFarAway(lived.persistent);
|
||||
if (lived.equipped) {
|
||||
final EntityEquipment equipment = entity.getEquipment();
|
||||
equipment.setItemInHand(lived.hands);
|
||||
equipment.setHelmet(lived.helmet);
|
||||
equipment.setChestplate(lived.chestplate);
|
||||
equipment.setLeggings(lived.leggings);
|
||||
equipment.setBoots(lived.boots);
|
||||
entity.setRemainingAir(this.lived.air);
|
||||
entity.setRemoveWhenFarAway(this.lived.persistent);
|
||||
if (this.lived.equipped) {
|
||||
EntityEquipment equipment = entity.getEquipment();
|
||||
equipment.setItemInHand(this.lived.hands);
|
||||
equipment.setHelmet(this.lived.helmet);
|
||||
equipment.setChestplate(this.lived.chestplate);
|
||||
equipment.setLeggings(this.lived.leggings);
|
||||
equipment.setBoots(this.lived.boots);
|
||||
}
|
||||
if (lived.leashed) {
|
||||
if (this.lived.leashed) {
|
||||
// TODO leashes
|
||||
// World world = entity.getWorld();
|
||||
// Entity leash = world.spawnEntity(new Location(world, Math.floor(x) + lived.leash_x, Math.floor(y) + lived.leash_y, Math
|
||||
@ -339,11 +340,11 @@ public class EntityWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreInventory(final InventoryHolder entity) {
|
||||
entity.getInventory().setContents(inventory);
|
||||
private void restoreInventory(InventoryHolder entity) {
|
||||
entity.getInventory().setContents(this.inventory);
|
||||
}
|
||||
|
||||
public void storeLiving(final LivingEntity lived) {
|
||||
public void storeLiving(LivingEntity lived) {
|
||||
this.lived = new LivingEntityStats();
|
||||
this.lived.potions = lived.getActivePotionEffects();
|
||||
this.lived.loot = lived.getCanPickupItems();
|
||||
@ -354,12 +355,12 @@ public class EntityWrapper {
|
||||
this.lived.persistent = lived.getRemoveWhenFarAway();
|
||||
this.lived.leashed = lived.isLeashed();
|
||||
if (this.lived.leashed) {
|
||||
final Location loc = lived.getLeashHolder().getLocation();
|
||||
this.lived.leash_x = (short) (x - loc.getBlockX());
|
||||
this.lived.leash_y = (short) (y - loc.getBlockY());
|
||||
this.lived.leash_z = (short) (z - loc.getBlockZ());
|
||||
Location loc = lived.getLeashHolder().getLocation();
|
||||
this.lived.leash_x = (short) (this.x - loc.getBlockX());
|
||||
this.lived.leash_y = (short) (this.y - loc.getBlockY());
|
||||
this.lived.leash_z = (short) (this.z - loc.getBlockZ());
|
||||
}
|
||||
final EntityEquipment equipment = lived.getEquipment();
|
||||
EntityEquipment equipment = lived.getEquipment();
|
||||
this.lived.equipped = equipment != null;
|
||||
if (this.lived.equipped) {
|
||||
this.lived.hands = equipment.getItemInHand().clone();
|
||||
@ -370,50 +371,50 @@ public class EntityWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreTameable(final Tameable entity) {
|
||||
if (tamed.tamed) {
|
||||
if (tamed.owner != null) {
|
||||
private void restoreTameable(Tameable entity) {
|
||||
if (this.tamed.tamed) {
|
||||
if (this.tamed.owner != null) {
|
||||
entity.setTamed(true);
|
||||
entity.setOwner(tamed.owner);
|
||||
entity.setOwner(this.tamed.owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreAgeable(final Ageable entity) {
|
||||
if (!aged.adult) {
|
||||
private void restoreAgeable(Ageable entity) {
|
||||
if (!this.aged.adult) {
|
||||
entity.setBaby();
|
||||
}
|
||||
entity.setAgeLock(aged.locked);
|
||||
if (aged.age > 0) {
|
||||
entity.setAge(aged.age);
|
||||
entity.setAgeLock(this.aged.locked);
|
||||
if (this.aged.age > 0) {
|
||||
entity.setAge(this.aged.age);
|
||||
}
|
||||
}
|
||||
|
||||
public void storeAgeable(final Ageable aged) {
|
||||
public void storeAgeable(Ageable aged) {
|
||||
this.aged = new AgeableStats();
|
||||
this.aged.age = aged.getAge();
|
||||
this.aged.locked = aged.getAgeLock();
|
||||
this.aged.adult = aged.isAdult();
|
||||
}
|
||||
|
||||
public void storeTameable(final Tameable tamed) {
|
||||
public void storeTameable(Tameable tamed) {
|
||||
this.tamed = new TameableStats();
|
||||
this.tamed.owner = tamed.getOwner();
|
||||
this.tamed.tamed = tamed.isTamed();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Entity spawn(final World world, final int x_offset, final int z_offset) {
|
||||
final Location loc = new Location(world, x + x_offset, y, z + z_offset);
|
||||
loc.setYaw(yaw);
|
||||
loc.setPitch(pitch);
|
||||
if (type.isSpawnable()) {
|
||||
public Entity spawn(World world, int x_offset, int z_offset) {
|
||||
Location loc = new Location(world, this.x + x_offset, this.y, this.z + z_offset);
|
||||
loc.setYaw(this.yaw);
|
||||
loc.setPitch(this.pitch);
|
||||
if (this.type.isSpawnable()) {
|
||||
return null;
|
||||
}
|
||||
Entity entity;
|
||||
switch (type) {
|
||||
switch (this.type) {
|
||||
case DROPPED_ITEM: {
|
||||
return world.dropItem(loc, stack);
|
||||
return world.dropItem(loc, this.stack);
|
||||
}
|
||||
case PLAYER:
|
||||
case LEASH_HITCH: {
|
||||
@ -428,28 +429,29 @@ public class EntityWrapper {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
entity = world.spawnEntity(loc, type);
|
||||
entity = world.spawnEntity(loc, this.type);
|
||||
break;
|
||||
}
|
||||
if (depth == 0) {
|
||||
if (this.depth == 0) {
|
||||
return entity;
|
||||
}
|
||||
if (base.passenger != null) {
|
||||
if (this.base.passenger != null) {
|
||||
try {
|
||||
entity.setPassenger(base.passenger.spawn(world, x_offset, z_offset));
|
||||
} catch (final Exception e) {}
|
||||
entity.setPassenger(this.base.passenger.spawn(world, x_offset, z_offset));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
if (base.fall != 0) {
|
||||
entity.setFallDistance(base.fall);
|
||||
if (this.base.fall != 0) {
|
||||
entity.setFallDistance(this.base.fall);
|
||||
}
|
||||
if (base.fire != 0) {
|
||||
entity.setFireTicks(base.fire);
|
||||
if (this.base.fire != 0) {
|
||||
entity.setFireTicks(this.base.fire);
|
||||
}
|
||||
if (base.age != 0) {
|
||||
entity.setTicksLived(base.age);
|
||||
if (this.base.age != 0) {
|
||||
entity.setTicksLived(this.base.age);
|
||||
}
|
||||
entity.setVelocity(new Vector(base.v_x, base.v_y, base.v_z));
|
||||
if (depth == 1) {
|
||||
entity.setVelocity(new Vector(this.base.v_x, this.base.v_y, this.base.v_z));
|
||||
if (this.depth == 1) {
|
||||
return entity;
|
||||
}
|
||||
switch (entity.getType()) {
|
||||
@ -491,15 +493,15 @@ public class EntityWrapper {
|
||||
}
|
||||
// MISC //
|
||||
case ITEM_FRAME: {
|
||||
final ItemFrame itemframe = (ItemFrame) entity;
|
||||
itemframe.setRotation(Rotation.values()[dataByte]);
|
||||
itemframe.setItem(stack);
|
||||
ItemFrame itemframe = (ItemFrame) entity;
|
||||
itemframe.setRotation(Rotation.values()[this.dataByte]);
|
||||
itemframe.setItem(this.stack);
|
||||
return entity;
|
||||
}
|
||||
case PAINTING: {
|
||||
final Painting painting = (Painting) entity;
|
||||
painting.setFacingDirection(BlockFace.values()[dataByte], true);
|
||||
painting.setArt(Art.getByName(dataString), true);
|
||||
Painting painting = (Painting) entity;
|
||||
painting.setFacingDirection(BlockFace.values()[this.dataByte], true);
|
||||
painting.setArt(Art.getByName(this.dataString), true);
|
||||
return entity;
|
||||
}
|
||||
// END MISC //
|
||||
@ -513,7 +515,7 @@ public class EntityWrapper {
|
||||
// START AGEABLE //
|
||||
// START TAMEABLE //
|
||||
case HORSE: {
|
||||
final Horse horse = (Horse) entity;
|
||||
Horse horse = (Horse) entity;
|
||||
horse.setJumpStrength(this.horse.jump);
|
||||
horse.setCarryingChest(this.horse.chest);
|
||||
horse.setVariant(Variant.values()[this.horse.variant]);
|
||||
@ -535,12 +537,12 @@ public class EntityWrapper {
|
||||
}
|
||||
// END AGEABLE //
|
||||
case SHEEP: {
|
||||
final Sheep sheep = (Sheep) entity;
|
||||
if (dataByte == 1) {
|
||||
Sheep sheep = (Sheep) entity;
|
||||
if (this.dataByte == 1) {
|
||||
sheep.setSheared(true);
|
||||
}
|
||||
if (dataByte2 != 0) {
|
||||
sheep.setColor(DyeColor.getByDyeData(dataByte2));
|
||||
if (this.dataByte2 != 0) {
|
||||
sheep.setColor(DyeColor.getByDyeData(this.dataByte2));
|
||||
}
|
||||
restoreAgeable((Ageable) entity);
|
||||
restoreLiving((LivingEntity) entity);
|
||||
@ -557,67 +559,67 @@ public class EntityWrapper {
|
||||
}
|
||||
// END AGEABLE //
|
||||
case RABBIT: { // NEW
|
||||
if (dataByte != 0) {
|
||||
((Rabbit) entity).setRabbitType(Type.values()[dataByte]);
|
||||
if (this.dataByte != 0) {
|
||||
((Rabbit) entity).setRabbitType(Type.values()[this.dataByte]);
|
||||
}
|
||||
restoreAgeable((Ageable) entity);
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
}
|
||||
case GUARDIAN: { // NEW
|
||||
if (dataByte != 0) {
|
||||
if (this.dataByte != 0) {
|
||||
((Guardian) entity).setElder(true);
|
||||
}
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
}
|
||||
case SKELETON: { // NEW
|
||||
if (dataByte != 0) {
|
||||
((Skeleton) entity).setSkeletonType(SkeletonType.values()[dataByte]);
|
||||
if (this.dataByte != 0) {
|
||||
((Skeleton) entity).setSkeletonType(SkeletonType.values()[this.dataByte]);
|
||||
}
|
||||
storeLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
}
|
||||
case ARMOR_STAND: { // NEW
|
||||
// CHECK positions
|
||||
final ArmorStand stand = (ArmorStand) entity;
|
||||
if (inventory[0] != null) {
|
||||
stand.setItemInHand(inventory[0]);
|
||||
ArmorStand stand = (ArmorStand) entity;
|
||||
if (this.inventory[0] != null) {
|
||||
stand.setItemInHand(this.inventory[0]);
|
||||
}
|
||||
if (inventory[1] != null) {
|
||||
stand.setHelmet(inventory[1]);
|
||||
if (this.inventory[1] != null) {
|
||||
stand.setHelmet(this.inventory[1]);
|
||||
}
|
||||
if (inventory[2] != null) {
|
||||
stand.setChestplate(inventory[2]);
|
||||
if (this.inventory[2] != null) {
|
||||
stand.setChestplate(this.inventory[2]);
|
||||
}
|
||||
if (inventory[3] != null) {
|
||||
stand.setLeggings(inventory[3]);
|
||||
if (this.inventory[3] != null) {
|
||||
stand.setLeggings(this.inventory[3]);
|
||||
}
|
||||
if (inventory[4] != null) {
|
||||
stand.setBoots(inventory[4]);
|
||||
if (this.inventory[4] != null) {
|
||||
stand.setBoots(this.inventory[4]);
|
||||
}
|
||||
if ((this.stand.head[0] != 0) || (this.stand.head[1] != 0) || (this.stand.head[2] != 0)) {
|
||||
final EulerAngle pose = new EulerAngle(this.stand.head[0], this.stand.head[1], this.stand.head[2]);
|
||||
EulerAngle pose = new EulerAngle(this.stand.head[0], this.stand.head[1], this.stand.head[2]);
|
||||
stand.setHeadPose(pose);
|
||||
}
|
||||
if ((this.stand.body[0] != 0) || (this.stand.body[1] != 0) || (this.stand.body[2] != 0)) {
|
||||
final EulerAngle pose = new EulerAngle(this.stand.body[0], this.stand.body[1], this.stand.body[2]);
|
||||
EulerAngle pose = new EulerAngle(this.stand.body[0], this.stand.body[1], this.stand.body[2]);
|
||||
stand.setBodyPose(pose);
|
||||
}
|
||||
if ((this.stand.leftLeg[0] != 0) || (this.stand.leftLeg[1] != 0) || (this.stand.leftLeg[2] != 0)) {
|
||||
final EulerAngle pose = new EulerAngle(this.stand.leftLeg[0], this.stand.leftLeg[1], this.stand.leftLeg[2]);
|
||||
EulerAngle pose = new EulerAngle(this.stand.leftLeg[0], this.stand.leftLeg[1], this.stand.leftLeg[2]);
|
||||
stand.setLeftLegPose(pose);
|
||||
}
|
||||
if ((this.stand.rightLeg[0] != 0) || (this.stand.rightLeg[1] != 0) || (this.stand.rightLeg[2] != 0)) {
|
||||
final EulerAngle pose = new EulerAngle(this.stand.rightLeg[0], this.stand.rightLeg[1], this.stand.rightLeg[2]);
|
||||
EulerAngle pose = new EulerAngle(this.stand.rightLeg[0], this.stand.rightLeg[1], this.stand.rightLeg[2]);
|
||||
stand.setRightLegPose(pose);
|
||||
}
|
||||
if ((this.stand.leftArm[0] != 0) || (this.stand.leftArm[1] != 0) || (this.stand.leftArm[2] != 0)) {
|
||||
final EulerAngle pose = new EulerAngle(this.stand.leftArm[0], this.stand.leftArm[1], this.stand.leftArm[2]);
|
||||
EulerAngle pose = new EulerAngle(this.stand.leftArm[0], this.stand.leftArm[1], this.stand.leftArm[2]);
|
||||
stand.setLeftArmPose(pose);
|
||||
}
|
||||
if ((this.stand.rightArm[0] != 0) || (this.stand.rightArm[1] != 0) || (this.stand.rightArm[2] != 0)) {
|
||||
final EulerAngle pose = new EulerAngle(this.stand.rightArm[0], this.stand.rightArm[1], this.stand.rightArm[2]);
|
||||
EulerAngle pose = new EulerAngle(this.stand.rightArm[0], this.stand.rightArm[1], this.stand.rightArm[2]);
|
||||
stand.setRightArmPose(pose);
|
||||
}
|
||||
if (this.stand.invisible) {
|
||||
@ -663,8 +665,8 @@ public class EntityWrapper {
|
||||
// END LIVING //
|
||||
}
|
||||
}
|
||||
|
||||
private byte getOrdinal(final Object[] list, final Object value) {
|
||||
|
||||
private byte getOrdinal(Object[] list, Object value) {
|
||||
for (byte i = 0; i < list.length; i++) {
|
||||
if (list[i].equals(value)) {
|
||||
return i;
|
||||
|
Reference in New Issue
Block a user